28169 před 1 měsícem
rodič
revize
56555f08da

binární
XT_New.exe Zobrazit soubor


+ 5 - 5
controllers/base_api_controller.go Zobrazit soubor

@@ -73,7 +73,7 @@ func (this *BaseAuthAPIController) Prepare() {
73 73
 		var userAdmin models.AdminUser
74 74
 		userAdmin.Id = 16919
75 75
 		userAdmin.Mobile = "15717313968"
76
-		userAdmin.Id = 10599 //4,809
76
+		userAdmin.Id = 10489 //4,809
77 77
 		userAdmin.Mobile = "12222222222"
78 78
 		userAdmin.IsSuperAdmin = true
79 79
 		userAdmin.Status = 1
@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 11
84
-		subscibe.OrgId = 10344 //机构id 10344
84
+		subscibe.OrgId = 10489 //机构id 10344
85 85
 		subscibe.PeriodStart = 1547447814
86 86
 		subscibe.PeriodEnd = 1550039814
87 87
 		subscibe.State = 1
@@ -91,7 +91,7 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 10344 //机构id小英9675或4
94
+		adminUserInfo.CurrentOrgId = 10489 //机构id小英9675或4
95 95
 		adminUserInfo.CurrentAppId = 3467  //4
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
@@ -326,7 +326,7 @@ func (this *BaseServeAPIController) Prepare() {
326 326
 		userAdmin.ModifyTime = 1530786071
327 327
 		var subscibe models.ServeSubscibe
328 328
 		subscibe.ID = 11
329
-		subscibe.OrgId = 10344 //机构id小英10344或4
329
+		subscibe.OrgId = 10489 //机构id小英10344或4
330 330
 		subscibe.PeriodStart = 1538035409
331 331
 		subscibe.PeriodEnd = 1569571409
332 332
 		subscibe.State = 1
@@ -336,7 +336,7 @@ func (this *BaseServeAPIController) Prepare() {
336 336
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
337 337
 		subscibes[4] = &subscibe
338 338
 		var adminUserInfo service.AdminUserInfo
339
-		adminUserInfo.CurrentOrgId = 10344 //机构id小英9675或4
339
+		adminUserInfo.CurrentOrgId = 10489 //机构id小英9675或4
340 340
 		adminUserInfo.CurrentAppId = 3467  //4
341 341
 		adminUserInfo.AdminUser = &userAdmin
342 342
 		adminUserInfo.Subscibes = subscibes

+ 2 - 3
controllers/common_api_controller.go Zobrazit soubor

@@ -1113,7 +1113,6 @@ func (this *CommonApiController) GetFirstQuarter() {
1113 1113
 	lapseto, _ := this.GetInt64("lapseto")
1114 1114
 	origin, _ := this.GetInt64("origin")
1115 1115
 
1116
-	fmt.Println("转归", lapseto)
1117 1116
 	startime := this.GetString("startime")
1118 1117
 
1119 1118
 	startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
@@ -1125,10 +1124,10 @@ func (this *CommonApiController) GetFirstQuarter() {
1125 1124
 	endTimeYMDHmsStr := endtime + " 23:59:59"
1126 1125
 	endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
1127 1126
 	entime := endDate.Unix()
1128
-	fmt.Println("结束日期", entime)
1127
+
1129 1128
 	//统计数值类型的数据
1130 1129
 	count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto, origin)
1131
-	fmt.Println("countwowowowoowowowowoww", count)
1130
+
1132 1131
 	//统计rang_type== 2
1133 1132
 	countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto, origin)
1134 1133
 

+ 1 - 1
controllers/dialysis_api_controller.go Zobrazit soubor

@@ -5934,7 +5934,7 @@ func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
5934 5934
 	//获取长期医嘱
5935 5935
 	adviceList, _ := service.GetAllLongAdviceList(orgId)
5936 5936
 
5937
-	longHisAdviceList, _ := service.GetHisLongAdviceList(orgId)
5937
+	longHisAdviceList, _ := service.GetAllHisAdviceTemplateList(orgId)
5938 5938
 
5939 5939
 	_, config := service.FindXTHisRecordByOrgId(orgId)
5940 5940
 

+ 1 - 1
controllers/doctors_api_controller.go Zobrazit soubor

@@ -778,7 +778,7 @@ func (this *DoctorsApiController) GetInspectionMajorItem() {
778 778
 	last_time := this.GetString("last_time")
779 779
 	timeLayout := "2006-01-02"
780 780
 	loc, _ := time.LoadLocation("Local")
781
-	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
781
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+"23:59:59", loc)
782 782
 	lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
783 783
 	patient_id, _ := this.GetInt64("patient_id")
784 784
 	adminUserInfo := this.GetAdminUserInfo()

+ 16 - 16
controllers/his_api_controller.go Zobrazit soubor

@@ -1918,6 +1918,17 @@ func (c *HisApiController) CreateHisPrescription() {
1918 1918
 		return
1919 1919
 	}
1920 1920
 
1921
+	// 开始主事务
1922
+	db := service.XTWriteDB()
1923
+	tx := db.Begin()
1924
+
1925
+	// 在函数结束时处理事务回滚
1926
+	defer func() {
1927
+		if r := recover(); r != nil {
1928
+			tx.Rollback()
1929
+		}
1930
+	}()
1931
+
1921 1932
 	pharmacyConfig, _ := service.FindPharmacyConfig(adminInfo.CurrentOrgId)
1922 1933
 
1923 1934
 	//药品发药出库
@@ -3091,17 +3102,6 @@ func (c *HisApiController) CreateHisPrescription() {
3091 3102
 	var adviceList []models.HisDoctorAdviceInfo
3092 3103
 	var projectList []models.HisPrescriptionProject
3093 3104
 
3094
-	// 开始主事务
3095
-	db := service.XTWriteDB()
3096
-	tx := db.Begin()
3097
-
3098
-	// 在函数结束时处理事务回滚
3099
-	defer func() {
3100
-		if r := recover(); r != nil {
3101
-			tx.Rollback()
3102
-		}
3103
-	}()
3104
-
3105 3105
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3106 3106
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
3107 3107
 
@@ -3545,30 +3545,30 @@ func (c *HisApiController) CreateHisPrescription() {
3545 3545
 
3546 3546
 						if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
3547 3547
 
3548
-							service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3548
+							service.ModifyNewDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3549 3549
 
3550 3550
 						}
3551 3551
 						if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
3552 3552
 
3553
-							service.ModifyDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3553
+							service.ModifyNewDrugWarehouseInfoStockMinNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3554 3554
 
3555 3555
 						}
3556 3556
 						if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
3557 3557
 
3558
-							service.ModifyDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId)
3558
+							service.ModifyNewDrugWarehouseInfoStockMaxNumber(it.Count, it.DrugId, it.OrgId, it.WarehouseInfoId, tx)
3559 3559
 
3560 3560
 						}
3561 3561
 					}
3562 3562
 				}
3563 3563
 
3564 3564
 				//删除记录
3565
-				service.DeleteDrugAutoWarehouseSeven(item.DrugId, patient_id, recordDateTime, item.ID)
3565
+				service.DeleteNewDrugAutoWarehouseSeven(item.DrugId, patient_id, recordDateTime, item.ID, tx)
3566 3566
 				//查询最后一次数据
3567 3567
 				if drugOutConfig.IsOpen == 1 {
3568 3568
 					//出库
3569 3569
 					if drug.IsUse == 2 {
3570 3570
 						creater := adminInfo.AdminUser.Id
3571
-						service.HisDrugsDelivery(item.UserOrgId, creater, item)
3571
+						service.NewHisDrugsDelivery(item.UserOrgId, creater, item, tx)
3572 3572
 
3573 3573
 					}
3574 3574
 

+ 9 - 8
controllers/mobile_api_controllers/dialysis_api_controller.go Zobrazit soubor

@@ -1548,8 +1548,10 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1548 1548
 
1549 1549
 		recordDialysis, _ := service.GetSigleAssessmentAfterDislysisRecord(assessmentAfterDislysis.PatientId, assessmentAfter.AssessmentDate, assessmentAfter.UserOrgId)
1550 1550
 
1551
-		if assessmentAfterDislysis.WeightAfter == 0 {
1552
-			assessmentAfterDislysis.WeightAfter = recordDialysis.WeightAfter
1551
+		if assessmentAfterDislysis.UserOrgId != 10340 {
1552
+			if assessmentAfterDislysis.WeightAfter == 0 {
1553
+				assessmentAfterDislysis.WeightAfter = recordDialysis.WeightAfter
1554
+			}
1553 1555
 		}
1554 1556
 
1555 1557
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
@@ -7323,7 +7325,7 @@ func (c *DialysisAPIController) EditConsumables() {
7323 7325
 								Count:                   item.Count,
7324 7326
 								Price:                   stockInInfo.Price,
7325 7327
 								Status:                  1,
7326
-								Ctime:                   time.Now().Unix(),
7328
+								Ctime:                   record_time,
7327 7329
 								UserOrgId:               adminInfo.Org.Id,
7328 7330
 								Manufacturer:            stockInInfo.Manufacturer,
7329 7331
 								Dealer:                  stockInInfo.Dealer,
@@ -7357,7 +7359,7 @@ func (c *DialysisAPIController) EditConsumables() {
7357 7359
 									Count:                   exsit.Count - delete_count,
7358 7360
 									Price:                   stockInInfo.Price,
7359 7361
 									Status:                  1,
7360
-									Ctime:                   time.Now().Unix(),
7362
+									Ctime:                   record_time,
7361 7363
 									UserOrgId:               adminInfo.Org.Id,
7362 7364
 									Manufacturer:            stockInInfo.Manufacturer,
7363 7365
 									Dealer:                  stockInInfo.Dealer,
@@ -7485,7 +7487,7 @@ func (c *DialysisAPIController) EditConsumables() {
7485 7487
 									Creator:                 adminInfo.AdminUser.Id,
7486 7488
 									UpdateCreator:           0,
7487 7489
 									Status:                  1,
7488
-									Ctime:                   time.Now().Unix(),
7490
+									Ctime:                   record_time,
7489 7491
 									Mtime:                   0,
7490 7492
 									Price:                   info.Price,
7491 7493
 									WarehousingDetailId:     info.WarehouseInfotId,
@@ -9003,7 +9005,6 @@ func (this *DialysisAPIController) GetRoleList() {
9003 9005
 
9004 9006
 func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *models.BloodAutomaticReduceDetail, warehouseOut *models.WarehouseOut, patient_id int64, creater int64, count int64) (err error) {
9005 9007
 
9006
-	fmt.Println("退库222322232322332232332322332232332233wo", good_yc.GoodId)
9007 9008
 	// 先根据相关信息查询当天该耗材的出库信息
9008 9009
 	warehouseOutInfos, err := service.FindStockOutInfoByStockTwo(orgID, good_yc.GoodTypeId, good_yc.GoodId, record_time, good_yc.PatientId)
9009 9010
 
@@ -9087,7 +9088,7 @@ func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *model
9087 9088
 			Count:                   count,
9088 9089
 			Price:                   stockInInfo.Price,
9089 9090
 			Status:                  1,
9090
-			Ctime:                   time.Now().Unix(),
9091
+			Ctime:                   record_time,
9091 9092
 			UserOrgId:               good_yc.OrgId,
9092 9093
 			Manufacturer:            stockInInfo.Manufacturer,
9093 9094
 			Dealer:                  stockInInfo.Dealer,
@@ -9193,7 +9194,7 @@ func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *model
9193 9194
 		Creator:                 warehouseOut.Creater,
9194 9195
 		UpdateCreator:           0,
9195 9196
 		Status:                  1,
9196
-		Ctime:                   time.Now().Unix(),
9197
+		Ctime:                   record_time,
9197 9198
 		Mtime:                   0,
9198 9199
 		Price:                   stockInInfo.Price,
9199 9200
 		WarehousingDetailId:     stockInInfo.ID,

+ 12 - 0
controllers/patient_dataconfig_api_controller.go Zobrazit soubor

@@ -73,6 +73,10 @@ func PatientDataConfigAPIControllerRegistRouters() {
73 73
 
74 74
 	beego.Router("/api/patient/deletepedpatientfallassment", &PatientDataConfigAPIController{}, "Get:DeletePadPatientFallassment")
75 75
 
76
+	beego.Router("/api/patient/savepatientpressuresore", &PatientDataConfigAPIController{}, "Post:SavePatientPressuresore")
77
+
78
+	beego.Router("/api/patient/savepatienthpressuresore", &PatientDataConfigAPIController{}, "Post:SavePatientHpPressuresore")
79
+
76 80
 }
77 81
 
78 82
 type PatientDataConfigAPIController struct {
@@ -2834,3 +2838,11 @@ func (this *PatientDataConfigAPIController) DeletePadPatientFallassment() {
2834 2838
 		"msg": "ok",
2835 2839
 	})
2836 2840
 }
2841
+
2842
+func (this *PatientDataConfigAPIController) SavePatientPressuresore() {
2843
+
2844
+}
2845
+
2846
+func (this *PatientDataConfigAPIController) SavePatientHpPressuresore() {
2847
+
2848
+}

+ 7 - 7
controllers/sign_api_controller.go Zobrazit soubor

@@ -1229,17 +1229,17 @@ func (this *SignApiController) ToAutoDiagnose() {
1229 1229
 	//	service.ModifyPatient(item.PatientId, item.Count)
1230 1230
 	//}
1231 1231
 
1232
-	list, _ := service.GetNewAllpatient(orgId)
1232
+	//list, _ := service.GetNewAllpatient(orgId)
1233
+	//
1234
+	//for _, item := range list {
1235
+	//	service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
1236
+	//}
1233 1237
 
1238
+	list, _ := service.GetAllDialysisOrder(6963)
1234 1239
 	for _, item := range list {
1235
-		service.UpdateAllPatient(item.BloodId, item.Diagnose, item.UserOrgId)
1240
+		service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, orgId, item.BedId, item.ZoneId, item.SchedualType)
1236 1241
 	}
1237 1242
 
1238
-	//list, _ := service.GetAllDialysisOrder(10579)
1239
-	//for _, item := range list {
1240
-	//	service.UpdateScheduleByOrder(item.PatientId, item.DialysisDate, 10579, item.BedId, item.ZoneId, item.SchedualType)
1241
-	//}
1242
-
1243 1243
 	//drugList, _ := service.GetAllBaseDrugList(10571)
1244 1244
 	//for _, item := range drugList {
1245 1245
 	//	//service.UpdateDrugWarehouseInfoByDrug(item.ID, item.MinPrice, item.OrgId)

+ 1 - 2
service/common_service.go Zobrazit soubor

@@ -991,8 +991,7 @@ func GetFirstQuarter(orgid int64, startime int64, endtime int64) (inspection []*
991 991
 }
992 992
 
993 993
 func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (inspection []*models.VmPatientInspectionTwo, err error) {
994
-	fmt.Println(lapseto)
995
-	fmt.Println(origin)
994
+
996 995
 	db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
997 996
 	if orgid > 0 {
998 997
 		db = db.Where("x.org_id = ? and x.inspect_value+0 <> 0 and r.range_type = 1 and q.user_org_id = ? and q.is_status = 1", orgid, orgid)

+ 10 - 0
service/manage_center_service.go Zobrazit soubor

@@ -175,6 +175,16 @@ func FindBaseDrugLibRecord(org_id int64, id int64) (lib models.BaseDrugLib, err
175 175
 	return
176 176
 }
177 177
 
178
+func FindNewBaseDrugLibRecord(org_id int64, id int64, tx *gorm.DB) (lib models.BaseDrugLib, err error) {
179
+	err = readDb.Model(&models.BaseDrugLib{}).Where("id = ? AND org_id = ?  AND status = 1", id, org_id).First(&lib).Error
180
+	if err != nil {
181
+		tx.Rollback()
182
+		return
183
+	}
184
+	tx.Commit()
185
+	return lib, err
186
+}
187
+
178 188
 func FindBaseDrugLibRecordSeven(org_id int64, id int64) (lib models.BaseDrugLibSeven, err error) {
179 189
 	err = readDb.Select("id,drug_name,max_unit,min_number,min_unit,sum_count,is_user,is_pharmacy").Where("org_id = ? AND id = ? AND status = 1", org_id, id).First(&lib).Error
180 190
 	return

+ 13 - 10
service/patient_service.go Zobrazit soubor

@@ -3296,19 +3296,22 @@ func GetDialysisOrderNoExecution(start_nurse int64, user_org_id int64, timenow i
3296 3296
 func GetAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.NoDoctorAdvice, err error) {
3297 3297
 
3298 3298
 	db := XTReadDB().Model(advice).Where("status=1 and  execution_state = 2 and advice_type = 2")
3299
-
3300
-	if advice_date > 0 {
3301
-		db = db.Where("advice_date= ?", advice_date)
3302
-	}
3303
-	if user_org_id > 0 {
3304
-		db = db.Where("user_org_id =?", user_org_id)
3305
-	}
3306 3299
 	if len(patientIds) > 0 {
3307
-		db = db.Where("patient_id in(?)", patientIds)
3300
+		if advice_date > 0 {
3301
+			db = db.Where("advice_date= ?", advice_date)
3302
+		}
3303
+		if user_org_id > 0 {
3304
+			db = db.Where("user_org_id =?", user_org_id)
3305
+		}
3306
+		if len(patientIds) > 0 {
3307
+			db = db.Where("patient_id in(?)", patientIds)
3308
+		}
3309
+		err = db.Select("patient_id,Count(id) as count,advice_date").Group("patient_id").Find(&advice).Error
3310
+		return advice, err
3311
+	} else {
3312
+		return advice, err
3308 3313
 	}
3309 3314
 
3310
-	err = db.Select("patient_id,Count(id) as count,advice_date").Group("patient_id").Find(&advice).Error
3311
-	return advice, err
3312 3315
 }
3313 3316
 
3314 3317
 func GetHisAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.HisNoDoctorAdvice, err error) {

+ 1 - 1
service/self_drug_service.go Zobrazit soubor

@@ -3057,7 +3057,7 @@ func GetInitOutBanceList(good_id int64, user_org_id int64, start_time int64, end
3057 3057
 		db = db.Where("storehouse_id = ?", storehouse_id)
3058 3058
 	}
3059 3059
 
3060
-	err = db.Find(&list).Error
3060
+	err = db.Group("patient_id,good_id,sys_record_time,is_sys").Find(&list).Error
3061 3061
 
3062 3062
 	return list, err
3063 3063
 }

+ 1 - 1
service/sign_service.go Zobrazit soubor

@@ -2112,7 +2112,7 @@ func UpdateAllPatient(id int64, diagose string, orgid int64) error {
2112 2112
 
2113 2113
 func GetAllDialysisOrder(user_org_id int64) (list []*models.XtDialysisOrder, err error) {
2114 2114
 
2115
-	err = XTReadDB().Where("user_org_id = ? and dialysis_date =?", 10579, 1701360000).Find(&list).Error
2115
+	err = XTReadDB().Where("patient_id = ? and status =1", 6963).Find(&list).Error
2116 2116
 
2117 2117
 	return list, err
2118 2118
 }

+ 55 - 1
service/stock_service.go Zobrazit soubor

@@ -1475,6 +1475,17 @@ func AddSigleDrugWarehouseOut(warehouseOut *models.DrugWarehouseOut) error {
1475 1475
 
1476 1476
 }
1477 1477
 
1478
+func AddNewSigleDrugWarehouseOut(warehouseOut *models.DrugWarehouseOut, tx *gorm.DB) error {
1479
+	err := tx.Create(&warehouseOut).Error
1480
+	if err != nil {
1481
+		tx.Rollback()
1482
+		return err
1483
+	}
1484
+	tx.Commit()
1485
+	return err
1486
+
1487
+}
1488
+
1478 1489
 func UpdateSingleDrugWarehouseOut(id int64, storehouse_id int64) error {
1479 1490
 
1480 1491
 	err := XTWriteDB().Model(&models.DrugWarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"storehouse_id": storehouse_id}).Error
@@ -3186,6 +3197,16 @@ func FindDrugStockOutByIsSys(org_id int64, is_sys int, record_time int64) (out m
3186 3197
 
3187 3198
 }
3188 3199
 
3200
+func FindNewDrugStockOutByIsSys(org_id int64, is_sys int, record_time int64, tx *gorm.DB) (out models.DrugWarehouseOut, err error) {
3201
+	err = tx.Model(&models.DrugWarehouseOut{}).Where("is_sys = ? AND status = 1 AND org_id = ? AND warehouse_out_time = ?", is_sys, org_id, record_time).First(&out).Error
3202
+	if err != nil {
3203
+		tx.Rollback()
3204
+		return
3205
+	}
3206
+	tx.Commit()
3207
+	return out, err
3208
+}
3209
+
3189 3210
 func FindDrugSettleStockOutByIsSys(org_id int64, is_sys int, record_time int64) (out models.DrugWarehouseOut, err error) {
3190 3211
 	err = readDb.Model(&models.DrugWarehouseOut{}).Where("is_sys = ? AND status = 1 AND org_id = ? AND warehouse_out_time = ?", is_sys, org_id, record_time).First(&out).Error
3191 3212
 	return
@@ -5560,11 +5581,22 @@ func DeleteDrugAutoWarehouse(drugid int64, patient_id int64, record_time int64)
5560 5581
 func DeleteDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64) error {
5561 5582
 
5562 5583
 	err := XTWriteDB().Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5563
-	//err = XTWriteDB().Model(models.DrugWarehouseOutInfo{}).Where("drug_id = ? and patient_id = ? and sys_record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5564 5584
 	err = XTWriteDB().Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5565 5585
 	return err
5566 5586
 }
5567 5587
 
5588
+func DeleteNewDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64, tx *gorm.DB) error {
5589
+
5590
+	err := tx.Model(models.DrugAutomaticReduceDetail{}).Where("drug_id = ? and patient_id = ? and record_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5591
+	err = tx.Model(models.DrugFlow{}).Where("drug_id = ? and patient_id = ? and system_time = ? and status = 1 and advice_id = ?", drugid, patient_id, record_time, advice_id).Updates(map[string]interface{}{"status": 0}).Error
5592
+	if err != nil {
5593
+		tx.Rollback()
5594
+		return err
5595
+	}
5596
+	tx.Commit()
5597
+	return err
5598
+}
5599
+
5568 5600
 func GetDrugWarehouseInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
5569 5601
 
5570 5602
 	info := models.XtDrugWarehouseInfo{}
@@ -8050,12 +8082,34 @@ func ModifyDrugWarehouseInfoStockMaxNumber(count int64, drugid int64, orgid int6
8050 8082
 	return err
8051 8083
 }
8052 8084
 
8085
+func ModifyNewDrugWarehouseInfoStockMaxNumber(count int64, drugid int64, orgid int64, id int64, tx *gorm.DB) error {
8086
+
8087
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and drug_id = ? and status = 1", id, orgid, drugid).UpdateColumn("stock_max_number", gorm.Expr("stock_max_number + ?", count)).Error
8088
+	if err != nil {
8089
+		tx.Rollback()
8090
+		return err
8091
+	}
8092
+	tx.Commit()
8093
+	return err
8094
+}
8095
+
8053 8096
 func ModifyDrugWarehouseInfoStockMinNumber(count int64, drugid int64, orgid int64, id int64) error {
8054 8097
 
8055 8098
 	err = XTWriteDB().Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and drug_id = ? and status = 1", id, orgid, drugid).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
8056 8099
 	return err
8057 8100
 }
8058 8101
 
8102
+func ModifyNewDrugWarehouseInfoStockMinNumber(count int64, drugid int64, orgid int64, id int64, tx *gorm.DB) error {
8103
+
8104
+	err = tx.Model(&models.DrugWarehouseInfo{}).Where("id = ? and org_id = ? and drug_id = ? and status = 1", id, orgid, drugid).UpdateColumn("stock_min_number", gorm.Expr("stock_min_number + ?", count)).Error
8105
+	if err != nil {
8106
+		tx.Rollback()
8107
+		return err
8108
+	}
8109
+	tx.Commit()
8110
+	return err
8111
+}
8112
+
8059 8113
 func ModifyDrugCancelStockInfo(id int64, info *models.DrugCancelStockInfo) error {
8060 8114
 
8061 8115
 	err := XTWriteDB().Model(&models.DrugCancelStockInfo{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"drug_id": info.DrugId, "count": info.Count, "price": info.Price, "total": info.Total, "product_date": info.ProductDate, "expiry_date": info.ExpiryDate, "dealer": info.Dealer, "manufacturer": info.Manufacturer, "retail_price": info.RetailPrice, "retail_total_price": info.RetailTotalPrice, "number": info.Number, "register_account": info.RegisterAccount, "remark": info.Remark, "batch_number": info.BatchNumber, "max_unit": info.MaxUnit, "batch_number_id": info.BatchNumberId, "storehouse_id": info.StorehouseId}).Error

+ 70 - 0
service/warhouse_service.go Zobrazit soubor

@@ -7699,3 +7699,73 @@ func GetAdviceIsOut(advice_id int64, user_org_id int64, patient_id int64, advice
7699 7699
 
7700 7700
 	return advice, err
7701 7701
 }
7702
+
7703
+// 药品出库
7704
+
7705
+func NewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoctorAdviceInfo, tx *gorm.DB) (err error) {
7706
+
7707
+	// 1.判断药品是否来自专用字典的药品库
7708
+	// 2.判断当天当前机构有没有创建出库单,没有则创建
7709
+	// 3.创建出库流程
7710
+	// 3.1 实现先进先出逻辑 由于药品执行后,不可以修改和删除,所以不考虑出库后的退库和修改出库数量等
7711
+
7712
+	isHasWay := false
7713
+	record_time := int64(0)
7714
+	isHasWay = true
7715
+	record_time = advice.RecordDate
7716
+
7717
+	if isHasWay {
7718
+		//判断当天当前机构有没有创建出库单,没有则创建
7719
+		out, err := FindNewDrugStockOutByIsSys(orgID, 1, record_time, tx)
7720
+
7721
+		houseConfig, _ := GetAllStoreHouseConfig(orgID)
7722
+		if err == gorm.ErrRecordNotFound {
7723
+			timeStr := time.Now().Format("2006-01-02")
7724
+			timeArr := strings.Split(timeStr, "-")
7725
+			total, _ := FindAllDrugWarehouseOut(orgID)
7726
+			total = total + 1
7727
+			warehousing_out_order := strconv.FormatInt(orgID, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
7728
+			number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
7729
+			number = number + total
7730
+			warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
7731
+
7732
+			warehouseOut := models.DrugWarehouseOut{
7733
+				WarehouseOutOrderNumber: warehousing_out_order,
7734
+				OperationTime:           time.Now().Unix(),
7735
+				OrgId:                   orgID,
7736
+				Creater:                 creater,
7737
+				Ctime:                   time.Now().Unix(),
7738
+				Status:                  1,
7739
+				WarehouseOutTime:        record_time,
7740
+				Dealer:                  0,
7741
+				Manufacturer:            0,
7742
+				Type:                    1,
7743
+				IsSys:                   1,
7744
+				StorehouseId:            houseConfig.DrugStorehouseOut,
7745
+				IsCheck:                 1,
7746
+			}
7747
+			err := AddNewSigleDrugWarehouseOut(&warehouseOut, tx)
7748
+			if err != nil {
7749
+				utils.TraceLog("创建出库单失败 err = %v", err)
7750
+				return err
7751
+			} else {
7752
+				out = warehouseOut
7753
+			}
7754
+		}
7755
+
7756
+		// 出库流程
7757
+		// 1.查询改药品在药品库的规格信息,并将处方里的规格进行换算(尽量将拆零单位转换成包装单位)
7758
+		drup, _ := FindNewBaseDrugLibRecord(orgID, advice.DrugId, tx)
7759
+		if drup.ID > 0 {
7760
+			prescribingNumber := advice.PrescribingNumber
7761
+
7762
+			BloodHisDrugDeliverInfo(orgID, prescribingNumber, &out, &drup, advice, prescribingNumber, advice.PrescribingNumberUnit)
7763
+
7764
+		} else {
7765
+			return errors.New("药品信息不存在")
7766
+		}
7767
+
7768
+	}
7769
+
7770
+	return
7771
+}