Browse Source

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

csx 3 years ago
parent
commit
20857f7898

+ 1 - 1
conf/app.conf View File

1
 appname = 血透
1
 appname = 血透
2
-httpport = 9531
2
+httpport = 9529
3
 runmode = dev
3
 runmode = dev
4
 
4
 
5
 #
5
 #

+ 59 - 60
controllers/base_api_controller.go View File

2
 
2
 
3
 import (
3
 import (
4
 	"XT_New/enums"
4
 	"XT_New/enums"
5
-	"XT_New/models"
6
 	"XT_New/service"
5
 	"XT_New/service"
7
 	"fmt"
6
 	"fmt"
8
 	"strconv"
7
 	"strconv"
70
 func (this *BaseAuthAPIController) Prepare() {
69
 func (this *BaseAuthAPIController) Prepare() {
71
 	this.BaseAPIController.Prepare()
70
 	this.BaseAPIController.Prepare()
72
 	if this.GetAdminUserInfo() == nil {
71
 	if this.GetAdminUserInfo() == nil {
73
-		var userAdmin models.AdminUser
74
-		userAdmin.Id = 1448
75
-		userAdmin.Mobile = "13318599895"
76
-
77
-		userAdmin.Id = 597
78
-		userAdmin.Mobile = "19874122664"
79
-		userAdmin.IsSuperAdmin = false
80
-		userAdmin.Status = 1
81
-		userAdmin.CreateTime = 1530786071
82
-		userAdmin.ModifyTime = 1530786071
83
-		var subscibe models.ServeSubscibe
84
-		subscibe.ID = 1
85
-		subscibe.OrgId = 3877
86
-		subscibe.PeriodStart = 1538035409
87
-		subscibe.PeriodEnd = 1569571409
88
-		subscibe.State = 1
89
-		subscibe.Status = 1
90
-		subscibe.CreatedTime = 1538035409
91
-		subscibe.UpdatedTime = 1538035409
92
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
93
-		subscibes[4] = &subscibe
94
-		var adminUserInfo service.AdminUserInfo
95
-		adminUserInfo.CurrentOrgId = 3877
96
-		adminUserInfo.CurrentAppId = 4
97
-		adminUserInfo.AdminUser = &userAdmin
98
-		adminUserInfo.Subscibes = subscibes
99
-		this.SetSession("admin_user_info", &adminUserInfo)
100
-
101
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
102
-		//this.StopRun()
72
+		//var userAdmin models.AdminUser
73
+		//userAdmin.Id = 1448
74
+		//userAdmin.Mobile = "13318599895"
75
+		//
76
+		//userAdmin.Id = 597
77
+		//userAdmin.Mobile = "19874122664"
78
+		//userAdmin.IsSuperAdmin = false
79
+		//userAdmin.Status = 1
80
+		//userAdmin.CreateTime = 1530786071
81
+		//userAdmin.ModifyTime = 1530786071
82
+		//var subscibe models.ServeSubscibe
83
+		//subscibe.ID = 1
84
+		//subscibe.OrgId = 3877
85
+		//subscibe.PeriodStart = 1538035409
86
+		//subscibe.PeriodEnd = 1569571409
87
+		//subscibe.State = 1
88
+		//subscibe.Status = 1
89
+		//subscibe.CreatedTime = 1538035409
90
+		//subscibe.UpdatedTime = 1538035409
91
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
92
+		//subscibes[4] = &subscibe
93
+		//var adminUserInfo service.AdminUserInfo
94
+		//adminUserInfo.CurrentOrgId = 3877
95
+		//adminUserInfo.CurrentAppId = 4
96
+		//adminUserInfo.AdminUser = &userAdmin
97
+		//adminUserInfo.Subscibes = subscibes
98
+		//this.SetSession("admin_user_info", &adminUserInfo)
99
+
100
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
101
+		this.StopRun()
103
 
102
 
104
 	}
103
 	}
105
 
104
 
316
 func (this *BaseServeAPIController) Prepare() {
315
 func (this *BaseServeAPIController) Prepare() {
317
 	this.BaseAPIController.Prepare()
316
 	this.BaseAPIController.Prepare()
318
 	if this.GetAdminUserInfo() == nil {
317
 	if this.GetAdminUserInfo() == nil {
319
-		var userAdmin models.AdminUser
320
-		userAdmin.Id = 1448
321
-		userAdmin.Mobile = "13318599895"
322
-
323
-		userAdmin.Id = 597
324
-		userAdmin.Mobile = "19874122664"
325
-		userAdmin.IsSuperAdmin = false
326
-		userAdmin.Status = 1
327
-		userAdmin.CreateTime = 1530786071
328
-		userAdmin.ModifyTime = 1530786071
329
-		var subscibe models.ServeSubscibe
330
-		subscibe.ID = 1
331
-		subscibe.OrgId = 3877
332
-		subscibe.PeriodStart = 1538035409
333
-		subscibe.PeriodEnd = 1569571409
334
-		subscibe.State = 1
335
-		subscibe.Status = 1
336
-		subscibe.CreatedTime = 1538035409
337
-		subscibe.UpdatedTime = 1538035409
338
-		subscibes := make(map[int64]*models.ServeSubscibe, 0)
339
-		subscibes[4] = &subscibe
340
-		var adminUserInfo service.AdminUserInfo
341
-		adminUserInfo.CurrentOrgId = 3877
342
-		adminUserInfo.CurrentAppId = 4
343
-		adminUserInfo.AdminUser = &userAdmin
344
-		adminUserInfo.Subscibes = subscibes
345
-		this.SetSession("admin_user_info", &adminUserInfo)
346
-		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
347
-		//this.StopRun()
318
+		//var userAdmin models.AdminUser
319
+		//userAdmin.Id = 1448
320
+		//userAdmin.Mobile = "13318599895"
321
+		//
322
+		//userAdmin.Id = 597
323
+		//userAdmin.Mobile = "19874122664"
324
+		//userAdmin.IsSuperAdmin = false
325
+		//userAdmin.Status = 1
326
+		//userAdmin.CreateTime = 1530786071
327
+		//userAdmin.ModifyTime = 1530786071
328
+		//var subscibe models.ServeSubscibe
329
+		//subscibe.ID = 1
330
+		//subscibe.OrgId = 3877
331
+		//subscibe.PeriodStart = 1538035409
332
+		//subscibe.PeriodEnd = 1569571409
333
+		//subscibe.State = 1
334
+		//subscibe.Status = 1
335
+		//subscibe.CreatedTime = 1538035409
336
+		//subscibe.UpdatedTime = 1538035409
337
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
338
+		//subscibes[4] = &subscibe
339
+		//var adminUserInfo service.AdminUserInfo
340
+		//adminUserInfo.CurrentOrgId = 3877
341
+		//adminUserInfo.CurrentAppId = 4
342
+		//adminUserInfo.AdminUser = &userAdmin
343
+		//adminUserInfo.Subscibes = subscibes
344
+		//this.SetSession("admin_user_info", &adminUserInfo)
345
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
346
+		this.StopRun()
348
 	}
347
 	}
349
 
348
 
350
 	//if adminUserInfo.AppRole != nil {
349
 	//if adminUserInfo.AppRole != nil {

+ 15 - 20
controllers/drug_stock_api_contorller.go View File

2213
 						dealer_id = item.ID
2213
 						dealer_id = item.ID
2214
 					}
2214
 					}
2215
 				}
2215
 				}
2216
-
2216
+				cancelInfo, _ := service.GetLastDrugCancelStockById(adminUserInfo.CurrentOrgId)
2217
 				cancelStockInfo := &models.DrugCancelStockInfo{
2217
 				cancelStockInfo := &models.DrugCancelStockInfo{
2218
-					OrderNumber:      cancelStock.OrderNumber,
2219
-					CancelStockId:    cancelStock.ID,
2218
+					OrderNumber:      cancelInfo.OrderNumber,
2219
+					CancelStockId:    cancelInfo.ID,
2220
 					DrugId:           drug_id,
2220
 					DrugId:           drug_id,
2221
 					Count:            count,
2221
 					Count:            count,
2222
 					Status:           1,
2222
 					Status:           1,
2278
 	}
2278
 	}
2279
 	//扣减库存逻辑
2279
 	//扣减库存逻辑
2280
 	for _, item := range cancelStockInfos {
2280
 	for _, item := range cancelStockInfos {
2281
+
2281
 		var total_number int64
2282
 		var total_number int64
2282
 		var out_number int64
2283
 		var out_number int64
2283
 		var can_number int64
2284
 		var can_number int64
2289
 		if item.MaxUnit == medical.MinUnit {
2290
 		if item.MaxUnit == medical.MinUnit {
2290
 			total_number = item.Count
2291
 			total_number = item.Count
2291
 		}
2292
 		}
2292
-		fmt.Println("当前退库数量", total_number)
2293
 		//查询当前药品退库的批次号的总入库数
2293
 		//查询当前药品退库的批次号的总入库数
2294
 		infoWareInfo, _ := service.GetDrugWarehouseInfo(item.BatchNumberId)
2294
 		infoWareInfo, _ := service.GetDrugWarehouseInfo(item.BatchNumberId)
2295
-		fmt.Println("hhh2h3h2hh3233", item.MaxUnit, medical.MaxUnit, infoWareInfo.StockMaxNumber, infoWareInfo.StockMinNumber)
2296
 		var total_count int64
2295
 		var total_count int64
2297
-		total_count = infoWareInfo.StockMaxNumber*medical.MinNumber + infoWareInfo.StockMinNumber
2296
+		total_count = infoWareInfo.WarehousingCount * medical.MinNumber
2298
 		fmt.Println("当前批次总库存", total_count)
2297
 		fmt.Println("当前批次总库存", total_count)
2299
 
2298
 
2300
 		//查询该批次的出库数量
2299
 		//查询该批次的出库数量
2311
 				item.Count = item.Count
2310
 				item.Count = item.Count
2312
 			}
2311
 			}
2313
 		}
2312
 		}
2313
+
2314
 		for _, item := range canInfo {
2314
 		for _, item := range canInfo {
2315
 			can_number += item.Count
2315
 			can_number += item.Count
2316
 		}
2316
 		}
2326
 		for _, item := range outInfo {
2326
 		for _, item := range outInfo {
2327
 			out_number += item.Count
2327
 			out_number += item.Count
2328
 		}
2328
 		}
2329
-		fmt.Println("当前退库数量", total_number)
2330
-		fmt.Println("出库数量23232232323222332", out_number)
2329
+
2331
 		if out_number == 0 {
2330
 		if out_number == 0 {
2332
 			service.UpdateDrugCancel(item.CancelStockId)
2331
 			service.UpdateDrugCancel(item.CancelStockId)
2333
 			c.ServeSuccessJSON(map[string]interface{}{
2332
 			c.ServeSuccessJSON(map[string]interface{}{
2335
 			})
2334
 			})
2336
 			return
2335
 			return
2337
 		}
2336
 		}
2337
+
2338
+		fmt.Println("hhhh233323232322323", total_number, total_count)
2339
+
2338
 		//判断退库数量是否大于总入库数量
2340
 		//判断退库数量是否大于总入库数量
2339
-		if total_number > out_number {
2341
+		if total_number > total_count {
2340
 			service.UpdateDrugCancel(item.CancelStockId)
2342
 			service.UpdateDrugCancel(item.CancelStockId)
2341
 			c.ServeSuccessJSON(map[string]interface{}{
2343
 			c.ServeSuccessJSON(map[string]interface{}{
2342
 				"msg": "2",
2344
 				"msg": "2",
2346
 
2348
 
2347
 		//判断总退库数量是否大于出库数量
2349
 		//判断总退库数量是否大于出库数量
2348
 		fmt.Println("该批次总退库数量", can_number+total_number)
2350
 		fmt.Println("该批次总退库数量", can_number+total_number)
2349
-		fmt.Println("总出口数量", out_number)
2351
+		fmt.Println("总出库数量", out_number)
2352
+		fmt.Println("当前退库数量", total_number)
2350
 		if can_number+total_number > out_number {
2353
 		if can_number+total_number > out_number {
2351
 			//清空退库单
2354
 			//清空退库单
2352
 			service.UpdateDrugCancel(item.CancelStockId)
2355
 			service.UpdateDrugCancel(item.CancelStockId)
2355
 			})
2358
 			})
2356
 			return
2359
 			return
2357
 		}
2360
 		}
2358
-
2361
+		fmt.Println("当前退库数量", total_number)
2362
+		fmt.Println("总出口数量", out_number)
2359
 		//正常退库
2363
 		//正常退库
2360
 		if total_number <= out_number {
2364
 		if total_number <= out_number {
2361
 			//创建退库详情
2365
 			//创建退库详情
2399
 					"msg": "1",
2403
 					"msg": "1",
2400
 				})
2404
 				})
2401
 			}
2405
 			}
2402
-			if errs != nil {
2403
-				utils.ErrorLog(errs.Error())
2404
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCancelStockFail)
2405
-				return
2406
-			}
2407
-
2408
-			c.ServeSuccessJSON(map[string]interface{}{
2409
-				"msg": "1",
2410
-			})
2411
 		}
2406
 		}
2412
 	}
2407
 	}
2413
 }
2408
 }

+ 4 - 0
controllers/gobal_config_api_controller.go View File

1040
 	dataBody := make(map[string]interface{}, 0)
1040
 	dataBody := make(map[string]interface{}, 0)
1041
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1041
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
1042
 	idsInters := dataBody["ids"].([]interface{})
1042
 	idsInters := dataBody["ids"].([]interface{})
1043
+	advice_type, _ := c.GetInt64("advice_type")
1044
+	stop_type, _ := c.GetInt64("stop_type")
1045
+	fmt.Println("advcie_type23323232322332", advice_type)
1046
+	fmt.Println("stop_type33332323223232323", stop_type)
1043
 	if len(idsInters) == 0 {
1047
 	if len(idsInters) == 0 {
1044
 		if err != nil {
1048
 		if err != nil {
1045
 			c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
1049
 			c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")

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

3955
 							err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
3955
 							err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
3956
 							break
3956
 							break
3957
 						}
3957
 						}
3958
-
3959
-						//if lastInfo.StockCount >= last_total {
3960
-						//	err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
3961
-						//	break
3962
-						//}
3963
-						//
3964
-						////如果库存不够,则出库到下一个批次
3965
-						//if lastInfo.StockCount < last_total {
3966
-						//
3967
-						//	err = ConsumablesDeliveryTotalSix(adminInfo.Org.Id, patient_id, record_time, beforePrepares, newBeforePrepares, adminInfo.AdminUser.Id)
3968
-						//	break
3969
-						//}
3970
 					}
3958
 					}
3971
 				}
3959
 				}
3972
 
3960
 

+ 8 - 0
controllers/mobile_api_controllers/patient_api_controller.go View File

975
 
975
 
976
 func (c *PatientApiController) ModifyExecDoctorAdvice() {
976
 func (c *PatientApiController) ModifyExecDoctorAdvice() {
977
 	execution_time := c.GetString("execution_time")
977
 	execution_time := c.GetString("execution_time")
978
+	fmt.Println("execution_time", execution_time)
978
 	groupno, _ := c.GetInt64("groupno", -1)
979
 	groupno, _ := c.GetInt64("groupno", -1)
979
 
980
 
980
 	var ids []string
981
 	var ids []string
1060
 			ExecutionTime: theTime.Unix(),
1061
 			ExecutionTime: theTime.Unix(),
1061
 			UpdatedTime:   time.Now().Unix(),
1062
 			UpdatedTime:   time.Now().Unix(),
1062
 		}
1063
 		}
1064
+		fmt.Println("ids2323232232323", ids)
1063
 		service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
1065
 		service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
1066
+
1067
+		project := models.HisPrescriptionProject{
1068
+			ExecutionTime: theTime.Unix(),
1069
+			Mtime:         time.Now().Unix(),
1070
+		}
1071
+		service.ModifyHisPrescriptionProject(&project, ids)
1064
 	}
1072
 	}
1065
 	if err != nil {
1073
 	if err != nil {
1066
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
1074
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)

+ 72 - 35
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go View File

293
 	}
293
 	}
294
 	if is_open == 1 {
294
 	if is_open == 1 {
295
 		//获取空床位的排班数据
295
 		//获取空床位的排班数据
296
-		list, err := service.GetPatientScheduleByBed(startTime, zoneid, orgid)
296
+		list, err := service.GetPatientScheduleByBed(startTime, zoneid, orgid, classtype)
297
 		stockType, _ := service.GetStockType(orgid)
297
 		stockType, _ := service.GetStockType(orgid)
298
 		if err != nil {
298
 		if err != nil {
299
 			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
299
 			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
372
 		"msg": "切换成功",
372
 		"msg": "切换成功",
373
 	})
373
 	})
374
 }
374
 }
375
-
376
-func (this *StaffScheduleApiController) UpdateBloodSchedule() {
377
-	timeLayout := "2006-01-02"
378
-	loc, _ := time.LoadLocation("Local")
379
-	id, _ := this.GetInt64("id")
375
+func (this *StaffScheduleApiController) UpdateDialysisPrescription() {
380
 	patient_id, _ := this.GetInt64("patient_id")
376
 	patient_id, _ := this.GetInt64("patient_id")
377
+	start_time, _ := this.GetInt64("start_time")
381
 	mode_id, _ := this.GetInt64("mode_id")
378
 	mode_id, _ := this.GetInt64("mode_id")
382
-	schedule_type, _ := this.GetInt64("schedule_type")
383
-	start_time := this.GetString("start_time")
384
 	dialyzer_perfusion_apparatus := this.GetString("dialyzer_perfusion_apparatus")
379
 	dialyzer_perfusion_apparatus := this.GetString("dialyzer_perfusion_apparatus")
385
-	var startTime int64
386
-	if len(start_time) > 0 {
387
-		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
380
+	dialysis_irrigation := this.GetString("dialysis_irrigation")
381
+	//更改透析模式
382
+	_, errcode := service.GetDialyisSolution(patient_id, start_time)
383
+	if errcode == gorm.ErrRecordNotFound {
384
+		orgId := this.GetMobileAdminUserInfo().Org.Id
385
+		prescription := models.DialysisPrescription{
386
+			DialysisDialyszers: dialyzer_perfusion_apparatus,
387
+			DialysisIrrigation: dialysis_irrigation,
388
+			PatientId:          patient_id,
389
+			UserOrgId:          orgId,
390
+			Status:             1,
391
+			RecordDate:         start_time,
392
+			CreatedTime:        time.Now().Unix(),
393
+			ModeId:             mode_id,
394
+		}
395
+		err := service.CreateDialysisPrescription(&prescription)
396
+
388
 		if err != nil {
397
 		if err != nil {
389
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
398
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
390
 			return
399
 			return
391
 		}
400
 		}
392
-		startTime = theTime.Unix()
401
+		this.ServeSuccessJSON(map[string]interface{}{
402
+			"msg": "保存成功",
403
+		})
404
+	} else if errcode == nil {
405
+		prescription := models.DialysisPrescription{
406
+			DialysisDialyszers: dialyzer_perfusion_apparatus,
407
+			DialysisIrrigation: dialysis_irrigation,
408
+			ModeId:             mode_id,
409
+		}
410
+		err := service.UpdateDialysisPrescriptionOne(prescription, patient_id, start_time, mode_id)
411
+		if err != nil {
412
+			this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
413
+			return
414
+		}
415
+		this.ServeSuccessJSON(map[string]interface{}{
416
+			"msg": "保存成功",
417
+		})
393
 	}
418
 	}
419
+}
394
 
420
 
421
+func (this *StaffScheduleApiController) UpdateBloodScheduleMode() {
422
+	id, _ := this.GetInt64("id")
423
+	mode_id, _ := this.GetInt64("mode_id")
424
+	schedule := models.XtSchedule{
425
+		ModeId: mode_id,
426
+	}
427
+	service.UpdatedScheduleMode(schedule, id)
428
+	this.ServeSuccessJSON(map[string]interface{}{
429
+		"msg": "保存成功",
430
+	})
431
+}
432
+
433
+func (this *StaffScheduleApiController) UpdateBloodSchedule() {
434
+
435
+	patient_id, _ := this.GetInt64("patient_id")
436
+	fmt.Println(patient_id)
437
+	mode_id, _ := this.GetInt64("mode_id")
438
+	schedule_type, _ := this.GetInt64("schedule_type")
439
+	start_time, _ := this.GetInt64("start_time")
440
+	bed_id, _ := this.GetInt64("bed_id")
395
 	//更改排班
441
 	//更改排班
396
 	schedule := models.XtSchedule{
442
 	schedule := models.XtSchedule{
397
 		ScheduleType: schedule_type,
443
 		ScheduleType: schedule_type,
398
 		ModeId:       mode_id,
444
 		ModeId:       mode_id,
399
 	}
445
 	}
400
 
446
 
401
-	service.UpdatedSchedule(schedule, id)
402
-
403
-	//更改透析模式
404
-	_, errcode := service.GetDialyisSolution(patient_id, startTime)
405
-	if errcode == gorm.ErrRecordNotFound {
406
-		orgId := this.GetAdminUserInfo().CurrentOrgId
407
-		prescription := models.DialysisPrescription{
408
-			DialyzerPerfusionApparatus: dialyzer_perfusion_apparatus,
409
-			DialysisDialyszers:         dialyzer_perfusion_apparatus,
410
-			PatientId:                  patient_id,
411
-			UserOrgId:                  orgId,
412
-			Status:                     1,
413
-			RecordDate:                 startTime,
414
-			CreatedTime:                time.Now().Unix(),
415
-		}
416
-		service.CreateDialysisPrescription(prescription)
417
-	} else if errcode == nil {
418
-		prescription := models.DialysisPrescription{
419
-			DialyzerPerfusionApparatus: dialyzer_perfusion_apparatus,
420
-			DialysisDialyszers:         dialyzer_perfusion_apparatus,
421
-		}
422
-		service.UpdateDialysisPrescriptionOne(prescription, patient_id, startTime)
447
+	//查询该床位该班次是否存在排班
448
+	_, errschedulecode := service.GetPatientScheduleIsExist(start_time, schedule_type, bed_id)
449
+	if errschedulecode == gorm.ErrRecordNotFound {
450
+		service.UpdatedSchedule(schedule, patient_id, start_time, schedule_type, bed_id)
451
+		this.ServeSuccessJSON(map[string]interface{}{
452
+			"msgerr": "保存成功",
453
+		})
454
+	} else if errschedulecode == nil {
455
+		this.ServeSuccessJSON(map[string]interface{}{
456
+			"msg":    "1",
457
+			"msgerr": "排班已存在",
458
+		})
423
 	}
459
 	}
460
+
424
 }
461
 }
425
 
462
 
426
 func (this *StaffScheduleApiController) GetSchedulePatient() {
463
 func (this *StaffScheduleApiController) GetSchedulePatient() {

+ 2 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go View File

20
 	beego.Router("/m/api/deleteSchedule", &StaffScheduleApiController{}, "Get:DeleteSchedule")
20
 	beego.Router("/m/api/deleteSchedule", &StaffScheduleApiController{}, "Get:DeleteSchedule")
21
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
21
 	beego.Router("/m/api/ssearchpatient", &StaffScheduleApiController{}, "Get:SearchPatient")
22
 	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
22
 	beego.Router("/m/api/updatepatientschedule", &StaffScheduleApiController{}, "Get:UpdatePatientScheduleById")
23
+	beego.Router("/m/api/updateschedulemode", &StaffScheduleApiController{}, "Get:UpdateBloodScheduleMode")
24
+	beego.Router("/m/api/updatedialysisprescription", &StaffScheduleApiController{}, "Get:UpdateDialysisPrescription")
23
 	beego.Router("/m/api/updateschedule", &StaffScheduleApiController{}, "Get:UpdateBloodSchedule")
25
 	beego.Router("/m/api/updateschedule", &StaffScheduleApiController{}, "Get:UpdateBloodSchedule")
24
 	beego.Router("m/api/schedule/patients", &StaffScheduleApiController{}, "Get:GetSchedulePatient")
26
 	beego.Router("m/api/schedule/patients", &StaffScheduleApiController{}, "Get:GetSchedulePatient")
25
 	beego.Router("/m/api/schedule/create", &StaffScheduleApiController{}, "Post:CreateMobileSchedulePatient")
27
 	beego.Router("/m/api/schedule/create", &StaffScheduleApiController{}, "Post:CreateMobileSchedulePatient")

+ 19 - 0
controllers/self_drug_api_congtroller.go View File

83
 	beego.Router("/api/drug/saveinentorylist", &SelfDrugApiController{}, "Post:SaveInventoryList")
83
 	beego.Router("/api/drug/saveinentorylist", &SelfDrugApiController{}, "Post:SaveInventoryList")
84
 
84
 
85
 	beego.Router("/api/drug/getdamagebydrugid", &SelfDrugApiController{}, "Get:GetDamageByDrugId")
85
 	beego.Router("/api/drug/getdamagebydrugid", &SelfDrugApiController{}, "Get:GetDamageByDrugId")
86
+
87
+	beego.Router("/api/drug/getinventorymodelist", &SelfDrugApiController{}, "Get:GetInventoryModeList")
86
 }
88
 }
87
 
89
 
88
 func (this *SelfDrugApiController) GetCurrentPatient() {
90
 func (this *SelfDrugApiController) GetCurrentPatient() {
2607
 		"list": list,
2609
 		"list": list,
2608
 	})
2610
 	})
2609
 }
2611
 }
2612
+
2613
+func (this *SelfDrugApiController) GetInventoryModeList() {
2614
+
2615
+	orgId := this.GetAdminUserInfo().CurrentOrgId
2616
+
2617
+	list, err := service.GetInventoryModeList(orgId)
2618
+	manufacturerList, err := service.GetAllManufacturerList(orgId)
2619
+	if err != nil {
2620
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
2621
+		return
2622
+	}
2623
+
2624
+	this.ServeSuccessJSON(map[string]interface{}{
2625
+		"list":             list,
2626
+		"manufacturerList": manufacturerList,
2627
+	})
2628
+}

+ 17 - 2
controllers/stock_in_api_controller.go View File

131
 	beego.Router("/api/stock/getgoodinventorywarehouselist", &StockManagerApiController{}, "Get:GetGoodInventoryWarehouseList")
131
 	beego.Router("/api/stock/getgoodinventorywarehouselist", &StockManagerApiController{}, "Get:GetGoodInventoryWarehouseList")
132
 	beego.Router("/api/stock/savestockinentorylist", &StockManagerApiController{}, "Post:SaveStockInventoryList")
132
 	beego.Router("/api/stock/savestockinentorylist", &StockManagerApiController{}, "Post:SaveStockInventoryList")
133
 	beego.Router("/api/sotck/getdamagedetailbygoodid", &StockManagerApiController{}, "Get:GetDamageDetailByGoodId")
133
 	beego.Router("/api/sotck/getdamagedetailbygoodid", &StockManagerApiController{}, "Get:GetDamageDetailByGoodId")
134
+	beego.Router("/api/stock/getinventoryexportlist", &StockManagerApiController{}, "Get:GetInventoryExportList")
134
 }
135
 }
135
 
136
 
136
 func (c *StockManagerApiController) CreateWarehouse() {
137
 func (c *StockManagerApiController) CreateWarehouse() {
2092
 	for _, item := range cancelStockInfos {
2093
 	for _, item := range cancelStockInfos {
2093
 
2094
 
2094
 		//统计该批次耗材的出库数量
2095
 		//统计该批次耗材的出库数量
2095
-		info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId, item.WarehouseInfoId)
2096
+		//info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId, item.WarehouseInfoId)
2097
+
2098
+		info, _ := service.GetWarehoureOrderStockOutFlow(item.GoodId, item.OrgId, item.WarehouseInfoId)
2096
 		fmt.Println("2333223323322332233223322323", item.Count, info.Count)
2099
 		fmt.Println("2333223323322332233223322323", item.Count, info.Count)
2097
 		if item.Count > info.Count {
2100
 		if item.Count > info.Count {
2098
 			service.UpdateCancelInfo(item.CancelStockId)
2101
 			service.UpdateCancelInfo(item.CancelStockId)
2489
 
2492
 
2490
 		for _, item := range cancelStockInfos {
2493
 		for _, item := range cancelStockInfos {
2491
 			//统计该耗材的出库数量
2494
 			//统计该耗材的出库数量
2492
-			info, _ := service.GetWarehoureOrderInfoCount(item.GoodId, item.OrgId, item.WarehouseInfoId)
2495
+			info, _ := service.GetWarehoureOrderStockOutFlow(item.GoodId, item.OrgId, item.WarehouseInfoId)
2493
 			if item.Count > info.Count {
2496
 			if item.Count > info.Count {
2494
 				c.ServeSuccessJSON(map[string]interface{}{
2497
 				c.ServeSuccessJSON(map[string]interface{}{
2495
 					"msg": "2",
2498
 					"msg": "2",
6496
 		"damageList": damageList,
6499
 		"damageList": damageList,
6497
 	})
6500
 	})
6498
 }
6501
 }
6502
+
6503
+func (this *StockManagerApiController) GetInventoryExportList() {
6504
+
6505
+	orgId := this.GetAdminUserInfo().CurrentOrgId
6506
+
6507
+	list, _ := service.GetInventoryExportList(orgId)
6508
+	manufacturerList, _ := service.GetAllManufacturerList(orgId)
6509
+	this.ServeSuccessJSON(map[string]interface{}{
6510
+		"list":             list,
6511
+		"manufacturerList": manufacturerList,
6512
+	})
6513
+}

+ 2 - 0
models/common_models.go View File

294
 	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
294
 	PunctureNeedleCount        float64 `gorm:"column:puncture_needle_count" json:"puncture_needle_count" form:"puncture_needle_count"`
295
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
295
 	Epo                        string  `gorm:"column:epo" json:"epo" form:"epo"`
296
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
296
 	EpoCount                   float64 `gorm:"column:epo_count" json:"epo_count" form:"epo_count"`
297
+	DialysisDialyszers         string  `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
298
+	DialysisIrrigation         string  `gorm:"column:dialysis_irrigation" json:"dialysis_irrigation" form:"dialysis_irrigation"`
297
 }
299
 }
298
 
300
 
299
 func (BloodDialysisPrescription) TableName() string {
301
 func (BloodDialysisPrescription) TableName() string {

+ 10 - 9
models/device_models.go View File

140
 }
140
 }
141
 
141
 
142
 type DeviceNumber struct {
142
 type DeviceNumber struct {
143
-	ID         int64  `gorm:"column:id" json:"id"`
144
-	OrgID      int64  `gorm:"column:org_id" json:"-"`
145
-	Number     string `gorm:"column:number" json:"number"`
146
-	GroupID    int64  `gorm:"column:group_id" json:"group_id"`
147
-	ZoneID     int64  `gorm:"column:zone_id" json:"zone_id"`
148
-	Status     int8   `json:"-"`
149
-	CreateTime int64  `gorm:"column:ctime" json:"-"`
150
-	ModifyTime int64  `gorm:"column:mtime" json:"-"`
151
-	Sort       int64  `gorm:"column:sort" json:"sort" form:"sort"`
143
+	ID         int64      `gorm:"column:id" json:"id"`
144
+	OrgID      int64      `gorm:"column:org_id" json:"-"`
145
+	Number     string     `gorm:"column:number" json:"number"`
146
+	GroupID    int64      `gorm:"column:group_id" json:"group_id"`
147
+	ZoneID     int64      `gorm:"column:zone_id" json:"zone_id"`
148
+	Status     int8       `json:"-"`
149
+	CreateTime int64      `gorm:"column:ctime" json:"-"`
150
+	ModifyTime int64      `gorm:"column:mtime" json:"-"`
151
+	Sort       int64      `gorm:"column:sort" json:"sort" form:"sort"`
152
+	DeviceZone DeviceZone `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:ZoneID;"`
152
 }
153
 }
153
 
154
 
154
 func (DeviceNumber) TableName() string {
155
 func (DeviceNumber) TableName() string {

+ 4 - 3
models/drug.go View File

65
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
65
 	HospApprFlag                int64   `gorm:"column:hosp_appr_flag" json:"hosp_appr_flag" form:"hosp_appr_flag"`
66
 	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
66
 	LmtUsedFlag                 int64   `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
67
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
67
 	//MedicineInsurancePercentage []*MedicineInsurancePercentage `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"monitoring_record"`
68
-	DrugDay               string  `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
69
-	Total                 float64 `gorm:"column:total" json:"total" form:"total"`
70
-	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
68
+	DrugDay               string                 `gorm:"column:drug_day" json:"drug_day" form:"drug_day"`
69
+	Total                 float64                `gorm:"column:total" json:"total" form:"total"`
70
+	PrescribingNumberUnit string                 `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
71
+	DrugWarehouseInfo     []*XtDrugWarehouseInfo `gorm:"ForeignKey:DrugId;AssociationForeignKey:ID" json:"drug_warehouse_info"`
71
 }
72
 }
72
 
73
 
73
 func (BaseDrugLib) TableName() string {
74
 func (BaseDrugLib) TableName() string {

+ 2 - 2
models/patient_models.go View File

1250
 	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii" form:"ductus_arantii"`
1250
 	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii" form:"ductus_arantii"`
1251
 	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment" form:"emergency_treatment"`
1251
 	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment" form:"emergency_treatment"`
1252
 	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other" form:"emergency_treatment_other"`
1252
 	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other" form:"emergency_treatment_other"`
1253
-	DialysisCount                  int64   `gorm:"column:dialysis_count" json:"dialysis_count" form:"dialysis_count"`
1253
+	DialysisCount                  string  `gorm:"column:dialysis_count" json:"dialysis_count" form:"dialysis_count"`
1254
 	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor" form:"assessment_doctor"`
1254
 	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor" form:"assessment_doctor"`
1255
 	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time" form:"assessment_time"`
1255
 	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time" form:"assessment_time"`
1256
 	MachineType                    string  `gorm:"column:machine_type" json:"machine_type" form:"machine_type"`
1256
 	MachineType                    string  `gorm:"column:machine_type" json:"machine_type" form:"machine_type"`
1262
 	DuctusArantiiOther             string  `gorm:"column:ductus_arantii_other" json:"ductus_arantii_other" form:"ductus_arantii_other"`
1262
 	DuctusArantiiOther             string  `gorm:"column:ductus_arantii_other" json:"ductus_arantii_other" form:"ductus_arantii_other"`
1263
 	PunctureNeedle                 string  `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
1263
 	PunctureNeedle                 string  `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
1264
 	DialysisIntakesUnit            int64   `gorm:"column:dialysis_intakes_unit" json:"dialysis_intakes_unit" form:"dialysis_intakes_unit"`
1264
 	DialysisIntakesUnit            int64   `gorm:"column:dialysis_intakes_unit" json:"dialysis_intakes_unit" form:"dialysis_intakes_unit"`
1265
-	HumorExcessiveSymptom          int64   `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom" form:"humor_excessive_symptom"`
1265
+	HumorExcessiveSymptom          string  `gorm:"column:humor_excessive_symptom" json:"humor_excessive_symptom" form:"humor_excessive_symptom"`
1266
 	LastPostDialysisOther          string  `gorm:"column:last_post_dialysis_other" json:"last_post_dialysis_other" form:"last_post_dialysis_other"`
1266
 	LastPostDialysisOther          string  `gorm:"column:last_post_dialysis_other" json:"last_post_dialysis_other" form:"last_post_dialysis_other"`
1267
 	SymptomBeforeDialysisOther     string  `gorm:"column:symptom_before_dialysis_other" json:"symptom_before_dialysis_other" form:"symptom_before_dialysis_other"`
1267
 	SymptomBeforeDialysisOther     string  `gorm:"column:symptom_before_dialysis_other" json:"symptom_before_dialysis_other" form:"symptom_before_dialysis_other"`
1268
 	DialysisInterphaseOther        string  `gorm:"column:dialysis_interphase_other" json:"dialysis_interphase_other" form:"dialysis_interphase_other"`
1268
 	DialysisInterphaseOther        string  `gorm:"column:dialysis_interphase_other" json:"dialysis_interphase_other" form:"dialysis_interphase_other"`

+ 7 - 9
models/schedule_models.go View File

49
 	DeviceNumber              DeviceNumber         `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
49
 	DeviceNumber              DeviceNumber         `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
50
 	TreatmentMode             TreatmentMode        `json:"mode" gorm:"foreignkey:ModeId"`
50
 	TreatmentMode             TreatmentMode        `json:"mode" gorm:"foreignkey:ModeId"`
51
 	DialysisOrder             DialysisOrder        `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
51
 	DialysisOrder             DialysisOrder        `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
52
-	DialysisPrescription      DialysisPrescription `json:"order" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId;"`
52
+	DialysisPrescription      DialysisPrescription `json:"dialysis_prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId;"`
53
 	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
53
 	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
54
 }
54
 }
55
 
55
 
190
 
190
 
191
 	DeviceZone                 DeviceZone                 `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
191
 	DeviceZone                 DeviceZone                 `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
192
 	DeviceNumber               DeviceNumber               `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
192
 	DeviceNumber               DeviceNumber               `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
193
-	DialysisOrder              DialysisOrder              `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
193
+	DialysisOrder              DialysisOrder              `json:"order" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
194
 	XtPatients                 XtPatients                 `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
194
 	XtPatients                 XtPatients                 `json:"patient" gorm:"foreignkey:ID;AssociationForeignKey:PatientId;"`
195
-	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
196
-	DialysisPrescription       DialysisPrescription       `json:"prescription" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
197
-	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
198
-	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
199
-	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
200
-	Solution                   []*DialysisSolution        `json:"solution" gorm:"foreignkey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
195
+	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
196
+	DialysisPrescription       DialysisPrescription       `json:"prescription" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
197
+	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
198
+	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId;"`
199
+	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
201
 }
200
 }
202
 
201
 
203
 func (VmSchedulesRemind) TableName() string {
202
 func (VmSchedulesRemind) TableName() string {
225
 	DialysisPrescription       DialysisSolution           `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
224
 	DialysisPrescription       DialysisSolution           `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
226
 	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
225
 	DoctorAdvice               []*DoctorAdvice            `json:"doctoradvice" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
227
 	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
226
 	HisDoctorAdviceInfo        []*HisDoctorAdviceInfo     `json:"hisdoctoradviceinfo" gorm:"foreignkey:AdviceDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
228
-	Solution                   []*DialysisSolution        `json:"solution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
229
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
227
 	DialysisSolution           DialysisSolution           `json:"dialysissolution" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
230
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate"`
228
 	XtAssessmentBeforeDislysis XtAssessmentBeforeDislysis `json:"assessmentbefor" gorm:"foreignkey:PatientId,AssessmentDate;AssociationForeignKey:PatientId,ScheduleDate"`
231
 }
229
 }

+ 18 - 0
models/self_drug_models.go View File

936
 func (SgjDrugWarehouseOutInfo) TableName() string {
936
 func (SgjDrugWarehouseOutInfo) TableName() string {
937
 	return "xt_drug_warehouse_out_info"
937
 	return "xt_drug_warehouse_out_info"
938
 }
938
 }
939
+
940
+type PatientDrugWarehouseInfo struct {
941
+	DrugId         int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
942
+	Number         string  `gorm:"column:number" json:"number" form:"number"`
943
+	ProductDate    int64   `gorm:"column:product_date" json:"product_date" form:"product_date"`
944
+	ExpiryDate     int64   `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
945
+	StockMaxNumber int64   `gorm:"column:stock_max_number" json:"stock_max_number" form:"stock_max_number"`
946
+	StockMinNumber int64   `gorm:"column:stock_min_number" json:"stock_min_number" form:"stock_min_number"`
947
+	BatchNumber    string  `gorm:"column:batch_number" json:"batch_number" form:"batch_number"`
948
+	DrugName       string  `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
949
+	MaxUnit        string  `gorm:"column:max_unit" json:"max_unit" form:"max_unit"`
950
+	MinUnit        string  `gorm:"column:min_unit" json:"min_unit" form:"min_unit"`
951
+	MinNumber      int64   `gorm:"column:min_number" json:"min_number" form:"min_number"`
952
+	Dose           float64 `gorm:"column:dose" json:"dose" form:"dose"`
953
+	DoseUnit       string  `gorm:"column:dose_unit" json:"dose_unit" form:"dose_unit"`
954
+	Manufacturer   int64   `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
955
+	Dealer         int64   `gorm:"column:dealer" json:"dealer" form:"dealer"`
956
+}

+ 43 - 23
models/stock_models.go View File

551
 }
551
 }
552
 
552
 
553
 type CancelStockInfo struct {
553
 type CancelStockInfo struct {
554
-	ID              int64       `gorm:"column:id" json:"id"`
555
-	GoodId          int64       `gorm:"column:good_id" json:"good_id"`
556
-	CancelStockId   int64       `gorm:"column:cancel_stock_id" json:"cancel_stock_id"`
557
-	GoodTypeId      int64       `gorm:"column:good_type_id" json:"good_type_id"`
558
-	Count           int64       `gorm:"column:count" json:"count"`
559
-	Price           float64     `gorm:"column:price" json:"price"`
560
-	Total           float64     `gorm:"column:total" json:"total"`
561
-	ProductDate     int64       `gorm:"column:product_date" json:"product_date"`
562
-	ExpiryDate      int64       `gorm:"column:expiry_date" json:"expiry_date"`
563
-	Ctime           int64       `gorm:"column:ctime" json:"ctime"`
564
-	Mtime           int64       `gorm:"column:mtime" json:"mtime"`
565
-	Status          int64       `gorm:"column:status" json:"status"`
566
-	OrgId           int64       `gorm:"column:org_id" json:"org_id"`
567
-	OrderNumber     string      `gorm:"column:order_number" json:"order_number"`
568
-	Type            int64       `gorm:"column:type" json:"type"`
569
-	CancelStock     CancelStock `ForeignKey:CancelStockId json:"CancelStock"`
570
-	Dealer          string      `gorm:"column:dealer" json:"dealer"`
571
-	Manufacturer    string      `gorm:"column:manufacturer" json:"manufacturer"`
572
-	Number          string      `gorm:"column:number" json:"number" form:"number"`
573
-	RegisterAccount string      `gorm:"column:register_account" json:"register_account" form:"register_account"`
574
-	Remark          string      `gorm:"column:remark" json:"remark" form:"remark"`
575
-	WarehouseInfoId int64       `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
576
-	GoodInfo        GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
554
+	ID              int64              `gorm:"column:id" json:"id"`
555
+	GoodId          int64              `gorm:"column:good_id" json:"good_id"`
556
+	CancelStockId   int64              `gorm:"column:cancel_stock_id" json:"cancel_stock_id"`
557
+	GoodTypeId      int64              `gorm:"column:good_type_id" json:"good_type_id"`
558
+	Count           int64              `gorm:"column:count" json:"count"`
559
+	Price           float64            `gorm:"column:price" json:"price"`
560
+	Total           float64            `gorm:"column:total" json:"total"`
561
+	ProductDate     int64              `gorm:"column:product_date" json:"product_date"`
562
+	ExpiryDate      int64              `gorm:"column:expiry_date" json:"expiry_date"`
563
+	Ctime           int64              `gorm:"column:ctime" json:"ctime"`
564
+	Mtime           int64              `gorm:"column:mtime" json:"mtime"`
565
+	Status          int64              `gorm:"column:status" json:"status"`
566
+	OrgId           int64              `gorm:"column:org_id" json:"org_id"`
567
+	OrderNumber     string             `gorm:"column:order_number" json:"order_number"`
568
+	Type            int64              `gorm:"column:type" json:"type"`
569
+	CancelStock     CancelStock        `ForeignKey:CancelStockId json:"CancelStock"`
570
+	Dealer          string             `gorm:"column:dealer" json:"dealer"`
571
+	Manufacturer    string             `gorm:"column:manufacturer" json:"manufacturer"`
572
+	Number          string             `gorm:"column:number" json:"number" form:"number"`
573
+	RegisterAccount string             `gorm:"column:register_account" json:"register_account" form:"register_account"`
574
+	Remark          string             `gorm:"column:remark" json:"remark" form:"remark"`
575
+	WarehouseInfoId int64              `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
576
+	GoodInfo        GoodInfo           `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
577
+	WarehousingInfo []*WarehousingInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:GoodId" json:"xt_warehouse_info"`
577
 }
578
 }
578
 
579
 
579
 func (CancelStockInfo) TableName() string {
580
 func (CancelStockInfo) TableName() string {
1124
 func (GoodSotckInfo) TableName() string {
1125
 func (GoodSotckInfo) TableName() string {
1125
 	return "xt_warehouse_info"
1126
 	return "xt_warehouse_info"
1126
 }
1127
 }
1128
+
1129
+type PatientWarehouseInfo struct {
1130
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
1131
+	GoodId            int64  `gorm:"column:good_id" json:"good_id" form:"good_id"`
1132
+	Number            string `gorm:"column:number" json:"number" form:"number"`
1133
+	ProductDate       int64  `gorm:"column:product_date" json:"product_date" form:"product_date"`
1134
+	ExpiryDate        int64  `gorm:"column:expiry_date" json:"expiry_date" form:"expiry_date"`
1135
+	WarehousingUnit   string `gorm:"column:warehousing_unit" json:"warehousing_unit" form:"warehousing_unit"`
1136
+	Dealer            int64  `gorm:"column:dealer" json:"dealer" form:"dealer"`
1137
+	Manufacturer      int64  `gorm:"column:manufacturer" json:"manufacturer" form:"manufacturer"`
1138
+	GoodName          string `gorm:"column:good_name" json:"good_name"`
1139
+	SpecificationName string `gorm:"column:specification_name" json:"specification_name" form:"specification_name"`
1140
+	PackingUnit       string `gorm:"column:packing_unit" json:"packing_unit" form:"packing_unit"`
1141
+	Remark            string `gorm:"column:remark" json:"remark" form:"remark"`
1142
+}
1143
+
1144
+func (PatientWarehouseInfo) TableName() string {
1145
+	return "xt_warehouse_info"
1146
+}

+ 11 - 0
service/dialysis_service.go View File

1219
 	return err
1219
 	return err
1220
 }
1220
 }
1221
 
1221
 
1222
+func ModifyHisPrescriptionProject(m *models.HisPrescriptionProject, ids []string) (err error) {
1223
+	ut := writeDb.Begin()
1224
+	err = ut.Model(&models.HisPrescriptionProject{}).Where("status = 1   AND id IN (?) AND execution_state = 1", ids).Updates(map[string]interface{}{"execution_time": m.ExecutionTime}).Error
1225
+	if err != nil {
1226
+		ut.Rollback()
1227
+		return
1228
+	}
1229
+	ut.Commit()
1230
+	return err
1231
+}
1232
+
1222
 func FindHisProjectById(orgID int64, id int64) (advice models.HisPrescriptionProject, err error) {
1233
 func FindHisProjectById(orgID int64, id int64) (advice models.HisPrescriptionProject, err error) {
1223
 	err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1234
 	err = readDb.Model(&models.HisPrescriptionProject{}).Where("user_org_id=? and status=1 and id = ?", orgID, id).First(&advice).Error
1224
 	return
1235
 	return

+ 47 - 13
service/doctor_schedule_service.go View File

598
 	return schedule, err
598
 	return schedule, err
599
 }
599
 }
600
 
600
 
601
-func GetPatientScheduleByBed(schedule_date int64, zoneid int64, orgid int64) (list []*models.PatientDeviceNumber, err error) {
601
+func GetPatientScheduleByBed(schedule_date int64, zoneid int64, orgid int64, class_type int64) (list []*models.PatientDeviceNumber, err error) {
602
 
602
 
603
 	db := XTReadDB().Table("xt_device_number as x").Where("x.status = 1")
603
 	db := XTReadDB().Table("xt_device_number as x").Where("x.status = 1")
604
 	if zoneid > 0 {
604
 	if zoneid > 0 {
607
 	if orgid > 0 {
607
 	if orgid > 0 {
608
 		db = db.Where("x.org_id = ?", orgid)
608
 		db = db.Where("x.org_id = ?", orgid)
609
 	}
609
 	}
610
-	err = db.Select("x.id,x.number,x.sort,x.group_id,x.zone_id,x.sort").Preload("DeviceZone", "status = 1").Preload("Schedule", func(db *gorm.DB) *gorm.DB {
611
-		return XTReadDB().Model(&models.BlodSchedule{}).Where("status = 1 AND user_org_id = ? and schedule_date = ?", orgid, schedule_date).Preload("VmBloodPatients", "status = 1 and user_org_id = ?", orgid).Preload("BloodDialysisOrder", "status = 1").Preload("BloodDialysisPrescription", "status = 1")
612
-	}).Find(&list).Error
610
+	if class_type > 0 {
611
+		err = db.Select("x.id,x.number,x.sort,x.group_id,x.zone_id,x.sort").Preload("DeviceZone", "status = 1").Preload("Schedule", func(db *gorm.DB) *gorm.DB {
612
+			return XTReadDB().Model(&models.BlodSchedule{}).Where("status = 1 AND user_org_id = ? and schedule_date = ? and schedule_type = ?", orgid, schedule_date, class_type).Preload("VmBloodPatients", "status = 1 and user_org_id = ?", orgid).Preload("BloodDialysisOrder", "status = 1 and dialysis_date = ?", schedule_date).Preload("BloodDialysisPrescription", "status = 1 and record_date = ?", schedule_date)
613
+		}).Find(&list).Error
614
+	} else {
615
+		err = db.Select("x.id,x.number,x.sort,x.group_id,x.zone_id,x.sort").Preload("DeviceZone", "status = 1").Preload("Schedule", func(db *gorm.DB) *gorm.DB {
616
+			return XTReadDB().Model(&models.BlodSchedule{}).Where("status = 1 AND user_org_id = ? and schedule_date = ?", orgid, schedule_date).Preload("VmBloodPatients", "status = 1 and user_org_id = ?", orgid).Preload("BloodDialysisOrder", "status = 1 and dialysis_date = ?", schedule_date).Preload("BloodDialysisPrescription", "status = 1 and record_date = ?", schedule_date)
617
+		}).Find(&list).Error
618
+	}
613
 
619
 
614
 	return list, err
620
 	return list, err
615
 }
621
 }
642
 
648
 
643
 	likeKey := "%" + keywords + "%"
649
 	likeKey := "%" + keywords + "%"
644
 	db := XTReadDB().Table("xt_schedule as s")
650
 	db := XTReadDB().Table("xt_schedule as s")
645
-	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", "status= 1").
646
-		Preload("DialysisOrder", "status =1").
651
+	err = db.Preload("DeviceZone", " status= 1").Preload("DeviceNumber", func(db *gorm.DB) *gorm.DB {
652
+		return db.Where("status =1").Preload("DeviceZone", "status = 1")
653
+	}).Preload("DialysisOrder", "status =1").
647
 		Joins("JOIN xt_patients as p ON p.id = s.patient_id And(p.name LIKE ? OR p.dialysis_no LIKE ?)", likeKey, likeKey).Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
654
 		Joins("JOIN xt_patients as p ON p.id = s.patient_id And(p.name LIKE ? OR p.dialysis_no LIKE ?)", likeKey, likeKey).Where("s.user_org_id = ? and s.schedule_date = ? and s.status =1", orgid, startime).
648
 		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
655
 		Select("s.id, s.user_org_id, s.partition_id, s.bed_id, s.patient_id, s.schedule_date, s.schedule_type, s.schedule_week, s.mode_id,p.name as patient").Find(&schedule).Error
649
 	return schedule, err
656
 	return schedule, err
668
 	return err
675
 	return err
669
 }
676
 }
670
 
677
 
671
-func UpdatedSchedule(schedule models.XtSchedule, id int64) error {
678
+func UpdatedScheduleMode(schedule models.XtSchedule, id int64) error {
679
+
680
+	xtSchedule := models.XtSchedule{}
681
+	err := XTWriteDB().Model(&xtSchedule).Where("id = ? and status =1 ", id).Updates(map[string]interface{}{"mode_id": schedule.ModeId}).Error
682
+	return err
683
+}
684
+
685
+func UpdatedSchedule(schedule models.XtSchedule, patient_id int64, schedule_date int64, schedule_type int64, bed_id int64) error {
672
 
686
 
673
 	xtSchedule := models.XtSchedule{}
687
 	xtSchedule := models.XtSchedule{}
674
-	err := XTWriteDB().Model(&xtSchedule).Where("id = ? and status =1", id).Updates(map[string]interface{}{"schedule_type": schedule.ScheduleType, "mode_id": schedule.ModeId}).Error
688
+	err := XTWriteDB().Model(&xtSchedule).Where("patient_id = ? and status =1 and schedule_date = ?  and bed_id = ?", patient_id, schedule_date, bed_id).Updates(map[string]interface{}{"schedule_type": schedule.ScheduleType, "mode_id": schedule.ModeId}).Error
675
 	return err
689
 	return err
676
 }
690
 }
677
 
691
 
679
 
693
 
680
 	prescription := models.DialysisPrescription{}
694
 	prescription := models.DialysisPrescription{}
681
 
695
 
682
-	err := XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and status = 1", patientid, recorddate).Find(&prescription).Error
696
+	err := XTReadDB().Where("patient_id = ? and record_date = ? and status = 1", patientid, recorddate).Find(&prescription).Error
697
+	if err != nil {
698
+		if err == gorm.ErrRecordNotFound {
699
+			return nil, err
700
+		} else {
701
+			return nil, err
702
+		}
703
+	}
704
+	return &prescription, nil
705
+}
706
+
707
+func GetPatientScheduleIsExist(startime int64, schedule_type int64, bed_id int64) (*models.Schedule, error) {
708
+
709
+	schedule := models.Schedule{}
710
+	err := XTReadDB().Model(&schedule).Where("schedule_date = ? and schedule_type = ? and bed_id = ? and status = 1", startime, schedule_type, bed_id).Find(&schedule).Error
683
 	if err == gorm.ErrRecordNotFound {
711
 	if err == gorm.ErrRecordNotFound {
684
 		return nil, err
712
 		return nil, err
685
 	}
713
 	}
686
 	if err != nil {
714
 	if err != nil {
687
 		return nil, err
715
 		return nil, err
688
 	}
716
 	}
689
-	return &prescription, nil
717
+	return &schedule, nil
690
 }
718
 }
691
 
719
 
692
-func CreateDialysisPrescription(prescription models.DialysisPrescription) error {
720
+func CreateDialysisPrescription(prescription *models.DialysisPrescription) error {
693
 
721
 
694
 	err := XTReadDB().Create(&prescription).Error
722
 	err := XTReadDB().Create(&prescription).Error
695
 
723
 
696
 	return err
724
 	return err
697
 }
725
 }
698
 
726
 
699
-func UpdateDialysisPrescriptionOne(prescription models.DialysisPrescription, patientid int64, recordate int64) error {
727
+func CreateDialysisSolution(solution models.DialysisSolution) error {
728
+
729
+	err := XTReadDB().Create(&solution).Error
730
+	return err
731
+}
732
+
733
+func UpdateDialysisPrescriptionOne(prescription models.DialysisPrescription, patientid int64, recordate int64, mode_id int64) error {
700
 
734
 
701
-	err := XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and status = 1", patientid, recordate).Updates(map[string]interface{}{"dialyzers": prescription.Dialyzer, "dialyzer_perfusion_apparatus": prescription.DialyzerPerfusionApparatus}).Error
735
+	err := XTReadDB().Model(&prescription).Where("patient_id = ? and record_date = ? and status = 1", patientid, recordate).Updates(map[string]interface{}{"dialysis_dialyszers": prescription.DialysisDialyszers, "mode_id": mode_id, "dialysis_irrigation": prescription.DialysisIrrigation}).Error
702
 	return err
736
 	return err
703
 }
737
 }

+ 2 - 2
service/gobal_config_service.go View File

166
 func GetPrint(ids []int64, orgid int64) (doctor []*models.DoctorAdvice, err error) {
166
 func GetPrint(ids []int64, orgid int64) (doctor []*models.DoctorAdvice, err error) {
167
 
167
 
168
 	if len(ids) == 1 {
168
 	if len(ids) == 1 {
169
-		err = XTReadDB().Model(&doctor).Where("groupno = ? and user_org_id = ?", ids[0], orgid).Find(&doctor).Error
169
+		err = XTReadDB().Model(&doctor).Where("groupno = ? and user_org_id = ? and status = 1", ids[0], orgid).Find(&doctor).Error
170
 	} else {
170
 	} else {
171
-		err = XTReadDB().Model(&doctor).Where("groupno IN(?) and user_org_id = ?", ids, orgid).Find(&doctor).Error
171
+		err = XTReadDB().Model(&doctor).Where("groupno IN(?) and user_org_id = ? and status = 1", ids, orgid).Find(&doctor).Error
172
 	}
172
 	}
173
 
173
 
174
 	return doctor, err
174
 	return doctor, err

+ 1 - 1
service/print_data_service/schedule_dialysis/print_schedule_dialysis_models.go View File

267
 	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii"`
267
 	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii"`
268
 	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment"`
268
 	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment"`
269
 	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other"`
269
 	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other"`
270
-	DialysisCount                  int64   `gorm:"column:dialysis_count" json:"dialysis_count"`
270
+	DialysisCount                  string  `gorm:"column:dialysis_count" json:"dialysis_count"`
271
 	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
271
 	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
272
 	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time"`
272
 	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time"`
273
 	MachineType                    string  `gorm:"column:machine_type" json:"machine_type"`
273
 	MachineType                    string  `gorm:"column:machine_type" json:"machine_type"`

+ 6 - 12
service/schedule_service.go View File

605
 		db = db.Where("x.partition_id in (?)", zone)
605
 		db = db.Where("x.partition_id in (?)", zone)
606
 	}
606
 	}
607
 
607
 
608
-	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("XtAssessmentBeforeDislysis", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
609
-		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
610
-	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
608
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date = ?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
609
+		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
610
+	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date =?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
611
 		return db.Where("status =1").Order("id asc")
611
 		return db.Where("status =1").Order("id asc")
612
-	}).Preload("Solution", func(db *gorm.DB) *gorm.DB {
613
-		return db.Where("status =1").Group("patient_id,mode_id").Order("id asc")
614
 	}).Find(&list).Error
612
 	}).Find(&list).Error
615
 
613
 
616
 	return list, err
614
 	return list, err
632
 		db = db.Where("x.partition_id in (?)", zone)
630
 		db = db.Where("x.partition_id in (?)", zone)
633
 	}
631
 	}
634
 
632
 
635
-	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1").Preload("XtAssessmentBeforeDislysis", "status = 1").Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
636
-		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
637
-	}).Preload("HisDoctorAdviceInfo", "status = 1").Preload("DialysisPrescription", "status = 1").Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
633
+	err = db.Select("x.id,x.user_org_id,x.partition_id,x.bed_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,x.is_export").Preload("XtPatients", "status = 1").Preload("DeviceZone", "status = 1").Preload("DeviceNumber", "status = 1").Preload("DialysisOrder", "status = 1 and dialysis_date =?", scheduleDate).Preload("XtAssessmentBeforeDislysis", "status = 1 and assessment_date =?", scheduleDate).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
634
+		return db.Where("status =1 and parent_id = 0 and advice_date = ?", scheduleDate).Preload("ChildDoctorAdvice", "status = 1")
635
+	}).Preload("HisDoctorAdviceInfo", "status = 1 and advice_date = ?", scheduleDate).Preload("DialysisPrescription", "status = 1 and record_date = ?", scheduleDate).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
638
 		return db.Where("status =1").Order("id asc")
636
 		return db.Where("status =1").Order("id asc")
639
-	}).Preload("Solution", func(db *gorm.DB) *gorm.DB {
640
-		return db.Where("status =1").Group("patient_id,mode_id").Order("id desc")
641
 	}).Find(&list).Error
637
 	}).Find(&list).Error
642
 
638
 
643
 	return list, err
639
 	return list, err
824
 			return db.Where("status = 1").Order("id asc")
820
 			return db.Where("status = 1").Order("id asc")
825
 		}).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
821
 		}).Preload("DialysisSolution", func(db *gorm.DB) *gorm.DB {
826
 		return db.Where("status = 1").Order("id asc")
822
 		return db.Where("status = 1").Order("id asc")
827
-	}).Preload("Solution", func(db *gorm.DB) *gorm.DB {
828
-		return db.Where("status = 1").Group("patient_id,mode_id").Order("id asc")
829
 	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
823
 	}).Preload("DoctorAdvice", func(db *gorm.DB) *gorm.DB {
830
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
824
 		return db.Where("status =1 and parent_id = 0").Preload("ChildDoctorAdvice", "status = 1")
831
 	}).Preload("HisDoctorAdviceInfo", "status = 1").Joins("JOIN xt_patients as p ON p.id = s.patient_id").
825
 	}).Preload("HisDoctorAdviceInfo", "status = 1").Joins("JOIN xt_patients as p ON p.id = s.patient_id").

+ 16 - 1
service/self_drug_service.go View File

1126
 
1126
 
1127
 func GetDamageByDrugId(drugid int64, warhousingorder string, drugtype int64) (drug []*models.VmXtDrugInventory, err error) {
1127
 func GetDamageByDrugId(drugid int64, warhousingorder string, drugtype int64) (drug []*models.VmXtDrugInventory, err error) {
1128
 
1128
 
1129
-	db := XTReadDB().Table("xt_drug_inventory").Where("status = 1 and type = 4 ")
1129
+	db := XTReadDB().Table("xt_drug_inventory").Where("status = 1")
1130
 
1130
 
1131
 	if drugid > 0 {
1131
 	if drugid > 0 {
1132
 		db = db.Where("drug_id = ?", drugid)
1132
 		db = db.Where("drug_id = ?", drugid)
1137
 	if drugtype > 0 {
1137
 	if drugtype > 0 {
1138
 		db = db.Where("type = ?", drugtype)
1138
 		db = db.Where("type = ?", drugtype)
1139
 	}
1139
 	}
1140
+	if drugtype == 0 {
1141
+		db = db.Where("type = 4")
1142
+	}
1140
 
1143
 
1141
 	err = db.Preload("XtBaseDrug", "status = 1").Find(&drug).Error
1144
 	err = db.Preload("XtBaseDrug", "status = 1").Find(&drug).Error
1142
 	return drug, err
1145
 	return drug, err
1143
 }
1146
 }
1147
+
1148
+func GetInventoryModeList(orgid int64) (info []*models.PatientDrugWarehouseInfo, err error) {
1149
+
1150
+	db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1")
1151
+	table := XTReadDB().Table("xt_base_drug as t").Where("t.status = 1")
1152
+	fmt.Println(table)
1153
+	if orgid > 0 {
1154
+		db = db.Where("x.org_id = ?", orgid)
1155
+	}
1156
+	err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1157
+	return info, err
1158
+}

+ 43 - 4
service/stock_service.go View File

1158
 }
1158
 }
1159
 
1159
 
1160
 func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err error) {
1160
 func FindCancelStockInfoById(id int64) (list []*models.CancelStockInfo, err error) {
1161
-	err = readDb.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Preload("GoodInfo", "status = 1").Find(&list).Error
1161
+	err = readDb.Model(&models.CancelStockInfo{}).Where("cancel_stock_id = ? AND status = 1", id).Preload("WarehousingInfo", "status = 1").Preload("GoodInfo", "status = 1").Find(&list).Error
1162
 	return list, err
1162
 	return list, err
1163
 }
1163
 }
1164
 
1164
 
1551
 	return stock, err
1551
 	return stock, err
1552
 }
1552
 }
1553
 
1553
 
1554
+func GetLastDrugCancelStockById(orgid int64) (models.DrugCancelStock, error) {
1555
+	stock := models.DrugCancelStock{}
1556
+	err := XTReadDB().Where("org_id = ? and status = 1", orgid).Last(&stock).Error
1557
+	return stock, err
1558
+}
1559
+
1554
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1560
 func AddSigleDrugCancelStock(cancelStock *models.DrugCancelStock) error {
1555
 	err := writeDb.Create(&cancelStock).Error
1561
 	err := writeDb.Create(&cancelStock).Error
1556
 	return err
1562
 	return err
3190
 	db := XTReadDB().Model(&drug).Where("org_id=? and status=1  and drug_status<>'停用'", orgid)
3196
 	db := XTReadDB().Model(&drug).Where("org_id=? and status=1  and drug_status<>'停用'", orgid)
3191
 	if len(keywords) > 0 {
3197
 	if len(keywords) > 0 {
3192
 		likekey := "%" + keywords + "%"
3198
 		likekey := "%" + keywords + "%"
3193
-		err = db.Where("(drug_name LIKE ?)", likekey).Find(&drug).Error
3199
+		err = db.Where("(drug_name LIKE ?)", likekey).Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
3200
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid).Group("id")
3201
+		}).Find(&drug).Error
3194
 	} else {
3202
 	} else {
3195
-		err = db.Find(&drug).Error
3203
+		err = db.Preload("DrugWarehouseInfo", func(db *gorm.DB) *gorm.DB {
3204
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid).Group("id")
3205
+		}).Find(&drug).Error
3196
 	}
3206
 	}
3197
 	return
3207
 	return
3198
 }
3208
 }
3206
 			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid)
3216
 			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid)
3207
 		}).Find(&good).Error
3217
 		}).Find(&good).Error
3208
 	} else {
3218
 	} else {
3209
-		err = db.Find(&good).Error
3219
+		err = db.Preload("StWarehousingInfo", func(db *gorm.DB) *gorm.DB {
3220
+			return XTReadDB().Where("org_id=? and status = 1 and warehousing_count <> 0", orgid)
3221
+		}).Find(&good).Error
3210
 	}
3222
 	}
3211
 	return
3223
 	return
3212
 }
3224
 }
3881
 	return info, err
3893
 	return info, err
3882
 }
3894
 }
3883
 
3895
 
3896
+func GetWarehoureOrderStockOutFlow(goodid int64, orgid int64, id int64) (info models.VmStockFlow, err error) {
3897
+	db := XTReadDB().Table("xt_stock_flow as x").Where("x.status =1 and x.consumable_type = 2 or x.consumable_type = 3")
3898
+	if goodid > 0 {
3899
+		db = db.Where("x.good_id = ?", goodid)
3900
+	}
3901
+	if orgid > 0 {
3902
+		db = db.Where("x.user_org_id = ?", orgid)
3903
+	}
3904
+	if id > 0 {
3905
+		db = db.Where("x.warehousing_id = ?", id)
3906
+	}
3907
+	err = db.Select("x.good_id,sum(x.count) as count").Scan(&info).Error
3908
+	return info, err
3909
+}
3910
+
3884
 func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3911
 func UpdateCancelInfo(id int64) (models.CancelStock, error) {
3885
 	stock := models.CancelStock{}
3912
 	stock := models.CancelStock{}
3886
 	err := XTWriteDB().Model(&stock).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
3913
 	err := XTWriteDB().Model(&stock).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
4994
 	err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count}).Error
5021
 	err := XTWriteDB().Model(&flow).Where("warehousing_id = ? and good_id = ? and status = 1", warehousing_id, good_id).Updates(map[string]interface{}{"count": flow.Count}).Error
4995
 	return err
5022
 	return err
4996
 }
5023
 }
5024
+
5025
+func GetInventoryExportList(orgid int64) (info []*models.PatientWarehouseInfo, err error) {
5026
+
5027
+	db := XTReadDB().Table("xt_warehouse_info as x").Where("x.status = 1")
5028
+	table := XTReadDB().Table("xt_good_information as t").Where("t.status = 1")
5029
+	fmt.Println(table)
5030
+	if orgid > 0 {
5031
+		db = db.Where("x.org_id = ?", orgid)
5032
+	}
5033
+	err = db.Select("x.id,x.good_id,x.number,x.number,x.product_date,x.expiry_date,x.warehousing_unit,x.dealer,x.manufacturer,t.good_name,t.specification_name,t.packing_unit,t.remark").Joins("left join xt_good_information as t on t.id = x.good_id").Group("x.good_id,x.number").Scan(&info).Error
5034
+	return info, err
5035
+}