Selaa lähdekoodia

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

陈少旭 6 päivää sitten
vanhempi
commit
620d2f8dd6
38 muutettua tiedostoa jossa 1994 lisäystä ja 327 poistoa
  1. 0 4
      .idea/.gitignore
  2. 0 5
      .idea/codeStyles/codeStyleConfig.xml
  3. 0 12
      .idea/dataSources.xml
  4. 0 4
      .idea/encodings.xml
  5. 0 26
      .idea/misc.xml
  6. 0 5
      .idea/vcs.xml
  7. BIN
      XT_New.exe
  8. 13 0
      conf/app.conf
  9. 6 6
      controllers/base_api_controller.go
  10. 10 14
      controllers/common_api_controller.go
  11. 23 12
      controllers/dialysis_api_controller.go
  12. 12 1
      controllers/gobal_config_api_controller.go
  13. 1 3
      controllers/his_api_controller.go
  14. 13 0
      controllers/mobile_api_controllers/check_weight_api_controller.go
  15. 233 8
      controllers/mobile_api_controllers/dialysis_api_controller.go
  16. 23 12
      controllers/mobile_api_controllers/patient_api_controller.go
  17. 19 1
      controllers/new_mobile_api_controllers/staff_schedule_api_controller.go
  18. 2 0
      controllers/new_mobile_api_controllers/staff_schedule_api_router.go
  19. 763 11
      controllers/patient_api_controller.go
  20. 3 0
      controllers/pharmacy_controller.go
  21. 66 51
      controllers/sign_api_controller.go
  22. 8 28
      controllers/statistics_api_controller.go
  23. 1 0
      models/dialysis.go
  24. 26 72
      models/his_models.go
  25. 92 0
      models/patient_models.go
  26. 1 0
      models/stock_models.go
  27. 8 14
      service/common_service.go
  28. 17 0
      service/db.go
  29. 12 0
      service/dialysis_service.go
  30. 6 0
      service/gobal_config_service.go
  31. 2 1
      service/mobile_dialysis_service.go
  32. 14 15
      service/new_warehouse_service.go
  33. 562 6
      service/patient_service.go
  34. 5 5
      service/patientmanage_service.go
  35. 9 1
      service/pharmacy_service.go
  36. 1 1
      service/self_drug_service.go
  37. 15 1
      service/sign_service.go
  38. 28 8
      service/warhouse_service.go

+ 0 - 4
.idea/.gitignore Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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 Näytä tiedosto


+ 13 - 0
conf/app.conf Näytä tiedosto

@@ -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!@#$

+ 6 - 6
controllers/base_api_controller.go Näytä tiedosto

@@ -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 = 9478 //机构id
86
+		subscibe.OrgId = 10721 //机构id
87 87
 		subscibe.PeriodStart = 1547447814
88 88
 		subscibe.PeriodEnd = 1550039814
89 89
 		subscibe.State = 1
@@ -93,8 +93,8 @@ 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 = 9478  //机构id小英9675或4
97
-		adminUserInfo.CurrentAppId = 18470 //4
96
+		adminUserInfo.CurrentOrgId = 10721 //机构id小英9675或4
97
+		adminUserInfo.CurrentAppId = 18723 //4
98 98
 		adminUserInfo.AdminUser = &userAdmin
99 99
 		adminUserInfo.Subscibes = subscibes
100 100
 		this.SetSession("admin_user_info", &adminUserInfo)
@@ -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 = 9478 //机构id小英9675或4
332
+		subscibe.OrgId = 10721 //机构id小英9675或4
333 333
 		subscibe.PeriodStart = 1538035409
334 334
 		subscibe.PeriodEnd = 1569571409
335 335
 		subscibe.State = 1
@@ -339,8 +339,8 @@ 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 = 9478  //机构id小英9675或4
343
-		adminUserInfo.CurrentAppId = 18470 //4
342
+		adminUserInfo.CurrentOrgId = 10721 //机构id小英9675或4
343
+		adminUserInfo.CurrentAppId = 18723 //4
344 344
 		adminUserInfo.AdminUser = &userAdmin
345 345
 		adminUserInfo.Subscibes = subscibes
346 346
 		this.SetSession("admin_user_info", &adminUserInfo)

+ 10 - 14
controllers/common_api_controller.go Näytä tiedosto

@@ -1,15 +1,16 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"encoding/json"
5
+	"fmt"
6
+	"strconv"
7
+	"time"
8
+
4 9
 	"XT_New/enums"
5 10
 	"XT_New/models"
6 11
 	"XT_New/service"
7 12
 	"XT_New/utils"
8
-	"encoding/json"
9
-	"fmt"
10 13
 	"github.com/jinzhu/gorm"
11
-	"strconv"
12
-	"time"
13 14
 )
14 15
 
15 16
 type CommonApiController struct {
@@ -583,11 +584,10 @@ func (this *CommonApiController) GetTotalLapseCount() {
583 584
 func (this *CommonApiController) GetTotalSexCount() {
584 585
 	adminUser := this.GetAdminUserInfo()
585 586
 	orgid := adminUser.CurrentOrgId
586
-	fmt.Println("orgid", orgid)
587
-	startime, _ := this.GetInt64("startime")
588
-	fmt.Println("开始时间", startime)
589
-	endtime, _ := this.GetInt64("endtime")
590
-	fmt.Println("结束时间", endtime)
587
+	//startime, _ := this.GetInt64("startime")
588
+	//
589
+	//endtime, _ := this.GetInt64("endtime")
590
+
591 591
 	lapsetotype, _ := this.GetInt64("lapsetotype")
592 592
 	sourcetype, _ := this.GetInt64("sourcetype")
593 593
 	total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
@@ -642,11 +642,6 @@ func (this *CommonApiController) GetTotalInfectiouscount() {
642 642
 func (this *CommonApiController) GetTotalAgeCount() {
643 643
 	adminUser := this.GetAdminUserInfo()
644 644
 	orgid := adminUser.CurrentOrgId
645
-	fmt.Println("orgid", orgid)
646
-	startime, _ := this.GetInt64("startime")
647
-	fmt.Println("开始时间", startime)
648
-	endtime, _ := this.GetInt64("endtime")
649
-	fmt.Println("结束时间", endtime)
650 645
 	lapsetotype, _ := this.GetInt64("lapsetotype")
651 646
 	sourcetype, _ := this.GetInt64("sourcetype")
652 647
 	//统计透析总人数
@@ -1451,6 +1446,7 @@ func (this *CommonApiController) GetPatientscontrol() {
1451 1446
 	limit, _ := this.GetInt64("limit")
1452 1447
 
1453 1448
 	patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
1449
+
1454 1450
 	control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
1455 1451
 
1456 1452
 	infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)

+ 23 - 12
controllers/dialysis_api_controller.go Näytä tiedosto

@@ -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)
@@ -2870,13 +2879,13 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
2870 2879
 			service.CreateDialysisFinish(finish)
2871 2880
 		}
2872 2881
 
2873
-		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 {
2882
+		if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 || adminUserInfo.CurrentOrgId == 10480 || adminUserInfo.CurrentOrgId == 10293 || adminUserInfo.CurrentOrgId == 9478 {
2874 2883
 			var dewater_amount float64
2875 2884
 			dewater_amount = 0
2876 2885
 			if dry_weight > 0 {
2877 2886
 				dewater_amount = weight_before - dry_weight - additional_weight
2878 2887
 
2879
-				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 && adminUserInfo.CurrentOrgId != 10723 {
2888
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 && adminUserInfo.CurrentOrgId != 10723 && adminUserInfo.CurrentOrgId != 10480 && adminUserInfo.CurrentOrgId != 10293 && adminUserInfo.CurrentOrgId != 9478 {
2880 2889
 					dewater_amount = dewater_amount * 1000
2881 2890
 				}
2882 2891
 
@@ -3239,8 +3248,8 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3239 3248
 		dewater_amount = 0
3240 3249
 		if evaluation.DryWeight > 0 {
3241 3250
 			dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3242
-			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10757 {
3243
-				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 {
3251
+			if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10757 || adminUserInfo.CurrentOrgId == 9478 {
3252
+				if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10751 && adminUserInfo.CurrentOrgId != 9478 {
3244 3253
 					dewater_amount = dewater_amount * 1000
3245 3254
 				}
3246 3255
 
@@ -3517,7 +3526,7 @@ func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
3517 3526
 		}
3518 3527
 
3519 3528
 		//针对孝昌康桥超滤率计算问题
3520
-		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 || adminUserInfo.CurrentOrgId == 10697 {
3529
+		if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10742 || adminUserInfo.CurrentOrgId == 10751 || adminUserInfo.CurrentOrgId == 10752 || adminUserInfo.CurrentOrgId == 10697 || adminUserInfo.CurrentOrgId == 9478 {
3521 3530
 			if assessmentBeforeDislysis.ID == 0 {
3522 3531
 				dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
3523 3532
 				if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
@@ -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
 

+ 12 - 1
controllers/gobal_config_api_controller.go Näytä tiedosto

@@ -1150,6 +1150,13 @@ func (c *GobalConfigApiController) GetPrintInfo() {
1150 1150
 	idsInters := dataBody["ids"].([]interface{})
1151 1151
 	advice_type, _ := c.GetInt64("advice_type")
1152 1152
 	stop_type, _ := c.GetInt64("stop_type")
1153
+	his_str := c.GetString("his_str")
1154
+	if len(his_str) == 0 {
1155
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1156
+		return
1157
+	}
1158
+
1159
+	idStrs := strings.Split(his_str, ",")
1153 1160
 	if len(idsInters) == 0 {
1154 1161
 		if err != nil {
1155 1162
 			c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
@@ -1161,9 +1168,13 @@ func (c *GobalConfigApiController) GetPrintInfo() {
1161 1168
 		id := int64(idsInter.(float64))
1162 1169
 		ids = append(ids, id)
1163 1170
 	}
1171
+
1164 1172
 	getPrint, err := service.GetPrint(ids, OrgID, advice_type, stop_type)
1173
+
1174
+	hisPrint, _ := service.GetHisPrint(idStrs, OrgID)
1165 1175
 	c.ServeSuccessJSON(map[string]interface{}{
1166
-		"doctoradvice": getPrint,
1176
+		"doctoradvice":    getPrint,
1177
+		"hisdoctoradvice": hisPrint,
1167 1178
 	})
1168 1179
 }
1169 1180
 

+ 1 - 3
controllers/his_api_controller.go Näytä tiedosto

@@ -3494,7 +3494,7 @@ func (c *HisApiController) CreateHisPrescription() {
3494 3494
 	var adviceList []models.HisDoctorAdviceInfo
3495 3495
 	var projectList []models.HisPrescriptionProject
3496 3496
 
3497
-	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 {
3497
+	if adminInfo.CurrentOrgId == 10489 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 10164 || adminInfo.CurrentOrgId == 10478 || adminInfo.CurrentOrgId == 10318 || adminInfo.CurrentOrgId == 10480 || adminInfo.CurrentOrgId == 10633 || adminInfo.CurrentOrgId == 10610 || adminInfo.CurrentOrgId == 10402 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10537 || adminInfo.CurrentOrgId == 10265 || adminInfo.CurrentOrgId == 10644 || adminInfo.CurrentOrgId == 10635 || adminInfo.CurrentOrgId == 10598 || adminInfo.CurrentOrgId == 10028 || adminInfo.CurrentOrgId == 10721 || adminInfo.CurrentOrgId == 10726 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10571 || adminInfo.CurrentOrgId == 10724 || adminInfo.CurrentOrgId == 9671 || adminInfo.CurrentOrgId == 10731 || adminInfo.CurrentOrgId == 10653 || adminInfo.CurrentOrgId == 10567 || adminInfo.CurrentOrgId == 10751 || adminInfo.CurrentOrgId == 10752 || adminInfo.CurrentOrgId == 9478 {
3498 3498
 		if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
3499 3499
 			prescriptions, _ := dataBody["prescriptions"].([]interface{})
3500 3500
 
@@ -3857,8 +3857,6 @@ func (c *HisApiController) CreateHisPrescription() {
3857 3857
 
3858 3858
 											}
3859 3859
 
3860
-											fmt.Println("s.ID==========================", s.ID)
3861
-
3862 3860
 											if s.ID > 0 {
3863 3861
 												//查询改药品是否已经停用
3864 3862
 												base, _ := service.GetBasedrugById(s.DrugId, s.UserOrgId)

+ 13 - 0
controllers/mobile_api_controllers/check_weight_api_controller.go Näytä tiedosto

@@ -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
 		//记录日志

+ 233 - 8
controllers/mobile_api_controllers/dialysis_api_controller.go Näytä tiedosto

@@ -3536,6 +3536,230 @@ func (c *DialysisAPIController) Finish() {
3536 3536
 
3537 3537
 	}
3538 3538
 
3539
+	//查找是否开启配置
3540
+	//orderSetting, _ := service.GetDialysisOrderSetting(adminUserInfo.Org.Id)
3541
+	////开启下机扣减
3542
+	//if orderSetting.IsOpen == 1 {
3543
+	//
3544
+	//	//查询今日患者排班的模式
3545
+	//	db := service.XTWriteDB()
3546
+	//	// 开始外部循环的事务
3547
+	//	tx := db.Begin()
3548
+	//	// 在函数结束时处理事务回滚
3549
+	//	defer func() {
3550
+	//		if r := recover(); r != nil {
3551
+	//			tx.Rollback()
3552
+	//		}
3553
+	//	}()
3554
+	//
3555
+	//	schedule, _ := service.GetDialysisOrderSchedule(id, recordDate.Unix(), adminUserInfo.Org.Id, tx)
3556
+	//
3557
+	//	if schedule.ModeId == 1 {
3558
+	//		//扣减库存
3559
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3560
+	//
3561
+	//		patient, _ := service.GetSfPatientById(tx, id)
3562
+	//		var over_count int64
3563
+	//		if schedule.ModeId == 1 {
3564
+	//			over_count = patient.HdCount
3565
+	//		}
3566
+	//		if schedule.ModeId == 2 {
3567
+	//			over_count = patient.HdfCount
3568
+	//		}
3569
+	//
3570
+	//		if schedule.ModeId == 3 {
3571
+	//			over_count = patient.HdhpCount
3572
+	//		}
3573
+	//		if schedule.ModeId == 4 {
3574
+	//			over_count = patient.HpCount
3575
+	//		}
3576
+	//		if schedule.ModeId == 5 {
3577
+	//			over_count = patient.OtherCount
3578
+	//		}
3579
+	//		patientCountFlow := models.SfPatientCountFlow{
3580
+	//			PatientId:      id,
3581
+	//			ModeId:         schedule.ModeId,
3582
+	//			Count:          1,
3583
+	//			Status:         1,
3584
+	//			Ctime:          time.Now().Unix(),
3585
+	//			Mtime:          time.Now().Unix(),
3586
+	//			RecordDate:     recordDate.Unix(),
3587
+	//			UserOrgId:      adminUserInfo.Org.Id,
3588
+	//			Creater:        adminUserInfo.AdminUser.Id,
3589
+	//			IsType:         1,
3590
+	//			OverCount:      over_count,
3591
+	//			WarehouseOutId: 0,
3592
+	//		}
3593
+	//
3594
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3595
+	//	}
3596
+	//
3597
+	//	if schedule.ModeId == 2 {
3598
+	//
3599
+	//		//扣减库存
3600
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3601
+	//
3602
+	//		patient, _ := service.GetSfPatientById(tx, id)
3603
+	//		var over_count int64
3604
+	//		if schedule.ModeId == 1 {
3605
+	//			over_count = patient.HdCount
3606
+	//		}
3607
+	//		if schedule.ModeId == 2 {
3608
+	//			over_count = patient.HdfCount
3609
+	//		}
3610
+	//
3611
+	//		if schedule.ModeId == 3 {
3612
+	//			over_count = patient.HdhpCount
3613
+	//		}
3614
+	//		if schedule.ModeId == 4 {
3615
+	//			over_count = patient.HpCount
3616
+	//		}
3617
+	//		if schedule.ModeId == 5 {
3618
+	//			over_count = patient.OtherCount
3619
+	//		}
3620
+	//		patientCountFlow := models.SfPatientCountFlow{
3621
+	//			PatientId:      id,
3622
+	//			ModeId:         schedule.ModeId,
3623
+	//			Count:          1,
3624
+	//			Status:         1,
3625
+	//			Ctime:          time.Now().Unix(),
3626
+	//			Mtime:          time.Now().Unix(),
3627
+	//			RecordDate:     recordDate.Unix(),
3628
+	//			UserOrgId:      adminUserInfo.Org.Id,
3629
+	//			Creater:        adminUserInfo.AdminUser.Id,
3630
+	//			IsType:         2,
3631
+	//			OverCount:      over_count,
3632
+	//			WarehouseOutId: 0,
3633
+	//		}
3634
+	//
3635
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3636
+	//	}
3637
+	//
3638
+	//	if schedule.ModeId == 3 {
3639
+	//
3640
+	//		//扣减库存
3641
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3642
+	//
3643
+	//		patient, _ := service.GetSfPatientById(tx, id)
3644
+	//		var over_count int64
3645
+	//		if schedule.ModeId == 1 {
3646
+	//			over_count = patient.HdCount
3647
+	//		}
3648
+	//		if schedule.ModeId == 2 {
3649
+	//			over_count = patient.HdfCount
3650
+	//		}
3651
+	//
3652
+	//		if schedule.ModeId == 3 {
3653
+	//			over_count = patient.HdhpCount
3654
+	//		}
3655
+	//		if schedule.ModeId == 4 {
3656
+	//			over_count = patient.HpCount
3657
+	//		}
3658
+	//		if schedule.ModeId == 5 {
3659
+	//			over_count = patient.OtherCount
3660
+	//		}
3661
+	//		patientCountFlow := models.SfPatientCountFlow{
3662
+	//			PatientId:      id,
3663
+	//			ModeId:         schedule.ModeId,
3664
+	//			Count:          1,
3665
+	//			Status:         1,
3666
+	//			Ctime:          time.Now().Unix(),
3667
+	//			Mtime:          time.Now().Unix(),
3668
+	//			RecordDate:     recordDate.Unix(),
3669
+	//			UserOrgId:      adminUserInfo.Org.Id,
3670
+	//			Creater:        adminUserInfo.AdminUser.Id,
3671
+	//			IsType:         3,
3672
+	//			OverCount:      over_count,
3673
+	//			WarehouseOutId: 0,
3674
+	//		}
3675
+	//
3676
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3677
+	//	}
3678
+	//	if schedule.ModeId == 4 {
3679
+	//
3680
+	//		//扣减库存
3681
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3682
+	//
3683
+	//		patient, _ := service.GetSfPatientById(tx, id)
3684
+	//		var over_count int64
3685
+	//		if schedule.ModeId == 1 {
3686
+	//			over_count = patient.HdCount
3687
+	//		}
3688
+	//		if schedule.ModeId == 2 {
3689
+	//			over_count = patient.HdfCount
3690
+	//		}
3691
+	//
3692
+	//		if schedule.ModeId == 3 {
3693
+	//			over_count = patient.HdhpCount
3694
+	//		}
3695
+	//		if schedule.ModeId == 4 {
3696
+	//			over_count = patient.HpCount
3697
+	//		}
3698
+	//		if schedule.ModeId == 5 {
3699
+	//			over_count = patient.OtherCount
3700
+	//		}
3701
+	//		patientCountFlow := models.SfPatientCountFlow{
3702
+	//			PatientId:      id,
3703
+	//			ModeId:         schedule.ModeId,
3704
+	//			Count:          1,
3705
+	//			Status:         1,
3706
+	//			Ctime:          time.Now().Unix(),
3707
+	//			Mtime:          time.Now().Unix(),
3708
+	//			RecordDate:     recordDate.Unix(),
3709
+	//			UserOrgId:      adminUserInfo.Org.Id,
3710
+	//			Creater:        adminUserInfo.AdminUser.Id,
3711
+	//			IsType:         4,
3712
+	//			OverCount:      over_count,
3713
+	//			WarehouseOutId: 0,
3714
+	//		}
3715
+	//
3716
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3717
+	//	}
3718
+	//	if schedule.ModeId != 1 && schedule.ModeId != 2 && schedule.ModeId != 3 && schedule.ModeId != 4 {
3719
+	//
3720
+	//		//扣减库存
3721
+	//		service.ReducePatientCount(1, schedule.ModeId, id, tx)
3722
+	//
3723
+	//		patient, _ := service.GetSfPatientById(tx, id)
3724
+	//		var over_count int64
3725
+	//		if schedule.ModeId == 1 {
3726
+	//			over_count = patient.HdCount
3727
+	//		}
3728
+	//		if schedule.ModeId == 2 {
3729
+	//			over_count = patient.HdfCount
3730
+	//		}
3731
+	//
3732
+	//		if schedule.ModeId == 3 {
3733
+	//			over_count = patient.HdhpCount
3734
+	//		}
3735
+	//		if schedule.ModeId == 4 {
3736
+	//			over_count = patient.HpCount
3737
+	//		}
3738
+	//		if schedule.ModeId == 5 {
3739
+	//			over_count = patient.OtherCount
3740
+	//		}
3741
+	//		patientCountFlow := models.SfPatientCountFlow{
3742
+	//			PatientId:      id,
3743
+	//			ModeId:         schedule.ModeId,
3744
+	//			Count:          1,
3745
+	//			Status:         1,
3746
+	//			Ctime:          time.Now().Unix(),
3747
+	//			Mtime:          time.Now().Unix(),
3748
+	//			RecordDate:     recordDate.Unix(),
3749
+	//			UserOrgId:      adminUserInfo.Org.Id,
3750
+	//			Creater:        adminUserInfo.AdminUser.Id,
3751
+	//			IsType:         5,
3752
+	//			OverCount:      over_count,
3753
+	//			WarehouseOutId: 0,
3754
+	//		}
3755
+	//
3756
+	//		service.CreatePatientCountFlow(patientCountFlow, tx)
3757
+	//	}
3758
+	//
3759
+	//	tx.Commit()
3760
+	//	return
3761
+	//}
3762
+
3539 3763
 }
3540 3764
 
3541 3765
 func (c *DialysisAPIController) GetAllZone() {
@@ -3916,7 +4140,7 @@ func (this *DialysisAPIController) StartDialysis() {
3916 4140
 				ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
3917 4141
 			}
3918 4142
 
3919
-			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 {
4143
+			if adminUserInfo.Org.Id == 10742 || adminUserInfo.Org.Id == 10740 || adminUserInfo.Org.Id == 10745 || adminUserInfo.Org.Id == 9478 {
3920 4144
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
3921 4145
 			}
3922 4146
 
@@ -4091,7 +4315,7 @@ func (this *DialysisAPIController) StartDialysis() {
4091 4315
 				}
4092 4316
 			}
4093 4317
 
4094
-			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 {
4318
+			if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10731 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10744 {
4095 4319
 				if prescription.ModeId == 2 {
4096 4320
 					totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
4097 4321
 					if totalMin == 0 {
@@ -5237,8 +5461,9 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5237 5461
 			}
5238 5462
 
5239 5463
 			//重庆塘坝卫生院
5240
-			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 {
5464
+			if adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10745 || adminInfo.Org.Id == 9478 {
5241 5465
 				ultrafiltration_rate = math.Floor(prescription.PrescriptionWater / float64(totalMin) * 60 * 1000)
5466
+				fmt.Println("ultrafiltration_rate--------------------", ultrafiltration_rate)
5242 5467
 				record.UltrafiltrationRate = ultrafiltration_rate
5243 5468
 			}
5244 5469
 
@@ -5428,7 +5653,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5428 5653
 	}
5429 5654
 
5430 5655
 	//长沙南雅
5431
-	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10610 || adminInfo.Org.Id == 10537 || adminInfo.Org.Id == 10667 {
5656
+	if adminInfo.Org.Id == 10395 || adminInfo.Org.Id == 10138 || adminInfo.Org.Id == 10278 || adminInfo.Org.Id == 10432 || adminInfo.Org.Id == 10441 || adminInfo.Org.Id == 10445 || adminInfo.Org.Id == 10469 || adminInfo.Org.Id == 10375 || adminInfo.Org.Id == 10610 || adminInfo.Org.Id == 10537 || adminInfo.Org.Id == 10667 || adminInfo.Org.Id == 9478 {
5432 5657
 
5433 5658
 		if ultrafiltration_rate > 0 {
5434 5659
 			ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
@@ -5509,7 +5734,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5509 5734
 		}
5510 5735
 	}
5511 5736
 
5512
-	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10757 {
5737
+	if adminInfo.Org.Id == 10721 || adminInfo.Org.Id == 10757 || adminInfo.Org.Id == 9478 || adminInfo.Org.Id == 10290 {
5513 5738
 		var replacement_rate float64
5514 5739
 		var displacement_quantity float64
5515 5740
 		totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
@@ -5533,7 +5758,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5533 5758
 
5534 5759
 	}
5535 5760
 
5536
-	if adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10745 {
5761
+	if adminInfo.Org.Id == 10740 || adminInfo.Org.Id == 10742 || adminInfo.Org.Id == 10745 || adminInfo.Org.Id == 9478 {
5537 5762
 
5538 5763
 		var replacement_rate float64
5539 5764
 		var displacement_quantity float64
@@ -5552,7 +5777,7 @@ func (this *DialysisAPIController) GetLastMonitorRecordTody() {
5552 5777
 		record.UltrafiltrationVolume = ultrafiltration_volume
5553 5778
 	}
5554 5779
 
5555
-	if adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10727 {
5780
+	if adminInfo.Org.Id == 10731 || adminInfo.Org.Id == 10727 || adminInfo.Org.Id == 10744 {
5556 5781
 
5557 5782
 		var replacement_rate float64
5558 5783
 		var displacement_quantity float64
@@ -12065,7 +12290,7 @@ func (c *DialysisAPIController) SaveLongMobileAdvice() {
12065 12290
 		StopTime:              0,
12066 12291
 		StopReason:            "",
12067 12292
 		StopDoctor:            0,
12068
-		StopState:             0,
12293
+		StopState:             2,
12069 12294
 		ParentId:              0,
12070 12295
 		ExecutionTime:         0,
12071 12296
 		ExecutionStaff:        0,

+ 23 - 12
controllers/mobile_api_controllers/patient_api_controller.go Näytä tiedosto

@@ -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)
@@ -3870,9 +3878,9 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
3870 3878
 	if evaluation.DryWeight > 0 {
3871 3879
 		dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
3872 3880
 
3873
-		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 {
3881
+		if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10727 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 || adminUserInfo.Org.Id == 9478 {
3874 3882
 
3875
-			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 {
3883
+			if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 && adminUserInfo.Org.Id != 10752 && adminUserInfo.Org.Id != 9478 {
3876 3884
 				dewater_amount = dewater_amount * 1000
3877 3885
 			}
3878 3886
 
@@ -4595,7 +4603,7 @@ func (c *PatientApiController) EditAssessmentBeforeDislysis() {
4595 4603
 	}
4596 4604
 
4597 4605
 	//针对孝昌康桥超滤率计算问题
4598
-	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 {
4606
+	if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 || adminUserInfo.Org.Id == 10721 || adminUserInfo.Org.Id == 10726 || adminUserInfo.Org.Id == 10164 || adminUserInfo.Org.Id == 10751 || adminUserInfo.Org.Id == 10752 || adminUserInfo.Org.Id == 10757 || adminUserInfo.Org.Id == 9478 {
4599 4607
 		if evaluation.ID == 0 {
4600 4608
 			dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
4601 4609
 			if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
@@ -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{

+ 19 - 1
controllers/new_mobile_api_controllers/staff_schedule_api_controller.go Näytä tiedosto

@@ -407,7 +407,7 @@ func (this *StaffScheduleApiController) GetAllZonePb() {
407 407
 	timenow := time.Now().Format("2006-01-02")
408 408
 	timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timenow)
409 409
 	//针对百霖和贝尔
410
-	if orgid == 10138 || orgid == 10278 || orgid == 3877 {
410
+	if orgid == 10138 || orgid == 10278 || orgid == 3877 || orgid == 10610 || orgid == 10537 {
411 411
 		//获取今日的排班数据
412 412
 		list, _ := service.GetMobileScheduleListByScheduleDate(orgid, startTime)
413 413
 		for _, item := range list {
@@ -1629,3 +1629,21 @@ func (c *StaffScheduleApiController) GetMobileDialysisCount() {
1629 1629
 		"order": order,
1630 1630
 	})
1631 1631
 }
1632
+
1633
+func (c *StaffScheduleApiController) GetPatientialysisSolutonByPatientId() {
1634
+
1635
+	patient_id, _ := c.GetInt64("patient_id")
1636
+
1637
+	record_date, _ := c.GetInt64("record_date")
1638
+
1639
+	orgId := c.GetAdminUserInfo().CurrentOrgId
1640
+
1641
+	schedule, _ := service.GetPatientScheduleByPatient(patient_id, record_date, orgId)
1642
+
1643
+	dialysisSolution, _ := service.GetDialysisSolutonByScheduleModeId(schedule.ModeId, patient_id, orgId)
1644
+
1645
+	c.ServeSuccessJSON(map[string]interface{}{
1646
+		"dialysisSolution": dialysisSolution,
1647
+	})
1648
+
1649
+}

+ 2 - 0
controllers/new_mobile_api_controllers/staff_schedule_api_router.go Näytä tiedosto

@@ -42,4 +42,6 @@ func StaffScheduleApiControllersRegisterRouters() {
42 42
 
43 43
 	beego.Router("/m/api/patient/getmobiledialysiscount", &StaffScheduleApiController{}, "Get:GetMobileDialysisCount")
44 44
 
45
+	beego.Router("/api/schedule/getpatientdialysissolutionbypatientid", &StaffScheduleApiController{}, "Get:GetPatientialysisSolutonByPatientId")
46
+
45 47
 }

+ 763 - 11
controllers/patient_api_controller.go Näytä tiedosto

@@ -225,6 +225,40 @@ 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/returncheck", &PatientApiController{}, "Get:ReturnCheckPatientCount")
237
+
238
+	beego.Router("/api/patient/deletepatientcount", &PatientApiController{}, "Get:DeletePatientCount")
239
+
240
+	beego.Router("/api/patient/savepatientoutcount", &PatientApiController{}, "Get:SavePatientOutCount")
241
+
242
+	beego.Router("/api/patient/getpatientoutcountlist", &PatientApiController{}, "Get:GetPatientOutCountList")
243
+
244
+	beego.Router("/api/patient/deletepatientoutcount", &PatientApiController{}, "Get:DeletePatientOutCount")
245
+
246
+	beego.Router("/api/patient/checkpatientoutcount", &PatientApiController{}, "Get:CheckPatientOutCount")
247
+
248
+	beego.Router("/api/patient/returnpatientoutlist", &PatientApiController{}, "Get:ReturnPatientOutList")
249
+
250
+	beego.Router("/api/patient/getpatientcountmaplist", &PatientApiController{}, "Get:GetPatientCountMapList")
251
+
252
+	beego.Router("/api/patient/getpatientcountflow", &PatientApiController{}, "Get:GetPatientCountFlow")
253
+
254
+	beego.Router("/api/patient/getdialysisordersetting", &PatientApiController{}, "Get:GetDialysisOrderSetting")
255
+
256
+	beego.Router("/api/patient/savepatientordersetting", &PatientApiController{}, "Get:SavePatientOrderSetting")
257
+
258
+	beego.Router("/api/patient/getpatientcountflowlist", &PatientApiController{}, "Get:GetPatientCountFlowList")
259
+
260
+	beego.Router("/api/patient/getpatientcountflowbyid", &PatientApiController{}, "Get:GetPatientCountFlowById")
261
+
228 262
 }
229 263
 func (c *PatientApiController) GetExportList() {
230 264
 	startTime := c.GetString("start_time")
@@ -1520,6 +1554,7 @@ func (c *PatientApiController) CreateDryWeights() {
1520 1554
 }
1521 1555
 
1522 1556
 func (c *PatientApiController) CreateGroupAdvice() {
1557
+
1523 1558
 	var err error
1524 1559
 	defer func() {
1525 1560
 		if rec := recover(); rec != nil {
@@ -1554,17 +1589,17 @@ func (c *PatientApiController) CreateGroupAdvice() {
1554 1589
 	}
1555 1590
 	utils.ErrorLog("%v", dataBody)
1556 1591
 
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
-	}
1592
+	//appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
1593
+	//if appRole.UserType == 3 {
1594
+	//	headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
1595
+	//	if getPermissionErr != nil {
1596
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
1597
+	//		return
1598
+	//	} else if headNursePermission == nil {
1599
+	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateAdvice)
1600
+	//		return
1601
+	//	}
1602
+	//}
1568 1603
 
1569 1604
 	timeLayout := "2006-01-02"
1570 1605
 	loc, _ := time.LoadLocation("Local")
@@ -1575,6 +1610,8 @@ func (c *PatientApiController) CreateGroupAdvice() {
1575 1610
 		return
1576 1611
 	}
1577 1612
 	adviceType := int64(dataBody["advice_type"].(float64))
1613
+
1614
+	fmt.Println("adviceType----------------", adviceType)
1578 1615
 	if adviceType != 1 && adviceType != 2 && adviceType != 3 && adviceType != 4 {
1579 1616
 		utils.ErrorLog("advice_type != 1&&2")
1580 1617
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
@@ -9060,3 +9097,718 @@ func (this *PatientApiController) GetInspectionByProjectId() {
9060 9097
 		"inspection": inspection,
9061 9098
 	})
9062 9099
 }
9100
+
9101
+func (this *PatientApiController) GetPatientMapList() {
9102
+
9103
+	keyword := this.GetString("keyword")
9104
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9105
+
9106
+	patient, _ := service.GetPatientMapList(orgId, keyword)
9107
+
9108
+	this.ServeSuccessJSON(map[string]interface{}{
9109
+		"patient": patient,
9110
+	})
9111
+}
9112
+
9113
+func (this *PatientApiController) SavePatientCount() {
9114
+
9115
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9116
+
9117
+	creater := this.GetAdminUserInfo().AdminUser.Id
9118
+
9119
+	patient_id, _ := this.GetInt64("patient_id")
9120
+
9121
+	hd_count, _ := this.GetInt64("hd_count")
9122
+
9123
+	hdf_count, _ := this.GetInt64("hdf_count")
9124
+
9125
+	hdhp_count, _ := this.GetInt64("hdhp_count")
9126
+
9127
+	hp_count, _ := this.GetInt64("hp_count")
9128
+
9129
+	other_count, _ := this.GetInt64("other_count")
9130
+
9131
+	remark := this.GetString("remark")
9132
+
9133
+	recordDateStr := time.Now().Format("2006-01-02")
9134
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9135
+
9136
+	nowtime := recordDate.Unix()
9137
+
9138
+	db := service.XTWriteDB()
9139
+	// 开始外部循环的事务
9140
+	tx := db.Begin()
9141
+	// 在函数结束时处理事务回滚
9142
+	defer func() {
9143
+		if r := recover(); r != nil {
9144
+			tx.Rollback()
9145
+		}
9146
+	}()
9147
+
9148
+	if hd_count > 0 {
9149
+		patientInCount := models.SfPatientInCount{
9150
+			PatientId:  patient_id,
9151
+			UserOrgId:  orgId,
9152
+			IsType:     1,
9153
+			Count:      hd_count,
9154
+			Status:     1,
9155
+			Creater:    creater,
9156
+			Ctime:      time.Now().Unix(),
9157
+			Mtime:      time.Now().Unix(),
9158
+			IsCheck:    2,
9159
+			RecordDate: nowtime,
9160
+			Remark:     remark,
9161
+			StockCount: hd_count,
9162
+		}
9163
+
9164
+		service.CreatePatientInCount(tx, patientInCount)
9165
+
9166
+	}
9167
+
9168
+	if hdf_count > 0 {
9169
+
9170
+		patientInCount := models.SfPatientInCount{
9171
+			PatientId:  patient_id,
9172
+			UserOrgId:  orgId,
9173
+			IsType:     2,
9174
+			Count:      hdf_count,
9175
+			Status:     1,
9176
+			Creater:    creater,
9177
+			Ctime:      time.Now().Unix(),
9178
+			Mtime:      time.Now().Unix(),
9179
+			IsCheck:    2,
9180
+			RecordDate: nowtime,
9181
+			Remark:     remark,
9182
+			StockCount: hdf_count,
9183
+		}
9184
+
9185
+		service.CreatePatientInCount(tx, patientInCount)
9186
+
9187
+	}
9188
+
9189
+	if hdhp_count > 0 {
9190
+
9191
+		patientInCount := models.SfPatientInCount{
9192
+			PatientId:  patient_id,
9193
+			UserOrgId:  orgId,
9194
+			IsType:     3,
9195
+			Count:      hdhp_count,
9196
+			Status:     1,
9197
+			Creater:    creater,
9198
+			Ctime:      time.Now().Unix(),
9199
+			Mtime:      time.Now().Unix(),
9200
+			IsCheck:    2,
9201
+			RecordDate: nowtime,
9202
+			Remark:     remark,
9203
+			StockCount: hdhp_count,
9204
+		}
9205
+
9206
+		service.CreatePatientInCount(tx, patientInCount)
9207
+	}
9208
+
9209
+	if hp_count > 0 {
9210
+
9211
+		patientInCount := models.SfPatientInCount{
9212
+			PatientId:  patient_id,
9213
+			UserOrgId:  orgId,
9214
+			IsType:     4,
9215
+			Count:      hp_count,
9216
+			Status:     1,
9217
+			Creater:    creater,
9218
+			Ctime:      time.Now().Unix(),
9219
+			Mtime:      time.Now().Unix(),
9220
+			IsCheck:    2,
9221
+			RecordDate: nowtime,
9222
+			Remark:     remark,
9223
+			StockCount: hp_count,
9224
+		}
9225
+		service.CreatePatientInCount(tx, patientInCount)
9226
+	}
9227
+
9228
+	if other_count > 0 {
9229
+
9230
+		patientInCount := models.SfPatientInCount{
9231
+			PatientId:  patient_id,
9232
+			UserOrgId:  orgId,
9233
+			IsType:     5,
9234
+			Count:      other_count,
9235
+			Status:     1,
9236
+			Creater:    creater,
9237
+			Ctime:      time.Now().Unix(),
9238
+			Mtime:      time.Now().Unix(),
9239
+			IsCheck:    2,
9240
+			RecordDate: nowtime,
9241
+			Remark:     remark,
9242
+			StockCount: other_count,
9243
+		}
9244
+
9245
+		service.CreatePatientInCount(tx, patientInCount)
9246
+	}
9247
+
9248
+	tx.Commit()
9249
+
9250
+	this.ServeSuccessJSON(map[string]interface{}{
9251
+		"msg": "保存成功",
9252
+	})
9253
+
9254
+}
9255
+
9256
+func (this *PatientApiController) GetPatientCountList() {
9257
+
9258
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9259
+	appId := this.GetAdminUserInfo().CurrentAppId
9260
+	patient_id, _ := this.GetInt64("patient_id")
9261
+	page, _ := this.GetInt64("page")
9262
+	limit, _ := this.GetInt64("limit")
9263
+	start_time := this.GetString("start_time")
9264
+	end_time := this.GetString("end_time")
9265
+	timeLayout := "2006-01-02"
9266
+	loc, _ := time.LoadLocation("Local")
9267
+	var startTime int64
9268
+	if len(start_time) > 0 {
9269
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9270
+		if err != nil {
9271
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9272
+			return
9273
+		}
9274
+		startTime = theTime.Unix()
9275
+	}
9276
+
9277
+	var endTime int64
9278
+	if len(end_time) > 0 {
9279
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9280
+		if err != nil {
9281
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9282
+			return
9283
+		}
9284
+		endTime = theTime.Unix()
9285
+	}
9286
+	list, total, _ := service.GetPatientCountList(orgId, patient_id, page, limit, startTime, endTime)
9287
+	patient, _ := service.GetPatientMapListOne(orgId)
9288
+
9289
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9290
+
9291
+	this.ServeSuccessJSON(map[string]interface{}{
9292
+		"list":     list,
9293
+		"total":    total,
9294
+		"patient":  patient,
9295
+		"userList": userList,
9296
+	})
9297
+}
9298
+
9299
+func (this *PatientApiController) CheckPatientCount() {
9300
+
9301
+	id, _ := this.GetInt64("id")
9302
+
9303
+	db := service.XTWriteDB()
9304
+	// 开始外部循环的事务
9305
+	tx := db.Begin()
9306
+	// 在函数结束时处理事务回滚
9307
+	defer func() {
9308
+		if r := recover(); r != nil {
9309
+			tx.Rollback()
9310
+		}
9311
+	}()
9312
+
9313
+	creater := this.GetAdminUserInfo().AdminUser.Id
9314
+
9315
+	recordDateStr := time.Now().Format("2006-01-02")
9316
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9317
+
9318
+	warehouseInfo, _ := service.GetPatientCountById(id, tx)
9319
+
9320
+	if warehouseInfo.ID > 0 {
9321
+		service.ModiftyPatientCount(warehouseInfo.Count, warehouseInfo.IsType, warehouseInfo.PatientId, tx)
9322
+		patient, _ := service.GetSfPatientById(tx, warehouseInfo.PatientId)
9323
+
9324
+		var over_count int64
9325
+		if warehouseInfo.IsType == 1 {
9326
+			over_count = patient.HdCount
9327
+		}
9328
+		if warehouseInfo.IsType == 2 {
9329
+			over_count = patient.HdfCount
9330
+		}
9331
+
9332
+		if warehouseInfo.IsType == 3 {
9333
+			over_count = patient.HdhpCount
9334
+		}
9335
+		if warehouseInfo.IsType == 4 {
9336
+			over_count = patient.HpCount
9337
+		}
9338
+		if warehouseInfo.IsType == 5 {
9339
+			over_count = patient.OtherCount
9340
+		}
9341
+		patientCountFlow := models.SfPatientCountFlow{
9342
+			UserOrgId:       warehouseInfo.UserOrgId,
9343
+			Count:           warehouseInfo.Count,
9344
+			ModeId:          warehouseInfo.IsType,
9345
+			IsType:          1,
9346
+			PatientId:       warehouseInfo.PatientId,
9347
+			Status:          1,
9348
+			Ctime:           time.Now().Unix(),
9349
+			Mtime:           time.Now().Unix(),
9350
+			OverCount:       over_count,
9351
+			RecordDate:      recordDate.Unix(),
9352
+			Creater:         creater,
9353
+			WarehouseInfoId: warehouseInfo.ID,
9354
+		}
9355
+		service.CreatePatientCountFlow(patientCountFlow, tx)
9356
+	}
9357
+
9358
+	checkpatientcount, _ := service.CheckPatientCount(id, tx)
9359
+
9360
+	tx.Commit()
9361
+
9362
+	this.ServeSuccessJSON(map[string]interface{}{
9363
+		"checkpatientcount": checkpatientcount,
9364
+	})
9365
+}
9366
+
9367
+func (this *PatientApiController) ReturnCheckPatientCount() {
9368
+
9369
+	id, _ := this.GetInt64("id")
9370
+
9371
+	db := service.XTWriteDB()
9372
+	// 开始外部循环的事务
9373
+	tx := db.Begin()
9374
+	// 在函数结束时处理事务回滚
9375
+	defer func() {
9376
+		if r := recover(); r != nil {
9377
+			tx.Rollback()
9378
+		}
9379
+	}()
9380
+
9381
+	patientCountObj, _ := service.GetPatientCountById(id, tx)
9382
+
9383
+	service.ReducePatientCount(patientCountObj.Count, patientCountObj.IsType, patientCountObj.PatientId, tx)
9384
+
9385
+	patientCount, _ := service.ReturnCheckPatientCount(id, tx)
9386
+
9387
+	service.UpdatePatientCountFlow(id, tx)
9388
+
9389
+	tx.Commit()
9390
+	this.ServeSuccessJSON(map[string]interface{}{
9391
+		"patientCount": patientCount,
9392
+	})
9393
+
9394
+}
9395
+
9396
+func (this *PatientApiController) DeletePatientCount() {
9397
+
9398
+	id, _ := this.GetInt64("id")
9399
+
9400
+	service.DeletePatientCount(id)
9401
+
9402
+	this.ServeSuccessJSON(map[string]interface{}{
9403
+		"msg": "删除成功!",
9404
+	})
9405
+
9406
+}
9407
+
9408
+func (this *PatientApiController) SavePatientOutCount() {
9409
+
9410
+	patient_id, _ := this.GetInt64("patient_id")
9411
+
9412
+	count, _ := this.GetInt64("count")
9413
+
9414
+	remark := this.GetString("remark")
9415
+
9416
+	mode_id, _ := this.GetInt64("mode_id")
9417
+
9418
+	creater := this.GetAdminUserInfo().AdminUser.Id
9419
+
9420
+	recordDateStr := time.Now().Format("2006-01-02")
9421
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9422
+
9423
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9424
+
9425
+	sfPatientOutCount := models.SfPatientOutCount{
9426
+		UserOrgId:  orgId,
9427
+		PatientId:  patient_id,
9428
+		ModeId:     mode_id,
9429
+		Count:      count,
9430
+		Remark:     remark,
9431
+		Creater:    creater,
9432
+		Status:     1,
9433
+		Ctime:      time.Now().Unix(),
9434
+		Mtime:      time.Now().Unix(),
9435
+		IsCheck:    2,
9436
+		RecordDate: recordDate.Unix(),
9437
+	}
9438
+
9439
+	service.CreateSfPatientOutCount(sfPatientOutCount)
9440
+
9441
+	this.ServeSuccessJSON(map[string]interface{}{
9442
+		"msg": "保存成功!",
9443
+	})
9444
+
9445
+}
9446
+
9447
+func (this *PatientApiController) GetPatientOutCountList() {
9448
+
9449
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9450
+
9451
+	limit, _ := this.GetInt64("limit")
9452
+
9453
+	page, _ := this.GetInt64("page")
9454
+
9455
+	patient_id, _ := this.GetInt64("patient_id")
9456
+
9457
+	start_time := this.GetString("start_time")
9458
+	end_time := this.GetString("end_time")
9459
+	timeLayout := "2006-01-02"
9460
+	loc, _ := time.LoadLocation("Local")
9461
+	var startTime int64
9462
+	if len(start_time) > 0 {
9463
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9464
+		if err != nil {
9465
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9466
+			return
9467
+		}
9468
+		startTime = theTime.Unix()
9469
+	}
9470
+
9471
+	var endTime int64
9472
+	if len(end_time) > 0 {
9473
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9474
+		if err != nil {
9475
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9476
+			return
9477
+		}
9478
+		endTime = theTime.Unix()
9479
+	}
9480
+
9481
+	outcount, total, _ := service.GetPatientOutCountList(patient_id, orgId, limit, page, startTime, endTime)
9482
+
9483
+	patient, _ := service.GetPatientMapListOne(orgId)
9484
+
9485
+	appId := this.GetAdminUserInfo().CurrentAppId
9486
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9487
+	this.ServeSuccessJSON(map[string]interface{}{
9488
+		"list":     outcount,
9489
+		"total":    total,
9490
+		"patient":  patient,
9491
+		"userList": userList,
9492
+	})
9493
+
9494
+}
9495
+
9496
+func (this *PatientApiController) DeletePatientOutCount() {
9497
+
9498
+	id, _ := this.GetInt64("id")
9499
+
9500
+	service.DeletePatientOutCount(id)
9501
+
9502
+	this.ServeSuccessJSON(map[string]interface{}{
9503
+		"msg": "ok",
9504
+	})
9505
+
9506
+}
9507
+
9508
+func (this *PatientApiController) CheckPatientOutCount() {
9509
+
9510
+	id, _ := this.GetInt64("id")
9511
+	db := service.XTWriteDB()
9512
+	// 开始外部循环的事务
9513
+	tx := db.Begin()
9514
+	// 在函数结束时处理事务回滚
9515
+	defer func() {
9516
+		if r := recover(); r != nil {
9517
+			tx.Rollback()
9518
+		}
9519
+	}()
9520
+	outCountList, _ := service.GetPatientOutCountById(id, tx)
9521
+
9522
+	creater := this.GetAdminUserInfo().AdminUser.Id
9523
+
9524
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9525
+
9526
+	recordDateStr := time.Now().Format("2006-01-02")
9527
+	recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
9528
+
9529
+	if outCountList.ID > 0 {
9530
+
9531
+		//扣减库存
9532
+		service.ReducePatientCount(outCountList.Count, outCountList.ModeId, outCountList.PatientId, tx)
9533
+
9534
+		patient, _ := service.GetSfPatientById(tx, outCountList.PatientId)
9535
+
9536
+		var over_count int64
9537
+		if outCountList.ModeId == 1 {
9538
+			over_count = patient.HdCount
9539
+		}
9540
+		if outCountList.ModeId == 2 {
9541
+			over_count = patient.HdfCount
9542
+		}
9543
+
9544
+		if outCountList.ModeId == 3 {
9545
+			over_count = patient.HdhpCount
9546
+		}
9547
+		if outCountList.ModeId == 4 {
9548
+			over_count = patient.HpCount
9549
+		}
9550
+		if outCountList.ModeId == 5 {
9551
+			over_count = patient.OtherCount
9552
+		}
9553
+
9554
+		patientCountFlow := models.SfPatientCountFlow{
9555
+			PatientId:      outCountList.PatientId,
9556
+			ModeId:         outCountList.ModeId,
9557
+			Count:          outCountList.Count,
9558
+			Status:         1,
9559
+			Ctime:          time.Now().Unix(),
9560
+			Mtime:          time.Now().Unix(),
9561
+			RecordDate:     recordDate.Unix(),
9562
+			UserOrgId:      orgId,
9563
+			Creater:        creater,
9564
+			IsType:         2,
9565
+			OverCount:      over_count,
9566
+			WarehouseOutId: outCountList.ID,
9567
+		}
9568
+
9569
+		service.CreatePatientCountFlow(patientCountFlow, tx)
9570
+
9571
+	}
9572
+	//审核
9573
+	service.CheckPatientOutCount(id, tx)
9574
+
9575
+	tx.Commit()
9576
+
9577
+	this.ServeSuccessJSON(map[string]interface{}{
9578
+		"msg": "ok",
9579
+	})
9580
+
9581
+}
9582
+
9583
+func (this *PatientApiController) ReturnPatientOutList() {
9584
+
9585
+	id, _ := this.GetInt64("id")
9586
+	db := service.XTWriteDB()
9587
+	// 开始外部循环的事务
9588
+	tx := db.Begin()
9589
+	// 在函数结束时处理事务回滚
9590
+	defer func() {
9591
+		if r := recover(); r != nil {
9592
+			tx.Rollback()
9593
+		}
9594
+	}()
9595
+	outCountList, _ := service.GetPatientOutCountById(id, tx)
9596
+
9597
+	if outCountList.ID > 0 {
9598
+		//回退库存
9599
+		service.ModiftyPatientCount(outCountList.Count, outCountList.ModeId, outCountList.PatientId, tx)
9600
+
9601
+		service.DeletePatientCountFlow(id, tx)
9602
+	}
9603
+	//反审核
9604
+	service.ReturnPatientOutCount(id, tx)
9605
+
9606
+	tx.Commit()
9607
+	this.ServeSuccessJSON(map[string]interface{}{
9608
+		"msg": "ok",
9609
+	})
9610
+}
9611
+
9612
+func (this *PatientApiController) GetPatientCountMapList() {
9613
+
9614
+	patient_id, _ := this.GetInt64("patient_id")
9615
+
9616
+	limit, _ := this.GetInt64("limit")
9617
+
9618
+	page, _ := this.GetInt64("page")
9619
+
9620
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9621
+
9622
+	list, total, _ := service.GetPatientCountMapList(patient_id, limit, page, orgId)
9623
+
9624
+	patient, _ := service.GetPatientMapListOne(orgId)
9625
+
9626
+	this.ServeSuccessJSON(map[string]interface{}{
9627
+		"list":    list,
9628
+		"total":   total,
9629
+		"patient": patient,
9630
+	})
9631
+}
9632
+
9633
+func (this *PatientApiController) GetPatientCountFlow() {
9634
+
9635
+	patient_id, _ := this.GetInt64("patient_id")
9636
+	is_type, _ := this.GetInt64("is_type")
9637
+	mode_id, _ := this.GetInt64("mode_id")
9638
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9639
+	start_time := this.GetString("start_time")
9640
+	end_time := this.GetString("end_time")
9641
+	timeLayout := "2006-01-02"
9642
+	loc, _ := time.LoadLocation("Local")
9643
+	var startTime int64
9644
+	if len(start_time) > 0 {
9645
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9646
+		if err != nil {
9647
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9648
+			return
9649
+		}
9650
+		startTime = theTime.Unix()
9651
+	}
9652
+
9653
+	var endTime int64
9654
+	if len(end_time) > 0 {
9655
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9656
+		if err != nil {
9657
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9658
+			return
9659
+		}
9660
+		endTime = theTime.Unix()
9661
+	}
9662
+
9663
+	list, total, _ := service.GetPatientCountFlow(patient_id, orgId, is_type, mode_id, startTime, endTime)
9664
+
9665
+	patient, _ := service.GetSfPatientByIdOne(patient_id)
9666
+
9667
+	appId := this.GetAdminUserInfo().CurrentAppId
9668
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9669
+
9670
+	this.ServeSuccessJSON(map[string]interface{}{
9671
+		"list":     list,
9672
+		"total":    total,
9673
+		"patient":  patient,
9674
+		"userList": userList,
9675
+	})
9676
+}
9677
+
9678
+func (this *PatientApiController) GetDialysisOrderSetting() {
9679
+
9680
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9681
+
9682
+	order, _ := service.GetDialysisOrderSetting(orgId)
9683
+
9684
+	this.ServeSuccessJSON(map[string]interface{}{
9685
+		"order": order,
9686
+	})
9687
+}
9688
+
9689
+func (this *PatientApiController) SavePatientOrderSetting() {
9690
+
9691
+	is_open, _ := this.GetInt64("is_open")
9692
+
9693
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9694
+
9695
+	orderSetting := models.XtDialysisOrderSetting{
9696
+		IsOpen:    is_open,
9697
+		UserOrgId: orgId,
9698
+		Ctime:     time.Now().Unix(),
9699
+		Mtime:     time.Now().Unix(),
9700
+		Status:    1,
9701
+	}
9702
+
9703
+	service.CreateDialysisOrder(orderSetting)
9704
+
9705
+	this.ServeSuccessJSON(map[string]interface{}{
9706
+		"order": orderSetting,
9707
+	})
9708
+}
9709
+
9710
+func (this *PatientApiController) GetPatientCountFlowList() {
9711
+
9712
+	patient_id, _ := this.GetInt64("patient_id")
9713
+
9714
+	start_time := this.GetString("start_time")
9715
+
9716
+	end_time := this.GetString("end_time")
9717
+
9718
+	limit, _ := this.GetInt64("limit")
9719
+
9720
+	page, _ := this.GetInt64("page")
9721
+
9722
+	is_type, _ := this.GetInt64("is_type")
9723
+
9724
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9725
+
9726
+	timeLayout := "2006-01-02"
9727
+	loc, _ := time.LoadLocation("Local")
9728
+	var startTime int64
9729
+	if len(start_time) > 0 {
9730
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9731
+		if err != nil {
9732
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9733
+			return
9734
+		}
9735
+		startTime = theTime.Unix()
9736
+	}
9737
+
9738
+	var endTime int64
9739
+	if len(end_time) > 0 {
9740
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9741
+		if err != nil {
9742
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9743
+			return
9744
+		}
9745
+		endTime = theTime.Unix()
9746
+	}
9747
+
9748
+	list, total, _ := service.GetPatientCountFlowList(patient_id, startTime, endTime, limit, page, orgId, is_type)
9749
+
9750
+	flowList, _ := service.GetPatientCountListFlowOne(patient_id, startTime, endTime, is_type, orgId)
9751
+
9752
+	patient, _ := service.GetPatientMapListOne(orgId)
9753
+
9754
+	appId := this.GetAdminUserInfo().CurrentAppId
9755
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9756
+
9757
+	this.ServeSuccessJSON(map[string]interface{}{
9758
+		"list":     list,
9759
+		"total":    total,
9760
+		"patient":  patient,
9761
+		"userList": userList,
9762
+		"flowList": flowList,
9763
+	})
9764
+}
9765
+
9766
+func (this *PatientApiController) GetPatientCountFlowById() {
9767
+
9768
+	patient_id, _ := this.GetInt64("patient_id")
9769
+
9770
+	start_time := this.GetString("start_time")
9771
+
9772
+	end_time := this.GetString("end_time")
9773
+
9774
+	is_type, _ := this.GetInt64("is_type")
9775
+
9776
+	mode_id, _ := this.GetInt64("mode_id")
9777
+
9778
+	orgId := this.GetAdminUserInfo().CurrentOrgId
9779
+
9780
+	appId := this.GetAdminUserInfo().CurrentAppId
9781
+
9782
+	timeLayout := "2006-01-02"
9783
+	loc, _ := time.LoadLocation("Local")
9784
+	var startTime int64
9785
+	if len(start_time) > 0 {
9786
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
9787
+		if err != nil {
9788
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9789
+			return
9790
+		}
9791
+		startTime = theTime.Unix()
9792
+	}
9793
+
9794
+	var endTime int64
9795
+	if len(end_time) > 0 {
9796
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
9797
+		if err != nil {
9798
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
9799
+			return
9800
+		}
9801
+		endTime = theTime.Unix()
9802
+	}
9803
+
9804
+	flowList, _ := service.GetPatientCountFlowByIdList(patient_id, orgId, mode_id, is_type, startTime, endTime)
9805
+
9806
+	patient, _ := service.GetPatientMapListOne(orgId)
9807
+
9808
+	userList, _ := service.GetAllAdminUserList(orgId, appId)
9809
+	this.ServeSuccessJSON(map[string]interface{}{
9810
+		"list":     flowList,
9811
+		"patient":  patient,
9812
+		"userList": userList,
9813
+	})
9814
+}

+ 3 - 0
controllers/pharmacy_controller.go Näytä tiedosto

@@ -1469,7 +1469,10 @@ func (this *PharmacyController) GetDrugTocalCount() {
1469 1469
 
1470 1470
 	adviceList, _ := service.GetDrugTocalCountByDrugId(drug_id, startTime, orgId)
1471 1471
 
1472
+	drug, _ := service.GetNewBaseDrugById(drug_id)
1473
+
1472 1474
 	this.ServeSuccessJSON(map[string]interface{}{
1473 1475
 		"adviceList": adviceList,
1476
+		"drug":       drug,
1474 1477
 	})
1475 1478
 }

+ 66 - 51
controllers/sign_api_controller.go Näytä tiedosto

@@ -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
+}

+ 8 - 28
controllers/statistics_api_controller.go Näytä tiedosto

@@ -1,17 +1,18 @@
1 1
 package controllers
2 2
 
3 3
 import (
4
+	"fmt"
5
+	"sort"
6
+	"strconv"
7
+	"strings"
8
+	"time"
9
+
4 10
 	"XT_New/enums"
5 11
 	"XT_New/models"
6 12
 	"XT_New/service"
7 13
 	"XT_New/service/statistics_service"
8 14
 	"XT_New/utils"
9
-	"fmt"
10 15
 	"github.com/astaxie/beego"
11
-	"sort"
12
-	"strconv"
13
-	"strings"
14
-	"time"
15 16
 )
16 17
 
17 18
 type StatisticsApiController struct {
@@ -497,28 +498,7 @@ func (c *StatisticsApiController) GetDialysisTotalDetail() {
497 498
 	mode, _ := c.GetInt64("mode")
498 499
 	origin, _ := c.GetInt64("origin")
499 500
 	time_way, _ := c.GetInt64("time_way")
500
-	//timeLayout := "2006-01-02"
501
-	//loc, _ := time.LoadLocation("Local")
502
-	//var startTime int64
503
-	//if len(start_date) > 0 {
504
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
505
-	//	fmt.Println("err-----------", err)
506
-	//	if err != nil {
507
-	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
508
-	//		return
509
-	//	}
510
-	//	//startTime = theTime.Unix()
511
-	//}
512
-	//var endTime int64
513
-	//if len(end_date) > 0 {
514
-	//	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_date+" 23:59:59", loc)
515
-	//	if err != nil {
516
-	//		utils.ErrorLog(err.Error())
517
-	//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
518
-	//		return
519
-	//	}
520
-	//	//endTime = theTime.Unix()
521
-	//}
501
+
522 502
 	dates, err := splitDateRange(start_date, end_date)
523 503
 	if err != nil {
524 504
 		fmt.Println("Error:", err)
@@ -1833,7 +1813,7 @@ func (c *StatisticsApiController) GetPatientCommonInspectionStatistisc() {
1833 1813
 	var startTime int64
1834 1814
 	if len(start_date) > 0 {
1835 1815
 		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_date+" 00:00:00", loc)
1836
-		fmt.Println("err-----------", err)
1816
+
1837 1817
 		if err != nil {
1838 1818
 			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
1839 1819
 			return

+ 1 - 0
models/dialysis.go Näytä tiedosto

@@ -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                 string  `gorm:"column:height" json:"height" form:"height"`
349 350
 }
350 351
 
351 352
 func (PredialysisEvaluationList) TableName() string {

+ 26 - 72
models/his_models.go Näytä tiedosto

@@ -3092,78 +3092,32 @@ func (NewHisPrescription) TableName() string {
3092 3092
 	return "his_prescription"
3093 3093
 }
3094 3094
 
3095
-type HisDoctorAdviceTeamInfo struct {
3096
-	ID                    int64       `gorm:"column:id" json:"id" form:"id"`
3097
-	UserOrgId             int64       `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3098
-	PatientId             int64       `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3099
-	AdviceName            string      `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
3100
-	AdviceDesc            string      `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
3101
-	SingleDose            float64     `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
3102
-	SingleDoseUnit        string      `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
3103
-	PrescribingNumber     float64     `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
3104
-	PrescribingNumberUnit string      `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
3105
-	DeliveryWay           string      `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
3106
-	ExecutionFrequency    string      `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
3107
-	AdviceDoctor          int64       `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
3108
-	Status                int64       `gorm:"column:status" json:"status" form:"status"`
3109
-	CreatedTime           int64       `gorm:"column:created_time" json:"created_time" form:"created_time"`
3110
-	UpdatedTime           int64       `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
3111
-	Remark                string      `gorm:"column:remark" json:"remark" form:"remark"`
3112
-	DrugSpec              float64     `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
3113
-	DrugSpecUnit          string      `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
3114
-	Groupno               int64       `gorm:"column:groupno" json:"groupno" form:"groupno"`
3115
-	RemindType            int64       `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
3116
-	FrequencyType         int64       `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
3117
-	DayCount              int64       `gorm:"column:day_count" json:"day_count" form:"day_count"`
3118
-	WeekDay               string      `gorm:"column:week_day" json:"week_day" form:"week_day"`
3119
-	TemplateId            string      `gorm:"column:template_id" json:"template_id" form:"template_id"`
3120
-	Modifier              int64       `gorm:"column:modifier" json:"modifier" form:"modifier"`
3121
-	DrugId                int64       `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
3122
-	Price                 float64     `gorm:"column:price" json:"price" form:"price"`
3123
-	BaseDrugLib           BaseDrugLib `gorm:"ForeignKey:ID;AssociationForeignKey:DrugId" json:"drug"`
3124
-}
3125
-
3126
-func (HisDoctorAdviceTeamInfo) TableName() string {
3127
-	return "his_doctor_advice_team_info"
3128
-}
3129
-
3130
-type NewHisOrderInfo struct {
3131
-	ID               int64   `gorm:"column:id" json:"id" form:"id"`
3132
-	OrderNumber      string  `gorm:"column:order_number" json:"order_number" form:"order_number"`
3133
-	UploadDate       int64   `gorm:"column:upload_date" json:"upload_date" form:"upload_date"`
3134
-	AdviceId         int64   `gorm:"column:advice_id" json:"advice_id" form:"advice_id"`
3135
-	DetItemFeeSumamt float64 `gorm:"column:det_item_fee_sumamt" json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
3136
-	Cnt              float64 `gorm:"column:cnt" json:"cnt" form:"cnt"`
3137
-	Pric             float64 `gorm:"column:pric" json:"pric" form:"pric"`
3138
-	PatientId        int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3139
-	PricUplmtAmt     float64 `gorm:"column:pric_uplmt_amt" json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
3140
-	SelfpayProp      float64 `gorm:"column:selfpay_prop" json:"selfpay_prop" form:"selfpay_prop"`
3141
-	FulamtOwnpayAmt  float64 `gorm:"column:fulamt_ownpay_amt" json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
3142
-	OverlmtAmt       float64 `gorm:"column:overlmt_amt" json:"overlmt_amt" form:"overlmt_amt"`
3143
-	PreselfpayAmt    float64 `gorm:"column:preselfpay_amt" json:"preselfpay_amt" form:"preselfpay_amt"`
3144
-	BasMednFlag      string  `gorm:"column:bas_medn_flag" json:"bas_medn_flag" form:"bas_medn_flag"`
3145
-	MedChrgitmType   string  `gorm:"column:med_chrgitm_type" json:"med_chrgitm_type" form:"med_chrgitm_type"`
3146
-	HiNegoDrugFlag   string  `gorm:"column:hi_nego_drug_flag" json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
3147
-	Status           int64   `gorm:"column:status" json:"status" form:"status"`
3148
-	Memo             string  `gorm:"column:memo" json:"memo" form:"memo"`
3149
-	FeedetlSn        string  `gorm:"column:feedetl_sn" json:"feedetl_sn" form:"feedetl_sn"`
3150
-	Mtime            int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
3151
-	InscpScpAmt      float64 `gorm:"column:inscp_scp_amt" json:"inscp_scp_amt" form:"inscp_scp_amt"`
3152
-	DrtReimFlag      string  `gorm:"column:drt_reim_flag" json:"drt_reim_flag" form:"drt_reim_flag"`
3153
-	Ctime            int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
3154
-	ListSpItemFlag   string  `gorm:"column:list_sp_item_flag" json:"list_sp_item_flag" form:"list_sp_item_flag"`
3155
-	ChldMedcFlag     string  `gorm:"column:chld_medc_flag" json:"chld_medc_flag" form:"chld_medc_flag"`
3156
-	LmtUsedFlag      string  `gorm:"column:lmt_used_flag" json:"lmt_used_flag" form:"lmt_used_flag"`
3157
-	ChrgitmLv        string  `gorm:"column:chrgitm_lv" json:"chrgitm_lv" form:"chrgitm_lv"`
3158
-	UserOrgId        int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3159
-	HisPatientId     int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
3160
-	OrderId          int64   `gorm:"column:order_id" json:"order_id" form:"order_id"`
3161
-	ProjectId        int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
3162
-	Type             int64   `gorm:"column:type" json:"type" form:"type"`
3163
-	ItemId           int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
3164
-	SettleType       int64   `gorm:"column:settle_type" json:"settle_type" form:"settle_type"`
3095
+type NBHisDoctorAdviceInfo struct {
3096
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
3097
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3098
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3099
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
3100
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
3101
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
3102
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
3103
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
3104
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
3105
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
3106
+	DrugCode              string  `gorm:"column:drug_code" json:"drug_code" form:"drug_code"`
3165 3107
 }
3166 3108
 
3167
-func (NewHisOrderInfo) TableName() string {
3168
-	return "his_order_info"
3109
+func (NBHisDoctorAdviceInfo) TableName() string {
3110
+	return "his_doctor_advice_info"
3111
+}
3112
+
3113
+type NBXtBaseDrug struct {
3114
+	ID       int64  `gorm:"column:id" json:"id" form:"id"`
3115
+	DrugName string `gorm:"column:drug_name" json:"drug_name" form:"drug_name"`
3116
+	Status   int64  `gorm:"column:status" json:"status" form:"status"`
3117
+	OrgId    int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
3118
+	ScanCode string `gorm:"column:scan_code" json:"scan_code" form:"scan_code"`
3119
+}
3120
+
3121
+func (NBXtBaseDrug) TableName() string {
3122
+	return "xt_base_drug"
3169 3123
 }

+ 92 - 0
models/patient_models.go Näytä tiedosto

@@ -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,94 @@ 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
+	OtherCount  int64  `gorm:"column:other_count" json:"other_count" form:"other_count"`
3138
+}
3139
+
3140
+func (SfPatients) TableName() string {
3141
+	return "xt_patients"
3142
+}
3143
+
3144
+type SfPatientInCount struct {
3145
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
3146
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3147
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3148
+	IsType     int64  `gorm:"column:is_type" json:"is_type" form:"is_type"`
3149
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
3150
+	Creater    int64  `gorm:"column:creater" json:"creater" form:"creater"`
3151
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
3152
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
3153
+	IsCheck    int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
3154
+	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
3155
+	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
3156
+	Count      int64  `gorm:"column:count" json:"count" form:"count"`
3157
+	StockCount int64  `gorm:"column:stock_count" json:"stock_count" form:"stock_count"`
3158
+}
3159
+
3160
+func (SfPatientInCount) TableName() string {
3161
+	return "xt_patient_in_count"
3162
+}
3163
+
3164
+type SfPatientOutCount struct {
3165
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
3166
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3167
+	ModeId     int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
3168
+	Count      int64  `gorm:"column:count" json:"count" form:"count"`
3169
+	Remark     string `gorm:"column:remark" json:"remark" form:"remark"`
3170
+	Creater    int64  `gorm:"column:creater" json:"creater" form:"creater"`
3171
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
3172
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
3173
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
3174
+	IsCheck    int64  `gorm:"column:is_check" json:"is_check" form:"is_check"`
3175
+	RecordDate int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
3176
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3177
+}
3178
+
3179
+func (SfPatientOutCount) TableName() string {
3180
+	return "xt_patient_out_count"
3181
+}
3182
+
3183
+type SfPatientCountFlow struct {
3184
+	ID              int64 `gorm:"column:id" json:"id" form:"id"`
3185
+	UserOrgId       int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3186
+	Count           int64 `gorm:"column:count" json:"count" form:"count"`
3187
+	ModeId          int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
3188
+	IsType          int64 `gorm:"column:is_type" json:"is_type" form:"is_type"`
3189
+	PatientId       int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
3190
+	Status          int64 `gorm:"column:status" json:"status" form:"status"`
3191
+	Ctime           int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
3192
+	Mtime           int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
3193
+	OverCount       int64 `gorm:"column:over_count" json:"over_count" form:"over_count"`
3194
+	RecordDate      int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
3195
+	Creater         int64 `gorm:"column:creater" json:"creater" form:"creater"`
3196
+	WarehouseInfoId int64 `gorm:"column:warehouse_info_id" json:"warehouse_info_id" form:"warehouse_info_id"`
3197
+	WarehouseOutId  int64 `gorm:"column:warehouse_out_id" json:"warehouse_out_id" form:"warehouse_out_id"`
3198
+}
3199
+
3200
+func (SfPatientCountFlow) TableName() string {
3201
+	return "xt_patient_count_flow"
3202
+}
3203
+
3204
+type XtDialysisOrderSetting struct {
3205
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
3206
+	IsOpen    int64 `gorm:"column:is_open" json:"is_open" form:"is_open"`
3207
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
3208
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
3209
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
3210
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
3211
+}
3212
+
3213
+func (XtDialysisOrderSetting) TableName() string {
3214
+	return "xt_dialysis_order_setting"
3215
+}

+ 1 - 0
models/stock_models.go Näytä tiedosto

@@ -123,6 +123,7 @@ type StWarehousingInfoOne struct {
123 123
 	StorehouseId     int64   `gorm:"column:storehouse_id" json:"storehouse_id" form:"storehouse_id"`
124 124
 	OrgId            int64   `gorm:"column:org_id" json:"org_id"`
125 125
 	Price            float64 `gorm:"column:price" json:"price" form:"price"`
126
+	PackingPrice     float64 `gorm:"column:packing_price" json:"packing_price" form:"packing_price"`
126 127
 }
127 128
 
128 129
 func (StWarehousingInfoOne) TableName() string {

+ 8 - 14
service/common_service.go Näytä tiedosto

@@ -293,13 +293,7 @@ func GetTotalRollOutPatientsTwo(orgid int64, startime int64, endtime int64, laps
293 293
 
294 294
 func GetPatientTotalCount(orgID int64, lapsetotype int64, sourcetype int64) (total int64) {
295 295
 	db := readDb.Table("xt_patients as x")
296
-	//if lapsetotype > 0 {
297
-	// db = db.Where("x.lapseto = ?", lapsetotype)
298
-	//}
299
-	//if sourcetype > 0 {
300
-	// db = db.Where("x.source = ?", sourcetype)
301
-	//}
302
-	db.Where("x.user_org_id=? and x.status=1", orgID).Count(&total)
296
+	db.Where("x.user_org_id=? and x.status=1 and x.patient_type=1", orgID).Count(&total)
303 297
 	return
304 298
 }
305 299
 
@@ -321,7 +315,7 @@ func GetManPatientTotalCount(orgid int64, starttime int64, endtime int64) (dialy
321 315
 
322 316
 func GetManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
323 317
 
324
-	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
318
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1 and x.patient_type =1")
325 319
 	if lapsetotype > 0 {
326 320
 		db = db.Where("x.lapseto = ?", lapsetotype)
327 321
 	}
@@ -333,7 +327,7 @@ func GetManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patie
333 327
 }
334 328
 
335 329
 func GetWoManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (patients []*models.XtPatients, total int64, err error) {
336
-	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1")
330
+	db := XTReadDB().Table("xt_patients as x").Where("x.status  = 1 and x.patient_type =1")
337 331
 	if lapsetotype > 0 {
338 332
 		db = db.Where("x.lapseto = ?", lapsetotype)
339 333
 	}
@@ -352,18 +346,18 @@ func GetWoManPatientTotal(orgid int64, lapsetotype int64, sourcetype int64) (pat
352 346
 func GetPatientInfectiousCount(orgid int64, startime int64, endtime int64, lapsetotype int64, sourcetype int64) (counts []*models.PatientContagionsCountStruct, err error) {
353 347
 
354 348
 	if lapsetotype == 0 {
355
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
349
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
356 350
 	}
357 351
 	if sourcetype == 0 {
358
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
352
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=?", orgid, startime, endtime).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
359 353
 	}
360 354
 
361 355
 	if lapsetotype > 0 {
362
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.lapseto = ?", orgid, startime, endtime, lapsetotype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
356
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.lapseto = ?", orgid, startime, endtime, lapsetotype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
363 357
 	}
364 358
 
365 359
 	if sourcetype > 0 {
366
-		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.source = ?", orgid, startime, endtime, sourcetype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
360
+		err = readDb.Table("xt_patients_infectious_diseases as x").Joins("join xt_patients as s on s.id = x.patient_id").Where("s.user_org_id = ? and s.status = 1 and s.patient_type =1 and x.status = 1 and x.updated_time>=? and x.updated_time<=? and s.source = ?", orgid, startime, endtime, sourcetype).Select("x.disease_id,count(x.disease_id) as count").Group("x.disease_id").Scan(&counts).Error
367 361
 	}
368 362
 
369 363
 	return counts, err
@@ -388,7 +382,7 @@ func GetTotalAgeCount(orgid int64, lapsetotype int64, sourcetype int64) (counts
388 382
     WHEN ( substring( now( ), 1, 4 ) - substring( id_card_no, 7, 4 ) ) - ( substring( id_card_no, 11, 4 ) - date_format( now( ), '%m%d' ) > 0 )<=80 THEN '80'
389 383
     ELSE '150'
390 384
 	 END
391
-	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1
385
+	 AS nnd FROM xt_patients as s  where s.user_org_id=? and s.status=1 and s.patient_type =1
392 386
 	 )a GROUP BY nnd`, orgid).Scan(&counts)
393 387
 
394 388
 	}

+ 17 - 0
service/db.go Näytä tiedosto

@@ -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 Näytä tiedosto

@@ -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.

+ 6 - 0
service/gobal_config_service.go Näytä tiedosto

@@ -202,6 +202,12 @@ func GetPrint(ids []int64, orgid int64, advicetype int64, stoptype int64) (docto
202 202
 	return doctor, err
203 203
 }
204 204
 
205
+func GetHisPrint(ids []string, org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
206
+
207
+	err = XTReadDB().Where("id in (?) and user_org_id = ?", ids, org_id).Order("execution_time asc").Find(&advice).Error
208
+	return advice, err
209
+}
210
+
205 211
 func GetExportLogByType(org_id int64, log_type int64) (log []*models.ExportLog, err error) {
206 212
 	err = readDb.Model(&models.ExportLog{}).Where("user_org_id = ? AND status = 1 AND log_type = ?", org_id, log_type).
207 213
 		Preload("ExportErrLog", "status = 1").Order("export_time desc").Find(&log).Error

+ 2 - 1
service/mobile_dialysis_service.go Näytä tiedosto

@@ -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 {
@@ -633,6 +634,7 @@ func MobileGetReceiverTreatmentAccessRecord(orgID int64, patientID int64, record
633 634
 
634 635
 	key := strconv.FormatInt(orgID, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(recordDate, 10) + ":receive_treatment_asses"
635 636
 	receive_treatment_asses_str, _ := redis.Get(key).Result()
637
+
636 638
 	if len(receive_treatment_asses_str) == 0 { //没有到缓存数据,从数据库中获取数据,进行缓存到redis
637 639
 		err = readDb.Model(&models.ReceiveTreatmentAsses{}).Where("patient_id = ? and user_org_id = ? and status = 1 and record_date = ?", patientID, orgID, recordDate).First(&record).Error
638 640
 		if err != nil {
@@ -8619,7 +8621,6 @@ func GetHisDoctorAdvicesTwentyOne(orgID int64, scheduleDate int64, deliverWay st
8619 8621
 		}
8620 8622
 		if patient_id > 0 {
8621 8623
 			if execution_state > 0 {
8622
-				fmt.Println("execution_state---------------------", execution_state)
8623 8624
 				if cost_type > 0 {
8624 8625
 					db = db.Preload("SchedualPatient", "status = 1 AND user_org_id = ? and id = ?", orgID, patient_id).
8625 8626
 						Preload("DeviceNumber", "status = 1 AND org_id = ?", orgID).

+ 14 - 15
service/new_warehouse_service.go Näytä tiedosto

@@ -4508,9 +4508,9 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4508 4508
 
4509 4509
 	if lastWarehouse.MaxUnit != lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4510 4510
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
4511
-			fmt.Println("hahhahahahahhaah")
4512 4511
 			var stockMax int64
4513 4512
 			var stockMin int64
4513
+
4514 4514
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
4515 4515
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
4516 4516
 
@@ -4522,7 +4522,6 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4522 4522
 	}
4523 4523
 
4524 4524
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
4525
-		fmt.Println("ooowowowowowowowowowo")
4526 4525
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
4527 4526
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
4528 4527
 
@@ -4547,8 +4546,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4547 4546
 
4548 4547
 	}
4549 4548
 
4550
-	fmt.Println("stock_number", stock_number)
4551
-	fmt.Println("deliver_number=============", deliver_number)
4549
+	//fmt.Println("stock_number", stock_number)
4550
+	//fmt.Println("deliver_number=============", deliver_number)
4552 4551
 	// 当库存数量大于或等于出库数量的话,则正常出库该批次
4553 4552
 	if stock_number >= deliver_number {
4554 4553
 
@@ -4558,8 +4557,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4558 4557
 		maxNumber = deliver_number / drup.MinNumber
4559 4558
 		minNumber = deliver_number % drup.MinNumber
4560 4559
 
4561
-		fmt.Println("max_Number=====================", maxNumber)
4562
-		fmt.Println("minNumber=====================", minNumber)
4560
+		//fmt.Println("max_Number=====================", maxNumber)
4561
+		//fmt.Println("minNumber=====================", minNumber)
4563 4562
 
4564 4563
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
4565 4564
 			minNumber = maxNumber
@@ -4573,18 +4572,18 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4573 4572
 
4574 4573
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4575 4574
 
4576
-			fmt.Println("金1")
4575
+			//fmt.Println("金1")
4577 4576
 
4578 4577
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
4579 4578
 		}
4580 4579
 
4581 4580
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
4582
-			fmt.Println("jin2")
4581
+			//fmt.Println("jin2")
4583 4582
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4584 4583
 		}
4585 4584
 
4586 4585
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
4587
-			fmt.Println("jin3")
4586
+			//fmt.Println("jin3")
4588 4587
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
4589 4588
 		}
4590 4589
 
@@ -4597,8 +4596,8 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4597 4596
 
4598 4597
 		warehouse.Mtime = time.Now().Unix()
4599 4598
 
4600
-		fmt.Println("hahhahahah", warehouse.StockMinNumber)
4601
-		fmt.Println("howowowoowow", minNumber)
4599
+		//fmt.Println("hahhahahah", warehouse.StockMinNumber)
4600
+		//fmt.Println("howowowoowow", minNumber)
4602 4601
 		if warehouse.StockMinNumber < minNumber {
4603 4602
 
4604 4603
 			if warehouse.MaxUnit != warehouse.MinUnit {
@@ -4609,10 +4608,10 @@ func HisStoryBloodHisDrugDeliverInfo(orgID int64, prescribingNumber float64, war
4609 4608
 			if warehouse.MaxUnit != warehouse.MinUnit {
4610 4609
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
4611 4610
 			}
4612
-			fmt.Println("minNumber------", minNumber)
4613
-			fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
4614
-			fmt.Println(" warehouse.MaxUnit", warehouse.MaxUnit)
4615
-			fmt.Println(" warehouse.MinUnit", warehouse.MinUnit)
4611
+			//fmt.Println("minNumber------", minNumber)
4612
+			//fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
4613
+			//fmt.Println(" warehouse.MaxUnit", warehouse.MaxUnit)
4614
+			//fmt.Println(" warehouse.MinUnit", warehouse.MinUnit)
4616 4615
 
4617 4616
 			if warehouse.MaxUnit == warehouse.MinUnit {
4618 4617
 				//改动的地方

+ 562 - 6
service/patient_service.go Näytä tiedosto

@@ -589,7 +589,7 @@ func GetPatientListById(orgID int64, patientId int64) (patients models.PatientLi
589 589
 }
590 590
 
591 591
 func GetPatientCount(orgID int64) (total int64) {
592
-	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1", orgID).Count(&total)
592
+	readDb.Model(&models.Patients{}).Where("user_org_id=? and status=1 and lapseto = 1 and patient_type = 1", orgID).Count(&total)
593 593
 	return
594 594
 }
595 595
 func GetLapsetoPatientCount(orgID int64, lapseto int64) (total int64) {
@@ -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,545 @@ 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 GetPatientMapListOne(user_org_id int64) (patient []*models.SfPatients, err error) {
5078
+
5079
+	err = XTReadDB().Where("user_org_id = ? and status=1 and lapseto =1", user_org_id).Find(&patient).Error
5080
+
5081
+	return patient, err
5082
+}
5083
+
5084
+func GetAllAdminUserList(org_id int64, app_id int64) (admin []*models.SgjUserAdminRole, err error) {
5085
+
5086
+	err = UserReadDB().Where("org_id = ? and app_id = ? and status=1", org_id, app_id).Find(&admin).Error
5087
+
5088
+	return admin, err
5089
+}
5090
+
5091
+func CreatePatientInCount(tx *gorm.DB, patientCount models.SfPatientInCount) error {
5092
+
5093
+	err := tx.Create(&patientCount).Error
5094
+
5095
+	if err != nil {
5096
+		tx.Rollback()
5097
+		return err
5098
+	}
5099
+	return err
5100
+}
5101
+
5102
+func ModifyPatientCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count int64, hp_count int64, other_count int64, patient_id int64) (models.SfPatients, error) {
5103
+
5104
+	patients := models.SfPatients{}
5105
+
5106
+	err = tx.Model(&patients).Where("id = ?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count + ?", hd_count)).Error
5107
+
5108
+	err = tx.Model(&patients).Where("id = ?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count + ?", hdf_count)).Error
5109
+
5110
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count + ?", hdhp_count)).Error
5111
+
5112
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count + ?", hp_count)).Error
5113
+
5114
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count + ?", other_count)).Error
5115
+
5116
+	return patients, err
5117
+}
5118
+
5119
+func UpdatePatientInCount(tx *gorm.DB, hd_count int64, hdf_count int64, hdhp_count int64, hp_count int64, patient_id int64) (models.SfPatients, error) {
5120
+
5121
+	patients := models.SfPatients{}
5122
+
5123
+	err = tx.Model(&patients).Where("id = ?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count - ?", hd_count)).Error
5124
+
5125
+	err = tx.Model(&patients).Where("id = ?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count - ?", hdf_count)).Error
5126
+
5127
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count - ?", hdhp_count)).Error
5128
+
5129
+	err = tx.Model(&patients).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count - ?", hp_count)).Error
5130
+
5131
+	return patients, err
5132
+}
5133
+
5134
+func ModiftyPatientCount(count int64, is_type int64, patient_id int64, tx *gorm.DB) (models.SfPatients, error) {
5135
+
5136
+	patients := models.SfPatients{}
5137
+	if is_type == 1 {
5138
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count + ?", count)).Error
5139
+		if err != nil {
5140
+			tx.Rollback()
5141
+			return patients, err
5142
+		}
5143
+	}
5144
+	if is_type == 2 {
5145
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count + ?", count)).Error
5146
+		if err != nil {
5147
+			tx.Rollback()
5148
+			return patients, err
5149
+		}
5150
+	}
5151
+	if is_type == 3 {
5152
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count + ?", count)).Error
5153
+		if err != nil {
5154
+			tx.Rollback()
5155
+			return patients, err
5156
+		}
5157
+	}
5158
+	if is_type == 4 {
5159
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count + ?", count)).Error
5160
+		if err != nil {
5161
+			tx.Rollback()
5162
+			return patients, err
5163
+		}
5164
+	}
5165
+	if is_type == 5 {
5166
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count + ?", count)).Error
5167
+		if err != nil {
5168
+			tx.Rollback()
5169
+			return patients, err
5170
+		}
5171
+	}
5172
+	return patients, err
5173
+}
5174
+
5175
+func ReducePatientCount(count int64, is_type int64, patient_id int64, tx *gorm.DB) (models.SfPatients, error) {
5176
+
5177
+	patients := models.SfPatients{}
5178
+	if is_type == 1 {
5179
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hd_count", gorm.Expr("hd_count - ?", count)).Error
5180
+		if err != nil {
5181
+			tx.Rollback()
5182
+			return patients, err
5183
+		}
5184
+	}
5185
+	if is_type == 2 {
5186
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdf_count", gorm.Expr("hdf_count - ?", count)).Error
5187
+		if err != nil {
5188
+			tx.Rollback()
5189
+			return patients, err
5190
+		}
5191
+	}
5192
+	if is_type == 3 {
5193
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hdhp_count", gorm.Expr("hdhp_count - ?", count)).Error
5194
+		if err != nil {
5195
+			tx.Rollback()
5196
+			return patients, err
5197
+		}
5198
+	}
5199
+	if is_type == 4 {
5200
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("hp_count", gorm.Expr("hp_count - ?", count)).Error
5201
+		if err != nil {
5202
+			tx.Rollback()
5203
+			return patients, err
5204
+		}
5205
+	}
5206
+	if is_type == 5 {
5207
+		err = tx.Model(&models.SfPatients{}).Where("id=?", patient_id).UpdateColumn("other_count", gorm.Expr("other_count - ?", count)).Error
5208
+		if err != nil {
5209
+			tx.Rollback()
5210
+			return patients, err
5211
+		}
5212
+	}
5213
+	return patients, err
5214
+}
5215
+
5216
+func GetPatientCountList(user_org_id int64, patient_id int64, page int64, limit int64, start_time int64, end_time int64) (patient []*models.SfPatientInCount, total int64, err error) {
5217
+
5218
+	db := XTReadDB().Model(&patient).Where("status=1")
5219
+
5220
+	offset := (page - 1) * limit
5221
+
5222
+	if patient_id > 0 {
5223
+		db = db.Where("patient_id = ?", patient_id)
5224
+	}
5225
+
5226
+	if user_org_id > 0 {
5227
+		db = db.Where("user_org_id = ?", user_org_id)
5228
+	}
5229
+
5230
+	if start_time > 0 {
5231
+		db = db.Where("record_date >=?", start_time)
5232
+	}
5233
+	if end_time > 0 {
5234
+		db = db.Where("record_date<=?", end_time)
5235
+	}
5236
+
5237
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&patient).Error
5238
+
5239
+	return patient, total, err
5240
+}
5241
+
5242
+func CheckPatientCount(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5243
+
5244
+	patientInCount := models.SfPatientInCount{}
5245
+
5246
+	err = tx.Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 1}).Error
5247
+	if err != nil {
5248
+		tx.Rollback()
5249
+		return patientInCount, err
5250
+	}
5251
+	return patientInCount, err
5252
+}
5253
+
5254
+func ReturnCheckPatientCount(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5255
+
5256
+	patientInCount := models.SfPatientInCount{}
5257
+
5258
+	err = tx.Model(&patientInCount).Where("id = ?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5259
+
5260
+	if err != nil {
5261
+		tx.Rollback()
5262
+		return patientInCount, err
5263
+	}
5264
+
5265
+	return patientInCount, err
5266
+}
5267
+
5268
+func UpdatePatientCountFlow(id int64, tx *gorm.DB) error {
5269
+
5270
+	err := tx.Model(&models.SfPatientCountFlow{}).Where("warehouse_info_id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
5271
+
5272
+	if err != nil {
5273
+		tx.Rollback()
5274
+		return err
5275
+	}
5276
+	return err
5277
+}
5278
+
5279
+func GetPatientCountById(id int64, tx *gorm.DB) (models.SfPatientInCount, error) {
5280
+
5281
+	patientInCount := models.SfPatientInCount{}
5282
+
5283
+	err := tx.Where("id = ?", id).Find(&patientInCount).Error
5284
+	if err != nil {
5285
+		tx.Rollback()
5286
+		return patientInCount, err
5287
+	}
5288
+
5289
+	return patientInCount, err
5290
+}
5291
+
5292
+func DeletePatientCount(id int64) (models.SfPatientInCount, error) {
5293
+
5294
+	patientCount := models.SfPatientInCount{}
5295
+
5296
+	err := XTWriteDB().Model(&patientCount).Where("id = ?", id).Updates(map[string]interface{}{"status": 0}).Error
5297
+
5298
+	return patientCount, err
5299
+}
5300
+
5301
+func CreateSfPatientOutCount(outCount models.SfPatientOutCount) error {
5302
+
5303
+	err := XTWriteDB().Create(&outCount).Error
5304
+
5305
+	return err
5306
+}
5307
+
5308
+func GetPatientOutCountList(patient_id int64, user_org_id int64, limit int64, page int64, start_time int64, end_time int64) (outcount []*models.SfPatientOutCount, total int64, err error) {
5309
+
5310
+	db := XTReadDB().Model(&outcount).Where("status=1")
5311
+
5312
+	offset := (page - 1) * limit
5313
+
5314
+	if patient_id > 0 {
5315
+		db = db.Where("patient_id = ?", patient_id)
5316
+	}
5317
+
5318
+	if user_org_id > 0 {
5319
+		db = db.Where("user_org_id = ?", user_org_id)
5320
+	}
5321
+
5322
+	if start_time > 0 {
5323
+		db = db.Where("start_time>=?", start_time)
5324
+	}
5325
+
5326
+	if end_time > 0 {
5327
+		db = db.Where("end_time<=?", end_time)
5328
+	}
5329
+
5330
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("record_date desc").Find(&outcount).Error
5331
+
5332
+	return outcount, total, err
5333
+
5334
+}
5335
+
5336
+func GetPatientScheduleByPatient(patient_id int64, record_date int64, user_org_id int64) (models.XtSchedule, error) {
5337
+
5338
+	schedule := models.XtSchedule{}
5339
+	err = XTReadDB().Where("patient_id = ? and schedule_date = ? and user_org_id = ? and status=1", patient_id, record_date, user_org_id).Last(&schedule).Error
5340
+
5341
+	return schedule, err
5342
+}
5343
+
5344
+func GetDialysisSolutonByScheduleModeId(mode_id int64, patient_id int64, user_org_id int64) (models.DialysisSolution, error) {
5345
+
5346
+	solution := models.DialysisSolution{}
5347
+
5348
+	err = XTReadDB().Where("mode_id = ? and patient_id = ? and user_org_id = ? and solution_status =1", mode_id, patient_id, user_org_id).Find(&solution).Error
5349
+
5350
+	return solution, err
5351
+}
5352
+
5353
+func DeletePatientOutCount(id int64) error {
5354
+
5355
+	outCount := models.SfPatientOutCount{}
5356
+
5357
+	err := XTWriteDB().Model(&outCount).Where("id = ? and status=1", id).Updates(map[string]interface{}{"status": 0}).Error
5358
+
5359
+	return err
5360
+}
5361
+
5362
+func GetPatientOutCountById(id int64, tx *gorm.DB) (models.SfPatientOutCount, error) {
5363
+
5364
+	outCount := models.SfPatientOutCount{}
5365
+	err = tx.Where("id=? and status=1", id).Find(&outCount).Error
5366
+
5367
+	if err != gorm.ErrRecordNotFound {
5368
+		if err != nil {
5369
+			tx.Rollback()
5370
+			return outCount, err
5371
+		}
5372
+	}
5373
+	return outCount, err
5374
+}
5375
+
5376
+func CreatePatientCountFlow(flow models.SfPatientCountFlow, tx *gorm.DB) error {
5377
+
5378
+	err := tx.Create(&flow).Error
5379
+
5380
+	if err != nil {
5381
+		tx.Rollback()
5382
+		return err
5383
+	}
5384
+
5385
+	return err
5386
+}
5387
+
5388
+func GetSfPatientById(tx *gorm.DB, patient_id int64) (models.SfPatients, error) {
5389
+
5390
+	patients := models.SfPatients{}
5391
+	err := tx.Where("id =? and status=1", patient_id).Find(&patients).Error
5392
+
5393
+	if err != gorm.ErrRecordNotFound {
5394
+		if err != nil {
5395
+			tx.Rollback()
5396
+			return patients, err
5397
+		}
5398
+	}
5399
+	return patients, err
5400
+}
5401
+
5402
+func GetSfPatientByIdOne(patient_id int64) (models.SfPatients, error) {
5403
+
5404
+	patients := models.SfPatients{}
5405
+	err := XTReadDB().Where("id =? and status=1", patient_id).Find(&patients).Error
5406
+
5407
+	return patients, err
5408
+}
5409
+
5410
+func CheckPatientOutCount(id int64, tx *gorm.DB) error {
5411
+
5412
+	patients := models.SfPatientOutCount{}
5413
+
5414
+	err := tx.Model(&patients).Where("id=? and status=1", id).Updates(map[string]interface{}{"is_check": 1, "mtime": time.Now().Unix()}).Error
5415
+
5416
+	return err
5417
+}
5418
+
5419
+func ReturnPatientOutCount(id int64, tx *gorm.DB) error {
5420
+
5421
+	err = tx.Model(&models.SfPatientOutCount{}).Where("id=?", id).Updates(map[string]interface{}{"is_check": 2}).Error
5422
+
5423
+	if err != nil {
5424
+		tx.Rollback()
5425
+		return err
5426
+	}
5427
+
5428
+	return err
5429
+}
5430
+
5431
+func DeletePatientCountFlow(id int64, tx *gorm.DB) error {
5432
+
5433
+	err := tx.Model(&models.SfPatientCountFlow{}).Where("warehouse_out_id = ?", id).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
5434
+
5435
+	if err != nil {
5436
+		tx.Rollback()
5437
+		return err
5438
+	}
5439
+	return err
5440
+
5441
+}
5442
+
5443
+func GetPatientCountMapList(patient_id int64, limit int64, page int64, user_org_id int64) (patient []*models.SfPatients, total int64, err error) {
5444
+
5445
+	db := XTReadDB().Model(&patient).Where("status=1")
5446
+
5447
+	offset := (page - 1) * limit
5448
+
5449
+	if (patient_id) > 0 {
5450
+		db = db.Where("id = ?", patient_id)
5451
+	}
5452
+	if (user_org_id) > 0 {
5453
+		db = db.Where("user_org_id = ?", user_org_id)
5454
+	}
5455
+
5456
+	err = db.Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&patient).Error
5457
+
5458
+	return patient, total, err
5459
+}
5460
+
5461
+func GetPatientCountFlow(patient_id int64, user_org_id int64, is_type int64, mode_id int64, start_time int64, end_time int64) (flow []*models.SfPatientCountFlow, total int64, err error) {
5462
+
5463
+	db := XTReadDB().Model(&flow).Where("status=1")
5464
+
5465
+	if patient_id > 0 {
5466
+		db = db.Where("patient_id=?", patient_id)
5467
+	}
5468
+	if user_org_id > 0 {
5469
+		db = db.Where("user_org_id = ?", user_org_id)
5470
+	}
5471
+	if is_type > 0 {
5472
+		db = db.Where("is_type = ?", is_type)
5473
+	}
5474
+	if mode_id > 0 {
5475
+		db = db.Where("mode_id = ?", mode_id)
5476
+	}
5477
+
5478
+	if start_time > 0 {
5479
+		db = db.Where("ctime>=?", start_time)
5480
+	}
5481
+	if end_time > 0 {
5482
+		db = db.Where("ctime<=?", end_time)
5483
+	}
5484
+	err = db.Find(&flow).Error
5485
+
5486
+	return flow, total, err
5487
+}
5488
+
5489
+func GetDialysisOrderSetting(user_org_id int64) (models.XtDialysisOrderSetting, error) {
5490
+
5491
+	orderSetting := models.XtDialysisOrderSetting{}
5492
+	err = XTReadDB().Model(&orderSetting).Where("user_org_id = ? and status=1", user_org_id).Find(&orderSetting).Error
5493
+
5494
+	return orderSetting, err
5495
+}
5496
+
5497
+func GetDialysisOrderSchedule(patient_id int64, schedule_date int64, user_org_id int64, tx *gorm.DB) (models.XtSchedule, error) {
5498
+
5499
+	schedule := models.XtSchedule{}
5500
+
5501
+	err = tx.Where("patient_id=? and schedule_date = ? and user_org_id=? and status=1", patient_id, schedule_date, user_org_id).Find(&schedule).Error
5502
+
5503
+	if err != nil {
5504
+		tx.Rollback()
5505
+		return schedule, err
5506
+	}
5507
+
5508
+	return schedule, err
5509
+}
5510
+
5511
+func CreateDialysisOrder(setting models.XtDialysisOrderSetting) error {
5512
+
5513
+	err := XTWriteDB().Create(&setting).Error
5514
+
5515
+	return err
5516
+}
5517
+
5518
+func GetPatientCountFlowList(patient_id int64, start_time int64, end_time int64, limit int64, page int64, orgId int64, is_type int64) (flow []*models.SfPatientCountFlow, total int64, err error) {
5519
+
5520
+	db := XTReadDB().Model(&flow).Where("status=1")
5521
+
5522
+	offset := (page - 1) * limit
5523
+
5524
+	if patient_id > 0 {
5525
+		db = db.Where("patient_id = ?", patient_id)
5526
+	}
5527
+	if start_time > 0 {
5528
+		db = db.Where("ctime>=?", start_time)
5529
+	}
5530
+
5531
+	if end_time > 0 {
5532
+		db = db.Where("ctime<=?", end_time)
5533
+	}
5534
+
5535
+	if orgId > 0 {
5536
+		db = db.Where("user_org_id = ?", orgId)
5537
+	}
5538
+
5539
+	if is_type > 0 {
5540
+		db = db.Where("is_type = ?", is_type)
5541
+	}
5542
+
5543
+	err = db.Group("patient_id,mode_id,is_type").Count(&total).Offset(offset).Limit(limit).Order("id desc").Find(&flow).Error
5544
+
5545
+	return flow, total, err
5546
+}
5547
+
5548
+func GetPatientCountListFlowOne(patient_id int64, start_time int64, end_time int64, is_type int64, orgId int64) (flow []*models.SfPatientCountFlow, err error) {
5549
+
5550
+	db := XTReadDB().Model(&flow).Where("status=1")
5551
+
5552
+	if patient_id > 0 {
5553
+		db = db.Where("patient_id = ?", patient_id)
5554
+	}
5555
+	if start_time > 0 {
5556
+		db = db.Where("ctime>=?", start_time)
5557
+	}
5558
+
5559
+	if end_time > 0 {
5560
+		db = db.Where("ctime<=?", end_time)
5561
+	}
5562
+
5563
+	if orgId > 0 {
5564
+		db = db.Where("user_org_id = ?", orgId)
5565
+	}
5566
+
5567
+	if is_type > 0 {
5568
+		db = db.Where("is_type = ?", is_type)
5569
+	}
5570
+
5571
+	err = db.Order("id desc").Find(&flow).Error
5572
+
5573
+	return flow, err
5574
+
5575
+}
5576
+
5577
+func GetPatientCountFlowByIdList(patient_id int64, orgId int64, mode_id int64, is_type int64, startTime int64, endTime int64) (flow []*models.SfPatientCountFlow, err error) {
5578
+
5579
+	db := XTReadDB().Model(&flow).Where("status=1")
5580
+
5581
+	if patient_id > 0 {
5582
+		db = db.Where("patient_id=?", patient_id)
5583
+	}
5584
+	if orgId > 0 {
5585
+		db = db.Where("user_org_id =?", orgId)
5586
+	}
5587
+
5588
+	if mode_id > 0 {
5589
+		db = db.Where("mode_id = ?", mode_id)
5590
+	}
5591
+
5592
+	if is_type > 0 {
5593
+		db = db.Where("is_type =?", is_type)
5594
+	}
5595
+
5596
+	if startTime > 0 {
5597
+		db = db.Where("ctime>=?", startTime)
5598
+	}
5599
+	if endTime > 0 {
5600
+		db = db.Where("ctime<=?", endTime)
5601
+	}
5602
+	if mode_id > 0 {
5603
+		db = db.Where("mode_id = ?", mode_id)
5604
+	}
5605
+	err = db.Find(&flow).Error
5606
+
5607
+	return flow, err
5608
+}

+ 5 - 5
service/patientmanage_service.go Näytä tiedosto

@@ -1971,22 +1971,22 @@ type InspectionCount struct {
1971 1971
 
1972 1972
 func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1973 1973
 	var count []*models.Inspection
1974
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ?  and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` <= ? and xti.inspect_value >= ? ) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, min_value).Scan(&count).Error
1974
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1 and pp.patient_type =1  WHERE (x.status = 1) AND (x.org_id = ?  and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` <= ? and xti.inspect_value >= ? ) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, min_value).Scan(&count).Error
1975 1975
 
1976 1976
 	return int64(len(count)), err2
1977 1977
 }
1978 1978
 func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1979 1979
 	var count []*models.Inspection
1980
-	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, orgid, item_name, startime, endtime, min_value).Scan(&count).Error
1980
+	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1 and pp.patient_type =1   WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, orgid, item_name, startime, endtime, min_value).Scan(&count).Error
1981 1981
 	return int64(len(count)), err2
1982 1982
 }
1983 1983
 func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, item_name string) (total int64, err error) {
1984
-	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.item_name = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, item_name, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1", orgid).Count(&total).Error
1984
+	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.item_name = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, item_name, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1 and xt_patients.patient_type = 1", orgid).Count(&total).Error
1985 1985
 	return total, err
1986 1986
 }
1987 1987
 
1988 1988
 func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, patient_id int64, item_name string) (inspections []*models.Inspection, err error) {
1989
-	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
1989
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1 and p.patient_type =1").Where("x.status = 1")
1990 1990
 	if startime > 0 {
1991 1991
 		db = db.Where("x.inspect_date >= ?", startime)
1992 1992
 	}
@@ -2009,7 +2009,7 @@ func GetPatientInspectionByID(startime int64, endtime int64, orgid int64, patien
2009 2009
 }
2010 2010
 
2011 2011
 func GetPatientKTVORURRInspectionByID(startime int64, endtime int64, orgid int64, projectid int64, item_id int64, patient_id int64) (inspections []*models.Inspection, err error) {
2012
-	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1").Where("x.status = 1")
2012
+	db := XTReadDB().Table("xt_inspection as x").Select("patient_id,inspect_date,inspect_value").Joins("join xt_patients p On p.id = x.patient_id and p.status = 1 and p.lapseto = 1 and p.patient_type =1").Where("x.status = 1")
2013 2013
 	if startime > 0 {
2014 2014
 		db = db.Where("x.inspect_date >= ?", startime)
2015 2015
 	}

+ 9 - 1
service/pharmacy_service.go Näytä tiedosto

@@ -2561,9 +2561,17 @@ func DispensingMedicineTwo(orgid, patient_id, advice_date, drug_id, creater int6
2561 2561
 	return
2562 2562
 }
2563 2563
 
2564
-func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.HisDoctorAdviceInfo, err error) {
2564
+func GetDrugTocalCountByDrugId(drug_id int64, advice_date int64, user_org_id int64) (advice []*models.NBHisDoctorAdviceInfo, err error) {
2565 2565
 
2566 2566
 	err = XTReadDB().Where("drug_id = ? and advice_date>=? and user_org_id = ? and status=1 and drug_code!=''", drug_id, advice_date, user_org_id).Find(&advice).Error
2567 2567
 
2568 2568
 	return advice, err
2569 2569
 }
2570
+
2571
+func GetNewBaseDrugById(id int64) (models.NBXtBaseDrug, error) {
2572
+
2573
+	drug := models.NBXtBaseDrug{}
2574
+	err := XTReadDB().Where("id = ?", id).Find(&drug).Error
2575
+
2576
+	return drug, err
2577
+}

+ 1 - 1
service/self_drug_service.go Näytä tiedosto

@@ -1271,7 +1271,7 @@ func GetInventoryModeList(orgid int64) (info []*models.PatientDrugWarehouseInfo,
1271 1271
 		if orgid > 0 {
1272 1272
 			db = db.Where("x.org_id = ?", orgid)
1273 1273
 		}
1274
-		err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count,x.max_unit as max_unit_one,x.min_unit as min_unit_one").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.batch_number").Scan(&info).Error
1274
+		err = db.Select("x.drug_id,x.number,x.product_date,x.expiry_date,x.stock_max_number,x.stock_min_number,x.batch_number,t.drug_name,t.max_unit,t.min_unit,t.min_number,t.dose,t.dose_unit,x.manufacturer,x.dealer,t.sum_count,x.max_unit as max_unit_one,x.min_unit as min_unit_one").Joins("left join xt_base_drug as t on t.id = x.drug_id").Group("x.drug_id,x.id").Scan(&info).Error
1275 1275
 		return info, err
1276 1276
 	} else {
1277 1277
 		db := XTReadDB().Table("xt_drug_warehouse_info as x").Where("x.status = 1 and (x.warehousing_count>0)")

+ 15 - 1
service/sign_service.go Näytä tiedosto

@@ -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 = 9535 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
+}

+ 28 - 8
service/warhouse_service.go Näytä tiedosto

@@ -11049,10 +11049,15 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11049 11049
 		if lastWarehouse.StockMinNumber >= drup.MinNumber {
11050 11050
 			var stockMax int64
11051 11051
 			var stockMin int64
11052
+
11053
+			var stockMac_One int64
11054
+
11052 11055
 			stockMax = lastWarehouse.StockMinNumber / drup.MinNumber
11053 11056
 			stockMin = lastWarehouse.StockMinNumber % drup.MinNumber
11054 11057
 
11055
-			ChangeNewMaxNumberOne(lastWarehouse.ID, stockMax, tx)
11058
+			stockMac_One = lastWarehouse.StockMaxNumber + stockMax
11059
+
11060
+			ChangeNewMaxNumberOne(lastWarehouse.ID, stockMac_One, tx)
11056 11061
 			UpdateNewMinNumber(lastWarehouse.ID, stockMin, tx)
11057 11062
 
11058 11063
 		}
@@ -11061,6 +11066,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11061 11066
 	if lastWarehouse.MaxUnit == lastWarehouse.MinUnit && drup.MaxUnit != drup.MinUnit && lastWarehouse.MinUnit != "" {
11062 11067
 
11063 11068
 		lastWarehouse.StockMaxNumber = lastWarehouse.StockMaxNumber + lastWarehouse.StockMinNumber
11069
+
11064 11070
 		ChangeNewMaxNumberOne(lastWarehouse.ID, lastWarehouse.StockMaxNumber, tx)
11065 11071
 
11066 11072
 	}
@@ -11083,6 +11089,9 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11083 11089
 		stock_number = warehouse.StockMaxNumber*drup.MinNumber + warehouse.StockMinNumber
11084 11090
 
11085 11091
 	}
11092
+
11093
+	fmt.Println("stock_number--------------", stock_number)
11094
+	fmt.Println("deliver_number", deliver_number)
11086 11095
 	if stock_number >= deliver_number {
11087 11096
 
11088 11097
 		var maxNumber int64 = 0
@@ -11091,6 +11100,10 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11091 11100
 		maxNumber = deliver_number / drup.MinNumber
11092 11101
 		minNumber = deliver_number % drup.MinNumber
11093 11102
 
11103
+		fmt.Println("maxNumber==============", maxNumber)
11104
+
11105
+		fmt.Println("maxNumber==============", minNumber)
11106
+
11094 11107
 		if warehouse.StockMaxNumber == 0 && drup.MaxUnit == drup.MinUnit {
11095 11108
 			minNumber = maxNumber
11096 11109
 		}
@@ -11101,17 +11114,20 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11101 11114
 			}
11102 11115
 		}
11103 11116
 
11117
+		fmt.Println("warehouse.StockMaxNumber", warehouse.StockMaxNumber)
11118
+		fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
11119
+
11104 11120
 		if drup.MinUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11105
-			//fmt.Println("金1")
11121
+			fmt.Println("金1")
11106 11122
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber*drup.MinNumber
11107 11123
 		}
11108 11124
 
11109 11125
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit != drup.MinUnit {
11110
-			//fmt.Println("金2")
11126
+			fmt.Println("金2")
11111 11127
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11112 11128
 		}
11113 11129
 		if drup.MaxUnit == warehouse.MaxUnit && drup.MaxUnit == drup.MinUnit {
11114
-			//fmt.Println("金3")
11130
+			fmt.Println("金3")
11115 11131
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - maxNumber
11116 11132
 		}
11117 11133
 
@@ -11124,8 +11140,12 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11124 11140
 
11125 11141
 		warehouse.Mtime = time.Now().Unix()
11126 11142
 
11143
+		fmt.Println("warehouse.StockMinNumber", warehouse.StockMinNumber)
11144
+
11145
+		fmt.Println("minNumber222222222222222", minNumber)
11146
+
11127 11147
 		if warehouse.StockMinNumber < minNumber {
11128
-			//fmt.Println("金4")
11148
+			fmt.Println("金4")
11129 11149
 			warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11130 11150
 			if warehouse.MaxUnit != warehouse.MinUnit {
11131 11151
 				warehouse.StockMinNumber = warehouse.StockMinNumber + drup.MinNumber - minNumber
@@ -11134,7 +11154,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11134 11154
 				warehouse.StockMaxNumber = warehouse.StockMaxNumber - 1
11135 11155
 			}
11136 11156
 		} else {
11137
-			//fmt.Println("金5")
11157
+			fmt.Println("金5", minNumber)
11138 11158
 			if minNumber > 0 {
11139 11159
 				if (warehouse.StockMinNumber - minNumber) >= 0 {
11140 11160
 					warehouse.StockMinNumber = warehouse.StockMinNumber - minNumber
@@ -11143,7 +11163,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11143 11163
 			}
11144 11164
 
11145 11165
 			if minNumber == 0 && maxNumber != 1 && warehouse.StockMaxNumber <= 0 {
11146
-				//fmt.Println("6")
11166
+				fmt.Println("6", warehouse.StockMinNumber)
11147 11167
 				if warehouse.StockMinNumber > 0 {
11148 11168
 					if warehouse.StockMinNumber-deliver_number >= 0 {
11149 11169
 						warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
@@ -11157,7 +11177,7 @@ func AutoNewDrugDeliverInfoFourtyOne(orgID int64, prescribingNumber int64, wareh
11157 11177
 
11158 11178
 		if maxNumber == 1 && minNumber == 0 && drup.MaxUnit != drup.MinUnit && warehouse.MaxUnit != warehouse.MinUnit {
11159 11179
 			if (warehouse.StockMinNumber - deliver_number) >= 0 {
11160
-				//fmt.Println("金7")
11180
+				fmt.Println("金7")
11161 11181
 				warehouse.StockMinNumber = warehouse.StockMinNumber - deliver_number
11162 11182
 			}
11163 11183