Browse Source

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

陈少旭 10 months ago
parent
commit
bd03828894

BIN
XT_New.exe View File


+ 5 - 5
controllers/base_api_controller.go View File

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

+ 2 - 3
controllers/common_api_controller.go View File

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

+ 1 - 1
controllers/dialysis_api_controller.go View File

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

+ 11 - 1
controllers/dialysis_record_api_controller.go View File

@@ -419,6 +419,8 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
419 419
 
420 420
 	allDoctor, _ := service.GetAllDoctor(adminInfo.CurrentOrgId, adminInfo.CurrentAppId)
421 421
 
422
+	lastAcceptTreatment, _ := service.GetLastAcceptTreatment(adminInfo.CurrentOrgId, patientID)
423
+
422 424
 	if getDryErr != nil {
423 425
 		this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
424 426
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
@@ -475,6 +477,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
475 477
 			"lastOrder":                   lastOrder,
476 478
 			"dryWeightList":               dryWeightList,
477 479
 			"docList":                     allDoctor,
480
+			"lastAcceptTreatment":         lastAcceptTreatment,
478 481
 		}
479 482
 		this.ServeSuccessJSON(returnData)
480 483
 
@@ -514,6 +517,7 @@ func (this *DialysisRecordAPIController) DialysisSchedule() {
514 517
 			"lastOrder":                   lastOrder,
515 518
 			"dryWeightList":               dryWeightList,
516 519
 			"docList":                     allDoctor,
520
+			"lastAcceptTreatment":         lastAcceptTreatment,
517 521
 		}
518 522
 		this.ServeSuccessJSON(returnData)
519 523
 	}
@@ -1142,6 +1146,7 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1142 1146
 		OrderRemark:            order_remark,
1143 1147
 		CatheterOperation:      catheter_operation,
1144 1148
 		BloodFlowVolume:        blood_flow_volume,
1149
+		BloodDrawing:           blood_drawing,
1145 1150
 	}
1146 1151
 
1147 1152
 	createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
@@ -1213,6 +1218,10 @@ func (this *DialysisRecordAPIController) StartDialysis() {
1213 1218
 			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1214 1219
 		}
1215 1220
 
1221
+		if blood_drawing > 0 && adminUserInfo.CurrentOrgId == 10629 { //adminUserInfo.CurrentOrgId == 9538
1222
+			tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
1223
+		}
1224
+
1216 1225
 		var ultrafiltration_rate float64
1217 1226
 		_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.CurrentOrgId)
1218 1227
 
@@ -1853,7 +1862,7 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
1853 1862
 	order_remark := this.GetString("order_remark")
1854 1863
 	catheter_operation := this.GetString("catheter_operation")
1855 1864
 	blood_flow_volume := this.GetString("blood_flow_volume")
1856
-
1865
+	blood_drawing, _ := this.GetInt64("blood_drawing")
1857 1866
 	if record_id == 0 {
1858 1867
 		this.ErrorLog("id:%v", record_id)
1859 1868
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -2021,6 +2030,7 @@ func (this *DialysisRecordAPIController) ModifyStartDialysis() {
2021 2030
 		OrderRemark:            order_remark,
2022 2031
 		CatheterOperation:      catheter_operation,
2023 2032
 		BloodFlowVolume:        blood_flow_volume,
2033
+		BloodDrawing:           blood_drawing,
2024 2034
 	}
2025 2035
 
2026 2036
 	infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)

+ 1 - 1
controllers/doctors_api_controller.go View File

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

+ 16 - 16
controllers/his_api_controller.go View File

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

+ 3 - 3
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -1377,7 +1377,7 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
1377 1377
 			} else {
1378 1378
 				sc["code"] = 1
1379 1379
 				sc["msg"] = "抱歉,您今天没有排版!"
1380
-				sc["mode"] = 0
1380
+				sc["mode"] = "HD"
1381 1381
 				sc["data"] = daySchedule
1382 1382
 			}
1383 1383
 		}
@@ -1394,7 +1394,7 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
1394 1394
 		if len(nextSchedule) <= 0 {
1395 1395
 			sc["code"] = 1
1396 1396
 			sc["msg"] = "抱歉,您后续没有排版!"
1397
-			sc["mode"] = 0
1397
+			sc["mode"] = "HD"
1398 1398
 			sc["data"] = nextSchedule
1399 1399
 		} else {
1400 1400
 			if nextSchedule[0].Schedule.ID > 0 {
@@ -1523,7 +1523,7 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
1523 1523
 			} else {
1524 1524
 				sc["code"] = 1
1525 1525
 				sc["msg"] = "抱歉,您后续没有排版!"
1526
-				sc["mode"] = 0
1526
+				sc["mode"] = "HD"
1527 1527
 				sc["data"] = nextSchedule
1528 1528
 			}
1529 1529
 		}

+ 16 - 9
controllers/mobile_api_controllers/dialysis_api_controller.go View File

@@ -1548,8 +1548,10 @@ func (c *DialysisAPIController) PostAssessmentAfterDislysis() {
1548 1548
 
1549 1549
 		recordDialysis, _ := service.GetSigleAssessmentAfterDislysisRecord(assessmentAfterDislysis.PatientId, assessmentAfter.AssessmentDate, assessmentAfter.UserOrgId)
1550 1550
 
1551
-		if assessmentAfterDislysis.WeightAfter == 0 {
1552
-			assessmentAfterDislysis.WeightAfter = recordDialysis.WeightAfter
1551
+		if assessmentAfterDislysis.UserOrgId != 10340 {
1552
+			if assessmentAfterDislysis.WeightAfter == 0 {
1553
+				assessmentAfterDislysis.WeightAfter = recordDialysis.WeightAfter
1554
+			}
1553 1555
 		}
1554 1556
 
1555 1557
 		err := service.AddSigleAssessmentAfterDislysisRecord(&assessmentAfterDislysis)
@@ -3311,6 +3313,7 @@ func (this *DialysisAPIController) StartDialysis() {
3311 3313
 		OrderRemark:            order_remark,
3312 3314
 		CatheterOperation:      catheter_operation,
3313 3315
 		BloodFlowVolume:        blood_flow_volume,
3316
+		BloodDrawing:           blood_drawing,
3314 3317
 	}
3315 3318
 	//查询该床位是否有人用了
3316 3319
 	_, errorscode := service.GetDialysisOrderByBedId(adminUserInfo.Org.Id, schedulestartTime, bedID, schedual_type)
@@ -3377,6 +3380,10 @@ func (this *DialysisAPIController) StartDialysis() {
3377 3380
 		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
3378 3381
 	}
3379 3382
 
3383
+	if blood_drawing > 0 && adminUserInfo.Org.Id == 10629 {
3384
+		tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
3385
+	}
3386
+
3380 3387
 	var ultrafiltration_rate float64
3381 3388
 	_, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.Org.Id)
3382 3389
 	//后期预增脱水量
@@ -4596,7 +4603,6 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
4596 4603
 	difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
4597 4604
 	new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
4598 4605
 	quality_nurse_id, _ := this.GetInt64("quality_nurse_id")
4599
-	fmt.Println("quality_nurse_id", quality_nurse_id)
4600 4606
 	patient_id, _ := this.GetInt64("patient_id")
4601 4607
 	record_date, _ := this.GetInt64("record_date")
4602 4608
 	puncture_needle := this.GetString("puncture_needle")
@@ -4609,6 +4615,7 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
4609 4615
 	schedule_remark := this.GetString("schedule_remark")
4610 4616
 	catheter_operation := this.GetString("catheter_operation")
4611 4617
 	blood_flow_volume := this.GetString("blood_flow_volume")
4618
+	blood_drawing, _ := this.GetInt64("blood_drawing")
4612 4619
 	if record_id == 0 {
4613 4620
 		this.ErrorLog("id:%v", record_id)
4614 4621
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -4775,6 +4782,7 @@ func (this *DialysisAPIController) ModifyStartDialysisOrder() {
4775 4782
 		ScheduleRemark:         schedule_remark,
4776 4783
 		CatheterOperation:      catheter_operation,
4777 4784
 		BloodFlowVolume:        blood_flow_volume,
4785
+		BloodDrawing:           blood_drawing,
4778 4786
 	}
4779 4787
 
4780 4788
 	//修改床位号需要重新消毒
@@ -7317,7 +7325,7 @@ func (c *DialysisAPIController) EditConsumables() {
7317 7325
 								Count:                   item.Count,
7318 7326
 								Price:                   stockInInfo.Price,
7319 7327
 								Status:                  1,
7320
-								Ctime:                   time.Now().Unix(),
7328
+								Ctime:                   record_time,
7321 7329
 								UserOrgId:               adminInfo.Org.Id,
7322 7330
 								Manufacturer:            stockInInfo.Manufacturer,
7323 7331
 								Dealer:                  stockInInfo.Dealer,
@@ -7351,7 +7359,7 @@ func (c *DialysisAPIController) EditConsumables() {
7351 7359
 									Count:                   exsit.Count - delete_count,
7352 7360
 									Price:                   stockInInfo.Price,
7353 7361
 									Status:                  1,
7354
-									Ctime:                   time.Now().Unix(),
7362
+									Ctime:                   record_time,
7355 7363
 									UserOrgId:               adminInfo.Org.Id,
7356 7364
 									Manufacturer:            stockInInfo.Manufacturer,
7357 7365
 									Dealer:                  stockInInfo.Dealer,
@@ -7479,7 +7487,7 @@ func (c *DialysisAPIController) EditConsumables() {
7479 7487
 									Creator:                 adminInfo.AdminUser.Id,
7480 7488
 									UpdateCreator:           0,
7481 7489
 									Status:                  1,
7482
-									Ctime:                   time.Now().Unix(),
7490
+									Ctime:                   record_time,
7483 7491
 									Mtime:                   0,
7484 7492
 									Price:                   info.Price,
7485 7493
 									WarehousingDetailId:     info.WarehouseInfotId,
@@ -8997,7 +9005,6 @@ func (this *DialysisAPIController) GetRoleList() {
8997 9005
 
8998 9006
 func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *models.BloodAutomaticReduceDetail, warehouseOut *models.WarehouseOut, patient_id int64, creater int64, count int64) (err error) {
8999 9007
 
9000
-	fmt.Println("退库222322232322332232332322332232332233wo", good_yc.GoodId)
9001 9008
 	// 先根据相关信息查询当天该耗材的出库信息
9002 9009
 	warehouseOutInfos, err := service.FindStockOutInfoByStockTwo(orgID, good_yc.GoodTypeId, good_yc.GoodId, record_time, good_yc.PatientId)
9003 9010
 
@@ -9081,7 +9088,7 @@ func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *model
9081 9088
 			Count:                   count,
9082 9089
 			Price:                   stockInInfo.Price,
9083 9090
 			Status:                  1,
9084
-			Ctime:                   time.Now().Unix(),
9091
+			Ctime:                   record_time,
9085 9092
 			UserOrgId:               good_yc.OrgId,
9086 9093
 			Manufacturer:            stockInInfo.Manufacturer,
9087 9094
 			Dealer:                  stockInInfo.Dealer,
@@ -9187,7 +9194,7 @@ func ConsumablesDeliveryDeleteNew(orgID int64, record_time int64, good_yc *model
9187 9194
 		Creator:                 warehouseOut.Creater,
9188 9195
 		UpdateCreator:           0,
9189 9196
 		Status:                  1,
9190
-		Ctime:                   time.Now().Unix(),
9197
+		Ctime:                   record_time,
9191 9198
 		Mtime:                   0,
9192 9199
 		Price:                   stockInInfo.Price,
9193 9200
 		WarehousingDetailId:     stockInInfo.ID,

+ 0 - 3
controllers/mobile_api_controllers/doctor_advice_api_controller.go View File

@@ -5,7 +5,6 @@ import (
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7 7
 	"XT_New/utils"
8
-	"fmt"
9 8
 	"strconv"
10 9
 	"time"
11 10
 )
@@ -45,7 +44,6 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
45 44
 	redis.Set(key, "", time.Second)
46 45
 	scheduals, err := service.MobileGetScheduleDoctorAdvicesTwo(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id, delivery_way)
47 46
 
48
-	fmt.Println("scheduals00923923999233223", scheduals)
49 47
 	//获取所有的患者
50 48
 	blood_patients, _ := service.GetAllPatientListByListSeven(orgID)
51 49
 	//获取透析处方
@@ -81,7 +79,6 @@ func (this *DoctorAdviceAPIController) ScheduleAdvices() {
81 79
 	config, _ := service.GetHisDoctorConfig(orgID)
82 80
 	project_config, _ := service.GetHisProjectConfig(orgID)
83 81
 
84
-	fmt.Println("project_config23323232322323", project_config.IsOpen)
85 82
 	if project_config.IsOpen == 1 || project_config.IsOpen == 2 {
86 83
 		//获取his医嘱数据
87 84
 		project, _ := service.GetMobileHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, adminInfo.AdminUser.Id)

+ 90 - 1
controllers/patient_api_controller.go View File

@@ -135,6 +135,14 @@ func PatientApiRegistRouters() {
135 135
 
136 136
 	beego.Router("/api/patient/savemedicalhistory", &PatientApiController{}, "Post:SaveMedicalHistory")
137 137
 
138
+	beego.Router("/api/patient/savepatientcritaicalinformed", &PatientApiController{}, "Post:SavePatientCritaicalInformed")
139
+
140
+	beego.Router("/api/patient/getPatientCriticalList", &PatientApiController{}, "Get:GetPatientCriticalList")
141
+
142
+	beego.Router("/api/patient/savepatientcriticalcalinformedone", &PatientApiController{}, "Post:SavePatientCriticalInformedOne")
143
+
144
+	beego.Router("/api/patient/getpatientcriticalonelist", &PatientApiController{}, "Get:GetPatientCriticalOneList")
145
+
138 146
 }
139 147
 func (c *PatientApiController) GetExportList() {
140 148
 	startTime := c.GetString("start_time")
@@ -1122,7 +1130,7 @@ func (c *PatientApiController) UpdateDialysisSolution() {
1122 1130
 	loc, _ := time.LoadLocation("Local")
1123 1131
 	todayTime, err := time.ParseInLocation(timeLayout, today, loc)
1124 1132
 
1125
-	if adminUserInfo.CurrentOrgId == 9538 {
1133
+	if adminUserInfo.CurrentOrgId == 9538 || adminUserInfo.CurrentOrgId == 10375 || adminUserInfo.CurrentOrgId == 10164 {
1126 1134
 		prescription := models.DialysisPrescription{
1127 1135
 			Dialyzer:                   solution.Dialyzer,
1128 1136
 			Anticoagulant:              solution.Anticoagulant,
@@ -6687,3 +6695,84 @@ func (c *PatientApiController) SaveMedicalHistory() {
6687 6695
 	})
6688 6696
 
6689 6697
 }
6698
+
6699
+func (c *PatientApiController) SavePatientCritaicalInformed() {
6700
+
6701
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6702
+	dataBody := make(map[string]interface{}, 0)
6703
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
6704
+	fmt.Println("err", err)
6705
+	content := dataBody["content"].(string)
6706
+
6707
+	patientCritical := models.XtPatientCritical{
6708
+		UserOrgId: orgId,
6709
+		Content:   content,
6710
+		Status:    1,
6711
+		Ctime:     time.Now().Unix(),
6712
+		Mtime:     time.Now().Unix(),
6713
+	}
6714
+
6715
+	patientCritaicalInformed, _ := service.GetPatientCritaicalInformed(orgId)
6716
+
6717
+	if patientCritaicalInformed.ID == 0 {
6718
+		service.CreatePatientCritaicalinformed(patientCritical)
6719
+	}
6720
+	if patientCritaicalInformed.ID > 0 {
6721
+		service.UpdatePatientCritaicalInformed(patientCritaicalInformed.ID, content)
6722
+	}
6723
+	c.ServeSuccessJSON(map[string]interface{}{
6724
+		"patientCritical": patientCritical,
6725
+	})
6726
+}
6727
+
6728
+func (c *PatientApiController) GetPatientCriticalList() {
6729
+
6730
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6731
+	patientCritaicalInformed, _ := service.GetPatientCritaicalInformed(orgId)
6732
+	c.ServeSuccessJSON(map[string]interface{}{
6733
+		"patientCritaicalInformed": patientCritaicalInformed,
6734
+	})
6735
+}
6736
+
6737
+func (c *PatientApiController) SavePatientCriticalInformedOne() {
6738
+
6739
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6740
+	dataBody := make(map[string]interface{}, 0)
6741
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
6742
+	fmt.Println("err", err)
6743
+	content := dataBody["content"].(string)
6744
+
6745
+	criticalOne := models.XtPatientCriticalOne{
6746
+		UserOrgId: orgId,
6747
+		Content:   content,
6748
+		Status:    1,
6749
+		Ctime:     time.Now().Unix(),
6750
+		Mtime:     time.Now().Unix(),
6751
+	}
6752
+
6753
+	critical, _ := service.GetPatientCriticalByUserOrgId(orgId)
6754
+
6755
+	if critical.ID == 0 {
6756
+		service.CreatePatientCritical(criticalOne)
6757
+	}
6758
+
6759
+	if critical.ID > 0 {
6760
+		service.UpdatePatientCriticalOne(orgId, content)
6761
+	}
6762
+
6763
+	c.ServeSuccessJSON(map[string]interface{}{
6764
+		"criticalOne": criticalOne,
6765
+	})
6766
+
6767
+}
6768
+
6769
+func (c *PatientApiController) GetPatientCriticalOneList() {
6770
+
6771
+	orgId := c.GetAdminUserInfo().CurrentOrgId
6772
+
6773
+	list, _ := service.GetPatientCriticalOneList(orgId)
6774
+
6775
+	c.ServeSuccessJSON(map[string]interface{}{
6776
+		"list": list,
6777
+	})
6778
+}

File diff suppressed because it is too large
+ 1479 - 37
controllers/patient_dataconfig_api_controller.go


+ 26 - 24
controllers/self_drug_api_congtroller.go View File

@@ -3987,34 +3987,36 @@ func (this *SelfDrugApiController) GetPurchaseNewDrugQuery() {
3987 3987
 			item.WareStartEndStockInventoryLosses = append(item.WareStartEndStockInventoryLosses, it)
3988 3988
 		}
3989 3989
 
3990
-		//获取入库
3991
-		infoFLow, _ := service.GetNewDrugFlowInWarehouseInfo(item.ID, orgId, startTime)
3990
+		if orgId != 10215 && orgId != 10265 {
3991
+			//获取入库
3992
+			infoFLow, _ := service.GetNewDrugFlowInWarehouseInfo(item.ID, orgId, startTime)
3992 3993
 
3993
-		for _, it := range infoFLow {
3994
-			item.NewDrugFlowInWarehouseInfo = append(item.NewDrugFlowInWarehouseInfo, it)
3995
-		}
3996
-		//获取盘盈
3997
-		infoProfitFlow, _ := service.GetNewDrugFlowPofitWarehouseInfo(item.ID, orgId, startTime)
3994
+			for _, it := range infoFLow {
3995
+				item.NewDrugFlowInWarehouseInfo = append(item.NewDrugFlowInWarehouseInfo, it)
3996
+			}
3997
+			//获取盘盈
3998
+			infoProfitFlow, _ := service.GetNewDrugFlowPofitWarehouseInfo(item.ID, orgId, startTime)
3998 3999
 
3999
-		for _, it := range infoProfitFlow {
4000
-			item.NewDrugFlowPofitWarehouseInfo = append(item.NewDrugFlowPofitWarehouseInfo, it)
4001
-		}
4002
-		//获取出库
4003
-		infoOutFlow, _ := service.GetNewDrugFlowOutWarehouseInfo(item.ID, orgId, startTime)
4004
-		for _, it := range infoOutFlow {
4005
-			item.NewDrugFlowOutWarehouseInfo = append(item.NewDrugFlowOutWarehouseInfo, it)
4006
-		}
4000
+			for _, it := range infoProfitFlow {
4001
+				item.NewDrugFlowPofitWarehouseInfo = append(item.NewDrugFlowPofitWarehouseInfo, it)
4002
+			}
4003
+			//获取出库
4004
+			infoOutFlow, _ := service.GetNewDrugFlowOutWarehouseInfo(item.ID, orgId, startTime)
4005
+			for _, it := range infoOutFlow {
4006
+				item.NewDrugFlowOutWarehouseInfo = append(item.NewDrugFlowOutWarehouseInfo, it)
4007
+			}
4007 4008
 
4008
-		//获取退库
4009
-		infoCacelFlow, _ := service.GetNewDrugFlowCacelWarehouseInfo(item.ID, orgId, startTime)
4010
-		for _, it := range infoCacelFlow {
4011
-			item.NewDrugFlowNoCancelWarehouseInfo = append(item.NewDrugFlowNoCancelWarehouseInfo, it)
4012
-		}
4009
+			//获取退库
4010
+			infoCacelFlow, _ := service.GetNewDrugFlowCacelWarehouseInfo(item.ID, orgId, startTime)
4011
+			for _, it := range infoCacelFlow {
4012
+				item.NewDrugFlowNoCancelWarehouseInfo = append(item.NewDrugFlowNoCancelWarehouseInfo, it)
4013
+			}
4013 4014
 
4014
-		//获取盘亏
4015
-		infoNoPofitFlow, _ := service.GetNewDrugFlowNoPofitWarehouseInfo(item.ID, orgId, startTime)
4016
-		for _, it := range infoNoPofitFlow {
4017
-			item.NewDrugFlowNoPofitWarehouseInfo = append(item.NewDrugFlowNoPofitWarehouseInfo, it)
4015
+			//获取盘亏
4016
+			infoNoPofitFlow, _ := service.GetNewDrugFlowNoPofitWarehouseInfo(item.ID, orgId, startTime)
4017
+			for _, it := range infoNoPofitFlow {
4018
+				item.NewDrugFlowNoPofitWarehouseInfo = append(item.NewDrugFlowNoPofitWarehouseInfo, it)
4019
+			}
4018 4020
 		}
4019 4021
 
4020 4022
 	}

+ 7 - 7
controllers/sign_api_controller.go View File

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

+ 2 - 0
models/dialysis.go View File

@@ -869,6 +869,7 @@ type DialysisOrder struct {
869 869
 	CatheterOperation          string        `gorm:"column:catheter_operation" json:"catheter_operation" form:"catheter_operation"`
870 870
 	BloodFlowVolume            string        `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
871 871
 	Condenser                  string        `gorm:"column:condenser" json:"condenser" form:"condenser"`
872
+	BloodDrawing               int64         `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
872 873
 }
873 874
 
874 875
 func (DialysisOrder) TableName() string {
@@ -953,6 +954,7 @@ type XtDialysisOrders struct {
953 954
 	WashpipeNurse  int64  `gorm:"column:washpipe_nurse" json:"washpipe_nurse" form:"washpipe_nurse"`
954 955
 	ModeId         int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
955 956
 	QualityNurseId int64  `gorm:"column:quality_nurse_id" json:"quality_nurse_id" form:"quality_nurse_id"`
957
+	BloodDrawing   int64  `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
956 958
 }
957 959
 
958 960
 type TreatmentMode struct {

+ 100 - 0
models/patient_models.go View File

@@ -2585,6 +2585,55 @@ func (XtPatientFallassessment) TableName() string {
2585 2585
 	return "xt_patient_fallassessment"
2586 2586
 }
2587 2587
 
2588
+type VmXtPatientFallassessment struct {
2589
+	ID                             int64                             `gorm:"column:id" json:"id" form:"id"`
2590
+	PatientId                      int64                             `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2591
+	UserOrgId                      int64                             `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2592
+	RecordDate                     int64                             `gorm:"column:record_date" json:"record_date" form:"record_date"`
2593
+	PingDate                       int64                             `gorm:"column:ping_date" json:"ping_date" form:"ping_date"`
2594
+	AdminUserId                    int64                             `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2595
+	Status                         int64                             `gorm:"column:status" json:"status" form:"status"`
2596
+	IsCheck                        int64                             `gorm:"column:is_check" json:"is_check" form:"is_check"`
2597
+	IsCheckOne                     int64                             `gorm:"column:is_check_one" json:"is_check_one" form:"is_check_one"`
2598
+	IsCheckTwo                     int64                             `gorm:"column:is_check_two" json:"is_check_two" form:"is_check_two"`
2599
+	IsCheckThree                   int64                             `gorm:"column:is_check_three" json:"is_check_three" form:"is_check_three"`
2600
+	IsCheckFour                    int64                             `gorm:"column:is_check_four" json:"is_check_four" form:"is_check_four"`
2601
+	IsCheckFive                    int64                             `gorm:"column:is_check_five" json:"is_check_five" form:"is_check_five"`
2602
+	IsCheckSix                     int64                             `gorm:"column:is_check_six" json:"is_check_six" form:"is_check_six"`
2603
+	IsCheckSeven                   int64                             `gorm:"column:is_check_seven" json:"is_check_seven" form:"is_check_seven"`
2604
+	IsCheckEight                   int64                             `gorm:"column:is_check_eight" json:"is_check_eight" form:"is_check_eight"`
2605
+	IsCheckNight                   int64                             `gorm:"column:is_check_night" json:"is_check_night" form:"is_check_night"`
2606
+	IsCheckTen                     int64                             `gorm:"column:is_check_ten" json:"is_check_ten" form:"is_check_ten"`
2607
+	IsCheckEleven                  int64                             `gorm:"column:is_check_eleven" json:"is_check_eleven" form:"is_check_eleven"`
2608
+	IsCheckTwelve                  int64                             `gorm:"column:is_check_twelve" json:"is_check_twelve" form:"is_check_twelve"`
2609
+	IsCheckThirteen                int64                             `gorm:"column:is_check_thirteen" json:"is_check_thirteen" form:"is_check_thirteen"`
2610
+	IsCheckFourteen                int64                             `gorm:"column:is_check_fourteen" json:"is_check_fourteen" form:"is_check_fourteen"`
2611
+	IsCheckFifteen                 int64                             `gorm:"column:is_check_fifteen" json:"is_check_fifteen" form:"is_check_fifteen"`
2612
+	IsCheckSixteen                 int64                             `gorm:"column:is_check_sixteen" json:"is_check_sixteen" form:"is_check_sixteen"`
2613
+	IsCheckSeventeen               int64                             `gorm:"column:is_check_seventeen" json:"is_check_seventeen" form:"is_check_seventeen"`
2614
+	IsCheckEighteen                int64                             `gorm:"column:is_check_eighteen" json:"is_check_eighteen" form:"is_check_eighteen"`
2615
+	IsCheckNineteen                int64                             `gorm:"column:is_check_nineteen" json:"is_check_nineteen" form:"is_check_nineteen"`
2616
+	Ctime                          int64                             `gorm:"column:ctime" json:"ctime" form:"ctime"`
2617
+	Mtime                          int64                             `gorm:"column:mtime" json:"mtime" form:"mtime"`
2618
+	Total                          int64                             `gorm:"column:total" json:"total" form:"total"`
2619
+	XtPatientFallassessmentAdd     []*XtPatientFallassessmentAdd     `json:"PatientFallassessmentAdd" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2620
+	XtPatientFallassessmentAddCopy []*XtPatientFallassessmentAddCopy `json:"PatientFallassessmentAddCopy" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2621
+	XtPatientFallassessmentAge     []*XtPatientFallassessmentAge     `json:"PatientFallassessmentAge" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2622
+	XtPatientFallassessmentBody    []*XtPatientFallassessmentBody    `json:"XtPatientFallassessmentBody" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2623
+	XtPatientFallassessmentCare    []*XtPatientFallassessmentCare    `json:"XtPatientFallassessmentCare" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2624
+	XtPatientFallassessmentExcrete []*XtPatientFallassessmentExcrete `json:"XtPatientFallassessmentExcrete" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2625
+	XtPatientFallassessmentFall    []*XtPatientFallassessmentFall    `json:"XtPatientFallassessmentFall" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2626
+	XtPatientFallassessmentHistory []*XtPatientFallassessmentHistory `json:"XtPatientFallassessmentHistory" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2627
+	XtPatientFallassessmentMedical []*XtPatientFallassessmentMedical `json:"XtPatientFallassessmentMedical" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2628
+	XtPatientFallassessmentOrgan   []*XtPatientFallassessmentOrgan   `json:"XtPatientFallassessmentOrgan" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2629
+	XtPatientFallassessmentPrevent []*XtPatientFallassessmentPrevent `json:"XtPatientFallassessmentPrevent" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2630
+	XtPatientFallassessmentRealize []*XtPatientFallassessmentRealize `json:"XtPatientFallassessmentRealize" gorm:"foreignkey:FassementId;AssociationForeignKey:ID;"`
2631
+}
2632
+
2633
+func (VmXtPatientFallassessment) TableName() string {
2634
+	return "xt_patient_fallassessment"
2635
+}
2636
+
2588 2637
 type XtPatientFallassessmentAdd struct {
2589 2638
 	ID            int64  `gorm:"column:id" json:"id" form:"id"`
2590 2639
 	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
@@ -2776,3 +2825,54 @@ type XtPatientFallassessmentRealize struct {
2776 2825
 func (XtPatientFallassessmentRealize) TableName() string {
2777 2826
 	return "xt_patient_fallassessment_realize"
2778 2827
 }
2828
+
2829
+type XtPatientPedFallssessment struct {
2830
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
2831
+	PatientId   int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
2832
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2833
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
2834
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2835
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2836
+	Text        string `gorm:"column:text" json:"text" form:"text"`
2837
+	RecordDate  int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
2838
+	Total       int64  `gorm:"column:total" json:"total" form:"total"`
2839
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
2840
+	Type        int64  `gorm:"column:type" json:"type" form:"type"`
2841
+	Age         int64  `gorm:"column:age" json:"age" form:"age"`
2842
+	Cognize     int64  `gorm:"column:cognize" json:"cognize" form:"cognize"`
2843
+	Diagnosis   int64  `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
2844
+	Environment int64  `gorm:"column:environment" json:"environment" form:"environment"`
2845
+	Medicine    int64  `gorm:"column:medicine" json:"medicine" form:"medicine"`
2846
+	Sex         int64  `gorm:"column:sex" json:"sex" form:"sex"`
2847
+	Tumble      int64  `gorm:"column:tumble" json:"tumble" form:"tumble"`
2848
+}
2849
+
2850
+func (XtPatientPedFallssessment) TableName() string {
2851
+	return "xt_patient_ped_fallssessment"
2852
+}
2853
+
2854
+type XtPatientCritical struct {
2855
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
2856
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2857
+	Content   string `gorm:"column:content" json:"content" form:"content"`
2858
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
2859
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2860
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2861
+}
2862
+
2863
+func (XtPatientCritical) TableName() string {
2864
+	return "xt_patient_critical"
2865
+}
2866
+
2867
+type XtPatientCriticalOne struct {
2868
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
2869
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
2870
+	Content   string `gorm:"column:content" json:"content" form:"content"`
2871
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
2872
+	Ctime     int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
2873
+	Mtime     int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
2874
+}
2875
+
2876
+func (XtPatientCriticalOne) TableName() string {
2877
+	return "xt_patient_critical_one"
2878
+}

+ 1 - 2
service/common_service.go View File

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

+ 1 - 1
service/dialysis_service.go View File

@@ -646,7 +646,7 @@ func FindDialysisMacher(orgid int64, patientid int64, dialysisDate int64) (model
646 646
 	db := readDb.Table("xt_dialysis_order as o").Where("o.status = 1")
647 647
 	table := readDb.Table("xt_device_number as n")
648 648
 	fmt.Print("table", table)
649
-	err := db.Select("o.id,o.dialysis_date,o.user_org_id,o.patient_id,o.prescription_id,o.stage,remark,o.bed_id,o.start_nurse,o.finish_nurse,o.status,o.created_time,o.updated_time,o.start_time,o.end_time,o.puncture_nurse,o.creator,o.modifier,o.finish_creator,o.finish_modifier,o.schedual_type,o.quality_nurse_id,n.number,r.user_name").Joins("left join xt_device_number as n on n.id = o.bed_id").Joins("left join sgj_users.sgj_user_admin_role  as r on r.admin_user_id = o.start_nurse").Where("o.user_org_id = ? and o.patient_id = ? and o.dialysis_date =?", orgid, patientid, dialysisDate).Scan(&orders).Error
649
+	err := db.Select("o.id,o.dialysis_date,o.user_org_id,o.patient_id,o.prescription_id,o.stage,remark,o.bed_id,o.start_nurse,o.finish_nurse,o.status,o.created_time,o.updated_time,o.start_time,o.end_time,o.puncture_nurse,o.creator,o.modifier,o.finish_creator,o.finish_modifier,o.schedual_type,o.quality_nurse_id,o.blood_drawing,n.number,r.user_name").Joins("left join xt_device_number as n on n.id = o.bed_id").Joins("left join sgj_users.sgj_user_admin_role  as r on r.admin_user_id = o.start_nurse").Where("o.user_org_id = ? and o.patient_id = ? and o.dialysis_date =?", orgid, patientid, dialysisDate).Scan(&orders).Error
650 650
 	return orders, err
651 651
 }
652 652
 func FindPunctureNurse(adminid int64, appid int64, orgid int64) (models.App_Roles, error) {

+ 10 - 0
service/manage_center_service.go View File

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

+ 8 - 1
service/mobile_dialysis_service.go View File

@@ -2241,7 +2241,7 @@ func BatchUpdateMonitors(monitors []*models.MonitoringRecord) error {
2241 2241
 func ModifyStartDialysisOrder(order *models.DialysisOrder) error {
2242 2242
 	tx := writeDb.Begin()
2243 2243
 	updateTime := time.Now().Unix()
2244
-	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse, "difficult_puncture_nurse": order.DifficultPunctureNurse, "new_fistula_nurse": order.NewFistulaNurse, "quality_nurse_id": order.QualityNurseId, "puncture_needle": order.PunctureNeedle, "puncture_way": order.PunctureWay, "dialysis_dialyszers": order.DialysisDialyszers, "dialysis_irrigation": order.DialysisIrrigation, "blood_access_id": order.BloodAccessId, "nuclein_date": order.NucleinDate, "schedule_remark": order.ScheduleRemark, "order_remark": order.OrderRemark, "catheter_operation": order.CatheterOperation, "blood_flow_volume": order.BloodFlowVolume}).Error
2244
+	err := tx.Model(&models.DialysisOrder{}).Where("user_org_id = ? AND id = ? AND status = 1 ", order.UserOrgId, order.ID).Updates(map[string]interface{}{"start_nurse": order.StartNurse, "updated_time": updateTime, "bed_id": order.BedID, "puncture_nurse": order.PunctureNurse, "start_time": order.StartTime, "modifier": order.Modifier, "schedual_type": order.SchedualType, "washpipe_nurse": order.WashpipeNurse, "change_nurse": order.ChangeNurse, "difficult_puncture_nurse": order.DifficultPunctureNurse, "new_fistula_nurse": order.NewFistulaNurse, "quality_nurse_id": order.QualityNurseId, "puncture_needle": order.PunctureNeedle, "puncture_way": order.PunctureWay, "dialysis_dialyszers": order.DialysisDialyszers, "dialysis_irrigation": order.DialysisIrrigation, "blood_access_id": order.BloodAccessId, "nuclein_date": order.NucleinDate, "schedule_remark": order.ScheduleRemark, "order_remark": order.OrderRemark, "catheter_operation": order.CatheterOperation, "blood_flow_volume": order.BloodFlowVolume, "blood_drawing": order.BloodDrawing}).Error
2245 2245
 	if err != nil {
2246 2246
 		tx.Rollback()
2247 2247
 		return err
@@ -9278,3 +9278,10 @@ func MobileGetLongScheduleDoctorAdvices(orgID int64, scheduleDate int64, adviceT
9278 9278
 	err := db.Find(&vms).Error
9279 9279
 	return vms, err
9280 9280
 }
9281
+
9282
+func GetLastAcceptTreatment(user_org_id int64, patient_id int64) (models.ReceiveTreatmentAsses, error) {
9283
+
9284
+	treatmentAsses := models.ReceiveTreatmentAsses{}
9285
+	err := XTReadDB().Where("user_org_id = ? and patient_id = ? and status=1 and admission_number<>''", user_org_id, patient_id).Last(&treatmentAsses).Error
9286
+	return treatmentAsses, err
9287
+}

+ 1 - 5
service/new_warehouse_service.go View File

@@ -97,8 +97,6 @@ func ConsumablesGoodDelivery(orgID int64, patient_id int64, record_time int64, g
97 97
 		warehouseOutInfo.Count = count
98 98
 		if orgID == 9671 || orgID == 10265 {
99 99
 			goodsInfo, _ := FindeGoodInfo(orgID, goods.GoodId)
100
-
101
-			fmt.Println("加个我我我哦我我我", goodsInfo.PackingPrice)
102 100
 			warehouseOutInfo.Price = goodsInfo.PackingPrice
103 101
 		}
104 102
 		_, errcodes := GetWarehouseOutInfoIsExistOne(goods.GoodId, patient_id, record_time, goods.ProjectId)
@@ -1287,8 +1285,6 @@ func BloodDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *
1287 1285
 // 药品自动出库 递归方式
1288 1286
 func BloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, warehouseout *models.DrugWarehouseOut, drup *models.BaseDrugLib, advice *models.HisDoctorAdviceInfo, hisprescribingNumber float64, unit string) (err error) {
1289 1287
 
1290
-	fmt.Println("出库拉22222222222222222222222222222222222222222222222222222222222222222222")
1291
-	fmt.Println("剩余库存2哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦哦噢噢噢噢", prescribingNumber)
1292 1288
 	//开事务
1293 1289
 	tx := XTWriteDB().Begin()
1294 1290
 	defer func() {
@@ -2468,7 +2464,7 @@ func GetSigleDrugWarehouseOutInfoTwo(patient_id int64, advice_date int64, orgid
2468 2464
 
2469 2465
 	info := models.XtDrugWarehouseOutInfo{}
2470 2466
 	var err error
2471
-	err = XTReadDB().Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1 and drug_id = ?", patient_id, advice_date, orgid, drug_id).Find(&info).Error
2467
+	err = XTReadDB().Where("patient_id = ? and sys_record_time = ? and org_id = ? and status = 1 and drug_id = ? and is_sys=1", patient_id, advice_date, orgid, drug_id).Find(&info).Error
2472 2468
 	if err == gorm.ErrRecordNotFound {
2473 2469
 		return nil, err
2474 2470
 	}

+ 474 - 12
service/patient_service.go View File

@@ -2838,7 +2838,7 @@ func GetAllTreatModeByList(orgID int64) (treatement []*models.TreatmentMode, err
2838 2838
 
2839 2839
 func GetAllPatientListByListSeven(orgID int64) (patients []*MSchedualPatientVM, err error) {
2840 2840
 
2841
-	err = readDb.Model(&MSchedualPatientVM{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2841
+	err = readDb.Model(&MSchedualPatientVM{}).Where("user_org_id=? and status=1", orgID).Find(&patients).Error
2842 2842
 	return patients, nil
2843 2843
 }
2844 2844
 
@@ -2849,7 +2849,7 @@ func GetAllPatientListByListTwo(orgID int64) (patients []*MSchedualPatientVM, er
2849 2849
 	patient_info_str, _ := redis.Get(key).Result()
2850 2850
 
2851 2851
 	if len(patient_info_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
2852
-		err = readDb.Model(&MSchedualPatientVM{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Find(&patients).Error
2852
+		err = readDb.Model(&MSchedualPatientVM{}).Where("user_org_id=? and status=1", orgID).Find(&patients).Error
2853 2853
 		if err != nil {
2854 2854
 			if err == gorm.ErrRecordNotFound {
2855 2855
 				return nil, nil
@@ -3296,19 +3296,22 @@ func GetDialysisOrderNoExecution(start_nurse int64, user_org_id int64, timenow i
3296 3296
 func GetAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.NoDoctorAdvice, err error) {
3297 3297
 
3298 3298
 	db := XTReadDB().Model(advice).Where("status=1 and  execution_state = 2 and advice_type = 2")
3299
-
3300
-	if advice_date > 0 {
3301
-		db = db.Where("advice_date= ?", advice_date)
3302
-	}
3303
-	if user_org_id > 0 {
3304
-		db = db.Where("user_org_id =?", user_org_id)
3305
-	}
3306 3299
 	if len(patientIds) > 0 {
3307
-		db = db.Where("patient_id in(?)", patientIds)
3300
+		if advice_date > 0 {
3301
+			db = db.Where("advice_date= ?", advice_date)
3302
+		}
3303
+		if user_org_id > 0 {
3304
+			db = db.Where("user_org_id =?", user_org_id)
3305
+		}
3306
+		if len(patientIds) > 0 {
3307
+			db = db.Where("patient_id in(?)", patientIds)
3308
+		}
3309
+		err = db.Select("patient_id,Count(id) as count,advice_date").Group("patient_id").Find(&advice).Error
3310
+		return advice, err
3311
+	} else {
3312
+		return advice, err
3308 3313
 	}
3309 3314
 
3310
-	err = db.Select("patient_id,Count(id) as count,advice_date").Group("patient_id").Find(&advice).Error
3311
-	return advice, err
3312 3315
 }
3313 3316
 
3314 3317
 func GetHisAdviceListNoExecution(advice_date int64, user_org_id int64, patientIds []int64) (advice []*models.HisNoDoctorAdvice, err error) {
@@ -3723,3 +3726,462 @@ func GetPatientMedicalList(patient_id int64, user_org_id int64) (models.XtMedica
3723 3726
 	err := XTReadDB().Where("patient_id = ? and user_org_id = ? and status=1", patient_id, user_org_id).Find(&history).Error
3724 3727
 	return history, err
3725 3728
 }
3729
+
3730
+func CreatePatientFallassessment(tx *gorm.DB, patientFallassessment models.XtPatientFallassessment) (err error) {
3731
+
3732
+	err = tx.Create(&patientFallassessment).Error
3733
+	if err == gorm.ErrRecordNotFound {
3734
+		tx.Rollback()
3735
+		return
3736
+	}
3737
+
3738
+	return
3739
+}
3740
+
3741
+func SavePatientFallassessment(tx *gorm.DB, patientFallassessment models.XtPatientFallassessment) (err error) {
3742
+
3743
+	err = tx.Save(&patientFallassessment).Error
3744
+	if err == gorm.ErrRecordNotFound {
3745
+		tx.Rollback()
3746
+		return
3747
+	}
3748
+
3749
+	return
3750
+}
3751
+
3752
+func GetLastPatientFallassessment(tx *gorm.DB, patient_id int64, user_org_id int64) (patientFallassessment models.XtPatientFallassessment, err error) {
3753
+
3754
+	err = tx.Where("patient_id = ? and user_org_id = ? and status=1", patient_id, user_org_id).Last(&patientFallassessment).Error
3755
+	if err == gorm.ErrRecordNotFound {
3756
+		tx.Rollback()
3757
+		return
3758
+	}
3759
+
3760
+	return
3761
+
3762
+}
3763
+
3764
+func CreateFallassessmentAge(tx *gorm.DB, patientAge models.XtPatientFallassessmentAge) (err error) {
3765
+
3766
+	err = tx.Create(&patientAge).Error
3767
+	if err == gorm.ErrRecordNotFound {
3768
+		tx.Rollback()
3769
+		return
3770
+	}
3771
+
3772
+	return
3773
+}
3774
+
3775
+func SaveFallassessmentAge(tx *gorm.DB, patientAge models.XtPatientFallassessmentAge) (err error) {
3776
+
3777
+	err = tx.Create(&patientAge).Error
3778
+	if err == gorm.ErrRecordNotFound {
3779
+		tx.Rollback()
3780
+		return
3781
+	}
3782
+
3783
+	return
3784
+}
3785
+
3786
+func CreateFallassessmentOrgan(tx *gorm.DB, organ models.XtPatientFallassessmentOrgan) (err error) {
3787
+
3788
+	err = tx.Create(&organ).Error
3789
+	if err == gorm.ErrRecordNotFound {
3790
+		tx.Rollback()
3791
+		return
3792
+	}
3793
+
3794
+	return
3795
+
3796
+}
3797
+
3798
+func SaveFallassessmentOrgan(tx *gorm.DB, organ models.XtPatientFallassessmentOrgan) (err error) {
3799
+
3800
+	err = tx.Create(&organ).Error
3801
+	if err == gorm.ErrRecordNotFound {
3802
+		tx.Rollback()
3803
+		return
3804
+	}
3805
+
3806
+	return
3807
+
3808
+}
3809
+
3810
+func CreateFallassessmentHistory(tx *gorm.DB, history models.XtPatientFallassessmentHistory) (err error) {
3811
+
3812
+	err = tx.Create(&history).Error
3813
+	if err == gorm.ErrRecordNotFound {
3814
+		tx.Rollback()
3815
+		return
3816
+	}
3817
+
3818
+	return
3819
+}
3820
+
3821
+func SaveFallassessmentHistory(tx *gorm.DB, history models.XtPatientFallassessmentHistory) (err error) {
3822
+
3823
+	err = tx.Save(&history).Error
3824
+	if err == gorm.ErrRecordNotFound {
3825
+		tx.Rollback()
3826
+		return
3827
+	}
3828
+
3829
+	return
3830
+}
3831
+
3832
+func CreateFallassessmentExcrete(tx *gorm.DB, excrete models.XtPatientFallassessmentExcrete) (err error) {
3833
+
3834
+	err = tx.Create(&excrete).Error
3835
+	if err == gorm.ErrRecordNotFound {
3836
+		tx.Rollback()
3837
+		return
3838
+	}
3839
+
3840
+	return
3841
+
3842
+}
3843
+
3844
+func SaveFallassessmentExcrete(tx *gorm.DB, excrete models.XtPatientFallassessmentExcrete) (err error) {
3845
+
3846
+	err = tx.Save(&excrete).Error
3847
+	if err == gorm.ErrRecordNotFound {
3848
+		tx.Rollback()
3849
+		return
3850
+	}
3851
+
3852
+	return
3853
+
3854
+}
3855
+
3856
+func CreateFallassessmentBody(tx *gorm.DB, body models.XtPatientFallassessmentBody) (err error) {
3857
+
3858
+	err = tx.Create(&body).Error
3859
+	if err == gorm.ErrRecordNotFound {
3860
+		tx.Rollback()
3861
+		return
3862
+	}
3863
+
3864
+	return
3865
+}
3866
+
3867
+func SaveFallassessmentBody(tx *gorm.DB, body models.XtPatientFallassessmentBody) (err error) {
3868
+
3869
+	err = tx.Save(&body).Error
3870
+	if err == gorm.ErrRecordNotFound {
3871
+		tx.Rollback()
3872
+		return
3873
+	}
3874
+
3875
+	return
3876
+}
3877
+
3878
+func CreateFallassessmentMedical(tx *gorm.DB, medical models.XtPatientFallassessmentMedical) (err error) {
3879
+
3880
+	err = tx.Create(&medical).Error
3881
+	if err == gorm.ErrRecordNotFound {
3882
+		tx.Rollback()
3883
+		return
3884
+	}
3885
+
3886
+	return
3887
+}
3888
+
3889
+func SaveFallassessmentMedical(tx *gorm.DB, medical models.XtPatientFallassessmentMedical) (err error) {
3890
+
3891
+	err = tx.Save(&medical).Error
3892
+	if err == gorm.ErrRecordNotFound {
3893
+		tx.Rollback()
3894
+		return
3895
+	}
3896
+
3897
+	return
3898
+}
3899
+
3900
+func CreateFallassessmentFall(tx *gorm.DB, fall models.XtPatientFallassessmentFall) (err error) {
3901
+
3902
+	err = tx.Create(&fall).Error
3903
+	if err == gorm.ErrRecordNotFound {
3904
+		tx.Rollback()
3905
+		return
3906
+	}
3907
+
3908
+	return
3909
+}
3910
+
3911
+func SaveFallassessmentFall(tx *gorm.DB, fall models.XtPatientFallassessmentFall) (err error) {
3912
+
3913
+	err = tx.Save(&fall).Error
3914
+	if err == gorm.ErrRecordNotFound {
3915
+		tx.Rollback()
3916
+		return
3917
+	}
3918
+
3919
+	return
3920
+}
3921
+
3922
+func CreateFallassessmentPrevent(tx *gorm.DB, excrete models.XtPatientFallassessmentPrevent) (err error) {
3923
+
3924
+	err = tx.Create(&excrete).Error
3925
+	if err == gorm.ErrRecordNotFound {
3926
+		tx.Rollback()
3927
+		return
3928
+	}
3929
+
3930
+	return
3931
+}
3932
+
3933
+func SaveFallassessmentPrevent(tx *gorm.DB, excrete models.XtPatientFallassessmentPrevent) (err error) {
3934
+
3935
+	err = tx.Save(&excrete).Error
3936
+	if err == gorm.ErrRecordNotFound {
3937
+		tx.Rollback()
3938
+		return
3939
+	}
3940
+
3941
+	return
3942
+}
3943
+
3944
+func CreateFallassessmentPealize(tx *gorm.DB, realize models.XtPatientFallassessmentRealize) (err error) {
3945
+
3946
+	err = tx.Create(&realize).Error
3947
+	if err == gorm.ErrRecordNotFound {
3948
+		tx.Rollback()
3949
+		return
3950
+	}
3951
+
3952
+	return
3953
+}
3954
+
3955
+func SaveFallassessmentPealize(tx *gorm.DB, realize models.XtPatientFallassessmentRealize) (err error) {
3956
+
3957
+	err = tx.Create(&realize).Error
3958
+	if err == gorm.ErrRecordNotFound {
3959
+		tx.Rollback()
3960
+		return
3961
+	}
3962
+
3963
+	return
3964
+}
3965
+
3966
+func CreateFallassessmentCare(tx *gorm.DB, care models.XtPatientFallassessmentCare) (err error) {
3967
+
3968
+	err = tx.Create(&care).Error
3969
+	if err == gorm.ErrRecordNotFound {
3970
+		tx.Rollback()
3971
+		return
3972
+	}
3973
+
3974
+	return
3975
+}
3976
+
3977
+func SaveFallassessmentCare(tx *gorm.DB, care models.XtPatientFallassessmentCare) (err error) {
3978
+
3979
+	err = tx.Save(&care).Error
3980
+	if err == gorm.ErrRecordNotFound {
3981
+		tx.Rollback()
3982
+		return
3983
+	}
3984
+
3985
+	return
3986
+}
3987
+
3988
+func GetPatientFallsessMentList(patient_id int64, user_org_id int64, limit int64, page int64) (list []*models.XtPatientFallassessment, total int64, err error) {
3989
+
3990
+	offset := (page - 1) * limit
3991
+
3992
+	db := XTReadDB().Model(&list).Where("status =1")
3993
+
3994
+	if patient_id > 0 {
3995
+		db = db.Where("patient_id = ?", patient_id)
3996
+	}
3997
+	if user_org_id > 0 {
3998
+		db = db.Where("user_org_id = ?", user_org_id)
3999
+	}
4000
+	err = db.Count(&total).Offset(offset).Limit(limit).Find(&list).Error
4001
+
4002
+	return list, total, err
4003
+}
4004
+
4005
+func CreateFallassessmentAdd(tx *gorm.DB, care models.XtPatientFallassessmentAdd) (err error) {
4006
+
4007
+	err = tx.Create(&care).Error
4008
+	if err == gorm.ErrRecordNotFound {
4009
+		tx.Rollback()
4010
+		return
4011
+	}
4012
+	return
4013
+}
4014
+
4015
+func SaveFallassessmentAdd(tx *gorm.DB, care models.XtPatientFallassessmentAdd) (err error) {
4016
+
4017
+	err = tx.Save(&care).Error
4018
+	if err == gorm.ErrRecordNotFound {
4019
+		tx.Rollback()
4020
+		return
4021
+	}
4022
+	return
4023
+}
4024
+
4025
+func XtPatientFallassessmentAddCopy(tx *gorm.DB, care models.XtPatientFallassessmentAddCopy) (err error) {
4026
+
4027
+	err = tx.Create(&care).Error
4028
+	if err == gorm.ErrRecordNotFound {
4029
+		tx.Rollback()
4030
+		return
4031
+	}
4032
+	return
4033
+}
4034
+
4035
+func SavePatientFallassessmentAddCopy(tx *gorm.DB, care models.XtPatientFallassessmentAddCopy) (err error) {
4036
+
4037
+	err = tx.Create(&care).Error
4038
+	if err == gorm.ErrRecordNotFound {
4039
+		tx.Rollback()
4040
+		return
4041
+	}
4042
+	return
4043
+}
4044
+
4045
+func GetPatientFallsessmentById(id int64, user_org_id int64) (models.VmXtPatientFallassessment, error) {
4046
+
4047
+	fallassessment := models.VmXtPatientFallassessment{}
4048
+
4049
+	err := XTReadDB().Where("id = ? and user_org_id = ?", id, user_org_id).Preload("XtPatientFallassessmentAdd", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentAge", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentAddCopy", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentBody", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentCare", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentExcrete", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentFall", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentHistory", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentMedical", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentOrgan", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentPrevent", "status=1 and user_org_id =?", user_org_id).Preload("XtPatientFallassessmentRealize", "status=1 and user_org_id =?", user_org_id).Find(&fallassessment).Error
4050
+
4051
+	return fallassessment, err
4052
+}
4053
+
4054
+func DeletePatientFallsessment(id int64, user_org_id int64) (models.XtPatientFallassessment, error) {
4055
+
4056
+	fallassessment := models.XtPatientFallassessment{}
4057
+	err := XTWriteDB().Where("id =? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
4058
+
4059
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentAdd{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4060
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentAddCopy{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4061
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentAge{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4062
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentBody{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4063
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentCare{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4064
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentExcrete{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4065
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentFall{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4066
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentHistory{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4067
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentMedical{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4068
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentOrgan{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4069
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentPrevent{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4070
+	err = XTWriteDB().Model(&models.XtPatientFallassessmentRealize{}).Where("status=1 and user_org_id =? and fassement_id=?", user_org_id, id).Updates(map[string]interface{}{"status": 0}).Error
4071
+	return fallassessment, err
4072
+}
4073
+
4074
+func CreatePadFallssessment(fallssessment models.XtPatientPedFallssessment) error {
4075
+
4076
+	err := XTWriteDB().Create(&fallssessment).Error
4077
+
4078
+	return err
4079
+}
4080
+
4081
+func UpdatePedFallssessment(fallssessment models.XtPatientPedFallssessment) error {
4082
+
4083
+	err := XTWriteDB().Save(&fallssessment).Error
4084
+
4085
+	return err
4086
+}
4087
+
4088
+func GetBedDiatricFallassessmentList(patient_id int64, is_type int64, user_org_id int64, limit int64, page int64) (list []*models.XtPatientPedFallssessment, total int64, err error) {
4089
+
4090
+	offset := (page - 1) * limit
4091
+
4092
+	db := XTReadDB().Model(&list).Where("status =1")
4093
+	if patient_id > 0 {
4094
+		db = db.Where("patient_id = ?", patient_id)
4095
+	}
4096
+	if user_org_id > 0 {
4097
+		db = db.Where("user_org_id = ?", user_org_id)
4098
+	}
4099
+	if is_type > 0 {
4100
+		db = db.Where("type = ?", is_type)
4101
+	}
4102
+	err = db.Count(&total).Offset(offset).Limit(limit).Find(&list).Error
4103
+
4104
+	return list, total, err
4105
+}
4106
+
4107
+func GetPedPatientFallassessmentById(id int64) (models.XtPatientPedFallssessment, error) {
4108
+
4109
+	fallassessment := models.XtPatientPedFallssessment{}
4110
+
4111
+	err := XTReadDB().Where("id = ? and status=1", id).Find(&fallassessment).Error
4112
+
4113
+	return fallassessment, err
4114
+}
4115
+
4116
+func DeletePadPatientFallassment(id int64) (err error) {
4117
+
4118
+	err = XTWriteDB().Model(&models.XtPatientPedFallssessment{}).Where("id=? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
4119
+	return err
4120
+
4121
+}
4122
+
4123
+func GetPatientCritaicalInformed(user_org_id int64) (models.XtPatientCritical, error) {
4124
+
4125
+	patientCritical := models.XtPatientCritical{}
4126
+
4127
+	err := XTReadDB().Where("user_org_id = ? and status=1", user_org_id).Find(&patientCritical).Error
4128
+
4129
+	return patientCritical, err
4130
+}
4131
+
4132
+func CreatePatientCritaicalinformed(critical models.XtPatientCritical) error {
4133
+
4134
+	err = XTWriteDB().Create(&critical).Error
4135
+
4136
+	return err
4137
+}
4138
+
4139
+func UpdatePatientCritaicalInformed(id int64, content string) error {
4140
+
4141
+	err := XTWriteDB().Model(&models.XtPatientCritical{}).Where("id = ? and status=1", id).Updates(map[string]interface{}{"content": content}).Error
4142
+	return err
4143
+}
4144
+
4145
+func GetPatientCriticalByUserOrgId(user_org_id int64) (models.XtPatientCriticalOne, error) {
4146
+
4147
+	criticalOne := models.XtPatientCriticalOne{}
4148
+
4149
+	err := XTReadDB().Where("user_org_id = ? and status=1", user_org_id).Find(&criticalOne).Error
4150
+
4151
+	return criticalOne, err
4152
+}
4153
+
4154
+func CreatePatientCritical(patient models.XtPatientCriticalOne) error {
4155
+
4156
+	err := XTWriteDB().Create(&patient).Error
4157
+
4158
+	return err
4159
+}
4160
+
4161
+func UpdatePatientCriticalOne(user_org_id int64, content string) error {
4162
+
4163
+	err := XTWriteDB().Model(&models.XtPatientCriticalOne{}).Where("user_org_id = ? and status=1", user_org_id).Updates(map[string]interface{}{"content": content}).Error
4164
+	return err
4165
+}
4166
+
4167
+func GetPatientCriticalOneList(user_org_id int64) (models.XtPatientCriticalOne, error) {
4168
+
4169
+	criticalOne := models.XtPatientCriticalOne{}
4170
+
4171
+	err := XTReadDB().Where("user_org_id = ? and status =1", user_org_id).Find(&criticalOne).Error
4172
+
4173
+	return criticalOne, err
4174
+}
4175
+
4176
+func CreatePatientPedList(fallssessment models.XtPatientPedFallssessment) error {
4177
+
4178
+	err := XTWriteDB().Create(&fallssessment).Error
4179
+	return err
4180
+}
4181
+
4182
+func UpdatePatientPedList(fallssessment models.XtPatientPedFallssessment) error {
4183
+
4184
+	err := XTWriteDB().Save(&fallssessment).Error
4185
+
4186
+	return err
4187
+}

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

@@ -110,6 +110,7 @@ type DialysisOrderVM struct {
110 110
 	DialysisDialyszers string          `gorm:"column:dialysis_dialyszers" json:"dialysis_dialyszers" form:"dialysis_dialyszers"`
111 111
 	PunctureWay        string          `gorm:"column:puncture_way" json:"puncture_way" form:"puncture_way"`
112 112
 	PunctureNeedle     string          `gorm:"column:puncture_needle" json:"puncture_needle" form:"puncture_needle"`
113
+	BloodDrawing       int64           `gorm:"column:blood_drawing" json:"blood_drawing" form:"blood_drawing"`
113 114
 }
114 115
 
115 116
 func (DialysisOrderVM) TableName() string {

+ 1 - 1
service/self_drug_service.go View File

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

+ 1 - 1
service/sign_service.go View File

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

+ 57 - 3
service/stock_service.go View File

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

+ 70 - 0
service/warhouse_service.go View File

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