Browse Source

2024/6/17

28169 2 months ago
parent
commit
9cdd7fa8a1

+ 2 - 2
controllers/dialysis_api_controller.go View File

@@ -4863,12 +4863,12 @@ func (c *DialysisApiController) GetDialysisOrder() {
4863 4863
 	}
4864 4864
 	if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 10345 {
4865 4865
 
4866
-		if xttime <= 1703952000 {
4866
+		if xttime <= 1735574400 {
4867 4867
 			dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4868 4868
 			patientInfo.TotalDialysis = dialysis_count
4869 4869
 		}
4870 4870
 
4871
-		if xttime >= 1704038400 {
4871
+		if xttime >= 1735660800 {
4872 4872
 			dialysis_count, _ := service.GetDialysisOrderCountTwo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
4873 4873
 			patientInfo.TotalDialysis = dialysis_count
4874 4874
 		}

+ 62 - 11
controllers/drug_stock_api_contorller.go View File

@@ -3583,6 +3583,7 @@ func (c *StockDrugApiController) CheckDrugOut() {
3583 3583
 				"max_unit":               drup.MaxUnit,
3584 3584
 				"msg":                    2,
3585 3585
 			})
3586
+			tx.Rollback()
3586 3587
 			return
3587 3588
 		}
3588 3589
 	}
@@ -3609,7 +3610,12 @@ func (c *StockDrugApiController) CheckDrugOut() {
3609 3610
 
3610 3611
 	}
3611 3612
 	warehousingOutInfoListThree, _ := service.GetNewDrugWarehouseOutListById(warehouse_out_id, orgId, tx)
3613
+
3614
+	var is_success = 2
3612 3615
 	for _, it := range warehousingOutInfoListThree {
3616
+
3617
+		var his_count = it.Count
3618
+		var his_count_unit = it.CountUnit
3613 3619
 		medical, _ := service.GetNewBaseDrugMedical(it.DrugId, tx)
3614 3620
 		drup, _ := service.FindNewBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
3615 3621
 		//出库逻辑
@@ -3637,6 +3643,47 @@ func (c *StockDrugApiController) CheckDrugOut() {
3637 3643
 		}
3638 3644
 		//更新基础库库存
3639 3645
 		service.UpdateNewBaseDrugSumTwo(it.DrugId, sum_count_one, it.OrgId, tx)
3646
+
3647
+		if it.OrgId == 10164 || it.OrgId == 10721 {
3648
+			var now_count int64
3649
+
3650
+			if his_count_unit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3651
+				now_count = his_count * medical.MinNumber
3652
+			}
3653
+			if his_count_unit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3654
+				now_count = his_count
3655
+			}
3656
+			if his_count_unit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3657
+				now_count = his_count
3658
+			}
3659
+
3660
+			var flow_count int64
3661
+
3662
+			//查询该药品的出库数量
3663
+			drugflowlist, _ := service.GetDrugOutFlowByWarehouseOut(it.DrugId, it.ID, it.OrgId, tx)
3664
+			if len(drugflowlist) > 0 {
3665
+				for _, items := range drugflowlist {
3666
+
3667
+					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
3668
+						flow_count = items.Count * medical.MinNumber
3669
+					}
3670
+					if items.MaxUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
3671
+						flow_count = items.Count
3672
+					}
3673
+					if items.MaxUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
3674
+						flow_count = items.Count
3675
+					}
3676
+				}
3677
+			}
3678
+
3679
+			if now_count != flow_count {
3680
+				is_success = 1
3681
+				tx.Rollback()
3682
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
3683
+				return
3684
+			}
3685
+		}
3686
+
3640 3687
 	}
3641 3688
 
3642 3689
 	out := models.DrugWarehouseOut{
@@ -3645,18 +3692,22 @@ func (c *StockDrugApiController) CheckDrugOut() {
3645 3692
 	//更新审核状态
3646 3693
 	service.UpdateNewCheckDrugOut(out, warehouse_out_id, tx)
3647 3694
 
3648
-	tx.Commit()
3695
+	//查询
3696
+	if is_success != 1 {
3697
+		tx.Commit()
3698
+		c.ServeSuccessJSON(map[string]interface{}{
3699
+			"warehousingOutInfoList": warehousingOutInfoList,
3700
+			"drug_name":              "",
3701
+			"dose":                   "",
3702
+			"dose_unit":              "",
3703
+			"min_number":             "",
3704
+			"min_unit":               "",
3705
+			"max_unit":               "",
3706
+			"msg":                    1,
3707
+		})
3708
+		return
3709
+	}
3649 3710
 
3650
-	c.ServeSuccessJSON(map[string]interface{}{
3651
-		"warehousingOutInfoList": warehousingOutInfoList,
3652
-		"drug_name":              "",
3653
-		"dose":                   "",
3654
-		"dose_unit":              "",
3655
-		"min_number":             "",
3656
-		"min_unit":               "",
3657
-		"max_unit":               "",
3658
-		"msg":                    1,
3659
-	})
3660 3711
 }
3661 3712
 
3662 3713
 func (c *StockDrugApiController) ToReturnCheck() {

+ 12 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -3900,10 +3900,14 @@ func (this *DialysisAPIController) StartDialysis() {
3900 3900
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
3901 3901
 
3902 3902
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
3903
-			if (template.TemplateId == 6 || template.TemplateId == 32 || template.TemplateId == 65 || adminUserInfo.Org.Id == 10375 || adminUserInfo.Org.Id == 10599 || adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745) && adminUserInfo.Org.Id != 9671 { //adminUserInfo.Org.Id == 9538
3903
+			if (template.TemplateId == 6 || template.TemplateId == 32 || template.TemplateId == 65 || adminUserInfo.Org.Id == 10375 || adminUserInfo.Org.Id == 10599) && adminUserInfo.Org.Id != 9671 { //adminUserInfo.Org.Id == 9538
3904 3904
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3905 3905
 			}
3906 3906
 
3907
+			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 {
3908
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3909
+			}
3910
+
3907 3911
 			if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10679 { //adminUserInfo.Org.Id == 9538
3908 3912
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3909 3913
 			}
@@ -5182,12 +5186,18 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5182 5186
 		if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
5183 5187
 
5184 5188
 			totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
5185
-			if (template.TemplateId == 6 || template.TemplateId == 65 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10599 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745) && adminInfo.Org.Id != 9538 {
5189
+			if (template.TemplateId == 6 || template.TemplateId == 65 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10599) && adminInfo.Org.Id != 9538 {
5186 5190
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
5187 5191
 				record.UltrafiltrationRate = ultrafiltration_rate
5188 5192
 
5189 5193
 			}
5190 5194
 
5195
+			//重庆塘坝卫生院
5196
+			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 {
5197
+				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5198
+				record.UltrafiltrationRate = ultrafiltration_rate
5199
+			}
5200
+
5191 5201
 			if adminInfo.Org.Id == 10597 || adminInfo.Org.Id == 10679 {
5192 5202
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5193 5203
 				record.UltrafiltrationRate = ultrafiltration_rate

+ 27 - 0
controllers/pharmacy_controller.go View File

@@ -50,6 +50,8 @@ func PharmacyApiRegistRouters() {
50 50
 
51 51
 	beego.Router("/api/pharmacy/changeZeroFlag", &PharmacyController{}, "Get:ChangeZeroFlag")
52 52
 
53
+	beego.Router("/api/pharmacy/getdrugtocalcount", &PharmacyController{}, "Get:GetDrugTocalCount")
54
+
53 55
 }
54 56
 
55 57
 // 测试
@@ -1446,3 +1448,28 @@ func (this *PharmacyController) ChangeZeroFlag() {
1446 1448
 	})
1447 1449
 
1448 1450
 }
1451
+
1452
+func (this *PharmacyController) GetDrugTocalCount() {
1453
+
1454
+	timeLayout := "2006-01-02"
1455
+	loc, _ := time.LoadLocation("Local")
1456
+	drug_id, _ := this.GetInt64("drug_id")
1457
+	start_time := this.GetString("start_time")
1458
+	var startTime int64
1459
+	if len(start_time) > 0 {
1460
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
1461
+		if err != nil {
1462
+			fmt.Println(err)
1463
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1464
+			return
1465
+		}
1466
+		startTime = theTime.Unix()
1467
+	}
1468
+	orgId := this.GetAdminUserInfo().CurrentOrgId
1469
+
1470
+	adviceList, _ := service.GetDrugTocalCountByDrugId(drug_id, startTime, orgId)
1471
+
1472
+	this.ServeSuccessJSON(map[string]interface{}{
1473
+		"adviceList": adviceList,
1474
+	})
1475
+}

+ 2 - 2
controllers/print_data_api_controller.go View File

@@ -107,14 +107,14 @@ func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
107 107
 
108 108
 			if this.GetAdminUserInfo().CurrentOrgId == 10101 || this.GetAdminUserInfo().CurrentOrgId == 9671 || this.GetAdminUserInfo().CurrentOrgId == 10345 || this.GetAdminUserInfo().CurrentOrgId == 9970 || this.GetAdminUserInfo().CurrentOrgId == 10495 || this.GetAdminUserInfo().CurrentOrgId == 10013 || this.GetAdminUserInfo().CurrentOrgId == 10014 {
109 109
 
110
-				if item.ScheduleDate <= 1703952000 {
110
+				if item.ScheduleDate <= 1735574400 {
111 111
 					listOne, _ := service.GetDialysisOrderCountEight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
112 112
 
113 113
 					item.Patient.TotalDialysis = listOne.Count
114 114
 					item.Count = listOne.Count
115 115
 				}
116 116
 
117
-				if item.ScheduleDate >= 1704038400 {
117
+				if item.ScheduleDate >= 1735660800 {
118 118
 
119 119
 					listOne, _ := service.GetDialysisOrderCountNight(adminUserInfo.CurrentOrgId, item.PatientID, item.ScheduleDate)
120 120
 

+ 27 - 2
controllers/stock_in_api_controller.go View File

@@ -7304,6 +7304,7 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7304 7304
 
7305 7305
 	////出库逻辑
7306 7306
 	for _, item := range warehousingOutInfo {
7307
+
7307 7308
 		// 查询该耗材是否有库存
7308 7309
 		warehouseOne, _ := service.FindNewWarehousingInfoTen(item.GoodId, item.StorehouseId, tx)
7309 7310
 
@@ -7323,10 +7324,14 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7323 7324
 		}
7324 7325
 
7325 7326
 	}
7327
+	var is_scucess = 2
7328
+
7326 7329
 	for _, item := range warehousingOutInfo {
7327 7330
 
7328 7331
 		creater := this.GetAdminUserInfo().AdminUser.Id
7329 7332
 
7333
+		var now_count = item.Count
7334
+
7330 7335
 		//出库
7331 7336
 		err := service.ConsumablesNewDeliveryThirty(orgId, item.SysRecordTime, item, &warehouseOut, item.Count, creater, tx)
7332 7337
 
@@ -7353,12 +7358,31 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7353 7358
 		//基础库扣减库存
7354 7359
 		service.UpdateNewGoodInfoReduceSumCount(item.GoodId, total_count, orgId, tx)
7355 7360
 
7361
+		var flow_count int64
7362
+		flowList, _ := service.GetGoodFlowByWarehouseOutId(item.GoodId, item.OrgId, item.ID, tx)
7363
+		if len(flowList) > 0 {
7364
+			for _, items := range flowList {
7365
+				flow_count += items.Count
7366
+			}
7367
+		}
7368
+
7369
+		if now_count != flow_count {
7370
+			is_scucess = 1
7371
+			tx.Rollback()
7372
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFlow)
7373
+			return
7374
+
7375
+		}
7376
+
7356 7377
 	}
7357 7378
 
7358 7379
 	//审核单据
7359 7380
 	err := service.UpdatedNewWarehouseOut(id, tx)
7360 7381
 
7361
-	tx.Commit()
7382
+	if is_scucess != 1 {
7383
+		tx.Commit()
7384
+	}
7385
+
7362 7386
 	if err == nil {
7363 7387
 		this.ServeSuccessJSON(map[string]interface{}{
7364 7388
 			"msg":                "2",
@@ -7366,6 +7390,7 @@ func (this *StockManagerApiController) CheckWarehouseOut() {
7366 7390
 			"specification_name": "",
7367 7391
 			"storehose_name":     "",
7368 7392
 		})
7393
+		return
7369 7394
 	}
7370 7395
 
7371 7396
 }
@@ -7492,8 +7517,8 @@ func (this *StockManagerApiController) CheckWarehouseInfo() {
7492 7517
 				Dealer:                  item.Dealer,
7493 7518
 				Creator:                 Creator,
7494 7519
 				UpdateCreator:           0,
7495
-				Status:                  1,
7496 7520
 				Ctime:                   item.Ctime,
7521
+				Status:                  1,
7497 7522
 				Mtime:                   0,
7498 7523
 				Price:                   item.PackingPrice,
7499 7524
 				WarehousingDetailId:     item.ID,

+ 3 - 0
enums/error_code.go View File

@@ -287,6 +287,8 @@ const ( // ErrorCode
287 287
 	ErrorTimeCodeParamWrong = 600000012
288 288
 
289 289
 	ErrorCodeAuthWrong = 600000013
290
+
291
+	ErrorCodeFlow = 600000014
290 292
 )
291 293
 
292 294
 var ErrCodeMsgs = map[int]string{
@@ -552,6 +554,7 @@ var ErrCodeMsgs = map[int]string{
552 554
 
553 555
 	ErrorTimeCodeParamWrong: "时间跨度不能超过一个月",
554 556
 	ErrorCodeAuthWrong:      "尚未实名认证,请先认证",
557
+	ErrorCodeFlow:           "网络错误,数据异常,审核失败",
555 558
 }
556 559
 
557 560
 type SGJError struct {

+ 1 - 0
models/schedule_models.go View File

@@ -477,6 +477,7 @@ type VmBloodScheduleTwo struct {
477 477
 	SchedualPatient            *NewMSchedualPatientVMList `gorm:"ForeignKey:PatientId" json:"patient"`
478 478
 	HisPrescriptionTemplateSix HisPrescriptionTemplateSix `gorm:"ForeignKey:PatientId,Mode;AssociationForeignKey:PatientId,ModeId" json:"his_prescription_template"`
479 479
 	HisPrescriptionProject     []*HisPrescriptionProject  `gorm:"ForeignKey:PatientId,schedule_date;AssociationForeignKey:PatientId,RecordDate" json:"his_prescription_project"`
480
+	DialysisSolution           DialysisSolution           `gorm:"ForeignKey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId" json:"dialysis_solution"`
480 481
 }
481 482
 
482 483
 func (VmBloodScheduleTwo) TableName() string {

+ 2 - 2
service/dialysis_solution_service.go View File

@@ -425,7 +425,7 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
425 425
 				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
426 426
 					return db.Where("org_id = ? and status = 1", orgID)
427 427
 				})
428
-			}).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
428
+			}).Preload("DialysisSolution", "status =1 and user_org_id = ? and solution_status=1").Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
429 429
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
430 430
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
431 431
 					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)
@@ -443,7 +443,7 @@ func GetHisPatientDialysisSolutionGroupList(keywords string, limit int64, page i
443 443
 				return db.Where("user_org_id = ? and status = 1 and record_date = ? and type =3", orgID, scheduleDate).Preload("GoodInfo", func(db *gorm.DB) *gorm.DB {
444 444
 					return db.Where("org_id = ? and status = 1", orgID)
445 445
 				})
446
-			}).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
446
+			}).Preload("DialysisSolution", "status =1 and user_org_id = ? and solution_status=1", orgID).Preload("HisPrescriptionTemplateSix", func(db *gorm.DB) *gorm.DB {
447 447
 			return db.Where("user_org_id = ? and status = 1", orgID).Preload("HisPrescriptionInfoTemplateSix", func(db *gorm.DB) *gorm.DB {
448 448
 				return db.Where("user_org_id = ? and status = 1 and type = 2", orgID).Preload("HisPrescriptionProjectTemplateSeven", func(db *gorm.DB) *gorm.DB {
449 449
 					return db.Where("user_org_id = ? and status = 1 and type = 3 and (frequency_type =1 or (frequency_type =2 and day_count >0) or (frequency_type =3 and week_day<>''))", orgID).Preload("GoodInfo", "org_id =? and status = 1", orgID)

+ 1 - 1
service/gobal_config_service.go View File

@@ -665,7 +665,7 @@ func GetAllBaseDrugListTwo(orgid int64) (drug []*models.BaseDrugLibEleven, err e
665 665
 	if orgid > 0 {
666 666
 		db = db.Where("x.org_id =?", orgid)
667 667
 	}
668
-	err = db.Select("x.id,x.drug_name,p.manufacturer_name,x.dose,x.dose_unit,x.min_number,x.max_unit,x.min_unit").Joins("left join xt_manufacturer as p on p.id =x.manufacturer").Scan(&drug).Error
668
+	err = db.Select("x.id,x.drug_name,p.manufacturer_name,x.dose,x.dose_unit,x.min_number,x.max_unit,x.min_unit,x.scan_code,x.drug_identification_code").Joins("left join xt_manufacturer as p on p.id =x.manufacturer").Scan(&drug).Error
669 669
 	return drug, err
670 670
 }
671 671
 

+ 2 - 2
service/mobile_dialysis_service.go View File

@@ -2889,12 +2889,12 @@ func GetDialysisOrderCount(orgID int64, patient_id int64, recordDate int64) (cou
2889 2889
 }
2890 2890
 
2891 2891
 func GetDialysisOrderCountOne(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2892
-	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1640966400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2892
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1704038400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2893 2893
 	return
2894 2894
 }
2895 2895
 
2896 2896
 func GetDialysisOrderCountTwo(orgID int64, patient_id int64, recordDate int64) (count int64, err error) {
2897
-	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1704038400 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2897
+	err = readDb.Model(&models.DialysisOrder{}).Where("dialysis_date>=1735660800 and  dialysis_date <= ? AND status = 1 AND stage = 2 AND user_org_id = ? AND patient_id = ?", recordDate, orgID, patient_id).Count(&count).Error
2898 2898
 	return
2899 2899
 }
2900 2900
 

+ 1 - 1
service/patientmanage_service.go View File

@@ -951,7 +951,7 @@ func GetNewPatient(id int64) (models.XtPatientsNew, error) {
951 951
 
952 952
 func UpdatedPatient(patients models.Patients, id int64) error {
953 953
 
954
-	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan, "patient_type": patients.PatientType}).Error
954
+	err := XTWriteDB().Model(&patients).Where("id=?", id).Update(map[string]interface{}{"name": patients.Name, "gender": patients.Gender, "birthday": patients.Birthday, "age": patients.Age, "phone": patients.Phone, "lapseto": patients.Lapseto, "admission_number": patients.AdmissionNumber, "first_dialysis_date": patients.FirstDialysisDate, "diagnose": patients.Diagnose, "source": patients.Source, "dialysis_no": patients.DialysisNo, "avatar": patients.Avatar, "id_card_no": patients.IdCardNo, "is_infectious": patients.IsInfectious, "out_reason": patients.OutReason, "death_time": patients.DeathTime, "relative_phone": patients.RelativePhone, "sch_remark": patients.SchRemark, "treatment_plan": patients.TreatmentPlan, "patient_type": patients.PatientType, "updated_time": time.Now().Unix()}).Error
955 955
 
956 956
 	return err
957 957
 }

+ 8 - 1
service/pharmacy_service.go View File

@@ -2466,7 +2466,7 @@ func ChangeHisDrugCode(id int64, drug_code string, user_org_id int64) (models.Hi
2466 2466
 
2467 2467
 	err := XTWriteDB().Model(&adviceInfo).Where("id = ? and user_org_id = ? and status =1", id, user_org_id).Updates(map[string]interface{}{"drug_code": drug_code}).Error
2468 2468
 
2469
-	fmt.Println("eeeeeeeeeeeeeeeeeeeeeeeeeeeeee", err)
2469
+	fmt.Println("", err)
2470 2470
 	return adviceInfo, err
2471 2471
 }
2472 2472
 
@@ -2560,3 +2560,10 @@ func DispensingMedicineTwo(orgid, patient_id, advice_date, drug_id, creater int6
2560 2560
 
2561 2561
 	return
2562 2562
 }
2563
+
2564
+func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
2565
+
2566
+	err = XTReadDB().Where("drug_id = ? and advice_date>=? and user_org_id = ? and status=1 and drug_code!=''", drug_id, advice_date, user_org_id).Find(&advice).Error
2567
+
2568
+	return advice, err
2569
+}

+ 2 - 2
service/print_data_service/schedule_dialysis/print_schedule_dialysis_service.go View File

@@ -236,13 +236,13 @@ func GetDialysisOrderCountTen(patient_id int64, recordDate int64) (models.VmDial
236 236
 
237 237
 func GetDialysisOrderCountEight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
238 238
 	order := models.VmDialysisOrder{}
239
-	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1672502400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
239
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1704038400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
240 240
 	return order, err
241 241
 }
242 242
 
243 243
 func GetDialysisOrderCountNight(orgID int64, patient_id int64, recordDate int64) (models.VmDialysisOrder, error) {
244 244
 	order := models.VmDialysisOrder{}
245
-	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1704038400 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
245
+	err := p_service.XTReadDB().Raw("SELECT Count(id) as count,Max(dialysis_date) as dialysis_date  from xt_dialysis_order where dialysis_date>=1735660800 and dialysis_date <= ? AND status = 1 AND stage = 2 AND patient_id = ? and user_org_id = ?", recordDate, patient_id, orgID).Scan(&order).Error
246 246
 	return order, err
247 247
 }
248 248
 

+ 40 - 1
service/stock_service.go View File

@@ -1872,6 +1872,20 @@ func GetNewDrugWarehouseOutIsExit(org_id int64, is_sys int, record_time int64, w
1872 1872
 	return drugWarehouseOut, err
1873 1873
 }
1874 1874
 
1875
+func GetNewDrugWarehouseOutIsExitOne(org_id int64, is_sys int, record_time int64, warehousing_out_order string, tx *gorm.DB, id int64) (models.DrugWarehouseOut, error) {
1876
+
1877
+	drugWarehouseOut := models.DrugWarehouseOut{}
1878
+	err := tx.Where("is_sys = ? AND status = 1 AND org_id = ? AND id = ?", is_sys, org_id, id).Find(&drugWarehouseOut).Error
1879
+	if err != gorm.ErrRecordNotFound {
1880
+		if err != nil {
1881
+			tx.Rollback()
1882
+			return drugWarehouseOut, err
1883
+		}
1884
+	}
1885
+
1886
+	return drugWarehouseOut, err
1887
+}
1888
+
1875 1889
 func AddSigleDrugWarehouseOut(warehouseOut *models.DrugWarehouseOut) error {
1876 1890
 	err := writeDb.Create(&warehouseOut).Error
1877 1891
 	return err
@@ -9108,7 +9122,6 @@ func UpdateNewCheckDrugOut(out models.DrugWarehouseOut, id int64, tx *gorm.DB) e
9108 9122
 		tx.Rollback()
9109 9123
 		return err
9110 9124
 	}
9111
-	tx.Commit()
9112 9125
 	return err
9113 9126
 }
9114 9127
 
@@ -9320,6 +9333,19 @@ func UpdateNewGoodInfoReduceSumCount(goodid int64, sum_count int64, orgid int64,
9320 9333
 
9321 9334
 }
9322 9335
 
9336
+func GetGoodFlowByWarehouseOutId(good_id int64, user_org_id int64, id int64, tx *gorm.DB) (flow []*models.VmStockFlow, err error) {
9337
+
9338
+	err = tx.Where("good_id = ? and user_org_id = ? and warehouse_out_detail_id = ? and status=1", good_id, user_org_id, id).Find(&flow).Error
9339
+
9340
+	if err != gorm.ErrRecordNotFound {
9341
+		if err != nil {
9342
+			tx.Rollback()
9343
+			return flow, err
9344
+		}
9345
+	}
9346
+	return
9347
+}
9348
+
9323 9349
 func UpdateGoodInfoAddSumCount(goodid int64, sum_count int64, orgid int64, sum_in_count int64) error {
9324 9350
 
9325 9351
 	err := XTWriteDB().Model(&models.GoodInfo{}).Where("id = ? and org_id = ? and status = 1", goodid, orgid).Update(map[string]interface{}{"sum_count": sum_count}).Error
@@ -10887,3 +10913,16 @@ func GetDrugWarehouseOutInfoByDrugCode(drug_id int64, patient_id int64, advice_d
10887 10913
 
10888 10914
 	return outinfo, err
10889 10915
 }
10916
+
10917
+func GetNewGoodWarehouseOutInfo(good_id int64, user_org_id int64, warehouse_out_id int64, tx *gorm.DB) (info []*models.WarehouseOutInfo, err error) {
10918
+
10919
+	err = tx.Where("good_id = ? and org_id = ? and warehouse_out_id = ? and status= 1", good_id, user_org_id, warehouse_out_id).Find(&info).Error
10920
+
10921
+	if err != gorm.ErrRecordNotFound {
10922
+		if err != nil {
10923
+			tx.Rollback()
10924
+			return info, err
10925
+		}
10926
+	}
10927
+	return info, err
10928
+}

+ 12 - 9
service/warhouse_service.go View File

@@ -6133,6 +6133,18 @@ func UpdateGoodWarehouseOutById(id int64, warehouse_info_id int64, org_id int64,
6133 6133
 	return err
6134 6134
 }
6135 6135
 
6136
+func GetDrugOutFlowByWarehouseOut(drug_id int64, warehouse_out_detail_id int64, org_id int64, tx *gorm.DB) (flow []*models.DrugFlow, err error) {
6137
+
6138
+	err = tx.Where("drug_id = ? and warehouse_out_detail_id = ? and user_org_id = ? and status=1", drug_id, warehouse_out_detail_id, org_id).Find(&flow).Error
6139
+	if err != gorm.ErrRecordNotFound {
6140
+		if err != nil {
6141
+			tx.Rollback()
6142
+			return flow, err
6143
+		}
6144
+	}
6145
+	return flow, err
6146
+}
6147
+
6136 6148
 func UpdateNewGoodWarehouseOutById(id int64, warehouse_info_id int64, org_id int64, over_count int64, tx *gorm.DB) error {
6137 6149
 
6138 6150
 	err := tx.Model(models.WarehouseOutInfo{}).Where("id = ?  and org_id = ? and status = 1", id, org_id).Update(map[string]interface{}{"warehouse_info_id": warehouse_info_id, "over_count": over_count}).Error
@@ -10904,14 +10916,6 @@ func ConsumablesNewDeliveryThirty(orgID int64, record_time int64, goods *models.
10904 10916
 		//更新出库数量
10905 10917
 		ModifyNewGoodSumCount(goods.StorehouseId, goods.Count, goods.OrgId, goods.GoodId, tx)
10906 10918
 
10907
-		fmt.Println("warehouse.StockCount----------------", warehouse.StockCount)
10908
-		fmt.Println("warehouse.StockCount----------------", maxNumber)
10909
-		//if warehouse.StockCount < maxNumber {
10910
-		//	tx.Rollback()
10911
-		//	return errors.New("库存数量不足")
10912
-		//
10913
-		//}
10914
-
10915 10919
 		return nil
10916 10920
 	} else {
10917 10921
 		// 出库完成后,要将该批次库存清零
@@ -10978,7 +10982,6 @@ func ConsumablesNewDeliveryThirty(orgID int64, record_time int64, goods *models.
10978 10982
 
10979 10983
 		goods.Count = deliver_number - stock_number
10980 10984
 
10981
-		fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", goods.Count)
10982 10985
 		ConsumablesNewDeliveryThirty(orgID, record_time, goods, warehouseOut, count, creator, tx)
10983 10986
 	}
10984 10987
 	return nil