28169 1 rok temu
rodzic
commit
7719ac70bd

+ 1 - 1
controllers/gobal_config_api_controller.go Wyświetl plik

@@ -2387,7 +2387,7 @@ func (c *GobalConfigApiController) GetDrugOutOrderPrint() {
2387 2387
 	warehousing, _ := service.GetExportOutOrderDrugListOne(ids)
2388 2388
 
2389 2389
 	drug_warhouse_out, _ := service.GetDrugWarehouseOutTenty(ids, admin.CurrentOrgId)
2390
-	fmt.Println("drug_warhouse_out9999999", drug_warhouse_out)
2390
+
2391 2391
 	c.ServeSuccessJSON(map[string]interface{}{
2392 2392
 		"info":              info,
2393 2393
 		"warehousing":       warehousing,

+ 6 - 0
controllers/his_project_api_controller.go Wyświetl plik

@@ -87,6 +87,7 @@ func HisProjectRouters() {
87 87
 	beego.Router("/api/hispatient/getmaintemplatebyid", &HisProjectApiController{}, "Get:GetMainTemplateById")
88 88
 	beego.Router("/api/hispatient/updatemaintemplate", &HisProjectApiController{}, "Get:UpdateMainTemplate")
89 89
 	beego.Router("/api/hispatient/deletemaintemplate", &HisProjectApiController{}, "Get:DeleteMainTemplate")
90
+
90 91
 }
91 92
 
92 93
 func (this *HisProjectApiController) SaveProject() {
@@ -1268,6 +1269,11 @@ func (this *HisProjectApiController) GetDoctorAdvicePrint() {
1268 1269
 	prescriptionInfo, _ := service.GetPrscriptionInfo(patient_id, recordDateTime)
1269 1270
 	//advicePrint, err := service.GetPre(patient_id, recordDateTime, idStrs, adminUserInfo.CurrentOrgId, temp_p_type)
1270 1271
 	hisPatient, _ := service.GetHisPatientInfoFour(adminUserInfo.CurrentOrgId, patient_id, recordDateTime, his_patient_id)
1272
+	hisPatient_two, _ := service.GetHisPatientInfoTen(adminUserInfo.CurrentOrgId, patient_id, recordDateTime)
1273
+	if hisPatient.ID == 0 {
1274
+		hisPatient = hisPatient_two
1275
+	}
1276
+
1271 1277
 	//hisPatient, _ := service.GetHisPatientById(patient_id)
1272 1278
 	hisHospitalRecord, _ := service.GetLastHospitalRecordTwo(patient_id, adminUserInfo.CurrentOrgId)
1273 1279
 

+ 5 - 0
service/his_service.go Wyświetl plik

@@ -297,6 +297,11 @@ func GetHisPatientInfoThree(org_id int64, number string) (info models.HisPatient
297 297
 	return
298 298
 }
299 299
 
300
+func GetHisPatientInfoTen(org_id int64, patient_id int64, record_date int64) (info models.HisPatient, err error) {
301
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).Last(&info).Error
302
+	return
303
+}
304
+
300 305
 func GetHisPatientInfoFour(org_id int64, patient_id int64, record_date int64, his_patient_id int64) (info models.HisPatient, err error) {
301 306
 	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND id = ?", org_id, record_date, patient_id, his_patient_id).First(&info).Error
302 307
 	return

+ 62 - 37
service/new_warehouse_service.go Wyświetl plik

@@ -813,6 +813,7 @@ func BloodDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *
813 813
 		}
814 814
 
815 815
 		//如果本次出库数据大于历史出库数据 新增1条流水
816
+
816 817
 		if deliver_number > (out_count - cancel_count) {
817 818
 			drugflow := models.DrugFlow{
818 819
 				WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
@@ -1262,7 +1263,7 @@ func BloodDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *
1262 1263
 }
1263 1264
 
1264 1265
 // 药品自动出库 递归方式
1265
-func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo) (err error) {
1266
+func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo, hisprescribingNumber float64) (err error) {
1266 1267
 
1267 1268
 	drugError := models.XtDrugError{
1268 1269
 		UserOrgId:             orgID,
@@ -1280,11 +1281,15 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1280 1281
 	CreateDrugError(drugError)
1281 1282
 	// 判断处方里药品单位是拆零单位还是包装单位,	如果是包装单位,则根据规格,将包装数量转为拆零数量
1282 1283
 	var deliver_number int64 = 0
1284
+	var deliver_number_one int64 = 0
1283 1285
 	var stock_number int64 = 0
1284 1286
 
1285 1287
 	prescribingNumber_temp := strconv.FormatFloat(math.Abs(prescribingNumber), 'f', 0, 64)
1286 1288
 	count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
1287 1289
 
1290
+	prescribingNumber_temp_one := strconv.FormatFloat(math.Abs(hisprescribingNumber), 'f', 0, 64)
1291
+	countone, _ := strconv.ParseInt(prescribingNumber_temp_one, 10, 64)
1292
+
1288 1293
 	var drug_price float64
1289 1294
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
1290 1295
 		deliver_number = count * drup.MinNumber
@@ -1294,6 +1299,16 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1294 1299
 
1295 1300
 	}
1296 1301
 
1302
+	if advice.PrescribingNumberUnit == drup.MaxUnit {
1303
+		deliver_number_one = countone * drup.MinNumber
1304
+
1305
+	} else {
1306
+		deliver_number_one = countone
1307
+
1308
+	}
1309
+
1310
+	fmt.Println(deliver_number_one)
1311
+
1297 1312
 	if advice.PrescribingNumberUnit == drup.MaxUnit {
1298 1313
 		drug_price = drup.RetailPrice
1299 1314
 	}
@@ -1320,6 +1335,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1320 1335
 
1321 1336
 			ChangeMaxNumber(lastWarehouse.ID, stockMax)
1322 1337
 			UpdateMinNumber(lastWarehouse.ID, stockMin)
1338
+
1323 1339
 		}
1324 1340
 	}
1325 1341
 
@@ -1543,33 +1559,41 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1543 1559
 			}
1544 1560
 		}
1545 1561
 		if lastDrugOutInfo.ID > 0 {
1546
-			var his_count int64
1547
-			if lastDrugOutInfo.CountUnit == drup.MaxUnit {
1548
-				his_count = lastDrugOutInfo.Count * drup.MinNumber
1549
-			}
1550
-			if lastDrugOutInfo.CountUnit == drup.MinUnit {
1551
-				his_count = lastDrugOutInfo.Count
1552
-			}
1553
-			if deliver_number != his_count {
1554
-				errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
1555
-				if errThree != nil {
1556
-					drugError := models.XtDrugError{
1557
-						UserOrgId:             orgID,
1558
-						DrugId:                advice.DrugId,
1559
-						RecordDate:            advice.AdviceDate,
1560
-						PatientId:             advice.PatientId,
1561
-						Remark:                "更新出库单失败",
1562
-						Status:                1,
1563
-						Ctime:                 time.Now().Unix(),
1564
-						Mtime:                 0,
1565
-						SumCount:              0,
1566
-						Prescribingnumber:     advice.PrescribingNumber,
1567
-						PrescribingNumberUnit: advice.PrescribingNumberUnit,
1568
-					}
1569
-					CreateDrugError(drugError)
1570
-					return errThree
1571
-				}
1572
-			}
1562
+
1563
+			//删除在新增
1564
+			UpdateDrugWarehouseOutInfoTen(lastDrugOutInfo.PatientId, lastDrugOutInfo.SysRecordTime, advice.ID)
1565
+
1566
+			AddSigleDrugWarehouseOutInfo(warehouseOutInfo)
1567
+
1568
+			//var his_count int64
1569
+			//if lastDrugOutInfo.CountUnit == drup.MaxUnit {
1570
+			//	his_count = lastDrugOutInfo.Count * drup.MinNumber
1571
+			//}
1572
+			//if lastDrugOutInfo.CountUnit == drup.MinUnit {
1573
+			//	his_count = lastDrugOutInfo.Count
1574
+			//}
1575
+			//fmt.Println("deliver_number", deliver_number)
1576
+			//fmt.Println("his_countwowowoowow", his_count)
1577
+			//if deliver_number != his_count {
1578
+			//	errThree := UpdateSigleDrugWarehouseOutInfo(lastDrugOutInfo.ID, warehouseOutInfo)
1579
+			//	if errThree != nil {
1580
+			//		drugError := models.XtDrugError{
1581
+			//			UserOrgId:             orgID,
1582
+			//			DrugId:                advice.DrugId,
1583
+			//			RecordDate:            advice.AdviceDate,
1584
+			//			PatientId:             advice.PatientId,
1585
+			//			Remark:                "更新出库单失败",
1586
+			//			Status:                1,
1587
+			//			Ctime:                 time.Now().Unix(),
1588
+			//			Mtime:                 0,
1589
+			//			SumCount:              0,
1590
+			//			Prescribingnumber:     advice.PrescribingNumber,
1591
+			//			PrescribingNumberUnit: advice.PrescribingNumberUnit,
1592
+			//		}
1593
+			//		CreateDrugError(drugError)
1594
+			//		return errThree
1595
+			//	}
1596
+			//}
1573 1597
 		}
1574 1598
 
1575 1599
 		var out_count int64
@@ -1586,11 +1610,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1586 1610
 			cancel_count += item.Count
1587 1611
 		}
1588 1612
 
1589
-		//如果本次出库数据大于历史出库数据 新增1条流水
1590
-		//fmt.Println("deliver_number233233223232wi", deliver_number)
1591
-		//fmt.Println("out_coutn23333333333333333", out_count)
1592
-		//fmt.Println("cancel_coutn099992ow", cancel_count)
1593
-		if deliver_number >= (out_count - cancel_count) {
1613
+		if deliver_number_one-(out_count-cancel_count) >= 0 {
1594 1614
 			if (deliver_number - out_count - cancel_count) != 0 {
1595 1615
 				drugflow := models.DrugFlow{
1596 1616
 					WarehouseOutOrderNumber: warehouseout.WarehouseOutOrderNumber,
@@ -1599,7 +1619,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1599 1619
 					Number:                  warehouse.Number,
1600 1620
 					ProductDate:             warehouse.ProductDate,
1601 1621
 					ExpireDate:              warehouse.ExpiryDate,
1602
-					Count:                   deliver_number - (out_count - cancel_count), //按最小单位计算,
1622
+					Count:                   deliver_number_one - (out_count - cancel_count), //按最小单位计算,
1603 1623
 					Price:                   warehouse.RetailPrice,
1604 1624
 					Status:                  1,
1605 1625
 					Ctime:                   advice.AdviceDate,
@@ -1667,7 +1687,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
1667 1687
 		}
1668 1688
 
1669 1689
 		//如果本次出库数据小于历史出库数据 新增1条退库流水
1670
-		if deliver_number < (out_count - cancel_count) {
1690
+		if deliver_number_one-(out_count-cancel_count) < 0 {
1671 1691
 
1672 1692
 			operation_time := time.Now().Unix()
1673 1693
 
@@ -2340,7 +2360,7 @@ func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseou
2340 2360
 		advice.PrescribingNumber = float64(prescribingNumber_two_temp)
2341 2361
 		advice.PrescribingNumberUnit = drup.MinUnit
2342 2362
 
2343
-		BloodHisDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice)
2363
+		BloodHisDrugDeliverInfo(orgID, overPlusNumber, warehouseout, drup, advice, hisprescribingNumber)
2344 2364
 	}
2345 2365
 
2346 2366
 	return
@@ -3935,7 +3955,6 @@ func ConsumablesGoodDeliveryNew(orgID int64, patient_id int64, record_time int64
3935 3955
 		utils.ErrorLog("事务失败,原因为: %v", err)
3936 3956
 		tx.Rollback()
3937 3957
 	} else {
3938
-		fmt.Println("err-----------------------", err)
3939 3958
 		tx.Commit()
3940 3959
 	}
3941 3960
 	var deliver_number int64 = 0
@@ -4513,3 +4532,9 @@ func ConsumablesGoodDeliveryNew(orgID int64, patient_id int64, record_time int64
4513 4532
 
4514 4533
 	return nil
4515 4534
 }
4535
+
4536
+func UpdateDrugWarehouseOutInfoTen(patient_id int64, sys_record_time int64, advice_id int64) error {
4537
+
4538
+	err := XTWriteDB().Model(&models.DrugWarehouseOutInfo{}).Where("patient_id = ? and sys_record_time  = ? and status=1 and advice_id = ?", patient_id, sys_record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
4539
+	return err
4540
+}

+ 1 - 1
service/warhouse_service.go Wyświetl plik

@@ -619,7 +619,7 @@ func HisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdvice
619 619
 		if drup.ID > 0 {
620 620
 			prescribingNumber := advice.PrescribingNumber
621 621
 
622
-			BloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice)
622
+			BloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber)
623 623
 
624 624
 		} else {
625 625
 			return errors.New("药品信息不存在")