|
@@ -1105,6 +1105,39 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1105
|
1105
|
for _, item := range advices {
|
1106
|
1106
|
//查询改药品信息
|
1107
|
1107
|
medical, _ := service.GetBaseDrugMedical(item.DrugId)
|
|
1108
|
+
|
|
1109
|
+ //判断单位是否合格
|
|
1110
|
+ if item.PrescribingNumberUnit != medical.MaxUnit && item.PrescribingNumberUnit != medical.MinUnit {
|
|
1111
|
+ //查询该药品是否有出库记录
|
|
1112
|
+ flowMap, _ := service.GetDrugFLowByAdviceById(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate)
|
|
1113
|
+ if len(flowMap) == 0 {
|
|
1114
|
+ errs := service.UpdateHisAdviceById(item.ID)
|
|
1115
|
+ if errs != nil {
|
|
1116
|
+ drugError := models.XtDrugError{
|
|
1117
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1118
|
+ DrugId: item.DrugId,
|
|
1119
|
+ RecordDate: item.AdviceDate,
|
|
1120
|
+ PatientId: item.PatientId,
|
|
1121
|
+ Remark: "单位不统一,执行失败",
|
|
1122
|
+ Status: 1,
|
|
1123
|
+ Ctime: time.Now().Unix(),
|
|
1124
|
+ Mtime: 0,
|
|
1125
|
+ SumCount: 0,
|
|
1126
|
+ Prescribingnumber: item.PrescribingNumber,
|
|
1127
|
+ PrescribingNumberUnit: item.PrescribingNumberUnit,
|
|
1128
|
+ }
|
|
1129
|
+ service.CreateDrugError(drugError)
|
|
1130
|
+ }
|
|
1131
|
+ }
|
|
1132
|
+ advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
|
|
1133
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1134
|
+ "msg": "7",
|
|
1135
|
+ "advice": advice,
|
|
1136
|
+ "ids": ids,
|
|
1137
|
+ })
|
|
1138
|
+ return
|
|
1139
|
+ }
|
|
1140
|
+
|
1108
|
1141
|
//查询这个患者这个患者这个药已经出库的所有数量
|
1109
|
1142
|
advicelist, _ := service.GetAllHisDoctorAdviceById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
|
1110
|
1143
|
drugoutlist, _ := service.GetAllDrugFlowById(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId)
|
|
@@ -1253,12 +1286,28 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1253
|
1286
|
if config.IsOpen != 1 {
|
1254
|
1287
|
if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
|
1255
|
1288
|
service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
1256
|
|
- fmt.Println("处方1111111111111")
|
|
1289
|
+
|
1257
|
1290
|
if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
|
1258
|
1291
|
//查询该药品是否有出库记录
|
1259
|
1292
|
flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
|
1260
|
1293
|
if len(flowMap) == 0 {
|
1261
|
|
- service.UpdateHisAdviceById(advice.ID)
|
|
1294
|
+ errs := service.UpdateHisAdviceById(advice.ID)
|
|
1295
|
+ if errs != nil {
|
|
1296
|
+ drugError := models.XtDrugError{
|
|
1297
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1298
|
+ DrugId: item.DrugId,
|
|
1299
|
+ RecordDate: item.AdviceDate,
|
|
1300
|
+ PatientId: item.PatientId,
|
|
1301
|
+ Remark: "出库记录为空,更新执行人失败",
|
|
1302
|
+ Status: 1,
|
|
1303
|
+ Ctime: time.Now().Unix(),
|
|
1304
|
+ Mtime: 0,
|
|
1305
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
1306
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1307
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1308
|
+ }
|
|
1309
|
+ service.CreateDrugError(drugError)
|
|
1310
|
+ }
|
1262
|
1311
|
c.ServeSuccessJSON(map[string]interface{}{
|
1263
|
1312
|
"msg": "6",
|
1264
|
1313
|
"advice": advice,
|
|
@@ -1269,14 +1318,31 @@ func (c *PatientApiController) ExecDoctorAdvice() {
|
1269
|
1318
|
}
|
1270
|
1319
|
}
|
1271
|
1320
|
if pharmacyConfig.IsOpen != 1 {
|
1272
|
|
- fmt.Println("处方我33333333323")
|
|
1321
|
+
|
1273
|
1322
|
service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
|
1274
|
1323
|
if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
|
1275
|
1324
|
//查询该药品是否有出库记录
|
1276
|
1325
|
flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
|
1277
|
|
- fmt.Println("flowMap----------", flowMap)
|
|
1326
|
+
|
1278
|
1327
|
if len(flowMap) == 0 {
|
1279
|
|
- service.UpdateHisAdviceById(advice.ID)
|
|
1328
|
+
|
|
1329
|
+ errs := service.UpdateHisAdviceById(advice.ID)
|
|
1330
|
+ if errs != nil {
|
|
1331
|
+ drugError := models.XtDrugError{
|
|
1332
|
+ UserOrgId: adminInfo.Org.Id,
|
|
1333
|
+ DrugId: item.DrugId,
|
|
1334
|
+ RecordDate: item.AdviceDate,
|
|
1335
|
+ PatientId: item.PatientId,
|
|
1336
|
+ Remark: "出库记录为空,更新执行人失败",
|
|
1337
|
+ Status: 1,
|
|
1338
|
+ Ctime: time.Now().Unix(),
|
|
1339
|
+ Mtime: 0,
|
|
1340
|
+ SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
|
|
1341
|
+ Prescribingnumber: advice.PrescribingNumber,
|
|
1342
|
+ PrescribingNumberUnit: advice.PrescribingNumberUnit,
|
|
1343
|
+ }
|
|
1344
|
+ service.CreateDrugError(drugError)
|
|
1345
|
+ }
|
1280
|
1346
|
c.ServeSuccessJSON(map[string]interface{}{
|
1281
|
1347
|
"msg": "6",
|
1282
|
1348
|
"advice": advice,
|