|
@@ -965,6 +965,8 @@ func (c *HisApiController) CreateHisPrescription() {
|
965
|
965
|
adminInfo := c.GetAdminUserInfo()
|
966
|
966
|
recordDateTime := theTime.Unix()
|
967
|
967
|
|
|
968
|
+ //查询默认出库仓库库存
|
|
969
|
+ storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
|
968
|
970
|
role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor_id)
|
969
|
971
|
|
970
|
972
|
if his_patient_id == 0 { //前端传过来的挂号id为0时,进行多一步判断
|
|
@@ -981,69 +983,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
981
|
983
|
|
982
|
984
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
983
|
985
|
|
984
|
|
- //已发药和已收费限制逻辑
|
985
|
|
- isMidicine := false
|
986
|
|
- isCharge := false
|
987
|
|
- if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
988
|
|
- prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
989
|
|
- if len(prescriptions) > 0 {
|
990
|
|
- for _, item := range prescriptions {
|
991
|
|
- items := item.(map[string]interface{})
|
992
|
|
- if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
993
|
|
- utils.ErrorLog("id")
|
994
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
995
|
|
- return
|
996
|
|
- }
|
997
|
|
- id := int64(items["id"].(float64))
|
998
|
|
- if id > 0 {
|
999
|
|
- new_prescription, err := service.GetPrescriptionById(id, adminInfo.CurrentOrgId)
|
1000
|
|
- if err != nil {
|
1001
|
|
- if new_prescription.OrderStatus == 2 {
|
1002
|
|
- isCharge = true
|
1003
|
|
- }
|
1004
|
|
- }
|
1005
|
|
- }
|
1006
|
|
-
|
1007
|
|
- if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
1008
|
|
- advices := items["advices"].([]interface{})
|
1009
|
|
- fmt.Println("~~~~~~~~4")
|
1010
|
|
-
|
1011
|
|
- if len(advices) > 0 {
|
1012
|
|
- for _, advice := range advices {
|
1013
|
|
- fmt.Println("~~~~~~~~3")
|
1014
|
|
-
|
1015
|
|
- var adviceId int64
|
1016
|
|
- if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
|
1017
|
|
- adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
|
1018
|
|
- }
|
1019
|
|
- if adviceId > 0 {
|
1020
|
|
- his_advice_info, err := service.GetHisDoctorAdviceInfo(adviceId)
|
1021
|
|
- fmt.Println("~~~~~~~~1")
|
1022
|
|
- fmt.Println("~~~~~~~~1")
|
1023
|
|
-
|
1024
|
|
- if err == nil {
|
1025
|
|
- if his_advice_info.IsMedicine == 1 {
|
1026
|
|
- fmt.Println("~~~~~~~~2")
|
1027
|
|
- isMidicine = true
|
1028
|
|
- }
|
1029
|
|
- }
|
1030
|
|
- }
|
1031
|
|
- }
|
1032
|
|
- }
|
1033
|
|
- }
|
1034
|
|
- }
|
1035
|
|
- }
|
1036
|
|
- }
|
1037
|
|
- if isMidicine == true {
|
1038
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMedicineWrong)
|
1039
|
|
- return
|
1040
|
|
- }
|
1041
|
|
- if isCharge == true {
|
1042
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChargeWrong)
|
1043
|
|
- return
|
1044
|
|
- }
|
1045
|
|
- //已发药和已收费限制逻辑
|
1046
|
|
-
|
1047
|
986
|
if drugStockConfig.IsOpen == 1 {
|
1048
|
987
|
//校验库存总量
|
1049
|
988
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
@@ -1081,8 +1020,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
1081
|
1020
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
1082
|
1021
|
return
|
1083
|
1022
|
}
|
1084
|
|
- //查询默认出库仓库库存
|
1085
|
|
- storeConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
|
|
1023
|
+
|
1086
|
1024
|
//查询药品的所有库存
|
1087
|
1025
|
list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId, storeConfig.DrugStorehouseOut)
|
1088
|
1026
|
|
|
@@ -1095,14 +1033,14 @@ func (c *HisApiController) CreateHisPrescription() {
|
1095
|
1033
|
advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
|
1096
|
1034
|
|
1097
|
1035
|
//查询最新批次库存
|
1098
|
|
- //info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
1099
|
|
- //var batch_number_count int64
|
1100
|
|
- //batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
|
1101
|
|
- //batch_number_counts := strconv.FormatInt(batch_number_count, 10)
|
|
1036
|
+ info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
|
1037
|
+ var batch_number_count int64
|
|
1038
|
+ batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
|
|
1039
|
+ batch_number_counts := strconv.FormatInt(batch_number_count, 10)
|
1102
|
1040
|
//新增处方
|
1103
|
1041
|
if advicelist.ID == 0 {
|
1104
|
1042
|
all_count, _ := strconv.ParseFloat(totals, 64)
|
1105
|
|
- //batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
|
1043
|
+ batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
1106
|
1044
|
if prescribingNumberUnit == drug.MinUnit {
|
1107
|
1045
|
|
1108
|
1046
|
if drug.IsUse != 1 {
|
|
@@ -1111,10 +1049,10 @@ func (c *HisApiController) CreateHisPrescription() {
|
1111
|
1049
|
return
|
1112
|
1050
|
}
|
1113
|
1051
|
|
1114
|
|
- //if prescribing_number > batch_number_all_count {
|
1115
|
|
- // c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
1116
|
|
- // return
|
1117
|
|
- //}
|
|
1052
|
+ if prescribing_number > batch_number_all_count {
|
|
1053
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
|
1054
|
+ return
|
|
1055
|
+ }
|
1118
|
1056
|
|
1119
|
1057
|
}
|
1120
|
1058
|
|
|
@@ -1127,10 +1065,10 @@ func (c *HisApiController) CreateHisPrescription() {
|
1127
|
1065
|
return
|
1128
|
1066
|
}
|
1129
|
1067
|
|
1130
|
|
- //if num > batch_number_all_count {
|
1131
|
|
- // c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
1132
|
|
- // return
|
1133
|
|
- //}
|
|
1068
|
+ if num > batch_number_all_count {
|
|
1069
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
|
1070
|
+ return
|
|
1071
|
+ }
|
1134
|
1072
|
}
|
1135
|
1073
|
}
|
1136
|
1074
|
}
|
|
@@ -1167,9 +1105,8 @@ func (c *HisApiController) CreateHisPrescription() {
|
1167
|
1105
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
1168
|
1106
|
return
|
1169
|
1107
|
}
|
1170
|
|
- houseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
|
1171
|
1108
|
//查询药品的所有库存
|
1172
|
|
- list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId, houseConfig.DrugStorehouseOut)
|
|
1109
|
+ list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId, storeConfig.DrugStorehouseOut)
|
1173
|
1110
|
var total_count int64
|
1174
|
1111
|
for _, it := range list {
|
1175
|
1112
|
total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
|
|
@@ -1181,27 +1118,27 @@ func (c *HisApiController) CreateHisPrescription() {
|
1181
|
1118
|
//新增处方
|
1182
|
1119
|
if advicelist.ID == 0 {
|
1183
|
1120
|
//查询最新批次库存
|
1184
|
|
- //info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
1185
|
|
- //var batch_number_count int64
|
1186
|
|
- //batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
|
1187
|
|
- //batch_number_counts := strconv.FormatInt(batch_number_count, 10)
|
|
1121
|
+ info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
|
1122
|
+ var batch_number_count int64
|
|
1123
|
+ batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
|
|
1124
|
+ batch_number_counts := strconv.FormatInt(batch_number_count, 10)
|
1188
|
1125
|
all_count, _ := strconv.ParseFloat(totals, 64)
|
1189
|
1126
|
if prescribingNumberUnit == drug.MinUnit {
|
1190
|
|
- //batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
|
1127
|
+ batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
1191
|
1128
|
if drug.IsUse != 1 {
|
1192
|
1129
|
if prescribing_number > all_count {
|
1193
|
1130
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
1194
|
1131
|
return
|
1195
|
1132
|
}
|
1196
|
|
- //if prescribing_number > batch_number_all_count {
|
1197
|
|
- // c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
1198
|
|
- // return
|
1199
|
|
- //}
|
|
1133
|
+ if prescribing_number > batch_number_all_count {
|
|
1134
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
|
1135
|
+ return
|
|
1136
|
+ }
|
1200
|
1137
|
}
|
1201
|
1138
|
|
1202
|
1139
|
} else {
|
1203
|
1140
|
if prescribingNumberUnit == drug.MaxUnit {
|
1204
|
|
- //batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
|
1141
|
+ batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
1205
|
1142
|
num := prescribing_number * float64(drug.MinNumber)
|
1206
|
1143
|
if drug.IsUse != 1 {
|
1207
|
1144
|
if num > all_count {
|
|
@@ -1209,10 +1146,10 @@ func (c *HisApiController) CreateHisPrescription() {
|
1209
|
1146
|
return
|
1210
|
1147
|
}
|
1211
|
1148
|
|
1212
|
|
- //if prescribing_number > batch_number_all_count {
|
1213
|
|
- // c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
1214
|
|
- // return
|
1215
|
|
- //}
|
|
1149
|
+ if prescribing_number > batch_number_all_count {
|
|
1150
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
|
1151
|
+ return
|
|
1152
|
+ }
|
1216
|
1153
|
}
|
1217
|
1154
|
|
1218
|
1155
|
}
|
|
@@ -1220,10 +1157,11 @@ func (c *HisApiController) CreateHisPrescription() {
|
1220
|
1157
|
}
|
1221
|
1158
|
//修改处方
|
1222
|
1159
|
if advicelist.ID > 0 {
|
|
1160
|
+ fmt.Println("232323232323232332323o2323o23o23o23o3o")
|
1223
|
1161
|
//查询最新批次库存
|
1224
|
|
- //info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
1225
|
|
- //var batch_number_count int64
|
1226
|
|
- //batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
|
|
1162
|
+ info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
|
1163
|
+ var batch_number_count int64
|
|
1164
|
+ batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
|
1227
|
1165
|
|
1228
|
1166
|
var device_number int64
|
1229
|
1167
|
|
|
@@ -1247,7 +1185,8 @@ func (c *HisApiController) CreateHisPrescription() {
|
1247
|
1185
|
prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
1248
|
1186
|
number_count = prescribingNumberInt
|
1249
|
1187
|
}
|
1250
|
|
-
|
|
1188
|
+ fmt.Println("number-count23323232233223", number_count)
|
|
1189
|
+ fmt.Println("device_number232323322323233223", device_number)
|
1251
|
1190
|
//如果修改的数量大于之前修改的数量
|
1252
|
1191
|
if (number_count - device_number) > 0 {
|
1253
|
1192
|
//如果修改的差数量 大于库存数量
|
|
@@ -1256,64 +1195,249 @@ func (c *HisApiController) CreateHisPrescription() {
|
1256
|
1195
|
c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
1257
|
1196
|
return
|
1258
|
1197
|
}
|
1259
|
|
- //if (number_count - device_number) > batch_number_count {
|
1260
|
|
- // c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
1261
|
|
- // return
|
1262
|
|
- //}
|
|
1198
|
+ fmt.Println("(number_count - device_number3232323232332", number_count-device_number)
|
|
1199
|
+ fmt.Println("(number_count - device_number3232323232332", batch_number_count)
|
|
1200
|
+ if (number_count - device_number) > batch_number_count {
|
|
1201
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
|
1202
|
+ return
|
|
1203
|
+ }
|
|
1204
|
+
|
|
1205
|
+ // 查询该药品最后一次出库记录
|
|
1206
|
+ outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
|
|
1207
|
+ var out_count int64
|
|
1208
|
+ var in_count int64
|
|
1209
|
+ var stock_max_number int64
|
|
1210
|
+ var stock_min_number int64
|
|
1211
|
+ for _, it := range outInfo {
|
|
1212
|
+ if it.CountUnit == drug.MaxUnit {
|
|
1213
|
+ it.Count = it.Count * drug.MinNumber
|
|
1214
|
+ }
|
|
1215
|
+ out_count += it.Count
|
|
1216
|
+ warehouseInfoList, _ := service.GetDrugWarehouseInfoById(it.WarehouseInfoId)
|
|
1217
|
+ stock_max_number = warehouseInfoList.StockMaxNumber
|
|
1218
|
+ stock_min_number = warehouseInfoList.StockMinNumber
|
|
1219
|
+ if warehouseInfoList.MaxUnit == drug.MaxUnit {
|
|
1220
|
+ in_count = warehouseInfoList.WarehousingCount * drug.MinNumber
|
|
1221
|
+ }
|
|
1222
|
+ if warehouseInfoList.MaxUnit == drug.MinUnit {
|
|
1223
|
+ in_count = warehouseInfoList.WarehousingCount
|
|
1224
|
+ }
|
|
1225
|
+ }
|
|
1226
|
+ if (out_count + (number_count - device_number)) > in_count {
|
|
1227
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
|
|
1228
|
+ return
|
|
1229
|
+ }
|
|
1230
|
+
|
1263
|
1231
|
}
|
1264
|
1232
|
|
1265
|
1233
|
}
|
1266
|
|
- //没通过药房发药的才退库
|
1267
|
|
- if drug.IsPharmacy != 1 {
|
1268
|
|
- if device_number != number_count {
|
1269
|
1234
|
|
1270
|
|
- // 查询该药品最后一次出库记录
|
1271
|
|
- druginfo, _ := service.GetLastDrugWarehouseOutByDrugId(drug_id, patient_id, recordDateTime, adviceId)
|
|
1235
|
+ if device_number != number_count {
|
|
1236
|
+
|
|
1237
|
+ // 查询该药品最后一次出库记录
|
|
1238
|
+ druginfo, _ := service.GetLastDrugWarehouseOutByDrugId(drug_id, patient_id, recordDateTime, adviceId)
|
|
1239
|
+
|
|
1240
|
+ //回退库存
|
|
1241
|
+ if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
|
1242
|
+
|
|
1243
|
+ service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
|
|
1244
|
+ }
|
|
1245
|
+ if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
|
1246
|
+ var stock_max_number int64
|
|
1247
|
+ var stock_min_number int64
|
|
1248
|
+
|
|
1249
|
+ if number_count >= drug.MinNumber {
|
1272
|
1250
|
|
1273
|
|
- //回退库存
|
1274
|
|
- if druginfo.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
|
1251
|
+ stock_max_number = device_number / drug.MinNumber
|
|
1252
|
+ service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
|
|
1253
|
+ stock_min_number = device_number % drug.MinNumber
|
|
1254
|
+ service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
|
1275
|
1255
|
|
1276
|
|
- service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, number_count)
|
|
1256
|
+ } else {
|
|
1257
|
+
|
|
1258
|
+ service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
|
1277
|
1259
|
}
|
1278
|
|
- if druginfo.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
|
1279
|
|
- var stock_max_number int64
|
1280
|
|
- var stock_min_number int64
|
|
1260
|
+ }
|
|
1261
|
+
|
|
1262
|
+ if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
|
|
1263
|
+ service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
|
|
1264
|
+ }
|
|
1265
|
+ //删除记录
|
|
1266
|
+ service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
|
|
1267
|
+
|
|
1268
|
+ //查询默认仓库剩余多少库存
|
|
1269
|
+ var sum_count int64
|
|
1270
|
+ stockInfo, _ := service.GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
|
|
1271
|
+ for _, its := range stockInfo {
|
|
1272
|
+ sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
|
|
1273
|
+ }
|
|
1274
|
+ service.UpdateBaseDrugSumTwo(drug_id, sum_count, druginfo.OrgId)
|
|
1275
|
+
|
|
1276
|
+ }
|
|
1277
|
+ }
|
|
1278
|
+ }
|
|
1279
|
+ }
|
|
1280
|
+
|
|
1281
|
+ //保存处方开药
|
|
1282
|
+ if drugOutConfig.IsOpen == 1 {
|
|
1283
|
+ //修改处方
|
|
1284
|
+ for _, advice := range advices {
|
|
1285
|
+ var drug_id int64
|
|
1286
|
+ var prescribing_number float64
|
|
1287
|
+ var prescribingNumberUnit string
|
|
1288
|
+ var prescribingNumber string
|
|
1289
|
+
|
|
1290
|
+ var adviceId int64
|
|
1291
|
+ if advice.(map[string]interface{})["id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["id"]).String() == "float64" {
|
|
1292
|
+ drug_id = int64(advice.(map[string]interface{})["id"].(float64))
|
|
1293
|
+ }
|
|
1294
|
+ if advice.(map[string]interface{})["prescribing_number"] != nil || reflect.TypeOf(advice.(map[string]interface{})["prescribing_number"]).String() == "string" {
|
|
1295
|
+ prescribing_number_str := advice.(map[string]interface{})["prescribing_number"].(string)
|
|
1296
|
+ prescribing_number, _ = strconv.ParseFloat(prescribing_number_str, 64)
|
|
1297
|
+ prescribingNumber = advice.(map[string]interface{})["prescribing_number"].(string)
|
|
1298
|
+ }
|
|
1299
|
+
|
|
1300
|
+ if advice.(map[string]interface{})["prescribing_number_unit"] != nil && reflect.TypeOf(advice.(map[string]interface{})["prescribing_number_unit"]).String() == "string" {
|
|
1301
|
+ prescribingNumberUnit, _ = advice.(map[string]interface{})["prescribing_number_unit"].(string)
|
|
1302
|
+ }
|
1281
|
1303
|
|
1282
|
|
- if number_count >= drug.MinNumber {
|
|
1304
|
+ if advice.(map[string]interface{})["advice_id"] != nil || reflect.TypeOf(advice.(map[string]interface{})["advice_id"]).String() == "float64" {
|
|
1305
|
+ adviceId = int64(advice.(map[string]interface{})["advice_id"].(float64))
|
|
1306
|
+ }
|
1283
|
1307
|
|
1284
|
|
- stock_max_number = device_number / drug.MinNumber
|
1285
|
|
- service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, stock_max_number)
|
1286
|
|
- stock_min_number = device_number % drug.MinNumber
|
1287
|
|
- service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, stock_min_number)
|
|
1308
|
+ drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, drug_id)
|
|
1309
|
+ if drug.ID == 0 {
|
|
1310
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1311
|
+ return
|
|
1312
|
+ }
|
|
1313
|
+ //查询药品的所有库存
|
|
1314
|
+ list, _ := service.GetDrugWarehouseInfoPrescriptionSeven(drug_id, adminInfo.CurrentOrgId, storeConfig.DrugStorehouseOut)
|
|
1315
|
+ var total_count int64
|
|
1316
|
+ for _, it := range list {
|
|
1317
|
+ total_count += it.StockMaxNumber*drug.MinNumber + it.StockMinNumber
|
|
1318
|
+ }
|
|
1319
|
+ totals := strconv.FormatInt(total_count, 10)
|
|
1320
|
+ //查询该药品是否存在开药记录
|
|
1321
|
+ advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
|
1288
|
1322
|
|
1289
|
|
- } else {
|
|
1323
|
+ //新增处方
|
|
1324
|
+ if advicelist.ID == 0 {
|
|
1325
|
+ //查询最新批次库存
|
|
1326
|
+ info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
|
1327
|
+ var batch_number_count int64
|
|
1328
|
+ batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
|
|
1329
|
+ batch_number_counts := strconv.FormatInt(batch_number_count, 10)
|
|
1330
|
+ all_count, _ := strconv.ParseFloat(totals, 64)
|
|
1331
|
+ if prescribingNumberUnit == drug.MinUnit {
|
|
1332
|
+ batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
|
1333
|
+ if drug.IsUse != 1 {
|
|
1334
|
+ if prescribing_number > all_count {
|
|
1335
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
|
1336
|
+ return
|
|
1337
|
+ }
|
|
1338
|
+ if prescribing_number > batch_number_all_count {
|
|
1339
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
|
1340
|
+ return
|
|
1341
|
+ }
|
|
1342
|
+ }
|
1290
|
1343
|
|
1291
|
|
- service.ModefyDrugByWarehouseInfoOne(druginfo.WarehouseInfoId, device_number)
|
|
1344
|
+ } else {
|
|
1345
|
+ if prescribingNumberUnit == drug.MaxUnit {
|
|
1346
|
+ batch_number_all_count, _ := strconv.ParseFloat(batch_number_counts, 64)
|
|
1347
|
+ num := prescribing_number * float64(drug.MinNumber)
|
|
1348
|
+ if drug.IsUse != 1 {
|
|
1349
|
+ if num > all_count {
|
|
1350
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
|
1351
|
+ return
|
|
1352
|
+ }
|
|
1353
|
+
|
|
1354
|
+ if prescribing_number > batch_number_all_count {
|
|
1355
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
|
1356
|
+ return
|
1292
|
1357
|
}
|
1293
|
1358
|
}
|
1294
|
1359
|
|
1295
|
|
- if druginfo.CountUnit == drug.MaxUnit && druginfo.CountUnit == drug.MinUnit && drug.MaxUnit == drug.MinUnit {
|
1296
|
|
- service.ModefyDrugByWarehouseInfo(druginfo.WarehouseInfoId, device_number)
|
|
1360
|
+ }
|
|
1361
|
+ }
|
|
1362
|
+ }
|
|
1363
|
+ //修改处方
|
|
1364
|
+ if advicelist.ID > 0 {
|
|
1365
|
+ //查询最新批次库存
|
|
1366
|
+ info, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
|
|
1367
|
+ var batch_number_count int64
|
|
1368
|
+ batch_number_count = info.StockMaxNumber*drug.MinNumber + info.StockMinNumber
|
|
1369
|
+
|
|
1370
|
+ var device_number int64
|
|
1371
|
+
|
|
1372
|
+ if advicelist.PrescribingNumberUnit == drug.MaxUnit {
|
|
1373
|
+ prescribingNumberOne := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
|
|
1374
|
+ prescribingNumberInt, _ := strconv.ParseInt(prescribingNumberOne, 10, 64)
|
|
1375
|
+ device_number = prescribingNumberInt * drug.MinNumber
|
|
1376
|
+ }
|
|
1377
|
+ if advicelist.PrescribingNumberUnit == drug.MinUnit {
|
|
1378
|
+ prescribingNumberOne := strconv.FormatFloat(advicelist.PrescribingNumber, 'f', -1, 64)
|
|
1379
|
+ prescribingNumberInt, _ := strconv.ParseInt(prescribingNumberOne, 10, 64)
|
|
1380
|
+ device_number = prescribingNumberInt
|
|
1381
|
+ }
|
|
1382
|
+
|
|
1383
|
+ var number_count int64
|
|
1384
|
+ if prescribingNumberUnit == drug.MaxUnit {
|
|
1385
|
+ prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1386
|
+ number_count = prescribingNumberInt * drug.MinNumber
|
|
1387
|
+ }
|
|
1388
|
+ if prescribingNumberUnit == drug.MinUnit {
|
|
1389
|
+ prescribingNumberInt, _ := strconv.ParseInt(prescribingNumber, 10, 64)
|
|
1390
|
+ number_count = prescribingNumberInt
|
|
1391
|
+ }
|
|
1392
|
+ //如果修改的数量大于之前修改的数量
|
|
1393
|
+ if (number_count - device_number) > 0 {
|
|
1394
|
+ //如果修改的差数量 大于库存数量
|
|
1395
|
+ if drug.IsUse != 1 {
|
|
1396
|
+ if (number_count - device_number) > total_count {
|
|
1397
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "库存不足")
|
|
1398
|
+ return
|
|
1399
|
+ }
|
|
1400
|
+ if (number_count - device_number) > batch_number_count {
|
|
1401
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(info.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(info.StockMinNumber, 10) + drug.MinUnit)
|
|
1402
|
+ return
|
|
1403
|
+ }
|
|
1404
|
+
|
|
1405
|
+ //查询历史出库数据总批次
|
|
1406
|
+ // 查询该药品最后一次出库记录
|
|
1407
|
+ outInfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(drug_id, patient_id, recordDateTime, adviceId)
|
|
1408
|
+ var out_count int64
|
|
1409
|
+ var in_count int64
|
|
1410
|
+ var stock_max_number int64
|
|
1411
|
+ var stock_min_number int64
|
|
1412
|
+ for _, it := range outInfo {
|
|
1413
|
+ if it.CountUnit == drug.MaxUnit {
|
|
1414
|
+ it.Count = it.Count * drug.MinNumber
|
|
1415
|
+ }
|
|
1416
|
+ out_count += it.Count
|
|
1417
|
+ warehouseInfoList, _ := service.GetDrugWarehouseInfoById(it.WarehouseInfoId)
|
|
1418
|
+ stock_max_number = warehouseInfoList.StockMaxNumber
|
|
1419
|
+ stock_min_number = warehouseInfoList.StockMinNumber
|
|
1420
|
+ if warehouseInfoList.MaxUnit == drug.MaxUnit {
|
|
1421
|
+ in_count = warehouseInfoList.WarehousingCount * drug.MinNumber
|
|
1422
|
+ }
|
|
1423
|
+ if warehouseInfoList.MaxUnit == drug.MinUnit {
|
|
1424
|
+ in_count = warehouseInfoList.WarehousingCount
|
|
1425
|
+ }
|
1297
|
1426
|
}
|
1298
|
|
- //删除记录
|
1299
|
|
- service.DeleteDrugAutoWarehouseSeven(drug_id, patient_id, recordDateTime, adviceId)
|
1300
|
|
-
|
1301
|
|
- //查询默认仓库
|
1302
|
|
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(druginfo.OrgId)
|
1303
|
|
- //查询默认仓库剩余多少库存
|
1304
|
|
- var sum_count int64
|
1305
|
|
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, druginfo.OrgId, drug_id)
|
1306
|
|
- for _, its := range stockInfo {
|
1307
|
|
- sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
|
|
1427
|
+ //fmt.Println("out_count23323232233233223",out_count)
|
|
1428
|
+ //fmt.Println("+(number_count - device_number)",(number_count - device_number))
|
|
1429
|
+ //fmt.Println("in_count23322323222222",in_count)
|
|
1430
|
+ if (out_count + (number_count - device_number)) > in_count {
|
|
1431
|
+ c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(stock_max_number, 10) + drug.MaxUnit + strconv.FormatInt(stock_min_number, 10) + drug.MinUnit)
|
|
1432
|
+ return
|
1308
|
1433
|
}
|
1309
|
|
- service.UpdateBaseDrugSumTwo(drug_id, sum_count, druginfo.OrgId)
|
1310
|
1434
|
|
1311
|
1435
|
}
|
1312
|
1436
|
}
|
1313
|
|
-
|
1314
|
1437
|
}
|
1315
|
1438
|
}
|
1316
|
1439
|
}
|
|
1440
|
+
|
1317
|
1441
|
}
|
1318
|
1442
|
}
|
1319
|
1443
|
}
|
|
@@ -1406,8 +1530,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
1406
|
1530
|
service.ModefyWarehouseInfo(item.Count, item.WarehouseInfotId)
|
1407
|
1531
|
|
1408
|
1532
|
//查询默认仓库
|
1409
|
|
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.OrgId)
|
1410
|
|
- stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeHouseConfig.StorehouseOutInfo, item.OrgId)
|
|
1533
|
+ stockList, _ := service.GetStockCountByGoodId(item.GoodId, storeConfig.StorehouseOutInfo, item.OrgId)
|
1411
|
1534
|
var total_count int64
|
1412
|
1535
|
for _, it := range stockList {
|
1413
|
1536
|
total_count += it.StockCount
|
|
@@ -1472,7 +1595,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
1472
|
1595
|
defer redis.Close()
|
1473
|
1596
|
} else {
|
1474
|
1597
|
hpInfo = models.HisPrescriptionInfo{
|
1475
|
|
-
|
1476
|
1598
|
ID: info.ID,
|
1477
|
1599
|
UserOrgId: adminInfo.CurrentOrgId,
|
1478
|
1600
|
RecordDate: info.RecordDate,
|
|
@@ -1510,8 +1632,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
1510
|
1632
|
var adviceList []models.HisDoctorAdviceInfo
|
1511
|
1633
|
var projectList []models.HisPrescriptionProject
|
1512
|
1634
|
|
1513
|
|
- //var hisLis []models.HisList
|
1514
|
|
-
|
1515
|
1635
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
1516
|
1636
|
prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
1517
|
1637
|
|
|
@@ -1605,7 +1725,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
1605
|
1725
|
tempPrescription.Modifier = adminInfo.AdminUser.Id
|
1606
|
1726
|
tempPrescription.Mtime = time.Now().Unix()
|
1607
|
1727
|
tempPrescription.Doctor = role.UserName
|
1608
|
|
-
|
1609
|
1728
|
//tempPrescription.OrderStatus = order_status
|
1610
|
1729
|
tempPrescription.PreTime = pTime
|
1611
|
1730
|
tempPrescription.MedType = med_type
|
|
@@ -1789,15 +1908,6 @@ func (c *HisApiController) CreateHisPrescription() {
|
1789
|
1908
|
|
1790
|
1909
|
service.SaveHisProjectTwo(&p)
|
1791
|
1910
|
|
1792
|
|
- //if p.Type == 3 { //处理透前准备耗材数量数据
|
1793
|
|
- // consumables, _ := service.FindHisConsumablesByID(adminInfo.CurrentOrgId, patient_id, recordDateTime, p.ProjectId)
|
1794
|
|
- // if consumables.ID > 0 {
|
1795
|
|
- // cnt, _ := strconv.ParseInt(p.Count, 10, 64)
|
1796
|
|
- // consumables.Count = cnt
|
1797
|
|
- // service.UpdateConsumables(&consumables)
|
1798
|
|
- // }
|
1799
|
|
- //}
|
1800
|
|
-
|
1801
|
1911
|
}
|
1802
|
1912
|
}
|
1803
|
1913
|
}
|
|
@@ -1841,18 +1951,17 @@ func (c *HisApiController) CreateHisPrescription() {
|
1841
|
1951
|
|
1842
|
1952
|
//查询今日该患者开的药品处方
|
1843
|
1953
|
hisdoctorlist, _ := service.GetHisAdviceListByDrugIdTwo(patient_id, recordDateTime, adminInfo.CurrentOrgId)
|
1844
|
|
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.CurrentOrgId)
|
1845
|
1954
|
drugOutConfig, _ := service.GetDrugOpenConfigOne(adminInfo.CurrentOrgId)
|
1846
|
1955
|
if drugOutConfig.IsOpen == 1 {
|
1847
|
1956
|
for _, item := range hisdoctorlist {
|
1848
|
1957
|
drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
|
1849
|
|
-
|
1850
|
1958
|
// 查询该药品最后一次出库记录
|
1851
|
1959
|
druginfo, _ := service.GetLastDrugWarehouseOutByDrugIdTwenty(item.DrugId, patient_id, recordDateTime, item.ID)
|
1852
|
1960
|
|
1853
|
1961
|
if len(druginfo) > 0 {
|
1854
|
1962
|
//回退库存
|
1855
|
1963
|
for _, it := range druginfo {
|
|
1964
|
+
|
1856
|
1965
|
if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
|
1857
|
1966
|
service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
|
1858
|
1967
|
}
|
|
@@ -1876,7 +1985,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
1876
|
1985
|
}
|
1877
|
1986
|
|
1878
|
1987
|
//更新字典里面的库存
|
1879
|
|
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
|
1988
|
+ stockInfo, _ := service.GetDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
|
1880
|
1989
|
var sum_count int64
|
1881
|
1990
|
for _, its := range stockInfo {
|
1882
|
1991
|
sum_count += its.StockMaxNumber*drug.MinNumber + its.StockMinNumber
|
|
@@ -2190,47 +2299,6 @@ func (c *HisApiController) DeletePrescription() {
|
2190
|
2299
|
|
2191
|
2300
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2192
|
2301
|
|
2193
|
|
- //已收费和已发药限制逻辑
|
2194
|
|
- isCharge := false
|
2195
|
|
- isMedicine := false
|
2196
|
|
- new_prescription, p_err := service.GetPrescriptionById(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
|
2197
|
|
- new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
2198
|
|
-
|
2199
|
|
- for _, item := range new_prescriptions {
|
2200
|
|
- if item.IsMedicine == 1 {
|
2201
|
|
- isMedicine = true
|
2202
|
|
- }
|
2203
|
|
- }
|
2204
|
|
-
|
2205
|
|
- for _, item := range new_prescriptions {
|
2206
|
|
- if item.OrderStatus == 2 {
|
2207
|
|
- isCharge = true
|
2208
|
|
- }
|
2209
|
|
- }
|
2210
|
|
-
|
2211
|
|
- if p_err != nil {
|
2212
|
|
- if new_prescription.ID > 0 {
|
2213
|
|
- if new_prescription.OrderStatus == 2 {
|
2214
|
|
- isCharge = true
|
2215
|
|
- }
|
2216
|
|
- }
|
2217
|
|
- }
|
2218
|
|
- for _, item := range advices {
|
2219
|
|
- if item.IsMedicine == 1 {
|
2220
|
|
- isMedicine = true
|
2221
|
|
- }
|
2222
|
|
- }
|
2223
|
|
- if isCharge {
|
2224
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
2225
|
|
- return
|
2226
|
|
- }
|
2227
|
|
-
|
2228
|
|
- if isMedicine {
|
2229
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
2230
|
|
- return
|
2231
|
|
- }
|
2232
|
|
- //已收费和已发药限制逻辑
|
2233
|
|
-
|
2234
|
2302
|
if len(projects) > 0 {
|
2235
|
2303
|
for _, item := range projects {
|
2236
|
2304
|
service.DeletePrintInfo(item.ID) //删除打印信息
|
|
@@ -2459,63 +2527,13 @@ func (c *HisApiController) DeletePrescription() {
|
2459
|
2527
|
return
|
2460
|
2528
|
|
2461
|
2529
|
}
|
|
2530
|
+
|
2462
|
2531
|
func (c *HisApiController) DeleteDoctorAdvice() {
|
2463
|
2532
|
id, _ := c.GetInt64("id")
|
2464
|
2533
|
advice, _ := service.GetHisDoctorAdvicesById(id)
|
2465
|
2534
|
|
2466
|
2535
|
_, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2467
|
2536
|
|
2468
|
|
- //已收费和已发药的限制逻辑
|
2469
|
|
- isCharge := false
|
2470
|
|
- isMedicine := false
|
2471
|
|
- new_prescription, _ := service.GetPrescriptionById(advice.PrescriptionId, c.GetAdminUserInfo().CurrentOrgId)
|
2472
|
|
-
|
2473
|
|
- //获取今天该患者所有处方,判断是否发药或者收费
|
2474
|
|
- new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
2475
|
|
- for _, item := range new_prescriptions {
|
2476
|
|
- if item.IsMedicine == 1 {
|
2477
|
|
- isMedicine = true
|
2478
|
|
- }
|
2479
|
|
- }
|
2480
|
|
- for _, item := range new_prescriptions {
|
2481
|
|
- if item.OrderStatus == 2 {
|
2482
|
|
- isCharge = true
|
2483
|
|
- }
|
2484
|
|
- }
|
2485
|
|
-
|
2486
|
|
- if isMedicine {
|
2487
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
2488
|
|
- return
|
2489
|
|
- }
|
2490
|
|
-
|
2491
|
|
- if isCharge {
|
2492
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
2493
|
|
- return
|
2494
|
|
- }
|
2495
|
|
-
|
2496
|
|
- advices, _ := service.GetHisPrescriptionAdviceByID(advice.PrescriptionId)
|
2497
|
|
- for _, item := range advices {
|
2498
|
|
- if item.IsMedicine == 1 {
|
2499
|
|
- isMedicine = true
|
2500
|
|
- }
|
2501
|
|
- }
|
2502
|
|
-
|
2503
|
|
- if isMedicine {
|
2504
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteMedicineWrong)
|
2505
|
|
- return
|
2506
|
|
- }
|
2507
|
|
- if new_prescription.ID > 0 {
|
2508
|
|
- if new_prescription.OrderStatus == 2 {
|
2509
|
|
- isCharge = true
|
2510
|
|
- }
|
2511
|
|
- }
|
2512
|
|
-
|
2513
|
|
- if isCharge {
|
2514
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrongTwo)
|
2515
|
|
- return
|
2516
|
|
- }
|
2517
|
|
- //已收费和已发药的限制逻辑
|
2518
|
|
-
|
2519
|
2537
|
err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
|
2520
|
2538
|
redis := service.RedisClient()
|
2521
|
2539
|
keyFive := strconv.FormatInt(advice.UserOrgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
|
|
@@ -2555,6 +2573,7 @@ func (c *HisApiController) DeleteDoctorAdvice() {
|
2555
|
2573
|
return
|
2556
|
2574
|
}
|
2557
|
2575
|
}
|
|
2576
|
+
|
2558
|
2577
|
func (c *HisApiController) DeleteProject() {
|
2559
|
2578
|
id, _ := c.GetInt64("id")
|
2560
|
2579
|
adminInfo := c.GetAdminUserInfo()
|
|
@@ -2562,40 +2581,6 @@ func (c *HisApiController) DeleteProject() {
|
2562
|
2581
|
// var consumable models.DialysisBeforePrepare
|
2563
|
2582
|
_, stockConfig := service.FindAutomaticReduceRecordByOrgId(c.GetAdminUserInfo().CurrentOrgId)
|
2564
|
2583
|
|
2565
|
|
- isCharge := false
|
2566
|
|
- isMedicine := false
|
2567
|
|
- new_prescription, _ := service.GetPrescriptionById(project.PrescriptionId, c.GetAdminUserInfo().CurrentOrgId)
|
2568
|
|
- new_prescriptions, _ := service.GetHisPrescription(c.GetAdminUserInfo().CurrentOrgId, new_prescription.PatientId, new_prescription.RecordDate, new_prescription.PType)
|
2569
|
|
- for _, item := range new_prescriptions {
|
2570
|
|
- if item.IsMedicine == 1 {
|
2571
|
|
- isMedicine = true
|
2572
|
|
- }
|
2573
|
|
- }
|
2574
|
|
- for _, item := range new_prescriptions {
|
2575
|
|
- if item.OrderStatus == 2 {
|
2576
|
|
- isCharge = true
|
2577
|
|
- }
|
2578
|
|
- }
|
2579
|
|
- if isMedicine {
|
2580
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePMedicineWrong)
|
2581
|
|
- return
|
2582
|
|
- }
|
2583
|
|
- if isCharge {
|
2584
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrong)
|
2585
|
|
- return
|
2586
|
|
- }
|
2587
|
|
-
|
2588
|
|
- if new_prescription.ID > 0 {
|
2589
|
|
- if new_prescription.OrderStatus == 2 {
|
2590
|
|
- isCharge = true
|
2591
|
|
- }
|
2592
|
|
- }
|
2593
|
|
-
|
2594
|
|
- if isCharge {
|
2595
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeletePChargeWrongTwo)
|
2596
|
|
- return
|
2597
|
|
- }
|
2598
|
|
-
|
2599
|
2584
|
service.DeletePrintInfo(id)
|
2600
|
2585
|
label, _ := service.GetProjectById(adminInfo.CurrentOrgId, id, project.RecordDate, project.PatientId)
|
2601
|
2586
|
label.Status = 0
|
|
@@ -3508,7 +3493,7 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
|
3508
|
3493
|
advice.CheckState = hisAdvice.CheckState
|
3509
|
3494
|
advice.StartTime = hisAdvice.StartTime
|
3510
|
3495
|
advice.HospApprFlag = hisAdvice.HospApprFlag
|
3511
|
|
- advice.IsMedicine = hisAdvice.IsMedicine
|
|
3496
|
+
|
3512
|
3497
|
if hisAdvice.UserOrgId == 10028 {
|
3513
|
3498
|
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 {
|
3514
|
3499
|
advice.ExecutionTime = 0
|
|
@@ -6238,7 +6223,7 @@ func (c *HisApiController) GetFaPiaoData() {
|
6238
|
6223
|
operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|
6239
|
6224
|
}
|
6240
|
6225
|
|
6241
|
|
- if item.MedChrgitmType == "08" || item.MedChrgitmType == "1401" { //材料费
|
|
6226
|
+ if item.MedChrgitmType == "08" { //材料费
|
6242
|
6227
|
materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
|
6243
|
6228
|
materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
|
6244
|
6229
|
materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
|