Browse Source

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

csx 3 years ago
parent
commit
da0eec2a22

+ 71 - 75
controllers/doctors_api_controller.go View File

@@ -931,47 +931,7 @@ func (this *DoctorsApiController) SaveCreationInspection() {
931 931
 	inspect_date := dataBody["inspect_date"].(string)
932 932
 	project_id := dataBody["project_id"].(string)
933 933
 	template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
934
-	//title := this.GetString("title")
935
-	//dryWeight := this.GetString("dry_weight")
936
-	//dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
937
-	//dialysis_count, _ := this.GetInt64("dialysis_count")
938
-	//hd_count, _ := this.GetInt64("hd_count")
939
-	//hdf_count, _ := this.GetInt64("hdf_count")
940
-	//hp_count, _ := this.GetInt64("hp_count")
941
-	//other_count, _ := this.GetInt64("other_count")
942
-	//dialzer_apparatus := this.GetString("dialzer_apparatus")
943
-	//perfusion_apparatus := this.GetString("perfusion_apparatus")
944
-	//anticoagulant, _ := this.GetInt64("anticoagulant")
945
-	//kaliumstr := this.GetString("kalium")
946
-	//kalium, _ := strconv.ParseFloat(kaliumstr, 64)
947
-	//
948
-	//autunitestr := this.GetString("autunite")
949
-	//autunite, _ := strconv.ParseFloat(autunitestr, 64)
950
-	//natriumstr := this.GetString("natrium")
951
-	//natrium, _ := strconv.ParseFloat(natriumstr, 64)
952
-	//hour, _ := this.GetInt64("hour")
953
-	//minute, _ := this.GetInt64("minute")
954
-	//beforWeight := this.GetString("befor_weight")
955
-	//befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
956
-	//afterWeight := this.GetString("after_weight")
957
-	//after_weight, _ := strconv.ParseFloat(afterWeight, 64)
958
-	//befor_pressure := this.GetString("befor_pressure")
959
-	//template_summary_content := this.GetString("template_summary_content")
960
-	//template_plan_content := this.GetString("template_plan_content")
961
-	//admin_user_id, _ := this.GetInt64("admin_user_id")
962
-	//record_time := this.GetString("record_time")
963
-	//timeLayout := "2006-01-02"
964
-	//loc, _ := time.LoadLocation("Local")
965
-	//recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
966
-	//after_pressure := this.GetString("after_pressure")
967
-	//template_summary_id, _ := this.GetInt64("template_summary_id")
968
-	//template_plan_id, _ := this.GetInt64("template_plan_id")
969
-	//template_inspection_id, _ := this.GetInt64("template_inspection_id")
970
-	//patient_id, _ := this.GetInt64("patient_id")
971
-	//fmt.Println("patient_id", patient_id)
972
-	//orgId := this.GetAdminUserInfo().CurrentOrgId
973
-	//inspect_date := this.GetString("inspect_date")
974
-	//project_id := this.GetString("project_id")
934
+
975 935
 	summary := models.XtTemplateSummary{
976 936
 		StartYear:              0,
977 937
 		StartMonth:             0,
@@ -1086,50 +1046,86 @@ func (this *DoctorsApiController) UpdateTempalteSummary() {
1086 1046
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1087 1047
 		return
1088 1048
 	}
1089
-
1090
-	id, _ := this.GetInt64("id")
1091
-	title := this.GetString("title")
1092
-
1093
-	dryWeight := this.GetString("dry_weight")
1049
+	id := int64(dataBody["id"].(float64))
1050
+	title := dataBody["title"].(string)
1051
+	dryWeight := dataBody["dry_weight"].(string)
1094 1052
 	dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
1095
-	dialysis_count, _ := this.GetInt64("dialysis_count")
1096
-	hd_count, _ := this.GetInt64("hd_count")
1097
-	hdf_count, _ := this.GetInt64("hdf_count")
1098
-	hp_count, _ := this.GetInt64("hp_count")
1099
-	other_count, _ := this.GetInt64("other_count")
1100
-	dialzer_apparatus := this.GetString("dialzer_apparatus")
1101
-	perfusion_apparatus := this.GetString("perfusion_apparatus")
1102
-	anticoagulant, _ := this.GetInt64("anticoagulant")
1103
-	kaliumstr := this.GetString("kalium")
1053
+	dialysis_count := int64(dataBody["dialysis_count"].(float64))
1054
+	hd_count := int64(dataBody["hd_count"].(float64))
1055
+	hdf_count := int64(dataBody["hdf_count"].(float64))
1056
+	hp_count := int64(dataBody["hp_count"].(float64))
1057
+	other_count := int64(dataBody["other_count"].(float64))
1058
+	dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
1059
+	perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
1060
+	anticoagulant := int64(dataBody["anticoagulant"].(float64))
1061
+	kaliumstr := dataBody["kalium"].(string)
1104 1062
 	kalium, _ := strconv.ParseFloat(kaliumstr, 64)
1105
-
1106
-	autunitestr := this.GetString("autunite")
1063
+	autunitestr := dataBody["autunite"].(string)
1107 1064
 	autunite, _ := strconv.ParseFloat(autunitestr, 64)
1108
-	natriumstr := this.GetString("natrium")
1065
+	natriumstr := dataBody["natrium"].(string)
1109 1066
 	natrium, _ := strconv.ParseFloat(natriumstr, 64)
1110
-	hour, _ := this.GetInt64("hour")
1111
-	minute, _ := this.GetInt64("minute")
1112
-	beforWeight := this.GetString("befor_weight")
1067
+	hour := int64(dataBody["hour"].(float64))
1068
+	minute := int64(dataBody["minute"].(float64))
1069
+	beforWeight := dataBody["befor_weight"].(string)
1113 1070
 	befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
1114
-	afterWeight := this.GetString("after_weight")
1071
+	afterWeight := dataBody["after_weight"].(string)
1115 1072
 	after_weight, _ := strconv.ParseFloat(afterWeight, 64)
1116
-	befor_pressure := this.GetString("befor_pressure")
1117
-	template_summary_content := this.GetString("template_summary_content")
1118
-	template_plan_content := this.GetString("template_plan_content")
1119
-	admin_user_id, _ := this.GetInt64("admin_user_id")
1120
-	record_time := this.GetString("record_time")
1073
+	befor_pressure := dataBody["befor_pressure"].(string)
1074
+	template_summary_content := dataBody["template_summary_content"].(string)
1075
+	template_plan_content := dataBody["template_plan_content"].(string)
1076
+	admin_user_id := int64(dataBody["admin_user_id"].(float64))
1077
+	record_time := dataBody["record_time"].(string)
1121 1078
 	timeLayout := "2006-01-02"
1122 1079
 	loc, _ := time.LoadLocation("Local")
1123 1080
 	recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
1124
-	after_pressure := this.GetString("after_pressure")
1125
-	template_summary_id, _ := this.GetInt64("template_summary_id")
1126
-	template_plan_id, _ := this.GetInt64("template_plan_id")
1127
-	template_inspection_id, _ := this.GetInt64("template_inspection_id")
1128
-	patient_id, _ := this.GetInt64("patient_id")
1129
-	fmt.Println("patient_id", patient_id)
1081
+	after_pressure := dataBody["after_pressure"].(string)
1082
+	template_summary_id := int64(dataBody["template_summary_id"].(float64))
1083
+	template_plan_id := int64(dataBody["template_plan_id"].(float64))
1084
+	patient_id := int64(dataBody["patient_id"].(float64))
1130 1085
 	orgId := this.GetAdminUserInfo().CurrentOrgId
1131
-	inspect_date := this.GetString("inspect_date")
1132
-	project_id := this.GetString("project_id")
1086
+	inspect_date := dataBody["inspect_date"].(string)
1087
+	project_id := dataBody["project_id"].(string)
1088
+	template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
1089
+	//dryWeight := this.GetString("dry_weight")
1090
+	//dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
1091
+	//dialysis_count, _ := this.GetInt64("dialysis_count")
1092
+	//hd_count, _ := this.GetInt64("hd_count")
1093
+	//hdf_count, _ := this.GetInt64("hdf_count")
1094
+	//hp_count, _ := this.GetInt64("hp_count")
1095
+	//other_count, _ := this.GetInt64("other_count")
1096
+	//dialzer_apparatus := this.GetString("dialzer_apparatus")
1097
+	//perfusion_apparatus := this.GetString("perfusion_apparatus")
1098
+	//anticoagulant, _ := this.GetInt64("anticoagulant")
1099
+	//kaliumstr := this.GetString("kalium")
1100
+	//kalium, _ := strconv.ParseFloat(kaliumstr, 64)
1101
+	//
1102
+	//autunitestr := this.GetString("autunite")
1103
+	//autunite, _ := strconv.ParseFloat(autunitestr, 64)
1104
+	//natriumstr := this.GetString("natrium")
1105
+	//natrium, _ := strconv.ParseFloat(natriumstr, 64)
1106
+	//hour, _ := this.GetInt64("hour")
1107
+	//minute, _ := this.GetInt64("minute")
1108
+	//beforWeight := this.GetString("befor_weight")
1109
+	//befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
1110
+	//afterWeight := this.GetString("after_weight")
1111
+	//after_weight, _ := strconv.ParseFloat(afterWeight, 64)
1112
+	//befor_pressure := this.GetString("befor_pressure")
1113
+	//template_summary_content := this.GetString("template_summary_content")
1114
+	//template_plan_content := this.GetString("template_plan_content")
1115
+	//admin_user_id, _ := this.GetInt64("admin_user_id")
1116
+	//record_time := this.GetString("record_time")
1117
+	//timeLayout := "2006-01-02"
1118
+	//loc, _ := time.LoadLocation("Local")
1119
+	//recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
1120
+	//after_pressure := this.GetString("after_pressure")
1121
+	//template_summary_id, _ := this.GetInt64("template_summary_id")
1122
+	//template_plan_id, _ := this.GetInt64("template_plan_id")
1123
+	//template_inspection_id, _ := this.GetInt64("template_inspection_id")
1124
+	//patient_id, _ := this.GetInt64("patient_id")
1125
+	//fmt.Println("patient_id", patient_id)
1126
+	//orgId := this.GetAdminUserInfo().CurrentOrgId
1127
+	//inspect_date := this.GetString("inspect_date")
1128
+	//project_id := this.GetString("project_id")
1133 1129
 	summary := models.XtTemplateSummary{
1134 1130
 		ID:                     id,
1135 1131
 		StartYear:              0,

+ 28 - 5
controllers/drug_stock_api_contorller.go View File

@@ -240,8 +240,13 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
240 240
 					MinUnit:          min_unit,
241 241
 					RetailPrice:      retail_price,
242 242
 				}
243
-
244
-				if max_unit == min_unit {
243
+				medical, _ := service.GetBaseDrugMedical(drug_id)
244
+				if medical.MaxUnit == medical.MinUnit {
245
+					warehouseInfo.StockMaxNumber = warehousing_count
246
+					warehouseInfo.StockMinNumber = 0
247
+					warehouseInfo.MaxUnit = min_unit
248
+				}
249
+				if max_unit == medical.MinUnit {
245 250
 					warehouseInfo.StockMaxNumber = 0
246 251
 					warehouseInfo.StockMinNumber = warehousing_count
247 252
 					warehouseInfo.MaxUnit = min_unit
@@ -271,9 +276,12 @@ func (c *StockDrugApiController) CreateDrugWarehouse() {
271 276
 					IsSys:            0,
272 277
 				}
273 278
 
274
-				if max_unit == min_unit {
279
+				if medical.MaxUnit == medical.MinUnit {
275 280
 					drugflow.MaxUnit = min_unit
276 281
 				}
282
+				if max_unit == medical.MinUnit {
283
+					warehouseInfo.MaxUnit = min_unit
284
+				}
277 285
 				drugFlow = append(drugFlow, drugflow)
278 286
 
279 287
 			}
@@ -561,6 +569,8 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
561 569
 				manufacturer := int64(items["manufacturer"].(float64))
562 570
 
563 571
 				dealer := int64(items["dealer"].(float64))
572
+
573
+				medical, _ := service.GetBaseDrugMedical(drug_id)
564 574
 				if id == 0 {
565 575
 					warehouseInfo := &models.DrugWarehouseInfo{
566 576
 						WarehousingOrder: warehouse.WarehousingOrder,
@@ -586,11 +596,17 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
586 596
 						MinUnit:          min_unit,
587 597
 						StockMaxNumber:   warehousing_count,
588 598
 					}
589
-					if max_unit == min_unit {
599
+
600
+					if medical.MaxUnit == medical.MinUnit {
590 601
 						warehouseInfo.StockMaxNumber = warehousing_count
591 602
 						warehouseInfo.StockMinNumber = 0
592 603
 						warehouseInfo.MaxUnit = min_unit
593 604
 					}
605
+					if max_unit == medical.MinUnit {
606
+						warehouseInfo.StockMaxNumber = 0
607
+						warehouseInfo.StockMinNumber = warehousing_count
608
+						warehouseInfo.MaxUnit = min_unit
609
+					}
594 610
 					warehousingInfo = append(warehousingInfo, warehouseInfo)
595 611
 
596 612
 				} else {
@@ -619,12 +635,18 @@ func (c *StockDrugApiController) EditDrugWarehouse() {
619 635
 						MinUnit:          min_unit,
620 636
 						BatchNumber:      batch_number,
621 637
 					}
622
-					if max_unit == min_unit {
638
+					if medical.MaxUnit == medical.MinUnit {
623 639
 						warehouseInfo.StockMaxNumber = warehousing_count
624 640
 						warehouseInfo.StockMinNumber = 0
625 641
 						warehouseInfo.MaxUnit = min_unit
626 642
 					}
627 643
 
644
+					if max_unit == medical.MinUnit {
645
+						warehouseInfo.StockMaxNumber = 0
646
+						warehouseInfo.StockMinNumber = warehousing_count
647
+						warehouseInfo.MaxUnit = min_unit
648
+					}
649
+
628 650
 					upDateWarehousingInfo = append(upDateWarehousingInfo, warehouseInfo)
629 651
 
630 652
 					drugflow := &models.DrugFlow{
@@ -1455,6 +1477,7 @@ func (c *StockDrugApiController) CreateDrugWarehouseOut() {
1455 1477
 			})
1456 1478
 			return
1457 1479
 		}
1480
+
1458 1481
 		if prescribing_number_total > total_count {
1459 1482
 
1460 1483
 			goodObj, _ := service.GetDrugByGoodId(item.DrugId)

+ 7 - 1
controllers/gobal_config_api_controller.go View File

@@ -2061,6 +2061,8 @@ func (c *GobalConfigApiController) GetBatchOrderDetail() {
2061 2061
 	page, _ := c.GetInt64("page")
2062 2062
 	detail, total, err := service.GetBatchOrderDetail(drug_id, orgId, page, limit)
2063 2063
 	manufacturerList, _ := service.GetAllManufacturerList(orgId)
2064
+
2065
+	drug, _ := service.GetBaseDrugMedical(drug_id)
2064 2066
 	if err != nil {
2065 2067
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2066 2068
 		return
@@ -2069,6 +2071,7 @@ func (c *GobalConfigApiController) GetBatchOrderDetail() {
2069 2071
 		"detail":           detail,
2070 2072
 		"total":            total,
2071 2073
 		"manufacturerList": manufacturerList,
2074
+		"drug":             drug,
2072 2075
 	})
2073 2076
 }
2074 2077
 
@@ -2127,11 +2130,13 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2127 2130
 	id, _ := c.GetInt64("id")
2128 2131
 	start_time, _ := c.GetInt64("start_time")
2129 2132
 	orgId := c.GetAdminUserInfo().CurrentOrgId
2133
+
2130 2134
 	list, err := service.GetSingleOrderDetail(id, orgId)
2135
+
2131 2136
 	dealerList, err := service.GetAllDealerList(orgId)
2132 2137
 	manufacturerList, err := service.GetAllManufacturerList(orgId)
2133 2138
 	drugFlowList, _ := service.GetDrugStockFlowDetail(start_time, orgId)
2134
-
2139
+	flowlist, _ := service.GetSingeOrderFlow(id, orgId)
2135 2140
 	if err != nil {
2136 2141
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
2137 2142
 		return
@@ -2141,6 +2146,7 @@ func (c *GobalConfigApiController) GetSingleOrderDetail() {
2141 2146
 		"dealerList":       dealerList,
2142 2147
 		"manufacturerList": manufacturerList,
2143 2148
 		"drugFlowList":     drugFlowList,
2149
+		"flowlist":         flowlist,
2144 2150
 	})
2145 2151
 }
2146 2152
 

+ 20 - 9
controllers/his_api_controller.go View File

@@ -1685,7 +1685,7 @@ func (c *HisApiController) DeletePrescription() {
1685 1685
 						cancelStockInfo := models.CancelStockInfo{
1686 1686
 							GoodId:          item.ProjectId,
1687 1687
 							CancelStockId:   cancel.ID,
1688
-							GoodTypeId:      info.GoodTypeId,
1688
+							GoodTypeId:      good.GoodTypeId,
1689 1689
 							Count:           prescribingNumber,
1690 1690
 							Price:           info.Price,
1691 1691
 							Total:           0,
@@ -2404,7 +2404,7 @@ func (c *HisApiController) DeleteProject() {
2404 2404
 				cancelStockInfo := models.CancelStockInfo{
2405 2405
 					GoodId:          project.ProjectId,
2406 2406
 					CancelStockId:   cancel.ID,
2407
-					GoodTypeId:      info.GoodTypeId,
2407
+					GoodTypeId:      good.GoodTypeId,
2408 2408
 					Count:           prescribingNumber,
2409 2409
 					Price:           info.Price,
2410 2410
 					Total:           0,
@@ -3235,13 +3235,24 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
3235 3235
 					advice.StartTime = hisAdvice.StartTime
3236 3236
 					advice.HospApprFlag = hisAdvice.HospApprFlag
3237 3237
 
3238
-					if hisAdvice.SingleDose != advice.SingleDose || hisAdvice.DeliveryWay != advice.DeliveryWay || hisAdvice.ExecutionFrequency != advice.ExecutionFrequency || hisAdvice.Day != advice.Day || hisAdvice.PrescribingNumber != advice.PrescribingNumber || hisAdvice.Price != advice.Price || hisAdvice.Remark != advice.Remark || hisAdvice.PrescribingNumberUnit != advice.PrescribingNumberUnit {
3239
-						advice.ExecutionTime = 0
3240
-						advice.ExecutionStaff = 0
3241
-						advice.ExecutionState = 2
3242
-						advice.CheckTime = 0
3243
-						advice.Checker = 0
3244
-						advice.CheckState = 2
3238
+					if hisAdvice.UserOrgId == 10028 {
3239
+						if hisAdvice.DeliveryWay != advice.DeliveryWay || hisAdvice.ExecutionFrequency != advice.ExecutionFrequency || hisAdvice.Day != advice.Day || hisAdvice.PrescribingNumber != advice.PrescribingNumber || hisAdvice.Price != advice.Price || hisAdvice.Remark != advice.Remark || hisAdvice.PrescribingNumberUnit != advice.PrescribingNumberUnit {
3240
+							advice.ExecutionTime = 0
3241
+							advice.ExecutionStaff = 0
3242
+							advice.ExecutionState = 2
3243
+							advice.CheckTime = 0
3244
+							advice.Checker = 0
3245
+							advice.CheckState = 2
3246
+						}
3247
+					} else {
3248
+						if hisAdvice.SingleDose != advice.SingleDose || hisAdvice.DeliveryWay != advice.DeliveryWay || hisAdvice.ExecutionFrequency != advice.ExecutionFrequency || hisAdvice.Day != advice.Day || hisAdvice.PrescribingNumber != advice.PrescribingNumber || hisAdvice.Price != advice.Price || hisAdvice.Remark != advice.Remark || hisAdvice.PrescribingNumberUnit != advice.PrescribingNumberUnit {
3249
+							advice.ExecutionTime = 0
3250
+							advice.ExecutionStaff = 0
3251
+							advice.ExecutionState = 2
3252
+							advice.CheckTime = 0
3253
+							advice.Checker = 0
3254
+							advice.CheckState = 2
3255
+						}
3245 3256
 					}
3246 3257
 
3247 3258
 					//advice.Groupno = hisAdvice.Groupno

+ 40 - 37
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -687,11 +687,13 @@ func (c *PatientApiController) ExecDoctorAdvice() {
687 687
 		if drugStockConfig.IsOpen == 1 {
688 688
 			if groupno > 0 {
689 689
 				advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
690
+
690 691
 				isHasWay := false //用来判断是否包含来自药品库的医嘱
691 692
 				for _, item := range advices {
692 693
 					if item.Way == 1 {
693 694
 						isHasWay = true
694 695
 					}
696
+
695 697
 				}
696 698
 
697 699
 				if isHasWay {
@@ -1001,6 +1003,44 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1001 1003
 			_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
1002 1004
 			if drugStockConfig.IsOpen == 1 {
1003 1005
 				for _, item := range advices {
1006
+					//查询改药品信息
1007
+					medical, _ := service.GetBaseDrugMedical(item.DrugId)
1008
+					//查询这个患者这个患者这个药已经出库的所有数量
1009
+					advicelist, _ := service.GetAllHisDoctorAdviceById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
1010
+					drugoutlist, _ := service.GetAllDrugFlowById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
1011
+					var total_count int64
1012
+					var drug_count int64
1013
+					for _, it := range advicelist {
1014
+						if it.PrescribingNumberUnit == medical.MaxUnit {
1015
+							prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
1016
+							prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1017
+							total_count += prenumber * medical.MinNumber
1018
+						}
1019
+						if it.PrescribingNumberUnit == medical.MinUnit {
1020
+							prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
1021
+							prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1022
+							total_count += prenumber
1023
+						}
1024
+
1025
+					}
1026
+
1027
+					for _, its := range drugoutlist {
1028
+						if its.CountUnit == medical.MaxUnit {
1029
+							drug_count += its.Count * medical.MinNumber
1030
+						}
1031
+						if its.CountUnit == medical.MinUnit {
1032
+							drug_count += its.Count
1033
+						}
1034
+					}
1035
+					if total_count == drug_count {
1036
+						advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
1037
+						c.ServeSuccessJSON(map[string]interface{}{
1038
+							"msg":    "1",
1039
+							"advice": advice,
1040
+							"ids":    ids,
1041
+						})
1042
+						return
1043
+					}
1004 1044
 
1005 1045
 					advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
1006 1046
 
@@ -1009,8 +1049,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1009 1049
 					//查询该药品是否有库存
1010 1050
 					list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId)
1011 1051
 
1012
-					//查询改药品信息
1013
-					medical, _ := service.GetBaseDrugMedical(advice.DrugId)
1014 1052
 					//判断单位是否相等
1015 1053
 					if medical.MaxUnit == advice.PrescribingNumberUnit {
1016 1054
 						prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
@@ -1030,41 +1068,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1030 1068
 					fmt.Println("数量一", prescribing_number_total)
1031 1069
 					fmt.Println("数量二", total)
1032 1070
 
1033
-					//查询该药品的医嘱记录
1034
-					//advicelist, _ := service.GetHisAdviceListByDrugId(advice.DrugId, advice.PatientId, advice.AdviceDate)
1035
-					//if(advicelist.ID > 0){
1036
-					//  //获取上一次的出库记录
1037
-					//  record, _ := service.GetDrugAutoReduceRecordOne(advice.DrugId, advice.PatientId, advice.AdviceDate)
1038
-					//  var out_count int64
1039
-					//  for _, res := range record {
1040
-					//    if(res.CountUnit == medical.MaxUnit){
1041
-					//      res.Count = res.Count * medical.MinNumber
1042
-					//    }
1043
-					//    if(res.CountUnit == medical.MinUnit){
1044
-					//      res.Count = res.Count
1045
-					//    }
1046
-					//    out_count += res.Count
1047
-					//  }
1048
-					//  if((prescribing_number_total - out_count) > 0){
1049
-					//
1050
-					//    if((prescribing_number_total - out_count) > total){
1051
-					//      c.ServeSuccessJSON(map[string]interface{}{
1052
-					//        "msg":    "2",
1053
-					//        "advice": advice,
1054
-					//        "ids":    ids,
1055
-					//      })
1056
-					//      return
1057
-					//
1058
-					//    }else{
1059
-					//      service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1060
-					//      break
1061
-					//    }
1062
-					//  }else{
1063
-					//    service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1064
-					//    break
1065
-					//  }
1066
-					//}
1067
-
1068 1071
 					if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
1069 1072
 						c.ServeSuccessJSON(map[string]interface{}{
1070 1073
 							"msg":    "3",

+ 38 - 48
controllers/patient_api_controller.go View File

@@ -1935,13 +1935,48 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1935 1935
 			//查询已经执行的医嘱
1936 1936
 			advices, _ := service.GetHisExecutionDoctors(adminUserInfo.CurrentOrgId, patient, id)
1937 1937
 			for _, item := range advices {
1938
+
1939
+				medical, _ := service.GetBaseDrugMedical(advice.DrugId)
1940
+				//查询这个患者这个患者这个药已经出库的所有数量
1941
+				advicelist, _ := service.GetAllHisDoctorAdviceById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
1942
+				drugoutlist, _ := service.GetAllDrugFlowById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
1943
+				var total_count int64
1944
+				var drug_count int64
1945
+				for _, it := range advicelist {
1946
+					if it.PrescribingNumberUnit == medical.MaxUnit {
1947
+						prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
1948
+						prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1949
+						total_count += prenumber * medical.MinNumber
1950
+					}
1951
+					if it.PrescribingNumberUnit == medical.MinUnit {
1952
+						prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
1953
+						prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1954
+						total_count += prenumber
1955
+					}
1956
+
1957
+				}
1958
+
1959
+				for _, its := range drugoutlist {
1960
+					if its.CountUnit == medical.MaxUnit {
1961
+						drug_count += its.Count * medical.MinNumber
1962
+					}
1963
+					if its.CountUnit == medical.MinUnit {
1964
+						drug_count += its.Count
1965
+					}
1966
+				}
1967
+				if total_count == drug_count {
1968
+					c.ServeSuccessJSON(map[string]interface{}{
1969
+						"msg":    "1",
1970
+						"advice": advice,
1971
+					})
1972
+					return
1973
+				}
1974
+
1938 1975
 				var total int64
1939 1976
 				var prescribing_number_total int64
1940 1977
 				//查询该药品是否有库存
1941 1978
 				list, _ := service.GetDrugTotalCount(advice.DrugId, advice.UserOrgId)
1942 1979
 
1943
-				//查询改药品信息
1944
-				medical, _ := service.GetBaseDrugMedical(advice.DrugId)
1945 1980
 				//判断单位是否相等
1946 1981
 				if medical.MaxUnit == advice.PrescribingNumberUnit {
1947 1982
 					prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
@@ -1950,9 +1985,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1950 1985
 					total = list.Count*medical.MinNumber + list.StockMinNumber
1951 1986
 					prescribing_number_total = count * medical.MinNumber
1952 1987
 				}
1953
-				//fmt.Println("单位1", medical.MinUnit)
1954
-				//fmt.Println("d单位23", advice.PrescribingNumberUnit)
1955
-				//fmt.Println("hhhhhhh", list.Count)
1988
+
1956 1989
 				if medical.MinUnit == advice.PrescribingNumberUnit {
1957 1990
 					prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
1958 1991
 					count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
@@ -1962,49 +1995,6 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1962 1995
 
1963 1996
 				}
1964 1997
 
1965
-				//fmt.Println("要出库的数量", prescribing_number_total)
1966
-				//fmt.Println("库存", total)
1967
-
1968
-				//查询该药品的医嘱记录
1969
-				//advicelist, _ := service.GetHisAdviceListByDrugId(advice.DrugId, advice.PatientId, advice.AdviceDate)
1970
-				//
1971
-				//if(advicelist.ID > 0){
1972
-				//  //获取上一次的出库记录
1973
-				//  record, _ := service.GetDrugAutoReduceRecordOne(advice.DrugId, advice.PatientId, advice.AdviceDate)
1974
-				//  var out_count int64
1975
-				//  for _, res := range record {
1976
-				//   if(res.CountUnit == medical.MaxUnit){
1977
-				//      res.Count = res.Count * medical.MinNumber
1978
-				//   }
1979
-				//   if(res.CountUnit == medical.MinUnit){
1980
-				//     res.Count = res.Count
1981
-				//   }
1982
-				//    out_count += res.Count
1983
-				//  }
1984
-				//  fmt.Println("上次",out_count)
1985
-				//  fmt.Println("这次出库",prescribing_number_total)
1986
-				//  fmt.Println("总库存",total)
1987
-				//  fmt.Println("差2332332323232232323",prescribing_number_total - out_count)
1988
-				//  //判断库存
1989
-				//  if((prescribing_number_total - out_count) > 0){
1990
-				//
1991
-				//     if((prescribing_number_total - out_count) > total){
1992
-				//       c.ServeSuccessJSON(map[string]interface{}{
1993
-				//         "msg":    "2",
1994
-				//         "advice": advice,
1995
-				//       })
1996
-				//       return
1997
-				//     }else{
1998
-				//       service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
1999
-				//       break
2000
-				//     }
2001
-				//  }else{
2002
-				//    service.HisDrugsDelivery(adminUserInfo.CurrentOrgId, item.ExecutionStaff, item)
2003
-				//    break
2004
-				//  }
2005
-				//
2006
-				//}
2007
-
2008 1998
 				if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
2009 1999
 					c.ServeSuccessJSON(map[string]interface{}{
2010 2000
 						"msg":    "3",

+ 14 - 4
controllers/schedule_api_controller.go View File

@@ -1417,17 +1417,27 @@ func (this *ScheduleApiController) ExportSchedule() {
1417 1417
 			schedule_date := time.Now().Format("2006-01-02")
1418 1418
 			date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
1419 1419
 			clear_schedule_date := date.Unix() //根据日期去清除,该日期未来的排班数据
1420
-			if err == nil {
1421 1420
 
1421
+			if err == nil {
1422 1422
 				for _, item := range schedules {
1423 1423
 					if item.ScheduleDate > clear_schedule_date {
1424
+						//查询已经存在的所有排班
1425
+
1424 1426
 						//查找当天日期是否存在
1425 1427
 						_, errcode := service.GetTodayScheduleIsExistOne(item.PatientId, item.ScheduleDate, item.UserOrgId)
1426 1428
 						if errcode == gorm.ErrRecordNotFound {
1429
+							//查询该床位是否有患者
1430
+							sch, errcodes := service.GetPatientByBed(item.ScheduleDate, item.BedId, item.ScheduleType, item.UserOrgId)
1431
+
1432
+							if errcodes == gorm.ErrRecordNotFound {
1433
+								service.CreateSchedule(item)
1434
+							} else if errcodes == nil {
1435
+
1436
+								//清除当天该床位已有的患者
1437
+								service.ModeFyScheduleById(sch.ScheduleDate, sch.BedId, sch.ScheduleType, sch.UserOrgId)
1438
+								service.CreateSchedule(item)
1439
+							}
1427 1440
 
1428
-							//清除当天该床位已有的患者
1429
-							service.ModeFyScheduleById(item.ScheduleDate, item.BedId, item.ScheduleType, item.UserOrgId)
1430
-							service.CreateSchedule(item)
1431 1441
 						} else if errcode == nil {
1432 1442
 							schedule := models.XtSchedule{
1433 1443
 								PartitionId:  item.PartitionId,

+ 6 - 27
controllers/stock_in_api_controller.go View File

@@ -1738,7 +1738,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1738 1738
 
1739 1739
 	if len(upDateWarehouseOutInfos) > 0 {
1740 1740
 		for _, item := range upDateWarehouseOutInfos {
1741
-
1741
+			fmt.Println("item233223232323233223", item.Count)
1742 1742
 			//1.查询该耗材该批次的最后一次出库记录
1743 1743
 			lastGood, _ := service.GetLastGoodInformationByGoodId(item.GoodId, item.WarehouseInfotId, item.OrgId)
1744 1744
 
@@ -1776,7 +1776,8 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1776 1776
 
1777 1777
 					//判断该批次的剩余库存 和出库的库存进行比较
1778 1778
 					//如果出库的库存大于该批次的剩余库存,那么需要出库下一批次的库存
1779
-
1779
+					fmt.Println("total233322323232332232332", total)
1780
+					fmt.Println("info333223322332323332233223", info.StockCount)
1780 1781
 					if total > info.StockCount {
1781 1782
 						//计算出库和该批次相差的库存
1782 1783
 						total_count = item.Count - info.StockCount
@@ -1789,9 +1790,6 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1789 1790
 							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1790 1791
 							return
1791 1792
 						}
1792
-						c.ServeSuccessJSON(map[string]interface{}{
1793
-							"msg": "1",
1794
-						})
1795 1793
 					}
1796 1794
 					//如果与上次比的库存小于或等于于该批次的剩余库存,那么需要该批次出库
1797 1795
 					if total <= info.StockCount {
@@ -1837,10 +1835,6 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1837 1835
 								c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1838 1836
 								return
1839 1837
 							}
1840
-							c.ServeSuccessJSON(map[string]interface{}{
1841
-								"msg": "1",
1842
-							})
1843
-							return
1844 1838
 						} else if errcode == nil {
1845 1839
 							service.UpDateWarehouseOutInfo(item)
1846 1840
 							//更新流水
@@ -1861,10 +1855,6 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1861 1855
 								Dealer:       item.Dealer,
1862 1856
 							}
1863 1857
 							service.UpdatedGoodInfo(goodInfo, item.GoodId)
1864
-							c.ServeSuccessJSON(map[string]interface{}{
1865
-								"msg": "1",
1866
-							})
1867
-							return
1868 1858
 						}
1869 1859
 					}
1870 1860
 				}
@@ -1931,10 +1921,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1931 1921
 							c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1932 1922
 							return
1933 1923
 						}
1934
-						c.ServeSuccessJSON(map[string]interface{}{
1935
-							"msg": "1",
1936
-						})
1937
-						return
1924
+
1938 1925
 					} else if errcode == nil {
1939 1926
 						service.UpDateWarehouseOutInfo(item)
1940 1927
 						flow := models.VmStockFlow{
@@ -1953,7 +1940,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1953 1940
 							Dealer:       item.Dealer,
1954 1941
 						}
1955 1942
 						service.UpdatedGoodInfo(goodInfo, item.GoodId)
1956
-						return
1943
+
1957 1944
 					}
1958 1945
 				}
1959 1946
 
@@ -1985,15 +1972,7 @@ func (c *StockManagerApiController) EditWarehouseOut() {
1985 1972
 					Dealer:       item.Dealer,
1986 1973
 				}
1987 1974
 				service.UpdatedGoodInfo(goodInfo, item.GoodId)
1988
-				if errs != nil {
1989
-					utils.ErrorLog(errs.Error())
1990
-					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateStockInFail)
1991
-					return
1992
-				}
1993
-				c.ServeSuccessJSON(map[string]interface{}{
1994
-					"msg": "1",
1995
-				})
1996
-				return
1975
+
1997 1976
 			}
1998 1977
 
1999 1978
 		}

+ 43 - 0
controllers/supply_order_api_contorller.go View File

@@ -0,0 +1,43 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/service"
5
+	"github.com/astaxie/beego"
6
+)
7
+
8
+type SupplyOrderApiController struct {
9
+	BaseAuthAPIController
10
+}
11
+
12
+func SupplyOrderApiRegistRouters() {
13
+
14
+	beego.Router("/api/supply/getinitorder", &SupplyOrderApiController{}, "get:GetInitOrder")
15
+}
16
+
17
+func (this *SupplyOrderApiController) GetInitOrder() {
18
+
19
+	orgId := this.GetAdminUserInfo().CurrentOrgId
20
+	//获取药品库数据
21
+	baseList, _ := service.GetSupplyDrugList(orgId)
22
+
23
+	goodList, _ := service.GetSupplyGoodList(orgId)
24
+
25
+	manufactuerList, _ := service.GetAllManufacturerList(orgId)
26
+
27
+	goodTypeList, _ := service.GetAllGoodType(orgId)
28
+
29
+	supplyList, _ := service.GetSupplierList(orgId)
30
+
31
+	var drugType = "药品类型"
32
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
33
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
34
+	this.ServeSuccessJSON(map[string]interface{}{
35
+		"drugList":        baseList,
36
+		"goodList":        goodList,
37
+		"manufactuerList": manufactuerList,
38
+		"goodTypeList":    goodTypeList,
39
+		"drugTypeList":    drugTypeList,
40
+		"supplyList":      supplyList,
41
+	})
42
+	return
43
+}

+ 1 - 1
models/device_models.go View File

@@ -166,7 +166,6 @@ func (MDeviceNumberForList) TableName() string {
166 166
 	return "xt_device_number"
167 167
 }
168 168
 
169
-
170 169
 type XtDeviceNumber struct {
171 170
 	ID      int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
172 171
 	OrgId   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
@@ -416,6 +415,7 @@ type XtSchedule struct {
416 415
 	Status          int64                   `gorm:"column:status" json:"status" form:"status"`
417 416
 	CreatedTime     int64                   `gorm:"column:created_time" json:"created_time" form:"created_time"`
418 417
 	UpdatedTime     int64                   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
418
+	IsExport        int64                   `gorm:"column:is_export" json:"is_export" form:"is_export"`
419 419
 	LastAfterWeight AssessmentAfterDislysis `gorm:"ForeignKey:PatientID;AssociationForeignKey:PatientID" json:"lastafterweight"`
420 420
 }
421 421
 

+ 89 - 0
models/supply.models.go View File

@@ -0,0 +1,89 @@
1
+package models
2
+
3
+type SpBaseDrug 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
+	DrugCategory      int64                  `gorm:"column:drug_category" json:"drug_category" form:"drug_category"`
7
+	DrugSpec          string                 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
8
+	DrugType          int64                  `gorm:"column:drug_type" json:"drug_type" form:"drug_type"`
9
+	MaxUnit           string                 `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
10
+	MinNumber         int64                  `gorm:"column:min_number" json:"min_number" form:"min_number"`
11
+	MinUnit           string                 `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
12
+	Dose              float64                `gorm:"column:dose" json:"dose" form:"dose"`
13
+	DoseUnit          string                 `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
14
+	DrugDose          float64                `gorm:"column:drug_dose" json:"drug_dose" form:"drug_dose"`
15
+	DrugDoseUnit      int64                  `gorm:"column:drug_dose_unit" json:"drug_dose_unit" form:"drug_dose_unit"`
16
+	Manufacturer      int64                  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
17
+	OrgId             int64                  `gorm:"column:org_id" json:"org_id" form:"org_id"`
18
+	Number            string                 `gorm:"column:number" json:"number" form:"number"`
19
+	DrugWarehouseInfo []*SpDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
20
+}
21
+
22
+func (SpBaseDrug) TableName() string {
23
+	return "xt_base_drug"
24
+}
25
+
26
+type SpGoodInformation struct {
27
+	ID                int64              `gorm:"column:id" json:"id" form:"id"`
28
+	SpecificationName string             `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
29
+	GoodTypeId        int64              `gorm:"column:good_type_id" json:"good_type_id" form:"good_type_id"`
30
+	GoodUnit          int64              `gorm:"column:good_unit" json:"good_unit" form:"good_unit"`
31
+	Manufacturer      int64              `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
32
+	OrgId             int64              `gorm:"column:org_id" json:"org_id" form:"org_id"`
33
+	GoodName          string             `gorm:"column:good_name" json:"good_name" form:"good_name"`
34
+	GoodWarehouseInfo []*SpWarehouseInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"good_warehouse_info"`
35
+}
36
+
37
+func (SpGoodInformation) TableName() string {
38
+	return "xt_good_information"
39
+}
40
+
41
+type SpWarehouseInfo struct {
42
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
43
+	GoodId     int64 `gorm:"column:good_id" json:"good_id" form:"good_id"`
44
+	StockCount int64 `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
45
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
46
+	OrgId      int64 `gorm:"column:org_id" json:"org_id" form:"org_id"`
47
+}
48
+
49
+func (SpWarehouseInfo) TableName() string {
50
+	return "xt_warehouse_info"
51
+}
52
+
53
+type SpDrugWarehouseInfo struct {
54
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
55
+	DrugId         int64  `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
56
+	MaxUnit        string `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
57
+	MinUnit        string `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
58
+	StockMaxNumber int64  `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
59
+	StockMinNumber int64  `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
60
+	BatchNumber    string `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
61
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
62
+	OrgId          int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
63
+}
64
+
65
+func (SpDrugWarehouseInfo) TableName() string {
66
+	return "xt_drug_warehouse_info"
67
+}
68
+
69
+type SpSupplierName struct {
70
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
71
+	SupplierCode string  `gorm:"column:supplier_code" json:"supplier_code" form:"supplier_code"`
72
+	SupplierName string  `gorm:"column:supplier_name" json:"supplier_name" form:"supplier_name"`
73
+	SupplierType int64   `gorm:"column:supplier_type" json:"supplier_type" form:"supplier_type"`
74
+	VatRate      float64 `gorm:"column:vat_rate" json:"vat_rate" form:"vat_rate"`
75
+	Number       string  `gorm:"column:number" json:"number" form:"number"`
76
+	Bank         string  `gorm:"column:bank" json:"bank" form:"bank"`
77
+	BankAccount  string  `gorm:"column:bank_account" json:"bank_account" form:"bank_account"`
78
+	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
79
+	Status       int64   `gorm:"column:status" json:"status" form:"status"`
80
+	ContactsId   string  `gorm:"column:contacts_id" json:"contacts_id" form:"contacts_id"`
81
+	Ctime        int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
82
+	Mtime        int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
83
+	Creater      int64   `gorm:"column:creater" json:"creater" form:"creater"`
84
+	Modify       int64   `gorm:"column:modify" json:"modify" form:"modify"`
85
+}
86
+
87
+func (SpSupplierName) TableName() string {
88
+	return "xt_supplier_name"
89
+}

+ 1 - 0
routers/router.go View File

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

+ 15 - 0
service/gobal_config_service.go View File

@@ -819,6 +819,21 @@ func GetDrugStockFlowDetail(record_time int64, orgid int64) (drugflow []*models.
819 819
 	return drugflow, err
820 820
 }
821 821
 
822
+func GetSingeOrderFlow(id int64, orgid int64) (outInfo []*models.VmDrugWarehouseOutInfo, err error) {
823
+	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")
824
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
825
+	fmt.Println(table)
826
+	if orgid > 0 {
827
+		db = db.Where("x.org_id = ?", orgid)
828
+	}
829
+	if id > 0 {
830
+		db = db.Where("x.warehouse_out_id in(?)", id)
831
+	}
832
+
833
+	err = db.Select("x.id,x.warehouse_out_id,x.drug_id,x.count,x.count_unit,x.price,x.total_price,x.product_date,x.expiry_date,x.remark,x.is_cancel,x.warehouse_out_order_number,x.type,x.dealer,t.manufacturer,x.is_sys,x.sys_record_time,x.retail_price,x.retail_total_price,t.drug_name,t.drug_type,t.max_unit,t.min_unit,t.min_number,x.number,x.batch_number,t.dose,t.dose_unit,t.last_price,t.min_price").Joins("left join xt_base_drug as t on t.id = x.drug_id").Scan(&outInfo).Error
834
+	return outInfo, err
835
+}
836
+
822 837
 func GetAllSingleDrugDetail(id int64, orgid int64) (outInfo []*models.VmDrugWarehouseOutInfo, err error) {
823 838
 
824 839
 	db := XTReadDB().Table("xt_drug_warehouse_out_info as x").Where("x.status = 1")

+ 13 - 0
service/schedule_service.go View File

@@ -199,6 +199,19 @@ func GetTodayScheduleIsExistOne(patientid int64, schedudate int64, orgid int64)
199 199
 	return &scheudle, nil
200 200
 }
201 201
 
202
+func GetPatientByBed(schedule_date int64, bed_id int64, scheduletype int64, orgid int64) (*models.XtSchedule, error) {
203
+	var scheudle models.XtSchedule
204
+	var err error
205
+	err = XTReadDB().Model(&scheudle).Where(" schedule_date= ? and bed_id = ? and  schedule_type = ? and  user_org_id = ? and status = 1", schedule_date, bed_id, scheduletype, orgid).Find(&scheudle).Error
206
+	if err == gorm.ErrRecordNotFound {
207
+		return nil, err
208
+	}
209
+	if err != nil {
210
+		return nil, err
211
+	}
212
+	return &scheudle, nil
213
+}
214
+
202 215
 func ModeFyScheduleById(schedule_date int64, bedid int64, scheduletype int64, orgid int64) error {
203 216
 
204 217
 	schedule := models.XtSchedule{}

+ 12 - 0
service/stock_service.go View File

@@ -5707,3 +5707,15 @@ func ModeFyDrugWarehouseMin(id int64, stock_min_number int64) error {
5707 5707
 	err = XTWriteDB().Model(&info).Where("id = ?", id).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number - ?", stock_min_number)).Error
5708 5708
 	return err
5709 5709
 }
5710
+
5711
+func GetAllHisDoctorAdviceById(drugid int64, patient_id int64, advicedate int64, orgid int64) (advice []*models.HisDoctorAdviceInfo, err error) {
5712
+
5713
+	err = XTReadDB().Where("drug_id = ? and patient_id = ? and advice_date = ? and execution_state = 1 and status = 1 and user_org_id = ?", drugid, patient_id, advicedate, orgid).Find(&advice).Error
5714
+	return advice, err
5715
+}
5716
+
5717
+func GetAllDrugFlowById(drugid int64, patient_id int64, advicedate int64, orgid int64) (info []*models.DrugWarehouseOutInfo, err error) {
5718
+
5719
+	err = XTReadDB().Where("drug_id = ? and patient_id = ? and sys_record_time = ? and org_id = ? and status = 1", drugid, patient_id, advicedate, orgid).Find(&info).Error
5720
+	return info, err
5721
+}

+ 33 - 0
service/supply_service.go View File

@@ -0,0 +1,33 @@
1
+package service
2
+
3
+import "XT_New/models"
4
+
5
+func GetSupplyDrugList(orgid int64) (drug []*models.SpBaseDrug, err error) {
6
+
7
+	db := XTReadDB().Table("xt_base_drug as x").Where("x.status = 1")
8
+
9
+	if orgid > 0 {
10
+		db = db.Where("x.org_id = ?", orgid)
11
+	}
12
+
13
+	err = db.Preload("DrugWarehouseInfo", "status = 1 and org_id = ?", orgid).Find(&drug).Error
14
+	return drug, err
15
+}
16
+
17
+func GetSupplyGoodList(orgid int64) (good []*models.SpGoodInformation, err error) {
18
+
19
+	db := XTReadDB().Table("xt_good_information as x").Where("x.status = 1")
20
+
21
+	if orgid > 0 {
22
+		db = db.Where("x.org_id = ?", orgid)
23
+	}
24
+
25
+	err = db.Preload("GoodWarehouseInfo", "status = 1 and org_id = ?", orgid).Find(&good).Error
26
+	return good, err
27
+}
28
+
29
+func GetSupplierList(orgid int64) (suppler []*models.SpSupplierName, err error) {
30
+
31
+	err = XTReadDB().Where("user_org_id = ? and status = 1", orgid).Find(&suppler).Error
32
+	return suppler, err
33
+}

+ 9 - 7
service/warhouse_service.go View File

@@ -798,6 +798,8 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
798 798
 
799 799
 	stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
800 800
 
801
+	fmt.Println("库存1", stock_number)
802
+	fmt.Println("c出库数量", deliver_number)
801 803
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
802 804
 	if stock_number >= deliver_number {
803 805
 
@@ -915,14 +917,14 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
915 917
 			ProductDate:             warehouse.ProductDate,
916 918
 			Number:                  warehouse.Number,
917 919
 			BatchNumber:             warehouse.BatchNumber,
918
-			Count:                   deliver_number,
920
+			Count:                   stock_number,
919 921
 			RetailPrice:             advice.RetailPrice,
920 922
 			Price:                   advice.Price,
921 923
 			WarehouseInfoId:         warehouse.ID,
922 924
 			CountUnit:               drup.MinUnit,
923 925
 			AdviceId:                advice.ID,
924 926
 		}
925
-		warehouseOutInfo.Count = prescribingNumber
927
+		warehouseOutInfo.Count = stock_number
926 928
 
927 929
 		warehouseOutInfo.CountUnit = advice.CountUnit
928 930
 
@@ -938,7 +940,7 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
938 940
 			Number:                  warehouse.Number,
939 941
 			ProductDate:             advice.ProductDate,
940 942
 			ExpireDate:              advice.ExpiryDate,
941
-			Count:                   deliver_number,
943
+			Count:                   stock_number,
942 944
 			Price:                   advice.Price,
943 945
 			Status:                  1,
944 946
 			Ctime:                   time.Now().Unix(),
@@ -965,7 +967,7 @@ func AutoDrugDeliverInfo(orgID int64, prescribingNumber int64, warehouseout *mod
965 967
 		}
966 968
 		// 清零完该库存后,还有剩余出库未出完,进行对应的递归操作
967 969
 		prescribingNumber_two_temp := deliver_number - stock_number
968
-
970
+		fmt.Println("剩余库存323323223232323232323323223", prescribingNumber_two_temp)
969 971
 		advice.CountUnit = drup.MinUnit
970 972
 
971 973
 		AutoDrugDeliverInfo(orgID, prescribingNumber_two_temp, warehouseout, drup, advice)
@@ -2422,7 +2424,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2422 2424
 			ExpiryDate:              warehouse.ExpiryDate,
2423 2425
 			PatientId:               advice.PatientId,
2424 2426
 			WarehouseInfoId:         warehouse.ID,
2425
-			Count:                   deliver_number,
2427
+			Count:                   stock_number,
2426 2428
 			CountUnit:               drup.MinUnit,
2427 2429
 			AdviceId:                advice.ID,
2428 2430
 		}
@@ -2434,7 +2436,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2434 2436
 			Number:                  warehouse.Number,
2435 2437
 			ProductDate:             warehouse.ProductDate,
2436 2438
 			ExpireDate:              warehouse.ExpiryDate,
2437
-			Count:                   deliver_number,
2439
+			Count:                   stock_number,
2438 2440
 			Price:                   min_price,
2439 2441
 			Status:                  1,
2440 2442
 			Ctime:                   time.Now().Unix(),
@@ -2469,7 +2471,7 @@ func NewHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout
2469 2471
 			RecordTime:              advice.RecordDate,
2470 2472
 			OrgId:                   orgID,
2471 2473
 			DrugId:                  advice.DrugId,
2472
-			Count:                   deliver_number,
2474
+			Count:                   stock_number,
2473 2475
 			CountUnit:               drup.MinUnit,
2474 2476
 			WarehouseInfoId:         warehouse.ID,
2475 2477
 			AdviceId:                advice.ID,