Browse Source

Merge branch '20201014_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20201014_xt_api_new_branch

csx 4 years ago
parent
commit
c5a2671960

+ 2 - 2
controllers/dialysis_record_api_controller.go View File

228
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
228
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
229
 		return
229
 		return
230
 	}
230
 	}
231
-	//dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
232
-	dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolutionOne(adminInfo.CurrentOrgId, schedual.ModeId)
231
+	dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
232
+	//dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolutionOne(adminInfo.CurrentOrgId, schedual.ModeId)
233
 
233
 
234
 	if getDialysisSolutionErr != nil {
234
 	if getDialysisSolutionErr != nil {
235
 		this.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
235
 		this.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)

+ 28 - 12
controllers/his_api_controller.go View File

917
 
917
 
918
 	blood_fat := c.GetString("blood_fat")
918
 	blood_fat := c.GetString("blood_fat")
919
 	bloodfatfloat, _ := strconv.ParseFloat(blood_fat, 64)
919
 	bloodfatfloat, _ := strconv.ParseFloat(blood_fat, 64)
920
-	//fmt.Println("33333333", bloodfatfloat)
920
+
921
 	blood_sugar := c.GetString("blood_sugar")
921
 	blood_sugar := c.GetString("blood_sugar")
922
 	bloodsugarfloat, _ := strconv.ParseFloat(blood_sugar, 64)
922
 	bloodsugarfloat, _ := strconv.ParseFloat(blood_sugar, 64)
923
 	fmt.Println(bloodsugarfloat)
923
 	fmt.Println(bloodsugarfloat)
927
 	dbpfloat, _ := strconv.ParseFloat(dbp, 64)
927
 	dbpfloat, _ := strconv.ParseFloat(dbp, 64)
928
 	delivery_way, _ := c.GetInt64("delivery_way")
928
 	delivery_way, _ := c.GetInt64("delivery_way")
929
 	diagnostic := c.GetString("diagnostic")
929
 	diagnostic := c.GetString("diagnostic")
930
-	fmt.Println("diagnostic", diagnostic)
930
+
931
 	family_history := c.GetString("family_history")
931
 	family_history := c.GetString("family_history")
932
-	fmt.Println(family_history)
932
+
933
 	height := c.GetString("height")
933
 	height := c.GetString("height")
934
 	history_of_present_illness := c.GetString("history_of_present_illness")
934
 	history_of_present_illness := c.GetString("history_of_present_illness")
935
 	is_infect, _ := c.GetInt64("is_infect")
935
 	is_infect, _ := c.GetInt64("is_infect")
957
 	doctor_advice := c.GetString("doctor_advice")
957
 	doctor_advice := c.GetString("doctor_advice")
958
 	remark := c.GetString("remark")
958
 	remark := c.GetString("remark")
959
 	breathingfloat, _ := strconv.ParseFloat(breathing, 64)
959
 	breathingfloat, _ := strconv.ParseFloat(breathing, 64)
960
-	//fmt.Println("breathingfloat", breathingfloat)
960
+
961
 	sick, _ := c.GetInt64("sick")
961
 	sick, _ := c.GetInt64("sick")
962
 	diagnose, _ := c.GetInt64("diagnose")
962
 	diagnose, _ := c.GetInt64("diagnose")
963
+	id, _ := c.GetInt64("id")
964
+
963
 	timeLayout := "2006-01-02"
965
 	timeLayout := "2006-01-02"
964
 	loc, _ := time.LoadLocation("Local")
966
 	loc, _ := time.LoadLocation("Local")
965
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
967
 	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
968
+	allergic_history := c.GetString("allergic_history")
966
 	if err != nil {
969
 	if err != nil {
967
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
970
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
968
 		return
971
 		return
1008
 		Remark:                  remark,
1011
 		Remark:                  remark,
1009
 		Sick:                    sick,
1012
 		Sick:                    sick,
1010
 		Diagnose:                diagnose,
1013
 		Diagnose:                diagnose,
1014
+		AllergicHistory:         allergic_history,
1011
 	}
1015
 	}
1012
-
1013
-	err = service.SaveHisPatientCaseHistory(&caseHistory)
1014
-	if err != nil {
1015
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1016
+	//查询该患者是否有病历
1017
+	_, errcodes := service.GetHisPatientCaseHistoryById(id)
1018
+	if errcodes == gorm.ErrRecordNotFound {
1019
+		err = service.SaveHisPatientCaseHistory(&caseHistory)
1020
+		if err != nil {
1021
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1022
+			return
1023
+		}
1024
+		c.ServeSuccessJSON(map[string]interface{}{
1025
+			"caseHistory": caseHistory,
1026
+		})
1016
 		return
1027
 		return
1028
+	} else if errcodes == nil {
1029
+		err := service.UpdatePatientCaseHistory(id, &caseHistory)
1030
+		if err != nil {
1031
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1032
+			return
1033
+		}
1034
+		c.ServeSuccessJSON(map[string]interface{}{
1035
+			"caseHistory": caseHistory,
1036
+		})
1017
 	}
1037
 	}
1018
-	c.ServeSuccessJSON(map[string]interface{}{
1019
-		"caseHistory": caseHistory,
1020
-	})
1021
-	return
1022
 
1038
 
1023
 	//查询该患者是否有病历
1039
 	//查询该患者是否有病历
1024
 	//_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)
1040
 	//_, errcode := service.GetHisPatientCaseHistoryById(his_patient_id)

+ 1 - 1
controllers/mobile_api_controllers/check_weight_api_controller.go View File

335
 
335
 
336
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
336
 	template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
337
 
337
 
338
-	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 {
338
+	if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 {
339
 		dewater_amount = dewater_amount * 1000
339
 		dewater_amount = dewater_amount * 1000
340
 	}
340
 	}
341
 
341
 

+ 36 - 10
controllers/mobile_api_controllers/dialysis_api_controller.go View File

1158
 		PreImpulse:                 pre_impulse,
1158
 		PreImpulse:                 pre_impulse,
1159
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
1159
 		AnticoagulantStopTimeHour:  anticoagulant_stop_time_hour,
1160
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
1160
 		AnticoagulantStopTimeMin:   anticoagulant_stop_time_min,
1161
-		Blood:                    blood,
1162
-		DialysisDialyszers:       dialysis_dialyszers,
1163
-		DialysisIrrigation:       dialysis_irrigation,
1164
-		AntioxidantCommodityName: antioxidant_commodity_name,
1165
-		DisplaceSpeed:            displace_speed,
1161
+		Blood:                      blood,
1162
+		DialysisDialyszers:         dialysis_dialyszers,
1163
+		DialysisIrrigation:         dialysis_irrigation,
1164
+		AntioxidantCommodityName:   antioxidant_commodity_name,
1165
+		DisplaceSpeed:              displace_speed,
1166
 	}
1166
 	}
1167
 
1167
 
1168
 	//查询最近透析准备表里是否存在 透析器 灌流器
1168
 	//查询最近透析准备表里是否存在 透析器 灌流器
2039
 		ALiquid:                   a_liquid,
2039
 		ALiquid:                   a_liquid,
2040
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
2040
 		AnticoagulantStopTimeMin:  anticoagulant_stop_time_min,
2041
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
2041
 		AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
2042
-		Blood:                    blood,
2043
-		DialysisDialyszers:       dialysis_dialyszers,
2044
-		DialysisIrrigation:       dialysis_irrigation,
2045
-		AntioxidantCommodityName: antioxidant_commodity_name,
2046
-		DisplaceSpeed:            displace_speed,
2042
+		Blood:                     blood,
2043
+		DialysisDialyszers:        dialysis_dialyszers,
2044
+		DialysisIrrigation:        dialysis_irrigation,
2045
+		AntioxidantCommodityName:  antioxidant_commodity_name,
2046
+		DisplaceSpeed:             displace_speed,
2047
 	}
2047
 	}
2048
 
2048
 
2049
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
2049
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
4692
 	})
4692
 	})
4693
 	return
4693
 	return
4694
 }
4694
 }
4695
+
4696
+func (c *DialysisAPIController) UpdateAutoReduceDetail() {
4697
+
4698
+	good_id, _ := c.GetInt64("good_id")
4699
+	count, _ := c.GetInt64("count")
4700
+	record_time, _ := c.GetInt64("record_time")
4701
+	patient_id, _ := c.GetInt64("patient_id")
4702
+	detail, _ := service.UpdateAutoReduceDetail(good_id, count, record_time, patient_id)
4703
+	c.ServeSuccessJSON(map[string]interface{}{
4704
+		"detail": detail,
4705
+	})
4706
+	return
4707
+}
4708
+
4709
+func (c *DialysisAPIController) DeleteAutoReduceDetail() {
4710
+
4711
+	good_id, _ := c.GetInt64("good_id")
4712
+	record_time, _ := c.GetInt64("record_time")
4713
+	patient_id, _ := c.GetInt64("patient_id")
4714
+	err := service.DeleteAutoReduceDetail(good_id, record_time, patient_id)
4715
+	fmt.Print("err", err)
4716
+	c.ServeSuccessJSON(map[string]interface{}{
4717
+		"msg": "批量删除成功",
4718
+	})
4719
+	return
4720
+}

+ 5 - 1
controllers/mobile_api_controllers/mobile_api_router_register.go View File

144
 	//获取单个患者1年的透析日期
144
 	//获取单个患者1年的透析日期
145
 	beego.Router("/m/api/getPatientDialysisRecord", &DialysisAPIController{}, "Get:GetPatientDialysisRecordList")
145
 	beego.Router("/m/api/getPatientDialysisRecord", &DialysisAPIController{}, "Get:GetPatientDialysisRecordList")
146
 	//批量删除医嘱
146
 	//批量删除医嘱
147
-	//beego.Router("/m/api/batchDeleteAdvice", &DialysisAPIController{}, "Get:BathDeleteAdviceList:")
147
+	beego.Router("/m/api/batchdeleteadvice", &DialysisAPIController{}, "Get:BathDeleteAdviceList")
148
+	//加减耗材数量
149
+	beego.Router("/m/api/updateautoreducedetail", &DialysisAPIController{}, "Get:UpdateAutoReduceDetail")
150
+	//删除数据
151
+	beego.Router("/m/api/deleteautoreducedetail", &DialysisAPIController{}, "Get:DeleteAutoReduceDetail")
148
 }
152
 }

+ 1 - 1
controllers/mobile_api_controllers/patient_api_controller.go View File

1545
 	if evaluation.DryWeight > 0 {
1545
 	if evaluation.DryWeight > 0 {
1546
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
1546
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
1547
 
1547
 
1548
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 {
1548
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 {
1549
 			dewater_amount = dewater_amount * 1000
1549
 			dewater_amount = dewater_amount * 1000
1550
 
1550
 
1551
 		}
1551
 		}

+ 29 - 28
controllers/role_controller.go View File

982
 			if total <= 0 {
982
 			if total <= 0 {
983
 				//新增用户
983
 				//新增用户
984
 				app_role := &models.App_Role{
984
 				app_role := &models.App_Role{
985
-					AdminUserId:    adminUser.Id,
986
-					OrgId:          adminUserInfo.CurrentOrgId,
987
-					AppId:          adminUserInfo.CurrentAppId,
988
-					Avatar:         "",
989
-					UserName:       name,
990
-					UserTitleName:  user_title_name,
991
-					Status:         1,
992
-					UserType:       int8(userType),
993
-					UserTitle:      int8(userTitle),
994
-					CreateTime:     time.Now().Unix(),
995
-					ModifyTime:     time.Now().Unix(),
996
-					RoleIds:        roleIds,
997
-					Department:     department,
998
-					DepartmentId:   department_id,
999
-					Sex:            sex,
1000
-					Age:            age,
1001
-					Nation:         nation,
1002
-					CardType:       card_type,
1003
-					IdCard:         id_card,
1004
-					Education:      education,
1005
-					StudyMajorName: study_major_name,
1006
-					WorkMajorName:  work_major_name,
1007
-					RoleType:       role_type,
1008
-					MedicalCode:    medical_code,
1009
-					DoctorCode:     doctor_code,
1010
-					Licensing:      licensing,
1011
-					JobNumber:      job_number,
985
+					AdminUserId:                             adminUser.Id,
986
+					OrgId:                                   adminUserInfo.CurrentOrgId,
987
+					AppId:                                   adminUserInfo.CurrentAppId,
988
+					Avatar:                                  "",
989
+					UserName:                                name,
990
+					UserTitleName:                           user_title_name,
991
+					Status:                                  1,
992
+					UserType:                                int8(userType),
993
+					UserTitle:                               int8(userTitle),
994
+					CreateTime:                              time.Now().Unix(),
995
+					ModifyTime:                              time.Now().Unix(),
996
+					RoleIds:                                 roleIds,
997
+					Department:                              department,
998
+					DepartmentId:                            department_id,
999
+					Sex:                                     sex,
1000
+					Age:                                     age,
1001
+					Nation:                                  nation,
1002
+					CardType:                                card_type,
1003
+					IdCard:                                  id_card,
1004
+					Education:                               education,
1005
+					StudyMajorName:                          study_major_name,
1006
+					WorkMajorName:                           work_major_name,
1007
+					RoleType:                                role_type,
1008
+					MedicalCode:                             medical_code,
1009
+					DoctorCode:                              doctor_code,
1010
+					Licensing:                               licensing,
1011
+					JobNumber:                               job_number,
1012
 					PrescriptionQualificationIdentification: prescription_qualification_identification,
1012
 					PrescriptionQualificationIdentification: prescription_qualification_identification,
1013
 					IdentificationOutpatients:               identification_outpatients,
1013
 					IdentificationOutpatients:               identification_outpatients,
1014
 					StartTime:                               theStartTime.Unix(),
1014
 					StartTime:                               theStartTime.Unix(),
1126
 	department := this.GetString("department")
1126
 	department := this.GetString("department")
1127
 	department_id, _ := this.GetInt64("department_id")
1127
 	department_id, _ := this.GetInt64("department_id")
1128
 	sort, _ := this.GetInt64("sort")
1128
 	sort, _ := this.GetInt64("sort")
1129
-
1129
+	sex, _ := this.GetInt64("sex")
1130
 	age, _ := this.GetInt64("age")
1130
 	age, _ := this.GetInt64("age")
1131
 	nation := this.GetString("nation")
1131
 	nation := this.GetString("nation")
1132
 	card_type, _ := this.GetInt64("card_type")
1132
 	card_type, _ := this.GetInt64("card_type")
1215
 	appRole.OutpatientIllnesscategory = outpatient_illnessCategory
1215
 	appRole.OutpatientIllnesscategory = outpatient_illnessCategory
1216
 	appRole.IsActive = is_active
1216
 	appRole.IsActive = is_active
1217
 	appRole.ActiveStatus = active_status
1217
 	appRole.ActiveStatus = active_status
1218
+	appRole.Sex = sex
1218
 	saveErr := service.SaveAppRole(appRole)
1219
 	saveErr := service.SaveAppRole(appRole)
1219
 	if saveErr != nil {
1220
 	if saveErr != nil {
1220
 		//beego.Error("修改App_Role失败:", saveErr)
1221
 		//beego.Error("修改App_Role失败:", saveErr)

+ 1 - 0
models/his_models.go View File

297
 	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
297
 	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
298
 	Sick                    int64   `gorm:"column:sick" json:"sick" form:"sick"`
298
 	Sick                    int64   `gorm:"column:sick" json:"sick" form:"sick"`
299
 	Diagnose                int64   `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
299
 	Diagnose                int64   `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
300
+	AllergicHistory         string  `gorm:"column:allergic_history" json:"allergic_history" form:"allergic_history"`
300
 }
301
 }
301
 
302
 
302
 func (HisPatientCaseHistory) TableName() string {
303
 func (HisPatientCaseHistory) TableName() string {

+ 8 - 2
service/his_service.go View File

243
 	return
243
 	return
244
 }
244
 }
245
 
245
 
246
-func GetHisPatientCaseHistoryById(hispatientid int64) (*models.HisPatientCaseHistory, error) {
246
+func GetHisPatientCaseHistoryById(id int64) (*models.HisPatientCaseHistory, error) {
247
 	history := models.HisPatientCaseHistory{}
247
 	history := models.HisPatientCaseHistory{}
248
-	err := XTReadDB().Model(&history).Where("his_patient_id = ? and status = 1", hispatientid).Find(&history).Error
248
+	err := XTReadDB().Model(&history).Where("id = ? and status = 1", id).Find(&history).Error
249
 	if err != nil {
249
 	if err != nil {
250
 		if err == gorm.ErrRecordNotFound {
250
 		if err == gorm.ErrRecordNotFound {
251
 			return nil, err
251
 			return nil, err
261
 	return err
261
 	return err
262
 }
262
 }
263
 
263
 
264
+func UpdatePatientCaseHistory(id int64, his *models.HisPatientCaseHistory) error {
265
+
266
+	err := XTWriteDB().Model(&his).Where("id = ? and status  =1", id).Updates(map[string]interface{}{"temperature": his.Temperature, "blood_sugar": his.BloodSugar, "pulse": his.BloodSugar, "allergic_history": his.AllergicHistory, "diagnose": his.AllergicHistory, "sick": his.Sick, "remark": his.Remark, "doctor_advice": his.DoctorAdvice, "breathing": his.Breathing, "delivery_way": his.DeliveryWay, "diagnostic": his.Diagnostic, "family_history": his.FamilyHistory, "personal_history": his.PersonalHistory, "chief_conplaint": his.ChiefConplaint, "doctor": his.Doctor, "past_history": his.PastHistory, "history_of_present_illness": his.HistoryOfPresentIllness, "is_infect": his.IsInfect, "sick_date": his.SickDate, "symptom": his.Symptom, "sick_type": his.SickType, "blood_fat": his.BloodFat}).Error
267
+	return err
268
+}
269
+
264
 func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
270
 func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
265
 	err = writeDb.Save(&prescription).Error
271
 	err = writeDb.Save(&prescription).Error
266
 	return
272
 	return

+ 12 - 3
service/mobile_dialysis_service.go View File

1965
 
1965
 
1966
 func GetPatientDialysisRecordList(patientid int64, startime int64, endtime int64) (order []*models.XtDialysisOrders, err error) {
1966
 func GetPatientDialysisRecordList(patientid int64, startime int64, endtime int64) (order []*models.XtDialysisOrders, err error) {
1967
 
1967
 
1968
-	//err = XTReadDB().Where("patient_id = ? and dialysis_date>=? and dialysis_date<=?  and status = 1", patientid, startime, endtime).Find(&order).Error
1969
-	//return order, err
1970
-
1971
 	db := XTReadDB().Table("xt_dialysis_order as x").Where("x.status = 1")
1968
 	db := XTReadDB().Table("xt_dialysis_order as x").Where("x.status = 1")
1972
 	table := XTReadDB().Table("xt_schedule as s")
1969
 	table := XTReadDB().Table("xt_schedule as s")
1973
 	fmt.Println(table)
1970
 	fmt.Println(table)
1996
 	return
1993
 	return
1997
 
1994
 
1998
 }
1995
 }
1996
+
1997
+func UpdateAutoReduceDetail(good_id int64, count int64, record_time int64, patient_id int64) (models.AutomaticReduceDetail, error) {
1998
+	detail := models.AutomaticReduceDetail{}
1999
+	err := XTWriteDB().Model(&detail).Where("good_id = ? and status = 1 and record_time = ? and patient_id = ?", good_id, record_time, patient_id).Updates(map[string]interface{}{"count": count}).Error
2000
+	return detail, err
2001
+}
2002
+
2003
+func DeleteAutoReduceDetail(good_id int64, record_time int64, patient_id int64) error {
2004
+	detail := models.AutomaticReduceDetail{}
2005
+	err := XTWriteDB().Model(&detail).Where("good_id = ? and status = 1 and record_time = ? and patient_id = ?", good_id, record_time, patient_id).Updates(map[string]interface{}{"status": 0}).Error
2006
+	return err
2007
+}