Procházet zdrojové kódy

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

陈少旭 před 3 měsíci
rodič
revize
8f7c764d69

+ 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 = 16919 //4,809
76
+		userAdmin.Id = 10612 //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 = 10612 //机构id 10344
84
+		subscibe.OrgId = 10460 //机构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 = 10612 //机构id小英9675或4
94
+		adminUserInfo.CurrentOrgId = 10460 //机构id小英9675或4
95 95
 		adminUserInfo.CurrentAppId = 17282 //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 = 10612 //机构id小英10344或4
329
+		subscibe.OrgId = 10460 //机构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 = 10612 //机构id小英9675或4
339
+		adminUserInfo.CurrentOrgId = 10460 //机构id小英9675或4
340 340
 		adminUserInfo.CurrentAppId = 17282 //4
341 341
 		adminUserInfo.AdminUser = &userAdmin
342 342
 		adminUserInfo.Subscibes = subscibes

+ 1 - 0
controllers/dialysis_api_controller.go Zobrazit soubor

@@ -2149,6 +2149,7 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
2149 2149
 	assessment.AccumulatedBloodVolume = data.AccumulatedBloodVolume
2150 2150
 	assessment.TransfusionVolume = data.TransfusionVolume
2151 2151
 	assessment.Condenser = data.Condenser
2152
+	assessment.LastAfterWeight = data.LastAfterWeight
2152 2153
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
2153 2154
 
2154 2155
 	if assessment.ID > 0 {

+ 12 - 2
controllers/doctor_schedule_api_controller.go Zobrazit soubor

@@ -38,6 +38,8 @@ func DoctorScheduleRouters() {
38 38
 	beego.Router("/api/schedule/changeoption", &DoctorScheduleApiController{}, "Get:ChangeOption")
39 39
 	beego.Router("/api/schedule/getchartlist", &DoctorScheduleApiController{}, "Get:GetChartlist")
40 40
 
41
+	beego.Router("/api/deletestaffschedulebyid", &DoctorScheduleApiController{}, "Get:DeleteStaffScheduleById")
42
+
41 43
 }
42 44
 
43 45
 func (this *DoctorScheduleApiController) SaveDoctorSchedules() {
@@ -335,9 +337,7 @@ func (this *DoctorScheduleApiController) AddSchedule() {
335 337
 func (this *DoctorScheduleApiController) GetStaffScheduleList() {
336 338
 
337 339
 	start_time, _ := this.GetInt64("start_time")
338
-	fmt.Println("start_time", start_time)
339 340
 	end_time, _ := this.GetInt64("end_time")
340
-	fmt.Println("end_time", end_time)
341 341
 	orgId := this.GetAdminUserInfo().CurrentOrgId
342 342
 	staffList, err := service.GetStaffScheduleList(orgId, start_time, end_time)
343 343
 	if err != nil {
@@ -656,3 +656,13 @@ func (this *DoctorScheduleApiController) GetChartlist() {
656 656
 		"workDaylist": workDaylist,
657 657
 	})
658 658
 }
659
+
660
+func (this *DoctorScheduleApiController) DeleteStaffScheduleById() {
661
+
662
+	id, _ := this.GetInt64("id")
663
+	orgId := this.GetAdminUserInfo().CurrentOrgId
664
+	service.DeleteStaffScheduleById(id, orgId)
665
+	this.ServeSuccessJSON(map[string]interface{}{
666
+		"msg": "ok",
667
+	})
668
+}

+ 48 - 3
controllers/his_api_controller.go Zobrazit soubor

@@ -1941,11 +1941,16 @@ func (c *HisApiController) CreateHisPrescription() {
1941 1941
 								//查询该药品是否存在开药记录
1942 1942
 								advicelist, _ := service.GetHisAdviceListByDrugIdEight(drug_id, patient_id, recordDateTime, adviceId)
1943 1943
 
1944
+								fmt.Println("wooooooooooooo", advicelist.ID)
1945
+								fmt.Println("prescribingNumberUnit", prescribingNumberUnit)
1946
+								fmt.Println("prescribingNumberUnit", drug.MinUnit)
1947
+								fmt.Println("prescribingNumberUnit", drug.MaxUnit)
1944 1948
 								//新增处方
1945 1949
 								if advicelist.ID == 0 {
1946 1950
 									all_count, _ := strconv.ParseFloat(totals, 64)
1947 1951
 									if prescribingNumberUnit == drug.MinUnit {
1948
-
1952
+										fmt.Println("prescribing_number", prescribing_number)
1953
+										fmt.Println("all_count", all_count)
1949 1954
 										if drug.IsUse != 1 {
1950 1955
 											if drug.IsProject == 0 || drug.IsProject == 2 {
1951 1956
 												if all_count == 0 {
@@ -2403,7 +2408,7 @@ func (c *HisApiController) CreateHisPrescription() {
2403 2408
 															var sum_in_count int64
2404 2409
 															warehouseInfo, _ := service.FindLastDrugWarehousingInfoByID(drug_id, storeConfig.DrugStorehouseOut)
2405 2410
 															sum_in_count = warehouseInfo.StockMaxNumber*drug.MinNumber + warehouseInfo.StockMinNumber
2406
-
2411
+															fmt.Println("sum_in_count", sum_in_count)
2407 2412
 															//如果修改的数量大于有库存的第一个批次
2408 2413
 															if number_count > sum_in_count {
2409 2414
 																c.ServeDynamicFailJsonSend(drug.DrugName + "该批次剩余库存不足,剩余库存:" + strconv.FormatInt(warehouseInfo.StockMaxNumber, 10) + drug.MaxUnit + strconv.FormatInt(warehouseInfo.StockMinNumber, 10) + drug.MinUnit)
@@ -9184,7 +9189,7 @@ func (c *HisApiController) GetFaPiaoData() {
9184 9189
 		"name":                                order.PsnName,            //姓名
9185 9190
 		"gender":                              patient.Gender,           //性别
9186 9191
 		"psn_cash_money":                      order.PsnCashPay,         //个人支付
9187
-		"pay_way":                             "门诊",                     //结算方式
9192
+		"pay_way":                             "门诊",                   //结算方式
9188 9193
 		"medfee_sumamt":                       order.MedfeeSumamt,       //总费用
9189 9194
 		"admin_user_name":                     admin.UserName,           //收款员
9190 9195
 		"order":                               order,
@@ -10889,12 +10894,25 @@ func (c *HisApiController) GetHisMonthChargePatientInfo() {
10889 10894
 	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
10890 10895
 	patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfo(admin.CurrentOrgId, patient_id, recordDateTime, p_type, his_patient_id)
10891 10896
 
10897
+	month_p_info, _ := service.FindPatientPrescriptionInfoTen(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
10898
+
10892 10899
 	lastPatientPrescriptionInfo, _ := service.FindLastPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
10893 10900
 
10894 10901
 	doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
10895 10902
 	//获取所有科室信息
10896 10903
 	department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
10897 10904
 
10905
+	var dia string
10906
+	for _, item := range month_p_info {
10907
+		if len(dia) == 0 {
10908
+			dia = item.Diagnosis
10909
+		} else {
10910
+			dia = dia + "," + item.Diagnosis
10911
+		}
10912
+	}
10913
+
10914
+	dia_arr := removeDuplicates(strings.Split(dia, ","))
10915
+	dia_arr = removeEmptyStrings(dia_arr)
10898 10916
 	c.ServeSuccessJSON(map[string]interface{}{
10899 10917
 		"his_info":            his_patient_info,
10900 10918
 		"xt_info":             xt_patient_info,
@@ -10906,10 +10924,37 @@ func (c *HisApiController) GetHisMonthChargePatientInfo() {
10906 10924
 		"doctors":             doctors,
10907 10925
 		"department":          department,
10908 10926
 		"settle_total":        settle_total,
10927
+		"dia_arr":             dia_arr,
10909 10928
 	})
10910 10929
 	return
10911 10930
 }
10912 10931
 
10932
+func removeEmptyStrings(input []string) []string {
10933
+	var output []string
10934
+
10935
+	for _, s := range input {
10936
+		if s != "" {
10937
+			output = append(output, s)
10938
+		}
10939
+	}
10940
+
10941
+	return output
10942
+}
10943
+
10944
+func removeDuplicates(input []string) []string {
10945
+	seen := make(map[string]bool)
10946
+	output := []string{}
10947
+
10948
+	for _, s := range input {
10949
+		if _, exists := seen[s]; !exists {
10950
+			seen[s] = true
10951
+			output = append(output, s)
10952
+		}
10953
+	}
10954
+
10955
+	return output
10956
+}
10957
+
10913 10958
 func (c *HisApiController) GetHisMonthPatientInfo() {
10914 10959
 	patient_id, _ := c.GetInt64("patient_id")
10915 10960
 	his_patient_id, _ := c.GetInt64("his_patient_id")

+ 8 - 8
controllers/inspection_api_controller.go Zobrazit soubor

@@ -152,17 +152,17 @@ func (c *InspectionApiController) PatientInspectionReference() {
152 152
 	referenceMap := make(map[string]*models.InspectionReferenceMap, 0)
153 153
 
154 154
 	for _, reference := range references {
155
-		if _, exist := referenceMap[reference.Project]; !exist {
156
-			referenceMap[reference.Project] = new(models.InspectionReferenceMap)
157
-			referenceMap[reference.Project].Project = reference.Project
158
-			referenceMap[reference.Project].ProjectId = reference.ProjectId
159
-			referenceMap[reference.Project].ProjectName = reference.ProjectName
155
+		if _, exist := referenceMap[reference.ProjectName]; !exist {
156
+			referenceMap[reference.ProjectName] = new(models.InspectionReferenceMap)
157
+			referenceMap[reference.ProjectName].Project = reference.Project
158
+			referenceMap[reference.ProjectName].ProjectId = reference.ProjectId
159
+			referenceMap[reference.ProjectName].ProjectName = reference.ProjectName
160 160
 			if _, cexit := countsMap[reference.ProjectId]; cexit {
161
-				referenceMap[reference.Project].Count = countsMap[reference.ProjectId]
161
+				referenceMap[reference.ProjectName].Count = countsMap[reference.ProjectId]
162 162
 			}
163
-			referenceMap[reference.Project].InspectionReference = make([]models.InspectionReference, 0)
163
+			referenceMap[reference.ProjectName].InspectionReference = make([]models.InspectionReference, 0)
164 164
 		}
165
-		referenceMap[reference.Project].InspectionReference = append(referenceMap[reference.Project].InspectionReference, *reference)
165
+		referenceMap[reference.ProjectName].InspectionReference = append(referenceMap[reference.ProjectName].InspectionReference, *reference)
166 166
 
167 167
 	}
168 168
 

+ 43 - 9
controllers/mobile_api_controllers/check_weight_api_controller.go Zobrazit soubor

@@ -545,8 +545,21 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
545 545
 					lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
546 546
 					newprescribe.Remark = lastDialysisPrescription.Remark
547 547
 				}
548
-				err := service.AddSigleRecord(&newprescribe)
549
-
548
+				//err := service.AddSigleRecord(&newprescribe)
549
+				var err error
550
+				if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10599 {
551
+					prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
552
+					if prescriptionTwenty.ID == 0 {
553
+						//插入透析处方
554
+						service.AddSigleRecord(&newprescribe)
555
+					} else {
556
+						//插入透析处方
557
+						service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
558
+					}
559
+				} else {
560
+					//插入透析处方
561
+					err = service.AddSigleRecord(&newprescribe)
562
+				}
550 563
 				//记录日志
551 564
 				byterequest, _ := json.Marshal(newprescribe)
552 565
 				prescriptionLog := models.XtDialysisPrescriptionLog{
@@ -1193,23 +1206,25 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
1193 1206
 	// 获取当前或者下次排班信息
1194 1207
 	var sc map[string]interface{}
1195 1208
 	sc = make(map[string]interface{})
1209
+	var mode_id int64
1196 1210
 	if dialysistype == 1 {
1197 1211
 		daySchedule, _ := service.GetPatientScheduleFormDay(adminUserInfo.Org.Id, startTime, endTime, id)
1212
+		println(daySchedule[0].Schedule.ModeId)
1198 1213
 		if len(daySchedule) <= 0 {
1199 1214
 			sc["code"] = 1
1200 1215
 			sc["msg"] = "抱歉,您今天没有排版!"
1201
-			sc["mode"] = 0
1216
+			mode_id = 0
1202 1217
 			sc["data"] = daySchedule
1203 1218
 		} else {
1204 1219
 			if daySchedule[0].Schedule.ID > 0 {
1205 1220
 				sc["code"] = 0
1206 1221
 				sc["msg"] = ""
1207
-				sc["mode"] = daySchedule[0].Schedule.ModeId
1222
+				mode_id = daySchedule[0].Schedule.ModeId
1208 1223
 				sc["data"] = daySchedule
1209 1224
 			} else {
1210 1225
 				sc["code"] = 1
1211 1226
 				sc["msg"] = "抱歉,您今天没有排版!"
1212
-				sc["mode"] = 0
1227
+				mode_id = 0
1213 1228
 				sc["data"] = daySchedule
1214 1229
 			}
1215 1230
 		}
@@ -1226,62 +1241,81 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
1226 1241
 		if len(nextSchedule) <= 0 {
1227 1242
 			sc["code"] = 1
1228 1243
 			sc["msg"] = "抱歉,您后续没有排版!"
1229
-			sc["mode"] = 0
1244
+			mode_id = 0
1230 1245
 			sc["data"] = nextSchedule
1231 1246
 		} else {
1232 1247
 			if nextSchedule[0].Schedule.ID > 0 {
1233 1248
 				sc["code"] = 0
1234 1249
 				sc["msg"] = ""
1235
-				sc["mode"] = nextSchedule[0].Schedule.ModeId
1250
+				mode_id = nextSchedule[0].Schedule.ModeId
1236 1251
 				sc["data"] = nextSchedule
1237 1252
 			} else {
1238 1253
 				sc["code"] = 1
1239 1254
 				sc["msg"] = "抱歉,您后续没有排版!"
1240
-				sc["mode"] = 0
1255
+				mode_id = 0
1241 1256
 				sc["data"] = nextSchedule
1242 1257
 			}
1243 1258
 		}
1244 1259
 	}
1245 1260
 
1246
-	switch sc["mode"] {
1261
+	switch mode_id {
1247 1262
 	case 1:
1248 1263
 		sc["mode"] = "HD"
1264
+		break
1249 1265
 	case 2:
1250 1266
 		sc["mode"] = "HDF"
1267
+		break
1251 1268
 	case 3:
1252 1269
 		sc["mode"] = "HD+HP"
1270
+		break
1253 1271
 	case 4:
1254 1272
 		sc["mode"] = "HP"
1273
+		break
1255 1274
 	case 5:
1256 1275
 		sc["mode"] = "HF"
1276
+		break
1257 1277
 	case 6:
1258 1278
 		sc["mode"] = "SCUF"
1279
+		break
1259 1280
 	case 7:
1260 1281
 		sc["mode"] = "IUF"
1282
+		break
1261 1283
 	case 8:
1262 1284
 		sc["mode"] = "HFHD"
1285
+		break
1263 1286
 	case 9:
1264 1287
 		sc["mode"] = "HFHD+HP"
1288
+		break
1265 1289
 	case 10:
1266 1290
 		sc["mode"] = "PHF"
1291
+		break
1267 1292
 	case 11:
1268 1293
 		sc["mode"] = "HFR"
1294
+		break
1269 1295
 	case 12:
1270 1296
 		sc["mode"] = "HDF+HP"
1297
+		break
1271 1298
 	case 13:
1272 1299
 		sc["mode"] = "CRRT"
1300
+		break
1273 1301
 	case 14:
1274 1302
 		sc["mode"] = "腹水回输"
1303
+		break
1275 1304
 	case 15:
1276 1305
 		sc["mode"] = "HD前置换"
1306
+		break
1277 1307
 	case 16:
1278 1308
 		sc["mode"] = "HD后置换"
1309
+		break
1279 1310
 	case 17:
1280 1311
 		sc["mode"] = "HDF前置换"
1312
+		break
1281 1313
 	case 18:
1282 1314
 		sc["mode"] = "HDF后置换"
1315
+		break
1283 1316
 	default:
1284 1317
 		sc["mode"] = "HD"
1318
+		break
1285 1319
 	}
1286 1320
 
1287 1321
 	// 获取患者透前干体重或者获取患者透前体重

+ 18 - 2
controllers/mobile_api_controllers/dialysis_api_controller.go Zobrazit soubor

@@ -602,6 +602,10 @@ func (this *DialysisAPIController) DialysisRecord() {
602 602
 	}
603 603
 
604 604
 	lastDialysisPrescription, _ := service.GetLastDialysisPrescription(patientID, adminInfo.Org.Id)
605
+
606
+	lastAssesmentBeforDialysis, _ := service.GetLastAssessmentBeforDialysis(patientID, adminInfo.Org.Id)
607
+
608
+	dryWeightList, _ := service.GetPatientDryList(patientID, adminInfo.Org.Id)
605 609
 	returnData := map[string]interface{}{
606 610
 		"patient":                        patient,
607 611
 		"schedual":                       schedual,
@@ -637,6 +641,8 @@ func (this *DialysisAPIController) DialysisRecord() {
637 641
 		"lastOrder":                      lastOrder,
638 642
 		"remind_lists":                   remind_lists,
639 643
 		"lastDialysisPrescription":       lastDialysisPrescription,
644
+		"lastAssesmentBeforDialysis":     lastAssesmentBeforDialysis,
645
+		"dryWeightList":                  dryWeightList,
640 646
 	}
641 647
 
642 648
 	this.ServeSuccessJSON(returnData)
@@ -1390,7 +1396,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1390 1396
 	pip_coagulation := c.GetString("pip_coagulation")
1391 1397
 	accumulated_blood_volume := c.GetString("accumulated_blood_volume")
1392 1398
 	transfusion_volume := c.GetString("transfusion_volume")
1393
-
1399
+	last_after_weight := c.GetString("last_after_weight")
1394 1400
 	if id <= 0 {
1395 1401
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1396 1402
 		return
@@ -1499,6 +1505,7 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1499 1505
 		PipCoagulation:               pip_coagulation,
1500 1506
 		AccumulatedBloodVolume:       accumulated_blood_volume,
1501 1507
 		TransfusionVolume:            transfusion_volume,
1508
+		LastAfterWeight:              last_after_weight,
1502 1509
 	}
1503 1510
 
1504 1511
 	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
@@ -8300,7 +8307,7 @@ func (c *DialysisAPIController) GetPatientDialysisRecordList() {
8300 8307
 	//	})
8301 8308
 	//	return
8302 8309
 	//}
8303
-	if org_id == 9538 || org_id == 10101 {
8310
+	if org_id == 9538 || org_id == 10101 || org_id == 10353 {
8304 8311
 		list, _ := service.GetPatientDialysisRecordList(id, startdateunix, enddateunix)
8305 8312
 		c.ServeSuccessJSON(map[string]interface{}{
8306 8313
 			"list": list,
@@ -10473,3 +10480,12 @@ func (c *DialysisAPIController) GetAdviceListNoExecution() {
10473 10480
 	})
10474 10481
 
10475 10482
 }
10483
+
10484
+func (c *DialysisAPIController) GetLastAcceptRecrods() {
10485
+
10486
+	patient_id, _ := c.GetInt64("patient_id")
10487
+	recrods, _ := service.GetLastAcceptRecrods(patient_id)
10488
+	c.ServeSuccessJSON(map[string]interface{}{
10489
+		"recrods": recrods,
10490
+	})
10491
+}

+ 2 - 2
controllers/mobile_api_controllers/dialysis_api_controller_extend.go Zobrazit soubor

@@ -684,7 +684,7 @@ func (this *DialysisAPIController) AddUrgentSchedule() {
684 684
 			}
685 685
 
686 686
 			service.CreateScheduleLog(scheduleLog)
687
-
687
+			service.UpdateRepeatSchStatus(adminUserInfo.Org.Id, scheduleDate.Unix())
688 688
 			redis := service.RedisClient()
689 689
 			timeStr := time.Now().Format("2006-01-02")
690 690
 			key := "scheduals_" + timeStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
@@ -763,9 +763,9 @@ func (this *DialysisAPIController) AddUrgentSchedule() {
763 763
 						AdminUserId: adminUserInfo.AdminUser.Id,
764 764
 					}
765 765
 					service.CreateScheduleLog(scheduleLog)
766
+					service.UpdateRepeatSchStatus(adminUserInfo.Org.Id, scheduleDate.Unix())
766 767
 
767 768
 					redis := service.RedisClient()
768
-
769 769
 					timeStr := time.Now().Format("2006-01-02")
770 770
 					key := "scheduals_" + timeStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
771 771
 					redis.Set(key, "", time.Second)

+ 2 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go Zobrazit soubor

@@ -206,4 +206,6 @@ func MobileAPIControllersRegisterRouters() {
206 206
 
207 207
 	beego.Router("/m/api/getadvicelistnoexecution", &DialysisAPIController{}, "Get:GetAdviceListNoExecution")
208 208
 
209
+	beego.Router("/m/api/getlastacceptrecrods", &DialysisAPIController{}, "Get:GetLastAcceptRecrods")
210
+
209 211
 }

+ 3 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Zobrazit soubor

@@ -932,6 +932,7 @@ func (c *StaffScheduleApiController) CreateMobileSchedulePatient() {
932 932
 
933 933
 	redis := service.RedisClient()
934 934
 	err = service.CreateScheduleTwo(&schedule)
935
+	service.UpdateRepeatSchStatus(adminUserInfo.Org.Id, schedule.ScheduleDate)
935 936
 	key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
936 937
 	redis.Set(key, "", time.Second)
937 938
 	defer redis.Close()
@@ -1205,7 +1206,7 @@ func (c *StaffScheduleApiController) ChangeScheduleBed() {
1205 1206
 			Module:      4,
1206 1207
 			AdminUserId: c.GetMobileAdminUserInfo().AdminUser.Id,
1207 1208
 		}
1208
-
1209
+		service.UpdateRepeatSchStatus(org_id, schedule_date)
1209 1210
 		service.CreateScheduleLog(scheduleLog)
1210 1211
 		if err == nil {
1211 1212
 			c.ServeSuccessJSON(map[string]interface{}{
@@ -1246,6 +1247,7 @@ func (c *StaffScheduleApiController) ChangeScheduleBed() {
1246 1247
 		}
1247 1248
 		var err error
1248 1249
 		err = service.CreateSchedule(&xtSchedule, id)
1250
+		service.UpdateRepeatSchStatus(org_id, schedule_date)
1249 1251
 		//记录日志
1250 1252
 		byterequest, _ := json.Marshal(schedule)
1251 1253
 		scheduleLog := models.XtScheduleLog{

+ 284 - 0
controllers/self_drug_api_congtroller.go Zobrazit soubor

@@ -115,6 +115,13 @@ func SelfDrugRouters() {
115 115
 	beego.Router("/api/stock/getdrugovercount", &SelfDrugApiController{}, "Get:GetDrugOverCount")
116 116
 
117 117
 	beego.Router("/api/stock/getdruginfolist", &SelfDrugApiController{}, "Get:GetDrugInventoryWarehouseInfoList")
118
+
119
+	beego.Router("/api/drug/getdrugflowdetailbyid", &SelfDrugApiController{}, "Get:GetDrugFlowDetailById")
120
+
121
+	//康允新版本
122
+	beego.Router("/api/stock/getpurchaseDrugQueryList", &SelfDrugApiController{}, "Get:GetPurchaseDrugQueryList")
123
+
124
+	beego.Router("/api/stock/getpurchasestockquerylist", &SelfDrugApiController{}, "Get:GetPurchaseStockQueryList")
118 125
 }
119 126
 
120 127
 func (this *SelfDrugApiController) GetCurrentPatient() {
@@ -4091,3 +4098,280 @@ func (this *SelfDrugApiController) GetInventoryDetailPrintList() {
4091 4098
 		"inventoryList": inventoryList,
4092 4099
 	})
4093 4100
 }
4101
+
4102
+func (this *SelfDrugApiController) GetDrugFlowDetailById() {
4103
+
4104
+	drug_id, _ := this.GetInt64("drug_id")
4105
+
4106
+	list, _ := service.GetDrugFlowDetailById(drug_id)
4107
+
4108
+	drugMedical, _ := service.GetBaseDrugMedical(drug_id)
4109
+
4110
+	for index, _ := range list {
4111
+		if list[index].ConsumableType == 3 || list[index].ConsumableType == 2 || list[index].ConsumableType == 11 || list[index].ConsumableType == 12 || list[index].ConsumableType == 15 {
4112
+			var count int64
4113
+			if list[index].MaxUnit == drugMedical.MaxUnit && list[index].MaxUnit != list[index].MinUnit {
4114
+				list[index].Count = list[index].Count * drugMedical.MinNumber
4115
+			}
4116
+
4117
+			if index == 0 {
4118
+				count = list[index].FlushOverCount - list[index].Count
4119
+				service.UpdateDrugOverCount(list[index+1].ID, count)
4120
+			}
4121
+
4122
+			if index >= 1 {
4123
+				lastStockFlow, _ := service.GetLastDrugOverCount(list[index-1].ID)
4124
+				count = lastStockFlow.FlushOverCount - list[index].Count
4125
+				service.UpdateDrugOverCount(list[index].ID, count)
4126
+			}
4127
+
4128
+		}
4129
+		if list[index].ConsumableType == 7 || list[index].ConsumableType == 4 || list[index].ConsumableType == 1 || list[index].ConsumableType == 10 || list[index].ConsumableType == 13 {
4130
+			if list[index].MaxUnit == drugMedical.MaxUnit && list[index].MaxUnit != list[index].MinUnit {
4131
+				list[index].Count = list[index].Count * drugMedical.MinNumber
4132
+			}
4133
+			if index == 0 {
4134
+				var count int64
4135
+				count = list[index].OverCount + list[index].Count
4136
+				service.UpdateDrugOverCount(list[index+1].ID, count)
4137
+			}
4138
+
4139
+			if index >= 1 {
4140
+				var count int64
4141
+				lastStockFlow, _ := service.GetLastDrugOverCount(list[index-1].ID)
4142
+				count = lastStockFlow.FlushOverCount + list[index].Count
4143
+				service.UpdateDrugOverCount(list[index].ID, count)
4144
+			}
4145
+
4146
+		}
4147
+
4148
+	}
4149
+}
4150
+
4151
+func (this *SelfDrugApiController) GetPurchaseDrugQueryList() {
4152
+
4153
+	good_type, _ := this.GetInt64("good_type")
4154
+
4155
+	keyword := this.GetString("keyword")
4156
+
4157
+	page, _ := this.GetInt64("page")
4158
+
4159
+	limit, _ := this.GetInt64("limit")
4160
+
4161
+	start_time := this.GetString("start_time")
4162
+	end_time := this.GetString("end_time")
4163
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4164
+	timeLayout := "2006-01-02"
4165
+	loc, _ := time.LoadLocation("Local")
4166
+
4167
+	var startTime int64
4168
+
4169
+	if len(start_time) > 0 {
4170
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4171
+		if err != nil {
4172
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4173
+			return
4174
+		}
4175
+		startTime = theTime.Unix()
4176
+	}
4177
+
4178
+	var endTime int64
4179
+	if len(end_time) > 0 {
4180
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
4181
+		if err != nil {
4182
+			utils.ErrorLog(err.Error())
4183
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4184
+			return
4185
+		}
4186
+		endTime = theTime.Unix()
4187
+	}
4188
+	var ids []int64
4189
+	var infoIds []int64
4190
+
4191
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
4192
+	for _, it := range manufacturers {
4193
+		ids = append(ids, it.ID)
4194
+	}
4195
+	infoList, _ := service.GetDrugWarehouseInfoByOrgIdTwo(orgId)
4196
+	for _, it := range infoList {
4197
+		infoIds = append(infoIds, it.DrugId)
4198
+	}
4199
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
4200
+	list, total, err := service.GetDrugNewPurchaseStockQueryList(good_type, keyword, page, limit, orgId, startTime, endTime, ids, infoIds)
4201
+
4202
+	for _, item := range list {
4203
+
4204
+		//获取期初结余
4205
+		flow, _ := service.GetDrugStartFlow(item.ID, orgId, startTime)
4206
+
4207
+		item.DrugStatFlow = flow
4208
+
4209
+		//获取期末结余
4210
+		endFlow, _ := service.GetDrugEndFlow(item.ID, orgId, endTime)
4211
+
4212
+		item.DrugEndFlow = endFlow
4213
+		//获取期初结余入库数量
4214
+
4215
+		//期中增加
4216
+		drugWarehouse, _ := service.GetDrugWarehouseStartEnd(item.ID, orgId, startTime, endTime)
4217
+		for _, it := range drugWarehouse {
4218
+			item.DrugWarehouseInfoStartEnd = append(item.DrugWarehouseInfoStartEnd, it)
4219
+		}
4220
+
4221
+		//期中减少
4222
+		outInfo, _ := service.FindeDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
4223
+		for _, it := range outInfo {
4224
+			item.DrugWarehouseOutInfoStartEnd = append(item.DrugWarehouseOutInfoStartEnd, it)
4225
+		}
4226
+
4227
+		//期中退库
4228
+		cancelstartInfo, _ := service.FindStartEndDrugWarehouseOutInfo(item.ID, item.OrgId, startTime, endTime)
4229
+		for _, it := range cancelstartInfo {
4230
+			item.WareStartEndStockCancelInfo = append(item.WareStartEndStockCancelInfo, it)
4231
+		}
4232
+
4233
+		//获取期中盘盈
4234
+		profit, _ := service.GetDrugFlowStartEndProfit(item.ID, orgId, startTime, endTime)
4235
+		for _, it := range profit {
4236
+			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
4237
+		}
4238
+
4239
+		//获取期中盘亏
4240
+		endLosses, _ := service.GetDrugFlowStartEndLosses(item.ID, orgId, startTime, endTime)
4241
+		for _, it := range endLosses {
4242
+			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
4243
+		}
4244
+	}
4245
+	if err != nil {
4246
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
4247
+		return
4248
+	}
4249
+	var drugType = "药品类型"
4250
+	drugTypeParent, _ := service.GetDrugDataConfig(0, drugType)
4251
+	drugTypeList, _ := service.GetParentDataConfig(drugTypeParent.ID, orgId)
4252
+
4253
+	this.ServeSuccessJSON(map[string]interface{}{
4254
+		"list":             list,
4255
+		"manufacturerList": manufacturerList,
4256
+		"total":            total,
4257
+		"drugTypeList":     drugTypeList,
4258
+	})
4259
+}
4260
+
4261
+func (this *SelfDrugApiController) GetPurchaseStockQueryList() {
4262
+
4263
+	good_type, _ := this.GetInt64("good_type")
4264
+
4265
+	keyword := this.GetString("keyword")
4266
+
4267
+	page, _ := this.GetInt64("page")
4268
+
4269
+	limit, _ := this.GetInt64("limit")
4270
+
4271
+	start_time := this.GetString("start_time")
4272
+	end_time := this.GetString("end_time")
4273
+	orgId := this.GetAdminUserInfo().CurrentOrgId
4274
+	timeLayout := "2006-01-02"
4275
+	loc, _ := time.LoadLocation("Local")
4276
+	var startTime int64
4277
+
4278
+	if len(start_time) > 0 {
4279
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
4280
+		if err != nil {
4281
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4282
+			return
4283
+		}
4284
+		startTime = theTime.Unix()
4285
+	}
4286
+
4287
+	var endTime int64
4288
+	if len(end_time) > 0 {
4289
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
4290
+		if err != nil {
4291
+			utils.ErrorLog(err.Error())
4292
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
4293
+			return
4294
+		}
4295
+		endTime = theTime.Unix()
4296
+	}
4297
+	var ids []int64
4298
+	var goodIds []int64
4299
+	infoList, _ := service.GetGoodWarehouseInfoByOrgIdTwo(orgId)
4300
+	for _, it := range infoList {
4301
+		goodIds = append(goodIds, it.GoodId)
4302
+	}
4303
+
4304
+	manufacturers, _ := service.GetManufacturerListByKeyword(orgId, keyword)
4305
+	for _, it := range manufacturers {
4306
+		ids = append(ids, it.ID)
4307
+	}
4308
+	manufacturerList, _ := service.GetNewAllManufacturerList(orgId)
4309
+
4310
+	list, total, err := service.GetPurchaseStockQueryList(good_type, keyword, page, limit, orgId, ids, goodIds)
4311
+	storeConfig, _ := service.GetAllStoreHouseConfig(orgId)
4312
+	for _, item := range list {
4313
+
4314
+		//获取期初结余
4315
+		low, _ := service.GetStartLastFLow(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
4316
+
4317
+		item.GoodStartFlowInfo = low
4318
+
4319
+		//获取期末结余
4320
+		flow, _ := service.GetEndLastFlow(item.ID, orgId, endTime, storeConfig.StorehouseOutInfo)
4321
+
4322
+		item.GoodEndFlowInfo = flow
4323
+
4324
+		//获取期间增加
4325
+		goodWarehouseInfoList, _ := service.GetAddGoodWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
4326
+
4327
+		for _, it := range goodWarehouseInfoList {
4328
+			item.WarehousingInfoOne = append(item.WarehousingInfoOne, it)
4329
+		}
4330
+
4331
+		//获取本期增加
4332
+		WarehouseInfoFlowList, _ := service.GetAddStartFlow(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
4333
+
4334
+		for _, it := range WarehouseInfoFlowList {
4335
+			item.StartFlowWarehouseInfo = append(item.StartFlowWarehouseInfo, it)
4336
+		}
4337
+		//获取本期减少
4338
+		reduceWarehouseInfoList, _ := service.GetReduceWarehouseInfoList(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
4339
+		for _, it := range reduceWarehouseInfoList {
4340
+			item.WarehouseOutInfoStart = append(item.WarehouseOutInfoStart, it)
4341
+		}
4342
+
4343
+		//获取期中减少退库
4344
+		lowInfo, _ := service.GetStartEndCancelFLowInfo(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
4345
+		for _, it := range lowInfo {
4346
+			item.StartEndCancelFLowInfo = append(item.StartEndCancelFLowInfo, it)
4347
+		}
4348
+		//
4349
+		outInfo, _ := service.FindeWarehouseOutInfo(item.ID, orgId, startTime, storeConfig.StorehouseOutInfo)
4350
+		for _, it := range outInfo {
4351
+			item.WarehouseOutInfoEnd = append(item.WarehouseOutInfoEnd, it)
4352
+		}
4353
+
4354
+		//期中盘盈
4355
+		profit, _ := service.FindeEndStokInventoryProfit(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
4356
+		for _, it := range profit {
4357
+			item.WareStartEndStockInventoryProfit = append(item.WareStartEndStockInventoryProfit, it)
4358
+		}
4359
+		//期中盘亏
4360
+		losses, _ := service.FindeEndStockInventoryLosses(item.ID, orgId, startTime, endTime, storeConfig.StorehouseOutInfo)
4361
+		for _, it := range losses {
4362
+			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
4363
+		}
4364
+	}
4365
+
4366
+	if err != nil {
4367
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "获取患者信息失败")
4368
+		return
4369
+	}
4370
+
4371
+	this.ServeSuccessJSON(map[string]interface{}{
4372
+		"list":             list,
4373
+		"manufacturerList": manufacturerList,
4374
+		"total":            total,
4375
+	})
4376
+
4377
+}

+ 1 - 0
models/dialysis.go Zobrazit soubor

@@ -657,6 +657,7 @@ type AssessmentAfterDislysis struct {
657 657
 	AccumulatedBloodVolume          string  `gorm:"column:accumulated_blood_volume" json:"accumulated_blood_volume" form:"accumulated_blood_volume"`
658 658
 	TransfusionVolume               string  `gorm:"column:transfusion_volume" json:"transfusion_volume" form:"transfusion_volume"`
659 659
 	Condenser                       string  `gorm:"column:condenser" json:"condenser" form:"condenser"`
660
+	LastAfterWeight                 string  `gorm:"column:last_after_weight" json:"last_after_weight" form:"last_after_weight"`
660 661
 }
661 662
 
662 663
 func (AssessmentAfterDislysis) TableName() string {

+ 2 - 0
models/drug_stock.go Zobrazit soubor

@@ -455,6 +455,8 @@ type DrugFlow struct {
455 455
 	RetailPrice               float64                `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
456 456
 	XtDrugWarehouseOutInfo    XtDrugWarehouseOutInfo `gorm:"ForeignKey:ID;AssociationForeignKey:WarehouseOutDetailId"json:"xt_drug_warehouse_out_info" `
457 457
 	OrderId                   int64                  `gorm:"column:order_id" json:"order_id" form:"order_id"`
458
+	FlushOverCount            int64                  `gorm:"column:flush_over_count" json:"flush_over_count" form:"flush_over_count"`
459
+	Remark                    string                 `gorm:"column:remark" json:"remark" form:"remark"`
458 460
 }
459 461
 
460 462
 func (DrugFlow) TableName() string {

+ 1 - 0
models/new_stock_models.go Zobrazit soubor

@@ -402,6 +402,7 @@ type VmBaseDrugTwenty struct {
402 402
 	RetailPrice                      float64           `gorm:"column:retail_price" json:"retail_price" form:"retail_price"`
403 403
 	MinPrice                         float64           `gorm:"column:min_price" json:"min_price" form:"min_price"`
404 404
 	LastPrice                        float64           `gorm:"column:last_price" json:"last_price" form:"last_price"`
405
+	DrugAlias                        string            `gorm:"column:drug_alias" json:"drug_alias" form:"drug_alias"`
405 406
 	Manufacturer                     int64             `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
406 407
 	Dealer                           int64             `gorm:"column:dealer" json:"dealer" form:"dealer"`
407 408
 	Status                           int64             `gorm:"column:status" json:"status" form:"status"`

+ 1 - 0
models/stock_models.go Zobrazit soubor

@@ -678,6 +678,7 @@ type VmStockFlow struct {
678 678
 	IsCheck                   int64           `gorm:"column:is_check" json:"is_check" form:"is_check"`
679 679
 	OverCount                 int64           `gorm:"column:over_count" json:"over_count" form:"over_count"`
680 680
 	OrderId                   int64           `gorm:"column:order_id" json:"order_id" form:"order_id"`
681
+	Remark                    string          `gorm:"column:remark" json:"remark" form:"remark"`
681 682
 }
682 683
 
683 684
 func (VmStockFlow) TableName() string {

+ 6 - 0
service/dialysis_parameter_service.go Zobrazit soubor

@@ -332,6 +332,12 @@ func GetLastAssessmentBeforDialysis(patientid int64, orgid int64) (models.Predia
332 332
 	return evaluation, err
333 333
 }
334 334
 
335
+func GetPatientDryList(patientid int64, orgid int64) (dryweight []*models.SgjPatientDryweight, err error) {
336
+
337
+	err = XTReadDB().Where("patient_id =? and user_org_id =? and status=1", patientid, orgid).Order("ctime desc").Limit(6).Find(&dryweight).Error
338
+	return dryweight, err
339
+}
340
+
335 341
 func GetDialysisPrescriptionList(patientid int64, orgid int64, startime int64) (models.DialysisPrescriptionParameter, error) {
336 342
 	prescription := models.DialysisPrescriptionParameter{}
337 343
 	err := XTReadDB().Model(&prescription).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientid, orgid, startime).Find(&prescription).Error

+ 1 - 1
service/dialysis_service.go Zobrazit soubor

@@ -224,7 +224,7 @@ func AddSigleRecord(prescription *models.DialysisPrescription) (err error) {
224 224
 
225 225
 func UpdateAddSigleRecord(id int64, target_ultrafiltration float64) error {
226 226
 
227
-	err := XTWriteDB().Model(&models.DialysisPrescription{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"target_ultrafiltration": target_ultrafiltration}).Error
227
+	err := XTWriteDB().Model(&models.DialysisPrescription{}).Where("id = ? and status =1", id).Updates(map[string]interface{}{"target_ultrafiltration": target_ultrafiltration, "prescription_water": target_ultrafiltration}).Error
228 228
 	return err
229 229
 }
230 230
 

+ 8 - 0
service/doctor_schedule_service.go Zobrazit soubor

@@ -818,3 +818,11 @@ func GetMobileScheduleListByScheduleDate(org_id int64, schedule_date int64) (sch
818 818
 
819 819
 	return schedule, err
820 820
 }
821
+
822
+func DeleteStaffScheduleById(id int64, user_org_id int64) (err error) {
823
+
824
+	schedule := models.StaffSchedule{}
825
+
826
+	err = XTWriteDB().Model(&schedule).Where("id = ? and user_org_id =? and status=1", id, user_org_id).Updates(map[string]interface{}{"status": 0}).Error
827
+	return err
828
+}

+ 7 - 0
service/patient_service.go Zobrazit soubor

@@ -3397,3 +3397,10 @@ func GetDialysisOrderCountTenEight(patient_id int64, recordDate int64) (models.V
3397 3397
 	err := XTReadDB().Where("patient_id = ? and dialysis_date = ? and status = 1", patient_id, recordDate).Last(&order).Error
3398 3398
 	return order, err
3399 3399
 }
3400
+
3401
+func GetLastAcceptRecrods(patient_id int64) (models.ReceiveTreatmentAsses, error) {
3402
+
3403
+	treatmentAsses := models.ReceiveTreatmentAsses{}
3404
+	err := XTReadDB().Where("patient_id = ? and status= 1 and admission_number!=''", patient_id).Last(&treatmentAsses).Error
3405
+	return treatmentAsses, err
3406
+}

+ 32 - 30
service/pharmacy_service.go Zobrazit soubor

@@ -839,36 +839,38 @@ func DispensingMedicineOne(orgid, patient_id, stime, etime, creater int64) (err
839 839
 	}
840 840
 
841 841
 	advice, err := GetDocAdviceList(orgid, patient_id, stime, etime)
842
-
843
-	if len(advice) > 0 {
844
-		for _, item := range advice {
845
-			err = DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
846
-			//查询默认仓库
847
-			storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
848
-			//查询默认仓库剩余多少库存
849
-			var sum_count int64
850
-			stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, item.DrugId)
851
-			for _, its := range stockInfo {
852
-				baseDrug, _ := GetBaseDrugMedical(its.DrugId)
853
-				if its.MaxUnit == baseDrug.MaxUnit {
854
-					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
842
+	//响水不走这里
843
+	if orgid != 10188 {
844
+		if len(advice) > 0 {
845
+			for _, item := range advice {
846
+				err = DrugsDelivery(item.UserOrgId, item.ExecutionStaff, item)
847
+				//查询默认仓库
848
+				storeHouseConfig, _ := GetAllStoreHouseConfig(orgid)
849
+				//查询默认仓库剩余多少库存
850
+				var sum_count int64
851
+				stockInfo, _ := GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, orgid, item.DrugId)
852
+				for _, its := range stockInfo {
853
+					baseDrug, _ := GetBaseDrugMedical(its.DrugId)
854
+					if its.MaxUnit == baseDrug.MaxUnit {
855
+						its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
856
+					}
857
+					sum_count += its.StockMaxNumber + its.StockMinNumber
855 858
 				}
856
-				sum_count += its.StockMaxNumber + its.StockMinNumber
857
-			}
858
-			UpdateBaseDrugSumTwo(item.DrugId, sum_count, orgid)
859
-			//扣减库存
860
-			UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
859
+				UpdateBaseDrugSumTwo(item.DrugId, sum_count, orgid)
860
+				//扣减库存
861
+				UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
861 862
 
862
-			over, _ := FindOverCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut)
863
-			UpdateActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount)
864
-			if err != nil {
865
-				err = fmt.Errorf("!:%v", err)
866
-				return
867
-			}
868
-			err = UpdateIsAdvice(item.ID)
869
-			if err != nil {
870
-				err = fmt.Errorf("!:%v", err)
871
-				return
863
+				over, _ := FindOverCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut)
864
+				UpdateActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount)
865
+				if err != nil {
866
+					err = fmt.Errorf("!:%v", err)
867
+					return
868
+				}
869
+				err = UpdateIsAdvice(item.ID)
870
+				if err != nil {
871
+					err = fmt.Errorf("!:%v", err)
872
+					return
873
+				}
872 874
 			}
873 875
 		}
874 876
 	}
@@ -889,7 +891,7 @@ func DispensingMedicineOne(orgid, patient_id, stime, etime, creater int64) (err
889 891
 
890 892
 func GetHisPatientNoMedical(user_org_id int64, patient_id int64, startime int64, end_time int64) (advice []*models.HisDoctorAdviceInfo, err error) {
891 893
 
892
-	err = XTReadDB().Where("user_org_id =? and patient_id = ? and advice_date>=? and advice_date<=? and is_medicine =0", user_org_id, patient_id, startime, end_time).Find(&advice).Error
894
+	err = XTReadDB().Where("user_org_id =? and patient_id = ? and advice_date>=? and advice_date<=? and is_medicine =0 and status=1", user_org_id, patient_id, startime, end_time).Find(&advice).Error
893 895
 	return advice, err
894 896
 }
895 897
 
@@ -907,7 +909,7 @@ func UpdateHisPrescription(id int64) (err error) {
907 909
 
908 910
 func GetDocAdviceList(user_org_id int64, patient_id int64, startime int64, end_time int64) (advice []*models.DoctorAdvice, err error) {
909 911
 
910
-	err = XTReadDB().Where("user_org_id =? and patient_id = ? and advice_date>=? and advice_date<=? and is_medicine =0", user_org_id, patient_id, startime, end_time).Find(&advice).Error
912
+	err = XTReadDB().Where("user_org_id =? and patient_id = ? and advice_date>=? and advice_date<=? and is_medicine =0 and status=1", user_org_id, patient_id, startime, end_time).Find(&advice).Error
911 913
 	return advice, err
912 914
 
913 915
 }

+ 15 - 0
service/secondary_service.go Zobrazit soubor

@@ -1162,6 +1162,12 @@ func UpdateOverCount(id int64, count int64) (err error) {
1162 1162
 	return err
1163 1163
 }
1164 1164
 
1165
+func UpdateDrugOverCount(id int64, count int64) (err error) {
1166
+
1167
+	err = XTWriteDB().Model(models.DrugFlow{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"flush_over_count": count}).Error
1168
+	return err
1169
+}
1170
+
1165 1171
 func GetLastOverCount(id int64) (models.VmStockFlow, error) {
1166 1172
 
1167 1173
 	stockFlow := models.VmStockFlow{}
@@ -1170,3 +1176,12 @@ func GetLastOverCount(id int64) (models.VmStockFlow, error) {
1170 1176
 
1171 1177
 	return stockFlow, err
1172 1178
 }
1179
+
1180
+func GetLastDrugOverCount(id int64) (models.DrugFlow, error) {
1181
+
1182
+	stockFlow := models.DrugFlow{}
1183
+
1184
+	err := XTReadDB().Where("id=? and status=1", id).Find(&stockFlow).Error
1185
+
1186
+	return stockFlow, err
1187
+}

+ 47 - 0
service/self_drug_service.go Zobrazit soubor

@@ -2881,6 +2881,30 @@ func GetDrugNewPurchaseStockQuery(good_type int64, keyword string, page int64, l
2881 2881
 	return druginfo, total, err
2882 2882
 }
2883 2883
 
2884
+func GetDrugNewPurchaseStockQueryList(good_type int64, keyword string, page int64, limit int64, orgid int64, startime int64, endtime int64, ids []int64, infos []int64) (druginfo []*models.VmBaseDrugTwenty, total int64, err error) {
2885
+
2886
+	db := XTReadDB().Model(&druginfo).Where("status = 1")
2887
+	offset := (page - 1) * limit
2888
+	likeKey := "%" + keyword + "%"
2889
+	if good_type > 0 {
2890
+		db = db.Where("drug_type = ?", good_type)
2891
+	}
2892
+
2893
+	if orgid > 0 {
2894
+		db = db.Where("org_id = ?", orgid)
2895
+	}
2896
+
2897
+	if len(keyword) > 0 {
2898
+		db = db.Where("drug_name like ? or manufacturer in(?)", likeKey, ids)
2899
+	}
2900
+	if len(infos) > 0 {
2901
+		db = db.Where("id in(?)", infos)
2902
+	}
2903
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("drug_alias desc").Find(&druginfo).Error
2904
+
2905
+	return druginfo, total, err
2906
+}
2907
+
2884 2908
 func GetDrugStartFlow(drug_id int64, user_org_id int64, startime int64) (models.DrugFlowTwenty, error) {
2885 2909
 
2886 2910
 	flow := models.DrugFlowTwenty{}
@@ -2965,3 +2989,26 @@ func UpdateDrugStockInCountOne(drugId int64, storehouseId int64, over_count int6
2965 2989
 	err := XTWriteDB().Model(&models.XtDrugStockCount{}).Where("drug_id =? and storehouse_id =? and status=1 and user_org_id =?", drugId, storehouseId, user_org_id).Update(map[string]interface{}{"sum_act_out_count": over_count}).Error
2966 2990
 	return err
2967 2991
 }
2992
+
2993
+func GetPurchaseStockQueryList(good_type int64, keyword string, page int64, limit int64, orgid int64, ids []int64, goodIds []int64) (goodinfo []*models.GoodInfoTwenty, total int64, err error) {
2994
+
2995
+	db := XTReadDB().Model(&goodinfo).Where("status = 1")
2996
+	offset := (page - 1) * limit
2997
+	likeKey := "%" + keyword + "%"
2998
+	if good_type > 0 {
2999
+		db = db.Where("good_type_id = ?", good_type)
3000
+	}
3001
+
3002
+	if orgid > 0 {
3003
+		db = db.Where("org_id = ?", orgid)
3004
+	}
3005
+	if len(ids) > 0 {
3006
+		db = db.Where("id in(?)", goodIds)
3007
+	}
3008
+	if len(keyword) > 0 {
3009
+		db = db.Where("good_name like ? or manufacturer in(?)", likeKey, ids)
3010
+	}
3011
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("good_number desc").Find(&goodinfo).Error
3012
+
3013
+	return goodinfo, total, err
3014
+}

+ 7 - 0
service/user_service.go Zobrazit soubor

@@ -214,3 +214,10 @@ func GetAllHisDoctor(orgid int64) (appRole []*models.App_Role, err error) {
214 214
 	err = UserReadDB().Where("org_id = ?  AND status = 1 AND  (user_type = ? OR user_type = ?) ", orgid, 2, 1).Find(&appRole).Error
215 215
 	return appRole, err
216 216
 }
217
+
218
+func GetDrugFlowDetailById(drug_id int64) (flow []*models.DrugFlow, err error) {
219
+
220
+	err = XTReadDB().Model(&flow).Where("drug_id = ? and status =1 and user_org_id =10402", drug_id).Order("id asc").Find(&flow).Error
221
+
222
+	return flow, err
223
+}

+ 4 - 0
service/warhouse_service.go Zobrazit soubor

@@ -5586,6 +5586,7 @@ func ConsumablesDeliveryThirty(orgID int64, record_time int64, goods *models.War
5586 5586
 			IsCheck:                 1,
5587 5587
 			OverCount:               sum_count,
5588 5588
 			RegisterNumber:          goods.RegisterNumber,
5589
+			Remark:                  goods.Remark,
5589 5590
 		}
5590 5591
 		//创建出库流水
5591 5592
 		errflow := CreateStockFlowOne(stockFlow)
@@ -5734,6 +5735,7 @@ func ConsumablesDeliveryThirty(orgID int64, record_time int64, goods *models.War
5734 5735
 			IsCheck:                 1,
5735 5736
 			OverCount:               sum_count,
5736 5737
 			RegisterNumber:          goods.RegisterNumber,
5738
+			Remark:                  goods.Remark,
5737 5739
 		}
5738 5740
 		//创建出库流水
5739 5741
 		errflow := CreateStockFlowOne(stockFlow)
@@ -6011,6 +6013,7 @@ func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehous
6011 6013
 			WarehousingId:           warehouse.ID,
6012 6014
 			SystemTime:              advice.SysRecordTime,
6013 6015
 			PatientId:               advice.PatientId,
6016
+			Remark:                  advice.Remark,
6014 6017
 		}
6015 6018
 		if warehouse.RetailPrice == 0 {
6016 6019
 			drugflow.Price = advice.Price
@@ -6081,6 +6084,7 @@ func AutoDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, warehous
6081 6084
 			WarehousingDetailId:     warehouse.ID,
6082 6085
 			SystemTime:              advice.SysRecordTime,
6083 6086
 			PatientId:               advice.PatientId,
6087
+			Remark:                  advice.Remark,
6084 6088
 		}
6085 6089
 
6086 6090
 		CreateDrugFlowOne(drugflow)