Bladeren bron

历史排班

28169 1 jaar geleden
bovenliggende
commit
56555f08da

BIN
XT_New.exe Bestand weergeven


+ 5 - 5
controllers/base_api_controller.go Bestand weergeven

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

+ 2 - 3
controllers/common_api_controller.go Bestand weergeven

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

+ 1 - 1
controllers/dialysis_api_controller.go Bestand weergeven

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

+ 1 - 1
controllers/doctors_api_controller.go Bestand weergeven

778
 	last_time := this.GetString("last_time")
778
 	last_time := this.GetString("last_time")
779
 	timeLayout := "2006-01-02"
779
 	timeLayout := "2006-01-02"
780
 	loc, _ := time.LoadLocation("Local")
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
 	lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
782
 	lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
783
 	patient_id, _ := this.GetInt64("patient_id")
783
 	patient_id, _ := this.GetInt64("patient_id")
784
 	adminUserInfo := this.GetAdminUserInfo()
784
 	adminUserInfo := this.GetAdminUserInfo()

+ 16 - 16
controllers/his_api_controller.go Bestand weergeven

1918
 		return
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
 	pharmacyConfig, _ := service.FindPharmacyConfig(adminInfo.CurrentOrgId)
1932
 	pharmacyConfig, _ := service.FindPharmacyConfig(adminInfo.CurrentOrgId)
1922
 
1933
 
1923
 	//药品发药出库
1934
 	//药品发药出库
3091
 	var adviceList []models.HisDoctorAdviceInfo
3102
 	var adviceList []models.HisDoctorAdviceInfo
3092
 	var projectList []models.HisPrescriptionProject
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
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3105
 	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3106
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
3106
 		prescriptions, _ := dataBody["prescriptions"].([]interface{})
3107
 
3107
 
3545
 
3545
 
3546
 						if it.CountUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
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
 						if it.CountUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
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
 						if it.CountUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
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
 				if drugOutConfig.IsOpen == 1 {
3567
 				if drugOutConfig.IsOpen == 1 {
3568
 					//出库
3568
 					//出库
3569
 					if drug.IsUse == 2 {
3569
 					if drug.IsUse == 2 {
3570
 						creater := adminInfo.AdminUser.Id
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 Bestand weergeven

1548
 
1548
 
1549
 		recordDialysis, _ := service.GetSigleAssessmentAfterDislysisRecord(assessmentAfterDislysis.PatientId, assessmentAfter.AssessmentDate, assessmentAfter.UserOrgId)
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
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
1557
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
7323
 								Count:                   item.Count,
7325
 								Count:                   item.Count,
7324
 								Price:                   stockInInfo.Price,
7326
 								Price:                   stockInInfo.Price,
7325
 								Status:                  1,
7327
 								Status:                  1,
7326
-								Ctime:                   time.Now().Unix(),
7328
+								Ctime:                   record_time,
7327
 								UserOrgId:               adminInfo.Org.Id,
7329
 								UserOrgId:               adminInfo.Org.Id,
7328
 								Manufacturer:            stockInInfo.Manufacturer,
7330
 								Manufacturer:            stockInInfo.Manufacturer,
7329
 								Dealer:                  stockInInfo.Dealer,
7331
 								Dealer:                  stockInInfo.Dealer,
7357
 									Count:                   exsit.Count - delete_count,
7359
 									Count:                   exsit.Count - delete_count,
7358
 									Price:                   stockInInfo.Price,
7360
 									Price:                   stockInInfo.Price,
7359
 									Status:                  1,
7361
 									Status:                  1,
7360
-									Ctime:                   time.Now().Unix(),
7362
+									Ctime:                   record_time,
7361
 									UserOrgId:               adminInfo.Org.Id,
7363
 									UserOrgId:               adminInfo.Org.Id,
7362
 									Manufacturer:            stockInInfo.Manufacturer,
7364
 									Manufacturer:            stockInInfo.Manufacturer,
7363
 									Dealer:                  stockInInfo.Dealer,
7365
 									Dealer:                  stockInInfo.Dealer,
7485
 									Creator:                 adminInfo.AdminUser.Id,
7487
 									Creator:                 adminInfo.AdminUser.Id,
7486
 									UpdateCreator:           0,
7488
 									UpdateCreator:           0,
7487
 									Status:                  1,
7489
 									Status:                  1,
7488
-									Ctime:                   time.Now().Unix(),
7490
+									Ctime:                   record_time,
7489
 									Mtime:                   0,
7491
 									Mtime:                   0,
7490
 									Price:                   info.Price,
7492
 									Price:                   info.Price,
7491
 									WarehousingDetailId:     info.WarehouseInfotId,
7493
 									WarehousingDetailId:     info.WarehouseInfotId,
9003
 
9005
 
9004
 func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *models.BloodAutomaticReduceDetail, warehouseOut *models.WarehouseOut, patient_id int64, creater int64, count int64) (err error) {
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
 	warehouseOutInfos, err := service.FindStockOutInfoByStockTwo(orgID, good_yc.GoodTypeId, good_yc.GoodId, record_time, good_yc.PatientId)
9009
 	warehouseOutInfos, err := service.FindStockOutInfoByStockTwo(orgID, good_yc.GoodTypeId, good_yc.GoodId, record_time, good_yc.PatientId)
9009
 
9010
 
9087
 			Count:                   count,
9088
 			Count:                   count,
9088
 			Price:                   stockInInfo.Price,
9089
 			Price:                   stockInInfo.Price,
9089
 			Status:                  1,
9090
 			Status:                  1,
9090
-			Ctime:                   time.Now().Unix(),
9091
+			Ctime:                   record_time,
9091
 			UserOrgId:               good_yc.OrgId,
9092
 			UserOrgId:               good_yc.OrgId,
9092
 			Manufacturer:            stockInInfo.Manufacturer,
9093
 			Manufacturer:            stockInInfo.Manufacturer,
9093
 			Dealer:                  stockInInfo.Dealer,
9094
 			Dealer:                  stockInInfo.Dealer,
9193
 		Creator:                 warehouseOut.Creater,
9194
 		Creator:                 warehouseOut.Creater,
9194
 		UpdateCreator:           0,
9195
 		UpdateCreator:           0,
9195
 		Status:                  1,
9196
 		Status:                  1,
9196
-		Ctime:                   time.Now().Unix(),
9197
+		Ctime:                   record_time,
9197
 		Mtime:                   0,
9198
 		Mtime:                   0,
9198
 		Price:                   stockInInfo.Price,
9199
 		Price:                   stockInInfo.Price,
9199
 		WarehousingDetailId:     stockInInfo.ID,
9200
 		WarehousingDetailId:     stockInInfo.ID,

+ 12 - 0
controllers/patient_dataconfig_api_controller.go Bestand weergeven

73
 
73
 
74
 	beego.Router("/api/patient/deletepedpatientfallassment", &PatientDataConfigAPIController{}, "Get:DeletePadPatientFallassment")
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
 type PatientDataConfigAPIController struct {
82
 type PatientDataConfigAPIController struct {
2834
 		"msg": "ok",
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 Bestand weergeven

1229
 	//	service.ModifyPatient(item.PatientId, item.Count)
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
 	for _, item := range list {
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
 	//drugList, _ := service.GetAllBaseDrugList(10571)
1243
 	//drugList, _ := service.GetAllBaseDrugList(10571)
1244
 	//for _, item := range drugList {
1244
 	//for _, item := range drugList {
1245
 	//	//service.UpdateDrugWarehouseInfoByDrug(item.ID, item.MinPrice, item.OrgId)
1245
 	//	//service.UpdateDrugWarehouseInfoByDrug(item.ID, item.MinPrice, item.OrgId)

+ 1 - 2
service/common_service.go Bestand weergeven

991
 }
991
 }
992
 
992
 
993
 func GetQuarterTotalCount(orgid int64, startime int64, endtime int64, lapseto int64, origin int64) (inspection []*models.VmPatientInspectionTwo, err error) {
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
 	db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
995
 	db := XTReadDB().Table("xt_inspection as x ").Where("x.status = 1")
997
 	if orgid > 0 {
996
 	if orgid > 0 {
998
 		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)
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 Bestand weergeven

175
 	return
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
 func FindBaseDrugLibRecordSeven(org_id int64, id int64) (lib models.BaseDrugLibSeven, err error) {
188
 func FindBaseDrugLibRecordSeven(org_id int64, id int64) (lib models.BaseDrugLibSeven, err error) {
179
 	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
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
 	return
190
 	return

+ 13 - 10
service/patient_service.go Bestand weergeven

3296
 func GetAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.NoDoctorAdvice, err error) {
3296
 func GetAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.NoDoctorAdvice, err error) {
3297
 
3297
 
3298
 	db := XTReadDB().Model(advice).Where("status=1 and  execution_state = 2 and advice_type = 2")
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
 	if len(patientIds) > 0 {
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
 func GetHisAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.HisNoDoctorAdvice, err error) {
3317
 func GetHisAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.HisNoDoctorAdvice, err error) {

+ 1 - 1
service/self_drug_service.go Bestand weergeven

3057
 		db = db.Where("storehouse_id = ?", storehouse_id)
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
 	return list, err
3062
 	return list, err
3063
 }
3063
 }

+ 1 - 1
service/sign_service.go Bestand weergeven

2112
 
2112
 
2113
 func GetAllDialysisOrder(user_org_id int64) (list []*models.XtDialysisOrder, err error) {
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
 	return list, err
2117
 	return list, err
2118
 }
2118
 }

+ 55 - 1
service/stock_service.go Bestand weergeven

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
 func UpdateSingleDrugWarehouseOut(id int64, storehouse_id int64) error {
1489
 func UpdateSingleDrugWarehouseOut(id int64, storehouse_id int64) error {
1479
 
1490
 
1480
 	err := XTWriteDB().Model(&models.DrugWarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"storehouse_id": storehouse_id}).Error
1491
 	err := XTWriteDB().Model(&models.DrugWarehouseOut{}).Where("id = ? and status = 1", id).Update(map[string]interface{}{"storehouse_id": storehouse_id}).Error
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
 func FindDrugSettleStockOutByIsSys(org_id int64, is_sys int, record_time int64) (out models.DrugWarehouseOut, err error) {
3210
 func FindDrugSettleStockOutByIsSys(org_id int64, is_sys int, record_time int64) (out models.DrugWarehouseOut, err error) {
3190
 	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
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
 	return
3212
 	return
5560
 func DeleteDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64) error {
5581
 func DeleteDrugAutoWarehouseSeven(drugid int64, patient_id int64, record_time int64, advice_id int64) error {
5561
 
5582
 
5562
 	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
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
 	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
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
 	return err
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
 func GetDrugWarehouseInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
5600
 func GetDrugWarehouseInfoById(id int64) (models.XtDrugWarehouseInfo, error) {
5569
 
5601
 
5570
 	info := models.XtDrugWarehouseInfo{}
5602
 	info := models.XtDrugWarehouseInfo{}
8050
 	return err
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
 func ModifyDrugWarehouseInfoStockMinNumber(count int64, drugid int64, orgid int64, id int64) error {
8096
 func ModifyDrugWarehouseInfoStockMinNumber(count int64, drugid int64, orgid int64, id int64) error {
8054
 
8097
 
8055
 	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
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
 	return err
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
 func ModifyDrugCancelStockInfo(id int64, info *models.DrugCancelStockInfo) error {
8113
 func ModifyDrugCancelStockInfo(id int64, info *models.DrugCancelStockInfo) error {
8060
 
8114
 
8061
 	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
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 Bestand weergeven

7699
 
7699
 
7700
 	return advice, err
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
+}