Browse Source

医保对接

csx 3 years ago
parent
commit
9672343ffa
50 changed files with 3461 additions and 1097 deletions
  1. 5 12
      controllers/data_api_controller.go
  2. 66 1
      controllers/dialysis_api_controller.go
  3. 84 69
      controllers/dialysis_record_api_controller.go
  4. 79 43
      controllers/doctors_api_controller.go
  5. 80 44
      controllers/drug_stock_api_contorller.go
  6. 11 0
      controllers/gobal_config_api_controller.go
  7. 76 5
      controllers/his_api_controller.go
  8. 4 5
      controllers/his_project_api_controller.go
  9. 93 92
      controllers/manage_api_controller.go
  10. 55 2
      controllers/manager_center_api_controller.go
  11. 71 7
      controllers/mobile_api_controllers/dialysis_api_controller.go
  12. 47 39
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  13. 1 1
      controllers/mobile_api_controllers/doctor_advice_api_controller.go
  14. 21 0
      controllers/mobile_api_controllers/patient_api_controller.go
  15. 45 24
      controllers/new_mobile_api_controllers/common_api_controller.go
  16. 4 2
      controllers/new_mobile_api_controllers/good_types.json
  17. 72 4
      controllers/new_mobile_api_controllers/mobile_his_api_controller.go
  18. 40 17
      controllers/new_mobile_api_controllers/new_common_api_controller.go
  19. 10 0
      controllers/new_mobile_api_controllers/new_dialysis_api_controller.go
  20. 290 277
      controllers/patient_api_controller.go
  21. 486 7
      controllers/schedule_api_controller.go
  22. 282 164
      controllers/stock_in_api_controller.go
  23. 4 0
      enums/error_code.go
  24. 32 0
      models/device_models.go
  25. 145 121
      models/dialysis.go
  26. 1 0
      models/doctor_advice_models.go
  27. 29 26
      models/drug.go
  28. 7 0
      models/drug_stock.go
  29. 3 1
      models/his_models.go
  30. 1 0
      models/inspection_models.go
  31. 13 0
      models/patient_models.go
  32. 73 17
      models/schedule_models.go
  33. 3 0
      models/self_drug_models.go
  34. 21 15
      models/service/stock_service.go
  35. 5 0
      models/stock_models.go
  36. 1 0
      routers/router.go
  37. 197 34
      service/common_service.go
  38. 1 1
      service/dialysis_service.go
  39. 5 0
      service/doctor_advice_service.go
  40. 3 0
      service/drug_stock_service.go
  41. 6 0
      service/gobal_config_service.go
  42. 14 2
      service/his_service.go
  43. 11 0
      service/manage_center_service.go
  44. 78 31
      service/mobile_dialysis_service.go
  45. 6 1
      service/patient_service.go
  46. 37 3
      service/patientmanage_service.go
  47. 7 0
      service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go
  48. 186 11
      service/schedule_service.go
  49. 101 19
      service/stock_service.go
  50. 549 0
      service/warhouse_service.go

+ 5 - 12
controllers/data_api_controller.go View File

@@ -892,8 +892,7 @@ func (c *DataApiController) DeleteExecutionFrequency() {
892 892
 func (c *DataApiController) CreateAdviceTemplate() {
893 893
 	templateName := c.GetString("template_name")
894 894
 	advice_type, _ := c.GetInt64("advice_type")
895
-
896
-	fmt.Println(templateName)
895
+	sort, _ := c.GetInt64("sort")
897 896
 
898 897
 	if templateName == "" {
899 898
 		utils.ErrorLog("模版名称不能为空")
@@ -921,13 +920,6 @@ func (c *DataApiController) CreateAdviceTemplate() {
921 920
 		}
922 921
 	}
923 922
 
924
-	//total := service.FindTemplateRecordByName(adminUserInfo.CurrentOrgId, templateName);
925
-	//if total > 0 {
926
-	//	utils.ErrorLog("模版名称已经存在")
927
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNameWrong)
928
-	//	return
929
-	//}
930
-
931 923
 	template := &models.DoctorAdviceParentTemplate{
932 924
 		Name:        templateName,
933 925
 		OrgId:       adminUserInfo.CurrentOrgId,
@@ -935,6 +927,7 @@ func (c *DataApiController) CreateAdviceTemplate() {
935 927
 		CreatedTime: time.Now().Unix(),
936 928
 		UpdatedTime: time.Now().Unix(),
937 929
 		AdviceType:  advice_type,
930
+		Sort:        sort,
938 931
 	}
939 932
 
940 933
 	createErr := service.CreateTemplate(template)
@@ -1326,7 +1319,7 @@ func (c *DataApiController) CreateSubAdviceTemplate() {
1326 1319
 func (this *DataApiController) ModifyTemplateName() {
1327 1320
 	template_name := this.GetString("template_name")
1328 1321
 	template_id, _ := this.GetInt64("template_id", 0)
1329
-
1322
+	sort, _ := this.GetInt64("sort")
1330 1323
 	if len(template_name) <= 0 {
1331 1324
 		utils.ErrorLog("模版名字不能为空")
1332 1325
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamEmptyWrong)
@@ -1344,7 +1337,7 @@ func (this *DataApiController) ModifyTemplateName() {
1344 1337
 	template, _ := service.FindParentTemplateRecordById(adminUserInfo.CurrentOrgId, template_id)
1345 1338
 	var err error
1346 1339
 	if template.Name == template_name {
1347
-		err = service.ModifyTemplateName(template_id, template_name)
1340
+		err = service.ModifyTemplateNameOne(template_id, template_name, sort)
1348 1341
 		if err != nil {
1349 1342
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
1350 1343
 			return
@@ -1356,7 +1349,7 @@ func (this *DataApiController) ModifyTemplateName() {
1356 1349
 		//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNameWrong)
1357 1350
 		//	return
1358 1351
 		//}
1359
-		err = service.ModifyTemplateName(template_id, template_name)
1352
+		err = service.ModifyTemplateNameOne(template_id, template_name, sort)
1360 1353
 
1361 1354
 		if err != nil {
1362 1355
 			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)

+ 66 - 1
controllers/dialysis_api_controller.go View File

@@ -249,6 +249,14 @@ func (c *DialysisApiController) PostPrescription() {
249 249
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
250 250
 	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
251 251
 	displace_speed := c.GetString("displace_speed")
252
+	illness, _ := c.GetInt64("illness")
253
+	amylaceum := c.GetString("amylaceum")
254
+	single_time := c.GetString("single_time")
255
+	single_water := c.GetString("single_water")
256
+	replacement_flow := c.GetString("replacement_flow")
257
+	plasma_separator := c.GetString("plasma_separator")
258
+	bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
259
+
252 260
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
253 261
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
254 262
 
@@ -332,6 +340,13 @@ func (c *DialysisApiController) PostPrescription() {
332 340
 		DialysisIrrigation:         dialysis_irrigation,
333 341
 		AntioxidantCommodityName:   antioxidant_commodity_name,
334 342
 		DisplaceSpeed:              displace_speed,
343
+		Illness:                    illness,
344
+		Amylaceum:                  amylaceum,
345
+		SingleTime:                 single_time,
346
+		SingleWater:                single_water,
347
+		ReplacementFlow:            replacement_flow,
348
+		PlasmaSeparator:            plasma_separator,
349
+		BilirubinAdsorptionColumn:  bilirubin_adsorption_column,
335 350
 	}
336 351
 
337 352
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -567,6 +582,13 @@ func (c *DialysisApiController) PostSoulution() {
567 582
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
568 583
 	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
569 584
 	displace_speed := c.GetString("displace_speed")
585
+	illness, _ := c.GetInt64("illness")
586
+	amylaceum := c.GetString("amylaceum")
587
+	single_time := c.GetString("single_time")
588
+	single_water := c.GetString("single_water")
589
+	replacement_flow := c.GetString("replacement_flow")
590
+	plasma_separator := c.GetString("plasma_separator")
591
+	bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
570 592
 	var prescription_doctor int64
571 593
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
572 594
 
@@ -661,6 +683,13 @@ func (c *DialysisApiController) PostSoulution() {
661 683
 		DialysisDialyszers:        dialysis_dialyszers,
662 684
 		AntioxidantCommodityName:  antioxidant_commodity_name,
663 685
 		DisplaceSpeed:             displace_speed,
686
+		Illness:                   illness,
687
+		Amylaceum:                 amylaceum,
688
+		SingleTime:                single_time,
689
+		SingleWater:               single_water,
690
+		ReplacementFlow:           replacement_flow,
691
+		PlasmaSeparator:           plasma_separator,
692
+		BilirubinAdsorptionColumn: bilirubin_adsorption_column,
664 693
 	}
665 694
 
666 695
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -971,7 +1000,7 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
971 1000
 	precaution_other := c.GetString("precaution_other")
972 1001
 	psychological_other := c.GetString("psychological_other")
973 1002
 	admission_number := c.GetString("admission_number")
974
-
1003
+	tumble, _ := c.GetInt64("tumble")
975 1004
 	if id <= 0 {
976 1005
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
977 1006
 		return
@@ -1019,6 +1048,7 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
1019 1048
 		PrecautionOther:              precaution_other,
1020 1049
 		PsychologicalOther:           psychological_other,
1021 1050
 		AdmissionNumber:              admission_number,
1051
+		Tumble:                       tumble,
1022 1052
 	}
1023 1053
 
1024 1054
 	if receiveTreatment.ID == 0 { //新增
@@ -1066,6 +1096,7 @@ func (c *DialysisApiController) PostReceiveTreatmentAsses() {
1066 1096
 }
1067 1097
 
1068 1098
 func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1099
+
1069 1100
 	patient, _ := c.GetInt64("patient", 0)
1070 1101
 	recordDateStr := c.GetString("record_date")
1071 1102
 	fmt.Println(recordDateStr)
@@ -1164,6 +1195,14 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
1164 1195
 	assessment.AdditionalWeight = data.AdditionalWeight
1165 1196
 	assessment.OtherComplication = data.OtherComplication
1166 1197
 	assessment.Ktv = data.Ktv
1198
+
1199
+	assessment.Urr = data.Urr
1200
+	assessment.Hypertenison = data.Hypertenison
1201
+	assessment.Hypopiesia = data.Hypopiesia
1202
+	assessment.LeaveOfficeMethod = data.LeaveOfficeMethod
1203
+	assessment.Lapse = data.Lapse
1204
+	assessment.Consciousness = data.Consciousness
1205
+	assessment.Fallrisk = data.Fallrisk
1167 1206
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1168 1207
 
1169 1208
 	if assessment.ID > 0 {
@@ -1294,6 +1333,11 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1294 1333
 	thrombus_a := c.GetString("thromubus_a")
1295 1334
 	thrombus_av := c.GetString("thrombus_av")
1296 1335
 	thrombus_v := c.GetString("thromubus_v")
1336
+	dehydration := c.GetString("dehydration")
1337
+	pre_dialysis_drugs := c.GetString("pre_dialysis_drugs")
1338
+	period, _ := c.GetInt64("period")
1339
+	estimated_food_intake := c.GetString("estimated_food_intake")
1340
+	blood_pressure_during_dialysis := c.GetString("blood_pressure_during_dialysis")
1297 1341
 	assessmentBeforeDislysis := models.PredialysisEvaluation{
1298 1342
 		DialysisCount:                  dialysis_count,
1299 1343
 		EmergencyTreatment:             emergency_treatment,
@@ -1355,6 +1399,11 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
1355 1399
 		ThrombusAv:                     thrombus_av,
1356 1400
 		ThromubusA:                     thrombus_a,
1357 1401
 		ThromubusV:                     thrombus_v,
1402
+		Dehydration:                    dehydration,
1403
+		PreDialysisDrugs:               pre_dialysis_drugs,
1404
+		Period:                         period,
1405
+		EstimatedFoodIntake:            estimated_food_intake,
1406
+		BloodPressureDuringDialysis:    blood_pressure_during_dialysis,
1358 1407
 	}
1359 1408
 
1360 1409
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
@@ -3072,6 +3121,11 @@ func (this *DialysisApiController) GetTodayMonitor() {
3072 3121
 
3073 3122
 	var ultrafiltration_rate float64
3074 3123
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, theAssessmentDateTime, adminInfo.CurrentOrgId)
3124
+	//针对福建医师汇 获取透前评估预增脱水量
3125
+
3126
+	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, theAssessmentDateTime, adminInfo.CurrentOrgId)
3127
+	fmt.Println("透前评估数据", evaluation)
3128
+
3075 3129
 	if prescription.ID > 0 {
3076 3130
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
3077 3131
 
@@ -3080,6 +3134,13 @@ func (this *DialysisApiController) GetTodayMonitor() {
3080 3134
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3081 3135
 				record.UltrafiltrationRate = ultrafiltration_rate
3082 3136
 			}
3137
+			if template.TemplateId == 6 && adminInfo.CurrentOrgId == 10121 {
3138
+
3139
+				dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
3140
+				ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
3141
+
3142
+				record.UltrafiltrationRate = ultrafiltration_rate
3143
+			}
3083 3144
 
3084 3145
 			if template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 { //adminInfo.CurrentOrgId == 9538
3085 3146
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
@@ -3095,7 +3156,9 @@ func (this *DialysisApiController) GetTodayMonitor() {
3095 3156
 		}
3096 3157
 	}
3097 3158
 	// record.UltrafiltrationRate = ultrafiltration_rate
3159
+
3098 3160
 	record.UltrafiltrationVolume = 0
3161
+
3099 3162
 	if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
3100 3163
 		if ultrafiltration_rate > 0 {
3101 3164
 			value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", float64(record.OperateTime+3600-fristrecord.OperateTime)/3600*ultrafiltration_rate), 6)
@@ -3106,8 +3169,10 @@ func (this *DialysisApiController) GetTodayMonitor() {
3106 3169
 	if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 {
3107 3170
 		if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
3108 3171
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
3172
+
3109 3173
 			record.UltrafiltrationVolume = ultrafiltration_volume
3110 3174
 		}
3175
+
3111 3176
 	}
3112 3177
 
3113 3178
 	this.ServeSuccessJSON(map[string]interface{}{

+ 84 - 69
controllers/dialysis_record_api_controller.go View File

@@ -322,37 +322,39 @@ type EditMonitorParamObject struct {
322 322
 	MonitoringDate int64 `json:"monitoring_date"`
323 323
 	OperateTime    int64 `json:"operate_time"`
324 324
 	// MonitoringTime        string  `json:"monitoring_time"`
325
-	SystolicBP                float64 `json:"systolic_bp"`
326
-	DiastolicBP               float64 `json:"diastolic_bp"`
327
-	PulseFrequency            float64 `json:"pulse_frequency"`
328
-	BreathingRated            float64 `json:"breathing_rated"`
329
-	BloodFlowVolume           float64 `json:"blood_flow_volume"`
330
-	VenousPressure            float64 `json:"venous_pressure"`
331
-	VenousPressureType        int64   `json:"venous_pressure_type"`
332
-	TransmembranePressure     float64 `json:"transmembrane_pressure"`
333
-	TransmembranePressureType int64   `json:"transmembrane_pressure_type"`
334
-	UltrafiltrationVolume     float64 `json:"ultrafiltration_volume"`
335
-	UltrafiltrationRate       float64 `json:"ultrafiltration_rate"`
336
-	ArterialPressure          float64 `json:"arterial_pressure"`
337
-	ArterialPressureType      int64   `json:"arterial_pressure_type"`
338
-	SodiumConcentration       float64 `json:"sodium_concentration"`
339
-	DialysateTemperature      float64 `json:"dialysate_temperature"`
340
-	Temperature               float64 `json:"temperature"`
341
-	ReplacementRate           float64 `json:"replacement_rate"`
342
-	DisplacementQuantity      float64 `json:"displacement_quantity"`
343
-	KTV                       float64 `json:"ktv"`
344
-	Symptom                   string  `json:"symptom"`
345
-	Dispose                   string  `json:"dispose"`
346
-	Result                    string  `json:"result"`
347
-	Conductivity              float64 `json:"conductivity"`
348
-	DisplacementFlowQuantity  float64 `json:"displacement_flow_quantity"`
349
-	BloodOxygenSaturation     string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
350
-	Heparin                   float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
351
-	DialysateFlow             float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
352
-	Urr                       string  `gorm:"column:urr" json:"urr" form:"urr"`
353
-	BloodSugar                float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
354
-	MonitorAnticoagulant      int64   `gorm:"column:monitor_anticoagulant" json:"monitor_anticoagulant" form:"monitor_anticoagulant"`
355
-	MonitorAnticoagulantValue string  `gorm:"column:monitor_anticoagulant_value" json:"monitor_anticoagulant_value" form:"monitor_anticoagulant_value"`
325
+	SystolicBP                  float64 `json:"systolic_bp"`
326
+	DiastolicBP                 float64 `json:"diastolic_bp"`
327
+	PulseFrequency              float64 `json:"pulse_frequency"`
328
+	BreathingRated              float64 `json:"breathing_rated"`
329
+	BloodFlowVolume             float64 `json:"blood_flow_volume"`
330
+	VenousPressure              float64 `json:"venous_pressure"`
331
+	VenousPressureType          int64   `json:"venous_pressure_type"`
332
+	TransmembranePressure       float64 `json:"transmembrane_pressure"`
333
+	TransmembranePressureType   int64   `json:"transmembrane_pressure_type"`
334
+	UltrafiltrationVolume       float64 `json:"ultrafiltration_volume"`
335
+	UltrafiltrationRate         float64 `json:"ultrafiltration_rate"`
336
+	ArterialPressure            float64 `json:"arterial_pressure"`
337
+	ArterialPressureType        int64   `json:"arterial_pressure_type"`
338
+	SodiumConcentration         float64 `json:"sodium_concentration"`
339
+	DialysateTemperature        float64 `json:"dialysate_temperature"`
340
+	Temperature                 float64 `json:"temperature"`
341
+	ReplacementRate             float64 `json:"replacement_rate"`
342
+	DisplacementQuantity        float64 `json:"displacement_quantity"`
343
+	KTV                         float64 `json:"ktv"`
344
+	Symptom                     string  `json:"symptom"`
345
+	Dispose                     string  `json:"dispose"`
346
+	Result                      string  `json:"result"`
347
+	Conductivity                float64 `json:"conductivity"`
348
+	DisplacementFlowQuantity    float64 `json:"displacement_flow_quantity"`
349
+	BloodOxygenSaturation       string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
350
+	Heparin                     float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
351
+	DialysateFlow               float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
352
+	Urr                         string  `gorm:"column:urr" json:"urr" form:"urr"`
353
+	BloodSugar                  float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
354
+	MonitorAnticoagulant        int64   `gorm:"column:monitor_anticoagulant" json:"monitor_anticoagulant" form:"monitor_anticoagulant"`
355
+	MonitorAnticoagulantValue   string  `gorm:"column:monitor_anticoagulant_value" json:"monitor_anticoagulant_value" form:"monitor_anticoagulant_value"`
356
+	BloodPressureMonitoringSite int64   `gorm:"column:blood_pressure_monitoring_site" json:"blood_pressure_monitoring_site" form:"blood_pressure_monitoring_site"`
357
+	Complication                int64   `gorm:"column:complication" json:"complication" form:"complication"`
356 358
 }
357 359
 
358 360
 // /api/dislysis/monitor/edit [post]
@@ -429,42 +431,44 @@ func (this *DialysisRecordAPIController) EditMonitor() {
429 431
 			MonitoringDate:  monitorParam.MonitoringDate,
430 432
 			OperateTime:     monitorParam.OperateTime,
431 433
 			// MonitoringTime:         monitorParam.MonitoringTime,
432
-			PulseFrequency:            monitorParam.PulseFrequency,
433
-			BreathingRate:             monitorParam.BreathingRated,
434
-			SystolicBloodPressure:     monitorParam.SystolicBP,
435
-			DiastolicBloodPressure:    monitorParam.DiastolicBP,
436
-			BloodFlowVolume:           monitorParam.BloodFlowVolume,
437
-			VenousPressure:            monitorParam.VenousPressure,
438
-			VenousPressureType:        monitorParam.VenousPressureType,
439
-			ArterialPressure:          monitorParam.ArterialPressure,
440
-			ArterialPressureType:      monitorParam.ArterialPressureType,
441
-			TransmembranePressure:     monitorParam.TransmembranePressure,
442
-			TransmembranePressureType: monitorParam.TransmembranePressureType,
443
-			UltrafiltrationRate:       monitorParam.UltrafiltrationRate,
444
-			UltrafiltrationVolume:     monitorParam.UltrafiltrationVolume,
445
-			SodiumConcentration:       monitorParam.SodiumConcentration,
446
-			DialysateTemperature:      monitorParam.DialysateTemperature,
447
-			Temperature:               monitorParam.Temperature,
448
-			ReplacementRate:           monitorParam.ReplacementRate,
449
-			DisplacementQuantity:      monitorParam.DisplacementQuantity,
450
-			Ktv:                       monitorParam.KTV,
451
-			Symptom:                   monitorParam.Symptom,
452
-			Dispose:                   monitorParam.Dispose,
453
-			Result:                    monitorParam.Result,
454
-			MonitoringNurse:           adminUserInfo.AdminUser.Id,
455
-			Conductivity:              monitorParam.Conductivity,
456
-			DisplacementFlowQuantity:  monitorParam.DisplacementFlowQuantity,
457
-			Status:                    1,
458
-			CreatedTime:               time.Now().Unix(),
459
-			UpdatedTime:               time.Now().Unix(),
460
-			BloodOxygenSaturation:     monitorParam.BloodOxygenSaturation,
461
-			Creator:                   adminUserInfo.AdminUser.Id,
462
-			Heparin:                   monitorParam.Heparin,
463
-			DialysateFlow:             monitorParam.DialysateFlow,
464
-			Urr:                       monitorParam.Urr,
465
-			BloodSugar:                monitorParam.BloodSugar,
466
-			MonitorAnticoagulant:      monitorParam.MonitorAnticoagulant,
467
-			MonitorAnticoagulantValue: monitorParam.MonitorAnticoagulantValue,
434
+			PulseFrequency:              monitorParam.PulseFrequency,
435
+			BreathingRate:               monitorParam.BreathingRated,
436
+			SystolicBloodPressure:       monitorParam.SystolicBP,
437
+			DiastolicBloodPressure:      monitorParam.DiastolicBP,
438
+			BloodFlowVolume:             monitorParam.BloodFlowVolume,
439
+			VenousPressure:              monitorParam.VenousPressure,
440
+			VenousPressureType:          monitorParam.VenousPressureType,
441
+			ArterialPressure:            monitorParam.ArterialPressure,
442
+			ArterialPressureType:        monitorParam.ArterialPressureType,
443
+			TransmembranePressure:       monitorParam.TransmembranePressure,
444
+			TransmembranePressureType:   monitorParam.TransmembranePressureType,
445
+			UltrafiltrationRate:         monitorParam.UltrafiltrationRate,
446
+			UltrafiltrationVolume:       monitorParam.UltrafiltrationVolume,
447
+			SodiumConcentration:         monitorParam.SodiumConcentration,
448
+			DialysateTemperature:        monitorParam.DialysateTemperature,
449
+			Temperature:                 monitorParam.Temperature,
450
+			ReplacementRate:             monitorParam.ReplacementRate,
451
+			DisplacementQuantity:        monitorParam.DisplacementQuantity,
452
+			Ktv:                         monitorParam.KTV,
453
+			Symptom:                     monitorParam.Symptom,
454
+			Dispose:                     monitorParam.Dispose,
455
+			Result:                      monitorParam.Result,
456
+			MonitoringNurse:             adminUserInfo.AdminUser.Id,
457
+			Conductivity:                monitorParam.Conductivity,
458
+			DisplacementFlowQuantity:    monitorParam.DisplacementFlowQuantity,
459
+			Status:                      1,
460
+			CreatedTime:                 time.Now().Unix(),
461
+			UpdatedTime:                 time.Now().Unix(),
462
+			BloodOxygenSaturation:       monitorParam.BloodOxygenSaturation,
463
+			Creator:                     adminUserInfo.AdminUser.Id,
464
+			Heparin:                     monitorParam.Heparin,
465
+			DialysateFlow:               monitorParam.DialysateFlow,
466
+			Urr:                         monitorParam.Urr,
467
+			BloodSugar:                  monitorParam.BloodSugar,
468
+			MonitorAnticoagulant:        monitorParam.MonitorAnticoagulant,
469
+			MonitorAnticoagulantValue:   monitorParam.MonitorAnticoagulantValue,
470
+			BloodPressureMonitoringSite: monitorParam.BloodPressureMonitoringSite,
471
+			Complication:                monitorParam.Complication,
468 472
 		}
469 473
 		createErr := service.CreateMonitor(&monitor)
470 474
 		if createErr != nil {
@@ -553,7 +557,6 @@ func (this *DialysisRecordAPIController) EditMonitor() {
553 557
 func (this *DialysisRecordAPIController) StartDialysis() {
554 558
 	patientID, _ := this.GetInt64("patient_id")
555 559
 	recordDateStr := this.GetString("date")
556
-	fmt.Println("上机日期222222222222222222222222", recordDateStr)
557 560
 	nurseID, _ := this.GetInt64("nurse")
558 561
 	punctureNurseId, _ := this.GetInt64("puncture_nurse")
559 562
 	startDateStr := this.GetString("start_time")
@@ -758,13 +761,25 @@ func (this *DialysisRecordAPIController) StartDialysis() {
758 761
 
759 762
 		var ultrafiltration_rate float64
760 763
 		_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.CurrentOrgId)
764
+
765
+		//获取预增水量
766
+		_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, schedulestartTime, adminUserInfo.CurrentOrgId)
761 767
 		if prescription.ID > 0 {
762 768
 			if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
763 769
 
764 770
 				totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
765
-				if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 36 {
771
+				if (template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 36) && adminUserInfo.CurrentOrgId != 9671 {
766 772
 					ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
767 773
 				}
774
+
775
+				//针对福建医师汇
776
+				if template.TemplateId == 6 && adminUserInfo.CurrentOrgId == 10121 {
777
+					if evaluation.ID > 0 {
778
+						dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
779
+						ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
780
+					}
781
+				}
782
+
768 783
 				// 只针对方济医院
769 784
 				if template.TemplateId == 1 && adminUserInfo.CurrentOrgId != 9849 {
770 785
 					value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)

+ 79 - 43
controllers/doctors_api_controller.go View File

@@ -351,39 +351,66 @@ func (this *DoctorsApiController) SaveVasularAccess() {
351 351
 	creator := adminUserInfo.AdminUser.Id
352 352
 
353 353
 	//查询改日期是否存在
354
-	_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
355
-	if errcode == gorm.ErrRecordNotFound {
356
-		access := models.XtPatientVascularAccess{
357
-			AccessProject:          access_project,
358
-			BloodAccessPartId:      blood_access_part_id,
359
-			BloodAccessPartOperaId: blood_access_part_opera_id,
360
-			FirstStartTime:         firstStartTime.Unix(),
361
-			InflowPass:             inflow_pass,
362
-			Remark:                 remark,
363
-			StartTime:              startTime.Unix(),
364
-			StopReason:             stop_reason,
365
-			UserStatus:             user_status,
366
-			Creator:                creator,
367
-			UserOrgId:              orgId,
368
-			Status:                 1,
369
-			Ctime:                  time.Now().Unix(),
370
-			StopTime:               stopTime.Unix(),
371
-			PatientId:              patient_id,
372
-			OtherVascular:          other_vascular,
373
-			CiType:                 ci_type,
374
-			BloodCultupe:           blood_cultupe,
375
-			SequelaeType:           sequelae_type,
376
-		}
377
-		err := service.SaveVascularAccess(&access)
378
-		if err == nil {
379
-			this.ServeSuccessJSON(map[string]interface{}{
380
-				"access": access,
381
-			})
382
-			return
383
-		}
384
-	} else if errcode == nil {
385
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
354
+	access := models.XtPatientVascularAccess{
355
+		AccessProject:          access_project,
356
+		BloodAccessPartId:      blood_access_part_id,
357
+		BloodAccessPartOperaId: blood_access_part_opera_id,
358
+		FirstStartTime:         firstStartTime.Unix(),
359
+		InflowPass:             inflow_pass,
360
+		Remark:                 remark,
361
+		StartTime:              startTime.Unix(),
362
+		StopReason:             stop_reason,
363
+		UserStatus:             user_status,
364
+		Creator:                creator,
365
+		UserOrgId:              orgId,
366
+		Status:                 1,
367
+		Ctime:                  time.Now().Unix(),
368
+		StopTime:               stopTime.Unix(),
369
+		PatientId:              patient_id,
370
+		OtherVascular:          other_vascular,
371
+		CiType:                 ci_type,
372
+		BloodCultupe:           blood_cultupe,
373
+		SequelaeType:           sequelae_type,
374
+	}
375
+	err := service.SaveVascularAccess(&access)
376
+	if err == nil {
377
+		this.ServeSuccessJSON(map[string]interface{}{
378
+			"access": access,
379
+		})
386 380
 		return
381
+		//_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
382
+		//if errcode == gorm.ErrRecordNotFound {
383
+		//	access := models.XtPatientVascularAccess{
384
+		//		AccessProject:          access_project,
385
+		//		BloodAccessPartId:      blood_access_part_id,
386
+		//		BloodAccessPartOperaId: blood_access_part_opera_id,
387
+		//		FirstStartTime:         firstStartTime.Unix(),
388
+		//		InflowPass:             inflow_pass,
389
+		//		Remark:                 remark,
390
+		//		StartTime:              startTime.Unix(),
391
+		//		StopReason:             stop_reason,
392
+		//		UserStatus:             user_status,
393
+		//		Creator:                creator,
394
+		//		UserOrgId:              orgId,
395
+		//		Status:                 1,
396
+		//		Ctime:                  time.Now().Unix(),
397
+		//		StopTime:               stopTime.Unix(),
398
+		//		PatientId:              patient_id,
399
+		//		OtherVascular:          other_vascular,
400
+		//		CiType:                 ci_type,
401
+		//		BloodCultupe:           blood_cultupe,
402
+		//		SequelaeType:           sequelae_type,
403
+		//	}
404
+		//	err := service.SaveVascularAccess(&access)
405
+		//	if err == nil {
406
+		//		this.ServeSuccessJSON(map[string]interface{}{
407
+		//			"access": access,
408
+		//		})
409
+		//		return
410
+		//	}
411
+		//} else if errcode == nil {
412
+		//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
413
+		//	return
387 414
 	}
388 415
 
389 416
 }
@@ -467,20 +494,29 @@ func (this *DoctorsApiController) UpdateVasularAccess() {
467 494
 		CiType:                 ci_type,
468 495
 		BloodCultupe:           blood_cultupe,
469 496
 		SequelaeType:           sequelae_type,
497
+		PatientId:              patientId,
470 498
 	}
471
-	_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
472
-	if errcode == gorm.ErrRecordNotFound {
473
-		err := service.UpdateVascularAccess(&access, id)
474
-		if err == nil {
475
-			this.ServeSuccessJSON(map[string]interface{}{
476
-				"access": access,
477
-			})
478
-			return
479
-		}
480
-	} else if errcode == nil {
481
-		this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
499
+
500
+	err := service.UpdateVascularAccess(&access, id)
501
+	if err == nil {
502
+		this.ServeSuccessJSON(map[string]interface{}{
503
+			"access": access,
504
+		})
482 505
 		return
483 506
 	}
507
+	//_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
508
+	//if errcode == gorm.ErrRecordNotFound {
509
+	//	err := service.UpdateVascularAccess(&access, id)
510
+	//	if err == nil {
511
+	//		this.ServeSuccessJSON(map[string]interface{}{
512
+	//			"access": access,
513
+	//		})
514
+	//		return
515
+	//	}
516
+	//} else if errcode == nil {
517
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
518
+	//	return
519
+	//}
484 520
 
485 521
 }
486 522
 

+ 80 - 44
controllers/drug_stock_api_contorller.go View File

@@ -136,27 +136,25 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
136 136
 
137 137
 				warehousing_count, _ := strconv.ParseInt(items["warehousing_count"].(string), 10, 64)
138 138
 
139
-				if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
140
-					utils.ErrorLog("price")
139
+				if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
140
+					utils.ErrorLog("last_price")
141 141
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
142 142
 					return
143 143
 				}
144
-				price, _ := strconv.ParseFloat(items["price"].(string), 64)
145
-				total := float64(warehousing_count) * price
144
+				last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
145
+				total := float64(warehousing_count) * last_price
146 146
 
147
-				if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
148
-					utils.ErrorLog("retail_price")
149
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
150
-					return
151
-				}
152
-				retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
153
-				retail_price_total := float64(warehousing_count) * retail_price
147
+				//if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
148
+				//	utils.ErrorLog("retail_price")
149
+				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
150
+				//	return
151
+				//}
152
+				//retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
153
+				retail_price_total := float64(warehousing_count) * last_price
154 154
 
155 155
 				var productDates int64
156 156
 				var expiryDates int64
157 157
 
158
-				fmt.Println()
159
-
160 158
 				if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "string" {
161 159
 					expiryDates = 0
162 160
 				} else {
@@ -185,15 +183,29 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
185 183
 
186 184
 				}
187 185
 
188
-				if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
189
-					utils.ErrorLog("number")
186
+				if items["lot_number"] == nil || reflect.TypeOf(items["lot_number"]).String() != "string" {
187
+					utils.ErrorLog("lot_number")
190 188
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
191 189
 					return
192 190
 				}
193
-				number, _ := items["number"].(string)
191
+				lot_number, _ := items["lot_number"].(string)
192
+
193
+				if items["batch_number"] == nil || reflect.TypeOf(items["batch_number"]).String() != "string" {
194
+					utils.ErrorLog("batch_number")
195
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
196
+					return
197
+				}
198
+				batch_number, _ := items["batch_number"].(string)
199
+
200
+				if items["packing_unit"] == nil || reflect.TypeOf(items["packing_unit"]).String() != "string" {
201
+					utils.ErrorLog("packing_unit")
202
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
203
+					return
204
+				}
205
+				packing_unit, _ := items["packing_unit"].(string)
194 206
 
195 207
 				var remark string
196
-				if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
208
+				if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
197 209
 					remark = ""
198 210
 				} else {
199 211
 					remark = items["remark"].(string)
@@ -203,11 +215,11 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
203 215
 					WarehousingOrder: warehousing.WarehousingOrder,
204 216
 					WarehousingId:    warehousing.ID,
205 217
 					DrugId:           drug_id,
206
-					Number:           number,
218
+					Number:           lot_number,
207 219
 					ProductDate:      productDates,
208 220
 					ExpiryDate:       expiryDates,
209 221
 					WarehousingCount: warehousing_count,
210
-					Price:            price,
222
+					Price:            last_price,
211 223
 					TotalPrice:       total,
212 224
 					Status:           1,
213 225
 					Ctime:            ctime,
@@ -216,8 +228,11 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
216 228
 					Type:             types,
217 229
 					Manufacturer:     manufacturer_id,
218 230
 					Dealer:           dealer_id,
219
-					RetailPrice:      retail_price,
231
+					//RetailPrice:      retail_price,
232
+					StockMaxNumber:   warehousing_count,
220 233
 					RetailTotalPrice: retail_price_total,
234
+					BatchNumber:      batch_number,
235
+					MaxUnit:          packing_unit,
221 236
 				}
222 237
 				warehousingInfo = append(warehousingInfo, warehouseInfo)
223 238
 
@@ -431,6 +446,7 @@ func (c *StockDrugApiController) GetDrugWarehouseInfoList() {
431 446
 
432 447
 	warehousing, err := service.FindDrugWarehousingById(id, admin.CurrentOrgId)
433 448
 
449
+	manufacturerList, _ := service.GetAllDrugLibList(admin.CurrentOrgId)
434 450
 	if err != nil {
435 451
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
436 452
 		return
@@ -443,8 +459,9 @@ func (c *StockDrugApiController) GetDrugWarehouseInfoList() {
443 459
 	warehousingInfo, err := service.FindDrugWarehousingInfoById(id, admin.CurrentOrgId)
444 460
 	if err == nil {
445 461
 		c.ServeSuccessJSON(map[string]interface{}{
446
-			"info":        warehousingInfo,
447
-			"warehousing": warehousing,
462
+			"info":             warehousingInfo,
463
+			"warehousing":      warehousing,
464
+			"manufacturerList": manufacturerList,
448 465
 		})
449 466
 	} else {
450 467
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -452,11 +469,12 @@ func (c *StockDrugApiController) GetDrugWarehouseInfoList() {
452 469
 }
453 470
 
454 471
 func (c *StockDrugApiController) EditDrugWarehouse() {
472
+
455 473
 	warehousing_time := c.GetString("warehousing_time")
456 474
 	id, _ := c.GetInt64("id", 0)
457 475
 	types, _ := c.GetInt64("type", 0)
458
-	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
459
-	dealer_id, _ := c.GetInt64("dealer_id", 0)
476
+	//manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
477
+	//dealer_id, _ := c.GetInt64("dealer_id", 0)
460 478
 
461 479
 	if id == 0 {
462 480
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -484,8 +502,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
484 502
 		Status:           1,
485 503
 		WarehousingTime:  warehousingDate.Unix(),
486 504
 		Type:             warehouse.Type,
487
-		Dealer:           dealer_id,
488
-		Manufacturer:     manufacturer_id,
505
+		//Dealer:           dealer_id,
506
+		//Manufacturer:     manufacturer_id,
489 507
 	}
490 508
 
491 509
 	service.EditDrugWarehousingOne(warehousing, id)
@@ -503,6 +521,7 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
503 521
 
504 522
 	if dataBody["stockIn"] != nil && reflect.TypeOf(dataBody["stockIn"]).String() == "[]interface {}" {
505 523
 		thisStockIn, _ := dataBody["stockIn"].([]interface{})
524
+
506 525
 		if len(thisStockIn) > 0 {
507 526
 			for _, item := range thisStockIn {
508 527
 				items := item.(map[string]interface{})
@@ -530,13 +549,22 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
530 549
 				price, _ := strconv.ParseFloat(items["price"].(string), 64)
531 550
 				total := float64(warehousing_count) * price
532 551
 
533
-				if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
534
-					utils.ErrorLog("retail_price")
552
+				//if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
553
+				//	utils.ErrorLog("retail_price")
554
+				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
555
+				//	return
556
+				//}
557
+				//retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
558
+				//retail_price_total := float64(warehousing_count) * last_price
559
+
560
+				if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
561
+					utils.ErrorLog("last_price")
535 562
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
536 563
 					return
537 564
 				}
538
-				retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
539
-				retail_price_total := float64(warehousing_count) * retail_price
565
+				last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
566
+
567
+				retail_price_total := float64(warehousing_count) * last_price
540 568
 
541 569
 				var productDates int64
542 570
 				var expiryDates int64
@@ -553,8 +581,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
553 581
 						expiryDates = expiry_date.Unix()
554 582
 
555 583
 					}
556
-
557 584
 				}
585
+
558 586
 				if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "string" {
559 587
 					productDates = 0
560 588
 				} else {
@@ -576,8 +604,15 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
576 604
 				}
577 605
 				number, _ := items["number"].(string)
578 606
 
607
+				if items["batch_number"] == nil || reflect.TypeOf(items["batch_number"]).String() != "string" {
608
+					utils.ErrorLog("batch_number")
609
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
610
+					return
611
+				}
612
+				batch_number, _ := items["batch_number"].(string)
613
+
579 614
 				var remark string
580
-				if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
615
+				if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
581 616
 					remark = ""
582 617
 				} else {
583 618
 					remark = items["remark"].(string)
@@ -590,13 +625,13 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
590 625
 				}
591 626
 				id := int64(items["id"].(float64))
592 627
 
593
-				if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "float64" {
594
-					utils.ErrorLog("dealer")
595
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
596
-					return
597
-				}
598
-				dealer := int64(items["dealer"].(float64))
599
-
628
+				//if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "float64" {
629
+				//	utils.ErrorLog("dealer")
630
+				//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
631
+				//	return
632
+				//}
633
+				//dealer := int64(items["dealer"].(float64))
634
+				//
600 635
 				if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "float64" {
601 636
 					utils.ErrorLog("manufacturer")
602 637
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -620,9 +655,10 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
620 655
 						OrgId:            adminUserInfo.CurrentOrgId,
621 656
 						Type:             types,
622 657
 						Manufacturer:     manufacturer,
623
-						Dealer:           dealer,
624
-						RetailPrice:      retail_price,
658
+						//Dealer:           dealer,
659
+						RetailPrice:      last_price,
625 660
 						RetailTotalPrice: retail_price_total,
661
+						BatchNumber:      batch_number,
626 662
 					}
627 663
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
628 664
 
@@ -644,8 +680,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
644 680
 						OrgId:            adminUserInfo.CurrentOrgId,
645 681
 						Type:             types,
646 682
 						Manufacturer:     manufacturer,
647
-						Dealer:           dealer,
648
-						RetailPrice:      retail_price,
683
+						//Dealer:           dealer,
684
+						RetailPrice:      last_price,
649 685
 						RetailTotalPrice: retail_price_total,
650 686
 					}
651 687
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
@@ -1428,7 +1464,7 @@ func (c *StockDrugApiController) EditDrugWarehouseOut() {
1428 1464
 					sys_record_time := int64(items["sys_record_time"].(float64))
1429 1465
 
1430 1466
 					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1431
-						ID: id,
1467
+						ID:                      id,
1432 1468
 						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1433 1469
 						WarehouseOutId:          warehouseOut.ID,
1434 1470
 						DrugId:                  drug_id,

+ 11 - 0
controllers/gobal_config_api_controller.go View File

@@ -87,6 +87,7 @@ func GobalConfigRegistRouters() {
87 87
 	beego.Router("/api/order/addorderconfig", &GobalConfigApiController{}, "Get:AddOrderConfig")
88 88
 	beego.Router("/api/order/getorderconfig", &GobalConfigApiController{}, "Get:GetOrderConfig")
89 89
 	beego.Router("/api/drugstock/getdrugautomaticlist", &GobalConfigApiController{}, "Get:GetDrugAutoMaticList")
90
+	beego.Router("/api/drugstock/getdrugwarehouseorderinfo", &GobalConfigApiController{}, "Get:GetDrugWarehuseOrderInfo")
90 91
 }
91 92
 
92 93
 //provinces, _ := service.GetDistrictsByUpid(0)21
@@ -1785,3 +1786,13 @@ func (c *GobalConfigApiController) GetDrugAutoMaticList() {
1785 1786
 		"drugList":   drugList,
1786 1787
 	})
1787 1788
 }
1789
+
1790
+func (c *GobalConfigApiController) GetDrugWarehuseOrderInfo() {
1791
+
1792
+	adminUserInfo := c.GetAdminUserInfo()
1793
+	orgId := adminUserInfo.CurrentOrgId
1794
+	list, _ := service.GetDrugWarehuseOrderInfo(orgId)
1795
+	c.ServeSuccessJSON(map[string]interface{}{
1796
+		"list": list,
1797
+	})
1798
+}

+ 76 - 5
controllers/his_api_controller.go View File

@@ -320,6 +320,42 @@ func (c *HisApiController) CreateHisPrescription() {
320 320
 		}
321 321
 	}
322 322
 
323
+	//校验库存总量
324
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
325
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
326
+		if len(prescriptions) > 0 {
327
+			for _, item := range prescriptions {
328
+				items := item.(map[string]interface{})
329
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
330
+					advices := items["advices"].([]interface{})
331
+					if len(advices) > 0 {
332
+						for _, advice := range advices {
333
+							var drug_id int64
334
+							var prescribing_number float64
335
+							if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
336
+								drug_id = int64(advice.(map[string]interface{})["id"].(float64))
337
+							}
338
+							if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "float64" {
339
+								prescribing_number = advice.(map[string]interface{})["prescribing_number"].(float64)
340
+							}
341
+
342
+							drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, drug_id)
343
+							if drug.ID == 0 {
344
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
345
+								return
346
+							}
347
+
348
+							if prescribing_number > drug.Total {
349
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
350
+								return
351
+							}
352
+						}
353
+					}
354
+				}
355
+			}
356
+		}
357
+	}
358
+
323 359
 	info, _ := service.FindHisPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
324 360
 	var hpInfo models.HisPrescriptionInfo
325 361
 	if info.ID == 0 {
@@ -838,6 +874,8 @@ func (c *HisApiController) EditHisPrescription() {
838 874
 func (c *HisApiController) DeletePrescription() {
839 875
 	prescription_id, _ := c.GetInt64("id")
840 876
 	projects, _ := service.GetHisPrescriptionProjectsByID(prescription_id)
877
+	advices, _ := service.GetHisPrescriptionAdviceByID(prescription_id)
878
+
841 879
 	err := service.DelelteHisPrescription(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
842 880
 	if err == nil {
843 881
 		if len(projects) > 0 {
@@ -851,6 +889,15 @@ func (c *HisApiController) DeletePrescription() {
851 889
 				}
852 890
 			}
853 891
 		}
892
+
893
+		if len(advices) > 0 {
894
+			for _, item := range advices {
895
+				drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, item.DrugId)
896
+				drug.Total = drug.Total + item.PrescribingNumber
897
+				service.UpdateBaseDrugLib(&drug)
898
+			}
899
+		}
900
+
854 901
 		c.ServeSuccessJSON(map[string]interface{}{
855 902
 			"msg": "删除成功",
856 903
 		})
@@ -863,9 +910,12 @@ func (c *HisApiController) DeletePrescription() {
863 910
 
864 911
 func (c *HisApiController) DeleteDoctorAdvice() {
865 912
 	id, _ := c.GetInt64("id")
866
-	//TODO 需要判断是否已经结算
913
+	advice, _ := service.GetHisDoctorAdvicesById(id)
867 914
 	err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
868 915
 	if err == nil {
916
+		drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, advice.DrugId)
917
+		drug.Total = drug.Total + advice.PrescribingNumber
918
+		service.UpdateBaseDrugLib(&drug)
869 919
 		c.ServeSuccessJSON(map[string]interface{}{
870 920
 			"msg": "删除成功",
871 921
 		})
@@ -1494,6 +1544,12 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
1494 1544
 			advice.DrugId = drug_id
1495 1545
 		}
1496 1546
 	}
1547
+
1548
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
1549
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
1550
+		advice.PrescribingNumber = prescribingNumber
1551
+	}
1552
+
1497 1553
 	if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
1498 1554
 		advice_id := int64(json["advice_id"].(float64))
1499 1555
 		advice.ID = advice_id
@@ -1514,6 +1570,24 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
1514 1570
 		}
1515 1571
 	}
1516 1572
 
1573
+	drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
1574
+	if advice.ID == 0 { //医嘱不存在
1575
+		drug.Total = drug.Total - advice.PrescribingNumber
1576
+		service.UpdateBaseDrugLib(&drug)
1577
+	} else if advice.ID > 0 { //医嘱存在
1578
+		hisAdvice, _ := service.GetHisDoctorAdvicesById(advice.ID)
1579
+		var num float64
1580
+		if hisAdvice.PrescribingNumber > advice.PrescribingNumber {
1581
+			num = hisAdvice.PrescribingNumber - advice.PrescribingNumber
1582
+			drug.Total = drug.Total + num
1583
+			service.UpdateBaseDrugLib(&drug)
1584
+		} else if hisAdvice.PrescribingNumber < advice.PrescribingNumber {
1585
+			num = advice.PrescribingNumber - hisAdvice.PrescribingNumber
1586
+			drug.Total = drug.Total - num
1587
+			service.UpdateBaseDrugLib(&drug)
1588
+		}
1589
+	}
1590
+
1517 1591
 	//
1518 1592
 	//if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
1519 1593
 	//	execution_time, _ := strconv.ParseInt(json["execution_time"].(string), 10,64)
@@ -1569,10 +1643,7 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
1569 1643
 		singleDoseUnit, _ := json["single_dose_unit"].(string)
1570 1644
 		advice.SingleDoseUnit = singleDoseUnit
1571 1645
 	}
1572
-	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
1573
-		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
1574
-		advice.PrescribingNumber = prescribingNumber
1575
-	}
1646
+
1576 1647
 	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
1577 1648
 		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
1578 1649
 		advice.PrescribingNumberUnit = prescribingNumberUnit

+ 4 - 5
controllers/his_project_api_controller.go View File

@@ -731,12 +731,11 @@ func (this *HisProjectApiController) GetTreatmentList() {
731 731
 }
732 732
 
733 733
 func (this *HisProjectApiController) GetAllProjectList() {
734
-
734
+	keyword := this.GetString("keyword")
735 735
 	adminUserInfo := this.GetAdminUserInfo()
736 736
 	orgId := adminUserInfo.CurrentOrgId
737
-	projectList, err := service.GetAllProjectList(orgId)
738
-
739
-	goodInfos, err := service.GetGoodInfomationList(orgId)
737
+	projectList, err := service.GetAllProjectList(orgId, keyword)
738
+	goodInfos, err := service.GetGoodInfomationList(orgId, keyword)
740 739
 
741 740
 	//获取列表数据
742 741
 	hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
@@ -1189,7 +1188,7 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1189 1188
 	//prescription_id, _ := this.GetInt64("prescription_id")
1190 1189
 	adminUserInfo := this.GetAdminUserInfo()
1191 1190
 	advicePrint, err := service.GetDoctorAdvicePrint(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId)
1192
-	projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId)
1191
+	projectlist, err := service.GetAllProjectList(adminUserInfo.CurrentOrgId, "")
1193 1192
 	//prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1194 1193
 	hisPatient, _ := service.GetHisPatientById(patient_id)
1195 1194
 	if err != nil {

+ 93 - 92
controllers/manage_api_controller.go View File

@@ -123,6 +123,7 @@ func ManageRouters() {
123 123
 	beego.Router("/api/manage/deletehadwater", &MachineApiController{}, "Get:DeleteHadWater")
124 124
 	beego.Router("/api/manage/deletewater", &MachineApiController{}, "Get:DeleteWater")
125 125
 	beego.Router("/api/manage/deletedeviceph", &MachineApiController{}, "Get:DeleteDevicePh")
126
+
126 127
 }
127 128
 
128 129
 func (this *MachineApiController) SaveManageInfo() {
@@ -1192,35 +1193,35 @@ func (this *MachineApiController) SaveInformation() {
1192 1193
 			Date:  startdate,
1193 1194
 			Class: classtype,
1194 1195
 			//	Zone:                  zone,
1195
-			BedNumber:           bednumber,
1196
-			PatientId:           patient_time,
1197
-			Contagion:           contagion,
1198
-			DialysisMode:        dialysis_mode,
1199
-			StartTime:           startDate.Unix(),
1200
-			EndTime:             endDate.Unix(),
1201
-			DialysisHour:        dialysis_time,
1202
-			Hyperfiltratio:      hyperfiletration,
1203
-			WeightLoss:          weight_loss,
1204
-			WarningValue:        warining_value,
1205
-			UserTotal:           user_total,
1206
-			Move:                run,
1207
-			FailureStage:        failure_stage,
1208
-			FaultDescription:    falult_desciription,
1209
-			CodeInformation:     code_information,
1210
-			DisinfectantType:    disinfectant_type,
1211
-			DisinfectType:       disinfect_type,
1212
-			Disinfection:        disinfection,
1213
-			MachineRun:          machine_run,
1214
-			FluidPath:           fluid_path,
1215
-			Disinfectant:        disinfectant,
1216
-			DisinfectionStatus:  disinfection_status,
1217
-			DisinfectionResidue: disinfection_residue,
1218
-			LongTime:            longtime,
1219
-			DisinfecStartime:    start_Date.Unix(),
1220
-			DisinfecEndtime:     end_Date.Unix(),
1221
-			DialysisChecked:     dialysis_checked,
1222
-			DialysisName:        dialysis_name,
1223
-			Norms:               norms,
1196
+			BedNumber:             bednumber,
1197
+			PatientId:             patient_time,
1198
+			Contagion:             contagion,
1199
+			DialysisMode:          dialysis_mode,
1200
+			StartTime:             startDate.Unix(),
1201
+			EndTime:               endDate.Unix(),
1202
+			DialysisHour:          dialysis_time,
1203
+			Hyperfiltratio:        hyperfiletration,
1204
+			WeightLoss:            weight_loss,
1205
+			WarningValue:          warining_value,
1206
+			UserTotal:             user_total,
1207
+			Move:                  run,
1208
+			FailureStage:          failure_stage,
1209
+			FaultDescription:      falult_desciription,
1210
+			CodeInformation:       code_information,
1211
+			DisinfectantType:      disinfectant_type,
1212
+			DisinfectType:         disinfect_type,
1213
+			Disinfection:          disinfection,
1214
+			MachineRun:            machine_run,
1215
+			FluidPath:             fluid_path,
1216
+			Disinfectant:          disinfectant,
1217
+			DisinfectionStatus:    disinfection_status,
1218
+			DisinfectionResidue:   disinfection_residue,
1219
+			LongTime:              longtime,
1220
+			DisinfecStartime:      start_Date.Unix(),
1221
+			DisinfecEndtime:       end_Date.Unix(),
1222
+			DialysisChecked:       dialysis_checked,
1223
+			DialysisName:          dialysis_name,
1224
+			Norms:                 norms,
1224 1225
 			DialysisConcentration: dialysis_concentration,
1225 1226
 			GermChecked:           germ_checked,
1226 1227
 			GermName:              germ_name,
@@ -1241,38 +1242,38 @@ func (this *MachineApiController) SaveInformation() {
1241 1242
 		})
1242 1243
 	} else if errinfor == nil {
1243 1244
 		infor := models.DeviceInformation{
1244
-			Date:                startdate,
1245
-			Class:               classtype,
1246
-			Zone:                zone,
1247
-			BedNumber:           bednumber,
1248
-			PatientId:           patient_time,
1249
-			Contagion:           contagion,
1250
-			DialysisMode:        dialysis_mode,
1251
-			StartTime:           startDate.Unix(),
1252
-			EndTime:             endDate.Unix(),
1253
-			DialysisHour:        dialysis_time,
1254
-			Hyperfiltratio:      hyperfiletration,
1255
-			WeightLoss:          weight_loss,
1256
-			WarningValue:        warining_value,
1257
-			UserTotal:           user_total,
1258
-			Move:                run,
1259
-			FailureStage:        failure_stage,
1260
-			FaultDescription:    falult_desciription,
1261
-			CodeInformation:     code_information,
1262
-			DisinfectantType:    disinfectant_type,
1263
-			DisinfectType:       disinfect_type,
1264
-			Disinfection:        disinfection,
1265
-			MachineRun:          machine_run,
1266
-			FluidPath:           fluid_path,
1267
-			Disinfectant:        disinfectant,
1268
-			DisinfectionStatus:  disinfection_status,
1269
-			DisinfectionResidue: disinfection_residue,
1270
-			LongTime:            longtime,
1271
-			DisinfecStartime:    start_Date.Unix(),
1272
-			DisinfecEndtime:     end_Date.Unix(),
1273
-			DialysisChecked:     dialysis_checked,
1274
-			DialysisName:        dialysis_name,
1275
-			Norms:               norms,
1245
+			Date:                  startdate,
1246
+			Class:                 classtype,
1247
+			Zone:                  zone,
1248
+			BedNumber:             bednumber,
1249
+			PatientId:             patient_time,
1250
+			Contagion:             contagion,
1251
+			DialysisMode:          dialysis_mode,
1252
+			StartTime:             startDate.Unix(),
1253
+			EndTime:               endDate.Unix(),
1254
+			DialysisHour:          dialysis_time,
1255
+			Hyperfiltratio:        hyperfiletration,
1256
+			WeightLoss:            weight_loss,
1257
+			WarningValue:          warining_value,
1258
+			UserTotal:             user_total,
1259
+			Move:                  run,
1260
+			FailureStage:          failure_stage,
1261
+			FaultDescription:      falult_desciription,
1262
+			CodeInformation:       code_information,
1263
+			DisinfectantType:      disinfectant_type,
1264
+			DisinfectType:         disinfect_type,
1265
+			Disinfection:          disinfection,
1266
+			MachineRun:            machine_run,
1267
+			FluidPath:             fluid_path,
1268
+			Disinfectant:          disinfectant,
1269
+			DisinfectionStatus:    disinfection_status,
1270
+			DisinfectionResidue:   disinfection_residue,
1271
+			LongTime:              longtime,
1272
+			DisinfecStartime:      start_Date.Unix(),
1273
+			DisinfecEndtime:       end_Date.Unix(),
1274
+			DialysisChecked:       dialysis_checked,
1275
+			DialysisName:          dialysis_name,
1276
+			Norms:                 norms,
1276 1277
 			DialysisConcentration: dialysis_concentration,
1277 1278
 			GermChecked:           germ_checked,
1278 1279
 			GermName:              germ_name,
@@ -2488,37 +2489,37 @@ func (this *MachineApiController) UpdateForm() {
2488 2489
 	err = service.UpdatedZoneID(bednumber, orgid, &deviceNumber)
2489 2490
 	fmt.Println("更新区号失败", err)
2490 2491
 	information := models.DeviceInformation{
2491
-		Date:                startdate,
2492
-		Class:               classtype,
2493
-		Zone:                zone,
2494
-		BedNumber:           bednumber,
2495
-		Contagion:           contagion,
2496
-		DialysisMode:        dialysis_mode,
2497
-		StartTime:           startDate.Unix(),
2498
-		EndTime:             endDate.Unix(),
2499
-		DialysisHour:        dialysis_time,
2500
-		Hyperfiltratio:      hyperfiletration,
2501
-		WeightLoss:          weight_loss,
2502
-		WarningValue:        warining_value,
2503
-		UserTotal:           user_total,
2504
-		Move:                run,
2505
-		FailureStage:        failure_stage,
2506
-		FaultDescription:    falult_desciription,
2507
-		CodeInformation:     code_information,
2508
-		DisinfectantType:    disinfectant_type,
2509
-		DisinfectType:       disinfect_type,
2510
-		Disinfection:        disinfection,
2511
-		MachineRun:          machine_run,
2512
-		FluidPath:           fluid_path,
2513
-		Disinfectant:        disinfectant,
2514
-		DisinfectionStatus:  disinfection_status,
2515
-		DisinfectionResidue: disinfection_residue,
2516
-		LongTime:            longtime,
2517
-		DisinfecStartime:    distartime,
2518
-		DisinfecEndtime:     diendtime,
2519
-		DialysisChecked:     dialysis_checked,
2520
-		DialysisName:        dialysis_name,
2521
-		Norms:               norms,
2492
+		Date:                  startdate,
2493
+		Class:                 classtype,
2494
+		Zone:                  zone,
2495
+		BedNumber:             bednumber,
2496
+		Contagion:             contagion,
2497
+		DialysisMode:          dialysis_mode,
2498
+		StartTime:             startDate.Unix(),
2499
+		EndTime:               endDate.Unix(),
2500
+		DialysisHour:          dialysis_time,
2501
+		Hyperfiltratio:        hyperfiletration,
2502
+		WeightLoss:            weight_loss,
2503
+		WarningValue:          warining_value,
2504
+		UserTotal:             user_total,
2505
+		Move:                  run,
2506
+		FailureStage:          failure_stage,
2507
+		FaultDescription:      falult_desciription,
2508
+		CodeInformation:       code_information,
2509
+		DisinfectantType:      disinfectant_type,
2510
+		DisinfectType:         disinfect_type,
2511
+		Disinfection:          disinfection,
2512
+		MachineRun:            machine_run,
2513
+		FluidPath:             fluid_path,
2514
+		Disinfectant:          disinfectant,
2515
+		DisinfectionStatus:    disinfection_status,
2516
+		DisinfectionResidue:   disinfection_residue,
2517
+		LongTime:              longtime,
2518
+		DisinfecStartime:      distartime,
2519
+		DisinfecEndtime:       diendtime,
2520
+		DialysisChecked:       dialysis_checked,
2521
+		DialysisName:          dialysis_name,
2522
+		Norms:                 norms,
2522 2523
 		DialysisConcentration: dialysis_concentration,
2523 2524
 		GermChecked:           germ_checked,
2524 2525
 		GermName:              germ_name,

+ 55 - 2
controllers/manager_center_api_controller.go View File

@@ -78,6 +78,8 @@ func ManagerCenterRegistRouters() {
78 78
 	beego.Router("/api/diagnose/list", &ManagerCenterApiController{}, "get:GetDiagnoseList")
79 79
 	beego.Router("/api/diagnose/delete", &ManagerCenterApiController{}, "post:DeleteDiagnose")
80 80
 	beego.Router("/api/diagnose/get", &ManagerCenterApiController{}, "get:GetDiagnose")
81
+	beego.Router("/api/drug/getalldruglist", &ManagerCenterApiController{}, "get:GetAllDrugList")
82
+	beego.Router("/api/drug/postsearchdruglist", &ManagerCenterApiController{}, "get:GetSearchDrugList")
81 83
 
82 84
 }
83 85
 
@@ -134,6 +136,11 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
134 136
 	loc, _ := time.LoadLocation("Local")
135 137
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
136 138
 	drug_remark := c.GetString("drug_remark")
139
+	dosage := c.GetString("dosage")
140
+	unval := c.GetString("unval")
141
+	packing_unit := c.GetString("packing_unit")
142
+	packing_price, _ := c.GetFloat("packing_price")
143
+	drug_day := c.GetString("drug_day")
137 144
 	//hosp_appr_flag
138 145
 	hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
139 146
 	lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
@@ -192,6 +199,11 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
192 199
 		SocialSecurityDirectoryCode: social_security_directory_code,
193 200
 		RecordDate:                  theTime.Unix(),
194 201
 		DrugRemark:                  drug_remark,
202
+		Dosage:                      dosage,
203
+		Unval:                       unval,
204
+		PackingUnit:                 packing_unit,
205
+		PackingPrice:                packing_price,
206
+		DrugDay:                     drug_day,
195 207
 		HospApprFlag:                hosp_appr_flag,
196 208
 		LmtUsedFlag:                 lmt_used_flag,
197 209
 	}
@@ -201,7 +213,7 @@ func (c *ManagerCenterApiController) CreateBaseDrugLib() {
201 213
 	drug_code = "54000000" + drug_code
202 214
 	drugLib.DrugCode = drug_code
203 215
 
204
-	count := service.FindBaseDrugLibRecordCount(drugLib)
216
+	count := service.FindBaseDrugLibRecordCountOne(drugLib)
205 217
 
206 218
 	if count == 0 {
207 219
 		err := service.CreateBaseDrugLib(drugLib)
@@ -278,6 +290,11 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
278 290
 	loc, _ := time.LoadLocation("Local")
279 291
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
280 292
 	drug_remark := c.GetString("drug_remark")
293
+	dosage := c.GetString("dosage")
294
+	unval := c.GetString("unval")
295
+	packing_unit := c.GetString("packing_unit")
296
+	packing_price, _ := c.GetFloat("packing_price")
297
+	drug_day := c.GetString("drug_day")
281 298
 	hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
282 299
 	lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
283 300
 	adminInfo := c.GetAdminUserInfo()
@@ -338,6 +355,11 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
338 355
 		SocialSecurityDirectoryCode: social_security_directory_code,
339 356
 		RecordDate:                  theTime.Unix(),
340 357
 		DrugRemark:                  drug_remark,
358
+		Dosage:                      dosage,
359
+		Unval:                       unval,
360
+		PackingPrice:                packing_price,
361
+		PackingUnit:                 packing_unit,
362
+		DrugDay:                     drug_day,
341 363
 		HospApprFlag:                hosp_appr_flag,
342 364
 		LmtUsedFlag:                 lmt_used_flag,
343 365
 	}
@@ -362,7 +384,7 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
362 384
 	//查询是否存在
363 385
 	_, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
364 386
 	if errTwo == gorm.ErrRecordNotFound {
365
-		fmt.Println("进来了吗1")
387
+
366 388
 		c.ServeSuccessJSON(map[string]interface{}{
367 389
 			"msg": "修改成功",
368 390
 		})
@@ -2136,3 +2158,34 @@ func (c *ManagerCenterApiController) GetDiagnose() {
2136 2158
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2137 2159
 	}
2138 2160
 }
2161
+
2162
+func (c *ManagerCenterApiController) GetAllDrugList() {
2163
+
2164
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2165
+
2166
+	list, err := service.GetAllDrugList(orgId)
2167
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2168
+	if err == nil {
2169
+		c.ServeSuccessJSON(map[string]interface{}{
2170
+			"list":             list,
2171
+			"manufacturerList": manufacturerList,
2172
+		})
2173
+	} else {
2174
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2175
+	}
2176
+}
2177
+
2178
+func (c *ManagerCenterApiController) GetSearchDrugList() {
2179
+	keyword := c.GetString("keyword")
2180
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2181
+	list, err := service.GetSearchDrugList(keyword, orgId)
2182
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2183
+	if err == nil {
2184
+		c.ServeSuccessJSON(map[string]interface{}{
2185
+			"list":             list,
2186
+			"manufacturerList": manufacturerList,
2187
+		})
2188
+	} else {
2189
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
2190
+	}
2191
+}

+ 71 - 7
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -694,6 +694,7 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
694 694
 	psychological_other := c.GetString("psychological_other")
695 695
 
696 696
 	admission_number := c.GetString("admission_number")
697
+	tumble, _ := c.GetInt64("tumble")
697 698
 
698 699
 	if id <= 0 {
699 700
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -747,6 +748,7 @@ func (c *DialysisAPIController) PostAcceptsAssessment() {
747 748
 		PrecautionOther:              precaution_other,
748 749
 		PsychologicalOther:           psychological_other,
749 750
 		AdmissionNumber:              admission_number,
751
+		Tumble:                       tumble,
750 752
 	}
751 753
 
752 754
 	if receiveTreatment.ID == 0 { //新增
@@ -853,6 +855,13 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
853 855
 	diastolic_pressure := c.GetString("diastolic_pressure")
854 856
 	other_complication := c.GetString("other_complication")
855 857
 	ktv := c.GetString("ktv")
858
+	urr := c.GetString("urr")
859
+	hypertenison, _ := c.GetInt64("hypertenison")
860
+	hypopiesia, _ := c.GetInt64("hypopiesia")
861
+	leave_office_method, _ := c.GetInt64("leave_office_method")
862
+	lapse, _ := c.GetInt64("lapse")
863
+	consciousness, _ := c.GetInt64("consciousness")
864
+	fallrisk, _ := c.GetInt64("fallrisk")
856 865
 	if id <= 0 {
857 866
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
858 867
 		return
@@ -946,6 +955,13 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
946 955
 		DiastolicPressure:            diastolic_pressure,
947 956
 		OtherComplication:            other_complication,
948 957
 		Ktv:                          ktv,
958
+		Urr:                          urr,
959
+		Hypopiesia:                   hypopiesia,
960
+		Hypertenison:                 hypertenison,
961
+		Lapse:                        lapse,
962
+		LeaveOfficeMethod:            leave_office_method,
963
+		Consciousness:                consciousness,
964
+		Fallrisk:                     fallrisk,
949 965
 	}
950 966
 
951 967
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
@@ -1084,6 +1100,13 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1084 1100
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
1085 1101
 	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
1086 1102
 	displace_speed := c.GetString("displace_speed")
1103
+	illness, _ := c.GetInt64("illness")
1104
+	amylaceum := c.GetString("amylaceum")
1105
+	single_time := c.GetString("single_time")
1106
+	single_water := c.GetString("single_water")
1107
+	replacement_flow := c.GetString("replacement_flow")
1108
+	plasma_separator := c.GetString("plasma_separator")
1109
+	bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
1087 1110
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
1088 1111
 	//template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
1089 1112
 	//
@@ -1171,6 +1194,13 @@ func (c *DialysisAPIController) PostDialysisPrescription() {
1171 1194
 		DialysisIrrigation:         dialysis_irrigation,
1172 1195
 		AntioxidantCommodityName:   antioxidant_commodity_name,
1173 1196
 		DisplaceSpeed:              displace_speed,
1197
+		Illness:                    illness,
1198
+		Amylaceum:                  amylaceum,
1199
+		SingleTime:                 single_time,
1200
+		SingleWater:                single_water,
1201
+		ReplacementFlow:            replacement_flow,
1202
+		PlasmaSeparator:            plasma_separator,
1203
+		BilirubinAdsorptionColumn:  bilirubin_adsorption_column,
1174 1204
 	}
1175 1205
 
1176 1206
 	//查询最近透析准备表里是否存在 透析器 灌流器
@@ -1794,14 +1824,23 @@ func (this *DialysisAPIController) StartDialysis() {
1794 1824
 
1795 1825
 	var ultrafiltration_rate float64
1796 1826
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
1827
+	//后期预增脱水量
1828
+	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
1829
+	fmt.Println(evaluation)
1797 1830
 	if prescription.ID > 0 {
1798 1831
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
1799 1832
 
1800 1833
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
1801
-			if template.TemplateId == 6 || template.TemplateId == 32 { //adminUserInfo.Org.Id == 9538
1834
+			if (template.TemplateId == 6 || template.TemplateId == 32) && adminUserInfo.Org.Id != 9671 { //adminUserInfo.Org.Id == 9538
1802 1835
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
1803 1836
 			}
1804 1837
 
1838
+			//针对医师汇
1839
+			if template.TemplateId == 6 && adminUserInfo.Org.Id == 9671 {
1840
+				dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
1841
+				ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
1842
+			}
1843
+
1805 1844
 			if template.TemplateId == 20 || template.TemplateId == 22 { //adminUserInfo.Org.Id == 9538
1806 1845
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
1807 1846
 			}
@@ -1964,6 +2003,13 @@ func (c *DialysisAPIController) PostSolution() {
1964 2003
 	dialysis_irrigation := c.GetString("dialysis_irrigation")
1965 2004
 	antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
1966 2005
 	displace_speed := c.GetString("displace_speed")
2006
+	illness, _ := c.GetInt64("illness")
2007
+	amylaceum := c.GetString("amylaceum")
2008
+	single_time := c.GetString("single_time")
2009
+	single_water := c.GetString("single_water")
2010
+	replacement_flow := c.GetString("replacement_flow")
2011
+	plasma_separator := c.GetString("plasma_separator")
2012
+	bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
1967 2013
 	if mode_id > 0 {
1968 2014
 		service.ModifyScheduleMode(mode_id, patient.ID, recordDate.Unix(), adminUserInfo.Org.Id)
1969 2015
 	}
@@ -2052,6 +2098,13 @@ func (c *DialysisAPIController) PostSolution() {
2052 2098
 		DialysisIrrigation:        dialysis_irrigation,
2053 2099
 		AntioxidantCommodityName:  antioxidant_commodity_name,
2054 2100
 		DisplaceSpeed:             displace_speed,
2101
+		Illness:                   illness,
2102
+		Amylaceum:                 amylaceum,
2103
+		SingleWater:               single_water,
2104
+		SingleTime:                single_time,
2105
+		ReplacementFlow:           replacement_flow,
2106
+		PlasmaSeparator:           plasma_separator,
2107
+		BilirubinAdsorptionColumn: bilirubin_adsorption_column,
2055 2108
 	}
2056 2109
 
2057 2110
 	_, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, recordDate.Unix(), adminUserInfo.Org.Id)
@@ -2265,6 +2318,7 @@ func (this *DialysisAPIController) GetLastMonitorRecord() {
2265 2318
 }
2266 2319
 
2267 2320
 func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2321
+
2268 2322
 	thisTime := time.Now()
2269 2323
 	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
2270 2324
 	timeLayout := "2006-01-02 15:04:05"
@@ -2282,16 +2336,23 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2282 2336
 
2283 2337
 	var ultrafiltration_rate float64
2284 2338
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, theAssessmentDateTime, adminInfo.Org.Id)
2339
+
2340
+	_, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, theAssessmentDateTime, adminInfo.Org.Id)
2341
+	fmt.Println(evaluation)
2285 2342
 	if prescription.ID > 0 {
2286 2343
 
2287 2344
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
2288 2345
 
2289 2346
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
2290
-			if template.TemplateId == 6 {
2291
-
2347
+			if template.TemplateId == 6 && adminInfo.Org.Id != 9538 {
2292 2348
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
2293 2349
 				record.UltrafiltrationRate = ultrafiltration_rate
2294 2350
 			}
2351
+			//if template.TemplateId == 6 && adminInfo.Org.Id ==9671{
2352
+			//  dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
2353
+			//  ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
2354
+			//  record.UltrafiltrationRate = ultrafiltration_rate
2355
+			//}
2295 2356
 
2296 2357
 			if template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 36 {
2297 2358
 
@@ -2313,7 +2374,9 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2313 2374
 		}
2314 2375
 	}
2315 2376
 	// record.UltrafiltrationRate = ultrafiltration_rate
2377
+
2316 2378
 	record.UltrafiltrationVolume = 0
2379
+
2317 2380
 	if template.TemplateId == 1 && adminInfo.Org.Id != 9849 { //adminInfo.Org.Id == 3907 || adminInfo.Org.Id == 4 || adminInfo.Org.Id == 12 || adminInfo.Org.Id == 13 || adminInfo.Org.Id == 9535adminInfo.Org.Id == 3907 || adminInfo.Org.Id == 4 || adminInfo.Org.Id == 12 || adminInfo.Org.Id == 13 || adminInfo.Org.Id == 9535
2318 2381
 		if ultrafiltration_rate > 0 {
2319 2382
 			value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", float64(record.OperateTime+3600-fristrecord.OperateTime)/3600*ultrafiltration_rate), 6)
@@ -2325,6 +2388,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
2325 2388
 		if ultrafiltration_rate > 0 && adminInfo.Org.Id != 9538 {
2326 2389
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
2327 2390
 			record.UltrafiltrationVolume = ultrafiltration_volume
2391
+
2328 2392
 		}
2329 2393
 	}
2330 2394
 
@@ -3561,7 +3625,7 @@ func (c *DialysisAPIController) EditConsumables() {
3561 3625
 		if dataBody["goods"] != nil && reflect.TypeOf(dataBody["goods"]).String() == "[]interface {}" {
3562 3626
 
3563 3627
 			goods, _ := dataBody["goods"].([]interface{})
3564
-			fmt.Println("goods2222222222222", goods)
3628
+
3565 3629
 			if len(goods) > 0 {
3566 3630
 				for _, item := range goods {
3567 3631
 					items := item.(map[string]interface{})
@@ -3645,7 +3709,7 @@ func (c *DialysisAPIController) EditConsumables() {
3645 3709
 				}
3646 3710
 			}
3647 3711
 		}
3648
-		fmt.Println("hhhhhhhhhhhhhhhhhhhh", beforePrepares)
3712
+
3649 3713
 		//查询今日患者出库列表
3650 3714
 		consumables_source, _ := service.FindConsumablesByDate(adminInfo.Org.Id, patient_id, record_time)
3651 3715
 
@@ -3705,7 +3769,7 @@ func (c *DialysisAPIController) EditConsumables() {
3705 3769
 
3706 3770
 		//查询是否有出库单
3707 3771
 		out, err := service.FindStockOutByIsSys(adminInfo.Org.Id, 1, record_time)
3708
-		fmt.Println("是否有出库单22222222222222222222222", err)
3772
+
3709 3773
 		if err == gorm.ErrRecordNotFound {
3710 3774
 			//没有记录,则创建出库单
3711 3775
 			timeStr := time.Now().Format("2006-01-02")
@@ -3854,7 +3918,7 @@ func (c *DialysisAPIController) EditConsumables() {
3854 3918
 							}
3855 3919
 							service.AddSigleAutoReduceRecordInfo(details)
3856 3920
 						} else if count == 1 {
3857
-							fmt.Println("llllllllllllllllllllll")
3921
+
3858 3922
 							service.UpdateUserInfoDetails(item.GoodTypeId, item.GoodId, record_time, adminInfo.Org.Id, patient_id, item.Count, &outInfo)
3859 3923
 						}
3860 3924
 						//details := &models.AutomaticReduceDetail{

+ 47 - 39
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

@@ -80,7 +80,7 @@ func (this *DialysisAPIController) AddMonitorRecord() {
80 80
 	replacementRate, _ := this.GetFloat("replacement_rate")
81 81
 	displacementQuantity, _ := this.GetFloat("displacement_quantity")
82 82
 	ktv, _ := this.GetFloat("ktv")
83
-	fmt.Println("ktv -------------------", ktv)
83
+
84 84
 	symptom := this.GetString("symptom")
85 85
 	dispose := this.GetString("dispose")
86 86
 	conductivity, _ := this.GetFloat("conductivity")
@@ -94,6 +94,8 @@ func (this *DialysisAPIController) AddMonitorRecord() {
94 94
 	blood_sugar, _ := this.GetFloat("blood_sugar")
95 95
 	monitor_anticoagulant, _ := this.GetInt64("monitor_anticoagulant")
96 96
 	monitor_anticoagulant_value := this.GetString("monitor_anticoagulant_value")
97
+	blood_pressure_monitoring_site, _ := this.GetInt64("blood_pressure_monitoring_site")
98
+	complication, _ := this.GetInt64("complication")
97 99
 	adminInfo := this.GetMobileAdminUserInfo()
98 100
 	patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
99 101
 	if getPatientErr != nil {
@@ -112,44 +114,46 @@ func (this *DialysisAPIController) AddMonitorRecord() {
112 114
 		MonitoringDate:  date,
113 115
 		OperateTime:     operateTime,
114 116
 		// MonitoringTime:            recordTime,
115
-		PulseFrequency:            pulseFrequency,
116
-		BreathingRate:             breathingRated,
117
-		SystolicBloodPressure:     systolicBP,
118
-		DiastolicBloodPressure:    diastolicBP,
119
-		BloodPressureType:         int64(BPType),
120
-		BloodFlowVolume:           bloodFlowVolume,
121
-		VenousPressure:            venousPressure,
122
-		VenousPressureType:        venousPressureType,
123
-		ArterialPressure:          arterialPressure,
124
-		ArterialPressureType:      arterialPressureType,
125
-		TransmembranePressure:     transmembranePressure,
126
-		TransmembranePressureType: transmembranePressureType,
127
-		UltrafiltrationRate:       ultrafiltrationRate,
128
-		UltrafiltrationVolume:     ultrafiltrationVolume,
129
-		SodiumConcentration:       sodiumConcentration,
130
-		DialysateTemperature:      dialysateTemperature,
131
-		Temperature:               temperature,
132
-		ReplacementRate:           replacementRate,
133
-		DisplacementQuantity:      displacementQuantity,
134
-		Ktv:                       ktv,
135
-		Symptom:                   symptom,
136
-		Dispose:                   dispose,
137
-		Result:                    result,
138
-		MonitoringNurse:           monitoringNurse,
139
-		Status:                    1,
140
-		CreatedTime:               time.Now().Unix(),
141
-		UpdatedTime:               time.Now().Unix(),
142
-		Conductivity:              conductivity,
143
-		DisplacementFlowQuantity:  displacement_flow_quantity,
144
-		BloodOxygenSaturation:     blood_oxygen_saturation,
145
-		Creator:                   adminInfo.AdminUser.Id,
146
-		Modify:                    0,
147
-		Heparin:                   heparin,
148
-		DialysateFlow:             dialysate_flow,
149
-		Urr:                       urr,
150
-		BloodSugar:                blood_sugar,
151
-		MonitorAnticoagulant:      monitor_anticoagulant,
152
-		MonitorAnticoagulantValue: monitor_anticoagulant_value,
117
+		PulseFrequency:              pulseFrequency,
118
+		BreathingRate:               breathingRated,
119
+		SystolicBloodPressure:       systolicBP,
120
+		DiastolicBloodPressure:      diastolicBP,
121
+		BloodPressureType:           int64(BPType),
122
+		BloodFlowVolume:             bloodFlowVolume,
123
+		VenousPressure:              venousPressure,
124
+		VenousPressureType:          venousPressureType,
125
+		ArterialPressure:            arterialPressure,
126
+		ArterialPressureType:        arterialPressureType,
127
+		TransmembranePressure:       transmembranePressure,
128
+		TransmembranePressureType:   transmembranePressureType,
129
+		UltrafiltrationRate:         ultrafiltrationRate,
130
+		UltrafiltrationVolume:       ultrafiltrationVolume,
131
+		SodiumConcentration:         sodiumConcentration,
132
+		DialysateTemperature:        dialysateTemperature,
133
+		Temperature:                 temperature,
134
+		ReplacementRate:             replacementRate,
135
+		DisplacementQuantity:        displacementQuantity,
136
+		Ktv:                         ktv,
137
+		Symptom:                     symptom,
138
+		Dispose:                     dispose,
139
+		Result:                      result,
140
+		MonitoringNurse:             monitoringNurse,
141
+		Status:                      1,
142
+		CreatedTime:                 time.Now().Unix(),
143
+		UpdatedTime:                 time.Now().Unix(),
144
+		Conductivity:                conductivity,
145
+		DisplacementFlowQuantity:    displacement_flow_quantity,
146
+		BloodOxygenSaturation:       blood_oxygen_saturation,
147
+		Creator:                     adminInfo.AdminUser.Id,
148
+		Modify:                      0,
149
+		Heparin:                     heparin,
150
+		DialysateFlow:               dialysate_flow,
151
+		Urr:                         urr,
152
+		BloodSugar:                  blood_sugar,
153
+		MonitorAnticoagulant:        monitor_anticoagulant,
154
+		MonitorAnticoagulantValue:   monitor_anticoagulant_value,
155
+		BloodPressureMonitoringSite: blood_pressure_monitoring_site,
156
+		Complication:                complication,
153 157
 	}
154 158
 
155 159
 	err := service.CreateMonitor(&record)
@@ -246,6 +250,8 @@ func (this *DialysisAPIController) EditMonitorRecord() {
246 250
 	adminInfo := this.GetMobileAdminUserInfo()
247 251
 	monitor_anticoagulant, _ := this.GetInt64("monitor_anticoagulant")
248 252
 	monitor_anticoagulant_value := this.GetString("monitor_anticoagulant_value")
253
+	blood_pressure_monitoring_site, _ := this.GetInt64("blood_pressure_monitoring_site")
254
+	complication, _ := this.GetInt64("complication")
249 255
 	monitor, err := service.GetMonitor(adminInfo.Org.Id, patientID, id)
250 256
 	if err != nil {
251 257
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -295,6 +301,8 @@ func (this *DialysisAPIController) EditMonitorRecord() {
295 301
 	monitor.BloodSugar = blood_sugar
296 302
 	monitor.MonitorAnticoagulant = monitor_anticoagulant
297 303
 	monitor.MonitorAnticoagulantValue = monitor_anticoagulant_value
304
+	monitor.BloodPressureMonitoringSite = blood_pressure_monitoring_site
305
+	monitor.Complication = complication
298 306
 	err = service.UpdateMonitor(monitor)
299 307
 	if err != nil {
300 308
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)

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

@@ -41,7 +41,7 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
41 41
 	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id, delivery_way)
42 42
 	//获取his医嘱数据
43 43
 	fmt.Println("date.un222222", date.Unix())
44
-	hisAdvices, _ := service.GetHisDoctorAdvices(orgID, date.Unix(), delivery_way)
44
+	hisAdvices, _ := service.GetHisDoctorAdvices(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)
45 45
 	config, _ := service.GetHisDoctorConfig(orgID)
46 46
 	adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
47 47
 	if err != nil {

+ 21 - 0
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -2402,6 +2402,27 @@ func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, dat
2402 2402
 		thromubus_v := dataBody["thromubus_v"].(string)
2403 2403
 		evaluation.ThromubusV = thromubus_v
2404 2404
 	}
2405
+
2406
+	if dataBody["dehydration"] != nil && reflect.TypeOf(dataBody["dehydration"]).String() == "string" {
2407
+		dehydration := dataBody["dehydration"].(string)
2408
+		evaluation.Dehydration = dehydration
2409
+	}
2410
+
2411
+	if dataBody["period"] != nil && reflect.TypeOf(dataBody["period"]).String() == "float64" {
2412
+		period := int64(dataBody["period"].(float64))
2413
+		evaluation.Period = period
2414
+	}
2415
+
2416
+	if dataBody["estimated_food_intake"] != nil && reflect.TypeOf(dataBody["estimated_food_intake"]).String() == "string" {
2417
+		estimated_food_intake := dataBody["estimated_food_intake"].(string)
2418
+		evaluation.EstimatedFoodIntake = estimated_food_intake
2419
+	}
2420
+
2421
+	if dataBody["blood_pressure_during_dialysis"] != nil && reflect.TypeOf(dataBody["blood_pressure_during_dialysis"]).String() == "string" {
2422
+		blood_pressure_during_dialysis := dataBody["blood_pressure_during_dialysis"].(string)
2423
+		evaluation.BloodPressureDuringDialysis = blood_pressure_during_dialysis
2424
+	}
2425
+
2405 2426
 	return
2406 2427
 }
2407 2428
 

+ 45 - 24
controllers/new_mobile_api_controllers/common_api_controller.go View File

@@ -220,7 +220,7 @@ func (this *CommonApiController) GetConfigurationDetail() {
220 220
 		}
221 221
 		this.ServeSuccessJSON(map[string]interface{}{
222 222
 			"configurationdetail": detail,
223
-			"vid": vid,
223
+			"vid":                 vid,
224 224
 		})
225 225
 	} else {
226 226
 		itemId, err := service.GetIdByItemId(detail.InspectionMinor, orgId)
@@ -230,7 +230,7 @@ func (this *CommonApiController) GetConfigurationDetail() {
230 230
 		}
231 231
 		this.ServeSuccessJSON(map[string]interface{}{
232 232
 			"configurationdetail": detail,
233
-			"vid": itemId.ID,
233
+			"vid":                 itemId.ID,
234 234
 		})
235 235
 	}
236 236
 
@@ -513,19 +513,23 @@ func (this *CommonApiController) GetDialysisModeType() {
513 513
 	loc, _ := time.LoadLocation("Local")
514 514
 	startime := this.GetString("startime")
515 515
 	endtime := this.GetString("endtime")
516
-	//fmt.Println("endtime", endtime)
516
+
517 517
 	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
518 518
 	startimes := startTimes.Unix()
519
-	// fmt.Println("startime",startimes)
519
+
520 520
 	endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
521 521
 	endtimeData := endtimes.Unix()
522
-	// fmt.Println("结束日期",endtimeData)
522
+
523
+	lapsetotype, _ := this.GetInt64("lapsetotype")
524
+	sourcetype, _ := this.GetInt64("sourcetype")
525
+
523 526
 	adminUser := this.GetAdminUserInfo()
524 527
 	orgid := adminUser.CurrentOrgId
525 528
 	//统计透析总量
526
-	_, total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid)
527
-
528
-	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid)
529
+	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
530
+	fmt.Println("total3333333333333", total)
531
+	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
532
+	fmt.Println("modetype555555555555555", modeType)
529 533
 	if err != nil {
530 534
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
531 535
 		return
@@ -547,19 +551,21 @@ func (this *CommonApiController) GetTotalLapseCount() {
547 551
 	endtime := this.GetString("endtime")
548 552
 	endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
549 553
 	endunix := endtimes.Unix()
550
-
554
+	lapsetotype, _ := this.GetInt64("lapsetotype")
555
+	sourcetype, _ := this.GetInt64("sourcetype")
551 556
 	//统计该机构的转出人数
552
-	patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix)
557
+	patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix, lapsetotype, sourcetype)
558
+
553 559
 	//统计该机构转出病人
554
-	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix)
555
-	count := service.GetPatientTotalCount(orgid)
560
+	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix, lapsetotype, sourcetype)
561
+	count := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
556 562
 	if err != nil {
557 563
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
558 564
 		return
559 565
 	}
560 566
 
561 567
 	//统计当前机构转出的人数
562
-	rollout, err := service.GetCountRollout(orgid, startnunix, endunix)
568
+	rollout, err := service.GetCountRollout(orgid, startnunix, endunix, lapsetotype, sourcetype)
563 569
 	this.ServeSuccessJSON(map[string]interface{}{
564 570
 		"patients":   patients,
565 571
 		"count":      count,
@@ -576,17 +582,22 @@ func (this *CommonApiController) GetTotalSexCount() {
576 582
 	fmt.Println("开始时间", startime)
577 583
 	endtime, _ := this.GetInt64("endtime")
578 584
 	fmt.Println("结束时间", endtime)
579
-	total := service.GetPatientTotalCount(orgid)
585
+	lapsetotype, _ := this.GetInt64("lapsetotype")
586
+	sourcetype, _ := this.GetInt64("sourcetype")
587
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
588
+
589
+	_, totalSex, err := service.GetManPatientTotal(orgid, lapsetotype, sourcetype)
580 590
 
581
-	_, totalSex, err := service.GetManPatientTotal(orgid)
591
+	_, totalWoman, err := service.GetWoManPatientTotal(orgid, lapsetotype, sourcetype)
582 592
 
583 593
 	if err != nil {
584 594
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
585 595
 		return
586 596
 	}
587 597
 	this.ServeSuccessJSON(map[string]interface{}{
588
-		"total":    total,
589
-		"totalSex": totalSex,
598
+		"total":      total,
599
+		"totalSex":   totalSex,
600
+		"totalWoman": totalWoman,
590 601
 	})
591 602
 }
592 603
 
@@ -602,10 +613,13 @@ func (this *CommonApiController) GetTotalInfectiouscount() {
602 613
 	endtime := this.GetString("endtime")
603 614
 	endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
604 615
 	endunix := endtimes.Unix()
616
+	lapsetotype, _ := this.GetInt64("lapsetotype")
617
+	sourcetype, _ := this.GetInt64("sourcetype")
618
+
605 619
 	//统计透析总人数
606
-	total := service.GetPatientTotalCount(orgid)
620
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
607 621
 	//统计透析人数传染病所占比例
608
-	count, err := service.GetPatientInfectiousCount(orgid, startnunix, endunix)
622
+	count, err := service.GetPatientInfectiousCount(orgid, startnunix, endunix, lapsetotype, sourcetype)
609 623
 	//统计其他
610 624
 	_, otherTotal, err := service.GetPatientOtherInfectious(orgid)
611 625
 	if err != nil {
@@ -627,9 +641,12 @@ func (this *CommonApiController) GetTotalAgeCount() {
627 641
 	fmt.Println("开始时间", startime)
628 642
 	endtime, _ := this.GetInt64("endtime")
629 643
 	fmt.Println("结束时间", endtime)
644
+	lapsetotype, _ := this.GetInt64("lapsetotype")
645
+	sourcetype, _ := this.GetInt64("sourcetype")
630 646
 	//统计透析总人数
631
-	total := service.GetPatientTotalCount(orgid)
632
-	agecount, err := service.GetTotalAgeCount(orgid)
647
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
648
+	agecount, err := service.GetTotalAgeCount(orgid, lapsetotype, sourcetype)
649
+	fmt.Println("ageCount22222222222", agecount)
633 650
 	//two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
634 651
 	if err != nil {
635 652
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -653,15 +670,17 @@ func (this *CommonApiController) GetTotalDialysisCount() {
653 670
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
654 671
 	fmt.Println("parseDateErr", parseDateErr)
655 672
 	nowtime := recordDate.Unix()
673
+	lapsetotype, _ := this.GetInt64("lapsetotype")
674
+	sourcetype, _ := this.GetInt64("sourcetype")
656 675
 	//统计透析总人数
657
-	total := service.GetPatientTotalCount(orgid)
676
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
658 677
 	fmt.Println("total", total)
659 678
 	//获取该机构下的所有病人数据
660 679
 	patients, err := service.GetTotalDialysisAgeCount(orgid)
661 680
 	fmt.Println("patients", patients)
662 681
 
663 682
 	//统计透年龄
664
-	dataage, _ := service.GetDialysisAgeData(orgid)
683
+	dataage, _ := service.GetDialysisAgeData(orgid, lapsetotype, sourcetype)
665 684
 	if err != nil {
666 685
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
667 686
 		return
@@ -2104,11 +2123,13 @@ func (this *CommonApiController) GetRolloutCount() {
2104 2123
 
2105 2124
 	start_time, _ := this.GetInt64("start_time")
2106 2125
 	end_time, _ := this.GetInt64("end_time")
2126
+	lapsetotype, _ := this.GetInt64("lapsetotype")
2127
+	sourcetype, _ := this.GetInt64("sourcetype")
2107 2128
 	adminUserInfo := this.GetAdminUserInfo()
2108 2129
 	orgId := adminUserInfo.CurrentOrgId
2109 2130
 
2110 2131
 	//统计当前机构转出的人数
2111
-	rollout, err := service.GetCountRollout(orgId, start_time, end_time)
2132
+	rollout, err := service.GetCountRollout(orgId, start_time, end_time, lapsetotype, sourcetype)
2112 2133
 
2113 2134
 	if err != nil {
2114 2135
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 4 - 2
controllers/new_mobile_api_controllers/good_types.json View File

@@ -28,7 +28,8 @@
28 28
       "status": 1,
29 29
       "type": 1,
30 30
       "number": 2,
31
-      "out_stock": 1
31
+      "out_stock": 1,
32
+      "stock_attribute": 2,
32 33
     },
33 34
     {
34 35
       "id": 10002,
@@ -43,7 +44,8 @@
43 44
       "status": 1,
44 45
       "type": 1,
45 46
       "number": 3,
46
-      "out_stock": 1
47
+      "out_stock": 1,
48
+      "stock_attribute": 3,
47 49
     },
48 50
     {
49 51
       "id": 10003,

+ 72 - 4
controllers/new_mobile_api_controllers/mobile_his_api_controller.go View File

@@ -138,6 +138,7 @@ func (this *MobileHisApiController) GetCallHisPrescription() {
138 138
 func (c *MobileHisApiController) DeletePrescription() {
139 139
 	prescription_id, _ := c.GetInt64("id")
140 140
 	projects, _ := service.GetHisPrescriptionProjectsByID(prescription_id)
141
+	advices, _ := service.GetHisPrescriptionAdviceByID(prescription_id)
141 142
 
142 143
 	err := service.DelelteHisPrescription(prescription_id, c.GetMobileAdminUserInfo().Org.Id)
143 144
 	if err == nil {
@@ -152,6 +153,13 @@ func (c *MobileHisApiController) DeletePrescription() {
152 153
 				}
153 154
 			}
154 155
 		}
156
+		if len(advices) > 0 {
157
+			for _, item := range advices {
158
+				drug, _ := service.FindBaseDrugLibRecord(c.GetAdminUserInfo().CurrentOrgId, item.DrugId)
159
+				drug.Total = drug.Total + item.PrescribingNumber
160
+				service.UpdateBaseDrugLib(&drug)
161
+			}
162
+		}
155 163
 		c.ServeSuccessJSON(map[string]interface{}{
156 164
 			"msg": "删除成功",
157 165
 		})
@@ -163,9 +171,14 @@ func (c *MobileHisApiController) DeletePrescription() {
163 171
 }
164 172
 func (c *MobileHisApiController) DeleteDoctorAdvice() {
165 173
 	id, _ := c.GetInt64("id")
174
+	advice, _ := service.GetHisDoctorAdvicesById(id)
175
+
166 176
 	//TODO 需要判断是否已经结算
167 177
 	err := service.DelelteDoctorAdvice(id, c.GetMobileAdminUserInfo().Org.Id)
168 178
 	if err == nil {
179
+		drug, _ := service.FindBaseDrugLibRecord(c.GetMobileAdminUserInfo().CurrentOrgId, advice.DrugId)
180
+		drug.Total = drug.Total + advice.PrescribingNumber
181
+		service.UpdateBaseDrugLib(&drug)
169 182
 		c.ServeSuccessJSON(map[string]interface{}{
170 183
 			"msg": "删除成功",
171 184
 		})
@@ -228,6 +241,41 @@ func (c *MobileHisApiController) CreateHisPrescription() {
228 241
 
229 242
 	role, _ := service.GetAdminUserInfoByID(adminInfo.Org.Id, doctor_id)
230 243
 
244
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
245
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
246
+		if len(prescriptions) > 0 {
247
+			for _, item := range prescriptions {
248
+				items := item.(map[string]interface{})
249
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
250
+					advices := items["advices"].([]interface{})
251
+					if len(advices) > 0 {
252
+						for _, advice := range advices {
253
+							var drug_id int64
254
+							var prescribing_number float64
255
+							if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
256
+								drug_id = int64(advice.(map[string]interface{})["id"].(float64))
257
+							}
258
+							if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "float64" {
259
+								prescribing_number = advice.(map[string]interface{})["prescribing_number"].(float64)
260
+							}
261
+
262
+							drug, _ := service.FindBaseDrugLibRecord(adminInfo.Org.Id, drug_id)
263
+							if drug.ID == 0 {
264
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
265
+								return
266
+							}
267
+
268
+							if prescribing_number > drug.Total {
269
+								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOutOfStockParamWrong)
270
+								return
271
+							}
272
+						}
273
+					}
274
+				}
275
+			}
276
+		}
277
+	}
278
+
231 279
 	info, _ := service.FindPatientPrescriptionInfo(adminInfo.Org.Id, patient_id, recordDateTime, 2)
232 280
 	var hpInfo models.HisPrescriptionInfo
233 281
 	if info.ID == 0 {
@@ -543,6 +591,29 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
543 591
 		}
544 592
 	}
545 593
 
594
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
595
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
596
+		advice.PrescribingNumber = prescribingNumber
597
+	}
598
+
599
+	drug, _ := service.FindBaseDrugLibRecord(advice.UserOrgId, advice.DrugId)
600
+	if advice.ID == 0 { //医嘱不存在
601
+		drug.Total = drug.Total - advice.PrescribingNumber
602
+		service.UpdateBaseDrugLib(&drug)
603
+	} else if advice.ID > 0 { //医嘱存在
604
+		hisAdvice, _ := service.GetHisDoctorAdvicesById(advice.ID)
605
+		var num float64
606
+		if hisAdvice.PrescribingNumber > advice.PrescribingNumber {
607
+			num = hisAdvice.PrescribingNumber - advice.PrescribingNumber
608
+			drug.Total = drug.Total + num
609
+			service.UpdateBaseDrugLib(&drug)
610
+		} else if hisAdvice.PrescribingNumber < advice.PrescribingNumber {
611
+			num = advice.PrescribingNumber - hisAdvice.PrescribingNumber
612
+			drug.Total = drug.Total - num
613
+			service.UpdateBaseDrugLib(&drug)
614
+		}
615
+	}
616
+
546 617
 	//
547 618
 	//if json["execution_time"] != nil && reflect.TypeOf(json["execution_time"]).String() == "string" {
548 619
 	//	execution_time, _ := strconv.ParseInt(json["execution_time"].(string), 10,64)
@@ -598,10 +669,7 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
598 669
 		singleDoseUnit, _ := json["single_dose_unit"].(string)
599 670
 		advice.SingleDoseUnit = singleDoseUnit
600 671
 	}
601
-	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
602
-		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
603
-		advice.PrescribingNumber = prescribingNumber
604
-	}
672
+
605 673
 	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
606 674
 		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
607 675
 		advice.PrescribingNumberUnit = prescribingNumberUnit

+ 40 - 17
controllers/new_mobile_api_controllers/new_common_api_controller.go View File

@@ -31,10 +31,14 @@ func (this *NewCommonApiController) GetTotalDialysis() {
31 31
 	adminUser := this.GetMobileAdminUserInfo()
32 32
 	orgid := adminUser.Org.Id
33 33
 
34
+	lapsetotype, _ := this.GetInt64("lapsetotype")
35
+	sourcetype, _ := this.GetInt64("sourcetype")
36
+
34 37
 	//统计透析总量
35
-	_, total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid)
38
+	total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
39
+
40
+	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
36 41
 
37
-	modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid)
38 42
 	if err != nil {
39 43
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
40 44
 		return
@@ -52,10 +56,16 @@ func (this *NewCommonApiController) GetMobileTotalLapseCount() {
52 56
 
53 57
 	adminUser := this.GetMobileAdminUserInfo()
54 58
 	orgid := adminUser.Org.Id
59
+	lapsetotype, _ := this.GetInt64("lapsetotype")
60
+	sourcetype, _ := this.GetInt64("sourcetype")
55 61
 	//统计转出的病人
56
-	patient, err := service.GetTotalRollOutPatients(orgid, startime, endtime)
57
-	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startime, endtime)
58
-	count := service.GetPatientTotalCount(orgid)
62
+	patient, err := service.GetTotalRollOutPatients(orgid, startime, endtime, lapsetotype, sourcetype)
63
+
64
+	patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startime, endtime, lapsetotype, sourcetype)
65
+	count := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
66
+	//统计当前机构转出的人数
67
+	rollout, err := service.GetCountRollout(orgid, startime, endtime, lapsetotype, sourcetype)
68
+	fmt.Println("roullout", rollout)
59 69
 	if err != nil {
60 70
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
61 71
 		return
@@ -64,6 +74,7 @@ func (this *NewCommonApiController) GetMobileTotalLapseCount() {
64 74
 		"patient":    patient,
65 75
 		"count":      count,
66 76
 		"patienttwo": patienttwo,
77
+		"rollout":    rollout,
67 78
 	})
68 79
 }
69 80
 
@@ -72,17 +83,21 @@ func (this *NewCommonApiController) GetMobileTotalSexCount() {
72 83
 	//fmt.Println("startime", startime)
73 84
 	//endtime, _ := this.GetInt64("endtime")
74 85
 	//fmt.Println("endtime", endtime)
86
+	lapsetotype, _ := this.GetInt64("lapsetotype")
87
+	sourcetype, _ := this.GetInt64("sourcetype")
75 88
 	adminUser := this.GetMobileAdminUserInfo()
76 89
 	orgid := adminUser.Org.Id
77
-	total := service.GetPatientTotalCount(orgid)
78
-	_, totalSex, err := service.GetManPatientTotal(orgid)
90
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
91
+	_, totalSex, err := service.GetManPatientTotal(orgid, lapsetotype, sourcetype)
92
+	_, totalWoman, err := service.GetWoManPatientTotal(orgid, lapsetotype, sourcetype)
79 93
 	if err != nil {
80 94
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
81 95
 		return
82 96
 	}
83 97
 	this.ServeSuccessJSON(map[string]interface{}{
84
-		"total":    total,
85
-		"totalSex": totalSex,
98
+		"total":      total,
99
+		"totalSex":   totalSex,
100
+		"totalWoman": totalWoman,
86 101
 	})
87 102
 }
88 103
 
@@ -93,10 +108,13 @@ func (this *NewCommonApiController) GetMobileTotalInfectiousCout() {
93 108
 
94 109
 	adminUser := this.GetMobileAdminUserInfo()
95 110
 	orgid := adminUser.Org.Id
111
+	lapsetotype, _ := this.GetInt64("lapsetotype")
112
+	sourcetype, _ := this.GetInt64("sourcetype")
113
+
96 114
 	//统计透析总人数
97
-	total := service.GetPatientTotalCount(orgid)
115
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
98 116
 	//统计透析人数传染病所占比例
99
-	count, err := service.GetPatientInfectiousCount(orgid, startime, endtime)
117
+	count, err := service.GetPatientInfectiousCount(orgid, startime, endtime, lapsetotype, sourcetype)
100 118
 	//统计其他
101 119
 	_, otherTotal, err := service.GetPatientOtherInfectious(orgid)
102 120
 	if err != nil {
@@ -114,11 +132,12 @@ func (this *NewCommonApiController) GetMobileTotalAgeCount() {
114 132
 	//startime, _ := this.GetInt64("startime")
115 133
 	//
116 134
 	//endtime, _ := this.GetInt64("endtime")
117
-
135
+	lapsetotype, _ := this.GetInt64("lapsetotype")
136
+	sourcetype, _ := this.GetInt64("sourcetype")
118 137
 	adminUser := this.GetMobileAdminUserInfo()
119 138
 	orgid := adminUser.Org.Id
120
-	total := service.GetPatientTotalCount(orgid)
121
-	agecount, err := service.GetTotalAgeCount(orgid)
139
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
140
+	agecount, err := service.GetTotalAgeCount(orgid, lapsetotype, sourcetype)
122 141
 	//two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
123 142
 	if err != nil {
124 143
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -141,10 +160,12 @@ func (this *NewCommonApiController) GetMobileTotalDialysisCount() {
141 160
 	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
142 161
 	fmt.Println(parseDateErr)
143 162
 	nowtime := recordDate.Unix()
163
+	lapsetotype, _ := this.GetInt64("lapsetotype")
164
+	sourcetype, _ := this.GetInt64("sourcetype")
144 165
 	//统计透析总人数
145
-	total := service.GetPatientTotalCount(orgid)
166
+	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
146 167
 	//获取该机构下的所有病人数据
147
-	ageData, err := service.GetDialysisAgeData(orgid)
168
+	ageData, err := service.GetDialysisAgeData(orgid, lapsetotype, sourcetype)
148 169
 
149 170
 	if err != nil {
150 171
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
@@ -2123,8 +2144,10 @@ func (this *NewCommonApiController) GetMobileRolloutCount() {
2123 2144
 
2124 2145
 	adminUserInfo := this.GetMobileAdminUserInfo()
2125 2146
 	orgId := adminUserInfo.Org.Id
2147
+	lapsetotype, _ := this.GetInt64("lapsetotype")
2148
+	sourcetype, _ := this.GetInt64("sourcetype")
2126 2149
 	//统计当前机构转出的人数
2127
-	rollout, err := service.GetCountRollout(orgId, startimes, endtimeData)
2150
+	rollout, err := service.GetCountRollout(orgId, startimes, endtimeData, lapsetotype, sourcetype)
2128 2151
 
2129 2152
 	if err != nil {
2130 2153
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)

+ 10 - 0
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go View File

@@ -172,6 +172,7 @@ func (this *NewDialysisApiController) SavePatient() {
172 172
 	birth := theTime.Unix()
173 173
 	fmt.Print(birth)
174 174
 	phone := dataBody["phone"].(string)
175
+	relative_phone := dataBody["relative_phone"].(string)
175 176
 	fmt.Print("电话号码", phone)
176 177
 	patientType := dataBody["result"].([]interface{})
177 178
 	fmt.Print("患者标签", patientType)
@@ -290,6 +291,7 @@ func (this *NewDialysisApiController) SavePatient() {
290 291
 			IdCardNo:          idCard,
291 292
 			IsInfectious:      is_infectious,
292 293
 			RegistrarsId:      adminInfo.AdminUser.Id,
294
+			RelativePhone:     relative_phone,
293 295
 		}
294 296
 		err = service.CreateOldPatient(&patients)
295 297
 		fmt.Print("报错", err)
@@ -331,6 +333,7 @@ func (this *NewDialysisApiController) SavePatient() {
331 333
 			IsInfectious:      is_infectious,
332 334
 			IdCardNo:          idCard,
333 335
 			RegistrarsId:      adminInfo.AdminUser.Id,
336
+			RelativePhone:     relative_phone,
334 337
 		}
335 338
 		err = service.CreateNewPatient(&patientsNew)
336 339
 		fmt.Print("报错", err)
@@ -455,6 +458,7 @@ func (this *NewDialysisApiController) SavePatient() {
455 458
 								MemberFistdate:    memtime,
456 459
 								MemberPatienttype: patient_type,
457 460
 								MemberTreatement:  treatmentmethod,
461
+								RelativePhone:     relative_phone,
458 462
 							}
459 463
 							err = service.CreateNewPatient(&patientsNew)
460 464
 							fmt.Print("报错", err)
@@ -541,6 +545,7 @@ func (this *NewDialysisApiController) SavePatient() {
541 545
 					MemberFistdate:    memtime,
542 546
 					MemberPatienttype: patient_type,
543 547
 					MemberTreatement:  treatmentmethod,
548
+					RelativePhone:     relative_phone,
544 549
 				}
545 550
 				err = service.CreateNewPatient(&patientsNew)
546 551
 				fmt.Print("报错", err)
@@ -1254,6 +1259,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1254 1259
 	fmt.Print(birth)
1255 1260
 	phone := dataBody["phone"].(string)
1256 1261
 	fmt.Print("电话号码", phone)
1262
+	relative_phone := dataBody["relative_phone"].(string)
1257 1263
 	patientType := dataBody["result"].([]interface{})
1258 1264
 	fmt.Print("患者标签", patientType)
1259 1265
 	dialysis := dataBody["dialysis"].(string)
@@ -1387,6 +1393,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1387 1393
 			Lapseto:           lapseto,
1388 1394
 			DeathTime:         death_time,
1389 1395
 			OutReason:         out_reason,
1396
+			RelativePhone:     relative_phone,
1390 1397
 		}
1391 1398
 		err = service.UpdatedPatient(patients, patient.BloodId)
1392 1399
 		//patientLapseto := models.PatientLapseto{
@@ -1417,6 +1424,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1417 1424
 			Lapseto:           lapseto,
1418 1425
 			OutReason:         out_reason,
1419 1426
 			DeathTime:         death_time,
1427
+			RelativePhone:     relative_phone,
1420 1428
 		}
1421 1429
 		err = service.UpdateXtPatientNew(patientsNew, id)
1422 1430
 		if err != nil {
@@ -1474,6 +1482,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1474 1482
 			EquitmentId:       requipmentId,
1475 1483
 			OutReason:         out_reason,
1476 1484
 			DeathTime:         death_time,
1485
+			RelativePhone:     relative_phone,
1477 1486
 		}
1478 1487
 		err = service.UpdateXtPatientNew(xtPatientsNew, id)
1479 1488
 		fmt.Print("更新失败", err)
@@ -1530,6 +1539,7 @@ func (this *NewDialysisApiController) UpdatedPatient() {
1530 1539
 			MemberTreatement:  treatmentmethod,
1531 1540
 			OutReason:         out_reason,
1532 1541
 			DeathTime:         death_time,
1542
+			RelativePhone:     relative_phone,
1533 1543
 		}
1534 1544
 		err = service.UpdateXtPatientNewOne(patientsNew, id)
1535 1545
 		if err != nil {

+ 290 - 277
controllers/patient_api_controller.go View File

@@ -254,29 +254,29 @@ func (c *PatientApiController) CreatePatient() {
254 254
 	//获取老表的最后一条数据
255 255
 	patients, err := service.GetLastPatientData(adminUserInfo.CurrentOrgId)
256 256
 	patientsNew := models.XtPatientsNew{
257
-		UserOrgId:          adminUserInfo.CurrentOrgId,
258
-		UserId:             0,
259
-		Avatar:             patients.Avatar,
260
-		PatientType:        patients.PatientType,
261
-		DialysisNo:         patients.DialysisNo,
262
-		AdmissionNumber:    patients.AdmissionNumber,
263
-		Source:             patients.Source,
264
-		Lapseto:            patients.Lapseto,
265
-		PartitionId:        patients.PartitionId,
266
-		BedId:              patients.BedId,
267
-		Name:               patients.Name,
268
-		Alias:              patients.Alias,
269
-		Gender:             patients.Gender,
270
-		MaritalStatus:      patients.MaritalStatus,
271
-		IdCardNo:           patients.IdCardNo,
272
-		Birthday:           patients.Birthday,
273
-		ReimbursementWayId: patients.ReimbursementWayId,
274
-		HealthCareType:     patients.HealthCareType,
275
-		HealthCareNo:       patients.HealthCareNo,
276
-		HealthCareDueDate:  patients.HealthCareDueDate,
277
-		Height:             patients.Height,
278
-		BloodType:          patients.BloodType,
279
-		Rh:                 patients.Rh,
257
+		UserOrgId:                    adminUserInfo.CurrentOrgId,
258
+		UserId:                       0,
259
+		Avatar:                       patients.Avatar,
260
+		PatientType:                  patients.PatientType,
261
+		DialysisNo:                   patients.DialysisNo,
262
+		AdmissionNumber:              patients.AdmissionNumber,
263
+		Source:                       patients.Source,
264
+		Lapseto:                      patients.Lapseto,
265
+		PartitionId:                  patients.PartitionId,
266
+		BedId:                        patients.BedId,
267
+		Name:                         patients.Name,
268
+		Alias:                        patients.Alias,
269
+		Gender:                       patients.Gender,
270
+		MaritalStatus:                patients.MaritalStatus,
271
+		IdCardNo:                     patients.IdCardNo,
272
+		Birthday:                     patients.Birthday,
273
+		ReimbursementWayId:           patients.ReimbursementWayId,
274
+		HealthCareType:               patients.HealthCareType,
275
+		HealthCareNo:                 patients.HealthCareNo,
276
+		HealthCareDueDate:            patients.HealthCareDueDate,
277
+		Height:                       patients.Height,
278
+		BloodType:                    patients.BloodType,
279
+		Rh:                           patients.Rh,
280 280
 		HealthCareDueAlertDate:       patients.HealthCareDueAlertDate,
281 281
 		EducationLevel:               patients.EducationLevel,
282 282
 		Profession:                   patients.Profession,
@@ -322,28 +322,28 @@ func (c *PatientApiController) CreatePatient() {
322 322
 		Nation:                       patients.Nation,
323 323
 		NativePlace:                  patients.NativePlace,
324 324
 		Age:                          patients.Age,
325
-		InfectiousNextRecordTime: patients.InfectiousNextRecordTime,
326
-		IsInfectious:             patients.IsInfectious,
327
-		RemindCycle:              patients.RemindCycle,
328
-		ResponseResult:           patients.ResponseResult,
329
-		IsOpenRemind:             patients.IsOpenRemind,
330
-		FirstTreatmentDate:       patients.FirstTreatmentDate,
331
-		DialysisAge:              patients.DialysisAge,
332
-		ExpenseKind:              patients.ExpenseKind,
333
-		TellPhone:                patients.TellPhone,
334
-		ContactName:              patients.ContactName,
335
-		BloodPatients:            1,
336
-		SlowPatients:             0,
337
-		MemberPatients:           0,
338
-		EcommerPatients:          "",
339
-		BloodId:                  patients.ID,
340
-		SlowId:                   0,
341
-		MemberId:                 0,
342
-		MemberFistdate:           0,
343
-		MemberPatienttype:        0,
344
-		MemberTreatement:         0,
345
-		EquitmentId:              "",
346
-		UserSysBeforeCount:       patient.UserSysBeforeCount,
325
+		InfectiousNextRecordTime:     patients.InfectiousNextRecordTime,
326
+		IsInfectious:                 patients.IsInfectious,
327
+		RemindCycle:                  patients.RemindCycle,
328
+		ResponseResult:               patients.ResponseResult,
329
+		IsOpenRemind:                 patients.IsOpenRemind,
330
+		FirstTreatmentDate:           patients.FirstTreatmentDate,
331
+		DialysisAge:                  patients.DialysisAge,
332
+		ExpenseKind:                  patients.ExpenseKind,
333
+		TellPhone:                    patients.TellPhone,
334
+		ContactName:                  patients.ContactName,
335
+		BloodPatients:                1,
336
+		SlowPatients:                 0,
337
+		MemberPatients:               0,
338
+		EcommerPatients:              "",
339
+		BloodId:                      patients.ID,
340
+		SlowId:                       0,
341
+		MemberId:                     0,
342
+		MemberFistdate:               0,
343
+		MemberPatienttype:            0,
344
+		MemberTreatement:             0,
345
+		EquitmentId:                  "",
346
+		UserSysBeforeCount:           patient.UserSysBeforeCount,
347 347
 	}
348 348
 
349 349
 	err = service.CreatePatientsNew(&patientsNew)
@@ -481,28 +481,28 @@ func (c *PatientApiController) EditPatient() {
481 481
 		return
482 482
 	}
483 483
 	patientsNew := models.XtPatientsNew{
484
-		UserOrgId:          patient.UserOrgId,
485
-		UserId:             patient.UserId,
486
-		Avatar:             patient.Avatar,
487
-		PatientType:        patient.PatientType,
488
-		DialysisNo:         patient.DialysisNo,
489
-		AdmissionNumber:    patient.AdmissionNumber,
490
-		Source:             patient.Source,
491
-		PartitionId:        patient.PartitionId,
492
-		BedId:              patient.BedId,
493
-		Name:               patient.Name,
494
-		Alias:              patient.Alias,
495
-		Gender:             patient.Gender,
496
-		MaritalStatus:      patient.MaritalStatus,
497
-		IdCardNo:           patient.IdCardNo,
498
-		Birthday:           patient.Birthday,
499
-		ReimbursementWayId: patient.ReimbursementWayId,
500
-		HealthCareType:     patient.HealthCareType,
501
-		HealthCareNo:       patient.HealthCareNo,
502
-		HealthCareDueDate:  patient.HealthCareDueDate,
503
-		Height:             patient.Height,
504
-		BloodType:          patient.BloodType,
505
-		Rh:                 patient.Rh,
484
+		UserOrgId:                 patient.UserOrgId,
485
+		UserId:                    patient.UserId,
486
+		Avatar:                    patient.Avatar,
487
+		PatientType:               patient.PatientType,
488
+		DialysisNo:                patient.DialysisNo,
489
+		AdmissionNumber:           patient.AdmissionNumber,
490
+		Source:                    patient.Source,
491
+		PartitionId:               patient.PartitionId,
492
+		BedId:                     patient.BedId,
493
+		Name:                      patient.Name,
494
+		Alias:                     patient.Alias,
495
+		Gender:                    patient.Gender,
496
+		MaritalStatus:             patient.MaritalStatus,
497
+		IdCardNo:                  patient.IdCardNo,
498
+		Birthday:                  patient.Birthday,
499
+		ReimbursementWayId:        patient.ReimbursementWayId,
500
+		HealthCareType:            patient.HealthCareType,
501
+		HealthCareNo:              patient.HealthCareNo,
502
+		HealthCareDueDate:         patient.HealthCareDueDate,
503
+		Height:                    patient.Height,
504
+		BloodType:                 patient.BloodType,
505
+		Rh:                        patient.Rh,
506 506
 		HealthCareDueAlertDate:    patient.HealthCareDueAlertDate,
507 507
 		EducationLevel:            patient.EducationLevel,
508 508
 		Profession:                patient.Profession,
@@ -544,19 +544,19 @@ func (c *PatientApiController) EditPatient() {
544 544
 		Nation:                    patient.Nation,
545 545
 		NativePlace:               patient.NativePlace,
546 546
 		Age:                       patient.Age,
547
-		InfectiousNextRecordTime: patient.InfectiousNextRecordTime,
548
-		IsInfectious:             patient.IsInfectious,
549
-		RemindCycle:              patient.RemindCycle,
550
-		ResponseResult:           patient.ResponseResult,
551
-		IsOpenRemind:             patient.IsOpenRemind,
552
-		FirstTreatmentDate:       patient.FirstTreatmentDate,
553
-		DialysisAge:              patient.DialysisAge,
554
-		ExpenseKind:              patient.ExpenseKind,
555
-		TellPhone:                patient.TellPhone,
556
-		ContactName:              patient.ContactName,
557
-		UpdatedTime:              time.Now().Unix(),
558
-		BloodPatients:            1,
559
-		Lapseto:                  patient.Lapseto,
547
+		InfectiousNextRecordTime:  patient.InfectiousNextRecordTime,
548
+		IsInfectious:              patient.IsInfectious,
549
+		RemindCycle:               patient.RemindCycle,
550
+		ResponseResult:            patient.ResponseResult,
551
+		IsOpenRemind:              patient.IsOpenRemind,
552
+		FirstTreatmentDate:        patient.FirstTreatmentDate,
553
+		DialysisAge:               patient.DialysisAge,
554
+		ExpenseKind:               patient.ExpenseKind,
555
+		TellPhone:                 patient.TellPhone,
556
+		ContactName:               patient.ContactName,
557
+		UpdatedTime:               time.Now().Unix(),
558
+		BloodPatients:             1,
559
+		Lapseto:                   patient.Lapseto,
560 560
 	}
561 561
 	//	//更新病人ID获取新表病人ID
562 562
 	err = service.UpdatepatientTwo(&patientsNew, id)
@@ -856,6 +856,8 @@ func (c *PatientApiController) UpdateDialysisSolution() {
856 856
 		DialysateTemperature:       solution.DialysateTemperature,
857 857
 		DialysisIrrigation:         solution.DialysisIrrigation,
858 858
 		DialysisDialyszers:         solution.DialysisDialyszers,
859
+		PlasmaSeparator:            solution.PlasmaSeparator,
860
+		BilirubinAdsorptionColumn:  solution.BilirubinAdsorptionColumn,
859 861
 	}
860 862
 	service.UpdatePatientDialysisSolutionOne(solution.PatientId, adminUserInfo.CurrentOrgId, &prescription, todayTime.Unix())
861 863
 	if err != nil {
@@ -1649,207 +1651,208 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1649 1651
 		fmt.Println("", drugStockConfig.IsOpen)
1650 1652
 		if drugStockConfig.IsOpen == 1 {
1651 1653
 			//查询已经执行的医嘱
1652
-			advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1653
-			for _, item := range advices {
1654
-				fmt.Println("非自备要22222")
1655
-				if item.Way == 1 {
1656
-					out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, item.RecordDate)
1657
-					if err == gorm.ErrRecordNotFound {
1658
-						//没有记录,则创建出库单
1659
-						timeStr := time.Now().Format("2006-01-02")
1660
-						timeArr := strings.Split(timeStr, "-")
1661
-						total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1662
-						total = total + 1
1663
-						warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1664
-						number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1665
-						number = number + total
1666
-						warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1667
-						creater := adminUserInfo.AdminUser.Id
1668
-						warehouseOut := models.DrugWarehouseOut{
1669
-							WarehouseOutOrderNumber: warehousing_out_order,
1670
-							OperationTime:           time.Now().Unix(),
1671
-							OrgId:                   adminUserInfo.CurrentOrgId,
1672
-							Creater:                 creater,
1673
-							Ctime:                   time.Now().Unix(),
1674
-							Status:                  1,
1675
-							WarehouseOutTime:        item.RecordDate,
1676
-							Dealer:                  0,
1677
-							Manufacturer:            0,
1678
-							Type:                    1,
1679
-							IsSys:                   1,
1680
-						}
1681
-
1682
-						err := service.AddSigleDrugWarehouseOut(&warehouseOut)
1683
-						if err != nil {
1684
-							utils.TraceLog("创建出库单失败 err = %v", err)
1685
-						} else {
1686
-							if item.Way == 1 {
1687
-								if item.PrescribingNumber > 0 {
1688
-									warehouseOutInfo := &models.DrugWarehouseOutInfo{
1689
-										WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1690
-										WarehouseOutId:          warehouseOut.ID,
1691
-										Status:                  1,
1692
-										Ctime:                   time.Now().Unix(),
1693
-										Remark:                  "",
1694
-										OrgId:                   adminUserInfo.CurrentOrgId,
1695
-										Type:                    1,
1696
-										Manufacturer:            0,
1697
-										Dealer:                  0,
1698
-										IsSys:                   1,
1699
-										SysRecordTime:           item.RecordDate,
1700
-										DrugId:                  item.DrugId,
1701
-									}
1702
-									prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1703
-									count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1704
-									warehouseOutInfo.Count = count
1705
-									stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1706
-									warehouseOutInfo.Price = stockInInfo.Price
1707
-									err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1708
-									if err == nil {
1709
-										details := &models.DrugAutomaticReduceDetail{
1710
-											WarehouseOutId:          warehouseOutInfo.ID,
1711
-											WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1712
-											PatientId:               item.PatientId,
1713
-											Ctime:                   time.Now().Unix(),
1714
-											Mtime:                   time.Now().Unix(),
1715
-											Status:                  1,
1716
-											RecordTime:              item.RecordDate,
1717
-											OrgId:                   adminUserInfo.CurrentOrgId,
1718
-											DrugId:                  item.DrugId,
1719
-											Count:                   count,
1720
-										}
1721
-										service.AddSigleDrugAutoReduceRecordInfo(details)
1722
-										if err != nil {
1723
-											utils.TraceLog("创建出库单失败 err = %v", err)
1724
-										} else {
1725
-											if item.Way == 1 {
1726
-												if item.PrescribingNumber > 0 {
1727
-													warehouseOutInfo := &models.DrugWarehouseOutInfo{
1728
-														WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1729
-														WarehouseOutId:          warehouseOut.ID,
1730
-														Status:                  1,
1731
-														Ctime:                   time.Now().Unix(),
1732
-														Remark:                  "",
1733
-														OrgId:                   adminUserInfo.CurrentOrgId,
1734
-														Type:                    1,
1735
-														Manufacturer:            0,
1736
-														Dealer:                  0,
1737
-														IsSys:                   1,
1738
-														SysRecordTime:           item.RecordDate,
1739
-														DrugId:                  item.DrugId,
1740
-													}
1741
-													prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1742
-													count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1743
-													warehouseOutInfo.Count = count
1744
-													stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1745
-													warehouseOutInfo.Price = stockInInfo.Price
1746
-													err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1747
-													if err == nil {
1748
-														details := &models.DrugAutomaticReduceDetail{
1749
-															WarehouseOutId:          warehouseOutInfo.ID,
1750
-															WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1751
-															PatientId:               item.PatientId,
1752
-															Ctime:                   time.Now().Unix(),
1753
-															Mtime:                   time.Now().Unix(),
1754
-															Status:                  1,
1755
-															RecordTime:              item.RecordDate,
1756
-															OrgId:                   adminUserInfo.CurrentOrgId,
1757
-															DrugId:                  item.DrugId,
1758
-															Count:                   count,
1759
-														}
1760
-														service.AddSigleDrugAutoReduceRecordInfo(details)
1761
-													}
1762
-												}
1763
-											}
1764
-										}
1765
-
1766
-									}
1767
-								}
1768
-							}
1769
-						}
1770
-					} else if err == nil {
1771
-						if item.Way == 1 {
1772
-							outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
1773
-							if err == gorm.ErrRecordNotFound {
1774
-								warehouseOutInfo := &models.DrugWarehouseOutInfo{
1775
-									WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
1776
-									WarehouseOutId:          out.ID,
1777
-									Status:                  1,
1778
-									Ctime:                   time.Now().Unix(),
1779
-									Remark:                  "",
1780
-									OrgId:                   adminUserInfo.CurrentOrgId,
1781
-									Type:                    1,
1782
-									Manufacturer:            0,
1783
-									Dealer:                  0,
1784
-									IsSys:                   1,
1785
-									SysRecordTime:           item.RecordDate,
1786
-								}
1787
-
1788
-								stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1789
-								warehouseOutInfo.Price = stockInInfo.Price
1790
-								warehouseOutInfo.DrugId = item.DrugId
1791
-								prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1792
-								count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1793
-								warehouseOutInfo.Count = count
1794
-								err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1795
-								if err == nil {
1796
-									details := &models.DrugAutomaticReduceDetail{
1797
-										WarehouseOutId:          warehouseOutInfo.ID,
1798
-										WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1799
-										PatientId:               item.PatientId,
1800
-										Ctime:                   time.Now().Unix(),
1801
-										Mtime:                   time.Now().Unix(),
1802
-										Status:                  1,
1803
-										RecordTime:              item.RecordDate,
1804
-										OrgId:                   adminUserInfo.CurrentOrgId,
1805
-										DrugId:                  item.DrugId,
1806
-										Count:                   count,
1807
-									}
1808
-									service.AddSigleDrugAutoReduceRecordInfo(details)
1809
-								}
1810
-
1811
-							} else if err == nil { //记录存在,则将增加数量
1812
-								if outInfo.ID > 0 {
1813
-									prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1814
-									count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1815
-									service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
1816
-								}
1817
-
1818
-								count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, item.RecordDate, item.DrugId, item.PatientId)
1819
-								if count == 0 {
1820
-									prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1821
-									count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1822
-									details := &models.DrugAutomaticReduceDetail{
1823
-										WarehouseOutId:          outInfo.ID,
1824
-										WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
1825
-										PatientId:               item.PatientId,
1826
-										Ctime:                   time.Now().Unix(),
1827
-										Mtime:                   time.Now().Unix(),
1828
-										Status:                  1,
1829
-										RecordTime:              item.RecordDate,
1830
-										OrgId:                   adminUserInfo.CurrentOrgId,
1831
-										DrugId:                  item.DrugId,
1832
-										Count:                   count,
1833
-									}
1834
-									service.AddSigleDrugAutoReduceRecordInfo(details)
1835
-								} else if count == 1 {
1836
-									prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1837
-									count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1838
-									service.UpdateDrugUserInfoDetails(item.DrugId, item.RecordDate, adminUserInfo.CurrentOrgId, item.PatientId, count, &outInfo)
1839
-								}
1840
-
1841
-							}
1842
-						}
1843
-					}
1844
-				}
1845
-			}
1654
+			//advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1655
+			//for _, item := range advices {
1656
+			//
1657
+			//	//调用药品出库接口
1658
+			//	//service.DrugsDelivery(item.UserOrgId, item)
1659
+			//
1660
+			//	//if item.Way == 1 {
1661
+			//	//	out, err := service.FindDrugStockOutByIsSys(adminUserInfo.CurrentOrgId, 1, item.RecordDate)
1662
+			//	//	if err == gorm.ErrRecordNotFound {
1663
+			//	//		//没有记录,则创建出库单
1664
+			//	//		timeStr := time.Now().Format("2006-01-02")
1665
+			//	//		timeArr := strings.Split(timeStr, "-")
1666
+			//	//		total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
1667
+			//	//		total = total + 1
1668
+			//	//		warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
1669
+			//	//		number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
1670
+			//	//		number = number + total
1671
+			//	//		warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
1672
+			//	//		creater := adminUserInfo.AdminUser.Id
1673
+			//	//		warehouseOut := models.DrugWarehouseOut{
1674
+			//	//			WarehouseOutOrderNumber: warehousing_out_order,
1675
+			//	//			OperationTime:           time.Now().Unix(),
1676
+			//	//			OrgId:                   adminUserInfo.CurrentOrgId,
1677
+			//	//			Creater:                 creater,
1678
+			//	//			Ctime:                   time.Now().Unix(),
1679
+			//	//			Status:                  1,
1680
+			//	//			WarehouseOutTime:        item.RecordDate,
1681
+			//	//			Dealer:                  0,
1682
+			//	//			Manufacturer:            0,
1683
+			//	//			Type:                    1,
1684
+			//	//			IsSys:                   1,
1685
+			//	//		}
1686
+			//	//
1687
+			//	//		err := service.AddSigleDrugWarehouseOut(&warehouseOut)
1688
+			//	//		if err != nil {
1689
+			//	//			utils.TraceLog("创建出库单失败 err = %v", err)
1690
+			//	//		} else {
1691
+			//	//			if item.Way == 1 {
1692
+			//	//				if item.PrescribingNumber > 0 {
1693
+			//	//					warehouseOutInfo := &models.DrugWarehouseOutInfo{
1694
+			//	//						WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1695
+			//	//						WarehouseOutId:          warehouseOut.ID,
1696
+			//	//						Status:                  1,
1697
+			//	//						Ctime:                   time.Now().Unix(),
1698
+			//	//						Remark:                  "",
1699
+			//	//						OrgId:                   adminUserInfo.CurrentOrgId,
1700
+			//	//						Type:                    1,
1701
+			//	//						Manufacturer:            0,
1702
+			//	//						Dealer:                  0,
1703
+			//	//						IsSys:                   1,
1704
+			//	//						SysRecordTime:           item.RecordDate,
1705
+			//	//						DrugId:                  item.DrugId,
1706
+			//	//					}
1707
+			//	//					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1708
+			//	//					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1709
+			//	//					warehouseOutInfo.Count = count
1710
+			//	//					stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1711
+			//	//					warehouseOutInfo.Price = stockInInfo.Price
1712
+			//	//					err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1713
+			//	//					if err == nil {
1714
+			//	//						details := &models.DrugAutomaticReduceDetail{
1715
+			//	//							WarehouseOutId:          warehouseOutInfo.ID,
1716
+			//	//							WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1717
+			//	//							PatientId:               item.PatientId,
1718
+			//	//							Ctime:                   time.Now().Unix(),
1719
+			//	//							Mtime:                   time.Now().Unix(),
1720
+			//	//							Status:                  1,
1721
+			//	//							RecordTime:              item.RecordDate,
1722
+			//	//							OrgId:                   adminUserInfo.CurrentOrgId,
1723
+			//	//							DrugId:                  item.DrugId,
1724
+			//	//							Count:                   count,
1725
+			//	//						}
1726
+			//	//						service.AddSigleDrugAutoReduceRecordInfo(details)
1727
+			//	//						if err != nil {
1728
+			//	//							utils.TraceLog("创建出库单失败 err = %v", err)
1729
+			//	//						} else {
1730
+			//	//							if item.Way == 1 {
1731
+			//	//								if item.PrescribingNumber > 0 {
1732
+			//	//									warehouseOutInfo := &models.DrugWarehouseOutInfo{
1733
+			//	//										WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
1734
+			//	//										WarehouseOutId:          warehouseOut.ID,
1735
+			//	//										Status:                  1,
1736
+			//	//										Ctime:                   time.Now().Unix(),
1737
+			//	//										Remark:                  "",
1738
+			//	//										OrgId:                   adminUserInfo.CurrentOrgId,
1739
+			//	//										Type:                    1,
1740
+			//	//										Manufacturer:            0,
1741
+			//	//										Dealer:                  0,
1742
+			//	//										IsSys:                   1,
1743
+			//	//										SysRecordTime:           item.RecordDate,
1744
+			//	//										DrugId:                  item.DrugId,
1745
+			//	//									}
1746
+			//	//									prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1747
+			//	//									count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1748
+			//	//									warehouseOutInfo.Count = count
1749
+			//	//									stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1750
+			//	//									warehouseOutInfo.Price = stockInInfo.Price
1751
+			//	//									err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1752
+			//	//									if err == nil {
1753
+			//	//										details := &models.DrugAutomaticReduceDetail{
1754
+			//	//											WarehouseOutId:          warehouseOutInfo.ID,
1755
+			//	//											WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1756
+			//	//											PatientId:               item.PatientId,
1757
+			//	//											Ctime:                   time.Now().Unix(),
1758
+			//	//											Mtime:                   time.Now().Unix(),
1759
+			//	//											Status:                  1,
1760
+			//	//											RecordTime:              item.RecordDate,
1761
+			//	//											OrgId:                   adminUserInfo.CurrentOrgId,
1762
+			//	//											DrugId:                  item.DrugId,
1763
+			//	//											Count:                   count,
1764
+			//	//										}
1765
+			//	//										service.AddSigleDrugAutoReduceRecordInfo(details)
1766
+			//	//									}
1767
+			//	//								}
1768
+			//	//							}
1769
+			//	//						}
1770
+			//	//
1771
+			//	//					}
1772
+			//	//				}
1773
+			//	//			}
1774
+			//	//		}
1775
+			//	//	} else if err == nil {
1776
+			//	//		if item.Way == 1 {
1777
+			//	//			outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.CurrentOrgId, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
1778
+			//	//			if err == gorm.ErrRecordNotFound {
1779
+			//	//				warehouseOutInfo := &models.DrugWarehouseOutInfo{
1780
+			//	//					WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
1781
+			//	//					WarehouseOutId:          out.ID,
1782
+			//	//					Status:                  1,
1783
+			//	//					Ctime:                   time.Now().Unix(),
1784
+			//	//					Remark:                  "",
1785
+			//	//					OrgId:                   adminUserInfo.CurrentOrgId,
1786
+			//	//					Type:                    1,
1787
+			//	//					Manufacturer:            0,
1788
+			//	//					Dealer:                  0,
1789
+			//	//					IsSys:                   1,
1790
+			//	//					SysRecordTime:           item.RecordDate,
1791
+			//	//				}
1792
+			//	//
1793
+			//	//				stockInInfo, _ := service.FindLastDrugStockInInfoRecord(item.DrugId, adminUserInfo.CurrentOrgId)
1794
+			//	//				warehouseOutInfo.Price = stockInInfo.Price
1795
+			//	//				warehouseOutInfo.DrugId = item.DrugId
1796
+			//	//				prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1797
+			//	//				count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1798
+			//	//				warehouseOutInfo.Count = count
1799
+			//	//				err := service.AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1800
+			//	//				if err == nil {
1801
+			//	//					details := &models.DrugAutomaticReduceDetail{
1802
+			//	//						WarehouseOutId:          warehouseOutInfo.ID,
1803
+			//	//						WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
1804
+			//	//						PatientId:               item.PatientId,
1805
+			//	//						Ctime:                   time.Now().Unix(),
1806
+			//	//						Mtime:                   time.Now().Unix(),
1807
+			//	//						Status:                  1,
1808
+			//	//						RecordTime:              item.RecordDate,
1809
+			//	//						OrgId:                   adminUserInfo.CurrentOrgId,
1810
+			//	//						DrugId:                  item.DrugId,
1811
+			//	//						Count:                   count,
1812
+			//	//					}
1813
+			//	//					service.AddSigleDrugAutoReduceRecordInfo(details)
1814
+			//	//				}
1815
+			//	//
1816
+			//	//			} else if err == nil { //记录存在,则将增加数量
1817
+			//	//				if outInfo.ID > 0 {
1818
+			//	//					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1819
+			//	//					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1820
+			//	//					service.UpdateDrugStockOutInfoCount2(adminUserInfo.CurrentOrgId, outInfo.ID, count)
1821
+			//	//				}
1822
+			//	//
1823
+			//	//				count, _ := service.FindPatientDrugAutomaticReduceRecord(adminUserInfo.CurrentOrgId, item.RecordDate, item.DrugId, item.PatientId)
1824
+			//	//				if count == 0 {
1825
+			//	//					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1826
+			//	//					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1827
+			//	//					details := &models.DrugAutomaticReduceDetail{
1828
+			//	//						WarehouseOutId:          outInfo.ID,
1829
+			//	//						WarehouseOutOrderNumber: outInfo.WarehouseOutOrderNumber,
1830
+			//	//						PatientId:               item.PatientId,
1831
+			//	//						Ctime:                   time.Now().Unix(),
1832
+			//	//						Mtime:                   time.Now().Unix(),
1833
+			//	//						Status:                  1,
1834
+			//	//						RecordTime:              item.RecordDate,
1835
+			//	//						OrgId:                   adminUserInfo.CurrentOrgId,
1836
+			//	//						DrugId:                  item.DrugId,
1837
+			//	//						Count:                   count,
1838
+			//	//					}
1839
+			//	//					service.AddSigleDrugAutoReduceRecordInfo(details)
1840
+			//	//				} else if count == 1 {
1841
+			//	//					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
1842
+			//	//					count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
1843
+			//	//					service.UpdateDrugUserInfoDetails(item.DrugId, item.RecordDate, adminUserInfo.CurrentOrgId, item.PatientId, count, &outInfo)
1844
+			//	//				}
1845
+			//	//
1846
+			//	//			}
1847
+			//	//		}
1848
+			//	//	}
1849
+			//	//}
1850
+			//}
1846 1851
 		}
1847 1852
 
1848 1853
 		advices, _ := service.GetExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1849 1854
 		for _, item := range advices {
1850
-			fmt.Println("33333", item.ExecutionState)
1851
-			fmt.Println("医嘱名称", item.AdviceName)
1852
-			fmt.Println("item", item.Way)
1855
+
1853 1856
 			if item.Way == 2 {
1854 1857
 				if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
1855 1858
 
@@ -3410,6 +3413,16 @@ func defaultSolutionFormData(solution *models.DialysisSolution, data []byte, met
3410 3413
 		solution.DialysisIrrigation = dialysisIrrigation
3411 3414
 	}
3412 3415
 
3416
+	if dataBody["plasma_separator"] != nil && reflect.TypeOf(dataBody["plasma_separator"]).String() == "string" {
3417
+		plasmaSeparator := dataBody["plasma_separator"].(string)
3418
+		solution.PlasmaSeparator = plasmaSeparator
3419
+	}
3420
+
3421
+	if dataBody["bilirubin_adsorption_column"] != nil && reflect.TypeOf(dataBody["bilirubin_adsorption_column"]).String() == "string" {
3422
+		bilirubinAdsorptionColumn := dataBody["bilirubin_adsorption_column"].(string)
3423
+		solution.BilirubinAdsorptionColumn = bilirubinAdsorptionColumn
3424
+	}
3425
+
3413 3426
 	return
3414 3427
 }
3415 3428
 

+ 486 - 7
controllers/schedule_api_controller.go View File

@@ -22,6 +22,7 @@ type ScheduleApiController struct {
22 22
 
23 23
 func ScheduleApiRegistRouters() {
24 24
 	beego.Router("/api/schedule/weekpanel", &ScheduleApiController{}, "Get:GetWeekPanels")
25
+
25 26
 	beego.Router("/api/schedule/schedules", &ScheduleApiController{}, "Get:GetSchedules")
26 27
 	beego.Router("/api/excel_date/init", &ScheduleApiController{}, "Get:GetInitExcelInitDate")
27 28
 
@@ -46,6 +47,25 @@ func ScheduleApiRegistRouters() {
46 47
 	beego.Router("/api/schedule/getallzones", &ScheduleApiController{}, "Get:GetAllZones")
47 48
 
48 49
 	beego.Router("/api/schedule/copypatientschedules", &ScheduleApiController{}, "Get:GetCopyPatientSchedules")
50
+
51
+	beego.Router("/api/schedule/saveremindprint", &ScheduleApiController{}, "Get:SaveRemindPrint")
52
+
53
+	beego.Router("/api/schedule/getremindprintlist", &ScheduleApiController{}, "Get:GetRemindPrintList")
54
+
55
+	beego.Router("/api/schedule/getbloodschedulelist", &ScheduleApiController{}, "Get:GetBloodScheduleList")
56
+
57
+	beego.Router("/api/schedule/getprintlist", &ScheduleApiController{}, "Get:GetPrintList")
58
+
59
+	beego.Router("/api/schedule/getallzonelist", &ScheduleApiController{}, "Get:GetAllZoneList")
60
+
61
+	beego.Router("/api/schedule/getpatientschedulecount", &ScheduleApiController{}, "Get:GetPatientScheduleCount")
62
+
63
+	beego.Router("/api/schedule/weekpanelone", &ScheduleApiController{}, "Get:GetWeekPanelsOne")
64
+	beego.Router("/api/schedule/schedulesone", &ScheduleApiController{}, "Get:GetScheduleOne")
65
+	beego.Router("/api/schedule/postscheduletemplate", &ScheduleApiController{}, "Get:SaveScheduleTemplate")
66
+	beego.Router("/api/schedule/getscheduletemplate", &ScheduleApiController{}, "Get:GetScheduleTemplate")
67
+	beego.Router("/api/order/changefuncprint", &ScheduleApiController{}, "Get:ChangeFuncPrint")
68
+	beego.Router("/api/order/getdataprint", &ScheduleApiController{}, "Get:GetDataPrint")
49 69
 }
50 70
 
51 71
 func (c *ScheduleApiController) GetWeekPanels() {
@@ -790,6 +810,7 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
790 810
 func (this *ScheduleApiController) GetWeekDaySchedule() {
791 811
 	week_type, _ := this.GetInt64("week_type", -1)
792 812
 	week_time, _ := this.GetInt64("week_time")
813
+
793 814
 	thisTime := time.Now()
794 815
 	weekDay := int(thisTime.Weekday())
795 816
 	if weekDay == 0 {
@@ -810,7 +831,14 @@ func (this *ScheduleApiController) GetWeekDaySchedule() {
810 831
 	fmt.Println(days)
811 832
 
812 833
 	var targetDayStr string
834
+	var startTime string
835
+	var endTime string
813 836
 	switch week_type {
837
+	case 0:
838
+		{
839
+			startTime = days[0]
840
+			endTime = days[6]
841
+		}
814 842
 	case 1:
815 843
 		targetDayStr = days[0]
816 844
 		break
@@ -840,14 +868,17 @@ func (this *ScheduleApiController) GetWeekDaySchedule() {
840 868
 		break
841 869
 	}
842 870
 	targetDay, parseErr := utils.ParseTimeStringToTime("2006-01-02", targetDayStr)
843
-
871
+	startDay, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
872
+	endDay, _ := utils.ParseTimeStringToTime("2006-01-02", endTime)
873
+	fmt.Println(startDay, endDay)
844 874
 	if parseErr != nil {
845 875
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
846 876
 		return
847 877
 	}
848 878
 
849
-	adminUserInfo := this.GetAdminUserInfo()
850
-	list, _ := service.GetWeekDayScheduleTwo(adminUserInfo.CurrentOrgId, targetDay.Unix(), targetDay, week_time)
879
+	orgId := this.GetAdminUserInfo().CurrentOrgId
880
+
881
+	list, _ := service.GetWeekDayScheduleTwo(orgId, targetDay.Unix(), targetDay, week_time)
851 882
 
852 883
 	this.ServeSuccessJSON(map[string]interface{}{
853 884
 		"schdules": list,
@@ -1324,10 +1355,11 @@ func (this *ScheduleApiController) ExportSchedule() {
1324 1355
 			if err == nil {
1325 1356
 				for _, item := range schedules {
1326 1357
 					//查找当天日期是否存在
1327
-					_, errcode := service.GetTodayScheduleIsExist(item.PatientId, item.ScheduleDate, item.UserOrgId)
1358
+					_, errcode := service.GetTodayScheduleIsExist(item.PatientId, item.ScheduleDate, item.UserOrgId, item.ModeId, item.ScheduleType)
1328 1359
 					if errcode == gorm.ErrRecordNotFound {
1329 1360
 						service.CreateSchedule(item)
1330 1361
 					} else if errcode == nil {
1362
+
1331 1363
 						schedule := models.XtSchedule{
1332 1364
 							PartitionId:  item.PartitionId,
1333 1365
 							BedId:        item.BedId,
@@ -1338,7 +1370,8 @@ func (this *ScheduleApiController) ExportSchedule() {
1338 1370
 							ModeId:       item.ModeId,
1339 1371
 							Status:       1,
1340 1372
 						}
1341
-						service.UpdateScheduleByOrgId(item.PatientId, item.ScheduleDate, item.UserOrgId, &schedule)
1373
+
1374
+						service.UpdateScheduleByOrgId(item.PatientId, item.ScheduleDate, item.UserOrgId, item.ModeId, item.ScheduleType, &schedule)
1342 1375
 					}
1343 1376
 
1344 1377
 				}
@@ -1947,10 +1980,10 @@ func (this *ScheduleApiController) GetNextWeekDaySchedule() {
1947 1980
 	week_time, _ := this.GetInt64("week_time")
1948 1981
 	start_time, _ := this.GetInt64("start_time")
1949 1982
 	end_time, _ := this.GetInt64("end_time")
1950
-
1983
+	zone, _ := this.GetInt64("zone")
1951 1984
 	adminUserInfo := this.GetAdminUserInfo()
1952 1985
 
1953
-	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId)
1986
+	schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone)
1954 1987
 	if err != nil {
1955 1988
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1956 1989
 		return
@@ -2188,3 +2221,449 @@ func (this *ScheduleApiController) GetCopyPatientSchedules() {
2188 2221
 	//	}
2189 2222
 	//}
2190 2223
 }
2224
+
2225
+func (this *ScheduleApiController) SaveRemindPrint() {
2226
+
2227
+	id, _ := this.GetInt64("id")
2228
+	anticoagulants, _ := this.GetInt64("anticoagulant")
2229
+	anticoagulant_zongliang, _ := this.GetInt64("anticoagulant_zongliang")
2230
+	classes, _ := this.GetInt64("classes")
2231
+	dialyzers, _ := this.GetInt64("dialyzers")
2232
+	doctor_advice, _ := this.GetInt64("doctor_advice")
2233
+	mode, _ := this.GetInt64("mode")
2234
+	name, _ := this.GetInt64("name")
2235
+	number, _ := this.GetInt64("number")
2236
+	perfusion_apparatus, _ := this.GetInt64("perfusion_apparatus")
2237
+	prescription_status, _ := this.GetInt64("prescription_status")
2238
+	week, _ := this.GetInt64("week")
2239
+	zone, _ := this.GetInt64("zone")
2240
+	adminUserInfo := this.GetAdminUserInfo()
2241
+	orgId := adminUserInfo.CurrentOrgId
2242
+	setting := models.XtRemindPrintSetting{
2243
+		Anticoagulant:          anticoagulants,
2244
+		Classes:                classes,
2245
+		AnticoagulantZongliang: anticoagulant_zongliang,
2246
+		Dialyzers:              dialyzers,
2247
+		DoctorAdvice:           doctor_advice,
2248
+		Mode:                   mode,
2249
+		Name:                   name,
2250
+		Number:                 number,
2251
+		PerfusionApparatus:     perfusion_apparatus,
2252
+		PrescriptionStatus:     prescription_status,
2253
+		Week:                   week,
2254
+		Zone:                   zone,
2255
+		UserOrgId:              orgId,
2256
+		Status:                 1,
2257
+		Ctime:                  time.Now().Unix(),
2258
+	}
2259
+	_, errcode := service.GetSettingById(id)
2260
+	if errcode == gorm.ErrRecordNotFound {
2261
+		err := service.CreateSetting(&setting)
2262
+		if err != nil {
2263
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2264
+			return
2265
+		}
2266
+
2267
+		this.ServeSuccessJSON(map[string]interface{}{
2268
+			"setting": setting,
2269
+		})
2270
+	} else if errcode == nil {
2271
+		err := service.UpdatedRemindPrint(&setting, id)
2272
+		if err != nil {
2273
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2274
+			return
2275
+		}
2276
+
2277
+		this.ServeSuccessJSON(map[string]interface{}{
2278
+			"setting": setting,
2279
+		})
2280
+	}
2281
+
2282
+}
2283
+func (this *ScheduleApiController) GetRemindPrintList() {
2284
+
2285
+	adminUserInfo := this.GetAdminUserInfo()
2286
+	orgId := adminUserInfo.CurrentOrgId
2287
+	list, err := service.GetRemindPrintList(orgId)
2288
+	if err != nil {
2289
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2290
+		return
2291
+	}
2292
+
2293
+	this.ServeSuccessJSON(map[string]interface{}{
2294
+		"list": list,
2295
+	})
2296
+}
2297
+
2298
+func (this *ScheduleApiController) GetBloodScheduleList() {
2299
+
2300
+	week_type, _ := this.GetInt64("week_type", -1)
2301
+	week_time, _ := this.GetInt64("week_time")
2302
+	zone, _ := this.GetInt64("zone")
2303
+	thisTime := time.Now()
2304
+	weekDay := int(thisTime.Weekday())
2305
+	if weekDay == 0 {
2306
+		weekDay = 7
2307
+	}
2308
+	weekEnd := 7 - weekDay
2309
+	weekStart := weekEnd - 6
2310
+	weekTitle := make([]string, 0)
2311
+	days := make([]string, 0)
2312
+	for index := weekStart; index <= weekEnd; index++ {
2313
+		theDay := thisTime.AddDate(0, 0, index)
2314
+		indexYear, indexMonthTime, indexDay := theDay.Date()
2315
+		indexMonth := int(indexMonthTime)
2316
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
2317
+		weekTitle = append(weekTitle, indexWeek)
2318
+		days = append(days, theDay.Format("2006-01-02"))
2319
+	}
2320
+	fmt.Println(days)
2321
+
2322
+	var targetDayStr string
2323
+	var startTime string
2324
+	switch week_type {
2325
+	case 0:
2326
+		startTime = days[0]
2327
+		targetDayStr = days[6]
2328
+		break
2329
+	case 1:
2330
+		targetDayStr = days[0]
2331
+		break
2332
+	case 2:
2333
+		targetDayStr = days[1]
2334
+
2335
+		break
2336
+	case 3:
2337
+		targetDayStr = days[2]
2338
+
2339
+		break
2340
+	case 4:
2341
+		targetDayStr = days[3]
2342
+
2343
+		break
2344
+	case 5:
2345
+		targetDayStr = days[4]
2346
+
2347
+		break
2348
+	case 6:
2349
+		targetDayStr = days[5]
2350
+
2351
+		break
2352
+	case 7:
2353
+		targetDayStr = days[6]
2354
+
2355
+		break
2356
+	}
2357
+	targetDay, parseErr := utils.ParseTimeStringToTime("2006-01-02", targetDayStr)
2358
+
2359
+	if parseErr != nil {
2360
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
2361
+		return
2362
+	}
2363
+
2364
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2365
+	if week_type > 0 {
2366
+		list, err := service.GetWeekDayScheduleById(orgId, targetDay.Unix(), week_time)
2367
+		if err != nil {
2368
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2369
+			return
2370
+		}
2371
+
2372
+		this.ServeSuccessJSON(map[string]interface{}{
2373
+			"list": list,
2374
+			"day":  targetDayStr,
2375
+		})
2376
+	}
2377
+
2378
+	if week_type == 0 {
2379
+		startDate, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
2380
+		list, err := service.GetWeekDayScheduleByIdTwo(orgId, targetDay.Unix(), week_time, startDate.Unix(), zone)
2381
+		if err != nil {
2382
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2383
+			return
2384
+		}
2385
+
2386
+		this.ServeSuccessJSON(map[string]interface{}{
2387
+			"list": list,
2388
+			"day":  targetDayStr,
2389
+		})
2390
+	}
2391
+
2392
+}
2393
+
2394
+func (this *ScheduleApiController) GetPrintList() {
2395
+
2396
+	adminUserInfo := this.GetAdminUserInfo()
2397
+	orgId := adminUserInfo.CurrentOrgId
2398
+
2399
+	list, err := service.GetRemindPrintList(orgId)
2400
+	if err != nil {
2401
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2402
+		return
2403
+	}
2404
+
2405
+	this.ServeSuccessJSON(map[string]interface{}{
2406
+		"list": list,
2407
+	})
2408
+}
2409
+
2410
+func (this *ScheduleApiController) GetAllZoneList() {
2411
+
2412
+	adminUserInfo := this.GetAdminUserInfo()
2413
+	orgId := adminUserInfo.CurrentOrgId
2414
+	zoneList, err := service.GetAllZoneOne(orgId)
2415
+	if err != nil {
2416
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2417
+		return
2418
+	}
2419
+
2420
+	this.ServeSuccessJSON(map[string]interface{}{
2421
+		"zoneList": zoneList,
2422
+	})
2423
+}
2424
+
2425
+func (this *ScheduleApiController) GetPatientScheduleCount() {
2426
+	patitionIdStr := this.GetString("partition_id")
2427
+	week, _ := this.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
2428
+	ids := strings.Split(patitionIdStr, ",")
2429
+	adminUserInfo := this.GetAdminUserInfo()
2430
+	orgId := adminUserInfo.CurrentOrgId
2431
+	thisTime := time.Now()
2432
+	weekDay := int(thisTime.Weekday())
2433
+	if week < 1 || week > 4 {
2434
+		week = 2
2435
+	}
2436
+	if week == 1 {
2437
+		thisTime = thisTime.AddDate(0, 0, -7)
2438
+	} else if week == 3 {
2439
+		thisTime = thisTime.AddDate(0, 0, 7)
2440
+	} else if week == 4 {
2441
+		thisTime = thisTime.AddDate(0, 0, 14)
2442
+	}
2443
+	if weekDay == 0 {
2444
+		weekDay = 7
2445
+	}
2446
+	weekEnd := 7 - weekDay
2447
+	weekStart := weekEnd - 6
2448
+	weekTitle := make([]string, 0)
2449
+	days := make([]string, 0)
2450
+	for index := weekStart; index <= weekEnd; index++ {
2451
+		theDay := thisTime.AddDate(0, 0, index)
2452
+		indexYear, indexMonthTime, indexDay := theDay.Date()
2453
+		indexMonth := int(indexMonthTime)
2454
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
2455
+		weekTitle = append(weekTitle, indexWeek)
2456
+		days = append(days, theDay.Format("2006-01-02"))
2457
+	}
2458
+
2459
+	weekStartDay := thisTime.AddDate(0, 0, weekStart)
2460
+	weekEndDay := thisTime.AddDate(0, 0, weekEnd)
2461
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
2462
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
2463
+
2464
+	timeLayout := "2006-01-02 15:04:05"
2465
+	loc, _ := time.LoadLocation("Local")
2466
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
2467
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
2468
+	weekStartPoint := theStarTime.Unix()
2469
+	weekEndPoint := theEndTime.Unix()
2470
+	fmt.Println("startTime222222222222222", weekStartPoint)
2471
+	fmt.Println("endtime33333333333333", weekEndPoint)
2472
+	list, err := service.GetPatientScheduleCount(orgId, weekStartPoint, weekEndPoint, ids)
2473
+	_, total, _ := service.GetTotalBedNumber(orgId, ids)
2474
+	if err != nil {
2475
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
2476
+		return
2477
+	}
2478
+
2479
+	this.ServeSuccessJSON(map[string]interface{}{
2480
+		"list":  list,
2481
+		"total": total,
2482
+	})
2483
+}
2484
+
2485
+func (c *ScheduleApiController) GetWeekPanelsOne() {
2486
+
2487
+	data, _ := c.GetInt64("data", 1)
2488
+	patitionIdStr := c.GetString("patitionid")
2489
+
2490
+	ids := strings.Split(patitionIdStr, ",")
2491
+
2492
+	adminInfo := c.GetAdminUserInfo()
2493
+	thisTime := time.Now()
2494
+	year, monthTime, day := thisTime.Date()
2495
+	month := int(monthTime)
2496
+	_, theWeek := thisTime.ISOWeek()
2497
+	weekDay := int(thisTime.Weekday())
2498
+	if weekDay == 0 {
2499
+		weekDay = 7
2500
+	}
2501
+	weekEnd := 7 - weekDay
2502
+	weekStart := weekEnd - 6
2503
+	weekDays := make([]string, 0)
2504
+	for index := weekStart; index <= weekEnd; index++ {
2505
+		theDay := thisTime.AddDate(0, 0, index)
2506
+		indexYear, indexMonthTime, indexDay := theDay.Date()
2507
+		indexMonth := int(indexMonthTime)
2508
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
2509
+		weekDays = append(weekDays, indexWeek)
2510
+	}
2511
+
2512
+	returnData := map[string]interface{}{
2513
+		"year":     year,
2514
+		"month":    month,
2515
+		"day":      day,
2516
+		"theWeek":  theWeek,
2517
+		"weekDay":  weekDay,
2518
+		"weekDays": weekDays,
2519
+	}
2520
+
2521
+	if data == 1 {
2522
+		partitions, _ := service.GetSchedulePartitionPanelTwo(adminInfo.CurrentOrgId, ids)
2523
+		returnData["partitions"] = partitions
2524
+	}
2525
+
2526
+	c.ServeSuccessJSON(returnData)
2527
+	return
2528
+}
2529
+
2530
+func (c *ScheduleApiController) GetScheduleOne() {
2531
+
2532
+	week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
2533
+	patitionIdStr := c.GetString("patitionid")
2534
+
2535
+	ids := strings.Split(patitionIdStr, ",")
2536
+	fmt.Println("patitonStr", ids)
2537
+	schedule_type, _ := c.GetInt64("schedule_type")
2538
+
2539
+	adminInfo := c.GetAdminUserInfo()
2540
+
2541
+	thisTime := time.Now()
2542
+	today := thisTime.Format("2006-01-02")
2543
+	if week < 1 || week > 4 {
2544
+		week = 2
2545
+	}
2546
+	if week == 1 {
2547
+		thisTime = thisTime.AddDate(0, 0, -7)
2548
+	} else if week == 3 {
2549
+		thisTime = thisTime.AddDate(0, 0, 7)
2550
+	} else if week == 4 {
2551
+		thisTime = thisTime.AddDate(0, 0, 14)
2552
+	}
2553
+
2554
+	weekDay := int(thisTime.Weekday())
2555
+	if weekDay == 0 {
2556
+		weekDay = 7
2557
+	}
2558
+	weekEnd := 7 - weekDay
2559
+	weekStart := weekEnd - 6
2560
+	weekTitle := make([]string, 0)
2561
+	days := make([]string, 0)
2562
+	for index := weekStart; index <= weekEnd; index++ {
2563
+		theDay := thisTime.AddDate(0, 0, index)
2564
+		indexYear, indexMonthTime, indexDay := theDay.Date()
2565
+		indexMonth := int(indexMonthTime)
2566
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
2567
+		weekTitle = append(weekTitle, indexWeek)
2568
+		days = append(days, theDay.Format("2006-01-02"))
2569
+	}
2570
+
2571
+	weekStartDay := thisTime.AddDate(0, 0, weekStart)
2572
+	weekEndDay := thisTime.AddDate(0, 0, weekEnd)
2573
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
2574
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
2575
+
2576
+	timeLayout := "2006-01-02 15:04:05"
2577
+	loc, _ := time.LoadLocation("Local")
2578
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
2579
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
2580
+	weekStartPoint := theStarTime.Unix()
2581
+	weekEndPoint := theEndTime.Unix()
2582
+
2583
+	schdules, _ := service.GetWeekScheduleTwo(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
2584
+	c.ServeSuccessJSON(map[string]interface{}{
2585
+		"days":      days,
2586
+		"weekTitle": weekTitle,
2587
+		"schdules":  schdules,
2588
+		"today":     today,
2589
+	})
2590
+	return
2591
+}
2592
+
2593
+func (c *ScheduleApiController) SaveScheduleTemplate() {
2594
+
2595
+	template_id, _ := c.GetInt64("template_id")
2596
+	orgId := c.GetAdminUserInfo().CurrentOrgId
2597
+	template := models.ScheduleTemplate{
2598
+		TemplateId: template_id,
2599
+		UserOrgId:  orgId,
2600
+		Status:     1,
2601
+		Ctime:      time.Now().Unix(),
2602
+	}
2603
+
2604
+	_, errcodes := service.GetScheudleTemplateById(orgId)
2605
+	if errcodes == gorm.ErrRecordNotFound {
2606
+		service.CreateXtscheduleTemplate(&template)
2607
+	} else if errcodes == nil {
2608
+		service.UpdateXtScheduleTemplate(&template, orgId)
2609
+	}
2610
+
2611
+	c.ServeSuccessJSON(map[string]interface{}{
2612
+		"template": template,
2613
+	})
2614
+	return
2615
+
2616
+}
2617
+
2618
+func (c *ScheduleApiController) GetScheduleTemplate() {
2619
+
2620
+	adminUserInfo := c.GetAdminUserInfo()
2621
+	orgId := adminUserInfo.CurrentOrgId
2622
+	template, _ := service.GetScheduleTemplate(orgId)
2623
+	c.ServeSuccessJSON(map[string]interface{}{
2624
+		"template": template,
2625
+	})
2626
+	return
2627
+}
2628
+
2629
+func (c *ScheduleApiController) ChangeFuncPrint() {
2630
+
2631
+	adminUserInfo := c.GetAdminUserInfo()
2632
+	orgId := adminUserInfo.CurrentOrgId
2633
+	is_open, _ := c.GetInt64("is_open")
2634
+	dataPrint := models.XtDataPrint{
2635
+		UserOrgId: orgId,
2636
+		IsOpen:    is_open,
2637
+		Status:    1,
2638
+		Ctime:     time.Now().Unix(),
2639
+	}
2640
+
2641
+	_, errcode := service.GetDataPrintByOrgId(orgId)
2642
+	fmt.Println("errcode222234444555556t66", errcode)
2643
+	if errcode == gorm.ErrRecordNotFound {
2644
+		service.CreateDataPrint(&dataPrint)
2645
+		c.ServeSuccessJSON(map[string]interface{}{
2646
+			"dataPrint": dataPrint,
2647
+		})
2648
+		return
2649
+	} else if errcode == nil {
2650
+		service.UpdteDataPrint(orgId, &dataPrint)
2651
+		c.ServeSuccessJSON(map[string]interface{}{
2652
+			"dataPrint": dataPrint,
2653
+		})
2654
+		return
2655
+	}
2656
+
2657
+}
2658
+
2659
+func (c *ScheduleApiController) GetDataPrint() {
2660
+
2661
+	adminUserInfo := c.GetAdminUserInfo()
2662
+	orgId := adminUserInfo.CurrentOrgId
2663
+
2664
+	dataPrint, _ := service.GetDataPrint(orgId)
2665
+	c.ServeSuccessJSON(map[string]interface{}{
2666
+		"dataPrint": dataPrint,
2667
+	})
2668
+	return
2669
+}

+ 282 - 164
controllers/stock_in_api_controller.go View File

@@ -74,6 +74,8 @@ func StockManagerApiRegistRouters() {
74 74
 	beego.Router("/api/good/postdruginformation", &StockManagerApiController{}, "Post:AddDrugInformation")
75 75
 
76 76
 	beego.Router("/api/good/initializtion", &StockManagerApiController{}, "Get:GetInitializtion")
77
+
78
+	beego.Router("/api/good/getwarehouseorderinfolist", &StockManagerApiController{}, "Get:GetWarehouseOrderInfolist")
77 79
 }
78 80
 
79 81
 func (c *StockManagerApiController) CreateWarehouse() {
@@ -1817,7 +1819,7 @@ func (c *StockManagerApiController) GetQueryInfo() {
1817 1819
 	list, total, err := service.FindAllStockInfo(adminUserInfo.CurrentOrgId, page, limit, keyword, startTime, endTime, type_name)
1818 1820
 	info, err := service.GetCoutWareseOutInfo(startTime, endTime, adminUserInfo.CurrentOrgId)
1819 1821
 
1820
-	infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId)
1822
+	infomationList, err := service.GetGoodInfomationList(adminUserInfo.CurrentOrgId, "")
1821 1823
 	if err == nil {
1822 1824
 		c.ServeSuccessJSON(map[string]interface{}{
1823 1825
 			"list":           list,
@@ -2605,21 +2607,119 @@ func (this *StockManagerApiController) AddDrugInformation() {
2605 2607
 
2606 2608
 		drug.DrugName = drug_name
2607 2609
 
2608
-		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
2609
-			utils.ErrorLog("drug_alias")
2610
+		if goodNameM["unval"] == nil || reflect.TypeOf(goodNameM["unval"]).String() != "string" {
2611
+			utils.ErrorLog("unval")
2610 2612
 			return
2611 2613
 		}
2612 2614
 
2613
-		drug_alias, _ := goodNameM["drug_alias"].(string)
2615
+		unval, _ := goodNameM["unval"].(string)
2616
+		if len(drug_name) == 0 { //名字为空则生成一条导入错误日志
2617
+			err_log := models.ExportErrLog{
2618
+				LogType:    4,
2619
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2620
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零不能为空",
2621
+				Status:     1,
2622
+				CreateTime: time.Now().Unix(),
2623
+				UpdateTime: time.Now().Unix(),
2624
+				ExportTime: time.Now().Unix(),
2625
+			}
2626
+			service.CreateExportErrLog(&err_log)
2627
+			continue
2628
+		}
2614 2629
 
2615
-		drug.DrugAlias = drug_alias
2630
+		drug.Unval = unval
2631
+
2632
+		min_unit := goodNameM["min_unit"].(string)
2633
+		if len(min_unit) == 0 { //名字为空则生成一条导入错误日志
2634
+			err_log := models.ExportErrLog{
2635
+				LogType:    4,
2636
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2637
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零单位不能为空",
2638
+				Status:     1,
2639
+				CreateTime: time.Now().Unix(),
2640
+				UpdateTime: time.Now().Unix(),
2641
+				ExportTime: time.Now().Unix(),
2642
+			}
2643
+			service.CreateExportErrLog(&err_log)
2644
+			continue
2645
+		}
2646
+
2647
+		drug.MinUnit = min_unit
2648
+
2649
+		dosage, _ := goodNameM["dosage"].(string)
2650
+		if len(dosage) == 0 { //名字为空则生成一条导入错误日志
2651
+			err_log := models.ExportErrLog{
2652
+				LogType:    4,
2653
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2654
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
2655
+				Status:     1,
2656
+				CreateTime: time.Now().Unix(),
2657
+				UpdateTime: time.Now().Unix(),
2658
+				ExportTime: time.Now().Unix(),
2659
+			}
2660
+			service.CreateExportErrLog(&err_log)
2661
+			continue
2662
+		}
2663
+
2664
+		drug.Dosage = dosage
2665
+
2666
+		max_unit_id := goodNameM["max_unit"].(string)
2667
+		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2668
+			err_log := models.ExportErrLog{
2669
+				LogType:    4,
2670
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2671
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量单位不能为空",
2672
+				Status:     1,
2673
+				CreateTime: time.Now().Unix(),
2674
+				UpdateTime: time.Now().Unix(),
2675
+				ExportTime: time.Now().Unix(),
2676
+			}
2677
+			service.CreateExportErrLog(&err_log)
2678
+			continue
2679
+		}
2680
+
2681
+		drug.MaxUnit = max_unit_id
2682
+
2683
+		packing_unit := goodNameM["packing_unit"].(string)
2684
+		if len(packing_unit) == 0 { //名字为空则生成一条导入错误日志
2685
+			err_log := models.ExportErrLog{
2686
+				LogType:    4,
2687
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2688
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的包装单位不能为空",
2689
+				Status:     1,
2690
+				CreateTime: time.Now().Unix(),
2691
+				UpdateTime: time.Now().Unix(),
2692
+				ExportTime: time.Now().Unix(),
2693
+			}
2694
+			service.CreateExportErrLog(&err_log)
2695
+			continue
2696
+		}
2697
+
2698
+		drug.PackingUnit = packing_unit
2699
+
2700
+		delivery_way := goodNameM["delivery_way"].(string)
2701
+		if len(delivery_way) == 0 { //名字为空则生成一条导入错误日志
2702
+			err_log := models.ExportErrLog{
2703
+				LogType:    4,
2704
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2705
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认给药途径不能为空",
2706
+				Status:     1,
2707
+				CreateTime: time.Now().Unix(),
2708
+				UpdateTime: time.Now().Unix(),
2709
+				ExportTime: time.Now().Unix(),
2710
+			}
2711
+			service.CreateExportErrLog(&err_log)
2712
+			continue
2713
+		}
2616 2714
 
2617
-		drug_spec, _ := goodNameM["drug_spec"].(string)
2618
-		if len(drug_spec) == 0 { //名字为空则生成一条导入错误日志
2715
+		drug.DeliveryWay = delivery_way
2716
+
2717
+		execution_frequency := goodNameM["execution_frequency"].(string)
2718
+		if len(execution_frequency) == 0 { //名字为空则生成一条导入错误日志
2619 2719
 			err_log := models.ExportErrLog{
2620 2720
 				LogType:    4,
2621 2721
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2622
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的药品规格不能为空",
2722
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
2623 2723
 				Status:     1,
2624 2724
 				CreateTime: time.Now().Unix(),
2625 2725
 				UpdateTime: time.Now().Unix(),
@@ -2629,7 +2729,24 @@ func (this *StockManagerApiController) AddDrugInformation() {
2629 2729
 			continue
2630 2730
 		}
2631 2731
 
2632
-		drug.DrugSpec = drug_spec
2732
+		drug.ExecutionFrequency = execution_frequency
2733
+
2734
+		drug_day := goodNameM["drug_day"].(string)
2735
+		if len(drug_day) == 0 { //名字为空则生成一条导入错误日志
2736
+			err_log := models.ExportErrLog{
2737
+				LogType:    4,
2738
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2739
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认执行频率不能为空",
2740
+				Status:     1,
2741
+				CreateTime: time.Now().Unix(),
2742
+				UpdateTime: time.Now().Unix(),
2743
+				ExportTime: time.Now().Unix(),
2744
+			}
2745
+			service.CreateExportErrLog(&err_log)
2746
+			continue
2747
+		}
2748
+
2749
+		drug.DrugDay = drug_day
2633 2750
 
2634 2751
 		drug_type := goodNameM["drug_type"].(string)
2635 2752
 		if len(drug_type) == 0 { //名字为空则生成一条导入错误日志
@@ -2826,12 +2943,12 @@ func (this *StockManagerApiController) AddDrugInformation() {
2826 2943
 		}
2827 2944
 		drug.MedicalInsuranceLevel = medical_insurance_level_id
2828 2945
 
2829
-		max_unit_id := goodNameM["max_unit"].(string)
2946
+		unit_matrixing := goodNameM["unit_matrixing"].(string)
2830 2947
 		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2831 2948
 			err_log := models.ExportErrLog{
2832 2949
 				LogType:    4,
2833 2950
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2834
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的最大不能为空",
2951
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
2835 2952
 				Status:     1,
2836 2953
 				CreateTime: time.Now().Unix(),
2837 2954
 				UpdateTime: time.Now().Unix(),
@@ -2841,14 +2958,15 @@ func (this *StockManagerApiController) AddDrugInformation() {
2841 2958
 			continue
2842 2959
 		}
2843 2960
 
2844
-		drug.MaxUnit = max_unit_id
2961
+		drug.UnitMatrixing = unit_matrixing
2962
+		retail_prices := goodNameM["retail_price"].(string)
2963
+		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
2845 2964
 
2846
-		min_unit := goodNameM["min_unit"].(string)
2847
-		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2965
+		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2848 2966
 			err_log := models.ExportErrLog{
2849 2967
 				LogType:    4,
2850 2968
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2851
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的最小单位不能为空",
2969
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的拆零售价不能为空",
2852 2970
 				Status:     1,
2853 2971
 				CreateTime: time.Now().Unix(),
2854 2972
 				UpdateTime: time.Now().Unix(),
@@ -2858,32 +2976,16 @@ func (this *StockManagerApiController) AddDrugInformation() {
2858 2976
 			continue
2859 2977
 		}
2860 2978
 
2861
-		drug.MinUnit = min_unit
2862
-
2863
-		unit_matrixing := goodNameM["unit_matrixing"].(string)
2864
-		if len(max_unit_id) == 0 { //名字为空则生成一条导入错误日志
2865
-			err_log := models.ExportErrLog{
2866
-				LogType:    4,
2867
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2868
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的单位换算不能为空",
2869
-				Status:     1,
2870
-				CreateTime: time.Now().Unix(),
2871
-				UpdateTime: time.Now().Unix(),
2872
-				ExportTime: time.Now().Unix(),
2873
-			}
2874
-			service.CreateExportErrLog(&err_log)
2875
-			continue
2876
-		}
2979
+		drug.RetailPrice = retail_price
2877 2980
 
2878
-		drug.UnitMatrixing = unit_matrixing
2879
-		retail_prices := goodNameM["retail_price"].(string)
2880
-		retail_price, _ := strconv.ParseFloat(retail_prices, 64)
2981
+		packing_prices := goodNameM["packing_price"].(string)
2982
+		packing_price, _ := strconv.ParseFloat(packing_prices, 64)
2881 2983
 
2882
-		if retail_price <= 0 { //名字为空则生成一条导入错误日志
2984
+		if packing_price <= 0 { //名字为空则生成一条导入错误日志
2883 2985
 			err_log := models.ExportErrLog{
2884 2986
 				LogType:    4,
2885 2987
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2886
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的零售价不能为空",
2988
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的包装零售价不能为空",
2887 2989
 				Status:     1,
2888 2990
 				CreateTime: time.Now().Unix(),
2889 2991
 				UpdateTime: time.Now().Unix(),
@@ -2901,7 +3003,7 @@ func (this *StockManagerApiController) AddDrugInformation() {
2901 3003
 			err_log := models.ExportErrLog{
2902 3004
 				LogType:    4,
2903 3005
 				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
2904
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的上次进价不能为空",
3006
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的进价不能为空",
2905 3007
 				Status:     1,
2906 3008
 				CreateTime: time.Now().Unix(),
2907 3009
 				UpdateTime: time.Now().Unix(),
@@ -2966,6 +3068,77 @@ func (this *StockManagerApiController) AddDrugInformation() {
2966 3068
 			}
2967 3069
 		}
2968 3070
 
3071
+		drug_dose := goodNameM["drug_dose"].(string)
3072
+
3073
+		if len(drug_dose) == 0 {
3074
+			err_log := models.ExportErrLog{
3075
+				LogType:    4,
3076
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3077
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认单次用量不能为空",
3078
+				Status:     1,
3079
+				CreateTime: time.Now().Unix(),
3080
+				UpdateTime: time.Now().Unix(),
3081
+				ExportTime: time.Now().Unix(),
3082
+			}
3083
+			service.CreateExportErrLog(&err_log)
3084
+			continue
3085
+		}
3086
+		drugDoses, _ := strconv.ParseFloat(drug_dose, 64)
3087
+		drug.DrugDose = drugDoses
3088
+
3089
+		var units = "单位"
3090
+		var unit_id int64
3091
+		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
3092
+
3093
+		if len(drugDoseUnit) == 0 {
3094
+			err_log := models.ExportErrLog{
3095
+				LogType:    4,
3096
+				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3097
+				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的默认单次用量单位不能为空",
3098
+				Status:     1,
3099
+				CreateTime: time.Now().Unix(),
3100
+				UpdateTime: time.Now().Unix(),
3101
+				ExportTime: time.Now().Unix(),
3102
+			}
3103
+			service.CreateExportErrLog(&err_log)
3104
+			continue
3105
+		}
3106
+
3107
+		dataConfig, _ := service.GetDataConfigIsExist(0, units)
3108
+		if len(drugDoseUnit) != 0 {
3109
+			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3110
+			if errcodedataconfig == gorm.ErrRecordNotFound {
3111
+				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3112
+				dataconfig := models.Dataconfig{
3113
+					ParentId:       dataConfig.ID,
3114
+					Module:         "hemodialysis",
3115
+					OrgId:          orgId,
3116
+					Name:           drugDoseUnit,
3117
+					FieldName:      "",
3118
+					Value:          childConfig.Value + 1,
3119
+					CreatedTime:    "",
3120
+					UpdatedTime:    "",
3121
+					CreateUserId:   adminUser.AdminUser.Id,
3122
+					Status:         1,
3123
+					Remark:         "",
3124
+					DeleteIdSystem: 0,
3125
+					Title:          "",
3126
+					Content:        "",
3127
+					Order:          0,
3128
+					Code:           "",
3129
+					FieldType:      0,
3130
+				}
3131
+				service.CreateDataConfig(&dataconfig)
3132
+			}
3133
+		}
3134
+		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
3135
+		for _, it := range list {
3136
+			if drugDoseUnit == it.Name {
3137
+				unit_id = int64(it.Value)
3138
+			}
3139
+		}
3140
+		drug.DrugDoseUnit = unit_id
3141
+
2969 3142
 		drug.DrugClassify = strconv.FormatInt(drug_classify_id, 10)
2970 3143
 
2971 3144
 		manufacturer := goodNameM["manufacturer"].(string)
@@ -3031,14 +3204,61 @@ func (this *StockManagerApiController) AddDrugInformation() {
3031 3204
 		}
3032 3205
 		drug.Dealer = dealer_id
3033 3206
 
3034
-		pinyin := goodNameM["pinyin"].(string)
3207
+		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
3035 3208
 
3036
-		drug.Pinyin = pinyin
3037
-		wubi := goodNameM["wubi"].(string)
3038
-		drug.Wubi = wubi
3209
+		drug.LmtUsedFlag = lmt_used_flags
3210
+
3211
+		if goodNameM["drug_alias"] == nil || reflect.TypeOf(goodNameM["drug_alias"]).String() != "string" {
3212
+			utils.ErrorLog("drug_alias")
3213
+			return
3214
+		}
3215
+
3216
+		drug_alias, _ := goodNameM["drug_alias"].(string)
3217
+
3218
+		drug.DrugAlias = drug_alias
3219
+
3220
+		drug_category := goodNameM["drug_category"].(string)
3221
+
3222
+		var drugCategory = "药品类别"
3223
+		var drug_category_id int64
3224
+
3225
+		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3226
+
3227
+		if len(drug_category) != 0 {
3228
+			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3229
+			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3230
+				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3231
+				dataconfig := models.DictDataconfig{
3232
+					ParentId:       drugCategoryConfig.ID,
3233
+					Module:         "system",
3234
+					OrgId:          orgId,
3235
+					Name:           drug_category,
3236
+					FieldName:      "",
3237
+					Value:          drugCategoryConfigSix.Value + 1,
3238
+					CreatedTime:    "",
3239
+					UpdatedTime:    "",
3240
+					CreateUserId:   adminUser.AdminUser.Id,
3241
+					Status:         1,
3242
+					Remark:         "",
3243
+					DeleteIdSystem: 0,
3244
+					Title:          "",
3245
+					Content:        "",
3246
+					Order:          0,
3247
+					Code:           "",
3248
+				}
3249
+				service.CreatedDicConfig(&dataconfig)
3250
+			}
3251
+		}
3252
+
3253
+		drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
3254
+		fmt.Println("drugCategoryList", drugCategoryList)
3255
+		for _, it := range drugCategoryList {
3256
+			if drug_category == it.Name {
3257
+				drug_category_id = int64(it.Value)
3258
+			}
3259
+		}
3039 3260
 
3040
-		drug_alias_pinyin := goodNameM["drug_alias_pinyin"].(string)
3041
-		drug.DrugAliasPinyin = drug_alias_pinyin
3261
+		drug.DrugCategory = drug_category_id
3042 3262
 
3043 3263
 		statistics_category := goodNameM["statistics_category"].(string)
3044 3264
 
@@ -3151,9 +3371,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
3151 3371
 		limit_remark := goodNameM["limit_remark"].(string)
3152 3372
 		drug.LimitRemark = limit_remark
3153 3373
 
3154
-		drug_alias_wubi := goodNameM["drug_alias_wubi"].(string)
3155
-		drug.DrugAliasWubi = drug_alias_wubi
3156
-
3157 3374
 		drug_control := goodNameM["drug_control"].(string)
3158 3375
 
3159 3376
 		var drugControl = "开药控制"
@@ -3194,123 +3411,6 @@ func (this *StockManagerApiController) AddDrugInformation() {
3194 3411
 		}
3195 3412
 		drug.DrugControl = drug_control_id
3196 3413
 
3197
-		drug_category := goodNameM["drug_category"].(string)
3198
-
3199
-		var drugCategory = "药品类别"
3200
-		var drug_category_id int64
3201
-
3202
-		drugCategoryConfig, _ := service.GetDrugDataConfig(0, drugCategory)
3203
-
3204
-		if len(drug_category) != 0 {
3205
-			_, drugcategoryerrcodes := service.IsExistDicConfig(drugCategoryConfig.ID, drug_category, orgId)
3206
-			if drugcategoryerrcodes == gorm.ErrRecordNotFound {
3207
-				drugCategoryConfigSix, _ := service.GetLastDicConfig(drugCategoryConfig.ID, orgId)
3208
-				dataconfig := models.DictDataconfig{
3209
-					ParentId:       drugCategoryConfig.ID,
3210
-					Module:         "system",
3211
-					OrgId:          orgId,
3212
-					Name:           drug_category,
3213
-					FieldName:      "",
3214
-					Value:          drugCategoryConfigSix.Value + 1,
3215
-					CreatedTime:    "",
3216
-					UpdatedTime:    "",
3217
-					CreateUserId:   adminUser.AdminUser.Id,
3218
-					Status:         1,
3219
-					Remark:         "",
3220
-					DeleteIdSystem: 0,
3221
-					Title:          "",
3222
-					Content:        "",
3223
-					Order:          0,
3224
-					Code:           "",
3225
-				}
3226
-				service.CreatedDicConfig(&dataconfig)
3227
-			}
3228
-		}
3229
-
3230
-		drugCategoryList, _ := service.GetParentDataConfig(drugCategoryConfig.ID, orgId)
3231
-		fmt.Println("drugCategoryList", drugCategoryList)
3232
-		for _, it := range drugCategoryList {
3233
-			if drug_category == it.Name {
3234
-				drug_category_id = int64(it.Value)
3235
-			}
3236
-		}
3237
-
3238
-		drug.DrugCategory = drug_category_id
3239
-
3240
-		drug_dose := goodNameM["drug_dose"].(string)
3241
-
3242
-		if len(drug_dose) == 0 {
3243
-			err_log := models.ExportErrLog{
3244
-				LogType:    4,
3245
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3246
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
3247
-				Status:     1,
3248
-				CreateTime: time.Now().Unix(),
3249
-				UpdateTime: time.Now().Unix(),
3250
-				ExportTime: time.Now().Unix(),
3251
-			}
3252
-			service.CreateExportErrLog(&err_log)
3253
-			continue
3254
-		}
3255
-		drugDoses, _ := strconv.ParseFloat(drug_dose, 64)
3256
-		drug.DrugDose = drugDoses
3257
-
3258
-		var units = "单位"
3259
-		var unit_id int64
3260
-		drugDoseUnit := goodNameM["drug_dose_unit"].(string)
3261
-
3262
-		if len(drugDoseUnit) == 0 {
3263
-			err_log := models.ExportErrLog{
3264
-				LogType:    4,
3265
-				UserOrgId:  this.GetAdminUserInfo().CurrentOrgId,
3266
-				ErrMsg:     "第" + strconv.Itoa(index+2) + "行" + "的剂量不能为空",
3267
-				Status:     1,
3268
-				CreateTime: time.Now().Unix(),
3269
-				UpdateTime: time.Now().Unix(),
3270
-				ExportTime: time.Now().Unix(),
3271
-			}
3272
-			service.CreateExportErrLog(&err_log)
3273
-			continue
3274
-		}
3275
-
3276
-		dataConfig, _ := service.GetDataConfigIsExist(0, units)
3277
-		if len(drugDoseUnit) != 0 {
3278
-			_, errcodedataconfig := service.GetChildeConfigIsExist(dataConfig.ID, drugDoseUnit, orgId)
3279
-			if errcodedataconfig == gorm.ErrRecordNotFound {
3280
-				childConfig, _ := service.GetLastChildeConfig(dataConfig.ID, orgId)
3281
-				dataconfig := models.Dataconfig{
3282
-					ParentId:       dataConfig.ID,
3283
-					Module:         "hemodialysis",
3284
-					OrgId:          orgId,
3285
-					Name:           drugDoseUnit,
3286
-					FieldName:      "",
3287
-					Value:          childConfig.Value + 1,
3288
-					CreatedTime:    "",
3289
-					UpdatedTime:    "",
3290
-					CreateUserId:   adminUser.AdminUser.Id,
3291
-					Status:         1,
3292
-					Remark:         "",
3293
-					DeleteIdSystem: 0,
3294
-					Title:          "",
3295
-					Content:        "",
3296
-					Order:          0,
3297
-					Code:           "",
3298
-					FieldType:      0,
3299
-				}
3300
-				service.CreateDataConfig(&dataconfig)
3301
-			}
3302
-		}
3303
-		list, _ := service.FindAllDataConfigList(orgId, dataConfig.ID)
3304
-		for _, it := range list {
3305
-			if drugDoseUnit == it.Name {
3306
-				unit_id = int64(it.Value)
3307
-			}
3308
-		}
3309
-		drug.DrugDoseUnit = unit_id
3310
-
3311
-		lmt_used_flags := int64(goodNameM["lmt_used_flag"].(float64))
3312
-
3313
-		drug.LmtUsedFlag = lmt_used_flags
3314 3414
 		drugList = append(drugList, &drug)
3315 3415
 	}
3316 3416
 
@@ -3363,10 +3463,17 @@ func (this *StockManagerApiController) AddDrugInformation() {
3363 3463
 				DrugDose:                    item.DrugDose,
3364 3464
 				DrugDoseUnit:                item.DrugDoseUnit,
3365 3465
 				LmtUsedFlag:                 item.LmtUsedFlag,
3466
+				Dosage:                      item.Dosage,
3467
+				Unval:                       item.Unval,
3468
+				PackingUnit:                 item.PackingUnit,
3469
+				PackingPrice:                item.PackingPrice,
3470
+				DrugDay:                     item.DrugDay,
3471
+				DeliveryWay:                 item.DeliveryWay,
3472
+				ExecutionFrequency:          item.ExecutionFrequency,
3366 3473
 			}
3367 3474
 
3368 3475
 			//查询同种药品同种规格是否存在
3369
-			_, drugerror := service.IsExistDrugByName(item.DrugName, item.DrugSpec, orgId)
3476
+			_, drugerror := service.IsExistDrugByNameOne(item.DrugName, item.Dosage, item.MaxUnit, item.Unval, item.MinUnit, item.PackingUnit, orgId)
3370 3477
 
3371 3478
 			if drugerror == gorm.ErrRecordNotFound {
3372 3479
 				service.CreateDrugsInfomation(&goodInfo)
@@ -3475,3 +3582,14 @@ func (this *StockManagerApiController) GetInitializtion() {
3475 3582
 		"costClassifyList":          costClassifyList,
3476 3583
 	})
3477 3584
 }
3585
+
3586
+func (this *StockManagerApiController) GetWarehouseOrderInfolist() {
3587
+
3588
+	adminUserInfo := this.GetAdminUserInfo()
3589
+	orgId := adminUserInfo.CurrentOrgId
3590
+	list, _ := service.GetWarehouseOrderInfoList(orgId)
3591
+
3592
+	this.ServeSuccessJSON(map[string]interface{}{
3593
+		"list": list,
3594
+	})
3595
+}

+ 4 - 0
enums/error_code.go View File

@@ -230,6 +230,8 @@ const ( // ErrorCode
230 230
 	ErrorCodeOrderParamWrong = 300003
231 231
 
232 232
 	ErrorCodeHisPatientParamWrong = 300004
233
+
234
+	ErrorCodeOutOfStockParamWrong = 300300
233 235
 )
234 236
 
235 237
 var ErrCodeMsgs = map[int]string{
@@ -450,6 +452,8 @@ var ErrCodeMsgs = map[int]string{
450 452
 	ErrorCodeOrderParamWrong: "结算记录不存在",
451 453
 
452 454
 	ErrorCodeHisPatientParamWrong: "订单正在结算、请先结算完成",
455
+
456
+	ErrorCodeOutOfStockParamWrong: "库存不足",
453 457
 }
454 458
 
455 459
 type SGJError struct {

+ 32 - 0
models/device_models.go View File

@@ -1022,3 +1022,35 @@ func (XtDevicePh) TableName() string {
1022 1022
 
1023 1023
 	return "xt_device_ph"
1024 1024
 }
1025
+
1026
+type XtRemindPrintSetting struct {
1027
+	ID                     int64 `gorm:"column:id" json:"id" form:"id"`
1028
+	PrescriptionStatus     int64 `gorm:"column:prescription_status" json:"prescription_status" form:"prescription_status"`
1029
+	Week                   int64 `gorm:"column:week" json:"week" form:"week"`
1030
+	Name                   int64 `gorm:"column:name" json:"name" form:"name"`
1031
+	Zone                   int64 `gorm:"column:zone" json:"zone" form:"zone"`
1032
+	Classes                int64 `gorm:"column:classes" json:"classes" form:"classes"`
1033
+	Number                 int64 `gorm:"column:number" json:"number" form:"number"`
1034
+	Mode                   int64 `gorm:"column:mode" json:"mode" form:"mode"`
1035
+	Dialyzers              int64 `gorm:"column:dialyzers" json:"dialyzers" form:"dialyzers"`
1036
+	PerfusionApparatus     int64 `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
1037
+	Anticoagulant          int64 `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
1038
+	DoctorAdvice           int64 `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
1039
+	UserOrgId              int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1040
+	Status                 int64 `gorm:"column:status" json:"status" form:"status"`
1041
+	Ctime                  int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
1042
+	Mtime                  int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
1043
+	AnticoagulantZongliang int64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
1044
+}
1045
+
1046
+func (XtRemindPrintSetting) TableName() string {
1047
+
1048
+	return "xt_remind_print_setting"
1049
+}
1050
+
1051
+type VmXtSchedule struct {
1052
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
1053
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
1054
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
1055
+	Count        int64
1056
+}

+ 145 - 121
models/dialysis.go View File

@@ -84,81 +84,82 @@ func (SchedualPatient) TableName() string {
84 84
 }
85 85
 
86 86
 type SchedualPatient2 struct {
87
-	ID                      int64                `gorm:"column:id" json:"id" form:"id"`
88
-	UserOrgId               int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
89
-	UserId                  int64                `gorm:"column:user_id" json:"user_id" form:"user_id"`
90
-	PatientType             int64                `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
91
-	Avatar                  string               `gorm:"column:avatar" json:"avatar" form:"avatar"`
92
-	DialysisNo              string               `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
93
-	AdmissionNumber         string               `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
94
-	Source                  int64                `gorm:"column:source" json:"source" form:"source"`
95
-	Lapseto                 int64                `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
96
-	PartitionId             int64                `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
97
-	BedId                   int64                `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
98
-	Name                    string               `gorm:"column:name" json:"name" form:"name"`
99
-	Alias                   string               `gorm:"column:alias" json:"alias" form:"alias"`
100
-	Gender                  int64                `gorm:"column:gender" json:"gender" form:"gender"`
101
-	Nation                  string               `gorm:"column:nation" json:"nation" form:"nation"`
102
-	NativePlace             string               `gorm:"column:native_place" json:"native_place" form:"native_place"`
103
-	MaritalStatus           int64                `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
104
-	IdCardNo                string               `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
105
-	Birthday                int64                `gorm:"column:birthday" json:"birthday" form:"birthday"`
106
-	ReimbursementWayId      int64                `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
107
-	HealthCareType          int64                `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
108
-	HealthCareNo            string               `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
109
-	HealthCareDueDate       int64                `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
110
-	Height                  int64                `gorm:"column:height" json:"height" form:"height"`
111
-	BloodType               int64                `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
112
-	Rh                      int64                `gorm:"column:rh" json:"rh" form:"rh"`
113
-	HealthCareDueAlertDate  int64                `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
114
-	EducationLevel          int64                `gorm:"column:education_level" json:"education_level" form:"education_level"`
115
-	Profession              int64                `gorm:"column:profession" json:"profession" form:"profession"`
116
-	Phone                   string               `gorm:"column:phone" json:"phone" form:"phone"`
117
-	HomeTelephone           string               `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
118
-	RelativePhone           string               `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
119
-	RelativeRelations       string               `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
120
-	HomeAddress             string               `gorm:"column:home_address" json:"home_address" form:"home_address"`
121
-	WorkUnit                string               `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
122
-	UnitAddress             string               `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
123
-	Children                int64                `gorm:"column:children" json:"children" form:"children"`
124
-	ReceivingDate           int64                `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
125
-	IsHospitalFirstDialysis int64                `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
126
-	FirstDialysisDate       int64                `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
127
-	FirstDialysisHospital   string               `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
128
-	InductionPeriod         int64                `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
129
-	InitialDialysis         int64                `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
130
-	TotalDialysis           int64                `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
131
-	AttendingDoctorId       int64                `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
132
-	HeadNurseId             int64                `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
133
-	Evaluate                string               `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
134
-	Diagnose                string               `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
135
-	Remark                  string               `gorm:"column:remark" json:"remark" form:"remark"`
136
-	RegistrarsId            int64                `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
137
-	Registrars              string               `gorm:"column:registrars" json:"registrars" form:"registrars"`
138
-	QrCode                  string               `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
139
-	BindingState            int64                `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
140
-	PatientComplains        string               `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
141
-	PresentHistory          string               `gorm:"column:present_history" json:"present_history"`     // 现病史
142
-	PastHistory             string               `gorm:"column:past_history" json:"past_history"`           // 既往史
143
-	Temperature             float64              `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
144
-	Pulse                   int64                `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
145
-	Respiratory             int64                `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
146
-	SBP                     int64                `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
147
-	DBP                     int64                `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
148
-	Status                  int64                `gorm:"column:status" json:"status" form:"status"`
149
-	CreatedTime             int64                `gorm:"column:created_time" json:"created_time" form:"created_time"`
150
-	UpdatedTime             int64                `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
151
-	DialysisSchedule        DialysisSchedule     `gorm:"ForeignKey:PatientId"`
152
-	InfectiousDiseases      []InfectiousDiseases `gorm:"ForeignKey:PatientId"`
153
-	Age                     int64                `gorm:"column:age" json:"age"`
154
-	IsOpenRemind            int64                `gorm:"column:is_open_remind" json:"is_open_remind"`
155
-	DialysisAge             int64                `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
156
-	ExpenseKind             int64                `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
157
-	TellPhone               string               `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
158
-	FirstTreatmentDate      int64                `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
159
-	ContactName             string               `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
160
-	UserSysBeforeCount      int64                `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
161
-	SchRemark               string               `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
87
+	ID                        int64                `gorm:"column:id" json:"id" form:"id"`
88
+	UserOrgId                 int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
89
+	UserId                    int64                `gorm:"column:user_id" json:"user_id" form:"user_id"`
90
+	PatientType               int64                `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
91
+	Avatar                    string               `gorm:"column:avatar" json:"avatar" form:"avatar"`
92
+	DialysisNo                string               `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
93
+	AdmissionNumber           string               `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
94
+	Source                    int64                `gorm:"column:source" json:"source" form:"source"`
95
+	Lapseto                   int64                `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
96
+	PartitionId               int64                `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
97
+	BedId                     int64                `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
98
+	Name                      string               `gorm:"column:name" json:"name" form:"name"`
99
+	Alias                     string               `gorm:"column:alias" json:"alias" form:"alias"`
100
+	Gender                    int64                `gorm:"column:gender" json:"gender" form:"gender"`
101
+	Nation                    string               `gorm:"column:nation" json:"nation" form:"nation"`
102
+	NativePlace               string               `gorm:"column:native_place" json:"native_place" form:"native_place"`
103
+	MaritalStatus             int64                `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
104
+	IdCardNo                  string               `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
105
+	Birthday                  int64                `gorm:"column:birthday" json:"birthday" form:"birthday"`
106
+	ReimbursementWayId        int64                `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
107
+	HealthCareType            int64                `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
108
+	HealthCareNo              string               `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
109
+	HealthCareDueDate         int64                `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
110
+	Height                    int64                `gorm:"column:height" json:"height" form:"height"`
111
+	BloodType                 int64                `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
112
+	Rh                        int64                `gorm:"column:rh" json:"rh" form:"rh"`
113
+	HealthCareDueAlertDate    int64                `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
114
+	EducationLevel            int64                `gorm:"column:education_level" json:"education_level" form:"education_level"`
115
+	Profession                int64                `gorm:"column:profession" json:"profession" form:"profession"`
116
+	Phone                     string               `gorm:"column:phone" json:"phone" form:"phone"`
117
+	HomeTelephone             string               `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
118
+	RelativePhone             string               `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
119
+	RelativeRelations         string               `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
120
+	HomeAddress               string               `gorm:"column:home_address" json:"home_address" form:"home_address"`
121
+	WorkUnit                  string               `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
122
+	UnitAddress               string               `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
123
+	Children                  int64                `gorm:"column:children" json:"children" form:"children"`
124
+	ReceivingDate             int64                `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
125
+	IsHospitalFirstDialysis   int64                `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
126
+	FirstDialysisDate         int64                `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
127
+	FirstDialysisHospital     string               `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
128
+	InductionPeriod           int64                `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
129
+	InitialDialysis           int64                `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
130
+	TotalDialysis             int64                `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
131
+	AttendingDoctorId         int64                `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
132
+	HeadNurseId               int64                `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
133
+	Evaluate                  string               `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
134
+	Diagnose                  string               `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
135
+	Remark                    string               `gorm:"column:remark" json:"remark" form:"remark"`
136
+	RegistrarsId              int64                `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
137
+	Registrars                string               `gorm:"column:registrars" json:"registrars" form:"registrars"`
138
+	QrCode                    string               `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
139
+	BindingState              int64                `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
140
+	PatientComplains          string               `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
141
+	PresentHistory            string               `gorm:"column:present_history" json:"present_history"`     // 现病史
142
+	PastHistory               string               `gorm:"column:past_history" json:"past_history"`           // 既往史
143
+	Temperature               float64              `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
144
+	Pulse                     int64                `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
145
+	Respiratory               int64                `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
146
+	SBP                       int64                `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
147
+	DBP                       int64                `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
148
+	Status                    int64                `gorm:"column:status" json:"status" form:"status"`
149
+	CreatedTime               int64                `gorm:"column:created_time" json:"created_time" form:"created_time"`
150
+	UpdatedTime               int64                `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
151
+	DialysisSchedule          DialysisSchedule     `gorm:"ForeignKey:PatientId"`
152
+	InfectiousDiseases        []InfectiousDiseases `gorm:"ForeignKey:PatientId"`
153
+	Age                       int64                `gorm:"column:age" json:"age"`
154
+	IsOpenRemind              int64                `gorm:"column:is_open_remind" json:"is_open_remind"`
155
+	DialysisAge               int64                `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
156
+	ExpenseKind               int64                `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
157
+	TellPhone                 string               `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
158
+	FirstTreatmentDate        int64                `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
159
+	ContactName               string               `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
160
+	UserSysBeforeCount        int64                `gorm:"column:user_sys_before_count" json:"user_sys_before_count" form:"user_sys_before_count"`
161
+	SchRemark                 string               `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
162
+	HospitalFirstDialysisDate int64                `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
162 163
 }
163 164
 
164 165
 func (SchedualPatient2) TableName() string {
@@ -280,6 +281,11 @@ type PredialysisEvaluation struct {
280 281
 	ThrombusAv                     string  `gorm:"column:thrombus_av" json:"thrombus_av" form:"thrombus_av"`
281 282
 	ThromubusA                     string  `gorm:"column:thromubus_a" json:"thromubus_a" form:"thromubus_a"`
282 283
 	ThromubusV                     string  `gorm:"column:thromubus_v" json:"thromubus_v" form:"thromubus_v"`
284
+	Dehydration                    string  `gorm:"column:dehydration" json:"dehydration" form:"dehydration"`
285
+	PreDialysisDrugs               string  `gorm:"column:pre_dialysis_drugs" json:"pre_dialysis_drugs" form:"pre_dialysis_drugs"`
286
+	Period                         int64   `gorm:"column:period" json:"period" form:"period"`
287
+	EstimatedFoodIntake            string  `gorm:"column:estimated_food_intake" json:"estimated_food_intake" form:"estimated_food_intake"`
288
+	BloodPressureDuringDialysis    string  `gorm:"column:blood_pressure_during_dialysis" json:"blood_pressure_during_dialysis" form:"blood_pressure_during_dialysis"`
283 289
 }
284 290
 
285 291
 func (PredialysisEvaluation) TableName() string {
@@ -586,6 +592,13 @@ type AssessmentAfterDislysis struct {
586 592
 	DiastolicPressure               string  `gorm:"column:diastolic_pressure" json:"diastolic_pressure" form:"diastolic_pressure"`
587 593
 	OtherComplication               string  `gorm:"column:other_complication" json:"other_complication" form:"other_complication"`
588 594
 	Ktv                             string  `gorm:"column:ktv" json:"ktv" form:"ktv"`
595
+	Urr                             string  `gorm:"column:urr" json:"urr" form:"urr"`
596
+	Hypertenison                    int64   `gorm:"column:hypertenison" json:"hypertenison" form:"hypertenison"`
597
+	Hypopiesia                      int64   `gorm:"column:hypopiesia" json:"hypopiesia" form:"hypopiesia"`
598
+	LeaveOfficeMethod               int64   `gorm:"column:leave_office_method" json:"leave_office_method" form:"leave_office_method"`
599
+	Lapse                           int64   `gorm:"column:lapse" json:"lapse" form:"lapse"`
600
+	Consciousness                   int64   `gorm:"column:consciousness" json:"consciousness" form:"consciousness"`
601
+	Fallrisk                        int64   `gorm:"column:fallrisk" json:"fallrisk" form:"fallrisk"`
589 602
 }
590 603
 
591 604
 func (AssessmentAfterDislysis) TableName() string {
@@ -642,52 +655,54 @@ func (DryWeightAdjust) TableName() string {
642 655
 }
643 656
 
644 657
 type MonitoringRecord struct {
645
-	ID                        int64   `gorm:"column:id" json:"id"`
646
-	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id"`
647
-	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id"`
648
-	DialysisOrderId           int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
649
-	MonitoringDate            int64   `gorm:"column:monitoring_date" json:"monitoring_date"`
650
-	OperateTime               int64   `gorm:"column:operate_time" json:"operate_time"`
651
-	MonitoringTime            string  `gorm:"column:monitoring_time" json:"monitoring_time"`
652
-	PulseFrequency            float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
653
-	BreathingRate             float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
654
-	SystolicBloodPressure     float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
655
-	DiastolicBloodPressure    float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
656
-	BloodPressureType         int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
657
-	Pic                       string  `gorm:"column:pic" json:"pic"`
658
-	BloodFlowVolume           float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
659
-	VenousPressure            float64 `gorm:"column:venous_pressure" json:"venous_pressure"`
660
-	VenousPressureType        int64   `gorm:"column:venous_pressure_type" json:"venous_pressure_type"`
661
-	ArterialPressure          float64 `gorm:"column:arterial_pressure" json:"arterial_pressure"`
662
-	ArterialPressureType      int64   `gorm:"column:arterial_pressure_type" json:"arterial_pressure_type"`
663
-	TransmembranePressure     float64 `gorm:"column:transmembrane_pressure" json:"transmembrane_pressure"`
664
-	TransmembranePressureType int64   `gorm:"column:transmembrane_pressure_type" json:"transmembrane_pressure_type"`
665
-	UltrafiltrationRate       float64 `gorm:"column:ultrafiltration_rate" json:"ultrafiltration_rate"`
666
-	UltrafiltrationVolume     float64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume"`
667
-	SodiumConcentration       float64 `gorm:"column:sodium_concentration" json:"sodium_concentration"`
668
-	DialysateTemperature      float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
669
-	Temperature               float64 `gorm:"column:temperature" json:"temperature"`
670
-	ReplacementRate           float64 `gorm:"column:replacement_rate" json:"replacement_rate"`
671
-	DisplacementQuantity      float64 `gorm:"column:displacement_quantity" json:"displacement_quantity"`
672
-	Ktv                       float64 `gorm:"column:ktv" json:"ktv"`
673
-	Symptom                   string  `gorm:"column:symptom" json:"symptom"`
674
-	Dispose                   string  `gorm:"column:dispose" json:"dispose"`
675
-	Result                    string  `gorm:"column:result" json:"result"`
676
-	MonitoringNurse           int64   `gorm:"column:monitoring_nurse" json:"monitoring_nurse"`
677
-	Status                    int64   `gorm:"column:status" json:"status"`
678
-	CreatedTime               int64   `gorm:"column:created_time" json:"created_time"`
679
-	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time"`
680
-	Conductivity              float64 `gorm:"column:conductivity" json:"conductivity"`
681
-	DisplacementFlowQuantity  float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
682
-	BloodOxygenSaturation     string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
683
-	Creator                   int64   `gorm:"column:creator" json:"creator" form:"creator"`
684
-	Modify                    int64   `gorm:"column:modify" json:"modify" form:"modify"`
685
-	Heparin                   float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
686
-	DialysateFlow             float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
687
-	Urr                       string  `gorm:"column:urr" json:"urr"`
688
-	BloodSugar                float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
689
-	MonitorAnticoagulant      int64   `gorm:"column:monitor_anticoagulant" json:"monitor_anticoagulant" form:"monitor_anticoagulant"`
690
-	MonitorAnticoagulantValue string  `gorm:"column:monitor_anticoagulant_value" json:"monitor_anticoagulant_value" form:"monitor_anticoagulant_value"`
658
+	ID                          int64   `gorm:"column:id" json:"id"`
659
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id"`
660
+	PatientId                   int64   `gorm:"column:patient_id" json:"patient_id"`
661
+	DialysisOrderId             int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
662
+	MonitoringDate              int64   `gorm:"column:monitoring_date" json:"monitoring_date"`
663
+	OperateTime                 int64   `gorm:"column:operate_time" json:"operate_time"`
664
+	MonitoringTime              string  `gorm:"column:monitoring_time" json:"monitoring_time"`
665
+	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
666
+	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
667
+	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
668
+	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
669
+	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
670
+	Pic                         string  `gorm:"column:pic" json:"pic"`
671
+	BloodFlowVolume             float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
672
+	VenousPressure              float64 `gorm:"column:venous_pressure" json:"venous_pressure"`
673
+	VenousPressureType          int64   `gorm:"column:venous_pressure_type" json:"venous_pressure_type"`
674
+	ArterialPressure            float64 `gorm:"column:arterial_pressure" json:"arterial_pressure"`
675
+	ArterialPressureType        int64   `gorm:"column:arterial_pressure_type" json:"arterial_pressure_type"`
676
+	TransmembranePressure       float64 `gorm:"column:transmembrane_pressure" json:"transmembrane_pressure"`
677
+	TransmembranePressureType   int64   `gorm:"column:transmembrane_pressure_type" json:"transmembrane_pressure_type"`
678
+	UltrafiltrationRate         float64 `gorm:"column:ultrafiltration_rate" json:"ultrafiltration_rate"`
679
+	UltrafiltrationVolume       float64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume"`
680
+	SodiumConcentration         float64 `gorm:"column:sodium_concentration" json:"sodium_concentration"`
681
+	DialysateTemperature        float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
682
+	Temperature                 float64 `gorm:"column:temperature" json:"temperature"`
683
+	ReplacementRate             float64 `gorm:"column:replacement_rate" json:"replacement_rate"`
684
+	DisplacementQuantity        float64 `gorm:"column:displacement_quantity" json:"displacement_quantity"`
685
+	Ktv                         float64 `gorm:"column:ktv" json:"ktv"`
686
+	Symptom                     string  `gorm:"column:symptom" json:"symptom"`
687
+	Dispose                     string  `gorm:"column:dispose" json:"dispose"`
688
+	Result                      string  `gorm:"column:result" json:"result"`
689
+	MonitoringNurse             int64   `gorm:"column:monitoring_nurse" json:"monitoring_nurse"`
690
+	Status                      int64   `gorm:"column:status" json:"status"`
691
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time"`
692
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time"`
693
+	Conductivity                float64 `gorm:"column:conductivity" json:"conductivity"`
694
+	DisplacementFlowQuantity    float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
695
+	BloodOxygenSaturation       string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
696
+	Creator                     int64   `gorm:"column:creator" json:"creator" form:"creator"`
697
+	Modify                      int64   `gorm:"column:modify" json:"modify" form:"modify"`
698
+	Heparin                     float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
699
+	DialysateFlow               float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
700
+	Urr                         string  `gorm:"column:urr" json:"urr"`
701
+	BloodSugar                  float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
702
+	MonitorAnticoagulant        int64   `gorm:"column:monitor_anticoagulant" json:"monitor_anticoagulant" form:"monitor_anticoagulant"`
703
+	MonitorAnticoagulantValue   string  `gorm:"column:monitor_anticoagulant_value" json:"monitor_anticoagulant_value" form:"monitor_anticoagulant_value"`
704
+	BloodPressureMonitoringSite int64   `gorm:"column:blood_pressure_monitoring_site" json:"blood_pressure_monitoring_site" form:"blood_pressure_monitoring_site"`
705
+	Complication                int64   `gorm:"column:complication" json:"complication" form:"complication"`
691 706
 }
692 707
 
693 708
 func (MonitoringRecord) TableName() string {
@@ -867,6 +882,7 @@ type ReceiveTreatmentAsses struct {
867 882
 	PsychologicalOther           string `gorm:"column:psychological_other" json:"psychological_other"`
868 883
 	IsPrecaution                 int64  `gorm:"column:is_precaution" json:"is_precaution"`
869 884
 	AdmissionNumber              string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
885
+	Tumble                       int64  `gorm:"column:tumble" json:"tumble" form:"tumble"`
870 886
 }
871 887
 
872 888
 func (ReceiveTreatmentAsses) TableName() string {
@@ -977,6 +993,14 @@ func (DialysisBeforePrepare) TableName() string {
977 993
 	return "dialysis_before_prepare"
978 994
 }
979 995
 
996
+type DialysisBeforePrepareGoods struct {
997
+	GoodId            int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
998
+	Count             int64  `gorm:"column:count" json:"count" form:"count"`
999
+	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
1000
+	TypeName          string `gorm:"column:type_name" json:"type_name" form:"type_name"`
1001
+	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1002
+}
1003
+
980 1004
 type QueueCallConfig struct {
981 1005
 	ID         int64 `gorm:"column:id" json:"id" form:"id"`
982 1006
 	OrgId      int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`

+ 1 - 0
models/doctor_advice_models.go View File

@@ -91,6 +91,7 @@ type DoctorAdviceParentTemplate struct {
91 91
 	UpdatedTime          int64                   `gorm:"column:updated_time" json:"updated_time"`
92 92
 	DoctorAdviceTemplate []*DoctorAdviceTemplate `gorm:"ForeignKey:TemplateId;AssociationForeignKey:ID"`
93 93
 	AdviceType           int64                   `gorm:"column:advice_type" json:"advice_type"`
94
+	Sort                 int64                   `gorm:"column:sort" json:"sort" form:"sort"`
94 95
 }
95 96
 
96 97
 func (DoctorAdviceParentTemplate) TableName() string {

+ 29 - 26
models/drug.go View File

@@ -1,28 +1,29 @@
1 1
 package models
2 2
 
3 3
 type BaseDrugLib struct {
4
-	ID                          int64   `gorm:"column:id" json:"id" form:"id"`
5
-	DrugName                    string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
6
-	Pinyin                      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
7
-	Wubi                        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
8
-	DrugAlias                   string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
9
-	DrugAliasPinyin             string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
10
-	DrugAliasWubi               string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
11
-	DrugCategory                int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
12
-	DrugSpec                    string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
13
-	DrugType                    int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
14
-	DrugStockLimit              string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
15
-	DrugOriginPlace             string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
16
-	DrugDosageForm              int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
17
-	MedicalInsuranceLevel       int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
18
-	MaxUnit                     string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
19
-	MinNumber                   int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
20
-	MinUnit                     string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
21
-	Dose                        float64 `gorm:"column:dose" json:"dose" form:"dose"`
22
-	DoseUnit                    string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
4
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
5
+	DrugName              string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
6
+	Pinyin                string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
7
+	Wubi                  string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
8
+	DrugAlias             string  `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
9
+	DrugAliasPinyin       string  `gorm:"column:drug_alias_pinyin" json:"drug_alias_pinyin" form:"drug_alias_pinyin"`
10
+	DrugAliasWubi         string  `gorm:"column:drug_alias_wubi" json:"drug_alias_wubi" form:"drug_alias_wubi"`
11
+	DrugCategory          int64   `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
12
+	DrugSpec              string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
13
+	DrugType              int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
14
+	DrugStockLimit        string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
15
+	DrugOriginPlace       string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
16
+	DrugDosageForm        int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
17
+	MedicalInsuranceLevel int64   `gorm:"column:medical_insurance_level" json:"medical_insurance_level" form:"medical_insurance_level"`
18
+	MaxUnit               string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
19
+	MinNumber             int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
20
+	MinUnit               string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
21
+	Dose                  float64 `gorm:"column:dose" json:"dose" form:"dose"`
22
+	DoseUnit              string  `gorm:"column:Dose_unit" json:"Dose_unit" form:"Dose_unit"`
23
+	MinPrice              string  `gorm:"column:min_price" json:"min_price" form:"min_price"`
24
+
23 25
 	UnitMatrixing               string  `gorm:"column:unit_matrixing" json:"unit_matrixing" form:"unit_matrixing"`
24 26
 	RetailPrice                 float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
25
-	MinPrice                    float64 `gorm:"column:min_price" json:"min_price" form:"min_price"`
26 27
 	LastPrice                   float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
27 28
 	DrugControl                 int64   `gorm:"column:drug_control" json:"drug_control" form:"drug_control"`
28 29
 	Number                      string  `gorm:"column:number" json:"number" form:"number"`
@@ -64,15 +65,17 @@ type BaseDrugLib struct {
64 65
 	IsMark                      int64   `gorm:"column:is_mark" json:"is_mark" form:"is_mark"`
65 66
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
66 67
 	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
67
-	Dosage                      string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
68
-	Unval                       string  `gorm:"column:unval" json:"unval" form:"unval"`
69
-	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
70
-	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
71
-	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
68
+	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
69
+	Dosage       string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
70
+	Unval        string  `gorm:"column:unval" json:"unval" form:"unval"`
71
+	PackingUnit  string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
72
+	PackingPrice float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
73
+	DrugDay      string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
74
+	Total        float64 `gorm:"column:total" json:"total" form:"total"`
72 75
 }
73 76
 
74 77
 func (BaseDrugLib) TableName() string {
75
-	return "xt_base_drug"
78
+	return ""
76 79
 }
77 80
 
78 81
 type DrugUnitSafeguard struct {

+ 7 - 0
models/drug_stock.go View File

@@ -42,6 +42,11 @@ type DrugWarehouseInfo struct {
42 42
 	Type             int64   `gorm:"column:type" json:"type" form:"type"`
43 43
 	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
44 44
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
45
+	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
46
+	MaxUnit          string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
47
+	MinUnit          string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
48
+	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
49
+	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
45 50
 }
46 51
 
47 52
 func (DrugWarehouseInfo) TableName() string {
@@ -78,6 +83,7 @@ type DrugWarehouseOutInfo struct {
78 83
 	DrugId                  int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
79 84
 	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target" form:"warehousing_out_target"`
80 85
 	Count                   int64   `gorm:"column:count" json:"count" form:"count"`
86
+	CountUnit               string  `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
81 87
 	Price                   float64 `gorm:"column:price" json:"price" form:"price"`
82 88
 	TotalPrice              float64 `gorm:"column:total_price" json:"total_price" form:"total_price"`
83 89
 	ProductDate             int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
@@ -210,6 +216,7 @@ type DrugAutomaticReduceDetail struct {
210 216
 	OrgId                   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
211 217
 	DrugId                  int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
212 218
 	Count                   int64  `gorm:"column:count" json:"count" form:"count"`
219
+	CountUnit               string `gorm:"column:count_unit" json:"count_unit" form:"count_unit"`
213 220
 }
214 221
 
215 222
 func (DrugAutomaticReduceDetail) TableName() string {

+ 3 - 1
models/his_models.go View File

@@ -2,7 +2,6 @@ package models
2 2
 
3 3
 import (
4 4
 	//"gdyb/models"
5
-
6 5
 	"time"
7 6
 )
8 7
 
@@ -234,6 +233,7 @@ type HisDoctorAdviceInfo struct {
234 233
 	ChildDoctorAdvice     []*HisDoctorAdviceInfo `gorm:"ForeignKey:ParentId;AssociationForeignKey:ID" json:"child"`
235 234
 	Drug                  Drug                   `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
236 235
 	Diagnosis             int64                  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
236
+	Way                   int64                  `gorm:"column:way" json:"way" form:"way"`
237 237
 	HospApprFlag          int64                  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
238 238
 	LmtUsedFlag           int64                  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
239 239
 }
@@ -311,6 +311,7 @@ type Drug struct {
311 311
 	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
312 312
 	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
313 313
 	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
314
+	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
314 315
 }
315 316
 
316 317
 func (Drug) TableName() string {
@@ -602,6 +603,7 @@ type VMDrug struct {
602 603
 	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
603 604
 	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
604 605
 	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
606
+	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
605 607
 }
606 608
 
607 609
 func (VMDrug) TableName() string {

+ 1 - 0
models/inspection_models.go View File

@@ -10,6 +10,7 @@ type Inspection struct {
10 10
 	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
11 11
 	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
12 12
 	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
13
+	InspectTips  string `gorm:"column:inspect_tips" json:"inspect_tips" form:"inspect_tips"`
13 14
 	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
14 15
 	Status       int64  `gorm:"column:status" json:"status" form:"status"`
15 16
 	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`

+ 13 - 0
models/patient_models.go View File

@@ -230,6 +230,13 @@ type DialysisPrescription struct {
230 230
 	DialysisIrrigation         string        `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
231 231
 	AntioxidantCommodityName   string        `gorm:"column:antioxidant_commodity_name" json:"antioxidant_commodity_name" form:"antioxidant_commodity_name"`
232 232
 	DisplaceSpeed              string        `gorm:"column:displace_speed" json:"displace_speed" form:"displace_speed"`
233
+	Illness                    int64         `gorm:"column:illness" json:"illness" form:"illness"`
234
+	Amylaceum                  string        `gorm:"column:amylaceum" json:"amylaceum" form:"amylaceum"`
235
+	SingleTime                 string        `gorm:"column:single_time" json:"single_time" form:"single_time"`
236
+	SingleWater                string        `gorm:"column:single_water" json:"single_water" form:"single_water"`
237
+	ReplacementFlow            string        `gorm:"column:replacement_flow" json:"replacement_flow" form:"replacement_flow"`
238
+	PlasmaSeparator            string        `gorm:"column:plasma_separator" json:"plasma_separator" form:"plasma_separator"`
239
+	BilirubinAdsorptionColumn  string        `gorm:"column:bilirubin_adsorption_column" json:"bilirubin_adsorption_column" form:"bilirubin_adsorption_column"`
233 240
 }
234 241
 
235 242
 func (DialysisPrescription) TableName() string {
@@ -329,6 +336,12 @@ type DialysisSolution struct {
329 336
 	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv"`
330 337
 	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
331 338
 	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
339
+	AntioxidantCommodityName   string  `gorm:"column:antioxidant_commodity_name" json:"antioxidant_commodity_name" form:"antioxidant_commodity_name"`
340
+	DisplaceSpeed              string  `gorm:"column:displace_speed" json:"displace_speed" form:"displace_speed"`
341
+	Illness                    int64   `gorm:"column:illness" json:"illness" form:"illness"`
342
+	Amylaceum                  string  `gorm:"column:amylaceum" json:"amylaceum" form:"amylaceum"`
343
+	PlasmaSeparator            string  `gorm:"column:plasma_separator" json:"plasma_separator" form:"plasma_separator"`
344
+	BilirubinAdsorptionColumn  string  `gorm:"column:bilirubin_adsorption_column" json:"bilirubin_adsorption_column" form:"bilirubin_adsorption_column"`
332 345
 }
333 346
 
334 347
 func (DialysisSolution) TableName() string {

+ 73 - 17
models/schedule_models.go View File

@@ -1,6 +1,6 @@
1 1
 package models
2 2
 
3
-type Schedule struct {
3
+type VmSchedules struct {
4 4
 	ID           int64 `gorm:"column:id" json:"id" form:"id"`
5 5
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6 6
 	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
@@ -15,20 +15,21 @@ type Schedule struct {
15 15
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
16 16
 	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
17 17
 
18
-	Patient       string        `gorm:"-" json:"patient" form:"patient"`
19
-	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
20
-	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
21
-	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
22
-	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
23
-
24
-	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
18
+	DeviceZone           DeviceZone             `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
19
+	DeviceNumber         DeviceNumber           `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
20
+	DialysisOrder        DialysisOrder          `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
21
+	XtPatients           XtPatients             `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
22
+	DoctorAdvice         []*DoctorAdvice        `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
23
+	DialysisPrescription DialysisPrescription   `json:"prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
24
+	HisDoctorAdviceInfo  []*HisDoctorAdviceInfo `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
25
+	DialysisSolution     []*DialysisSolution    `json:"dialysissolution" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
25 26
 }
26 27
 
27
-func (Schedule) TableName() string {
28
+func (VmSchedules) TableName() string {
28 29
 	return "xt_schedule"
29 30
 }
30 31
 
31
-type SchedulePatients struct {
32
+type Schedule struct {
32 33
 	ID           int64 `gorm:"column:id" json:"id" form:"id"`
33 34
 	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
34 35
 	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
@@ -42,13 +43,40 @@ type SchedulePatients struct {
42 43
 	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
43 44
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
44 45
 	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
45
-	Patient      PatientListForFace        `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
46
+
47
+	Patient       string        `gorm:"-" json:"patient" form:"patient"`
48
+	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
49
+	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
50
+	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
51
+	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
52
+
53
+	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
46 54
 }
47 55
 
48
-func (SchedulePatients) TableName() string {
56
+func (Schedule) TableName() string {
49 57
 	return "xt_schedule"
50 58
 }
51 59
 
60
+type SchedulePatients struct {
61
+	ID           int64              `gorm:"column:id" json:"id" form:"id"`
62
+	UserOrgId    int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
63
+	PartitionId  int64              `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
64
+	BedId        int64              `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
65
+	PatientId    int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
66
+	ScheduleDate int64              `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
67
+	ScheduleType int64              `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
68
+	ScheduleWeek int64              `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
69
+	ModeId       int64              `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
70
+	Status       int64              `gorm:"column:status" json:"status" form:"status"`
71
+	CreatedTime  int64              `gorm:"column:created_time" json:"created_time" form:"created_time"`
72
+	UpdatedTime  int64              `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
73
+	IsExport     int64              `gorm:"column:is_export" json:"is_export" form:"is_export"`
74
+	Patient      PatientListForFace `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
75
+}
76
+
77
+func (SchedulePatients) TableName() string {
78
+	return "xt_schedule"
79
+}
52 80
 
53 81
 type PatientSchedule struct {
54 82
 	Schedule
@@ -104,13 +132,41 @@ type WeekSchedule struct {
104 132
 	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
105 133
 	IsExport     int64 `gorm:"column:is_export" json:"is_export" form:"is_export"`
106 134
 
107
-	Patient              string           `gorm:"-" json:"patient" form:"patient"`
108
-	DeviceZone           DeviceZone       `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
109
-	DeviceNumber         DeviceNumber     `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
110
-	DialysisPrescription DialysisSolution `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
111
-	DoctorAdvice         []*DoctorAdvice  `json:"doctor_advice" gorm:"-"`
135
+	Patient              string                 `gorm:"-" json:"patient" form:"patient"`
136
+	DeviceZone           DeviceZone             `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
137
+	DeviceNumber         DeviceNumber           `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
138
+	DialysisPrescription DialysisSolution       `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
139
+	DoctorAdvice         []*DoctorAdvice        `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
140
+	HisDoctorAdviceInfo  []*HisDoctorAdviceInfo `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
141
+	DialysisSolution     []*DialysisSolution    `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
112 142
 }
113 143
 
114 144
 func (WeekSchedule) TableName() string {
115 145
 	return "xt_schedule"
116 146
 }
147
+
148
+type ScheduleTemplate struct {
149
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
150
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
151
+	TemplateId int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
152
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
153
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
154
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
155
+}
156
+
157
+func (ScheduleTemplate) TableName() string {
158
+	return "xt_schedule_template"
159
+}
160
+
161
+type XtDataPrint struct {
162
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
163
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
164
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
165
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
166
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
167
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
168
+}
169
+
170
+func (XtDataPrint) TableName() string {
171
+	return "xt_data_print"
172
+}

+ 3 - 0
models/self_drug_models.go View File

@@ -65,6 +65,7 @@ type XtBaseDrug struct {
65 65
 	OrgId                  int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
66 66
 	HospApprFlag           int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
67 67
 	LmtUsedFlag            int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
68
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
68 69
 }
69 70
 
70 71
 func (XtBaseDrug) TableName() string {
@@ -389,6 +390,8 @@ type XtDrugWarehouseInfo struct {
389 390
 	Type             int64   `gorm:"column:type" json:"type" form:"type"`
390 391
 	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
391 392
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
393
+	StockMaxNumber   int64   `gorm:"column:stock_max_number" json:"stock_max_number"`
394
+	StockMinNumber   int64   `gorm:"column:stock_min_number" json:"stock_min_number"`
392 395
 }
393 396
 
394 397
 func (XtDrugWarehouseInfo) TableName() string {

+ 21 - 15
models/service/stock_service.go View File

@@ -507,21 +507,22 @@ func (VMDrugWarehouseInfo) TableName() string {
507 507
 }
508 508
 
509 509
 type Drug struct {
510
-	ID              int64  `gorm:"column:id" json:"id" form:"id"`
511
-	DrugName        string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
512
-	DrugSpec        string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
513
-	DrugType        int64  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
514
-	DrugStockLimit  string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
515
-	DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
516
-	DrugDosageForm  int64  `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
517
-	Manufacturer    int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
518
-	Status          int64  `gorm:"column:status" json:"status" form:"status"`
519
-	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
520
-	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
521
-	OrgId           int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
522
-	DrugCode        string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
523
-	HospApprFlag    int64  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
524
-	LmtUsedFlag     int64  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
510
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
511
+	DrugName        string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
512
+	DrugSpec        string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
513
+	DrugType        int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
514
+	DrugStockLimit  string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
515
+	DrugOriginPlace string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
516
+	DrugDosageForm  int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
517
+	Manufacturer    int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
518
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
519
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
520
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
521
+	OrgId           int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
522
+	DrugCode        string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
523
+	HospApprFlag    int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
524
+	LmtUsedFlag     int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
525
+	Total           float64 `gorm:"column:total" json:"total" form:"total"`
525 526
 }
526 527
 
527 528
 func (Drug) TableName() string {
@@ -1257,6 +1258,11 @@ func UpDateWarehouseInfo(warehouseInfo *models.WarehousingInfo) (err error) {
1257 1258
 	return
1258 1259
 }
1259 1260
 
1261
+func UpDateWarehouseInfoByStock(warehouseInfo *models.WarehousingInfo) (err error) {
1262
+	err = writeDb.Save(&warehouseInfo).Error
1263
+	return
1264
+}
1265
+
1260 1266
 func UpDateWarehouseStatus(id int64) (err error) {
1261 1267
 	err = readDb.Model(&models.WarehousingInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1262 1268
 	return

+ 5 - 0
models/stock_models.go View File

@@ -79,6 +79,8 @@ type WarehousingInfo struct {
79 79
 	ProductDate      int64       `gorm:"column:product_date" json:"product_date"`
80 80
 	ExpiryDate       int64       `gorm:"column:expiry_date" json:"expiry_date"`
81 81
 	WarehousingCount int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
82
+	WarehousingUnit  string      `gorm:"column:warehousing_unit" json:"warehousing_unit"`
83
+	StockNumber      int64       `gorm:"column:stock_number" json:"stock_number"`
82 84
 	Price            float64     `gorm:"column:price" json:"price"`
83 85
 	TotalPrice       float64     `gorm:"column:total_price" json:"total_price"`
84 86
 	Dealer           int64       `gorm:"column:dealer" json:"dealer"`
@@ -126,6 +128,7 @@ func (WarehouseOut) TableName() string {
126 128
 type WarehouseOutInfo struct {
127 129
 	ID                      int64        `gorm:"column:id" json:"id"`
128 130
 	WarehouseOutId          int64        `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
131
+	WarehouseInfotId        int64        `gorm:"column:warehouse_info_id" json:"warehouse_info_id"`
129 132
 	GoodId                  int64        `gorm:"column:good_id" json:"good_id"`
130 133
 	GoodTypeId              int64        `gorm:"column:good_type_id" json:"good_type_id"`
131 134
 	WarehousingOutTarget    int64        `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
@@ -148,6 +151,7 @@ type WarehouseOutInfo struct {
148 151
 	Manufacturer            int64        `gorm:"column:manufacturer" json:"manufacturer"`
149 152
 	IsSys                   int64        `gorm:"column:is_sys" json:"is_sys"`
150 153
 	SysRecordTime           int64        `gorm:"column:sys_record_time" json:"sys_record_time"`
154
+	PatientId               int64        `gorm:"column:patient_id" json:"patient_id"`
151 155
 }
152 156
 
153 157
 func (WarehouseOutInfo) TableName() string {
@@ -303,6 +307,7 @@ type AutomaticReduceDetail struct {
303 307
 	GoodsType               GoodsType `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"type"`
304 308
 	Patients                Patients  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"user"`
305 309
 	Count                   int64     `gorm:"column:count" json:"count"`
310
+	Type                    int64     `gorm:"column:type" json:"type"`
306 311
 }
307 312
 
308 313
 func (AutomaticReduceDetail) TableName() string {

+ 1 - 0
routers/router.go View File

@@ -76,4 +76,5 @@ func init() {
76 76
 	//new_m_api.NewDrugApiControllersRegisterRouters()
77 77
 	controllers.HisProjectRouters()
78 78
 	controllers.GdybRegistRouters()
79
+
79 80
 }

+ 197 - 34
service/common_service.go View File

@@ -204,19 +204,64 @@ func DeleteCheck(id int64) error {
204 204
 	return err
205 205
 }
206 206
 
207
-func GetDialysiTotal(startime int64, endtime int64, orgid int64) (order []*models.DialysisOrder, total int64, err error) {
208
-	err = XTReadDB().Model(&order).Where("dialysis_date >= ? and dialysis_date<=? and user_org_id = ?", startime, endtime, orgid).Count(&total).Find(&order).Error
209
-	return order, total, err
207
+//
208
+//func GetDialysiTotal(startime int64, endtime int64, orgid int64,lapsetotype int64,sourcetype int64) (order []*models.DialysisOrder, total int64, err error) {
209
+//	err = XTReadDB().Model(&order).Where("dialysis_date >= ? and dialysis_date<=? and user_org_id = ?", startime, endtime, orgid).Count(&total).Find(&order).Error
210
+//	return order, total, err
211
+//}
212
+
213
+func GetDialysiTotal(startime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (models.PatientPrescriptionCountStruct, error) {
214
+	counts := models.PatientPrescriptionCountStruct{}
215
+
216
+	db := XTReadDB().Table("xt_dialysis_order as x").Where("x.status = 1")
217
+	table := XTReadDB().Table("xt_paitents as s").Where("s.status = 1")
218
+	fmt.Println(table)
219
+
220
+	if lapsetotype > 0 {
221
+		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? and s.lapseto = ?", startime, endtime, orgid, lapsetotype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
222
+	}
223
+	if lapsetotype == 0 {
224
+		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? ", startime, endtime, orgid).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
225
+	}
226
+
227
+	if sourcetype > 0 {
228
+		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ? and s.source = ?", startime, endtime, orgid, sourcetype).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
229
+	}
210 230
 
231
+	if sourcetype == 0 {
232
+		err = db.Select("count(x.id) as count").Where("x.dialysis_date >= ? and x.dialysis_date<=? and x.user_org_id = ?", startime, endtime, orgid).Joins("left join xt_patients as s on s.id= x.patient_id").Scan(&counts).Error
233
+	}
234
+
235
+	return counts, err
211 236
 }
212 237
 
213
-func GetDialysisCountMode(starttime int64, endtime int64, orgid int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
214
-	//err = readDb.Table("xt_dialysis_prescription as p").Where("p.record_date>= ? and p.record_date<=? and p.user_org_id=?", starttime, endtime, orgid).Select("p.mode_id,count(p.mode_id) as count").Group("p.mode_id").Scan(&counts).Error
238
+func GetDialysisCountMode(starttime int64, endtime int64, orgid int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientPrescriptionCountStruct, err error) {
239
+
240
+	//err = readDb.Table("xt_dialysis_order as o left join xt_schedule as s on s.patient_id = o.patient_id").Where("s.schedule_date = o.dialysis_date and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and o.status = 1 and s.status = 1", starttime, endtime, orgid).Select("s.mode_id,count(s.mode_id) as count").Group("s.mode_id").Scan(&counts).Error
215 241
 	//return counts, err
216 242
 
217
-	err = readDb.Table("xt_dialysis_order as o left join xt_schedule as s on s.patient_id = o.patient_id").Where("s.schedule_date = o.dialysis_date and o.dialysis_date>=? and o.dialysis_date<=? and o.user_org_id = ? and o.status = 1 and s.status = 1", starttime, endtime, orgid).Select("s.mode_id,count(s.mode_id) as count").Group("s.mode_id").Scan(&counts).Error
243
+	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
244
+	table := readDb.Table("xt_schedule as s").Where("s.status = 1")
245
+	fmt.Println(table)
246
+	p := readDb.Table("xt_patients as p").Where("p.status = 1")
247
+	fmt.Println(p)
248
+	if starttime > 0 {
249
+		db = db.Where("o.dialysis_date >=?", starttime)
250
+	}
251
+	if endtime > 0 {
252
+		db = db.Where("o.dialysis_date<=?", endtime)
253
+	}
254
+	if orgid > 0 {
255
+		db = db.Where("o.user_org_id = ?", orgid)
256
+	}
257
+	if lapsetotype > 0 {
258
+		db = db.Where("p.lapseto = ?", lapsetotype)
259
+	}
260
+	if sourcetype > 0 {
261
+		db = db.Where("p.source = ?", sourcetype)
262
+	}
263
+	err = db.Select("s.mode_id,count(s.mode_id) as count").Joins("left join xt_schedule as s on s.patient_id = o.patient_id and s.schedule_date = o.dialysis_date and s.status= 1").Joins("left join xt_patients as  p on o.patient_id = p.id").Group("s.mode_id").Scan(&counts).Error
218 264
 	return counts, err
219
-
220 265
 }
221 266
 
222 267
 func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*models.PatientLapseto, total int64, err error) {
@@ -228,22 +273,41 @@ func GetTotalRollOut(starttime int64, endtime int64, orgid int64) (counts []*mod
228 273
 	return counts, total, err
229 274
 }
230 275
 
231
-func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
276
+func GetTotalRollOutPatients(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, err error) {
277
+
278
+	db := XTReadDB().Table("xt_patients as x")
232 279
 
233
-	db := XTReadDB().Table("x.patients as x")
234
-	err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
280
+	if sourcetype == 0 {
281
+		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
282
+	}
283
+	if sourcetype > 0 {
284
+		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 1 and x.status = 1 and x.source = ?", startime, endtime, orgid, sourcetype).Scan(&patients).Error
285
+	}
235 286
 	return patients, err
236 287
 }
237 288
 
238
-func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64) (patients []*models.XtPatients, err error) {
289
+func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, err error) {
290
+
291
+	db := XTReadDB().Table("xt_patients as x")
292
+	if sourcetype == 0 {
293
+		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
239 294
 
240
-	db := XTReadDB().Table("x.patients as x")
241
-	err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1", startime, endtime, orgid).Scan(&patients).Error
295
+	}
296
+	if sourcetype > 0 {
297
+		err = db.Raw("select x.id,x.`name`,s.lapseto_type,s.lapseto_time from xt_patients as x left join xt_patient_lapseto AS s ON s.patient_id = x.id where s.lapseto_time >=? and s.lapseto_time <=? and x.user_org_id = ? and s.lapseto_type = 2 and x.status = 1 and x.source = ?", startime, endtime, orgid, sourcetype).Scan(&patients).Error
298
+	}
242 299
 	return patients, err
243 300
 }
244 301
 
245
-func GetPatientTotalCount(orgID int64) (total int64) {
246
-	readDb.Model(&models.XtPatients{}).Where("user_org_id=? and status=1", orgID).Count(&total)
302
+func GetPatientTotalCount(orgID int64, lapsetotype int64, sourcetype int64) (total int64) {
303
+	db := readDb.Table("xt_patients as x")
304
+	//if lapsetotype > 0 {
305
+	// db = db.Where("x.lapseto = ?", lapsetotype)
306
+	//}
307
+	//if sourcetype > 0 {
308
+	// db = db.Where("x.source = ?", sourcetype)
309
+	//}
310
+	db.Where("x.user_org_id=? and x.status=1", orgID).Count(&total)
247 311
 	return
248 312
 }
249 313
 
@@ -263,9 +327,28 @@ func GetManPatientTotalCount(orgid int64, starttime int64, endtime int64) (dialy
263 327
 
264 328
 }
265 329
 
266
-func GetManPatientTotal(orgid int64) (patients []*models.XtPatients, total int64, err error) {
330
+func GetManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
267 331
 
268
-	err = XTReadDB().Model(&patients).Where("user_org_id = ? and status = 1 and gender = 1", orgid).Count(&total).Find(&patients).Error
332
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
333
+	if lapsetotype > 0 {
334
+		db = db.Where("x.lapseto = ?", lapsetotype)
335
+	}
336
+	if sourcetype > 0 {
337
+		db = db.Where("x.source = ?", sourcetype)
338
+	}
339
+	err = db.Where("x.user_org_id = ? and x.status = 1 and x.gender = 1", orgid).Count(&total).Find(&patients).Error
340
+	return patients, total, err
341
+}
342
+
343
+func GetWoManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
344
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
345
+	if lapsetotype > 0 {
346
+		db = db.Where("x.lapseto = ?", lapsetotype)
347
+	}
348
+	if sourcetype > 0 {
349
+		db = db.Where("x.source = ?", sourcetype)
350
+	}
351
+	err = db.Where("x.user_org_id = ? and x.status = 1 and x.gender = 2", orgid).Count(&total).Find(&patients).Error
269 352
 	return patients, total, err
270 353
 }
271 354
 
@@ -274,10 +357,25 @@ func GetManPatientTotal(orgid int64) (patients []*models.XtPatients, total int64
274 357
 //	return counts, err
275 358
 //}
276 359
 
277
-func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64) (counts []*models.PatientContagionsCountStruct, err error) {
360
+func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientContagionsCountStruct, err error) {
361
+
362
+	if lapsetotype == 0 {
363
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
364
+	}
365
+	if sourcetype == 0 {
366
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
367
+	}
368
+
369
+	if lapsetotype > 0 {
370
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.lapseto = ?", orgid, startime, endtime, lapsetotype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
371
+	}
372
+
373
+	if sourcetype > 0 {
374
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.source = ?", orgid, startime, endtime, sourcetype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
375
+	}
278 376
 
279
-	err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
280 377
 	return counts, err
378
+
281 379
 }
282 380
 
283 381
 func GetPatientOtherInfectious(orgid int64) (patients []*models.XtPatients, total int64, err error) {
@@ -286,9 +384,10 @@ func GetPatientOtherInfectious(orgid int64) (patients []*models.XtPatients, tota
286 384
 	return patients, total, err
287 385
 }
288 386
 
289
-func GetTotalAgeCount(orgid int64) (counts []*models.PatientAgeCountStruct, err error) {
387
+func GetTotalAgeCount(orgid int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientAgeCountStruct, err error) {
290 388
 
291
-	readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
389
+	if lapsetotype == 0 || sourcetype == 0 {
390
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
292 391
 	 SELECT
293 392
 	 CASE
294 393
 	  WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=20 THEN '20'
@@ -299,8 +398,39 @@ func GetTotalAgeCount(orgid int64) (counts []*models.PatientAgeCountStruct, err
299 398
 	 END
300 399
 	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1
301 400
 	 )a GROUP BY nnd`, orgid).Scan(&counts)
302
-	return
303 401
 
402
+	}
403
+
404
+	if lapsetotype > 0 {
405
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
406
+	 SELECT
407
+	 CASE
408
+	  WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=20 THEN '20'
409
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=40 THEN '40'
410
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=60 THEN '60'
411
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
412
+    ELSE '150'
413
+	 END
414
+	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1 and s.lapseto = ?
415
+	 )a GROUP BY nnd`, orgid, lapsetotype).Scan(&counts)
416
+
417
+	}
418
+
419
+	if sourcetype > 0 {
420
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
421
+	 SELECT
422
+	 CASE
423
+	  WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=20 THEN '20'
424
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=40 THEN '40'
425
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=60 THEN '60'
426
+    WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
427
+    ELSE '150'
428
+	 END
429
+	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1 and s.source = ?
430
+	 )a GROUP BY nnd`, orgid, sourcetype).Scan(&counts)
431
+
432
+	}
433
+	return
304 434
 }
305 435
 
306 436
 func GetTotalAgeCountTwo(orgid int64, starttime int64, endtime int64) (counts []*models.PatientAgeCountStruct, err error) {
@@ -320,18 +450,42 @@ func GetTotalDialysisAgeCount(orgid int64) (patients []*models.XtPatients, err e
320 450
 	return patients, err
321 451
 }
322 452
 
323
-func GetDialysisAgeData(orgID int64) (counts []*models.DialysisAgePieDataStruct, err error) {
453
+func GetDialysisAgeData(orgID int64, lapsetotype int64, sourcetype int64) (counts []*models.DialysisAgePieDataStruct, err error) {
324 454
 
325
-	readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
326
-	SELECT
327
-	CASE
328
-	WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '1'
329
-  WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '2'
330
-  WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '3'
331
-  WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60 THEN '4'
332
-  END AS nnd FROM xt_patients as p  where p.user_org_id=? and p.status=1 and p.first_dialysis_date <> 0)a GROUP BY nnd`, orgID).Scan(&counts)
333
-	return
455
+	if lapsetotype == 0 || sourcetype == 0 {
456
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
457
+    SELECT
458
+    CASE
459
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '1'
460
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '2'
461
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '3'
462
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60 THEN '4'
463
+    END AS nnd FROM xt_patients as p  where p.user_org_id=? and p.status=1 and p.first_dialysis_date <> 0)a GROUP BY nnd`, orgID).Scan(&counts)
464
+	}
465
+
466
+	if lapsetotype > 0 {
467
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
468
+    SELECT
469
+    CASE
470
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '1'
471
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '2'
472
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '3'
473
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60 THEN '4'
474
+    END AS nnd FROM xt_patients as p  where p.user_org_id=? and p.status=1 and p.first_dialysis_date <> 0 and p.lapseto = ?)a GROUP BY nnd`, orgID, lapsetotype).Scan(&counts)
475
+	}
476
+
477
+	if sourcetype > 0 {
478
+		readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM(
479
+    SELECT
480
+    CASE
481
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) >= 0 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 12 THEN '1'
482
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 12 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 36 THEN '2'
483
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 36 AND TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) <= 60 THEN '3'
484
+    WHEN TIMESTAMPDIFF( YEAR, DATE( DATE_ADD( FROM_UNIXTIME( 0 ), INTERVAL p.first_dialysis_date SECOND ) ), curdate( ) ) > 60 THEN '4'
485
+    END AS nnd FROM xt_patients as p  where p.user_org_id=? and p.status=1 and p.first_dialysis_date <> 0 and p.source = ?)a GROUP BY nnd`, orgID, sourcetype).Scan(&counts)
486
+	}
334 487
 
488
+	return
335 489
 }
336 490
 
337 491
 func GetCurentOrgPatients(orgid int64) (patients []*models.BloodXtPatients, err error) {
@@ -3375,7 +3529,7 @@ func GetCountModeId(startime int64, endtime int64, modeid int64, orgid int64) (o
3375 3529
 
3376 3530
 }
3377 3531
 
3378
-func GetCountRollout(orgid int64, startime int64, endtime int64) (lapseto []*models.BloodLapsetoCount, err error) {
3532
+func GetCountRollout(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (lapseto []*models.BloodLapsetoCount, err error) {
3379 3533
 
3380 3534
 	table := XTReadDB().Table("xt_patients as s")
3381 3535
 	fmt.Println(table)
@@ -3386,6 +3540,15 @@ func GetCountRollout(orgid int64, startime int64, endtime int64) (lapseto []*mod
3386 3540
 	if endtime > 0 {
3387 3541
 		db = db.Where("x.lapseto_time<=?", endtime)
3388 3542
 	}
3389
-	err = db.Group("x.lapseto_time,x.lapseto_type").Select("count(x.id) as count,x.lapseto_type,x.lapseto_time").Joins("left join xt_patients as s  on s.id = x.patient_id").Where("s.user_org_id = ?", orgid).Scan(&lapseto).Error
3543
+	if lapsetotype == 0 || sourcetype == 0 {
3544
+		err = db.Group("x.lapseto_time,x.lapseto_type").Select("count(x.id) as count,x.lapseto_type,x.lapseto_time").Joins("left join xt_patients as s  on s.id = x.patient_id").Where("s.user_org_id = ?", orgid).Scan(&lapseto).Error
3545
+	}
3546
+
3547
+	if lapsetotype > 0 {
3548
+		err = db.Group("x.lapseto_time,x.lapseto_type").Select("count(x.id) as count,x.lapseto_type,x.lapseto_time").Joins("left join xt_patients as s  on s.id = x.patient_id").Where("s.user_org_id = ? and s.lapseto = ?", orgid, lapsetotype).Scan(&lapseto).Error
3549
+	}
3550
+	if sourcetype > 0 {
3551
+		err = db.Group("x.lapseto_time,x.lapseto_type").Select("count(x.id) as count,x.lapseto_type,x.lapseto_time").Joins("left join xt_patients as s  on s.id = x.patient_id").Where("s.user_org_id = ? and s.source = ?", orgid, sourcetype).Scan(&lapseto).Error
3552
+	}
3390 3553
 	return lapseto, err
3391 3554
 }

+ 1 - 1
service/dialysis_service.go View File

@@ -1101,7 +1101,7 @@ func UpdateDialysisBeforePrepareTwo(info *models.DialysisBeforePrepare) (err err
1101 1101
 
1102 1102
 func UpdateAutoReduceDetailSix(detail *models.AutomaticReduceDetail) (err error) {
1103 1103
 
1104
-	err = writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? and good_type_id = ? And patient_id = ? and org_id =?", detail.GoodId, detail.GoodTypeId, detail.PatientId, detail.OrgId).Updates(map[string]interface{}{"count": detail.Count, "mtime": detail.Mtime, "status": 1}).Error
1104
+	err = writeDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? and good_type_id = ? And patient_id = ? and org_id =? and record_time = ?", detail.GoodId, detail.GoodTypeId, detail.PatientId, detail.OrgId, detail.RecordTime).Updates(map[string]interface{}{"count": detail.Count, "mtime": detail.Mtime, "status": 1}).Error
1105 1105
 	return err
1106 1106
 }
1107 1107
 

+ 5 - 0
service/doctor_advice_service.go View File

@@ -360,6 +360,11 @@ func ModifyTemplateName(id int64, template_name string) (err error) {
360 360
 	return err
361 361
 }
362 362
 
363
+func ModifyTemplateNameOne(id int64, template_name string, sort int64) (err error) {
364
+	err = writeDb.Model(&models.DoctorAdviceParentTemplate{}).Where("status=1 AND id = ?", id).Updates(map[string]interface{}{"name": template_name, "updated_time": time.Now().Unix(), "sort": sort}).Error
365
+	return err
366
+}
367
+
363 368
 func ModifyHisTemplateName(id int64, template_name string) (err error) {
364 369
 	err = writeDb.Model(&models.HisDoctorAdviceParentTemplate{}).Where("status=1 AND id = ?", id).Updates(map[string]interface{}{"name": template_name, "updated_time": time.Now().Unix()}).Error
365 370
 	return err

+ 3 - 0
service/drug_stock_service.go View File

@@ -21,6 +21,7 @@ type DrugConfig struct {
21 21
 	MinUnit      string       `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
22 22
 	HospApprFlag int64        `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
23 23
 	LmtUsedFlag  int64        `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
24
+	Total        float64      `gorm:"column:total" json:"total" form:"total"`
24 25
 }
25 26
 
26 27
 func (DrugConfig) TableName() string {
@@ -89,6 +90,8 @@ type DrugStockInfo struct {
89 90
 	QuerySalesReturnInfo  []models.DrugSalesReturnInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"query_drug_sales_return_info"`
90 91
 	QueryWarehouseOutInfo []models.DrugWarehouseOutInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"query_drug_warehouseout_info"`
91 92
 	QueryCancelStockInfo  []models.DrugCancelStockInfo  `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"query_drug_cancel_stock_info"`
93
+
94
+	Total float64 `gorm:"column:total" json:"total" form:"total"`
92 95
 }
93 96
 
94 97
 func (DrugStockInfo) TableName() string {

+ 6 - 0
service/gobal_config_service.go View File

@@ -489,3 +489,9 @@ func GetAllBaseDrugList(orgid int64) (drug []*models.BaseDrugLib, err error) {
489 489
 	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1", orgid).Find(&drug).Error
490 490
 	return drug, err
491 491
 }
492
+
493
+func GetDrugWarehuseOrderInfo(orgid int64) (drug []*models.DrugWarehouseInfo, err error) {
494
+
495
+	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Group("drug_id").Find(&drug).Error
496
+	return drug, err
497
+}

+ 14 - 2
service/his_service.go View File

@@ -679,6 +679,7 @@ type BaseDrugLib struct {
679 679
 	PackingUnit                 string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
680 680
 	PackingPrice                float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
681 681
 	DrugDay                     string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
682
+	Total                       float64 `gorm:"column:total" json:"total" form:"total"`
682 683
 
683 684
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
684 685
 	OtherDrugWarehouseInfo []*OtherDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"stock_in"`
@@ -706,8 +707,14 @@ func GetAllDrugLibs(org_id int64) (drugs []*Drugs, err error) {
706 707
 	return
707 708
 }
708 709
 
709
-func GetAllProjectList(org_id int64) (list []*models.HisProject, err error) {
710
-	err = readDb.Model(&models.HisProject{}).Where("user_org_id = ?  AND status = 1", org_id).Find(&list).Error
710
+func GetAllProjectList(org_id int64, keyword string) (list []*models.HisProject, err error) {
711
+	if len(keyword) != 0 {
712
+		key := "%" + keyword + "%"
713
+		err = readDb.Model(&models.HisProject{}).Where("user_org_id = ?  AND status = 1 AND project_name Like ?", org_id, key).Find(&list).Error
714
+	} else {
715
+		err = readDb.Model(&models.HisProject{}).Where("user_org_id = ?  AND status = 1", org_id).Find(&list).Error
716
+	}
717
+
711 718
 	return
712 719
 }
713 720
 
@@ -1858,3 +1865,8 @@ func GetHisPrescriptionProjectByID(id int64) (projects models.HisPrescriptionPro
1858 1865
 	err = readDb.Model(&models.HisPrescriptionProject{}).Preload("GoodInfo", "status = 1").Where("id = ? AND status = 1", id).First(&projects).Error
1859 1866
 	return
1860 1867
 }
1868
+
1869
+func GetHisPrescriptionAdviceByID(id int64) (advices []*models.HisDoctorAdviceInfo, err error) {
1870
+	err = readDb.Model(&models.HisDoctorAdviceInfo{}).Where("prescription_id = ? AND status = 1", id).Find(&advices).Error
1871
+	return
1872
+}

+ 11 - 0
service/manage_center_service.go View File

@@ -158,6 +158,11 @@ func FindBaseDrugLibRecordCount(lib *models.BaseDrugLib) (count int64) {
158 158
 	return
159 159
 }
160 160
 
161
+func FindBaseDrugLibRecordCountOne(lib *models.BaseDrugLib) (count int64) {
162
+	readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? and drug_name = ? and dosage = ? and max_unit = ? and unval = ? and min_unit = ? and packing_unit = ? and manufacturer = ? and status = 1", lib.OrgId, lib.DrugName, lib.Dosage, lib.MaxUnit, lib.Unval, lib.MinUnit, lib.PackingUnit, lib.Manufacturer).Count(&count)
163
+	return
164
+}
165
+
161 166
 func FindAllDrugLibRecordTotal(org_id int64) (count int64) {
162 167
 	readDb.Model(&models.BaseDrugLib{}).Where("org_id = ? AND status = 1", org_id).Count(&count)
163 168
 	return
@@ -357,3 +362,9 @@ func GetDoseCode(dose_id int64, user_org_id int64) (error, string) {
357 362
 	err := readDb.Model(&models.DictDataconfig{}).Where(" (user_org_id = ? Or user_org_id = 0) AND parent_id = 4 AND module = 'system' AND status = 1 AND value = ?", user_org_id, dose_id).First(&data).Error
358 363
 	return err, data.Code
359 364
 }
365
+
366
+func GetAllDrugList(orgid int64) (drug []*models.BaseDrugLib, err error) {
367
+
368
+	err = XTReadDB().Model(&drug).Where("org_id = ? and status = 1", orgid).Find(&drug).Error
369
+	return drug, err
370
+}

+ 78 - 31
service/mobile_dialysis_service.go View File

@@ -852,13 +852,14 @@ func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType
852 852
 		}
853 853
 
854 854
 	} else if adviceType == 2 && len(deliverWay) <= 0 {
855
+
855 856
 		if patientType == 0 {
856 857
 			adviceWhere = "status = 1 AND user_org_id = ? AND advice_type = 2 AND record_date = ?"
857 858
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
858 859
 
859 860
 		} else if patientType == 1 {
860
-			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND advice_doctor = ?"
861
-			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId)
861
+			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2 AND (advice_doctor = ? or execution_staff = ?)"
862
+			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate, adminUserId, adminUserId)
862 863
 		} else if patientType == 2 {
863 864
 			adviceWhere = "status = 1 AND user_org_id = ? AND record_date = ? AND advice_type = 2  AND execution_staff = 0"
864 865
 			adviceCondition = append(adviceCondition, adviceWhere, orgID, scheduleDate)
@@ -886,41 +887,82 @@ func MobileGetScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceType
886 887
 	return vms, err
887 888
 }
888 889
 
889
-func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string) ([]*HisMScheduleDoctorAdviceVM, error) {
890
+func GetHisDoctorAdvices(orgID int64, scheduleDate int64, deliverWay string, patientType int, adminUserId int64) ([]*HisMScheduleDoctorAdviceVM, error) {
890 891
 
891 892
 	var vms []*HisMScheduleDoctorAdviceVM
892 893
 	if len(deliverWay) > 0 {
893
-		db := readDb.
894
-			Table("xt_schedule").
895
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
896
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
897
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
898
-			}).
899
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
900
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
901
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
902
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
903
-			Where("status = 1 AND user_org_id = ?", orgID)
904
-		if scheduleDate != 0 {
905
-			db = db.Where("schedule_date = ?", scheduleDate)
894
+		if patientType == 0 {
895
+			db := readDb.
896
+				Table("xt_schedule").
897
+				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
898
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
899
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
900
+				}).
901
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
902
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
903
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
904
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ?", orgID, scheduleDate, deliverWay).
905
+				Where("status = 1 AND user_org_id = ?", orgID)
906
+			if scheduleDate != 0 {
907
+				db = db.Where("schedule_date = ?", scheduleDate)
908
+			}
909
+			err = db.Find(&vms).Error
906 910
 		}
907
-		err = db.Find(&vms).Error
911
+		if patientType > 0 {
912
+			db := readDb.
913
+				Table("xt_schedule").
914
+				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
915
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
916
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
917
+				}).
918
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
919
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
920
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
921
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and delivery_way = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, deliverWay, adminUserId, adminUserId).
922
+				Where("status = 1 AND user_org_id = ?", orgID)
923
+			if scheduleDate != 0 {
924
+				db = db.Where("schedule_date = ?", scheduleDate)
925
+			}
926
+			err = db.Find(&vms).Error
927
+		}
928
+
908 929
 	} else {
909
-		db := readDb.
910
-			Table("xt_schedule").
911
-			Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
912
-			Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
913
-				return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
914
-			}).
915
-			Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
916
-			Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
917
-			Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
918
-			Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ?", orgID, scheduleDate).
919
-			Where("status = 1 AND user_org_id = ?", orgID)
920
-		if scheduleDate != 0 {
921
-			db = db.Where("schedule_date = ?", scheduleDate)
930
+		if patientType == 0 {
931
+			db := readDb.
932
+				Table("xt_schedule").
933
+				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
934
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
935
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
936
+				}).
937
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
938
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
939
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
940
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
941
+				Where("status = 1 AND user_org_id = ?", orgID)
942
+			if scheduleDate != 0 {
943
+				db = db.Where("schedule_date = ?", scheduleDate)
944
+			}
945
+			err = db.Find(&vms).Error
922 946
 		}
923
-		err = db.Find(&vms).Error
947
+		fmt.Println("patin34te2222222222222222222", patientType)
948
+		if patientType > 0 {
949
+			db := readDb.
950
+				Table("xt_schedule").
951
+				Preload("SchedualPatient", "status = 1 AND user_org_id = ?", orgID).
952
+				Preload("DialysisOrder", func(db *gorm.DB) *gorm.DB {
953
+					return db.Where("status = 1 AND user_org_id = ?", orgID).Preload("DeviceNumber", "status = 1 AND org_id= ?", orgID)
954
+				}).
955
+				Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).
956
+				Preload("DeviceNumber.Zone", "status = 1 AND org_id = ?", orgID).
957
+				Preload("Prescription", "status = 1 AND user_org_id = ? AND record_date = ?", orgID, scheduleDate).
958
+				Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ? AND advice_date = ? and  (advice_doctor = ? or execution_staff = ?) ", orgID, scheduleDate, adminUserId, adminUserId).
959
+				Where("status = 1 AND user_org_id = ?", orgID)
960
+			if scheduleDate != 0 {
961
+				db = db.Where("schedule_date = ?", scheduleDate)
962
+			}
963
+			err = db.Find(&vms).Error
964
+		}
965
+
924 966
 	}
925 967
 
926 968
 	return vms, err
@@ -1427,6 +1469,11 @@ func FindConsumablesByDate(orgID int64, patient_id int64, recordDate int64) (con
1427 1469
 	return
1428 1470
 }
1429 1471
 
1472
+func FindConsumablesByDateTwo(orgID int64, patient_id int64, recordDate int64) (consumables []*models.DialysisBeforePrepare, err error) {
1473
+	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1 AND count > 0", orgID, patient_id, recordDate).Find(&consumables).Error
1474
+	return
1475
+}
1476
+
1430 1477
 //func FindLastConsumables(orgID int64, patient_id int64, recordDate int64) (consumables []*models.DialysisBeforePrepare, err error){
1431 1478
 //	err = readDb.Model(&models.DialysisBeforePrepare{}).Where("user_org_id = ? AND patient_id = ? AND record_date = ? AND status = 1", orgID, patient_id,recordDate).Find(&consumables).Error
1432 1479
 //	return

+ 6 - 1
service/patient_service.go View File

@@ -1491,10 +1491,15 @@ func GetDialysisCount(orgid int64, partitionid int64) (order []*models.BloodDial
1491 1491
 
1492 1492
 func UpdatePatientDialysisSolutionOne(patientid int64, orgid int64, prescription *models.DialysisPrescription, timenow int64) error {
1493 1493
 
1494
-	err = XTWriteDB().Model(&prescription).Where("patient_id = ? and user_org_id = ? and record_date = ? ", patientid, orgid, timenow).Updates(map[string]interface{}{"dialyzer": prescription.Dialyzer, "anticoagulant": prescription.Anticoagulant, "mode_id": prescription.ModeId, "dialysis_duration_hour": prescription.DialysisDurationHour, "anticoagulant_shouji": prescription.AnticoagulantShouji, "anticoagulant_weichi": prescription.AnticoagulantWeichi, "anticoagulant_zongliang": prescription.AnticoagulantZongliang, "kalium": prescription.Kalium, "sodium": prescription.Sodium, "calcium": prescription.Calcium, "dialyzer_perfusion_apparatus": prescription.DialyzerPerfusionApparatus, "blood_access": prescription.BloodAccess, "dialysate_flow": prescription.DialysateFlow, "dialysate_temperature": prescription.DialysateTemperature, "dialysis_dialyszers": prescription.DialysisDialyszers, "dialysis_irrigation": prescription.DialysisIrrigation}).Error
1494
+	err = XTWriteDB().Model(&prescription).Where("patient_id = ? and user_org_id = ? and record_date = ? ", patientid, orgid, timenow).Updates(map[string]interface{}{"dialyzer": prescription.Dialyzer, "anticoagulant": prescription.Anticoagulant, "mode_id": prescription.ModeId, "dialysis_duration_hour": prescription.DialysisDurationHour, "anticoagulant_shouji": prescription.AnticoagulantShouji, "anticoagulant_weichi": prescription.AnticoagulantWeichi, "anticoagulant_zongliang": prescription.AnticoagulantZongliang, "kalium": prescription.Kalium, "sodium": prescription.Sodium, "calcium": prescription.Calcium, "dialyzer_perfusion_apparatus": prescription.DialyzerPerfusionApparatus, "blood_access": prescription.BloodAccess, "dialysate_flow": prescription.DialysateFlow, "dialysate_temperature": prescription.DialysateTemperature, "dialysis_dialyszers": prescription.DialysisDialyszers, "dialysis_irrigation": prescription.DialysisIrrigation, "plasma_separator": prescription.PlasmaSeparator, "bilirubin_adsorption_column": prescription.BilirubinAdsorptionColumn}).Error
1495 1495
 	return err
1496 1496
 }
1497 1497
 
1498
+//func FindRemindAdvice(user_org_id int64, advice_name string, advice_desc string, template_id string, fre_type int64, patient_id int64, record_date int64) (advice models.DoctorAdvice, err error) {
1499
+//	err = XTWriteDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and advice_name = ? and advice_desc = ? and template_id = ? and frequency_type = ? ", patient_id, user_org_id, record_date, advice_name, advice_desc, template_id, fre_type).First(&advice).Error
1500
+//	return
1501
+//}
1502
+
1498 1503
 func FindRemindAdvice(user_org_id int64, advice_name string, advice_desc string, template_id string, fre_type int64, patient_id int64, record_date int64) (advice models.DoctorAdvice, err error) {
1499 1504
 	err = XTWriteDB().Model(&models.DoctorAdvice{}).Where("patient_id = ? and user_org_id = ? and record_date = ? and advice_name = ? and advice_desc = ? and template_id = ? and frequency_type = ? AND advice_type = 2 ", patient_id, user_org_id, record_date, advice_name, advice_desc, template_id, fre_type).First(&advice).Error
1500 1505
 	return

+ 37 - 3
service/patientmanage_service.go View File

@@ -865,7 +865,7 @@ func GetDialysisrecord(patientID int64, start int64, end int64, limit int64, pag
865 865
 			return readUserDb.Where("org_id=? and status = 1", orgID)
866 866
 		}).
867 867
 		Joins("JOIN xt_schedule as s ON s.patient_id=? and FROM_UNIXTIME(s.schedule_date, '%Y-%m-%d')=FROM_UNIXTIME(do.dialysis_date, '%Y-%m-%d')", patientID).
868
-		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id", orgID).
868
+		Joins("JOIN xt_device_zone as dz ON dz.org_id = ? and dz.id=s.partition_id and s.status = 1", orgID).
869 869
 		Where("do.patient_id=? and do.user_org_id=? and do.stage = 2 and do.status=1", patientID, orgID).Group("s.schedule_date")
870 870
 
871 871
 	if start > 0 {
@@ -949,14 +949,14 @@ func GetNewPatient(id int64) (models.XtPatientsNew, error) {
949 949
 
950 950
 func UpdatedPatient(patients models.Patients, id int64) error {
951 951
 
952
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime}).Error
952
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone}).Error
953 953
 
954 954
 	return err
955 955
 }
956 956
 
957 957
 func UpdateXtPatientNew(patients models.XtPatientsNew, id int64) error {
958 958
 
959
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime}).Error
959
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone}).Error
960 960
 
961 961
 	return err
962 962
 }
@@ -1587,3 +1587,37 @@ func GetBloodAccess(orgid int64) (*models.Dataconfig, error) {
1587 1587
 	err := XTReadDB().Model(&dataconfig).Where("org_id = 0 and name = '血管通路部位' and status = 1 ").Find(&dataconfig).Error
1588 1588
 	return &dataconfig, err
1589 1589
 }
1590
+
1591
+func GetPatientScheduleCount(orgid int64, startTime int64, endTime int64, ids []string) (schedule []*models.VmXtSchedule, err error) {
1592
+
1593
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status =1")
1594
+	if orgid > 0 {
1595
+		db = db.Where("x.user_org_id = ?", orgid)
1596
+	}
1597
+	if startTime > 0 {
1598
+		db = db.Where("x.schedule_date >=?", startTime)
1599
+	}
1600
+	if endTime > 0 {
1601
+		db = db.Where("x.schedule_date<=?", endTime)
1602
+	}
1603
+	if len(ids) > 0 {
1604
+		db = db.Where("x.partition_id in (?)", ids)
1605
+	}
1606
+	err = db.Select("count(x.id) as count,x.schedule_type,x.schedule_week").Group("x.schedule_week,x.schedule_type").Scan(&schedule).Error
1607
+	return schedule, err
1608
+}
1609
+
1610
+func GetTotalBedNumber(orgid int64, ids []string) (list []*models.XtDeviceNumber, total int64, err error) {
1611
+
1612
+	//err = XTReadDB().Model(&list).Where("org_id = ? and status = 1 ",orgid).Count(&total).Find(&list).Error
1613
+	//return list,total,err
1614
+	db := XTReadDB().Table("xt_device_number as x").Where("x.status = 1")
1615
+	if orgid > 0 {
1616
+		db = db.Where("x.org_id = ?", orgid)
1617
+	}
1618
+	if len(ids) > 0 {
1619
+		db = db.Where("x.zone_id in (?)", ids)
1620
+	}
1621
+	err = db.Count(&total).Find(&list).Error
1622
+	return list, total, err
1623
+}

+ 7 - 0
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

@@ -196,6 +196,13 @@ type PrescriptionVM struct {
196 196
 	AnticoagulantStopTimeHour  int64   `gorm:"column:anticoagulant_stop_time_hour" json:"anticoagulant_stop_time_hour" form:"anticoagulant_stop_time_hour"`
197 197
 	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
198 198
 	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
199
+	Illness                    int64   `gorm:"column:illness" json:"illness" form:"illness"`
200
+	Amylaceum                  string  `gorm:"column:amylaceum" json:"amylaceum" form:"amylaceum"`
201
+	SingleTime                 string  `gorm:"column:single_time" json:"single_time" form:"single_time"`
202
+	SingleWater                string  `gorm:"column:single_water" json:"single_water" form:"single_water"`
203
+	ReplacementFlow            string  `gorm:"column:replacement_flow" json:"replacement_flow" form:"replacement_flow"`
204
+	PlasmaSeparator            string  `gorm:"column:plasma_separator" json:"plasma_separator" form:"plasma_separator"`
205
+	BilirubinAdsorptionColumn  string  `gorm:"column:bilirubin_adsorption_column" json:"bilirubin_adsorption_column" form:"bilirubin_adsorption_column"`
199 206
 }
200 207
 
201 208
 func (PrescriptionVM) TableName() string {

+ 186 - 11
service/schedule_service.go View File

@@ -19,7 +19,7 @@ func GetSchedulePartitionPanel(orgID int64) (partitions []*models.Partition, err
19 19
 }
20 20
 
21 21
 func GetSchedulePartitionPanelOne(orgID int64, partionId int64) (partitions []*models.Partition, err error) {
22
-	fmt.Println("partionId3333333333333333", partionId)
22
+
23 23
 	if partionId > 0 {
24 24
 		err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1 and zone_id = ?", orgID, partionId).Where("org_id=? and status=1 and id = ?", orgID, partionId).Find(&partitions).Error
25 25
 	}
@@ -30,6 +30,18 @@ func GetSchedulePartitionPanelOne(orgID int64, partionId int64) (partitions []*m
30 30
 	return
31 31
 }
32 32
 
33
+func GetSchedulePartitionPanelTwo(orgID int64, schIDs []string) (partitions []*models.Partition, err error) {
34
+
35
+	if len(schIDs) == 0 {
36
+		err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1", orgID).Where("org_id=? and status=1", orgID).Find(&partitions).Error
37
+	}
38
+	if len(schIDs) > 0 {
39
+		err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1 and zone_id in(?)", orgID, schIDs).Where("org_id=? and status=1 and id in(?)", orgID, schIDs).Find(&partitions).Error
40
+	}
41
+
42
+	return
43
+}
44
+
33 45
 func GetPatientWithScheduleAndSolution(orgID int64, keywords string, weekStart, weekEnd, schedule, contagion int64) (patients []*models.Patients, err error) {
34 46
 	db := readDb.Table("xt_patients as p").
35 47
 		Preload("DialysisSolutions", "user_org_id=? and initiate_mode=1 and affirm_state=1 and parent_id=0 and status=1", orgID).
@@ -83,6 +95,25 @@ func GetWeekScheduleOne(orgID int64, start, end int64, partionid int64, schedule
83 95
 	return
84 96
 }
85 97
 
98
+func GetWeekScheduleTwo(orgID int64, start, end int64, schIds []string, scheduletype int64) (schedules []*models.Schedule, err error) {
99
+
100
+	db := readDb.Table("xt_schedule as s")
101
+	fmt.Println("schIds2222222")
102
+	if len(schIds) > 0 {
103
+		db = db.Where("s.partition_id in (?)", schIds)
104
+	}
105
+	if scheduletype > 0 {
106
+		db = db.Where("s.schedule_type = ?", scheduletype)
107
+	}
108
+	err = db.Preload("PatientInfectiousDiseases", "status = 1 ").
109
+		Joins("JOIN xt_patients as p ON p.id = s.patient_id").
110
+		Where("s.user_org_id=? and s.schedule_date>=? and s.schedule_date<=? and s.status=1", orgID, start, end).
111
+		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
112
+		Order("updated_time asc").
113
+		Find(&schedules).Error
114
+	return
115
+}
116
+
86 117
 func GetDaySchedule(orgID, start, end, patientID int64) (schedule models.Schedule, err error) {
87 118
 	err = readDb.Model(&models.Schedule{}).Where("user_org_id=? and patient_id=? and schedule_date>=? and schedule_date<=? and status=1", orgID, patientID, start, end).First(&schedule).Error
88 119
 	return
@@ -133,10 +164,10 @@ func CreateSchedule(m *models.Schedule) error {
133 164
 	return writeDb.Model(&models.Schedule{}).Create(&m).Error
134 165
 }
135 166
 
136
-func GetTodayScheduleIsExist(patientid int64, schedudate int64, orgid int64) (*models.XtSchedule, error) {
167
+func GetTodayScheduleIsExist(patientid int64, schedudate int64, orgid int64, mode_id int64, schedule_type int64) (*models.XtSchedule, error) {
137 168
 	var scheudle models.XtSchedule
138 169
 	var err error
139
-	err = XTReadDB().Model(&scheudle).Where("patient_id = ? and schedule_date= ? and user_org_id = ? and status = 1", patientid, schedudate, orgid).Find(&scheudle).Error
170
+	err = XTReadDB().Model(&scheudle).Where("patient_id = ? and schedule_date= ? and user_org_id = ? and status = 1 and mode_id = ? and schedule_type = ?", patientid, schedudate, orgid, mode_id, schedule_type).Find(&scheudle).Error
140 171
 	if err == gorm.ErrRecordNotFound {
141 172
 		return nil, err
142 173
 	}
@@ -146,8 +177,8 @@ func GetTodayScheduleIsExist(patientid int64, schedudate int64, orgid int64) (*m
146 177
 	return &scheudle, nil
147 178
 }
148 179
 
149
-func UpdateScheduleByOrgId(patientid int64, scheduledate int64, orgid int64, sch *models.XtSchedule) error {
150
-	err := XTWriteDB().Model(&sch).Where("patient_id = ? and schedule_date= ? and user_org_id = ? and status = 1", patientid, scheduledate, orgid).Updates(map[string]interface{}{"partition_id": sch.PartitionId, "bed_id": sch.BedId, "schedule_type": sch.ScheduleType, "schedule_week": sch.ScheduleWeek, "mode_id": sch.ModeId, "updated_time": time.Now().Unix()}).Error
180
+func UpdateScheduleByOrgId(patientid int64, scheduledate int64, orgid int64, mode_id int64, schedule_type int64, sch *models.XtSchedule) error {
181
+	err := XTWriteDB().Model(&sch).Where("patient_id = ? and schedule_date= ? and user_org_id = ? and status = 1 and mode_id = ? and schedule_type = ?", patientid, scheduledate, orgid, mode_id, schedule_type).Updates(map[string]interface{}{"partition_id": sch.PartitionId, "bed_id": sch.BedId, "schedule_type": sch.ScheduleType, "schedule_week": sch.ScheduleWeek, "mode_id": sch.ModeId, "updated_time": time.Now().Unix()}).Error
151 182
 	return err
152 183
 }
153 184
 
@@ -385,8 +416,7 @@ func GetWeekDayScheduleTwo(orgID int64, scheduleDate int64, scheduleDates *time.
385 416
 				advice.IsCheck = 1
386 417
 				if advice.FrequencyType == 3 {
387 418
 					week := int(scheduleDates.Weekday())
388
-					fmt.Println("week-------", week)
389
-					fmt.Println(advice.WeekDay)
419
+
390 420
 					switch week {
391 421
 					case 1:
392 422
 						if strings.Index(advice.WeekDay, "周一") > -1 {
@@ -534,6 +564,49 @@ func GetWeekDaySchedule(orgID int64, scheduleDate int64, scheduleDates *time.Tim
534 564
 	return
535 565
 }
536 566
 
567
+func GetWeekDayScheduleById(orgid int64, scheduleDate int64, scheduleType int64) (list []*models.VmSchedules, err error) {
568
+
569
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
570
+	if orgid > 0 {
571
+		db = db.Where("x.user_org_id = ?", orgid)
572
+	}
573
+	if scheduleDate > 0 {
574
+		db = db.Where("x.schedule_date = ?", scheduleDate)
575
+	}
576
+	if scheduleType > 0 {
577
+		db = db.Where("x.schedule_type = ?", scheduleType)
578
+	}
579
+
580
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
581
+		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
582
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", "status = 1 and user_org_id = ?", orgid).Find(&list).Error
583
+
584
+	return list, err
585
+}
586
+
587
+func GetWeekDayScheduleByIdTwo(orgid int64, scheduleDate int64, scheduleType int64, startDate int64, zone int64) (list []*models.VmSchedules, err error) {
588
+
589
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
590
+	if orgid > 0 {
591
+		db = db.Where("x.user_org_id = ?", orgid)
592
+	}
593
+	if scheduleDate > 0 {
594
+		db = db.Where("x.schedule_date >=? and x.schedule_date<=?", startDate, scheduleDate)
595
+	}
596
+	if scheduleType > 0 {
597
+		db = db.Where("x.schedule_type = ?", scheduleType)
598
+	}
599
+	if zone > 0 {
600
+		db = db.Where("s.partition_id = ?", zone)
601
+	}
602
+
603
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
604
+		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
605
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", "user_org_id =? and status = 1", orgid).Find(&list).Error
606
+
607
+	return list, err
608
+}
609
+
537 610
 func RemoveRepeatedElement(arr []*models.DoctorAdvice) (newArr []*models.DoctorAdvice) {
538 611
 	newArr = make([]*models.DoctorAdvice, 0)
539 612
 	for i := 0; i < len(arr); i++ {
@@ -678,7 +751,7 @@ func UpdateNewScheduleTemplateStatus(id int64, org_id int64) (err error) {
678 751
 	return
679 752
 }
680 753
 
681
-func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64) (schedules []*models.WeekSchedule, err error) {
754
+func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endtime int64, orgID int64, zone int64) (schedules []*models.WeekSchedule, err error) {
682 755
 
683 756
 	db := readDb.Table("xt_schedule as s ").Where("s.status =1")
684 757
 	if orgID > 0 {
@@ -696,14 +769,20 @@ func GetNextWeekDaySchedule(weektype int64, weektime int64, startime int64, endt
696 769
 	if weektype > 0 {
697 770
 		db = db.Where("s.schedule_week = ?", weektype)
698 771
 	}
772
+	if zone > 0 {
773
+		db = db.Where("s.partition_id = ?", zone)
774
+	}
699 775
 	err = db.
700 776
 		Preload("DeviceZone", "status = 1 ").
701 777
 		Preload("DeviceNumber", "status = 1 ").
702 778
 		Preload("DialysisPrescription", func(db *gorm.DB) *gorm.DB {
703 779
 			return db.Where("status = 1").Order("id asc")
704
-		}).
705
-		Joins("JOIN xt_patients as p ON p.id = s.patient_id").
706
-		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
780
+		}).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
781
+		return db.Where("status = 1").Order("id asc")
782
+	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
783
+		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
784
+	}).Preload("HisDoctorAdviceInfo", "status = 1").Joins("JOIN xt_patients as p ON p.id = s.patient_id").
785
+		Select("s.id,s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id, s.status, s.created_time, s.updated_time, p.name as patient").
707 786
 		Order("s.partition_id asc").
708 787
 		Find(&schedules).Error
709 788
 	return schedules, err
@@ -768,3 +847,99 @@ func UpdatePatientSchedule(orgid int64, startime int64, endtime int64) error {
768 847
 	err := XTWriteDB().Model(&schedule).Where("user_org_id = ? and schedule_date>=? and schedule_date<=? and status =1", orgid, startime, endtime).Updates(map[string]interface{}{"status": 0}).Error
769 848
 	return err
770 849
 }
850
+
851
+func GetSettingById(id int64) (*models.XtRemindPrintSetting, error) {
852
+	setting := models.XtRemindPrintSetting{}
853
+	err := XTReadDB().Model(&setting).Where("id = ? and status = 1", id).Find(&setting).Error
854
+	if err == gorm.ErrRecordNotFound {
855
+		return nil, err
856
+	}
857
+	if err != nil {
858
+		return nil, err
859
+	}
860
+	return &setting, nil
861
+}
862
+
863
+func CreateSetting(setting *models.XtRemindPrintSetting) error {
864
+
865
+	err := XTReadDB().Create(&setting).Error
866
+	return err
867
+}
868
+
869
+func UpdatedRemindPrint(set *models.XtRemindPrintSetting, id int64) error {
870
+
871
+	err := XTWriteDB().Model(&set).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"prescription_status": set.PrescriptionStatus, "week": set.Week, "name": set.Name, "zone": set.Zone, "classes": set.Classes, "number": set.Number, "mode": set.Mode, "dialyzers": set.Dialyzers, "perfusion_apparatus": set.PerfusionApparatus, "anticoagulant": set.Anticoagulant, "doctor_advice": set.DoctorAdvice, "anticoagulant_zongliang": set.AnticoagulantZongliang}).Error
872
+	return err
873
+}
874
+
875
+func GetRemindPrintList(id int64) (models.XtRemindPrintSetting, error) {
876
+
877
+	setting := models.XtRemindPrintSetting{}
878
+	err := XTReadDB().Model(&setting).Where("user_org_id = ? and status =1", id).Find(&setting).Error
879
+	return setting, err
880
+}
881
+
882
+func GetScheudleTemplateById(orgid int64) (*models.ScheduleTemplate, error) {
883
+
884
+	schedule := models.ScheduleTemplate{}
885
+	err := XTReadDB().Model(&schedule).Where("user_org_id = ? and status = 1", orgid).Find(&schedule).Error
886
+	if err == gorm.ErrRecordNotFound {
887
+		return nil, err
888
+	}
889
+	if err != nil {
890
+		return nil, err
891
+	}
892
+	return &schedule, nil
893
+}
894
+
895
+func CreateXtscheduleTemplate(template *models.ScheduleTemplate) error {
896
+
897
+	err := XTWriteDB().Create(&template).Error
898
+	return err
899
+}
900
+
901
+func UpdateXtScheduleTemplate(template *models.ScheduleTemplate, orgid int64) error {
902
+
903
+	err := XTWriteDB().Model(&template).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"template_id": template.TemplateId}).Error
904
+	return err
905
+}
906
+
907
+func GetScheduleTemplate(orgid int64) (models.ScheduleTemplate, error) {
908
+
909
+	template := models.ScheduleTemplate{}
910
+	err := XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&template).Error
911
+	return template, err
912
+}
913
+
914
+func GetDataPrintByOrgId(orgid int64) (*models.XtDataPrint, error) {
915
+
916
+	dataPrint := models.XtDataPrint{}
917
+
918
+	err := XTReadDB().Model(&dataPrint).Where("user_org_id = ? and status = 1", orgid).Find(&dataPrint).Error
919
+
920
+	if err == gorm.ErrRecordNotFound {
921
+		return nil, err
922
+	}
923
+	if err != nil {
924
+		return nil, err
925
+	}
926
+	return &dataPrint, nil
927
+}
928
+
929
+func CreateDataPrint(dataPrint *models.XtDataPrint) error {
930
+
931
+	err := XTWriteDB().Create(&dataPrint).Error
932
+	return err
933
+}
934
+
935
+func UpdteDataPrint(orgid int64, dataPrint *models.XtDataPrint) error {
936
+
937
+	err := XTWriteDB().Model(&dataPrint).Where("user_org_id = ? and status = 1", orgid).Updates(map[string]interface{}{"is_open": dataPrint.IsOpen}).Error
938
+	return err
939
+}
940
+
941
+func GetDataPrint(orgid int64) (models.XtDataPrint, error) {
942
+	dataPrint := models.XtDataPrint{}
943
+	err := XTReadDB().Model(&dataPrint).Where("user_org_id = ? and status = 1", orgid).Find(&dataPrint).Error
944
+	return dataPrint, err
945
+}

+ 101 - 19
service/stock_service.go View File

@@ -453,11 +453,27 @@ func CreateDrugWarehousingInfo(warehousingInfo []*models.DrugWarehouseInfo) (err
453 453
 
454 454
 func FindLastWarehousingInfo(order string) (info models.WarehousingInfo, err error) {
455 455
 	err = readDb.Model(&models.WarehousingInfo{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
456
-
457 456
 	return info, err
457
+}
458
+
459
+//func FindFirstWarehousingInfoByStock(good_id int64,good_type_id int64) (info models.WarehousingInfo, err error) {
460
+//	err = readDb.Model(&models.WarehousingInfo{}).Where("good_id = ? AND good_type_id = ? AND status = 1 and stock_count > 0", order).Order("ctime").First(&info).Error
461
+//	return info, err
462
+//}
463
+
464
+//药品先进先出,找出最先入库的批次
458 465
 
466
+func FindLastDrugWarehousingInfoByID(drug_id int64) (info models.XtDrugWarehouseInfo, err error) {
467
+	err = readDb.Model(&models.XtDrugWarehouseInfo{}).Where("drug_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) ", drug_id).Order("ctime").First(&info).Error
468
+	return info, err
459 469
 }
460 470
 
471
+// 出库时先进先出,找出最先入库的批次
472
+//func  (drug_id int64) (info models.WarehousingInfo, err error) {
473
+//	err = readDb.Model(&models.WarehousingInfo{}).Where("drup_id = ? AND status = 1 AND (stock_max_number > 0 or stock_min_number > 0) ", drug_id).Order("ctime").First(&info).Error
474
+//	return info, err
475
+//}
476
+
461 477
 func FindLastDrugWarehousingInfo(order string) (info models.DrugWarehouseInfo, err error) {
462 478
 	err = readDb.Model(&models.DrugWarehouseInfo{}).Where("warehousing_order = ? AND status = 1", order).Last(&info).Error
463 479
 
@@ -532,6 +548,7 @@ type VMDrugWarehouseInfo struct {
532 548
 	Type             int64   `gorm:"column:type" json:"type" form:"type"`
533 549
 	RetailPrice      float64 `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
534 550
 	RetailTotalPrice float64 `gorm:"column:retail_total_price" json:"retail_total_price" form:"retail_total_price"`
551
+	BatchNumber      string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
535 552
 	Drug             *Drug   `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug"`
536 553
 }
537 554
 
@@ -540,21 +557,30 @@ func (VMDrugWarehouseInfo) TableName() string {
540 557
 }
541 558
 
542 559
 type Drug struct {
543
-	ID              int64  `gorm:"column:id" json:"id" form:"id"`
544
-	DrugName        string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
545
-	DrugSpec        string `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
546
-	DrugType        int64  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
547
-	DrugStockLimit  string `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
548
-	DrugOriginPlace string `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
549
-	DrugDosageForm  int64  `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
550
-	Manufacturer    int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
551
-	Status          int64  `gorm:"column:status" json:"status" form:"status"`
552
-	Ctime           int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
553
-	Mtime           int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
554
-	OrgId           int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
555
-	DrugCode        string `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
556
-	HospApprFlag    int64  `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
557
-	LmtUsedFlag     int64  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
560
+	ID              int64   `gorm:"column:id" json:"id" form:"id"`
561
+	DrugName        string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
562
+	DrugSpec        string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
563
+	DrugType        int64   `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
564
+	DrugStockLimit  string  `gorm:"column:drug_stock_limit" json:"drug_stock_limit" form:"drug_stock_limit"`
565
+	DrugOriginPlace string  `gorm:"column:drug_origin_place" json:"drug_origin_place" form:"drug_origin_place"`
566
+	DrugDosageForm  int64   `gorm:"column:drug_dosage_form" json:"drug_dosage_form" form:"drug_dosage_form"`
567
+	Manufacturer    int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
568
+	Status          int64   `gorm:"column:status" json:"status" form:"status"`
569
+	Ctime           int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
570
+	Mtime           int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
571
+	OrgId           int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
572
+	DrugCode        string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
573
+	Dosage          string  `gorm:"column:dosage" json:"dosage" form:"dosage"`
574
+	Unval           string  `gorm:"column:unval" json:"unval" form:"unval"`
575
+	PackingUnit     string  `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
576
+	PackingPrice    float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
577
+	DrugDay         string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
578
+	MaxUnit         string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
579
+	MinUnit         string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
580
+	LastPrice       float64 `gorm:"column:last_price" json:"last_price" form:"last_price"`
581
+	HospApprFlag    int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
582
+	LmtUsedFlag     int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
583
+	Total           float64 `gorm:"column:total" json:"total" form:"total"`
558 584
 }
559 585
 
560 586
 func (Drug) TableName() string {
@@ -1589,6 +1615,21 @@ func UpDateWarehouseOutStatus(id int64) (err error) {
1589 1615
 	return
1590 1616
 }
1591 1617
 
1618
+func UpDateDrugWarehouseInfoByStock(info *models.XtDrugWarehouseInfo) (err error) {
1619
+	err = writeDb.Save(&info).Error
1620
+	return err
1621
+}
1622
+
1623
+func UpDateWarehouseInfoByStock(info *models.WarehousingInfo) (err error) {
1624
+	err = writeDb.Save(&info).Error
1625
+	return err
1626
+}
1627
+
1628
+//func UpDateWarehouseInfoByStockDelete(id int64,count int64) (err error) {
1629
+//	err = DB.Model(&models.WarehousingInfo{}).Where("id = ?",info.ID).UpdateColumn("stock_count", gorm.Expr("stock_count + ?", count)).Error
1630
+//	return err
1631
+//}
1632
+
1592 1633
 func UpDateDrugWarehouseOutStatus(id int64) (err error) {
1593 1634
 	err = readDb.Model(&models.DrugWarehouseOutInfo{}).Where("id = ? AND status = 1", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
1594 1635
 	return
@@ -2050,6 +2091,11 @@ func FindStockOutInfoByTypeId(org_id int64, good_type_id int64, good_id int64, o
2050 2091
 	return
2051 2092
 }
2052 2093
 
2094
+func FindStockOutInfoByStock(org_id int64, good_type_id int64, good_id int64, record_date int64, patient_id int64) (out []*models.WarehouseOutInfo, err error) {
2095
+	err = readDb.Model(&models.WarehouseOutInfo{}).Where("status = 1 AND org_id = ? AND good_type_id = ? AND good_id = ? AND is_sys = 1 AND sys_record_time = ? AND patient_id = ?", org_id, good_type_id, good_id, record_date, patient_id).Order("ctime desc").Find(&out).Error
2096
+	return
2097
+}
2098
+
2053 2099
 func FindDrugStockOutInfoByTypeId(org_id int64, drug_id int64, out_id int64, number string) (out models.DrugWarehouseOutInfo, err error) {
2054 2100
 	err = readDb.Model(&models.DrugWarehouseOutInfo{}).Where("status = 1 AND org_id = ? AND  drug_id = ? AND is_sys = 1 AND  (warehouse_out_id = ? or warehouse_out_order_number = ?)", org_id, drug_id, out_id, number).First(&out).Error
2055 2101
 	return
@@ -2286,9 +2332,14 @@ func GetCoutWareseOutInfo(startime int64, endtime int64, orgid int64) (houseOutI
2286 2332
 	return houseOutInfo, err
2287 2333
 }
2288 2334
 
2289
-func GetGoodInfomationList(orgid int64) (goodInfo []*models.GoodInfo, err error) {
2335
+func GetGoodInfomationList(orgid int64, keyword string) (goodInfo []*models.GoodInfo, err error) {
2336
+	if len(keyword) == 0 {
2337
+		err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
2338
+	} else {
2339
+		key := "%" + keyword + "%"
2340
+		err = XTReadDB().Where("org_id = ? and status = 1 and good_name Like ?", orgid, key).Find(&goodInfo).Error
2341
+	}
2290 2342
 
2291
-	err = XTReadDB().Where("org_id = ? and status = 1", orgid).Find(&goodInfo).Error
2292 2343
 	return goodInfo, err
2293 2344
 }
2294 2345
 
@@ -2305,6 +2356,19 @@ func IsExistDrugByName(drugname string, drugdesc string, orgid int64) (*models.B
2305 2356
 	return &drug, nil
2306 2357
 }
2307 2358
 
2359
+func IsExistDrugByNameOne(drugname string, dosage string, maxunit string, unival string, minunit string, packtunit string, orgid int64) (*models.BaseDrugLib, error) {
2360
+	var drug models.BaseDrugLib
2361
+	var err error
2362
+	err = XTReadDB().Model(&drug).Where("drug_name = ? and dosage = ?  and max_unit = ? and unval = ? and min_unit=? and packing_unit = ? and status =1 and org_id = ?", drugname, dosage, maxunit, unival, minunit, packtunit, orgid).Find(&drug).Error
2363
+	if err == gorm.ErrRecordNotFound {
2364
+		return nil, err
2365
+	}
2366
+	if err != nil {
2367
+		return nil, err
2368
+	}
2369
+	return &drug, nil
2370
+}
2371
+
2308 2372
 func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2309 2373
 	err := XTWriteDB().Create(&info).Error
2310 2374
 	return err
@@ -2312,7 +2376,7 @@ func CreateDrugsInfomation(info *models.BaseDrugLib) error {
2312 2376
 
2313 2377
 func UpdateDrugsInformation(drug *models.BaseDrugLib, drugName string, drugSpec string, orgid int64) error {
2314 2378
 
2315
-	err := XTWriteDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and org_id = ? and status = 1", drugName, drugSpec, orgid).Updates(map[string]interface{}{"drug_name": drug.DrugName, "drug_alias": drug.DrugAlias, "drug_spec": drug.DrugSpec, "drug_type": drug.DrugType, "drug_stock_limit": drug.DrugStockLimit, "drug_origin_place": drug.DrugOriginPlace, "drug_dosage_form": drug.DrugDosageForm, "medical_insurance_level": drug.MedicalInsuranceLevel, "max_unit": drug.MaxUnit, "min_unit": drug.MinUnit, "unit_matrixing": drug.UnitMatrixing, "retail_price": drug.RetailPrice, "last_price": drug.LastPrice, "drug_classify": drug.DrugClassify, "manufacturer": drug.Manufacturer, "dealer": drug.Dealer, "pinyin": drug.Pinyin, "wubi": drug.Wubi, "drug_alias_pinyin": drug.DrugAliasPinyin, "drug_alias_wubi": drug.DrugAliasWubi, "drug_category": drug.DrugCategory, "drug_control": drug.DrugControl, "number": drug.Number, "hosp_appr_flag": drug.HospApprFlag, "medical_insurance_number": drug.MedicalInsuranceNumber, "pharmacology_category": drug.PharmacologyCategory, "statistics_category": drug.StatisticsCategory, "code": drug.Code, "is_special_diseases": drug.IsSpecialDiseases, "is_record": drug.IsRecord, "prescription_mark": drug.PrescriptionMark, "social_security_directory_code": drug.SocialSecurityDirectoryCode, "record_date": drug.RecordDate, "drug_remark": drug.DrugRemark, "drug_status": drug.DrugStatus, "limit_remark": drug.LimitRemark, "drug_dose": drug.DrugDose, "drug_dose_unit": drug.DrugDoseUnit, "lmt_used_flag": drug.LmtUsedFlag}).Error
2379
+	err := XTWriteDB().Model(&drug).Where("drug_name = ? and drug_spec = ? and org_id = ? and status = 1", drugName, drugSpec, orgid).Updates(map[string]interface{}{"drug_name": drug.DrugName, "drug_alias": drug.DrugAlias, "drug_spec": drug.DrugSpec, "drug_type": drug.DrugType, "drug_stock_limit": drug.DrugStockLimit, "drug_origin_place": drug.DrugOriginPlace, "drug_dosage_form": drug.DrugDosageForm, "medical_insurance_level": drug.MedicalInsuranceLevel, "max_unit": drug.MaxUnit, "min_unit": drug.MinUnit, "unit_matrixing": drug.UnitMatrixing, "retail_price": drug.RetailPrice, "last_price": drug.LastPrice, "drug_classify": drug.DrugClassify, "manufacturer": drug.Manufacturer, "dealer": drug.Dealer, "pinyin": drug.Pinyin, "wubi": drug.Wubi, "drug_alias_pinyin": drug.DrugAliasPinyin, "drug_alias_wubi": drug.DrugAliasWubi, "drug_category": drug.DrugCategory, "drug_control": drug.DrugControl, "number": drug.Number, "hosp_appr_flag": drug.HospApprFlag, "medical_insurance_number": drug.MedicalInsuranceNumber, "pharmacology_category": drug.PharmacologyCategory, "statistics_category": drug.StatisticsCategory, "code": drug.Code, "is_special_diseases": drug.IsSpecialDiseases, "is_record": drug.IsRecord, "prescription_mark": drug.PrescriptionMark, "social_security_directory_code": drug.SocialSecurityDirectoryCode, "record_date": drug.RecordDate, "drug_remark": drug.DrugRemark, "drug_status": drug.DrugStatus, "limit_remark": drug.LimitRemark, "drug_dose": drug.DrugDose, "drug_dose_unit": drug.DrugDoseUnit, "lmt_used_flag": drug.LmtUsedFlag, "delivery_way": drug.DeliveryWay, "execution_frequency": drug.ExecutionFrequency, "dosage": drug.Dosage, "unval": drug.Unval, "packing_unit": drug.PackingUnit, "packing_price": drug.PackingPrice, "drug_day": drug.DrugDay}).Error
2316 2380
 	return err
2317 2381
 }
2318 2382
 
@@ -2511,3 +2575,21 @@ func FindAllDataConfigList(orgid int64, parentId int64) (dataconfig []*models.Da
2511 2575
 	err = XTReadDB().Model(&dataconfig).Where("(org_id = ? or org_id = 0) and parent_id = ? and status = 1", orgid, parentId).Find(&dataconfig).Error
2512 2576
 	return dataconfig, err
2513 2577
 }
2578
+
2579
+func GetWarehouseOrderInfoList(orgid int64) (list []*models.WarehousingInfo, err error) {
2580
+
2581
+	err = XTReadDB().Model(&list).Where("org_id = ? and status = 1", orgid).Order("id asc").Group("good_id").Find(&list).Error
2582
+	return list, err
2583
+}
2584
+
2585
+func GetSearchDrugList(keywords string, orgid int64) (drug []*models.BaseDrugLib, err error) {
2586
+
2587
+	db := XTReadDB().Model(&drug).Where("org_id=? and status=1 ", orgid)
2588
+	if len(keywords) > 0 {
2589
+		likekey := "%" + keywords + "%"
2590
+		err = db.Where("(drug_name LIKE ?)", likekey).Find(&drug).Error
2591
+	} else {
2592
+		err = db.Find(&drug).Error
2593
+	}
2594
+	return
2595
+}

+ 549 - 0
service/warhouse_service.go View File

@@ -0,0 +1,549 @@
1
+package service
2
+
3
+//
4
+//import (
5
+//	"XT_New/models"
6
+//	"XT_New/utils"
7
+//	"errors"
8
+//	"fmt"
9
+//	_ "fmt"
10
+//	"github.com/jinzhu/gorm"
11
+//	"math"
12
+//	"strconv"
13
+//	"strings"
14
+//	"time"
15
+//)
16
+//
17
+//// 药品出库
18
+//
19
+//func DrugsDelivery(orgID int64, advice *models.DoctorAdvice) (err error) {
20
+//	// 1.判断药品是否来自专用字典的药品库
21
+//	// 2.判断当天当前机构有没有创建出库单,没有则创建
22
+//	// 3.创建出库流程
23
+//	// 3.1 实现先进先出逻辑 由于药品执行后,不可以修改和删除,所以不考虑出库后的退库和修改出库数量等
24
+//	isHasWay := false
25
+//	record_time := int64(0)
26
+//	if advice.Way == 1 {
27
+//		isHasWay = true
28
+//		record_time = advice.RecordDate
29
+//	}
30
+//	if isHasWay {
31
+//		//判断当天当前机构有没有创建出库单,没有则创建
32
+//		out, err := FindDrugStockOutByIsSys(orgID, 1, record_time)
33
+//		if err == gorm.ErrRecordNotFound {
34
+//			timeStr := time.Now().Format("2006-01-02")
35
+//			timeArr := strings.Split(timeStr, "-")
36
+//			total, _ := FindAllDrugWarehouseOut(orgID)
37
+//			total = total + 1
38
+//			warehousing_out_order := strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
39
+//			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
40
+//			number = number + total
41
+//			warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
42
+//			// creater := adminUserInfo.AdminUser.Id
43
+//			warehouseOut := models.DrugWarehouseOut{
44
+//				WarehouseOutOrderNumber: warehousing_out_order,
45
+//				OperationTime:           time.Now().Unix(),
46
+//				OrgId:                   orgID,
47
+//				Creater:                 0,
48
+//				Ctime:                   time.Now().Unix(),
49
+//				Status:                  1,
50
+//				WarehouseOutTime:        record_time,
51
+//				Dealer:                  0,
52
+//				Manufacturer:            0,
53
+//				Type:                    1,
54
+//				IsSys:                   1,
55
+//			}
56
+//			err := AddSigleDrugWarehouseOut(&warehouseOut)
57
+//			if err != nil {
58
+//				utils.TraceLog("创建出库单失败 err = %v", err)
59
+//				return err
60
+//			} else {
61
+//				out = warehouseOut
62
+//			}
63
+//		}
64
+//
65
+//		// 出库流程
66
+//		// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
67
+//		drup, _ := FindBaseDrugLibRecord(orgID, advice.DrugId)
68
+//		if drup.ID > 0 {
69
+//			prescribingNumber := advice.PrescribingNumber
70
+//			DrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice)
71
+//		} else {
72
+//			return errors.New("药品信息不存在")
73
+//		}
74
+//
75
+//	}
76
+//
77
+//	return
78
+//}
79
+//
80
+//// 药品出库 递归方式
81
+//func DrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.DoctorAdvice) (err error) {
82
+//	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
83
+//	var deliver_number int64 = 0
84
+//	var stock_number int64 = 0
85
+//
86
+//	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
87
+//	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
88
+//	if advice.PrescribingNumberUnit == drup.MaxUnit {
89
+//		deliver_number = count * drup.MinNumber
90
+//	} else {
91
+//		deliver_number = count
92
+//	}
93
+//
94
+//	// 根据先进先出原则,查询最先入库的批次,进行出库
95
+//	// 如果没有对应的库存,则报错
96
+//	warehouse, err := FindLastDrugWarehousingInfoByID(advice.DrugId)
97
+//	fmt.Println("查询222222222222222222222222222222222222222222222222", err)
98
+//	if err != nil {
99
+//		return err
100
+//	}
101
+//
102
+//	// 将该批次的剩余库存数量转换为拆零数量
103
+//	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
104
+//	// 当库存数量大于或等于出库数量的话,则正常出库该批次
105
+//	if stock_number >= deliver_number {
106
+//		warehouseOutInfo := &models.DrugWarehouseOutInfo{
107
+//			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
108
+//			WarehouseOutId:          warehouseout.ID,
109
+//			Status:                  1,
110
+//			Ctime:                   time.Now().Unix(),
111
+//			Remark:                  "",
112
+//			OrgId:                   orgID,
113
+//			Type:                    1,
114
+//			Manufacturer:            0,
115
+//			Dealer:                  0,
116
+//			IsSys:                   1,
117
+//			SysRecordTime:           advice.RecordDate,
118
+//			DrugId:                  advice.DrugId,
119
+//		}
120
+//		warehouseOutInfo.Count = deliver_number
121
+//		warehouseOutInfo.CountUnit = drup.MinUnit
122
+//		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
123
+//		if errOne != nil {
124
+//			return errOne
125
+//		} else {
126
+//			// prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
127
+//			// count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
128
+//			details := &models.DrugAutomaticReduceDetail{
129
+//				WarehouseOutId:          warehouseOutInfo.ID,
130
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
131
+//				PatientId:               advice.PatientId,
132
+//				Ctime:                   time.Now().Unix(),
133
+//				Mtime:                   time.Now().Unix(),
134
+//				Status:                  1,
135
+//				RecordTime:              advice.RecordDate,
136
+//				OrgId:                   orgID,
137
+//				DrugId:                  advice.DrugId,
138
+//				Count:                   deliver_number,
139
+//				CountUnit:               drup.MinUnit,
140
+//			}
141
+//			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
142
+//			if errTwo != nil {
143
+//				return errTwo
144
+//			}
145
+//		}
146
+//		// 出库完成后,要减去对应批次的库存数量
147
+//		// 判断处方里药品单位是拆零单位还是包装单位,	如果是拆零单位,则根据规格,将拆零数量转为包装数量
148
+//		var maxNumber int64 = 0
149
+//		var minNumber int64 = 0
150
+//		if advice.PrescribingNumberUnit == drup.MinUnit {
151
+//			maxNumber = count / drup.MinNumber
152
+//			minNumber = count % drup.MinNumber
153
+//		} else {
154
+//			maxNumber = count
155
+//		}
156
+//
157
+//		if warehouse.StockMaxNumber < maxNumber {
158
+//			return errors.New("库存数量不足")
159
+//		}
160
+//
161
+//		warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
162
+//		warehouse.Mtime = time.Now().Unix()
163
+//		if warehouse.StockMinNumber < minNumber {
164
+//			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
165
+//			warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
166
+//		} else {
167
+//			warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
168
+//		}
169
+//
170
+//		if warehouse.StockMaxNumber < 0 {
171
+//			return errors.New("库存数量不足")
172
+//		}
173
+//		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
174
+//		if errThree != nil {
175
+//			return errThree
176
+//		}
177
+//
178
+//		return nil
179
+//	} else {
180
+//		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
181
+//		warehouseOutInfo := &models.DrugWarehouseOutInfo{
182
+//			WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
183
+//			WarehouseOutId:          warehouseout.ID,
184
+//			Status:                  1,
185
+//			Ctime:                   time.Now().Unix(),
186
+//			Remark:                  "",
187
+//			OrgId:                   orgID,
188
+//			Type:                    1,
189
+//			Manufacturer:            0,
190
+//			Dealer:                  0,
191
+//			IsSys:                   1,
192
+//			SysRecordTime:           advice.RecordDate,
193
+//			DrugId:                  advice.DrugId,
194
+//		}
195
+//		// prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
196
+//		// count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
197
+//		warehouseOutInfo.Count = stock_number
198
+//		warehouseOutInfo.CountUnit = drup.MinUnit
199
+//
200
+//		errOne := AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
201
+//		if errOne != nil {
202
+//			return errOne
203
+//		} else {
204
+//			details := &models.DrugAutomaticReduceDetail{
205
+//				WarehouseOutId:          warehouseOutInfo.ID,
206
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
207
+//				PatientId:               advice.PatientId,
208
+//				Ctime:                   time.Now().Unix(),
209
+//				Mtime:                   time.Now().Unix(),
210
+//				Status:                  1,
211
+//				RecordTime:              advice.RecordDate,
212
+//				OrgId:                   orgID,
213
+//				DrugId:                  advice.DrugId,
214
+//				Count:                   stock_number,
215
+//				CountUnit:               drup.MinUnit,
216
+//			}
217
+//			errTwo := AddSigleDrugAutoReduceRecordInfo(details)
218
+//			if errTwo != nil {
219
+//				return errTwo
220
+//			}
221
+//		}
222
+//		// 出库完成后,要将该批次库存清零
223
+//		warehouse.StockMaxNumber = 0
224
+//		warehouse.StockMinNumber = 0
225
+//		warehouse.Mtime = time.Now().Unix()
226
+//		errThree := UpDateDrugWarehouseInfoByStock(&warehouse)
227
+//		if errThree != nil {
228
+//			return errThree
229
+//		}
230
+//		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
231
+//		prescribingNumber_two_temp := deliver_number - stock_number
232
+//		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
233
+//		advice.PrescribingNumberUnit = drup.MinUnit
234
+//		DrugDeliverInfo(orgID, prescribingNumber, warehouseout, drup, advice)
235
+//	}
236
+//	return
237
+//}
238
+//
239
+//// 耗材出库
240
+//func ConsumablesDeliveryTotal(orgID int64,patient_id int64,record_time int64,goods []models.DialysisBeforePrepareGoods) (err error) {
241
+//	//查询该患者当天已经出库的耗材信息
242
+//	goods_yc,_ := FindConsumablesByDateTwo(orgID, patient_id, record_time)
243
+//	// 和新请求的出库数据进行对比,分出那些是继续出库的,那些是需要删除出库的
244
+//	for i := len(goods_yc) - 1; i >= 0; i--{
245
+//		goods_yc_temp := goods_yc[i]
246
+//		for j := len(goods) - 1; j >= 0; j-- {
247
+//			goods_temp := goods[j]
248
+//			// 已经出库和新请求出库都存在该耗材,则判断出库数量,分成是继续出库,还是删除出库
249
+//			if goods_yc_temp.GoodTypeId == goods_temp.GoodTypeId && goods_yc_temp.GoodId == goods_temp.GoodId{
250
+//				// 已经出库和新请求出库的出库数量一致,则清除两个结构体里的数据(既不出库,也不删除出库)
251
+//				if goods_yc_temp.Count == goods_temp.Count {
252
+//					goods_yc = append(goods_yc[:i],goods_yc[i+1:]...)
253
+//					goods = append(goods[:j],goods[j+1:]...)
254
+//				}
255
+//
256
+//				// 如果已经出库的数量 大于 新请求出库的数量,则代表需要删除出库
257
+//				if goods_yc_temp.Count > goods_temp.Count {
258
+//					temp_count := goods_yc_temp.Count - goods_temp.Count
259
+//					goods_yc[i].Count = temp_count
260
+//					goods = append(goods[:j],goods[j+1:]...)
261
+//				}
262
+//
263
+//				// 如果已经出库的数量 小于 新请求出库的梳理,则代表需要增加出库
264
+//				if goods_yc_temp.Count < goods_temp.Count {
265
+//					temp_count := goods_temp.Count - goods_yc_temp.Count
266
+//					goods[j].Count = temp_count
267
+//					goods_yc = append(goods_yc[:i],goods_yc[i+1:]...)
268
+//				}
269
+//			}
270
+//		}
271
+//	}
272
+//
273
+//	// goods_yc 这个数据就是需要已经出库了,但是现在需要删除出库的耗材数据
274
+//	// goods 这个数据就是需要出库的耗材的数据
275
+//	if len(goods) > 0 {
276
+//		out, err := FindStockOutByIsSys(orgID, 1, record_time)
277
+//		if err == gorm.ErrRecordNotFound {
278
+//			//没有记录,则创建出库单
279
+//			timeStr := time.Now().Format("2006-01-02")
280
+//			timeArr := strings.Split(timeStr, "-")
281
+//			total, _ :=  FindAllWarehouseOut(orgID)
282
+//			total = total + 1
283
+//			warehousing_out_order := strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
284
+//			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
285
+//			number = number + total
286
+//			warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
287
+//			warehouseOut := models.WarehouseOut{
288
+//				WarehouseOutOrderNumber: warehousing_out_order,
289
+//				OperationTime:           time.Now().Unix(),
290
+//				OrgId:                   orgID,
291
+//				Creater:                 0,
292
+//				Ctime:                   time.Now().Unix(),
293
+//				Status:                  1,
294
+//				WarehouseOutTime:        record_time,
295
+//				Dealer:                  0,
296
+//				Manufacturer:            0,
297
+//				Type:                    1,
298
+//				IsSys:                   1,
299
+//			}
300
+//			err := AddSigleWarehouseOut(&warehouseOut)
301
+//			if err != nil {
302
+//				utils.TraceLog("创建出库单失败 err = %v", err)
303
+//				return err
304
+//			} else {
305
+//				out = warehouseOut
306
+//			}
307
+//		}
308
+//		for _,good := range goods {
309
+//			ConsumablesDelivery(orgID ,patient_id ,record_time ,good,out )
310
+//		}
311
+//	}
312
+//
313
+//	if len(goods_yc) > 0 {
314
+//		for _,good_yc := range goods_yc{
315
+//			ConsumablesDeliveryDelete(orgID ,patient_id ,record_time ,good_yc ,out )
316
+//		}
317
+//	}
318
+//
319
+//	return nil
320
+//}
321
+//
322
+//// 耗材出库
323
+//func ConsumablesDelivery(orgID int64,patient_id int64,record_time int64,goods models.DialysisBeforePrepareGoods,warehouseOut models.WarehouseOut) (err error) {
324
+//	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
325
+//	var deliver_number int64 = 0
326
+//	var stock_number int64 = 0
327
+//
328
+//	deliver_number = good.Count
329
+//
330
+//
331
+//	// 根据先进先出原则,查询最先入库的批次,进行出库
332
+//	// 如果没有对应的库存,则报错
333
+//	warehouse, err := FindFirstWarehousingInfoByStock(goods.GoodId,goods.GoodTypeId)
334
+//	if err != nil {
335
+//		return err
336
+//	}
337
+//
338
+//	// 将该批次的剩余库存数量转换为拆零数量
339
+//	stock_number = warehouse.StockCount
340
+//	// 当库存数量大于或等于出库数量的话,则正常出库该批次
341
+//	if stock_number >= deliver_number {
342
+//		warehouseOutInfo := &models.WarehouseOutInfo{
343
+//			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
344
+//			WarehouseOutId:          warehouseOut.ID,
345
+//			WarehouseInfoId:		 warehouse.ID,
346
+//			Status:                  1,
347
+//			Ctime:                   time.Now().Unix(),
348
+//			Remark:                  "",
349
+//			OrgId:                   orgID,
350
+//			Type:                    1,
351
+//			Manufacturer:            0,
352
+//			Dealer:                  0,
353
+//			IsSys:                   1,
354
+//			SysRecordTime:           record_time,
355
+//			GoodTypeId:              goods.GoodTypeId,
356
+//			GoodId:                  goods.GoodId,
357
+//			PatientId:				 patient_id,
358
+//		}
359
+//		warehouseOutInfo.Count = goods.Count
360
+//		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
361
+//		warehouseOutInfo.Price = stockInInfo.Price
362
+//		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
363
+//		if errOne != nil {
364
+//			return errOne
365
+//		} else {
366
+//			details := &models.AutomaticReduceDetail{
367
+//				WarehouseOutId:          warehouseOutInfo.ID,
368
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
369
+//				PatientId:               patient_id,
370
+//				Ctime:                   time.Now().Unix(),
371
+//				Mtime:                   time.Now().Unix(),
372
+//				Status:                  1,
373
+//				RecordTime:              record_time,
374
+//				OrgId:                   orgID,
375
+//				GoodId:                  goods.GoodId,
376
+//				GoodTypeId:              goods.GoodTypeId,
377
+//				Count:                   goods.Count,
378
+//			}
379
+//			errTwo := service.AddSigleAutoReduceRecordInfo(details)
380
+//			if errTwo != nil {
381
+//				return errTwo
382
+//			}
383
+//		}
384
+//
385
+//		// 出库完成后,要减去对应批次的库存数量
386
+//
387
+//		maxNumber = goods.Count
388
+//
389
+//
390
+//		if warehouse.StockMaxNumber < maxNumber {
391
+//			return errors.New("库存数量不足")
392
+//		}
393
+//
394
+//		warehouse.StockNumber = warehouse.StockMaxNumber - maxNumber
395
+//		warehouse.Mtime = time.Now().Unix()
396
+//
397
+//
398
+//		if warehouse.StockNumber < 0 {
399
+//			return errors.New("库存数量不足")
400
+//		}
401
+//		errThree := UpDateWarehouseInfoByStock(&warehouse)
402
+//		if errThree != nil {
403
+//			return errThree
404
+//		}
405
+//
406
+//		return nil
407
+//	}  else {
408
+//		// 当改批次的库存数量小于出库数量的话,则先把该批次出库完后,再进行递归出库
409
+//		warehouseOutInfo := &models.WarehouseOutInfo{
410
+//			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
411
+//			WarehouseOutId:          warehouseOut.ID,
412
+//			WarehouseInfoId:		 warehouse.ID,
413
+//			Status:                  1,
414
+//			Ctime:                   time.Now().Unix(),
415
+//			Remark:                  "",
416
+//			OrgId:                   orgID,
417
+//			Type:                    1,
418
+//			Manufacturer:            0,
419
+//			Dealer:                  0,
420
+//			IsSys:                   1,
421
+//			SysRecordTime:           record_time,
422
+//			GoodTypeId:              goods.GoodTypeId,
423
+//			GoodId:                  goods.GoodId,
424
+//			PatientId:				 patient_id,
425
+//		}
426
+//		warehouseOutInfo.Count = stock_number
427
+//		stockInInfo, _ := service.FindLastStockInInfoRecord(goods.GoodId, orgID)
428
+//		warehouseOutInfo.Price = stockInInfo.Price
429
+//		errOne := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
430
+//		if errOne != nil {
431
+//			return errOne
432
+//		} else {
433
+//			details := &models.AutomaticReduceDetail{
434
+//				WarehouseOutId:          warehouseOutInfo.ID,
435
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
436
+//				PatientId:               patient_id,
437
+//				Ctime:                   time.Now().Unix(),
438
+//				Mtime:                   time.Now().Unix(),
439
+//				Status:                  1,
440
+//				RecordTime:              record_time,
441
+//				OrgId:                   orgID,
442
+//				GoodId:                  goods.GoodId,
443
+//				GoodTypeId:              goods.GoodTypeId,
444
+//				Count:                   goods.Count,
445
+//			}
446
+//			errTwo := service.AddSigleAutoReduceRecordInfo(details)
447
+//			if errTwo != nil {
448
+//				return errTwo
449
+//			}
450
+//		}
451
+//		// 出库完成后,要将该批次库存清零
452
+//		warehouse.StockNumber = 0
453
+//		warehouse.Mtime = time.Now().Unix()
454
+//		errThree := UpDateWarehouseInfoByStock(&warehouse)
455
+//		if errThree != nil {
456
+//			return errThree
457
+//		}
458
+//		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
459
+//		goods.Count := deliver_number - stock_number
460
+//
461
+//		ConsumablesDelivery(orgID ,patient_id ,record_time ,good,out )
462
+//	}
463
+//	return nil
464
+//}
465
+//
466
+//// 耗材出库删除
467
+//func ConsumablesDeliveryDelete(orgID int64,patient_id int64,record_time int64,good_yc models.DialysisBeforePrepare,warehouseOut models.WarehouseOut) (err error) {
468
+//	// 先根据相关信息查询当天该耗材的出库信息
469
+//	warehouseOutInfos,err :=FindStockOutInfoByStock(orgID,good_yc.GoodTypeId,good_yc.GoodId,record_time,patient_id)
470
+//	if err != nil {
471
+//		return err
472
+//	}
473
+//
474
+//	var delete_count int64 = 0
475
+//
476
+//	for _ , ware := range warehouseOutInfos{
477
+//		// 判断当前出库的数据和删除出库数量
478
+//		if good_yc.Count <= ware.Count {
479
+//			delete_count = good_yc.Count
480
+//		} else {
481
+//			delete_count = ware.Count
482
+//		}
483
+//		// 在出库记录表里记录退库详情
484
+//		warehouseOutInfo := &models.WarehouseOutInfo{
485
+//			WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
486
+//			WarehouseOutId:          warehouseOut.ID,
487
+//			WarehouseInfoId:		 warehouse.ID,
488
+//			Status:                  1,
489
+//			Ctime:                   time.Now().Unix(),
490
+//			Remark:                  "",
491
+//			OrgId:                   orgID,
492
+//			Type:                    1,
493
+//			Manufacturer:            0,
494
+//			Dealer:                  0,
495
+//			IsSys:                   2,
496
+//			SysRecordTime:           record_time,
497
+//			GoodTypeId:              goods.GoodTypeId,
498
+//			GoodId:                  goods.GoodId,
499
+//			PatientId:				 patient_id,
500
+//		}
501
+//		warehouseOutInfo.Count = delete_count
502
+//		stockInInfo, _ := FindLastStockInInfoRecord(goods.GoodId, orgID)
503
+//		warehouseOutInfo.Price = stockInInfo.Price
504
+//		errOne := AddSigleWarehouseOutInfo(warehouseOutInfo)
505
+//		if errOne != nil {
506
+//			return errOne
507
+//		} else {
508
+//			details := &models.AutomaticReduceDetail{
509
+//				WarehouseOutId:          warehouseOutInfo.ID,
510
+//				WarehouseOutOrderNumber: warehouseOutInfo.WarehouseOutOrderNumber,
511
+//				PatientId:               patient_id,
512
+//				Ctime:                   time.Now().Unix(),
513
+//				Mtime:                   time.Now().Unix(),
514
+//				Status:                  1,
515
+//				RecordTime:              record_time,
516
+//				OrgId:                   orgID,
517
+//				GoodId:                  goods.GoodId,
518
+//				GoodTypeId:              goods.GoodTypeId,
519
+//				Count:                   delete_count,
520
+//				Type:					 2,
521
+//			}
522
+//			errTwo := AddSigleAutoReduceRecordInfo(details)
523
+//			if errTwo != nil {
524
+//				return errTwo
525
+//			}
526
+//		}
527
+//
528
+//		// 删除出库完成后,要增加对应批次的库存数量
529
+//
530
+//
531
+//
532
+//		errThree := UpDateWarehouseInfoByStockDelete(ware.WarehouseInfoId,delete_count)
533
+//		if errThree != nil {
534
+//			return errThree
535
+//		}
536
+//
537
+//		// 增加了对应的库存后,看看还有多少需要退库的
538
+//		good_yc.Count = goods_yc.Count - delete_count
539
+//		if good_yc.Count == 0 {
540
+//			return nil
541
+//		}
542
+//	}
543
+//
544
+//	if good_yd.Count == 0 {
545
+//		return nil
546
+//	}  else {
547
+//		return errors.New("退库和出库数据不匹配")
548
+//	}
549
+//}