28169 3 weeks ago
parent
commit
30e6785b70

+ 0 - 4
.idea/.gitignore View File

@@ -1,4 +0,0 @@
1
-# Default ignored files
2
-/workspace.xml
3
-# Datasource local storage ignored files
4
-/dataSources.local.xml

+ 0 - 5
.idea/codeStyles/codeStyleConfig.xml View File

@@ -1,5 +0,0 @@
1
-<component name="ProjectCodeStyleConfiguration">
2
-  <state>
3
-    <option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
4
-  </state>
5
-</component>

+ 0 - 12
.idea/dataSources.xml View File

@@ -1,12 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
4
-    <data-source source="LOCAL" name="@rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com" uuid="a5e97996-c706-42df-9eba-66746647237e">
5
-      <driver-ref>mysql.8</driver-ref>
6
-      <synchronize>true</synchronize>
7
-      <remarks>lijc de database</remarks>
8
-      <jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
9
-      <jdbc-url>jdbc:mysql://rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com:3306</jdbc-url>
10
-    </data-source>
11
-  </component>
12
-</project>

+ 0 - 4
.idea/encodings.xml View File

@@ -1,4 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="Encoding" addBOMForNewFiles="with NO BOM" />
4
-</project>

+ 0 - 26
.idea/misc.xml View File

@@ -1,26 +0,0 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<project version="4">
3
-  <component name="JavaScriptSettings">
4
-    <option name="languageLevel" value="ES6" />
5
-  </component>
6
-  <component name="SvnBranchConfigurationManager">
7
-    <option name="myConfigurationMap">
8
-      <map>
9
-        <entry key="$PROJECT_DIR$/../CDM">
10
-          <value>
11
-            <SvnBranchConfiguration>
12
-              <option name="trunkUrl" value="svn://112.74.16.180/Product/SGJ/SGJ1.0/Project/SGJ1.0/Application/MBGL" />
13
-            </SvnBranchConfiguration>
14
-          </value>
15
-        </entry>
16
-        <entry key="$PROJECT_DIR$/../SYB_Admin">
17
-          <value>
18
-            <SvnBranchConfiguration>
19
-              <option name="trunkUrl" value="svn://112.74.16.180/Product/SYB/SYB1.0/Application/SYB_Admin" />
20
-            </SvnBranchConfiguration>
21
-          </value>
22
-        </entry>
23
-      </map>
24
-    </option>
25
-  </component>
26
-</project>

+ 0 - 5
.idea/vcs.xml View File

@@ -1,10 +1,5 @@
1 1
 <?xml version="1.0" encoding="UTF-8"?>
2 2
 <project version="4">
3
-  <component name="GitSharedSettings">
4
-    <option name="FORCE_PUSH_PROHIBITED_PATTERNS">
5
-      <list />
6
-    </option>
7
-  </component>
8 3
   <component name="VcsDirectoryMappings">
9 4
     <mapping directory="$PROJECT_DIR$" vcs="Git" />
10 5
   </component>

BIN
XT_New.exe View File


+ 13 - 0
conf/app.conf View File

@@ -65,6 +65,13 @@ readmysqluser2 = syh
65 65
 readmysqlpass2 = Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4
66 66
 readmysqlname2 = sgj_xt
67 67
 
68
+readmysqlhost3 = rm-wz9r3iil42mn24675oo.mysql.rds.aliyuncs.com
69
+readmysqlport3 = 3306
70
+readmysqluser3 = syh
71
+readmysqlpass3 = Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4
72
+readmysqlname3 = sgj_xt
73
+
74
+
68 75
 writemysqlhost = kuyicloud2024lt.mysql.rds.aliyuncs.com
69 76
 writemysqlport = 3306
70 77
 writemysqluser = syh
@@ -103,6 +110,8 @@ readsgjpatientmysqluser = syh
103 110
 readsgjpatientmysqlpass = Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4
104 111
 readsgjpatientmysqlname = sgj_patient
105 112
 
113
+
114
+
106 115
 writesgjpatientmysqlhost = kuyicloud2024lt.mysql.rds.aliyuncs.com
107 116
 writesgjpatientmysqlport = 3306
108 117
 writesgjpatientmysqluser = syh
@@ -116,12 +125,16 @@ readpatientuser = syh
116 125
 readpatientpass = Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4
117 126
 readpatientname = sgj_cdm
118 127
 
128
+
129
+
119 130
 writepatienthost = kuyicloud2024lt.mysql.rds.aliyuncs.com
120 131
 writepatientport = 3306
121 132
 writepatientuser = syh
122 133
 writepatientpass = Zc8xxwN4jkZswprx8VKHRSd2rBMRWgC4
123 134
 writepatientname = sgj_cdm
124 135
 
136
+
137
+
125 138
 redishost = kuyicloud.redis.rds.aliyuncs.com
126 139
 redisport = 6379
127 140
 redispasswrod = 1Q2W3e4r!@#$

+ 4 - 4
controllers/base_api_controller.go View File

@@ -83,7 +83,7 @@ func (this *BaseAuthAPIController) Prepare() {
83 83
 		userAdmin.ModifyTime = 1530786071
84 84
 		var subscibe models.ServeSubscibe
85 85
 		subscibe.ID = 11
86
-		subscibe.OrgId = 10164 //机构id
86
+		subscibe.OrgId = 10744 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,7 +93,7 @@ func (this *BaseAuthAPIController) Prepare() {
93 93
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
94 94
 		subscibes[4] = &subscibe
95 95
 		var adminUserInfo service.AdminUserInfo
96
-		adminUserInfo.CurrentOrgId = 10164 //机构id小英9675或4
96
+		adminUserInfo.CurrentOrgId = 10744 //机构id小英9675或4
97 97
 		adminUserInfo.CurrentAppId = 18470 //4
98 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
@@ -329,7 +329,7 @@ func (this *BaseServeAPIController) Prepare() {
329 329
 		userAdmin.ModifyTime = 1530786071
330 330
 		var subscibe models.ServeSubscibe
331 331
 		subscibe.ID = 11
332
-		subscibe.OrgId = 10164 //机构id小英9675或4
332
+		subscibe.OrgId = 10744 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,7 +339,7 @@ func (this *BaseServeAPIController) Prepare() {
339 339
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
340 340
 		subscibes[4] = &subscibe
341 341
 		var adminUserInfo service.AdminUserInfo
342
-		adminUserInfo.CurrentOrgId = 10164 //机构id小英9675或4
342
+		adminUserInfo.CurrentOrgId = 10744 //机构id小英9675或4
343 343
 		adminUserInfo.CurrentAppId = 18470 //4
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes

+ 18 - 7
controllers/dialysis_api_controller.go View File

@@ -2500,6 +2500,15 @@ func (c *DialysisApiController) PostAssessmentAfterDislysis() {
2500 2500
 
2501 2501
 			}
2502 2502
 		}
2503
+
2504
+		if adminUserInfo.CurrentOrgId == 10744 {
2505
+			evaluation, _ := service.GetAssessmentBeforThrity(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
2506
+			if evaluation.WeightBefore > 0 {
2507
+				assessment.WeightLoss = evaluation.WeightBefore - assessment.WeightAfter
2508
+			}
2509
+
2510
+		}
2511
+
2503 2512
 		err = service.UpdateAssessmentAfterDislysisRecord(&assessment)
2504 2513
 		//记录日志
2505 2514
 		byterequest, _ := json.Marshal(assessment)
@@ -3529,14 +3538,16 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3529 3538
 				}
3530 3539
 			}
3531 3540
 
3532
-			if assessmentBeforeDislysis.ID > 0 {
3533
-				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3534
-				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3535
-					dewater_amount = assessmentBeforeDislysis.WeightBefore - assessmentBeforeDislysis.DryWeight - assessmentBeforeDislysis.AdditionalWeight
3536
-					if adminUserInfo.CurrentOrgId == 10751 {
3537
-						dewater_amount = dewater_amount * 1000
3541
+			if adminUserInfo.CurrentOrgId != 10751 {
3542
+				if assessmentBeforeDislysis.ID > 0 {
3543
+					dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3544
+					if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
3545
+						dewater_amount = assessmentBeforeDislysis.WeightBefore - assessmentBeforeDislysis.DryWeight - assessmentBeforeDislysis.AdditionalWeight
3546
+						//if adminUserInfo.CurrentOrgId == 10751 {
3547
+						//	dewater_amount = dewater_amount * 1000
3548
+						//}
3549
+						service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
3538 3550
 					}
3539
-					service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
3540 3551
 				}
3541 3552
 			}
3542 3553
 

+ 13 - 0
controllers/mobile_api_controllers/check_weight_api_controller.go View File

@@ -882,6 +882,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
882 882
 			evaluation.UserOrgId = adminUserInfo.Org.Id
883 883
 			// 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
884 884
 			lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
885
+
885 886
 			// 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
886 887
 			assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
887 888
 			if getAADErr != nil {
@@ -968,6 +969,9 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
968 969
 				if adminUserInfo.Org.Id == 10702 {
969 970
 					evaluation.PulseFrequency = 0
970 971
 				}
972
+				if adminUserInfo.Org.Id == 10121 || adminUserInfo.Org.Id == 10234 {
973
+					evaluation.Height = lastPredialysisEvaluation.Height
974
+				}
971 975
 			}
972 976
 		} else {
973 977
 			evaluation.UpdatedTime = time.Now().Unix()
@@ -1073,6 +1077,7 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
1073 1077
 		}
1074 1078
 
1075 1079
 		afterevaluation.WeightAfter = weight_after
1080
+
1076 1081
 		afterevaluation.WeightLoss = weight_loss
1077 1082
 
1078 1083
 		if adminUserInfo.Org.Id == 10138 {
@@ -1148,6 +1153,14 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
1148 1153
 			afterevaluation.Temperature = 36.5
1149 1154
 		}
1150 1155
 
1156
+		if adminUserInfo.Org.Id == 10744 {
1157
+			evaluation, _ := service.GetAssessmentBeforThrity(adminUserInfo.Org.Id, id, theAssessmentDateTime)
1158
+			if evaluation.WeightBefore > 0 {
1159
+				afterevaluation.WeightLoss = evaluation.WeightBefore - weight_after
1160
+			}
1161
+
1162
+		}
1163
+
1151 1164
 		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
1152 1165
 
1153 1166
 		//记录日志

+ 20 - 9
controllers/mobile_api_controllers/patient_api_controller.go View File

@@ -1538,8 +1538,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1538 1538
 					infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
1539 1539
 					//申请状态不允许的情况 拒绝修改
1540 1540
 					if infor.ApplicationStatus != 1 {
1541
+
1541 1542
 						c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
1542 1543
 						return
1544
+
1543 1545
 					}
1544 1546
 
1545 1547
 				}
@@ -1649,7 +1651,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
1649 1651
 
1650 1652
 		storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
1651 1653
 
1652
-		if drugStockConfig.IsOpen == 1 {
1654
+		if drugStockConfig.IsOpen == 1 && adminUserInfo.Org.Id != 10644 && adminUserInfo.Org.Id != 10721 {
1653 1655
 			if groupno > 0 {
1654 1656
 				advices, _ := service.FindAllDoctorAdviceByGoroupNoTwety(adminUserInfo.Org.Id, groupno)
1655 1657
 
@@ -2182,6 +2184,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2182 2184
 			// 查询信息规挡的设置天数
2183 2185
 
2184 2186
 			infor, _ := service.GetDialysisInformationSetting(item.UserOrgId)
2187
+
2188
+			fmt.Println("infor==================", infor.ID)
2185 2189
 			if infor.ID > 0 {
2186 2190
 
2187 2191
 				var cha_time int64
@@ -2288,6 +2292,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2288 2292
 								PrescribingNumberUnit: item.PrescribingNumberUnit,
2289 2293
 							}
2290 2294
 							service.CreateDrugError(drugError)
2295
+							tx.Rollback()
2291 2296
 						}
2292 2297
 					}
2293 2298
 					advice, _ := service.FindHisDoctorAdviceByIdTwo(adminInfo.Org.Id, item.ID, tx)
@@ -2451,6 +2456,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
2451 2456
 						}
2452 2457
 					}
2453 2458
 
2459
+					fmt.Println("prescribing_number_total", prescribing_number_total)
2460
+					fmt.Println("total------------", total)
2461
+
2454 2462
 					if prescribing_number_total <= total {
2455 2463
 
2456 2464
 						pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
@@ -4607,14 +4615,16 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
4607 4615
 			}
4608 4616
 		}
4609 4617
 
4610
-		if evaluation.ID > 0 {
4611
-			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4612
-			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4613
-				dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
4614
-				if adminUserInfo.Org.Id == 10751 {
4615
-					dewater_amount = dewater_amount * 1000
4618
+		if adminUserInfo.Org.Id != 10751 {
4619
+			if evaluation.ID > 0 {
4620
+				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4621
+				if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
4622
+					dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
4623
+					//if adminUserInfo.Org.Id == 10751 {
4624
+					//	dewater_amount = dewater_amount * 1000
4625
+					//}
4626
+					service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
4616 4627
 				}
4617
-				service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
4618 4628
 			}
4619 4629
 		}
4620 4630
 
@@ -6337,6 +6347,7 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
6337 6347
 func (c *PatientApiController) CreateGroupAdvice() {
6338 6348
 	is_child, _ := c.GetInt64("is_child", 0)
6339 6349
 
6350
+	fmt.Println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", is_child)
6340 6351
 	if is_child == 1 {
6341 6352
 		patient, _ := c.GetInt64("id", 0)
6342 6353
 		if patient <= 0 {
@@ -7020,7 +7031,7 @@ func (c *PatientApiController) DelDoctorAdvice() {
7020 7031
 				}
7021 7032
 			}
7022 7033
 
7023
-			err = service.DeleteDoctorAdviceByGroupNo(&advice)
7034
+			err = service.DeleteDoctorAdviceByGroupNoOne(&advice)
7024 7035
 			//记录日志
7025 7036
 			byterequest, _ := json.Marshal(advice)
7026 7037
 			adviceLog := models.XtDoctorAdviceLog{

+ 154 - 11
controllers/patient_api_controller.go View File

@@ -225,6 +225,16 @@ func PatientApiRegistRouters() {
225 225
 
226 226
 	beego.Router("/api/patient/getinspectionbyprojectid", &PatientApiController{}, "Get:GetInspectionByProjectId")
227 227
 
228
+	beego.Router("/api/patient/getpatientmaplist", &PatientApiController{}, "Get:GetPatientMapList")
229
+
230
+	beego.Router("/api/patient/savepatientcount", &PatientApiController{}, "Get:SavePatientCount")
231
+
232
+	beego.Router("/api/patient/getpatientcount", &PatientApiController{}, "Get:GetPatientCountList")
233
+
234
+	beego.Router("/api/patient/checkpatientcount", &PatientApiController{}, "Get:CheckPatientCount")
235
+
236
+	beego.Router("/api/patient/returncheckpatientcount", &PatientApiController{}, "Get:ReturnCheckPatientCount")
237
+
228 238
 }
229 239
 func (c *PatientApiController) GetExportList() {
230 240
 	startTime := c.GetString("start_time")
@@ -1520,6 +1530,7 @@ func (c *PatientApiController) CreateDryWeights() {
1520 1530
 }
1521 1531
 
1522 1532
 func (c *PatientApiController) CreateGroupAdvice() {
1533
+
1523 1534
 	var err error
1524 1535
 	defer func() {
1525 1536
 		if rec := recover(); rec != nil {
@@ -1554,17 +1565,17 @@ func (c *PatientApiController) CreateGroupAdvice() {
1554 1565
 	}
1555 1566
 	utils.ErrorLog("%v", dataBody)
1556 1567
 
1557
-	appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1558
-	if appRole.UserType == 3 {
1559
-		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1560
-		if getPermissionErr != nil {
1561
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1562
-			return
1563
-		} else if headNursePermission == nil {
1564
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateAdvice)
1565
-			return
1566
-		}
1567
-	}
1568
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1569
+	//if appRole.UserType == 3 {
1570
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1571
+	//	if getPermissionErr != nil {
1572
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1573
+	//		return
1574
+	//	} else if headNursePermission == nil {
1575
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateAdvice)
1576
+	//		return
1577
+	//	}
1578
+	//}
1568 1579
 
1569 1580
 	timeLayout := "2006-01-02"
1570 1581
 	loc, _ := time.LoadLocation("Local")
@@ -1575,6 +1586,8 @@ func (c *PatientApiController) CreateGroupAdvice() {
1575 1586
 		return
1576 1587
 	}
1577 1588
 	adviceType := int64(dataBody["advice_type"].(float64))
1589
+
1590
+	fmt.Println("adviceType----------------", adviceType)
1578 1591
 	if adviceType != 1 && adviceType != 2 && adviceType != 3 && adviceType != 4 {
1579 1592
 		utils.ErrorLog("advice_type != 1&&2")
1580 1593
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -9060,3 +9073,133 @@ func (this *PatientApiController) GetInspectionByProjectId() {
9060 9073
 		"inspection": inspection,
9061 9074
 	})
9062 9075
 }
9076
+
9077
+func (this *PatientApiController) GetPatientMapList() {
9078
+
9079
+	keyword := this.GetString("keyword")
9080
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9081
+
9082
+	patient, _ := service.GetPatientMapList(orgId, keyword)
9083
+
9084
+	this.ServeSuccessJSON(map[string]interface{}{
9085
+		"patient": patient,
9086
+	})
9087
+}
9088
+
9089
+func (this *PatientApiController) SavePatientCount() {
9090
+
9091
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9092
+
9093
+	creater := this.GetAdminUserInfo().AdminUser.Id
9094
+
9095
+	patient_id, _ := this.GetInt64("patient_id")
9096
+
9097
+	hd_count, _ := this.GetInt64("hd_count")
9098
+
9099
+	hdf_count, _ := this.GetInt64("hdf_count")
9100
+
9101
+	hdhp_count, _ := this.GetInt64("hdhp_count")
9102
+
9103
+	hp_count, _ := this.GetInt64("hp_count")
9104
+
9105
+	other_count, _ := this.GetInt64("other_count")
9106
+
9107
+	remark := this.GetString("remark")
9108
+
9109
+	recordDateStr := time.Now().Format("2006-01-02")
9110
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9111
+
9112
+	nowtime := recordDate.Unix()
9113
+
9114
+	patientInCount := models.SfPatientInCount{
9115
+		PatientId:  patient_id,
9116
+		UserOrgId:  orgId,
9117
+		HdCount:    hd_count,
9118
+		HdfCount:   hdf_count,
9119
+		HdhpCount:  hdhp_count,
9120
+		HpCount:    hp_count,
9121
+		Status:     1,
9122
+		Creater:    creater,
9123
+		Ctime:      time.Now().Unix(),
9124
+		Mtime:      time.Now().Unix(),
9125
+		IsCheck:    2,
9126
+		RecordDate: nowtime,
9127
+		Remark:     remark,
9128
+		OtherCount: other_count,
9129
+	}
9130
+
9131
+	fmt.Println(patientInCount)
9132
+
9133
+	db := service.XTWriteDB()
9134
+	// 开始外部循环的事务
9135
+	tx := db.Begin()
9136
+	// 在函数结束时处理事务回滚
9137
+	defer func() {
9138
+		if r := recover(); r != nil {
9139
+			tx.Rollback()
9140
+		}
9141
+	}()
9142
+
9143
+	service.CreatePatientInCount(tx, patientInCount)
9144
+
9145
+	service.ModifyPatientCount(tx, hd_count, hdf_count, hdhp_count, hp_count, patient_id)
9146
+
9147
+	tx.Commit()
9148
+
9149
+	this.ServeSuccessJSON(map[string]interface{}{
9150
+		"patientInCount": patientInCount,
9151
+	})
9152
+
9153
+}
9154
+
9155
+func (this *PatientApiController) GetPatientCountList() {
9156
+
9157
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9158
+	patient_id, _ := this.GetInt64("patient_id")
9159
+	page, _ := this.GetInt64("page")
9160
+	limit, _ := this.GetInt64("limit")
9161
+	patient, total, _ := service.GetPatientCountList(orgId, patient_id, page, limit)
9162
+
9163
+	this.ServeSuccessJSON(map[string]interface{}{
9164
+		"patient": patient,
9165
+		"total":   total,
9166
+	})
9167
+}
9168
+
9169
+func (this *PatientApiController) CheckPatientCount() {
9170
+
9171
+	id, _ := this.GetInt64("id")
9172
+
9173
+	checkpatientcount, _ := service.CheckPatientCount(id)
9174
+
9175
+	this.ServeSuccessJSON(map[string]interface{}{
9176
+		"checkpatientcount": checkpatientcount,
9177
+	})
9178
+}
9179
+
9180
+func (this *PatientApiController) ReturnCheckPatientCount() {
9181
+
9182
+	id, _ := this.GetInt64("id")
9183
+
9184
+	db := service.XTWriteDB()
9185
+	// 开始外部循环的事务
9186
+	tx := db.Begin()
9187
+	// 在函数结束时处理事务回滚
9188
+	defer func() {
9189
+		if r := recover(); r != nil {
9190
+			tx.Rollback()
9191
+		}
9192
+	}()
9193
+
9194
+	patientCount, _ := service.ReturnCheckPatientCount(id)
9195
+
9196
+	patientCountObj, _ := service.GetPatientCountById(id)
9197
+
9198
+	service.UpdatePatientInCount(tx, patientCountObj.HdCount, patientCountObj.HdfCount, patientCountObj.HdhpCount, patientCountObj.HpCount, patientCountObj.PatientId)
9199
+
9200
+	tx.Commit()
9201
+	this.ServeSuccessJSON(map[string]interface{}{
9202
+		"patientCount": patientCount,
9203
+	})
9204
+
9205
+}

+ 66 - 51
controllers/sign_api_controller.go View File

@@ -1525,63 +1525,73 @@ func (this *SignApiController) ToAutoDiagnose() {
1525 1525
 
1526 1526
 	//
1527 1527
 
1528
-	adviceInfo, _ := service.GetHisDoctorAdviceByUserOrgId(10752)
1529
-	adminInfo := this.GetAdminUserInfo()
1530
-	db := service.XTWriteDB()
1531
-	tx := db.Begin()
1532
-	if len(adviceInfo) > 0 {
1533
-		for _, item := range adviceInfo {
1534
-
1535
-			drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
1536
-			var local_count int64
1537
-			if item.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1538
-
1539
-				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1540
-				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1541
-
1542
-				local_count += prescribingNumberSevenTy * drug.MinNumber
1543
-			}
1544
-
1545
-			if item.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1546
-
1547
-				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1548
-				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1549
-				local_count += prescribingNumberSevenTy
1550
-			}
1551
-
1552
-			if item.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
1553
-
1554
-				prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1555
-				prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1556
-				local_count += prescribingNumberSevenTy
1557
-			}
1558
-
1559
-			item.PrescribingNumberUnit = drug.MinUnit
1560
-
1561
-			service.BloodNewHisDrugsDelivery(item.UserOrgId, 5685, item, tx)
1528
+	//adviceInfo, _ := service.GetHisDoctorAdviceByUserOrgId(10752)
1529
+	//adminInfo := this.GetAdminUserInfo()
1530
+	//db := service.XTWriteDB()
1531
+	//tx := db.Begin()
1532
+	//if len(adviceInfo) > 0 {
1533
+	//	for _, item := range adviceInfo {
1534
+	//
1535
+	//		drug, _ := service.FindBaseDrugLibRecordSeven(adminInfo.CurrentOrgId, item.DrugId)
1536
+	//		var local_count int64
1537
+	//		if item.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit != drug.MinUnit {
1538
+	//
1539
+	//			prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1540
+	//			prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1541
+	//
1542
+	//			local_count += prescribingNumberSevenTy * drug.MinNumber
1543
+	//		}
1544
+	//
1545
+	//		if item.PrescribingNumberUnit == drug.MinUnit && drug.MaxUnit != drug.MinUnit {
1546
+	//
1547
+	//			prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1548
+	//			prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1549
+	//			local_count += prescribingNumberSevenTy
1550
+	//		}
1551
+	//
1552
+	//		if item.PrescribingNumberUnit == drug.MaxUnit && drug.MaxUnit == drug.MinUnit {
1553
+	//
1554
+	//			prescribingNumberTenty := strconv.FormatFloat(item.PrescribingNumber, 'f', -1, 64)
1555
+	//			prescribingNumberSevenTy, _ := strconv.ParseInt(prescribingNumberTenty, 10, 64)
1556
+	//			local_count += prescribingNumberSevenTy
1557
+	//		}
1558
+	//
1559
+	//		item.PrescribingNumberUnit = drug.MinUnit
1560
+	//
1561
+	//		service.BloodNewHisDrugsDelivery(item.UserOrgId, 5685, item, tx)
1562
+	//
1563
+	//		storeConfig, _ := service.GetNewAllStoreHouseConfig(item.UserOrgId, tx)
1564
+	//
1565
+	//		stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId, tx)
1566
+	//		var sum_count int64
1567
+	//		for _, its := range stockInfo {
1568
+	//			baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
1569
+	//			if its.MaxUnit == baseDrug.MaxUnit {
1570
+	//				its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
1571
+	//			}
1572
+	//			sum_count += its.StockMaxNumber + its.StockMinNumber
1573
+	//		}
1574
+	//		//更新基础库存
1575
+	//		service.UpdateNewBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId, tx)
1576
+	//		//剩余库存
1577
+	//		service.UpdateNewDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
1578
+	//
1579
+	//		over, _ := service.FindNewOverCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, tx)
1580
+	//		service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
1581
+	//	}
1582
+	//}
1562 1583
 
1563
-			storeConfig, _ := service.GetNewAllStoreHouseConfig(item.UserOrgId, tx)
1584
+	//tx.Commit()
1585
+	schedule, _ := service.CheckSchedule()
1564 1586
 
1565
-			stockInfo, _ := service.GetNewDrugAllStockInfo(storeConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId, tx)
1566
-			var sum_count int64
1567
-			for _, its := range stockInfo {
1568
-				baseDrug, _ := service.GetNewBaseDrugMedical(its.DrugId, tx)
1569
-				if its.MaxUnit == baseDrug.MaxUnit {
1570
-					its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
1571
-				}
1572
-				sum_count += its.StockMaxNumber + its.StockMinNumber
1573
-			}
1574
-			//更新基础库存
1575
-			service.UpdateNewBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId, tx)
1576
-			//剩余库存
1577
-			service.UpdateNewDrugStockCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, sum_count, tx)
1587
+	if len(schedule) > 0 {
1588
+		for _, item := range schedule {
1589
+			fmt.Println("item.p------------------", item.PatientId)
1578 1590
 
1579
-			over, _ := service.FindNewOverCount(item.DrugId, item.UserOrgId, storeConfig.DrugStorehouseOut, tx)
1580
-			service.UpdateNewActOut(over.ID, over.SumInCount, over.FlushCount, over.SumCancelCount, tx)
1591
+			service.UpdateScheduleByIdOneList(item.ID, item.ScheduleDate, item.ScheduleType, item.ScheduleWeek, item.Status, item.PatientId, item.PartitionId, item.BedId, item.DialysisMachineName, item.UserOrgId, item.ModeId)
1581 1592
 		}
1582 1593
 	}
1583 1594
 
1584
-	tx.Commit()
1585 1595
 	this.ServeSuccessJSON(map[string]interface{}{
1586 1596
 		"msg": "ok",
1587 1597
 	})
@@ -1811,3 +1821,8 @@ func (this *SignApiController) ToCheckQuery() {
1811 1821
 		"msg": "ok",
1812 1822
 	})
1813 1823
 }
1824
+
1825
+func (this *SignApiController) CheckSchedule() {
1826
+
1827
+	service.CheckSchedule()
1828
+}

+ 1 - 0
models/dialysis.go View File

@@ -346,6 +346,7 @@ type PredialysisEvaluationList struct {
346 346
 	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
347 347
 	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
348 348
 	DryWeight              float64 `gorm:"column:dry_weight" json:"dry_weight"`
349
+	Height                 int64   `gorm:"column:height" json:"height" form:"height"`
349 350
 }
350 351
 
351 352
 func (PredialysisEvaluationList) TableName() string {

+ 40 - 0
models/patient_models.go View File

@@ -27,6 +27,7 @@ type MSchedualPatientList struct {
27 27
 	ScheduleRemark     string `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
28 28
 	FirstLetter        string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
29 29
 	IsInfectious       int64  `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
30
+	Height             int64  `gorm:"column:height" json:"height" form:"height"`
30 31
 }
31 32
 
32 33
 func (MSchedualPatientList) TableName() string {
@@ -3121,3 +3122,42 @@ type XtInspectionOne struct {
3121 3122
 	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
3122 3123
 	Count        int64
3123 3124
 }
3125
+
3126
+type SfPatients struct {
3127
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
3128
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3129
+	Name        string `gorm:"column:name" json:"name" form:"name"`
3130
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
3131
+	Lapseto     int64  `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
3132
+	FirstLetter string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
3133
+	HdCount     int64  `gorm:"column:hd_count" json:"hd_count" form:"hd_count"`
3134
+	HdfCount    int64  `gorm:"column:hdf_count" json:"hdf_count" form:"hdf_count"`
3135
+	HdhpCount   int64  `gorm:"column:hdhp_count" json:"hdhp_count" form:"hdhp_count"`
3136
+	HpCount     int64  `gorm:"column:hp_count" json:"hp_count" form:"hp_count"`
3137
+}
3138
+
3139
+func (SfPatients) TableName() string {
3140
+	return "xt_patients"
3141
+}
3142
+
3143
+type SfPatientInCount struct {
3144
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
3145
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3146
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3147
+	HdCount    int64  `gorm:"column:hd_count" json:"hd_count" form:"hd_count"`
3148
+	HdfCount   int64  `gorm:"column:hdf_count" json:"hdf_count" form:"hdf_count"`
3149
+	HdhpCount  int64  `gorm:"column:hdhp_count" json:"hdhp_count" form:"hdhp_count"`
3150
+	HpCount    int64  `gorm:"column:hp_count" json:"hp_count" form:"hp_count"`
3151
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
3152
+	Creater    int64  `gorm:"column:creater" json:"creater" form:"creater"`
3153
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
3154
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
3155
+	IsCheck    int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
3156
+	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
3157
+	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
3158
+	OtherCount int64  `gorm:"column:other_count" json:"other_count" form:"other_count"`
3159
+}
3160
+
3161
+func (SfPatientInCount) TableName() string {
3162
+	return "xt_patient_in_count"
3163
+}

+ 17 - 0
service/db.go View File

@@ -26,6 +26,7 @@ import (
26 26
 
27 27
 var readDb *gorm.DB
28 28
 var readDb2 *gorm.DB
29
+var readDb3 *gorm.DB
29 30
 var writeDb *gorm.DB
30 31
 var readUserDb *gorm.DB
31 32
 var writeUserDb *gorm.DB
@@ -33,6 +34,8 @@ var writeUserDb *gorm.DB
33 34
 var readMiddleDb *gorm.DB
34 35
 var writeMiddleDb *gorm.DB
35 36
 
37
+var newReadMiddleDb *gorm.DB
38
+
36 39
 var readPatientDb *gorm.DB
37 40
 var writePatientDb *gorm.DB
38 41
 
@@ -57,6 +60,12 @@ func ConnectDB() {
57 60
 	readPass2 := beego.AppConfig.String("readmysqlpass2")
58 61
 	readName2 := beego.AppConfig.String("readmysqlname2")
59 62
 
63
+	readHost3 := beego.AppConfig.String("readmysqlhost3")
64
+	readPort3 := beego.AppConfig.String("readmysqlport3")
65
+	readUser3 := beego.AppConfig.String("readmysqluser3")
66
+	readPass3 := beego.AppConfig.String("readmysqlpass3")
67
+	readName3 := beego.AppConfig.String("readmysqlname3")
68
+
60 69
 	writeHost := beego.AppConfig.String("writemysqlhost")
61 70
 	writePort := beego.AppConfig.String("writemysqlport")
62 71
 	writeUser := beego.AppConfig.String("writemysqluser")
@@ -127,6 +136,8 @@ func ConnectDB() {
127 136
 
128 137
 	rdsn2 := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser2, readPass2, readHost2, readPort2, readName2)
129 138
 
139
+	rdsn3 := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser3, readPass3, readHost3, readPort3, readName3)
140
+
130 141
 	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
131 142
 
132 143
 	rudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUserUser, readUserPass, readUserHost, readUserPort, readUserName)
@@ -146,6 +157,8 @@ func ConnectDB() {
146 157
 
147 158
 	readDb2, err = gorm.Open("mysql", rdsn2)
148 159
 
160
+	readDb3, err = gorm.Open("mysql", rdsn3)
161
+
149 162
 	readDb, err = gorm.Open("mysql", rdsn)
150 163
 	if err != nil {
151 164
 		//beego.Error(err)
@@ -158,6 +171,10 @@ func ConnectDB() {
158 171
 	readDb2.DB().SetMaxOpenConns(100)
159 172
 	readDb2.LogMode(true)
160 173
 
174
+	readDb3.DB().SetMaxIdleConns(10)
175
+	readDb3.DB().SetMaxOpenConns(100)
176
+	readDb3.LogMode(true)
177
+
161 178
 	writeDb, err = gorm.Open("mysql", wdsn)
162 179
 	if err != nil {
163 180
 		//beego.Error(err)

+ 12 - 0
service/dialysis_service.go View File

@@ -1074,6 +1074,18 @@ func DeleteDoctorAdviceByGroupNo(m *models.DoctorAdvice) (err error) {
1074 1074
 	return
1075 1075
 }
1076 1076
 
1077
+func DeleteDoctorAdviceByGroupNoOne(m *models.DoctorAdvice) (err error) {
1078
+	ut := writeDb.Begin()
1079
+	err = ut.Model(&models.DoctorAdvice{}).Where("groupno = ? AND user_org_id =  ? and patient_id = ? and advice_date = ?", m.GroupNo, m.UserOrgId, m.PatientId, m.AdviceDate).Update(map[string]interface{}{"UpdatedTime": m.UpdatedTime, "Status": 0, "modifier": m.Modifier}).Error
1080
+	if err != nil {
1081
+		ut.Rollback()
1082
+		return
1083
+	}
1084
+	ut.Commit()
1085
+
1086
+	return
1087
+}
1088
+
1077 1089
 func GetDialysisBoard(orgID int64, scheduleDate int64, offset, limit int64) ([]*models.DialysisBoardVM, error) {
1078 1090
 	var boards []*models.DialysisBoardVM
1079 1091
 	db := readDb.

+ 1 - 1
service/mobile_dialysis_service.go View File

@@ -195,6 +195,7 @@ type MSchedualPatientVMList struct {
195 195
 	SchRemark          string `gorm:"column:sch_remark" json:"sch_remark" form:"sch_remark"`
196 196
 	ScheduleRemark     string `gorm:"column:schedule_remark" json:"schedule_remark" form:"schedule_remark"`
197 197
 	FirstLetter        string `gorm:"column:first_letter" json:"first_letter" form:"first_letter"`
198
+	Height             int64  `gorm:"column:height" json:"height" form:"height"`
198 199
 }
199 200
 
200 201
 func (MSchedualPatientVMList) TableName() string {
@@ -8619,7 +8620,6 @@ func GetHisDoctorAdvicesTwentyOne(orgID int64, scheduleDate int64, deliverWay st
8619 8620
 		}
8620 8621
 		if patient_id > 0 {
8621 8622
 			if execution_state > 0 {
8622
-				fmt.Println("execution_state---------------------", execution_state)
8623 8623
 				if cost_type > 0 {
8624 8624
 					db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id = ?", orgID, patient_id).
8625 8625
 						Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).

+ 115 - 5
service/patient_service.go View File

@@ -687,12 +687,26 @@ func FindPatientByIdWithDiseases(orgID int64, id int64) (patient models.Patients
687 687
 }
688 688
 
689 689
 func FindPatientWithDeviceByNo(orgID int64, no string, time int64) (patient models.SchedualPatient2, err error) {
690
-	err = readDb.Preload("DialysisSchedule", func(db *gorm.DB) *gorm.DB {
691
-		return db.Preload("DeviceNumber", "org_id = ?", orgID).
692
-			Preload("DeviceZone", "org_id = ?", orgID).
693
-			Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
694
-	}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and dialysis_no = ? and status = 1 ", orgID, no).First(&patient).Error
690
+
691
+	if orgID != 9882 {
692
+		err = readDb.Preload("DialysisSchedule", func(db *gorm.DB) *gorm.DB {
693
+			return db.Preload("DeviceNumber", "org_id = ?", orgID).
694
+				Preload("DeviceZone", "org_id = ?", orgID).
695
+				Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
696
+		}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and dialysis_no = ? and status = 1 ", orgID, no).First(&patient).Error
697
+	}
698
+
699
+	if orgID == 9882 {
700
+		err = readDb.Preload("DialysisSchedule", func(db *gorm.DB) *gorm.DB {
701
+			return db.Preload("DeviceNumber", "org_id = ?", orgID).
702
+				Preload("DeviceZone", "org_id = ?", orgID).
703
+				Where("user_org_id = ? AND schedule_date = ? ", orgID, time)
704
+		}).Preload("InfectiousDiseases", "status = 1").Where("user_org_id=? and dialysis_no = ? and status = 1 and  lapseto =1", orgID, no).First(&patient).Error
705
+
706
+	}
707
+
695 708
 	return
709
+
696 710
 }
697 711
 
698 712
 func FindPatientWithDeviceByPatientId(orgID int64, id int64, time int64) (patient models.SchedualPatient2, err error) {
@@ -5050,3 +5064,99 @@ func ModifyExecutionAdvice(id int64, execution_staff int64, ExecutionTime int64)
5050 5064
 
5051 5065
 	return err
5052 5066
 }
5067
+
5068
+func GetPatientMapList(user_org_id int64, keyword string) (patient []*models.SfPatients, err error) {
5069
+
5070
+	keyword = "%" + keyword + "%"
5071
+
5072
+	err = XTReadDB().Where("user_org_id = ? and status=1 and lapseto =1 and (name like ? or first_letter like ?)", user_org_id, keyword, keyword).Find(&patient).Error
5073
+
5074
+	return patient, err
5075
+}
5076
+
5077
+func CreatePatientInCount(tx *gorm.DB, patientCount models.SfPatientInCount) error {
5078
+
5079
+	err := tx.Create(&patientCount).Error
5080
+
5081
+	if err != nil {
5082
+		tx.Rollback()
5083
+		return err
5084
+	}
5085
+	return err
5086
+}
5087
+
5088
+func ModifyPatientCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count int64, hp_count int64, patient_id int64) (models.SfPatients, error) {
5089
+
5090
+	patients := models.SfPatients{}
5091
+
5092
+	err = tx.Model(&patients).Where("id = ?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count + ?", hd_count)).Error
5093
+
5094
+	err = tx.Model(&patients).Where("id = ?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count + ?", hdf_count)).Error
5095
+
5096
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count + ?", hdhp_count)).Error
5097
+
5098
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count + ?", hp_count)).Error
5099
+
5100
+	return patients, err
5101
+}
5102
+
5103
+func UpdatePatientInCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count int64, hp_count int64, patient_id int64) (models.SfPatients, error) {
5104
+
5105
+	patients := models.SfPatients{}
5106
+
5107
+	err = tx.Model(&patients).Where("id = ?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count - ?", hd_count)).Error
5108
+
5109
+	err = tx.Model(&patients).Where("id = ?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count - ?", hdf_count)).Error
5110
+
5111
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count - ?", hdhp_count)).Error
5112
+
5113
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count - ?", hp_count)).Error
5114
+
5115
+	return patients, err
5116
+}
5117
+
5118
+func GetPatientCountList(user_org_id int64, patient_id int64, page int64, limit int64) (patient []*models.SfPatientInCount, total int64, err error) {
5119
+
5120
+	db := XTReadDB().Model(&patient).Where("status=1")
5121
+
5122
+	offset := (page - 1) * limit
5123
+
5124
+	if patient_id > 0 {
5125
+		db = db.Where("patient_id = ?", patient_id)
5126
+	}
5127
+
5128
+	if user_org_id > 0 {
5129
+		db = db.Where("user_org_id = ?", user_org_id)
5130
+	}
5131
+
5132
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&patient).Error
5133
+
5134
+	return patient, total, err
5135
+}
5136
+
5137
+func CheckPatientCount(id int64) (models.SfPatientInCount, error) {
5138
+
5139
+	patientInCount := models.SfPatientInCount{}
5140
+
5141
+	err = XTWriteDB().Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 1}).Error
5142
+
5143
+	return patientInCount, err
5144
+}
5145
+
5146
+func ReturnCheckPatientCount(id int64) (models.SfPatientInCount, error) {
5147
+
5148
+	patientInCount := models.SfPatientInCount{}
5149
+
5150
+	err = XTWriteDB().Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5151
+
5152
+	return patientInCount, err
5153
+}
5154
+
5155
+func GetPatientCountById(id int64) (models.SfPatientInCount, error) {
5156
+
5157
+	patientInCount := models.SfPatientInCount{}
5158
+
5159
+	err := XTReadDB().Where("id = ?", id).Find(&patientInCount).Error
5160
+
5161
+	return patientInCount, err
5162
+}

+ 15 - 1
service/sign_service.go View File

@@ -2192,7 +2192,7 @@ func UpdateScheduleByOrder(patient_id int64, schedule_date int64, user_org_id in
2192 2192
 
2193 2193
 func GetScheduleListByOrder(user_org_id int64) (list []*models.XtSchedule, err error) {
2194 2194
 
2195
-	err = XTReadDB().Where("user_org_id = ? and schedule_date >=? and status =1 and schedule_date<=?", 10579, 1703260800, 1703347200).Find(&list).Error
2195
+	err = XTReadDB().Where("user_org_id = ? and schedule_date >=? and status =1 and schedule_date<=?", 10579, 1741795200, 1742054400).Find(&list).Error
2196 2196
 	return list, err
2197 2197
 }
2198 2198
 
@@ -2485,3 +2485,17 @@ func BloodNewHisDrugsDelivery(orgID int64, creater int64, advice *models.HisDoct
2485 2485
 
2486 2486
 	return
2487 2487
 }
2488
+
2489
+func CheckSchedule() (schedule []*models.XtSchedule, err error) {
2490
+
2491
+	err = readDb3.Where("user_org_id = 10445 and schedule_date<1741536000").Find(&schedule).Error
2492
+
2493
+	return schedule, err
2494
+}
2495
+
2496
+func UpdateScheduleByIdOneList(id int64, schedule_date int64, schedule_type int64, schedule_week int64, status int64, patient_id int64, partition_id int64, bed_id int64, dialysis_machine_name string, user_org_id int64, mode_id int64) error {
2497
+
2498
+	err := XTWriteDB().Model(&models.XtSchedule{}).Where("id = ?", id).Updates(map[string]interface{}{"schedule_date": schedule_date, "schedule_type": schedule_type, "schedule_week": schedule_week, "status": status, "patient_id": patient_id, "partition_id": partition_id, "bed_id": bed_id, "dialysis_machine_name": dialysis_machine_name, "user_org_id": user_org_id, "mode_id": mode_id}).Error
2499
+
2500
+	return err
2501
+}