Browse Source

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

28169 1 year ago
parent
commit
5f3f75bda7

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

@@ -685,7 +685,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
685 685
 		privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
686 686
 
687 687
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
688
-		fmt.Println("drugStockConfig.IsOpen32232323232", drugStockConfig.IsOpen)
688
+
689 689
 		if drugStockConfig.IsOpen == 1 {
690 690
 			if groupno > 0 {
691 691
 				advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
@@ -1253,9 +1253,38 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1253 1253
 								if config.IsOpen != 1 {
1254 1254
 									if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
1255 1255
 										service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1256
+										fmt.Println("处方1111111111111")
1257
+										if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1258
+											//查询该药品是否有出库记录
1259
+											flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
1260
+											if len(flowMap) == 0 {
1261
+												service.UpdateHisAdviceById(advice.ID)
1262
+												c.ServeSuccessJSON(map[string]interface{}{
1263
+													"msg":    "6",
1264
+													"advice": advice,
1265
+													"ids":    ids,
1266
+												})
1267
+												return
1268
+											}
1269
+										}
1256 1270
 									}
1257 1271
 									if pharmacyConfig.IsOpen != 1 {
1272
+										fmt.Println("处方我33333333323")
1258 1273
 										service.HisDrugsDelivery(adminInfo.Org.Id, creater, &advice)
1274
+										if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
1275
+											//查询该药品是否有出库记录
1276
+											flowMap, _ := service.GetDrugFLowByAdviceById(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate)
1277
+											fmt.Println("flowMap----------", flowMap)
1278
+											if len(flowMap) == 0 {
1279
+												service.UpdateHisAdviceById(advice.ID)
1280
+												c.ServeSuccessJSON(map[string]interface{}{
1281
+													"msg":    "6",
1282
+													"advice": advice,
1283
+													"ids":    ids,
1284
+												})
1285
+												return
1286
+											}
1287
+										}
1259 1288
 									}
1260 1289
 
1261 1290
 									//更新字典里面的库存
@@ -1275,6 +1304,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1275 1304
 							}
1276 1305
 						}
1277 1306
 					}
1307
+
1278 1308
 					//
1279 1309
 					//if config.IsOpen == 1 && item.UserOrgId == 10088 {
1280 1310
 					//

+ 12 - 0
service/warhouse_service.go View File

@@ -7477,3 +7477,15 @@ func UpdateAutomaticReduce(patient_id int64, record_date int64, good_id int64, p
7477 7477
 	err := XTWriteDB().Model(&models.AutomaticReduceDetail{}).Where("patient_id = ? and record_time =? and good_id = ? and project_id = ? and status = 1", patient_id, record_date, good_id, project_id).Update(map[string]interface{}{"status": 0}).Error
7478 7478
 	return err
7479 7479
 }
7480
+
7481
+func GetDrugFLowByAdviceById(drug_id int64, patient_id int64, user_org_id int64, advice_date int64) (outInfo []*models.DrugWarehouseOutInfo, err error) {
7482
+
7483
+	err = XTReadDB().Where("drug_id = ? and patient_id = ? and org_id = ? and sys_record_time = ? and status= 1", drug_id, patient_id, user_org_id, advice_date).Find(&outInfo).Error
7484
+	return outInfo, err
7485
+}
7486
+
7487
+func UpdateHisAdviceById(id int64) error {
7488
+
7489
+	err := XTWriteDB().Model(&models.HisDoctorAdviceInfo{}).Where("id = ?", id).Updates(map[string]interface{}{"execution_time": "", "execution_staff": "", "execution_state": 2}).Error
7490
+	return err
7491
+}