Browse Source

new project commit

csx 4 years ago
parent
commit
b919cca41f
100 changed files with 48015 additions and 0 deletions
  1. 5 0
      .gitignore
  2. 176 0
      conf/app.conf
  3. 58 0
      controllers/admin_api_controllers/admin_api_base_controller.go
  4. 16 0
      controllers/admin_api_controllers/admin_api_router_register.go
  5. 466 0
      controllers/admin_api_controllers/analysis_api_controller.go
  6. 35 0
      controllers/admin_api_controllers/login_api_controller.go
  7. 2223 0
      controllers/advice_template.json
  8. 219 0
      controllers/base_api_controller.go
  9. 40 0
      controllers/base_controller.go
  10. 58 0
      controllers/base_view_controller.go
  11. 1415 0
      controllers/data_api_controller.go
  12. 15 0
      controllers/default.go
  13. 1184 0
      controllers/device_api_controller.go
  14. 4923 0
      controllers/dialysis_api_controller.go
  15. 58 0
      controllers/dialysis_board_api_controller.go
  16. 2562 0
      controllers/dialysis_record_api_controller.go
  17. 25 0
      controllers/district_api_controller.go
  18. 194 0
      controllers/doctors_api_controller.go
  19. 942 0
      controllers/gobal_config_api_controller.go
  20. 622 0
      controllers/inspection_api_controller.go
  21. 282 0
      controllers/integration_config_api_controller.go
  22. 164 0
      controllers/invoice_api_controller.go
  23. 3000 0
      controllers/manage_api_controller.go
  24. 93 0
      controllers/mobile_api_controllers/admin_user_api_controller.go
  25. 7 0
      controllers/mobile_api_controllers/advice_api_controller.go
  26. 109 0
      controllers/mobile_api_controllers/check_api_controller.go
  27. 994 0
      controllers/mobile_api_controllers/check_weight_api_controller.go
  28. 6252 0
      controllers/mobile_api_controllers/dialysis_api_controller.go
  29. 507 0
      controllers/mobile_api_controllers/dialysis_api_controller_extend.go
  30. 73 0
      controllers/mobile_api_controllers/doctor_advice_api_controller.go
  31. 29 0
      controllers/mobile_api_controllers/doctor_api_controller.go
  32. 339 0
      controllers/mobile_api_controllers/login_api_controller.go
  33. 61 0
      controllers/mobile_api_controllers/mobile_api_base_controller.go
  34. 113 0
      controllers/mobile_api_controllers/mobile_api_router_register.go
  35. 2584 0
      controllers/mobile_api_controllers/patient_api_controller.go
  36. 28 0
      controllers/mobile_api_controllers/qiniiu_api_controller.go
  37. 73 0
      controllers/mobile_api_controllers/stock_api_controller.go
  38. 294 0
      controllers/orginfo_api_controller.go
  39. 3157 0
      controllers/patient_api_controller.go
  40. 368 0
      controllers/patient_dataconfig_api_controller.go
  41. 620 0
      controllers/pay_api_controller.go
  42. 152 0
      controllers/print_data_api_controller.go
  43. 158 0
      controllers/public_api_controller.go
  44. 864 0
      controllers/qcd_api_controller.go
  45. 36 0
      controllers/qiniiu_api_controller.go
  46. 713 0
      controllers/role_controller.go
  47. 704 0
      controllers/schedule_api_controller.go
  48. 398 0
      controllers/schedule_template_api_controller.go
  49. 610 0
      controllers/sign_weigh_api_controller.go
  50. 69 0
      controllers/statistics_api_controller.go
  51. 347 0
      controllers/stock_api_controller.go
  52. 375 0
      controllers/stock_good_api_controller.go
  53. 1938 0
      controllers/stock_in_api_controller.go
  54. 323 0
      controllers/verify_login_controller.go
  55. 2 0
      db/xt_drug_dic
  56. 21 0
      db/xt_drugway_dic
  57. 35 0
      db/xt_ef_dic
  58. BIN
      db/xtdb.docx
  59. 401 0
      enums/error_code.go
  60. 21 0
      main.go
  61. 16 0
      models/admin_models/admin_models.go
  62. 69 0
      models/admin_user_models.go
  63. 16 0
      models/app_version_models.go
  64. 125 0
      models/board_models.go
  65. 63 0
      models/data_models.go
  66. 34 0
      models/data_upload_models.go
  67. 14 0
      models/db_err_models.go
  68. 846 0
      models/device_models.go
  69. 801 0
      models/dialysis.go
  70. 18 0
      models/district_models.go
  71. 154 0
      models/doctor_advice_models.go
  72. 76 0
      models/gobal_models.go
  73. 49 0
      models/good_models.go
  74. 79 0
      models/inspection_models.go
  75. 272 0
      models/intergration_models.go
  76. 139 0
      models/monitor_models.go
  77. 105 0
      models/org_models.go
  78. 381 0
      models/patient_models.go
  79. 45 0
      models/patient_schedule_template_models.go
  80. 37 0
      models/purview_models.go
  81. 78 0
      models/role_models.go
  82. 91 0
      models/schedule_models.go
  83. 130 0
      models/service_models.go
  84. 104 0
      models/sign_weigh_models.go
  85. 303 0
      models/stock_models.go
  86. 123 0
      models/stock_query_models.go
  87. 11 0
      models/subscibe_state_models.go
  88. 104 0
      models/user_models.go
  89. 58 0
      routers/router.go
  90. 353 0
      service/admin_service.go
  91. 19 0
      service/app_version.go
  92. 45 0
      service/auto_clear_schedules_service.go
  93. 261 0
      service/auto_create_week_disinfection.go
  94. 149 0
      service/auto_create_week_plan.go
  95. 281 0
      service/auto_create_week_schedules_service.go
  96. 187 0
      service/data.go
  97. 156 0
      service/db.go
  98. 27 0
      service/db_err_service.go
  99. 646 0
      service/device_service.go
  100. 0 0
      service/dialysis_service.go

+ 5 - 0
.gitignore View File

@@ -0,0 +1,5 @@
1
+.svn
2
+.git
3
+XT.ext
4
+/*.exe
5
+/*.exe~

+ 176 - 0
conf/app.conf View File

@@ -0,0 +1,176 @@
1
+appname = 血透
2
+httpport = 9529
3
+runmode = dev
4
+
5
+
6
+copyrequestbody = true
7
+sessionon = true
8
+sessiongcmaxlifetime = 64800
9
+
10
+tokencookiemaxlifetime = 7200
11
+
12
+enablexsrf = false
13
+xsrfkey = 61oETzKXQAGaYdkL5gEmGeJJFuYh7EQnp2XdTP1o
14
+xsrfexpire = 3600
15
+
16
+qiniu_accesskey = -l_Pcc1YJs0gh3w0YwN2uoaZO_5fY5J9SIYnSjg0
17
+qiniu_secretkey = DmZSp_Bmnp-9aUB7xUvoyViZpzmx1Rs2RL69GvlW
18
+qiniu_domain = https://images.shengws.com/
19
+qiniu_bucket = syhclub-storage
20
+
21
+aes_key = "xuetou-201807319"
22
+
23
+wxtoken = gh_ac6cd0cdde3d
24
+wxoriId = gh_ac6cd0cdde3d
25
+wxappId = wxbb9223f20bc11612
26
+# wxappsecret = a78c793c377268db25dde2eb971a2ebb
27
+# wxEncodingAESKey = 1vRDzqltXYOc9iMqhsQT7AkIRRpUaGl8MZlUcP7x4UK
28
+
29
+sms_appId = dcabb3aa7afd402794046ebbbf652bce
30
+sms_sid = a26cb0ceb3a811ca82143972f4ef38a4
31
+sms_token = ea475ed8d3de6c54c2b3f9d78db76d1e
32
+sms_baseUrl = https://open.ucpaas.com/ol/sms/
33
+ip_max_send_count = 20
34
+moblie_max_send_count = 5
35
+sms_verification_code_templateid = 329532
36
+
37
+
38
+appid = "wx43ad410d9eef426e"
39
+mchid = "1509573721"
40
+key = "e4SHrkiZu0pQEwVoGBapDBTf9N1Q6MxV"
41
+appsecret="61ee2e6268497d5aa9de0b0187c39aea"
42
+
43
+
44
+
45
+[prod]
46
+httpdomain = https://api.xt.kuyicloud.com
47
+sso_domain = https://sso.kuyicloud.com
48
+front_end_domain = "https://xt.kuyicloud.com/#"
49
+
50
+readmysqlhost = shengws1.mysql.rds.aliyuncs.com
51
+readmysqlport = 3306
52
+readmysqluser = syh
53
+readmysqlpass = xhPECP2nFObR8aUK
54
+readmysqlname = sgj_xt
55
+
56
+writemysqlhost = shengws1.mysql.rds.aliyuncs.com
57
+writemysqlport = 3306
58
+writemysqluser = syh
59
+writemysqlpass = xhPECP2nFObR8aUK
60
+writemysqlname = sgj_xt
61
+
62
+
63
+readuserhost = shengws1.mysql.rds.aliyuncs.com
64
+readuserport = 3306
65
+readuseruser = syh
66
+readuserpass = xhPECP2nFObR8aUK
67
+readusername = sgj_users
68
+
69
+writeuserhost = shengws1.mysql.rds.aliyuncs.com
70
+writeuserport = 3306
71
+writeuseruser = syh
72
+writeuserpass = xhPECP2nFObR8aUK
73
+writeusername = sgj_users
74
+
75
+readmiddlehost = shengws1.mysql.rds.aliyuncs.com
76
+readmiddleport = 3306
77
+readmiddleuser = syh
78
+readmiddlepass = xhPECP2nFObR8aUK
79
+readmiddlename = ky_xt_middle
80
+
81
+writemiddlehost = shengws1.mysql.rds.aliyuncs.com
82
+writemiddleport = 3306
83
+writemiddleuser = syh
84
+writemiddlepass = xhPECP2nFObR8aUK
85
+writemiddlename = ky_xt_middle
86
+
87
+redishost = 349e580b2a524290.redis.rds.aliyuncs.com
88
+redisport = 6379
89
+redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
90
+redisdb = 0
91
+
92
+
93
+
94
+
95
+niprocart =  63
96
+jms = 58
97
+fistula_needle_set = 65
98
+fistula_needle_set_16 = 64
99
+hemoperfusion = 55
100
+dialyser_sterilised = 12
101
+filtryzer = 53
102
+dialyzers = 8
103
+injector = 81
104
+bloodlines = 42
105
+tubingHemodialysis = 30
106
+package = 82
107
+aliquid = 83
108
+
109
+
110
+
111
+[dev]
112
+httpdomain = http://api.xt.test.sgjyun.com
113
+sso_domain = https://testsso.sgjyun.com
114
+front_end_domain = "http://xt.test.sgjyun.com/#"
115
+
116
+readmysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
117
+readmysqlport = 3306
118
+readmysqluser = root
119
+readmysqlpass = 1Q2W3e4r!@#$
120
+readmysqlname = sgj_xt
121
+
122
+writemysqlhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
123
+writemysqlport = 3306
124
+writemysqluser = root
125
+writemysqlpass = 1Q2W3e4r!@#$
126
+writemysqlname = sgj_xt
127
+
128
+readuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
129
+readuserport = 3306
130
+readuseruser = root
131
+readuserpass = 1Q2W3e4r!@#$
132
+readusername = sgj_users
133
+
134
+writeuserhost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
135
+writeuserport = 3306
136
+writeuseruser = root
137
+writeuserpass = 1Q2W3e4r!@#$
138
+writeusername = sgj_users
139
+
140
+
141
+readmiddlehost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
142
+readmiddleport = 3306
143
+readmiddleuser = root
144
+readmiddlepass = 1Q2W3e4r!@#$
145
+readmiddlename = ky_xt_middle
146
+
147
+writemiddlehost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
148
+writemiddleport = 3306
149
+writemiddleuser = root
150
+writemiddlepass = 1Q2W3e4r!@#$
151
+writemiddlename = ky_xt_middle
152
+
153
+
154
+
155
+
156
+#redishost = 120.77.235.13
157
+redishost = 127.0.0.1
158
+redisport = 6379
159
+redispasswrod = syh@#$%123456!
160
+redisdb = 0
161
+
162
+
163
+
164
+niprocart =  83
165
+jms = 80
166
+fistula_needle_set = 81
167
+fistula_needle_set_16 = 82
168
+hemoperfusion = 85
169
+dialyser_sterilised = 84
170
+filtryzer = 79
171
+dialyzers = 10000
172
+injector = 10001
173
+bloodlines = 10002
174
+tubingHemodialysis = 10003
175
+package = 10004
176
+aliquid = 10005

+ 58 - 0
controllers/admin_api_controllers/admin_api_base_controller.go View File

@@ -0,0 +1,58 @@
1
+package admin_api_controllers
2
+
3
+import (
4
+	"XT_New/controllers"
5
+	"XT_New/enums"
6
+	"XT_New/models/admin_models"
7
+)
8
+
9
+type AdminBaseAPIController struct {
10
+	controllers.BaseAPIController
11
+}
12
+
13
+func (this *AdminBaseAPIController) ErrorLog(format string, a ...interface{}) {
14
+	//beego.Error(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
15
+}
16
+
17
+func (this *AdminBaseAPIController) WarnLog(format string, a ...interface{}) {
18
+	//beego.Warn(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
19
+}
20
+
21
+func (this *AdminBaseAPIController) InfoLog(format string, a ...interface{}) {
22
+	//beego.Info(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
23
+}
24
+
25
+func (this *AdminBaseAPIController) DebugLog(format string, a ...interface{}) {
26
+	//beego.Debug(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
27
+}
28
+
29
+func (this *AdminBaseAPIController) TraceLog(format string, a ...interface{}) {
30
+	//beego.Trace(fmt.Sprintf("[管理员后台] %v", fmt.Sprintf(format, a...)))
31
+}
32
+
33
+func (this *AdminBaseAPIController) GetAdminInfo() *AdminInfo {
34
+	userInfo := this.GetSession("admin_info")
35
+	if userInfo == nil {
36
+		return nil
37
+	} else {
38
+		return userInfo.(*AdminInfo)
39
+	}
40
+}
41
+
42
+type AdminInfo struct {
43
+	Admin *admin_models.AdminAccount
44
+}
45
+
46
+type AdminBaseAPIAuthController struct {
47
+	AdminBaseAPIController
48
+}
49
+
50
+func (this *AdminBaseAPIAuthController) Prepare() {
51
+	this.AdminBaseAPIController.Prepare()
52
+
53
+	adminInfo := this.GetAdminInfo()
54
+	if adminInfo == nil {
55
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
56
+		this.StopRun()
57
+	}
58
+}

+ 16 - 0
controllers/admin_api_controllers/admin_api_router_register.go View File

@@ -0,0 +1,16 @@
1
+package admin_api_controllers
2
+
3
+import "github.com/astaxie/beego"
4
+
5
+// 管理员后台路由,以 /admin/api 为前缀
6
+func AdminAPIControllersRegisterRouters() {
7
+	beego.Router("/admin/api/login/pwd", &LoginAPIController{}, "post:LoginByPwd")
8
+
9
+	beego.Router("/admin/api/org/regist", &AnalysisAPIController{}, "get:RegistOrg")
10
+	beego.Router("/admin/api/org/active", &AnalysisAPIController{}, "get:ActiveOrg")
11
+	beego.Router("/admin/api/user/active", &AnalysisAPIController{}, "get:ActiveUser")
12
+	beego.Router("/admin/api/org/expiring", &AnalysisAPIController{}, "get:ExpiringOrg")
13
+	beego.Router("/admin/api/dialysis/analysis", &AnalysisAPIController{}, "get:DialysisAnalysis")
14
+	beego.Router("/admin/api/monitor/analysis", &AnalysisAPIController{}, "get:MonitorAnalysis")
15
+	beego.Router("/admin/api/patient/analysis", &AnalysisAPIController{}, "get:PatientAnalysis")
16
+}

+ 466 - 0
controllers/admin_api_controllers/analysis_api_controller.go View File

@@ -0,0 +1,466 @@
1
+package admin_api_controllers
2
+
3
+import (
4
+	"XT_New/models"
5
+	"XT_New/service"
6
+	"XT_New/utils"
7
+	"time"
8
+)
9
+
10
+type AnalysisAPIController struct {
11
+	AdminBaseAPIAuthController
12
+	// AdminBaseAPIController
13
+}
14
+
15
+// /admin/api/org/regist [get] RegistOrg
16
+func (this *AnalysisAPIController) RegistOrg() {
17
+	totalOrg, getTotalOrgErr := service.GetTotalOrgCount()
18
+	if getTotalOrgErr != nil {
19
+		this.ErrorLog("获取总机构数失败:%v", getTotalOrgErr)
20
+	}
21
+
22
+	now := time.Now()
23
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
24
+	registOrgCountToday, getRegistOrgCountTodayErr := service.GetRegistedOrgCountFromDayToDay(zeroHourTimeOfToday, now)
25
+	if getRegistOrgCountTodayErr != nil {
26
+		this.ErrorLog("获取今日注册机构数失败:%v", getRegistOrgCountTodayErr)
27
+	}
28
+
29
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
30
+	registOrgCountThisWeek, getRegistOrgCountThisWeekErr := service.GetRegistedOrgCountFromDayToDay(monday, sunday)
31
+	if getRegistOrgCountThisWeekErr != nil {
32
+		this.ErrorLog("获取本周注册机构数失败:%v", getRegistOrgCountThisWeekErr)
33
+	}
34
+
35
+	thisYear := now.Year()
36
+	thisMonth := int(now.Month())
37
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
38
+	registOrgCountThisMonth, getRegistOrgCountThisMonthErr := service.GetRegistedOrgCountFromDayToDay(beginningOfMonth, endOfMonth)
39
+	if getRegistOrgCountThisMonthErr != nil {
40
+		this.ErrorLog("获取本月注册机构数失败:%v", getRegistOrgCountThisMonthErr)
41
+	}
42
+
43
+	monthRegistOrgCounts := make([]map[string]interface{}, 0, 12)
44
+	for m := 1; m < 12; m++ {
45
+		if m > thisMonth {
46
+			break
47
+		}
48
+		if m == thisMonth {
49
+			monthRegistOrgCounts = append(monthRegistOrgCounts, map[string]interface{}{
50
+				"month": m,
51
+				"count": registOrgCountThisMonth,
52
+			})
53
+
54
+		} else {
55
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
56
+			registOrgCount, getRegistOrgCountErr := service.GetRegistedOrgCountFromDayToDay(BOM, EOM)
57
+			if getRegistOrgCountErr != nil {
58
+				this.ErrorLog("获取%v月注册机构数失败:%v", m, getRegistOrgCountErr)
59
+			}
60
+			monthRegistOrgCounts = append(monthRegistOrgCounts, map[string]interface{}{
61
+				"month": m,
62
+				"count": registOrgCount,
63
+			})
64
+		}
65
+	}
66
+
67
+	registOrgsThisWeek, getRegistOrgThisWeekErr := service.GetRegistedOrgsFromDayToDay(monday, sunday)
68
+	if getRegistOrgThisWeekErr != nil {
69
+		this.ErrorLog("获取本周注册机构失败:%v", getRegistOrgThisWeekErr)
70
+		registOrgsThisWeek = make([]*models.Org, 0)
71
+	}
72
+
73
+	registOrgsThisMonth, getRegistOrgThisMonthErr := service.GetRegistedOrgsFromDayToDay(beginningOfMonth, endOfMonth)
74
+	if getRegistOrgThisMonthErr != nil {
75
+		this.ErrorLog("获取本月注册机构失败:%v", getRegistOrgThisMonthErr)
76
+		registOrgsThisMonth = make([]*models.Org, 0)
77
+	}
78
+
79
+	this.ServeSuccessJSON(map[string]interface{}{
80
+		"total_org_count":         totalOrg,
81
+		"regist_org_count_today":  registOrgCountToday,
82
+		"regist_org_count_week":   registOrgCountThisWeek,
83
+		"regist_org_count_month":  registOrgCountThisMonth,
84
+		"regist_org_count_months": monthRegistOrgCounts,
85
+		"regist_orgs_week":        registOrgsThisWeek,
86
+		"regist_orgs_month":       registOrgsThisMonth,
87
+	})
88
+}
89
+
90
+// /admin/api/org/active [get] ActiveOrg
91
+func (this *AnalysisAPIController) ActiveOrg() {
92
+	now := time.Now()
93
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
94
+	activeOrgCountToday, getActiveTodayErr := service.GetActiveOrgCountFromDayToDay(zeroHourTimeOfToday, now)
95
+	if getActiveTodayErr != nil {
96
+		this.ErrorLog("获取今日活跃机构数失败:%v", getActiveTodayErr)
97
+	}
98
+
99
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
100
+	activeOrgCountThisWeek, getActiveOrgCountThisWeekErr := service.GetActiveOrgCountFromDayToDay(monday, sunday)
101
+	if getActiveOrgCountThisWeekErr != nil {
102
+		this.ErrorLog("获取本周活跃机构数失败:%v", getActiveOrgCountThisWeekErr)
103
+	}
104
+
105
+	thisYear := now.Year()
106
+	thisMonth := int(now.Month())
107
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
108
+	activeOrgCountThisMonth, getActiveOrgCountThisMonthErr := service.GetActiveOrgCountFromDayToDay(beginningOfMonth, endOfMonth)
109
+	if getActiveOrgCountThisMonthErr != nil {
110
+		this.ErrorLog("获取本月活跃机构数失败:%v", getActiveOrgCountThisMonthErr)
111
+	}
112
+
113
+	monthActiveOrgCounts := make([]map[string]interface{}, 0, 12)
114
+	for m := 1; m < 12; m++ {
115
+		if m > thisMonth {
116
+			break
117
+		}
118
+		if m == thisMonth {
119
+			monthActiveOrgCounts = append(monthActiveOrgCounts, map[string]interface{}{
120
+				"month": m,
121
+				"count": activeOrgCountThisMonth,
122
+			})
123
+
124
+		} else {
125
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
126
+			activeOrgCount, getActiveOrgCountErr := service.GetActiveOrgCountFromDayToDay(BOM, EOM)
127
+			if getActiveOrgCountErr != nil {
128
+				this.ErrorLog("获取%v月活跃机构数失败:%v", m, getActiveOrgCountErr)
129
+			}
130
+			monthActiveOrgCounts = append(monthActiveOrgCounts, map[string]interface{}{
131
+				"month": m,
132
+				"count": activeOrgCount,
133
+			})
134
+		}
135
+	}
136
+
137
+	activeOrgsThisWeek, getActiveOrgThisWeekErr := service.GetActiveOrgsFromDayToDay(monday, sunday)
138
+	if getActiveOrgThisWeekErr != nil {
139
+		this.ErrorLog("获取本周活跃机构失败:%v", getActiveOrgThisWeekErr)
140
+		activeOrgsThisWeek = make([]*service.ActiveOrgListVM, 0)
141
+	}
142
+
143
+	activeOrgsThisMonth, getActiveOrgThisMonthErr := service.GetActiveOrgsFromDayToDay(beginningOfMonth, endOfMonth)
144
+	if getActiveOrgThisMonthErr != nil {
145
+		this.ErrorLog("获取本月活跃机构失败:%v", getActiveOrgThisMonthErr)
146
+		activeOrgsThisMonth = make([]*service.ActiveOrgListVM, 0)
147
+	}
148
+
149
+	this.ServeSuccessJSON(map[string]interface{}{
150
+		"active_org_count_today":  activeOrgCountToday,
151
+		"active_org_count_week":   activeOrgCountThisWeek,
152
+		"active_org_count_month":  activeOrgCountThisMonth,
153
+		"active_org_count_months": monthActiveOrgCounts,
154
+		"active_orgs_week":        activeOrgsThisWeek,
155
+		"active_orgs_month":       activeOrgsThisMonth,
156
+	})
157
+}
158
+
159
+// /admin/api/user/active [get] ActiveUser
160
+func (this *AnalysisAPIController) ActiveUser() {
161
+	now := time.Now()
162
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
163
+	activeAdminCountToday, getActiveTodayErr := service.GetActiveAdminUserCountFromDayToDay(zeroHourTimeOfToday, now)
164
+	if getActiveTodayErr != nil {
165
+		this.ErrorLog("获取今日活跃账户数失败:%v", getActiveTodayErr)
166
+	}
167
+
168
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
169
+	activeAdminCountThisWeek, getActiveAdminCountThisWeekErr := service.GetActiveAdminUserCountFromDayToDay(monday, sunday)
170
+	if getActiveAdminCountThisWeekErr != nil {
171
+		this.ErrorLog("获取本周活跃账户数失败:%v", getActiveAdminCountThisWeekErr)
172
+	}
173
+
174
+	thisYear := now.Year()
175
+	thisMonth := int(now.Month())
176
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
177
+	activeAdminCountThisMonth, getActiveAdminCountThisMonthErr := service.GetActiveAdminUserCountFromDayToDay(beginningOfMonth, endOfMonth)
178
+	if getActiveAdminCountThisMonthErr != nil {
179
+		this.ErrorLog("获取本月活跃账户数失败:%v", getActiveAdminCountThisMonthErr)
180
+	}
181
+
182
+	monthActiveAdminCounts := make([]map[string]interface{}, 0, 12)
183
+	for m := 1; m < 12; m++ {
184
+		if m > thisMonth {
185
+			break
186
+		}
187
+		if m == thisMonth {
188
+			monthActiveAdminCounts = append(monthActiveAdminCounts, map[string]interface{}{
189
+				"month": m,
190
+				"count": activeAdminCountThisMonth,
191
+			})
192
+
193
+		} else {
194
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
195
+			activeAdminCount, getActiveAdminCountErr := service.GetActiveAdminUserCountFromDayToDay(BOM, EOM)
196
+			if getActiveAdminCountErr != nil {
197
+				this.ErrorLog("获取%v月活跃账户数失败:%v", m, getActiveAdminCountErr)
198
+			}
199
+			monthActiveAdminCounts = append(monthActiveAdminCounts, map[string]interface{}{
200
+				"month": m,
201
+				"count": activeAdminCount,
202
+			})
203
+		}
204
+	}
205
+
206
+	activeAdminsThisWeek, getActiveAdminThisWeekErr := service.GetActiveAdminUsersFromDayToDay(monday, sunday)
207
+	if getActiveAdminThisWeekErr != nil {
208
+		this.ErrorLog("获取本周活跃账户失败:%v", getActiveAdminThisWeekErr)
209
+		activeAdminsThisWeek = make([]*service.ActiveAdminUserListVM, 0)
210
+	}
211
+
212
+	activeAdminsThisMonth, getActiveAdminThisMonthErr := service.GetActiveAdminUsersFromDayToDay(beginningOfMonth, endOfMonth)
213
+	if getActiveAdminThisMonthErr != nil {
214
+		this.ErrorLog("获取本月活跃账户失败:%v", getActiveAdminThisMonthErr)
215
+		activeAdminsThisMonth = make([]*service.ActiveAdminUserListVM, 0)
216
+	}
217
+
218
+	this.ServeSuccessJSON(map[string]interface{}{
219
+		"active_admin_count_today":  activeAdminCountToday,
220
+		"active_admin_count_week":   activeAdminCountThisWeek,
221
+		"active_admin_count_month":  activeAdminCountThisMonth,
222
+		"active_admin_count_months": monthActiveAdminCounts,
223
+		"active_admins_week":        activeAdminsThisWeek,
224
+		"active_admins_month":       activeAdminsThisMonth,
225
+	})
226
+}
227
+
228
+// /admin/api/org/expiring [get] ExpiringOrg
229
+func (this *AnalysisAPIController) ExpiringOrg() {
230
+	now := time.Now()
231
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
232
+	// endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
233
+	timeAfter15Days := zeroHourTimeOfToday.AddDate(0, 0, 15)
234
+	timeBefore15Days := zeroHourTimeOfToday.AddDate(0, 0, -15)
235
+
236
+	countOfWillExpireOrg, getWillExpireOrgCountErr := service.GetWillExpireOrgCountFromDayToDay(zeroHourTimeOfToday, timeAfter15Days)
237
+	if getWillExpireOrgCountErr != nil {
238
+		this.ErrorLog("获取即将到期机构数失败:%v", getWillExpireOrgCountErr)
239
+	}
240
+
241
+	countOfExpiredOrg, getExpiredOrgCountErr := service.GetDidExpiredOrgCountFromDayToDay(timeBefore15Days, zeroHourTimeOfToday)
242
+	if getExpiredOrgCountErr != nil {
243
+		this.ErrorLog("获取刚到期机构数失败:%v", getExpiredOrgCountErr)
244
+	}
245
+
246
+	willExpireOrgs, getWillExpireOrgsErr := service.GetWillExpireOrgsFromDayToDay(zeroHourTimeOfToday, timeAfter15Days)
247
+	if getWillExpireOrgsErr != nil {
248
+		this.ErrorLog("获取即将到期机构失败:%v", getWillExpireOrgsErr)
249
+		willExpireOrgs = make([]*service.ExpireOrgListVM, 0, 0)
250
+	}
251
+
252
+	expiredOrgs, getExpiredOrgsErr := service.GetDidExpireOrgsFromDayToDay(timeBefore15Days, zeroHourTimeOfToday)
253
+	if getExpiredOrgsErr != nil {
254
+		this.ErrorLog("获取已到期机构失败:%v", getExpiredOrgsErr)
255
+		expiredOrgs = make([]*service.ExpireOrgListVM, 0, 0)
256
+	}
257
+
258
+	this.ServeSuccessJSON(map[string]interface{}{
259
+		"will_expire_org_count": countOfWillExpireOrg,
260
+		"did_expired_org_count": countOfExpiredOrg,
261
+		"will_expire_orgs":      willExpireOrgs,
262
+		"did_expired_orgs":      expiredOrgs,
263
+	})
264
+}
265
+
266
+// /admin/api/dialysis/analysis [get] DialysisAnalysis
267
+func (this *AnalysisAPIController) DialysisAnalysis() {
268
+	now := time.Now()
269
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
270
+	endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
271
+
272
+	timesToday, getTimesTodayErr := service.GetDialysisTimesFromDayToDay(zeroHourTimeOfToday, endTimeOfToday)
273
+	if getTimesTodayErr != nil {
274
+		this.ErrorLog("获取今日透析次数失败:%v", getTimesTodayErr)
275
+	}
276
+
277
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
278
+	timesThisWeek, getTimesThisWeekErr := service.GetDialysisTimesFromDayToDay(monday, sunday)
279
+	if getTimesThisWeekErr != nil {
280
+		this.ErrorLog("获取本周透析次数失败:%v", getTimesThisWeekErr)
281
+	}
282
+
283
+	thisYear := now.Year()
284
+	thisMonth := int(now.Month())
285
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
286
+	timesThisMonth, getTimesThisMonthErr := service.GetDialysisTimesFromDayToDay(beginningOfMonth, endOfMonth)
287
+	if getTimesThisMonthErr != nil {
288
+		this.ErrorLog("获取本月透析次数失败:%v", getTimesThisMonthErr)
289
+	}
290
+
291
+	monthTimes := make([]map[string]interface{}, 0, 12)
292
+	for m := 1; m < 12; m++ {
293
+		if m > thisMonth {
294
+			break
295
+		}
296
+		if m == thisMonth {
297
+			monthTimes = append(monthTimes, map[string]interface{}{
298
+				"month": m,
299
+				"count": timesThisMonth,
300
+			})
301
+
302
+		} else {
303
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
304
+			times, getTimesErr := service.GetDialysisTimesFromDayToDay(BOM, EOM)
305
+			if getTimesErr != nil {
306
+				this.ErrorLog("获取%v月透析次数失败:%v", m, getTimesErr)
307
+			}
308
+			monthTimes = append(monthTimes, map[string]interface{}{
309
+				"month": m,
310
+				"count": times,
311
+			})
312
+		}
313
+	}
314
+
315
+	this.ServeSuccessJSON(map[string]interface{}{
316
+		"times_today":  timesToday,
317
+		"times_week":   timesThisWeek,
318
+		"times_month":  timesThisMonth,
319
+		"times_months": monthTimes,
320
+	})
321
+}
322
+
323
+// /admin/api/monitor/analysis [get] MonitorAnalysis
324
+func (this *AnalysisAPIController) MonitorAnalysis() {
325
+	now := time.Now()
326
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
327
+	endTimeOfToday := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 59, 999, time.Local)
328
+
329
+	timesToday, getTimesTodayErr := service.GetMonitoringTimesFromDayToDay(zeroHourTimeOfToday, endTimeOfToday)
330
+	if getTimesTodayErr != nil {
331
+		this.ErrorLog("获取今日监控次数失败:%v", getTimesTodayErr)
332
+	}
333
+
334
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
335
+	timesThisWeek, getTimesThisWeekErr := service.GetMonitoringTimesFromDayToDay(monday, sunday)
336
+	if getTimesThisWeekErr != nil {
337
+		this.ErrorLog("获取本周监控次数失败:%v", getTimesThisWeekErr)
338
+	}
339
+
340
+	thisYear := now.Year()
341
+	thisMonth := int(now.Month())
342
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
343
+	timesThisMonth, getTimesThisMonthErr := service.GetMonitoringTimesFromDayToDay(beginningOfMonth, endOfMonth)
344
+	if getTimesThisMonthErr != nil {
345
+		this.ErrorLog("获取本月监控次数失败:%v", getTimesThisMonthErr)
346
+	}
347
+
348
+	monthTimes := make([]map[string]interface{}, 0, 12)
349
+	for m := 1; m < 12; m++ {
350
+		if m > thisMonth {
351
+			break
352
+		}
353
+		if m == thisMonth {
354
+			monthTimes = append(monthTimes, map[string]interface{}{
355
+				"month": m,
356
+				"count": timesThisMonth,
357
+			})
358
+
359
+		} else {
360
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
361
+			times, getTimesErr := service.GetMonitoringTimesFromDayToDay(BOM, EOM)
362
+			if getTimesErr != nil {
363
+				this.ErrorLog("获取%v月监控次数失败:%v", m, getTimesErr)
364
+			}
365
+			monthTimes = append(monthTimes, map[string]interface{}{
366
+				"month": m,
367
+				"count": times,
368
+			})
369
+		}
370
+	}
371
+
372
+	this.ServeSuccessJSON(map[string]interface{}{
373
+		"times_today":  timesToday,
374
+		"times_week":   timesThisWeek,
375
+		"times_month":  timesThisMonth,
376
+		"times_months": monthTimes,
377
+	})
378
+}
379
+
380
+// /admin/api/patient/analysis [get] PatientAnalysis
381
+func (this *AnalysisAPIController) PatientAnalysis() {
382
+	now := time.Now()
383
+	zeroHourTimeOfToday := utils.ZeroHourTimeOfDay(now)
384
+	newCountToday, getNewCountTodayErr := service.GetNewPatientCountFromDayToDay(zeroHourTimeOfToday, now)
385
+	if getNewCountTodayErr != nil {
386
+		this.ErrorLog("获取今日新增病人数失败:%v", getNewCountTodayErr)
387
+	}
388
+
389
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
390
+	newCountThisWeek, getNewCountThisWeekErr := service.GetNewPatientCountFromDayToDay(monday, sunday)
391
+	if getNewCountThisWeekErr != nil {
392
+		this.ErrorLog("获取本周新增病人数失败:%v", getNewCountThisWeekErr)
393
+	}
394
+
395
+	thisYear := now.Year()
396
+	thisMonth := int(now.Month())
397
+	beginningOfMonth, endOfMonth := utils.MonthBeginningToEnd(thisYear, thisMonth)
398
+	newCountThisMonth, getNewCountThisMonthErr := service.GetNewPatientCountFromDayToDay(beginningOfMonth, endOfMonth)
399
+	if getNewCountThisMonthErr != nil {
400
+		this.ErrorLog("获取本月新增病人数失败:%v", getNewCountThisMonthErr)
401
+	}
402
+
403
+	monthNewCounts := make([]map[string]interface{}, 0, 12)
404
+	for m := 1; m < 12; m++ {
405
+		if m > thisMonth {
406
+			break
407
+		}
408
+		if m == thisMonth {
409
+			monthNewCounts = append(monthNewCounts, map[string]interface{}{
410
+				"month": m,
411
+				"count": newCountThisMonth,
412
+			})
413
+
414
+		} else {
415
+			BOM, EOM := utils.MonthBeginningToEnd(thisYear, m)
416
+			newCount, getNewCountErr := service.GetNewPatientCountFromDayToDay(BOM, EOM)
417
+			if getNewCountErr != nil {
418
+				this.ErrorLog("获取%v月新增病人数失败:%v", m, getNewCountErr)
419
+			}
420
+			monthNewCounts = append(monthNewCounts, map[string]interface{}{
421
+				"month": m,
422
+				"count": newCount,
423
+			})
424
+		}
425
+	}
426
+
427
+	maleCount, femaleCount, unknowGenderCount, getGenderCountErr := service.GetPatientGenderDistribution()
428
+	if getGenderCountErr != nil {
429
+		this.ErrorLog("获取病人性别分布失败:%v", getGenderCountErr)
430
+	}
431
+
432
+	// 1乙肝 2丙肝 3艾滋病 4肺结核 5梅毒
433
+	// 不写错误日志了,累了
434
+	normalPCount, _ := service.GetInfectiousDiseasePatientCount(0)
435
+	type1PCount, _ := service.GetInfectiousDiseasePatientCount(1)
436
+	type2PCount, _ := service.GetInfectiousDiseasePatientCount(2)
437
+	type3PCount, _ := service.GetInfectiousDiseasePatientCount(3)
438
+	type4PCount, _ := service.GetInfectiousDiseasePatientCount(4)
439
+	type5PCount, _ := service.GetInfectiousDiseasePatientCount(5)
440
+
441
+	ageDistribution, getAgeDistributionErr := service.GetPatientAgeDistribution()
442
+	if getAgeDistributionErr != nil {
443
+		this.ErrorLog("获取病人年龄分布失败:%v", getAgeDistributionErr)
444
+		ageDistribution = make([]*service.PatientAgeCountStruct, 0, 0)
445
+	}
446
+
447
+	this.ServeSuccessJSON(map[string]interface{}{
448
+		"new_patient_count_today":  newCountToday,
449
+		"new_patient_count_week":   newCountThisWeek,
450
+		"new_patient_count_month":  newCountThisMonth,
451
+		"new_patient_count_months": monthNewCounts,
452
+
453
+		"male_count":   maleCount,
454
+		"female_count": femaleCount,
455
+		"total_count":  maleCount + femaleCount + unknowGenderCount,
456
+
457
+		"disease_type_0_count": normalPCount,
458
+		"disease_type_1_count": type1PCount,
459
+		"disease_type_2_count": type2PCount,
460
+		"disease_type_3_count": type3PCount,
461
+		"disease_type_4_count": type4PCount,
462
+		"disease_type_5_count": type5PCount,
463
+
464
+		"age_counts": ageDistribution,
465
+	})
466
+}

+ 35 - 0
controllers/admin_api_controllers/login_api_controller.go View File

@@ -0,0 +1,35 @@
1
+package admin_api_controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+)
7
+
8
+type LoginAPIController struct {
9
+	AdminBaseAPIController
10
+}
11
+
12
+// /admin/api/login/pwd [post] LoginByPwd
13
+// @param account:string
14
+// @param password:string
15
+func (this *LoginAPIController) LoginByPwd() {
16
+	account := this.GetString("account")
17
+	password := this.GetString("password")
18
+
19
+	admin, getAdminErr := service.GetAdminAccount(account, password)
20
+	if getAdminErr != nil {
21
+		this.ErrorLog("获取管理员信息失败:%v", getAdminErr)
22
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
23
+		return
24
+	} else if admin == nil {
25
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
26
+		return
27
+	}
28
+
29
+	this.SetSession("admin_info", &AdminInfo{
30
+		Admin: admin,
31
+	})
32
+	this.ServeSuccessJSON(map[string]interface{}{
33
+		"admin": admin,
34
+	})
35
+}

File diff suppressed because it is too large
+ 2223 - 0
controllers/advice_template.json


+ 219 - 0
controllers/base_api_controller.go View File

@@ -0,0 +1,219 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+)
7
+
8
+type BaseAPIController struct {
9
+	BaseController
10
+}
11
+
12
+// func (this *BaseAPIController) Prepare() {
13
+// 	this.BaseController.Prepare()
14
+// 	beego.Trace("============================================================")
15
+// 	beego.Trace("session ID: %v", this.Ctx.Input.Cookie("beegosessionID"))
16
+// 	beego.Trace("session : %v", this.GetSession("info"))
17
+// 	this.SetSession("info", time.Now().Format("2006/01/02 15:04:05"))
18
+// 	beego.Trace("============================================================")
19
+// }
20
+
21
+// 输出数据格式化
22
+/*
23
+	success json:
24
+	{
25
+		"state": 1,
26
+		"code": 0,
27
+		"data": json,
28
+	}
29
+
30
+	fail json:
31
+	{
32
+		"state": 0,
33
+		"code": int,
34
+		"msg": string,
35
+	}
36
+*/
37
+func (this *BaseAPIController) ServeSuccessJSON(data map[string]interface{}) {
38
+	this.Data["json"] = enums.MakeSuccessResponseJSON(data)
39
+	this.ServeJSON()
40
+}
41
+
42
+func (this *BaseAPIController) ServeFailJSONWithSGJErrorCode(code int) {
43
+	this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(code)
44
+	this.ServeJSON()
45
+}
46
+
47
+func (this *BaseAPIController) ServeFailJSONWithSGJError(err *enums.SGJError) {
48
+	this.Data["json"] = enums.MakeFailResponseJSONWithSGJError(err)
49
+	this.ServeJSON()
50
+}
51
+
52
+func (this *BaseAPIController) ServeFailJsonSend(code int, msg string) {
53
+	this.Data["json"] = enums.MakeFailResponseJSON(msg, code)
54
+	this.ServeJSON()
55
+}
56
+
57
+type BaseAuthAPIController struct {
58
+	BaseAPIController
59
+}
60
+
61
+func (this *BaseAuthAPIController) Prepare() {
62
+	this.BaseAPIController.Prepare()
63
+	if this.GetAdminUserInfo() == nil {
64
+		//var userAdmin models.AdminUser
65
+		//userAdmin.Id = 380
66
+		//userAdmin.Mobile = "13532250447"
67
+		//userAdmin.IsSuperAdmin = true
68
+		//userAdmin.Status = 1
69
+		//userAdmin.CreateTime = 1530786071
70
+		//userAdmin.ModifyTime = 1530786071
71
+		//var subscibe models.ServeSubscibe
72
+		//subscibe.ID = 1
73
+		//subscibe.OrgId = 4
74
+		//subscibe.PeriodStart = 1538035409
75
+		//subscibe.PeriodEnd = 1569571409
76
+		//subscibe.State = 1
77
+		//subscibe.Status = 1
78
+		//subscibe.CreatedTime = 1538035409
79
+		//subscibe.UpdatedTime = 1538035409
80
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
81
+		//subscibes[4] = &subscibe
82
+		//
83
+		//var template models.GobalTemplate
84
+		//template.TemplateId = 2
85
+		//
86
+		//
87
+		//var adminUserInfo service.AdminUserInfo
88
+		//adminUserInfo.CurrentOrgId = 4
89
+		//adminUserInfo.CurrentAppId = 5
90
+		//adminUserInfo.AdminUser = &userAdmin
91
+		//adminUserInfo.Subscibes = subscibes
92
+		//this.SetSession("admin_user_info", &adminUserInfo)
93
+
94
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
95
+		this.StopRun()
96
+	}
97
+
98
+	if this.Ctx.Request.Method != "GET" {
99
+		adminUserInfo := this.GetAdminUserInfo()
100
+
101
+		err := service.GetOrgSubscibeState(adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId])
102
+		if err != nil || adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId].State == 3 {
103
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSubscibe)
104
+			this.StopRun()
105
+		}
106
+	}
107
+
108
+	//if this.Ctx.Request.Header.Get("Permission") == "1" {
109
+	//
110
+	//	isPermission := false
111
+	//	roles := []int64{1,2}		//模拟该用户有多少角色
112
+	//	var targetRole models.RolePurview
113
+	//	var userRolePurview []string
114
+	//
115
+	//	//用户角色1对应的权限
116
+	//	role1 := models.RolePurview{PurviewIds:"11,12,13"}
117
+	//
118
+	//	//用户角色2对应的权限
119
+	//	role2 := models.RolePurview{PurviewIds:"11,15,16"}
120
+	//
121
+	//
122
+	//	//模拟角色2
123
+	//	//判断该用户有多少个角色,合并最大角色权限
124
+	//	if len(roles) == 1{ //单个
125
+	//		targetRole = role1
126
+	//		userRolePurview = strings.Split(targetRole.PurviewIds, ",")
127
+	//
128
+	//	}else{ //多个
129
+	//		targetRole = role1
130
+	//		targetRole.PurviewIds = targetRole.PurviewIds + "," + role2.PurviewIds
131
+	//		userRolePurview = strings.Split(targetRole.PurviewIds, ",")
132
+	//	}
133
+	//
134
+	//	userRolePurview = RemoveRepeatedElement2(userRolePurview)
135
+	//
136
+	//	fmt.Println(userRolePurview)
137
+	//	//所有权限列表
138
+	//	allPermission := []models.Purview{{Id:10,Urlfor:"/m/api/dialysis/dialysisPrescription-/api/dialysis/prescription"},
139
+	//		{Id:11,Urlfor:"/m/api/dialysis/dialysisPrescription1-/api/dialysis/prescription1"},
140
+	//		{Id:12,Urlfor:"/m/api/dialysis/dialysisPrescription2-/api/dialysis/prescription2"},
141
+	//		{Id:13,Urlfor:"/m/api/dialysis/dialysisPrescription3-/api/dialysis/prescription3"},
142
+	//		{Id:14,Urlfor:"/m/api/dialysis/dialysisPrescription4-/api/dialysis/prescription4"},
143
+	//		{Id:15,Urlfor:"/m/api/dialysis/dialysisPrescription5-/api/dialysis/prescription5"},
144
+	//		{Id:16,Urlfor:"/m/api/dialysis/dialysisPrescription6-/api/dialysis/prescription6"}}
145
+	//	for _, item := range allPermission {
146
+	//		//判断当前路由是否在权限路由列表里面
147
+	//		if strings.Split(item.Urlfor, "-")[1] == strings.Split(this.Ctx.Request.RequestURI , "?")[0]{
148
+	//			fmt.Println(strings.Split(this.Ctx.Request.RequestURI , "?")[0])
149
+	//
150
+	//			//获取该角色的所有权限
151
+	//			for _, items := range userRolePurview{
152
+	//				id, _ := strconv.ParseInt(items, 10, 64)
153
+	//				if id == item.Id{
154
+	//					isPermission = true
155
+	//				}
156
+	//			}
157
+	//			if !isPermission{
158
+	//				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreExist)
159
+	//				this.StopRun()
160
+	//			}
161
+	//		}
162
+	//
163
+	//	}
164
+	//}
165
+}
166
+
167
+type BaseServeAPIController struct {
168
+	BaseAPIController
169
+}
170
+
171
+func (this *BaseServeAPIController) Prepare() {
172
+	this.BaseAPIController.Prepare()
173
+	if this.GetAdminUserInfo() == nil {
174
+		//var userAdmin models.AdminUser
175
+		//userAdmin.Id = 380
176
+		//userAdmin.Mobile = "13532250447"
177
+		//userAdmin.IsSuperAdmin = true
178
+		//userAdmin.Status = 1
179
+		//userAdmin.CreateTime = 1530786071
180
+		//userAdmin.ModifyTime = 1530786071
181
+		//var subscibe models.ServeSubscibe
182
+		//subscibe.ID = 1
183
+		//subscibe.OrgId = 4
184
+		//subscibe.PeriodStart = 1538035409
185
+		//subscibe.PeriodEnd = 1569571409
186
+		//subscibe.State = 1
187
+		//subscibe.Status = 1
188
+		//subscibe.CreatedTime = 1538035409
189
+		//subscibe.UpdatedTime = 1538035409
190
+		//subscibes := make(map[int64]*models.ServeSubscibe, 0)
191
+		//subscibes[4] = &subscibe
192
+		//var adminUserInfo service.AdminUserInfo
193
+		//adminUserInfo.CurrentOrgId = 4
194
+		//adminUserInfo.CurrentAppId = 5
195
+		//adminUserInfo.AdminUser = &userAdmin
196
+		//adminUserInfo.Subscibes = subscibes
197
+		//this.SetSession("admin_user_info", &adminUserInfo)
198
+
199
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
200
+		this.StopRun()
201
+	}
202
+}
203
+
204
+func RemoveRepeatedElement2(arr []string) (newArr []string) {
205
+	newArr = make([]string, 0)
206
+	for i := 0; i < len(arr); i++ {
207
+		repeat := false
208
+		for j := i + 1; j < len(arr); j++ {
209
+			if arr[i] == arr[j] {
210
+				repeat = true
211
+				break
212
+			}
213
+		}
214
+		if !repeat {
215
+			newArr = append(newArr, arr[i])
216
+		}
217
+	}
218
+	return
219
+}

+ 40 - 0
controllers/base_controller.go View File

@@ -0,0 +1,40 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/service"
5
+
6
+	"github.com/astaxie/beego"
7
+)
8
+
9
+type BaseController struct {
10
+	beego.Controller
11
+}
12
+
13
+func (this *BaseController) GetAdminUserInfo() *service.AdminUserInfo {
14
+	userInfo := this.GetSession("admin_user_info")
15
+	if userInfo == nil {
16
+		return nil
17
+	} else {
18
+		return userInfo.(*service.AdminUserInfo)
19
+	}
20
+}
21
+
22
+func (this *BaseController) ErrorLog(format string, a ...interface{}) {
23
+	//beego.Error(fmt.Sprintf(format, a...))
24
+}
25
+
26
+func (this *BaseController) WarnLog(format string, a ...interface{}) {
27
+	//beego.Warn(fmt.Sprintf(format, a...))
28
+}
29
+
30
+func (this *BaseController) InfoLog(format string, a ...interface{}) {
31
+	//beego.Info(fmt.Sprintf(format, a...))
32
+}
33
+
34
+func (this *BaseController) DebugLog(format string, a ...interface{}) {
35
+	//beego.Debug(fmt.Sprintf(format, a...))
36
+}
37
+
38
+func (this *BaseController) TraceLog(format string, a ...interface{}) {
39
+	//beego.Trace(fmt.Sprintf(format, a...))
40
+}

+ 58 - 0
controllers/base_view_controller.go View File

@@ -0,0 +1,58 @@
1
+package controllers
2
+
3
+type BaseViewController struct {
4
+	BaseController
5
+}
6
+
7
+// 设置模板
8
+// 第一个参数模板,第二个参数为layout
9
+func (this *BaseViewController) SetTpl(template ...string) {
10
+	var tplName string
11
+	layout := ""
12
+	switch {
13
+	case len(template) == 1:
14
+		tplName = template[0]
15
+	case len(template) == 2:
16
+		tplName = template[0]
17
+		layout = template[1]
18
+	default:
19
+		tplName = "index.tpl"
20
+	}
21
+	this.Layout = layout
22
+	this.TplName = tplName
23
+}
24
+
25
+// 重定向
26
+func (this *BaseViewController) Redirect302(url string) {
27
+	this.Redirect(url, 302)
28
+	this.StopRun()
29
+}
30
+
31
+// 错误页面
32
+func (this *BaseViewController) Abort404() {
33
+	this.Abort("404")
34
+}
35
+
36
+// // 微信错误页面
37
+// func (this *BaseViewController) WxAbort404(title, desc string) {
38
+// 	this.Data["Title"] = title
39
+// 	this.Data["Desc"] = desc
40
+// 	this.SetTpl("view_wx/error/404.html")
41
+// }
42
+
43
+// type BaseAuthViewController struct {
44
+// 	BaseViewController
45
+// }
46
+
47
+// func (this *BaseAuthViewController) Prepare() {
48
+// 	this.BaseController.Prepare()
49
+// 	backUrl := utils.SetThisRequestURI(this.Ctx.Request.RequestURI)
50
+// 	backUrl = base64.URLEncoding.EncodeToString([]byte(backUrl))
51
+// 	if this.GetUserInfo() == nil {
52
+// 		if strings.HasPrefix(this.Ctx.Request.RequestURI, "/web/") {
53
+// 			this.Redirect302(beego.URLFor("WebLoginViewController.Login") + "?backUrl=" + backUrl)
54
+// 		} else {
55
+// 			this.Redirect302(beego.URLFor("WxLoginViewController.Login") + "?backUrl=" + backUrl)
56
+// 		}
57
+// 	}
58
+// }

File diff suppressed because it is too large
+ 1415 - 0
controllers/data_api_controller.go


+ 15 - 0
controllers/default.go View File

@@ -0,0 +1,15 @@
1
+package controllers
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+)
6
+
7
+type MainController struct {
8
+	beego.Controller
9
+}
10
+
11
+func (c *MainController) Get() {
12
+	c.Data["Website"] = "beego.me"
13
+	c.Data["Email"] = "astaxie@gmail.com"
14
+	c.TplName = "index.tpl"
15
+}

File diff suppressed because it is too large
+ 1184 - 0
controllers/device_api_controller.go


File diff suppressed because it is too large
+ 4923 - 0
controllers/dialysis_api_controller.go


+ 58 - 0
controllers/dialysis_board_api_controller.go View File

@@ -0,0 +1,58 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"XT_New/utils"
7
+	"time"
8
+
9
+	"github.com/astaxie/beego"
10
+)
11
+
12
+func DialysisBoardAPIControllerRegistRouter() {
13
+	beego.Router("/api/dialysis/board", &DialysisBoardAPIController{}, "get:BoardData")
14
+}
15
+
16
+type DialysisBoardAPIController struct {
17
+	BaseAuthAPIController
18
+}
19
+
20
+func (c *DialysisBoardAPIController) BoardData() {
21
+	page, _ := c.GetInt64("page", 0)
22
+	if page <= 0 {
23
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
24
+		return
25
+	}
26
+	nowTimeUinx := time.Now()
27
+	today := nowTimeUinx.Format("2006-01-02")
28
+	week := nowTimeUinx.Weekday()
29
+
30
+	timeLayout := "2006-01-02"
31
+	loc, _ := time.LoadLocation("Local")
32
+
33
+	todayTime, err := time.ParseInLocation(timeLayout, today, loc)
34
+	if err != nil {
35
+		utils.ErrorLog("%v", err)
36
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
37
+		return
38
+	}
39
+	var limit int64 = 10
40
+	offset := (page - 1) * limit
41
+	todayTimeStamp := todayTime.Unix()
42
+
43
+	adminUserInfo := c.GetAdminUserInfo()
44
+
45
+	boards, err := service.GetDialysisBoard(adminUserInfo.CurrentOrgId, todayTimeStamp, offset, limit)
46
+	if err != nil {
47
+		utils.ErrorLog("%v", err)
48
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
49
+		return
50
+	}
51
+
52
+	c.ServeSuccessJSON(map[string]interface{}{
53
+		"today":  today,
54
+		"week":   week,
55
+		"boards": boards,
56
+	})
57
+
58
+}

File diff suppressed because it is too large
+ 2562 - 0
controllers/dialysis_record_api_controller.go


+ 25 - 0
controllers/district_api_controller.go View File

@@ -0,0 +1,25 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/service"
5
+
6
+	"github.com/astaxie/beego"
7
+)
8
+
9
+type DistrictApiController struct {
10
+	BaseAuthAPIController
11
+}
12
+
13
+func DistrictApiRegistRouters() {
14
+	beego.Router("/api/district/getdistrictsbyupid", &DistrictApiController{}, "get:GetDistrictsByUpid")
15
+}
16
+
17
+func (c *DistrictApiController) GetDistrictsByUpid() {
18
+	id, _ := c.GetInt64("id", 0)
19
+	citys, _ := service.GetDistrictsByUpid(id)
20
+
21
+	c.ServeSuccessJSON(map[string]interface{}{
22
+		"citys": citys,
23
+	})
24
+	return
25
+}

+ 194 - 0
controllers/doctors_api_controller.go View File

@@ -0,0 +1,194 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/service"
5
+
6
+	"XT_New/models"
7
+	"XT_New/utils"
8
+	"fmt"
9
+	"github.com/astaxie/beego"
10
+	"github.com/jinzhu/gorm"
11
+	"time"
12
+)
13
+
14
+type DoctorsApiController struct {
15
+	BaseAuthAPIController
16
+}
17
+
18
+func DoctorApiRegistRouters() {
19
+	beego.Router("/api/alldoctors", &DoctorsApiController{}, "get:GetAllDoctorAndNurse")
20
+	beego.Router("/api/admin/users", &DoctorsApiController{}, "get:GetAllAdminUsers")
21
+	beego.Router("/api/patient/getdryweightdata", &DoctorsApiController{}, "Get:GetDryWeightData")
22
+	beego.Router("/api/patient/getAllDoctor", &DoctorsApiController{}, "Get:GetAllDoctor")
23
+	beego.Router("/api/patient/updatedryweightdata", &DoctorsApiController{}, "Post:UpdatedDryWeightData")
24
+	beego.Router("/api/patient/getalldata", &DoctorsApiController{}, "Get:GetAllData")
25
+}
26
+
27
+func (c *DoctorsApiController) GetAllDoctorAndNurse() {
28
+
29
+	adminUserInfo := c.GetAdminUserInfo()
30
+	doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
31
+
32
+	c.ServeSuccessJSON(map[string]interface{}{
33
+		"doctors": doctors,
34
+		"nursers": nursers,
35
+	})
36
+	return
37
+}
38
+func (c *DoctorsApiController) GetAllAdminUsers() {
39
+
40
+	adminUserInfo := c.GetAdminUserInfo()
41
+	users, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
42
+	c.ServeSuccessJSON(map[string]interface{}{
43
+		"users": users,
44
+	})
45
+	return
46
+}
47
+
48
+func (c *DoctorsApiController) GetDryWeightData() {
49
+	adminUserInfo := c.GetAdminUserInfo()
50
+	orgid := adminUserInfo.CurrentOrgId
51
+
52
+	patientid, _ := c.GetInt64("patientid")
53
+	fmt.Println("patientid", patientid)
54
+	id := adminUserInfo.AdminUser.Id
55
+	fmt.Println("id", id)
56
+	recordDateStr := time.Now().Format("2006-01-02")
57
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
58
+	fmt.Scan("parseDateErr", parseDateErr)
59
+	nowtime := recordDate.Unix()
60
+	fmt.Println("nowtime", nowtime)
61
+	pre, err := service.GetDryWeightByPatientId(patientid, orgid)
62
+	fmt.Println("错误", err)
63
+	c.ServeSuccessJSON(map[string]interface{}{
64
+		"pre": pre,
65
+	})
66
+}
67
+
68
+func (c *DoctorsApiController) GetAllDoctor() {
69
+	adminUserInfo := c.GetAdminUserInfo()
70
+	orgid := adminUserInfo.CurrentOrgId
71
+	appid := adminUserInfo.CurrentAppId
72
+	fmt.Println("appid", appid)
73
+	appRole, err := service.GetAllDoctor(orgid, appid)
74
+	fmt.Println("appRole", appRole)
75
+	fmt.Println("错误", err)
76
+	c.ServeSuccessJSON(map[string]interface{}{
77
+		"appRole": appRole,
78
+	})
79
+}
80
+
81
+func (c *DoctorsApiController) UpdatedDryWeightData() {
82
+	adminUserInfo := c.GetAdminUserInfo()
83
+	orgid := adminUserInfo.CurrentOrgId
84
+	userid := adminUserInfo.AdminUser.Id
85
+	fmt.Println("userid", userid)
86
+	dry_weight, _ := c.GetFloat("dry_weight")
87
+	fmt.Println("dry_weight", dry_weight)
88
+	doctors, _ := c.GetInt64("doctors")
89
+	fmt.Println("doctors", doctors)
90
+	remarks := c.GetString("remarks")
91
+	fmt.Println("remarks", remarks)
92
+	patientid, _ := c.GetInt64("patient_id")
93
+	fmt.Println("patientid", patientid)
94
+	//透前数据
95
+	dryweight, _ := c.GetFloat("dryweight")
96
+	fmt.Println("dryweight", dryweight)
97
+	var weight = dryweight - dry_weight
98
+	weights := fmt.Sprintf("%.1f", weight)
99
+	//weights := strconv.FormatFloat(sprintf, 'E', -1, 64)
100
+
101
+	fmt.Println("weight", weights)
102
+	fmt.Println("weight", weight)
103
+	var sum string
104
+	dryWeight, errcode := service.QueryDryWeight(orgid, patientid)
105
+	fmt.Println("errcode", errcode)
106
+	fmt.Println("dryWeight", dryWeight)
107
+	if errcode == gorm.ErrRecordNotFound {
108
+		sum = "/"
109
+		patientDryweight := models.SgjPatientDryweight{
110
+			DryWeight:     dry_weight,
111
+			Creator:       doctors,
112
+			Remakes:       remarks,
113
+			AdjustedValue: sum,
114
+			PatientId:     patientid,
115
+			Ctime:         time.Now().Unix(),
116
+			UserOrgId:     orgid,
117
+			Status:        1,
118
+			UserId:        userid,
119
+		}
120
+
121
+		err := service.CreatePatientWeight(&patientDryweight)
122
+		fmt.Println("err", err)
123
+		c.ServeSuccessJSON(map[string]interface{}{
124
+			"patientDryweight": patientDryweight,
125
+		})
126
+		return
127
+	}
128
+	fmt.Println("sum", sum)
129
+	if weight == 0 {
130
+		sum = "/"
131
+	}
132
+	if weight > 0 {
133
+		sum = weights + "(" + "下调" + ")"
134
+
135
+	}
136
+	if weight < 0 {
137
+		var sums = dry_weight - dryweight
138
+		float := fmt.Sprintf("%.1f", sums)
139
+		//float := strconv.FormatFloat(sums, 'E', -1, 64)
140
+		sum = float + "(" + "上调" + ")"
141
+	}
142
+
143
+	patientDryweight := models.SgjPatientDryweight{
144
+		DryWeight:     dry_weight,
145
+		Creator:       doctors,
146
+		Remakes:       remarks,
147
+		AdjustedValue: sum,
148
+		PatientId:     patientid,
149
+		Ctime:         time.Now().Unix(),
150
+		UserOrgId:     orgid,
151
+		Status:        1,
152
+		UserId:        userid,
153
+	}
154
+
155
+	err := service.CreatePatientWeight(&patientDryweight)
156
+	//sgjPatientDryweight, _ := service.GetLastData(orgid)
157
+	//fmt.Println("fffffffffffffffffffffffffffffffffffffffffffff")
158
+	//fmt.Println("sgjPatientDryWeight",sgjPatientDryweight)s
159
+	recordDateStr := time.Now().Format("2006-01-02")
160
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
161
+	fmt.Scan("parseDateErr", parseDateErr)
162
+	nowtime := recordDate.Unix()
163
+	fmt.Println("nowtime", nowtime)
164
+	//prescription := models.PredialysisEvaluation{
165
+	//	DryWeight: dryweight,
166
+	//}
167
+	//errors := service.UpdateDialysisPrescription( sgjPatientDryweight.PatientId, sgjPatientDryweight.UserOrgId, sgjPatientDryweight.DryWeight, prescription)
168
+	//fmt.Println("error",errors)
169
+	fmt.Println("err", err)
170
+	fmt.Println("patientdryweight", patientDryweight)
171
+	c.ServeSuccessJSON(map[string]interface{}{
172
+		"patientDryweight": patientDryweight,
173
+	})
174
+}
175
+
176
+func (c *DoctorsApiController) GetAllData() {
177
+	id, _ := c.GetInt64("id")
178
+	page, _ := c.GetInt64("page")
179
+	fmt.Println("page", page)
180
+	limit, _ := c.GetInt64("limit")
181
+	fmt.Println("limit", limit)
182
+
183
+	fmt.Println("id", id)
184
+	adminUserInfo := c.GetAdminUserInfo()
185
+	orgid := adminUserInfo.CurrentOrgId
186
+	dry, total, err := service.GetAllData(orgid, id, page, limit)
187
+	fmt.Println("total是是多少", total)
188
+	fmt.Println("错误是什么", err)
189
+	fmt.Println("dry", err)
190
+	c.ServeSuccessJSON(map[string]interface{}{
191
+		"dry":   dry,
192
+		"total": total,
193
+	})
194
+}

+ 942 - 0
controllers/gobal_config_api_controller.go View File

@@ -0,0 +1,942 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"bytes"
9
+	"encoding/json"
10
+	"fmt"
11
+	"github.com/jinzhu/gorm"
12
+	"io/ioutil"
13
+	"log"
14
+	"os"
15
+	"path"
16
+	"reflect"
17
+	"regexp"
18
+	"runtime"
19
+	"strconv"
20
+	"time"
21
+
22
+	"github.com/astaxie/beego"
23
+)
24
+
25
+type GobalConfigApiController struct {
26
+	BaseAuthAPIController
27
+}
28
+
29
+func GobalConfigRegistRouters() {
30
+	beego.Router("/api/stock/automaticreduce/isopen", &GobalConfigApiController{}, "post:PostStockConfig")
31
+	beego.Router("/api/automaticreduce/get", &GobalConfigApiController{}, "get:GetConfig")
32
+
33
+	beego.Router("/api/print/template/commit", &GobalConfigApiController{}, "post:PostPrintTemplate")
34
+	beego.Router("/api/print/template/get", &GobalConfigApiController{}, "get:GetPrintTemplate")
35
+
36
+	beego.Router("/api/dataupload/config/commit", &GobalConfigApiController{}, "post:PostConfig")
37
+	beego.Router("/api/dataupload/config/modify", &GobalConfigApiController{}, "post:ModifyConfig")
38
+	beego.Router("/api/dataupload/config/get", &GobalConfigApiController{}, "get:GetDataUploadConfig")
39
+	beego.Router("/api/dataupload/is_docking/get", &GobalConfigApiController{}, "get:GetDataUploadIsDocking")
40
+
41
+	beego.Router("/api/adviceconfig/isopen", &GobalConfigApiController{}, "post:PostDoctorAdviceConfig")
42
+	beego.Router("/api/adviceconfig/get", &GobalConfigApiController{}, "get:GetDoctorAdviceConfig")
43
+
44
+	beego.Router("/api/advicetemplate/init/commit", &GobalConfigApiController{}, "post:PostInitAdviceTemplate")
45
+	beego.Router("/api/advicetemplate/init/get", &GobalConfigApiController{}, "get:GetAdviceInitConfig")
46
+
47
+	beego.Router("/api/systemprescription/commit", &GobalConfigApiController{}, "post:CreateSystemPrescription")
48
+	beego.Router("/api/systemprescription/update", &GobalConfigApiController{}, "post:UpdateSystemPrescription")
49
+
50
+	beego.Router("/api/systemprescription/all", &GobalConfigApiController{}, "get:GetAllSystemPrescription")
51
+	beego.Router("/api/systemprescription/get", &GobalConfigApiController{}, "get:GetSystemPrescription")
52
+
53
+	beego.Router("/api/advicetemplate/getprintinfo", &GobalConfigApiController{}, "post:GetPrintInfo")
54
+
55
+}
56
+
57
+//provinces, _ := service.GetDistrictsByUpid(0)21
58
+
59
+func (c *GobalConfigApiController) PostStockConfig() {
60
+	is_open, _ := c.GetInt64("is_open", 0)
61
+	adminUserInfo := c.GetAdminUserInfo()
62
+	org_id := adminUserInfo.CurrentOrgId
63
+	config := models.GobalConfig{
64
+		OrgId:        org_id,
65
+		IsOpen:       is_open,
66
+		Status:       1,
67
+		CreateTime:   time.Now().Unix(),
68
+		UpdateTime:   time.Now().Unix(),
69
+		IsOpenRemind: 0,
70
+	}
71
+
72
+	errs, configs := service.FindAutomaticReduceRecordByOrgId(org_id)
73
+
74
+	if errs == gorm.ErrRecordNotFound {
75
+		err := service.CreateAutomaticReduceRecord(&config)
76
+		if err != nil {
77
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
78
+			return
79
+		}
80
+
81
+	} else if errs == nil {
82
+		modifyConfig := models.GobalConfig{
83
+			ID:           configs.ID,
84
+			OrgId:        org_id,
85
+			IsOpen:       is_open,
86
+			Status:       1,
87
+			CreateTime:   time.Now().Unix(),
88
+			UpdateTime:   time.Now().Unix(),
89
+			IsOpenRemind: configs.IsOpenRemind,
90
+		}
91
+
92
+		err := service.UpdateAutomaticReduceRecord(&modifyConfig)
93
+		if err != nil {
94
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
95
+			return
96
+		}
97
+
98
+	}
99
+
100
+	c.ServeSuccessJSON(map[string]interface{}{
101
+		"is_open": is_open,
102
+	})
103
+
104
+	return
105
+}
106
+
107
+func (c *GobalConfigApiController) GetConfig() {
108
+	adminUserInfo := c.GetAdminUserInfo()
109
+	_, config := service.FindAutomaticReduceRecordByOrgId(adminUserInfo.CurrentOrgId)
110
+	c.ServeSuccessJSON(map[string]interface{}{
111
+		"config": config,
112
+	})
113
+}
114
+
115
+func (c *GobalConfigApiController) PostPrintTemplate() {
116
+	template_id, _ := c.GetInt64("template_id", 0)
117
+	adminUserInfo := c.GetAdminUserInfo()
118
+	org_id := adminUserInfo.CurrentOrgId
119
+	template := models.GobalTemplate{
120
+		OrgId:      org_id,
121
+		TemplateId: template_id,
122
+		Status:     1,
123
+		Ctime:      time.Now().Unix(),
124
+		Mtime:      time.Now().Unix(),
125
+	}
126
+
127
+	errs, templates := service.FindPrintTemplateByOrgId(org_id)
128
+
129
+	if errs == gorm.ErrRecordNotFound {
130
+		err := service.CreatePrintTemplateRecord(&template)
131
+		if err != nil {
132
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
133
+			return
134
+		}
135
+
136
+	} else if errs == nil {
137
+		templates := models.GobalTemplate{
138
+			ID:         templates.ID,
139
+			OrgId:      org_id,
140
+			TemplateId: template_id,
141
+			Status:     1,
142
+			Ctime:      templates.Ctime,
143
+			Mtime:      time.Now().Unix(),
144
+		}
145
+
146
+		err := service.UpdatePrintTemplate(&templates)
147
+		if err != nil {
148
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
149
+			return
150
+		}
151
+
152
+	}
153
+	c.ServeSuccessJSON(map[string]interface{}{
154
+		"template_id": template_id,
155
+	})
156
+	return
157
+}
158
+
159
+//func (c *GobalConfigApiController) PostPrintTemplate() {
160
+//	template_id, _ := c.GetInt64("template_id", 0)
161
+//	adminUserInfo := c.GetAdminUserInfo()
162
+//	org_id := adminUserInfo.CurrentOrgId
163
+//	template := models.GobalTemplate{
164
+//		OrgId:      org_id,
165
+//		TemplateId: template_id,
166
+//		Status:     1,
167
+//		Ctime:      time.Now().Unix(),
168
+//		Mtime:      time.Now().Unix(),
169
+//	}
170
+//
171
+//	errs, templates := service.FindPrintTemplateByOrgId(org_id)
172
+//
173
+//	if errs == gorm.ErrRecordNotFound {
174
+//		err := service.CreatePrintTemplateRecord(&template)
175
+//		if err != nil {
176
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
177
+//			return
178
+//		}
179
+//
180
+//		//if err == nil { //处理模版切换,显示配置处理逻辑
181
+//		//	//service.FindAllConfig
182
+//		//	//先将所有数据设置为显示
183
+//		//	updateErr := service.UpdateFiledConfig(adminUserInfo.CurrentOrgId)
184
+//		//	if updateErr == nil {
185
+//		//		//查出该模版对应显示配置字段中所有隐藏的字段
186
+//		//		_, config := service.FindAllHideFiledConfig(template_id)
187
+//		//
188
+//		//		var fileds []string
189
+//		//		for _, item := range config {
190
+//		//			fileds = append(fileds, item.FiledName)
191
+//		//		}
192
+//		//		service.UpdateShowFieldConfig(adminUserInfo.CurrentOrgId, fileds)
193
+//		//	}
194
+//		//
195
+//		//}
196
+//		//FiledList, _ := service.FindFiledByOrgId(adminUserInfo.CurrentOrgId)
197
+//		c.ServeSuccessJSON(map[string]interface{}{
198
+//			"template_id": template_id,
199
+//			//"fileds":      FiledList,
200
+//		})
201
+//
202
+//	} else if errs == nil {
203
+//		templates := models.GobalTemplate{
204
+//			ID:         templates.ID,
205
+//			OrgId:      org_id,
206
+//			TemplateId: template_id,
207
+//			Status:     1,
208
+//			Ctime:      templates.Ctime,
209
+//			Mtime:      time.Now().Unix(),
210
+//		}
211
+//
212
+//		err := service.UpdatePrintTemplate(&templates)
213
+//		if err != nil {
214
+//			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
215
+//			return
216
+//		}
217
+//
218
+//		if err == nil { //处理模版切换,显示配置处理逻辑
219
+//			//service.FindAllConfig
220
+//			//先将所有数据设置为显示
221
+//			updateErr := service.UpdateFiledConfig(adminUserInfo.CurrentOrgId)
222
+//			if updateErr == nil {
223
+//				//查出该模版对应显示配置字段中所有隐藏的字段
224
+//				_, config := service.FindAllHideFiledConfig(template_id)
225
+//				var fileds []string
226
+//				for _, item := range config {
227
+//					fileds = append(fileds, item.FiledName)
228
+//				}
229
+//				service.UpdateShowFieldConfig(adminUserInfo.CurrentOrgId, fileds)
230
+//
231
+//			}
232
+//
233
+//		}
234
+//		FiledList, _ := service.FindFiledByOrgId(adminUserInfo.CurrentOrgId)
235
+//		c.ServeSuccessJSON(map[string]interface{}{
236
+//			"template_id": template_id,
237
+//			"fileds":      FiledList,
238
+//		})
239
+//		return
240
+//	}
241
+//}
242
+
243
+func (c *GobalConfigApiController) GetPrintTemplate() {
244
+	adminUserInfo := c.GetAdminUserInfo()
245
+	_, template := service.FindPrintTemplateByOrgId(adminUserInfo.CurrentOrgId)
246
+	c.ServeSuccessJSON(map[string]interface{}{
247
+		"template": template,
248
+	})
249
+}
250
+
251
+func (c *GobalConfigApiController) PostConfig() {
252
+	gateway_address := c.GetString("gateway_address")
253
+	app_id := c.GetString("app_id")
254
+	key := c.GetString("key")
255
+	config_type, _ := c.GetInt64("config_type")
256
+	time_type, _ := c.GetInt64("time_type")
257
+	province, _ := c.GetInt64("province")
258
+	city, _ := c.GetInt64("city")
259
+
260
+	if config_type > 1 {
261
+		_, err := service.GetDockingStatus(config_type, province, city)
262
+		if err == gorm.ErrRecordNotFound {
263
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotDocking)
264
+			return
265
+		}
266
+	}
267
+
268
+	adminUserInfo := c.GetAdminUserInfo()
269
+	org_id := adminUserInfo.CurrentOrgId
270
+	config := &models.DataUploadConfig{
271
+		OrgId:          org_id,
272
+		ProvinceId:     province,
273
+		CityId:         city,
274
+		GatewayAddress: gateway_address,
275
+		AppId:          app_id,
276
+		Key:            key,
277
+		Status:         1,
278
+		CreateTime:     time.Now().Unix(),
279
+		ModifyTime:     time.Now().Unix(),
280
+		TimeQuantum:    time_type,
281
+		ConfigType:     config_type,
282
+	}
283
+	err := service.CreateConfigData(config)
284
+
285
+	if err == nil {
286
+		c.ServeSuccessJSON(map[string]interface{}{
287
+			"config": config,
288
+		})
289
+	} else {
290
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
291
+		return
292
+	}
293
+
294
+}
295
+
296
+func (c *GobalConfigApiController) GetDataUploadConfig() {
297
+	config_type, _ := c.GetInt64("config_type")
298
+	adminUserInfo := c.GetAdminUserInfo()
299
+	org_id := adminUserInfo.CurrentOrgId
300
+	config, err := service.GetConfigData(org_id, config_type)
301
+	fmt.Println(err)
302
+	if err == nil {
303
+		c.ServeSuccessJSON(map[string]interface{}{
304
+			"config": config,
305
+		})
306
+	} else {
307
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
308
+		return
309
+	}
310
+
311
+}
312
+
313
+func (c *GobalConfigApiController) GetDataUploadIsDocking() {
314
+	config_type, _ := c.GetInt64("config_type")
315
+	province, _ := c.GetInt64("province")
316
+	city, _ := c.GetInt64("city")
317
+
318
+	config, err := service.GetDockingStatus(config_type, province, city)
319
+	fmt.Println(config)
320
+	fmt.Println(err)
321
+	if err == gorm.ErrRecordNotFound {
322
+		c.ServeSuccessJSON(map[string]interface{}{
323
+			"is_docking": 2,
324
+		})
325
+
326
+	} else if err == nil {
327
+		if config.ID > 0 {
328
+			c.ServeSuccessJSON(map[string]interface{}{
329
+				"is_docking": 1,
330
+			})
331
+		} else {
332
+			c.ServeSuccessJSON(map[string]interface{}{
333
+				"is_docking": 2,
334
+			})
335
+
336
+		}
337
+	}
338
+}
339
+
340
+func (c *GobalConfigApiController) ModifyConfig() {
341
+	id, _ := c.GetInt64("id")
342
+	gateway_address := c.GetString("gateway_address")
343
+	app_id := c.GetString("app_id")
344
+	key := c.GetString("key")
345
+	config_type, _ := c.GetInt64("config_type")
346
+	time_type, _ := c.GetInt64("time_type")
347
+	province, _ := c.GetInt64("province")
348
+	city, _ := c.GetInt64("city")
349
+	adminUserInfo := c.GetAdminUserInfo()
350
+	org_id := adminUserInfo.CurrentOrgId
351
+
352
+	if config_type > 1 {
353
+		_, err := service.GetDockingStatus(config_type, province, city)
354
+		if err == gorm.ErrRecordNotFound {
355
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotDocking)
356
+			return
357
+		}
358
+	}
359
+
360
+	tempConfig, _ := service.GetConfigDataById(id)
361
+
362
+	config := &models.DataUploadConfig{
363
+		ID:             tempConfig.ID,
364
+		OrgId:          org_id,
365
+		ProvinceId:     province,
366
+		CityId:         city,
367
+		GatewayAddress: gateway_address,
368
+		AppId:          app_id,
369
+		Key:            key,
370
+		Status:         1,
371
+		CreateTime:     tempConfig.CreateTime,
372
+		ModifyTime:     time.Now().Unix(),
373
+		TimeQuantum:    time_type,
374
+		ConfigType:     config_type,
375
+	}
376
+	err := service.SaveConfigData(config)
377
+
378
+	if err == nil {
379
+		c.ServeSuccessJSON(map[string]interface{}{
380
+			"config": config,
381
+		})
382
+	} else {
383
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
384
+		return
385
+	}
386
+}
387
+
388
+func (c *GobalConfigApiController) PostDoctorAdviceConfig() {
389
+	is_open_remind, _ := c.GetInt64("is_open_remind", 0)
390
+	adminUserInfo := c.GetAdminUserInfo()
391
+	org_id := adminUserInfo.CurrentOrgId
392
+	config := models.DoctorAdviceConfig{
393
+		UserOrgId:    org_id,
394
+		IsOpenRemind: is_open_remind,
395
+		Status:       1,
396
+		CreateTime:   time.Now().Unix(),
397
+		UpdateTime:   time.Now().Unix(),
398
+	}
399
+
400
+	errs, configs := service.FindDoctorAdviceRecordByOrgId(org_id)
401
+
402
+	if errs == gorm.ErrRecordNotFound {
403
+		err := service.CreateDoctorAdviceRecord(&config)
404
+		if err != nil {
405
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
406
+			return
407
+		}
408
+
409
+	} else if errs == nil {
410
+		modifyConfig := models.DoctorAdviceConfig{
411
+			ID:           configs.ID,
412
+			UserOrgId:    org_id,
413
+			Status:       1,
414
+			CreateTime:   time.Now().Unix(),
415
+			UpdateTime:   time.Now().Unix(),
416
+			IsOpenRemind: is_open_remind,
417
+		}
418
+
419
+		err := service.UpdateDoctorAdviceRecord(&modifyConfig)
420
+		if err != nil {
421
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
422
+			return
423
+		}
424
+
425
+	}
426
+
427
+	c.ServeSuccessJSON(map[string]interface{}{
428
+		"is_open_remind": is_open_remind,
429
+	})
430
+
431
+	return
432
+}
433
+
434
+func (c *GobalConfigApiController) GetDoctorAdviceConfig() {
435
+	adminUserInfo := c.GetAdminUserInfo()
436
+	_, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
437
+	c.ServeSuccessJSON(map[string]interface{}{
438
+		"config": config,
439
+	})
440
+}
441
+
442
+//SF6090214798525
443
+func (c *GobalConfigApiController) Load(filename string, v interface{}) {
444
+	//ReadFile函数会读取文件的全部内容,并将结果以[]byte类型返回
445
+	data, err := ioutil.ReadFile(filename)
446
+	if err != nil {
447
+		return
448
+	}
449
+	//读取的数据为json格式,需要进行解码
450
+	err = json.Unmarshal(data, v)
451
+	if err != nil {
452
+		return
453
+	}
454
+}
455
+
456
+type Config struct {
457
+	Parent_template []*models.VMDoctorAdviceParentTemplate "json:parent_template"
458
+}
459
+
460
+func LoadConfig(dataFile string) *Config {
461
+	var config Config
462
+	_, filename, _, _ := runtime.Caller(1)
463
+	datapath := path.Join(path.Dir(filename), dataFile)
464
+	config_file, err := os.Open(datapath)
465
+	if err != nil {
466
+		emit("Failed to open config file '%s': %s\n", datapath, err)
467
+		return &config
468
+	}
469
+
470
+	fi, _ := config_file.Stat()
471
+
472
+	buffer := make([]byte, fi.Size())
473
+	_, err = config_file.Read(buffer)
474
+
475
+	buffer, err = StripComments(buffer) //去掉注释
476
+	if err != nil {
477
+		emit("Failed to strip comments from json: %s\n", err)
478
+		return &config
479
+	}
480
+
481
+	buffer = []byte(os.ExpandEnv(string(buffer))) //特殊
482
+	err = json.Unmarshal(buffer, &config)         //解析json格式数据
483
+	if err != nil {
484
+		emit("Failed unmarshalling json: %s\n", err)
485
+		return &config
486
+	}
487
+	return &config
488
+}
489
+
490
+func StripComments(data []byte) ([]byte, error) {
491
+	data = bytes.Replace(data, []byte("\r"), []byte(""), 0) // Windows
492
+	lines := bytes.Split(data, []byte("\n"))                //split to muli lines
493
+	filtered := make([][]byte, 0)
494
+
495
+	for _, line := range lines {
496
+		match, err := regexp.Match(`^\s*#`, line)
497
+		if err != nil {
498
+			return nil, err
499
+		}
500
+		if !match {
501
+			filtered = append(filtered, line)
502
+		}
503
+	}
504
+
505
+	return bytes.Join(filtered, []byte("\n")), nil
506
+}
507
+
508
+func emit(msgfmt string, args ...interface{}) {
509
+	log.Printf(msgfmt, args...)
510
+}
511
+
512
+func (c *GobalConfigApiController) GetAdviceInitConfig() {
513
+	adminUserInfo := c.GetAdminUserInfo()
514
+	advice_init, _ := service.FindAdviceInitConfig(adminUserInfo.CurrentOrgId)
515
+	c.ServeSuccessJSON(map[string]interface{}{
516
+		"advice_init": advice_init,
517
+	})
518
+}
519
+
520
+func (c *GobalConfigApiController) PostInitAdviceTemplate() {
521
+	is_init, _ := c.GetInt64("is_init")
522
+	adminUserInfo := c.GetAdminUserInfo()
523
+	adviceInit := &models.AdviceInit{
524
+		UserOrgId:  adminUserInfo.CurrentOrgId,
525
+		CreateTime: time.Now().Unix(),
526
+		UpdateTime: time.Now().Unix(),
527
+		Status:     1,
528
+		IsInit:     is_init,
529
+	}
530
+
531
+	adviceParentTemplate := LoadConfig("./advice_template.json").Parent_template
532
+	for _, item := range adviceParentTemplate {
533
+		parentTemplate := &models.DoctorAdviceParentTemplate{
534
+			OrgId:       adminUserInfo.CurrentOrgId,
535
+			Name:        item.Name,
536
+			Status:      1,
537
+			CreatedTime: time.Now().Unix(),
538
+			UpdatedTime: time.Now().Unix(),
539
+			AdviceType:  item.AdviceType,
540
+		}
541
+
542
+		createErr := service.CreateDoctorParentTemplate(parentTemplate)
543
+		fmt.Println(parentTemplate.ID)
544
+		if createErr == nil {
545
+			for _, adviceTemplateItem := range item.DoctorAdviceTemplate {
546
+				adviceTeplate := &models.DoctorAdviceTemplate{
547
+					OrgId:                 adminUserInfo.CurrentOrgId,
548
+					AdviceName:            adviceTemplateItem.AdviceName,
549
+					AdviceDesc:            adviceTemplateItem.AdviceDesc,
550
+					SingleDose:            adviceTemplateItem.SingleDose,
551
+					SingleDoseUnit:        adviceTemplateItem.SingleDoseUnit,
552
+					PrescribingNumber:     adviceTemplateItem.PrescribingNumber,
553
+					PrescribingNumberUnit: adviceTemplateItem.PrescribingNumberUnit,
554
+					DeliveryWay:           adviceTemplateItem.DeliveryWay,
555
+					ExecutionFrequency:    adviceTemplateItem.ExecutionFrequency,
556
+					AdviceDoctor:          adviceTemplateItem.AdviceDoctor,
557
+					Status:                1,
558
+					CreatedTime:           time.Now().Unix(),
559
+					UpdatedTime:           time.Now().Unix(),
560
+					TemplateId:            parentTemplate.ID,
561
+					DrugSpec:              adviceTemplateItem.DrugSpec,
562
+					DrugSpecUnit:          adviceTemplateItem.DrugSpecUnit,
563
+					ParentId:              adviceTemplateItem.ParentId,
564
+					AdviceType:            adviceTemplateItem.AdviceType,
565
+					DayCount:              adviceTemplateItem.DayCount,
566
+					WeekDays:              adviceTemplateItem.WeekDays,
567
+					FrequencyType:         adviceTemplateItem.FrequencyType,
568
+				}
569
+				createErr := service.CreateDoctorTemplate(adviceTeplate)
570
+
571
+				if createErr == nil {
572
+					for _, childItem := range adviceTemplateItem.SubDoctorAdviceTemplate {
573
+						adviceTeplate := &models.DoctorAdviceTemplate{
574
+							OrgId:                 adminUserInfo.CurrentOrgId,
575
+							AdviceName:            childItem.AdviceName,
576
+							AdviceDesc:            childItem.AdviceDesc,
577
+							SingleDose:            childItem.SingleDose,
578
+							SingleDoseUnit:        childItem.SingleDoseUnit,
579
+							PrescribingNumber:     childItem.PrescribingNumber,
580
+							PrescribingNumberUnit: childItem.PrescribingNumberUnit,
581
+							DeliveryWay:           childItem.DeliveryWay,
582
+							ExecutionFrequency:    childItem.ExecutionFrequency,
583
+							AdviceDoctor:          childItem.AdviceDoctor,
584
+							Status:                1,
585
+							CreatedTime:           time.Now().Unix(),
586
+							UpdatedTime:           time.Now().Unix(),
587
+							TemplateId:            parentTemplate.ID,
588
+							DrugSpec:              childItem.DrugSpec,
589
+							DrugSpecUnit:          childItem.DrugSpecUnit,
590
+							ParentId:              adviceTeplate.ID,
591
+							AdviceType:            childItem.AdviceType,
592
+							DayCount:              childItem.DayCount,
593
+							WeekDays:              childItem.WeekDays,
594
+							FrequencyType:         childItem.FrequencyType,
595
+						}
596
+						service.CreateDoctorTemplate(adviceTeplate)
597
+					}
598
+				}
599
+			}
600
+		}
601
+	}
602
+	err := service.CreateAdviceInitConfig(adviceInit)
603
+	if err == nil {
604
+		c.ServeSuccessJSON(map[string]interface{}{
605
+			"init_config": adviceInit,
606
+		})
607
+	} else {
608
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
609
+		return
610
+	}
611
+}
612
+
613
+func (c *GobalConfigApiController) CreateSystemPrescription() {
614
+	adminUserInfo := c.GetAdminUserInfo()
615
+	var solution models.SystemPrescription
616
+	code := defaultSystemSolutionFormData(&solution, c.Ctx.Input.RequestBody, "create")
617
+	if code > 0 {
618
+		c.ServeFailJSONWithSGJErrorCode(code)
619
+		return
620
+	}
621
+
622
+	solution.RegistrarsId = adminUserInfo.AdminUser.Id
623
+	solution.Doctor = adminUserInfo.AdminUser.Id
624
+	solution.Status = 1
625
+	solution.CreatedTime = time.Now().Unix()
626
+	solution.UserOrgId = adminUserInfo.CurrentOrgId
627
+	solution.UpdatedTime = time.Now().Unix()
628
+
629
+	err := service.CreateSystemDialysisSolution(&solution)
630
+	if err != nil {
631
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionCreate)
632
+		return
633
+	}
634
+
635
+	prescriptions, _ := service.FindAllSystemPrescription(adminUserInfo.CurrentOrgId)
636
+
637
+	c.ServeSuccessJSON(map[string]interface{}{
638
+		"prescription":  solution,
639
+		"prescriptions": prescriptions,
640
+	})
641
+	return
642
+}
643
+
644
+func (c *GobalConfigApiController) UpdateSystemPrescription() {
645
+	id, _ := c.GetInt64("id", 0)
646
+	if id <= 0 {
647
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
648
+		return
649
+	}
650
+
651
+	adminUserInfo := c.GetAdminUserInfo()
652
+
653
+	solution, _ := service.FindSystemDialysisSolution(adminUserInfo.CurrentOrgId, id)
654
+	if solution.ID == 0 {
655
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionNotExist)
656
+		return
657
+	}
658
+
659
+	code := defaultSystemSolutionFormData(&solution, c.Ctx.Input.RequestBody, "edit")
660
+	if code > 0 {
661
+		c.ServeFailJSONWithSGJErrorCode(code)
662
+		return
663
+	}
664
+
665
+	solution.UpdatedTime = time.Now().Unix()
666
+	solution.Doctor = adminUserInfo.AdminUser.Id
667
+	solution.RegistrarsId = adminUserInfo.AdminUser.Id
668
+
669
+	err := service.UpdateSystemDialysisSolution(&solution)
670
+	if err != nil {
671
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionUpdate)
672
+		return
673
+	}
674
+
675
+	c.ServeSuccessJSON(map[string]interface{}{
676
+		"msg":          "ok",
677
+		"prescription": solution,
678
+	})
679
+	return
680
+}
681
+
682
+func (c *GobalConfigApiController) GetAllSystemPrescription() {
683
+	adminUserInfo := c.GetAdminUserInfo()
684
+	prescriptions, _ := service.FindAllSystemPrescription(adminUserInfo.CurrentOrgId)
685
+	c.ServeSuccessJSON(map[string]interface{}{
686
+		"prescriptions": prescriptions,
687
+	})
688
+}
689
+
690
+func (c *GobalConfigApiController) GetSystemPrescription() {
691
+	adminUserInfo := c.GetAdminUserInfo()
692
+	id, _ := c.GetInt64("id", 0)
693
+	prescription, _ := service.FindSystemDialysisPrescriptionByMode(adminUserInfo.CurrentOrgId, id)
694
+	c.ServeSuccessJSON(map[string]interface{}{
695
+		"prescription": prescription,
696
+	})
697
+
698
+}
699
+
700
+func defaultSystemSolutionFormData(solution *models.SystemPrescription, data []byte, method string) (code int) {
701
+	dataBody := make(map[string]interface{}, 0)
702
+	err := json.Unmarshal(data, &dataBody)
703
+	utils.InfoLog(string(data))
704
+	if err != nil {
705
+		utils.ErrorLog(err.Error())
706
+		code = enums.ErrorCodeParamWrong
707
+		return
708
+	}
709
+
710
+	if method == "create" {
711
+		if dataBody["mode"] == nil || reflect.TypeOf(dataBody["mode"]).String() != "float64" {
712
+			utils.ErrorLog("mode")
713
+			code = enums.ErrorCodeParamWrong
714
+			return
715
+		}
716
+		mode := int64(dataBody["mode"].(float64))
717
+		if mode <= 0 {
718
+			utils.ErrorLog("mode <= 0")
719
+			code = enums.ErrorCodeParamWrong
720
+			return
721
+		}
722
+		solution.ModeId = mode
723
+
724
+	}
725
+
726
+	if dataBody["dialysis_duration"] != nil && reflect.TypeOf(dataBody["dialysis_duration"]).String() == "string" {
727
+		dialysisDuration, _ := strconv.ParseFloat(dataBody["dialysis_duration"].(string), 64)
728
+		solution.DialysisDuration = dialysisDuration
729
+	}
730
+
731
+	if dataBody["target_ultrafiltration"] != nil && reflect.TypeOf(dataBody["target_ultrafiltration"]).String() == "string" {
732
+		targetUltrafiltration, _ := strconv.ParseFloat(dataBody["target_ultrafiltration"].(string), 64)
733
+		solution.TargetUltrafiltration = targetUltrafiltration
734
+	}
735
+
736
+	if dataBody["dialysate_formulation"] != nil && reflect.TypeOf(dataBody["dialysate_formulation"]).String() == "float64" {
737
+		dialysateFormulation := int64(dataBody["dialysate_formulation"].(float64))
738
+		solution.DialysateFormulation = dialysateFormulation
739
+	}
740
+
741
+	if dataBody["dialysis_duration_hour"] != nil && reflect.TypeOf(dataBody["dialysis_duration_hour"]).String() == "string" {
742
+		dialysisDurationHour, _ := strconv.ParseFloat(dataBody["dialysis_duration_hour"].(string), 64)
743
+		solution.DialysisDurationHour = int64(dialysisDurationHour)
744
+	}
745
+
746
+	if dataBody["dialysis_duration_minute"] != nil && reflect.TypeOf(dataBody["dialysis_duration_minute"]).String() == "string" {
747
+		dialysisDurationMinute, _ := strconv.ParseFloat(dataBody["dialysis_duration_minute"].(string), 64)
748
+		solution.DialysisDurationMinute = int64(dialysisDurationMinute)
749
+	}
750
+
751
+	if dataBody["hemodialysis_machine"] != nil && reflect.TypeOf(dataBody["hemodialysis_machine"]).String() == "float64" {
752
+		hemodialysisMachine := int64(dataBody["hemodialysis_machine"].(float64))
753
+		solution.HemodialysisMachine = hemodialysisMachine
754
+	}
755
+	if dataBody["dialyzer"] != nil && reflect.TypeOf(dataBody["dialyzer"]).String() == "float64" {
756
+		dialyzer := int64(dataBody["dialyzer"].(float64))
757
+		solution.Dialyzer = dialyzer
758
+	}
759
+
760
+	if dataBody["perfusion_apparatus"] != nil && reflect.TypeOf(dataBody["perfusion_apparatus"]).String() == "float64" {
761
+		perfusionApparatus := int64(dataBody["perfusion_apparatus"].(float64))
762
+		solution.PerfusionApparatus = perfusionApparatus
763
+	}
764
+
765
+	if dataBody["blood_flow_volume"] != nil && reflect.TypeOf(dataBody["blood_flow_volume"]).String() == "string" {
766
+		bloodFlowVolume, _ := strconv.ParseFloat(dataBody["blood_flow_volume"].(string), 64)
767
+		solution.BloodFlowVolume = bloodFlowVolume
768
+	}
769
+
770
+	if dataBody["dewater"] != nil && reflect.TypeOf(dataBody["dewater"]).String() == "string" {
771
+		dewater, _ := strconv.ParseFloat(dataBody["dewater"].(string), 64)
772
+		solution.Dewater = dewater
773
+	}
774
+
775
+	if dataBody["displace_liqui"] != nil && reflect.TypeOf(dataBody["displace_liqui"]).String() == "string" {
776
+		displaceLiqui, _ := strconv.ParseFloat(dataBody["displace_liqui"].(string), 64)
777
+		solution.DisplaceLiqui = displaceLiqui
778
+	}
779
+
780
+	if dataBody["replacement_way"] != nil && reflect.TypeOf(dataBody["replacement_way"]).String() == "float64" {
781
+		replacementWay := int64(dataBody["replacement_way"].(float64))
782
+		solution.ReplacementWay = replacementWay
783
+	}
784
+
785
+	if dataBody["anticoagulant"] != nil && reflect.TypeOf(dataBody["anticoagulant"]).String() == "float64" {
786
+		anticoagulant := int64(dataBody["anticoagulant"].(float64))
787
+		solution.Anticoagulant = anticoagulant
788
+	}
789
+
790
+	if dataBody["anticoagulant_shouji"] != nil && reflect.TypeOf(dataBody["anticoagulant_shouji"]).String() == "string" {
791
+		anticoagulantShouji, _ := strconv.ParseFloat(dataBody["anticoagulant_shouji"].(string), 64)
792
+		solution.AnticoagulantShouji = anticoagulantShouji
793
+	}
794
+
795
+	if dataBody["anticoagulant_weichi"] != nil && reflect.TypeOf(dataBody["anticoagulant_weichi"]).String() == "string" {
796
+		anticoagulantWeichi, _ := strconv.ParseFloat(dataBody["anticoagulant_weichi"].(string), 64)
797
+		solution.AnticoagulantWeichi = anticoagulantWeichi
798
+	}
799
+
800
+	if dataBody["anticoagulant_zongliang"] != nil && reflect.TypeOf(dataBody["anticoagulant_zongliang"]).String() == "string" {
801
+		anticoagulantZongliang, _ := strconv.ParseFloat(dataBody["anticoagulant_zongliang"].(string), 64)
802
+		solution.AnticoagulantZongliang = anticoagulantZongliang
803
+	}
804
+
805
+	if dataBody["anticoagulant_gaimingcheng"] != nil && reflect.TypeOf(dataBody["anticoagulant_gaimingcheng"]).String() == "string" {
806
+		anticoagulantGaimingcheng, _ := dataBody["anticoagulant_gaimingcheng"].(string)
807
+		solution.AnticoagulantGaimingcheng = anticoagulantGaimingcheng
808
+	}
809
+
810
+	if dataBody["anticoagulant_gaijiliang"] != nil && reflect.TypeOf(dataBody["anticoagulant_gaijiliang"]).String() == "string" {
811
+		anticoagulantGaijiliang, _ := dataBody["anticoagulant_gaijiliang"].(string)
812
+		solution.AnticoagulantGaijiliang = anticoagulantGaijiliang
813
+	}
814
+
815
+	if dataBody["kalium"] != nil && reflect.TypeOf(dataBody["kalium"]).String() == "string" {
816
+		kalium, _ := strconv.ParseFloat(dataBody["kalium"].(string), 64)
817
+		solution.Kalium = kalium
818
+	}
819
+
820
+	if dataBody["sodium"] != nil && reflect.TypeOf(dataBody["sodium"]).String() == "string" {
821
+		sodium, _ := strconv.ParseFloat(dataBody["sodium"].(string), 64)
822
+		solution.Sodium = sodium
823
+	}
824
+
825
+	if dataBody["calcium"] != nil && reflect.TypeOf(dataBody["calcium"]).String() == "string" {
826
+		calcium, _ := strconv.ParseFloat(dataBody["calcium"].(string), 64)
827
+		solution.Calcium = calcium
828
+	}
829
+
830
+	if dataBody["bicarbonate"] != nil && reflect.TypeOf(dataBody["bicarbonate"]).String() == "string" {
831
+		bicarbonate, _ := strconv.ParseFloat(dataBody["bicarbonate"].(string), 64)
832
+		solution.Bicarbonate = bicarbonate
833
+	}
834
+
835
+	if dataBody["glucose"] != nil && reflect.TypeOf(dataBody["glucose"]).String() == "string" {
836
+		glucose, _ := strconv.ParseFloat(dataBody["glucose"].(string), 64)
837
+		solution.Glucose = glucose
838
+	}
839
+
840
+	// if dataBody["dry_weight"] != nil && reflect.TypeOf(dataBody["dry_weight"]).String() == "string" {
841
+	// 	dryWeight, _ := strconv.ParseFloat(dataBody["dry_weight"].(string), 64)
842
+	// 	solution.DryWeight = dryWeight
843
+	// }
844
+
845
+	if dataBody["dialysate_flow"] != nil && reflect.TypeOf(dataBody["dialysate_flow"]).String() == "string" {
846
+		dialysateFlow, _ := strconv.ParseFloat(dataBody["dialysate_flow"].(string), 64)
847
+		solution.DialysateFlow = dialysateFlow
848
+	}
849
+
850
+	if dataBody["dialysate_temperature"] != nil && reflect.TypeOf(dataBody["dialysate_temperature"]).String() == "string" {
851
+		dialysateTemperature, _ := strconv.ParseFloat(dataBody["dialysate_temperature"].(string), 64)
852
+		solution.DialysateTemperature = dialysateTemperature
853
+	}
854
+
855
+	if dataBody["conductivity"] != nil && reflect.TypeOf(dataBody["conductivity"]).String() == "string" {
856
+		conductivity, _ := strconv.ParseFloat(dataBody["conductivity"].(string), 64)
857
+		solution.Conductivity = conductivity
858
+	}
859
+
860
+	if dataBody["replacement_total"] != nil && reflect.TypeOf(dataBody["replacement_total"]).String() == "string" {
861
+		replacementTotal, _ := strconv.ParseFloat(dataBody["replacement_total"].(string), 64)
862
+		solution.ReplacementTotal = replacementTotal
863
+	}
864
+
865
+	if dataBody["dialyzer_perfusion_apparatus"] != nil && reflect.TypeOf(dataBody["dialyzer_perfusion_apparatus"]).String() == "string" {
866
+		dialyzer_perfusion_apparatus := dataBody["dialyzer_perfusion_apparatus"].(string)
867
+		solution.DialyzerPerfusionApparatus = dialyzer_perfusion_apparatus
868
+	}
869
+
870
+	if dataBody["body_fluid"] != nil && reflect.TypeOf(dataBody["body_fluid"]).String() == "float64" {
871
+		body_fluid := int64(dataBody["body_fluid"].(float64))
872
+		solution.BodyFluid = body_fluid
873
+	}
874
+
875
+	if dataBody["body_fluid_other"] != nil && reflect.TypeOf(dataBody["body_fluid_other"]).String() == "string" {
876
+		body_fluid_other := dataBody["body_fluid_other"].(string)
877
+		solution.BodyFluidOther = body_fluid_other
878
+	}
879
+
880
+	if dataBody["special_medicine"] != nil && reflect.TypeOf(dataBody["special_medicine"]).String() == "float64" {
881
+		special_medicine := int64(dataBody["special_medicine"].(float64))
882
+		solution.SpecialMedicine = special_medicine
883
+	}
884
+
885
+	if dataBody["special_medicine_other"] != nil && reflect.TypeOf(dataBody["special_medicine_other"]).String() == "string" {
886
+		special_medicine_other := dataBody["special_medicine_other"].(string)
887
+		solution.SpecialMedicineOther = special_medicine_other
888
+	}
889
+
890
+	if dataBody["displace_liqui_part"] != nil && reflect.TypeOf(dataBody["displace_liqui_part"]).String() == "float64" {
891
+		displace_liqui_part := int64(dataBody["displace_liqui_part"].(float64))
892
+		solution.DisplaceLiquiPart = displace_liqui_part
893
+	}
894
+	if dataBody["displace_liqui_value"] != nil && reflect.TypeOf(dataBody["displace_liqui_value"]).String() == "string" {
895
+		displace_liqui_value, _ := strconv.ParseFloat(dataBody["displace_liqui_value"].(string), 64)
896
+		solution.DisplaceLiquiValue = displace_liqui_value
897
+	}
898
+	if dataBody["blood_access"] != nil && reflect.TypeOf(dataBody["blood_access"]).String() == "float64" {
899
+		blood_access := int64(dataBody["blood_access"].(float64))
900
+		solution.BloodAccess = blood_access
901
+	}
902
+
903
+	if dataBody["ultrafiltration"] != nil && reflect.TypeOf(dataBody["ultrafiltration"]).String() == "string" {
904
+		ultrafiltration, _ := strconv.ParseFloat(dataBody["ultrafiltration"].(string), 64)
905
+		solution.Ultrafiltration = ultrafiltration
906
+	}
907
+
908
+	if dataBody["target_ktv"] != nil && reflect.TypeOf(dataBody["target_ktv"]).String() == "string" {
909
+		target_ktv, _ := strconv.ParseFloat(dataBody["target_ktv"].(string), 64)
910
+		solution.TargetKtv = target_ktv
911
+	}
912
+
913
+	if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
914
+		remark := dataBody["remark"].(string)
915
+		solution.Remark = remark
916
+	}
917
+
918
+	return
919
+}
920
+
921
+func (c *GobalConfigApiController) GetPrintInfo() {
922
+	adminUserInfo := c.GetAdminUserInfo()
923
+	OrgID := adminUserInfo.CurrentOrgId
924
+	dataBody := make(map[string]interface{}, 0)
925
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
926
+	idsInters := dataBody["ids"].([]interface{})
927
+	if len(idsInters) == 0 {
928
+		if err != nil {
929
+			c.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
930
+			return
931
+		}
932
+	}
933
+	ids := make([]int64, 0)
934
+	for _, idsInter := range idsInters {
935
+		id := int64(idsInter.(float64))
936
+		ids = append(ids, id)
937
+	}
938
+	getPrint, err := service.GetPrint(ids, OrgID)
939
+	c.ServeSuccessJSON(map[string]interface{}{
940
+		"doctoradvice": getPrint,
941
+	})
942
+}

+ 622 - 0
controllers/inspection_api_controller.go View File

@@ -0,0 +1,622 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"fmt"
10
+	"github.com/astaxie/beego"
11
+	"strconv"
12
+	"strings"
13
+	"time"
14
+)
15
+
16
+type InspectionApiController struct {
17
+	BaseAuthAPIController
18
+}
19
+
20
+func InspectionApiRegistRouters() {
21
+	beego.Router("/api/patient/inspection/list", &InspectionApiController{}, "Get:GetPatientInspections")
22
+	beego.Router("/api/patient/inspection/reference", &InspectionApiController{}, "Get:PatientInspectionReference")
23
+	beego.Router("/api/patient/inspection/create", &InspectionApiController{}, "Post:CreatePatientInspection")
24
+	beego.Router("/api/patient/inspection/edit", &InspectionApiController{}, "Put:EditPatientInspection")
25
+	beego.Router("/api/patient/inspection/delete", &InspectionApiController{}, "Delete:DeletePatientInspection")
26
+
27
+	beego.Router("/api/patient/inspection/get", &InspectionApiController{}, "Get:GetAllPatientInspection")
28
+	beego.Router("/api/patient/inspectioninit/get", &InspectionApiController{}, "Get:GetInitInsepction")
29
+
30
+}
31
+
32
+//PatientInspectionReference 请求检验检查大小项目
33
+//[get]: /api/patient/inspection/reference
34
+func (c *InspectionApiController) PatientInspectionReference() {
35
+	patient, _ := c.GetInt64("patient")
36
+	if patient <= 0 {
37
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
38
+		return
39
+	}
40
+
41
+	adminUserInfo := c.GetAdminUserInfo()
42
+
43
+	references, err := service.GetInspectionReference(adminUserInfo.CurrentOrgId)
44
+	if err != nil {
45
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
46
+		return
47
+	}
48
+
49
+	patient_info, _ := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient)
50
+
51
+	counts, err := service.GetPatientInspectionProjectCount(adminUserInfo.CurrentOrgId, patient)
52
+	if err != nil {
53
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
54
+		return
55
+	}
56
+	countsMap := make(map[int64]int64, 0)
57
+	for _, count := range counts {
58
+		countsMap[count.ProjectId] = count.Count
59
+	}
60
+
61
+	referenceMap := make(map[string]*models.InspectionReferenceMap, 0)
62
+
63
+	for _, reference := range references {
64
+		if _, exist := referenceMap[reference.Project]; !exist {
65
+			referenceMap[reference.Project] = new(models.InspectionReferenceMap)
66
+			referenceMap[reference.Project].Project = reference.Project
67
+			referenceMap[reference.Project].ProjectId = reference.ProjectId
68
+			referenceMap[reference.Project].ProjectName = reference.ProjectName
69
+			if _, cexit := countsMap[reference.ProjectId]; cexit {
70
+				referenceMap[reference.Project].Count = countsMap[reference.ProjectId]
71
+			}
72
+			referenceMap[reference.Project].InspectionReference = make([]models.InspectionReference, 0)
73
+		}
74
+		referenceMap[reference.Project].InspectionReference = append(referenceMap[reference.Project].InspectionReference, *reference)
75
+
76
+	}
77
+
78
+	reference := make([]*models.InspectionReferenceMap, 0)
79
+	for _, item := range referenceMap {
80
+		reference = append(reference, item)
81
+	}
82
+
83
+	rl := len(reference)
84
+	for index := 0; index < rl-1; index++ {
85
+		for jndex := 0; jndex < rl-1-index; jndex++ {
86
+			if reference[jndex].ProjectId > reference[jndex+1].ProjectId {
87
+				var item models.InspectionReferenceMap
88
+				item = *reference[jndex]
89
+				reference[jndex] = reference[jndex+1]
90
+				reference[jndex+1] = &item
91
+			}
92
+		}
93
+	}
94
+
95
+	c.ServeSuccessJSON(map[string]interface{}{
96
+		"reference":    reference,
97
+		"patient_info": patient_info,
98
+	})
99
+	return
100
+
101
+}
102
+
103
+func (c *InspectionApiController) CreatePatientInspection() {
104
+	patient, _ := c.GetInt64("patient", 0)
105
+	remind_cycle, _ := c.GetInt64("remind_cycle", 0)
106
+
107
+	if patient <= 0 {
108
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
109
+		return
110
+	}
111
+
112
+	adminUserInfo := c.GetAdminUserInfo()
113
+	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
114
+	if patientInfo.ID == 0 {
115
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
116
+		return
117
+	}
118
+
119
+	var from models.InepectionForm
120
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &from)
121
+	if err != nil {
122
+		utils.ErrorLog("%v", err)
123
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
124
+		return
125
+	}
126
+
127
+	timeLayout := "2006-01-02 15:04:05"
128
+	loc, _ := time.LoadLocation("Local")
129
+
130
+	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate+" 00:00:00", loc)
131
+	if err != nil {
132
+		utils.ErrorLog(err.Error())
133
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
134
+		return
135
+	}
136
+
137
+	if len(from.FormItem) == 0 {
138
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
139
+		return
140
+	}
141
+
142
+	date := theTime.Unix()
143
+	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, from.ProjectId)
144
+	if err != nil {
145
+		utils.ErrorLog("%v", err)
146
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
147
+		return
148
+	}
149
+	if len(insp) > 0 {
150
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateExit)
151
+		return
152
+	}
153
+
154
+	inspections := make([]models.Inspection, 0)
155
+	for _, item := range from.FormItem {
156
+		var inspection models.Inspection
157
+		inspection.OrgId = adminUserInfo.CurrentOrgId
158
+		inspection.PatientId = patient
159
+		inspection.ProjectId = from.ProjectId
160
+		inspection.ItemId = item.ItemId
161
+		inspection.ItemName = item.ItemName
162
+		inspection.ProjectName = item.ProjectName
163
+		inspection.InspectType = item.RangeType
164
+		inspection.InspectValue = item.Value
165
+		inspection.InspectDate = date
166
+		inspection.Status = 1
167
+		inspection.CreatedTime = time.Now().Unix()
168
+		inspection.UpdatedTime = time.Now().Unix()
169
+		inspections = append(inspections, inspection)
170
+	}
171
+
172
+	err = service.CreatePatientInspection(inspections)
173
+	if err != nil {
174
+		utils.ErrorLog("%v", err)
175
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionAddFail)
176
+		return
177
+	}
178
+
179
+	if remind_cycle > 0 {
180
+		infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, 14)
181
+		fmt.Println(infectiousRecord.InspectDate)
182
+		var record_time int64
183
+		switch remind_cycle {
184
+		case 1: //1个月
185
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
186
+			record_time = ts.AddDate(0, 1, 0).Unix()
187
+			fmt.Println(record_time)
188
+			break
189
+		case 2: //2个月
190
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
191
+			record_time = ts.AddDate(0, 2, 0).Unix()
192
+			fmt.Println(record_time)
193
+
194
+			break
195
+		case 3: //3个月
196
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
197
+			record_time = ts.AddDate(0, 3, 0).Unix()
198
+			fmt.Println(record_time)
199
+
200
+			break
201
+		case 4: //6个月
202
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
203
+			record_time = ts.AddDate(0, 6, 0).Unix()
204
+			fmt.Println(record_time)
205
+
206
+			break
207
+		case 5: //12个月
208
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
209
+			record_time = ts.AddDate(0, 12, 0).Unix()
210
+			fmt.Println(record_time)
211
+
212
+			break
213
+		}
214
+
215
+		errs := service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
216
+		if errs != nil {
217
+			utils.ErrorLog("更新日期出错:%v", errs)
218
+		}
219
+	}
220
+
221
+	c.ServeSuccessJSON(map[string]interface{}{
222
+		"inspections":  inspections,
223
+		"remind_cycle": remind_cycle,
224
+	})
225
+	return
226
+}
227
+
228
+func (c *InspectionApiController) EditPatientInspection() {
229
+	patient, _ := c.GetInt64("patient", 0)
230
+	remind_cycle, _ := c.GetInt64("remind_cycle", 0)
231
+
232
+	if patient <= 0 {
233
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
234
+		return
235
+	}
236
+
237
+	adminUserInfo := c.GetAdminUserInfo()
238
+	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
239
+	if patientInfo.ID == 0 {
240
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
241
+		return
242
+	}
243
+
244
+	var from models.InepectionForm
245
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &from)
246
+	if err != nil {
247
+		utils.ErrorLog("%v", err)
248
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
249
+		return
250
+	}
251
+
252
+	timeLayout := "2006-01-02 15:04:05"
253
+	loc, _ := time.LoadLocation("Local")
254
+
255
+	theTime, err := time.ParseInLocation(timeLayout, from.InspectDate+" 00:00:00", loc)
256
+	if err != nil {
257
+		utils.ErrorLog(err.Error())
258
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
259
+		return
260
+	}
261
+
262
+	if len(from.FormItem) == 0 {
263
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
264
+		return
265
+	}
266
+
267
+	date := theTime.Unix()
268
+	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, from.ProjectId)
269
+	if err != nil {
270
+		utils.ErrorLog("%v", err)
271
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
272
+		return
273
+	}
274
+	if len(insp) == 0 {
275
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
276
+		return
277
+	}
278
+	inspMap := make(map[int64]*models.Inspection)
279
+	for _, item := range insp {
280
+		inspMap[item.ID] = item
281
+	}
282
+
283
+	addinsp := make([]models.Inspection, 0)
284
+	editinsp := make([]models.Inspection, 0)
285
+	noMap := make([]int64, 0)
286
+	fmt.Println(from.FormItem)
287
+
288
+	for _, item := range from.FormItem {
289
+		fmt.Println(item.ID)
290
+		if item.ID == 0 {
291
+			var inspection models.Inspection
292
+			inspection.OrgId = adminUserInfo.CurrentOrgId
293
+			inspection.PatientId = patient
294
+			inspection.ProjectId = from.ProjectId
295
+			inspection.ItemId = item.ItemId
296
+			inspection.ItemName = item.ItemName
297
+			inspection.ProjectName = item.ProjectName
298
+			inspection.InspectType = item.RangeType
299
+			inspection.InspectValue = item.Value
300
+			inspection.InspectDate = date
301
+			inspection.Status = 1
302
+			inspection.CreatedTime = time.Now().Unix()
303
+			inspection.UpdatedTime = time.Now().Unix()
304
+			addinsp = append(addinsp, inspection)
305
+		} else if _, exi := inspMap[item.ID]; exi {
306
+			fmt.Println("2222222222")
307
+			inspection := *inspMap[item.ID]
308
+			inspection.InspectValue = item.Value
309
+			inspection.UpdatedTime = time.Now().Unix()
310
+			editinsp = append(editinsp, inspection)
311
+			noMap = append(noMap, item.ID)
312
+		}
313
+
314
+	}
315
+
316
+	err = service.EditPatientInspection(addinsp, editinsp, noMap, patient, adminUserInfo.CurrentOrgId, from.ProjectId, date)
317
+	if err != nil {
318
+		utils.ErrorLog("%v", err)
319
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionEditFail)
320
+		return
321
+	}
322
+
323
+	inspections := make([]models.Inspection, 0)
324
+	inspections = append(inspections, editinsp...)
325
+	inspections = append(inspections, addinsp...)
326
+
327
+	if remind_cycle > 0 {
328
+		infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, 14)
329
+		fmt.Println(infectiousRecord.InspectDate)
330
+		var record_time int64
331
+		switch remind_cycle {
332
+		case 1: //1个月
333
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
334
+			record_time = ts.AddDate(0, 1, 0).Unix()
335
+
336
+			break
337
+		case 2: //2个月
338
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
339
+			record_time = ts.AddDate(0, 2, 0).Unix()
340
+			break
341
+		case 3: //3个月
342
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
343
+			record_time = ts.AddDate(0, 3, 0).Unix()
344
+			break
345
+		case 4: //6个月
346
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
347
+			record_time = ts.AddDate(0, 6, 0).Unix()
348
+			break
349
+		case 5: //12个月
350
+			ts := time.Unix(infectiousRecord.InspectDate, 0)
351
+			record_time = ts.AddDate(0, 12, 0).Unix()
352
+			break
353
+		}
354
+		fmt.Println(record_time)
355
+		errs := service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
356
+		if errs != nil {
357
+			utils.ErrorLog("更新日期出错:%v", errs)
358
+		}
359
+	}
360
+
361
+	c.ServeSuccessJSON(map[string]interface{}{
362
+		"inspections":  inspections,
363
+		"remind_cycle": remind_cycle,
364
+	})
365
+	return
366
+}
367
+
368
+func (c *InspectionApiController) DeletePatientInspection() {
369
+	patient, _ := c.GetInt64("patient", 0)
370
+	ProjectId, _ := c.GetInt64("project_id", 0)
371
+	InspectDate := c.GetString("date")
372
+	if patient <= 0 || ProjectId <= 0 || len(InspectDate) != 10 {
373
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
374
+		return
375
+	}
376
+
377
+	timeLayout := "2006-01-02 15:04:05"
378
+	loc, _ := time.LoadLocation("Local")
379
+
380
+	theTime, err := time.ParseInLocation(timeLayout, InspectDate+" 00:00:00", loc)
381
+	if err != nil {
382
+		utils.ErrorLog(err.Error())
383
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
384
+		return
385
+	}
386
+
387
+	adminUserInfo := c.GetAdminUserInfo()
388
+
389
+	date := theTime.Unix()
390
+	insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, ProjectId)
391
+	if err != nil {
392
+		utils.ErrorLog("%v", err)
393
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
394
+		return
395
+	}
396
+	if len(insp) == 0 {
397
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
398
+		return
399
+	}
400
+
401
+	err = service.DeletePatientInspection(adminUserInfo.CurrentOrgId, patient, ProjectId, date)
402
+	if err != nil {
403
+		utils.ErrorLog("%v", err)
404
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDeleteFail)
405
+		return
406
+	}
407
+
408
+	c.ServeSuccessJSON(map[string]interface{}{
409
+		"msg": "ok",
410
+	})
411
+	return
412
+}
413
+
414
+func (c *InspectionApiController) GetPatientInspections() {
415
+	patient, _ := c.GetInt64("patient", 0)
416
+	projectId, _ := c.GetInt64("project_id", 0)
417
+	if patient <= 0 || projectId <= 0 {
418
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
419
+		return
420
+	}
421
+	page, _ := c.GetInt64("page", 0)
422
+	if page <= 0 {
423
+		page = 1
424
+	}
425
+
426
+	adminUserInfo := c.GetAdminUserInfo()
427
+	inspections, total, dateTime, err := service.GetPatientInspections(adminUserInfo.CurrentOrgId, patient, projectId, page)
428
+	if err != nil {
429
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
430
+		return
431
+	}
432
+
433
+	date := ""
434
+	if len(inspections) > 0 {
435
+		date = time.Unix(dateTime, 0).Format("2006-01-02")
436
+	}
437
+
438
+	c.ServeSuccessJSON(map[string]interface{}{
439
+		"inspections": inspections,
440
+		"total":       total,
441
+		"date":        date,
442
+	})
443
+	return
444
+
445
+}
446
+
447
+func (c *InspectionApiController) GetAllPatientInspection() {
448
+	patient, _ := c.GetInt64("patient", 0)
449
+	projectStr := c.GetString("project")
450
+	start_time, _ := c.GetInt64("start_time")
451
+	end_time, _ := c.GetInt64("end_time")
452
+	upload_type, _ := c.GetInt64("type")
453
+
454
+	ids := strings.Split(projectStr, "-")
455
+
456
+	if patient <= 0 {
457
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
458
+		return
459
+	}
460
+	page, _ := c.GetInt64("page", 0)
461
+	if page <= 0 {
462
+		page = 1
463
+	}
464
+
465
+	adminUserInfo := c.GetAdminUserInfo()
466
+
467
+	switch upload_type {
468
+	case 1:
469
+		var inspections []*models.Inspection
470
+
471
+		for _, item := range ids {
472
+			id, _ := strconv.ParseInt(item, 10, 64)
473
+			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
474
+			//fmt.Println(err)
475
+			//if err != nil {
476
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
477
+			//	return
478
+			//}
479
+			for _, inspection_item := range inspection {
480
+				inspections = append(inspections, inspection_item)
481
+			}
482
+		}
483
+
484
+		c.ServeSuccessJSON(map[string]interface{}{
485
+			"inspections": inspections,
486
+			"type":        upload_type,
487
+		})
488
+		break
489
+
490
+	case 2:
491
+		id_one, _ := strconv.ParseInt(ids[0], 10, 64)
492
+		id_two, _ := strconv.ParseInt(ids[1], 10, 64)
493
+		id_three, _ := strconv.ParseInt(ids[2], 10, 64)
494
+		inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
495
+		inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
496
+		inspection_three, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_three, start_time, end_time)
497
+
498
+		c.ServeSuccessJSON(map[string]interface{}{
499
+			"inspections_one":   inspection_one,
500
+			"inspections_two":   inspection_two,
501
+			"inspections_three": inspection_three,
502
+			"type":              upload_type,
503
+		})
504
+
505
+		break
506
+	case 3:
507
+		var inspections []*models.Inspection
508
+
509
+		for _, item := range ids {
510
+			id, _ := strconv.ParseInt(item, 10, 64)
511
+			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
512
+			//fmt.Println(err)
513
+			//if err != nil {
514
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
515
+			//	return
516
+			//}
517
+			for _, inspection_item := range inspection {
518
+				inspections = append(inspections, inspection_item)
519
+			}
520
+		}
521
+
522
+		c.ServeSuccessJSON(map[string]interface{}{
523
+			"inspections": inspections,
524
+			"type":        upload_type,
525
+		})
526
+
527
+		break
528
+	case 4:
529
+		id_one, _ := strconv.ParseInt(ids[0], 10, 64)
530
+		id_two, _ := strconv.ParseInt(ids[1], 10, 64)
531
+		id_three, _ := strconv.ParseInt(ids[2], 10, 64)
532
+		id_four, _ := strconv.ParseInt(ids[3], 10, 64)
533
+		id_five, _ := strconv.ParseInt(ids[4], 10, 64)
534
+
535
+		inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
536
+		inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
537
+		inspection_three, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_three, start_time, end_time)
538
+		inspection_four, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_four, start_time, end_time)
539
+		inspection_five, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_five, start_time, end_time)
540
+
541
+		c.ServeSuccessJSON(map[string]interface{}{
542
+			"inspections_one":   inspection_one,
543
+			"inspections_two":   inspection_two,
544
+			"inspections_three": inspection_three,
545
+			"inspections_four":  inspection_four,
546
+			"inspections_five":  inspection_five,
547
+			"type":              upload_type,
548
+		})
549
+
550
+		break
551
+	case 5:
552
+		id_one, _ := strconv.ParseInt(ids[0], 10, 64)
553
+		id_two, _ := strconv.ParseInt(ids[1], 10, 64)
554
+		inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
555
+		inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
556
+
557
+		c.ServeSuccessJSON(map[string]interface{}{
558
+			"inspections_one": inspection_one,
559
+			"inspections_two": inspection_two,
560
+			"type":            upload_type,
561
+		})
562
+
563
+		break
564
+	case 6:
565
+		var inspections []*models.Inspection
566
+
567
+		for _, item := range ids {
568
+			id, _ := strconv.ParseInt(item, 10, 64)
569
+			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
570
+			//fmt.Println(err)
571
+			//if err != nil {
572
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
573
+			//	return
574
+			//}
575
+			for _, inspection_item := range inspection {
576
+				inspections = append(inspections, inspection_item)
577
+			}
578
+		}
579
+
580
+		c.ServeSuccessJSON(map[string]interface{}{
581
+			"inspections": inspections,
582
+			"type":        upload_type,
583
+		})
584
+
585
+		break
586
+	case 7:
587
+		var inspections []*models.Inspection
588
+
589
+		for _, item := range ids {
590
+			id, _ := strconv.ParseInt(item, 10, 64)
591
+			inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
592
+			//fmt.Println(err)
593
+			//if err != nil {
594
+			//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
595
+			//	return
596
+			//}
597
+			for _, inspection_item := range inspection {
598
+				inspections = append(inspections, inspection_item)
599
+			}
600
+		}
601
+
602
+		c.ServeSuccessJSON(map[string]interface{}{
603
+			"inspections": inspections,
604
+			"type":        upload_type,
605
+		})
606
+
607
+		break
608
+
609
+	}
610
+
611
+	return
612
+
613
+}
614
+
615
+func (c *InspectionApiController) GetInitInsepction() {
616
+	references, _ := service.GetAllInspectionReference(0)
617
+	c.ServeSuccessJSON(map[string]interface{}{
618
+		"references": references,
619
+	})
620
+	return
621
+
622
+}

+ 282 - 0
controllers/integration_config_api_controller.go View File

@@ -0,0 +1,282 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"github.com/astaxie/beego"
8
+	"time"
9
+)
10
+
11
+type IntegrationConfigApiController struct {
12
+	BaseAuthAPIController
13
+}
14
+
15
+func IntegrationConfigRegistRouters() {
16
+
17
+	beego.Router("/api/integration/patients", &IntegrationConfigApiController{}, "get:GetPatientsList")
18
+	beego.Router("/api/patienthis/edit", &IntegrationConfigApiController{}, "post:EditPatientHis")
19
+	beego.Router("/api/patienthis/create", &IntegrationConfigApiController{}, "post:CreatePatientHis")
20
+
21
+	beego.Router("/api/integration/admin", &IntegrationConfigApiController{}, "get:GetAdminsList")
22
+	beego.Router("/api/adminhis/edit", &IntegrationConfigApiController{}, "post:EditAdminHis")
23
+	beego.Router("/api/adminhis/create", &IntegrationConfigApiController{}, "post:CreateAdminHis")
24
+
25
+}
26
+
27
+func (c *IntegrationConfigApiController) GetPatientsList() {
28
+	page, _ := c.GetInt64("page", 1)
29
+	limit, _ := c.GetInt64("limit", 10)
30
+
31
+	if page <= 0 {
32
+		page = 1
33
+	}
34
+	if limit <= 0 {
35
+		limit = 10
36
+	}
37
+
38
+	adminUserInfo := c.GetAdminUserInfo()
39
+	patients, total, _ := service.GetIntegrationPatientList(adminUserInfo.CurrentOrgId, page, limit)
40
+
41
+	c.ServeSuccessJSON(map[string]interface{}{
42
+		"list":  patients,
43
+		"total": total,
44
+	})
45
+	return
46
+
47
+}
48
+
49
+func (c *IntegrationConfigApiController) EditPatientHis() {
50
+	his_user_id := c.GetString("his_user_id")
51
+	id, _ := c.GetInt64("id", 0)
52
+
53
+	adminUserInfo := c.GetAdminUserInfo()
54
+
55
+	total, _ := service.FindHisPatientByHisId(adminUserInfo.CurrentOrgId, his_user_id)
56
+
57
+	if total > 0 {
58
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisIdExist)
59
+		return
60
+
61
+	}
62
+
63
+	err := service.UpdatePatientsHis(adminUserInfo.CurrentOrgId, his_user_id, id)
64
+	if err == nil {
65
+		c.ServeSuccessJSON(map[string]interface{}{
66
+			"his_user_id": his_user_id,
67
+		})
68
+	} else {
69
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
70
+
71
+	}
72
+	return
73
+
74
+}
75
+
76
+func (c *IntegrationConfigApiController) CreatePatientHis() {
77
+	his_user_id := c.GetString("his_user_id")
78
+	id, _ := c.GetInt64("id", 0)
79
+
80
+	adminUserInfo := c.GetAdminUserInfo()
81
+	patient, _ := service.FindVMPatientById(adminUserInfo.CurrentOrgId, id)
82
+
83
+	total, _ := service.FindHisPatientByHisId(adminUserInfo.CurrentOrgId, his_user_id)
84
+
85
+	if total > 0 {
86
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisIdExist)
87
+		return
88
+
89
+	}
90
+
91
+	hisPatient := &models.HisPatients{
92
+		UserOrgId:          adminUserInfo.CurrentOrgId,
93
+		UserId:             patient.UserId,
94
+		Avatar:             patient.Avatar,
95
+		PatientType:        patient.PatientType,
96
+		DialysisNo:         patient.DialysisNo,
97
+		AdmissionNumber:    patient.AdmissionNumber,
98
+		Source:             patient.Source,
99
+		Lapseto:            patient.Lapseto,
100
+		PartitionId:        patient.PartitionId,
101
+		BedId:              patient.BedId,
102
+		Name:               patient.Name,
103
+		Alias:              patient.Alias,
104
+		Gender:             patient.Gender,
105
+		Nation:             patient.Nation,
106
+		NativePlace:        patient.NativePlace,
107
+		MaritalStatus:      patient.MaritalStatus,
108
+		IdCardNo:           patient.IdCardNo,
109
+		Birthday:           patient.Birthday,
110
+		ReimbursementWayId: patient.ReimbursementWayId,
111
+		HealthCareType:     patient.HealthCareType,
112
+		HealthCareNo:       patient.HealthCareNo,
113
+		HealthCareDueDate:  patient.HealthCareDueDate,
114
+		Height:             patient.Height,
115
+		BloodType:          patient.BloodType,
116
+		Rh:                 patient.Rh,
117
+		HealthCareDueAlertDate:       patient.HealthCareDueAlertDate,
118
+		EducationLevel:               patient.EducationLevel,
119
+		Profession:                   patient.Profession,
120
+		Phone:                        patient.Phone,
121
+		HomeTelephone:                patient.HomeTelephone,
122
+		RelativePhone:                patient.RelativePhone,
123
+		HomeAddress:                  patient.HomeAddress,
124
+		WorkUnit:                     patient.WorkUnit,
125
+		UnitAddress:                  patient.UnitAddress,
126
+		ReceivingDate:                patient.ReceivingDate,
127
+		IsHospitalFirstDialysis:      patient.IsHospitalFirstDialysis,
128
+		FirstDialysisDate:            patient.FirstDialysisDate,
129
+		FirstDialysisHospital:        patient.FirstDialysisHospital,
130
+		PredialysisCondition:         patient.PredialysisCondition,
131
+		PreHospitalDialysisFrequency: patient.PreHospitalDialysisFrequency,
132
+		PreHospitalDialysisTimes:     patient.PreHospitalDialysisTimes,
133
+		HospitalFirstDialysisDate:    patient.HospitalFirstDialysisDate,
134
+		InductionPeriod:              patient.InductionPeriod,
135
+		InitialDialysis:              patient.InitialDialysis,
136
+		TotalDialysis:                patient.TotalDialysis,
137
+		AttendingDoctorId:            patient.AttendingDoctorId,
138
+		HeadNurseId:                  patient.HeadNurseId,
139
+		Evaluate:                     patient.Evaluate,
140
+		Diagnose:                     patient.Diagnose,
141
+		Remark:                       patient.Remark,
142
+		RegistrarsId:                 patient.RegistrarsId,
143
+		Registrars:                   patient.Registrars,
144
+		QrCode:                       patient.QrCode,
145
+		BindingState:                 patient.BindingState,
146
+		PatientComplains:             patient.PatientComplains,
147
+		PresentHistory:               patient.PresentHistory,
148
+		PastHistory:                  patient.PastHistory,
149
+		Temperature:                  patient.Temperature,
150
+		Pulse:                        patient.Pulse,
151
+		Respiratory:                  patient.Respiratory,
152
+		Sbp:                          patient.SBP,
153
+		Dbp:                          patient.DBP,
154
+		Status:                       1,
155
+		CreatedTime:                  time.Now().Unix(),
156
+		UpdatedTime:                  time.Now().Unix(),
157
+		Age:                          patient.Age,
158
+		InfectiousNextRecordTime: patient.InfectiousNextRecordTime,
159
+		IsInfectious:             patient.IsInfectious,
160
+		RemindCycle:              patient.RemindCycle,
161
+		ResponseResult:           patient.ResponseResult,
162
+		IsOpenRemind:             patient.IsOpenRemind,
163
+		DialysisAge:              patient.DialysisAge,
164
+		ExpenseKind:              patient.ExpenseKind,
165
+		TellPhone:                patient.TellPhone,
166
+		FirstTreatmentDate:       patient.FirstTreatmentDate,
167
+		ContactName:              patient.ContactName,
168
+		HisUserId:                his_user_id,
169
+		XtPatientId:              patient.ID,
170
+	}
171
+
172
+	err := service.CreatePatientsHis(hisPatient)
173
+	if err == nil {
174
+		c.ServeSuccessJSON(map[string]interface{}{
175
+			"patient": hisPatient,
176
+		})
177
+	} else {
178
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
179
+
180
+	}
181
+	return
182
+
183
+}
184
+
185
+func (c *IntegrationConfigApiController) GetAdminsList() {
186
+	page, _ := c.GetInt("page", 1)
187
+	limit, _ := c.GetInt("limit", 10)
188
+
189
+	if page <= 0 {
190
+		page = 1
191
+	}
192
+	if limit <= 0 {
193
+		limit = 10
194
+	}
195
+
196
+	adminUserInfo := c.GetAdminUserInfo()
197
+
198
+	viewModels, total, getAdminsErr := service.GetAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, limit)
199
+	if getAdminsErr != nil {
200
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
201
+		return
202
+	}
203
+	c.ServeSuccessJSON(map[string]interface{}{
204
+		"admins":      viewModels,
205
+		"total_count": total,
206
+	})
207
+
208
+	return
209
+
210
+}
211
+
212
+func (c *IntegrationConfigApiController) EditAdminHis() {
213
+	his_user_id := c.GetString("his_user_id")
214
+	id, _ := c.GetInt64("id", 0)
215
+
216
+	adminUserInfo := c.GetAdminUserInfo()
217
+
218
+	total, _ := service.FindHisAdminByHisId(adminUserInfo.CurrentOrgId, his_user_id, adminUserInfo.CurrentAppId)
219
+
220
+	if total > 0 {
221
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisIdExist)
222
+		return
223
+
224
+	}
225
+
226
+	err := service.UpdateAdminsHis(adminUserInfo.CurrentOrgId, his_user_id, id)
227
+	if err == nil {
228
+		c.ServeSuccessJSON(map[string]interface{}{
229
+			"his_user_id": his_user_id,
230
+		})
231
+	} else {
232
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
233
+
234
+	}
235
+	return
236
+
237
+}
238
+
239
+func (c *IntegrationConfigApiController) CreateAdminHis() {
240
+	his_user_id := c.GetString("his_user_id")
241
+	id, _ := c.GetInt64("id", 0)
242
+
243
+	adminUserInfo := c.GetAdminUserInfo()
244
+	adminRole, _ := service.FindVMAdminRoleById(adminUserInfo.CurrentOrgId, id, adminUserInfo.CurrentAppId)
245
+
246
+	total, _ := service.FindHisAdminByHisId(adminUserInfo.CurrentOrgId, his_user_id, adminUserInfo.CurrentAppId)
247
+
248
+	if total > 0 {
249
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisIdExist)
250
+		return
251
+
252
+	}
253
+
254
+	hisAdminRole := &models.HisUserAdminRole{
255
+		OrgId:       adminUserInfo.CurrentOrgId,
256
+		AdminUserId: adminRole.AdminUserId,
257
+		AppId:       adminRole.AppId,
258
+		RoleId:      adminRole.RoleId,
259
+		UserName:    adminRole.UserName,
260
+		Avatar:      adminRole.Avatar,
261
+		UserType:    adminRole.UserType,
262
+		UserTitle:   adminRole.UserTitle,
263
+		Intro:       adminRole.Intro,
264
+		Status:      1,
265
+		Ctime:       time.Now().Unix(),
266
+		Mtime:       time.Now().Unix(),
267
+		XtRoleId:    adminRole.ID,
268
+		HisUserId:   his_user_id,
269
+	}
270
+
271
+	err := service.CreateAdminsHis(hisAdminRole)
272
+	if err == nil {
273
+		c.ServeSuccessJSON(map[string]interface{}{
274
+			"his_role": hisAdminRole,
275
+		})
276
+	} else {
277
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
278
+
279
+	}
280
+	return
281
+
282
+}

+ 164 - 0
controllers/invoice_api_controller.go View File

@@ -0,0 +1,164 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"encoding/json"
8
+	"fmt"
9
+	"github.com/astaxie/beego"
10
+	"regexp"
11
+	"strconv"
12
+	"strings"
13
+	"time"
14
+)
15
+
16
+type InvoiceApiController struct {
17
+	BaseServeAPIController
18
+}
19
+
20
+func InvoiceApiRegistRouters() {
21
+	beego.Router("/api/invoice/applies", &InvoiceApiController{}, "Get:GetApplies")
22
+	beego.Router("/api/invoice/apply", &InvoiceApiController{}, "Post:CreateInvoice")
23
+	beego.Router("/api/invoice/noinvorders", &InvoiceApiController{}, "Get:GetNoInvOrders")
24
+	beego.Router("/api/invoices", &InvoiceApiController{}, "Get:GetInvoices")
25
+}
26
+
27
+func (c *InvoiceApiController) GetApplies() {
28
+	orders := c.GetString("orders")
29
+	if len(orders) == 0 {
30
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
31
+		return
32
+	}
33
+
34
+	if match, _ := regexp.MatchString("^([0-9]+[,])*([0-9]+)$", orders); !match {
35
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
36
+		return
37
+	}
38
+
39
+	adminUserInfo := c.GetAdminUserInfo()
40
+
41
+	ordersIDSlipe := make([]int64, 0)
42
+	ordersSlipe := strings.Split(orders, ",")
43
+	for index := range ordersSlipe {
44
+		orderid, _ := strconv.ParseInt(ordersSlipe[index], 10, 64)
45
+		if orderid > 0 {
46
+			ordersIDSlipe = append(ordersIDSlipe, orderid)
47
+		}
48
+	}
49
+	if len(ordersIDSlipe) == 0 {
50
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
51
+		return
52
+	}
53
+
54
+	has, nos, err := service.FindServeOrdersByIDs(adminUserInfo.CurrentOrgId, ordersIDSlipe)
55
+	if err != nil {
56
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
57
+		return
58
+	}
59
+
60
+	c.ServeSuccessJSON(map[string]interface{}{
61
+		"has": has,
62
+		"nos": nos,
63
+	})
64
+}
65
+
66
+func (c *InvoiceApiController) CreateInvoice() {
67
+	orders := c.GetString("orders")
68
+	if len(orders) == 0 {
69
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
70
+		return
71
+	}
72
+
73
+	if match, _ := regexp.MatchString("^([0-9]+[,])*([0-9]+)$", orders); !match {
74
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
75
+		return
76
+	}
77
+
78
+	adminUserInfo := c.GetAdminUserInfo()
79
+
80
+	ordersIDSlipe := make([]int64, 0)
81
+	ordersSlipe := strings.Split(orders, ",")
82
+	for index := range ordersSlipe {
83
+		orderid, _ := strconv.ParseInt(ordersSlipe[index], 10, 64)
84
+		if orderid > 0 {
85
+			ordersIDSlipe = append(ordersIDSlipe, orderid)
86
+		}
87
+	}
88
+	if len(ordersIDSlipe) == 0 {
89
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
90
+		return
91
+	}
92
+
93
+	_, nos, err := service.FindServeOrdersByIDs(adminUserInfo.CurrentOrgId, ordersIDSlipe)
94
+	if err != nil {
95
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
96
+		return
97
+	}
98
+	if len(nos) == 0 {
99
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
100
+		return
101
+	}
102
+
103
+	var invoiceData models.ServeInvoice
104
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &invoiceData)
105
+	if err != nil {
106
+		fmt.Println(err)
107
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
108
+		return
109
+	}
110
+
111
+	inds := make([]string, 0)
112
+	var inc float64
113
+	for index := range nos {
114
+		inds = append(inds, strconv.FormatInt(nos[index].ID, 10))
115
+		inc += nos[index].PayableAmount
116
+	}
117
+
118
+	invoiceData.OrgId = adminUserInfo.CurrentOrgId
119
+	invoiceData.Status = 1
120
+	invoiceData.CreatedTime = time.Now().Unix()
121
+	invoiceData.UpdatedTime = time.Now().Unix()
122
+	invoiceData.InvoiceAmountGross = inc
123
+	orders = "," + strings.Join(inds, ",") + ","
124
+	invoiceData.Orders = orders
125
+	invoiceData.InvoiceStatus = 1
126
+
127
+	err = service.CreateInvoice(&invoiceData)
128
+	if err != nil {
129
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeApplyInvoiceFail)
130
+		return
131
+	}
132
+
133
+	c.ServeSuccessJSON(map[string]interface{}{
134
+		"invoice": invoiceData,
135
+	})
136
+}
137
+
138
+func (c *InvoiceApiController) GetNoInvOrders() {
139
+	adminUserInfo := c.GetAdminUserInfo()
140
+
141
+	orders, err := service.FindUnInvoiceOrders(adminUserInfo.CurrentOrgId)
142
+	if err != nil {
143
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
144
+		return
145
+	}
146
+
147
+	c.ServeSuccessJSON(map[string]interface{}{
148
+		"orders": orders,
149
+	})
150
+}
151
+
152
+func (c *InvoiceApiController) GetInvoices() {
153
+	adminUserInfo := c.GetAdminUserInfo()
154
+
155
+	invoices, err := service.FindInvoices(adminUserInfo.CurrentOrgId)
156
+	if err != nil {
157
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
158
+		return
159
+	}
160
+
161
+	c.ServeSuccessJSON(map[string]interface{}{
162
+		"invoices": invoices,
163
+	})
164
+}

File diff suppressed because it is too large
+ 3000 - 0
controllers/manage_api_controller.go


+ 93 - 0
controllers/mobile_api_controllers/admin_user_api_controller.go View File

@@ -0,0 +1,93 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"encoding/json"
8
+	"fmt"
9
+	"time"
10
+
11
+	"github.com/astaxie/beego"
12
+)
13
+
14
+type AdminUserApiController struct {
15
+	MobileBaseAPIAuthController
16
+}
17
+
18
+func (c *AdminUserApiController) GetAdminUserElectronicSignature() {
19
+
20
+	adminUserInfo := c.GetMobileAdminUserInfo()
21
+
22
+	es, _ := service.GetAdminUserElectronicSignature(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id)
23
+
24
+	if es != nil {
25
+		c.ServeSuccessJSON(map[string]interface{}{
26
+			"state":                1,
27
+			"electronic_signature": es,
28
+		})
29
+	} else {
30
+		c.ServeSuccessJSON(map[string]interface{}{
31
+			"state": 0,
32
+		})
33
+	}
34
+	return
35
+}
36
+
37
+func (c *AdminUserApiController) SaveAdminUserElectronicSignature() {
38
+	adminUserInfo := c.GetMobileAdminUserInfo()
39
+
40
+	es, _ := service.GetAdminUserElectronicSignature(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id)
41
+
42
+	action := "update"
43
+	timeNow := time.Now().Unix()
44
+	if es == nil {
45
+		es = new(models.AdminUserElectronicSignature)
46
+		es.Status = 1
47
+		es.OrgId = adminUserInfo.Org.Id
48
+		es.AppId = adminUserInfo.App.Id
49
+		es.Ctime = timeNow
50
+		es.Creator = adminUserInfo.AdminUser.Id
51
+		action = "create"
52
+	}
53
+	es.Mtime = timeNow
54
+
55
+	var esdata models.AdminUserElectronicSignature
56
+	var err error
57
+	if err = json.Unmarshal(c.Ctx.Input.RequestBody, &esdata); err != nil {
58
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
59
+		return
60
+	}
61
+
62
+	es.Hash = esdata.Hash
63
+	es.Url = beego.AppConfig.String("qiniu_domain") + esdata.Hash
64
+
65
+	if action == "create" {
66
+		err = service.CreateAdminUserElectronicSignature(es)
67
+	} else {
68
+		err = service.SaveAdminUserElectronicSignature(es)
69
+	}
70
+	if err != nil {
71
+		fmt.Println(err)
72
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
73
+		return
74
+	}
75
+
76
+	c.ServeSuccessJSON(map[string]interface{}{
77
+		"electronic_signature": es,
78
+	})
79
+}
80
+
81
+func (c *AdminUserApiController) GetMyInfo() {
82
+	adminUserInfo := c.GetMobileAdminUserInfo()
83
+
84
+	roleInfo := adminUserInfo.AppRole
85
+
86
+	es, _ := service.GetAdminUserElectronicSignature(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id)
87
+
88
+	c.ServeSuccessJSON(map[string]interface{}{
89
+		"electronic_signature": es,
90
+		"roleInfo":             roleInfo,
91
+	})
92
+	return
93
+}

+ 7 - 0
controllers/mobile_api_controllers/advice_api_controller.go View File

@@ -0,0 +1,7 @@
1
+package mobile_api_controllers
2
+
3
+type AdviceAPIController struct {
4
+	MobileBaseAPIAuthController
5
+}
6
+
7
+// /m/api/dialysis/advices [get]

+ 109 - 0
controllers/mobile_api_controllers/check_api_controller.go View File

@@ -0,0 +1,109 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"time"
8
+)
9
+
10
+type CheckApiController struct {
11
+	MobileBaseAPIAuthController
12
+}
13
+
14
+func (c *CheckApiController) GetInspectionReference() {
15
+	patient, _ := c.GetInt64("patient")
16
+	if patient <= 0 {
17
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
18
+		return
19
+	}
20
+
21
+	adminUserInfo := c.GetMobileAdminUserInfo()
22
+
23
+	references, err := service.GetInspectionReference(adminUserInfo.Org.Id)
24
+	if err != nil {
25
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
26
+		return
27
+	}
28
+
29
+	counts, err := service.GetPatientInspectionProjectCount(adminUserInfo.Org.Id, patient)
30
+	if err != nil {
31
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
32
+		return
33
+	}
34
+	countsMap := make(map[int64]int64, 0)
35
+	for _, count := range counts {
36
+		countsMap[count.ProjectId] = count.Count
37
+	}
38
+
39
+	referenceMap := make(map[string]*models.InspectionReferenceMap, 0)
40
+
41
+	for _, reference := range references {
42
+		if _, exist := referenceMap[reference.Project]; !exist {
43
+			referenceMap[reference.Project] = new(models.InspectionReferenceMap)
44
+			referenceMap[reference.Project].Project = reference.Project
45
+			referenceMap[reference.Project].ProjectId = reference.ProjectId
46
+			referenceMap[reference.Project].ProjectName = reference.ProjectName
47
+			if _, cexit := countsMap[reference.ProjectId]; cexit {
48
+				referenceMap[reference.Project].Count = countsMap[reference.ProjectId]
49
+			}
50
+			referenceMap[reference.Project].InspectionReference = make([]models.InspectionReference, 0)
51
+		}
52
+		referenceMap[reference.Project].InspectionReference = append(referenceMap[reference.Project].InspectionReference, *reference)
53
+
54
+	}
55
+
56
+	reference := make([]*models.InspectionReferenceMap, 0)
57
+	for _, item := range referenceMap {
58
+		reference = append(reference, item)
59
+	}
60
+
61
+	rl := len(reference)
62
+	for index := 0; index < rl-1; index++ {
63
+		for jndex := 0; jndex < rl-1-index; jndex++ {
64
+			if reference[jndex].ProjectId > reference[jndex+1].ProjectId {
65
+				var item models.InspectionReferenceMap
66
+				item = *reference[jndex]
67
+				reference[jndex] = reference[jndex+1]
68
+				reference[jndex+1] = &item
69
+			}
70
+		}
71
+	}
72
+
73
+	c.ServeSuccessJSON(map[string]interface{}{
74
+		"reference": reference,
75
+	})
76
+	return
77
+
78
+}
79
+
80
+func (c *CheckApiController) GetInspections() {
81
+	patient, _ := c.GetInt64("patient_id", 0)
82
+	projectId, _ := c.GetInt64("project_id", 0)
83
+	if patient <= 0 || projectId <= 0 {
84
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
85
+		return
86
+	}
87
+	page, _ := c.GetInt64("page", 0)
88
+	if page <= 0 {
89
+		page = 1
90
+	}
91
+
92
+	adminUserInfo := c.GetMobileAdminUserInfo()
93
+
94
+	inspections, _, dateTime, err := service.GetPatientInspections(adminUserInfo.Org.Id, patient, projectId, page)
95
+	if err != nil {
96
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
97
+		return
98
+	}
99
+	date := ""
100
+	if len(inspections) > 0 {
101
+		date = time.Unix(dateTime, 0).Format("2006-01-02")
102
+	}
103
+
104
+	c.ServeSuccessJSON(map[string]interface{}{
105
+		"inspections": inspections,
106
+		"date":        date,
107
+	})
108
+	return
109
+}

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

@@ -0,0 +1,994 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	_ "XT_New/utils"
8
+	_ "encoding/json"
9
+	"fmt"
10
+	_ "github.com/astaxie/beego"
11
+	"github.com/jinzhu/gorm"
12
+	_ "strings"
13
+
14
+	// "fmt"
15
+	_ "reflect"
16
+	_ "strconv"
17
+	"time"
18
+)
19
+
20
+type CheckWeightApiController struct {
21
+	MobileBaseAPIAuthController
22
+}
23
+
24
+func (c *CheckWeightApiController) SaveBloodPressure() {
25
+	id, _ := c.GetInt64("patient", 0)
26
+	dialysistype, _ := c.GetInt64("dialysistype", 0)
27
+	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)   //收缩压
28
+	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0) //舒张压
29
+	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)                   //脉率
30
+
31
+	if id <= 0 {
32
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
33
+		return
34
+	}
35
+	if dialysistype <= 0 {
36
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
37
+		return
38
+	}
39
+	if systolic_blood_pressure <= 0 {
40
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
41
+		return
42
+	}
43
+	if diastolic_blood_pressure <= 0 {
44
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
45
+		return
46
+	}
47
+
48
+	adminUserInfo := c.GetMobileAdminUserInfo()
49
+	patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
50
+	if patient.ID == 0 {
51
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
52
+		return
53
+	}
54
+
55
+	thisTime := time.Now()
56
+
57
+	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
58
+	timeLayout := "2006-01-02 15:04:05"
59
+	loc, _ := time.LoadLocation("Local")
60
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
61
+	theAssessmentDateTime := theStartTime.Unix()
62
+
63
+	if dialysistype == 1 {
64
+		// 保存透前相关数据
65
+		// 获取透析处方
66
+		dialysisPrescribe, getDialysisPrescribeErr := service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
67
+		if getDialysisPrescribeErr != nil {
68
+			c.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
69
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
70
+			return
71
+		}
72
+
73
+		// 获取透析模版
74
+		dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
75
+		if getDialysisSolutionErr != nil {
76
+			c.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
77
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
78
+			return
79
+		}
80
+
81
+		// 插入透析处方
82
+		if dialysisPrescribe == nil && dialysisSolution != nil {
83
+			var newprescribe models.DialysisPrescription
84
+			newprescribe.UserOrgId = dialysisSolution.UserOrgId
85
+			newprescribe.PatientId = dialysisSolution.PatientId
86
+			newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
87
+			newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
88
+			newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
89
+			newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
90
+			newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
91
+			newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
92
+			newprescribe.ModeId = dialysisSolution.ModeId
93
+			newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
94
+			newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
95
+			newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
96
+			newprescribe.BloodFilter = dialysisSolution.BloodFilter
97
+			newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
98
+			newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
99
+			newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
100
+			newprescribe.Glucose = dialysisSolution.Glucose
101
+			newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
102
+			newprescribe.Kalium = dialysisSolution.Kalium
103
+			newprescribe.Sodium = dialysisSolution.Sodium
104
+			newprescribe.Calcium = dialysisSolution.Calcium
105
+			newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
106
+			newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
107
+			newprescribe.Conductivity = dialysisSolution.Conductivity
108
+			newprescribe.BodyFluid = dialysisSolution.BodyFluid
109
+			newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
110
+			newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
111
+			newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
112
+			newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
113
+			newprescribe.BloodAccess = dialysisSolution.BloodAccess
114
+			newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
115
+			newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
116
+			newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
117
+			newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
118
+			newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
119
+			newprescribe.Dialyzer = dialysisSolution.Dialyzer
120
+			newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
121
+			newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
122
+			newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
123
+			newprescribe.TargetKtv = dialysisSolution.TargetKtv
124
+
125
+			newprescribe.CreatedTime = time.Now().Unix()
126
+			newprescribe.UpdatedTime = time.Now().Unix()
127
+			newprescribe.RecordDate = theAssessmentDateTime
128
+			// newprescribe.DewaterAmount = dewater_amount
129
+			// newprescribe.TargetUltrafiltration = dewater_amount
130
+			newprescribe.Status = 1
131
+
132
+			err := service.AddSigleRecord(&newprescribe)
133
+			if err != nil {
134
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
135
+			}
136
+		}
137
+
138
+		if dialysisPrescribe == nil && dialysisSolution == nil {
139
+			var newprescribe models.DialysisPrescription
140
+			newprescribe.UserOrgId = adminUserInfo.Org.Id
141
+			newprescribe.PatientId = id
142
+			newprescribe.CreatedTime = time.Now().Unix()
143
+			newprescribe.UpdatedTime = time.Now().Unix()
144
+			newprescribe.RecordDate = theAssessmentDateTime
145
+			// newprescribe.DewaterAmount = dewater_amount
146
+			// newprescribe.TargetUltrafiltration = dewater_amount
147
+			newprescribe.Status = 1
148
+
149
+			err := service.AddSigleRecord(&newprescribe)
150
+			if err != nil {
151
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
152
+			}
153
+		}
154
+
155
+		if dialysisPrescribe != nil {
156
+			dialysisPrescribe.UpdatedTime = time.Now().Unix()
157
+			dialysisPrescribe.RecordDate = theAssessmentDateTime
158
+			// dialysisPrescribe.DewaterAmount = dewater_amount
159
+			// dialysisPrescribe.TargetUltrafiltration = dewater_amount
160
+			dialysisPrescribe.Status = 1
161
+			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
162
+			if updateErr != nil {
163
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
164
+			}
165
+		}
166
+
167
+		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
168
+		if getPEErr != nil {
169
+			c.ErrorLog("获取透前评估失败:%v", getPEErr)
170
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
171
+			return
172
+		}
173
+
174
+		var evaluation models.PredialysisEvaluation
175
+		if theEvaluation != nil {
176
+			evaluation = *theEvaluation
177
+		}
178
+
179
+		// 如果今天没有透前评估,则插入新的数据
180
+		if theEvaluation == nil {
181
+			evaluation.CreatedTime = time.Now().Unix()
182
+			evaluation.Status = 1
183
+			evaluation.AssessmentDate = theAssessmentDateTime
184
+			evaluation.PatientId = id
185
+			evaluation.UserOrgId = adminUserInfo.Org.Id
186
+			// 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
187
+			lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
188
+			// 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
189
+			assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.Org.Id, id, theAssessmentDateTime)
190
+			if getAADErr != nil {
191
+				c.ErrorLog("获取透后评估失败:%v", getAADErr)
192
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
193
+				return
194
+			}
195
+
196
+			// 获取干体重,先从干体重配置里去读,如果没有,则读取上一次透前评估的干体重
197
+			weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
198
+			if err == gorm.ErrRecordNotFound {
199
+				evaluation.DryWeight = lastPredialysisEvaluation.DryWeight
200
+			} else {
201
+				evaluation.DryWeight = weight.DryWeight
202
+			}
203
+
204
+			if assessmentAfterDislysis != nil {
205
+				evaluation.WeightAfterLastTransparency = assessmentAfterDislysis.WeightAfter
206
+			}
207
+
208
+			if lastPredialysisEvaluation != nil {
209
+				evaluation.BloodAccessPartId = lastPredialysisEvaluation.BloodAccessPartId
210
+				evaluation.BloodAccessPartOperaId = lastPredialysisEvaluation.BloodAccessPartOperaId
211
+				evaluation.AdditionalWeight = lastPredialysisEvaluation.AdditionalWeight // 衣物重
212
+			}
213
+		} else {
214
+			evaluation.UpdatedTime = time.Now().Unix()
215
+		}
216
+
217
+		evaluation.SystolicBloodPressure = systolic_blood_pressure   // 收缩压
218
+		evaluation.DiastolicBloodPressure = diastolic_blood_pressure // 舒张压
219
+		evaluation.PulseFrequency = pulse_frequency                  // 脉率
220
+
221
+		evaluation.AssessmentTime = time.Now().Unix()
222
+
223
+		err := service.UpadatePredialysisEvaluation(&evaluation)
224
+		if err != nil {
225
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
226
+			return
227
+		}
228
+
229
+		c.ServeSuccessJSON(map[string]interface{}{
230
+			"msg":        "ok",
231
+			"evaluation": evaluation,
232
+		})
233
+		return
234
+
235
+	} else {
236
+
237
+		// 保存透后相关数据
238
+		assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminUserInfo.Org.Id, id, theAssessmentDateTime)
239
+		if getAADErr != nil {
240
+			c.ErrorLog("获取透后评估失败:%v", getAADErr)
241
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
242
+			return
243
+		}
244
+
245
+		var afterevaluation models.AssessmentAfterDislysis
246
+		if assessmentAfterDislysis != nil {
247
+			afterevaluation = *assessmentAfterDislysis
248
+		}
249
+		if assessmentAfterDislysis == nil {
250
+			afterevaluation.CreatedTime = time.Now().Unix()
251
+			afterevaluation.Status = 1
252
+			afterevaluation.AssessmentDate = theAssessmentDateTime
253
+			afterevaluation.PatientId = id
254
+			afterevaluation.UserOrgId = adminUserInfo.Org.Id
255
+		} else {
256
+
257
+			afterevaluation.UpdatedTime = time.Now().Unix()
258
+		}
259
+
260
+		afterevaluation.SystolicBloodPressure = systolic_blood_pressure   // 收缩压
261
+		afterevaluation.DiastolicBloodPressure = diastolic_blood_pressure // 舒张压
262
+		afterevaluation.PulseFrequency = pulse_frequency                  // 脉率
263
+
264
+		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
265
+		if err == nil {
266
+			c.ServeSuccessJSON(map[string]interface{}{
267
+				"assessmentAfterDislysis": afterevaluation,
268
+			})
269
+		}
270
+	}
271
+
272
+}
273
+
274
+func (c *CheckWeightApiController) SavePatientInfoDialysis() {
275
+	id, _ := c.GetInt64("patient", 0)
276
+	dialysistype, _ := c.GetInt64("dialysistype", 0)
277
+	if id <= 0 {
278
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
279
+		return
280
+	}
281
+	if dialysistype <= 0 {
282
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
283
+		return
284
+	}
285
+
286
+	adminUserInfo := c.GetMobileAdminUserInfo()
287
+	patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
288
+	if patient.ID == 0 {
289
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
290
+		return
291
+	}
292
+
293
+	thisTime := time.Now()
294
+
295
+	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
296
+	// scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
297
+	timeLayout := "2006-01-02 15:04:05"
298
+	loc, _ := time.LoadLocation("Local")
299
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
300
+	// theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
301
+	theAssessmentDateTime := theStartTime.Unix()
302
+	// endTime := theEndTime.Unix()
303
+	// dry_weight,_ := c.GetFloat("dry_weight",0)  // 干体重
304
+	weighing_before, _ := c.GetFloat("weighing_before", 0) // 透前体重
305
+	dewater_amount, _ := c.GetFloat("dewater_amount", 0)   // 目标脱水量(L)
306
+
307
+	weight_after, _ := c.GetFloat("weight_after", 0) // 透后体重
308
+	weight_loss, _ := c.GetFloat("weight_loss", 0)   // 体重减少
309
+
310
+	schedual, _ := service.MobileGetSchedualDetail(adminUserInfo.Org.Id, patient.ID, theStartTime.Unix())
311
+
312
+	//dialysisSolution,_ := service.MobileGetDialysisSolutionByModeId(adminUserInfo.Org.Id,patient.ID,schedual.ModeId)
313
+
314
+	//dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminUserInfo.Org.Id, patient.ID, theStartTime.Unix(),schedual.ModeId)
315
+
316
+	//dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminUserInfo.Org.Id, patient.ID, theStartTime.Unix(),schedual.ModeId)
317
+
318
+	//dialysisPrescribe, _ := service.MobileGetDialysisPrescribeByModeId(adminUserInfo.Org.Id, patient.ID, theStartTime.Unix(),schedual.ModeId)
319
+
320
+	// 查询当前用户今天有没有排班,没有排班,则不处理
321
+	// daySchedule, _ := service.GetPatientScheduleFormDay(adminUserInfo.Org.Id, theAssessmentDateTime, endTime, id)
322
+	// if(len(daySchedule) <= 0) {
323
+	// 	c.ServeSuccessJSON(map[string]interface{}{
324
+	// 		"msg":        "ok",
325
+	// 	})
326
+	// 	return
327
+	// }
328
+
329
+	if dialysistype == 1 {
330
+		// 保存透前相关数据
331
+		// 获取透析处方
332
+
333
+		var lastDialysisPrescribe *models.DialysisPrescription
334
+		var dialysisSolution *models.DialysisSolution
335
+		var dialysisPrescribe *models.DialysisPrescription
336
+		var system_dialysisPrescribe *models.SystemPrescription
337
+
338
+		var mode_id int64
339
+
340
+		dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
341
+		lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeId(adminUserInfo.Org.Id, id, schedual.ModeId)
342
+		if schedual != nil {
343
+			// 获取透析模版
344
+			dialysisSolution, _ = service.MobileGetDialysisSolutionByModeId(adminUserInfo.Org.Id, id, schedual.ModeId)
345
+			system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeId(adminUserInfo.Org.Id, schedual.ModeId)
346
+			mode_id = schedual.ModeId
347
+		} else {
348
+			// 获取透析模版
349
+			dialysisSolution, _ = service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
350
+
351
+			if dialysisPrescribe == nil && dialysisSolution != nil {
352
+				mode_id = dialysisSolution.ModeId
353
+			}
354
+
355
+			if dialysisPrescribe == nil && dialysisSolution == nil {
356
+				mode_id = 0
357
+			}
358
+		}
359
+
360
+		// 插入透析处方
361
+		if dialysisPrescribe == nil && dialysisSolution != nil {
362
+			var newprescribe models.DialysisPrescription
363
+			newprescribe.UserOrgId = dialysisSolution.UserOrgId
364
+			newprescribe.PatientId = dialysisSolution.PatientId
365
+			newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
366
+			newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
367
+			newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
368
+			newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
369
+			newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
370
+			newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
371
+			newprescribe.ModeId = dialysisSolution.ModeId
372
+			newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
373
+			newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
374
+			newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
375
+			newprescribe.BloodFilter = dialysisSolution.BloodFilter
376
+			newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
377
+			newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
378
+			newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
379
+			newprescribe.Glucose = dialysisSolution.Glucose
380
+			newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
381
+			newprescribe.Kalium = dialysisSolution.Kalium
382
+			newprescribe.Sodium = dialysisSolution.Sodium
383
+			newprescribe.Calcium = dialysisSolution.Calcium
384
+			newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
385
+			newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
386
+			newprescribe.Conductivity = dialysisSolution.Conductivity
387
+			newprescribe.BodyFluid = dialysisSolution.BodyFluid
388
+			newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
389
+			newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
390
+			newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
391
+			newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
392
+			newprescribe.BloodAccess = dialysisSolution.BloodAccess
393
+			newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
394
+			newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
395
+			newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
396
+			newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
397
+			newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
398
+			newprescribe.Dialyzer = dialysisSolution.Dialyzer
399
+			newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
400
+			newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
401
+			newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
402
+			newprescribe.TargetKtv = dialysisSolution.TargetKtv
403
+
404
+			newprescribe.CreatedTime = time.Now().Unix()
405
+			newprescribe.UpdatedTime = time.Now().Unix()
406
+			newprescribe.RecordDate = theAssessmentDateTime
407
+			newprescribe.DewaterAmount = dewater_amount
408
+			newprescribe.TargetUltrafiltration = dewater_amount
409
+			newprescribe.Status = 1
410
+
411
+			err := service.AddSigleRecord(&newprescribe)
412
+			if err != nil {
413
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
414
+			}
415
+		}
416
+
417
+		if dialysisPrescribe == nil && dialysisSolution == nil {
418
+			if lastDialysisPrescribe != nil {
419
+				var newprescribe models.DialysisPrescription
420
+				newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
421
+				newprescribe.PatientId = lastDialysisPrescribe.PatientId
422
+				newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
423
+				newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
424
+				newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
425
+				newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
426
+				newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
427
+				newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
428
+				newprescribe.ModeId = lastDialysisPrescribe.ModeId
429
+				newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
430
+				newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
431
+				newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
432
+				newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
433
+				newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
434
+				newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
435
+				newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
436
+				newprescribe.Glucose = lastDialysisPrescribe.Glucose
437
+				newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
438
+				newprescribe.Kalium = lastDialysisPrescribe.Kalium
439
+				newprescribe.Sodium = lastDialysisPrescribe.Sodium
440
+				newprescribe.Calcium = lastDialysisPrescribe.Calcium
441
+				newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
442
+				newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
443
+				newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
444
+				newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
445
+				newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
446
+				newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
447
+				newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
448
+				newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
449
+				newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
450
+				newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
451
+				newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
452
+				newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
453
+				newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
454
+				newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
455
+				newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
456
+				newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
457
+				newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
458
+				newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
459
+				newprescribe.CreatedTime = time.Now().Unix()
460
+				newprescribe.UpdatedTime = time.Now().Unix()
461
+				newprescribe.RecordDate = theAssessmentDateTime
462
+				newprescribe.DewaterAmount = dewater_amount
463
+				newprescribe.TargetUltrafiltration = dewater_amount
464
+				newprescribe.Status = 1
465
+				err := service.AddSigleRecord(&newprescribe)
466
+				if err != nil {
467
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
468
+				}
469
+			} else if system_dialysisPrescribe != nil {
470
+				fmt.Println(dewater_amount)
471
+				fmt.Println("22111111")
472
+
473
+				var newprescribe models.DialysisPrescription
474
+				newprescribe.UserOrgId = system_dialysisPrescribe.UserOrgId
475
+				newprescribe.PatientId = id
476
+				newprescribe.Anticoagulant = system_dialysisPrescribe.Anticoagulant
477
+				newprescribe.AnticoagulantShouji = system_dialysisPrescribe.AnticoagulantShouji
478
+				newprescribe.AnticoagulantWeichi = system_dialysisPrescribe.AnticoagulantWeichi
479
+				newprescribe.AnticoagulantZongliang = system_dialysisPrescribe.AnticoagulantZongliang
480
+				newprescribe.AnticoagulantGaimingcheng = system_dialysisPrescribe.AnticoagulantGaimingcheng
481
+				newprescribe.AnticoagulantGaijiliang = system_dialysisPrescribe.AnticoagulantGaijiliang
482
+				newprescribe.ModeId = system_dialysisPrescribe.ModeId
483
+				newprescribe.DialysisDuration = system_dialysisPrescribe.DialysisDuration
484
+				newprescribe.ReplacementWay = system_dialysisPrescribe.ReplacementWay
485
+				newprescribe.HemodialysisMachine = system_dialysisPrescribe.HemodialysisMachine
486
+				newprescribe.BloodFilter = system_dialysisPrescribe.BloodFilter
487
+				newprescribe.PerfusionApparatus = system_dialysisPrescribe.PerfusionApparatus
488
+				newprescribe.BloodFlowVolume = system_dialysisPrescribe.BloodFlowVolume
489
+				newprescribe.DisplaceLiqui = system_dialysisPrescribe.DisplaceLiqui
490
+				newprescribe.Glucose = system_dialysisPrescribe.Glucose
491
+				newprescribe.DialysateFlow = system_dialysisPrescribe.DialysateFlow
492
+				newprescribe.Kalium = system_dialysisPrescribe.Kalium
493
+				newprescribe.Sodium = system_dialysisPrescribe.Sodium
494
+				newprescribe.Calcium = system_dialysisPrescribe.Calcium
495
+				newprescribe.Bicarbonate = system_dialysisPrescribe.Bicarbonate
496
+				newprescribe.DialysateTemperature = system_dialysisPrescribe.DialysateTemperature
497
+				newprescribe.Conductivity = system_dialysisPrescribe.Conductivity
498
+				newprescribe.BodyFluid = system_dialysisPrescribe.BodyFluid
499
+				newprescribe.SpecialMedicine = system_dialysisPrescribe.SpecialMedicine
500
+				newprescribe.SpecialMedicineOther = system_dialysisPrescribe.SpecialMedicineOther
501
+				newprescribe.DisplaceLiquiPart = system_dialysisPrescribe.DisplaceLiquiPart
502
+				newprescribe.DisplaceLiquiValue = system_dialysisPrescribe.DisplaceLiquiValue
503
+				newprescribe.BloodAccess = system_dialysisPrescribe.BloodAccess
504
+				newprescribe.Ultrafiltration = system_dialysisPrescribe.Ultrafiltration
505
+				newprescribe.DialysisDurationHour = system_dialysisPrescribe.DialysisDurationHour
506
+				newprescribe.DialysisDurationMinute = system_dialysisPrescribe.DialysisDurationMinute
507
+				newprescribe.DialysateFormulation = system_dialysisPrescribe.DialysateFormulation
508
+				newprescribe.Dialyzer = system_dialysisPrescribe.Dialyzer
509
+				newprescribe.ReplacementTotal = system_dialysisPrescribe.ReplacementTotal
510
+				newprescribe.DialyzerPerfusionApparatus = system_dialysisPrescribe.DialyzerPerfusionApparatus
511
+				newprescribe.BodyFluidOther = system_dialysisPrescribe.BodyFluidOther
512
+				newprescribe.TargetKtv = system_dialysisPrescribe.TargetKtv
513
+				newprescribe.CreatedTime = time.Now().Unix()
514
+				newprescribe.UpdatedTime = time.Now().Unix()
515
+				newprescribe.RecordDate = theAssessmentDateTime
516
+				newprescribe.DewaterAmount = dewater_amount
517
+				newprescribe.TargetUltrafiltration = dewater_amount
518
+				newprescribe.Status = 1
519
+				fmt.Println(newprescribe.DewaterAmount)
520
+				fmt.Println(newprescribe.TargetUltrafiltration)
521
+
522
+				err := service.AddSigleRecord(&newprescribe)
523
+				if err != nil {
524
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
525
+				}
526
+
527
+			} else {
528
+				var newprescribe models.DialysisPrescription
529
+				newprescribe.UserOrgId = adminUserInfo.Org.Id
530
+				newprescribe.PatientId = id
531
+				newprescribe.ModeId = mode_id
532
+				newprescribe.CreatedTime = time.Now().Unix()
533
+				newprescribe.UpdatedTime = time.Now().Unix()
534
+				newprescribe.RecordDate = theAssessmentDateTime
535
+				newprescribe.DewaterAmount = dewater_amount
536
+				newprescribe.TargetUltrafiltration = dewater_amount
537
+				newprescribe.Status = 1
538
+
539
+				err := service.AddSigleRecord(&newprescribe)
540
+				if err != nil {
541
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
542
+				}
543
+			}
544
+		}
545
+
546
+		if dialysisPrescribe != nil {
547
+			dialysisPrescribe.UpdatedTime = time.Now().Unix()
548
+			dialysisPrescribe.RecordDate = theAssessmentDateTime
549
+			dialysisPrescribe.DewaterAmount = dewater_amount
550
+			dialysisPrescribe.TargetUltrafiltration = dewater_amount
551
+			dialysisPrescribe.Status = 1
552
+			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
553
+			if updateErr != nil {
554
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
555
+			}
556
+		}
557
+
558
+		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
559
+		if getPEErr != nil {
560
+			c.ErrorLog("获取透前评估失败:%v", getPEErr)
561
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
562
+			return
563
+		}
564
+
565
+		var evaluation models.PredialysisEvaluation
566
+		if theEvaluation != nil {
567
+			evaluation = *theEvaluation
568
+		}
569
+
570
+		// 如果今天没有透前评估,则插入新的数据
571
+		if theEvaluation == nil {
572
+			evaluation.CreatedTime = time.Now().Unix()
573
+			evaluation.Status = 1
574
+			evaluation.AssessmentDate = theAssessmentDateTime
575
+			evaluation.PatientId = id
576
+			evaluation.UserOrgId = adminUserInfo.Org.Id
577
+			// 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
578
+			lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
579
+			// 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
580
+			assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.Org.Id, id, theAssessmentDateTime)
581
+			if getAADErr != nil {
582
+				c.ErrorLog("获取透后评估失败:%v", getAADErr)
583
+				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
584
+				return
585
+			}
586
+
587
+			// 获取干体重,先从干体重配置里去读,如果没有,则读取上一次透前评估的干体重
588
+			weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
589
+			if err == gorm.ErrRecordNotFound {
590
+				if lastPredialysisEvaluation != nil {
591
+					evaluation.DryWeight = lastPredialysisEvaluation.DryWeight
592
+				} else {
593
+					evaluation.DryWeight = 0
594
+				}
595
+			} else {
596
+				evaluation.DryWeight = weight.DryWeight
597
+			}
598
+
599
+			if assessmentAfterDislysis != nil {
600
+				evaluation.WeightAfterLastTransparency = assessmentAfterDislysis.WeightAfter
601
+			}
602
+
603
+			if lastPredialysisEvaluation != nil {
604
+				evaluation.BloodAccessPartId = lastPredialysisEvaluation.BloodAccessPartId
605
+				evaluation.BloodAccessPartOperaId = lastPredialysisEvaluation.BloodAccessPartOperaId
606
+				evaluation.AdditionalWeight = lastPredialysisEvaluation.AdditionalWeight
607
+				evaluation.Temperature = lastPredialysisEvaluation.Temperature
608
+				evaluation.BreathingRate = lastPredialysisEvaluation.BreathingRate
609
+				evaluation.Catheter = lastPredialysisEvaluation.Catheter
610
+				evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
611
+				evaluation.PulseFrequency = lastPredialysisEvaluation.PulseFrequency
612
+				evaluation.Complication = lastPredialysisEvaluation.Complication
613
+				evaluation.LastPostDialysis = lastPredialysisEvaluation.LastPostDialysis
614
+				evaluation.DialysisInterphase = lastPredialysisEvaluation.DialysisInterphase
615
+				evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
616
+				evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
617
+				evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
618
+
619
+			}
620
+		} else {
621
+			evaluation.UpdatedTime = time.Now().Unix()
622
+		}
623
+
624
+		evaluation.WeightBefore = weighing_before
625
+		evaluation.AssessmentTime = time.Now().Unix()
626
+
627
+		err := service.UpadatePredialysisEvaluation(&evaluation)
628
+		if err != nil {
629
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
630
+			return
631
+		}
632
+
633
+		c.ServeSuccessJSON(map[string]interface{}{
634
+			"msg":        "ok",
635
+			"evaluation": evaluation,
636
+		})
637
+		return
638
+
639
+	} else {
640
+
641
+		// 保存透后相关数据
642
+		assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminUserInfo.Org.Id, id, theAssessmentDateTime)
643
+		if getAADErr != nil {
644
+			c.ErrorLog("获取透后评估失败:%v", getAADErr)
645
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
646
+			return
647
+		}
648
+
649
+		var afterevaluation models.AssessmentAfterDislysis
650
+		if assessmentAfterDislysis != nil {
651
+			afterevaluation = *assessmentAfterDislysis
652
+		}
653
+		if assessmentAfterDislysis == nil {
654
+			afterevaluation.CreatedTime = time.Now().Unix()
655
+			afterevaluation.Status = 1
656
+			afterevaluation.AssessmentDate = theAssessmentDateTime
657
+			afterevaluation.PatientId = id
658
+			afterevaluation.UserOrgId = adminUserInfo.Org.Id
659
+		} else {
660
+
661
+			afterevaluation.UpdatedTime = time.Now().Unix()
662
+		}
663
+
664
+		afterevaluation.WeightAfter = weight_after
665
+		afterevaluation.WeightLoss = weight_loss
666
+		// if (adminUserInfo.Org.Id == 9538){
667
+		// 	afterevaluation.ActualUltrafiltration = weight_loss * 1000  //中能建的计量单位是毫升(ml)
668
+		// } else {
669
+		// 	afterevaluation.ActualUltrafiltration = weight_loss  // 计量单位是L
670
+		// }
671
+
672
+		err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
673
+		if err == nil {
674
+			c.ServeSuccessJSON(map[string]interface{}{
675
+				"assessmentAfterDislysis": afterevaluation,
676
+			})
677
+		}
678
+	}
679
+}
680
+
681
+func (c *CheckWeightApiController) GetPatientInfoDialysis() {
682
+	id, _ := c.GetInt64("patient", 0)
683
+	if id <= 0 {
684
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
685
+		return
686
+	}
687
+	adminUserInfo := c.GetMobileAdminUserInfo()
688
+	patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
689
+	if patient.ID <= 0 {
690
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
691
+		return
692
+	}
693
+
694
+	var dialysisinfo map[string]interface{}
695
+	dialysisinfo = make(map[string]interface{})
696
+
697
+	dialysisinfo["id"] = patient.ID
698
+	dialysisinfo["name"] = patient.Name
699
+	dialysisinfo["dialysis_no"] = patient.DialysisNo
700
+
701
+	thisTime := time.Now()
702
+
703
+	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
704
+	scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
705
+	timeLayout := "2006-01-02 15:04:05"
706
+	loc, _ := time.LoadLocation("Local")
707
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
708
+	theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
709
+	startTime := theStartTime.Unix()
710
+	endTime := theEndTime.Unix()
711
+
712
+	// 判断当前用户是透析前还是透析后
713
+	var dialysistype int
714
+
715
+	_, dialysisOrder := service.FindDialysisRecordById(adminUserInfo.Org.Id, id, startTime)
716
+	if dialysisOrder == nil {
717
+		dialysistype = 1
718
+	} else {
719
+		dialysistype = 2
720
+	}
721
+
722
+	// 获取当前或者下次排班信息
723
+	var sc map[string]interface{}
724
+	sc = make(map[string]interface{})
725
+	if dialysistype == 1 {
726
+		daySchedule, _ := service.GetPatientScheduleFormDay(adminUserInfo.Org.Id, startTime, endTime, id)
727
+		if len(daySchedule) <= 0 {
728
+			sc["code"] = 1
729
+			sc["msg"] = "抱歉,您今天没有排版!"
730
+			sc["mode"] = 0
731
+			sc["data"] = daySchedule
732
+		} else {
733
+			if daySchedule[0].Schedule.ID > 0 {
734
+				sc["code"] = 0
735
+				sc["msg"] = ""
736
+				sc["mode"] = daySchedule[0].Schedule.ModeId
737
+				sc["data"] = daySchedule
738
+			} else {
739
+				sc["code"] = 1
740
+				sc["msg"] = "抱歉,您今天没有排版!"
741
+				sc["mode"] = 0
742
+				sc["data"] = daySchedule
743
+			}
744
+		}
745
+	} else {
746
+		nextSchedule, _ := service.GetNextSchedule(adminUserInfo.Org.Id, endTime, id)
747
+		if len(nextSchedule) <= 0 {
748
+			sc["code"] = 1
749
+			sc["msg"] = "抱歉,您后续没有排版!"
750
+			sc["mode"] = 0
751
+			sc["data"] = nextSchedule
752
+		} else {
753
+			if nextSchedule[0].Schedule.ID > 0 {
754
+				sc["code"] = 0
755
+				sc["msg"] = ""
756
+				sc["mode"] = nextSchedule[0].Schedule.ModeId
757
+				sc["data"] = nextSchedule
758
+			} else {
759
+				sc["code"] = 1
760
+				sc["msg"] = "抱歉,您后续没有排版!"
761
+				sc["mode"] = 0
762
+				sc["data"] = nextSchedule
763
+			}
764
+		}
765
+	}
766
+
767
+	switch sc["mode"] {
768
+	case 1:
769
+		sc["mode"] = "HD"
770
+	case 2:
771
+		sc["mode"] = "HDF"
772
+	case 3:
773
+		sc["mode"] = "HD+HP"
774
+	case 4:
775
+		sc["mode"] = "HP"
776
+	case 5:
777
+		sc["mode"] = "HF"
778
+	case 6:
779
+		sc["mode"] = "SCUF"
780
+	case 7:
781
+		sc["mode"] = "IUF"
782
+	case 8:
783
+		sc["mode"] = "HFHD"
784
+	case 9:
785
+		sc["mode"] = "HFHD+HP"
786
+	case 10:
787
+		sc["mode"] = "PHF"
788
+	case 11:
789
+		sc["mode"] = "HFR"
790
+	case 12:
791
+		sc["mode"] = "HDF+HP"
792
+	case 13:
793
+		sc["mode"] = "CRRT"
794
+	case 14:
795
+		sc["mode"] = "腹水回输"
796
+	case 15:
797
+		sc["mode"] = "HD前置换"
798
+	case 16:
799
+		sc["mode"] = "HD后置换"
800
+	case 17:
801
+		sc["mode"] = "HDF前置换"
802
+	case 18:
803
+		sc["mode"] = "HDF后置换"
804
+	default:
805
+		sc["mode"] = "HD"
806
+	}
807
+
808
+	// 获取患者透前干体重或者获取患者透前体重
809
+	var dry_weight map[string]interface{}
810
+	dry_weight = make(map[string]interface{})
811
+	if dialysistype == 1 {
812
+
813
+		lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
814
+		weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
815
+		if err == gorm.ErrRecordNotFound {
816
+			if getLPEErr != nil {
817
+				dry_weight["code"] = 1
818
+				dry_weight["dry_weight"] = nil
819
+			} else {
820
+				if lastPredialysisEvaluation == nil {
821
+					dry_weight["code"] = 1
822
+					dry_weight["dry_weight"] = nil
823
+				} else {
824
+					// 传输的干体重实际为干体重加上衣服重
825
+					dry_weight["code"] = 0
826
+					dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight + lastPredialysisEvaluation.AdditionalWeight
827
+				}
828
+			}
829
+		} else {
830
+			if err != nil {
831
+				dry_weight["code"] = 1
832
+				dry_weight["dry_weight"] = nil
833
+			} else {
834
+				dry_weight["code"] = 0
835
+				if getLPEErr != nil {
836
+					dry_weight["code"] = 0
837
+					dry_weight["dry_weight"] = weight.DryWeight
838
+				} else {
839
+					if lastPredialysisEvaluation == nil {
840
+						dry_weight["code"] = 1
841
+						dry_weight["dry_weight"] = weight.DryWeight
842
+					} else {
843
+						// 传输的干体重实际为干体重加上衣服重
844
+						dry_weight["code"] = 0
845
+						dry_weight["dry_weight"] = weight.DryWeight + lastPredialysisEvaluation.AdditionalWeight
846
+					}
847
+				}
848
+			}
849
+		}
850
+
851
+	} else {
852
+		predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, startTime)
853
+		if getPEErr != nil {
854
+			dry_weight["code"] = 1
855
+			dry_weight["dry_weight"] = nil
856
+		} else {
857
+			if predialysisEvaluation == nil {
858
+				dry_weight["code"] = 1
859
+				dry_weight["dry_weight"] = nil
860
+			} else {
861
+				dry_weight["code"] = 0
862
+				dry_weight["dry_weight"] = predialysisEvaluation.WeightBefore
863
+			}
864
+		}
865
+	}
866
+
867
+	c.ServeSuccessJSON(map[string]interface{}{
868
+		"dialysistype": dialysistype,
869
+		"patient":      dialysisinfo,
870
+		"schedule":     sc,
871
+		"dryweight":    dry_weight,
872
+	})
873
+	return
874
+}
875
+
876
+func (c *CheckWeightApiController) GetPatientInfoBeforeDialysis() {
877
+	id, _ := c.GetInt64("patient", 0)
878
+	if id <= 0 {
879
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
880
+		return
881
+	}
882
+	adminUserInfo := c.GetMobileAdminUserInfo()
883
+	patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
884
+	if patient.ID == 0 {
885
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
886
+		return
887
+	}
888
+
889
+	var dialysisinfo map[string]interface{}
890
+	dialysisinfo = make(map[string]interface{})
891
+
892
+	dialysisinfo["id"] = patient.ID
893
+	dialysisinfo["name"] = patient.Name
894
+	dialysisinfo["dialysis_no"] = patient.DialysisNo
895
+
896
+	thisTime := time.Now()
897
+
898
+	scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
899
+	scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
900
+	fmt.Println(scheduleDateStart, scheduleDateEnd)
901
+	timeLayout := "2006-01-02 15:04:05"
902
+	loc, _ := time.LoadLocation("Local")
903
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
904
+	theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
905
+	fmt.Println(theStartTime, theEndTime)
906
+	startTime := theStartTime.Unix()
907
+	endTime := theEndTime.Unix()
908
+
909
+	var sc map[string]interface{}
910
+	sc = make(map[string]interface{})
911
+	//一天只有排班一次
912
+	daySchedule, _ := service.GetDaySchedule(adminUserInfo.Org.Id, startTime, endTime, id)
913
+	if daySchedule.ID > 0 {
914
+		switch daySchedule.ModeId {
915
+		case 1:
916
+			sc["mode"] = "HD"
917
+		case 2:
918
+			sc["mode"] = "HDF"
919
+		case 3:
920
+			sc["mode"] = "HD+HP"
921
+		case 4:
922
+			sc["mode"] = "HP"
923
+		case 5:
924
+			sc["mode"] = "HF"
925
+		case 6:
926
+			sc["mode"] = "SCUF"
927
+		case 7:
928
+			sc["mode"] = "IUF"
929
+		case 8:
930
+			sc["mode"] = "HFHD"
931
+		case 9:
932
+			sc["mode"] = "HFHD+HP"
933
+		case 10:
934
+			sc["mode"] = "PHF"
935
+		case 11:
936
+			sc["mode"] = "HFR"
937
+		case 12:
938
+			sc["mode"] = "HDF+HP"
939
+		case 13:
940
+			sc["mode"] = "CRRT"
941
+		case 14:
942
+			sc["mode"] = "腹水回输"
943
+		case 15:
944
+			sc["mode"] = "HD前置换"
945
+		case 16:
946
+			sc["mode"] = "HD后置换"
947
+		case 17:
948
+			sc["mode"] = "HDF前置换"
949
+		case 18:
950
+			sc["mode"] = "HDF后置换"
951
+		default:
952
+			sc["mode"] = "HD"
953
+		}
954
+		sc["code"] = 0
955
+		sc["msg"] = ""
956
+		sc["data"] = daySchedule
957
+	} else {
958
+		sc["code"] = 1
959
+		sc["msg"] = "抱歉,您今天没有排版!"
960
+		sc["mode"] = ""
961
+		sc["data"] = daySchedule
962
+	}
963
+
964
+	fmt.Println(sc)
965
+
966
+	type dryWeight struct {
967
+		code       int
968
+		dry_weight float64
969
+	}
970
+
971
+	var dry_weight map[string]interface{}
972
+	dry_weight = make(map[string]interface{})
973
+
974
+	lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, startTime)
975
+	if getLPEErr != nil {
976
+		dry_weight["code"] = 1
977
+		dry_weight["dry_weight"] = nil
978
+	} else {
979
+		if lastPredialysisEvaluation == nil {
980
+			dry_weight["code"] = 1
981
+			dry_weight["dry_weight"] = nil
982
+		} else {
983
+			dry_weight["code"] = 0
984
+			dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight
985
+		}
986
+	}
987
+
988
+	c.ServeSuccessJSON(map[string]interface{}{
989
+		"patient":   dialysisinfo,
990
+		"schedule":  sc,
991
+		"dryweight": dry_weight,
992
+	})
993
+	return
994
+}

File diff suppressed because it is too large
+ 6252 - 0
controllers/mobile_api_controllers/dialysis_api_controller.go


+ 507 - 0
controllers/mobile_api_controllers/dialysis_api_controller_extend.go View File

@@ -0,0 +1,507 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"fmt"
9
+	"github.com/jinzhu/gorm"
10
+	"time"
11
+)
12
+
13
+// /m/api/monitor/add [post]
14
+// @param patient_id:int
15
+// @param order_id?:int 透析记录 ID
16
+// @param date?:int 日期(10位时间戳)
17
+// @param operate_time?:int 实际测量日期(10位时间戳)
18
+// @param time?:string 时间(hh:mm) 废弃
19
+// @param pulse_frequency?:float 脉率(P)(次/min)
20
+// @param breathing_rated?:float 呼吸频率(R)(次/min)
21
+// @param systolic_bp?:float 收缩压
22
+// @param diastolic_bp?:float 舒张压
23
+// @param bp_type?:int 血压测量类型
24
+// @param blood_flow_volume?:float 血流量(ml/min)
25
+// @param venous_pressure?:float 静脉压
26
+// @param venous_pressure_unit?:string 静脉压单位
27
+// @param arterial_pressure?:float 动脉压
28
+// @param transmembrane_pressure?:float 跨膜压
29
+// @param transmembrane_pressure_unit?:string 跨膜压单位
30
+// @param ultrafiltration_rate?:float 超滤率(ml/h)
31
+// @param ultrafiltration_volume?:float 超滤量(ml)
32
+// @param sodium_concentration?:float 钠浓度(mmol/L)
33
+// @param dialysate_temperature?:float 透析液温度(℃)
34
+// @param replacement_rate?:float 置换率(ml/min)
35
+// @param displacement_quantity?:float 置换量(L)
36
+// @param ktv?:float KT/V(在线)
37
+// @param symptom?:string 症状
38
+// @param dispose?:string 处理
39
+// @param result?:string 结果
40
+// @param monitoring_nurse?:int 监测人
41
+func (this *DialysisAPIController) AddMonitorRecord() {
42
+	patientID, _ := this.GetInt64("patient_id")
43
+	if patientID <= 0 {
44
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
45
+		return
46
+	}
47
+	orderID, _ := this.GetInt64("order_id")
48
+	if orderID < 0 {
49
+		orderID = 0
50
+	}
51
+	date, _ := this.GetInt64("date")
52
+	operateTime, _ := this.GetInt64("operate_time")
53
+
54
+	// recordTime := this.GetString("time")
55
+	if date <= 0 || operateTime <= 0 {
56
+		date = 0
57
+		operateTime = 0
58
+		// recordTime = ""
59
+	}
60
+	fmt.Println(date)
61
+	fmt.Println(operateTime)
62
+
63
+	pulseFrequency, _ := this.GetFloat("pulse_frequency")
64
+	breathingRated, _ := this.GetFloat("breathing_rated")
65
+	systolicBP, _ := this.GetFloat("systolic_bp")
66
+	diastolicBP, _ := this.GetFloat("diastolic_bp")
67
+	BPType, _ := this.GetInt("bp_type")
68
+	bloodFlowVolume, _ := this.GetFloat("blood_flow_volume")
69
+	venousPressure, _ := this.GetFloat("venous_pressure")
70
+	venousPressureUnit := this.GetString("venous_pressure_unit")
71
+	arterialPressure, _ := this.GetFloat("arterial_pressure")
72
+	transmembranePressure, _ := this.GetFloat("transmembrane_pressure")
73
+	transmembranePressureUnit := this.GetString("transmembrane_pressure_unit")
74
+	ultrafiltrationRate, _ := this.GetFloat("ultrafiltration_rate")
75
+	ultrafiltrationVolume, _ := this.GetFloat("ultrafiltration_volume")
76
+	sodiumConcentration, _ := this.GetFloat("sodium_concentration")
77
+	dialysateTemperature, _ := this.GetFloat("dialysate_temperature")
78
+	temperature, _ := this.GetFloat("temperature")
79
+	replacementRate, _ := this.GetFloat("replacement_rate")
80
+	displacementQuantity, _ := this.GetFloat("displacement_quantity")
81
+	ktv, _ := this.GetFloat("ktv")
82
+	symptom := this.GetString("symptom")
83
+	dispose := this.GetString("dispose")
84
+	conductivity, _ := this.GetFloat("conductivity")
85
+	displacement_flow_quantity, _ := this.GetFloat("displacement_flow_quantity")
86
+	blood_oxygen_saturation := this.GetString("blood_oxygen_saturation")
87
+	result := this.GetString("result")
88
+	monitoringNurse, _ := this.GetInt64("monitoring_nurse")
89
+
90
+	adminInfo := this.GetMobileAdminUserInfo()
91
+	patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
92
+	if getPatientErr != nil {
93
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
94
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
95
+		return
96
+	} else if patient == nil {
97
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
98
+		return
99
+	}
100
+
101
+	record := models.MonitoringRecord{
102
+		UserOrgId:       adminInfo.Org.Id,
103
+		PatientId:       patientID,
104
+		DialysisOrderId: orderID,
105
+		MonitoringDate:  date,
106
+		OperateTime:     operateTime,
107
+		// MonitoringTime:            recordTime,
108
+		PulseFrequency:            pulseFrequency,
109
+		BreathingRate:             breathingRated,
110
+		SystolicBloodPressure:     systolicBP,
111
+		DiastolicBloodPressure:    diastolicBP,
112
+		BloodPressureType:         int64(BPType),
113
+		BloodFlowVolume:           bloodFlowVolume,
114
+		VenousPressure:            venousPressure,
115
+		VenousPressureUnit:        venousPressureUnit,
116
+		ArterialPressure:          arterialPressure,
117
+		TransmembranePressure:     transmembranePressure,
118
+		TransmembranePressureUnit: transmembranePressureUnit,
119
+		UltrafiltrationRate:       ultrafiltrationRate,
120
+		UltrafiltrationVolume:     ultrafiltrationVolume,
121
+		SodiumConcentration:       sodiumConcentration,
122
+		DialysateTemperature:      dialysateTemperature,
123
+		Temperature:               temperature,
124
+		ReplacementRate:           replacementRate,
125
+		DisplacementQuantity:      displacementQuantity,
126
+		Ktv:                       ktv,
127
+		Symptom:                   symptom,
128
+		Dispose:                   dispose,
129
+		Result:                    result,
130
+		MonitoringNurse:           monitoringNurse,
131
+		Status:                    1,
132
+		CreatedTime:               time.Now().Unix(),
133
+		UpdatedTime:               time.Now().Unix(),
134
+		Conductivity:              conductivity,
135
+		DisplacementFlowQuantity:  displacement_flow_quantity,
136
+		BloodOxygenSaturation:     blood_oxygen_saturation,
137
+	}
138
+
139
+	err := service.CreateMonitor(&record)
140
+	if err != nil {
141
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
142
+		return
143
+	}
144
+
145
+	this.ServeSuccessJSON(map[string]interface{}{
146
+		"monitor": record,
147
+	})
148
+}
149
+
150
+// /m/api/monitor/edit [post]
151
+// @param patient_id:int
152
+// @param order_id?:int 透析记录 ID
153
+// @param date?:int 日期(10位时间戳)
154
+// @param operate_time?:int 实际测量日期(10位时间戳)
155
+// @param time?:string 时间(hh:mm)废弃
156
+// @param pulse_frequency?:float 脉率(P)(次/min)
157
+// @param breathing_rated?:float 呼吸频率(R)(次/min)
158
+// @param systolic_bp?:float 收缩压
159
+// @param diastolic_bp?:float 舒张压
160
+// @param bp_type?:int 血压测量类型
161
+// @param blood_flow_volume?:float 血流量(ml/min)
162
+// @param venous_pressure?:float 静脉压
163
+// @param venous_pressure_unit?:string 静脉压单位
164
+// @param arterial_pressure?:float 动脉压
165
+// @param transmembrane_pressure?:float 跨膜压
166
+// @param transmembrane_pressure_unit?:string 跨膜压单位
167
+// @param ultrafiltration_rate?:float 超滤率(ml/h)
168
+// @param ultrafiltration_volume?:float 超滤量(ml)
169
+// @param sodium_concentration?:float 钠浓度(mmol/L)
170
+// @param dialysate_temperature?:float 透析液温度(℃)
171
+// @param replacement_rate?:float 置换率(ml/min)
172
+// @param displacement_quantity?:float 置换量(L)
173
+// @param ktv?:float KT/V(在线)
174
+// @param symptom?:string 症状
175
+// @param dispose?:string 处理
176
+// @param result?:string 结果
177
+// @param monitoring_nurse?:int 监测人
178
+func (this *DialysisAPIController) EditMonitorRecord() {
179
+	patientID, _ := this.GetInt64("patient_id")
180
+	if patientID <= 0 {
181
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
182
+		return
183
+	}
184
+	id, _ := this.GetInt64("id")
185
+	if id <= 0 {
186
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
187
+		return
188
+	}
189
+	orderID, _ := this.GetInt64("order_id")
190
+	if orderID < 0 {
191
+		orderID = 0
192
+	}
193
+	date, _ := this.GetInt64("date")
194
+	operateTime, _ := this.GetInt64("operate_time")
195
+	if date <= 0 {
196
+		date = 0
197
+		operateTime = 0
198
+	}
199
+	pulseFrequency, _ := this.GetFloat("pulse_frequency")
200
+	breathingRated, _ := this.GetFloat("breathing_rated")
201
+	systolicBP, _ := this.GetFloat("systolic_bp")
202
+	diastolicBP, _ := this.GetFloat("diastolic_bp")
203
+	BPType, _ := this.GetInt("bp_type")
204
+	bloodFlowVolume, _ := this.GetFloat("blood_flow_volume")
205
+	venousPressure, _ := this.GetFloat("venous_pressure")
206
+	venousPressureUnit := this.GetString("venous_pressure_unit")
207
+	arterialPressure, _ := this.GetFloat("arterial_pressure")
208
+	transmembranePressure, _ := this.GetFloat("transmembrane_pressure")
209
+	transmembranePressureUnit := this.GetString("transmembrane_pressure_unit")
210
+	ultrafiltrationRate, _ := this.GetFloat("ultrafiltration_rate")
211
+	ultrafiltrationVolume, _ := this.GetFloat("ultrafiltration_volume")
212
+	sodiumConcentration, _ := this.GetFloat("sodium_concentration")
213
+	dialysateTemperature, _ := this.GetFloat("dialysate_temperature")
214
+	temperature, _ := this.GetFloat("temperature")
215
+	replacementRate, _ := this.GetFloat("replacement_rate")
216
+	displacementQuantity, _ := this.GetFloat("displacement_quantity")
217
+	ktv, _ := this.GetFloat("ktv")
218
+	symptom := this.GetString("symptom")
219
+	dispose := this.GetString("dispose")
220
+	result := this.GetString("result")
221
+	blood_oxygen_saturation := this.GetString("blood_oxygen_saturation")
222
+	monitoringNurse, _ := this.GetInt64("monitoring_nurse")
223
+	conductivity, _ := this.GetFloat("conductivity")
224
+	displacement_flow_quantity, _ := this.GetFloat("displacement_flow_quantity")
225
+
226
+	adminInfo := this.GetMobileAdminUserInfo()
227
+
228
+	monitor, err := service.GetMonitor(adminInfo.Org.Id, patientID, id)
229
+	if err != nil {
230
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
231
+		return
232
+	}
233
+	//if monitor == nil {
234
+	//	this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorNotExist)
235
+	//	return
236
+	//} else {
237
+	//	if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
238
+	//		headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.Org.Id, adminInfo.App.Id, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
239
+	//		if getPermissionErr != nil {
240
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
241
+	//			return
242
+	//		} else if headNursePermission == nil {
243
+	//			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
244
+	//			return
245
+	//		}
246
+	//	}
247
+	//}
248
+	monitor.Conductivity = conductivity
249
+	monitor.DialysisOrderId = orderID
250
+	monitor.MonitoringDate = date
251
+	monitor.OperateTime = operateTime
252
+	monitor.PulseFrequency = pulseFrequency
253
+	monitor.BreathingRate = breathingRated
254
+	monitor.SystolicBloodPressure = systolicBP
255
+	monitor.DiastolicBloodPressure = diastolicBP
256
+	monitor.BloodPressureType = int64(BPType)
257
+	monitor.BloodFlowVolume = bloodFlowVolume
258
+	monitor.VenousPressure = venousPressure
259
+	monitor.VenousPressureUnit = venousPressureUnit
260
+	monitor.ArterialPressure = arterialPressure
261
+	monitor.TransmembranePressure = transmembranePressure
262
+	monitor.TransmembranePressureUnit = transmembranePressureUnit
263
+	monitor.UltrafiltrationRate = ultrafiltrationRate
264
+	monitor.UltrafiltrationVolume = ultrafiltrationVolume
265
+	monitor.SodiumConcentration = sodiumConcentration
266
+	monitor.DialysateTemperature = dialysateTemperature
267
+	monitor.Temperature = temperature
268
+	monitor.ReplacementRate = replacementRate
269
+	monitor.DisplacementQuantity = displacementQuantity
270
+	monitor.Ktv = ktv
271
+	monitor.Symptom = symptom
272
+	monitor.Dispose = dispose
273
+	monitor.Result = result
274
+	monitor.MonitoringNurse = monitoringNurse
275
+	monitor.Status = 1
276
+	monitor.UpdatedTime = time.Now().Unix()
277
+	monitor.DisplacementFlowQuantity = displacement_flow_quantity
278
+	monitor.BloodOxygenSaturation = blood_oxygen_saturation
279
+	err = service.UpdateMonitor(monitor)
280
+	if err != nil {
281
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)
282
+		return
283
+	}
284
+
285
+	this.ServeSuccessJSON(map[string]interface{}{
286
+		"monitor": monitor,
287
+	})
288
+}
289
+
290
+// /m/api/monitor/delete [post]
291
+// @param record_id:int
292
+// @param patient_id:int
293
+func (this *DialysisAPIController) DeleteMonitor() {
294
+	recordID, _ := this.GetInt64("record_id")
295
+	patientID, _ := this.GetInt64("patient_id")
296
+	if recordID <= 0 || patientID <= 0 {
297
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
298
+		return
299
+	}
300
+	adminInfo := this.GetMobileAdminUserInfo()
301
+	patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
302
+	if getPatientErr != nil {
303
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
304
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
305
+		return
306
+	} else if patient == nil {
307
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
308
+		return
309
+	}
310
+
311
+	monitor, getMonitorErr := service.GetMonitor(adminInfo.Org.Id, patientID, recordID)
312
+	if getMonitorErr != nil {
313
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
314
+		return
315
+	}
316
+	if monitor != nil {
317
+		if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
318
+			headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.Org.Id, adminInfo.App.Id, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
319
+			if getPermissionErr != nil {
320
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
321
+				return
322
+			} else if headNursePermission == nil {
323
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
324
+				return
325
+			}
326
+		}
327
+	}
328
+
329
+	err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID)
330
+	if err != nil {
331
+		this.ErrorLog("删除透析监测记录失败:%v", err)
332
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
333
+		return
334
+	}
335
+	this.ServeSuccessJSON(map[string]interface{}{
336
+		"record_id": monitor.ID,
337
+	})
338
+}
339
+
340
+// /m/api/schedule/urgentinit [get]
341
+func (this *DialysisAPIController) UrgentScheduleInitData() {
342
+	schedule_type, _ := this.GetInt("type", 0)
343
+	adminUserInfo := this.GetMobileAdminUserInfo()
344
+	today := utils.ZeroHourTimeOfDay(time.Now())
345
+	//获取所有病人且没有上机记录的病人
346
+	patients, getPatientsErr := service.MobileGetAllPatientsForUrgentSchedule(adminUserInfo.Org.Id, today.Unix())
347
+	if getPatientsErr != nil {
348
+		this.ErrorLog("获取所有患者失败:%v", getPatientsErr)
349
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
350
+		return
351
+	}
352
+	modes, getModesErr := service.MobileGetAllTrearmentModesForUrgentSchedule()
353
+	if getModesErr != nil {
354
+		this.ErrorLog("获取所有治疗模式失败:%v", getModesErr)
355
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
356
+		return
357
+	}
358
+	deviceNumbers, getDeviceNumbersErr := service.GetAllAvaildDeviceNumbers(adminUserInfo.Org.Id, today.Unix(), schedule_type)
359
+	if getDeviceNumbersErr != nil {
360
+		this.ErrorLog("获取所有床位失败:%v", getDeviceNumbersErr)
361
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
362
+		return
363
+	}
364
+	schedules, getSchedulesErr := service.MobileGetOtherSchedulesForUrgentSchedule(adminUserInfo.Org.Id, today.Unix(), schedule_type)
365
+	if getSchedulesErr != nil {
366
+		this.ErrorLog("获取所有排班失败:%v", getSchedulesErr)
367
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
368
+		return
369
+	}
370
+
371
+	this.ServeSuccessJSON(map[string]interface{}{
372
+		"patients":       patients,
373
+		"modes":          modes,
374
+		"device_numbers": deviceNumbers,
375
+		"schedules":      schedules,
376
+	})
377
+}
378
+
379
+// /m/api/schedule/urgentadd [post]
380
+// @param patient_id:int
381
+// @param schedule_type:int
382
+// @param mode:int
383
+// @param bed:int
384
+func (this *DialysisAPIController) AddUrgentSchedule() {
385
+	patientID, _ := this.GetInt64("patient_id")
386
+	scheduleType, _ := this.GetInt64("schedule_type")
387
+	modeID, _ := this.GetInt64("mode")
388
+	bedID, _ := this.GetInt64("bed")
389
+	if patientID <= 0 || scheduleType < 1 || scheduleType > 3 || modeID < 1 || modeID > 14 || bedID <= 0 {
390
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
391
+		return
392
+	}
393
+
394
+	adminUserInfo := this.GetMobileAdminUserInfo()
395
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.Org.Id, patientID)
396
+	if getPatientErr != nil {
397
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
398
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
399
+		return
400
+	} else if patient == nil {
401
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
402
+		return
403
+	}
404
+
405
+	deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.Org.Id, bedID)
406
+	if getDeviceNumberErr != nil {
407
+		this.ErrorLog("获取床位失败:%v", getDeviceNumberErr)
408
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
409
+		return
410
+	} else if deviceNumber == nil {
411
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
412
+		return
413
+	}
414
+
415
+	scheduleDate := utils.ZeroHourTimeOfDay(time.Now())
416
+	weekday := int64(scheduleDate.Weekday())
417
+	if weekday == 0 {
418
+		weekday = 7
419
+	}
420
+
421
+	//判断这个人今天是否有排班
422
+	daySchedule, dayScheduleErr := service.GetDayScheduleTwo(adminUserInfo.Org.Id, scheduleDate.Unix(), patientID)
423
+
424
+	//判断当前时段该床位是否有排班
425
+	schedule, err := service.GetDayScheduleByBedid(adminUserInfo.Org.Id, scheduleDate.Unix(), bedID, scheduleType)
426
+	if dayScheduleErr == gorm.ErrRecordNotFound { //今天没有排班
427
+		if err == gorm.ErrRecordNotFound { //空床位
428
+			// 创建排班数据
429
+			newSchedule := &models.Schedule{
430
+				UserOrgId:    adminUserInfo.Org.Id,
431
+				PartitionId:  deviceNumber.ZoneID,
432
+				BedId:        deviceNumber.ID,
433
+				PatientId:    patientID,
434
+				ScheduleDate: scheduleDate.Unix(),
435
+				ScheduleType: scheduleType,
436
+				ScheduleWeek: weekday,
437
+				ModeId:       modeID,
438
+				Status:       1,
439
+				CreatedTime:  time.Now().Unix(),
440
+				UpdatedTime:  time.Now().Unix(),
441
+			}
442
+			createErr := service.CreateSchedule(newSchedule)
443
+			if createErr != nil {
444
+				this.ErrorLog("紧急排班失败:%v", createErr)
445
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
446
+				return
447
+			} else {
448
+				this.ServeSuccessJSON(map[string]interface{}{
449
+					"schedule": newSchedule,
450
+					"patient":  patient,
451
+				})
452
+			}
453
+		} else if err == nil {
454
+			if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //该床位有排班没上机记录
455
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorSchedualcRepeatBed)
456
+			} else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //有排班且有上机记录
457
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
458
+				return
459
+			}
460
+		} else if err != nil {
461
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
462
+			return
463
+		}
464
+
465
+	} else if dayScheduleErr == nil { //今天有排班
466
+
467
+		if daySchedule.ID > 0 && daySchedule.DialysisOrder.ID <= 0 { //今天有排班但是没上机
468
+
469
+			if err == gorm.ErrRecordNotFound { //空床位
470
+				// 修改了床位逻辑
471
+				daySchedule, _ := service.GetDayScheduleTwo(adminUserInfo.Org.Id, scheduleDate.Unix(), patientID)
472
+				if daySchedule.ID > 0 {
473
+					daySchedule.PartitionId = deviceNumber.ZoneID
474
+					daySchedule.BedId = bedID
475
+					daySchedule.ModeId = modeID
476
+					daySchedule.ScheduleType = scheduleType
477
+					daySchedule.UpdatedTime = time.Now().Unix()
478
+					err := service.UpdateSchedule(&daySchedule)
479
+					if err != nil {
480
+						this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
481
+						return
482
+					}
483
+					this.ServeSuccessJSON(map[string]interface{}{
484
+						"schedule": daySchedule,
485
+						"patient":  patient,
486
+					})
487
+				}
488
+			} else if err == nil { //该床位被人霸占
489
+				if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //霸占该床位的病人有排班没上机记录
490
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorSchedualcRepeatBed)
491
+					return
492
+				} else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //霸占该床位的病人有排班且有上机记录
493
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
494
+					return
495
+				}
496
+			} else if err != nil {
497
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
498
+				return
499
+			}
500
+
501
+		} else if daySchedule.ID > 0 && daySchedule.DialysisOrder.ID > 0 { //今天有排班且上机
502
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrder)
503
+			return
504
+		}
505
+	}
506
+
507
+}

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

@@ -0,0 +1,73 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+)
9
+
10
+type DoctorAdviceAPIController struct {
11
+	MobileBaseAPIAuthController
12
+}
13
+
14
+// /m/api/schedule/advices [get]
15
+// @param date:string (yyyy-mm-dd)
16
+// @param advice_type:int 1长期医嘱 3临时医嘱 其他:全部
17
+func (this *DoctorAdviceAPIController) ScheduleAdvices() {
18
+	schedualDate := this.GetString("date")
19
+	adviceType, _ := this.GetInt("advice_type")
20
+	patientType, _ := this.GetInt("patient_type")
21
+
22
+	if adviceType != 1 && adviceType != 3 && adviceType != 2 {
23
+		adviceType = 0
24
+	}
25
+
26
+	if patientType != 1 && patientType != 2 {
27
+
28
+		patientType = 0
29
+	}
30
+
31
+	date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
32
+	if parseDateErr != nil {
33
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
34
+		return
35
+	}
36
+
37
+	adminInfo := this.GetMobileAdminUserInfo()
38
+	orgID := adminInfo.Org.Id
39
+
40
+	scheduals, err := service.MobileGetScheduleDoctorAdvices(orgID, date.Unix(), adviceType, patientType, adminInfo.AdminUser.Id)
41
+	adminUser, _ := service.GetAllAdminUsers(orgID, adminInfo.App.Id)
42
+	if err != nil {
43
+		this.ErrorLog("获取排班信息失败:%v", err)
44
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
45
+	} else {
46
+		filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
47
+		for _, schedual := range scheduals {
48
+			if len(schedual.DoctorAdvices) > 0 {
49
+				filtedScheduals = append(filtedScheduals, schedual)
50
+			}
51
+		}
52
+		this.ServeSuccessJSON(map[string]interface{}{
53
+			"scheduals": filtedScheduals,
54
+
55
+			"adminUser": adminUser,
56
+		})
57
+	}
58
+}
59
+
60
+func (c *DoctorAdviceAPIController) GetAdviceConfigs() {
61
+	advice_type, _ := c.GetInt64("type", 0)
62
+	adminUserInfo := c.GetMobileAdminUserInfo()
63
+	var drugs []models.DrugDic
64
+	drugways, _, _ := service.GetDrugWayDics(adminUserInfo.Org.Id)
65
+	efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.Org.Id)
66
+	adviceTemplates, _ := service.FindAllAdviceTemplate(adminUserInfo.Org.Id, advice_type)
67
+	c.ServeSuccessJSON(map[string]interface{}{
68
+		"drugs":            drugs,
69
+		"drugways":         drugways,
70
+		"efs":              efs,
71
+		"advice_templates": adviceTemplates,
72
+	})
73
+}

+ 29 - 0
controllers/mobile_api_controllers/doctor_api_controller.go View File

@@ -0,0 +1,29 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/service"
5
+)
6
+
7
+type DoctorsApiController struct {
8
+	MobileBaseAPIAuthController
9
+}
10
+
11
+func (c *DoctorsApiController) GetAllDoctorAndNurse() {
12
+	adminUserInfo := c.GetMobileAdminUserInfo()
13
+	doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.Org.Id, adminUserInfo.App.Id)
14
+	c.ServeSuccessJSON(map[string]interface{}{
15
+		"doctors": doctors,
16
+		"nursers": nursers,
17
+	})
18
+	return
19
+}
20
+
21
+func (c *DoctorsApiController) GetAllAdminUsers() {
22
+	//adminUserInfo := c.GetAdminUserInfo()
23
+	adminUserInfo := c.GetMobileAdminUserInfo()
24
+	users, _ := service.GetAllAdminUsers(adminUserInfo.Org.Id, adminUserInfo.App.Id)
25
+	c.ServeSuccessJSON(map[string]interface{}{
26
+		"users": users,
27
+	})
28
+	return
29
+}

+ 339 - 0
controllers/mobile_api_controllers/login_api_controller.go View File

@@ -0,0 +1,339 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"encoding/json"
5
+	"io/ioutil"
6
+	"net/http"
7
+	"net/url"
8
+
9
+	"XT_New/enums"
10
+	"XT_New/models"
11
+	"XT_New/service"
12
+	"XT_New/utils"
13
+
14
+	"github.com/astaxie/beego"
15
+)
16
+
17
+type LoginAPIController struct {
18
+	MobileBaseAPIController
19
+}
20
+
21
+func (this *LoginAPIController) LoginByCs() {
22
+	mobile := this.GetString("mobile")
23
+	pwd := this.GetString("password")
24
+	if len(mobile) == 0 || len(pwd) == 0 || utils.CellPhoneRegexp().MatchString(mobile) == false {
25
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
26
+		return
27
+	}
28
+	ip := utils.GetIP(this.Ctx.Request)
29
+
30
+	ssoDomain := beego.AppConfig.String("sso_domain")
31
+	api := ssoDomain + "/m/login/pwd"
32
+	values := make(url.Values)
33
+	values.Set("mobile", mobile)
34
+	values.Set("password", pwd)
35
+	values.Set("app_type", "3")
36
+	values.Set("ip", ip)
37
+	resp, requestErr := http.PostForm(api, values)
38
+
39
+	if requestErr != nil {
40
+		utils.ErrorLog("请求SSO登录接口失败: %v", requestErr)
41
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
42
+		return
43
+	}
44
+	defer resp.Body.Close()
45
+	body, ioErr := ioutil.ReadAll(resp.Body)
46
+	if ioErr != nil {
47
+		utils.ErrorLog("SSO登录接口返回数据读取失败: %v", ioErr)
48
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
49
+		return
50
+	}
51
+	var respJSON map[string]interface{}
52
+	utils.InfoLog(string(body))
53
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
54
+		utils.ErrorLog("SSO登录接口返回数据解析JSON失败: %v", err)
55
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
56
+		return
57
+	}
58
+
59
+	if respJSON["state"].(float64) != 1 {
60
+		msg := respJSON["msg"].(string)
61
+		utils.ErrorLog("SSO登录接口请求失败: %v", msg)
62
+		if int(respJSON["code"].(float64)) == 609 {
63
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
64
+			return
65
+		}
66
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
67
+		return
68
+	} else {
69
+		utils.SuccessLog("SSO登录成功")
70
+		// 下面这几段 Map=>JSON=>Struct 的流程可能会造成速度很慢
71
+		userJSON := respJSON["data"].(map[string]interface{})["admin"].(map[string]interface{})
72
+		userJSONBytes, _ := json.Marshal(userJSON)
73
+		var adminUser models.AdminUser
74
+		if err := json.Unmarshal(userJSONBytes, &adminUser); err != nil {
75
+			utils.ErrorLog("解析管理员失败:%v", err)
76
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
77
+			return
78
+		}
79
+		orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
80
+		orgJSONBytes, _ := json.Marshal(orgJSON)
81
+		var org models.Org
82
+		if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
83
+			utils.ErrorLog("解析机构失败:%v", err)
84
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
85
+			return
86
+		}
87
+		appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
88
+		appJSONBytes, _ := json.Marshal(appJSON)
89
+		var app models.OrgApp
90
+		if err := json.Unmarshal(appJSONBytes, &app); err != nil {
91
+			utils.ErrorLog("解析应用失败:%v", err)
92
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
93
+			return
94
+		}
95
+		appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
96
+		appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
97
+		var appRole models.App_Role
98
+		if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
99
+			utils.ErrorLog("解析AppRole失败:%v", err)
100
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
101
+			return
102
+		}
103
+		subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
104
+		subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
105
+		var subscibe models.ServeSubscibe
106
+		if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
107
+			utils.ErrorLog("解析Subscibe失败:%v", err)
108
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
109
+			return
110
+		}
111
+		service.GetOrgSubscibeState(&subscibe)
112
+		templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
113
+
114
+		mobileAdminUserInfo := &MobileAdminUserInfo{
115
+			AdminUser:    &adminUser,
116
+			Org:          &org,
117
+			App:          &app,
118
+			AppRole:      &appRole,
119
+			Subscibe:     &subscibe,
120
+			TemplateInfo: &templateInfo,
121
+		}
122
+		this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
123
+
124
+		// configList, _ := service.GetConfigList(org.Id)
125
+
126
+		// var FiledList []*models.FiledConfig
127
+
128
+		// FiledList, _ = service.FindFiledByOrgId(org.Id)
129
+
130
+		// if len(FiledList) == 0 {
131
+		// 	err := service.BatchInsertFiledConfig(org.Id)
132
+		// 	if err == nil {
133
+		// 		FiledList, _ = service.FindFiledByOrgId(org.Id)
134
+
135
+		// 	} else {
136
+		// 		utils.ErrorLog("字段批量插入失败:%v", err)
137
+		// 	}
138
+		// }
139
+
140
+		this.ServeSuccessJSON(map[string]interface{}{
141
+			"user": map[string]interface{}{
142
+				"id":         adminUser.Id,
143
+				"mobile":     adminUser.Mobile,
144
+				"user_name":  appRole.UserName,
145
+				"avatar":     appRole.Avatar,
146
+				"intro":      appRole.Intro,
147
+				"user_type":  appRole.UserType,
148
+				"user_title": appRole.UserTitle,
149
+			},
150
+			"org": map[string]interface{}{
151
+				"id":             org.Id,
152
+				"org_name":       org.OrgName,
153
+				"org_short_name": org.OrgShortName,
154
+				"org_intro":      org.OrgIntroduction,
155
+				"org_logo":       org.OrgLogo,
156
+				"province":       org.Province,
157
+				"city":           org.City,
158
+				"district":       org.District,
159
+				"address":        org.Address,
160
+			},
161
+			"subscibe": map[string]interface{}{
162
+				"id":           subscibe.ID,
163
+				"period_start": subscibe.PeriodStart,
164
+				"period_end":   subscibe.PeriodEnd,
165
+				"state":        subscibe.State,
166
+			}, "template_info": map[string]interface{}{
167
+				"id":          templateInfo.ID,
168
+				"org_id":      templateInfo.OrgId,
169
+				"template_id": templateInfo.TemplateId,
170
+			},
171
+			// "config_list": configList,
172
+			// "filed_list":  FiledList,
173
+		})
174
+	}
175
+}
176
+
177
+// /m/api/login/pwd [post] LoginByPwd
178
+// @param mobile:string
179
+// @param password:string
180
+func (this *LoginAPIController) LoginByPwd() {
181
+	mobile := this.GetString("mobile")
182
+	pwd := this.GetString("password")
183
+	if len(mobile) == 0 || len(pwd) == 0 || utils.CellPhoneRegexp().MatchString(mobile) == false {
184
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
185
+		return
186
+	}
187
+	ip := utils.GetIP(this.Ctx.Request)
188
+
189
+	ssoDomain := beego.AppConfig.String("sso_domain")
190
+	api := ssoDomain + "/m/login/pwd"
191
+	values := make(url.Values)
192
+	values.Set("mobile", mobile)
193
+	values.Set("password", pwd)
194
+	values.Set("app_type", "3")
195
+	values.Set("ip", ip)
196
+	resp, requestErr := http.PostForm(api, values)
197
+
198
+	if requestErr != nil {
199
+		utils.ErrorLog("请求SSO登录接口失败: %v", requestErr)
200
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
201
+		return
202
+	}
203
+	defer resp.Body.Close()
204
+	body, ioErr := ioutil.ReadAll(resp.Body)
205
+	if ioErr != nil {
206
+		utils.ErrorLog("SSO登录接口返回数据读取失败: %v", ioErr)
207
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
208
+		return
209
+	}
210
+	var respJSON map[string]interface{}
211
+	utils.InfoLog(string(body))
212
+	if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
213
+		utils.ErrorLog("SSO登录接口返回数据解析JSON失败: %v", err)
214
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
215
+		return
216
+	}
217
+
218
+	if respJSON["state"].(float64) != 1 {
219
+		msg := respJSON["msg"].(string)
220
+		utils.ErrorLog("SSO登录接口请求失败: %v", msg)
221
+		if int(respJSON["code"].(float64)) == 609 {
222
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrPasswordWrong)
223
+			return
224
+		}
225
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
226
+		return
227
+	} else {
228
+		utils.SuccessLog("SSO登录成功")
229
+		// 下面这几段 Map=>JSON=>Struct 的流程可能会造成速度很慢
230
+		userJSON := respJSON["data"].(map[string]interface{})["admin"].(map[string]interface{})
231
+		userJSONBytes, _ := json.Marshal(userJSON)
232
+		var adminUser models.AdminUser
233
+		if err := json.Unmarshal(userJSONBytes, &adminUser); err != nil {
234
+			utils.ErrorLog("解析管理员失败:%v", err)
235
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
236
+			return
237
+		}
238
+		orgJSON := respJSON["data"].(map[string]interface{})["org"].(map[string]interface{})
239
+		orgJSONBytes, _ := json.Marshal(orgJSON)
240
+		var org models.Org
241
+		if err := json.Unmarshal(orgJSONBytes, &org); err != nil {
242
+			utils.ErrorLog("解析机构失败:%v", err)
243
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
244
+			return
245
+		}
246
+		appJSON := respJSON["data"].(map[string]interface{})["app"].(map[string]interface{})
247
+		appJSONBytes, _ := json.Marshal(appJSON)
248
+		var app models.OrgApp
249
+		if err := json.Unmarshal(appJSONBytes, &app); err != nil {
250
+			utils.ErrorLog("解析应用失败:%v", err)
251
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
252
+			return
253
+		}
254
+		appRoleJSON := respJSON["data"].(map[string]interface{})["app_role"].(map[string]interface{})
255
+		appRoleJSONBytes, _ := json.Marshal(appRoleJSON)
256
+		var appRole models.App_Role
257
+		if err := json.Unmarshal(appRoleJSONBytes, &appRole); err != nil {
258
+			utils.ErrorLog("解析AppRole失败:%v", err)
259
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
260
+			return
261
+		}
262
+		subscibeJSON := respJSON["data"].(map[string]interface{})["subscibe"].(map[string]interface{})
263
+		subscibeJSONBytes, _ := json.Marshal(subscibeJSON)
264
+		var subscibe models.ServeSubscibe
265
+		if err := json.Unmarshal(subscibeJSONBytes, &subscibe); err != nil {
266
+			utils.ErrorLog("解析Subscibe失败:%v", err)
267
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
268
+			return
269
+		}
270
+		service.GetOrgSubscibeState(&subscibe)
271
+		templateInfo, _ := service.GetOrgInfoTemplate(org.Id)
272
+
273
+		mobileAdminUserInfo := &MobileAdminUserInfo{
274
+			AdminUser:    &adminUser,
275
+			Org:          &org,
276
+			App:          &app,
277
+			AppRole:      &appRole,
278
+			Subscibe:     &subscibe,
279
+			TemplateInfo: &templateInfo,
280
+		}
281
+		this.SetSession("mobile_admin_user_info", mobileAdminUserInfo)
282
+
283
+		configList, _ := service.GetConfigList(org.Id)
284
+
285
+		var FiledList []*models.FiledConfig
286
+
287
+		FiledList, _ = service.FindFiledByOrgId(org.Id)
288
+
289
+		if len(FiledList) == 0 {
290
+			err := service.BatchInsertFiledConfig(org.Id)
291
+			if err == nil {
292
+				FiledList, _ = service.FindFiledByOrgId(org.Id)
293
+
294
+			} else {
295
+				utils.ErrorLog("字段批量插入失败:%v", err)
296
+			}
297
+		}
298
+
299
+		this.ServeSuccessJSON(map[string]interface{}{
300
+			"user": map[string]interface{}{
301
+				"id":         adminUser.Id,
302
+				"mobile":     adminUser.Mobile,
303
+				"user_name":  appRole.UserName,
304
+				"avatar":     appRole.Avatar,
305
+				"intro":      appRole.Intro,
306
+				"user_type":  appRole.UserType,
307
+				"user_title": appRole.UserTitle,
308
+			},
309
+			"org": map[string]interface{}{
310
+				"id":             org.Id,
311
+				"org_name":       org.OrgName,
312
+				"org_short_name": org.OrgShortName,
313
+				"org_intro":      org.OrgIntroduction,
314
+				"org_logo":       org.OrgLogo,
315
+				"province":       org.Province,
316
+				"city":           org.City,
317
+				"district":       org.District,
318
+				"address":        org.Address,
319
+			},
320
+			"subscibe": map[string]interface{}{
321
+				"id":           subscibe.ID,
322
+				"period_start": subscibe.PeriodStart,
323
+				"period_end":   subscibe.PeriodEnd,
324
+				"state":        subscibe.State,
325
+			}, "template_info": map[string]interface{}{
326
+				"id":          templateInfo.ID,
327
+				"org_id":      templateInfo.OrgId,
328
+				"template_id": templateInfo.TemplateId,
329
+			},
330
+			"config_list": configList,
331
+			"filed_list":  FiledList,
332
+		})
333
+	}
334
+}
335
+
336
+// /m/api/login/code [post] LoginByCode
337
+func (this *LoginAPIController) LoginByCode() {
338
+
339
+}

+ 61 - 0
controllers/mobile_api_controllers/mobile_api_base_controller.go View File

@@ -0,0 +1,61 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/controllers"
5
+	"XT_New/enums"
6
+	"XT_New/models"
7
+	"XT_New/service"
8
+)
9
+
10
+type MobileBaseAPIController struct {
11
+	controllers.BaseAPIController
12
+}
13
+
14
+func (this *MobileBaseAPIController) Prepare() {
15
+	this.BaseAPIController.Prepare()
16
+	// beego.Trace("============================================================")
17
+	// beego.Trace("session ID: %v", this.Ctx.Input.Cookie("beegosessionID"))
18
+	// beego.Trace("session : %v", this.GetSession("info"))
19
+	// this.SetSession("info", time.Now().Format("2006/01/02 15:04:05"))
20
+	// beego.Trace("============================================================")
21
+}
22
+
23
+func (this *MobileBaseAPIController) GetMobileAdminUserInfo() *MobileAdminUserInfo {
24
+	userInfo := this.GetSession("mobile_admin_user_info")
25
+	if userInfo == nil {
26
+		return nil
27
+	} else {
28
+		return userInfo.(*MobileAdminUserInfo)
29
+	}
30
+}
31
+
32
+type MobileAdminUserInfo struct {
33
+	AdminUser    *models.AdminUser
34
+	Org          *models.Org
35
+	App          *models.OrgApp
36
+	AppRole      *models.App_Role
37
+	Subscibe     *models.ServeSubscibe
38
+	TemplateInfo *models.GobalTemplate
39
+}
40
+
41
+type MobileBaseAPIAuthController struct {
42
+	MobileBaseAPIController
43
+}
44
+
45
+func (this *MobileBaseAPIAuthController) Prepare() {
46
+	this.MobileBaseAPIController.Prepare()
47
+
48
+	adminUserInfo := this.GetMobileAdminUserInfo()
49
+	if adminUserInfo == nil {
50
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotLogin)
51
+		this.StopRun()
52
+	}
53
+
54
+	if this.Ctx.Request.Method != "GET" {
55
+		err := service.GetOrgSubscibeState(adminUserInfo.Subscibe)
56
+		if err != nil || adminUserInfo.Subscibe.State == 3 {
57
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNotSubscibe)
58
+			this.StopRun()
59
+		}
60
+	}
61
+}

+ 113 - 0
controllers/mobile_api_controllers/mobile_api_router_register.go View File

@@ -0,0 +1,113 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"github.com/astaxie/beego"
5
+)
6
+
7
+// 平板端路由,以 /m/api 为前缀
8
+func MobileAPIControllersRegisterRouters() {
9
+	beego.Router("/m/api/login/pwd", &LoginAPIController{}, "post:LoginByPwd")
10
+	// beego.Router("/m/api/login/cs", &LoginAPIController{}, "post:LoginByCs")
11
+
12
+	// beego.Router("/m/api/test", &DialysisTestAPIController{}, "get:Test")
13
+	beego.Router("/m/api/savebloodpressure", &CheckWeightApiController{}, "Post:SaveBloodPressure")
14
+	beego.Router("/m/api/checkbeforedialysis", &CheckWeightApiController{}, "get:GetPatientInfoBeforeDialysis")
15
+	beego.Router("/m/api/checkdialysis", &CheckWeightApiController{}, "get:GetPatientInfoDialysis")
16
+	beego.Router("/m/api/savecheckdialysis", &CheckWeightApiController{}, "Post:SavePatientInfoDialysis")
17
+	beego.Router("/m/api/scheduals", &DialysisAPIController{}, "get:Scheduals")
18
+	beego.Router("/m/api/waiting_scheduals", &DialysisAPIController{}, "get:WaitingScheduals")
19
+
20
+	beego.Router("/m/api/solution/create", &PatientApiController{}, "Post:CreateDialysisSolution")
21
+	beego.Router("/m/api/solution/edit", &PatientApiController{}, "Post:EditDialysisSolution")
22
+	beego.Router("/m/api/assessmentbefore/commit", &PatientApiController{}, "Post:EditAssessmentBeforeDislysis")
23
+
24
+	beego.Router("/m/api/dialysisglobalconfig", &DialysisAPIController{}, "Get:GetDialysisGlobalConfig")
25
+	beego.Router("/m/api/dialysis/record", &DialysisAPIController{}, "get:DialysisRecord")
26
+
27
+	beego.Router("/m/api/dialysis/dialysisPrescription", &DialysisAPIController{}, "post:PostDialysisPrescription")
28
+	beego.Router("/m/api/dialysis/treatmentSummary", &DialysisAPIController{}, "post:PostAtreatmentInfo")
29
+	beego.Router("/m/api/dialysis/doublecheck", &DialysisAPIController{}, "post:PostDoubleCheck")
30
+	beego.Router("/m/api/dialysis/acceptsAssessment", &DialysisAPIController{}, "post:PostAcceptsAssessment")
31
+	beego.Router("/m/api/dialysis/assessmentAfterDislysis", &DialysisAPIController{}, "post:PostAssessmentAfterDislysis")
32
+	beego.Router("/m/api/dialysis/finish", &DialysisAPIController{}, "post:Finish")
33
+	beego.Router("/m/api/dialysis/allzone", &DialysisAPIController{}, "get:GetAllZone")
34
+	beego.Router("/m/api/dialysis/patients", &DialysisAPIController{}, "get:GetSchedualPatientsList")
35
+	beego.Router("/m/api/startOrder/edit", &DialysisAPIController{}, "post:ModifyStartDialysisOrder")
36
+	beego.Router("/m/api/finishOrder/edit", &DialysisAPIController{}, "post:ModifyFinishDialysisOrder")
37
+
38
+	beego.Router("/m/api/advice/create", &PatientApiController{}, "Post:CreateDoctorAdvice")
39
+	beego.Router("/m/api/advice/edit", &PatientApiController{}, "Put:EditDoctorAdvice")
40
+	beego.Router("/m/api/advice/stop", &PatientApiController{}, "Post:StopDoctorAdvice")
41
+	beego.Router("/m/api/advice/creategroup", &PatientApiController{}, "Post:CreateGroupAdvice")
42
+	beego.Router("/m/api/advice/group/modify_starttime", &PatientApiController{}, "Post:ModifyAdviceGroupStartTime")
43
+
44
+	beego.Router("/m/api/advice/delete", &PatientApiController{}, "Delete:DeleteDoctorAdvice")
45
+	beego.Router("/m/api/advice/exec", &PatientApiController{}, "Post:ExecDoctorAdvice")
46
+	beego.Router("/m/api/advice/exec/modify", &PatientApiController{}, "Post:ModifyExecDoctorAdvice")
47
+
48
+	beego.Router("/m/api/advice/check", &PatientApiController{}, "Post:CheckDoctorAdvice")
49
+	beego.Router("/m/api/patient/info", &PatientApiController{}, "Get:GetPatientInfoWithDiseases")
50
+
51
+	beego.Router("/m/api/monitor/add", &DialysisAPIController{}, "post:AddMonitorRecord")
52
+	beego.Router("/m/api/monitor/edit", &DialysisAPIController{}, "post:EditMonitorRecord")
53
+	beego.Router("/m/api/monitor/delete", &DialysisAPIController{}, "post:DeleteMonitor")
54
+
55
+	beego.Router("/m/api/accepts/get", &DialysisAPIController{}, "Get:GetAcceptsAssessment")
56
+
57
+	beego.Router("/m/api/patient/education", &PatientApiController{}, "get:GetPatientEducation")
58
+	beego.Router("/m/api/patients/schedules", &PatientApiController{}, "Get:GetPatientSchedulesList")
59
+	beego.Router("/m/api/patients/record", &PatientApiController{}, "Get:GetRecords")
60
+	beego.Router("/m/api/patients/solutions", &PatientApiController{}, "Get:GetPatientDialysisSolutionList")
61
+	beego.Router("/m/api/patients/doctoradvices", &PatientApiController{}, "Get:GetDoctorAdvices")
62
+
63
+	beego.Router("/m/api/monitor", &PatientApiController{}, "Get:GetPatientMonitor")
64
+	beego.Router("/m/api/monitor/patient", &PatientApiController{}, "get:SearchMonitorPatient")
65
+
66
+	beego.Router("/m/api/alldoctors", &DoctorsApiController{}, "Get:GetAllDoctorAndNurse")
67
+	beego.Router("/m/api/admin/users", &DoctorsApiController{}, "Get:GetAllAdminUsers")
68
+
69
+	beego.Router("/m/api/solution", &DialysisAPIController{}, "Post:PostSolution")
70
+
71
+	beego.Router("/m/api/schedule/advices", &DoctorAdviceAPIController{}, "Get:ScheduleAdvices")
72
+
73
+	beego.Router("/m/api/dialysis/start", &DialysisAPIController{}, "Post:StartDialysis")
74
+
75
+	beego.Router("/m/api/getelectronicsignature", &AdminUserApiController{}, "Get:GetAdminUserElectronicSignature")
76
+	beego.Router("/m/api/savelectronicsignature", &AdminUserApiController{}, "Post:SaveAdminUserElectronicSignature")
77
+	beego.Router("/m/api/my", &AdminUserApiController{}, "Get:GetMyInfo")
78
+
79
+	beego.Router("/m/api/qiniu/uptoken", &QiNiuApiController{}, "get:GetQNUpToken")
80
+
81
+	beego.Router("/m/api/getadviceconfigs", &DoctorAdviceAPIController{}, "Get:GetAdviceConfigs")
82
+
83
+	beego.Router("/m/api/inspection/reference", &CheckApiController{}, "Get:GetInspectionReference")
84
+	beego.Router("/m/api/inspection/list", &CheckApiController{}, "Get:GetInspections")
85
+
86
+	beego.Router("/m/api/print/dialysisorder", &PatientApiController{}, "Get:GetPrintDialysisOrder")
87
+
88
+	beego.Router("/m/api/schedule/urgentinit", &DialysisAPIController{}, "Get:UrgentScheduleInitData")
89
+	beego.Router("/m/api/schedule/urgentadd", &DialysisAPIController{}, "Post:AddUrgentSchedule")
90
+
91
+	beego.Router("/m/api/dialysis/sign", &DialysisAPIController{}, "Post:PostSignInfo")
92
+
93
+	beego.Router("/m/api/monitor/get", &DialysisAPIController{}, "Get:GetLastMonitorRecord")
94
+	beego.Router("/m/api/monitor/gettodaylast", &DialysisAPIController{}, "Get:GetLastMonitorRecordTody")
95
+
96
+	beego.Router("/m/api/newadvice/delete", &PatientApiController{}, "Delete:DelDoctorAdvice")
97
+
98
+	beego.Router("/m/api/delete/subadvice", &PatientApiController{}, "Delete:DelSubDoctorAdvice")
99
+
100
+	beego.Router("/m/api/advice/unread", &PatientApiController{}, "Get:GetAdviceUnReadMessage")
101
+	beego.Router("/m/api/patients/search", &PatientApiController{}, "Post:GetPatientsByKeyWord")
102
+
103
+	beego.Router("/m/api/warehouse/query", &StockApiController{}, "get:GetWarehouse")
104
+
105
+	beego.Router("/m/api/dialysis/advice_remind", &DialysisAPIController{}, "Get:GetLongAdvice")
106
+	beego.Router("/m/api/advice_remind/create", &DialysisAPIController{}, "Post:CreateRemindDoctorAdvice")
107
+	beego.Router("/m/api/dryweight/commit", &DialysisAPIController{}, "Post:UploadDryWeight")
108
+
109
+	beego.Router("/m/api/solution/get", &DialysisAPIController{}, "Get:GetSolution")
110
+
111
+	beego.Router("/m/api/schedule/get", &DialysisAPIController{}, "Get:GetSchedule")
112
+
113
+}

File diff suppressed because it is too large
+ 2584 - 0
controllers/mobile_api_controllers/patient_api_controller.go


+ 28 - 0
controllers/mobile_api_controllers/qiniiu_api_controller.go View File

@@ -0,0 +1,28 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"fmt"
7
+)
8
+
9
+type QiNiuApiController struct {
10
+	MobileBaseAPIAuthController
11
+}
12
+
13
+func (c *QiNiuApiController) GetQNUpToken() {
14
+	redisClient := service.RedisClient()
15
+	defer redisClient.Close()
16
+
17
+	token, err := redisClient.Get("qn_token").Result()
18
+	if err != nil {
19
+		defer fmt.Println(err)
20
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
21
+		return
22
+	}
23
+
24
+	c.ServeSuccessJSON(map[string]interface{}{
25
+		"uptoken": token,
26
+	})
27
+	return
28
+}

+ 73 - 0
controllers/mobile_api_controllers/stock_api_controller.go View File

@@ -0,0 +1,73 @@
1
+package mobile_api_controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"github.com/astaxie/beego"
7
+)
8
+
9
+type StockApiController struct {
10
+	MobileBaseAPIAuthController
11
+}
12
+
13
+func (this *StockApiController) GetWarehouse() {
14
+	adminInfo := this.GetMobileAdminUserInfo()
15
+	types, _ := this.GetInt64("type_id", 0)
16
+	var type_id int64
17
+	switch types {
18
+	case 1:
19
+		type_id, _ = beego.AppConfig.Int64("niprocart")
20
+
21
+		break
22
+	case 2:
23
+		type_id, _ = beego.AppConfig.Int64("jms")
24
+		break
25
+	case 3:
26
+		type_id, _ = beego.AppConfig.Int64("fistula_needle_set")
27
+
28
+		break
29
+	case 4:
30
+		type_id, _ = beego.AppConfig.Int64("fistula_needle_set_16")
31
+
32
+		break
33
+	case 5:
34
+		type_id, _ = beego.AppConfig.Int64("hemoperfusion")
35
+
36
+		break
37
+	case 6:
38
+		type_id, _ = beego.AppConfig.Int64("dialyser_sterilised")
39
+		break
40
+	case 7:
41
+		type_id, _ = beego.AppConfig.Int64("filtryzer")
42
+		break
43
+	case 8:
44
+		type_id, _ = beego.AppConfig.Int64("dialyzers")
45
+
46
+		break
47
+	case 9:
48
+		type_id, _ = beego.AppConfig.Int64("injector")
49
+		break
50
+	case 10:
51
+		type_id, _ = beego.AppConfig.Int64("bloodlines")
52
+		break
53
+	case 11:
54
+		type_id, _ = beego.AppConfig.Int64("tubingHemodialysis")
55
+		break
56
+	case 12:
57
+		type_id, _ = beego.AppConfig.Int64("package")
58
+		break
59
+	case 13:
60
+		type_id, _ = beego.AppConfig.Int64("aliquid")
61
+		break
62
+	}
63
+
64
+	info, err := service.FindWarehouseInfoByGoodType(type_id, adminInfo.Org.Id)
65
+	if err != nil {
66
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
67
+		return
68
+	}
69
+	this.ServeSuccessJSON(map[string]interface{}{
70
+		"list": info,
71
+	})
72
+
73
+}

+ 294 - 0
controllers/orginfo_api_controller.go View File

@@ -0,0 +1,294 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"reflect"
10
+	"time"
11
+
12
+	"github.com/astaxie/beego"
13
+)
14
+
15
+type OrgInfoApiController struct {
16
+	BaseAuthAPIController
17
+}
18
+
19
+func OrgInfoApiRegistRouters() {
20
+	beego.Router("/api/orginfo/getinfo", &OrgInfoApiController{}, "get:GetOrgInfo")
21
+	beego.Router("/api/orginfo/savegallery", &OrgInfoApiController{}, "post:SaveOrgGallery")
22
+	beego.Router("/api/orginfo/deletegallery", &OrgInfoApiController{}, "delete:DeleteOrgGallery")
23
+	beego.Router("/api/orginfo/edit", &OrgInfoApiController{}, "post:EditOrgInfo")
24
+
25
+}
26
+
27
+func (c *OrgInfoApiController) GetOrgInfo() {
28
+
29
+	adminUserInfo := c.GetAdminUserInfo()
30
+
31
+	orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
32
+	provinces, _ := service.GetDistrictsByUpid(0)
33
+	var citys []*models.District
34
+	var districts []*models.District
35
+	if orgInfo.Province > 0 {
36
+		citys, _ = service.GetDistrictsByUpid(orgInfo.Province)
37
+	}
38
+	if orgInfo.City > 0 {
39
+		districts, _ = service.GetDistrictsByUpid(orgInfo.City)
40
+	}
41
+
42
+	orgtypes, _ := service.GetOrgTypes()
43
+
44
+	illness, _ := service.GetIllnessList()
45
+
46
+	c.ServeSuccessJSON(map[string]interface{}{
47
+		"orginfo":   orgInfo,
48
+		"provinces": provinces,
49
+		"citys":     citys,
50
+		"districts": districts,
51
+		"orgtypes":  orgtypes,
52
+		"illness":   illness,
53
+	})
54
+	return
55
+}
56
+
57
+func (c *OrgInfoApiController) EditOrgInfo() {
58
+	adminUserInfo := c.GetAdminUserInfo()
59
+
60
+	if !adminUserInfo.AdminUser.IsSuperAdmin {
61
+		c.ServeFailJsonSend(enums.ErrorCodePermissionDenied, "权限不足")
62
+		return
63
+	}
64
+
65
+	dataBody := make(map[string]interface{}, 0)
66
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
67
+	if err != nil {
68
+		utils.ErrorLog(err.Error())
69
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
70
+		return
71
+	}
72
+
73
+	orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
74
+	org := *orgInfo
75
+
76
+	if dataBody["org_name"] == nil || reflect.TypeOf(dataBody["org_name"]).String() != "string" {
77
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:机构名称")
78
+		return
79
+	}
80
+	orgName, _ := dataBody["org_name"].(string)
81
+	if len(orgName) == 0 {
82
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "机构名称不能为空")
83
+		return
84
+	}
85
+
86
+	org.OrgName = orgName
87
+
88
+	if dataBody["contact_name"] == nil || reflect.TypeOf(dataBody["contact_name"]).String() != "string" {
89
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:联系人姓名")
90
+		return
91
+	}
92
+	contactName, _ := dataBody["contact_name"].(string)
93
+	if len(contactName) == 0 {
94
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "联系人姓名不能为空")
95
+		return
96
+	}
97
+	org.ContactName = contactName
98
+
99
+	// if dataBody["org_short_name"] == nil || reflect.TypeOf(dataBody["org_short_name"]).String() != "string" {
100
+	// 	c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:商家简称")
101
+	// 	return
102
+	// }
103
+	// orgShortName, _ := dataBody["org_short_name"].(string)
104
+	// if len(orgShortName) == 0 {
105
+	// 	c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "商家简称不能为空")
106
+	// 	return
107
+	// }
108
+	org.OrgShortName = orgName
109
+
110
+	if dataBody["org_introduction"] == nil || reflect.TypeOf(dataBody["org_introduction"]).String() != "string" {
111
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:机构介绍")
112
+		return
113
+	}
114
+	orgIntroduction, _ := dataBody["org_introduction"].(string)
115
+	if len(orgIntroduction) == 0 {
116
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "机构介绍不能为空")
117
+		return
118
+	}
119
+	org.OrgIntroduction = orgIntroduction
120
+
121
+	if dataBody["org_logo"] == nil || reflect.TypeOf(dataBody["org_logo"]).String() != "string" {
122
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "缺少参数:机构头像")
123
+		return
124
+	}
125
+	orgLogo, _ := dataBody["org_logo"].(string)
126
+	if len(orgLogo) == 0 {
127
+		c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "机构头像不能为空")
128
+		return
129
+	}
130
+	org.OrgLogo = orgLogo
131
+
132
+	if dataBody["province"] != nil || reflect.TypeOf(dataBody["province"]).String() == "float64" {
133
+		province := int64(dataBody["province"].(float64))
134
+		org.Province = province
135
+	}
136
+
137
+	if dataBody["city"] != nil || reflect.TypeOf(dataBody["city"]).String() == "float64" {
138
+		city := int64(dataBody["city"].(float64))
139
+		org.City = city
140
+	}
141
+
142
+	if dataBody["district"] != nil || reflect.TypeOf(dataBody["district"]).String() == "float64" {
143
+		district := int64(dataBody["district"].(float64))
144
+		org.District = district
145
+	}
146
+
147
+	if dataBody["address"] != nil || reflect.TypeOf(dataBody["address"]).String() == "string" {
148
+		address, _ := dataBody["address"].(string)
149
+		org.Address = address
150
+	}
151
+
152
+	if dataBody["org_type"] != nil || reflect.TypeOf(dataBody["org_type"]).String() == "float64" {
153
+		orgType := int64(dataBody["org_type"].(float64))
154
+		org.OrgType = orgType
155
+	}
156
+
157
+	if dataBody["telephone"] != nil || reflect.TypeOf(dataBody["telephone"]).String() == "string" {
158
+		telephone, _ := dataBody["telephone"].(string)
159
+		org.Telephone = telephone
160
+	}
161
+
162
+	if dataBody["operating_state"] != nil || reflect.TypeOf(dataBody["operating_state"]).String() == "float64" {
163
+		operatingState := int64(dataBody["operating_state"].(float64))
164
+		org.OperatingState = operatingState
165
+	}
166
+
167
+	if dataBody["business_week"] != nil || reflect.TypeOf(dataBody["business_week"]).String() == "string" {
168
+		businessWeek, _ := dataBody["business_week"].(string)
169
+		org.BusinessWeek = businessWeek
170
+	}
171
+
172
+	if dataBody["business_time"] != nil || reflect.TypeOf(dataBody["business_time"]).String() == "string" {
173
+		businessTime, _ := dataBody["business_time"].(string)
174
+		org.BusinessTime = businessTime
175
+	}
176
+	if dataBody["illness"] != nil || reflect.TypeOf(dataBody["illness"]).String() == "string" {
177
+		illness, _ := dataBody["illness"].(string)
178
+		org.Illness = illness
179
+	}
180
+
181
+	timeNow := time.Now().Unix()
182
+	org.ModifyTime = timeNow
183
+	org.OrgGallery = nil
184
+	err = service.UpdateOrgInfo(&org)
185
+	if err != nil {
186
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
187
+		return
188
+	}
189
+
190
+	orgInfo.OrgName = orgName
191
+	orgInfo.OrgShortName = orgName
192
+	orgInfo.OrgIntroduction = orgIntroduction
193
+	orgInfo.OrgLogo = orgLogo
194
+	orgInfo.Province = org.Province
195
+	orgInfo.District = org.District
196
+	orgInfo.City = org.City
197
+	orgInfo.OrgType = org.OrgType
198
+	orgInfo.Telephone = org.Telephone
199
+	orgInfo.OperatingState = org.OperatingState
200
+	orgInfo.BusinessWeek = org.BusinessWeek
201
+	orgInfo.BusinessTime = org.BusinessTime
202
+	orgInfo.Illness = org.Illness
203
+	orgInfo.ContactName = org.ContactName
204
+
205
+	c.ServeSuccessJSON(map[string]interface{}{
206
+		"msg": "ok",
207
+	})
208
+	return
209
+}
210
+
211
+func (c *OrgInfoApiController) SaveOrgGallery() {
212
+	adminUserInfo := c.GetAdminUserInfo()
213
+
214
+	dataBody := make(map[string]interface{}, 0)
215
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
216
+	if err != nil {
217
+		utils.ErrorLog(err.Error())
218
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
219
+		return
220
+	}
221
+
222
+	if dataBody["type"] == nil || reflect.TypeOf(dataBody["type"]).String() != "float64" {
223
+		utils.ErrorLog("type")
224
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
225
+		return
226
+	}
227
+	galleryType := int64(dataBody["type"].(float64))
228
+	if galleryType != 1 && galleryType != 2 {
229
+		utils.ErrorLog("galleryType != 1&&2")
230
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
231
+		return
232
+	}
233
+
234
+	if dataBody["url"] == nil || reflect.TypeOf(dataBody["url"]).String() != "string" {
235
+		utils.ErrorLog("url")
236
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
237
+		return
238
+	}
239
+	url, _ := dataBody["url"].(string)
240
+	if len(url) == 0 {
241
+		utils.ErrorLog("len(url) == 0")
242
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
243
+		return
244
+	}
245
+
246
+	timeNow := time.Now().Unix()
247
+	var gallery models.OrgGallery
248
+	gallery.Type = galleryType
249
+	gallery.Url = url
250
+	gallery.OrgId = adminUserInfo.CurrentOrgId
251
+	gallery.Status = 1
252
+	gallery.Ctime = timeNow
253
+	gallery.Mtime = timeNow
254
+	err = service.CreateOrgGalleryItem(&gallery)
255
+	if err != nil {
256
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
257
+		return
258
+	}
259
+
260
+	orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
261
+	orgInfo.OrgGallery = append(orgInfo.OrgGallery, &gallery)
262
+	c.ServeSuccessJSON(map[string]interface{}{
263
+		"msg": "ok",
264
+	})
265
+	return
266
+
267
+}
268
+
269
+func (c *OrgInfoApiController) DeleteOrgGallery() {
270
+	adminUserInfo := c.GetAdminUserInfo()
271
+	id, _ := c.GetInt64("id", 0)
272
+	if id <= 0 {
273
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
274
+		return
275
+	}
276
+
277
+	err := service.DeleteOrgGalleryItem(id)
278
+	if err != nil {
279
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
280
+		return
281
+	}
282
+
283
+	orgInfo := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
284
+	for index, item := range orgInfo.OrgGallery {
285
+		if item.ID == id {
286
+			orgInfo.OrgGallery = append(orgInfo.OrgGallery[:index], orgInfo.OrgGallery[index+1:]...)
287
+		}
288
+	}
289
+	c.ServeSuccessJSON(map[string]interface{}{
290
+		"msg": "ok",
291
+	})
292
+	return
293
+
294
+}

File diff suppressed because it is too large
+ 3157 - 0
controllers/patient_api_controller.go


+ 368 - 0
controllers/patient_dataconfig_api_controller.go View File

@@ -0,0 +1,368 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"strconv"
9
+	"strings"
10
+	"time"
11
+
12
+	"github.com/astaxie/beego"
13
+)
14
+
15
+func PatientDataConfigAPIControllerRegistRouters() {
16
+	beego.Router("/api/patient/courses", &PatientDataConfigAPIController{}, "get:Courses")
17
+	beego.Router("/api/patient/course/create", &PatientDataConfigAPIController{}, "post:CreateCourse")
18
+	beego.Router("/api/patient/course/delete", &PatientDataConfigAPIController{}, "post:DeleteCourse")
19
+	beego.Router("/api/patient/course/modify", &PatientDataConfigAPIController{}, "post:ModifyCourse")
20
+
21
+	beego.Router("/api/patient/rescues", &PatientDataConfigAPIController{}, "get:Rescues")
22
+	beego.Router("/api/patient/rescue/create", &PatientDataConfigAPIController{}, "post:CreateRescue")
23
+	beego.Router("/api/patient/rescue/delete", &PatientDataConfigAPIController{}, "post:DeleteRescue")
24
+}
25
+
26
+type PatientDataConfigAPIController struct {
27
+	BaseAuthAPIController
28
+}
29
+
30
+// /api/patient/courses [get]
31
+// @param patient_id:int
32
+// @param start_time:string (yyyy-MM-dd)
33
+// @param end_time:string (yyyy-MM-dd)
34
+func (this *PatientDataConfigAPIController) Courses() {
35
+	patientID, _ := this.GetInt64("patient_id")
36
+	startTimeYMDStr := this.GetString("start_time")
37
+	endTimeYMDStr := this.GetString("end_time")
38
+	if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
39
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
40
+		return
41
+	}
42
+	endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
43
+	startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
44
+	endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
45
+	if parseStartTimeErr != nil || parseEndTimeErr != nil {
46
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
47
+		return
48
+	}
49
+
50
+	adminUserInfo := this.GetAdminUserInfo()
51
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
52
+	if getPatientErr != nil {
53
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
54
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
55
+		return
56
+	} else if patient == nil {
57
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
58
+		return
59
+	}
60
+
61
+	records, getRecordsErr := service.GetPatientCourseOfDisease(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
62
+	if getRecordsErr != nil {
63
+		this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
64
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
65
+		return
66
+	}
67
+
68
+	admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
69
+	if getAllAdminsErr != nil {
70
+		this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
71
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
72
+		return
73
+	}
74
+
75
+	this.ServeSuccessJSON(map[string]interface{}{
76
+		"records": records,
77
+		"doctors": admins,
78
+	})
79
+}
80
+
81
+// /api/patient/course/create [post]
82
+// @param patient_id:int
83
+// @param content:string
84
+func (this *PatientDataConfigAPIController) CreateCourse() {
85
+	patientID, _ := this.GetInt64("patient_id")
86
+	content := this.GetString("content")
87
+	record_time_str := this.GetString("record_time")
88
+	title := this.GetString("title")
89
+
90
+	if patientID <= 0 || len(content) == 0 {
91
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
92
+		return
93
+	}
94
+
95
+	if len(record_time_str) == 0 {
96
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
97
+		return
98
+	}
99
+
100
+	checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_time_str)
101
+
102
+	adminUserInfo := this.GetAdminUserInfo()
103
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
104
+	if getPatientErr != nil {
105
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
106
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
107
+		return
108
+	} else if patient == nil {
109
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
110
+		return
111
+	}
112
+
113
+	now := time.Now().Unix()
114
+	record := models.PatientDiseaseCourse{
115
+		OrgID:      adminUserInfo.CurrentOrgId,
116
+		PatientID:  patientID,
117
+		Recorder:   adminUserInfo.AdminUser.Id,
118
+		RecordTime: checkDate.Unix(),
119
+		Content:    content,
120
+		Status:     1,
121
+		CreateTime: now,
122
+		ModifyTime: now,
123
+		Title:      title,
124
+	}
125
+
126
+	createErr := service.CreatePatientCourseOfDisease(&record)
127
+	if createErr != nil {
128
+		this.ErrorLog("创建患者病程记录失败:%v", createErr)
129
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
130
+		return
131
+	}
132
+
133
+	this.ServeSuccessJSON(map[string]interface{}{
134
+		"record": record,
135
+	})
136
+}
137
+
138
+// /api/patient/course/delete
139
+// @param patient_id:int
140
+// @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
141
+func (this *PatientDataConfigAPIController) DeleteCourse() {
142
+	patientID, _ := this.GetInt64("patient_id")
143
+	idsStr := this.GetString("ids")
144
+	if patientID <= 0 || len(idsStr) == 0 {
145
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
146
+		return
147
+	}
148
+
149
+	adminUserInfo := this.GetAdminUserInfo()
150
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
151
+	if getPatientErr != nil {
152
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
153
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
154
+		return
155
+	} else if patient == nil {
156
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
157
+		return
158
+	}
159
+
160
+	recordIDStrs := strings.Split(idsStr, ",")
161
+	recordIDs := make([]int64, 0, len(recordIDStrs))
162
+	for _, idStr := range recordIDStrs {
163
+		id, parseErr := strconv.Atoi(idStr)
164
+		if parseErr != nil {
165
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
166
+			return
167
+		}
168
+		recordIDs = append(recordIDs, int64(id))
169
+	}
170
+
171
+	deleteErr := service.DeletePatientCoursesInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
172
+	if deleteErr != nil {
173
+		this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
174
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
175
+		return
176
+	}
177
+	this.ServeSuccessJSON(nil)
178
+}
179
+
180
+// /api/patient/rescues [get]
181
+// @param patient_id:int
182
+// @param start_time:string (yyyy-MM-dd)
183
+// @param end_time:string (yyyy-MM-dd)
184
+func (this *PatientDataConfigAPIController) Rescues() {
185
+	patientID, _ := this.GetInt64("patient_id")
186
+	startTimeYMDStr := this.GetString("start_time")
187
+	endTimeYMDStr := this.GetString("end_time")
188
+	if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
189
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
190
+		return
191
+	}
192
+	endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
193
+	startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
194
+	endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
195
+	if parseStartTimeErr != nil || parseEndTimeErr != nil {
196
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
197
+		return
198
+	}
199
+
200
+	adminUserInfo := this.GetAdminUserInfo()
201
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
202
+	if getPatientErr != nil {
203
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
204
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
205
+		return
206
+	} else if patient == nil {
207
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
208
+		return
209
+	}
210
+
211
+	records, getRecordsErr := service.GetPatientRescueRecords(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
212
+	if getRecordsErr != nil {
213
+		this.ErrorLog("获取患者抢救记录失败:%v", getRecordsErr)
214
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
215
+		return
216
+	}
217
+
218
+	admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
219
+	if getAllAdminsErr != nil {
220
+		this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
221
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
222
+		return
223
+	}
224
+
225
+	this.ServeSuccessJSON(map[string]interface{}{
226
+		"records": records,
227
+		"doctors": admins,
228
+	})
229
+}
230
+
231
+// /api/patient/rescue/create [post]
232
+// @param patient_id:int
233
+// @param content:string
234
+func (this *PatientDataConfigAPIController) CreateRescue() {
235
+	patientID, _ := this.GetInt64("patient_id")
236
+	content := this.GetString("content")
237
+	if patientID <= 0 || len(content) == 0 {
238
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
239
+		return
240
+	}
241
+
242
+	adminUserInfo := this.GetAdminUserInfo()
243
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
244
+	if getPatientErr != nil {
245
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
246
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
247
+		return
248
+	} else if patient == nil {
249
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
250
+		return
251
+	}
252
+
253
+	now := time.Now().Unix()
254
+	record := models.PatientRescueRecord{
255
+		OrgID:      adminUserInfo.CurrentOrgId,
256
+		PatientID:  patientID,
257
+		Recorder:   adminUserInfo.AdminUser.Id,
258
+		RecordTime: now,
259
+		Content:    content,
260
+		Status:     1,
261
+		CreateTime: now,
262
+		ModifyTime: now,
263
+	}
264
+
265
+	createErr := service.CreatePatientRescueRecord(&record)
266
+	if createErr != nil {
267
+		this.ErrorLog("创建患者抢救记录失败:%v", createErr)
268
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
269
+		return
270
+	}
271
+
272
+	this.ServeSuccessJSON(map[string]interface{}{
273
+		"record": record,
274
+	})
275
+}
276
+
277
+// /api/patient/rescue/delete
278
+// @param patient_id:int
279
+// @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
280
+func (this *PatientDataConfigAPIController) DeleteRescue() {
281
+	patientID, _ := this.GetInt64("patient_id")
282
+	idsStr := this.GetString("ids")
283
+	if patientID <= 0 || len(idsStr) == 0 {
284
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
285
+		return
286
+	}
287
+
288
+	adminUserInfo := this.GetAdminUserInfo()
289
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
290
+	if getPatientErr != nil {
291
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
292
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
293
+		return
294
+	} else if patient == nil {
295
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
296
+		return
297
+	}
298
+
299
+	recordIDStrs := strings.Split(idsStr, ",")
300
+	recordIDs := make([]int64, 0, len(recordIDStrs))
301
+	for _, idStr := range recordIDStrs {
302
+		id, parseErr := strconv.Atoi(idStr)
303
+		if parseErr != nil {
304
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
305
+			return
306
+		}
307
+		recordIDs = append(recordIDs, int64(id))
308
+	}
309
+
310
+	deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
311
+	if deleteErr != nil {
312
+		this.ErrorLog("删除患者抢救记录失败:%v", deleteErr)
313
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
314
+		return
315
+	}
316
+	this.ServeSuccessJSON(nil)
317
+}
318
+
319
+func (this *PatientDataConfigAPIController) ModifyCourse() {
320
+	patientID, _ := this.GetInt64("patient_id")
321
+	content := this.GetString("content")
322
+	id, _ := this.GetInt64("id", 0)
323
+	record_time_str := this.GetString("record_time")
324
+	title := this.GetString("title")
325
+
326
+	if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
327
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
328
+		return
329
+	}
330
+	checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", record_time_str)
331
+
332
+	adminUserInfo := this.GetAdminUserInfo()
333
+	patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
334
+	if getPatientErr != nil {
335
+		this.ErrorLog("获取患者信息失败:%v", getPatientErr)
336
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
337
+		return
338
+	} else if patient == nil {
339
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
340
+		return
341
+	}
342
+
343
+	now := time.Now().Unix()
344
+
345
+	record := models.PatientDiseaseCourse{
346
+		ID:         id,
347
+		OrgID:      adminUserInfo.CurrentOrgId,
348
+		PatientID:  patientID,
349
+		Recorder:   adminUserInfo.AdminUser.Id,
350
+		Content:    content,
351
+		Status:     1,
352
+		CreateTime: now,
353
+		ModifyTime: now,
354
+		Title:      title,
355
+		RecordTime: checkDate.Unix(),
356
+	}
357
+
358
+	createErr := service.ModifyPatientCourses(&record)
359
+	if createErr != nil {
360
+		this.ErrorLog("创建患者抢救记录失败:%v", createErr)
361
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
362
+		return
363
+	}
364
+
365
+	this.ServeSuccessJSON(map[string]interface{}{
366
+		"record": record,
367
+	})
368
+}

+ 620 - 0
controllers/pay_api_controller.go View File

@@ -0,0 +1,620 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"bytes"
8
+	"crypto/md5"
9
+	"encoding/hex"
10
+	"encoding/json"
11
+	"encoding/xml"
12
+	"errors"
13
+	"fmt"
14
+	"github.com/astaxie/beego"
15
+	"io/ioutil"
16
+	"math/rand"
17
+	"net/http"
18
+	"regexp"
19
+	"sort"
20
+	"strconv"
21
+	"strings"
22
+	"time"
23
+)
24
+
25
+const (
26
+	pay_url = "https://api.mch.weixin.qq.com/pay/unifiedorder"
27
+)
28
+
29
+type PayApiController struct {
30
+	BaseServeAPIController
31
+	parameters       map[string]string
32
+	resultParameters map[string]string
33
+	payUrl           string
34
+}
35
+
36
+type PayApiController2 struct {
37
+	beego.Controller
38
+	parameters       map[string]string
39
+	resultParameters map[string]string
40
+	payUrl           string
41
+}
42
+
43
+func PayApiRegistRouters() {
44
+	beego.Router("/api/my/service", &PayApiController{}, "Get:GetMyService")
45
+	beego.Router("/api/product", &PayApiController{}, "Get:GetProduct")
46
+	beego.Router("/api/pay", &PayApiController{}, "Get:GetPayUrl")
47
+	beego.Router("/api/pay/transfer", &PayApiController{}, "Post:PostTransferStatus")
48
+	beego.Router("/api/order", &PayApiController{}, "Post:PostOrderInfo")
49
+	beego.Router("/api/order/get", &PayApiController{}, "Get:GetOrderInfo")
50
+	beego.Router("/api/pay/notify", &PayApiController2{}, "Post:WxPaySuccessNotify")
51
+	beego.Router("/api/order/cancel", &PayApiController{}, "Post:CancelOrder")
52
+	beego.Router("/api/order/list", &PayApiController{}, "Get:GetOrderList")
53
+	beego.Router("/api/order/hetong", &PayApiController{}, "Get:GetHeTong")
54
+	beego.Router("/api/order/hetong", &PayApiController{}, "Post:CreateHeTong")
55
+
56
+}
57
+func (c *PayApiController) GetOrderList() {
58
+	adminUserInfo := c.GetAdminUserInfo()
59
+	serviceOrderList, err := service.GetOrderList(adminUserInfo.CurrentOrgId)
60
+	if err == nil {
61
+		c.ServeSuccessJSON(map[string]interface{}{
62
+			"list": serviceOrderList,
63
+		})
64
+	} else {
65
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
66
+	}
67
+
68
+}
69
+
70
+func (c *PayApiController) CancelOrder() {
71
+	adminUserInfo := c.GetAdminUserInfo()
72
+	orderId, _ := c.GetInt64("id", 0)
73
+	if orderId == 0 {
74
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
75
+		return
76
+	}
77
+	order, err := service.FindServeOrderByID(adminUserInfo.CurrentOrgId, orderId)
78
+	if err != nil {
79
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
80
+		return
81
+	}
82
+	if order == nil {
83
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
84
+		return
85
+	}
86
+
87
+	errs := service.UpdateOrderStatus(adminUserInfo.CurrentOrgId, orderId)
88
+	if errs == nil {
89
+		c.ServeSuccessJSON(map[string]interface{}{
90
+			"msg": "取消成功",
91
+		})
92
+	} else {
93
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
94
+	}
95
+}
96
+
97
+func (c *PayApiController) PostTransferStatus() {
98
+	adminUserInfo := c.GetAdminUserInfo()
99
+	orderId, _ := c.GetInt64("id", 0)
100
+	if orderId == 0 {
101
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
102
+		return
103
+	}
104
+	order, err := service.FindServeOrderByID(adminUserInfo.CurrentOrgId, orderId)
105
+	if err != nil {
106
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
107
+		return
108
+	}
109
+	if order == nil {
110
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
111
+		return
112
+	}
113
+
114
+	errs := service.UpdateOrderPayType(adminUserInfo.CurrentOrgId, orderId)
115
+
116
+	if errs == nil {
117
+		c.ServeSuccessJSON(map[string]interface{}{
118
+			"msg": "确认成功",
119
+		})
120
+	} else {
121
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
122
+	}
123
+}
124
+
125
+func (c *PayApiController) GetOrderInfo() {
126
+	adminUserInfo := c.GetAdminUserInfo()
127
+	orderId, _ := c.GetInt64("id", 0)
128
+	order, err := service.FindServeOrderByID(adminUserInfo.CurrentOrgId, orderId)
129
+	if err != nil {
130
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
131
+		return
132
+	}
133
+	if order == nil {
134
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
135
+		return
136
+	}
137
+
138
+	orderInfo, err := service.FindOrderInfomationByID(order.OrderNumber, adminUserInfo.CurrentOrgId)
139
+	if err != nil {
140
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
141
+		return
142
+	}
143
+	if orderInfo == nil {
144
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
145
+		return
146
+	}
147
+	c.ServeSuccessJSON(map[string]interface{}{
148
+		"total":       order.PaymentAmount,
149
+		"orderNumber": order.OrderNumber,
150
+		"OrgName":     adminUserInfo.Orgs[adminUserInfo.CurrentOrgId].OrgName,
151
+		"order":       order,
152
+		"orderInfo":   orderInfo,
153
+	})
154
+}
155
+
156
+func (c *PayApiController) PostOrderInfo() {
157
+	adminUserInfo := c.GetAdminUserInfo()
158
+	amount, _ := c.GetInt64("amount", 0)
159
+	productId, _ := c.GetInt64("id", 0)
160
+
161
+	product, err := service.FindProductByID(productId)
162
+	if err != nil {
163
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
164
+		return
165
+	}
166
+	if product == nil {
167
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeProductError)
168
+		return
169
+	}
170
+	timestamp := c.GetTimestamp()
171
+	//自定义订单号
172
+	bill_no := "S" + strconv.FormatInt(timestamp, 10) + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
173
+
174
+	order := models.ServeOrder{
175
+		OrgId:           adminUserInfo.CurrentOrgId,
176
+		Period:          amount * 12,
177
+		Status:          1,
178
+		CreatedTime:     time.Now().Unix(),
179
+		UpdatedTime:     time.Now().Unix(),
180
+		OrderNumber:     bill_no,
181
+		OrderStatus:     1,
182
+		PayableAmount:   float64(amount) * product.Price,
183
+		PaymentAmount:   float64(amount) * product.Price,
184
+		ServeName:       product.ServeName,
185
+		ServeDesc:       product.ServeDesc,
186
+		OrderExpireTime: time.Now().Unix() + (7 * 24 * 3600),
187
+		Quantity:        amount,
188
+		Price:           product.Price,
189
+		ServeId:         productId,
190
+	}
191
+	infomation := models.ServeOrderInfomation{
192
+		OrgId:       adminUserInfo.CurrentOrgId,
193
+		OrderNumber: bill_no,
194
+		Status:      1,
195
+		ProductId:   product.ID,
196
+		ProductName: product.ServeName,
197
+		ProductDesc: product.ServeDesc,
198
+		Price:       product.Price,
199
+		Quantity:    amount,
200
+		MarketPrice: product.OriginalPrice,
201
+	}
202
+
203
+	service.CreateOrderRecord(&order)
204
+	service.CreateOrderInfomation(&infomation)
205
+	c.ServeSuccessJSON(map[string]interface{}{
206
+		"order": order,
207
+		"msg":   "提交订单成功",
208
+	})
209
+}
210
+
211
+func (c *PayApiController) GetProduct() {
212
+	adminUserInfo := c.GetAdminUserInfo()
213
+	products, err := service.FindAllProduct()
214
+	subscibe, _ := service.FindServiceSubscibeByOrgId(adminUserInfo.CurrentOrgId)
215
+
216
+	if err == nil {
217
+		c.ServeSuccessJSON(map[string]interface{}{
218
+			"products":    products,
219
+			"subscibe":    subscibe,
220
+			"serviceTime": time.Now().Unix(),
221
+			//"OrgName":  adminUserInfo.Orgs[adminUserInfo.CurrentOrgId].OrgName,
222
+		})
223
+	} else {
224
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
225
+	}
226
+}
227
+
228
+func (c *PayApiController) GetMyService() {
229
+	adminUserInfo := c.GetAdminUserInfo()
230
+	subscibe, err := service.FindServiceSubscibeByOrgId(adminUserInfo.CurrentOrgId)
231
+	if err == nil {
232
+		c.ServeSuccessJSON(map[string]interface{}{
233
+			"subscibe":    subscibe,
234
+			"serviceTime": time.Now().Unix(),
235
+		})
236
+	} else {
237
+
238
+	}
239
+
240
+}
241
+
242
+func (c *PayApiController) GetPayUrl() {
243
+	adminUserInfo := c.GetAdminUserInfo()
244
+	orderId, _ := c.GetInt64("id", 0)
245
+	if orderId == 0 {
246
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
247
+		return
248
+	}
249
+	order, err := service.FindServeOrderByID(adminUserInfo.CurrentOrgId, orderId)
250
+	if err != nil {
251
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
252
+		return
253
+	}
254
+	if order == nil {
255
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
256
+		return
257
+	}
258
+
259
+	orderInfo, err := service.FindOrderInfomationByID(order.OrderNumber, adminUserInfo.CurrentOrgId)
260
+	if err != nil {
261
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
262
+		return
263
+	}
264
+	if orderInfo == nil {
265
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
266
+		return
267
+	}
268
+
269
+	totalPrice := orderInfo.Price * float64(orderInfo.Quantity)
270
+	totalFee := fmt.Sprintf("%.0f", totalPrice*100)
271
+	c.SetParameter("out_trade_no", orderInfo.OrderNumber)
272
+	c.SetParameter("total_fee", totalFee)
273
+	c.SetParameter("trade_type", "NATIVE")
274
+	c.SetParameter("body", order.ServeName)
275
+	notify_url := beego.AppConfig.String("httpdomain") + "/api/pay/notify"
276
+	c.SetParameter("product_id", orderInfo.OrderNumber)
277
+	c.SetParameter("notify_url", notify_url)
278
+	c.SetParameter("spbill_create_ip", c.GetClientIp())
279
+	fmt.Println(c.GetClientIp())
280
+	url, err := c.GetPayCodeUrl()
281
+	fmt.Println(err)
282
+	if err == nil {
283
+		c.SetPayUrl(url)
284
+		c.ServeSuccessJSON(map[string]interface{}{
285
+			"payUrl": url,
286
+			"price":  order.PayableAmount,
287
+			//":  adminUserInfo.Orgs[adminUserInfo.CurrentOrgId].OrgName,
288
+		})
289
+	} else {
290
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
291
+		// utils.LogError(err)
292
+	}
293
+
294
+}
295
+
296
+func (this *PayApiController2) WxPaySuccessNotify() {
297
+
298
+	type PaySuccessXmlResp struct {
299
+		ReturnCode    string `xml:"return_code"`
300
+		Appid         string `xml:"appid"`
301
+		BankType      string `xml:"bank_type"`
302
+		CashFee       int64  `xml:"cash_fee"`
303
+		FeeType       string `xml:"fee_type"`
304
+		IsSubscribe   string `xml:"is_subscribe"`
305
+		MchId         string `xml:"mch_id"`
306
+		NonceStr      string `xml:"nonce_str"`
307
+		OpenId        string `xml:"openid"`
308
+		OutTradeNo    string `xml:"out_trade_no"`
309
+		ResultCode    string `xml:"result_code"`
310
+		Sign          string `xml:"sign"`
311
+		TimeEnd       string `xml:"time_end"`
312
+		TotalFee      string `xml:"total_fee"`
313
+		TradeType     string `xml:"trade_type"`
314
+		TransactionId string `xml:"transaction_id"`
315
+	}
316
+
317
+	defer this.Ctx.Request.Body.Close()
318
+	result, _ := ioutil.ReadAll(this.Ctx.Request.Body)
319
+
320
+	res := new(PaySuccessXmlResp)
321
+	xmlErr := xml.Unmarshal(result, &res)
322
+	if xmlErr != nil {
323
+
324
+	}
325
+
326
+	order, _ := service.FindServeOrderByOrderNumber(res.OutTradeNo)
327
+	service.UpdateOrder(order.OrderNumber, order.Quantity, order.OrgId, res.TransactionId, order.PeriodEnd, order.PeriodStart)
328
+
329
+	this.SetResultParameter("return_code", res.ReturnCode)
330
+	results := this.ParamsToXml2(this.resultParameters)
331
+	this.Ctx.WriteString(results)
332
+	this.ServeXML()
333
+
334
+}
335
+
336
+func (this *PayApiController) GetTimestamp() int64 {
337
+	return time.Now().UnixNano() / 1000000 //毫秒
338
+}
339
+
340
+func (this *PayApiController) GetClientIp() string {
341
+	ip := this.Ctx.Request.Header.Get("Remote_addr")
342
+	if ip == "" {
343
+		ip = this.Ctx.Request.RemoteAddr
344
+	}
345
+	if strings.Contains(ip, ":") {
346
+		ip = this.Substr(ip, 0, strings.Index(ip, ":"))
347
+	}
348
+	return ip
349
+}
350
+
351
+//截取字符串 start 起点下标 end 终点下标(不包括)
352
+func (this *PayApiController) Substr(str string, start int, end int) string {
353
+	rs := []rune(str)
354
+	length := len(rs)
355
+
356
+	if start < 0 || start > length {
357
+		return ""
358
+	}
359
+	if end < 0 || end > length {
360
+		return ""
361
+	}
362
+	return string(rs[start:end])
363
+}
364
+
365
+//设置请求参数
366
+func (this *PayApiController) SetParameter(key string, value string) {
367
+	if this.parameters == nil {
368
+		this.parameters = make(map[string]string)
369
+	}
370
+	this.parameters[key] = value
371
+}
372
+
373
+//设置请求参数
374
+func (this *PayApiController2) SetResultParameter(key string, value string) {
375
+	if this.resultParameters == nil {
376
+		this.resultParameters = make(map[string]string)
377
+	}
378
+	this.resultParameters[key] = value
379
+}
380
+
381
+//设置prepay_id
382
+func (this *PayApiController) SetPayUrl(payUrl string) {
383
+	this.payUrl = payUrl
384
+}
385
+
386
+type XmlResp struct {
387
+	Return_code  string `xml:"return_code"`
388
+	Return_msg   string `xml:"return_msg"`
389
+	Result_code  string `xml:"result_code"`
390
+	Err_code     string `xml:"err_code"`
391
+	Err_code_des string `xml:"err_code_des"`
392
+	Prepay_id    string `xml:"prepay_id"`
393
+	Code_url     string `xml:"code_url"`
394
+}
395
+
396
+func (this *PayApiController) GetPayCodeUrl() (string, error) {
397
+	strXml, err := this.CreateXml()
398
+	if err != nil {
399
+		return "", this.Error("get pay_code_url error", err)
400
+	}
401
+	result, err := this.http_post(pay_url, strXml)
402
+	if err != nil {
403
+		return "", this.Error("get pay_code_url error", err)
404
+	}
405
+
406
+	res := new(XmlResp)
407
+	xmlErr := xml.Unmarshal(result, &res)
408
+	if xmlErr != nil {
409
+		return "", this.Error("get pay_code_url xml error", xmlErr)
410
+	}
411
+	if res.Return_code != "SUCCESS" {
412
+		return "", this.Error("get pay_code_url result error: "+res.Return_msg, nil)
413
+	}
414
+
415
+	if res.Result_code != "SUCCESS" {
416
+		return "", this.Error("get pay_code_url result error: "+res.Err_code+"-"+res.Err_code_des, nil)
417
+	}
418
+	if res.Code_url == "" {
419
+		return "", this.Error("get pay_code_url result error: not get pay_code_url", nil)
420
+	}
421
+	return res.Code_url, nil
422
+}
423
+
424
+func (this *PayApiController) http_post(url string, xml string) ([]byte, error) {
425
+	bc := &http.Client{
426
+		Timeout: 30 * time.Second, //设置超时时间30s
427
+	}
428
+	res, err := bc.Post(url, "text/xml:charset=UTF-8", strings.NewReader(xml))
429
+	if err != nil {
430
+		return nil, this.Error("post", err)
431
+	}
432
+	result, err := ioutil.ReadAll(res.Body)
433
+	res.Body.Close()
434
+	if err != nil {
435
+		return nil, this.Error("post result err", err)
436
+	}
437
+	return result, nil
438
+}
439
+
440
+func (this *PayApiController) CreateXml() (string, error) {
441
+	//检测必填参数
442
+	if this.parameters["out_trade_no"] == "" {
443
+		return "", this.Error("缺少统一支付接口必填参数out_trade_no(商户订单号)!", nil)
444
+	} else if this.parameters["body"] == "" {
445
+		return "", this.Error("缺少统一支付接口必填参数body(商品描述)!", nil)
446
+	} else if this.parameters["total_fee"] == "" {
447
+		return "", this.Error("缺少统一支付接口必填参数total_fee(交易金额)!", nil)
448
+	} else if this.parameters["notify_url"] == "" {
449
+		return "", this.Error("缺少统一支付接口必填参数notify_url(异步接收微信支付结果通知的回调地址)!", nil)
450
+	} else if this.parameters["trade_type"] == "" {
451
+		return "", this.Error("缺少统一支付接口必填参数trade_type(交易类型)!", nil)
452
+	} else if this.parameters["spbill_create_ip"] == "" {
453
+		return "", this.Error("缺少统一支付接口必填参数spbill_create_ip(终端ip)", nil)
454
+	} else if this.parameters["trade_type"] == "NATIVE" && this.parameters["product_id"] == "" {
455
+		return "", this.Error("统一支付接口中,缺少必填参数product_id!trade_type为NATIVE时,product_id为必填参数!", nil)
456
+	}
457
+	this.parameters["appid"] = beego.AppConfig.String("appid")                             //公众账号ID
458
+	this.parameters["mch_id"] = beego.AppConfig.String("mchid")                            //商户号
459
+	this.parameters["nonce_str"] = this.CreateNoncestr(32)                                 //随机字符串
460
+	this.parameters["sign"] = this.GetSign(this.parameters, beego.AppConfig.String("key")) //签名
461
+	return this.ParamsToXml(this.parameters), nil
462
+}
463
+
464
+//产生随机字符串,不长于32位
465
+func (this *PayApiController) CreateNoncestr(length int) (nonceStr string) {
466
+	chars := "abcdefghijklmnopqrstuvwxyz0123456789"
467
+	for i := 0; i < length; i++ {
468
+		idx := rand.Intn(len(chars) - 1)
469
+		nonceStr += chars[idx : idx+1]
470
+	}
471
+	return
472
+}
473
+
474
+func (this *PayApiController) Error(strMsg string, err error) error {
475
+	if err == nil {
476
+		return errors.New(strMsg)
477
+	} else {
478
+		return errors.New(strMsg + ": " + err.Error())
479
+	}
480
+}
481
+
482
+//格式化参数,签名过程需要使用
483
+func (this *PayApiController) FormatParams(paramsMap map[string]string) string {
484
+	//STEP 1, 对key进行升序排序.
485
+	var sorted_keys []string
486
+	for k, _ := range paramsMap {
487
+		sorted_keys = append(sorted_keys, k)
488
+	}
489
+	sort.Strings(sorted_keys)
490
+
491
+	//STEP2, 对key=value的键值对用&连接起来,略过空值
492
+	var paramsStr []string
493
+	for _, k := range sorted_keys {
494
+		v := fmt.Sprintf("%v", strings.TrimSpace(paramsMap[k]))
495
+		if v != "" {
496
+			paramsStr = append(paramsStr, fmt.Sprintf("%s=%s", k, v))
497
+		}
498
+	}
499
+	return strings.Join(paramsStr, "&")
500
+}
501
+
502
+//生成签名
503
+func (this *PayApiController) GetSign(paramsMap map[string]string, wxKey string) string {
504
+	//STEP 1:按字典序排序参数
505
+	paramsStr := this.FormatParams(paramsMap)
506
+	//STEP 2:在string后加入KEY
507
+	signStr := paramsStr + "&key=" + wxKey
508
+	//STEP 3:MD5加密
509
+	sign := md5.New()
510
+	sign.Write([]byte(signStr))
511
+	//STEP 3:所有字符转为大写
512
+	return strings.ToUpper(hex.EncodeToString(sign.Sum(nil)))
513
+}
514
+
515
+//xml结构
516
+func (this *PayApiController) ParamsToXml(data map[string]string) string {
517
+	fmt.Println(data)
518
+	buf := bytes.NewBufferString("<xml>")
519
+	for k, v := range data {
520
+		str := "<![CDATA[%s]]>"
521
+		flag, _ := regexp.MatchString("^\\d+\\.?\\d*$", v)
522
+		if flag {
523
+			str = "%s"
524
+		}
525
+		buf.WriteString(fmt.Sprintf("<%s>"+str+"</%s>", k, v, k))
526
+	}
527
+	buf.WriteString("</xml>")
528
+	return buf.String()
529
+}
530
+
531
+//xml结构
532
+func (this *PayApiController2) ParamsToXml2(data map[string]string) string {
533
+	fmt.Println(data)
534
+	buf := bytes.NewBufferString("<xml>")
535
+	for k, v := range data {
536
+		str := "<![CDATA[%s]]>"
537
+		flag, _ := regexp.MatchString("^\\d+\\.?\\d*$", v)
538
+		if flag {
539
+			str = "%s"
540
+		}
541
+		buf.WriteString(fmt.Sprintf("<%s>"+str+"</%s>", k, v, k))
542
+	}
543
+	buf.WriteString("</xml>")
544
+	return buf.String()
545
+}
546
+
547
+func (this *PayApiController) SetUrl(payUrl string) {
548
+	this.payUrl = payUrl
549
+}
550
+
551
+func (c *PayApiController) GetHeTong() {
552
+	order_id, _ := c.GetInt64("order_id", 0)
553
+	if order_id <= 0 {
554
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
555
+		return
556
+	}
557
+
558
+	admin := c.GetAdminUserInfo()
559
+	ht, err := service.GetHetong(admin.CurrentOrgId, order_id)
560
+	if err != nil {
561
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
562
+		return
563
+	}
564
+
565
+	c.ServeSuccessJSON(map[string]interface{}{
566
+		"ht": ht,
567
+	})
568
+}
569
+
570
+func (c *PayApiController) CreateHeTong() {
571
+	orderId, _ := c.GetInt64("order_id", 0)
572
+	if orderId <= 0 {
573
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
574
+		return
575
+	}
576
+	admin := c.GetAdminUserInfo()
577
+	order, err := service.FindServeOrderByID(admin.CurrentOrgId, orderId)
578
+	if err != nil {
579
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
580
+		return
581
+	}
582
+	if order == nil {
583
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeServeNotExist)
584
+		return
585
+	}
586
+	ht, err := service.GetHetong(admin.CurrentOrgId, orderId)
587
+	if err != nil {
588
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
589
+		return
590
+	}
591
+	if ht != nil {
592
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHetongHad)
593
+		return
594
+	}
595
+
596
+	var hetong models.ServeOrderContract
597
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &hetong)
598
+	if err != nil {
599
+		fmt.Println(err)
600
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
601
+		return
602
+	}
603
+
604
+	hetong.OrderId = orderId
605
+	hetong.OrderNumber = order.OrderNumber
606
+	hetong.CreatedTime = time.Now().Unix()
607
+	hetong.UpdatedTime = time.Now().Unix()
608
+	hetong.Status = 1
609
+	hetong.OrgId = admin.CurrentOrgId
610
+
611
+	err = service.CreateHetong(&hetong)
612
+	if err != nil {
613
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateHetongFail)
614
+		return
615
+	}
616
+
617
+	c.ServeSuccessJSON(map[string]interface{}{
618
+		"ht": hetong,
619
+	})
620
+}

+ 152 - 0
controllers/print_data_api_controller.go View File

@@ -0,0 +1,152 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	service "XT_New/service/print_data_service/schedule_dialysis"
6
+	"XT_New/utils"
7
+	"fmt"
8
+	"strings"
9
+	"time"
10
+
11
+	"github.com/astaxie/beego"
12
+)
13
+
14
+func PrintDataAPIControllerRegistRouters() {
15
+	beego.Router("/api/print/schedule/dialysis", &PrintDataAPIController{}, "get:ScheduleDialysisRecordPrintData")
16
+	beego.Router("/api/print/stock", &PrintDataAPIController{}, "get:StockRecordPrintData")
17
+	beego.Router("/api/print/course", &PrintDataAPIController{}, "get:CourseRecordPrintData")
18
+	beego.Router("/api/print/getlastafterweight", &PrintDataAPIController{}, "get:GetLastAfterWeight")
19
+}
20
+
21
+type PrintDataAPIController struct {
22
+	BaseAuthAPIController
23
+}
24
+
25
+// /api/print/schedule/dialysis [get]
26
+// @param ids:string 排班 id,以逗号隔开 ("1,2,3")
27
+func (this *PrintDataAPIController) ScheduleDialysisRecordPrintData() {
28
+	schIDStr := this.GetString("ids")
29
+	if len(schIDStr) == 0 {
30
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
31
+		return
32
+	}
33
+
34
+	idStrs := strings.Split(schIDStr, ",")
35
+	adminUserInfo := this.GetAdminUserInfo()
36
+	schedules, getScheduleErr := service.GetSchedules(adminUserInfo.CurrentOrgId, idStrs)
37
+
38
+	if getScheduleErr != nil {
39
+		this.ErrorLog("获取打印透析记录失败:%v", getScheduleErr)
40
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
41
+		return
42
+	}
43
+
44
+	medicalStaffs, getMedicalStaffErr := service.GetMedicalStaffs(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
45
+	if getMedicalStaffErr != nil {
46
+		this.ErrorLog("获取医护人员失败:%v", getMedicalStaffErr)
47
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
48
+		return
49
+	}
50
+
51
+	adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
52
+	name, getScheduleErr := service.GetAllName(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
53
+	templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
54
+
55
+	this.ServeSuccessJSON(map[string]interface{}{
56
+		"schedules":      schedules,
57
+		"medical_staffs": medicalStaffs,
58
+		"users":          adminUser,
59
+		"templateInfo":   templateInfo,
60
+		"name":           name,
61
+	})
62
+}
63
+
64
+func (this *PrintDataAPIController) StockRecordPrintData() {
65
+	types, _ := this.GetInt("type", 0)
66
+	start_time := this.GetString("start_time")
67
+	end_time := this.GetString("end_time")
68
+	adminUserInfo := this.GetAdminUserInfo()
69
+
70
+	timeLayout := "2006-01-02"
71
+	loc, _ := time.LoadLocation("Local")
72
+	var startTime int64
73
+	if len(start_time) > 0 {
74
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
75
+		if err != nil {
76
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
77
+			return
78
+		}
79
+		startTime = theTime.Unix()
80
+	}
81
+	var endTime int64
82
+	if len(end_time) > 0 {
83
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
84
+		if err != nil {
85
+			utils.ErrorLog(err.Error())
86
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
87
+			return
88
+		}
89
+		endTime = theTime.Unix()
90
+	}
91
+
92
+	list, err := service.FindPrintStockGoodInfoByType(types, startTime, endTime, adminUserInfo.CurrentOrgId)
93
+
94
+	if err != nil {
95
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
96
+	} else {
97
+		this.ServeSuccessJSON(map[string]interface{}{
98
+			"list": list,
99
+			"type": types,
100
+		})
101
+	}
102
+}
103
+
104
+func (this *PrintDataAPIController) CourseRecordPrintData() {
105
+	id, _ := this.GetInt64("id", 0)
106
+	adminUserInfo := this.GetAdminUserInfo()
107
+
108
+	if id == 0 {
109
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
110
+		return
111
+	}
112
+	timeLayout := "2006-01-02 15:04:05"
113
+	record, err := service.GetPatientCoursesRecords(adminUserInfo.CurrentOrgId, id)
114
+	dataTimeStr := time.Unix(record.RecordTime, 0).Format(timeLayout) //设置时间戳 使用模板格式化为日期字符串
115
+	tempTime := strings.Split(dataTimeStr, " ")
116
+
117
+	recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", tempTime[0])
118
+	if parseDateErr != nil {
119
+		this.ErrorLog("日期(%v)解析错误:%v", tempTime[0], parseDateErr)
120
+		//this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
121
+		//return
122
+	}
123
+
124
+	patient, _ := service.FindPatientWithDeviceById(adminUserInfo.CurrentOrgId, record.PatientID, recordDate.Unix())
125
+	if err != nil {
126
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
127
+		return
128
+	} else {
129
+		this.ServeSuccessJSON(map[string]interface{}{
130
+			"record":  record,
131
+			"patient": patient,
132
+		})
133
+	}
134
+}
135
+
136
+func (this *PrintDataAPIController) GetLastAfterWeight() {
137
+	id, _ := this.GetInt64("id")
138
+	fmt.Print("id", id)
139
+	assmentdate, _ := this.GetInt64("assmentdate")
140
+
141
+	adminUserInfo := this.GetAdminUserInfo()
142
+	org_id := adminUserInfo.CurrentOrgId
143
+	weight, err := service.GetLastAfterWeight(org_id, id, assmentdate)
144
+	//fmt.Print("errr-------------",err)
145
+	if err != nil {
146
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
147
+		return
148
+	}
149
+	this.ServeSuccessJSON(map[string]interface{}{
150
+		"weight": weight,
151
+	})
152
+}

+ 158 - 0
controllers/public_api_controller.go View File

@@ -0,0 +1,158 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"encoding/json"
7
+	"fmt"
8
+	"strings"
9
+	"time"
10
+
11
+	"github.com/astaxie/beego"
12
+)
13
+
14
+type PublicApiController struct {
15
+	BaseAPIController
16
+}
17
+
18
+func PublicApiRegistRouters() {
19
+	beego.Router("/api/public/getadviceconfig", &PublicApiController{}, "Get:GetDoctorAdviceConfig")
20
+	beego.Router("/api/public/servertime", &PublicApiController{}, "Get:GetServerTime")
21
+	beego.Router("/api/app/release", &PublicApiController{}, "Get:AppRelease")
22
+	beego.Router("/api/get", &PublicApiController{}, "Get:GetJson")
23
+
24
+}
25
+
26
+func (c *PublicApiController) GetDoctorAdviceConfig() {
27
+	drugs, _, _ := service.GetPublicDrugDics()
28
+	drugways, _, _ := service.GetPublicDrugWayDics()
29
+	efs, _, _ := service.GetPublicExecutionFrequencyDics()
30
+
31
+	c.ServeSuccessJSON(map[string]interface{}{
32
+		"drugs":    drugs,
33
+		"drugways": drugways,
34
+		"efs":      efs,
35
+	})
36
+}
37
+
38
+func (c *PublicApiController) GetServerTime() {
39
+	timeNow := time.Now()
40
+	timeNowStamp := timeNow.Unix()
41
+	timeNowStr := timeNow.Format("2006-01-02 15:04:05")
42
+	c.ServeSuccessJSON(map[string]interface{}{
43
+		"time":      timeNowStr,
44
+		"timestamp": timeNowStamp,
45
+	})
46
+
47
+}
48
+
49
+func (c *PublicApiController) AppRelease() {
50
+	// appId := c.GetString("appid")
51
+	version := c.GetString("version")
52
+	appType, _ := c.GetInt64("app_type", 0)
53
+
54
+	appVersion, err := service.GetAppVersionByAppType(appType)
55
+	if err != nil {
56
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
57
+		return
58
+	}
59
+
60
+	if appVersion == nil {
61
+		c.ServeSuccessJSON(map[string]interface{}{
62
+			"version": nil,
63
+			"state":   2,
64
+		})
65
+		return
66
+	}
67
+
68
+	state := strings.Compare(version, appVersion.Version)
69
+	// state := 1
70
+
71
+	if state < 0 {
72
+		c.ServeSuccessJSON(map[string]interface{}{
73
+			"version": appVersion,
74
+			"state":   appVersion.Status,
75
+		})
76
+		return
77
+	}
78
+	c.ServeSuccessJSON(map[string]interface{}{
79
+		"version": nil,
80
+		"state":   2,
81
+	})
82
+	return
83
+
84
+}
85
+
86
+func (this *PublicApiController) GetJson() {
87
+	type Global struct {
88
+		DeviceSN        string
89
+		Version         string
90
+		Timestamp       string
91
+		InterfaceSource string
92
+	}
93
+	type RBPResultModel struct {
94
+		Sys         string
95
+		Dia         string
96
+		HR          string
97
+		MeasureTime string
98
+	}
99
+
100
+	type ScannerResultModel struct {
101
+		Code string
102
+	}
103
+
104
+	type IDCardResultModel struct {
105
+		IDCardNo         string
106
+		UserName         string
107
+		Age              string
108
+		Female           string
109
+		Male             string
110
+		SocialSecurityNo string
111
+	}
112
+
113
+	type JsonTemp struct {
114
+		Global             Global
115
+		RBPResultModel     RBPResultModel
116
+		ScannerResultModel ScannerResultModel
117
+		IDCardResultModel  IDCardResultModel
118
+	}
119
+
120
+	var person JsonTemp
121
+	err3 := json.Unmarshal([]byte(this.GetString("params")), &person)
122
+	fmt.Println(err3)
123
+
124
+	fmt.Println(person.Global)
125
+
126
+	//temp := JsonTemp{
127
+	//	Global:Global{
128
+	//		DeviceSN:"1122",
129
+	//		Version:"1122",
130
+	//		Timestamp:"1222",
131
+	//		InterfaceSource:"1233",
132
+	//	},
133
+	//	RBPResultModel: RBPResultModel{
134
+	//		Sys:"12",
135
+	//		Dia:"22",
136
+	//		HR:"23",
137
+	//		MeasureTime:"123",
138
+	//	},
139
+	//	ScannerResultModel:ScannerResultModel{
140
+	//		Code:"1233",
141
+	//	},
142
+	//	IDCardResultModel:IDCardResultModel{
143
+	//		IDCardNo:"123",
144
+	//		UserName:"123",
145
+	//		Age:"123",
146
+	//		Female:"123",
147
+	//		Male:"123",
148
+	//		SocialSecurityNo:"123",
149
+	//	},
150
+	//}
151
+	//
152
+	//jsonBytes, err := json.Marshal(temp)
153
+	//if err != nil {
154
+	//	fmt.Println(err)
155
+	//}
156
+	//fmt.Println(string(jsonBytes))
157
+
158
+}

+ 864 - 0
controllers/qcd_api_controller.go View File

@@ -0,0 +1,864 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"XT_New/utils"
7
+	"time"
8
+
9
+	"github.com/astaxie/beego"
10
+)
11
+
12
+type QcdApiController struct {
13
+	BaseAuthAPIController
14
+}
15
+
16
+func QcdApiRegistRouters() {
17
+	beego.Router("/api/qcd/dialysistotaldata", &QcdApiController{}, "get:GetDialysisTotalData")
18
+	beego.Router("/api/qcd/processindicatorsdata", &QcdApiController{}, "get:GetProcessIndicatorsData")
19
+	beego.Router("/api/qcd/oicdata", &QcdApiController{}, "get:GetOICData")
20
+	beego.Router("/api/qcd/oiqdata", &QcdApiController{}, "get:GetOIQData")
21
+	beego.Router("/api/qcd/patotaldata", &QcdApiController{}, "get:GetPATotalData")
22
+	beego.Router("/api/qcd/padialysisagedata", &QcdApiController{}, "get:GetPADialysisAgeData")
23
+	beego.Router("/api/qcd/paweightdata", &QcdApiController{}, "get:GetPAWeightData")
24
+	beego.Router("/api/qcd/pabloodpressuredata", &QcdApiController{}, "get:GetPABloodPressureData")
25
+	beego.Router("/api/qcd/pacomplicationdata", &QcdApiController{}, "get:GetPAComplicationData")
26
+	beego.Router("/api/qcd/painfectiousdiseasesdata", &QcdApiController{}, "get:GetPAInfectiousDiseasesData")
27
+	beego.Router("/api/qcd/papersonlapsetdata", &QcdApiController{}, "get:GetPersonLapsetoData")
28
+	beego.Router("/api/qcd/papersonweightdata", &QcdApiController{}, "get:GetPersonWeightData")
29
+	beego.Router("/api/qcd/papersonbloodpressuredata", &QcdApiController{}, "get:GetPersonBloodPressureData")
30
+	beego.Router("/api/qcd/papersonicdata", &QcdApiController{}, "get:GetPersonICData")
31
+	beego.Router("/api/qcd/papersonadvicedata", &QcdApiController{}, "get:GetPersonAdviceData")
32
+}
33
+
34
+func (c *QcdApiController) GetDialysisTotalData() {
35
+	page, _ := c.GetInt64("page", 1)
36
+	limit, _ := c.GetInt64("limit", 10)
37
+	lapseto, _ := c.GetInt64("lapseto", 0)
38
+	statisticalMethod, _ := c.GetInt64("statistical_method", 0)
39
+	modeID, _ := c.GetInt64("mode_id", 0)
40
+	startTime := c.GetString("start_time", "")
41
+	endTime := c.GetString("end_time", "")
42
+
43
+	if page <= 0 {
44
+		page = 1
45
+	}
46
+	if limit <= 0 {
47
+		limit = 10
48
+	}
49
+
50
+	adminUserInfo := c.GetAdminUserInfo()
51
+
52
+	timeLayout := "2006-01-02"
53
+	loc, _ := time.LoadLocation("Local")
54
+
55
+	var isStartTime bool
56
+	var theStartTIme int64
57
+	if len(startTime) > 0 {
58
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
59
+		if err != nil {
60
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
61
+			return
62
+		}
63
+		isStartTime = true
64
+		theStartTIme = theTime.Unix()
65
+	}
66
+	var isEndTime bool
67
+	var theEndtTIme int64
68
+	if len(endTime) > 0 {
69
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
70
+		if err != nil {
71
+			utils.ErrorLog(err.Error())
72
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
73
+			return
74
+		}
75
+		isEndTime = true
76
+		theEndtTIme = theTime.Unix()
77
+	}
78
+
79
+	data, ttd, total, _ := service.GetDialysisTotalData(adminUserInfo.CurrentOrgId, page, limit, lapseto, statisticalMethod, modeID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
80
+
81
+	c.ServeSuccessJSON(map[string]interface{}{
82
+		"dtd":   data,
83
+		"ttd":   ttd,
84
+		"total": total,
85
+	})
86
+	return
87
+}
88
+
89
+func (c *QcdApiController) GetProcessIndicatorsData() {
90
+	page, _ := c.GetInt64("page", 1)
91
+	limit, _ := c.GetInt64("limit", 10)
92
+	lapseto, _ := c.GetInt64("lapseto", 0)
93
+	dialysisAge, _ := c.GetInt64("dialysis_age", 0)
94
+	projectID, _ := c.GetInt64("project_id", 0)
95
+	startTime := c.GetString("start_time", "")
96
+	endTime := c.GetString("end_time", "")
97
+
98
+	if page <= 0 {
99
+		page = 1
100
+	}
101
+	if limit <= 0 {
102
+		limit = 10
103
+	}
104
+
105
+	adminUserInfo := c.GetAdminUserInfo()
106
+
107
+	timeLayout := "2006-01-02"
108
+	loc, _ := time.LoadLocation("Local")
109
+
110
+	var isStartTime bool
111
+	var theStartTIme int64
112
+	if len(startTime) > 0 {
113
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
114
+		if err != nil {
115
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
116
+			return
117
+		}
118
+		isStartTime = true
119
+		theStartTIme = theTime.Unix()
120
+	}
121
+	var isEndTime bool
122
+	var theEndtTIme int64
123
+	if len(endTime) > 0 {
124
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
125
+		if err != nil {
126
+			utils.ErrorLog(err.Error())
127
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
128
+			return
129
+		}
130
+		isEndTime = true
131
+		theEndtTIme = theTime.Unix()
132
+	}
133
+
134
+	inspections, references, patients, counts, total, err := service.GetProcessIndicatorsData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisAge, projectID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
135
+	if err != nil {
136
+		utils.ErrorLog(err.Error())
137
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
138
+		return
139
+	}
140
+	c.ServeSuccessJSON(map[string]interface{}{
141
+		"inspections":     inspections,
142
+		"references":      references,
143
+		"patients":        patients,
144
+		"unfinishedcount": counts[0].Count,
145
+		"total":           total,
146
+	})
147
+	return
148
+}
149
+
150
+func (c *QcdApiController) GetOICData() {
151
+	page, _ := c.GetInt64("page", 1)
152
+	limit, _ := c.GetInt64("limit", 10)
153
+	lapseto, _ := c.GetInt64("lapseto", 0)
154
+	dialysisAge, _ := c.GetInt64("dialysis_age", 0)
155
+	projectID, _ := c.GetInt64("project_id", 0)
156
+	itemID, _ := c.GetInt64("item_id", 0)
157
+	startTime := c.GetString("start_time", "")
158
+	endTime := c.GetString("end_time", "")
159
+
160
+	if page <= 0 {
161
+		page = 1
162
+	}
163
+	if limit <= 0 {
164
+		limit = 10
165
+	}
166
+
167
+	adminUserInfo := c.GetAdminUserInfo()
168
+
169
+	timeLayout := "2006-01-02"
170
+	loc, _ := time.LoadLocation("Local")
171
+
172
+	var isStartTime bool
173
+	var theStartTIme int64
174
+	if len(startTime) > 0 {
175
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
176
+		if err != nil {
177
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
178
+			return
179
+		}
180
+		isStartTime = true
181
+		theStartTIme = theTime.Unix()
182
+	}
183
+	var isEndTime bool
184
+	var theEndtTIme int64
185
+	if len(endTime) > 0 {
186
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
187
+		if err != nil {
188
+			utils.ErrorLog(err.Error())
189
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
190
+			return
191
+		}
192
+		isEndTime = true
193
+		theEndtTIme = theTime.Unix()
194
+	}
195
+
196
+	inspections, references, patients, counts, total, err := service.GetOICData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisAge, projectID, itemID, theStartTIme, theEndtTIme, isStartTime, isEndTime)
197
+	if err != nil {
198
+		utils.ErrorLog(err.Error())
199
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
200
+		return
201
+	}
202
+	c.ServeSuccessJSON(map[string]interface{}{
203
+		"inspections":     inspections,
204
+		"references":      references,
205
+		"patients":        patients,
206
+		"unfinishedcount": counts[0].Count,
207
+		"total":           total,
208
+	})
209
+	return
210
+}
211
+
212
+func (c *QcdApiController) GetOIQData() {
213
+	page, _ := c.GetInt64("page", 1)
214
+	limit, _ := c.GetInt64("limit", 10)
215
+	projectID, _ := c.GetInt64("project_id", 0)
216
+	startTime := c.GetString("start_time", "")
217
+	endTime := c.GetString("end_time", "")
218
+	searchKey := c.GetString("search", "")
219
+
220
+	if page <= 0 {
221
+		page = 1
222
+	}
223
+	if limit <= 0 {
224
+		limit = 10
225
+	}
226
+
227
+	adminUserInfo := c.GetAdminUserInfo()
228
+
229
+	timeLayout := "2006-01-02"
230
+	loc, _ := time.LoadLocation("Local")
231
+
232
+	var isStartTime bool
233
+	var theStartTIme int64
234
+	if len(startTime) > 0 {
235
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
236
+		if err != nil {
237
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
238
+			return
239
+		}
240
+		isStartTime = true
241
+		theStartTIme = theTime.Unix()
242
+	}
243
+	var isEndTime bool
244
+	var theEndtTIme int64
245
+	if len(endTime) > 0 {
246
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
247
+		if err != nil {
248
+			utils.ErrorLog(err.Error())
249
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
250
+			return
251
+		}
252
+		isEndTime = true
253
+		theEndtTIme = theTime.Unix()
254
+	}
255
+
256
+	inspections, references, patients, total, err := service.GetOIQData(adminUserInfo.CurrentOrgId, page, limit, projectID, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
257
+	if err != nil {
258
+		utils.ErrorLog(err.Error())
259
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
260
+		return
261
+	}
262
+	c.ServeSuccessJSON(map[string]interface{}{
263
+		"inspections": inspections,
264
+		"references":  references,
265
+		"patients":    patients,
266
+		"total":       total,
267
+	})
268
+	return
269
+}
270
+
271
+func (c *QcdApiController) GetPATotalData() {
272
+	page, _ := c.GetInt64("page", 1)
273
+	limit, _ := c.GetInt64("limit", 10)
274
+	startTime := c.GetString("start_time", "")
275
+	endTime := c.GetString("end_time", "")
276
+	searchKey := c.GetString("search", "")
277
+	age, _ := c.GetInt64("age", 0)
278
+	lapseto, _ := c.GetInt64("lapseto", 0)
279
+	source, _ := c.GetInt64("source", 0)
280
+
281
+	if page <= 0 {
282
+		page = 1
283
+	}
284
+	if limit <= 0 {
285
+		limit = 10
286
+	}
287
+
288
+	adminUserInfo := c.GetAdminUserInfo()
289
+
290
+	timeLayout := "2006-01-02"
291
+	loc, _ := time.LoadLocation("Local")
292
+
293
+	var isStartTime bool
294
+	var theStartTIme int64
295
+	if len(startTime) > 0 {
296
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
297
+		if err != nil {
298
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
299
+			return
300
+		}
301
+		isStartTime = true
302
+		theStartTIme = theTime.Unix()
303
+	}
304
+	var isEndTime bool
305
+	var theEndtTIme int64
306
+	if len(endTime) > 0 {
307
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
308
+		if err != nil {
309
+			utils.ErrorLog(err.Error())
310
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
311
+			return
312
+		}
313
+		isEndTime = true
314
+		theEndtTIme = theTime.Unix()
315
+	}
316
+
317
+	patients, lapsetoOut, lapsetoIn, total, err := service.GetPATotalData(adminUserInfo.CurrentOrgId, page, limit, lapseto, source, age, theStartTIme, theEndtTIme, isStartTime, isEndTime, searchKey)
318
+	if err != nil {
319
+		utils.ErrorLog(err.Error())
320
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
321
+		return
322
+	}
323
+	c.ServeSuccessJSON(map[string]interface{}{
324
+		"patients":   patients,
325
+		"total":      total,
326
+		"lapsetoOut": lapsetoOut,
327
+		"lapsetoIn":  lapsetoIn,
328
+	})
329
+	return
330
+}
331
+
332
+func (c *QcdApiController) GetPADialysisAgeData() {
333
+	page, _ := c.GetInt64("page", 1)
334
+	limit, _ := c.GetInt64("limit", 10)
335
+	startTime := c.GetString("start_time", "")
336
+	endTime := c.GetString("end_time", "")
337
+	age, _ := c.GetInt64("age", 0)
338
+	dialysisAge, _ := c.GetInt64("dialysis_age", 0)
339
+	lapseto, _ := c.GetInt64("lapseto", 0)
340
+
341
+	if page <= 0 {
342
+		page = 1
343
+	}
344
+	if limit <= 0 {
345
+		limit = 10
346
+	}
347
+
348
+	adminUserInfo := c.GetAdminUserInfo()
349
+
350
+	timeLayout := "2006-01-02"
351
+	loc, _ := time.LoadLocation("Local")
352
+
353
+	var isStartTime bool
354
+	var theStartTIme int64
355
+	if len(startTime) > 0 {
356
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
357
+		if err != nil {
358
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
359
+			return
360
+		}
361
+		isStartTime = true
362
+		theStartTIme = theTime.Unix()
363
+	}
364
+	var isEndTime bool
365
+	var theEndtTIme int64
366
+	if len(endTime) > 0 {
367
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
368
+		if err != nil {
369
+			utils.ErrorLog(err.Error())
370
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
371
+			return
372
+		}
373
+		isEndTime = true
374
+		theEndtTIme = theTime.Unix()
375
+	}
376
+
377
+	patients, counts, total, err := service.GetPADialysisAgeData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, dialysisAge, theStartTIme, theEndtTIme, isStartTime, isEndTime)
378
+	if err != nil {
379
+		utils.ErrorLog(err.Error())
380
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
381
+		return
382
+	}
383
+	c.ServeSuccessJSON(map[string]interface{}{
384
+		"patients": patients,
385
+		"counts":   counts,
386
+		"total":    total,
387
+	})
388
+	return
389
+}
390
+
391
+func (c *QcdApiController) GetPAWeightData() {
392
+	page, _ := c.GetInt64("page", 1)
393
+	limit, _ := c.GetInt64("limit", 10)
394
+	startTime := c.GetString("start_time", "")
395
+	endTime := c.GetString("end_time", "")
396
+	age, _ := c.GetInt64("age", 0)
397
+	lapseto, _ := c.GetInt64("lapseto", 0)
398
+
399
+	if page <= 0 {
400
+		page = 1
401
+	}
402
+	if limit <= 0 {
403
+		limit = 10
404
+	}
405
+
406
+	adminUserInfo := c.GetAdminUserInfo()
407
+
408
+	timeLayout := "2006-01-02"
409
+	loc, _ := time.LoadLocation("Local")
410
+
411
+	var isStartTime bool
412
+	var theStartTIme int64
413
+	if len(startTime) > 0 {
414
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
415
+		if err != nil {
416
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
417
+			return
418
+		}
419
+		isStartTime = true
420
+		theStartTIme = theTime.Unix()
421
+	}
422
+	var isEndTime bool
423
+	var theEndtTIme int64
424
+	if len(endTime) > 0 {
425
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
426
+		if err != nil {
427
+			utils.ErrorLog(err.Error())
428
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
429
+			return
430
+		}
431
+		isEndTime = true
432
+		theEndtTIme = theTime.Unix()
433
+	}
434
+
435
+	weights, dryweight, weightincrease, afterweight, total, err := service.GetPAWeightData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, theStartTIme, theEndtTIme, isStartTime, isEndTime)
436
+	if err != nil {
437
+		utils.ErrorLog(err.Error())
438
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
439
+		return
440
+	}
441
+	c.ServeSuccessJSON(map[string]interface{}{
442
+		"weights":        weights,
443
+		"dryweight":      dryweight,
444
+		"weightincrease": weightincrease,
445
+		"afterweight":    afterweight,
446
+		"total":          total,
447
+	})
448
+	return
449
+}
450
+
451
+func (c *QcdApiController) GetPABloodPressureData() {
452
+	page, _ := c.GetInt64("page", 1)
453
+	limit, _ := c.GetInt64("limit", 10)
454
+	startTime := c.GetString("start_time", "")
455
+	endTime := c.GetString("end_time", "")
456
+	lapseto, _ := c.GetInt64("lapseto", 0)
457
+	dialysisStage, _ := c.GetInt64("dialysis_stage", 0)
458
+
459
+	if page <= 0 {
460
+		page = 1
461
+	}
462
+	if limit <= 0 {
463
+		limit = 10
464
+	}
465
+
466
+	adminUserInfo := c.GetAdminUserInfo()
467
+
468
+	timeLayout := "2006-01-02"
469
+	loc, _ := time.LoadLocation("Local")
470
+
471
+	var isStartTime bool
472
+	var theStartTIme int64
473
+	if len(startTime) > 0 {
474
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
475
+		if err != nil {
476
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
477
+			return
478
+		}
479
+		isStartTime = true
480
+		theStartTIme = theTime.Unix()
481
+	}
482
+	var isEndTime bool
483
+	var theEndtTIme int64
484
+	if len(endTime) > 0 {
485
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
486
+		if err != nil {
487
+			utils.ErrorLog(err.Error())
488
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
489
+			return
490
+		}
491
+		isEndTime = true
492
+		theEndtTIme = theTime.Unix()
493
+	}
494
+
495
+	bloodPressures, bps, total, err := service.GetPABloodPressureData(adminUserInfo.CurrentOrgId, page, limit, lapseto, dialysisStage, theStartTIme, theEndtTIme, isStartTime, isEndTime)
496
+	if err != nil {
497
+		utils.ErrorLog(err.Error())
498
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
499
+		return
500
+	}
501
+	c.ServeSuccessJSON(map[string]interface{}{
502
+		"blood_pressures": bloodPressures,
503
+		"bps":             bps,
504
+		"total":           total,
505
+	})
506
+	return
507
+}
508
+
509
+func (c *QcdApiController) GetPAComplicationData() {
510
+	page, _ := c.GetInt64("page", 1)
511
+	limit, _ := c.GetInt64("limit", 10)
512
+	startTime := c.GetString("start_time", "")
513
+	endTime := c.GetString("end_time", "")
514
+	age, _ := c.GetInt64("age", 0)
515
+	statisticalState, _ := c.GetInt64("statistical_state", 0)
516
+
517
+	if page <= 0 {
518
+		page = 1
519
+	}
520
+	if limit <= 0 {
521
+		limit = 10
522
+	}
523
+
524
+	adminUserInfo := c.GetAdminUserInfo()
525
+
526
+	timeLayout := "2006-01-02"
527
+	loc, _ := time.LoadLocation("Local")
528
+
529
+	var isStartTime bool
530
+	var theStartTIme int64
531
+	if len(startTime) > 0 {
532
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
533
+		if err != nil {
534
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
535
+			return
536
+		}
537
+		isStartTime = true
538
+		theStartTIme = theTime.Unix()
539
+	}
540
+	var isEndTime bool
541
+	var theEndtTIme int64
542
+	if len(endTime) > 0 {
543
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
544
+		if err != nil {
545
+			utils.ErrorLog(err.Error())
546
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
547
+			return
548
+		}
549
+		isEndTime = true
550
+		theEndtTIme = theTime.Unix()
551
+	}
552
+
553
+	complications, pcps, total, err := service.GetPAComplicationData(adminUserInfo.CurrentOrgId, page, limit, age, statisticalState, theStartTIme, theEndtTIme, isStartTime, isEndTime)
554
+	if err != nil {
555
+		utils.ErrorLog(err.Error())
556
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
557
+		return
558
+	}
559
+	c.ServeSuccessJSON(map[string]interface{}{
560
+		"complications": complications,
561
+		"pcps":          pcps,
562
+		"total":         total,
563
+	})
564
+	return
565
+}
566
+
567
+func (c *QcdApiController) GetPAInfectiousDiseasesData() {
568
+	page, _ := c.GetInt64("page", 1)
569
+	limit, _ := c.GetInt64("limit", 10)
570
+	startTime := c.GetString("start_time", "")
571
+	endTime := c.GetString("end_time", "")
572
+	age, _ := c.GetInt64("age", 0)
573
+	contagionType, _ := c.GetInt64("contagion_type", 0)
574
+	lapseto, _ := c.GetInt64("lapseto", 0)
575
+
576
+	if page <= 0 {
577
+		page = 1
578
+	}
579
+	if limit <= 0 {
580
+		limit = 10
581
+	}
582
+
583
+	adminUserInfo := c.GetAdminUserInfo()
584
+
585
+	timeLayout := "2006-01-02"
586
+	loc, _ := time.LoadLocation("Local")
587
+
588
+	var isStartTime bool
589
+	var theStartTIme int64
590
+	if len(startTime) > 0 {
591
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
592
+		if err != nil {
593
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
594
+			return
595
+		}
596
+		isStartTime = true
597
+		theStartTIme = theTime.Unix()
598
+	}
599
+	var isEndTime bool
600
+	var theEndtTIme int64
601
+	if len(endTime) > 0 {
602
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
603
+		if err != nil {
604
+			utils.ErrorLog(err.Error())
605
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
606
+			return
607
+		}
608
+		isEndTime = true
609
+		theEndtTIme = theTime.Unix()
610
+	}
611
+
612
+	patients, dsp, total, err := service.GetPAInfectiousDiseasesData(adminUserInfo.CurrentOrgId, page, limit, lapseto, age, contagionType, theStartTIme, theEndtTIme, isStartTime, isEndTime)
613
+	if err != nil {
614
+		utils.ErrorLog(err.Error())
615
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
616
+		return
617
+	}
618
+	c.ServeSuccessJSON(map[string]interface{}{
619
+		"patients": patients,
620
+		"dsp":      dsp,
621
+		"total":    total,
622
+	})
623
+	return
624
+}
625
+
626
+func (c *QcdApiController) GetPersonLapsetoData() {
627
+	page, _ := c.GetInt64("page", 1)
628
+	limit, _ := c.GetInt64("limit", 10)
629
+	patientId, _ := c.GetInt64("patient_id", 0)
630
+
631
+	if page <= 0 {
632
+		page = 1
633
+	}
634
+	if limit <= 0 {
635
+		limit = 10
636
+	}
637
+
638
+	adminUserInfo := c.GetAdminUserInfo()
639
+
640
+	patient, lapsetos, total, err := service.GetPersonLapsetoData(adminUserInfo.CurrentOrgId, patientId, page, limit)
641
+	if err != nil {
642
+		utils.ErrorLog(err.Error())
643
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
644
+		return
645
+	}
646
+	c.ServeSuccessJSON(map[string]interface{}{
647
+		"patient":  patient,
648
+		"lapsetos": lapsetos,
649
+		"total":    total,
650
+	})
651
+	return
652
+}
653
+
654
+func (c *QcdApiController) GetPersonWeightData() {
655
+	page, _ := c.GetInt64("page", 1)
656
+	limit, _ := c.GetInt64("limit", 10)
657
+	patientId, _ := c.GetInt64("patient_id", 0)
658
+	startTime := c.GetString("start_time", "")
659
+	endTime := c.GetString("end_time", "")
660
+
661
+	if page <= 0 {
662
+		page = 1
663
+	}
664
+	if limit <= 0 {
665
+		limit = 10
666
+	}
667
+	var isStartTime bool
668
+	var theStartTIme int64
669
+
670
+	timeLayout := "2006-01-02"
671
+	loc, _ := time.LoadLocation("Local")
672
+
673
+	if len(startTime) > 0 {
674
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
675
+		if err != nil {
676
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
677
+			return
678
+		}
679
+		isStartTime = true
680
+		theStartTIme = theTime.Unix()
681
+	}
682
+	var isEndTime bool
683
+	var theEndtTIme int64
684
+	if len(endTime) > 0 {
685
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
686
+		if err != nil {
687
+			utils.ErrorLog(err.Error())
688
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
689
+			return
690
+		}
691
+		isEndTime = true
692
+		theEndtTIme = theTime.Unix()
693
+	}
694
+
695
+	adminUserInfo := c.GetAdminUserInfo()
696
+
697
+	patient, weight, pie, total, err := service.GetPersonWeightData(adminUserInfo.CurrentOrgId, patientId, page, limit, theStartTIme, theEndtTIme, isStartTime, isEndTime)
698
+	if err != nil {
699
+		utils.ErrorLog(err.Error())
700
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
701
+		return
702
+	}
703
+	c.ServeSuccessJSON(map[string]interface{}{
704
+		"patient": patient,
705
+		"weight":  weight,
706
+		"pie":     pie,
707
+		"total":   total,
708
+	})
709
+	return
710
+}
711
+
712
+func (c *QcdApiController) GetPersonBloodPressureData() {
713
+	page, _ := c.GetInt64("page", 1)
714
+	limit, _ := c.GetInt64("limit", 10)
715
+	patientId, _ := c.GetInt64("patient_id", 0)
716
+	startTime := c.GetString("start_time", "")
717
+	endTime := c.GetString("end_time", "")
718
+
719
+	if page <= 0 {
720
+		page = 1
721
+	}
722
+	if limit <= 0 {
723
+		limit = 10
724
+	}
725
+	var isStartTime bool
726
+	var theStartTIme int64
727
+
728
+	timeLayout := "2006-01-02"
729
+	loc, _ := time.LoadLocation("Local")
730
+
731
+	if len(startTime) > 0 {
732
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
733
+		if err != nil {
734
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
735
+			return
736
+		}
737
+		isStartTime = true
738
+		theStartTIme = theTime.Unix()
739
+	}
740
+	var isEndTime bool
741
+	var theEndtTIme int64
742
+	if len(endTime) > 0 {
743
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
744
+		if err != nil {
745
+			utils.ErrorLog(err.Error())
746
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
747
+			return
748
+		}
749
+		isEndTime = true
750
+		theEndtTIme = theTime.Unix()
751
+	}
752
+
753
+	adminUserInfo := c.GetAdminUserInfo()
754
+
755
+	patient, bps, lines, total, err := service.GetPersonBloodPressureData(adminUserInfo.CurrentOrgId, patientId, page, limit, theStartTIme, theEndtTIme, isStartTime, isEndTime)
756
+	if err != nil {
757
+		utils.ErrorLog(err.Error())
758
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
759
+		return
760
+	}
761
+	c.ServeSuccessJSON(map[string]interface{}{
762
+		"patient": patient,
763
+		"bps":     bps,
764
+		"lines":   lines,
765
+		"total":   total,
766
+	})
767
+	return
768
+}
769
+
770
+func (c *QcdApiController) GetPersonICData() {
771
+	page, _ := c.GetInt64("page", 1)
772
+	limit, _ := c.GetInt64("limit", 10)
773
+	patientId, _ := c.GetInt64("patient_id", 0)
774
+
775
+	if page <= 0 {
776
+		page = 1
777
+	}
778
+	if limit <= 0 {
779
+		limit = 10
780
+	}
781
+	adminUserInfo := c.GetAdminUserInfo()
782
+
783
+	patient, inspections, references, total, err := service.GetPersonICData(adminUserInfo.CurrentOrgId, patientId, page, limit)
784
+	if err != nil {
785
+		utils.ErrorLog(err.Error())
786
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
787
+		return
788
+	}
789
+	c.ServeSuccessJSON(map[string]interface{}{
790
+		"patient":     patient,
791
+		"inspections": inspections,
792
+		"references":  references,
793
+		"total":       total,
794
+	})
795
+	return
796
+}
797
+
798
+func (c *QcdApiController) GetPersonAdviceData() {
799
+	page, _ := c.GetInt64("page", 1)
800
+	limit, _ := c.GetInt64("limit", 10)
801
+	patientId, _ := c.GetInt64("patient_id", 0)
802
+	adviceType, _ := c.GetInt64("advice_type", 0)
803
+	medicalType, _ := c.GetInt64("medical_type", 0)
804
+	startTime := c.GetString("start_time", "")
805
+	endTime := c.GetString("end_time", "")
806
+
807
+	if page <= 0 {
808
+		page = 1
809
+	}
810
+	if limit <= 0 {
811
+		limit = 10
812
+	}
813
+	var isStartTime bool
814
+	var theStartTIme int64
815
+
816
+	timeLayout := "2006-01-02"
817
+	loc, _ := time.LoadLocation("Local")
818
+
819
+	if len(startTime) > 0 {
820
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
821
+		if err != nil {
822
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
823
+			return
824
+		}
825
+		isStartTime = true
826
+		theStartTIme = theTime.Unix()
827
+	}
828
+	var isEndTime bool
829
+	var theEndtTIme int64
830
+	if len(endTime) > 0 {
831
+		theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
832
+		if err != nil {
833
+			utils.ErrorLog(err.Error())
834
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
835
+			return
836
+		}
837
+		isEndTime = true
838
+		theEndtTIme = theTime.Unix()
839
+	}
840
+
841
+	adminUserInfo := c.GetAdminUserInfo()
842
+
843
+	patient, advices, total, err := service.GetPersonAdviceData(adminUserInfo.CurrentOrgId, patientId, page, limit, adviceType, medicalType, theStartTIme, theEndtTIme, isStartTime, isEndTime)
844
+	if err != nil {
845
+		utils.ErrorLog(err.Error())
846
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
847
+		return
848
+	}
849
+
850
+	users, err := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
851
+	if err != nil {
852
+		utils.ErrorLog(err.Error())
853
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
854
+		return
855
+	}
856
+
857
+	c.ServeSuccessJSON(map[string]interface{}{
858
+		"patient": patient,
859
+		"advices": advices,
860
+		"users":   users,
861
+		"total":   total,
862
+	})
863
+	return
864
+}

+ 36 - 0
controllers/qiniiu_api_controller.go View File

@@ -0,0 +1,36 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/service"
6
+	"fmt"
7
+
8
+	"github.com/astaxie/beego"
9
+)
10
+
11
+type QiNiuApiController struct {
12
+	BaseAPIController
13
+	// beego.Controller
14
+}
15
+
16
+func QiniuApiRegistRouters() {
17
+	beego.Router("/api/qiniu/uptoken", &QiNiuApiController{}, "get:GetQNUpToken")
18
+}
19
+
20
+func (c *QiNiuApiController) GetQNUpToken() {
21
+	redisClient := service.RedisClient()
22
+	defer redisClient.Close()
23
+
24
+	token, err := redisClient.Get("qn_token").Result()
25
+
26
+	if err != nil {
27
+		defer fmt.Println(err)
28
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGetQiniuUpToken)
29
+		return
30
+	}
31
+
32
+	c.ServeSuccessJSON(map[string]interface{}{
33
+		"uptoken": token,
34
+	})
35
+	return
36
+}

+ 713 - 0
controllers/role_controller.go View File

@@ -0,0 +1,713 @@
1
+package controllers
2
+
3
+import (
4
+	"strconv"
5
+	"strings"
6
+	"time"
7
+
8
+	"XT_New/enums"
9
+	"XT_New/models"
10
+	"XT_New/service"
11
+
12
+	"github.com/astaxie/beego"
13
+)
14
+
15
+func RoleAPIControllerRegistRouters() {
16
+	beego.Router("/api/roles", &RoleAPIController{}, "get:GetRoles")
17
+	beego.Router("/api/role/create", &RoleAPIController{}, "post:CreateRole")
18
+	beego.Router("/api/role/modify", &RoleAPIController{}, "post:ModifyRole")
19
+	beego.Router("/api/role/setstatus", &RoleAPIController{}, "post:ModifyRoleStatus")
20
+
21
+	beego.Router("/role/purview/editinit", &RoleAPIController{}, "get:EditPurviewInitData")
22
+	beego.Router("/role/purview/edit", &RoleAPIController{}, "post:EditPurview")
23
+
24
+	beego.Router("/api/adminmain", &RoleAPIController{}, "get:AdminMainView")
25
+	beego.Router("/api/admins", &RoleAPIController{}, "get:Admins")
26
+	beego.Router("/api/admin/addinit", &RoleAPIController{}, "get:AddAdminInitData")
27
+	beego.Router("/api/admin/add", &RoleAPIController{}, "post:AddAdmin")
28
+	beego.Router("/api/admin/editinit", &RoleAPIController{}, "get:EditAdminInitData")
29
+	beego.Router("/api/admin/edit", &RoleAPIController{}, "post:EditAdmin")
30
+	beego.Router("/api/admin/setstatus", &RoleAPIController{}, "post:AdminSetStatus")
31
+
32
+	beego.Router("/api/admin/specialpermission/initdata", &RoleAPIController{}, "get:SpecialPermissionInitData")
33
+	beego.Router("/api/admin/specialpermission/dialysisrecord/submit", &RoleAPIController{}, "post:SubmitDialysisRecordPermission")
34
+}
35
+
36
+type RoleAPIController struct {
37
+	BaseAuthAPIController
38
+}
39
+
40
+// /api/roles [get]
41
+// @param page?:int
42
+func (this *RoleAPIController) GetRoles() {
43
+	page, _ := this.GetInt("page")
44
+	adminUserInfo := this.GetAdminUserInfo()
45
+	//beego.Alert(adminUserInfo.AdminUser)
46
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
47
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
48
+		return
49
+	}
50
+
51
+	if page <= 0 {
52
+		page = 1
53
+	}
54
+	roles, total, getRoleErr := service.GetRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, 10)
55
+	if getRoleErr != nil {
56
+		//beego.Error("获取角色列表失败:", getRoleErr)
57
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
58
+	} else {
59
+		this.ServeSuccessJSON(map[string]interface{}{
60
+			"roles":       roles,
61
+			"total_count": total,
62
+		})
63
+	}
64
+}
65
+
66
+// /api/role/create [post]
67
+// @param name:string
68
+// @param intro:string
69
+func (this *RoleAPIController) CreateRole() {
70
+	name := this.GetString("name")
71
+	intro := this.GetString("intro")
72
+	if len(name) == 0 || len(intro) == 0 {
73
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
74
+		return
75
+	}
76
+	adminUserInfo := this.GetAdminUserInfo()
77
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
78
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
79
+		return
80
+	}
81
+
82
+	role, createErr := service.CreateRole(adminUserInfo.AdminUser.Id, adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, name, intro)
83
+	if createErr != nil {
84
+		//beego.Error("创建角色失败:", createErr)
85
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
86
+	} else {
87
+		this.ServeSuccessJSON(map[string]interface{}{
88
+			"id":     role.Id,
89
+			"name":   role.RoleName,
90
+			"intro":  role.RoleIntro,
91
+			"status": role.Status,
92
+		})
93
+	}
94
+}
95
+
96
+// /api/role/modify
97
+// @param role_id:int
98
+// @param name:string
99
+// @param intro:string
100
+func (this *RoleAPIController) ModifyRole() {
101
+	roleID, _ := this.GetInt64("role_id")
102
+	name := this.GetString("name")
103
+	intro := this.GetString("intro")
104
+	if roleID <= 0 || len(name) == 0 || len(intro) == 0 {
105
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
106
+		return
107
+	}
108
+	adminUserInfo := this.GetAdminUserInfo()
109
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
110
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
111
+		return
112
+	}
113
+
114
+	role, getRoleErr := service.GetRoleByRoleID(roleID)
115
+	if getRoleErr != nil {
116
+		//beego.Error("获取角色失败:", getRoleErr)
117
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
118
+		return
119
+	} else if role == nil {
120
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
121
+		return
122
+	}
123
+
124
+	role.RoleName = name
125
+	role.RoleIntro = intro
126
+	role.ModifyTime = time.Now().Unix()
127
+	saveErr := service.ModifyRole(role)
128
+	if saveErr != nil {
129
+		//beego.Error("修改角色失败:", role.Id, saveErr)
130
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
131
+	} else {
132
+		this.ServeSuccessJSON(nil)
133
+	}
134
+}
135
+
136
+// /api/role/setstatus
137
+// @param role_id:int
138
+// @param enable:bool
139
+func (this *RoleAPIController) ModifyRoleStatus() {
140
+	roleID, _ := this.GetInt64("role_id")
141
+	enable, _ := this.GetBool("enable")
142
+	if roleID <= 0 {
143
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
144
+		return
145
+	}
146
+
147
+	adminUserInfo := this.GetAdminUserInfo()
148
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
149
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
150
+		return
151
+	}
152
+
153
+	role, getRoleErr := service.GetRoleByRoleID(roleID)
154
+	if getRoleErr != nil {
155
+		//beego.Error("获取角色失败:", getRoleErr)
156
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
157
+		return
158
+	} else if role == nil {
159
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
160
+		return
161
+	}
162
+
163
+	if enable == false {
164
+		if count, _ := service.RoleAdminUserCount(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleID); count != 0 {
165
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCannotRemoveRole)
166
+			return
167
+		}
168
+	}
169
+
170
+	if enable {
171
+		role.Status = 1
172
+	} else {
173
+		role.Status = 2
174
+	}
175
+	role.ModifyTime = time.Now().Unix()
176
+	saveErr := service.ModifyRole(role)
177
+	if saveErr != nil {
178
+		//beego.Error("修改角色失败:", role.Id, saveErr)
179
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
180
+	} else {
181
+		this.ServeSuccessJSON(nil)
182
+	}
183
+}
184
+
185
+// /role/purview/editinit [get]
186
+// @param role_id:int
187
+func (this *RoleAPIController) EditPurviewInitData() {
188
+	adminUserInfo := this.GetAdminUserInfo()
189
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
190
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
191
+		return
192
+	}
193
+
194
+	roleId, _ := this.GetInt64("role_id")
195
+	if roleId <= 0 {
196
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
197
+		return
198
+	}
199
+	purviews, getPurviewsErr := service.GetAllGeneralPurviewVMsProcessed()
200
+	if getPurviewsErr != nil {
201
+		//beego.Error("获取所有权限时出错:", getPurviewsErr)
202
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
203
+		return
204
+	}
205
+	rolePurviewIdStr, getRPIdsErr := service.GetRolePurviewIds(roleId)
206
+	if getRPIdsErr != nil {
207
+		//beego.Error("获取角色的权限时出错:", getRPIdsErr)
208
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
209
+		return
210
+	}
211
+
212
+	this.ServeSuccessJSON(map[string]interface{}{
213
+		"purviews":         purviews,
214
+		"role_purview_ids": rolePurviewIdStr,
215
+	})
216
+}
217
+
218
+// /role/purview/edit [post]
219
+// @param role_id:int
220
+// @param purview_ids:string
221
+func (this *RoleAPIController) EditPurview() {
222
+	adminUserInfo := this.GetAdminUserInfo()
223
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
224
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
225
+		return
226
+	}
227
+	roleId, _ := this.GetInt64("role_id")
228
+	purviewIds := this.GetString("purview_ids")
229
+	if roleId <= 0 {
230
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
231
+		return
232
+	}
233
+
234
+	err := service.SaveRolePurviewIds(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleId, purviewIds)
235
+	if err != nil {
236
+		//beego.Error("设置角色的权限时出错:", err)
237
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
238
+	} else {
239
+		this.ServeSuccessJSON(nil)
240
+	}
241
+}
242
+
243
+// func (this *RoleAPIController) doesUserHaveAccess(userID int64) bool {
244
+// 	adminUser, getAdminUserErr := service.GetAdminUserByUserID(userID)
245
+// 	if getAdminUserErr != nil {
246
+// 		beego.Error("获取用户信息失败:%v", getAdminUserErr)
247
+// 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
248
+// 		return false
249
+// 	} else if adminUser == nil {
250
+// 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
251
+// 		return false
252
+// 	} else if adminUser.Status == 2 {
253
+// 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUserWasForbidden)
254
+// 		return false
255
+// 	} else if adminUser.IsSuperAdmin == false {
256
+// 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
257
+// 		return false
258
+// 	}
259
+// 	return true
260
+// }
261
+
262
+// func (this *RoleAPIController) isAppRoleExist(orgID int64, appID int64, userID int64) bool {
263
+// 	appRole, getAppRoleErr := service.GetAppRole(orgID, appID, userID)
264
+// 	if getAppRoleErr != nil {
265
+// 		beego.Error("检查用户和机构应用对应关系时失败:%v", getAppRoleErr)
266
+// 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
267
+// 		return false
268
+// 	} else if appRole == nil {
269
+// 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
270
+// 		return false
271
+// 	}
272
+// 	return true
273
+// }
274
+
275
+// /api/adminmain [get]
276
+func (this *RoleAPIController) AdminMainView() {
277
+	adminUserInfo := this.GetAdminUserInfo()
278
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
279
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
280
+		return
281
+	}
282
+
283
+	viewModels, total, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, 1, 10)
284
+	if getAdminsErr != nil {
285
+		//beego.Error("获取管理员列表失败:", getAdminsErr)
286
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
287
+		return
288
+	}
289
+
290
+	existRoleCount, _ := service.GetValidRoleCount(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id)
291
+
292
+	this.ServeSuccessJSON(map[string]interface{}{
293
+		"admins":        viewModels,
294
+		"total_count":   total,
295
+		"is_exist_role": existRoleCount > 0,
296
+	})
297
+}
298
+
299
+// /api/admins [get]
300
+// @param page?:int
301
+func (this *RoleAPIController) Admins() {
302
+	adminUserInfo := this.GetAdminUserInfo()
303
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
304
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
305
+		return
306
+	}
307
+
308
+	page, _ := this.GetInt("page")
309
+	viewModels, total, getAdminsErr := service.GetAdminUsersAndLoginInfo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, page, 10)
310
+	if getAdminsErr != nil {
311
+		//beego.Error("获取管理员列表失败:", getAdminsErr)
312
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
313
+	} else {
314
+		this.ServeSuccessJSON(map[string]interface{}{
315
+			"admins":      viewModels,
316
+			"total_count": total,
317
+		})
318
+	}
319
+}
320
+
321
+// /api/admin/addinit [get]
322
+func (this *RoleAPIController) AddAdminInitData() {
323
+	adminUserInfo := this.GetAdminUserInfo()
324
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
325
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
326
+		return
327
+	}
328
+
329
+	roles, getRoleErr := service.GetAllValidRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
330
+	if getRoleErr != nil {
331
+		//beego.Error("获取所有角色失败:", getRoleErr)
332
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
333
+		return
334
+	}
335
+
336
+	redisClient := service.RedisClient()
337
+	defer redisClient.Close()
338
+	qntoken, _ := redisClient.Get("qn_token").Result()
339
+
340
+	this.ServeSuccessJSON(map[string]interface{}{
341
+		"roles":   roles,
342
+		"qntoken": qntoken,
343
+	})
344
+}
345
+
346
+// /api/admin/add [post]
347
+// @param mobile:string
348
+// @param name:string
349
+// @param type:int 管理员类型:2.医生 3.护士 4.运营
350
+// @param title:int 用户职称(1.医士;2.医师;3.住院医师;4.主治医师;5.副主任医师;6.主任医师;7.护士;8.护师;9.主管护师;10.副主任护师;11.主任护师;12.运营专员;13.运营主管)
351
+// @param role:int
352
+// @param intro?:string
353
+func (this *RoleAPIController) AddAdmin() {
354
+	adminUserInfo := this.GetAdminUserInfo()
355
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
356
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
357
+		return
358
+	}
359
+
360
+	mobile := this.GetString("mobile")
361
+	name := this.GetString("name")
362
+	userType, _ := this.GetInt("type")
363
+	userTitle, _ := this.GetInt("title")
364
+	roleId, _ := this.GetInt64("role")
365
+	intro := this.GetString("intro")
366
+
367
+	_, titleExist := models.UserTitle[userTitle]
368
+	if len(mobile) == 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || !titleExist || roleId <= 0 {
369
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
370
+		return
371
+	}
372
+
373
+	isRoleExist, getRoleErr := service.IsRoleExist(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleId)
374
+	if getRoleErr != nil {
375
+		//beego.Error("查询角色是否存在时失败:", getRoleErr)
376
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
377
+		return
378
+	}
379
+	if !isRoleExist {
380
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
381
+		return
382
+	}
383
+
384
+	// 判断该应用是否已存在该手机号
385
+	if isMobileDidUsed, err := service.IsMobileDidUsedAtApp(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile); err != nil {
386
+		//beego.Error("查询用户是否已被添加为管理员时失败:", err)
387
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
388
+		return
389
+	} else {
390
+		if isMobileDidUsed {
391
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMobileDidUsedInApp)
392
+			return
393
+		}
394
+	}
395
+
396
+	if isSuperAdmin, err := service.IsUserSuperAdminWithMobile(mobile); err != nil {
397
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMobileNotExit)
398
+		return
399
+	} else {
400
+		if isSuperAdmin {
401
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleMobileIsSuperAdmin)
402
+			return
403
+		}
404
+	}
405
+
406
+	_, password, createErr := service.CreateGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, mobile, name, userType, userTitle, intro, roleId)
407
+	if createErr != nil {
408
+		//beego.Error("创建管理员失败:", createErr)
409
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBCreate)
410
+		return
411
+
412
+	} else {
413
+		//beego.Trace("用户密码:", password)
414
+		// 发送短信通知这个手机号
415
+		sendSMSErr := service.SMSSendInviteMobileToJoinOrgAdmin(name, mobile, password)
416
+		if sendSMSErr != nil {
417
+			//beego.Error("发送邀请短信失败:%v", sendSMSErr)
418
+		}
419
+
420
+		this.ServeSuccessJSON(nil)
421
+		return
422
+	}
423
+}
424
+
425
+// /api/admin/editinit [get]
426
+// @param uid:int
427
+func (this *RoleAPIController) EditAdminInitData() {
428
+	adminUserInfo := this.GetAdminUserInfo()
429
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
430
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
431
+		return
432
+	}
433
+
434
+	admin_user_id, _ := this.GetInt64("uid")
435
+	if admin_user_id <= 0 {
436
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
437
+		return
438
+	}
439
+
440
+	adminUserViewModel, getInfoErr := service.GetGeneralAdminUser(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, admin_user_id)
441
+	if getInfoErr != nil {
442
+		//beego.Error("获取管理员信息失败:", getInfoErr)
443
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
444
+		return
445
+	}
446
+	if adminUserViewModel == nil {
447
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
448
+		return
449
+	}
450
+
451
+	roles, getRoleErr := service.GetAllValidRoles(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
452
+	if getRoleErr != nil {
453
+		//beego.Error("获取所有角色失败:", getRoleErr)
454
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
455
+		return
456
+	}
457
+
458
+	redisClient := service.RedisClient()
459
+	defer redisClient.Close()
460
+	qntoken, _ := redisClient.Get("qn_token").Result()
461
+
462
+	this.ServeSuccessJSON(map[string]interface{}{
463
+		"admin":   adminUserViewModel,
464
+		"roles":   roles,
465
+		"qntoken": qntoken,
466
+	})
467
+}
468
+
469
+// /api/admin/edit [post]
470
+// @param uid:int
471
+// @param name:string
472
+// @param type:int
473
+// @param title:int
474
+// @param role:int
475
+// @param intro?:string
476
+func (this *RoleAPIController) EditAdmin() {
477
+	adminUserInfo := this.GetAdminUserInfo()
478
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
479
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
480
+		return
481
+	}
482
+
483
+	adminUserId, _ := this.GetInt64("uid")
484
+	name := this.GetString("name")
485
+	userType, _ := this.GetInt("type")
486
+	userTitle, _ := this.GetInt("title")
487
+	roleId, _ := this.GetInt64("role")
488
+	intro := this.GetString("intro")
489
+
490
+	_, titleExist := models.UserTitle[userTitle]
491
+	if adminUserId <= 0 || len(name) == 0 || (userType != 2 && userType != 3 && userType != 4) || !titleExist || roleId <= 0 {
492
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
493
+		return
494
+	}
495
+
496
+	appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserId)
497
+	if getAppRoleErr != nil {
498
+		//beego.Error("查询管理员信息时失败:", getAppRoleErr)
499
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
500
+		return
501
+	}
502
+	if appRole == nil {
503
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
504
+		return
505
+	}
506
+
507
+	isRoleExist, getRoleErr := service.IsRoleExist(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, roleId)
508
+	if getRoleErr != nil {
509
+		//beego.Error("查询角色是否存在时失败:", getRoleErr)
510
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
511
+		return
512
+	}
513
+	if !isRoleExist {
514
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
515
+		return
516
+	}
517
+
518
+	appRole.UserName = name
519
+	appRole.UserType = int8(userType)
520
+	appRole.UserTitle = int8(userTitle)
521
+	appRole.RoleId = roleId
522
+	appRole.Intro = intro
523
+	appRole.ModifyTime = time.Now().Unix()
524
+	saveErr := service.SaveAppRole(appRole)
525
+	if saveErr != nil {
526
+		//beego.Error("修改App_Role失败:", saveErr)
527
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
528
+
529
+	} else {
530
+		this.ServeSuccessJSON(nil)
531
+	}
532
+}
533
+
534
+// /api/admin/setstatus [post]
535
+// @param uid:int
536
+// @param enable:bool
537
+func (this *RoleAPIController) AdminSetStatus() {
538
+	adminUserInfo := this.GetAdminUserInfo()
539
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
540
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
541
+		return
542
+	}
543
+
544
+	userID, _ := this.GetInt64("uid")
545
+	if userID <= 0 {
546
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
547
+		return
548
+	}
549
+	appRole, getAppRoleErr := service.GetAppRole(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, userID)
550
+	if getAppRoleErr != nil {
551
+		//beego.Error("查询管理员信息失败:", getAppRoleErr)
552
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
553
+		return
554
+	} else if appRole == nil {
555
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserNotExist)
556
+		return
557
+	}
558
+
559
+	enable, _ := this.GetBool("enable")
560
+	if enable == true {
561
+		if roleEnable, _ := service.IsRoleExist(appRole.OrgId, appRole.AppId, appRole.RoleId); roleEnable == false {
562
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRoleNotExist)
563
+			return
564
+		}
565
+	}
566
+
567
+	if enable {
568
+		appRole.Status = 1
569
+	} else {
570
+		appRole.Status = 0
571
+	}
572
+	appRole.ModifyTime = time.Now().Unix()
573
+	saveErr := service.SaveAppRole(appRole)
574
+	if saveErr != nil {
575
+		//beego.Error("保存AppRole失败:", saveErr)
576
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
577
+
578
+	} else {
579
+		this.ServeSuccessJSON(nil)
580
+	}
581
+}
582
+
583
+// /api/admin/specialpermission/initdata [get]
584
+func (this *RoleAPIController) SpecialPermissionInitData() {
585
+	adminUserInfo := this.GetAdminUserInfo()
586
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
587
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
588
+		return
589
+	}
590
+
591
+	adminUsers, getAdminUsersErr := service.GetAllGeneralAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
592
+	if getAdminUsersErr != nil {
593
+		this.ErrorLog("获取所有普通用户失败:%v", getAdminUsersErr)
594
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
595
+		return
596
+	}
597
+
598
+	headNurses, getAllHeadNursesErr := service.GetAllValidAdminUsersWithSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
599
+	if getAllHeadNursesErr != nil {
600
+		this.ErrorLog("获取所有拥有护士长特殊权限的用户失败:%v", getAllHeadNursesErr)
601
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
602
+		return
603
+	}
604
+
605
+	this.ServeSuccessJSON(map[string]interface{}{
606
+		"users":       adminUsers,
607
+		"head_nurses": headNurses,
608
+	})
609
+}
610
+
611
+// /api/admin/specialpermission/dialysisrecord/submit [post]
612
+// @param ids:string ("1,2,5")
613
+func (this *RoleAPIController) SubmitDialysisRecordPermission() {
614
+	adminUserInfo := this.GetAdminUserInfo()
615
+	if adminUserInfo.AdminUser.IsSuperAdmin == false {
616
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePermissionDenied)
617
+		return
618
+	}
619
+
620
+	idsString := this.GetString("ids")
621
+	if len(idsString) == 0 {
622
+		// 取消所有用户的护士长权限
623
+		cancelErr := service.CancelAllSpecialPermissionAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
624
+		if cancelErr != nil {
625
+			this.ErrorLog("取消所有用户的护士长权限失败:%v", cancelErr)
626
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
627
+			return
628
+		} else {
629
+			this.ServeSuccessJSON(nil)
630
+			return
631
+		}
632
+
633
+	} else {
634
+		ids := make([]int64, 0)
635
+		idStrs := strings.Split(idsString, ",")
636
+		for _, idStr := range idStrs {
637
+			id, parseErr := strconv.Atoi(idStr)
638
+			if parseErr != nil {
639
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
640
+				return
641
+			}
642
+			ids = append(ids, int64(id))
643
+		}
644
+
645
+		headNurses, getAllHeadNursesErr := service.GetAllSpecialPermissionAdminUsersWithoutStatus(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
646
+		if getAllHeadNursesErr != nil {
647
+			this.ErrorLog("获取所有拥有或曾拥有护士长特殊权限的用户失败:%v", getAllHeadNursesErr)
648
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
649
+			return
650
+		}
651
+
652
+		cancelList := make([]*models.AdminUserSpecialPermission, 0)
653
+		addList := make([]*models.AdminUserSpecialPermission, 0)
654
+		for _, id := range ids {
655
+			exit := false
656
+			for _, headNurse := range headNurses {
657
+				if headNurse.AdminUserID == id {
658
+					exit = true
659
+					if headNurse.Status != 1 {
660
+						headNurse.Status = 1
661
+						headNurse.ModifyTime = time.Now().Unix()
662
+						addList = append(addList, headNurse)
663
+					}
664
+					break
665
+				}
666
+			}
667
+			if exit == false {
668
+				newHeadNurse := &models.AdminUserSpecialPermission{
669
+					OrgID:       adminUserInfo.CurrentOrgId,
670
+					AppID:       adminUserInfo.CurrentAppId,
671
+					AdminUserID: id,
672
+					Permission:  int64(models.SpecialPermissionTypeHeadNurse),
673
+					Status:      1,
674
+					CreateTime:  time.Now().Unix(),
675
+					ModifyTime:  time.Now().Unix(),
676
+				}
677
+				addList = append(addList, newHeadNurse)
678
+			}
679
+		}
680
+
681
+		for _, headNurse := range headNurses {
682
+			cancel := true
683
+			for _, willAdd := range addList {
684
+				if willAdd.AdminUserID == headNurse.AdminUserID {
685
+					cancel = false
686
+					break
687
+				}
688
+			}
689
+			if cancel {
690
+				headNurse.Status = 0
691
+				headNurse.ModifyTime = time.Now().Unix()
692
+				cancelList = append(cancelList, headNurse)
693
+			}
694
+		}
695
+
696
+		addErr := service.BatchSaveSpecialPermissionAdminUsers(addList)
697
+		if addErr != nil {
698
+			this.ErrorLog("授权失败:%v", addErr)
699
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
700
+			return
701
+		}
702
+
703
+		cancelErr := service.BatchSaveSpecialPermissionAdminUsers(cancelList)
704
+		if cancelErr != nil {
705
+			this.ErrorLog("取消授权失败:%v", cancelErr)
706
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
707
+			return
708
+		}
709
+
710
+		this.ServeSuccessJSON(nil)
711
+	}
712
+
713
+}

+ 704 - 0
controllers/schedule_api_controller.go View File

@@ -0,0 +1,704 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"fmt"
10
+	"reflect"
11
+	"strconv"
12
+	"time"
13
+
14
+	"github.com/astaxie/beego"
15
+)
16
+
17
+type ScheduleApiController struct {
18
+	BaseAuthAPIController
19
+}
20
+
21
+func ScheduleApiRegistRouters() {
22
+	beego.Router("/api/schedule/weekpanel", &ScheduleApiController{}, "Get:GetWeekPanels")
23
+	beego.Router("/api/schedule/schedules", &ScheduleApiController{}, "Get:GetSchedules")
24
+	beego.Router("/api/schedule/patients", &ScheduleApiController{}, "Get:GetPatients")
25
+	beego.Router("/api/schedule/create", &ScheduleApiController{}, "Post:CreateSchedule")
26
+	beego.Router("/api/schedule/delete", &ScheduleApiController{}, "Delete:DeleteSchedule")
27
+	beego.Router("/api/schedule/change", &ScheduleApiController{}, "Put:ChangeSchedule")
28
+	beego.Router("/api/schedule/urgentinit", &ScheduleApiController{}, "Get:UrgentScheduleData")
29
+
30
+	beego.Router("/api/schedule/print/initdata", &ScheduleApiController{}, "get:PrintInitData")
31
+
32
+	beego.Router("/api/schedule/search", &ScheduleApiController{}, "get:SearchSchedulePatients")
33
+
34
+	beego.Router("/api/schedule/week", &ScheduleApiController{}, "get:GetWeekDaySchedule")
35
+
36
+}
37
+
38
+func (c *ScheduleApiController) GetWeekPanels() {
39
+
40
+	data, _ := c.GetInt64("data", 1)
41
+
42
+	adminInfo := c.GetAdminUserInfo()
43
+	thisTime := time.Now()
44
+	year, monthTime, day := thisTime.Date()
45
+	month := int(monthTime)
46
+	_, theWeek := thisTime.ISOWeek()
47
+	weekDay := int(thisTime.Weekday())
48
+	if weekDay == 0 {
49
+		weekDay = 7
50
+	}
51
+	weekEnd := 7 - weekDay
52
+	weekStart := weekEnd - 6
53
+	weekDays := make([]string, 0)
54
+	for index := weekStart; index <= weekEnd; index++ {
55
+		theDay := thisTime.AddDate(0, 0, index)
56
+		indexYear, indexMonthTime, indexDay := theDay.Date()
57
+		indexMonth := int(indexMonthTime)
58
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
59
+		weekDays = append(weekDays, indexWeek)
60
+	}
61
+
62
+	returnData := map[string]interface{}{
63
+		"year":     year,
64
+		"month":    month,
65
+		"day":      day,
66
+		"theWeek":  theWeek,
67
+		"weekDay":  weekDay,
68
+		"weekDays": weekDays,
69
+	}
70
+
71
+	if data == 1 {
72
+		partitions, _ := service.GetSchedulePartitionPanel(adminInfo.CurrentOrgId)
73
+		returnData["partitions"] = partitions
74
+	}
75
+
76
+	c.ServeSuccessJSON(returnData)
77
+	return
78
+}
79
+
80
+func (c *ScheduleApiController) GetSchedules() {
81
+	week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
82
+
83
+	adminInfo := c.GetAdminUserInfo()
84
+
85
+	thisTime := time.Now()
86
+	today := thisTime.Format("2006-01-02")
87
+	if week < 1 || week > 4 {
88
+		week = 2
89
+	}
90
+	if week == 1 {
91
+		thisTime = thisTime.AddDate(0, 0, -7)
92
+	} else if week == 3 {
93
+		thisTime = thisTime.AddDate(0, 0, 7)
94
+	} else if week == 4 {
95
+		thisTime = thisTime.AddDate(0, 0, 14)
96
+	}
97
+
98
+	weekDay := int(thisTime.Weekday())
99
+	if weekDay == 0 {
100
+		weekDay = 7
101
+	}
102
+	weekEnd := 7 - weekDay
103
+	weekStart := weekEnd - 6
104
+	weekTitle := make([]string, 0)
105
+	days := make([]string, 0)
106
+	for index := weekStart; index <= weekEnd; index++ {
107
+		theDay := thisTime.AddDate(0, 0, index)
108
+		indexYear, indexMonthTime, indexDay := theDay.Date()
109
+		indexMonth := int(indexMonthTime)
110
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
111
+		weekTitle = append(weekTitle, indexWeek)
112
+		days = append(days, theDay.Format("2006-01-02"))
113
+	}
114
+
115
+	weekStartDay := thisTime.AddDate(0, 0, weekStart)
116
+	weekEndDay := thisTime.AddDate(0, 0, weekEnd)
117
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
118
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
119
+
120
+	timeLayout := "2006-01-02 15:04:05"
121
+	loc, _ := time.LoadLocation("Local")
122
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
123
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
124
+	weekStartPoint := theStarTime.Unix()
125
+	weekEndPoint := theEndTime.Unix()
126
+
127
+	schdules, _ := service.GetWeekSchedule(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint)
128
+
129
+	c.ServeSuccessJSON(map[string]interface{}{
130
+		"days":      days,
131
+		"weekTitle": weekTitle,
132
+		"schdules":  schdules,
133
+		"today":     today,
134
+	})
135
+	return
136
+}
137
+
138
+func (c *ScheduleApiController) GetPatients() {
139
+	keywords := c.GetString("keywords", "")
140
+	schedule, _ := c.GetInt64("schedule", 0) //1已2未
141
+	contagion, _ := c.GetInt64("contagion", 0)
142
+
143
+	adminInfo := c.GetAdminUserInfo()
144
+
145
+	thisTime := time.Now()
146
+	weekDay := int(thisTime.Weekday())
147
+	if weekDay == 0 {
148
+		weekDay = 7
149
+	}
150
+	thisWeekEnd := 7 - weekDay
151
+	weekStartPoint := thisWeekEnd - 6
152
+	weekStartDay := thisTime.AddDate(0, 0, weekStartPoint)
153
+	weekEndPoint := thisWeekEnd + 7
154
+	weekEndDay := thisTime.AddDate(0, 0, weekEndPoint)
155
+	fmt.Println(weekStartPoint, weekStartDay, weekEndPoint, weekEndDay)
156
+
157
+	weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
158
+	weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
159
+	fmt.Println(weekStartTime, weekEndTime)
160
+
161
+	timeLayout := "2006-01-02 15:04:05"
162
+	loc, _ := time.LoadLocation("Local")
163
+	theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
164
+	theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
165
+	weekStart := theStarTime.Unix()
166
+	weekEnd := theEndTime.Unix()
167
+
168
+	patients, _ := service.GetPatientWithScheduleAndSolution(adminInfo.CurrentOrgId, keywords, weekStart, weekEnd, schedule, contagion)
169
+
170
+	c.ServeSuccessJSON(map[string]interface{}{
171
+		"patients": patients,
172
+	})
173
+	return
174
+}
175
+
176
+func (c *ScheduleApiController) CreateSchedule() {
177
+	patientID, _ := c.GetInt64("patient_id", 0)
178
+	if patientID <= 0 {
179
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
180
+		return
181
+	}
182
+
183
+	adminUserInfo := c.GetAdminUserInfo()
184
+	patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patientID)
185
+	if patientInfo.ID == 0 {
186
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
187
+		return
188
+	}
189
+
190
+	var schedule models.Schedule
191
+	dataBody := make(map[string]interface{}, 0)
192
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
193
+	if err != nil {
194
+		utils.ErrorLog(err.Error())
195
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
196
+		return
197
+	}
198
+
199
+	if dataBody["schedule_date"] == nil || reflect.TypeOf(dataBody["schedule_date"]).String() != "string" {
200
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
201
+		return
202
+	}
203
+	scheduleDate, _ := dataBody["schedule_date"].(string)
204
+	if len(scheduleDate) == 0 {
205
+		utils.ErrorLog("len(schedule_date) == 0")
206
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
207
+		return
208
+	}
209
+	timeLayout := "2006-01-02"
210
+	loc, _ := time.LoadLocation("Local")
211
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
212
+	if err != nil {
213
+		utils.ErrorLog(err.Error())
214
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
215
+		return
216
+	}
217
+	schedule.ScheduleDate = theTime.Unix()
218
+
219
+	timeNow := time.Now().Format("2006-01-02")
220
+	if timeNow > scheduleDate {
221
+		utils.ErrorLog(timeNow)
222
+		utils.ErrorLog(scheduleDate)
223
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
224
+		return
225
+	}
226
+
227
+	if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
228
+		utils.ErrorLog("schedule_type")
229
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
230
+		return
231
+	}
232
+	scheduleType := int64(dataBody["schedule_type"].(float64))
233
+	if scheduleType < 1 || scheduleType > 3 {
234
+		utils.ErrorLog("scheduleType < 3")
235
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
236
+		return
237
+	}
238
+	schedule.ScheduleType = scheduleType
239
+
240
+	if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
241
+		utils.ErrorLog("bed_id")
242
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
243
+		return
244
+	}
245
+	bedId := int64(dataBody["bed_id"].(float64))
246
+	if bedId < 1 {
247
+		utils.ErrorLog("bedId < 1")
248
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
249
+		return
250
+	}
251
+	schedule.BedId = bedId
252
+
253
+	if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
254
+		utils.ErrorLog("partition_id")
255
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
256
+		return
257
+	}
258
+	partitionId := int64(dataBody["partition_id"].(float64))
259
+	if partitionId < 1 {
260
+		utils.ErrorLog("partitionId < 1")
261
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
262
+		return
263
+	}
264
+	schedule.PartitionId = partitionId
265
+
266
+	if dataBody["schedule_week"] == nil || reflect.TypeOf(dataBody["schedule_week"]).String() != "float64" {
267
+		utils.ErrorLog("schedule_week")
268
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
269
+		return
270
+	}
271
+	scheduleWeek := int64(dataBody["schedule_week"].(float64))
272
+	if scheduleWeek < 1 || scheduleWeek > 7 {
273
+		utils.ErrorLog("scheduleWeek < 1")
274
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
275
+		return
276
+	}
277
+	schedule.ScheduleWeek = scheduleWeek
278
+
279
+	if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
280
+		utils.ErrorLog("mode_id")
281
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
282
+		return
283
+	}
284
+	modeId := int64(dataBody["mode_id"].(float64))
285
+	if modeId < 1 && modeId > 14 {
286
+		utils.ErrorLog("modeId < 1")
287
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
288
+		return
289
+	}
290
+	schedule.ModeId = modeId
291
+
292
+	schedule.PatientId = patientID
293
+	schedule.CreatedTime = time.Now().Unix()
294
+	schedule.UpdatedTime = time.Now().Unix()
295
+	schedule.Status = 1
296
+	schedule.UserOrgId = adminUserInfo.CurrentOrgId
297
+
298
+	bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
299
+	if bed == nil {
300
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
301
+		return
302
+	}
303
+	if bed.ZoneID != schedule.PartitionId {
304
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
305
+		return
306
+	}
307
+
308
+	scheduleDateStart := scheduleDate + " 00:00:00"
309
+	scheduleDateEnd := scheduleDate + " 23:59:59"
310
+	timeLayout = "2006-01-02 15:04:05"
311
+	theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
312
+	theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
313
+	startTime := theStartTime.Unix()
314
+	endTime := theEndTime.Unix()
315
+
316
+	//一天只有排班一次
317
+	daySchedule, err := service.GetDaySchedule(adminUserInfo.CurrentOrgId, startTime, endTime, patientID)
318
+	if daySchedule.ID > 0 {
319
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
320
+		return
321
+	}
322
+
323
+	//同天同位置只能排一个
324
+	pointSchedule, err := service.GetPointSchedule(adminUserInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
325
+	if err != nil {
326
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
327
+		return
328
+	}
329
+	if pointSchedule.ID > 0 {
330
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
331
+		return
332
+	}
333
+
334
+	err = service.CreateSchedule(&schedule)
335
+	fmt.Println(err)
336
+	if err != nil {
337
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
338
+		return
339
+	}
340
+	schedule.Patient = patientInfo.Name
341
+
342
+	c.ServeSuccessJSON(map[string]interface{}{
343
+		"msg":      "ok",
344
+		"schedule": schedule,
345
+	})
346
+	return
347
+}
348
+
349
+func (c *ScheduleApiController) DeleteSchedule() {
350
+	id, _ := c.GetInt64("id", 0)
351
+	if id <= 0 {
352
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
353
+		return
354
+	}
355
+
356
+	adminINfo := c.GetAdminUserInfo()
357
+
358
+	schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
359
+	if schedule == nil {
360
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
361
+		return
362
+	}
363
+
364
+	order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
365
+	if err != nil {
366
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
367
+		return
368
+	}
369
+
370
+	if order != nil {
371
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDelScheduleFailByDialysis)
372
+		return
373
+	}
374
+
375
+	schedule.Status = 0
376
+	schedule.UpdatedTime = time.Now().Unix()
377
+	err = service.UpdateSchedule(schedule)
378
+	if err != nil {
379
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
380
+		return
381
+	}
382
+
383
+	c.ServeSuccessJSON(map[string]interface{}{
384
+		"msg":      "ok",
385
+		"schedule": &schedule,
386
+	})
387
+}
388
+
389
+func (c *ScheduleApiController) ChangeSchedule() {
390
+	id, _ := c.GetInt64("id", 0)
391
+	if id <= 0 {
392
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
393
+		return
394
+	}
395
+
396
+	adminINfo := c.GetAdminUserInfo()
397
+
398
+	schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
399
+	if schedule == nil {
400
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
401
+		return
402
+	}
403
+
404
+	dataBody := make(map[string]interface{}, 0)
405
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
406
+	if err != nil {
407
+		utils.ErrorLog(err.Error())
408
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
409
+		return
410
+	}
411
+
412
+	if dataBody["change_action"] == nil || reflect.TypeOf(dataBody["change_action"]).String() != "string" {
413
+		utils.ErrorLog("change_action")
414
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
415
+		return
416
+	}
417
+	changeAction := dataBody["change_action"].(string)
418
+
419
+	if changeAction == "change_mode" {
420
+		if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
421
+			utils.ErrorLog("mode_id")
422
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
423
+			return
424
+		}
425
+		modeId := int64(dataBody["mode_id"].(float64))
426
+		if modeId < 1 {
427
+			utils.ErrorLog("modeId < 1")
428
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
429
+			return
430
+		}
431
+		schedule.ModeId = modeId
432
+
433
+		order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
434
+		if err != nil {
435
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
436
+			return
437
+		}
438
+
439
+		if order != nil {
440
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeMode)
441
+			return
442
+		}
443
+
444
+	} else if changeAction == "change_device" {
445
+
446
+		order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
447
+		if err != nil {
448
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
449
+			return
450
+		}
451
+
452
+		if order != nil {
453
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeDeviceNumber)
454
+			return
455
+		}
456
+
457
+		if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
458
+			utils.ErrorLog("schedule_type")
459
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
460
+			return
461
+		}
462
+		scheduleType := int64(dataBody["schedule_type"].(float64))
463
+		if scheduleType < 1 || scheduleType > 3 {
464
+			utils.ErrorLog("scheduleType < 3")
465
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
466
+			return
467
+		}
468
+		schedule.ScheduleType = scheduleType
469
+
470
+		if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
471
+			utils.ErrorLog("bed_id")
472
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
473
+			return
474
+		}
475
+		bedId := int64(dataBody["bed_id"].(float64))
476
+		if bedId < 1 {
477
+			utils.ErrorLog("bedId < 1")
478
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
479
+			return
480
+		}
481
+		schedule.BedId = bedId
482
+
483
+		if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
484
+			utils.ErrorLog("partition_id")
485
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
486
+			return
487
+		}
488
+		partitionId := int64(dataBody["partition_id"].(float64))
489
+		if partitionId < 1 {
490
+			utils.ErrorLog("partitionId < 1")
491
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
492
+			return
493
+		}
494
+		schedule.PartitionId = partitionId
495
+
496
+		bed, _ := service.GetDeviceNumberByID(adminINfo.CurrentOrgId, schedule.BedId)
497
+		if bed == nil {
498
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
499
+			return
500
+		}
501
+		if bed.ZoneID != schedule.PartitionId {
502
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
503
+			return
504
+		}
505
+
506
+		startTime := schedule.ScheduleDate
507
+		endTime := startTime + 86399
508
+
509
+		//一天只有排班一次
510
+		daySchedule, err := service.GetDaySchedule(adminINfo.CurrentOrgId, startTime, endTime, schedule.PatientId)
511
+		if daySchedule.ID > 0 && daySchedule.ID != schedule.ID {
512
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
513
+			return
514
+		}
515
+
516
+		//同天同位置只能排一个
517
+		pointSchedule, err := service.GetPointSchedule(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
518
+		if err != nil {
519
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
520
+			return
521
+		}
522
+		if pointSchedule.ID > 0 {
523
+			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
524
+			return
525
+		}
526
+	} else {
527
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
528
+		return
529
+	}
530
+
531
+	schedule.UpdatedTime = time.Now().Unix()
532
+	err = service.UpdateSchedule(schedule)
533
+	if err != nil {
534
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeScheduleFail)
535
+		return
536
+	}
537
+	c.ServeSuccessJSON(map[string]interface{}{
538
+		"msg":      "ok",
539
+		"schedule": &schedule,
540
+	})
541
+}
542
+
543
+// /api/schedule/print/initdata [get]
544
+// @param date:string yyyy-MM-dd 要打印的那一周中的任一天
545
+func (this *ScheduleApiController) PrintInitData() {
546
+	dateStr := this.GetString("date")
547
+	var date *time.Time
548
+	if len(dateStr) == 0 {
549
+		now := time.Now()
550
+		date = &now
551
+	} else {
552
+		var parseErr error
553
+		date, parseErr = utils.ParseTimeStringToTime("2006-01-02", dateStr)
554
+		if parseErr != nil {
555
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
556
+			return
557
+		}
558
+	}
559
+
560
+	adminUserInfo := this.GetAdminUserInfo()
561
+	// 获取本周的排班
562
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(date)
563
+	schedules, getScheduleErr := service.GetPrinitWeekSchedules(adminUserInfo.CurrentOrgId, monday.Unix(), sunday.Unix())
564
+	if getScheduleErr != nil {
565
+		this.ErrorLog("获取周排班失败:%v", getScheduleErr)
566
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
567
+		return
568
+	}
569
+
570
+	this.ServeSuccessJSON(map[string]interface{}{
571
+		"schedules": schedules,
572
+		"monday":    monday.Unix(),
573
+	})
574
+}
575
+
576
+func (this *ScheduleApiController) UrgentScheduleData() {
577
+	schedule_type, _ := this.GetInt("type", 0)
578
+	schedule_date := this.GetString("date")
579
+	var date *time.Time
580
+	if len(schedule_date) == 0 {
581
+		now := time.Now()
582
+		date = &now
583
+	} else {
584
+		var parseErr error
585
+		date, parseErr = utils.ParseTimeStringToTime("2006-01-02", schedule_date)
586
+		if parseErr != nil {
587
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
588
+			return
589
+		}
590
+	}
591
+
592
+	adminUserInfo := this.GetAdminUserInfo()
593
+	deviceNumbers, getDeviceNumbersErr := service.MobileGetAllDeviceNumbersForUrgentSchedule(adminUserInfo.CurrentOrgId, date.Unix(), schedule_type)
594
+	if getDeviceNumbersErr != nil {
595
+		this.ErrorLog("获取所有床位失败:%v", getDeviceNumbersErr)
596
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
597
+		return
598
+	}
599
+	// today := utils.ZeroHourTimeOfDay(time.Now())
600
+	schedules, getSchedulesErr := service.MobileGetOtherSchedulesForUrgentSchedule(adminUserInfo.CurrentOrgId, date.Unix(), schedule_type)
601
+	if getSchedulesErr != nil {
602
+		this.ErrorLog("获取所有排班失败:%v", getSchedulesErr)
603
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
604
+		return
605
+	}
606
+	this.ServeSuccessJSON(map[string]interface{}{
607
+		"device_numbers": deviceNumbers,
608
+		"schedules":      schedules,
609
+	})
610
+}
611
+
612
+func (this *ScheduleApiController) SearchSchedulePatients() {
613
+	keywords := this.GetString("keywords")
614
+	adminUserInfo := this.GetAdminUserInfo()
615
+	list, _ := service.GetSchedualPatientsByKeywords(keywords, adminUserInfo.CurrentOrgId)
616
+	this.ServeSuccessJSON(map[string]interface{}{
617
+		"schdules": list,
618
+	})
619
+
620
+}
621
+
622
+type aa struct {
623
+	b int64
624
+	c int64
625
+}
626
+
627
+func (this *ScheduleApiController) GetWeekDaySchedule() {
628
+	week_type, _ := this.GetInt64("week_type", -1)
629
+	fmt.Println(week_type)
630
+	thisTime := time.Now()
631
+	weekDay := int(thisTime.Weekday())
632
+	if weekDay == 0 {
633
+		weekDay = 7
634
+	}
635
+	weekEnd := 7 - weekDay
636
+	weekStart := weekEnd - 6
637
+	weekTitle := make([]string, 0)
638
+	days := make([]string, 0)
639
+	for index := weekStart; index <= weekEnd; index++ {
640
+		theDay := thisTime.AddDate(0, 0, index)
641
+		indexYear, indexMonthTime, indexDay := theDay.Date()
642
+		indexMonth := int(indexMonthTime)
643
+		indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
644
+		weekTitle = append(weekTitle, indexWeek)
645
+		days = append(days, theDay.Format("2006-01-02"))
646
+	}
647
+	fmt.Println(days)
648
+
649
+	var targetDayStr string
650
+	switch week_type {
651
+	case 1:
652
+		targetDayStr = days[0]
653
+		break
654
+	case 2:
655
+		targetDayStr = days[1]
656
+
657
+		break
658
+	case 3:
659
+		targetDayStr = days[2]
660
+
661
+		break
662
+	case 4:
663
+		targetDayStr = days[3]
664
+
665
+		break
666
+	case 5:
667
+		targetDayStr = days[4]
668
+
669
+		break
670
+	case 6:
671
+		targetDayStr = days[5]
672
+
673
+		break
674
+	case 7:
675
+		targetDayStr = days[6]
676
+
677
+		break
678
+	}
679
+	targetDay, parseErr := utils.ParseTimeStringToTime("2006-01-02", targetDayStr)
680
+	if parseErr != nil {
681
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
682
+		return
683
+	}
684
+
685
+	adminUserInfo := this.GetAdminUserInfo()
686
+	list, _ := service.GetWeekDaySchedule(adminUserInfo.CurrentOrgId, targetDay.Unix())
687
+
688
+	this.ServeSuccessJSON(map[string]interface{}{
689
+		"schdules": list,
690
+		"day":      targetDayStr,
691
+	})
692
+
693
+}
694
+
695
+func Struct2Map(obj interface{}) map[string]interface{} {
696
+	t := reflect.TypeOf(obj)
697
+	v := reflect.ValueOf(obj)
698
+
699
+	var data = make(map[string]interface{})
700
+	for i := 0; i < t.NumField(); i++ {
701
+		data[t.Field(i).Name] = v.Field(i).Interface()
702
+	}
703
+	return data
704
+}

+ 398 - 0
controllers/schedule_template_api_controller.go View File

@@ -0,0 +1,398 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"time"
10
+
11
+	"github.com/astaxie/beego"
12
+)
13
+
14
+func PatientScheduleTemplateAPIControllerRegistRouters() {
15
+	beego.Router("/api/schtemp/p/initdata", &PatientScheduleTemplateAPIController{}, "get:InitData")
16
+	beego.Router("/api/schtemp/p/setmode", &PatientScheduleTemplateAPIController{}, "post:SetMode")
17
+	beego.Router("/api/schtemp/p/update_sch", &PatientScheduleTemplateAPIController{}, "post:UpdateSchedules")
18
+
19
+	// beego.Router("/api/test", &TestCtr{}, "get:Test")
20
+}
21
+
22
+// type TestCtr struct {
23
+// 	BaseAPIController
24
+// }
25
+
26
+// func (this *TestCtr) Test() {
27
+// 	now := time.Now().AddDate(0, 0, 7)
28
+
29
+// 	weekday := int(now.Weekday())
30
+// 	if weekday == 0 {
31
+// 		weekday = 7
32
+// 	}
33
+
34
+// 	monday := now.AddDate(0, 0, 1-weekday)
35
+// 	sunday := now.AddDate(0, 0, 7-weekday)
36
+
37
+// 	// this.TraceLog("%v", weekday)
38
+// 	this.ServeSuccessJSON(map[string]interface{}{
39
+// 		"weekday": weekday,
40
+// 		"monday":  monday.Format("2006-01-02"),
41
+// 		"sunday":  sunday.Format("2006-01-02"),
42
+// 	})
43
+// }
44
+
45
+// ------- 患者排班模板 --------
46
+type PatientScheduleTemplateAPIController struct {
47
+	BaseAuthAPIController
48
+}
49
+
50
+// /api/schtemp/p/initdata [get]
51
+func (this *PatientScheduleTemplateAPIController) InitData() {
52
+	adminUserInfo := this.GetAdminUserInfo()
53
+
54
+	mode, getModeErr := service.GetOrgPatientScheduleTemplateMode(adminUserInfo.CurrentOrgId)
55
+	if getModeErr != nil {
56
+		this.ErrorLog("获取排班模板启用模式失败:%v", getModeErr)
57
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
58
+		return
59
+	}
60
+	now := time.Now()
61
+	if mode == nil {
62
+		mode = &models.PatientScheduleTemplateMode{
63
+			OrgID:        adminUserInfo.CurrentOrgId,
64
+			Mode:         0,
65
+			ExecuteTimes: 0,
66
+			Status:       1,
67
+			CreateTime:   now.Unix(),
68
+			ModifyTime:   now.Unix(),
69
+		}
70
+		createModeErr := service.SavePatientScheduleTemplateMode(mode)
71
+		if createModeErr != nil {
72
+			this.ErrorLog("创建排班模板启用模式失败:%v", createModeErr)
73
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
74
+			return
75
+		}
76
+	}
77
+
78
+	deviceNumbers, getDeviceNumbersErr := service.GetScheduleValidDeviceNumbers(adminUserInfo.CurrentOrgId)
79
+	if getDeviceNumbersErr != nil {
80
+		this.ErrorLog("获取床位号失败:%v", getDeviceNumbersErr)
81
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
82
+		return
83
+	}
84
+
85
+	templates, getTemplatesErr := service.GetOrgPatientScheduleTemplateItems(adminUserInfo.CurrentOrgId)
86
+	if getTemplatesErr != nil {
87
+		this.ErrorLog("获取排班模板及其排班列表失败:%v", getTemplatesErr)
88
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
89
+		return
90
+	}
91
+	if len(templates) == 0 {
92
+		firstTemp, secondTemp, createTempErr := service.CreateTwoPatientScheduleTemplates(adminUserInfo.CurrentOrgId)
93
+		if createTempErr != nil {
94
+			this.ErrorLog("创建两个排班模板失败:%v", createTempErr)
95
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
96
+			return
97
+		}
98
+		templates = append(templates, firstTemp, secondTemp)
99
+
100
+	} else if len(templates) == 1 {
101
+		temp, createTempErr := service.CreatePatientScheduleTemplate(adminUserInfo.CurrentOrgId)
102
+		if createTempErr != nil {
103
+			this.ErrorLog("创建两个排班模板失败:%v", createTempErr)
104
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
105
+			return
106
+		}
107
+		templates = append(templates, temp)
108
+	}
109
+
110
+	patients, getPatientsErr := service.PatientScheduleTemplateGetAllValidPatient(adminUserInfo.CurrentOrgId)
111
+	if getPatientsErr != nil {
112
+		this.ErrorLog("获取患者列表失败失败:%v", getPatientsErr)
113
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
114
+		return
115
+	}
116
+
117
+	// 获取本周的排班
118
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&now)
119
+	schedules, getScheduleErr := service.GetWeekSchedule(adminUserInfo.CurrentOrgId, monday.Unix(), sunday.Unix())
120
+	if getScheduleErr != nil {
121
+		this.ErrorLog("获取本周排班失败:%v", getScheduleErr)
122
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
123
+		return
124
+	}
125
+
126
+	this.ServeSuccessJSON(map[string]interface{}{
127
+		"template_mode":  mode,
128
+		"device_numbers": deviceNumbers,
129
+		"templates":      templates,
130
+		"patients":       patients,
131
+		"schedules":      schedules,
132
+	})
133
+}
134
+
135
+// /api/schtemp/p/setmode [post]
136
+// @param mode:int 0.不启用模板 1.单周模板 2.双周模板
137
+func (this *PatientScheduleTemplateAPIController) SetMode() {
138
+	mode, _ := this.GetInt8("mode")
139
+	if mode != 1 && mode != 2 && mode != 0 {
140
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
141
+		return
142
+	}
143
+
144
+	adminUserInfo := this.GetAdminUserInfo()
145
+
146
+	templateMode, getTemplateModeErr := service.GetOrgPatientScheduleTemplateMode(adminUserInfo.CurrentOrgId)
147
+	if getTemplateModeErr != nil {
148
+		this.ErrorLog("获取排班模板启用模式失败:%v", getTemplateModeErr)
149
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
150
+		return
151
+	} else if templateMode == nil {
152
+		this.ErrorLog("获取不到排班模板启用模式")
153
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
154
+		return
155
+	}
156
+
157
+	if mode != templateMode.Mode {
158
+		if templateMode.Mode == 0 { // 0 -> 1 或 0 -> 2 则直接清除下两周的排班
159
+			templateMode.Mode = mode
160
+			templateMode.ExecuteTimes = 0
161
+			templateMode.ModifyTime = time.Now().Unix()
162
+			updateErr := service.SavePatientScheduleTemplateModeAndClearNextTwoWeekSchedules(templateMode)
163
+			if updateErr != nil {
164
+				this.ErrorLog("更新排班模板启用方式(0 -> 1 或 0 -> 2)时失败:%v", updateErr)
165
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
166
+				return
167
+			}
168
+
169
+		} else if mode == 0 { // 1 -> 0 或 2 -> 0 则不处理排班,但清除所有模板item
170
+			templateMode.Mode = mode
171
+			templateMode.ExecuteTimes = 0
172
+			templateMode.ModifyTime = time.Now().Unix()
173
+			updateErr := service.SavePatientScheduleTemplateModeAndClearAllTemplateItems(templateMode)
174
+			if updateErr != nil {
175
+				this.ErrorLog("更新排班模板启用方式(1 -> 0 或 2 -> 0)时失败:%v", updateErr)
176
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
177
+				return
178
+			}
179
+
180
+		} else if templateMode.Mode == 1 && mode == 2 { // 1 -> 2 清除第二周排班
181
+			templateMode.Mode = mode
182
+			templateMode.ExecuteTimes = 0
183
+			templateMode.ModifyTime = time.Now().Unix()
184
+			updateErr := service.SavePatientScheduleTemplateModeAndClearNextSecondWeekSchedules(templateMode)
185
+			if updateErr != nil {
186
+				this.ErrorLog("更新排班模板启用方式(1 -> 2)时失败:%v", updateErr)
187
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
188
+				return
189
+			}
190
+
191
+		} else if templateMode.Mode == 2 && mode == 1 { // 2 -> 1 清除第二周模板item,清除第二周排班,将第一周的排班重复到第二周
192
+			templateIDs, getTemplateIDsErr := service.GetOrgPatientScheduleTemplateIDs(adminUserInfo.CurrentOrgId)
193
+			if getTemplateIDsErr != nil {
194
+				this.ErrorLog("获取排班模板失败:%v", getTemplateIDsErr)
195
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
196
+				return
197
+			}
198
+
199
+			firstWeekItems, getFirstWeekItemsErr := service.GetOrgPatientScheduleTemplateItemsWithoutPatientByTemplateID(adminUserInfo.CurrentOrgId, templateIDs[0].ID)
200
+			if getFirstWeekItemsErr != nil {
201
+				this.ErrorLog("获取排班模板排班失败:%v", getFirstWeekItemsErr)
202
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
203
+				return
204
+			}
205
+
206
+			templateMode.Mode = mode
207
+			templateMode.ExecuteTimes = 0
208
+			templateMode.ModifyTime = time.Now().Unix()
209
+			updateErr := service.SavePatientScheduleTemplateMode2To1(templateMode, templateIDs[1].ID, firstWeekItems)
210
+			if updateErr != nil {
211
+				this.ErrorLog("更新排班模板启用方式(1 -> 2)时失败:%v", updateErr)
212
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
213
+				return
214
+			}
215
+		}
216
+	}
217
+	this.ServeSuccessJSON(nil)
218
+}
219
+
220
+// /api/schtemp/p/update_sch [post]
221
+// @param template_id:int
222
+// @param add_schs:array'json ([ {device_number_id, patient_id, mode(treat_mode), weekday, time_type} ])
223
+// @param del_schs:array'json ([ {device_number_id, weekday, time_type} ])
224
+// @param change_schs:array'json ([ {device_number_id, patient_id, mode(treat_mode), weekday, time_type} ])
225
+func (this *PatientScheduleTemplateAPIController) UpdateSchedules() {
226
+	templateID, _ := this.GetInt64("template_id")
227
+	addSchedulesJSON := this.GetString("add_schs")
228
+	delSchedulesJSON := this.GetString("del_schs")
229
+	changeSchedulesJSON := this.GetString("change_schs")
230
+	if templateID <= 0 || len(addSchedulesJSON) == 0 || len(delSchedulesJSON) == 0 || len(changeSchedulesJSON) == 0 {
231
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
232
+		return
233
+	}
234
+
235
+	var addSchedules []*ParamModelSchedule
236
+	var delSchedules []*ParamModelSchedule
237
+	var changeSchedules []*ParamModelSchedule
238
+	parseErr := json.Unmarshal([]byte(addSchedulesJSON), &addSchedules)
239
+	if parseErr != nil {
240
+		this.ErrorLog("解析增加排班的数组参数失败:%v", parseErr)
241
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
242
+		return
243
+	}
244
+	parseErr = json.Unmarshal([]byte(delSchedulesJSON), &delSchedules)
245
+	if parseErr != nil {
246
+		this.ErrorLog("解析删除排班的数组参数失败:%v", parseErr)
247
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
248
+		return
249
+	}
250
+	parseErr = json.Unmarshal([]byte(changeSchedulesJSON), &changeSchedules)
251
+	if parseErr != nil {
252
+		this.ErrorLog("解析修改排班的数组参数失败:%v", parseErr)
253
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
254
+		return
255
+	}
256
+
257
+	adminUserInfo := this.GetAdminUserInfo()
258
+	templateIDs, getTemplateIDsErr := service.GetOrgPatientScheduleTemplateIDs(adminUserInfo.CurrentOrgId)
259
+	if getTemplateIDsErr != nil {
260
+		this.ErrorLog("获取排班模板失败:%v", getTemplateIDsErr)
261
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
262
+		return
263
+	} else {
264
+		isTemplateIDExist := false
265
+		for _, templateIDObject := range templateIDs {
266
+			if templateIDObject.ID == templateID {
267
+				isTemplateIDExist = true
268
+				break
269
+			}
270
+		}
271
+		if isTemplateIDExist == false {
272
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleTemplateNotExist)
273
+			return
274
+		}
275
+	}
276
+
277
+	addTemplateItems := make([]*models.PatientScheduleTemplateItem, 0, len(addSchedules))
278
+	delTemplateItems := make([]*models.PatientScheduleTemplateItem, 0, len(delSchedules))
279
+	changeTemplateItems := make([]*models.PatientScheduleTemplateItem, 0, len(changeSchedules))
280
+	for _, sch := range addSchedules {
281
+		if sch.DeviceNumberID <= 0 || sch.PatientID <= 0 || sch.Weekday < 1 || sch.Weekday > 7 || sch.TimeType < 1 || sch.TimeType > 3 {
282
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
283
+			return
284
+		}
285
+		addTemplateItems = append(addTemplateItems, &models.PatientScheduleTemplateItem{
286
+			DeviceNumberID: sch.DeviceNumberID,
287
+			PatientID:      sch.PatientID,
288
+			TreatMode:      sch.Mode,
289
+			Weekday:        sch.Weekday,
290
+			TimeType:       sch.TimeType,
291
+		})
292
+	}
293
+	for _, sch := range delSchedules {
294
+		if sch.DeviceNumberID <= 0 || sch.Weekday < 1 || sch.Weekday > 7 || sch.TimeType < 1 || sch.TimeType > 3 {
295
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
296
+			return
297
+		}
298
+		delTemplateItems = append(delTemplateItems, &models.PatientScheduleTemplateItem{
299
+			DeviceNumberID: sch.DeviceNumberID,
300
+			Weekday:        sch.Weekday,
301
+			TimeType:       sch.TimeType,
302
+		})
303
+	}
304
+	for _, sch := range changeSchedules {
305
+		if sch.DeviceNumberID <= 0 || sch.PatientID <= 0 || sch.Weekday < 1 || sch.Weekday > 7 || sch.TimeType < 1 || sch.TimeType > 3 {
306
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
307
+			return
308
+		}
309
+		changeTemplateItems = append(changeTemplateItems, &models.PatientScheduleTemplateItem{
310
+			DeviceNumberID: sch.DeviceNumberID,
311
+			PatientID:      sch.PatientID,
312
+			TreatMode:      sch.Mode,
313
+			Weekday:        sch.Weekday,
314
+			TimeType:       sch.TimeType,
315
+		})
316
+	}
317
+
318
+	templateMode, getTemplateModeErr := service.GetOrgPatientScheduleTemplateMode(adminUserInfo.CurrentOrgId)
319
+	if getTemplateModeErr != nil {
320
+		this.ErrorLog("获取排班模板启用模式失败:%v", getTemplateModeErr)
321
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
322
+		return
323
+	} else if templateMode == nil {
324
+		this.ErrorLog("获取不到排班模板启用模式")
325
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
326
+		return
327
+	}
328
+
329
+	shouldUpdateNextWeekSchedules := false
330
+	shouldUpdateNextSecondWeekSchedules := false
331
+	if templateMode.Mode == 0 {
332
+		this.ErrorLog("当前未开启排班模板,所以更新模板的操作将被无视")
333
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
334
+		return
335
+	}
336
+	templateIDIndex := 1
337
+	for index, templateIDObject := range templateIDs {
338
+		if templateIDObject.ID == templateID {
339
+			templateIDIndex = index + 1
340
+		}
341
+	}
342
+	if templateMode.Mode == 1 {
343
+		if templateIDIndex == 1 {
344
+			shouldUpdateNextWeekSchedules = true
345
+			shouldUpdateNextSecondWeekSchedules = true
346
+		} else {
347
+			this.ErrorLog("当前开启的是单周模板,所以不会更新第二个模板")
348
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
349
+			return
350
+		}
351
+
352
+	} else { // mode == 2 => 开启双周模板时,只需更新一周排班
353
+		if templateIDIndex == 1 {
354
+			if templateMode.ExecuteTimes%2 == 0 {
355
+				shouldUpdateNextWeekSchedules = true
356
+				shouldUpdateNextSecondWeekSchedules = false
357
+			} else {
358
+				shouldUpdateNextWeekSchedules = false
359
+				shouldUpdateNextSecondWeekSchedules = true
360
+			}
361
+
362
+		} else {
363
+			if templateMode.ExecuteTimes%2 == 0 {
364
+				shouldUpdateNextWeekSchedules = false
365
+				shouldUpdateNextSecondWeekSchedules = true
366
+			} else {
367
+				shouldUpdateNextWeekSchedules = true
368
+				shouldUpdateNextSecondWeekSchedules = false
369
+			}
370
+
371
+		}
372
+	}
373
+
374
+	updateErr := service.UpdateScheduleTemplate(adminUserInfo.CurrentOrgId, templateID, addTemplateItems, delTemplateItems, changeTemplateItems, shouldUpdateNextWeekSchedules, shouldUpdateNextSecondWeekSchedules)
375
+	if updateErr != nil {
376
+		this.ErrorLog("更新排班模板排班失败:%v", updateErr)
377
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
378
+		return
379
+	}
380
+
381
+	newItems, getTemplateItemsErr := service.GetOrgPatientScheduleTemplateItemsByTemplateID(adminUserInfo.CurrentOrgId, templateID)
382
+	if getTemplateItemsErr != nil {
383
+		this.ErrorLog("获取排班模板排班失败:%v", getTemplateItemsErr)
384
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
385
+		return
386
+	}
387
+	this.ServeSuccessJSON(map[string]interface{}{
388
+		"items": newItems,
389
+	})
390
+}
391
+
392
+type ParamModelSchedule struct {
393
+	DeviceNumberID int64 `json:"device_number_id"`
394
+	PatientID      int64 `json:"patient_id"`
395
+	Mode           int64 `json:"mode"`
396
+	Weekday        int8  `json:"weekday"`
397
+	TimeType       int8  `json:"time_type"`
398
+}

+ 610 - 0
controllers/sign_weigh_api_controller.go View File

@@ -0,0 +1,610 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"encoding/json"
8
+	"fmt"
9
+	"github.com/astaxie/beego"
10
+	"github.com/jinzhu/gorm"
11
+	"reflect"
12
+	"strconv"
13
+	"time"
14
+)
15
+
16
+func SignWeighAPIControllerRegistRouters() {
17
+	beego.Router("/api/sign/patients", &SignWeighAPIController{}, "Get:GetPatients")
18
+	beego.Router("/api/sign/patientsign", &SignWeighAPIController{}, "Get:GetPatientSign")
19
+
20
+	beego.Router("/api/signweign", &SignWeighAPIController{}, "Post:EditPatientSign")
21
+
22
+	beego.Router("/api/sign/getDialysisInforInfomation", &SignWeighAPIController{}, "Get:GetPatientList")
23
+
24
+	beego.Router("/api/sign/getDialysisAfterInfomation", &SignWeighAPIController{}, "Get:GetInforByPatientId")
25
+
26
+	beego.Router("/api/sign/savaData", &SignWeighAPIController{}, "Post:SaveData")
27
+
28
+	beego.Router("/api/sign/editdata", &SignWeighAPIController{}, "Post:EditData")
29
+
30
+	beego.Router("/api/sigh/sighdata", &SignWeighAPIController{}, "Post:Sighdata")
31
+
32
+	beego.Router("/api/sign/updateSignweight", &SignWeighAPIController{}, "Post:UpdateSignweight")
33
+
34
+}
35
+
36
+type SignWeighAPIController struct {
37
+	BaseAuthAPIController
38
+}
39
+
40
+// /api/sign/patients [get]
41
+func (c *SignWeighAPIController) GetPatients() {
42
+	keywrods := c.GetString("keywords")
43
+	fmt.Println("关键字" + keywrods)
44
+	scheduleType, _ := c.GetInt64("schedule_type", 0)
45
+	needScheduleType, _ := c.GetInt64("need_schedule_type", 0)
46
+	nowDateTime := time.Now()
47
+	nowDate := nowDateTime.Format("2006-01-02")
48
+	today := nowDate
49
+	nowDate += " 00:00:00"
50
+
51
+	//认为没有选择{0:'全部',1:'上午',2:'下午'3:'晚上' }中的一个
52
+	if scheduleType < 0 || scheduleType > 3 {
53
+		nowH := nowDateTime.Hour()
54
+
55
+		if nowH < 12 {
56
+			scheduleType = 1
57
+		} else if nowH < 18 {
58
+			scheduleType = 2
59
+		} else {
60
+			scheduleType = 3
61
+		}
62
+	}
63
+
64
+	timeLayout := "2006-01-02"
65
+	loc, _ := time.LoadLocation("Local")
66
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
67
+	if err != nil {
68
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
69
+		return
70
+	}
71
+	dateTime := theTime.Unix()
72
+	fmt.Println("dataTime是多少", dateTime)
73
+	adminUserInfo := c.GetAdminUserInfo()
74
+
75
+	patients, err := service.GetSignPatients(adminUserInfo.CurrentOrgId, keywrods, dateTime, scheduleType)
76
+
77
+	fmt.Println("病人信息", patients)
78
+	if err != nil {
79
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
80
+		return
81
+	}
82
+
83
+	panel := make(map[int64]map[string]int64, 0)
84
+	if needScheduleType == 1 {
85
+		panel, _ = service.GetSignPanels(adminUserInfo.CurrentOrgId, dateTime)
86
+		fmt.Println("panel是什么", panel)
87
+	}
88
+
89
+	c.ServeSuccessJSON(map[string]interface{}{
90
+		"patients":      patients,
91
+		"today":         today,
92
+		"schedule_type": scheduleType,
93
+		"panel":         panel,
94
+	})
95
+	return
96
+}
97
+
98
+func (c *SignWeighAPIController) GetPatientSign() {
99
+	patientID, _ := c.GetInt64("patient_id", 0)
100
+	dateTime := c.GetString("date_time")
101
+	timeLayout := "2006-01-02"
102
+	loc, _ := time.LoadLocation("Local")
103
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
104
+	if err != nil {
105
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
106
+		return
107
+	}
108
+	dateTimeStam := theTime.Unix()
109
+
110
+	adminUserInfo := c.GetAdminUserInfo()
111
+
112
+	sign, err := service.GetPatientDateSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
113
+
114
+	if err != nil {
115
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
116
+		return
117
+	}
118
+
119
+	c.ServeSuccessJSON(map[string]interface{}{
120
+		"sign": sign,
121
+	})
122
+	return
123
+}
124
+
125
+func (c *SignWeighAPIController) EditPatientSign() {
126
+	patientID, _ := c.GetInt64("patient_id", 0)
127
+	dateTime := c.GetString("date_time")
128
+
129
+	timeLayout := "2006-01-02"
130
+	loc, _ := time.LoadLocation("Local")
131
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
132
+	if err != nil {
133
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
134
+		return
135
+	}
136
+	dateTimeStam := theTime.Unix()
137
+
138
+	adminUserInfo := c.GetAdminUserInfo()
139
+
140
+	sign, err := service.GetPatientDateSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
141
+
142
+	if err != nil {
143
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
144
+		return
145
+	}
146
+
147
+	var signForm models.SigninAndWeigh
148
+	if sign != nil {
149
+		signForm = *sign
150
+		signForm.UpdatedTime = time.Now().Unix()
151
+
152
+	} else {
153
+		signForm.PatientId = patientID
154
+		signForm.RecordDate = dateTimeStam
155
+		signForm.UserOrgId = adminUserInfo.CurrentOrgId
156
+		signForm.SignTime = time.Now().Unix()
157
+		signForm.Status = 1
158
+		signForm.CreatedTime = time.Now().Unix()
159
+		signForm.UpdatedTime = time.Now().Unix()
160
+	}
161
+
162
+	signData := make(map[string]interface{}, 0)
163
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &signData)
164
+	if err != nil {
165
+		//utils.ErrorLog(err.Error())
166
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
167
+	}
168
+
169
+	if signData["dry_weight"] == nil || reflect.TypeOf(signData["dry_weight"]).String() != "string" {
170
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
171
+		return
172
+	}
173
+	dryWeight, _ := strconv.ParseFloat(signData["dry_weight"].(string), 64)
174
+	signForm.DryWeight = dryWeight
175
+
176
+	if signData["clothes_weight"] == nil || reflect.TypeOf(signData["clothes_weight"]).String() != "string" {
177
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
178
+		return
179
+	}
180
+	clothesWeight, _ := strconv.ParseFloat(signData["clothes_weight"].(string), 64)
181
+	signForm.ClothingWeight = clothesWeight
182
+
183
+	if signData["weigh_before"] == nil || reflect.TypeOf(signData["weigh_before"]).String() != "string" {
184
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
185
+		return
186
+	}
187
+	weighBefore, _ := strconv.ParseFloat(signData["weigh_before"].(string), 64)
188
+	signForm.WeighingBefore = weighBefore
189
+
190
+	if signData["dehydrated_weight"] == nil || reflect.TypeOf(signData["dehydrated_weight"]).String() != "string" {
191
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
192
+		return
193
+	}
194
+	dehydratedWeight, _ := strconv.ParseFloat(signData["dehydrated_weight"].(string), 64)
195
+	signForm.TargetDewatering = dehydratedWeight
196
+
197
+	if signData["weight_before"] == nil || reflect.TypeOf(signData["weight_before"]).String() != "string" {
198
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
199
+		return
200
+	}
201
+	weightBefore, _ := strconv.ParseFloat(signData["weight_before"].(string), 64)
202
+	signForm.WeightBefore = weightBefore
203
+
204
+	if signData["temperature_before"] == nil || reflect.TypeOf(signData["temperature_before"]).String() != "string" {
205
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
206
+		return
207
+	}
208
+	temperatureBefore, _ := strconv.ParseFloat(signData["temperature_before"].(string), 64)
209
+	signForm.TemperatureBefore = temperatureBefore
210
+
211
+	if signData["pulse_rate_before"] == nil || reflect.TypeOf(signData["pulse_rate_before"]).String() != "string" {
212
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
213
+		return
214
+	}
215
+	pulseRateBefore, _ := strconv.ParseFloat(signData["pulse_rate_before"].(string), 64)
216
+	signForm.PulseFrequencyBefore = pulseRateBefore
217
+
218
+	if signData["respiratory_rate_before"] == nil || reflect.TypeOf(signData["respiratory_rate_before"]).String() != "string" {
219
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
220
+		return
221
+	}
222
+	respiratoryRateBefore, _ := strconv.ParseFloat(signData["respiratory_rate_before"].(string), 64)
223
+	signForm.BreathingRateBefore = respiratoryRateBefore
224
+
225
+	if signData["DBP_before"] == nil || reflect.TypeOf(signData["DBP_before"]).String() != "string" {
226
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
227
+		return
228
+	}
229
+	DBPBefore, _ := strconv.ParseFloat(signData["DBP_before"].(string), 64)
230
+	signForm.DiastolicBloodPressureBefore = DBPBefore
231
+
232
+	if signData["SBP_before"] == nil || reflect.TypeOf(signData["SBP_before"]).String() != "string" {
233
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
234
+		return
235
+	}
236
+	SBPBefore, _ := strconv.ParseFloat(signData["SBP_before"].(string), 64)
237
+	signForm.SystolicBloodPressureBefore = SBPBefore
238
+
239
+	if signData["weigh_after"] == nil || reflect.TypeOf(signData["weigh_after"]).String() != "string" {
240
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
241
+		return
242
+	}
243
+	weighAfter, _ := strconv.ParseFloat(signData["weigh_after"].(string), 64)
244
+	signForm.WeighingAfter = weighAfter
245
+
246
+	if signData["weight_reduce_after"] == nil || reflect.TypeOf(signData["weight_reduce_after"]).String() != "string" {
247
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
248
+		return
249
+	}
250
+	weightReduceAfter, _ := strconv.ParseFloat(signData["weight_reduce_after"].(string), 64)
251
+	signForm.WeightLoss = weightReduceAfter
252
+
253
+	if signData["weight_after"] == nil || reflect.TypeOf(signData["weight_after"]).String() != "string" {
254
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
255
+		return
256
+	}
257
+	weightAfter, _ := strconv.ParseFloat(signData["weight_after"].(string), 64)
258
+	signForm.WeightAfter = weightAfter
259
+
260
+	if signData["temperature_after"] == nil || reflect.TypeOf(signData["temperature_after"]).String() != "string" {
261
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
262
+		return
263
+	}
264
+	temperatureAfter, _ := strconv.ParseFloat(signData["temperature_after"].(string), 64)
265
+	signForm.TemperatureAfter = temperatureAfter
266
+
267
+	if signData["pulse_rate_after"] == nil || reflect.TypeOf(signData["pulse_rate_after"]).String() != "string" {
268
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
269
+		return
270
+	}
271
+	pulseRateAfter, _ := strconv.ParseFloat(signData["pulse_rate_after"].(string), 64)
272
+	signForm.PulseFrequencyAfter = pulseRateAfter
273
+
274
+	if signData["respiratory_rate_after"] == nil || reflect.TypeOf(signData["respiratory_rate_after"]).String() != "string" {
275
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
276
+		return
277
+	}
278
+	respiratoryRateAfter, _ := strconv.ParseFloat(signData["respiratory_rate_after"].(string), 64)
279
+	signForm.BreathingRateAfter = respiratoryRateAfter
280
+
281
+	if signData["DBP_after"] == nil || reflect.TypeOf(signData["DBP_after"]).String() != "string" {
282
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
283
+		return
284
+	}
285
+	DBPAfter, _ := strconv.ParseFloat(signData["DBP_after"].(string), 64)
286
+	signForm.DiastolicBloodPressureAfter = DBPAfter
287
+
288
+	if signData["SBP_after"] == nil || reflect.TypeOf(signData["SBP_after"]).String() != "string" {
289
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
290
+		return
291
+	}
292
+	SBPAfter, _ := strconv.ParseFloat(signData["SBP_after"].(string), 64)
293
+	signForm.SystolicBloodPressureAfter = SBPAfter
294
+
295
+	if signForm.WeighingAfter > 0 {
296
+		signForm.WeighTime = time.Now().Unix()
297
+	}
298
+	if signForm.WeighingBefore > 0 {
299
+		signForm.WeighBeforeTime = time.Now().Unix()
300
+	}
301
+
302
+	err = service.EditPatientSign(&signForm)
303
+
304
+	if err != nil {
305
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
306
+		return
307
+	}
308
+
309
+	c.ServeSuccessJSON(map[string]interface{}{
310
+		"sign": signForm,
311
+	})
312
+	return
313
+}
314
+
315
+func (c *SignWeighAPIController) GetPatientList() {
316
+	patientID, _ := c.GetInt64("patient_id", 0)
317
+	fmt.Println("patientID是设么", patientID)
318
+	adminUserInfo := c.GetAdminUserInfo()
319
+	nowDateTime := time.Now()
320
+	nowDate := nowDateTime.Format("2006-01-02")
321
+	nowDate += " 00:00:00"
322
+	timeLayout := "2006-01-02"
323
+	loc, _ := time.LoadLocation("Local")
324
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
325
+	datetime := theTime.Unix()
326
+
327
+	list := service.GetPatientInformationList(adminUserInfo.CurrentOrgId, patientID, datetime)
328
+	c.ServeSuccessJSON(map[string]interface{}{
329
+		"patientlist": list,
330
+	})
331
+	return
332
+}
333
+
334
+func (c *SignWeighAPIController) GetInforByPatientId() {
335
+	patientID, _ := c.GetInt64("patient_id", 0)
336
+	adminUserInfo := c.GetAdminUserInfo()
337
+	nowDateTime := time.Now()
338
+	nowDate := nowDateTime.Format("2006-01-02")
339
+	nowDate += " 00:00:00"
340
+	timeLayout := "2006-01-02"
341
+	loc, _ := time.LoadLocation("Local")
342
+	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
343
+	datetime := theTime.Unix()
344
+	patient := service.GetInforByPatient(adminUserInfo.CurrentOrgId, patientID, datetime)
345
+	fmt.Println("patient是什么", patient)
346
+	c.ServeSuccessJSON(map[string]interface{}{
347
+		"patientinfor": patient,
348
+	})
349
+}
350
+
351
+func (c *SignWeighAPIController) SaveData() {
352
+	adminUserInfo := c.GetAdminUserInfo()
353
+	orgId := adminUserInfo.CurrentOrgId
354
+	patient_id, _ := c.GetInt64("patient_id", 0)
355
+	weight_before, _ := c.GetFloat("weight_before", 0)
356
+	dry_weight, _ := c.GetFloat("dry_weight", 0)
357
+	temperature, _ := c.GetFloat("temperature", 0)
358
+	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
359
+	breathing_rate, _ := c.GetFloat("breathing_rate", 0)
360
+	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
361
+	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
362
+
363
+	predialysisevaluation := &models.PredialysisEvaluation{
364
+		WeightBefore:           weight_before,
365
+		DryWeight:              dry_weight,
366
+		Temperature:            temperature,
367
+		PulseFrequency:         pulse_frequency,
368
+		BreathingRate:          breathing_rate,
369
+		SystolicBloodPressure:  systolic_blood_pressure,
370
+		DiastolicBloodPressure: diastolic_blood_pressure,
371
+	}
372
+	data := service.SaveData(predialysisevaluation, patient_id, orgId)
373
+	c.ServeSuccessJSON(map[string]interface{}{
374
+		"params": data,
375
+	})
376
+}
377
+
378
+func (c *SignWeighAPIController) EditData() {
379
+	adminUserInfo := c.GetAdminUserInfo()
380
+	orgId := adminUserInfo.CurrentOrgId
381
+	patient_id, _ := c.GetInt64("patient_id", 0)
382
+	weight_after, _ := c.GetFloat("weight_after", 0)
383
+	dry_weight, _ := c.GetFloat("dry_weight", 0)
384
+	temperature, _ := c.GetFloat("temperature", 0)
385
+	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
386
+	breathing_rate, _ := c.GetFloat("breathing_rate", 0)
387
+	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
388
+	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
389
+
390
+	assessmentafterdislysis := &models.AssessmentAfterDislysis{
391
+		WeightAfter:            weight_after,
392
+		DryWeight:              dry_weight,
393
+		Temperature:            temperature,
394
+		PulseFrequency:         pulse_frequency,
395
+		BreathingRate:          breathing_rate,
396
+		SystolicBloodPressure:  systolic_blood_pressure,
397
+		DiastolicBloodPressure: diastolic_blood_pressure,
398
+	}
399
+	editdata := service.Editdata(assessmentafterdislysis, patient_id, orgId)
400
+	c.ServeSuccessJSON(map[string]interface{}{
401
+		"params": editdata,
402
+	})
403
+}
404
+
405
+func (c *SignWeighAPIController) Sighdata() {
406
+	fmt.Println("哈哈哈哈哈哈哈哈哈哈")
407
+	patientID, _ := c.GetInt64("patient_id", 0)
408
+	fmt.Println("patientID", patientID)
409
+	dateTime := c.GetString("date_time")
410
+	fmt.Println(patientID, dateTime)
411
+
412
+	timeLayout := "2006-01-02"
413
+	loc, _ := time.LoadLocation("Local")
414
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
415
+	if err != nil {
416
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
417
+		return
418
+	}
419
+	dateTimeStam := theTime.Unix()
420
+	fmt.Println("datatimestam是什么", dateTimeStam)
421
+	adminUserInfo := c.GetAdminUserInfo()
422
+	fmt.Println(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
423
+	sign, errord := service.GetSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
424
+	fmt.Println("sigh是什么东西", sign)
425
+	fmt.Println(err)
426
+	weighbefore, _ := c.GetFloat("weight_before", 0)
427
+	dryweightbefore, _ := c.GetFloat("dry_weight", 0)
428
+	temperaturebefore, _ := c.GetFloat("temperature", 0)
429
+	pulsefrequencybefore, _ := c.GetFloat("pulse_frequency", 0)
430
+	breathinratebefore, _ := c.GetFloat("breathing_rate", 0)
431
+	systolicbloodpressurebefore, _ := c.GetFloat("systolic_blood_pressure", 0)
432
+	diastorlicbloodpressurebefore, _ := c.GetFloat("diastolic_blood_pressure", 0)
433
+	weightafter, _ := c.GetFloat("weight_after", 0)
434
+	temperatureafter, _ := c.GetFloat("temperatureafter", 0)
435
+	pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
436
+	breathingrateafter, _ := c.GetFloat("breathing_rateafter", 0)
437
+	systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
438
+	diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
439
+	fmt.Println("请查看数据")
440
+	fmt.Println("透前称重:", weighbefore, "干体重:", dryweightbefore, "透前温度", temperaturebefore, "透前脉搏", pulsefrequencybefore, "透前呼吸", breathinratebefore, "透前舒张压", systolicbloodpressurebefore, "透前伸缩呀", diastorlicbloodpressurebefore)
441
+	fmt.Println("透后体重", weightafter, "透后温度", temperatureafter, "透后脉搏", pulsefrequencyafter, "透后呼吸", breathingrateafter, "透后舒张压", systolicbloodpressureafter, "透后圣索亚", diastolicbloodpressureafter)
442
+
443
+	var sighForm models.SignWeight
444
+
445
+	sighForm.WeightBefore = weighbefore
446
+	sighForm.DryWeightBefore = dryweightbefore
447
+	sighForm.TemperatureBefore = temperaturebefore
448
+	sighForm.PulseFrequencyBefore = pulsefrequencybefore
449
+	sighForm.BreathingRateBefore = breathinratebefore
450
+	sighForm.SystolicBloodPressureBefore = systolicbloodpressurebefore
451
+	sighForm.DiastolicBloodPressureBefore = diastorlicbloodpressurebefore
452
+	sighForm.WeightAfter = weightafter
453
+	sighForm.TemperatureAfter = temperatureafter
454
+	sighForm.PulseFrequencyAfter = pulsefrequencyafter
455
+	sighForm.BreathingRateAfter = breathingrateafter
456
+	sighForm.SystolicBloodPressureAfter = systolicbloodpressureafter
457
+	sighForm.DiastolicBloodPressureAfter = diastolicbloodpressureafter
458
+	sighForm.PatientId = patientID
459
+	sighForm.RecordDate = dateTimeStam
460
+	sighForm.UserOrgId = adminUserInfo.CurrentOrgId
461
+	sighForm.SignTime = time.Now().Unix()
462
+	sighForm.Status = 1
463
+	sighForm.CreatedTime = time.Now().Unix()
464
+
465
+	if sighForm.WeightBefore > 0 {
466
+		sighForm.WeighBeforeTime = time.Now().Unix()
467
+	}
468
+
469
+	if sighForm.WeightAfter > 0 {
470
+		sighForm.WeighTime = time.Now().Unix()
471
+	}
472
+	fmt.Println("sightForm是什么", sighForm)
473
+	if errord == gorm.ErrRecordNotFound {
474
+		fmt.Println("aaaaaaaaaaaaaa")
475
+		savesignweigh := service.Savesignweigh(&sighForm)
476
+		fmt.Println("savesignweight", savesignweigh)
477
+		c.ServeSuccessJSON(map[string]interface{}{
478
+			"signs": sighForm,
479
+		})
480
+		//signweigh := service.GetSignweigh(adminUserInfo.CurrentOrgId, patientID)
481
+		//fmt.Println("signweigh是什么?",signweigh)
482
+		fmt.Println(sighForm)
483
+	} else if errord == nil {
484
+		service.Updatesignweigh(&sighForm, patientID, adminUserInfo.CurrentOrgId)
485
+	} else {
486
+		fmt.Println("ccccccccccccc")
487
+		service.Updatesignweigh(&sighForm, patientID, adminUserInfo.CurrentOrgId)
488
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
489
+	}
490
+	return
491
+}
492
+
493
+func (c *SignWeighAPIController) UpdateSignweight() {
494
+	patientID, _ := c.GetInt64("patient_id", 0)
495
+	dateTime := c.GetString("date_time")
496
+	fmt.Println("病人ID", patientID, dateTime)
497
+	timeLayout := "2006-01-02"
498
+	loc, _ := time.LoadLocation("Local")
499
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
500
+	if err != nil {
501
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
502
+		return
503
+	}
504
+	dateTimeStam := theTime.Unix()
505
+	fmt.Println("datatimestam是什么", dateTimeStam)
506
+	adminUserInfo := c.GetAdminUserInfo()
507
+	fmt.Println(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
508
+	//透前
509
+	weight_before, _ := c.GetFloat("weight_before", 0)
510
+	dry_weight, _ := c.GetFloat("dry_weight", 0)
511
+	temperature, _ := c.GetFloat("temperature", 0)
512
+	pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
513
+	systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
514
+	diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
515
+	fmt.Println("dry_weight", dry_weight)
516
+	var predialysisevaluation models.PredialysisEvaluation
517
+	predialysisevaluation.PatientId = patientID
518
+	predialysisevaluation.UserOrgId = adminUserInfo.CurrentOrgId
519
+	predialysisevaluation.AssessmentDate = dateTimeStam
520
+	predialysisevaluation.WeightBefore = weight_before
521
+	predialysisevaluation.DryWeight = dry_weight
522
+	predialysisevaluation.Temperature = temperature
523
+	predialysisevaluation.PulseFrequency = pulse_frequency
524
+	predialysisevaluation.SystolicBloodPressure = systolic_blood_pressure
525
+	predialysisevaluation.DiastolicBloodPressure = diastolic_blood_pressure
526
+	predialysisevaluation.CreatedTime = time.Now().Unix()
527
+	predialysisevaluation.Status = 1
528
+
529
+	predialysis, errcode := service.GetDislysisBerfore(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
530
+	fmt.Println("sigh是什么东西", predialysis)
531
+	fmt.Println("错误装太:", errcode)
532
+	if errcode == gorm.ErrRecordNotFound {
533
+		fmt.Println("aaaaa")
534
+		service.SaveDislysisiBefore(&predialysisevaluation)
535
+	} else if errcode == nil {
536
+		fmt.Println("bbbbbbbbb")
537
+		service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
538
+	} else {
539
+		service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
540
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
541
+	}
542
+
543
+	//透后
544
+	weight_after, _ := c.GetFloat("weight_after", 0)
545
+	temperatureafter, _ := c.GetFloat("temperatureafter", 0)
546
+	pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
547
+	systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
548
+	diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
549
+	fmt.Println("aaaa")
550
+	fmt.Println(weight_after, temperatureafter, pulsefrequencyafter, systolicbloodpressureafter, diastolicbloodpressureafter)
551
+
552
+	var assessmentafterdislysis models.AssessmentAfterDislysis
553
+	assessmentafterdislysis.PatientId = patientID
554
+	assessmentafterdislysis.UserOrgId = adminUserInfo.CurrentOrgId
555
+	assessmentafterdislysis.AssessmentDate = dateTimeStam
556
+	assessmentafterdislysis.WeightAfter = weight_after
557
+	assessmentafterdislysis.Temperature = temperatureafter
558
+	assessmentafterdislysis.PulseFrequency = pulsefrequencyafter
559
+	assessmentafterdislysis.SystolicBloodPressure = systolicbloodpressureafter
560
+	assessmentafterdislysis.DiastolicBloodPressure = diastolicbloodpressureafter
561
+	assessmentafterdislysis.CreatedTime = time.Now().Unix()
562
+	assessmentafterdislysis.Status = 1
563
+	dislysis, errcoder := service.GetAssessmentaafterdislysis(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
564
+	fmt.Println("sigh是什么东西", dislysis)
565
+	fmt.Println("错误装太:", errcoder)
566
+
567
+	if errcoder == gorm.ErrRecordNotFound {
568
+		fmt.Println("oooooooo")
569
+		service.SaveAssessmentafter(&assessmentafterdislysis)
570
+		c.ServeSuccessJSON(map[string]interface{}{
571
+			"signs": predialysisevaluation,
572
+		})
573
+	} else if errcoder == nil {
574
+		fmt.Println("ffffffffffffffff")
575
+		service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
576
+		c.ServeSuccessJSON(map[string]interface{}{
577
+			"signs": predialysisevaluation,
578
+		})
579
+	} else {
580
+		service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
581
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
582
+	}
583
+}
584
+
585
+//func (c *SignWeighAPIController) GetForenoonData()  {
586
+//	nowDateTime := time.Now()
587
+//	nowDate := nowDateTime.Format("2006-01-02")
588
+//	nowDate += " 00:00:00"
589
+//	timeLayout := "2006-01-02"
590
+//	loc, _ := time.LoadLocation("Local")
591
+//	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
592
+//	datetime := theTime.Unix()
593
+//	fmt.Println("hhhhhhhhhhhhhhhhhhh")
594
+//	fmt.Println("datetime",datetime)
595
+//	adminUserInfo := c.GetAdminUserInfo()
596
+//	orgId := adminUserInfo.CurrentOrgId
597
+//	fmt.Println("orgid是什么",orgId)
598
+//	total, schedule, err := service.GetForenoonData(datetime, orgId, 1)
599
+//	fmt.Println("total",total)
600
+//	fmt.Println("schedule",schedule)
601
+//	if err != nil {
602
+//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
603
+//		return
604
+//	}
605
+//
606
+//	c.ServeSuccessJSON(map[string]interface{}{
607
+//		"total": total,
608
+//	})
609
+//
610
+//}

+ 69 - 0
controllers/statistics_api_controller.go View File

@@ -0,0 +1,69 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/service"
5
+	"github.com/astaxie/beego"
6
+	"time"
7
+)
8
+
9
+type StatisticsApiController struct {
10
+	BaseAuthAPIController
11
+}
12
+
13
+func StatisticsApiRegistRouters() {
14
+
15
+	beego.Router("/api/statistisc/index", &StatisticsApiController{}, "get:GetStatistics")
16
+
17
+}
18
+
19
+func (c *StatisticsApiController) GetStatistics() {
20
+	adminUserInfo := c.GetAdminUserInfo()
21
+
22
+	// thisTime := time.Now()
23
+	year, month, day := time.Now().Date()
24
+	todayTime := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
25
+	startYearTime := time.Date(year, 1, 1, 0, 0, 0, 0, time.Local)
26
+	endYearTime := time.Date(year+1, 1, 1, 0, 0, 0, 0, time.Local)
27
+
28
+	todayWeek := int(todayTime.Weekday())
29
+	if todayWeek == 0 {
30
+		todayWeek = 7
31
+	}
32
+
33
+	weekEnd := 7 - todayWeek
34
+	weekStart := weekEnd - 6
35
+	// endDay := todayTime.AddDate(0, 0, weekEnd)
36
+	startDay := todayTime.AddDate(0, 0, weekStart)
37
+
38
+	//患者总数
39
+	patientCount := service.GetPatientCount(adminUserInfo.CurrentOrgId)
40
+
41
+	//今日透析
42
+	todayDialysisCount := service.GetDayDialysisCount(adminUserInfo.CurrentOrgId, todayTime.Unix())
43
+
44
+	//本周透析
45
+	weekDaylysisCount := service.GetTimebetweenDialysisCount(adminUserInfo.CurrentOrgId, startDay.Unix(), todayTime.Unix())
46
+
47
+	//传染病
48
+	diseaseCounts := service.GetPatientContagionCounts(adminUserInfo.CurrentOrgId)
49
+
50
+	//性别分布
51
+	genderCounts := service.GetPatientGenderCounts(adminUserInfo.CurrentOrgId)
52
+
53
+	//年龄分布
54
+	ageCounts := service.GetPatiendAgeBetweenCount(adminUserInfo.CurrentOrgId)
55
+
56
+	//透析模式
57
+	modeCounts := service.GetPatientDialysisModeBetweenCount(adminUserInfo.CurrentOrgId, startYearTime.Unix(), endYearTime.Unix())
58
+
59
+	c.ServeSuccessJSON(map[string]interface{}{
60
+		"patient_count":        patientCount,
61
+		"today_dialysis_count": todayDialysisCount,
62
+		"week_daylysis_count":  weekDaylysisCount,
63
+		"disease_counts":       diseaseCounts,
64
+		"gender_counts":        genderCounts,
65
+		"age_counts":           ageCounts,
66
+		"mode_counts":          modeCounts,
67
+	})
68
+
69
+}

+ 347 - 0
controllers/stock_api_controller.go View File

@@ -0,0 +1,347 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"github.com/astaxie/beego"
9
+	"strconv"
10
+	"time"
11
+)
12
+
13
+type StockApiController struct {
14
+	BaseAuthAPIController
15
+}
16
+
17
+func StockApiRegistRouters() {
18
+	beego.Router("/api/stock/dealer/create", &StockApiController{}, "post:CreateDealer")
19
+	beego.Router("/api/stock/dealer/modify", &StockApiController{}, "post:ModifyDealer")
20
+	beego.Router("/api/stock/dealer/list", &StockApiController{}, "get:GetDealersList")
21
+	beego.Router("/api/stock/dealer/delete", &StockApiController{}, "post:DeleteDealer")
22
+	beego.Router("/api/stock/dealer/get", &StockApiController{}, "get:GetDealer")
23
+
24
+	beego.Router("/api/stock/manufacturer/create", &StockApiController{}, "post:CreateManufacturer")
25
+	beego.Router("/api/stock/manufacturer/modify", &StockApiController{}, "post:ModifyManufacturer")
26
+	beego.Router("/api/stock/manufacturer/list", &StockApiController{}, "get:GetManufacturerList")
27
+	beego.Router("/api/stock/manufacturer/delete", &StockApiController{}, "post:DeleteManufacturer")
28
+	beego.Router("/api/stock/manufacturer/get", &StockApiController{}, "get:GetManufacturer")
29
+
30
+	beego.Router("/api/stock/dealer/all", &StockApiController{}, "get:GetAllDealer")
31
+	beego.Router("/api/stock/manufacturer/all", &StockApiController{}, "get:GetAllManufacturer")
32
+
33
+}
34
+
35
+func (c *StockApiController) CreateDealer() {
36
+	dealer_name := c.GetString("dealer_name")
37
+	contact := c.GetString("contact")
38
+	contact_phone := c.GetString("contact_phone")
39
+	platform_number := c.GetString("platform_number")
40
+	email := c.GetString("email")
41
+	contact_address := c.GetString("contact_address")
42
+	remark := c.GetString("remark")
43
+
44
+	if len(dealer_name) <= 0 {
45
+		utils.ErrorLog("len(dealer_name) == 0")
46
+
47
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
48
+		return
49
+	}
50
+
51
+	adminUserInfo := c.GetAdminUserInfo()
52
+
53
+	total := service.FindAllDealerTotal(adminUserInfo.CurrentOrgId)
54
+	totalStr := strconv.FormatInt(total+1, 10)
55
+	code := "1000" + totalStr
56
+	dealer := models.Dealer{
57
+		DealerName:     dealer_name,
58
+		Contact:        contact,
59
+		ContactPhone:   contact_phone,
60
+		ContactAddress: contact_address,
61
+		DealerCode:     code,
62
+		Ctime:          time.Now().Unix(),
63
+		Mtime:          time.Now().Unix(),
64
+		Remark:         remark,
65
+		Creater:        adminUserInfo.AdminUser.Id,
66
+		Email:          email,
67
+		PlatformNumber: platform_number,
68
+		OrgId:          adminUserInfo.CurrentOrgId,
69
+		Status:         1,
70
+	}
71
+
72
+	err, dealers := service.AddSigleDealer(&dealer)
73
+	if err == nil {
74
+		c.ServeSuccessJSON(map[string]interface{}{
75
+			"dealer": dealers,
76
+		})
77
+
78
+	} else {
79
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
80
+
81
+	}
82
+
83
+}
84
+func (c *StockApiController) ModifyDealer() {
85
+	id, _ := c.GetInt64("id", 0)
86
+	dealer_name := c.GetString("dealer_name")
87
+	contact := c.GetString("contact")
88
+	contact_phone := c.GetString("contact_phone")
89
+	platform_number := c.GetString("platform_number")
90
+	dealer_code := c.GetString("dealer_code")
91
+	email := c.GetString("email")
92
+	contact_address := c.GetString("contact_address")
93
+	remark := c.GetString("remark")
94
+	if id <= 0 {
95
+		utils.ErrorLog("id == 0")
96
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
97
+		return
98
+	}
99
+
100
+	if len(dealer_name) <= 0 {
101
+		utils.ErrorLog("len(dealer_name) == 0")
102
+
103
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
104
+		return
105
+	}
106
+
107
+	adminUserInfo := c.GetAdminUserInfo()
108
+	dealer := models.Dealer{
109
+		ID:             id,
110
+		DealerName:     dealer_name,
111
+		Contact:        contact,
112
+		ContactPhone:   contact_phone,
113
+		ContactAddress: contact_address,
114
+		Mtime:          time.Now().Unix(),
115
+		DealerCode:     dealer_code,
116
+		Remark:         remark,
117
+		Creater:        adminUserInfo.AdminUser.Id,
118
+		Email:          email,
119
+		PlatformNumber: platform_number,
120
+		Modifier:       adminUserInfo.AdminUser.Id,
121
+		OrgId:          adminUserInfo.CurrentOrgId,
122
+		Status:         1,
123
+	}
124
+
125
+	err := service.ModifyDealer(&dealer)
126
+
127
+	if err == nil {
128
+		c.ServeSuccessJSON(map[string]interface{}{
129
+			"dealer": dealer,
130
+		})
131
+	} else {
132
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
133
+	}
134
+}
135
+func (c *StockApiController) GetDealersList() {
136
+	page, _ := c.GetInt64("page", 1)
137
+	limit, _ := c.GetInt64("limit", 7)
138
+	adminUserInfo := c.GetAdminUserInfo()
139
+	deales, total, err := service.FindAllDealerList(adminUserInfo.CurrentOrgId, page, limit)
140
+	if err == nil {
141
+		c.ServeSuccessJSON(map[string]interface{}{
142
+			"dealer": deales,
143
+			"total":  total,
144
+		})
145
+	} else {
146
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
147
+	}
148
+}
149
+func (c *StockApiController) DeleteDealer() {
150
+	id, _ := c.GetInt64("id", 0)
151
+	total, _ := service.FindStockInByDealerId(id)
152
+	if total > 0 {
153
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteDealerWrong)
154
+		return
155
+	}
156
+	err := service.DeleteDealerById(id)
157
+	if err == nil {
158
+		c.ServeSuccessJSON(map[string]interface{}{
159
+			"msg": "删除成功",
160
+		})
161
+	} else {
162
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
163
+	}
164
+}
165
+
166
+func (c *StockApiController) GetDealer() {
167
+	id, _ := c.GetInt64("id", 0)
168
+	dealer, err := service.FindDealerById(id)
169
+	if err == nil {
170
+		c.ServeSuccessJSON(map[string]interface{}{
171
+			"dealer": dealer,
172
+		})
173
+	} else {
174
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
175
+	}
176
+}
177
+
178
+func (c *StockApiController) CreateManufacturer() {
179
+	manufacturer_name := c.GetString("manufacturer_name")
180
+	contact := c.GetString("contact")
181
+	contact_phone := c.GetString("contact_phone")
182
+	platform_number := c.GetString("platform_number")
183
+	email := c.GetString("email")
184
+	contact_address := c.GetString("contact_address")
185
+	remark := c.GetString("remark")
186
+
187
+	if len(manufacturer_name) <= 0 {
188
+		utils.ErrorLog("len(manufacturer_name) == 0")
189
+
190
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
191
+		return
192
+	}
193
+
194
+	adminUserInfo := c.GetAdminUserInfo()
195
+	total := service.FindManufacturerTotal(adminUserInfo.CurrentOrgId)
196
+	totalStr := strconv.FormatInt(total+1, 10)
197
+	code := "2000" + totalStr
198
+	manufacturer := models.Manufacturer{
199
+		ManufacturerName: manufacturer_name,
200
+		Contact:          contact,
201
+		ContactPhone:     contact_phone,
202
+		ContactAddress:   contact_address,
203
+		Ctime:            time.Now().Unix(),
204
+		Mtime:            time.Now().Unix(),
205
+		Remark:           remark,
206
+		Creater:          adminUserInfo.AdminUser.Id,
207
+		Email:            email,
208
+		PlatformNumber:   platform_number,
209
+		OrgId:            adminUserInfo.CurrentOrgId,
210
+		Status:           1,
211
+		ManufacturerCode: code,
212
+	}
213
+
214
+	err, manufacturers := service.AddSigleManufacturer(&manufacturer)
215
+	if err == nil {
216
+		c.ServeSuccessJSON(map[string]interface{}{
217
+			"manufacturer": manufacturers,
218
+		})
219
+
220
+	} else {
221
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
222
+	}
223
+
224
+}
225
+func (c *StockApiController) ModifyManufacturer() {
226
+
227
+	id, _ := c.GetInt64("id", 0)
228
+	manufacturer_name := c.GetString("manufacturer_name")
229
+	contact := c.GetString("contact")
230
+	contact_phone := c.GetString("contact_phone")
231
+	platform_number := c.GetString("platform_number")
232
+	email := c.GetString("email")
233
+	contact_address := c.GetString("contact_address")
234
+	remark := c.GetString("remark")
235
+	manufacturer_code := c.GetString("manufacturer_code")
236
+
237
+	if id <= 0 {
238
+		utils.ErrorLog("id == 0")
239
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
240
+		return
241
+	}
242
+
243
+	if len(manufacturer_name) <= 0 {
244
+		utils.ErrorLog("len(manufacturer_name) == 0")
245
+
246
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
247
+		return
248
+	}
249
+
250
+	adminUserInfo := c.GetAdminUserInfo()
251
+	manufacturer := models.Manufacturer{
252
+		ID:               id,
253
+		ManufacturerName: manufacturer_name,
254
+		Contact:          contact,
255
+		ContactPhone:     contact_phone,
256
+		ContactAddress:   contact_address,
257
+		Mtime:            time.Now().Unix(),
258
+		Remark:           remark,
259
+		Creater:          adminUserInfo.AdminUser.Id,
260
+		Email:            email,
261
+		PlatformNumber:   platform_number,
262
+		Modifier:         adminUserInfo.AdminUser.Id,
263
+		OrgId:            adminUserInfo.CurrentOrgId,
264
+		ManufacturerCode: manufacturer_code,
265
+		Status:           1,
266
+	}
267
+
268
+	err := service.ModifyManufacturer(&manufacturer)
269
+
270
+	if err == nil {
271
+		c.ServeSuccessJSON(map[string]interface{}{
272
+			"manufacturer": manufacturer,
273
+		})
274
+	} else {
275
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
276
+	}
277
+
278
+}
279
+func (c *StockApiController) GetManufacturerList() {
280
+	page, _ := c.GetInt64("page", 1)
281
+	limit, _ := c.GetInt64("limit", 10)
282
+	adminUserInfo := c.GetAdminUserInfo()
283
+	manufacturer, total, err := service.FindAllManufacturerList(adminUserInfo.CurrentOrgId, page, limit)
284
+	if err == nil {
285
+		c.ServeSuccessJSON(map[string]interface{}{
286
+			"manufacturer": manufacturer,
287
+			"total":        total,
288
+		})
289
+	} else {
290
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
291
+	}
292
+}
293
+func (c *StockApiController) DeleteManufacturer() {
294
+	id, _ := c.GetInt64("id", 0)
295
+	total, _ := service.FindStockInByManufacturerId(id)
296
+	if total > 0 {
297
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteManufacturerWrong)
298
+		return
299
+	}
300
+
301
+	err := service.DeleteManufacturerById(id)
302
+	if err == nil {
303
+		c.ServeSuccessJSON(map[string]interface{}{
304
+			"msg": "删除成功",
305
+		})
306
+	} else {
307
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
308
+	}
309
+}
310
+func (c *StockApiController) GetManufacturer() {
311
+	id, _ := c.GetInt64("id", 0)
312
+	manufacturer, err := service.FindManufacturerById(id)
313
+	if err == nil {
314
+		c.ServeSuccessJSON(map[string]interface{}{
315
+			"manufacturer": manufacturer,
316
+		})
317
+	} else {
318
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
319
+	}
320
+
321
+}
322
+
323
+func (c *StockApiController) GetAllDealer() {
324
+	adminUserInfo := c.GetAdminUserInfo()
325
+	dealer, err := service.FindAllDealer(adminUserInfo.CurrentOrgId)
326
+	if err == nil {
327
+		c.ServeSuccessJSON(map[string]interface{}{
328
+			"dealer": dealer,
329
+		})
330
+	} else {
331
+
332
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
333
+	}
334
+}
335
+
336
+func (c *StockApiController) GetAllManufacturer() {
337
+	adminUserInfo := c.GetAdminUserInfo()
338
+	manufacturer, err := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
339
+	if err == nil {
340
+		c.ServeSuccessJSON(map[string]interface{}{
341
+			"manufacturer": manufacturer,
342
+		})
343
+	} else {
344
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
345
+	}
346
+
347
+}

+ 375 - 0
controllers/stock_good_api_controller.go View File

@@ -0,0 +1,375 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"fmt"
8
+	"github.com/astaxie/beego"
9
+	"strconv"
10
+	"time"
11
+)
12
+
13
+type StockGoodApiController struct {
14
+	BaseAuthAPIController
15
+}
16
+
17
+func StockGoodApiRegistRouters() {
18
+	beego.Router("/api/stock/good/type/create", &StockGoodApiController{}, "post:CreateGoodType")
19
+	beego.Router("/api/stock/good/type/modify", &StockGoodApiController{}, "post:ModifyGoodType")
20
+	beego.Router("/api/stock/good/type/list", &StockGoodApiController{}, "get:GetGoodTypeList")
21
+	beego.Router("/api/type/delete", &StockGoodApiController{}, "post:DeleteGoodType")
22
+	beego.Router("/api/stock/good/type/get", &StockGoodApiController{}, "get:GetGoodType")
23
+
24
+	beego.Router("/api/stock/good/info/create", &StockGoodApiController{}, "post:CreateGoodInfo")
25
+	beego.Router("/api/stock/good/info/modify", &StockGoodApiController{}, "post:ModifyGoodInfo")
26
+	beego.Router("/api/stock/good/info/list", &StockGoodApiController{}, "get:GetGoodInfoList")
27
+	beego.Router("/api/info/delete", &StockGoodApiController{}, "post:DeleteGoodInfo")
28
+	beego.Router("/api/stock/good/info/get", &StockGoodApiController{}, "get:GetGoodInfoByGoodId")
29
+	beego.Router("/api/stock/good/info", &StockGoodApiController{}, "get:GetGoodInfoById")
30
+
31
+	beego.Router("/api/stock/good/type/all", &StockGoodApiController{}, "get:GetAllGoodType")
32
+	beego.Router("/api/stock/good/info/all", &StockGoodApiController{}, "get:GetAllGoodInfo")
33
+	beego.Router("/api/good/get", &StockGoodApiController{}, "get:GetAllGood")
34
+
35
+}
36
+
37
+func (c *StockGoodApiController) CreateGoodType() {
38
+	type_name := c.GetString("type_name")
39
+	remark := c.GetString("remark")
40
+	adminUserInfo := c.GetAdminUserInfo()
41
+	totals := service.FindGoodTypeByName(type_name, adminUserInfo.CurrentOrgId)
42
+	if totals > 0 {
43
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodTypeNameExistError)
44
+		return
45
+	}
46
+
47
+	total := service.FindAllGoodTypeTotal(adminUserInfo.CurrentOrgId)
48
+	code := strconv.FormatInt(total+1, 10)
49
+	code = "34000000" + code
50
+	goodType := models.GoodsType{
51
+		TypeCode: code,
52
+		TypeName: type_name,
53
+		Remark:   remark,
54
+		Ctime:    time.Now().Unix(),
55
+		Mtime:    time.Now().Unix(),
56
+		OrgId:    adminUserInfo.CurrentOrgId,
57
+		Creater:  adminUserInfo.AdminUser.Id,
58
+		Status:   1,
59
+	}
60
+	err, types := service.AddSigleGoodType(&goodType)
61
+	if err == nil {
62
+		c.ServeSuccessJSON(map[string]interface{}{
63
+			"goodTypes": types,
64
+		})
65
+	} else {
66
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
67
+	}
68
+}
69
+
70
+func (c *StockGoodApiController) ModifyGoodType() {
71
+	id, _ := c.GetInt64("id", 0)
72
+	type_name := c.GetString("type_name")
73
+	remark := c.GetString("remark")
74
+	good_type_code := c.GetString("type_code")
75
+	adminUserInfo := c.GetAdminUserInfo()
76
+
77
+	//totals := service.FindGoodTypeByName(type_name, adminUserInfo.CurrentOrgId)
78
+	//if totals > 0 {
79
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodTypeNameExistError)
80
+	//	return
81
+	//}
82
+
83
+	goodType := models.GoodsType{
84
+		ID:       id,
85
+		TypeCode: good_type_code,
86
+		TypeName: type_name,
87
+		Remark:   remark,
88
+		Ctime:    time.Now().Unix(),
89
+		Mtime:    time.Now().Unix(),
90
+		OrgId:    adminUserInfo.CurrentOrgId,
91
+		Modifier: adminUserInfo.AdminUser.Id,
92
+		Status:   1,
93
+	}
94
+	err, types := service.ModifyGoodType(&goodType)
95
+	if err == nil {
96
+		c.ServeSuccessJSON(map[string]interface{}{
97
+			"goodTypes": types,
98
+		})
99
+	} else {
100
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
101
+	}
102
+
103
+}
104
+
105
+func (c *StockGoodApiController) GetGoodTypeList() {
106
+	page, _ := c.GetInt64("page", 1)
107
+	limit, _ := c.GetInt64("limit", 7)
108
+	keyword := c.GetString("keyword")
109
+
110
+	adminUserInfo := c.GetAdminUserInfo()
111
+	goodTypes, total, err := service.FindAllGoodTypeList(adminUserInfo.CurrentOrgId, page, limit, keyword)
112
+
113
+	if err == nil {
114
+		c.ServeSuccessJSON(map[string]interface{}{
115
+			"list":  goodTypes,
116
+			"total": total,
117
+		})
118
+	} else {
119
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
120
+	}
121
+}
122
+
123
+func (c *StockGoodApiController) DeleteGoodType() {
124
+	id, _ := c.GetInt64("id", 0)
125
+	adminUserInfo := c.GetAdminUserInfo()
126
+	goodInfo, _ := service.FindGoodInfoByGoodId(id)
127
+	if len(goodInfo) > 0 {
128
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodTypeFail)
129
+		return
130
+	}
131
+	err := service.DeleteGoodTypeById(id, adminUserInfo.AdminUser.Id)
132
+	if err == nil {
133
+		c.ServeSuccessJSON(map[string]interface{}{
134
+			"msg": "删除成功",
135
+		})
136
+	} else {
137
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
138
+	}
139
+
140
+}
141
+func (c *StockGoodApiController) GetGoodType() {
142
+	id, _ := c.GetInt64("id", 0)
143
+	goodType, err := service.FindGoodTypeById(id)
144
+	if err == nil {
145
+		c.ServeSuccessJSON(map[string]interface{}{
146
+			"goodType": goodType,
147
+		})
148
+	} else {
149
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
150
+	}
151
+
152
+}
153
+
154
+func (c *StockGoodApiController) CreateGoodInfo() {
155
+	good_id, _ := c.GetInt64("good_id", 0)
156
+	specification_name := c.GetString("specification_name")
157
+	good_unit, _ := c.GetInt64("good_unit", -1)
158
+	buy_price, _ := c.GetFloat("buy_price", 0)
159
+	sell_price, _ := c.GetFloat("sell_price", 0)
160
+	remark := c.GetString("remark")
161
+	manufacturer, _ := c.GetInt64("manufacturer", 0)
162
+	dealer, _ := c.GetInt64("dealer", 0)
163
+	expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
164
+	stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
165
+	is_reuse, _ := c.GetInt64("is_reuse", 0)
166
+
167
+	adminUserInfo := c.GetAdminUserInfo()
168
+
169
+	totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId)
170
+	if totals > 0 {
171
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
172
+		return
173
+	}
174
+
175
+	total := service.FindAllGoodInfoTotal(adminUserInfo.CurrentOrgId)
176
+	code := strconv.FormatInt(total+1, 10)
177
+	code = "24000000" + code
178
+
179
+	goodInfo := models.GoodInfo{
180
+		GoodCode:               code,
181
+		SpecificationName:      specification_name,
182
+		GoodTypeId:             good_id,
183
+		GoodUnit:               good_unit,
184
+		BuyPrice:               buy_price,
185
+		SellPrice:              sell_price,
186
+		Remark:                 remark,
187
+		Ctime:                  time.Now().Unix(),
188
+		Manufacturer:           manufacturer,
189
+		Dealer:                 dealer,
190
+		ExpiryDateWarnDayCount: expiry_date_warn_day_count,
191
+		StockWarnCount:         stock_warn_count,
192
+		IsReuse:                is_reuse,
193
+		Status:                 1,
194
+		OrgId:                  adminUserInfo.CurrentOrgId,
195
+		Creater:                adminUserInfo.AdminUser.Id,
196
+	}
197
+	err, goodInfos := service.AddSigleGoodInfo(&goodInfo)
198
+	if err == nil {
199
+		c.ServeSuccessJSON(map[string]interface{}{
200
+			"goodInfo": goodInfos,
201
+		})
202
+	} else {
203
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
204
+	}
205
+
206
+}
207
+
208
+func (c *StockGoodApiController) ModifyGoodInfo() {
209
+	id, _ := c.GetInt64("id", 0)
210
+	good_id, _ := c.GetInt64("good_id", 0)
211
+	specification_name := c.GetString("specification_name")
212
+	good_unit, _ := c.GetInt64("good_unit", -1)
213
+	buy_price, _ := c.GetFloat("buy_price", 0)
214
+	sell_price, _ := c.GetFloat("sell_price", 0)
215
+	remark := c.GetString("remark")
216
+	manufacturer, _ := c.GetInt64("manufacturer", 0)
217
+	dealer, _ := c.GetInt64("dealer", 0)
218
+	expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
219
+	stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
220
+	is_reuse, _ := c.GetInt64("is_reuse", 0)
221
+	code := c.GetString("good_code")
222
+
223
+	adminUserInfo := c.GetAdminUserInfo()
224
+
225
+	//totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId)
226
+	//if totals > 0 {
227
+	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
228
+	//	return
229
+	//}
230
+
231
+	goodInfo := models.GoodInfo{
232
+		ID:                     id,
233
+		GoodCode:               code,
234
+		SpecificationName:      specification_name,
235
+		GoodTypeId:             good_id,
236
+		GoodUnit:               good_unit,
237
+		BuyPrice:               buy_price,
238
+		SellPrice:              sell_price,
239
+		Remark:                 remark,
240
+		Mtime:                  time.Now().Unix(),
241
+		Manufacturer:           manufacturer,
242
+		Dealer:                 dealer,
243
+		ExpiryDateWarnDayCount: expiry_date_warn_day_count,
244
+		StockWarnCount:         stock_warn_count,
245
+		IsReuse:                is_reuse,
246
+		Status:                 1,
247
+		OrgId:                  adminUserInfo.CurrentOrgId,
248
+		Modifier:               adminUserInfo.AdminUser.Id,
249
+	}
250
+	err, goodInfos := service.ModifyGoodInfo(&goodInfo)
251
+	if err == nil {
252
+		c.ServeSuccessJSON(map[string]interface{}{
253
+			"goodInfo": goodInfos,
254
+		})
255
+	} else {
256
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
257
+	}
258
+
259
+}
260
+func (c *StockGoodApiController) GetGoodInfoList() {
261
+	page, _ := c.GetInt64("page", 1)
262
+	limit, _ := c.GetInt64("limit", 7)
263
+	keyword := c.GetString("keyword")
264
+
265
+	adminUserInfo := c.GetAdminUserInfo()
266
+	goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword)
267
+	if err == nil {
268
+		c.ServeSuccessJSON(map[string]interface{}{
269
+			"list":  goodInfos,
270
+			"total": total,
271
+		})
272
+	} else {
273
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
274
+	}
275
+
276
+}
277
+func (c *StockGoodApiController) DeleteGoodInfo() {
278
+	id, _ := c.GetInt64("id", 0)
279
+	adminUserInfo := c.GetAdminUserInfo()
280
+
281
+	total, _ := service.FindWarehouseInfoTotalByGoodId(id)
282
+	if total > 0 {
283
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
284
+		return
285
+	}
286
+	err := service.DeleteGoodInfoById(id, adminUserInfo.AdminUser.Id)
287
+	if err == nil {
288
+		c.ServeSuccessJSON(map[string]interface{}{
289
+			"msg": "删除成功",
290
+		})
291
+	} else {
292
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
293
+	}
294
+
295
+}
296
+
297
+func (c *StockGoodApiController) GetGoodInfoByGoodId() {
298
+	id, _ := c.GetInt64("id", 0)
299
+	goodInfo, err := service.FindGoodInfoByGoodId(id)
300
+	if err == nil {
301
+		c.ServeSuccessJSON(map[string]interface{}{
302
+			"list": goodInfo,
303
+		})
304
+	} else {
305
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
306
+	}
307
+}
308
+
309
+func (c *StockGoodApiController) GetGoodInfoById() {
310
+	id, _ := c.GetInt64("id", 0)
311
+	goodInfo, err := service.FindGoodInfoById(id)
312
+	if err == nil {
313
+		c.ServeSuccessJSON(map[string]interface{}{
314
+			"goodInfo": goodInfo,
315
+		})
316
+	} else {
317
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
318
+	}
319
+}
320
+
321
+func (c *StockGoodApiController) GetAllGoodType() {
322
+	adminUserInfo := c.GetAdminUserInfo()
323
+	goodTypes, err := service.FindAllGoodType(adminUserInfo.CurrentOrgId)
324
+	if err == nil {
325
+		c.ServeSuccessJSON(map[string]interface{}{
326
+			"goodType": goodTypes,
327
+		})
328
+	} else {
329
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
330
+	}
331
+}
332
+
333
+func (c *StockGoodApiController) GetAllGoodInfo() {
334
+	adminUserInfo := c.GetAdminUserInfo()
335
+	goodInfo, err := service.FindAllGoodInfo(adminUserInfo.CurrentOrgId)
336
+	if err == nil {
337
+		c.ServeSuccessJSON(map[string]interface{}{
338
+			"goodInfo": goodInfo,
339
+		})
340
+	} else {
341
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
342
+	}
343
+}
344
+
345
+func (c *StockGoodApiController) GetAllGood() {
346
+	adminUserInfo := c.GetAdminUserInfo()
347
+	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
348
+	dealer_id, _ := c.GetInt64("dealer_id", 0)
349
+	fmt.Println(manufacturer_id)
350
+	fmt.Println(dealer_id)
351
+
352
+	goodInfo, err := service.FindAllGoodByManufactureId(manufacturer_id, dealer_id, adminUserInfo.CurrentOrgId)
353
+	if err == nil {
354
+		c.ServeSuccessJSON(map[string]interface{}{
355
+			"goodInfo": goodInfo,
356
+		})
357
+	} else {
358
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
359
+	}
360
+}
361
+
362
+func (c *StockGoodApiController) GetWarehouseGoodInfo() {
363
+	adminUserInfo := c.GetAdminUserInfo()
364
+	manufacturer_id, _ := c.GetInt64("manufacturer_id", 0)
365
+	dealer_id, _ := c.GetInt64("dealer_id", 0)
366
+
367
+	goodInfo, err := service.FindAllGoodByManufactureId(manufacturer_id, dealer_id, adminUserInfo.CurrentOrgId)
368
+	if err == nil {
369
+		c.ServeSuccessJSON(map[string]interface{}{
370
+			"goodInfo": goodInfo,
371
+		})
372
+	} else {
373
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
374
+	}
375
+}

File diff suppressed because it is too large
+ 1938 - 0
controllers/stock_in_api_controller.go


+ 323 - 0
controllers/verify_login_controller.go View File

@@ -0,0 +1,323 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/models"
5
+	"fmt"
6
+	"net/url"
7
+
8
+	"XT_New/enums"
9
+	"XT_New/service"
10
+	"XT_New/utils"
11
+
12
+	"github.com/astaxie/beego"
13
+)
14
+
15
+func VerifyUserLoginControllerRegistRouters() {
16
+	beego.Router("/login", &VerifyUserLoginController{}, "get:Login")
17
+	beego.Router("/logout", &VerifyUserLoginController{}, "get,post:Logout")
18
+	beego.Router("/handle_error", &VerifyUserLoginController{}, "get:HandleError")
19
+
20
+	beego.Router("/api/token/verify", &VerifyUserLoginAPIController{}, "post:VerifyToken")
21
+	beego.Router("/api/admin/edit_info", &VerifyUserLoginAPIController{}, "post:EditAdminUserInfo")
22
+
23
+	beego.Router("/api/password/code", &PersonAPIController{}, "post:CodeOfModifyPwd")
24
+	beego.Router("/api/password/modify", &PersonAPIController{}, "post:ModifyPwd")
25
+}
26
+
27
+type VerifyUserLoginController struct {
28
+	BaseViewController
29
+}
30
+
31
+// /login [get]
32
+// @param token?:string
33
+// @param relogin?:bool
34
+func (this *VerifyUserLoginController) Login() {
35
+	token := this.Ctx.Input.Query("token")
36
+	if len(token) > 0 { // 带 token 参数的一般是从 SSO 回调回来的
37
+		utils.TraceLog("SSO Login 回调: token=%v", token)
38
+		xtFrontEndDomain := beego.AppConfig.String("front_end_domain") + "?lt=" + token
39
+		this.Redirect302(xtFrontEndDomain)
40
+
41
+	} else {
42
+		relogin, _ := this.GetBool("relogin", false)
43
+		returnURL := url.QueryEscape(fmt.Sprintf("%v%v", beego.AppConfig.String("httpdomain"), this.Ctx.Request.RequestURI))
44
+		ssoDomain := beego.AppConfig.String("sso_domain")
45
+		ssoLoginURL := fmt.Sprintf("%v/login?returnurl=%v&app_type=3&relogin=%v", ssoDomain, returnURL, relogin)
46
+		this.Redirect302(ssoLoginURL)
47
+	}
48
+}
49
+
50
+// /logout [get/post]
51
+func (this *VerifyUserLoginController) Logout() {
52
+	if this.Ctx.Request.Method == "GET" {
53
+		this.DelSession("admin_user_info")
54
+		this.Redirect302(fmt.Sprintf("%v/logout", beego.AppConfig.String("sso_domain")))
55
+	} else if this.Ctx.Request.Method == "POST" {
56
+		this.DelSession("admin_user_info")
57
+	}
58
+}
59
+
60
+// /handle_error [get]
61
+// @param code:int
62
+func (this *VerifyUserLoginController) HandleError() {
63
+	code, _ := this.GetInt("code")
64
+	if code == enums.ErrorCodeNeverCreateTypeApp {
65
+		ssoDomain := beego.AppConfig.String("sso_domain")
66
+		createAppURL := fmt.Sprintf("%v/org/app/create", ssoDomain)
67
+		this.Redirect302(createAppURL)
68
+
69
+	} else if code == enums.ErrorCodeContactSuperAdminCreateTypeApp {
70
+		ssoDomain := beego.AppConfig.String("sso_domain")
71
+		hitURL := fmt.Sprintf("%v/create_app_hint", ssoDomain)
72
+		this.Redirect302(hitURL)
73
+
74
+	} else {
75
+		this.Abort404()
76
+	}
77
+}
78
+
79
+type VerifyUserLoginAPIController struct {
80
+	BaseAPIController
81
+}
82
+
83
+// /api/token/verify [post]
84
+// @param token:string
85
+func (this *VerifyUserLoginAPIController) VerifyToken() {
86
+	if this.Ctx.Request.Method == "OPTIONS" {
87
+		this.Abort("200")
88
+
89
+	} else {
90
+		token := this.GetString("token")
91
+		utils.TraceLog("token: %v", token)
92
+		if len(token) == 0 {
93
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
94
+			return
95
+		}
96
+
97
+		ip := utils.GetIP(this.Ctx.Request)
98
+		fmt.Println("ip是什么", ip)
99
+		sessionID := this.Ctx.GetCookie("s")
100
+		fmt.Println("sessionID", sessionID)
101
+		utils.TraceLog("Request: %v", this.Ctx.Request)
102
+		utils.TraceLog("cookie session id: %v", sessionID)
103
+		adminUserInfo, err, errCode := service.VerifyToken(token, ip, sessionID)
104
+		fmt.Println("错误是什么", err)
105
+		fmt.Println("errCode是什么", errCode)
106
+		if err != nil {
107
+			if errCode == 903 { // 未创建应用
108
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNeverCreateTypeApp)
109
+
110
+			} else if errCode == 904 { // 联系超管来开通
111
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeContactSuperAdminCreateTypeApp)
112
+
113
+			} else {
114
+				utils.ErrorLog("令牌验证失败:%v", err)
115
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInvalidToken)
116
+			}
117
+			return
118
+
119
+		} else {
120
+			adminUser := adminUserInfo.AdminUser
121
+			fmt.Println("adminUser", adminUser)
122
+			appRole := adminUserInfo.AppRoles[adminUserInfo.CurrentAppId]
123
+			userInfo := map[string]interface{}{
124
+				"id":         adminUser.Id,
125
+				"mobile":     adminUser.Mobile,
126
+				"user_name":  appRole.UserName,
127
+				"avatar":     appRole.Avatar,
128
+				"intro":      appRole.Intro,
129
+				"user_type":  appRole.UserType,
130
+				"user_title": appRole.UserTitle,
131
+			}
132
+			curOrg := adminUserInfo.Orgs[adminUserInfo.CurrentOrgId]
133
+			org := map[string]interface{}{
134
+				"id":             curOrg.Id,
135
+				"org_name":       curOrg.OrgName,
136
+				"org_short_name": curOrg.OrgShortName,
137
+				"org_intro":      curOrg.OrgIntroduction,
138
+				"org_logo":       curOrg.OrgLogo,
139
+				"province":       curOrg.Province,
140
+				"city":           curOrg.City,
141
+				"district":       curOrg.District,
142
+				"address":        curOrg.Address,
143
+			}
144
+
145
+			tempInfo, _ := service.GetOrgInfoTemplate(curOrg.Id)
146
+			fmt.Println("teimpInfo", tempInfo)
147
+			template_info := map[string]interface{}{
148
+				"id":          tempInfo.ID,
149
+				"org_id":      tempInfo.OrgId,
150
+				"template_id": tempInfo.TemplateId,
151
+			}
152
+			var FiledList []*models.FiledConfig
153
+
154
+			FiledList, _ = service.FindFiledByOrgId(curOrg.Id)
155
+			if len(FiledList) == 0 {
156
+				err := service.BatchInsertFiledConfig(curOrg.Id)
157
+				if err == nil {
158
+					FiledList, _ = service.FindFiledByOrgId(curOrg.Id)
159
+
160
+				} else {
161
+					utils.ErrorLog("字段批量插入失败:%v", err)
162
+				}
163
+			}
164
+			curApp := adminUserInfo.OrgApps[adminUserInfo.CurrentOrgId][adminUserInfo.CurrentAppId]
165
+			if curApp.OpenStatus != 1 {
166
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNeverCreateTypeApp)
167
+				return
168
+			}
169
+
170
+			curAppUrlfors := adminUserInfo.AppUrlfors[adminUserInfo.CurrentAppId]
171
+
172
+			subscibe := adminUserInfo.Subscibes[adminUserInfo.CurrentOrgId]
173
+			fmt.Println("subscibe", subscibe)
174
+			if err := service.GetOrgSubscibeState(subscibe); err != nil {
175
+				this.ErrorLog("没有机构订阅信息,数据有误")
176
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
177
+				return
178
+			}
179
+
180
+			orgApps := adminUserInfo.OrgApps[curOrg.Id]
181
+			didRegistedForSCRM := false
182
+			didRegistedForMall := false
183
+			didRegistedForCDM := false
184
+			for _, app := range orgApps {
185
+				if app.AppType == 1 && app.OpenStatus == 1 {
186
+					didRegistedForSCRM = true
187
+				}
188
+				if app.AppType == 4 && app.OpenStatus == 1 {
189
+					didRegistedForCDM = true
190
+				}
191
+				if app.AppType == 5 && app.OpenStatus == 1 {
192
+					didRegistedForMall = true
193
+				}
194
+			}
195
+
196
+			this.SetSession("admin_user_info", adminUserInfo)
197
+
198
+			this.ServeSuccessJSON(map[string]interface{}{
199
+				"user":            userInfo,
200
+				"org":             org,
201
+				"urlfors":         curAppUrlfors,
202
+				"current_org_id":  adminUserInfo.CurrentOrgId,
203
+				"current_app_id":  adminUserInfo.CurrentAppId,
204
+				"subscibe":        subscibe,
205
+				"scrm_role_exist": didRegistedForSCRM,
206
+				"cdm_role_exist":  didRegistedForCDM,
207
+				"mall_role_exist": didRegistedForMall,
208
+				"template_info":   template_info,
209
+				"fileds":          FiledList,
210
+			})
211
+			return
212
+		}
213
+	}
214
+}
215
+
216
+// /api/admin/edit_info [post]
217
+// @param avatar:string
218
+// @param name:string
219
+// @param opwd?:string 没有原始密码的时候,认为不修改密码
220
+// @param npwd?:string
221
+func (this *VerifyUserLoginAPIController) EditAdminUserInfo() {
222
+	adminUserInfo := this.GetAdminUserInfo()
223
+
224
+	avatar := this.GetString("avatar")
225
+	name := this.GetString("name")
226
+	if len(name) == 0 {
227
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMissingUserName)
228
+		return
229
+	}
230
+	// oldPwd := this.GetString("opwd")
231
+	// newPwd := this.GetString("npwd")
232
+	// modifyPwd := len(oldPwd) != 0
233
+	// if modifyPwd {
234
+	// 	if len(newPwd) == 0 {
235
+	// 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodePasswordEmpty)
236
+	// 		this.ServeJSON()
237
+	// 		return
238
+	// 	}
239
+	// 	pwdRight, err := service.IsPasswordRight(adminUserInfo.AdminUser.Id, oldPwd)
240
+	// 	if err != nil {
241
+	// 		utils.ErrorLog("判断旧密码是否错误失败:%v", err)
242
+	// 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeDataException)
243
+	// 		this.ServeJSON()
244
+	// 		return
245
+	// 	}
246
+	// 	if !pwdRight {
247
+	// 		this.Data["json"] = enums.MakeFailResponseJSONWithSGJErrorCode(enums.ErrorCodeOldPasswordWrong)
248
+	// 		this.ServeJSON()
249
+	// 		return
250
+	// 	}
251
+	// } else {
252
+	// 	newPwd = ""
253
+	// }
254
+	modifyErr := service.ModifyAdminUserInfo(adminUserInfo.AdminUser.Id, adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, name, avatar, "")
255
+	if modifyErr != nil {
256
+		this.ErrorLog("修改个人信息失败:%v", modifyErr)
257
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
258
+
259
+	} else {
260
+		appRole := adminUserInfo.AppRoles[adminUserInfo.CurrentAppId]
261
+		appRole.UserName = name
262
+		appRole.Avatar = avatar
263
+		this.ServeSuccessJSON(nil)
264
+	}
265
+}
266
+
267
+type PersonAPIController struct {
268
+	BaseAuthAPIController
269
+}
270
+
271
+// /api/password/code [post]
272
+func (this *PersonAPIController) CodeOfModifyPwd() {
273
+	adminUserInfo := this.GetAdminUserInfo()
274
+	mobile := adminUserInfo.AdminUser.Mobile
275
+	if err := service.SMSSendVerificationCode(mobile); err != nil {
276
+		utils.ErrorLog("修改密码发送验证码失败:%v", err)
277
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
278
+		return
279
+	} else {
280
+		this.ServeSuccessJSON(map[string]interface{}{
281
+			"msg": "短信发送成功,有效期为10分钟",
282
+		})
283
+	}
284
+}
285
+
286
+// /api/password/modify [post]
287
+// @param password:string
288
+// @param code:string
289
+func (this *PersonAPIController) ModifyPwd() {
290
+	new_pwd := this.GetString("password")
291
+	code := this.GetString("code")
292
+	if len(new_pwd) == 0 || len(code) == 0 {
293
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
294
+		return
295
+	}
296
+
297
+	adminUserInfo := this.GetAdminUserInfo()
298
+	mobile := adminUserInfo.AdminUser.Mobile
299
+
300
+	redisClient := service.RedisClient()
301
+	defer redisClient.Close()
302
+	cachedCode, err := redisClient.Get("xt_modify_pwd_" + mobile).Result()
303
+	if err != nil {
304
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrVerCodeWrong)
305
+		return
306
+	}
307
+	if code != cachedCode {
308
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAccountOrVerCodeWrong)
309
+		return
310
+	}
311
+
312
+	if modifyErr := service.ModifyPassword(adminUserInfo.AdminUser.Id, new_pwd); modifyErr != nil {
313
+		this.ErrorLog("修改密码失败:%v", modifyErr)
314
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
315
+		return
316
+	}
317
+
318
+	// 清除验证码
319
+	redisClient.Del("xt_modify_pwd_" + mobile)
320
+	this.ServeSuccessJSON(map[string]interface{}{
321
+		"msg": "密码已修改",
322
+	})
323
+}

File diff suppressed because it is too large
+ 2 - 0
db/xt_drug_dic


+ 21 - 0
db/xt_drugway_dic View File

@@ -0,0 +1,21 @@
1
+INSERT INTO xt_drugway_dic (code, name, status, created_time, updated_time) VALUES 
2
+("DGCX","导管冲洗",1,1536290447,1536290447),
3
+("PO","口服",1,1536290447,1536290447),
4
+("LNZS","瘤内注射",1,1536290447,1536290447),
5
+("IVPUMP","微泵注射",1,1536290447,1536290447),
6
+("WBZS","微泵注射",1,1536290447,1536290447),
7
+("SXHF","舌下含服",1,1536290447,1536290447),
8
+("JMFG","静脉封管",1,1536290447,1536290447),
9
+("DGNWBZS","导管内微泵注射",1,1536290447,1536290447),
10
+("GLCX","管路冲洗",1,1536290447,1536290447),
11
+("PS","皮试 ",1,1536290447,1536290447),
12
+("JMCX","静脉采血",1,1536290447,1536290447),
13
+("YLGCX","引流管冲洗",1,1536290447,1536290447),
14
+("ID","皮内注射",1,1536290447,1536290447),
15
+("IH","皮下注射",1,1536290447,1536290447),
16
+("IM","肌肉注射",1,1536290447,1536290447),
17
+("IV","静脉注射",1,1536290447,1536290447),
18
+("IVGTT","静脉输液(普通)",1,1536290447,1536290447),
19
+("IVGTT","静脉输液(特殊)",1,1536290447,1536290447),
20
+("JBMZ","局部麻醉",1,1536290447,1536290447),
21
+("DGRS","导管溶栓",1,1536290447,1536290447);

+ 35 - 0
db/xt_ef_dic View File

@@ -0,0 +1,35 @@
1
+INSERT INTO xt_execution_frequency_dic (code,name,status,created_time,updated_time) VALUES
2
+("AM","上午",1,1536290447,1536290447),
3
+("QW","每周一次",1,1536290447,1536290447),
4
+("SAS","需要时",1,1536290447,1536290447),
5
+("SQ30FZ","术前30分钟",1,1536290447,1536290447),
6
+("ST","立即",1,1536290447,1536290447),
7
+("TID","每日三次",1,1536290447,1536290447),
8
+("QID","每日四次",1,1536290447,1536290447),
9
+("QIW","每周四次",1,1536290447,1536290447),
10
+("TIW","每周三次",1,1536290447,1536290447),
11
+("TXHLJ","透析后立即",1,1536290447,1536290447),
12
+("XJQ","下机前",1,1536290447,1536290447),
13
+("ONCE","临时一次",1,1536290447,1536290447),
14
+("LZYC","两周一次",1,1536290447,1536290447),
15
+("LZSC","两周三次",1,1536290447,1536290447),
16
+("AA","各",1,1536290447,1536290447),
17
+("SZYC","四周一次",1,1536290447,1536290447),
18
+("QOD","隔日一次",1,1536290447,1536290447),
19
+("QN","每晚一次",1,1536290447,1536290447),
20
+("BID","每日二次",1,1536290447,1536290447),
21
+("BIW","每周二次",1,1536290447,1536290447),
22
+("CF","长方",1,1536290447,1536290447),
23
+("CITO!","急速地",1,1536290447,1536290447),
24
+("CXSY","持续使用",1,1536290447,1536290447),
25
+("F","份",1,1536290447,1536290447),
26
+("HS","临睡前",1,1536290447,1536290447),
27
+("LSKY","临时开药",1,1536290447,1536290447),
28
+("MCYC","每晨一次",1,1536290447,1536290447),
29
+("MFZYC","每分钟一次",1,1536290447,1536290447),
30
+("QD","每日一次",1,1536290447,1536290447),
31
+("QEH","每小时",1,1536290447,1536290447),
32
+("QH","每1小时一次",1,1536290447,1536290447),
33
+("QM","每晨一次",1,1536290447,1536290447),
34
+("QN","每晚",1,1536290447,1536290447),
35
+("SJQ","上机前",1,1536290447,1536290447);

BIN
db/xtdb.docx View File


+ 401 - 0
enums/error_code.go View File

@@ -0,0 +1,401 @@
1
+package enums
2
+
3
+import "XT_New/utils"
4
+
5
+const ( // ErrorCode
6
+	// 登录注册错误 6000+
7
+	ErrorCodeLoginTimeout                   = 6001
8
+	ErrorCodeNotLogin                       = 6002
9
+	ErrorCodePermissionDenied               = 6003
10
+	ErrorCodeMobileRegistered               = 6004
11
+	ErrorCodePasswordEmpty                  = 6005
12
+	ErrorCodeVerificationCodeWrong          = 6006
13
+	ErrorCodeRegisterFail                   = 6007
14
+	ErrorCodeInvalidToken                   = 6008
15
+	ErrorCodeAccountOrPasswordWrong         = 6009
16
+	ErrorCodeMissingOrg                     = 6010
17
+	ErrorCodeMissingOrgApp                  = 6011
18
+	ErrorCodeAccountOrVerCodeWrong          = 6012
19
+	ErrorCodeMobileNotExit                  = 6013
20
+	ErrorCodeUserNotExist                   = 6014
21
+	ErrorCodeUserWasForbidden               = 6015
22
+	ErrorCodeNeverCreateTypeApp             = 6016
23
+	ErrorCodeContactSuperAdminCreateTypeApp = 6017
24
+
25
+	// 数据验证错误 7000+
26
+	ErrorCodeMobileFormat     = 7001
27
+	ErrorCodeTelphoneFormat   = 7002
28
+	ErrorCodeParamWrong       = 7003
29
+	ErrorCodeParamFormatWrong = 7004
30
+
31
+	// 数据库操作错误 8000+
32
+	ErrorCodeDBCreate         = 8001
33
+	ErrorCodeDBUpdate         = 8002
34
+	ErrorCodeDBDelete         = 8003
35
+	ErrorCodeDBSelectNoResult = 8004
36
+	ErrorCodeDataException    = 8005
37
+
38
+	// 业务逻辑操作错误 9000+
39
+	ErrorCodeRoleNotExist           = 9001
40
+	ErrorCodeAdminUserNotExist      = 9002
41
+	ErrorCodeMobileDidUsedInApp     = 9003
42
+	ErrorCodeMissingUserName        = 9004
43
+	ErrorCodeOldPasswordWrong       = 9005
44
+	ErrorCodeCannotRemoveRole       = 9006
45
+	ErrorCodeRoleMobileIsSuperAdmin = 9007
46
+
47
+	ErrorCodeGetQiniuUpToken                = 1001
48
+	ErrorCodeCreatePatient                  = 1002
49
+	ErrorCodeDialysisNoExist                = 1003
50
+	ErrorCodeIdCardNoExist                  = 1004
51
+	ErrorCodePatientNoExist                 = 1005
52
+	ErrorCodeUpdatePatient                  = 1006
53
+	ErrorCodeDialysisSolutionExist          = 1007
54
+	ErrorCodeDialysisSolutionCreate         = 1008
55
+	ErrorCodeDialysisSolutionUpdate         = 1009
56
+	ErrorCodeDialysisSolutionNotExist       = 1010
57
+	ErrorCodeParentDialysisSolutionNotExist = 1011
58
+	ErrorCodeAlReadyHadChildSolution        = 1012
59
+	ErrorCodeCanntCreateChildChildSolution  = 1013
60
+	ErrorCodeDialysisSolutionUsed           = 1014
61
+	ErrorCodeCreateDryWeightFail            = 1015
62
+	ErrorCodeCreateDoctorAdviceFail         = 1016
63
+	ErrorCodeDoctorAdviceNotExist           = 1017
64
+	ErrorCodeUpdateDoctorAdviceFail         = 1018
65
+	ErrorCodeLongTimeAdviceNotCanntEdit     = 1019
66
+	ErrorCodeAdviceStoped                   = 1020
67
+	ErrorCodeParentAdviceNotExist           = 1021
68
+	ErrorCodeStopAdviceFail                 = 1022
69
+	ErrorCodeDeleteAdviceFail               = 1023
70
+	ErrorCodeDialysisSolutionDelete         = 1024
71
+	ErrorCodeDeviceNumberNotTheZone         = 1025
72
+	ErrorCodeCreateScheduleFail             = 1026
73
+	ErrorCodeCantSetScheduleAgainOneDay     = 1027
74
+	ErrorCodeCantSetScheduleBeforeNow       = 1028
75
+	ErrorCodeScheduleNotExist               = 1029
76
+	ErrorCodeDeleteScheduleFail             = 1030
77
+	ErrorCodeChangeScheduleFail             = 1031
78
+	ErrorCodePatientPhoneUsed               = 1032
79
+	ErrorCodeAdviceExced                    = 1033
80
+	ErrorCodeAdviceChecked                  = 1034
81
+	ErrorCodePointScheduleExist             = 1035
82
+	ErrorCodeExceAndCheckNotOneUser         = 1036
83
+	ErrorCodeCanotEditOtherAdvice           = 1037
84
+	ErrorCodeEditLapsetoFail                = 1038
85
+	ErrorCodeAdviceCheckBeforeExce          = 1039
86
+	ErrorCodeAdviceExceBeforeStart          = 1040
87
+	ErrorCodeDelScheduleFailByDialysis      = 1041
88
+	ErrorCodeNotSelectLapsetoType           = 1042
89
+	ErrorCodeNotSelectLapsetoTime           = 1043
90
+
91
+	ErrorCodeInspectionDateExit    = 1201
92
+	ErrorCodeInspectionAddFail     = 1202
93
+	ErrorCodeInspectionEditFail    = 1204
94
+	ErrorCodeInspectionDateNotExit = 1203
95
+	ErrorCodeInspectionDeleteFail  = 1205
96
+
97
+	ErrorCodeMonitorCreate                  = 1128
98
+	ErrorCodeMonitorNotExist                = 1129
99
+	ErrorCodeMonitorUpdate                  = 1130
100
+	ErrorDialysisOrderNoStart               = 1132
101
+	ErrorDialysisOrderNoEND                 = 1133
102
+	ErrorDialysisOrderRepeatStart           = 1134
103
+	ErrorDialysisOrderRepeatBed             = 1136
104
+	ErrorCodeDialysisPermissionDeniedModify = 1135
105
+
106
+	ErrorCodeNotSubscibe       = 4003
107
+	ErrorCodeServeNotExist     = 4004
108
+	ErrorCodeInvoiceExist      = 4005
109
+	ErrorCodeApplyInvoiceFail  = 4006
110
+	ErrorCodeHetongHad         = 4007
111
+	ErrorCodeCreateHetongFail  = 4008
112
+	ErrorCodePatientReachLimit = 4009
113
+
114
+	ErrorCodeDeviceZoneNotExist                      = 9021
115
+	ErrorCodeDeviceZoneNameRepeat                    = 9022
116
+	ErrorCodeDeviceGroupNotExist                     = 9023
117
+	ErrorCodeDeviceGroupNameRepeat                   = 9024
118
+	ErrorCodeDeviceNumberNotExist                    = 9025
119
+	ErrorCodeDeviceNumberRepeat                      = 9026
120
+	ErrorCodeDeviceNotExist                          = 9027
121
+	ErrorCodeDeviceZoneCannotDisable                 = 9028
122
+	ErrorCodeDeviceNumberCannotDisableCuzDevice      = 9029
123
+	ErrorCodeDeviceNumberCannotDisableCuzSchedule    = 9030
124
+	ErrorCodeDeviceNumberCannotDisableCuzSchTemplate = 9031
125
+
126
+	ErrorCommitFail = 90000
127
+
128
+	ErrorCodeCreateStockInFail = 20001
129
+
130
+	ErrorCodeScheduleTemplateNotExist = 10001
131
+
132
+	ErrorCodeSystemError  = 6666
133
+	ErrorCodeProductError = 6667
134
+	ErrorCodeFieldExist   = 100001
135
+	ErrorCodeCreateConfig = 100002
136
+	ErrorCodeUpdateConfig = 100003
137
+
138
+	ErrorCodeDoubleCheckWrong     = 200003
139
+	ErrorCodeDoubleCheckUserWrong = 200004
140
+	ErrorCodeGoodNoStockInError   = 200005
141
+	ErrorCodeCancelStockFail      = 200006
142
+	ErrorCodeDeleteGoodTypeFail   = 200007
143
+	ErrorCodeDeleteGoodInfoFail   = 200008
144
+	ErrorCodeDeleteFail           = 200009
145
+
146
+	ErrorCodeKeyFail                 = 200010
147
+	ErrorCodeDeleteStockInRecordFail = 200011
148
+	ErrorCodeNameWrong               = 200012
149
+
150
+	ErrorCodeParamEmptyWrong       = 200013
151
+	ErrorCodeParamAdviceEmptyWrong = 200014
152
+
153
+	ErrorCodeParamTemplateNOEXISTWrong = 200015
154
+
155
+	ErrorCodeDeleteDealerWrong       = 200016
156
+	ErrorCodeDeleteManufacturerWrong = 200017
157
+	ErrorCodeGoodTypeNameExistError  = 200018
158
+	ErrorCodeGoodInfoNameExistError  = 200019
159
+
160
+	ErrorCodePrescriptionPermissionDeniedModify = 200020
161
+
162
+	ErrorCodeAdvicePermissionDeniedModify = 200021
163
+	ErrorCodePrescriptionException        = 200022
164
+
165
+	ErrorCodeNotDocking = 200023
166
+
167
+	ErrorCodeAdviceTypeWrong = 200024
168
+
169
+	ErrorCodeCreateAdvice = 200025
170
+
171
+	ErrorCodePatientDialysisOrder = 20026
172
+	ErrorSchedualcRepeatBed       = 20027
173
+
174
+	ErrorCodeChangeMode         = 20028
175
+	ErrorCodeChangeDeviceNumber = 20029
176
+
177
+	ErrorCodeHisIdExist = 20030
178
+
179
+	ErrorCodePreExist = 20031
180
+)
181
+
182
+var ErrCodeMsgs = map[int]string{
183
+	// 登录注册错误
184
+	ErrorCodeLoginTimeout:                   "登录超时",
185
+	ErrorCodeNotLogin:                       "未登录",
186
+	ErrorCodePermissionDenied:               "权限不足",
187
+	ErrorCodeMobileRegistered:               "手机号已被注册",
188
+	ErrorCodePasswordEmpty:                  "密码为空",
189
+	ErrorCodeVerificationCodeWrong:          "验证码错误",
190
+	ErrorCodeRegisterFail:                   "注册失败",
191
+	ErrorCodeInvalidToken:                   "令牌无效",
192
+	ErrorCodeAccountOrPasswordWrong:         "账号或密码错误",
193
+	ErrorCodeMissingOrg:                     "未创建机构",
194
+	ErrorCodeMissingOrgApp:                  "未创建任何应用",
195
+	ErrorCodeAccountOrVerCodeWrong:          "账号或验证码错误",
196
+	ErrorCodeMobileNotExit:                  "手机号不存在",
197
+	ErrorCodeUserNotExist:                   "用户不存在",
198
+	ErrorCodeUserWasForbidden:               "该用户被禁用",
199
+	ErrorCodeNeverCreateTypeApp:             "未创建此种应用",
200
+	ErrorCodeContactSuperAdminCreateTypeApp: "请联系超级管理员开通此种应用",
201
+
202
+	// 数据验证错误
203
+	ErrorCodeMobileFormat:     "手机号格式错误",
204
+	ErrorCodeTelphoneFormat:   "电话格式错误",
205
+	ErrorCodeParamWrong:       "参数错误",
206
+	ErrorCodeParamFormatWrong: "参数格式错误",
207
+
208
+	// 数据库操作错误
209
+	ErrorCodeDBCreate:         "数据库创建出错",
210
+	ErrorCodeDBUpdate:         "数据库更新出错",
211
+	ErrorCodeDBDelete:         "数据库删除出错",
212
+	ErrorCodeDBSelectNoResult: "查询无结果",
213
+	ErrorCodeDataException:    "数据异常",
214
+
215
+	// 业务逻辑操作错误
216
+	ErrorCodeRoleNotExist:           "角色不存在",
217
+	ErrorCodeAdminUserNotExist:      "管理员不存在",
218
+	ErrorCodeMobileDidUsedInApp:     "该手机号已在该应用中被注册为管理员",
219
+	ErrorCodeMissingUserName:        "缺少用户名",
220
+	ErrorCodeOldPasswordWrong:       "原密码不正确",
221
+	ErrorCodeCannotRemoveRole:       "该角色下存在用户,不能删除该角色",
222
+	ErrorCodeRoleMobileIsSuperAdmin: "该手机号已注册为超级管理员",
223
+
224
+	ErrorCodeGetQiniuUpToken: "获取七牛uptoken失败",
225
+	ErrorCodeCreatePatient:   "创建患者失败",
226
+	ErrorCodeDialysisNoExist: "患者透析号重复!",
227
+	ErrorCodeIdCardNoExist:   "身份证号重复!",
228
+	ErrorCodePatientNoExist:  "患者信息不存在!",
229
+	ErrorCodeUpdatePatient:   "修改患者信息失败",
230
+
231
+	ErrorCodeDialysisSolutionExist:          "该处方已经存在",
232
+	ErrorCodeDialysisSolutionCreate:         "创建处方失败",
233
+	ErrorCodeDialysisSolutionUpdate:         "修改处方失败",
234
+	ErrorCodeDialysisSolutionNotExist:       "该处方不存在",
235
+	ErrorCodeParentDialysisSolutionNotExist: "上级处方不存在",
236
+	ErrorCodeAlReadyHadChildSolution:        "所选处方已经存在子方案",
237
+	ErrorCodeCanntCreateChildChildSolution:  "子方案不能添加子方案",
238
+	ErrorCodeDialysisSolutionUsed:           "处方已被使用,不能删除",
239
+	ErrorCodeCreateDryWeightFail:            "添加干体重失败",
240
+	ErrorCodeCreateDoctorAdviceFail:         "添加医嘱失败",
241
+	ErrorCodeUpdateDoctorAdviceFail:         "修改医嘱信息失败",
242
+	ErrorCodeDoctorAdviceNotExist:           "医嘱不存在",
243
+	ErrorCodeLongTimeAdviceNotCanntEdit:     "长期医嘱不能修改!",
244
+	ErrorCodeAdviceStoped:                   "所选医嘱已停止",
245
+	ErrorCodeParentAdviceNotExist:           "上级医嘱不存在",
246
+	ErrorCodeDeleteAdviceFail:               "删除医嘱失败",
247
+	ErrorCodeStopAdviceFail:                 "停止医嘱失败",
248
+	ErrorCodeDialysisSolutionDelete:         "删除方案失败",
249
+	ErrorCodeDeviceNumberNotTheZone:         "所选机号不在选择分区中",
250
+	ErrorCodeCreateScheduleFail:             "添加排班失败",
251
+	ErrorCodeCantSetScheduleAgainOneDay:     "同一天不可有两次排班",
252
+	ErrorCodeCantSetScheduleBeforeNow:       "不能给今天之前的日期排班",
253
+	ErrorCodeScheduleNotExist:               "排班不存在",
254
+	ErrorCodePointScheduleExist:             "所先位置排班已经存在",
255
+	ErrorCodeDeleteScheduleFail:             "取消排班失败",
256
+	ErrorCodeChangeScheduleFail:             "修改排班失败",
257
+	ErrorCodePatientPhoneUsed:               "手机号已经存在",
258
+	ErrorCodeAdviceExced:                    "医嘱已经执行",
259
+	ErrorCodeAdviceCheckBeforeExce:          "核对医嘱不能在执行医嘱之前",
260
+	ErrorCodeAdviceExceBeforeStart:          "执行医嘱不能在开始之前",
261
+	ErrorCodeAdviceChecked:                  "医嘱已经核对",
262
+	ErrorCodeExceAndCheckNotOneUser:         "核对与执行不能是同一人",
263
+	ErrorCodeCanotEditOtherAdvice:           "不能修改非本人添加的医嘱",
264
+	ErrorCodeEditLapsetoFail:                "转归失败",
265
+	ErrorCodeDelScheduleFailByDialysis:      "已经上机透析,不能取消排班",
266
+	ErrorCodeNotSelectLapsetoType:           "请选择转归状态",
267
+	ErrorCodeNotSelectLapsetoTime:           "请选择转归时间",
268
+
269
+	ErrorCodeInspectionDateExit:    "当天已经存在检验检查记录",
270
+	ErrorCodeInspectionAddFail:     "添加记录失败",
271
+	ErrorCodeInspectionDateNotExit: "当天不存在检验检查记录",
272
+	ErrorCodeInspectionEditFail:    "修改记录失败",
273
+	ErrorCodeInspectionDeleteFail:  "删除记录失败",
274
+
275
+	ErrorCodeDeviceZoneNotExist:                      "设备分区不存在",
276
+	ErrorCodeDeviceZoneNameRepeat:                    "该分区名已存在",
277
+	ErrorCodeDeviceGroupNotExist:                     "设备分组不存在",
278
+	ErrorCodeDeviceGroupNameRepeat:                   "该分组名已存在",
279
+	ErrorCodeDeviceNumberNotExist:                    "机号不存在",
280
+	ErrorCodeDeviceNumberRepeat:                      "该机号已存在",
281
+	ErrorCodeDeviceNotExist:                          "该设备不存在",
282
+	ErrorCodeDeviceZoneCannotDisable:                 "该分区存在床位号,不能删除",
283
+	ErrorCodeDeviceNumberCannotDisableCuzDevice:      "该床位存在设备,不能删除",
284
+	ErrorCodeDeviceNumberCannotDisableCuzSchedule:    "该床位尚有排班安排,不能删除",
285
+	ErrorCodeDeviceNumberCannotDisableCuzSchTemplate: "排班模板在该床位尚有排班安排,不能删除",
286
+
287
+	ErrorCodeNotSubscibe:       "没有订阅服务或服务已过期,请先购买服务!",
288
+	ErrorCodeServeNotExist:     "服务订单不存在!",
289
+	ErrorCodeInvoiceExist:      "已经申请了发票!",
290
+	ErrorCodeApplyInvoiceFail:  "申请发票失败!",
291
+	ErrorCodeHetongHad:         "合同已经存在!",
292
+	ErrorCodeCreateHetongFail:  "合同创建失败",
293
+	ErrorCodePatientReachLimit: "患者数已达到当前服务版本病人数,需要升级到更高的版本",
294
+
295
+	ErrorCodeMonitorCreate:                  "创建监测失败",
296
+	ErrorCodeMonitorNotExist:                "监测记录不存在",
297
+	ErrorCodeMonitorUpdate:                  "修改监测失败",
298
+	ErrorCodeDialysisPermissionDeniedModify: "您没有权限修改其他医护的数据!",
299
+
300
+	ErrorDialysisOrderNoStart:     "尚未上机,无法执行下机操作",
301
+	ErrorDialysisOrderNoEND:       "已处于下机状态",
302
+	ErrorDialysisOrderRepeatStart: "已上机",
303
+	ErrorDialysisOrderRepeatBed:   "该床位已有患者上机,请选择其他床位",
304
+	//ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
305
+
306
+	ErrorCodeSystemError:              "系统异常",
307
+	ErrorCodeProductError:             "该服务商品已丢失",
308
+	ErrorCodeScheduleTemplateNotExist: "排班模板不存在",
309
+
310
+	ErrorCodeCreateStockInFail: "入库失败",
311
+	//ErrorCodeSystemError:  "系统异常",
312
+	//ErrorCodeProductError: "该服务商品已丢失",
313
+	ErrorCodeFieldExist:   "配置字段已存在",
314
+	ErrorCodeCreateConfig: "创建配置失败",
315
+	ErrorCodeUpdateConfig: "修改配置失败",
316
+
317
+	ErrorCommitFail:               "提交失败",
318
+	ErrorCodeDoubleCheckWrong:     "核对已完成, 无法再次提交",
319
+	ErrorCodeDoubleCheckUserWrong: "你已完成核对,不能重复核对",
320
+	ErrorCodeGoodNoStockInError:   "该商品尚未入库",
321
+
322
+	ErrorCodeCancelStockFail:    "出库退库失败",
323
+	ErrorCodeDeleteGoodTypeFail: "该类型存在商品信息,无法删除",
324
+	ErrorCodeDeleteGoodInfoFail: "该商品已经入库无法删除",
325
+
326
+	ErrorCodeDeleteFail: "删除失败",
327
+
328
+	ErrorCodeKeyFail:                 "关键字不能为空",
329
+	ErrorCodeDeleteStockInRecordFail: "该记录已经有出库或退货操作,无法删除",
330
+	ErrorCodeNameWrong:               "该模版名字已存在",
331
+	ErrorCodeParamEmptyWrong:         "模版名称不能为空",
332
+	ErrorCodeParamAdviceEmptyWrong:   "医嘱名称不能为空",
333
+
334
+	ErrorCodeDeleteDealerWrong:       "该经销商所属商品已入库无法删除",
335
+	ErrorCodeDeleteManufacturerWrong: "该厂商所属商品已入库无法删除",
336
+	ErrorCodeGoodTypeNameExistError:  "该商品类型名字已存在",
337
+	ErrorCodeGoodInfoNameExistError:  "该规格名称名字已存在",
338
+
339
+	ErrorCodePrescriptionPermissionDeniedModify: "您没有权限修改透析处方数据",
340
+	ErrorCodeAdvicePermissionDeniedModify:       "您没有权限添加医嘱",
341
+	ErrorCodePrescriptionException:              "上机失败,请先开处方",
342
+	ErrorCodeNotDocking:                         "该地区尚未对接",
343
+
344
+	ErrorCodeAdviceTypeWrong:      "请选择医嘱模版类型",
345
+	ErrorCodeCreateAdvice:         "你没有权限开医嘱",
346
+	ErrorCodePatientDialysisOrder: "该病人已经上机,无法临时排班",
347
+	ErrorSchedualcRepeatBed:       "该床位已经有人排班,无法临时排班",
348
+
349
+	ErrorCodeChangeMode:         "该患者今天已上机治疗,请在透析记录中进行调整透析模式",
350
+	ErrorCodeChangeDeviceNumber: "该患者今天已上机治疗,请在透析记录中进行调整机号",
351
+
352
+	ErrorCodeHisIdExist: "该his_id已被占用,请重新输入",
353
+
354
+	ErrorCodePreExist: "没有该权限",
355
+}
356
+
357
+type SGJError struct {
358
+	Code int
359
+}
360
+
361
+func (e *SGJError) Error() string {
362
+	value, ok := ErrCodeMsgs[e.Code]
363
+	if ok {
364
+		return value
365
+	} else {
366
+		return "未知错误"
367
+	}
368
+}
369
+
370
+func MakeSuccessResponseJSON(data map[string]interface{}) map[string]interface{} {
371
+	json := make(map[string]interface{})
372
+	if data != nil {
373
+		json["data"] = data
374
+	} else {
375
+		json["data"] = make(map[string]interface{})
376
+	}
377
+	json["state"] = 1
378
+	json["code"] = 0
379
+	return json
380
+}
381
+
382
+func MakeFailResponseJSON(errMsg string, errCode int) map[string]interface{} {
383
+	json := make(map[string]interface{})
384
+	json["msg"] = errMsg
385
+	json["code"] = errCode
386
+	json["state"] = 0
387
+	return json
388
+}
389
+
390
+func MakeFailResponseJSONWithSGJError(err *SGJError) map[string]interface{} {
391
+	if err == nil {
392
+		utils.WarningLog("MakeFailResponseJSONWithSGJError 参数err 不能为空")
393
+		return nil
394
+	}
395
+	return MakeFailResponseJSON(err.Error(), err.Code)
396
+}
397
+
398
+func MakeFailResponseJSONWithSGJErrorCode(code int) map[string]interface{} {
399
+	err := &SGJError{Code: code}
400
+	return MakeFailResponseJSON(err.Error(), err.Code)
401
+}

+ 21 - 0
main.go View File

@@ -0,0 +1,21 @@
1
+package main
2
+
3
+import (
4
+	_ "XT/routers"
5
+	"XT/service"
6
+
7
+	"github.com/astaxie/beego"
8
+)
9
+
10
+func init() {
11
+	service.ConnectDB()
12
+}
13
+
14
+func main() {
15
+	service.BeginAutoCreateWeekSchedulesJob()
16
+	service.BeginAutoCreateWeekDisinfectionJob()
17
+	//service.BeginAutoCreatePlanJob()
18
+	//service.AutoClearSchedules()
19
+
20
+	beego.Run()
21
+}

+ 16 - 0
models/admin_models/admin_models.go View File

@@ -0,0 +1,16 @@
1
+// 统计后台的 models
2
+
3
+package admin_models
4
+
5
+type AdminAccount struct {
6
+	Id         int    `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
7
+	Account    string `json:"account"`
8
+	Pwd        string `json:"-"`
9
+	Status     int8   `json:"-"`                     // 状态 0.无效 1.有效
10
+	CreateTime int64  `gorm:"column:ctime" json:"-"` // 创建时间
11
+	ModifyTime int64  `gorm:"column:mtime" json:"-"` // 修改时间
12
+}
13
+
14
+func (AdminAccount) TableName() string {
15
+	return "sgj_admin"
16
+}

+ 69 - 0
models/admin_user_models.go View File

@@ -0,0 +1,69 @@
1
+package models
2
+
3
+type AdminUser struct {
4
+	Id           int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // 管理员用户 ID
5
+	Mobile       string `json:"mobile"`
6
+	Password     string `json:"password"`
7
+	IsSuperAdmin bool   `gorm:"column:is_super_admin" json:"is_super_admin"` // 是否为超级管理员
8
+	Status       int8   `json:"status"`                                      // 状态 0.无效 1.有效
9
+	CreateTime   int64  `gorm:"column:ctime" json:"ctime"`                   // 创建时间
10
+	ModifyTime   int64  `gorm:"column:mtime" json:"mtime"`                   // 修改时间
11
+}
12
+
13
+func (AdminUser) TableName() string {
14
+	return "sgj_user_admin"
15
+}
16
+
17
+type AdminUserLoginLog struct {
18
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT"` // 记录 ID
19
+	AdminUserId int64  `gorm:"column:admin_user_id"`
20
+	OrgId       int64  `gorm:"column:org_id"`
21
+	AppId       int64  `gorm:"column:app_id"`
22
+	IP          string `gorm:"column:ip"`
23
+	OperateType int8   `gorm:"column:operate_type"` // 操作类型(1.登录;2.退出;3.切换机构)
24
+	AppType     int8   `gorm:"column:app_type"`     // 应用类型,与 OrgApp.AppType 一致
25
+	CreateTime  int64  `gorm:"column:ctime"`        // 创建时间
26
+}
27
+
28
+func (AdminUserLoginLog) TableName() string {
29
+	return "sgj_user_admin_login_log"
30
+}
31
+
32
+type AdminUserElectronicSignature struct {
33
+	ID      int64  `gorm:"column:id" json:"id" form:"id"`
34
+	Creator int64  `gorm:"column:creator" json:"creator" form:"creator"`
35
+	OrgId   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
36
+	AppId   int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
37
+	Url     string `gorm:"column:url" json:"url" form:"url"`
38
+	Hash    string `gorm:"column:hash" json:"hash" form:"hash"`
39
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
40
+	Ctime   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
41
+	Mtime   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
42
+}
43
+
44
+func (AdminUserElectronicSignature) TableName() string {
45
+	return "sgj_user_admin_electronic_signature"
46
+}
47
+
48
+// 管理员用户特殊权限,详见表注释
49
+type AdminUserSpecialPermission struct {
50
+	ID          int64 `gorm:"column:id" json:"id"`
51
+	OrgID       int64 `gorm:"column:org_id" json:"org_id"`
52
+	AppID       int64 `gorm:"column:app_id" json:"app_id"`
53
+	AdminUserID int64 `gorm:"column:admin_user_id" json:"admin_user_id"`
54
+	Permission  int64 `gorm:"column:permission" json:"permission"`
55
+	Status      int64 `gorm:"column:status" json:"-"`
56
+	CreateTime  int64 `gorm:"column:ctime" json:"-"`
57
+	ModifyTime  int64 `gorm:"column:mtime" json:"-"`
58
+}
59
+
60
+func (AdminUserSpecialPermission) TableName() string {
61
+	return "xt_admin_user_special_permission"
62
+}
63
+
64
+type SpecialPermissionType int64
65
+
66
+const (
67
+	_                              SpecialPermissionType = iota
68
+	SpecialPermissionTypeHeadNurse                       // 护士长
69
+)

+ 16 - 0
models/app_version_models.go View File

@@ -0,0 +1,16 @@
1
+package models
2
+
3
+type AppVersion struct {
4
+	ID      int64  `gorm:"column:id" json:"id" form:"id"`
5
+	AppType int64  `gorm:"column:app_type" json:"app_type" form:"app_type"`
6
+	Details string `gorm:"column:details" json:"details" form:"details"`
7
+	Version string `gorm:"column:version" json:"version" form:"version"`
8
+	Ctime   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
9
+	Mtime   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
10
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
11
+	Url     string `gorm:"column:url" json:"url" form:"url"`
12
+}
13
+
14
+func (AppVersion) TableName() string {
15
+	return "xt_app_version"
16
+}

+ 125 - 0
models/board_models.go View File

@@ -0,0 +1,125 @@
1
+package models
2
+
3
+type BoardPatients struct {
4
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
7
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
8
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
9
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
10
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
11
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
12
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
13
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
14
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
15
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
16
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
17
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
18
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
19
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
20
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
21
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
22
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
23
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
24
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
25
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
26
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
27
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
28
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
29
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
30
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
31
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
32
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
33
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
34
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
35
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
36
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
37
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
38
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
39
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
40
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
41
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
42
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
43
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
44
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
45
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
46
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
47
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
48
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
49
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
50
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
51
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
52
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
53
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
54
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
55
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
56
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
57
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
58
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
59
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
60
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
61
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
62
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history"`     // 现病史
63
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history"`           // 既往史
64
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
65
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
66
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
67
+	SBP                          int64   `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
68
+	DBP                          int64   `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
69
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
70
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
71
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
72
+	Age                          int64   `gorm:"column:age" json:"age"`
73
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind"`
74
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
75
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
76
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
77
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
78
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
79
+}
80
+
81
+func (BoardPatients) TableName() string {
82
+	return "xt_patients"
83
+}
84
+
85
+type NextSchedule struct {
86
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
87
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
88
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
89
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
90
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
91
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
92
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
93
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
94
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
95
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
96
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
97
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
98
+}
99
+
100
+func (NextSchedule) TableName() string {
101
+	return "xt_schedule"
102
+}
103
+
104
+type DialysisBoardVM struct {
105
+	ID           int64 `gorm:"column:id" json:"id"`
106
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
107
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id"`
108
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id"`
109
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id"`
110
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
111
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
112
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id"`
113
+	Status       int64 `gorm:"column:status" json:"status"`
114
+
115
+	NextSchedules  []*NextSchedule `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"next_schedules"`
116
+	Patient        *BoardPatients  `gorm:"ForeignKey:PatientId" json:"patient"`
117
+	DeviceNumber   *DeviceNumber   `gorm:"ForeignKey:BedId" json:"device_number"`
118
+	DeviceZone     *DeviceZone     `gorm:"ForeignKey:PartitionId" json:"device_zone"`
119
+	DialysisOrder  *DialysisOrder  `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
120
+	SigninAndWeigh *SigninAndWeigh `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"sign"`
121
+}
122
+
123
+func (DialysisBoardVM) TableName() string {
124
+	return "xt_schedule"
125
+}

+ 63 - 0
models/data_models.go View File

@@ -0,0 +1,63 @@
1
+package models
2
+
3
+type Dataconfig struct {
4
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
5
+	ParentId       int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
6
+	Module         string `gorm:"column:module" json:"module" form:"module"`
7
+	OrgId          int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
8
+	Name           string `gorm:"column:name" json:"name" form:"name"`
9
+	FieldName      string `gorm:"column:field_name" json:"field_name" form:"field_name"`
10
+	Value          int    `gorm:"column:value" json:"value" form:"value"`
11
+	CreatedTime    string `gorm:"column:create_time" json:"create_time" form:"create_time"`
12
+	UpdatedTime    string `gorm:"column:update_time" json:"update_time" form:"update_time"`
13
+	CreateUserId   int64  `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
14
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
15
+	Remark         string `gorm:"column:remark" json:"remark" form:"remark"`
16
+	DeleteIdSystem int64  `gorm:"column:delete_id_system" json:"delete_id_system" form:"delete_id_system"`
17
+	Title          string `gorm:"column:title" json:"title" form:"title"`
18
+	Content        string `gorm:"column:content" json:"content" form:"content"`
19
+	Order          int64  `gorm:"column:orders" json:"orders" form:"orders"`
20
+}
21
+
22
+func (Dataconfig) TableName() string {
23
+	return "xt_data_config"
24
+}
25
+
26
+type ConfigViewModel struct {
27
+	ID           int64         `gorm:"column:id" json:"id" form:"id"`
28
+	ParentId     int64         `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
29
+	Module       string        `gorm:"column:module" json:"module" form:"module"`
30
+	OrgId        int64         `gorm:"column:org_id" json:"org_id" form:"org_id"`
31
+	Name         string        `gorm:"column:name" json:"name" form:"name"`
32
+	FieldName    string        `gorm:"column:field_name" json:"field_name" form:"field_name"`
33
+	Value        int           `gorm:"column:value" json:"value" form:"value"`
34
+	CreatedTime  string        `gorm:"column:create_time" json:"create_time" form:"create_time"`
35
+	UpdatedTime  string        `gorm:"column:update_time" json:"update_time" form:"update_time"`
36
+	CreateUserId int64         `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
37
+	Status       int64         `gorm:"column:status" json:"status" form:"status"`
38
+	Remark       string        `gorm:"column:remark" json:"remark" form:"remark"`
39
+	Title        string        `gorm:"column:title" json:"title" form:"title"`
40
+	Content      string        `gorm:"column:content" json:"content" form:"content"`
41
+	Order        int64         `gorm:"column:orders" json:"orders" form:"orders"`
42
+	Childs       []*Dataconfig `json:"childs" `
43
+}
44
+
45
+func (ConfigViewModel) TableName() string {
46
+	return "xt_data_config"
47
+}
48
+
49
+type FiledConfig struct {
50
+	ID          int64  `gorm:"column:id" json:"id"`
51
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
52
+	Module      int64  `gorm:"column:module" json:"module"`
53
+	FiledName   string `gorm:"column:filed_name" json:"filed_name"`
54
+	FiledNameCn string `gorm:"column:filed_name_cn" json:"filed_name_cn"`
55
+	IsShow      int64  `gorm:"column:is_show" json:"is_show"`
56
+	CreateTime  int64  `gorm:"column:create_time" json:"create_time"`
57
+	UpdateTime  int64  `gorm:"column:update_time" json:"update_time"`
58
+	SysModule   int64  `gorm:"column:sys_module" json:"sys_module" form:"sys_module"`
59
+}
60
+
61
+func (FiledConfig) TableName() string {
62
+	return "xt_filed_config"
63
+}

+ 34 - 0
models/data_upload_models.go View File

@@ -0,0 +1,34 @@
1
+package models
2
+
3
+type DataUploadConfig struct {
4
+	ID             int64  `gorm:"column:id" json:"id"`
5
+	OrgId          int64  `gorm:"column:org_id" json:"org_id"`
6
+	ProvinceId     int64  `gorm:"column:province_id" json:"province_id"`
7
+	CityId         int64  `gorm:"column:city_id" json:"city_id"`
8
+	GatewayAddress string `gorm:"column:gateway_address" json:"gateway_address"`
9
+	AppId          string `gorm:"column:app_id" json:"app_id"`
10
+	Key            string `gorm:"column:key" json:"key"`
11
+	Status         int64  `gorm:"column:status" json:"status"`
12
+	CreateTime     int64  `gorm:"column:create_time" json:"create_time"`
13
+	ModifyTime     int64  `gorm:"column:modify_time" json:"modify_time"`
14
+	TimeQuantum    int64  `gorm:"column:time_quantum" json:"time_quantum"`
15
+	ConfigType     int64  `gorm:"column:config_type" json:"config_type"`
16
+}
17
+
18
+func (DataUploadConfig) TableName() string {
19
+	return "data_upload_config"
20
+}
21
+
22
+type DockingStatus struct {
23
+	ID          int64 `gorm:"column:id" json:"id"`
24
+	DockingType int64 `gorm:"column:docking_type" json:"docking_type"`
25
+	ProvinceId  int64 `gorm:"column:province_id" json:"province_id"`
26
+	CityId      int64 `gorm:"column:city_id" json:"city_id"`
27
+	Status      int64 `gorm:"column:status" json:"status"`
28
+	Ctime       int64 `gorm:"column:ctime" json:"ctime"`
29
+	Mtime       int64 `gorm:"column:mtime" json:"mtime"`
30
+}
31
+
32
+func (DockingStatus) TableName() string {
33
+	return "docking_status"
34
+}

+ 14 - 0
models/db_err_models.go View File

@@ -0,0 +1,14 @@
1
+package models
2
+
3
+type DBErrorRecord struct {
4
+	ID         int64  `gorm:"column:id"`
5
+	OrgID      int64  `gorm:"column:org_id"`
6
+	ErrDesc    string `gorm:"column:err_desc"`
7
+	Status     int8   `gorm:"column:status"`
8
+	CreateTime int64  `gorm:"column:ctime"`
9
+	ModifyTime int64  `gorm:"column:mtime"`
10
+}
11
+
12
+func (DBErrorRecord) TableName() string {
13
+	return "xt_db_err_records"
14
+}

+ 846 - 0
models/device_models.go View File

@@ -0,0 +1,846 @@
1
+package models
2
+
3
+// 设备关联表 将设备类型、ID 和 机号、分区、分组关联
4
+type Device struct {
5
+	ID             int64  `gorm:"column:id" json:"id"`
6
+	OrgID          int64  `gorm:"column:org_id" json:"-"`
7
+	DeviceType     int8   `json:"device_type"`                                     // 设备类型 1.透析机 2.水处理机
8
+	DMID           int64  `gorm:"column:dm_id" json:"-"`                           // 透析机 id(type = 1时)
9
+	WTEID          int64  `gorm:"column:wte_id" json:"-"`                          // 水处理机 id(type = 2时)
10
+	SerialNumber   string `json:"serial_number"`                                   // 序列号
11
+	Name           string `json:"name"`                                            // 设备名
12
+	Model          string `json:"model"`                                           // 型号
13
+	DeviceNumberID int64  `gorm:"column:device_number_id" json:"device_number_id"` // 机号
14
+	DeviceNumber   string `json:"device_number"`                                   // 机号名
15
+	DeviceZoneID   int64  `gorm:"column:device_zone_id" json:"device_zone_id"`     // 分区
16
+	DeviceGroupID  int64  `gorm:"column:device_group_id" json:"device_group_id"`   // 分组
17
+	Status         int8   `json:"-"`
18
+	CreateTime     int64  `gorm:"column:ctime" json:"-"`
19
+	ModifyTime     int64  `gorm:"column:mtime" json:"-"`
20
+}
21
+
22
+func (Device) TableName() string {
23
+	return "xt_device"
24
+}
25
+
26
+// 透析机
27
+type DeviceDM struct {
28
+	ID                int64  `gorm:"column:id" json:"id"`
29
+	OrgID             int64  `gorm:"column:org_id" json:"-"`
30
+	SerialNumber      string `json:"serial_number"`      // 序列号
31
+	Name              string `json:"name"`               // 设备名
32
+	Manufacturer      string `json:"manufacturer"`       // 生产厂家
33
+	RepairFactory     string `json:"repair_factory"`     // 维修厂家
34
+	Model             string `json:"model"`              // 型号
35
+	Department        string `json:"department"`         // 使用科室
36
+	DepartmentNumber  string `json:"department_number"`  // 科室编号
37
+	PurchaseDate      int64  `json:"purchase_date"`      // 购买日期
38
+	InstallDate       int64  `json:"install_date"`       // 安装日期
39
+	CommissioningDate int64  `json:"commissioning_date"` // 启用日期
40
+	Maintainer        string `json:"maintainer"`         // 维修工程师
41
+	MaintenanceCall   string `json:"maintenance_call"`   // 维修联系电话
42
+	WarrantyPeriod    string `json:"warranty_period"`    // 保修期限
43
+	DeviceStatus      int    `json:"device_status"`      // 机器状态 1.使用机 2.备用机 3.急诊机 4.报废机
44
+	InitialUseTimes   int    `json:"initial_use_times"`  // 初始使用次数
45
+	Mark              string `json:"mark"`               // 备注
46
+	RetirementDate    int64  `json:"retirement_date"`    // 报废日期
47
+	RetirementReason  string `json:"retirement_reason"`  // 报废原因
48
+	ServiceLife       int    `json:"service_life"`       // 使用年限
49
+	WorkingTime       int    `json:"working_time"`       // 工作时长
50
+	TreatmentMode     string `json:"treatment_mode"`     // 治疗模式
51
+	Status            int8   `json:"-"`
52
+	CreateTime        int64  `gorm:"column:ctime" json:"-"`
53
+	ModifyTime        int64  `gorm:"column:mtime" json:"-"`
54
+}
55
+
56
+func (DeviceDM) TableName() string {
57
+	return "xt_device_info_dm"
58
+}
59
+
60
+// 水处理机
61
+type DeviceWTE struct {
62
+	ID                 int64  `gorm:"column:id" json:"id"`
63
+	OrgID              int64  `gorm:"column:org_id" json:"-"`
64
+	SerialNumber       string `json:"serial_number"`        // 序列号
65
+	Name               string `json:"name"`                 // 设备名
66
+	Manufacturer       string `json:"manufacturer"`         // 生产厂家
67
+	RepairFactory      string `json:"repair_factory"`       // 维修厂家
68
+	Model              string `json:"model"`                // 型号
69
+	Department         string `json:"department"`           // 使用科室
70
+	DepartmentNumber   string `json:"department_number"`    // 科室编号
71
+	PurchaseDate       int64  `json:"purchase_date"`        // 购买日期
72
+	InstallDate        int64  `json:"install_date"`         // 安装日期
73
+	CommissioningDate  int64  `json:"commissioning_date"`   // 启用日期
74
+	Maintainer         string `json:"maintainer"`           // 维修工程师
75
+	MaintenanceCall    string `json:"maintenance_call"`     // 维修联系电话
76
+	WarrantyPeriod     string `json:"warranty_period"`      // 保修期限
77
+	DeviceStatus       int    `json:"device_status"`        // 机器状态 1.使用机 2.备用机 3.急诊机 4.报废机
78
+	InitialUseTimes    int    `json:"initial_use_times"`    // 初始使用次数
79
+	Mark               string `json:"mark"`                 // 备注
80
+	RetirementDate     int64  `json:"retirement_date"`      // 报废日期
81
+	RetirementReason   string `json:"retirement_reason"`    // 报废原因
82
+	ServiceLife        int    `json:"service_life"`         // 使用年限
83
+	WorkingTime        int    `json:"working_time"`         // 工作时长
84
+	ReverseOsmosisMode int    `json:"reverse_osmosis_mode"` // 反渗模式
85
+	Status             int8   `json:"-"`
86
+	CreateTime         int64  `gorm:"column:ctime" json:"-"`
87
+	ModifyTime         int64  `gorm:"column:mtime" json:"-"`
88
+}
89
+
90
+func (DeviceWTE) TableName() string {
91
+	return "xt_device_info_wte"
92
+}
93
+
94
+type DeviceZone struct {
95
+	ID         int64  `gorm:"column:id" json:"id"`
96
+	OrgID      int64  `gorm:"column:org_id" json:"-"`
97
+	Name       string `json:"name"`
98
+	Type       int    `json:"type"`
99
+	Status     int8   `json:"-"`
100
+	CreateTime int64  `gorm:"column:ctime" json:"-"`
101
+	ModifyTime int64  `gorm:"column:mtime" json:"-"`
102
+}
103
+
104
+func (DeviceZone) TableName() string {
105
+	return "xt_device_zone"
106
+}
107
+
108
+type DeviceGroup struct {
109
+	ID         int64  `gorm:"column:id" json:"id"`
110
+	OrgID      int64  `gorm:"column:org_id" json:"-"`
111
+	Name       string `json:"name"`
112
+	Status     int8   `json:"-"`
113
+	CreateTime int64  `gorm:"column:ctime" json:"-"`
114
+	ModifyTime int64  `gorm:"column:mtime" json:"-"`
115
+}
116
+
117
+func (DeviceGroup) TableName() string {
118
+	return "xt_device_group"
119
+}
120
+
121
+type DeviceNumber struct {
122
+	ID         int64  `gorm:"column:id" json:"id"`
123
+	OrgID      int64  `gorm:"column:org_id" json:"-"`
124
+	Number     string `json:"number"`
125
+	GroupID    int64  `gorm:"column:group_id" json:"group_id"`
126
+	ZoneID     int64  `gorm:"column:zone_id" json:"zone_id"`
127
+	Status     int8   `json:"-"`
128
+	CreateTime int64  `gorm:"column:ctime" json:"-"`
129
+	ModifyTime int64  `gorm:"column:mtime" json:"-"`
130
+}
131
+
132
+func (DeviceNumber) TableName() string {
133
+	return "xt_device_number"
134
+}
135
+
136
+type XtDeviceNumber struct {
137
+	ID      int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
138
+	OrgId   int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
139
+	Number  string `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
140
+	GroupId int64  `gorm:"column:group_id" json:"group_id" form:"group_id"`
141
+	ZoneId  int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
142
+	Status  int64  `gorm:"column:status" json:"status" form:"status"`
143
+	Ctime   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
144
+	Mtime   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
145
+}
146
+
147
+func (XtDeviceNumber) TableName() string {
148
+	return "xt_device_number"
149
+}
150
+
151
+type DeviceAddmachers struct {
152
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
153
+	SerialNumber        string `gorm:"column:serial_number" json:"serial_number" form:"serial_number"`
154
+	DeviceType          int64  `gorm:"column:device_type" json:"device_type" form:"device_type"`
155
+	BedNumber           string `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
156
+	DeviceName          string `gorm:"column:device_name" json:"device_name" form:"device_name"`
157
+	ManufactureFactory  string `gorm:"column:manufacture_factory" json:"manufacture_factory" form:"manufacture_factory"`
158
+	ServiceManufacturer string `gorm:"column:service_manufacturer" json:"service_manufacturer" form:"service_manufacturer"`
159
+	UnitType            string `gorm:"column:unit_type" json:"unit_type" form:"unit_type"`
160
+	UseSection          string `gorm:"column:use_section" json:"use_section" form:"use_section"`
161
+	SectionNumber       string `gorm:"column:section_number" json:"section_number" form:"section_number"`
162
+	BuyDate             int64  `gorm:"column:buy_date" json:"buy_date" form:"buy_date"`
163
+	InstallDate         int64  `gorm:"column:install_date" json:"install_date" form:"install_date"`
164
+	StartDate           int64  `gorm:"column:start_date" json:"start_date" form:"start_date"`
165
+	MaintenaceEngineer  string `gorm:"column:maintenace_engineer" json:"maintenace_engineer" form:"maintenace_engineer"`
166
+	Telephone           string `gorm:"column:telephone" json:"telephone" form:"telephone"`
167
+	GuaranteeDate       string `gorm:"column:guarantee_date" json:"guarantee_date" form:"guarantee_date"`
168
+	MachineStatus       int64  `gorm:"column:machine_status" json:"machine_status" form:"machine_status"`
169
+	UserTotal           string `gorm:"column:user_total" json:"user_total" form:"user_total"`
170
+	DisinfectionMode    int64  `gorm:"column:disinfection_mode" json:"disinfection_mode" form:"disinfection_mode"`
171
+	Remarks             string `gorm:"column:remarks" json:"remarks" form:"remarks"`
172
+	RubbishDate         int64  `gorm:"column:rubbish_date" json:"rubbish_date" form:"rubbish_date"`
173
+	RubbishReason       int64  `gorm:"column:rubbish_reason" json:"rubbish_reason" form:"rubbish_reason"`
174
+	UserYear            string `gorm:"column:user_year" json:"user_year" form:"user_year"`
175
+	WorkTime            string `gorm:"column:work_time" json:"work_time" form:"work_time"`
176
+	ReversMode          int64  `gorm:"column:revers_mode" json:"revers_mode" form:"revers_mode"`
177
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
178
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
179
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
180
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
181
+	ZoneId              int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
182
+	Name                string `gorm:"column:name" json:"name" form:"name"`
183
+	EquitmentName       string `gorm:"column:equitment_name" json:"equitment_name" form:"equitment_name"`
184
+	BedId               int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
185
+	DeviceMode          string `gorm:"column:device_mode" json:"device_mode" form:"device_mode"`
186
+}
187
+
188
+type DeviceAddmacher struct {
189
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
190
+	SerialNumber        string `gorm:"column:serial_number" json:"serial_number" form:"serial_number"`
191
+	DeviceType          int64  `gorm:"column:device_type" json:"device_type" form:"device_type"`
192
+	BedNumber           string `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
193
+	DeviceName          string `gorm:"column:device_name" json:"device_name" form:"device_name"`
194
+	ManufactureFactory  string `gorm:"column:manufacture_factory" json:"manufacture_factory" form:"manufacture_factory"`
195
+	ServiceManufacturer string `gorm:"column:service_manufacturer" json:"service_manufacturer" form:"service_manufacturer"`
196
+	UnitType            string `gorm:"column:unit_type" json:"unit_type" form:"unit_type"`
197
+	UseSection          string `gorm:"column:use_section" json:"use_section" form:"use_section"`
198
+	SectionNumber       string `gorm:"column:section_number" json:"section_number" form:"section_number"`
199
+	BuyDate             int64  `gorm:"column:buy_date" json:"buy_date" form:"buy_date"`
200
+	InstallDate         int64  `gorm:"column:install_date" json:"install_date" form:"install_date"`
201
+	StartDate           int64  `gorm:"column:start_date" json:"start_date" form:"start_date"`
202
+	MaintenaceEngineer  string `gorm:"column:maintenace_engineer" json:"maintenace_engineer" form:"maintenace_engineer"`
203
+	Telephone           string `gorm:"column:telephone" json:"telephone" form:"telephone"`
204
+	GuaranteeDate       string `gorm:"column:guarantee_date" json:"guarantee_date" form:"guarantee_date"`
205
+	MachineStatus       int64  `gorm:"column:machine_status" json:"machine_status" form:"machine_status"`
206
+	UserTotal           string `gorm:"column:user_total" json:"user_total" form:"user_total"`
207
+	DisinfectionMode    int64  `gorm:"column:disinfection_mode" json:"disinfection_mode" form:"disinfection_mode"`
208
+	Remarks             string `gorm:"column:remarks" json:"remarks" form:"remarks"`
209
+	RubbishDate         int64  `gorm:"column:rubbish_date" json:"rubbish_date" form:"rubbish_date"`
210
+	RubbishReason       int64  `gorm:"column:rubbish_reason" json:"rubbish_reason" form:"rubbish_reason"`
211
+	UserYear            string `gorm:"column:user_year" json:"user_year" form:"user_year"`
212
+	WorkTime            string `gorm:"column:work_time" json:"work_time" form:"work_time"`
213
+	ReversMode          int64  `gorm:"column:revers_mode" json:"revers_mode" form:"revers_mode"`
214
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
215
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
216
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
217
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
218
+	ZoneId              int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
219
+	BedId               int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
220
+}
221
+
222
+func (DeviceAddmacher) TableName() string {
223
+	return "xt_device_addmacher"
224
+}
225
+
226
+type DeviceTreatmentmode struct {
227
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
228
+	MachineId  int64 `gorm:"column:machine_id" json:"machine_id" form:"machine_id"`
229
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
230
+	Ctime      int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
231
+	Mtime      int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
232
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
233
+	TreateMode int64 `gorm:"column:treate_mode" json:"treate_mode" form:"treate_mode"`
234
+}
235
+
236
+func (DeviceTreatmentmode) TableName() string {
237
+	return "xt_device_treatmentmode"
238
+}
239
+
240
+type XtDeviceMachine struct {
241
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
242
+	SerialNumber        int64  `gorm:"column:serial_number" json:"serial_number" form:"serial_number"`
243
+	DeviceType          int64  `gorm:"column:device_type" json:"device_type" form:"device_type"`
244
+	BedNumber           string `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
245
+	DeviceName          string `gorm:"column:device_name" json:"device_name" form:"device_name"`
246
+	ManufactureFactory  string `gorm:"column:manufacture_factory" json:"manufacture_factory" form:"manufacture_factory"`
247
+	ServiceManufacturer string `gorm:"column:service_manufacturer" json:"service_manufacturer" form:"service_manufacturer"`
248
+	UnitType            string `gorm:"column:unit_type" json:"unit_type" form:"unit_type"`
249
+	UseSection          string `gorm:"column:use_section" json:"use_section" form:"use_section"`
250
+	SectionNumber       string `gorm:"column:section_number" json:"section_number" form:"section_number"`
251
+	BuyDate             int64  `gorm:"column:buy_date" json:"buy_date" form:"buy_date"`
252
+	InstallDate         int64  `gorm:"column:install_date" json:"install_date" form:"install_date"`
253
+	StartDate           int64  `gorm:"column:start_date" json:"start_date" form:"start_date"`
254
+	MaintenaceEngineer  string `gorm:"column:maintenace_engineer" json:"maintenace_engineer" form:"maintenace_engineer"`
255
+	Telephone           string `gorm:"column:telephone" json:"telephone" form:"telephone"`
256
+	GuaranteeDate       string `gorm:"column:guarantee_date" json:"guarantee_date" form:"guarantee_date"`
257
+	MachineStatus       int64  `gorm:"column:machine_status" json:"machine_status" form:"machine_status"`
258
+	UserTotal           string `gorm:"column:user_total" json:"user_total" form:"user_total"`
259
+	DisinfectionMode    int64  `gorm:"column:disinfection_mode" json:"disinfection_mode" form:"disinfection_mode"`
260
+	Remarks             string `gorm:"column:remarks" json:"remarks" form:"remarks"`
261
+	RubbishDate         int64  `gorm:"column:rubbish_date" json:"rubbish_date" form:"rubbish_date"`
262
+	RubbishReason       int64  `gorm:"column:rubbish_reason" json:"rubbish_reason" form:"rubbish_reason"`
263
+	UserYear            string `gorm:"column:user_year" json:"user_year" form:"user_year"`
264
+	WorkTime            string `gorm:"column:work_time" json:"work_time" form:"work_time"`
265
+	ReversMode          int64  `gorm:"column:revers_mode" json:"revers_mode" form:"revers_mode"`
266
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
267
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
268
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
269
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
270
+	ZoneId              int64  `gorm:"column:zone_id" json:"zone_id" form:"zone_id"`
271
+	BedId               int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
272
+}
273
+
274
+func (XtDeviceMachine) TableName() string {
275
+	return "xt_device_machine"
276
+}
277
+
278
+type DeviceEquimentname struct {
279
+	ID            int64  `gorm:"column:id" json:"id" form:"id"`
280
+	EquitmentName string `gorm:"column:equitment_name" json:"equitment_name" form:"equitment_name"`
281
+	Status        int64  `gorm:"column:status" json:"status" form:"status"`
282
+	Ctime         int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
283
+	Mtime         int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
284
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
285
+	EquitmentId   int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
286
+	BedId         int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
287
+}
288
+
289
+func (DeviceEquimentname) TableName() string {
290
+
291
+	return "xt_device_equimentname"
292
+}
293
+
294
+type DevicePlanss struct {
295
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
296
+	DeviceType          int64  `gorm:"column:device_type" json:"device_type" form:"device_type"`
297
+	DisinfecTime        int64  `gorm:"column:disinfec_time" json:"disinfec_time" form:"disinfec_time"`
298
+	Time                int64  `gorm:"column:time" json:"time" form:"time"`
299
+	Classtime           int64  `gorm:"column:classtime" json:"classtime" form:"classtime"`
300
+	Way                 int64  `gorm:"column:way" json:"way" form:"way"`
301
+	MachineDisinfectant int64  `gorm:"column:machine_disinfectant" json:"machine_disinfectant" form:"machine_disinfectant"`
302
+	DisinfectanWay      int64  `gorm:"column:disinfectan_way" json:"disinfectan_way" form:"disinfectan_way"`
303
+	Disinfectant        int64  `gorm:"column:disinfectant" json:"disinfectant" form:"disinfectant"`
304
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
305
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
306
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
307
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
308
+	EquimentId          int64  `gorm:"column:equiment_id" json:"equiment_id" form:"equiment_id"`
309
+	EquitmentName       string `gorm:"column:equitment_name" json:"equitment_name" form:"equitment_name"`
310
+}
311
+
312
+type DevicePlans struct {
313
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
314
+	DeviceType          int64  `gorm:"column:device_type" json:"device_type" form:"device_type"`
315
+	DisinfecTime        int64  `gorm:"column:disinfec_time" json:"disinfec_time" form:"disinfec_time"`
316
+	Time                int64  `gorm:"column:time" json:"time" form:"time"`
317
+	Classtime           int64  `gorm:"column:classtime" json:"classtime" form:"classtime"`
318
+	Way                 int64  `gorm:"column:way" json:"way" form:"way"`
319
+	MachineDisinfectant int64  `gorm:"column:machine_disinfectant" json:"machine_disinfectant" form:"machine_disinfectant"`
320
+	DisinfectanWay      int64  `gorm:"column:disinfectan_way" json:"disinfectan_way" form:"disinfectan_way"`
321
+	Disinfectant        int64  `gorm:"column:disinfectant" json:"disinfectant" form:"disinfectant"`
322
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
323
+	Ctime               int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
324
+	Mtime               int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
325
+	UserOrgId           int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
326
+	EquimentId          int64  `gorm:"column:equiment_id" json:"equiment_id" form:"equiment_id"`
327
+	DeviceMode          string `gorm:"column:device_mode" json:"device_mode" form:"device_mode"`
328
+}
329
+
330
+type DevicePlan struct {
331
+	ID                  int64 `gorm:"column:id" json:"id" form:"id"`
332
+	DeviceType          int64 `gorm:"column:device_type" json:"device_type" form:"device_type"`
333
+	DisinfecTime        int64 `gorm:"column:disinfec_time" json:"disinfec_time" form:"disinfec_time"`
334
+	Time                int64 `gorm:"column:time" json:"time" form:"time"`
335
+	Classtime           int64 `gorm:"column:classtime" json:"classtime" form:"classtime"`
336
+	Way                 int64 `gorm:"column:way" json:"way" form:"way"`
337
+	MachineDisinfectant int64 `gorm:"column:machine_disinfectant" json:"machine_disinfectant" form:"machine_disinfectant"`
338
+	DisinfectanWay      int64 `gorm:"column:disinfectan_way" json:"disinfectan_way" form:"disinfectan_way"`
339
+	Disinfectant        int64 `gorm:"column:disinfectant" json:"disinfectant" form:"disinfectant"`
340
+	Status              int64 `gorm:"column:status" json:"status" form:"status"`
341
+	Ctime               int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
342
+	Mtime               int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
343
+	UserOrgId           int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
344
+	EquimentId          int64 `gorm:"column:equiment_id" json:"equiment_id" form:"equiment_id"`
345
+	BedId               int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
346
+}
347
+
348
+func (DevicePlan) TableName() string {
349
+
350
+	return "xt_device_plan"
351
+}
352
+
353
+type Schedules struct {
354
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
355
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
356
+	PartitionId  int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
357
+	BedId        int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
358
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
359
+	ScheduleDate int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
360
+	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
361
+	ScheduleWeek int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
362
+	ModeId       int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
363
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
364
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
365
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
366
+	Name         string `gorm:"column:name" json:"name" form:"name"`
367
+	IsInfectious int64  `gorm:"column:is_infectious" json:"is_infectious"`
368
+}
369
+
370
+type XtSchedule struct {
371
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
372
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
373
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
374
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
375
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
376
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
377
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
378
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
379
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
380
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
381
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
382
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
383
+}
384
+
385
+func (XtSchedule) TableName() string {
386
+
387
+	return "xt_schedule"
388
+}
389
+
390
+type DeviceInformationss struct {
391
+	ID                    int64  `gorm:"column:id" json:"id" form:"id"`
392
+	Date                  int64  `gorm:"column:date" json:"date" form:"date"`
393
+	Class                 int64  `gorm:"column:class" json:"class" form:"class"`
394
+	Zone                  int64  `gorm:"column:zone" json:"zone" form:"zone"`
395
+	BedNumber             int64  `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
396
+	PatientId             int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
397
+	Contagion             string `gorm:"column:contagion" json:"contagion" form:"contagion"`
398
+	DialysisMode          int64  `gorm:"column:dialysis_mode" json:"dialysis_mode" form:"dialysis_mode"`
399
+	StartTime             int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
400
+	EndTime               int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
401
+	DialysisHour          string `gorm:"column:dialysis_hour" json:"dialysis_hour" form:"dialysis_hour"`
402
+	Hyperfiltratio        string `gorm:"column:hyperfiltratio" json:"hyperfiltratio" form:"hyperfiltratio"`
403
+	WeightLoss            string `gorm:"column:weight_loss" json:"weight_loss" form:"weight_loss"`
404
+	WarningValue          string `gorm:"column:warning_value" json:"warning_value" form:"warning_value"`
405
+	UserTotal             string `gorm:"column:user_total" json:"user_total" form:"user_total"`
406
+	Move                  int64  `gorm:"column:move" json:"move" form:"move"`
407
+	FailureStage          int64  `gorm:"column:failure_stage" json:"failure_stage" form:"failure_stage"`
408
+	FaultDescription      string `gorm:"column:fault_description" json:"fault_description" form:"fault_description"`
409
+	CodeInformation       string `gorm:"column:code_information" json:"code_information" form:"code_information"`
410
+	DisinfectType         int64  `gorm:"column:disinfect_type" json:"disinfect_type" form:"disinfect_type"`
411
+	DisinfectantType      int64  `gorm:"column:disinfectant_type" json:"disinfectant_type" form:"disinfectant_type"`
412
+	Disinfection          int64  `gorm:"column:disinfection" json:"disinfection" form:"disinfection"`
413
+	MachineRun            int64  `gorm:"column:machine_run" json:"machine_run" form:"machine_run"`
414
+	FluidPath             int64  `gorm:"column:fluid_path" json:"fluid_path" form:"fluid_path"`
415
+	Disinfectant          int64  `gorm:"column:disinfectant" json:"disinfectant" form:"disinfectant"`
416
+	DisinfectionStatus    int64  `gorm:"column:disinfection_status" json:"disinfection_status" form:"disinfection_status"`
417
+	DisinfectionResidue   int64  `gorm:"column:disinfection_residue" json:"disinfection_residue" form:"disinfection_residue"`
418
+	LongTime              string `gorm:"column:long_time" json:"long_time" form:"long_time"`
419
+	DisinfecStartime      int64  `gorm:"column:disinfec_startime" json:"disinfec_startime" form:"disinfec_startime"`
420
+	DisinfecEndtime       int64  `gorm:"column:disinfec_endtime" json:"disinfec_endtime" form:"disinfec_endtime"`
421
+	DialysisChecked       int64  `gorm:"column:dialysis_checked" json:"dialysis_checked" form:"dialysis_checked"`
422
+	DialysisName          int64  `gorm:"column:dialysis_name" json:"dialysis_name" form:"dialysis_name"`
423
+	Norms                 string `gorm:"column:norms" json:"norms" form:"norms"`
424
+	DialysisConcentration int64  `gorm:"column:dialysis_concentration" json:"dialysis_concentration" form:"dialysis_concentration"`
425
+	GermChecked           int64  `gorm:"column:germ_checked" json:"germ_checked" form:"germ_checked"`
426
+	GermName              int64  `gorm:"column:germ_name" json:"germ_name" form:"germ_name"`
427
+	GermNumber            string `gorm:"column:germ_number" json:"germ_number" form:"germ_number"`
428
+	Clean                 int64  `gorm:"column:clean" json:"clean" form:"clean"`
429
+	SignName              int64  `gorm:"column:sign_name" json:"sign_name" form:"sign_name"`
430
+	Status                int64  `gorm:"column:status" json:"status" form:"status"`
431
+	Ctime                 int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
432
+	Mtime                 int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
433
+	UserOrgId             int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
434
+	EquimentId            int64  `gorm:"column:equiment_id" json:"equiment_id" form:"equiment_id"`
435
+	Name                  string `gorm:"column:name" json:"name" form:"name"`
436
+	UserName              string `gorm:"column:user_name" json:"user_name" form:"user_name"`
437
+}
438
+
439
+type DeviceInformations struct {
440
+	ID                    int64  `gorm:"column:id" json:"id" form:"id"`
441
+	Date                  int64  `gorm:"column:date" json:"date" form:"date"`
442
+	Class                 int64  `gorm:"column:class" json:"class" form:"class"`
443
+	Zone                  int64  `gorm:"column:zone" json:"zone" form:"zone"`
444
+	BedNumber             int64  `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
445
+	PatientId             int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
446
+	Contagion             string `gorm:"column:contagion" json:"contagion" form:"contagion"`
447
+	DialysisMode          int64  `gorm:"column:dialysis_mode" json:"dialysis_mode" form:"dialysis_mode"`
448
+	StartTime             int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
449
+	EndTime               int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
450
+	DialysisHour          string `gorm:"column:dialysis_hour" json:"dialysis_hour" form:"dialysis_hour"`
451
+	Hyperfiltratio        string `gorm:"column:hyperfiltratio" json:"hyperfiltratio" form:"hyperfiltratio"`
452
+	WeightLoss            string `gorm:"column:weight_loss" json:"weight_loss" form:"weight_loss"`
453
+	WarningValue          string `gorm:"column:warning_value" json:"warning_value" form:"warning_value"`
454
+	UserTotal             string `gorm:"column:user_total" json:"user_total" form:"user_total"`
455
+	Move                  int64  `gorm:"column:move" json:"move" form:"move"`
456
+	FailureStage          int64  `gorm:"column:failure_stage" json:"failure_stage" form:"failure_stage"`
457
+	FaultDescription      string `gorm:"column:fault_description" json:"fault_description" form:"fault_description"`
458
+	CodeInformation       string `gorm:"column:code_information" json:"code_information" form:"code_information"`
459
+	DisinfectType         int64  `gorm:"column:disinfect_type" json:"disinfect_type" form:"disinfect_type"`
460
+	DisinfectantType      int64  `gorm:"column:disinfectant_type" json:"disinfectant_type" form:"disinfectant_type"`
461
+	Disinfection          int64  `gorm:"column:disinfection" json:"disinfection" form:"disinfection"`
462
+	MachineRun            int64  `gorm:"column:machine_run" json:"machine_run" form:"machine_run"`
463
+	FluidPath             int64  `gorm:"column:fluid_path" json:"fluid_path" form:"fluid_path"`
464
+	Disinfectant          int64  `gorm:"column:disinfectant" json:"disinfectant" form:"disinfectant"`
465
+	DisinfectionStatus    int64  `gorm:"column:disinfection_status" json:"disinfection_status" form:"disinfection_status"`
466
+	DisinfectionResidue   int64  `gorm:"column:disinfection_residue" json:"disinfection_residue" form:"disinfection_residue"`
467
+	LongTime              string `gorm:"column:long_time" json:"long_time" form:"long_time"`
468
+	DisinfecStartime      int64  `gorm:"column:disinfec_startime" json:"disinfec_startime" form:"disinfec_startime"`
469
+	DisinfecEndtime       int64  `gorm:"column:disinfec_endtime" json:"disinfec_endtime" form:"disinfec_endtime"`
470
+	DialysisChecked       int64  `gorm:"column:dialysis_checked" json:"dialysis_checked" form:"dialysis_checked"`
471
+	DialysisName          int64  `gorm:"column:dialysis_name" json:"dialysis_name" form:"dialysis_name"`
472
+	Norms                 string `gorm:"column:norms" json:"norms" form:"norms"`
473
+	DialysisConcentration int64  `gorm:"column:dialysis_concentration" json:"dialysis_concentration" form:"dialysis_concentration"`
474
+	GermChecked           int64  `gorm:"column:germ_checked" json:"germ_checked" form:"germ_checked"`
475
+	GermName              int64  `gorm:"column:germ_name" json:"germ_name" form:"germ_name"`
476
+	GermNumber            string `gorm:"column:germ_number" json:"germ_number" form:"germ_number"`
477
+	Clean                 int64  `gorm:"column:clean" json:"clean" form:"clean"`
478
+	SignName              int64  `gorm:"column:sign_name" json:"sign_name" form:"sign_name"`
479
+	Status                int64  `gorm:"column:status" json:"status" form:"status"`
480
+	Ctime                 int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
481
+	Mtime                 int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
482
+	UserOrgId             int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
483
+	EquimentId            int64  `gorm:"column:equiment_id" json:"equiment_id" form:"equiment_id"`
484
+	Bed                   string `gorm:"column:bed" json:"bed" form:"bed"`
485
+	Name                  string `gorm:"column:name" json:"name" form:"name"`
486
+	UserName              string `gorm:"column:user_name" json:"user_name" form:"user_name"`
487
+	AdminUserId           int64  `gorm:"column:admin_user_id" json:"admin_user_id"`
488
+}
489
+
490
+type DeviceInformation struct {
491
+	ID                    int64  `gorm:"column:id" json:"id" form:"id"`
492
+	Date                  int64  `gorm:"column:date" json:"date" form:"date"`
493
+	Class                 int64  `gorm:"column:class" json:"class" form:"class"`
494
+	Zone                  int64  `gorm:"column:zone" json:"zone" form:"zone"`
495
+	BedNumber             int64  `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
496
+	PatientId             int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
497
+	Contagion             string `gorm:"column:contagion" json:"contagion" form:"contagion"`
498
+	DialysisMode          int64  `gorm:"column:dialysis_mode" json:"dialysis_mode" form:"dialysis_mode"`
499
+	StartTime             int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
500
+	EndTime               int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
501
+	DialysisHour          string `gorm:"column:dialysis_hour" json:"dialysis_hour" form:"dialysis_hour"`
502
+	Hyperfiltratio        string `gorm:"column:hyperfiltratio" json:"hyperfiltratio" form:"hyperfiltratio"`
503
+	WeightLoss            string `gorm:"column:weight_loss" json:"weight_loss" form:"weight_loss"`
504
+	WarningValue          string `gorm:"column:warning_value" json:"warning_value" form:"warning_value"`
505
+	UserTotal             string `gorm:"column:user_total" json:"user_total" form:"user_total"`
506
+	Move                  int64  `gorm:"column:move" json:"move" form:"move"`
507
+	FailureStage          int64  `gorm:"column:failure_stage" json:"failure_stage" form:"failure_stage"`
508
+	FaultDescription      string `gorm:"column:fault_description" json:"fault_description" form:"fault_description"`
509
+	CodeInformation       string `gorm:"column:code_information" json:"code_information" form:"code_information"`
510
+	DisinfectType         int64  `gorm:"column:disinfect_type" json:"disinfect_type" form:"disinfect_type"`
511
+	DisinfectantType      int64  `gorm:"column:disinfectant_type" json:"disinfectant_type" form:"disinfectant_type"`
512
+	Disinfection          int64  `gorm:"column:disinfection" json:"disinfection" form:"disinfection"`
513
+	MachineRun            int64  `gorm:"column:machine_run" json:"machine_run" form:"machine_run"`
514
+	FluidPath             int64  `gorm:"column:fluid_path" json:"fluid_path" form:"fluid_path"`
515
+	Disinfectant          int64  `gorm:"column:disinfectant" json:"disinfectant" form:"disinfectant"`
516
+	DisinfectionStatus    int64  `gorm:"column:disinfection_status" json:"disinfection_status" form:"disinfection_status"`
517
+	DisinfectionResidue   int64  `gorm:"column:disinfection_residue" json:"disinfection_residue" form:"disinfection_residue"`
518
+	LongTime              string `gorm:"column:long_time" json:"long_time" form:"long_time"`
519
+	DisinfecStartime      int64  `gorm:"column:disinfec_startime" json:"disinfec_startime" form:"disinfec_startime"`
520
+	DisinfecEndtime       int64  `gorm:"column:disinfec_endtime" json:"disinfec_endtime" form:"disinfec_endtime"`
521
+	DialysisChecked       int64  `gorm:"column:dialysis_checked" json:"dialysis_checked" form:"dialysis_checked"`
522
+	DialysisName          int64  `gorm:"column:dialysis_name" json:"dialysis_name" form:"dialysis_name"`
523
+	Norms                 string `gorm:"column:norms" json:"norms" form:"norms"`
524
+	DialysisConcentration int64  `gorm:"column:dialysis_concentration" json:"dialysis_concentration" form:"dialysis_concentration"`
525
+	GermChecked           int64  `gorm:"column:germ_checked" json:"germ_checked" form:"germ_checked"`
526
+	GermName              int64  `gorm:"column:germ_name" json:"germ_name" form:"germ_name"`
527
+	GermNumber            string `gorm:"column:germ_number" json:"germ_number" form:"germ_number"`
528
+	Clean                 int64  `gorm:"column:clean" json:"clean" form:"clean"`
529
+	SignName              int64  `gorm:"column:sign_name" json:"sign_name" form:"sign_name"`
530
+	Status                int64  `gorm:"column:status" json:"status" form:"status"`
531
+	Ctime                 int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
532
+	Mtime                 int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
533
+	UserOrgId             int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
534
+	EquimentId            int64  `gorm:"column:equiment_id" json:"equiment_id" form:"equiment_id"`
535
+	Bed                   string `gorm:"column:bed" json:"bed" form:"bed"`
536
+	Stime                 int64  `gorm:"column:stime" json:"stime" form:"stime"`
537
+}
538
+
539
+func (DeviceInformation) TableName() string {
540
+
541
+	return "xt_device_information"
542
+}
543
+
544
+type DeviceCultures struct {
545
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
546
+	SpelingDate       int64  `gorm:"column:speling_date" json:"speling_date" form:"speling_date"`
547
+	Specimen          int64  `gorm:"column:specimen" json:"specimen" form:"specimen"`
548
+	ConcentrateNoa    string `gorm:"column:concentrate_noa" json:"concentrate_noa" form:"concentrate_noa"`
549
+	ConcentrateNob    string `gorm:"column:concentrate_nob" json:"concentrate_nob" form:"concentrate_nob"`
550
+	SamplingLocationa int64  `gorm:"column:sampling_locationa" json:"sampling_locationa" form:"sampling_locationa"`
551
+	DetectionUnit     string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
552
+	Sampler           int64  `gorm:"column:sampler" json:"sampler" form:"sampler"`
553
+	ReportingDate     int64  `gorm:"column:reporting_date" json:"reporting_date" form:"reporting_date"`
554
+	DetectionResult   string `gorm:"column:detection_result" json:"detection_result" form:"detection_result"`
555
+	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
556
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
557
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
558
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
559
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
560
+	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
561
+	UserName          string `gorm:"column:user_name" json:"user_name" form:"user_name"`
562
+	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
563
+}
564
+
565
+//细菌培养检测
566
+type DeviceCulture struct {
567
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
568
+	SpelingDate       int64  `gorm:"column:speling_date" json:"speling_date" form:"speling_date"`
569
+	Specimen          int64  `gorm:"column:specimen" json:"specimen" form:"specimen"`
570
+	ConcentrateNoa    string `gorm:"column:concentrate_noa" json:"concentrate_noa" form:"concentrate_noa"`
571
+	ConcentrateNob    string `gorm:"column:concentrate_nob" json:"concentrate_nob" form:"concentrate_nob"`
572
+	SamplingLocationa int64  `gorm:"column:sampling_locationa" json:"sampling_locationa" form:"sampling_locationa"`
573
+	DetectionUnit     string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
574
+	Sampler           int64  `gorm:"column:sampler" json:"sampler" form:"sampler"`
575
+	ReportingDate     int64  `gorm:"column:reporting_date" json:"reporting_date" form:"reporting_date"`
576
+	DetectionResult   string `gorm:"column:detection_result" json:"detection_result" form:"detection_result"`
577
+	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
578
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
579
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
580
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
581
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
582
+	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
583
+	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
584
+}
585
+
586
+func (DeviceCulture) TableName() string {
587
+
588
+	return "xt_device_culture"
589
+}
590
+
591
+type DeviceDialysates struct {
592
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
593
+	SamplingDate      int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
594
+	Specimenb         int64  `gorm:"column:specimenb" json:"specimenb" form:"specimenb"`
595
+	ConcentrateNoc    string `gorm:"column:concentrate_noc" json:"concentrate_noc" form:"concentrate_noc"`
596
+	ConcentratebNod   string `gorm:"column:concentrateb_nod" json:"concentrateb_nod" form:"concentrateb_nod"`
597
+	SamplingLocationb int64  `gorm:"column:sampling_locationb" json:"sampling_locationb" form:"sampling_locationb"`
598
+	DetectionUnit     string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
599
+	Samplerb          int64  `gorm:"column:samplerb" json:"samplerb" form:"samplerb"`
600
+	ReportingDateb    int64  `gorm:"column:reporting_dateb" json:"reporting_dateb" form:"reporting_dateb"`
601
+	DetectionResultb  string `gorm:"column:detection_resultb" json:"detection_resultb" form:"detection_resultb"`
602
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
603
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
604
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
605
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
606
+	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
607
+	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
608
+	UserName          string `gorm:"column:user_name" json:"user_name" form:"user_name"`
609
+	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
610
+}
611
+
612
+//内霉素检测
613
+type DeviceDialysate struct {
614
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
615
+	SamplingDate      int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
616
+	Specimenb         int64  `gorm:"column:specimenb" json:"specimenb" form:"specimenb"`
617
+	ConcentrateNoc    string `gorm:"column:concentrate_noc" json:"concentrate_noc" form:"concentrate_noc"`
618
+	ConcentratebNod   string `gorm:"column:concentrateb_nod" json:"concentrateb_nod" form:"concentrateb_nod"`
619
+	SamplingLocationb int64  `gorm:"column:sampling_locationb" json:"sampling_locationb" form:"sampling_locationb"`
620
+	DetectionUnit     string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
621
+	Samplerb          int64  `gorm:"column:samplerb" json:"samplerb" form:"samplerb"`
622
+	ReportingDateb    int64  `gorm:"column:reporting_dateb" json:"reporting_dateb" form:"reporting_dateb"`
623
+	DetectionResultb  string `gorm:"column:detection_resultb" json:"detection_resultb" form:"detection_resultb"`
624
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
625
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
626
+	Ctime             int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
627
+	Mtime             int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
628
+	BedId             int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
629
+	EquitmentId       int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
630
+	Bed               string `gorm:"column:bed" json:"bed" form:"bed"`
631
+}
632
+
633
+func (DeviceDialysate) TableName() string {
634
+
635
+	return "xt_device_dialysate"
636
+}
637
+
638
+type DeviceIons struct {
639
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
640
+	SamplingDate   int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
641
+	Samplerc       int64  `gorm:"column:samplerc" json:"samplerc" form:"samplerc"`
642
+	DetectionUnit  string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
643
+	ConcentrateNof string `gorm:"column:concentrate_nof" json:"concentrate_nof" form:"concentrate_nof"`
644
+	ConcentrateNog string `gorm:"column:concentrate_nog" json:"concentrate_nog" form:"concentrate_nog"`
645
+	DateReportc    int64  `gorm:"column:date_reportc" json:"date_reportc" form:"date_reportc"`
646
+	ActualNa       string `gorm:"column:actual_na" json:"actual_na" form:"actual_na"`
647
+	ActualPna      string `gorm:"column:actual_pna" json:"actual_pna" form:"actual_pna"`
648
+	ActualK        string `gorm:"column:actual_k" json:"actual_k" form:"actual_k"`
649
+	ActualCa       string `gorm:"column:actual_ca" json:"actual_ca" form:"actual_ca"`
650
+	ActualCi       string `gorm:"column:actual_ci" json:"actual_ci" form:"actual_ci"`
651
+	ActualHco      string `gorm:"column:actual_hco" json:"actual_hco" form:"actual_hco"`
652
+	ActualMg       string `gorm:"column:actual_mg" json:"actual_mg" form:"actual_mg"`
653
+	ActualPh       string `gorm:"column:actual_ph" json:"actual_ph" form:"actual_ph"`
654
+	Remakes        string `gorm:"column:remakes" json:"remakes" form:"remakes"`
655
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
656
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
657
+	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
658
+	Mtime          int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
659
+	BedId          int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
660
+	EquitmentId    int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
661
+	UserName       string `gorm:"column:user_name" json:"user_name" form:"user_name"`
662
+	Bed            string `gorm:"column:bed" json:"bed" form:"bed"`
663
+}
664
+
665
+//透析液离子浓度检测
666
+type DeviceIon struct {
667
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
668
+	SamplingDate   int64  `gorm:"column:sampling_date" json:"sampling_date" form:"sampling_date"`
669
+	Samplerc       int64  `gorm:"column:samplerc" json:"samplerc" form:"samplerc"`
670
+	DetectionUnit  string `gorm:"column:detection_unit" json:"detection_unit" form:"detection_unit"`
671
+	ConcentrateNof string `gorm:"column:concentrate_nof" json:"concentrate_nof" form:"concentrate_nof"`
672
+	ConcentrateNog string `gorm:"column:concentrate_nog" json:"concentrate_nog" form:"concentrate_nog"`
673
+	DateReportc    int64  `gorm:"column:date_reportc" json:"date_reportc" form:"date_reportc"`
674
+	ActualNa       string `gorm:"column:actual_na" json:"actual_na" form:"actual_na"`
675
+	ActualPna      string `gorm:"column:actual_pna" json:"actual_pna" form:"actual_pna"`
676
+	ActualK        string `gorm:"column:actual_k" json:"actual_k" form:"actual_k"`
677
+	ActualCa       string `gorm:"column:actual_ca" json:"actual_ca" form:"actual_ca"`
678
+	ActualCi       string `gorm:"column:actual_ci" json:"actual_ci" form:"actual_ci"`
679
+	ActualHco      string `gorm:"column:actual_hco" json:"actual_hco" form:"actual_hco"`
680
+	ActualMg       string `gorm:"column:actual_mg" json:"actual_mg" form:"actual_mg"`
681
+	ActualPh       string `gorm:"column:actual_ph" json:"actual_ph" form:"actual_ph"`
682
+	Remakes        string `gorm:"column:remakes" json:"remakes" form:"remakes"`
683
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
684
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
685
+	Ctime          int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
686
+	Mtime          int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
687
+	BedId          int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
688
+	EquitmentId    int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
689
+	Bed            string `gorm:"column:bed" json:"bed" form:"bed"`
690
+}
691
+
692
+func (DeviceIon) TableName() string {
693
+
694
+	return "xt_device_ion"
695
+}
696
+
697
+type DeviceRepairs struct {
698
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
699
+	GuaranteeDate    int64  `gorm:"column:guarantee_date" json:"guarantee_date" form:"guarantee_date"`
700
+	StartTime        int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
701
+	ArriveTime       int64  `gorm:"column:arrive_time" json:"arrive_time" form:"arrive_time"`
702
+	FinishTime       int64  `gorm:"column:finish_time" json:"finish_time" form:"finish_time"`
703
+	TotalDistance    string `gorm:"column:total_distance" json:"total_distance" form:"total_distance"`
704
+	FailureStage     int64  `gorm:"column:failure_stage" json:"failure_stage" form:"failure_stage"`
705
+	FaultDescription string `gorm:"column:fault_description" json:"fault_description" form:"fault_description"`
706
+	CauseAnalysis    string `gorm:"column:cause_analysis" json:"cause_analysis" form:"cause_analysis"`
707
+	TreatmentProcess string `gorm:"column:treatment_process" json:"treatment_process" form:"treatment_process"`
708
+	Images           string `gorm:"column:images" json:"images" form:"images"`
709
+	Exclude          int64  `gorm:"column:exclude" json:"exclude" form:"exclude"`
710
+	Reason           string `gorm:"column:reason" json:"reason" form:"reason"`
711
+	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
712
+	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
713
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
714
+	UserOrgId        int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
715
+	BedId            int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
716
+	EquitmentId      int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
717
+	CodeInformation  string `gorm:"column:code_information" json:"code_information" form:"code_information"`
718
+	BedNumber        string `gorm:"column:bed_number" json:"bed_number" form:"bed_number"`
719
+}
720
+
721
+type DeviceRepair struct {
722
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
723
+	GuaranteeDate    int64  `gorm:"column:guarantee_date" json:"guarantee_date" form:"guarantee_date"`
724
+	StartTime        int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
725
+	ArriveTime       int64  `gorm:"column:arrive_time" json:"arrive_time" form:"arrive_time"`
726
+	FinishTime       int64  `gorm:"column:finish_time" json:"finish_time" form:"finish_time"`
727
+	TotalDistance    string `gorm:"column:total_distance" json:"total_distance" form:"total_distance"`
728
+	FailureStage     int64  `gorm:"column:failure_stage" json:"failure_stage" form:"failure_stage"`
729
+	FaultDescription string `gorm:"column:fault_description" json:"fault_description" form:"fault_description"`
730
+	CauseAnalysis    string `gorm:"column:cause_analysis" json:"cause_analysis" form:"cause_analysis"`
731
+	TreatmentProcess string `gorm:"column:treatment_process" json:"treatment_process" form:"treatment_process"`
732
+	Images           string `gorm:"column:images" json:"images" form:"images"`
733
+	Exclude          int64  `gorm:"column:exclude" json:"exclude" form:"exclude"`
734
+	Reason           string `gorm:"column:reason" json:"reason" form:"reason"`
735
+	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
736
+	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
737
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
738
+	UserOrgId        int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
739
+	BedId            int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
740
+	EquitmentId      int64  `gorm:"column:equitment_id" json:"equitment_id" form:"equitment_id"`
741
+	CodeInformation  string `gorm:"column:code_information" json:"code_information" form:"code_information"`
742
+	ImageName        string `gorm:"column:image_name" json:"image_name" form:"image_name"`
743
+}
744
+
745
+func (DeviceRepair) TableName() string {
746
+
747
+	return "xt_device_repair"
748
+}
749
+
750
+type XtAssessmentAfterDislysis struct {
751
+	ID                              int64   `gorm:"column:id" json:"id" form:"id"`
752
+	UserOrgId                       int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
753
+	PatientId                       int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
754
+	AssessmentDate                  int64   `gorm:"column:assessment_date" json:"assessment_date" form:"assessment_date"`
755
+	DialysisOrderId                 int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
756
+	Temperature                     float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
757
+	PulseFrequency                  float64 `gorm:"column:pulse_frequency" json:"pulse_frequency" form:"pulse_frequency"`
758
+	BreathingRate                   float64 `gorm:"column:breathing_rate" json:"breathing_rate" form:"breathing_rate"`
759
+	SystolicBloodPressure           float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure" form:"systolic_blood_pressure"`
760
+	DiastolicBloodPressure          float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure" form:"diastolic_blood_pressure"`
761
+	BloodPressureType               int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type" form:"blood_pressure_type"`
762
+	ActualUltrafiltration           float64 `gorm:"column:actual_ultrafiltration" json:"actual_ultrafiltration" form:"actual_ultrafiltration"`
763
+	ActualDisplacement              float64 `gorm:"column:actual_displacement" json:"actual_displacement" form:"actual_displacement"`
764
+	ActualTreatmentHour             int64   `gorm:"column:actual_treatment_hour" json:"actual_treatment_hour" form:"actual_treatment_hour"`
765
+	ActualTreatmentMinute           int64   `gorm:"column:actual_treatment_minute" json:"actual_treatment_minute" form:"actual_treatment_minute"`
766
+	WeighingWay                     string  `gorm:"column:weighing_way" json:"weighing_way" form:"weighing_way"`
767
+	WeightAfter                     float64 `gorm:"column:weight_after" json:"weight_after" form:"weight_after"`
768
+	AdditionalWeight                float64 `gorm:"column:additional_weight" json:"additional_weight" form:"additional_weight"`
769
+	WeightLoss                      float64 `gorm:"column:weight_loss" json:"weight_loss" form:"weight_loss"`
770
+	Cruor                           string  `gorm:"column:cruor" json:"cruor" form:"cruor"`
771
+	SymptomAfterDialysis            string  `gorm:"column:symptom_after_dialysis" json:"symptom_after_dialysis" form:"symptom_after_dialysis"`
772
+	InternalFistula                 string  `gorm:"column:internal_fistula" json:"internal_fistula" form:"internal_fistula"`
773
+	Catheter                        string  `gorm:"column:catheter" json:"catheter" form:"catheter"`
774
+	Complication                    string  `gorm:"column:complication" json:"complication" form:"complication"`
775
+	Evaluator                       int64   `gorm:"column:evaluator" json:"evaluator" form:"evaluator"`
776
+	Remark                          string  `gorm:"column:remark" json:"remark" form:"remark"`
777
+	DialysisIntakes                 int64   `gorm:"column:dialysis_intakes" json:"dialysis_intakes" form:"dialysis_intakes"`
778
+	DialysisIntakesFeed             int64   `gorm:"column:dialysis_intakes_feed" json:"dialysis_intakes_feed" form:"dialysis_intakes_feed"`
779
+	DialysisIntakesTransfusion      int64   `gorm:"column:dialysis_intakes_transfusion" json:"dialysis_intakes_transfusion" form:"dialysis_intakes_transfusion"`
780
+	DialysisIntakesBloodTransfusion int64   `gorm:"column:dialysis_intakes_blood_transfusion" json:"dialysis_intakes_blood_transfusion" form:"dialysis_intakes_blood_transfusion"`
781
+	DialysisIntakesWashpipe         int64   `gorm:"column:dialysis_intakes_washpipe" json:"dialysis_intakes_washpipe" form:"dialysis_intakes_washpipe"`
782
+	Status                          int64   `gorm:"column:status" json:"status" form:"status"`
783
+	CreatedTime                     int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
784
+	UpdatedTime                     int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
785
+	Creater                         int64   `gorm:"column:creater" json:"creater" form:"creater"`
786
+	Modifier                        int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
787
+	BloodAccessPartId               int64   `gorm:"column:blood_access_part_id" json:"blood_access_part_id" form:"blood_access_part_id"`
788
+	BloodAccessPartOperaId          int64   `gorm:"column:blood_access_part_opera_id" json:"blood_access_part_opera_id" form:"blood_access_part_opera_id"`
789
+	PuncturePointOozingBlood        int64   `gorm:"column:puncture_point_oozing_blood" json:"puncture_point_oozing_blood" form:"puncture_point_oozing_blood"`
790
+	PuncturePointHaematoma          int64   `gorm:"column:puncture_point_haematoma" json:"puncture_point_haematoma" form:"puncture_point_haematoma"`
791
+	InternalFistulaTremorAc         int64   `gorm:"column:internal_fistula_tremor_ac" json:"internal_fistula_tremor_ac" form:"internal_fistula_tremor_ac"`
792
+	PatientGose                     int64   `gorm:"column:patient_gose" json:"patient_gose" form:"patient_gose"`
793
+	InpatientDepartment             string  `gorm:"column:inpatient_department" json:"inpatient_department" form:"inpatient_department"`
794
+	ObservationContent              string  `gorm:"column:observation_content" json:"observation_content" form:"observation_content"`
795
+	ObservationContentOther         string  `gorm:"column:observation_content_other" json:"observation_content_other" form:"observation_content_other"`
796
+	DryWeight                       float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
797
+	DialysisProcess                 int64   `gorm:"column:dialysis_process" json:"dialysis_process" form:"dialysis_process"`
798
+	InAdvanceMinute                 float64 `gorm:"column:in_advance_minute" json:"in_advance_minute" form:"in_advance_minute"`
799
+	InAdvanceReason                 string  `gorm:"column:in_advance_reason" json:"in_advance_reason" form:"in_advance_reason"`
800
+	HemostasisMinute                int64   `gorm:"column:hemostasis_minute" json:"hemostasis_minute" form:"hemostasis_minute"`
801
+	HemostasisOpera                 int64   `gorm:"column:hemostasis_opera" json:"hemostasis_opera" form:"hemostasis_opera"`
802
+	TremorNoise                     int64   `gorm:"column:tremor_noise" json:"tremor_noise" form:"tremor_noise"`
803
+	DisequilibriumSyndrome          int64   `gorm:"column:disequilibrium_syndrome" json:"disequilibrium_syndrome" form:"disequilibrium_syndrome"`
804
+	DisequilibriumSyndromeOption    string  `gorm:"column:disequilibrium_syndrome_option" json:"disequilibrium_syndrome_option" form:"disequilibrium_syndrome_option"`
805
+	ArterialTube                    int64   `gorm:"column:arterial_tube" json:"arterial_tube" form:"arterial_tube"`
806
+	IntravenousTube                 int64   `gorm:"column:intravenous_tube" json:"intravenous_tube" form:"intravenous_tube"`
807
+	Dialyzer                        int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialyzer"`
808
+	InAdvanceReasonOther            string  `gorm:"column:in_advance_reason_other" json:"in_advance_reason_other" form:"in_advance_reason_other"`
809
+	AssessmentDoctor                int64   `gorm:"column:assessment_doctor" json:"assessment_doctor" form:"assessment_doctor"`
810
+	AssessmentTime                  int64   `gorm:"column:assessment_time" json:"assessment_time" form:"assessment_time"`
811
+	IsEat                           int64   `gorm:"column:is_eat" json:"is_eat" form:"is_eat"`
812
+	DialysisIntakesUnit             int64   `gorm:"column:dialysis_intakes_unit" json:"dialysis_intakes_unit" form:"dialysis_intakes_unit"`
813
+}
814
+
815
+func (XtAssessmentAfterDislysis) TableName() string {
816
+
817
+	return "xt_assessment_after_dislysis"
818
+}
819
+
820
+type DeviceRemander struct {
821
+	ID        int64 `gorm:"column:id" json:"id" form:"id"`
822
+	IsRun     int64 `gorm:"column:is_run" json:"is_run" form:"is_run"`
823
+	UserOrgId int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
824
+	Status    int64 `gorm:"column:status" json:"status" form:"status"`
825
+	Ctime     int64 `gorm:"column:ctime" json:"ctime" form:"ctime"`
826
+	Mtime     int64 `gorm:"column:mtime" json:"mtime" form:"mtime"`
827
+}
828
+
829
+func (DeviceRemander) TableName() string {
830
+
831
+	return "xt_device_remander"
832
+}
833
+
834
+type DeviceMode struct {
835
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
836
+	DeviceMode string `gorm:"column:device_mode" json:"device_mode" form:"device_mode"`
837
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
838
+	UserOrgId  int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
839
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
840
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
841
+}
842
+
843
+func (DeviceMode) TableName() string {
844
+
845
+	return "xt_device_mode"
846
+}

+ 801 - 0
models/dialysis.go View File

@@ -0,0 +1,801 @@
1
+package models
2
+
3
+type SchedualPatient struct {
4
+	ID                      int64                   `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId               int64                   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	UserId                  int64                   `gorm:"column:user_id" json:"user_id" form:"user_id"`
7
+	PatientType             int64                   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
8
+	Avatar                  string                  `gorm:"column:avatar" json:"avatar" form:"avatar"`
9
+	DialysisNo              string                  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
10
+	AdmissionNumber         string                  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
11
+	Source                  int64                   `gorm:"column:source" json:"source" form:"source"`
12
+	Lapseto                 int64                   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
13
+	PartitionId             int64                   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
14
+	BedId                   int64                   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
15
+	Name                    string                  `gorm:"column:name" json:"name" form:"name"`
16
+	Alias                   string                  `gorm:"column:alias" json:"alias" form:"alias"`
17
+	Gender                  int64                   `gorm:"column:gender" json:"gender" form:"gender"`
18
+	Nation                  string                  `gorm:"column:nation" json:"nation" form:"nation"`
19
+	NativePlace             string                  `gorm:"column:native_place" json:"native_place" form:"native_place"`
20
+	MaritalStatus           int64                   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
21
+	IdCardNo                string                  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
22
+	Birthday                int64                   `gorm:"column:birthday" json:"birthday" form:"birthday"`
23
+	ReimbursementWayId      int64                   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
24
+	HealthCareType          int64                   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
25
+	HealthCareNo            string                  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
26
+	HealthCareDueDate       int64                   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
27
+	Height                  int64                   `gorm:"column:height" json:"height" form:"height"`
28
+	BloodType               int64                   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
29
+	Rh                      int64                   `gorm:"column:rh" json:"rh" form:"rh"`
30
+	HealthCareDueAlertDate  int64                   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
31
+	EducationLevel          int64                   `gorm:"column:education_level" json:"education_level" form:"education_level"`
32
+	Profession              int64                   `gorm:"column:profession" json:"profession" form:"profession"`
33
+	Phone                   string                  `gorm:"column:phone" json:"phone" form:"phone"`
34
+	HomeTelephone           string                  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
35
+	RelativePhone           string                  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
36
+	RelativeRelations       string                  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
37
+	HomeAddress             string                  `gorm:"column:home_address" json:"home_address" form:"home_address"`
38
+	WorkUnit                string                  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
39
+	UnitAddress             string                  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
40
+	Children                int64                   `gorm:"column:children" json:"children" form:"children"`
41
+	ReceivingDate           int64                   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
42
+	IsHospitalFirstDialysis int64                   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
43
+	FirstDialysisDate       int64                   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
44
+	FirstDialysisHospital   string                  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
45
+	InductionPeriod         int64                   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
46
+	InitialDialysis         int64                   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
47
+	TotalDialysis           int64                   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
48
+	AttendingDoctorId       int64                   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
49
+	HeadNurseId             int64                   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
50
+	Evaluate                string                  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
51
+	Diagnose                string                  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
52
+	Remark                  string                  `gorm:"column:remark" json:"remark" form:"remark"`
53
+	RegistrarsId            int64                   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
54
+	Registrars              string                  `gorm:"column:registrars" json:"registrars" form:"registrars"`
55
+	QrCode                  string                  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
56
+	BindingState            int64                   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
57
+	PatientComplains        string                  `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
58
+	PresentHistory          string                  `gorm:"column:present_history" json:"present_history"`     // 现病史
59
+	PastHistory             string                  `gorm:"column:past_history" json:"past_history"`           // 既往史
60
+	Temperature             float64                 `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
61
+	Pulse                   int64                   `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
62
+	Respiratory             int64                   `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
63
+	SBP                     int64                   `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
64
+	DBP                     int64                   `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
65
+	Age                     int64                   `gorm:"column:age" json:"age"`
66
+	Status                  int64                   `gorm:"column:status" json:"status" form:"status"`
67
+	CreatedTime             int64                   `gorm:"column:created_time" json:"created_time" form:"created_time"`
68
+	UpdatedTime             int64                   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
69
+	PredialysisEvaluation   PredialysisEvaluation   `json:"PredialysisEvaluation" gorm:"ForeignKey:PatientId"`
70
+	AssessmentAfterDislysis AssessmentAfterDislysis `gorm:"ForeignKey:PatientId"`
71
+	MonitoringRecord        []MonitoringRecord      `gorm:"ForeignKey:PatientId"`
72
+	IsOpenRemind            int64                   `gorm:"column:is_open_remind" json:"is_open_remind"`
73
+	DialysisAge             int64                   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
74
+	ExpenseKind             int64                   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
75
+	TellPhone               string                  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
76
+	FirstTreatmentDate      int64                   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
77
+	ContactName             string                  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
78
+}
79
+
80
+func (SchedualPatient) TableName() string {
81
+	return "xt_patients"
82
+}
83
+
84
+type SchedualPatient2 struct {
85
+	ID                      int64            `gorm:"column:id" json:"id" form:"id"`
86
+	UserOrgId               int64            `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
87
+	UserId                  int64            `gorm:"column:user_id" json:"user_id" form:"user_id"`
88
+	PatientType             int64            `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
89
+	Avatar                  string           `gorm:"column:avatar" json:"avatar" form:"avatar"`
90
+	DialysisNo              string           `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
91
+	AdmissionNumber         string           `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
92
+	Source                  int64            `gorm:"column:source" json:"source" form:"source"`
93
+	Lapseto                 int64            `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
94
+	PartitionId             int64            `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
95
+	BedId                   int64            `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
96
+	Name                    string           `gorm:"column:name" json:"name" form:"name"`
97
+	Alias                   string           `gorm:"column:alias" json:"alias" form:"alias"`
98
+	Gender                  int64            `gorm:"column:gender" json:"gender" form:"gender"`
99
+	Nation                  string           `gorm:"column:nation" json:"nation" form:"nation"`
100
+	NativePlace             string           `gorm:"column:native_place" json:"native_place" form:"native_place"`
101
+	MaritalStatus           int64            `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
102
+	IdCardNo                string           `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
103
+	Birthday                int64            `gorm:"column:birthday" json:"birthday" form:"birthday"`
104
+	ReimbursementWayId      int64            `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
105
+	HealthCareType          int64            `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
106
+	HealthCareNo            string           `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
107
+	HealthCareDueDate       int64            `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
108
+	Height                  int64            `gorm:"column:height" json:"height" form:"height"`
109
+	BloodType               int64            `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
110
+	Rh                      int64            `gorm:"column:rh" json:"rh" form:"rh"`
111
+	HealthCareDueAlertDate  int64            `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
112
+	EducationLevel          int64            `gorm:"column:education_level" json:"education_level" form:"education_level"`
113
+	Profession              int64            `gorm:"column:profession" json:"profession" form:"profession"`
114
+	Phone                   string           `gorm:"column:phone" json:"phone" form:"phone"`
115
+	HomeTelephone           string           `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
116
+	RelativePhone           string           `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
117
+	RelativeRelations       string           `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
118
+	HomeAddress             string           `gorm:"column:home_address" json:"home_address" form:"home_address"`
119
+	WorkUnit                string           `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
120
+	UnitAddress             string           `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
121
+	Children                int64            `gorm:"column:children" json:"children" form:"children"`
122
+	ReceivingDate           int64            `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
123
+	IsHospitalFirstDialysis int64            `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
124
+	FirstDialysisDate       int64            `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
125
+	FirstDialysisHospital   string           `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
126
+	InductionPeriod         int64            `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
127
+	InitialDialysis         int64            `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
128
+	TotalDialysis           int64            `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
129
+	AttendingDoctorId       int64            `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
130
+	HeadNurseId             int64            `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
131
+	Evaluate                string           `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
132
+	Diagnose                string           `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
133
+	Remark                  string           `gorm:"column:remark" json:"remark" form:"remark"`
134
+	RegistrarsId            int64            `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
135
+	Registrars              string           `gorm:"column:registrars" json:"registrars" form:"registrars"`
136
+	QrCode                  string           `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
137
+	BindingState            int64            `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
138
+	PatientComplains        string           `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
139
+	PresentHistory          string           `gorm:"column:present_history" json:"present_history"`     // 现病史
140
+	PastHistory             string           `gorm:"column:past_history" json:"past_history"`           // 既往史
141
+	Temperature             float64          `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
142
+	Pulse                   int64            `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
143
+	Respiratory             int64            `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
144
+	SBP                     int64            `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
145
+	DBP                     int64            `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
146
+	Status                  int64            `gorm:"column:status" json:"status" form:"status"`
147
+	CreatedTime             int64            `gorm:"column:created_time" json:"created_time" form:"created_time"`
148
+	UpdatedTime             int64            `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
149
+	DialysisSchedule        DialysisSchedule `gorm:"ForeignKey:PatientId"`
150
+	Age                     int64            `gorm:"column:age" json:"age"`
151
+	IsOpenRemind            int64            `gorm:"column:is_open_remind" json:"is_open_remind"`
152
+	DialysisAge             int64            `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
153
+	ExpenseKind             int64            `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
154
+	TellPhone               string           `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
155
+	FirstTreatmentDate      int64            `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
156
+	ContactName             string           `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
157
+}
158
+
159
+func (SchedualPatient2) TableName() string {
160
+	return "xt_patients"
161
+}
162
+
163
+type DialysisSchedule struct {
164
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
165
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
166
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
167
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
168
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
169
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
170
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
171
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
172
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
173
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
174
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
175
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
176
+
177
+	MonitorPatients MonitorPatients `gorm:"ForeignKey:PatientId" json:"patient"`
178
+	DeviceNumber    DeviceNumber    `gorm:"ForeignKey:BedId" json:"device_number"`
179
+	DeviceZone      DeviceZone      `gorm:"ForeignKey:PartitionId" json:"device_zone"`
180
+	TreatmentMode   TreatmentMode   `gorm:"ForeignKey:ModeId" json:"treatment_mode"`
181
+
182
+	DialysisOrder            MonitorDialysisOrder    `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
183
+	Prescription             DialysisPrescription    `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
184
+	AssessmentBeforeDislysis PredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
185
+	AssessmentAfterDislysis  AssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
186
+	MonitoringRecord         []MonitoringRecord      `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"monitoring_record"`
187
+
188
+	//Patient         string          `gorm:"-" json:"patient" form:"patient"`
189
+	//SchedualPatient SchedualPatient `gorm:"ForeignKey:PatientId"`
190
+	//DeviceNumber    DeviceNumber    `gorm:"ForeignKey:BedId"`
191
+	//DeviceZone      DeviceZone      `gorm:"ForeignKey:PartitionId"`
192
+	//TreatmentMode   TreatmentMode   `gorm:"ForeignKey:ModeId"`
193
+}
194
+
195
+func (DialysisSchedule) TableName() string {
196
+	return "xt_schedule"
197
+}
198
+
199
+type PredialysisEvaluation struct {
200
+	ID                          int64   `gorm:"column:id" json:"id"`
201
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id"`
202
+	PatientId                   int64   `gorm:"column:patient_id" json:"patient_id"`
203
+	AssessmentDate              int64   `gorm:"column:assessment_date" json:"assessment_date"`
204
+	DialysisOrderId             int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
205
+	Temperature                 float64 `gorm:"column:temperature" json:"temperature"`
206
+	PulseFrequency              float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
207
+	BreathingRate               float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
208
+	SystolicBloodPressure       float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
209
+	DiastolicBloodPressure      float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
210
+	BloodPressureType           int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
211
+	DryWeight                   float64 `gorm:"column:dry_weight" json:"dry_weight"`
212
+	WeightAfterLastTransparency float64 `gorm:"column:weight_after_last_transparency" json:"weight_after_last_transparency"`
213
+	WeighingWay                 string  `gorm:"column:weighing_way" json:"weighing_way"`
214
+	WeighingBefore              float64 `gorm:"column:weighing_before" json:"weighing_before"`
215
+	AdditionalWeight            float64 `gorm:"column:additional_weight" json:"additional_weight"`
216
+	WeightBefore                float64 `gorm:"column:weight_before" json:"weight_before"`
217
+	WeightGain                  float64 `gorm:"column:weight_gain" json:"weight_gain"`
218
+	PreloadedDewatering         float64 `gorm:"column:preloaded_dewatering" json:"preloaded_dewatering"`
219
+	UltrafiltrationAmount       float64 `gorm:"column:ultrafiltration_amount" json:"ultrafiltration_amount"`
220
+	DialysisInterphase          string  `gorm:"column:dialysis_interphase" json:"dialysis_interphase"`
221
+	LastPostDialysis            string  `gorm:"column:last_post_dialysis" json:"last_post_dialysis"`
222
+	SymptomBeforeDialysis       string  `gorm:"column:symptom_before_dialysis" json:"symptom_before_dialysis"`
223
+	InternalFistula             string  `gorm:"column:internal_fistula" json:"internal_fistula"`
224
+	InternalFistulaSkin         string  `gorm:"column:internal_fistula_skin" json:"internal_fistula_skin"`
225
+	Catheter                    string  `gorm:"column:catheter" json:"catheter"`
226
+	CatheterBend                int     `gorm:"column:catheter_bend" json:"catheter_bend"`
227
+	Complication                string  `gorm:"column:complication" json:"complication"`
228
+	Evaluator                   int64   `gorm:"column:evaluator" json:"evaluator"`
229
+	Creater                     int64   `gorm:"column:creater" json:"creater"`
230
+	Remark                      string  `gorm:"column:remark" json:"remark"`
231
+	Status                      int64   `gorm:"column:status" json:"status"`
232
+	CreatedTime                 int64   `gorm:"column:created_time" json:"created_time"`
233
+	UpdatedTime                 int64   `gorm:"column:updated_time" json:"updated_time"`
234
+	Modifier                    int64   `gorm:"column:modifier" json:"modifier"`
235
+	BloodAccessPartId           int64   `gorm:"column:blood_access_part_id" json:"blood_access_part_id"`
236
+	BloodAccessPartOperaId      int64   `gorm:"column:blood_access_part_opera_id" json:"blood_access_part_opera_id"`
237
+	IsHemorrhage                int64   `gorm:"column:is_hemorrhage" json:"is_hemorrhage"`
238
+	Hemorrhage                  string  `gorm:"column:hemorrhage" json:"hemorrhage"`
239
+	HemorrhageOther             string  `gorm:"column:hemorrhage_other" json:"hemorrhage_other"`
240
+	PunctureMethod              string  `gorm:"column:puncture_method" json:"puncture_method"`
241
+	BloodAccessInternalFistula  string  `gorm:"column:blood_access_internal_fistula" json:"blood_access_internal_fistula"`
242
+	InternalFistulaOther        string  `gorm:"column:internal_fistula_other" json:"internal_fistula_other"`
243
+
244
+	BloodAccessNoise               int64   `gorm:"column:blood_access_noise" json:"blood_access_noise"`
245
+	PunctureWay                    int64   `gorm:"column:puncture_way" json:"puncture_way"`
246
+	VenousCatheterization          int64   `gorm:"column:venous_catheterization" json:"venous_catheterization"`
247
+	VenousCatheterizationPart      int64   `gorm:"column:venous_catheterization_part" json:"venous_catheterization_part"`
248
+	VenousCatheterizationPartOther string  `gorm:"column:venous_catheterization_part_other" json:"venous_catheterization_part_other"`
249
+	DuctusArantii                  string  `gorm:"column:ductus_arantii" json:"ductus_arantii"`
250
+	EmergencyTreatment             int64   `gorm:"column:emergency_treatment" json:"emergency_treatment"`
251
+	EmergencyTreatmentOther        string  `gorm:"column:emergency_treatment_other" json:"emergency_treatment_other"`
252
+	DialysisCount                  int64   `gorm:"column:dialysis_count" json:"dialysis_count"`
253
+	AssessmentDoctor               int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
254
+	AssessmentTime                 int64   `gorm:"column:assessment_time" json:"assessment_time"`
255
+	MachineType                    string  `gorm:"column:machine_type" json:"machine_type"`
256
+	IsInfect                       int64   `gorm:"column:is_infect" json:"is_infect"`
257
+	Exposed                        float64 `gorm:"column:exposed" json:"exposed"`
258
+	Skin                           int64   `gorm:"column:skin" json:"skin"`
259
+	SkinOther                      string  `gorm:"column:skin_other" json:"skin_other"`
260
+	InfectOther                    string  `gorm:"column:infect_other" json:"infect_other"`
261
+	DuctusArantiiOther             string  `gorm:"column:ductus_arantii_other" json:"ductus_arantii_other"`
262
+	PunctureNeedle                 string  `gorm:"column:puncture_needle" json:"puncture_needle"`
263
+	LastPostDialysisOther          string  `gorm:"column:last_post_dialysis_other" json:"last_post_dialysis_other"`
264
+	SymptomBeforeDialysisOther     string  `gorm:"column:symptom_before_dialysis_other" json:"symptom_before_dialysis_other"`
265
+	DialysisInterphaseOther        string  `gorm:"column:dialysis_interphase_other" json:"dialysis_interphase_other"`
266
+}
267
+
268
+func (PredialysisEvaluation) TableName() string {
269
+	return "xt_assessment_before_dislysis"
270
+}
271
+
272
+type PredialysisEvaluationList struct {
273
+	ID                          int64   `gorm:"column:id" json:"id"`
274
+	UserOrgId                   int64   `gorm:"column:user_org_id" json:"user_org_id"`
275
+	PatientId                   int64   `gorm:"column:patient_id" json:"patient_id"`
276
+	AssessmentDate              int64   `gorm:"column:assessment_date" json:"assessment_date"`
277
+	DialysisOrderId             int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
278
+	DryWeight                   float64 `gorm:"column:dry_weight" json:"dry_weight"`
279
+	WeightAfterLastTransparency float64 `gorm:"column:weight_after_last_transparency" json:"weight_after_last_transparency"`
280
+	WeighingWay                 string  `gorm:"column:weighing_way" json:"weighing_way"`
281
+	WeighingBefore              float64 `gorm:"column:weighing_before" json:"weighing_before"`
282
+	AdditionalWeight            float64 `gorm:"column:additional_weight" json:"additional_weight"`
283
+	WeightBefore                float64 `gorm:"column:weight_before" json:"weight_before"`
284
+	Evaluator                   int64   `gorm:"column:evaluator" json:"evaluator"`
285
+	Creater                     int64   `gorm:"column:creater" json:"creater"`
286
+}
287
+
288
+func (PredialysisEvaluationList) TableName() string {
289
+	return "xt_assessment_before_dislysis"
290
+}
291
+
292
+//更改的地方
293
+type DoctorAdvices struct {
294
+	ID                    int64           `gorm:"column:id" json:"id" form:"id"`
295
+	GroupNo               int64           `gorm:"column:groupno" json:"groupno" form:"groupno"`
296
+	UserOrgId             int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
297
+	PatientId             int64           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
298
+	AdviceType            int64           `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
299
+	AdviceDate            int64           `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
300
+	StartTime             int64           `gorm:"column:start_time" json:"start_time" form:"start_time"`
301
+	AdviceName            string          `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
302
+	AdviceDesc            string          `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
303
+	ReminderDate          int64           `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
304
+	SingleDose            float64         `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
305
+	SingleDoseUnit        string          `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
306
+	DrugSpec              float64         `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
307
+	DrugSpecUnit          string          `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
308
+	PrescribingNumber     float64         `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
309
+	PrescribingNumberUnit string          `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
310
+	DeliveryWay           string          `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
311
+	ExecutionFrequency    string          `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
312
+	AdviceDoctor          int64           `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
313
+	Status                int64           `gorm:"column:status" json:"status" form:"status"`
314
+	CreatedTime           int64           `gorm:"column:created_time" json:"created_time" form:"created_time"`
315
+	UpdatedTime           int64           `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
316
+	AdviceAffirm          string          `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
317
+	Remark                string          `gorm:"column:remark" json:"remark" form:"remark"`
318
+	StopTime              int64           `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
319
+	StopReason            string          `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
320
+	StopDoctor            int64           `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
321
+	StopState             int64           `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
322
+	ParentId              int64           `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
323
+	ExecutionTime         int64           `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
324
+	ExecutionStaff        int64           `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
325
+	ExecutionState        int64           `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
326
+	Checker               int64           `gorm:"column:checker" json:"checker" form:"checker"`
327
+	RecordDate            int64           `gorm:"column:record_date" json:"record_date"`
328
+	DialysisOrderId       int64           `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
329
+	CheckTime             int64           `gorm:"column:check_time" json:"check_time" form:"check_time"`
330
+	CheckState            int64           `gorm:"column:check_state" json:"check_state" form:"check_state"`
331
+	AdviceId              int64           `gorm:"-"`
332
+	RemindType            int64           `gorm:"column:remind_type" json:"remind_type"`
333
+	FrequencyType         int64           `gorm:"column:frequency_type" json:"frequency_type"`
334
+	DayCount              int64           `gorm:"column:day_count" json:"day_count"`
335
+	WeekDay               string          `gorm:"column:week_day" json:"week_day"`
336
+	ChildDoctorAdvice     []*DoctorAdvice `gorm:"ForeignKey:ParentId;AssociationForeignKey:ID" json:"child"`
337
+	TemplateId            string          `gorm:"column:template_id" json:"template_id"`
338
+	UserName              string          `gorm:"column:user_name" json:"user_name" form:"user_name"`
339
+}
340
+
341
+type DoctorAdvice struct {
342
+	ID                    int64           `gorm:"column:id" json:"id" form:"id"`
343
+	GroupNo               int64           `gorm:"column:groupno" json:"groupno" form:"groupno"`
344
+	UserOrgId             int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
345
+	PatientId             int64           `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
346
+	AdviceType            int64           `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
347
+	AdviceDate            int64           `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
348
+	StartTime             int64           `gorm:"column:start_time" json:"start_time" form:"start_time"`
349
+	AdviceName            string          `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
350
+	AdviceDesc            string          `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
351
+	ReminderDate          int64           `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
352
+	SingleDose            float64         `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
353
+	SingleDoseUnit        string          `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
354
+	DrugSpec              float64         `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
355
+	DrugSpecUnit          string          `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
356
+	PrescribingNumber     float64         `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
357
+	PrescribingNumberUnit string          `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
358
+	DeliveryWay           string          `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
359
+	ExecutionFrequency    string          `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
360
+	AdviceDoctor          int64           `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
361
+	Status                int64           `gorm:"column:status" json:"status" form:"status"`
362
+	CreatedTime           int64           `gorm:"column:created_time" json:"created_time" form:"created_time"`
363
+	UpdatedTime           int64           `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
364
+	AdviceAffirm          string          `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
365
+	Remark                string          `gorm:"column:remark" json:"remark" form:"remark"`
366
+	StopTime              int64           `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
367
+	StopReason            string          `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
368
+	StopDoctor            int64           `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
369
+	StopState             int64           `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
370
+	ParentId              int64           `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
371
+	ExecutionTime         int64           `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
372
+	ExecutionStaff        int64           `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
373
+	ExecutionState        int64           `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
374
+	Checker               int64           `gorm:"column:checker" json:"checker" form:"checker"`
375
+	RecordDate            int64           `gorm:"column:record_date" json:"record_date"`
376
+	DialysisOrderId       int64           `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
377
+	CheckTime             int64           `gorm:"column:check_time" json:"check_time" form:"check_time"`
378
+	CheckState            int64           `gorm:"column:check_state" json:"check_state" form:"check_state"`
379
+	AdviceId              int64           `gorm:"-"`
380
+	RemindType            int64           `gorm:"column:remind_type" json:"remind_type"`
381
+	FrequencyType         int64           `gorm:"column:frequency_type" json:"frequency_type"`
382
+	DayCount              int64           `gorm:"column:day_count" json:"day_count"`
383
+	WeekDay               string          `gorm:"column:week_day" json:"week_day"`
384
+	ChildDoctorAdvice     []*DoctorAdvice `gorm:"ForeignKey:ParentId;AssociationForeignKey:ID" json:"child"`
385
+	TemplateId            string          `gorm:"column:template_id" json:"template_id"`
386
+	Modifier              int64           `gorm:"column:modifier" json:"modifier" form:"modifier"`
387
+}
388
+
389
+func (DoctorAdvice) TableName() string {
390
+	return "xt_doctor_advice"
391
+}
392
+
393
+type XtDoctorAdvice struct {
394
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
395
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
396
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
397
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
398
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
399
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
400
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
401
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
402
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
403
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
404
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
405
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
406
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
407
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
408
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
409
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
410
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
411
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
412
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
413
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
414
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
415
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
416
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
417
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
418
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
419
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
420
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
421
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
422
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
423
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
424
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
425
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
426
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
427
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
428
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
429
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
430
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
431
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
432
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
433
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
434
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
435
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
436
+	UserName              string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
437
+	CheckerName           string  `gorm:"column:user_name" json:"name" form:"name"`
438
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
439
+}
440
+
441
+func (XtDoctorAdvice) TableName() string {
442
+	return "xt_doctor_advice"
443
+}
444
+
445
+type GroupAdvice struct {
446
+	DoctorAdvice
447
+	Children []*GroupAdvice
448
+}
449
+
450
+func (GroupAdvice) TableName() string {
451
+	return "xt_doctor_advice"
452
+}
453
+
454
+type DoubleCheck struct {
455
+	ID                         int64  `gorm:"column:id" json:"id"`
456
+	UserOrgId                  int64  `gorm:"column:user_org_id" json:"user_org_id"`
457
+	PatientId                  int64  `gorm:"column:patient_id" json:"patient_id"`
458
+	DialysisOrderId            int64  `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
459
+	CheckDate                  int64  `gorm:"column:check_date" json:"check_date"`
460
+	DialysisItemCheck          int64  `gorm:"column:dialysis_item_check" json:"dialysis_item_check"`
461
+	DialysisItemDesc           string `gorm:"column:dialysis_item_desc" json:"dialysis_item_desc"`
462
+	DialysisParameterCheck     int64  `gorm:"column:dialysis_parameter_check" json:"dialysis_parameter_check"`
463
+	DialysisParameterDesc      string `gorm:"column:dialysis_parameter_desc" json:"dialysis_parameter_desc"`
464
+	VascularAccessVerification int64  `gorm:"column:vascular_access_verification" json:"vascular_access_verification"`
465
+	VascularAccessDesc         string `gorm:"column:vascular_access_desc" json:"vascular_access_desc"`
466
+	PipelineConnectionCheck    int64  `gorm:"column:pipeline_connection_check" json:"pipeline_connection_check"`
467
+	PipelineConnectionDesc     string `gorm:"column:pipeline_connection_desc" json:"pipeline_connection_desc"`
468
+	Collator                   int64  `gorm:"column:collator" json:"collator"`
469
+	Status                     int64  `gorm:"column:status" json:"status"`
470
+	CreatedTime                int64  `gorm:"column:created_time" json:"created_time"`
471
+	UpdatedTime                int64  `gorm:"column:updated_time" json:"updated_time"`
472
+	Creater                    int64  `gorm:"column:creater" json:"creater"`
473
+	Modifier                   int64  `gorm:"column:modifier" json:"modifier"`
474
+	CheckTime                  int64  `gorm:"column:check_time" json:"check_time"`
475
+	FirstCheckTime             int64  `gorm:"column:first_check_time" json:"first_check_time"`
476
+}
477
+
478
+func (DoubleCheck) TableName() string {
479
+	return "xt_double_check"
480
+}
481
+
482
+type AssessmentAfterDislysis struct {
483
+	ID                     int64   `gorm:"column:id" json:"id"`
484
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id"`
485
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id"`
486
+	AssessmentDate         int64   `gorm:"column:assessment_date" json:"assessment_date"`
487
+	DialysisOrderId        int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
488
+	Temperature            float64 `gorm:"column:temperature" json:"temperature"`
489
+	PulseFrequency         float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
490
+	BreathingRate          float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
491
+	SystolicBloodPressure  float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
492
+	DiastolicBloodPressure float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
493
+	BloodPressureType      int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
494
+	ActualUltrafiltration  float64 `gorm:"column:actual_ultrafiltration" json:"actual_ultrafiltration"`
495
+	ActualDisplacement     float64 `gorm:"column:actual_displacement" json:"actual_displacement"`
496
+	ActualTreatmentHour    int64   `gorm:"column:actual_treatment_hour" json:"actual_treatment_hour"`
497
+	ActualTreatmentMinute  int64   `gorm:"column:actual_treatment_minute" json:"actual_treatment_minute"`
498
+	WeighingWay            string  `gorm:"column:weighing_way" json:"weighing_way"`
499
+	WeightAfter            float64 `gorm:"column:weight_after" json:"weight_after"`
500
+	AdditionalWeight       float64 `gorm:"column:additional_weight" json:"additional_weight"`
501
+	WeightLoss             float64 `gorm:"column:weight_loss" json:"weight_loss"`
502
+	Cruor                  string  `gorm:"column:cruor" json:"cruor"`
503
+	SymptomAfterDialysis   string  `gorm:"column:symptom_after_dialysis" json:"symptom_after_dialysis"`
504
+	InternalFistula        string  `gorm:"column:internal_fistula" json:"internal_fistula"`
505
+	// InternalFistulaSkin             string  `gorm:"column:internal_fistula_skin" json:"internal_fistula_skin"`
506
+	Catheter string `gorm:"column:catheter" json:"catheter"`
507
+	// CatheterBend                    int     `gorm:"column:catheter_bend" json:"catheter_bend"`
508
+	Complication                    string  `gorm:"column:complication" json:"complication"`
509
+	Evaluator                       int64   `gorm:"column:evaluator" json:"evaluator"`
510
+	Remark                          string  `gorm:"column:remark" json:"remark"`
511
+	DialysisIntakes                 int64   `gorm:"column:dialysis_intakes" json:"dialysis_intakes"`
512
+	DialysisIntakesFeed             int64   `gorm:"column:dialysis_intakes_feed" json:"dialysis_intakes_feed"`
513
+	DialysisIntakesTransfusion      int64   `gorm:"column:dialysis_intakes_transfusion" json:"dialysis_intakes_transfusion"`
514
+	DialysisIntakesBloodTransfusion int64   `gorm:"column:dialysis_intakes_blood_transfusion" json:"dialysis_intakes_blood_transfusion"`
515
+	DialysisIntakesWashpipe         int64   `gorm:"column:dialysis_intakes_washpipe" json:"dialysis_intakes_washpipe"`
516
+	Status                          int64   `gorm:"column:status" json:"status"`
517
+	CreatedTime                     int64   `gorm:"column:created_time" json:"created_time"`
518
+	UpdatedTime                     int64   `gorm:"column:updated_time" json:"updated_time"`
519
+	Creater                         int64   `gorm:"column:creater" json:"creater"`
520
+	Modifier                        int64   `gorm:"column:modifier" json:"modifier"`
521
+	BloodAccessPartId               int64   `gorm:"column:blood_access_part_id" json:"blood_access_part_id"`
522
+	BloodAccessPartOperaId          int64   `gorm:"column:blood_access_part_opera_id" json:"blood_access_part_opera_id"`
523
+	PuncturePointOozingBlood        int64   `gorm:"column:puncture_point_oozing_blood" json:"puncture_point_oozing_blood"`
524
+	PuncturePointHaematoma          int64   `gorm:"column:puncture_point_haematoma" json:"puncture_point_haematoma"`
525
+	InternalFistulaTremorAc         int64   `gorm:"column:internal_fistula_tremor_ac" json:"internal_fistula_tremor_ac"`
526
+	PatientGose                     int64   `gorm:"column:patient_gose" json:"patient_gose"`
527
+	InpatientDepartment             string  `gorm:"column:inpatient_department" json:"inpatient_department"`
528
+	ObservationContent              string  `gorm:"column:observation_content" json:"observation_content"`
529
+	ObservationContentOther         string  `gorm:"column:observation_content_other" json:"observation_content_other"`
530
+	DryWeight                       float64 `gorm:"column:dry_weight" json:"dry_weight"`
531
+	DialysisProcess                 int64   `gorm:"column:dialysis_process" json:"dialysis_process"`
532
+	InAdvanceMinute                 float64 `gorm:"column:in_advance_minute" json:"in_advance_minute"`
533
+	InAdvanceReason                 string  `gorm:"column:in_advance_reason" json:"in_advance_reason"`
534
+	HemostasisMinute                int64   `gorm:"column:hemostasis_minute" json:"hemostasis_minute"`
535
+	HemostasisOpera                 int64   `gorm:"column:hemostasis_opera" json:"hemostasis_opera"`
536
+	TremorNoise                     int64   `gorm:"column:tremor_noise" json:"tremor_noise"`
537
+	DisequilibriumSyndrome          int64   `gorm:"column:disequilibrium_syndrome" json:"disequilibrium_syndrome"`
538
+	DisequilibriumSyndromeOption    string  `gorm:"column:disequilibrium_syndrome_option" json:"disequilibrium_syndrome_option"`
539
+	ArterialTube                    int64   `gorm:"column:arterial_tube" json:"arterial_tube"`
540
+	IntravenousTube                 int64   `gorm:"column:intravenous_tube" json:"intravenous_tube"`
541
+	Dialyzer                        int64   `gorm:"column:dialyzer" json:"dialyzer"`
542
+	InAdvanceReasonOther            string  `gorm:"column:in_advance_reason_other" json:"in_advance_reason_other"`
543
+	AssessmentTime                  int64   `gorm:"column:assessment_time" json:"assessment_time"`
544
+	AssessmentDoctor                int64   `gorm:"column:assessment_doctor" json:"assessment_doctor"`
545
+	IsEat                           int64   `gorm:"column:is_eat" json:"is_eat"`
546
+	DialysisIntakesUnit             int64   `gorm:"column:dialysis_intakes_unit" json:"dialysis_intakes_unit"`
547
+}
548
+
549
+func (AssessmentAfterDislysis) TableName() string {
550
+	return "xt_assessment_after_dislysis"
551
+}
552
+
553
+type TreatmentSummary struct {
554
+	ID                int64  `gorm:"column:id" json:"id"`
555
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id"`
556
+	PatientId         int64  `gorm:"column:patient_id" json:"patient_id"`
557
+	AssessmentDate    int64  `gorm:"column:assessment_date" json:"assessment_date"`
558
+	DialysisOrderId   int64  `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
559
+	Mission           string `gorm:"column:mission" json:"mission"`
560
+	DialysisSummary   string `gorm:"column:dialysis_summary" json:"dialysis_summary"`
561
+	Change            int64  `gorm:"column:change" json:"change"`
562
+	SjNurse           int64  `gorm:"column:sj_nurse" json:"sj_nurse"`
563
+	ZlNurse           int64  `gorm:"column:zl_nurse" json:"zl_nurse"`
564
+	HdNurse           int64  `gorm:"column:hd_nurse" json:"hd_nurse"`
565
+	XjNurse           int64  `gorm:"column:xj_nurse" json:"xj_nurse"`
566
+	ZlDoctor          int64  `gorm:"column:zl_doctor" json:"zl_doctor"`
567
+	ChannelImage      string `gorm:"column:channel_image" json:"channel_image"`
568
+	Puncture          string `gorm:"column:puncture" json:"puncture"`
569
+	PunctureNeedle    string `gorm:"column:puncture_needle" json:"puncture_needle"`
570
+	PunctureDirection string `gorm:"column:puncture_direction" json:"puncture_direction"`
571
+	Status            int64  `gorm:"column:status" json:"status"`
572
+	CreatedTime       int64  `gorm:"column:created_time" json:"created_time"`
573
+	UpdatedTime       int64  `gorm:"column:updated_time" json:"updated_time"`
574
+	Creater           int64  `gorm:"column:creater" json:"creater"`
575
+	Modifier          int64  `gorm:"column:modifier" json:"modifier"`
576
+}
577
+
578
+func (TreatmentSummary) TableName() string {
579
+	return "xt_treatment_summary"
580
+}
581
+
582
+type DryWeightAdjust struct {
583
+	ID            int64   `gorm:"column:id" json:"id" form:"id"`
584
+	UserOrgId     int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
585
+	PatientId     int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
586
+	Weight        float64 `gorm:"column:weight" json:"weight" form:"weight"`
587
+	AdjustedValue float64 `gorm:"column:adjusted_value" json:"adjusted_value" form:"adjusted_value"`
588
+	Doctor        int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
589
+	RegistrarsId  int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
590
+	Remark        string  `gorm:"column:remark" json:"remark" form:"remark"`
591
+	Status        int64   `gorm:"column:status" json:"status" form:"status"`
592
+	CreatedTime   int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
593
+	UpdatedTime   int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
594
+}
595
+
596
+func (DryWeightAdjust) TableName() string {
597
+	return "xt_dry_weight_adjust"
598
+}
599
+
600
+type MonitoringRecord struct {
601
+	ID                        int64   `gorm:"column:id" json:"id"`
602
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id"`
603
+	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id"`
604
+	DialysisOrderId           int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id"`
605
+	MonitoringDate            int64   `gorm:"column:monitoring_date" json:"monitoring_date"`
606
+	OperateTime               int64   `gorm:"column:operate_time" json:"operate_time"`
607
+	MonitoringTime            string  `gorm:"column:monitoring_time" json:"monitoring_time"`
608
+	PulseFrequency            float64 `gorm:"column:pulse_frequency" json:"pulse_frequency"`
609
+	BreathingRate             float64 `gorm:"column:breathing_rate" json:"breathing_rate"`
610
+	SystolicBloodPressure     float64 `gorm:"column:systolic_blood_pressure" json:"systolic_blood_pressure"`
611
+	DiastolicBloodPressure    float64 `gorm:"column:diastolic_blood_pressure" json:"diastolic_blood_pressure"`
612
+	BloodPressureType         int64   `gorm:"column:blood_pressure_type" json:"blood_pressure_type"`
613
+	Pic                       string  `gorm:"column:pic" json:"pic"`
614
+	BloodFlowVolume           float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
615
+	VenousPressure            float64 `gorm:"column:venous_pressure" json:"venous_pressure"`
616
+	VenousPressureUnit        string  `gorm:"column:venous_pressure_unit" json:"venous_pressure_unit"`
617
+	ArterialPressure          float64 `gorm:"column:arterial_pressure" json:"arterial_pressure"`
618
+	TransmembranePressure     float64 `gorm:"column:transmembrane_pressure" json:"transmembrane_pressure"`
619
+	TransmembranePressureUnit string  `gorm:"column:transmembrane_pressure_unit" json:"transmembrane_pressure_unit"`
620
+	UltrafiltrationRate       float64 `gorm:"column:ultrafiltration_rate" json:"ultrafiltration_rate"`
621
+	UltrafiltrationVolume     float64 `gorm:"column:ultrafiltration_volume" json:"ultrafiltration_volume"`
622
+	SodiumConcentration       float64 `gorm:"column:sodium_concentration" json:"sodium_concentration"`
623
+	DialysateTemperature      float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
624
+	Temperature               float64 `gorm:"column:temperature" json:"temperature"`
625
+	ReplacementRate           float64 `gorm:"column:replacement_rate" json:"replacement_rate"`
626
+	DisplacementQuantity      float64 `gorm:"column:displacement_quantity" json:"displacement_quantity"`
627
+	Ktv                       float64 `gorm:"column:ktv" json:"ktv"`
628
+	Symptom                   string  `gorm:"column:symptom" json:"symptom"`
629
+	Dispose                   string  `gorm:"column:dispose" json:"dispose"`
630
+	Result                    string  `gorm:"column:result" json:"result"`
631
+	MonitoringNurse           int64   `gorm:"column:monitoring_nurse" json:"monitoring_nurse"`
632
+	Status                    int64   `gorm:"column:status" json:"status"`
633
+	CreatedTime               int64   `gorm:"column:created_time" json:"created_time"`
634
+	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time"`
635
+	Conductivity              float64 `gorm:"column:conductivity" json:"conductivity"`
636
+	DisplacementFlowQuantity  float64 `gorm:"column:displacement_flow_quantity" json:"displacement_flow_quantity"`
637
+	BloodOxygenSaturation     string  `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
638
+}
639
+
640
+func (MonitoringRecord) TableName() string {
641
+	return "xt_monitoring_record"
642
+}
643
+
644
+type DialysisOrders struct {
645
+	ID             int64        `gorm:"column:id" json:"id"`
646
+	DialysisDate   int64        `gorm:"column:dialysis_date" json:"dialysis_date"`
647
+	UserOrgId      int64        `gorm:"column:user_org_id" json:"user_org_id"`
648
+	PatientId      int64        `gorm:"column:patient_id" json:"patient_id"`
649
+	PrescriptionId int64        `gorm:"column:prescription_id" json:"prescription_id"`
650
+	Stage          int64        `gorm:"column:stage" json:"stage"`
651
+	Remark         string       `gorm:"column:remark" json:"remark"`
652
+	BedID          int64        `gorm:"column:bed_id" json:"bed_id"`
653
+	StartNurse     int64        `gorm:"column:start_nurse" json:"start_nurse"`
654
+	FinishNurse    int64        `gorm:"column:finish_nurse" json:"finish_nurse"`
655
+	Status         int64        `gorm:"column:status" json:"status"`
656
+	CreatedTime    int64        `gorm:"column:created_time" json:"created_time"`
657
+	UpdatedTime    int64        `gorm:"column:updated_time" json:"updated_time"`
658
+	DeviceNumber   DeviceNumber `gorm:"ForeignKey:BedID"`
659
+	StartTime      int64        `gorm:"column:start_time" json:"start_time"`
660
+	EndTime        int64        `gorm:"column:end_time" json:"end_time"`
661
+	PunctureNurse  int64        `gorm:"column:puncture_nurse" json:"puncture_nurse"`
662
+	Creator        int64        `gorm:"column:creator" json:"creator"`
663
+	Modifier       int64        `gorm:"column:modifier" json:"modifier"`
664
+	FinishCreator  int64        `gorm:"column:finish_creator" json:"finish_creator"`
665
+	FinishModifier int64        `gorm:"column:finish_modifier" json:"finish_modifier"`
666
+	SchedualType   int64        `gorm:"column:schedual_type" json:"schedual_type"`
667
+	Name           int64        `gorm:"column:name" json:"name"`
668
+	Number         string       `gorm:"column:number" json:"number"`
669
+}
670
+
671
+type DialysisOrder struct {
672
+	ID             int64         `gorm:"column:id" json:"id"`
673
+	DialysisDate   int64         `gorm:"column:dialysis_date" json:"dialysis_date"`
674
+	UserOrgId      int64         `gorm:"column:user_org_id" json:"user_org_id"`
675
+	PatientId      int64         `gorm:"column:patient_id" json:"patient_id"`
676
+	PrescriptionId int64         `gorm:"column:prescription_id" json:"prescription_id"`
677
+	Stage          int64         `gorm:"column:stage" json:"stage"`
678
+	Remark         string        `gorm:"column:remark" json:"remark"`
679
+	BedID          int64         `gorm:"column:bed_id" json:"bed_id"`
680
+	StartNurse     int64         `gorm:"column:start_nurse" json:"start_nurse"`
681
+	FinishNurse    int64         `gorm:"column:finish_nurse" json:"finish_nurse"`
682
+	Status         int64         `gorm:"column:status" json:"status"`
683
+	CreatedTime    int64         `gorm:"column:created_time" json:"created_time"`
684
+	UpdatedTime    int64         `gorm:"column:updated_time" json:"updated_time"`
685
+	DeviceNumber   DeviceNumber  `gorm:"ForeignKey:BedID"`
686
+	StartTime      int64         `gorm:"column:start_time" json:"start_time"`
687
+	EndTime        int64         `gorm:"column:end_time" json:"end_time"`
688
+	PunctureNurse  int64         `gorm:"column:puncture_nurse" json:"puncture_nurse"`
689
+	Creator        int64         `gorm:"column:creator" json:"creator"`
690
+	Modifier       int64         `gorm:"column:modifier" json:"modifier"`
691
+	FinishCreator  int64         `gorm:"column:finish_creator" json:"finish_creator"`
692
+	FinishModifier int64         `gorm:"column:finish_modifier" json:"finish_modifier"`
693
+	SchedualType   int64         `gorm:"column:schedual_type" json:"schedual_type"`
694
+	UserAdminRole  UserAdminRole `json:"role" gorm:"foreignkey:AdminUserId;AssociationForeignKey:StartNurse;"`
695
+}
696
+
697
+func (DialysisOrder) TableName() string {
698
+	return "xt_dialysis_order"
699
+}
700
+
701
+type XtDialysisOrder struct {
702
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
703
+	DialysisDate   int64  `gorm:"column:dialysis_date" json:"dialysis_date" form:"dialysis_date"`
704
+	UserOrgId      int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
705
+	PatientId      int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
706
+	PrescriptionId int64  `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
707
+	Stage          int64  `gorm:"column:stage" json:"stage" form:"stage"`
708
+	Remark         string `gorm:"column:remark" json:"remark" form:"remark"`
709
+	BedId          int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
710
+	StartNurse     int64  `gorm:"column:start_nurse" json:"start_nurse" form:"start_nurse"`
711
+	FinishNurse    int64  `gorm:"column:finish_nurse" json:"finish_nurse" form:"finish_nurse"`
712
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
713
+	CreatedTime    int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
714
+	UpdatedTime    int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
715
+	StartTime      int64  `gorm:"column:start_time" json:"start_time" form:"start_time"`
716
+	EndTime        int64  `gorm:"column:end_time" json:"end_time" form:"end_time"`
717
+	PunctureNurse  int64  `gorm:"column:puncture_nurse" json:"puncture_nurse" form:"puncture_nurse"`
718
+	Creator        int64  `gorm:"column:creator" json:"creator" form:"creator"`
719
+	Modifier       int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
720
+	FinishCreator  int64  `gorm:"column:finish_creator" json:"finish_creator" form:"finish_creator"`
721
+	FinishModifier int64  `gorm:"column:finish_modifier" json:"finish_modifier" form:"finish_modifier"`
722
+	SchedualType   int64  `gorm:"column:schedual_type" json:"schedual_type" form:"schedual_type"`
723
+	Number         int64  `gorm:"column:number" json:"number" form:"number"`
724
+	UserName       int64  `gorm:"column:user_name" json:"user_name" form:"user_name"`
725
+}
726
+
727
+func (XtDialysisOrder) TableName() string {
728
+	return "xt_dialysis_order"
729
+}
730
+
731
+type TreatmentMode struct {
732
+	ID                  int64  `gorm:"column:id" json:"id" form:"id"`
733
+	Name                string `gorm:"column:name" json:"name" form:"name"`
734
+	DialysisDuration    int64  `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
735
+	ReplacementWay      int64  `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
736
+	HemodialysisMachine int64  `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
737
+	BloodFilter         int64  `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
738
+	PerfusionApparatus  int64  `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
739
+	BloodFlowVolume     int64  `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
740
+	DialysateFlow       int64  `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
741
+	Kalium              int64  `gorm:"column:kalium" json:"kalium" form:"kalium"`
742
+	Sodium              int64  `gorm:"column:sodium" json:"sodium" form:"sodium"`
743
+	Calcium             int64  `gorm:"column:calcium" json:"calcium" form:"calcium"`
744
+	Bicarbonate         int64  `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
745
+	Remark              string `gorm:"column:remark" json:"remark" form:"remark"`
746
+	Status              int64  `gorm:"column:status" json:"status" form:"status"`
747
+	CreatedTime         int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
748
+	UpdatedTime         int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
749
+}
750
+
751
+func (TreatmentMode) TableName() string {
752
+	return "xt_treatment_mode"
753
+}
754
+
755
+type ReceiveTreatmentAsses struct {
756
+	ID                           int64  `gorm:"column:id" json:"id"`
757
+	Way                          int64  `gorm:"column:way" json:"way"`
758
+	Consciousness                int64  `gorm:"column:consciousness" json:"consciousness"`
759
+	Appetite                     int64  `gorm:"column:appetite" json:"appetite"`
760
+	Condition                    int64  `gorm:"column:condition" json:"condition"`
761
+	Creater                      int64  `gorm:"column:creater" json:"creater"`
762
+	Posture                      int64  `gorm:"column:posture" json:"posture"`
763
+	CreatedTime                  int64  `gorm:"column:created_time" json:"created_time"`
764
+	UpdateTime                   int64  `gorm:"column:update_time" json:"update_time"`
765
+	RecordId                     int64  `gorm:"column:record_id" json:"record_id"`
766
+	RecordDate                   int64  `gorm:"column:record_date" json:"record_date"`
767
+	Modifier                     int64  `gorm:"column:modifier" json:"modifier"`
768
+	Status                       int64  `gorm:"column:status" json:"status"`
769
+	UserOrgId                    int64  `gorm:"column:user_org_id" json:"user_org_id"`
770
+	PatientId                    int64  `gorm:"column:patient_id" json:"patient_id"`
771
+	SickCondition                int64  `gorm:"column:sick_condition" json:"sick_condition"`
772
+	DangerLevel                  int64  `gorm:"column:danger_level" json:"danger_level"`
773
+	Intake                       int64  `gorm:"column:intake" json:"intake"`
774
+	Nutrition                    int64  `gorm:"column:nutrition" json:"nutrition"`
775
+	PsychologicalAssessment      int64  `gorm:"column:psychological_assessment" json:"psychological_assessment"`
776
+	PsychologicalAssessmentOther string `gorm:"column:psychological_assessment_other" json:"psychological_assessment_other"`
777
+	Score                        string `gorm:"column:score" json:"score"`
778
+	SickConditionOther           string `gorm:"column:sick_condition_other" json:"sick_condition_other"`
779
+	Precaution                   int64  `gorm:"column:precaution" json:"precaution"`
780
+	PrecautionOther              string `gorm:"column:precaution_other" json:"precaution_other"`
781
+	PsychologicalOther           string `gorm:"column:psychological_other" json:"psychological_other"`
782
+	IsPrecaution                 int64  `gorm:"column:is_precaution" json:"is_precaution"`
783
+	AdmissionNumber              string `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
784
+}
785
+
786
+func (ReceiveTreatmentAsses) TableName() string {
787
+	return "xt_receive_treatment_asses"
788
+}
789
+
790
+type GobalTemplate struct {
791
+	ID         int64 `gorm:"column:id" json:"id"`
792
+	OrgId      int64 `gorm:"column:org_id" json:"org_id"`
793
+	TemplateId int64 `gorm:"column:template_id" json:"template_id"`
794
+	Status     int64 `gorm:"column:status" json:"status"`
795
+	Ctime      int64 `gorm:"column:ctime" json:"ctime"`
796
+	Mtime      int64 `gorm:"column:mtime" json:"mtime"`
797
+}
798
+
799
+func (GobalTemplate) TableName() string {
800
+	return "xt_gobal_template"
801
+}

+ 18 - 0
models/district_models.go View File

@@ -0,0 +1,18 @@
1
+package models
2
+
3
+type District struct {
4
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
5
+	Name      string `gorm:"column:name" json:"name" form:"name"`
6
+	Level     int64  `gorm:"column:level" json:"level" form:"level"`
7
+	Upid      int64  `gorm:"column:upid" json:"upid" form:"upid"`
8
+	Path      string `gorm:"column:path" json:"path" form:"path"`
9
+	Namepath  string `gorm:"column:namepath" json:"namepath" form:"namepath"`
10
+	Initial   string `gorm:"column:initial" json:"initial" form:"initial"`
11
+	Longitude string `gorm:"column:longitude" json:"longitude" form:"longitude"`
12
+	Latitude  string `gorm:"column:latitude" json:"latitude" form:"latitude"`
13
+	Adcode    int64  `gorm:"column:adcode" json:"adcode" form:"adcode"`
14
+}
15
+
16
+func (District) TableName() string {
17
+	return "sgj_user_district"
18
+}

+ 154 - 0
models/doctor_advice_models.go View File

@@ -0,0 +1,154 @@
1
+package models
2
+
3
+type DrugDic struct {
4
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
5
+	Code        string `gorm:"column:code" json:"code" form:"code"`
6
+	Name        string `gorm:"column:name" json:"name" form:"name"`
7
+	Spec        string `gorm:"column:spec" json:"spec" form:"spec"`
8
+	SpecUnit    string `gorm:"column:spec_unit" json:"spec_unit" form:"spec_unit"`
9
+	Form        string `gorm:"column:form" json:"form" form:"form"`
10
+	FormUnit    string `gorm:"column:form_unit" json:"form_unit" form:"form_unit"`
11
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
12
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
13
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
14
+	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
15
+	Creator     int64  `gorm:"column:creator" json:"creator" form:"creator"`
16
+}
17
+
18
+func (DrugDic) TableName() string {
19
+	return "xt_drug_dic"
20
+}
21
+
22
+type DrugwayDic struct {
23
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
24
+	Code        string `gorm:"column:code" json:"code" form:"code"`
25
+	Name        string `gorm:"column:name" json:"name" form:"name"`
26
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
27
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
28
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
29
+	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
30
+	Creator     int64  `gorm:"column:creator" json:"creator" form:"creator"`
31
+}
32
+
33
+func (DrugwayDic) TableName() string {
34
+	return "xt_drugway_dic"
35
+}
36
+
37
+type ExecutionFrequencyDic struct {
38
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
39
+	Code        string `gorm:"column:code" json:"code" form:"code"`
40
+	Name        string `gorm:"column:name" json:"name" form:"name"`
41
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
42
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
43
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
44
+	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
45
+	Creator     int64  `gorm:"column:creator" json:"creator" form:"creator"`
46
+}
47
+
48
+func (ExecutionFrequencyDic) TableName() string {
49
+	return "xt_execution_frequency_dic"
50
+}
51
+
52
+type DoctorAdviceTemplate struct {
53
+	ID                      int64                   `gorm:"column:id" json:"id" form:"id"`
54
+	OrgId                   int64                   `gorm:"column:org_id" json:"org_id" form:"org_id"`
55
+	AdviceName              string                  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
56
+	AdviceDesc              string                  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
57
+	SingleDose              float64                 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
58
+	SingleDoseUnit          string                  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
59
+	PrescribingNumber       float64                 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
60
+	PrescribingNumberUnit   string                  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
61
+	DeliveryWay             string                  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
62
+	ExecutionFrequency      string                  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
63
+	AdviceDoctor            int64                   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
64
+	Status                  int64                   `gorm:"column:status" json:"status" form:"status"`
65
+	CreatedTime             int64                   `gorm:"column:created_time" json:"created_time" form:"created_time"`
66
+	UpdatedTime             int64                   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
67
+	TemplateId              int64                   `gorm:"column:template_id" json:"template_id"`
68
+	DrugSpec                string                  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
69
+	DrugSpecUnit            string                  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
70
+	ParentId                int64                   `gorm:"column:parent_id" json:"parent_id"`
71
+	AdviceType              int64                   `gorm:"column:advice_type" json:"advice_type"`
72
+	DayCount                int64                   `gorm:"column:day_count" json:"day_count"`
73
+	WeekDays                string                  `gorm:"column:week_days" json:"week_days"`
74
+	FrequencyType           int64                   `gorm:"column:frequency_type" json:"frequency_type"`
75
+	SubDoctorAdviceTemplate []*DoctorAdviceTemplate `gorm:"ForeignKey:ParentId;AssociationForeignKey:ID" json:"child"`
76
+}
77
+
78
+func (DoctorAdviceTemplate) TableName() string {
79
+	return "xt_doctor_advice_template"
80
+}
81
+
82
+type DoctorAdviceParentTemplate struct {
83
+	ID                   int64                   `gorm:"column:id" json:"id"`
84
+	OrgId                int64                   `gorm:"column:org_id" json:"org_id"`
85
+	Name                 string                  `gorm:"column:name" json:"name"`
86
+	Status               int64                   `gorm:"column:status" json:"status"`
87
+	CreatedTime          int64                   `gorm:"column:created_time" json:"created_time"`
88
+	UpdatedTime          int64                   `gorm:"column:updated_time" json:"updated_time"`
89
+	DoctorAdviceTemplate []*DoctorAdviceTemplate `gorm:"ForeignKey:TemplateId;AssociationForeignKey:ID"`
90
+	AdviceType           int64                   `gorm:"column:advice_type" json:"advice_type"`
91
+}
92
+
93
+func (DoctorAdviceParentTemplate) TableName() string {
94
+	return "xt_doctor_advice_parent_template"
95
+}
96
+
97
+type VMDoctorAdviceParentTemplate struct {
98
+	ID                   int64                   `gorm:"column:id" json:"id"`
99
+	OrgId                int64                   `gorm:"column:org_id" json:"org_id"`
100
+	Name                 string                  `gorm:"column:name" json:"name"`
101
+	Status               int64                   `gorm:"column:status" json:"status"`
102
+	CreatedTime          int64                   `gorm:"column:created_time" json:"created_time"`
103
+	UpdatedTime          int64                   `gorm:"column:updated_time" json:"updated_time"`
104
+	DoctorAdviceTemplate []*DoctorAdviceTemplate `gorm:"ForeignKey:TemplateId;AssociationForeignKey:ID" json:"advice_template"`
105
+	AdviceType           int64                   `gorm:"column:advice_type" json:"advice_type"`
106
+}
107
+
108
+func (VMDoctorAdviceParentTemplate) TableName() string {
109
+	return "xt_doctor_advice_parent_template"
110
+}
111
+
112
+type AdviceRemind struct {
113
+	ID            int64  `gorm:"column:id" json:"id"`
114
+	UserOrgId     int64  `gorm:"column:user_org_id" json:"user_org_id"`
115
+	PatientId     int64  `gorm:"column:patient_id" json:"patient_id"`
116
+	RemindType    int64  `gorm:"column:remind_type" json:"remind_type"`
117
+	FrequencyType int64  `gorm:"column:frequency_type" json:"frequency_type"`
118
+	DayCount      int64  `gorm:"column:day_count" json:"day_count"`
119
+	WeekDay       string `gorm:"column:week_day" json:"week_day"`
120
+	Ctime         int64  `gorm:"column:ctime" json:"ctime"`
121
+	Mtime         int64  `gorm:"column:mtime" json:"mtime"`
122
+	Status        int64  `gorm:"column:status" json:"status"`
123
+	AdviceDate    int64  `gorm:"column:advice_date" json:"advice_date"`
124
+}
125
+
126
+func (AdviceRemind) TableName() string {
127
+	return "xt_advice_remind"
128
+}
129
+
130
+type AdviceInit struct {
131
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
132
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
133
+	CreateTime int64 `gorm:"column:create_time" json:"create_time" form:"create_time"`
134
+	UpdateTime int64 `gorm:"column:update_time" json:"update_time" form:"update_time"`
135
+	Status     int64 `gorm:"column:status" json:"status" form:"status"`
136
+	IsInit     int64 `gorm:"column:is_init" json:"is_init" form:"is_init"`
137
+}
138
+
139
+func (AdviceInit) TableName() string {
140
+	return "xt_advice_init"
141
+}
142
+
143
+type DoctorAdviceConfig struct {
144
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
145
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
146
+	CreateTime   int64 `gorm:"column:create_time" json:"create_time" form:"create_time"`
147
+	UpdateTime   int64 `gorm:"column:update_time" json:"update_time" form:"update_time"`
148
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
149
+	IsOpenRemind int64 `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
150
+}
151
+
152
+func (DoctorAdviceConfig) TableName() string {
153
+	return "xt_doctor_config"
154
+}

+ 76 - 0
models/gobal_models.go View File

@@ -0,0 +1,76 @@
1
+package models
2
+
3
+type GobalConfig struct {
4
+	ID           int64 `gorm:"column:id" json:"id"`
5
+	OrgId        int64 `gorm:"column:org_id" json:"org_id"`
6
+	IsOpen       int64 `gorm:"column:is_open" json:"is_open"`
7
+	Status       int64 `gorm:"column:status" json:"status"`
8
+	CreateTime   int64 `gorm:"column:create_time" json:"create_time"`
9
+	UpdateTime   int64 `gorm:"column:update_time" json:"update_time"`
10
+	IsOpenRemind int64 `gorm:"column:is_open_remind" json:"is_open_remind"`
11
+}
12
+
13
+func (GobalConfig) TableName() string {
14
+	return "xt_gobal_config"
15
+}
16
+
17
+type SystemPrescription struct {
18
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
19
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
20
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
21
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
22
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
23
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
24
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
25
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
26
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
27
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
28
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
29
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
30
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
31
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
32
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
33
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
34
+	Dewater                    float64 `gorm:"column:dewater" json:"dewater" form:"dewater"`
35
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
36
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
37
+	DryWeight                  float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
38
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
39
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
40
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
41
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
42
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
43
+	Doctor                     int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
44
+	FirstDialysis              int64   `gorm:"column:first_dialysis" json:"first_dialysis" form:"first_dialysis"`
45
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
46
+	InitiateMode               int64   `gorm:"column:initiate_mode" json:"initiate_mode" form:"initiate_mode"`
47
+	AffirmState                int64   `gorm:"column:affirm_state" json:"affirm_state" form:"affirm_state"`
48
+	UseState                   int64   `gorm:"column:use_state" json:"use_state" form:"use_state"`
49
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
50
+	RegistrarsId               int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
51
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
52
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
53
+	SolutionType               int64   `gorm:"column:solution_type" json:"solution_type" form:"solution_type"`
54
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
55
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
56
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
57
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
58
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
59
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
60
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialyzer"`
61
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total" form:"replacement_total"`
62
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
63
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid" form:"body_fluid"`
64
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine" form:"special_medicine"`
65
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other" form:"special_medicine_other"`
66
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part" form:"displace_liqui_part"`
67
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
68
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access" form:"blood_access"`
69
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
70
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
71
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
72
+}
73
+
74
+func (SystemPrescription) TableName() string {
75
+	return "xt_system_prescription"
76
+}

+ 49 - 0
models/good_models.go View File

@@ -0,0 +1,49 @@
1
+package models
2
+
3
+type GoodsType struct {
4
+	ID       int64  `gorm:"column:id" json:"id"`
5
+	TypeCode string `gorm:"column:type_code" json:"type_code"`
6
+	TypeName string `gorm:"column:type_name" json:"type_name"`
7
+	Remark   string `gorm:"column:remark" json:"remark"`
8
+	Ctime    int64  `gorm:"column:ctime" json:"ctime"`
9
+	Mtime    int64  `gorm:"column:mtime" json:"mtime"`
10
+	Creater  int64  `gorm:"column:creater" json:"creater"`
11
+	Modifier int64  `gorm:"column:modifier" json:"modifier"`
12
+	OrgId    int64  `gorm:"column:org_id" json:"org_id"`
13
+	Status   int64  `gorm:"column:status" json:"status"`
14
+	Type     int64  `gorm:"column:type" json:"type"`
15
+}
16
+
17
+func (GoodsType) TableName() string {
18
+	return "xt_goods_type"
19
+}
20
+
21
+type GoodInfo struct {
22
+	ID                     int64     `gorm:"column:id" json:"id"`
23
+	GoodCode               string    `gorm:"column:good_code" json:"good_code"`
24
+	SpecificationName      string    `gorm:"column:specification_name" json:"specification_name"`
25
+	GoodTypeId             int64     `gorm:"column:good_type_id" json:"good_type_id"`
26
+	GoodUnit               int64     `gorm:"column:good_unit" json:"good_unit"`
27
+	BuyPrice               float64   `gorm:"column:buy_price" json:"buy_price"`
28
+	SellPrice              float64   `gorm:"column:sell_price" json:"sell_price"`
29
+	Remark                 string    `gorm:"column:remark" json:"remark"`
30
+	Ctime                  int64     `gorm:"column:ctime" json:"ctime"`
31
+	Mtime                  int64     `gorm:"column:mtime" json:"mtime"`
32
+	Manufacturer           int64     `gorm:"column:manufacturer" json:"manufacturer"`
33
+	Dealer                 int64     `gorm:"column:dealer" json:"dealer"`
34
+	ExpiryDateWarnDayCount int64     `gorm:"column:expiry_date_warn_day_count" json:"expiry_date_warn_day_count"`
35
+	StockWarnCount         int64     `gorm:"column:stock_warn_count" json:"stock_warn_count"`
36
+	IsReuse                int64     `gorm:"column:is_reuse" json:"is_reuse"`
37
+	Status                 int64     `gorm:"column:status" json:"status"`
38
+	FilmArea               string    `gorm:"column:film_area" json:"film_area"`
39
+	IsUse                  int64     `gorm:"column:is_use" json:"is_use"`
40
+	FilmMaterialQuality    string    `gorm:"column:film_material_quality" json:"film_material_quality"`
41
+	OrgId                  int64     `gorm:"column:org_id" json:"org_id"`
42
+	Modifier               int64     `gorm:"column:modifier" json:"modifier"`
43
+	Creater                int64     `gorm:"column:creater" json:"creater"`
44
+	GoodsType              GoodsType `gorm:"ForeignKey:ID;AssociationForeignKey:GoodTypeId" `
45
+}
46
+
47
+func (GoodInfo) TableName() string {
48
+	return "xt_good_information"
49
+}

+ 79 - 0
models/inspection_models.go View File

@@ -0,0 +1,79 @@
1
+package models
2
+
3
+type Inspection struct {
4
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
5
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
6
+	OrgId        int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
7
+	ProjectId    int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
8
+	ItemId       int64  `gorm:"column:item_id" json:"item_id" form:"item_id"`
9
+	ItemName     string `gorm:"column:item_name" json:"item_name" form:"item_name"`
10
+	ProjectName  string `gorm:"column:project_name" json:"project_name" form:"project_name"`
11
+	InspectType  int64  `gorm:"column:inspect_type" json:"inspect_type" form:"inspect_type"`
12
+	InspectValue string `gorm:"column:inspect_value" json:"inspect_value" form:"inspect_value"`
13
+	InspectDate  int64  `gorm:"column:inspect_date" json:"inspect_date" form:"inspect_date"`
14
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
15
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
16
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
17
+}
18
+
19
+func (Inspection) TableName() string {
20
+	return "xt_inspection"
21
+}
22
+
23
+type InspectionReference struct {
24
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
25
+	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
26
+	ProjectName      string `gorm:"column:project_name" json:"project_name" form:"project_name"`
27
+	Project          string `gorm:"column:project" json:"project" form:"project"`
28
+	ProjectId        int64  `gorm:"column:project_id" json:"project_id" form:"project_id"`
29
+	ItemName         string `gorm:"column:item_name" json:"item_name" form:"item_name"`
30
+	ItemNameAddition string `gorm:"column:item_name_addition" json:"item_name_addition" form:"item_name_addition"`
31
+	Item             string `gorm:"column:item" json:"item" form:"item"`
32
+	RangeType        int64  `gorm:"column:range_type" json:"range_type" form:"range_type"`
33
+	RangeMin         string `gorm:"column:range_min" json:"range_min" form:"range_min"`
34
+	RangeMax         string `gorm:"column:range_max" json:"range_max" form:"range_max"`
35
+	RangeValue       string `gorm:"column:range_value" json:"range_value" form:"range_value"`
36
+	RangeOptions     string `gorm:"column:range_options" json:"range_options" form:"range_options"`
37
+	Unit             string `gorm:"column:unit" json:"unit" form:"unit"`
38
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
39
+	CreatedTime      int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
40
+	UpdatedTime      int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
41
+}
42
+
43
+func (InspectionReference) TableName() string {
44
+	return "xt_inspection_reference"
45
+}
46
+
47
+type UserInspectionProjectCount struct {
48
+	PatientId int64
49
+	Count     int64
50
+	ProjectId int64
51
+}
52
+
53
+type InspectionReferenceMap struct {
54
+	ProjectName         string                `gorm:"-" json:"project_name" form:"project_name"`
55
+	Project             string                `gorm:"-" json:"project" form:"project"`
56
+	ProjectId           int64                 `gorm:"-" json:"project_id" form:"project_id"`
57
+	Count               int64                 `gorm:"-" json:"count" form:"count"`
58
+	InspectionReference []InspectionReference `gorm:"-" json:"inspection_reference" form:"inspection_reference"`
59
+}
60
+
61
+type InepectionForm struct {
62
+	Method      string `json:"method"`
63
+	ProjectId   int64  `json:"project_id"`
64
+	InspectDate string `json:"inspect_date"`
65
+	FormItem    []struct {
66
+		ID          int64  `json:"id"`
67
+		ProjectId   int64  `json:"project_id"`
68
+		ProjectName string `json:"project_name"`
69
+		ItemId      int64  `json:"item_id"`
70
+		Item        string `json:"item"`
71
+		ItemName    string `json:"item_name"`
72
+		RangeType   int64  `json:"range_type"`
73
+		Value       string `json:"value"`
74
+	} `json:"formItem"`
75
+}
76
+
77
+type InspectionDate struct {
78
+	InspectDate int64
79
+}

+ 272 - 0
models/intergration_models.go View File

@@ -0,0 +1,272 @@
1
+package models
2
+
3
+type VMPatients struct {
4
+	ID                           int64                `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId                    int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	UserId                       int64                `gorm:"column:user_id" json:"user_id" form:"user_id"`
7
+	Avatar                       string               `gorm:"column:avatar" json:"avatar" form:"avatar"`
8
+	PatientType                  int64                `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
9
+	DialysisNo                   string               `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
10
+	AdmissionNumber              string               `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
11
+	Source                       int64                `gorm:"column:source" json:"source" form:"source"`
12
+	Lapseto                      int64                `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
13
+	PartitionId                  int64                `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
14
+	BedId                        int64                `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
15
+	Name                         string               `gorm:"column:name" json:"name" form:"name"`
16
+	Alias                        string               `gorm:"column:alias" json:"alias" form:"alias"`
17
+	Gender                       int64                `gorm:"column:gender" json:"gender" form:"gender"`
18
+	Nation                       string               `gorm:"column:nation" json:"nation" form:"nation"`
19
+	NativePlace                  string               `gorm:"column:native_place" json:"native_place" form:"native_place"`
20
+	MaritalStatus                int64                `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
21
+	IdCardNo                     string               `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
22
+	Birthday                     int64                `gorm:"column:birthday" json:"birthday" form:"birthday"`
23
+	ReimbursementWayId           int64                `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
24
+	HealthCareType               int64                `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
25
+	HealthCareNo                 string               `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
26
+	HealthCareDueDate            int64                `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
27
+	Height                       int64                `gorm:"column:height" json:"height" form:"height"`
28
+	BloodType                    int64                `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
29
+	Rh                           int64                `gorm:"column:rh" json:"rh" form:"rh"`
30
+	HealthCareDueAlertDate       int64                `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
31
+	EducationLevel               int64                `gorm:"column:education_level" json:"education_level" form:"education_level"`
32
+	Profession                   int64                `gorm:"column:profession" json:"profession" form:"profession"`
33
+	Phone                        string               `gorm:"column:phone" json:"phone" form:"phone"`
34
+	HomeTelephone                string               `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
35
+	RelativePhone                string               `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
36
+	RelativeRelations            string               `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
37
+	HomeAddress                  string               `gorm:"column:home_address" json:"home_address" form:"home_address"`
38
+	WorkUnit                     string               `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
39
+	UnitAddress                  string               `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
40
+	Children                     int64                `gorm:"column:children" json:"children" form:"children"`
41
+	ReceivingDate                int64                `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
42
+	IsHospitalFirstDialysis      int64                `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
43
+	FirstDialysisDate            int64                `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
44
+	FirstDialysisHospital        string               `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
45
+	PredialysisCondition         string               `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
46
+	PreHospitalDialysisFrequency string               `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
47
+	PreHospitalDialysisTimes     int64                `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
48
+	HospitalFirstDialysisDate    int64                `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
49
+	InductionPeriod              int64                `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
50
+	InitialDialysis              int64                `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
51
+	TotalDialysis                int64                `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
52
+	AttendingDoctorId            int64                `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
53
+	HeadNurseId                  int64                `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
54
+	Evaluate                     string               `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
55
+	Diagnose                     string               `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
56
+	Remark                       string               `gorm:"column:remark" json:"remark" form:"remark"`
57
+	RegistrarsId                 int64                `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
58
+	Registrars                   string               `gorm:"column:registrars" json:"registrars" form:"registrars"`
59
+	QrCode                       string               `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
60
+	BindingState                 int64                `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
61
+	PatientComplains             string               `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
62
+	PresentHistory               string               `gorm:"column:present_history" json:"present_history"`     // 现病史
63
+	PastHistory                  string               `gorm:"column:past_history" json:"past_history"`           // 既往史
64
+	Temperature                  float64              `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
65
+	Pulse                        int64                `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
66
+	Respiratory                  int64                `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
67
+	SBP                          int64                `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
68
+	DBP                          int64                `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
69
+	Status                       int64                `gorm:"column:status" json:"status" form:"status"`
70
+	CreatedTime                  int64                `gorm:"column:created_time" json:"created_time" form:"created_time"`
71
+	UpdatedTime                  int64                `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
72
+	DialysisSolutions            []DialysisSolution   `json:"solutions" gorm:"foreignkey:PatientId"`
73
+	Age                          int64                `gorm:"column:age" json:"age"`
74
+	Schedules                    []Schedule           `json:"schedules" gorm:"foreignkey:PatientId"`
75
+	Contagions                   []InfectiousDiseases `json:"contagions" gorm:"foreignkey:PatientId"`
76
+	Diseases                     []ChronicDiseases    `json:"diseases" gorm:"foreignkey:PatientId"`
77
+
78
+	InfectiousNextRecordTime int64         `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time"`
79
+	IsInfectious             int64         `gorm:"column:is_infectious" json:"is_infectious"`
80
+	RemindCycle              int64         `gorm:"column:remind_cycle" json:"remind_cycle"`
81
+	ResponseResult           string        `gorm:"column:response_result" json:"response_result"`
82
+	IsOpenRemind             int64         `gorm:"column:is_open_remind" json:"is_open_remind"`
83
+	DialysisAge              int64         `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
84
+	ExpenseKind              int64         `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
85
+	TellPhone                string        `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
86
+	FirstTreatmentDate       int64         `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
87
+	ContactName              string        `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
88
+	VMHisPatients            VMHisPatients `gorm:"ForeignKey:XtPatientId;AssociationForeignKey:ID" json:"his_patient"`
89
+}
90
+
91
+func (VMPatients) TableName() string {
92
+	return "xt_patients"
93
+}
94
+
95
+type VMHisPatients struct {
96
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
97
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
98
+	HisUserId   string `gorm:"column:his_user_id" json:"his_user_id" form:"his_user_id"`
99
+	XtPatientId int64  `gorm:"column:xt_patient_id" json:"xt_patient_id" form:"xt_patient_id"`
100
+}
101
+
102
+func (VMHisPatients) TableName() string {
103
+	return "xt_middle_patients"
104
+}
105
+
106
+type HisPatients struct {
107
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
108
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
109
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
110
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
111
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
112
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
113
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
114
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
115
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
116
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
117
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
118
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
119
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
120
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
121
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
122
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
123
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
124
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
125
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
126
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
127
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
128
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
129
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
130
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
131
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
132
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
133
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
134
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
135
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
136
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
137
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
138
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
139
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
140
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
141
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
142
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
143
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
144
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
145
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
146
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
147
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
148
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
149
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
150
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
151
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
152
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
153
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
154
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
155
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
156
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
157
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
158
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
159
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
160
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
161
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
162
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains" form:"patient_complains"`
163
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history" form:"present_history"`
164
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
165
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
166
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse" form:"pulse"`
167
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory" form:"respiratory"`
168
+	Sbp                          int64   `gorm:"column:sbp" json:"sbp" form:"sbp"`
169
+	Dbp                          int64   `gorm:"column:dbp" json:"dbp" form:"dbp"`
170
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
171
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
172
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
173
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
174
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
175
+	Age                          int64   `gorm:"column:age" json:"age" form:"age"`
176
+	InfectiousNextRecordTime     int64   `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time" form:"infectious_next_record_time"`
177
+	IsInfectious                 int64   `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
178
+	RemindCycle                  int64   `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
179
+	ResponseResult               string  `gorm:"column:response_result" json:"response_result" form:"response_result"`
180
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
181
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
182
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
183
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
184
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
185
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
186
+	HisUserId                    string  `gorm:"column:his_user_id" json:"his_user_id" form:"his_user_id"`
187
+	XtPatientId                  int64   `gorm:"column:xt_patient_id" json:"xt_patient_id" form:"xt_patient_id"`
188
+}
189
+
190
+func (HisPatients) TableName() string {
191
+	return "xt_middle_patients"
192
+}
193
+
194
+type HisUserAdminRole struct {
195
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
196
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
197
+	OrgId       int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
198
+	AppId       int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
199
+	RoleId      int64  `gorm:"column:role_id" json:"role_id" form:"role_id"`
200
+	UserName    string `gorm:"column:user_name" json:"user_name" form:"user_name"`
201
+	Avatar      string `gorm:"column:avatar" json:"avatar" form:"avatar"`
202
+	UserType    int64  `gorm:"column:user_type" json:"user_type" form:"user_type"`
203
+	UserTitle   int64  `gorm:"column:user_title" json:"user_title" form:"user_title"`
204
+	Intro       string `gorm:"column:intro" json:"intro" form:"intro"`
205
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
206
+	Ctime       int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
207
+	Mtime       int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
208
+	HisUserId   string `gorm:"column:his_user_id" json:"his_user_id" form:"his_user_id"`
209
+	XtRoleId    int64  `gorm:"column:xt_role_id" json:"xt_role_id" form:"xt_role_id"`
210
+}
211
+
212
+func (HisUserAdminRole) TableName() string {
213
+	return "xt_middle_user_admin_role"
214
+}
215
+
216
+type VMUserAdminRole struct {
217
+	ID               int64            `gorm:"column:id" json:"id" form:"id"`
218
+	AdminUserId      int64            `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
219
+	OrgId            int64            `gorm:"column:org_id" json:"org_id" form:"org_id"`
220
+	AppId            int64            `gorm:"column:app_id" json:"app_id" form:"app_id"`
221
+	RoleId           int64            `gorm:"column:role_id" json:"role_id" form:"role_id"`
222
+	UserName         string           `gorm:"column:user_name" json:"user_name" form:"user_name"`
223
+	Avatar           string           `gorm:"column:avatar" json:"avatar" form:"avatar"`
224
+	UserType         int64            `gorm:"column:user_type" json:"user_type" form:"user_type"`
225
+	UserTitle        int64            `gorm:"column:user_title" json:"user_title" form:"user_title"`
226
+	Intro            string           `gorm:"column:intro" json:"intro" form:"intro"`
227
+	Status           int64            `gorm:"column:status" json:"status" form:"status"`
228
+	Ctime            int64            `gorm:"column:ctime" json:"ctime" form:"ctime"`
229
+	Mtime            int64            `gorm:"column:mtime" json:"mtime" form:"mtime"`
230
+	VMUserAdmin      VMUserAdmin      `gorm:"ForeignKey:ID;AssociationForeignKey:AdminUserId" json:"admin"`
231
+	HisUserAdminRole HisUserAdminRole `gorm:"ForeignKey:XtRoleId;AssociationForeignKey:ID" json:"middle_admin_role"`
232
+	VMUserRole       VMUserRole       `gorm:"ForeignKey:ID;AssociationForeignKey:RoleId" json:"role"`
233
+}
234
+
235
+func (VMUserAdminRole) TableName() string {
236
+	return "sgj_user_admin_role"
237
+}
238
+
239
+type VMUserAdmin struct {
240
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
241
+	Mobile       string `gorm:"column:mobile" json:"mobile" form:"mobile"`
242
+	Password     string `gorm:"column:password" json:"password" form:"password"`
243
+	IsSuperAdmin int64  `gorm:"column:is_super_admin" json:"is_super_admin" form:"is_super_admin"`
244
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
245
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
246
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
247
+	Source       int64  `gorm:"column:source" json:"source" form:"source"`
248
+	Ttype        int64  `gorm:"column:ttype" json:"ttype" form:"ttype"`
249
+	Ttid         int64  `gorm:"column:ttid" json:"ttid" form:"ttid"`
250
+	Tuid         int64  `gorm:"column:tuid" json:"tuid" form:"tuid"`
251
+}
252
+
253
+func (VMUserAdmin) TableName() string {
254
+	return "sgj_user_admin"
255
+}
256
+
257
+type VMUserRole struct {
258
+	ID               int64  `gorm:"column:id" json:"id" form:"id"`
259
+	RoleName         string `gorm:"column:role_name" json:"role_name" form:"role_name"`
260
+	RoleIntroduction string `gorm:"column:role_introduction" json:"role_introduction" form:"role_introduction"`
261
+	Creator          int64  `gorm:"column:creator" json:"creator" form:"creator"`
262
+	OrgId            int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
263
+	AppId            int64  `gorm:"column:app_id" json:"app_id" form:"app_id"`
264
+	IsSuperAdmin     int64  `gorm:"column:is_super_admin" json:"is_super_admin" form:"is_super_admin"`
265
+	Status           int64  `gorm:"column:status" json:"status" form:"status"`
266
+	Ctime            int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
267
+	Mtime            int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
268
+}
269
+
270
+func (VMUserRole) TableName() string {
271
+	return "sgj_user_role"
272
+}

+ 139 - 0
models/monitor_models.go View File

@@ -0,0 +1,139 @@
1
+package models
2
+
3
+type MonitorDialysisSchedule struct {
4
+	ID           int64 `gorm:"column:id" json:"id"`
5
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
6
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id"`
7
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id"`
8
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id"`
9
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
10
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
11
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id"`
12
+	Status       int64 `gorm:"column:status" json:"status"`
13
+
14
+	MonitorPatients MonitorPatients `gorm:"ForeignKey:PatientId" json:"patient"`
15
+	DeviceNumber    DeviceNumber    `gorm:"ForeignKey:BedId" json:"device_number"`
16
+	DeviceZone      DeviceZone      `gorm:"ForeignKey:PartitionId" json:"device_zone"`
17
+	TreatmentMode   TreatmentMode   `gorm:"ForeignKey:ModeId" json:"treatment_mode"`
18
+
19
+	DialysisOrder            MonitorDialysisOrder    `gorm:"ForeignKey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"dialysis_order"`
20
+	Prescription             DialysisPrescription    `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"prescription"`
21
+	AssessmentBeforeDislysis PredialysisEvaluation   `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_before_dislysis"`
22
+	AssessmentAfterDislysis  AssessmentAfterDislysis `gorm:"ForeignKey:AssessmentDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"assessment_after_dislysis"`
23
+	MonitoringRecord         []MonitoringRecord      `gorm:"ForeignKey:MonitoringDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId" json:"monitoring_record"`
24
+}
25
+
26
+func (MonitorDialysisSchedule) TableName() string {
27
+	return "xt_schedule"
28
+}
29
+
30
+type MonitorPatients struct {
31
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
32
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
33
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
34
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
35
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
36
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
37
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
38
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
39
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
40
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
41
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
42
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
43
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
44
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
45
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
46
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
47
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
48
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
49
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
50
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
51
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
52
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
53
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
54
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
55
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
56
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
57
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
58
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
59
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
60
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
61
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
62
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
63
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
64
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
65
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
66
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
67
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
68
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
69
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
70
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
71
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
72
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
73
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
74
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
75
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
76
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
77
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
78
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
79
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
80
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
81
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
82
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
83
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
84
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
85
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
86
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
87
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
88
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
89
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history"`     // 现病史
90
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history"`           // 既往史
91
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
92
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
93
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
94
+	SBP                          int64   `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
95
+	DBP                          int64   `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
96
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
97
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
98
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
99
+	Age                          int64   `gorm:"column:age" json:"age"`
100
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind"`
101
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
102
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
103
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
104
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
105
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
106
+}
107
+
108
+func (MonitorPatients) TableName() string {
109
+	return "xt_patients"
110
+}
111
+
112
+type MonitorDialysisOrder struct {
113
+	ID             int64        `gorm:"column:id" json:"id"`
114
+	DialysisDate   int64        `gorm:"column:dialysis_date" json:"dialysis_date"`
115
+	UserOrgId      int64        `gorm:"column:user_org_id" json:"user_org_id"`
116
+	PatientId      int64        `gorm:"column:patient_id" json:"patient_id"`
117
+	PrescriptionId int64        `gorm:"column:prescription_id" json:"prescription_id"`
118
+	Stage          int64        `gorm:"column:stage" json:"stage"`
119
+	Remark         string       `gorm:"column:remark" json:"remark"`
120
+	BedID          int64        `gorm:"column:bed_id" json:"bed_id"`
121
+	StartNurse     int64        `gorm:"column:start_nurse" json:"start_nurse"`
122
+	FinishNurse    int64        `gorm:"column:finish_nurse" json:"finish_nurse"`
123
+	Status         int64        `gorm:"column:status" json:"status"`
124
+	CreatedTime    int64        `gorm:"column:created_time" json:"created_time"`
125
+	UpdatedTime    int64        `gorm:"column:updated_time" json:"updated_time"`
126
+	StartTime      int64        `gorm:"column:start_time" json:"start_time"`
127
+	EndTime        int64        `gorm:"column:end_time" json:"end_time"`
128
+	DeviceNumber   DeviceNumber `gorm:"ForeignKey:BedId" json:"device_number"`
129
+	PunctureNurse  int64        `gorm:"column:puncture_nurse" json:"puncture_nurse"`
130
+	Creator        int64        `gorm:"column:creator" json:"creator"`
131
+	Modifier       int64        `gorm:"column:modifier" json:"modifier"`
132
+	FinishCreator  int64        `gorm:"column:finish_creator" json:"finish_creator"`
133
+	FinishModifier int64        `gorm:"column:finish_modifier" json:"finish_modifier"`
134
+	SchedualType   int64        `gorm:"column:schedual_type" json:"schedual_type"`
135
+}
136
+
137
+func (MonitorDialysisOrder) TableName() string {
138
+	return "xt_dialysis_order"
139
+}

+ 105 - 0
models/org_models.go View File

@@ -0,0 +1,105 @@
1
+package models
2
+
3
+type Org struct {
4
+	Id              int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // 机构 ID
5
+	Creator         int64  `json:"creator"`                              // 创建者,即管理员用户的 id
6
+	OrgName         string `gorm:"column:org_name" json:"org_name"`
7
+	OrgShortName    string `gorm:"column:org_short_name" json:"org_short_name"` // 简称
8
+	OrgLogo         string `gorm:"column:org_logo" json:"org_logo"`
9
+	OrgIntroduction string `gorm:"column:org_introduction" json:"org_introduction"`
10
+	Province        int64  `json:"province"` // 省,代号,下面的市、区也一样
11
+	City            int64  `json:"city"`
12
+	District        int64  `json:"district"`
13
+	Address         string `json:"address"`                   // 详细地址
14
+	Illness         string `json:"illness"`                   // 服务病种 多个并用“,”隔开
15
+	Status          int8   `json:"status"`                    // 状态 0.无效 1.有效 2.禁用
16
+	CreateTime      int64  `gorm:"column:ctime" json:"ctime"` // 创建时间
17
+	ModifyTime      int64  `gorm:"column:mtime" json:"mtime"` // 修改时间
18
+
19
+	OrgType        int64         `gorm:"column:org_type" json:"org_type"`
20
+	Evaluate       float64       `gorm:"column:evaluate" json:"evaluate"`
21
+	Comments       int64         `gorm:"column:comments" json:"comments"`
22
+	OperatingState int64         `gorm:"column:operating_state" json:"operating_state"`
23
+	Claim          int64         `gorm:"column:claim" json:"claim"`
24
+	Telephone      string        `gorm:"column:telephone" json:"telephone"`
25
+	BusinessWeek   string        `gorm:"column:business_week" json:"business_week"`
26
+	BusinessTime   string        `gorm:"column:business_time" json:"business_time"`
27
+	Gallery        string        `gorm:"column:gallery" json:"gallery"`
28
+	ContactName    string        `gorm:"column:contact_name" json:"contact_name"`
29
+	OrgGallery     []*OrgGallery `gorm:"ForeignKey:OrgId" json:"org_gallery"`
30
+}
31
+
32
+func (Org) TableName() string {
33
+	return "sgj_user_org"
34
+}
35
+
36
+type OrgGallery struct {
37
+	ID     int64  `gorm:"column:id" json:"id" form:"id"`
38
+	Url    string `gorm:"column:url" json:"url" form:"url"`
39
+	Type   int64  `gorm:"column:type" json:"type" form:"type"`
40
+	OrgId  int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
41
+	UserId int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
42
+	Status int64  `gorm:"column:status" json:"status" form:"status"`
43
+	Ctime  int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
44
+	Mtime  int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
45
+}
46
+
47
+func (OrgGallery) TableName() string {
48
+	return "sgj_user_org_gallery"
49
+}
50
+
51
+type OrgApp struct {
52
+	Id         int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"` // ID
53
+	AppType    int   `gorm:"column:app_type" json:"app_type"`      // 应用类型 1.病友经营;2.科普号;3.血透经营;4.慢病管理
54
+	Creator    int   `json:"creator"`                              // 创建者,即管理员用户的 id
55
+	OrgId      int   `gorm:"column:org_id" json:"org_id"`
56
+	OpenStatus int   `gorm:"column:open_status" json:"open_status"`
57
+	Status     int8  `json:"status"`                    // 状态 0.无效 1.有效 2.禁用
58
+	CreateTime int64 `gorm:"column:ctime" json:"ctime"` // 创建时间
59
+	ModifyTime int64 `gorm:"column:mtime" json:"mtime"` // 修改时间
60
+}
61
+
62
+func (OrgApp) TableName() string {
63
+	return "sgj_user_org_app"
64
+}
65
+
66
+type OrgBan struct {
67
+	ID      int64  `gorm:"column:id" json:"id"`
68
+	OrgId   int64  `gorm:"column:org_id" json:"org_id"`
69
+	Reason  string `gorm:"column:reason" json:"reason"`
70
+	Ctime   int64  `gorm:"column:ctime" json:"ctime"`
71
+	BanTime int64  `gorm:"column:ban_time" json:"ban_time"`
72
+	Status  int64  `gorm:"column:status" json:"status"`
73
+	Mtime   int64  `gorm:"column:mtime" json:"mtime"`
74
+}
75
+
76
+func (OrgBan) TableName() string {
77
+	return "sgj_user_admin_org_ban"
78
+}
79
+
80
+type OrgType struct {
81
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
82
+	Name        string `gorm:"column:name" json:"name" form:"name"`
83
+	ShortName   string `gorm:"column:short_name" json:"short_name" form:"short_name"`
84
+	Pid         int64  `gorm:"column:pid" json:"pid" form:"pid"`
85
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
86
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
87
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
88
+	SortNo      int64  `gorm:"column:sort_no" json:"sort_no" form:"sort_no"`
89
+}
90
+
91
+func (OrgType) TableName() string {
92
+	return "sgj_user_org_type"
93
+}
94
+
95
+type Illness struct {
96
+	ID          int64  `gorm:"column:id" json:"id"`
97
+	IllnessName string `gorm:"column:illness_name" json:"illness_name"`
98
+	Status      int64  `gorm:"column:status" json:"status"`
99
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time"`
100
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time"`
101
+}
102
+
103
+func (Illness) TableName() string {
104
+	return "sgj_user_illness"
105
+}

+ 381 - 0
models/patient_models.go View File

@@ -0,0 +1,381 @@
1
+package models
2
+
3
+type Patients struct {
4
+	ID                           int64                `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId                    int64                `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	UserId                       int64                `gorm:"column:user_id" json:"user_id" form:"user_id"`
7
+	Avatar                       string               `gorm:"column:avatar" json:"avatar" form:"avatar"`
8
+	PatientType                  int64                `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
9
+	DialysisNo                   string               `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
10
+	AdmissionNumber              string               `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
11
+	Source                       int64                `gorm:"column:source" json:"source" form:"source"`
12
+	Lapseto                      int64                `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
13
+	PartitionId                  int64                `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
14
+	BedId                        int64                `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
15
+	Name                         string               `gorm:"column:name" json:"name" form:"name"`
16
+	Alias                        string               `gorm:"column:alias" json:"alias" form:"alias"`
17
+	Gender                       int64                `gorm:"column:gender" json:"gender" form:"gender"`
18
+	Nation                       string               `gorm:"column:nation" json:"nation" form:"nation"`
19
+	NativePlace                  string               `gorm:"column:native_place" json:"native_place" form:"native_place"`
20
+	MaritalStatus                int64                `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
21
+	IdCardNo                     string               `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
22
+	Birthday                     int64                `gorm:"column:birthday" json:"birthday" form:"birthday"`
23
+	ReimbursementWayId           int64                `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
24
+	HealthCareType               int64                `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
25
+	HealthCareNo                 string               `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
26
+	HealthCareDueDate            int64                `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
27
+	Height                       int64                `gorm:"column:height" json:"height" form:"height"`
28
+	BloodType                    int64                `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
29
+	Rh                           int64                `gorm:"column:rh" json:"rh" form:"rh"`
30
+	HealthCareDueAlertDate       int64                `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
31
+	EducationLevel               int64                `gorm:"column:education_level" json:"education_level" form:"education_level"`
32
+	Profession                   int64                `gorm:"column:profession" json:"profession" form:"profession"`
33
+	Phone                        string               `gorm:"column:phone" json:"phone" form:"phone"`
34
+	HomeTelephone                string               `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
35
+	RelativePhone                string               `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
36
+	RelativeRelations            string               `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
37
+	HomeAddress                  string               `gorm:"column:home_address" json:"home_address" form:"home_address"`
38
+	WorkUnit                     string               `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
39
+	UnitAddress                  string               `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
40
+	Children                     int64                `gorm:"column:children" json:"children" form:"children"`
41
+	ReceivingDate                int64                `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
42
+	IsHospitalFirstDialysis      int64                `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
43
+	FirstDialysisDate            int64                `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
44
+	FirstDialysisHospital        string               `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
45
+	PredialysisCondition         string               `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
46
+	PreHospitalDialysisFrequency string               `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
47
+	PreHospitalDialysisTimes     int64                `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
48
+	HospitalFirstDialysisDate    int64                `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
49
+	InductionPeriod              int64                `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
50
+	InitialDialysis              int64                `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
51
+	TotalDialysis                int64                `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
52
+	AttendingDoctorId            int64                `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
53
+	HeadNurseId                  int64                `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
54
+	Evaluate                     string               `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
55
+	Diagnose                     string               `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
56
+	Remark                       string               `gorm:"column:remark" json:"remark" form:"remark"`
57
+	RegistrarsId                 int64                `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
58
+	Registrars                   string               `gorm:"column:registrars" json:"registrars" form:"registrars"`
59
+	QrCode                       string               `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
60
+	BindingState                 int64                `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
61
+	PatientComplains             string               `gorm:"column:patient_complains" json:"patient_complains"` // 主诉
62
+	PresentHistory               string               `gorm:"column:present_history" json:"present_history"`     // 现病史
63
+	PastHistory                  string               `gorm:"column:past_history" json:"past_history"`           // 既往史
64
+	Temperature                  float64              `gorm:"column:temperature" json:"temperature"`             // 体格检查-体温
65
+	Pulse                        int64                `gorm:"column:pulse" json:"pulse"`                         // 体格检查-脉搏
66
+	Respiratory                  int64                `gorm:"column:respiratory" json:"respiratory"`             // 体格检查-呼吸频率
67
+	SBP                          int64                `gorm:"column:sbp" json:"sbp"`                             // 体格检查-收缩压
68
+	DBP                          int64                `gorm:"column:dbp" json:"dbp"`                             // 体格检查-舒张压
69
+	Status                       int64                `gorm:"column:status" json:"status" form:"status"`
70
+	CreatedTime                  int64                `gorm:"column:created_time" json:"created_time" form:"created_time"`
71
+	UpdatedTime                  int64                `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
72
+	DialysisSolutions            []DialysisSolution   `json:"solutions" gorm:"foreignkey:PatientId"`
73
+	Age                          int64                `gorm:"column:age" json:"age"`
74
+	Schedules                    []Schedule           `json:"schedules" gorm:"foreignkey:PatientId"`
75
+	Contagions                   []InfectiousDiseases `json:"contagions" gorm:"foreignkey:PatientId"`
76
+	Diseases                     []ChronicDiseases    `json:"diseases" gorm:"foreignkey:PatientId"`
77
+
78
+	InfectiousNextRecordTime int64  `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time"`
79
+	IsInfectious             int64  `gorm:"column:is_infectious" json:"is_infectious"`
80
+	RemindCycle              int64  `gorm:"column:remind_cycle" json:"remind_cycle"`
81
+	ResponseResult           string `gorm:"column:response_result" json:"response_result"`
82
+	IsOpenRemind             int64  `gorm:"column:is_open_remind" json:"is_open_remind"`
83
+	DialysisAge              int64  `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
84
+	ExpenseKind              int64  `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
85
+	TellPhone                string `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
86
+	FirstTreatmentDate       int64  `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
87
+	ContactName              string `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
88
+}
89
+
90
+func (Patients) TableName() string {
91
+	return "xt_patients"
92
+}
93
+
94
+type ChronicDiseases struct {
95
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
96
+	PatientId   int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
97
+	DiseaseId   int64 `gorm:"column:disease_id" json:"disease_id" form:"disease_id"`
98
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
99
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
100
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
101
+}
102
+
103
+func (ChronicDiseases) TableName() string {
104
+	return "xt_patients_chronic_diseases"
105
+}
106
+
107
+type InfectiousDiseases struct {
108
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
109
+	PatientId   int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
110
+	DiseaseId   int64 `gorm:"column:disease_id" json:"disease_id" form:"disease_id"`
111
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
112
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
113
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
114
+}
115
+
116
+func (InfectiousDiseases) TableName() string {
117
+	return "xt_patients_infectious_diseases"
118
+}
119
+
120
+type DialysisPrescription struct {
121
+	ID                        int64   `gorm:"column:id" json:"id"`
122
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id"`
123
+	PatientId                 int64   `gorm:"column:patient_id" json:"patient_id"`
124
+	Dialyzer                  int64   `gorm:"column:dialyzer" json:"dialyzer"`
125
+	MachineType               string  `gorm:"column:machine_type" json:"machine_type"`
126
+	DewaterAmount             float64 `gorm:"column:dewater_amount" json:"dewater_amount"`
127
+	PrescriptionDewatering    float64 `gorm:"column:prescription_dewatering" json:"prescription_dewatering"`
128
+	Anticoagulant             int64   `gorm:"column:anticoagulant" json:"anticoagulant"`
129
+	AnticoagulantShouji       float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji"`
130
+	AnticoagulantWeichi       float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi"`
131
+	AnticoagulantZongliang    float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang"`
132
+	AnticoagulantGaimingcheng string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng"`
133
+	AnticoagulantGaijiliang   string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang"`
134
+	ModeId                    int64   `gorm:"column:mode_id" json:"mode_id"`
135
+	DialysisDuration          float64 `gorm:"column:dialysis_duration" json:"dialysis_duration"`
136
+	ReplacementTotal          float64 `gorm:"column:replacement_total" json:"replacement_total"`
137
+	ReplacementWay            int64   `gorm:"column:replacement_way" json:"replacement_way"`
138
+	HemodialysisMachine       int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine"`
139
+	BloodFilter               int64   `gorm:"column:blood_filter" json:"blood_filter"`
140
+	PerfusionApparatus        int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus"`
141
+	//DryWeight                 float64 `gorm:"column:dry_weight" json:"dry_weight"`
142
+	VascularAccessMode         int64         `gorm:"column:vascular_access_mode" json:"vascular_access_mode"`
143
+	VascularAccess             int64         `gorm:"column:vascular_access" json:"vascular_access"`
144
+	BloodFlowVolume            float64       `gorm:"column:blood_flow_volume" json:"blood_flow_volume"`
145
+	DialysateFlow              float64       `gorm:"column:dialysate_flow" json:"dialysate_flow"`
146
+	DisplaceLiqui              float64       `gorm:"column:displace_liqui" json:"displace_liqui"`
147
+	Kalium                     float64       `gorm:"column:kalium" json:"kalium"`
148
+	Sodium                     float64       `gorm:"column:sodium" json:"sodium"`
149
+	Calcium                    float64       `gorm:"column:calcium" json:"calcium"`
150
+	Bicarbonate                float64       `gorm:"column:bicarbonate" json:"bicarbonate"`
151
+	Glucose                    float64       `gorm:"column:glucose" json:"glucose"`
152
+	DialysateTemperature       float64       `gorm:"column:dialysate_temperature" json:"dialysate_temperature"`
153
+	Conductivity               float64       `gorm:"column:conductivity" json:"conductivity"`
154
+	PrescriptionDoctor         int64         `gorm:"column:prescription_doctor" json:"prescription_doctor"`
155
+	Remark                     string        `gorm:"column:remark" json:"remark"`
156
+	Status                     int64         `gorm:"column:status" json:"status"`
157
+	CreatedTime                int64         `gorm:"column:created_time" json:"created_time"`
158
+	UpdatedTime                int64         `gorm:"column:updated_time" json:"updated_time"`
159
+	RecordDate                 int64         `gorm:"column:record_date" json:"record_date"`
160
+	RecordId                   int64         `gorm:"column:record_id" json:"record_id"`
161
+	Creater                    int64         `gorm:"column:creater" json:"creater"`
162
+	Modifier                   int64         `gorm:"column:modifier" json:"modifier"`
163
+	DialysisDurationHour       int64         `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour"`
164
+	DialysisDurationMinute     int64         `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute"`
165
+	DialysateFormulation       int64         `gorm:"column:dialysate_formulation" json:"dialysate_formulation"`
166
+	TargetUltrafiltration      float64       `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration"`
167
+	DialyzerPerfusionApparatus string        `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
168
+	BodyFluid                  int64         `gorm:"column:body_fluid" json:"body_fluid"`
169
+	SpecialMedicine            int64         `gorm:"column:special_medicine" json:"special_medicine"`
170
+	SpecialMedicineOther       string        `gorm:"column:special_medicine_other" json:"special_medicine_other"`
171
+	DisplaceLiquiPart          int64         `gorm:"column:displace_liqui_part" json:"displace_liqui_part"`
172
+	DisplaceLiquiValue         float64       `gorm:"column:displace_liqui_value" json:"displace_liqui_value"`
173
+	BloodAccess                int64         `gorm:"column:blood_access" json:"blood_access"`
174
+	Ultrafiltration            float64       `gorm:"column:ultrafiltration" json:"ultrafiltration"`
175
+	BodyFluidOther             string        `gorm:"column:body_fluid_other" json:"body_fluid_other"`
176
+	Niprocart                  int64         `gorm:"column:niprocart" json:"niprocart"`
177
+	Jms                        int64         `gorm:"column:jms" json:"jms"`
178
+	FistulaNeedleSet           int64         `gorm:"column:fistula_needle_set" json:"fistula_needle_set"`
179
+	FistulaNeedleSet16         int64         `gorm:"column:fistula_needle_set_16" json:"fistula_needle_set_16"`
180
+	Hemoperfusion              int64         `gorm:"column:hemoperfusion" json:"hemoperfusion"`
181
+	DialyserSterilised         int64         `gorm:"column:dialyser_sterilised" json:"dialyser_sterilised"`
182
+	Filtryzer                  int64         `gorm:"column:filtryzer" json:"filtryzer"`
183
+	TargetKtv                  float64       `gorm:"column:target_ktv" json:"target_ktv"`
184
+	Dialyzers                  int64         `gorm:"column:dialyzers" json:"dialyzers"`
185
+	Injector                   int64         `gorm:"column:injector" json:"injector"`
186
+	Bloodlines                 int64         `gorm:"column:bloodlines" json:"bloodlines"`
187
+	TubingHemodialysis         int64         `gorm:"column:tubing_hemodialysis" json:"tubing_hemodialysis"`
188
+	Package                    int64         `gorm:"column:package" json:"package"`
189
+	ALiquid                    int64         `gorm:"column:a_liquid" json:"a_liquid"`
190
+	UserAdminRole              UserAdminRole `json:"role" gorm:"foreignkey:AdminUserId;AssociationForeignKey:Creater;"`
191
+}
192
+
193
+func (DialysisPrescription) TableName() string {
194
+	return "xt_dialysis_prescription"
195
+}
196
+
197
+type DialysisPrescriptionList struct {
198
+	ID         int64 `gorm:"column:id" json:"id"`
199
+	UserOrgId  int64 `gorm:"column:user_org_id" json:"user_org_id"`
200
+	PatientId  int64 `gorm:"column:patient_id" json:"patient_id"`
201
+	ModeId     int64 `gorm:"column:mode_id" json:"mode_id"`
202
+	RecordDate int64 `gorm:"column:record_date" json:"record_date"`
203
+	RecordId   int64 `gorm:"column:record_id" json:"record_id"`
204
+	Creater    int64 `gorm:"column:creater" json:"creater"`
205
+	Modifier   int64 `gorm:"column:modifier" json:"modifier"`
206
+}
207
+
208
+func (DialysisPrescriptionList) TableName() string {
209
+	return "xt_dialysis_prescription"
210
+}
211
+
212
+type DialysisSolution struct {
213
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
214
+	Name                       string  `gorm:"column:name" json:"name" form:"name"`
215
+	SubName                    string  `gorm:"column:sub_name" json:"sub_name" form:"sub_name"`
216
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
217
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
218
+	ParentId                   int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
219
+	Type                       int64   `gorm:"column:type" json:"type" form:"type"`
220
+	Period                     string  `gorm:"column:period" json:"period" form:"period"`
221
+	Times                      string  `gorm:"column:times" json:"times" form:"times"`
222
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
223
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
224
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
225
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
226
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
227
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
228
+	ModeName                   string  `gorm:"column:mode_name" json:"mode_name" form:"mode_name"`
229
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
230
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
231
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
232
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
233
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
234
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
235
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
236
+	Dewater                    float64 `gorm:"column:dewater" json:"dewater" form:"dewater"`
237
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
238
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
239
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
240
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
241
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
242
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
243
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
244
+	Doctor                     int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
245
+	FirstDialysis              int64   `gorm:"column:first_dialysis" json:"first_dialysis" form:"first_dialysis"`
246
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
247
+	InitiateMode               int64   `gorm:"column:initiate_mode" json:"initiate_mode" form:"initiate_mode"`
248
+	AffirmState                int64   `gorm:"column:affirm_state" json:"affirm_state" form:"affirm_state"`
249
+	UseState                   int64   `gorm:"column:use_state" json:"use_state" form:"use_state"`
250
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
251
+	RegistrarsId               int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
252
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
253
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
254
+	SolutionType               int64   `gorm:"column:solution_type" json:"solution_type" form:"solution_type"`
255
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
256
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
257
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid"`
258
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine"`
259
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other"`
260
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part"`
261
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value"`
262
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access"`
263
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration"`
264
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
265
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
266
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
267
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
268
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialysate_formulation"`
269
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total"`
270
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus"`
271
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other"`
272
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv"`
273
+}
274
+
275
+func (DialysisSolution) TableName() string {
276
+	return "xt_dialysis_solution"
277
+}
278
+
279
+type UserAdminRole struct {
280
+	ID          int64  `gorm:"column:id" json:"id"`
281
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id"`
282
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
283
+	AppId       int64  `gorm:"column:app_id" json:"app_id"`
284
+	RoleId      int64  `gorm:"column:role_id" json:"role_id"`
285
+	UserName    string `gorm:"column:user_name" json:"user_name"`
286
+	Avatar      string `gorm:"column:avatar" json:"avatar"`
287
+	UserType    int64  `gorm:"column:user_type" json:"user_type"`
288
+	UserTitle   int64  `gorm:"column:user_title" json:"user_title"`
289
+	Intro       string `gorm:"column:intro" json:"intro"`
290
+	Status      int64  `gorm:"column:status" json:"status"`
291
+	Ctime       int64  `gorm:"column:ctime" json:"ctime"`
292
+	Mtime       int64  `gorm:"column:mtime" json:"mtime"`
293
+}
294
+
295
+func (UserAdminRole) TableName() string {
296
+	return "sgj_user_admin_role"
297
+}
298
+
299
+type PatientDialysisRecord struct {
300
+	DialysisOrder
301
+
302
+	ScheduleType  int64  `gorm:"-" json:"schedule_type" form:"schedule_type"`
303
+	PartitionId   int64  `gorm:"-" json:"partition_id" form:"partition_id"`
304
+	PartitionName string `gorm:"-" json:"partition_name" form:"partition_name"`
305
+	DeviceNumber  string `gorm:"-" json:"device_number" form:"device_number"`
306
+
307
+	// DialysisPrescription    DialysisPrescription    `json:"prescription" gorm:"foreignkey:RecordId"`
308
+	// PredialysisEvaluation   PredialysisEvaluation   `json:"predialysis_evaluation" gorm:"foreignkey:DialysisOrderId"`
309
+	// AssessmentAfterDislysis AssessmentAfterDislysis `json:"assessment_after_dislysis" gorm:"foreignkey:DialysisOrderId"`
310
+	// TreatmentSummary        TreatmentSummary        `json:"treatment_summary" gorm:"foreignkey:DialysisOrderId"`
311
+
312
+	DialysisPrescription    DialysisPrescription    `json:"prescription" gorm:"foreignkey:RecordDate;AssociationForeignKey:DialysisDate;"`
313
+	PredialysisEvaluation   PredialysisEvaluation   `json:"predialysis_evaluation" gorm:"foreignkey:AssessmentDate;AssociationForeignKey:DialysisDate;"`
314
+	AssessmentAfterDislysis AssessmentAfterDislysis `json:"assessment_after_dislysis" gorm:"foreignkey:AssessmentDate;AssociationForeignKey:DialysisDate;"`
315
+	TreatmentSummary        TreatmentSummary        `json:"treatment_summary" gorm:"foreignkey:AssessmentDate;AssociationForeignKey:DialysisDate;"`
316
+	Device                  DeviceNumber            `json:"device" gorm:"foreignkey:ID;AssociationForeignKey:BedID;"`
317
+}
318
+
319
+type DialysisPrescriptionAddtional struct {
320
+	DialysisPrescription
321
+
322
+	Device Device `json:"device" gorm:"foreignkey:dialyzer"`
323
+}
324
+
325
+type PatientDiseaseCourse struct {
326
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
327
+	OrgID      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
328
+	PatientID  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
329
+	Recorder   int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
330
+	RecordTime int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
331
+	Content    string `gorm:"column:content" json:"content" form:"content"`
332
+	Status     int64  `gorm:"column:status" json:"-" form:"-"`
333
+	CreateTime int64  `gorm:"column:ctime" json:"-" form:"-"`
334
+	ModifyTime int64  `gorm:"column:mtime" json:"-" form:"-"`
335
+	Title      string `gorm:"column:title" json:"title"`
336
+}
337
+
338
+func (PatientDiseaseCourse) TableName() string {
339
+	return "xt_patient_course_of_disease"
340
+}
341
+
342
+type PatientRescueRecord struct {
343
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
344
+	OrgID      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
345
+	PatientID  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
346
+	Recorder   int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
347
+	RecordTime int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
348
+	Content    string `gorm:"column:content" json:"content" form:"content"`
349
+	Status     int64  `gorm:"column:status" json:"-" form:"-"`
350
+	CreateTime int64  `gorm:"column:ctime" json:"-" form:"-"`
351
+	ModifyTime int64  `gorm:"column:mtime" json:"-" form:"-"`
352
+}
353
+
354
+func (PatientRescueRecord) TableName() string {
355
+	return "xt_patient_rescue_record"
356
+}
357
+
358
+type PatientLapseto struct {
359
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
360
+	PatientId   int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
361
+	LapsetoType int64 `gorm:"column:lapseto_type" json:"lapseto_type" form:"lapseto_type"`
362
+	LapsetoTime int64 `gorm:"column:lapseto_time" json:"lapseto_time" form:"lapseto_time"`
363
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
364
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
365
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
366
+}
367
+
368
+func (PatientLapseto) TableName() string {
369
+	return "xt_patient_lapseto"
370
+}
371
+
372
+type FormItem struct {
373
+	ID          int64  `json:"id"`
374
+	ProjectId   int64  `json:"project_id"`
375
+	ProjectName string `json:"project_name"`
376
+	ItemId      int64  `json:"item_id"`
377
+	Item        string `json:"item"`
378
+	ItemName    string `json:"item_name"`
379
+	RangeType   int64  `json:"range_type"`
380
+	Value       string `json:"value"`
381
+}

+ 45 - 0
models/patient_schedule_template_models.go View File

@@ -0,0 +1,45 @@
1
+package models
2
+
3
+type PatientScheduleTemplateMode struct {
4
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
5
+	OrgID        int64 `gorm:"column:org_id" json:"-" form:"org_id"`
6
+	Mode         int8  `gorm:"column:mode" json:"mode" form:"mode"`       // 模式:0.不启用模板 1.单周模板 2.双周模板
7
+	ExecuteTimes int64 `gorm:"column:execute_times" json:"execute_times"` // 已定期执行的次数(每次修改 mode 都重置为0)
8
+	Status       int8  `gorm:"column:status" json:"-" form:"status"`
9
+	CreateTime   int64 `gorm:"column:ctime" json:"-" form:"ctime"`
10
+	ModifyTime   int64 `gorm:"column:mtime" json:"-" form:"mtime"`
11
+}
12
+
13
+func (PatientScheduleTemplateMode) TableName() string {
14
+	return "xt_patient_schedule_template_mode"
15
+}
16
+
17
+type PatientScheduleTemplateId struct {
18
+	ID         int64 `gorm:"column:id" json:"id" form:"id"`
19
+	OrgID      int64 `gorm:"column:org_id" json:"-" form:"org_id"`
20
+	Status     int8  `gorm:"column:status" json:"-" form:"status"`
21
+	CreateTime int64 `gorm:"column:ctime" json:"-" form:"ctime"`
22
+	ModifyTime int64 `gorm:"column:mtime" json:"-" form:"mtime"`
23
+}
24
+
25
+func (PatientScheduleTemplateId) TableName() string {
26
+	return "xt_patient_schedule_template_id"
27
+}
28
+
29
+type PatientScheduleTemplateItem struct {
30
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
31
+	OrgID          int64 `gorm:"column:org_id" json:"-" form:"org_id"`
32
+	TemplateID     int64 `gorm:"column:template_id" json:"template_id" form:"template_id"`
33
+	DeviceNumberID int64 `gorm:"column:device_number_id" json:"device_number_id" form:"device_number_id"`
34
+	PatientID      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
35
+	TreatMode      int64 `gorm:"column:treat_mode" json:"treat_mode" form:"treat_mode"` // 治疗模式
36
+	Weekday        int8  `gorm:"column:weekday" json:"weekday" form:"weekday"`          // 周一-周日 1-7
37
+	TimeType       int8  `gorm:"column:time_type" json:"time_type" form:"time_type"`    // 上下晚 123
38
+	Status         int8  `gorm:"column:status" json:"-" form:"status"`
39
+	CreateTime     int64 `gorm:"column:ctime" json:"-" form:"ctime"`
40
+	ModifyTime     int64 `gorm:"column:mtime" json:"-" form:"mtime"`
41
+}
42
+
43
+func (PatientScheduleTemplateItem) TableName() string {
44
+	return "xt_patient_schedule_template_item"
45
+}

+ 37 - 0
models/purview_models.go View File

@@ -0,0 +1,37 @@
1
+package models
2
+
3
+type Purview struct {
4
+	Id                  int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
5
+	Parentid            int64  `json:"pid"`                                                // 父级ID
6
+	Module              int8   `json:"module"`                                             // 所属应用类型 1.病友经营;2.科普号;3.血透经营;4.慢病管理;
7
+	Name                string `json:"name"`                                               // 规则名称(也是菜单名)
8
+	Urlfor              string `json:"urlfor"`                                             // 规则唯一英文标识,(Controller.Method)
9
+	MenuIconClass       string `gorm:"menu_icon_class" json:"menu_icon_class"`             // 菜单图标的 css 样式
10
+	SuperAdminExclusive int8   `gorm:"super_admin_exclusive" json:"super_admin_exclusive"` // 是否为超级管理员专属 0否1是
11
+	Listorder           int    `json:"-"`                                                  // 排序ID
12
+	Status              int8   `json:"status"`                                             // 状态 0.无效 1.有效 2.禁用
13
+	CreateTime          int64  `gorm:"column:ctime" json:"-"`                              // 创建时间
14
+	ModifyTime          int64  `gorm:"column:mtime" json:"-"`                              // 修改时间
15
+
16
+	Link   string     `gorm:"-" json:"link"`   // urlfor 解析后的链接
17
+	Childs []*Purview `gorm:"-" json:"childs"` // 子节点
18
+}
19
+
20
+func (Purview) TableName() string {
21
+	return "sgj_user_purview"
22
+}
23
+
24
+type RolePurview struct {
25
+	Id         int64 `gorm:"PRIMARY_KEY;AUTO_INCREMENT"`
26
+	RoleId     int64
27
+	OrgId      int64
28
+	AppId      int64
29
+	PurviewIds string
30
+	Status     int8  // 状态 0.无效 1.有效 2.禁用
31
+	CreateTime int64 `gorm:"column:ctime"` // 创建时间
32
+	ModifyTime int64 `gorm:"column:mtime"` // 修改时间
33
+}
34
+
35
+func (RolePurview) TableName() string {
36
+	return "sgj_user_role_purview"
37
+}

+ 78 - 0
models/role_models.go View File

@@ -0,0 +1,78 @@
1
+package models
2
+
3
+type Role struct {
4
+	Id           int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
5
+	RoleName     string `gorm:"column:role_name" json:"name"`
6
+	RoleIntro    string `gorm:"column:role_introduction" json:"intro"`
7
+	Creator      int64  `json:"-"`
8
+	OrgId        int64  `gorm:"column:org_id" json:"-"`
9
+	AppId        int64  `gorm:"column:app_id" json:"-"`
10
+	IsSuperAdmin bool   `gorm:"column:is_super_admin" json:"-"`
11
+	Status       int8   `json:"status"`                // 状态 0.无效 1.有效 2.禁用
12
+	CreateTime   int64  `gorm:"column:ctime" json:"-"` // 创建时间
13
+	ModifyTime   int64  `gorm:"column:mtime" json:"-"` // 修改时间
14
+}
15
+
16
+func (Role) TableName() string {
17
+	return "sgj_user_role"
18
+}
19
+
20
+type App_Roles struct {
21
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
22
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id"`
23
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
24
+	AppId       int64  `gorm:"column:app_id" json:"app_id"`
25
+	RoleId      int64  `gorm:"column:role_id" json:"role_id"`
26
+	Avatar      string `json:"avatar" json:"avatar"`
27
+	UserName    string `gorm:"column:user_name" json:"user_name"`   // 用户名称
28
+	Intro       string `json:"intro"`                               // 简介
29
+	UserType    int8   `gorm:"column:user_type" json:"user_type"`   // 用户类型(1.管理员;2.医生;3.护士;4.运营)
30
+	UserTitle   int8   `gorm:"column:user_title" json:"user_title"` // 用户职称(1.医士;2.医师;3.住院医师;4.主治医师;5.副主任医师;6.主任医师;7.护士;8.护师;9.主管护师;10.副主任护师;11.主任护师;12.运营专员;13.运营主管)
31
+	Status      int8   `json:"status"`                              // 状态 0.无效 1.有效
32
+	CreateTime  int64  `gorm:"column:ctime" json:"ctime"`           // 创建时间
33
+	ModifyTime  int64  `gorm:"column:mtime" json:"mtime"`           // 修改时间
34
+	Url         string `gorm:"column:url" json:"url" form:"url"`
35
+}
36
+
37
+type App_Role struct {
38
+	Id          int64  `gorm:"PRIMARY_KEY;AUTO_INCREMENT" json:"id"`
39
+	AdminUserId int64  `gorm:"column:admin_user_id" json:"admin_user_id"`
40
+	OrgId       int64  `gorm:"column:org_id" json:"org_id"`
41
+	AppId       int64  `gorm:"column:app_id" json:"app_id"`
42
+	RoleId      int64  `gorm:"column:role_id" json:"role_id"`
43
+	Avatar      string `json:"avatar" json:"avatar"`
44
+	UserName    string `gorm:"column:user_name" json:"user_name"`   // 用户名称
45
+	Intro       string `json:"intro"`                               // 简介
46
+	UserType    int8   `gorm:"column:user_type" json:"user_type"`   // 用户类型(1.管理员;2.医生;3.护士;4.运营)
47
+	UserTitle   int8   `gorm:"column:user_title" json:"user_title"` // 用户职称(1.医士;2.医师;3.住院医师;4.主治医师;5.副主任医师;6.主任医师;7.护士;8.护师;9.主管护师;10.副主任护师;11.主任护师;12.运营专员;13.运营主管)
48
+	Status      int8   `json:"status"`                              // 状态 0.无效 1.有效
49
+	CreateTime  int64  `gorm:"column:ctime" json:"ctime"`           // 创建时间
50
+	ModifyTime  int64  `gorm:"column:mtime" json:"mtime"`           // 修改时间
51
+}
52
+
53
+func (App_Role) TableName() string {
54
+	return "sgj_user_admin_role"
55
+}
56
+
57
+var UserType = map[int]string{
58
+	1: "管理员",
59
+	2: "医生",
60
+	3: "护士",
61
+	4: "运营",
62
+}
63
+
64
+var UserTitle = map[int]string{
65
+	1:  "医士",
66
+	2:  "医师",
67
+	3:  "住院医师",
68
+	4:  "主治医师",
69
+	5:  "副主任医师",
70
+	6:  "主任医师",
71
+	7:  "护士",
72
+	8:  "护师",
73
+	9:  "主管护师",
74
+	10: "副主任护师",
75
+	11: "主任护师",
76
+	12: "运营专员",
77
+	13: "运营主管",
78
+}

+ 91 - 0
models/schedule_models.go View File

@@ -0,0 +1,91 @@
1
+package models
2
+
3
+type Schedule struct {
4
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
7
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
8
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
9
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
10
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
11
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
12
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
13
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
14
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
15
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
16
+
17
+	Patient       string        `gorm:"-" json:"patient" form:"patient"`
18
+	DeviceZone    DeviceZone    `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
19
+	DeviceNumber  DeviceNumber  `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
20
+	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
21
+	DialysisOrder DialysisOrder `json:"order" gorm:"foreignkey:DialysisDate,PatientId;AssociationForeignKey:ScheduleDate,PatientId;"`
22
+
23
+	PatientInfectiousDiseases []InfectiousDiseases `json:"patient_contagions" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId;"`
24
+}
25
+
26
+func (Schedule) TableName() string {
27
+	return "xt_schedule"
28
+}
29
+
30
+type PatientSchedule struct {
31
+	Schedule
32
+
33
+	DeviceZone   DeviceZone   `json:"zone" gorm:"foreignkey:PartitionId"`
34
+	DeviceNumber DeviceNumber `json:"bed" gorm:"foreignkey:BedId"`
35
+
36
+	Week int64 `gorm:"-" json:"week" form:"week"`
37
+
38
+	TreatmentMode TreatmentMode `json:"mode" gorm:"foreignkey:ModeId"`
39
+}
40
+
41
+type Partition struct {
42
+	DeviceZone
43
+
44
+	Jihaos []DeviceNumber `json:"jihaos" gorm:"foreignkey:ZoneID"`
45
+}
46
+
47
+type Search_Schedule struct {
48
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
49
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
50
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
51
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
52
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
53
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
54
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
55
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
56
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
57
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
58
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
59
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
60
+
61
+	Patient string `gorm:"-" json:"patient" form:"patient"`
62
+}
63
+
64
+func (Search_Schedule) TableName() string {
65
+	return "xt_schedule"
66
+}
67
+
68
+type WeekSchedule struct {
69
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
70
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
71
+	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
72
+	BedId        int64 `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
73
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
74
+	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
75
+	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
76
+	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
77
+	ModeId       int64 `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
78
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
79
+	CreatedTime  int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
80
+	UpdatedTime  int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
81
+
82
+	Patient              string           `gorm:"-" json:"patient" form:"patient"`
83
+	DeviceZone           DeviceZone       `json:"zone" gorm:"foreignkey:ID;AssociationForeignKey:PartitionId;"`
84
+	DeviceNumber         DeviceNumber     `json:"number" gorm:"foreignkey:ID;AssociationForeignKey:BedId;"`
85
+	DialysisPrescription DialysisSolution `json:"prescription" gorm:"foreignkey:PatientId,ModeId;AssociationForeignKey:PatientId,ModeId"`
86
+	DoctorAdvice         []*DoctorAdvice  `json:"doctor_advice" gorm:"foreignkey:PatientId;AssociationForeignKey:PatientId"`
87
+}
88
+
89
+func (WeekSchedule) TableName() string {
90
+	return "xt_schedule"
91
+}

+ 130 - 0
models/service_models.go View File

@@ -0,0 +1,130 @@
1
+package models
2
+
3
+import "time"
4
+
5
+type ServeOrder struct {
6
+	ID                    int64     `gorm:"column:id" json:"id"`
7
+	OrgId                 int64     `gorm:"column:org_id" json:"org_id"`
8
+	Period                int64     `gorm:"column:period" json:"period"`
9
+	PeriodStart           int64     `gorm:"column:period_start" json:"period_start"`
10
+	PeriodEnd             int64     `gorm:"column:period_end" json:"period_end"`
11
+	PeriodStartTime       time.Time `gorm:"column:period_start_time" json:"period_start_time"`
12
+	PeriodEndTime         time.Time `gorm:"column:period_end_time" json:"period_end_time"`
13
+	Status                int64     `gorm:"column:status" json:"status"`
14
+	CreatedTime           int64     `gorm:"column:created_time" json:"created_time"`
15
+	UpdatedTime           int64     `gorm:"column:updated_time" json:"updated_time"`
16
+	OrderNumber           string    `gorm:"column:order_number" json:"order_number"`
17
+	OrderStatus           int64     `gorm:"column:order_status" json:"order_status"`
18
+	PayType               int64     `gorm:"column:pay_type" json:"pay_type"`
19
+	PayTime               int64     `gorm:"column:pay_time" json:"pay_time"`
20
+	PaymentAmount         float64   `gorm:"column:payment_amount" json:"payment_amount"`
21
+	PayableAmount         float64   `gorm:"column:payable_amount" json:"payable_amount"`
22
+	DiscountableAmount    float64   `gorm:"column:discountable_amount" json:"discountable_amount"`
23
+	PaymentTransactionId  string    `gorm:"column:payment_transaction_id" json:"payment_transaction_id"`
24
+	ServeName             string    `gorm:"column:serve_name" json:"serve_name"`
25
+	ServeDesc             string    `gorm:"column:serve_desc" json:"serve_desc"`
26
+	ServeDuration         string    `gorm:"column:serve_duration" json:"serve_duration"`
27
+	OrderExpireTime       int64     `gorm:"column:order_expire_time" json:"order_expire_time"`
28
+	Price                 float64   `gorm:"column:price" json:"price"`
29
+	Quantity              int64     `gorm:"column:quantity" json:"quantity"`
30
+	ServeId               int64     `gorm:"column:serve_id" json:"serve_id"`
31
+	OrderExpireTimeFormat string    `gorm:"-"`
32
+}
33
+
34
+func (ServeOrder) TableName() string {
35
+	return "sgj_serve_order"
36
+}
37
+
38
+type ServeOrderInfomation struct {
39
+	ID          int64   `gorm:"column:id" json:"id"`
40
+	OrgId       int64   `gorm:"column:org_id" json:"org_id"`
41
+	OrderNumber string  `gorm:"column:order_number" json:"order_number"`
42
+	ProductId   int64   `gorm:"column:product_id" json:"product_id"`
43
+	ProductName string  `gorm:"column:product_name" json:"product_name"`
44
+	ProductDesc string  `gorm:"column:product_desc" json:"product_desc"`
45
+	Price       float64 `gorm:"column:price" json:"price"`
46
+	Quantity    int64   `gorm:"column:quantity" json:"quantity"`
47
+	MarketPrice float64 `gorm:"column:market_price" json:"market_price"`
48
+	Status      int64   `gorm:"column:status" json:"status"`
49
+}
50
+
51
+func (ServeOrderInfomation) TableName() string {
52
+	return "sgj_serve_order_infomation"
53
+}
54
+
55
+type ServeProduct struct {
56
+	ID            int64   `gorm:"column:id" json:"id"`
57
+	ServeName     string  `gorm:"column:serve_name" json:"serve_name"`
58
+	ServeDesc     string  `gorm:"column:serve_desc" json:"serve_desc"`
59
+	OriginalPrice float64 `gorm:"column:original_price" json:"original_price"`
60
+	Price         float64 `gorm:"column:price" json:"price"`
61
+	Status        int64   `gorm:"column:status" json:"status"`
62
+	CreatedTime   int64   `gorm:"column:created_time" json:"created_time"`
63
+	UpdatedTime   int64   `gorm:"column:updated_time" json:"updated_time"`
64
+	ServeDuration int64   `gorm:"column:serve_duration" json:"serve_duration"`
65
+	Edition       int64   `gorm:"column:edition" json:"edition"`
66
+}
67
+
68
+func (ServeProduct) TableName() string {
69
+	return "sgj_serve_product"
70
+}
71
+
72
+type ServeSubscibe struct {
73
+	ID              int64     `gorm:"column:id" json:"id"`
74
+	OrgId           int64     `gorm:"column:org_id" json:"org_id"`
75
+	PeriodStart     int64     `gorm:"column:period_start" json:"period_start"`
76
+	PeriodEnd       int64     `gorm:"column:period_end" json:"period_end"`
77
+	PeriodStartTime time.Time `gorm:"column:period_start_time" json:"period_start_time"`
78
+	PeriodEndTime   time.Time `gorm:"column:period_end_time" json:"period_end_time"`
79
+	Status          int64     `gorm:"column:status" json:"status"`
80
+	CreatedTime     int64     `gorm:"column:created_time" json:"created_time"`
81
+	UpdatedTime     int64     `gorm:"column:updated_time" json:"updated_time"`
82
+	State           int64     `gorm:"column:state" json:"state" form:"statstateus"`
83
+	Org             Org       `gorm:"ForeignKey:OrgId"`
84
+
85
+	Patients int64 `gorm:"-" json:"patients"`
86
+}
87
+
88
+func (ServeSubscibe) TableName() string {
89
+	return "sgj_serve_subscibe"
90
+}
91
+
92
+type ServeInvoice struct {
93
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
94
+	InvoiceType             int64   `gorm:"column:invoice_type" json:"invoice_type" form:"invoice_type"`
95
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
96
+	InvoiceTitle            string  `gorm:"column:invoice_title" json:"invoice_title" form:"invoice_title"`
97
+	InvoiceAmountGross      float64 `gorm:"column:invoice_amount_gross" json:"invoice_amount_gross" form:"invoice_amount_gross"`
98
+	Recipient               string  `gorm:"column:recipient" json:"recipient" form:"recipient"`
99
+	ContactPhone            string  `gorm:"column:contact_phone" json:"contact_phone" form:"contact_phone"`
100
+	Address                 string  `gorm:"column:address" json:"address" form:"address"`
101
+	TaxIdentificationNumber string  `gorm:"column:tax_identification_number" json:"tax_identification_number" form:"tax_identification_number"`
102
+	Remark                  string  `gorm:"column:remark" json:"remark" form:"remark"`
103
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
104
+	CreatedTime             int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
105
+	UpdatedTime             int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
106
+	Orders                  string  `gorm:"column:orders" json:"orders" form:"orders"`
107
+	InvoiceStatus           int64   `gorm:"column:invoice_status" json:"invoice_status" form:"invoice_status"`
108
+}
109
+
110
+func (ServeInvoice) TableName() string {
111
+	return "sgj_serve_invoice"
112
+}
113
+
114
+type ServeOrderContract struct {
115
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
116
+	OrgId          int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
117
+	OrderId        int64  `gorm:"column:order_id" json:"order_id" form:"order_id"`
118
+	OrderNumber    string `gorm:"column:order_number" json:"order_number" form:"order_number"`
119
+	CompanyTitle   string `gorm:"column:company_title" json:"company_title" form:"company_title"`
120
+	CompanyAddress string `gorm:"column:company_address" json:"company_address" form:"company_address"`
121
+	ContactPhone   string `gorm:"column:contact_phone" json:"contact_phone" form:"contact_phone"`
122
+	Contact        string `gorm:"column:contact" json:"contact" form:"contact"`
123
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
124
+	CreatedTime    int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
125
+	UpdatedTime    int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
126
+}
127
+
128
+func (ServeOrderContract) TableName() string {
129
+	return "sgj_serve_order_contract"
130
+}

+ 104 - 0
models/sign_weigh_models.go View File

@@ -0,0 +1,104 @@
1
+package models
2
+
3
+type SignWeighRecord struct {
4
+	ID                    int64   `gorm:"column:id" json:"id"`
5
+	OrgID                 int64   `gorm:"column:org_id" json:"-"`
6
+	PatientID             int64   `gorm:"column:patient_id" json:"patient_id"`
7
+	ClothesWeight         float64 `gorm:"column:clothes_weight" json:"clothes_weight"`
8
+	WeighBefore           float64 `gorm:"column:weigh_before" json:"weigh_before"`
9
+	TemperatureBefore     float64 `gorm:"column:temperature_before" json:"temperature_before"`
10
+	PulseRateBefore       float64 `gorm:"column:pulse_rate_before" json:"pulse_rate_before"`
11
+	RespiratoryRateBefore float64 `gorm:"column:respiratory_rate_before" json:"respiratory_rate_before"`
12
+	DBPBefore             float64 `gorm:"column:dbp_before" json:"dbp_before"`
13
+	SBPBefore             float64 `gorm:"column:sbp_before" json:"sbp_before"`
14
+	WeighAfter            float64 `gorm:"column:weigh_after" json:"weigh_after"`
15
+	TemperatureAfter      float64 `gorm:"column:temperature_after" json:"temperature_after"`
16
+	PulseRateAfter        float64 `gorm:"column:pulse_rate_after" json:"pulse_rate_after"`
17
+	RespiratoryRateAfter  float64 `gorm:"column:respiratory_rate_after" json:"respiratory_rate_after"`
18
+	DBPAfter              float64 `gorm:"column:dbp_after" json:"dbp_after"`
19
+	SBPAfter              float64 `gorm:"column:sbp_after" json:"sbp_after"`
20
+	Status                int8    `gorm:"column:status" json:"-"`
21
+	CreateTime            int64   `gorm:"column:ctime" json:"-"`
22
+	ModifyTime            int64   `gorm:"column:mtime" json:"-"`
23
+}
24
+
25
+func (SignWeighRecord) TableName() string {
26
+	return "xt_sign_weigh"
27
+}
28
+
29
+type SigninAndWeigh struct {
30
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
31
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
32
+	PatientId                    int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
33
+	RecordDate                   int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
34
+	SignTime                     int64   `gorm:"column:sign_time" json:"sign_time" form:"sign_time"`
35
+	WeighTime                    int64   `gorm:"column:weigh_time" json:"weigh_time" form:"weigh_time"`
36
+	WeighBeforeTime              int64   `gorm:"column:weigh_before_time" json:"weigh_before_time" form:"weigh_before_time"`
37
+	DryWeight                    float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
38
+	ClothingWeight               float64 `gorm:"column:clothing_weight" json:"clothing_weight" form:"clothing_weight"`
39
+	WeightBefore                 float64 `gorm:"column:weight_before" json:"weight_before" form:"weight_before"`
40
+	WeighingBefore               float64 `gorm:"column:weighing_before" json:"weighing_before" form:"weighing_before"`
41
+	TargetDewatering             float64 `gorm:"column:target_dewatering" json:"target_dewatering" form:"target_dewatering"`
42
+	TemperatureBefore            float64 `gorm:"column:temperature_before" json:"temperature_before" form:"temperature_before"`
43
+	PulseFrequencyBefore         float64 `gorm:"column:pulse_frequency_before" json:"pulse_frequency_before" form:"pulse_frequency_before"`
44
+	BreathingRateBefore          float64 `gorm:"column:breathing_rate_before" json:"breathing_rate_before" form:"breathing_rate_before"`
45
+	SystolicBloodPressureBefore  float64 `gorm:"column:systolic_blood_pressure_before" json:"systolic_blood_pressure_before" form:"systolic_blood_pressure_before"`
46
+	DiastolicBloodPressureBefore float64 `gorm:"column:diastolic_blood_pressure_before" json:"diastolic_blood_pressure_before" form:"diastolic_blood_pressure_before"`
47
+	WeightAfter                  float64 `gorm:"column:weight_after" json:"weight_after" form:"weight_after"`
48
+	WeighingAfter                float64 `gorm:"column:weighing_after" json:"weighing_after" form:"weighing_after"`
49
+	WeightLoss                   float64 `gorm:"column:weight_loss" json:"weight_loss" form:"weight_loss"`
50
+	TemperatureAfter             float64 `gorm:"column:temperature_after" json:"temperature_after" form:"temperature_after"`
51
+	PulseFrequencyAfter          float64 `gorm:"column:pulse_frequency_after" json:"pulse_frequency_after" form:"pulse_frequency_after"`
52
+	BreathingRateAfter           float64 `gorm:"column:breathing_rate_after" json:"breathing_rate_after" form:"breathing_rate_after"`
53
+	SystolicBloodPressureAfter   float64 `gorm:"column:systolic_blood_pressure_after" json:"systolic_blood_pressure_after" form:"systolic_blood_pressure_after"`
54
+	DiastolicBloodPressureAfter  float64 `gorm:"column:diastolic_blood_pressure_after" json:"diastolic_blood_pressure_after" form:"diastolic_blood_pressure_after"`
55
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
56
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
57
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
58
+}
59
+
60
+func (SigninAndWeigh) TableName() string {
61
+	return "xt_signin_and_weigh"
62
+}
63
+
64
+type SignPatients struct {
65
+	Patients
66
+	Schedule              Schedule              `json:"schedule" gorm:"foreignkey:PatientId"`
67
+	SignWeight            SignWeight            `json:"signin" gorm:"foreignkey:PatientId"`
68
+	DialysisOrder         DialysisOrder         `json:"dialysis_order" gorm:"foreignkey:PatientId"`
69
+	PredialysisEvaluation PredialysisEvaluation `json:"predialysisevaluation" gorm:"foreignkey:PatientId"`
70
+}
71
+
72
+func (SignPatients) TableName() string {
73
+	return "xt_patients"
74
+}
75
+
76
+type SignWeight struct {
77
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
78
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
79
+	PatientId                    int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
80
+	SignTime                     int64   `gorm:"column:sign_time" json:"sign_time" form:"sign_time"`
81
+	RecordDate                   int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
82
+	WeightBefore                 float64 `gorm:"column:weightbefore" json:"weightbefore" form:"weightbefore"`
83
+	DryWeightBefore              float64 `gorm:"column:dry_weight_before" json:"dry_weight_before" form:"dry_weight_before"`
84
+	TemperatureBefore            float64 `gorm:"column:temperature_before" json:"temperature_before" form:"temperature_before"`
85
+	PulseFrequencyBefore         float64 `gorm:"column:pulse_frequency_before" json:"pulse_frequency_before" form:"pulse_frequency_before"`
86
+	BreathingRateBefore          float64 `gorm:"column:breathing_rate_before" json:"breathing_rate_before" form:"breathing_rate_before"`
87
+	SystolicBloodPressureBefore  float64 `gorm:"column:systolic_blood_pressure_before" json:"systolic_blood_pressure_before" form:"systolic_blood_pressure_before"`
88
+	DiastolicBloodPressureBefore float64 `gorm:"column:diastolic_blood_pressure_before" json:"diastolic_blood_pressure_before" form:"diastolic_blood_pressure_before"`
89
+	WeightAfter                  float64 `gorm:"column:weightafter" json:"weightafter" form:"weightafter"`
90
+	TemperatureAfter             float64 `gorm:"column:temperature_after" json:"temperature_after" form:"temperature_after"`
91
+	PulseFrequencyAfter          float64 `gorm:"column:pulse_frequency_after" json:"pulse_frequency_after" form:"pulse_frequency_after"`
92
+	BreathingRateAfter           float64 `gorm:"column:breathing_rate_after" json:"breathing_rate_after" form:"breathing_rate_after"`
93
+	SystolicBloodPressureAfter   float64 `gorm:"column:systolic_blood_pressure_after" json:"systolic_blood_pressure_after" form:"systolic_blood_pressure_after"`
94
+	DiastolicBloodPressureAfter  float64 `gorm:"column:diastolic_blood_pressure_after" json:"diastolic_blood_pressure_after" form:"diastolic_blood_pressure_after"`
95
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
96
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
97
+	WeighBeforeTime              int64   `gorm:"column:weigh_before_time" json:"weigh_before_time" form:"weigh_before_time"`
98
+	WeighTime                    int64   `gorm:"column:weigh_time" json:"weigh_time" form:"weigh_time"`
99
+}
100
+
101
+func (SignWeight) TableName() string {
102
+
103
+	return "xt_sign_weight"
104
+}

+ 303 - 0
models/stock_models.go View File

@@ -0,0 +1,303 @@
1
+package models
2
+
3
+type Manufacturer struct {
4
+	ID               int64  `gorm:"column:id" json:"id"`
5
+	ManufacturerName string `gorm:"column:manufacturer_name" json:"manufacturer_name"`
6
+	Contact          string `gorm:"column:contact" json:"contact"`
7
+	ContactPhone     string `gorm:"column:contact_phone" json:"contact_phone"`
8
+	PlatformNumber   string `gorm:"column:platform_number" json:"platform_number"`
9
+	Email            string `gorm:"column:email" json:"email"`
10
+	ContactAddress   string `gorm:"column:contact_address" json:"contact_address"`
11
+	Remark           string `gorm:"column:remark" json:"remark"`
12
+	Creater          int64  `gorm:"column:creater" json:"creater"`
13
+	Modifier         int64  `gorm:"column:modifier" json:"modifier"`
14
+	Ctime            int64  `gorm:"column:ctime" json:"ctime"`
15
+	Mtime            int64  `gorm:"column:mtime" json:"mtime"`
16
+	OrgId            int64  `gorm:"column:org_id" json:"org_id"`
17
+	Status           int64  `gorm:"column:status" json:"status"`
18
+	ManufacturerCode string `gorm:"column:manufacturer_code" json:"manufacturer_code"`
19
+}
20
+
21
+func (Manufacturer) TableName() string {
22
+	return "xt_manufacturer"
23
+}
24
+
25
+type Dealer struct {
26
+	ID             int64  `gorm:"column:id" json:"id"`
27
+	DealerName     string `gorm:"column:dealer_name" json:"dealer_name"`
28
+	Contact        string `gorm:"column:contact" json:"contact"`
29
+	ContactPhone   string `gorm:"column:contact_phone" json:"contact_phone"`
30
+	PlatformNumber string `gorm:"column:platform_number" json:"platform_number"`
31
+	Email          string `gorm:"column:email" json:"email"`
32
+	ContactAddress string `gorm:"column:contact_address" json:"contact_address"`
33
+	Remark         string `gorm:"column:remark" json:"remark"`
34
+	Creater        int64  `gorm:"column:creater" json:"creater"`
35
+	Modifier       int64  `gorm:"column:modifier" json:"modifier"`
36
+	Ctime          int64  `gorm:"column:ctime" json:"ctime"`
37
+	Mtime          int64  `gorm:"column:mtime" json:"mtime"`
38
+	OrgId          int64  `gorm:"column:org_id" json:"org_id"`
39
+	Status         int64  `gorm:"column:status" json:"status"`
40
+	DealerCode     string `gorm:"column:dealer_code" json:"dealer_code"`
41
+}
42
+
43
+func (Dealer) TableName() string {
44
+	return "xt_dealer"
45
+}
46
+
47
+type Warehousing struct {
48
+	ID               int64        `gorm:"column:id" json:"id"`
49
+	WarehousingOrder string       `gorm:"column:warehousing_order" json:"warehousing_order"`
50
+	OperationTime    int64        `gorm:"column:operation_time" json:"operation_time"`
51
+	OrgId            int64        `gorm:"column:org_id" json:"org_id"`
52
+	Creater          int64        `gorm:"column:creater" json:"creater"`
53
+	Ctime            int64        `gorm:"column:ctime" json:"ctime"`
54
+	Modifier         int64        `gorm:"column:modifier" json:"modifier"`
55
+	Mtime            int64        `gorm:"column:mtime" json:"mtime"`
56
+	Status           int64        `gorm:"column:status" json:"status"`
57
+	WarehousingTime  int64        `gorm:"column:warehousing_time" json:"warehousing_time"`
58
+	Dealer           int64        `gorm:"column:dealer" json:"dealer"`
59
+	Manufacturer     int64        `gorm:"column:manufacturer" json:"manufacturer"`
60
+	Manufacturers    Manufacturer `gorm:"ForeignKey:ID;AssociationForeignKey:Manufacturer" json:"Manufacturer"`
61
+	Dealers          Dealer       `gorm:"ForeignKey:ID;AssociationForeignKey:Dealer" json:"Dealer"`
62
+	Type             int64        `gorm:"column:type" json:"type"`
63
+}
64
+
65
+func (Warehousing) TableName() string {
66
+	return "xt_warehouse"
67
+}
68
+
69
+type WarehousingInfo struct {
70
+	ID               int64       `gorm:"column:id" json:"id"`
71
+	WarehousingId    int64       `gorm:"column:warehousing_id" json:"warehousing_id"`
72
+	GoodId           int64       `gorm:"column:good_id" json:"good_id"`
73
+	GoodTypeId       int64       `gorm:"column:good_type_id" json:"good_type_id"`
74
+	Number           string      `gorm:"column:number" json:"number"`
75
+	ProductDate      int64       `gorm:"column:product_date" json:"product_date"`
76
+	ExpiryDate       int64       `gorm:"column:expiry_date" json:"expiry_date"`
77
+	WarehousingCount int64       `gorm:"column:warehousing_count" json:"warehousing_count"`
78
+	Price            float64     `gorm:"column:price" json:"price"`
79
+	TotalPrice       float64     `gorm:"column:total_price" json:"total_price"`
80
+	Dealer           int64       `gorm:"column:dealer" json:"dealer"`
81
+	Manufacturer     int64       `gorm:"column:manufacturer" json:"manufacturer"`
82
+	Remark           string      `gorm:"column:remark" json:"remark"`
83
+	Ctime            int64       `gorm:"column:ctime" json:"ctime"`
84
+	Mtime            int64       `gorm:"column:mtime" json:"mtime"`
85
+	Status           int64       `gorm:"column:status" json:"status"`
86
+	OrgId            int64       `gorm:"column:org_id" json:"org_id"`
87
+	IsReturn         int64       `gorm:"column:is_return" json:"is_return"`
88
+	Warehousing      Warehousing `ForeignKey:WarehousingId json:"warehouse"`
89
+	WarehousingOrder string      `gorm:"column:warehousing_order" json:"warehousing_order"`
90
+	GoodInfo         GoodInfo    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
91
+	Type             int64       `gorm:"column:type" json:"type"`
92
+}
93
+
94
+func (WarehousingInfo) TableName() string {
95
+	return "xt_warehouse_info"
96
+}
97
+
98
+type WarehouseOut struct {
99
+	ID                      int64        `gorm:"column:id" json:"id"`
100
+	WarehouseOutOrderNumber string       `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
101
+	OperationTime           int64        `gorm:"column:operation_time" json:"operation_time"`
102
+	Creater                 int64        `gorm:"column:creater" json:"creater"`
103
+	OrgId                   int64        `gorm:"column:org_id" json:"org_id"`
104
+	Modifier                int64        `gorm:"column:modifier" json:"modifier"`
105
+	Remark                  string       `gorm:"column:remark" json:"remark"`
106
+	Ctime                   int64        `gorm:"column:ctime" json:"ctime"`
107
+	Mtime                   int64        `gorm:"column:mtime" json:"mtime"`
108
+	Status                  int64        `gorm:"column:status" json:"status"`
109
+	WarehouseOutTime        int64        `gorm:"column:warehouse_out_time" json:"warehouse_out_time"`
110
+	Dealer                  int64        `gorm:"column:dealer" json:"dealer"`
111
+	Manufacturer            int64        `gorm:"column:manufacturer" json:"manufacturer"`
112
+	Manufacturers           Manufacturer `gorm:"ForeignKey:ID;AssociationForeignKey:Manufacturer" json:"Manufacturer"`
113
+	Dealers                 Dealer       `gorm:"ForeignKey:ID;AssociationForeignKey:Dealer" json:"Dealer"`
114
+	Type                    int64        `gorm:"column:type" json:"type"`
115
+	IsSys                   int64        `gorm:"column:is_sys" json:"is_sys"`
116
+}
117
+
118
+func (WarehouseOut) TableName() string {
119
+	return "xt_warehouse_out"
120
+}
121
+
122
+type WarehouseOutInfo struct {
123
+	ID                      int64        `gorm:"column:id" json:"id"`
124
+	WarehouseOutId          int64        `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
125
+	GoodId                  int64        `gorm:"column:good_id" json:"good_id"`
126
+	GoodTypeId              int64        `gorm:"column:good_type_id" json:"good_type_id"`
127
+	WarehousingOutTarget    int64        `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
128
+	Count                   int64        `gorm:"column:count" json:"count"`
129
+	Price                   float64      `gorm:"column:price" json:"price"`
130
+	TotalPrice              float64      `gorm:"column:total_price" json:"total_price"`
131
+	ProductDate             int64        `gorm:"column:product_date" json:"product_date"`
132
+	ExpiryDate              int64        `gorm:"column:expiry_date" json:"expiry_date"`
133
+	Mtime                   int64        `gorm:"column:mtime" json:"mtime"`
134
+	Ctime                   int64        `gorm:"column:ctime" json:"ctime"`
135
+	Status                  int64        `gorm:"column:status" json:"status"`
136
+	OrgId                   int64        `gorm:"column:org_id" json:"org_id"`
137
+	Remark                  string       `gorm:"column:remark" json:"remark"`
138
+	IsCancel                int64        `gorm:"column:is_cancel" json:"is_cancel"`
139
+	WarehouseOut            WarehouseOut `ForeignKey:WarehouseOutId json:"WarehouseOut"`
140
+	WarehouseOutOrderNumber string       `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
141
+	GoodInfo                GoodInfo     `gorm:"ForeignKey:ID;AssociationForeignKey:GoodId" `
142
+	Type                    int64        `gorm:"column:type" json:"type"`
143
+	Dealer                  int64        `gorm:"column:dealer" json:"dealer"`
144
+	Manufacturer            int64        `gorm:"column:manufacturer" json:"manufacturer"`
145
+	IsSys                   int64        `gorm:"column:is_sys" json:"is_sys"`
146
+	SysRecordTime           int64        `gorm:"column:sys_record_time" json:"sys_record_time"`
147
+}
148
+
149
+func (WarehouseOutInfo) TableName() string {
150
+	return "xt_warehouse_out_info"
151
+}
152
+
153
+type SalesReturn struct {
154
+	ID           int64  `gorm:"column:id" json:"id"`
155
+	OrderNumber  string `gorm:"column:order_number" json:"order_number"`
156
+	OperaTime    int64  `gorm:"column:opera_time" json:"opera_time"`
157
+	Total        int64  `gorm:"column:total" json:"total"`
158
+	Creater      int64  `gorm:"column:creater" json:"creater"`
159
+	Ctime        int64  `gorm:"column:ctime" json:"ctime"`
160
+	Mtime        int64  `gorm:"column:mtime" json:"mtime"`
161
+	Status       int64  `gorm:"column:status" json:"status"`
162
+	OrgId        int64  `gorm:"column:org_id" json:"org_id"`
163
+	ReturnTime   int64  `gorm:"column:return_time" json:"return_time"`
164
+	Manufacturer int64  `gorm:"column:manufacturer" json:"manufacturer"`
165
+	Dealer       int64  `gorm:"column:dealer" json:"dealer"`
166
+	Type         int64  `gorm:"column:type" json:"type"`
167
+}
168
+
169
+func (SalesReturn) TableName() string {
170
+	return "xt_sales_return"
171
+}
172
+
173
+type SalesReturnInfo struct {
174
+	ID            int64       `gorm:"column:id" json:"id"`
175
+	GoodId        int64       `gorm:"column:good_id" json:"good_id"`
176
+	SalesReturnId int64       `gorm:"column:sales_return_id" json:"sales_return_id"`
177
+	GoodTypeId    int64       `gorm:"column:good_type_id" json:"good_type_id"`
178
+	Count         int64       `gorm:"column:count" json:"count"`
179
+	Price         float64     `gorm:"column:price" json:"price"`
180
+	Total         float64     `gorm:"column:total" json:"total"`
181
+	ProductDate   int64       `gorm:"column:product_date" json:"product_date"`
182
+	ExpiryDate    int64       `gorm:"column:expiry_date" json:"expiry_date"`
183
+	Ctime         int64       `gorm:"column:ctime" json:"ctime"`
184
+	Mtime         int64       `gorm:"column:mtime" json:"mtime"`
185
+	Status        int64       `gorm:"column:status" json:"status"`
186
+	OrgId         int64       `gorm:"column:org_id" json:"org_id"`
187
+	OrderNumber   string      `gorm:"column:order_number" json:"order_number"`
188
+	Type          int64       `gorm:"column:type" json:"type"`
189
+	SalesReturn   SalesReturn `ForeignKey:SalesReturnId json:"SalesReturn"`
190
+	Dealer        int64       `gorm:"column:dealer" json:"dealer"`
191
+	Manufacturer  int64       `gorm:"column:manufacturer" json:"manufacturer"`
192
+}
193
+
194
+func (SalesReturnInfo) TableName() string {
195
+	return "xt_sales_return_info"
196
+}
197
+
198
+type CancelStockInfo struct {
199
+	ID            int64       `gorm:"column:id" json:"id"`
200
+	GoodId        int64       `gorm:"column:good_id" json:"good_id"`
201
+	CancelStockId int64       `gorm:"column:cancel_stock_id" json:"cancel_stock_id"`
202
+	GoodTypeId    int64       `gorm:"column:good_type_id" json:"good_type_id"`
203
+	Count         int64       `gorm:"column:count" json:"count"`
204
+	Price         float64     `gorm:"column:price" json:"price"`
205
+	Total         float64     `gorm:"column:total" json:"total"`
206
+	ProductDate   int64       `gorm:"column:product_date" json:"product_date"`
207
+	ExpiryDate    int64       `gorm:"column:expiry_date" json:"expiry_date"`
208
+	Ctime         int64       `gorm:"column:ctime" json:"ctime"`
209
+	Mtime         int64       `gorm:"column:mtime" json:"mtime"`
210
+	Status        int64       `gorm:"column:status" json:"status"`
211
+	OrgId         int64       `gorm:"column:org_id" json:"org_id"`
212
+	OrderNumber   string      `gorm:"column:order_number" json:"order_number"`
213
+	Type          int64       `gorm:"column:type" json:"type"`
214
+	CancelStock   CancelStock `ForeignKey:CancelStockId json:"CancelStock"`
215
+	Dealer        int64       `gorm:"column:dealer" json:"dealer"`
216
+	Manufacturer  int64       `gorm:"column:manufacturer" json:"manufacturer"`
217
+}
218
+
219
+func (CancelStockInfo) TableName() string {
220
+	return "xt_cancel_stock_info"
221
+}
222
+
223
+type CancelStock struct {
224
+	ID           int64  `gorm:"column:id" json:"id"`
225
+	OrderNumber  string `gorm:"column:order_number" json:"order_number"`
226
+	OperaTime    int64  `gorm:"column:opera_time" json:"opera_time"`
227
+	Total        int64  `gorm:"column:total" json:"total"`
228
+	Creater      int64  `gorm:"column:creater" json:"creater"`
229
+	Ctime        int64  `gorm:"column:ctime" json:"ctime"`
230
+	Mtime        int64  `gorm:"column:mtime" json:"mtime"`
231
+	Status       int64  `gorm:"column:status" json:"status"`
232
+	OrgId        int64  `gorm:"column:org_id" json:"org_id"`
233
+	ReturnTime   int64  `gorm:"column:return_time" json:"return_time"`
234
+	Dealer       int64  `gorm:"column:dealer" json:"dealer"`
235
+	Manufacturer int64  `gorm:"column:manufacturer" json:"manufacturer"`
236
+	Type         int64  `gorm:"column:type" json:"type"`
237
+}
238
+
239
+func (CancelStock) TableName() string {
240
+	return "xt_cancel_stock"
241
+}
242
+
243
+type WarehousingGoodInfo struct {
244
+	ID                int64        `gorm:"column:id" json:"id"`
245
+	GoodCode          string       `gorm:"column:good_code" json:"good_code"`
246
+	SpecificationName string       `gorm:"column:specification_name" json:"specification_name"`
247
+	GoodTypeId        int64        `gorm:"column:good_type_id" json:"good_type_id"`
248
+	GoodUnit          int64        `gorm:"column:good_unit" json:"good_unit"`
249
+	Manufacturer      int64        `gorm:"column:manufacturer" json:"manufacturer"`
250
+	Dealer            int64        `gorm:"column:dealer" json:"dealer"`
251
+	Status            int64        `gorm:"column:status" json:"status"`
252
+	GoodsType         GoodsType    `gorm:"ForeignKey:ID;AssociationForeignKey:GoodTypeId" json:"type"`
253
+	Manufacturers     Manufacturer `gorm:"ForeignKey:Manufacturer;AssociationForeignKey:ID" json:"manufacturers"`
254
+	Dealers           Dealer       `gorm:"ForeignKey:Dealer;AssociationForeignKey:ID" json:"dealers"`
255
+	BuyPrice          float64      `gorm:"column:buy_price" json:"buy_price"`
256
+}
257
+
258
+func (WarehousingGoodInfo) TableName() string {
259
+	return "xt_good_information"
260
+}
261
+
262
+type WarehousingInfoConfig struct {
263
+	ID                  int64               `gorm:"column:id" json:"id"`
264
+	WarehousingId       int64               `gorm:"column:warehousing_id" json:"warehousing_id"`
265
+	GoodId              int64               `gorm:"column:good_id" json:"good_id"`
266
+	WarehousingGoodInfo WarehousingGoodInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"info"`
267
+}
268
+
269
+func (WarehousingInfoConfig) TableName() string {
270
+	return "xt_warehouse_info"
271
+}
272
+
273
+type WarehousingOutInfoConfig struct {
274
+	ID                  int64               `gorm:"column:id" json:"id"`
275
+	WarehouseOutId      int64               `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
276
+	GoodId              int64               `gorm:"column:good_id" json:"good_id"`
277
+	WarehousingGoodInfo WarehousingGoodInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"info"`
278
+}
279
+
280
+func (WarehousingOutInfoConfig) TableName() string {
281
+	return "xt_warehouse_out_info"
282
+}
283
+
284
+type AutomaticReduceDetail struct {
285
+	ID                      int64     `gorm:"column:id" json:"id"`
286
+	WarehouseOutId          int64     `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
287
+	WarehouseOutOrderNumber string    `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
288
+	PatientId               int64     `gorm:"column:patient_id" json:"patient_id"`
289
+	Ctime                   int64     `gorm:"column:ctime" json:"ctime"`
290
+	Mtime                   int64     `gorm:"column:mtime" json:"mtime"`
291
+	Status                  int64     `gorm:"column:status" json:"status"`
292
+	RecordTime              int64     `gorm:"column:record_time" json:"record_time"`
293
+	OrgId                   int64     `gorm:"column:org_id" json:"org_id"`
294
+	GoodId                  int64     `gorm:"column:good_id" json:"good_id"`
295
+	GoodTypeId              int64     `gorm:"column:good_type_id" json:"good_type_id"`
296
+	GoodInfo                GoodInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"info"`
297
+	GoodsType               GoodsType `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"type"`
298
+	Patients                Patients  `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"user"`
299
+}
300
+
301
+func (AutomaticReduceDetail) TableName() string {
302
+	return "xt_automatic_reduce_detail"
303
+}

+ 123 - 0
models/stock_query_models.go View File

@@ -0,0 +1,123 @@
1
+package models
2
+
3
+type StockInfo struct {
4
+	ID                int64  `gorm:"column:id" json:"id"`
5
+	GoodCode          string `gorm:"column:good_code" json:"good_code"`
6
+	SpecificationName string `gorm:"column:specification_name" json:"specification_name"`
7
+	GoodTypeId        int64  `gorm:"column:good_type_id" json:"good_type_id"`
8
+	GoodUnit          int64  `gorm:"column:good_unit" json:"good_unit"`
9
+
10
+	QueryWarehousingInfo  []QueryWarehousingInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"query_warehousing_info"`
11
+	QuerySalesReturnInfo  []QuerySalesReturnInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"query_sales_return_info"`
12
+	QueryWarehouseOutInfo []QueryWarehouseOutInfo `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"query_warehouseout_info"`
13
+	QueryCancelStockInfo  []QueryCancelStockInfo  `gorm:"ForeignKey:GoodId;AssociationForeignKey:ID" json:"query_cancel_stock_info"`
14
+	GoodsType             GoodsType               `gorm:"ForeignKey:GoodTypeId;AssociationForeignKey:ID" json:"type"`
15
+}
16
+
17
+func (StockInfo) TableName() string {
18
+	return "xt_good_information"
19
+}
20
+
21
+type QueryWarehousingInfo struct {
22
+	ID               int64   `gorm:"column:id" json:"id"`
23
+	WarehousingId    int64   `gorm:"column:warehousing_id" json:"warehousing_id"`
24
+	GoodId           int64   `gorm:"column:good_id" json:"good_id"`
25
+	GoodTypeId       int64   `gorm:"column:good_type_id" json:"good_type_id"`
26
+	Number           string  `gorm:"column:number" json:"number"`
27
+	ProductDate      int64   `gorm:"column:product_date" json:"product_date"`
28
+	ExpiryDate       int64   `gorm:"column:expiry_date" json:"expiry_date"`
29
+	WarehousingCount int64   `gorm:"column:warehousing_count" json:"warehousing_count"`
30
+	Price            float64 `gorm:"column:price" json:"price"`
31
+	TotalPrice       float64 `gorm:"column:total_price" json:"total_price"`
32
+	Dealer           int64   `gorm:"column:dealer" json:"dealer"`
33
+	Manufacturer     int64   `gorm:"column:manufacturer" json:"manufacturer"`
34
+	Remark           string  `gorm:"column:remark" json:"remark"`
35
+	Ctime            int64   `gorm:"column:ctime" json:"ctime"`
36
+	Mtime            int64   `gorm:"column:mtime" json:"mtime"`
37
+	Status           int64   `gorm:"column:status" json:"status"`
38
+	OrgId            int64   `gorm:"column:org_id" json:"org_id"`
39
+	IsReturn         int64   `gorm:"column:is_return" json:"is_return"`
40
+	WarehousingOrder string  `gorm:"column:warehousing_order" json:"warehousing_order"`
41
+	Type             int64   `gorm:"column:type" json:"type"`
42
+}
43
+
44
+func (QueryWarehousingInfo) TableName() string {
45
+	return "xt_warehouse_info"
46
+}
47
+
48
+type QueryWarehouseOutInfo struct {
49
+	ID                      int64   `gorm:"column:id" json:"id"`
50
+	WarehouseOutId          int64   `gorm:"column:warehouse_out_id" json:"warehouse_out_id"`
51
+	GoodId                  int64   `gorm:"column:good_id" json:"good_id"`
52
+	GoodTypeId              int64   `gorm:"column:good_type_id" json:"good_type_id"`
53
+	WarehousingOutTarget    int64   `gorm:"column:warehousing_out_target" json:"warehousing_out_target"`
54
+	Count                   int64   `gorm:"column:count" json:"count"`
55
+	Price                   float64 `gorm:"column:price" json:"price"`
56
+	TotalPrice              float64 `gorm:"column:total_price" json:"total_price"`
57
+	ProductDate             int64   `gorm:"column:product_date" json:"product_date"`
58
+	ExpiryDate              int64   `gorm:"column:expiry_date" json:"expiry_date"`
59
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime"`
60
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime"`
61
+	Status                  int64   `gorm:"column:status" json:"status"`
62
+	OrgId                   int64   `gorm:"column:org_id" json:"org_id"`
63
+	Remark                  string  `gorm:"column:remark" json:"remark"`
64
+	IsCancel                int64   `gorm:"column:is_cancel" json:"is_cancel"`
65
+	WarehouseOutOrderNumber string  `gorm:"column:warehouse_out_order_number" json:"warehouse_out_order_number"`
66
+	Type                    int64   `gorm:"column:type" json:"type"`
67
+	Dealer                  int64   `gorm:"column:dealer" json:"dealer"`
68
+	Manufacturer            int64   `gorm:"column:manufacturer" json:"manufacturer"`
69
+	IsSys                   int64   `gorm:"column:is_sys" json:"is_sys"`
70
+	SysRecordTime           int64   `gorm:"column:sys_record_time" json:"sys_record_time"`
71
+}
72
+
73
+func (QueryWarehouseOutInfo) TableName() string {
74
+	return "xt_warehouse_out_info"
75
+}
76
+
77
+type QuerySalesReturnInfo struct {
78
+	ID            int64   `gorm:"column:id" json:"id"`
79
+	GoodId        int64   `gorm:"column:good_id" json:"good_id"`
80
+	SalesReturnId int64   `gorm:"column:sales_return_id" json:"sales_return_id"`
81
+	GoodTypeId    int64   `gorm:"column:good_type_id" json:"good_type_id"`
82
+	Count         int64   `gorm:"column:count" json:"count"`
83
+	Price         float64 `gorm:"column:price" json:"price"`
84
+	Total         float64 `gorm:"column:total" json:"total"`
85
+	ProductDate   int64   `gorm:"column:product_date" json:"product_date"`
86
+	ExpiryDate    int64   `gorm:"column:expiry_date" json:"expiry_date"`
87
+	Ctime         int64   `gorm:"column:ctime" json:"ctime"`
88
+	Mtime         int64   `gorm:"column:mtime" json:"mtime"`
89
+	Status        int64   `gorm:"column:status" json:"status"`
90
+	OrgId         int64   `gorm:"column:org_id" json:"org_id"`
91
+	OrderNumber   string  `gorm:"column:order_number" json:"order_number"`
92
+	Type          int64   `gorm:"column:type" json:"type"`
93
+	Dealer        int64   `gorm:"column:dealer" json:"dealer"`
94
+	Manufacturer  int64   `gorm:"column:manufacturer" json:"manufacturer"`
95
+}
96
+
97
+func (QuerySalesReturnInfo) TableName() string {
98
+	return "xt_sales_return_info"
99
+}
100
+
101
+type QueryCancelStockInfo struct {
102
+	ID            int64   `gorm:"column:id" json:"id"`
103
+	GoodId        int64   `gorm:"column:good_id" json:"good_id"`
104
+	CancelStockId int64   `gorm:"column:cancel_stock_id" json:"cancel_stock_id"`
105
+	GoodTypeId    int64   `gorm:"column:good_type_id" json:"good_type_id"`
106
+	Count         int64   `gorm:"column:count" json:"count"`
107
+	Price         float64 `gorm:"column:price" json:"price"`
108
+	Total         float64 `gorm:"column:total" json:"total"`
109
+	ProductDate   int64   `gorm:"column:product_date" json:"product_date"`
110
+	ExpiryDate    int64   `gorm:"column:expiry_date" json:"expiry_date"`
111
+	Ctime         int64   `gorm:"column:ctime" json:"ctime"`
112
+	Mtime         int64   `gorm:"column:mtime" json:"mtime"`
113
+	Status        int64   `gorm:"column:status" json:"status"`
114
+	OrgId         int64   `gorm:"column:org_id" json:"org_id"`
115
+	OrderNumber   string  `gorm:"column:order_number" json:"order_number"`
116
+	Type          int64   `gorm:"column:type" json:"type"`
117
+	Dealer        int64   `gorm:"column:dealer" json:"dealer"`
118
+	Manufacturer  int64   `gorm:"column:manufacturer" json:"manufacturer"`
119
+}
120
+
121
+func (QueryCancelStockInfo) TableName() string {
122
+	return "xt_cancel_stock_info"
123
+}

+ 11 - 0
models/subscibe_state_models.go View File

@@ -0,0 +1,11 @@
1
+package models
2
+
3
+type ServeSubscibeState struct {
4
+	ServeSubscibe
5
+
6
+	State int64 `gorm:"-" json:"state"`
7
+}
8
+
9
+func (ServeSubscibeState) TableName() string {
10
+	return "sgj_serve_subscibe"
11
+}

+ 104 - 0
models/user_models.go View File

@@ -0,0 +1,104 @@
1
+package models
2
+
3
+type SgjCustomer struct {
4
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
5
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
6
+	UserId          int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
7
+	Mobile          string `gorm:"column:mobile" json:"mobile" form:"mobile"`
8
+	Name            string `gorm:"column:name" json:"name" form:"name"`
9
+	Gender          int64  `gorm:"column:gender" json:"gender" form:"gender"`
10
+	ProvinceId      int64  `gorm:"column:province_id" json:"province_id" form:"province_id"`
11
+	CityId          int64  `gorm:"column:city_id" json:"city_id" form:"city_id"`
12
+	Address         string `gorm:"column:address" json:"address" form:"address"`
13
+	Birthday        int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
14
+	TreatType       int64  `gorm:"column:treat_type" json:"treat_type" form:"treat_type"`
15
+	Relationship    int64  `gorm:"column:relationship" json:"relationship" form:"relationship"`
16
+	IllnessId       int64  `gorm:"column:illness_id" json:"illness_id" form:"illness_id"`
17
+	WechatOpenid    string `gorm:"column:wechat_openid" json:"wechat_openid" form:"wechat_openid"`
18
+	Membership      int64  `gorm:"column:membership" json:"membership" form:"membership"`
19
+	Sources         int64  `gorm:"column:sources" json:"sources" form:"sources"`
20
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
21
+	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
22
+	UpdatedTime     int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
23
+	Avatar          string `gorm:"column:avatar" json:"avatar" form:"avatar"`
24
+	WechatUnionid   string `gorm:"column:wechat_unionid" json:"wechat_unionid" form:"wechat_unionid"`
25
+	Remark          string `gorm:"column:remark" json:"remark" form:"remark"`
26
+	MedicalDiagnose string `gorm:"column:medical_diagnose" json:"medical_diagnose" form:"medical_diagnose"`
27
+	YzUid           int64  `gorm:"column:yz_uid" json:"yz_uid" form:"yz_uid"`
28
+	IllDate         int64  `gorm:"column:ill_date" json:"ill_date" form:"ill_date"`
29
+	DistrictId      int64  `gorm:"column:district_id" json:"district_id" form:"district_id"`
30
+}
31
+
32
+func (SgjCustomer) TableName() string {
33
+	return "sgj_user_customer"
34
+}
35
+
36
+type SgjUser struct {
37
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
38
+	Password        string `gorm:"column:password" json:"password" form:"password"`
39
+	Mobile          string `gorm:"column:mobile" json:"mobile" form:"mobile"`
40
+	Username        string `gorm:"column:username" json:"username" form:"username"`
41
+	Remarkname      string `gorm:"column:remarkname" json:"remarkname" form:"remarkname"`
42
+	Realname        string `gorm:"column:realname" json:"realname" form:"realname"`
43
+	Introduce       string `gorm:"column:introduce" json:"introduce" form:"introduce"`
44
+	Avatar          string `gorm:"column:avatar" json:"avatar" form:"avatar"`
45
+	AvatarThumb     string `gorm:"column:avatar_thumb" json:"avatar_thumb" form:"avatar_thumb"`
46
+	Gender          int64  `gorm:"column:gender" json:"gender" form:"gender"`
47
+	ReceivingPhone  string `gorm:"column:receiving_phone" json:"receiving_phone" form:"receiving_phone"`
48
+	ProvinceId      int64  `gorm:"column:province_id" json:"province_id" form:"province_id"`
49
+	CityId          int64  `gorm:"column:city_id" json:"city_id" form:"city_id"`
50
+	DistrictId      int64  `gorm:"column:district_id" json:"district_id" form:"district_id"`
51
+	Birthday        int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
52
+	Address         string `gorm:"column:address" json:"address" form:"address"`
53
+	Recipient       string `gorm:"column:recipient" json:"recipient" form:"recipient"`
54
+	TreatType       int64  `gorm:"column:treat_type" json:"treat_type" form:"treat_type"`
55
+	Token           string `gorm:"column:token" json:"token" form:"token"`
56
+	Imei            string `gorm:"column:imei" json:"imei" form:"imei"`
57
+	Relationship    int64  `gorm:"column:relationship" json:"relationship" form:"relationship"`
58
+	Platform        string `gorm:"column:platform" json:"platform" form:"platform"`
59
+	IllnessId       int64  `gorm:"column:illness_id" json:"illness_id" form:"illness_id"`
60
+	Sources         int64  `gorm:"column:sources" json:"sources" form:"sources"`
61
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
62
+	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
63
+	UpdatedTime     int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
64
+	WechatOpenid    string `gorm:"column:wechat_openid" json:"wechat_openid" form:"wechat_openid"`
65
+	MedicalDiagnose string `gorm:"column:medical_diagnose" json:"medical_diagnose" form:"medical_diagnose"`
66
+}
67
+
68
+func (SgjUser) TableName() string {
69
+	return "sgj_user_user"
70
+}
71
+
72
+type SgjPatientDryweight struct {
73
+	ID            int64   `gorm:"column:id" json:"id" form:"id"`
74
+	DryWeight     float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
75
+	Creator       int64   `gorm:"column:creator" json:"creator" form:"creator"`
76
+	Remakes       string  `gorm:"column:remakes" json:"remakes" form:"remakes"`
77
+	PatientId     int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
78
+	Ctime         int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
79
+	Mtime         int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
80
+	Status        int64   `gorm:"column:status" json:"status" form:"status"`
81
+	AdjustedValue string  `gorm:"column:adjusted_value" json:"adjusted_value" form:"adjusted_value"`
82
+	UserOrgId     int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
83
+	UserId        int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
84
+}
85
+
86
+func (SgjPatientDryweight) TableName() string {
87
+
88
+	return "xt_patient_dryweight"
89
+}
90
+
91
+type XtPatientDryweight struct {
92
+	ID            int64   `gorm:"column:id" json:"id" form:"id"`
93
+	DryWeight     float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
94
+	Creator       int64   `gorm:"column:creator" json:"creator" form:"creator"`
95
+	Remakes       string  `gorm:"column:remakes" json:"remakes" form:"remakes"`
96
+	PatientId     int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
97
+	Ctime         int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
98
+	Mtime         int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
99
+	Status        int64   `gorm:"column:status" json:"status" form:"status"`
100
+	AdjustedValue string  `gorm:"column:adjusted_value" json:"adjusted_value" form:"adjusted_value"`
101
+	UserOrgId     int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
102
+	UserId        int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
103
+	UserName      string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
104
+}

+ 58 - 0
routers/router.go View File

@@ -0,0 +1,58 @@
1
+package routers
2
+
3
+import (
4
+	"XT_New/controllers"
5
+	admin_api "XT_New/controllers/admin_api_controllers"
6
+	m_api "XT_New/controllers/mobile_api_controllers"
7
+
8
+	"github.com/astaxie/beego"
9
+	"github.com/astaxie/beego/plugins/cors"
10
+)
11
+
12
+func init() {
13
+	beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
14
+		// AllowAllOrigins:  true,
15
+		AllowOrigins: []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com", "https://xt.test.shengws.com", "http://xt.test.sgjyun.com", "https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com", "https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com", "http://mobile.sgjyun.com", "http://mobile.kuyicloud.com"},
16
+		//AllowOrigins:     []string{"https://xt.kuyicloud.com", "http://localhost:9528", "http://xt.test.shengws.com","https://xt.test.shengws.com", "http://xt.test.sgjyun.com","https://xt.test.sgjyun.com", "http://localhost:8081", "http://localhost:8082", "https://pad.kuyicloud.com", "http://pad.kuyicloud.com", "http://pad.test.sgjyun.com","https://pad.test.sgjyun.com", "http://admin.xt.test.sgjyun.com", "http://admin.xt.kuyicloud.com","http://mobile.sgjyun.com","http://mobile.kuyicloud.com"},
17
+		AllowMethods:     []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
18
+		AllowHeaders:     []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type", "X-XSRF-TOKEN", "Permission"},
19
+		ExposeHeaders:    []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
20
+		AllowCredentials: true,
21
+	}))
22
+
23
+	// beego.Router("/", &controllers.MainController{})
24
+
25
+	controllers.VerifyUserLoginControllerRegistRouters()
26
+	controllers.RoleAPIControllerRegistRouters()
27
+	controllers.PatientApiRegistRouters()
28
+	controllers.DialysisApiRegistRouters()
29
+	controllers.QiniuApiRegistRouters()
30
+	controllers.DataApiRegistRouters()
31
+	controllers.DoctorApiRegistRouters()
32
+	controllers.PublicApiRegistRouters()
33
+	controllers.DeviceAPIControllerRegistRouters()
34
+	controllers.PayApiRegistRouters()
35
+	controllers.ScheduleApiRegistRouters()
36
+	controllers.SignWeighAPIControllerRegistRouters()
37
+	controllers.InvoiceApiRegistRouters()
38
+	controllers.StockApiRegistRouters()
39
+	controllers.StockGoodApiRegistRouters()
40
+	controllers.StockManagerApiRegistRouters()
41
+	controllers.PatientScheduleTemplateAPIControllerRegistRouters()
42
+	controllers.DialysisRecordAPIControllerRegistRouter()
43
+	controllers.InspectionApiRegistRouters()
44
+	controllers.StatisticsApiRegistRouters()
45
+	controllers.PatientDataConfigAPIControllerRegistRouters()
46
+	controllers.PrintDataAPIControllerRegistRouters()
47
+	controllers.DialysisBoardAPIControllerRegistRouter()
48
+	controllers.QcdApiRegistRouters()
49
+	controllers.OrgInfoApiRegistRouters()
50
+	controllers.DistrictApiRegistRouters()
51
+	controllers.GobalConfigRegistRouters()
52
+	controllers.IntegrationConfigRegistRouters()
53
+
54
+	m_api.MobileAPIControllersRegisterRouters()
55
+	admin_api.AdminAPIControllersRegisterRouters()
56
+
57
+	controllers.ManageRouters()
58
+}

+ 353 - 0
service/admin_service.go View File

@@ -0,0 +1,353 @@
1
+// 统计后台的 service
2
+
3
+package service
4
+
5
+import (
6
+	"XT_New/models"
7
+	"XT_New/models/admin_models"
8
+	"time"
9
+
10
+	"github.com/jinzhu/gorm"
11
+)
12
+
13
+func GetAdminAccount(account string, password string) (*admin_models.AdminAccount, error) {
14
+	var model admin_models.AdminAccount
15
+	err := readUserDb.Where("account = ? AND pwd = ? AND status = 1", account, password).First(&model).Error
16
+	if err != nil {
17
+		if err == gorm.ErrRecordNotFound {
18
+			return nil, nil
19
+		}
20
+		return nil, err
21
+	}
22
+	return &model, nil
23
+}
24
+
25
+// 获取总机构数
26
+func GetTotalOrgCount() (int, error) {
27
+	var count int
28
+	err := readUserDb.Model(&models.Org{}).Where("status <> 0").Count(&count).Error
29
+	if err != nil {
30
+		return 0, err
31
+	}
32
+	return count, nil
33
+}
34
+
35
+// 获取一段时间内注册的机构数量
36
+func GetRegistedOrgCountFromDayToDay(from time.Time, to time.Time) (int, error) {
37
+	var count int
38
+	err := readUserDb.Model(&models.Org{}).Where("status <> 0 AND ctime >= ? AND ctime <= ?", from.Unix(), to.Unix()).Count(&count).Error
39
+	if err != nil {
40
+		return 0, err
41
+	}
42
+	return count, nil
43
+}
44
+
45
+// 获取一段时间内注册的机构
46
+func GetRegistedOrgsFromDayToDay(from time.Time, to time.Time) ([]*models.Org, error) {
47
+	var orgs []*models.Org
48
+	err := readUserDb.Model(&models.Org{}).Where("status <> 0 AND ctime >= ? AND ctime <= ?", from.Unix(), to.Unix()).Find(&orgs).Error
49
+	if err != nil {
50
+		return nil, err
51
+	}
52
+	return orgs, nil
53
+}
54
+
55
+// 获取一段时间内的活跃机构数
56
+func GetActiveOrgCountFromDayToDay(from time.Time, to time.Time) (int, error) {
57
+	var count int
58
+	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_user_admin_login_log WHERE ctime >= ? AND ctime <= ?", from.Unix(), to.Unix()).Rows()
59
+	if err != nil {
60
+		return 0, err
61
+	}
62
+	if rows.Next() {
63
+		rows.Scan(&count)
64
+	}
65
+	return count, nil
66
+}
67
+
68
+type ActiveOrgListVM struct {
69
+	models.Org
70
+	ActiveTime int64 `gorm:"column:active_time" json:"active_time"`
71
+}
72
+
73
+// 获取一段时间内的活跃机构
74
+func GetActiveOrgsFromDayToDay(from time.Time, to time.Time) ([]*ActiveOrgListVM, error) {
75
+	var orgs []*ActiveOrgListVM
76
+	err := readUserDb.Raw("select * from (select log.org_id, org.*, log.ctime as active_time from sgj_user_admin_login_log as log left join sgj_user_org as org on log.org_id = org.id where log.ctime >= ? AND log.ctime <= ? AND org.status <> 0 order by log.ctime desc) as t group by t.org_id;", from.Unix(), to.Unix()).Scan(&orgs).Error
77
+	if err != nil {
78
+		return nil, err
79
+	}
80
+	return orgs, nil
81
+}
82
+
83
+// 获取一段时间内的活跃账户数
84
+func GetActiveAdminUserCountFromDayToDay(from time.Time, to time.Time) (int, error) {
85
+	var count int
86
+	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT admin_user_id) AS count FROM sgj_user_admin_login_log WHERE ctime >= ? AND ctime <= ? AND operate_type = 1", from.Unix(), to.Unix()).Rows()
87
+	if err != nil {
88
+		return 0, err
89
+	}
90
+	if rows.Next() {
91
+		rows.Scan(&count)
92
+	}
93
+	return count, nil
94
+}
95
+
96
+type ActiveAdminUserListVM struct {
97
+	models.App_Role
98
+	OrgName    string `gorm:"column:org_name" json:"org_name"`
99
+	ActiveTime int64  `gorm:"column:active_time" json:"active_time"`
100
+}
101
+
102
+// 获取一段时间内的活跃账户
103
+func GetActiveAdminUsersFromDayToDay(from time.Time, to time.Time) ([]*ActiveAdminUserListVM, error) {
104
+	var users []*ActiveAdminUserListVM
105
+	err := readUserDb.Raw("select * from (select log.admin_user_id as uid, admin.*, org.org_name, log.ctime as active_time from sgj_user_admin_login_log as log left join sgj_user_admin_role as admin on log.admin_user_id = admin.admin_user_id left join sgj_user_org as org on log.org_id = org.id where log.ctime >= ? AND log.ctime <= ? AND log.operate_type = 1 AND admin.status > 0 order by log.ctime desc) as t group by t.uid;", from.Unix(), to.Unix()).Scan(&users).Error
106
+	if err != nil {
107
+		return nil, err
108
+	}
109
+	return users, nil
110
+}
111
+
112
+// 获取即将到期机构数
113
+func GetWillExpireOrgCountFromDayToDay(from time.Time, to time.Time) (int, error) {
114
+	var count int
115
+	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_serve_subscibe WHERE period_end >= ? AND period_end <= ? AND state <> 9 GROUP BY org_id;", from.Unix(), to.Unix()).Rows()
116
+	if err != nil {
117
+		return 0, err
118
+	}
119
+	if rows.Next() {
120
+		rows.Scan(&count)
121
+	}
122
+	return count, nil
123
+}
124
+
125
+// 获取已到期机构数
126
+func GetDidExpiredOrgCountFromDayToDay(from time.Time, to time.Time) (int, error) {
127
+	var count int
128
+	rows, err := readUserDb.Raw("SELECT COUNT(DISTINCT org_id) AS count FROM sgj_serve_subscibe WHERE period_end >= ? AND period_end <= ? AND state <> 9 GROUP BY org_id;", from.Unix(), to.Unix()).Rows()
129
+	if err != nil {
130
+		return 0, err
131
+	}
132
+	if rows.Next() {
133
+		rows.Scan(&count)
134
+	}
135
+	return count, nil
136
+}
137
+
138
+type ExpireOrgListVM struct {
139
+	OrgID      int64  `gorm:"column:org_id" json:"org_id"`
140
+	OrgName    string `gorm:"column:org_name" json:"org_name"`
141
+	PeriodEnd  int64  `gorm:"column:period_end" json:"period_end"`
142
+	Telephone  string `gorm:"column:telephone" json:"telephone"`
143
+	ExpireDays int    `gorm:"-" json:"expire_days"`
144
+}
145
+
146
+// 获取即将到期机构
147
+func GetWillExpireOrgsFromDayToDay(from time.Time, to time.Time) ([]*ExpireOrgListVM, error) {
148
+	var vms []*ExpireOrgListVM
149
+	err := readUserDb.Raw("select s_o.org_id, s_o.period_end, o.org_name, o.telephone from (select ss.* from (select s.org_id as org_id, s.id as sid, s.period_end from sgj_serve_subscibe as s where s.period_end <= ? AND s.period_end >= ? AND s.state <> 9 order by s.id desc) as ss group by ss.org_id) as s_o left join sgj_user_org as o on o.id = s_o.org_id", to.Unix(), from.Unix()).Scan(&vms).Error
150
+	if err != nil {
151
+		return nil, err
152
+	}
153
+	for _, vm := range vms {
154
+		vm.ExpireDays = time.Unix(vm.PeriodEnd, 0).Day() - from.Day()
155
+	}
156
+	return vms, nil
157
+}
158
+
159
+// 获取已到期机构
160
+func GetDidExpireOrgsFromDayToDay(from time.Time, to time.Time) ([]*ExpireOrgListVM, error) {
161
+	var vms []*ExpireOrgListVM
162
+	err := readUserDb.Raw("select s_o.org_id, s_o.period_end, o.org_name, o.telephone from (select ss.* from (select s.org_id as org_id, s.id as sid, s.period_end from sgj_serve_subscibe as s where s.period_end >= ? AND s.period_end <= ? AND s.state <> 9 order by s.id desc) as ss group by ss.org_id) as s_o left join sgj_user_org as o on o.id = s_o.org_id", from.Unix(), to.Unix()).Scan(&vms).Error
163
+	if err != nil {
164
+		return nil, err
165
+	}
166
+	for _, vm := range vms {
167
+		vm.ExpireDays = to.Day() - time.Unix(vm.PeriodEnd, 0).Day()
168
+	}
169
+	return vms, nil
170
+}
171
+
172
+// 获取一段时间内的透析次数
173
+func GetDialysisTimesFromDayToDay(from time.Time, to time.Time) (int, error) {
174
+	var count int
175
+	err := readDb.Model(&models.DialysisOrder{}).Where("status > 0 AND dialysis_date >= ? AND dialysis_date <= ?", from.Unix(), to.Unix()).Count(&count).Error
176
+	if err != nil {
177
+		return 0, err
178
+	}
179
+	return count, nil
180
+}
181
+
182
+// 获取一段时间内的监控次数
183
+func GetMonitoringTimesFromDayToDay(from time.Time, to time.Time) (int, error) {
184
+	var count int
185
+	err := readDb.Model(&models.MonitoringRecord{}).Where("status > 0 AND monitoring_date >= ? AND monitoring_date <= ?", from.Unix(), to.Unix()).Count(&count).Error
186
+	if err != nil {
187
+		return 0, err
188
+	}
189
+	return count, nil
190
+}
191
+
192
+// 获取一段时间内新增病人数量
193
+func GetNewPatientCountFromDayToDay(from time.Time, to time.Time) (int, error) {
194
+	var count int
195
+	err := readDb.Model(&models.Patients{}).Where("status > 0 AND created_time >= ? AND created_time <= ?", from.Unix(), to.Unix()).Count(&count).Error
196
+	if err != nil {
197
+		return 0, err
198
+	}
199
+	return count, nil
200
+}
201
+
202
+// 获取病人性别分布
203
+func GetPatientGenderDistribution() (int, int, int, error) {
204
+	var maleCount, femaleCount, unknowGenderCount int
205
+	rows, err := readDb.Raw("SELECT count(id), gender FROM xt_patients WHERE (status > 0) group by gender;").Rows()
206
+	if err != nil {
207
+		return 0, 0, 0, err
208
+	}
209
+	for rows.Next() {
210
+		var gender, count int
211
+		rows.Scan(&count, &gender)
212
+		if gender == 1 {
213
+			maleCount = count
214
+		} else if gender == 2 {
215
+			femaleCount = count
216
+		} else {
217
+			unknowGenderCount = count
218
+		}
219
+	}
220
+	return maleCount, femaleCount, unknowGenderCount, nil
221
+}
222
+
223
+// 获取某种传染病的病人数,diseaseType = 0时为没有传染病
224
+// 1乙肝 2丙肝 3艾滋病 4肺结核 5梅毒
225
+func GetInfectiousDiseasePatientCount(diseaseType int) (int, error) {
226
+	if diseaseType == 0 {
227
+		var count int
228
+		rows, err := readDb.Raw("select count(p.id) from xt_patients as p where id not in (select p_d.patient_id from xt_patients_infectious_diseases as p_d where status = 1 group by p_d.patient_id) and status = 1;").Rows()
229
+		if err != nil {
230
+			return 0, err
231
+		}
232
+		if rows.Next() {
233
+			rows.Scan(&count)
234
+		}
235
+		return count, nil
236
+
237
+	} else {
238
+		var count int
239
+		rows, err := readDb.Raw("select count(distinct patient_id) from xt_patients_infectious_diseases where status = 1 and disease_id = ?;", diseaseType).Rows()
240
+		if err != nil {
241
+			return 0, err
242
+		}
243
+		if rows.Next() {
244
+			rows.Scan(&count)
245
+		}
246
+		return count, nil
247
+	}
248
+}
249
+
250
+// 获取患者年龄分布
251
+func GetPatientAgeDistribution() ([]*PatientAgeCountStruct, error) {
252
+	var counts []*PatientAgeCountStruct
253
+	err := readDb.Raw(`SELECT nnd AS 'age',COUNT(*) AS 'count' FROM (
254
+		SELECT
255
+			CASE
256
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d'))<10 THEN '10'
257
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=10 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<20 THEN '20'
258
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=20 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<30 THEN '30'
259
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=30 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<40 THEN '40'
260
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=40 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<50 THEN '50'
261
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=50 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<60 THEN '60'
262
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=60 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<70 THEN '70'
263
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=70 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<80 THEN '80'
264
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=80 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<90 THEN '90'
265
+				WHEN (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )>=90 AND (YEAR(NOW())-DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%Y')-1) + (DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(0), INTERVAL birthday SECOND),'%m%d') <= DATE_FORMAT(NOW(), '%m%d') )<100 THEN '100'
266
+				ELSE '-1'
267
+			END
268
+		AS nnd FROM xt_patients where status=1
269
+	) a GROUP BY nnd;`).Scan(&counts).Error
270
+	if err != nil {
271
+		return nil, err
272
+	}
273
+	return counts, nil
274
+}
275
+
276
+func GetAdminUserElectronicSignature(orgID int64, appID int64, userID int64) (*models.AdminUserElectronicSignature, error) {
277
+	var es models.AdminUserElectronicSignature
278
+	err := readUserDb.Model(&models.AdminUserElectronicSignature{}).Where("org_id=? and app_id=? and creator=? and status=1", orgID, appID, userID).First(&es).Error
279
+
280
+	if err == gorm.ErrRecordNotFound {
281
+		return nil, nil
282
+	}
283
+	if err != nil {
284
+		return nil, err
285
+	}
286
+	return &es, nil
287
+}
288
+
289
+func CreateAdminUserElectronicSignature(es *models.AdminUserElectronicSignature) error {
290
+	err := writeUserDb.Create(es).Error
291
+	return err
292
+}
293
+
294
+func SaveAdminUserElectronicSignature(es *models.AdminUserElectronicSignature) error {
295
+	err := writeUserDb.Save(es).Error
296
+	return err
297
+}
298
+
299
+func GetAdminUserSpecialPermission(orgID int64, appID int64, adminUserID int64, permissionType models.SpecialPermissionType) (*models.AdminUserSpecialPermission, error) {
300
+	var record models.AdminUserSpecialPermission
301
+	err := readDb.Model(&models.AdminUserSpecialPermission{}).Where("org_id = ? AND app_id = ? AND admin_user_id = ? AND permission = ? AND status = 1", orgID, appID, adminUserID, permissionType).First(&record).Error
302
+	if err != nil {
303
+		if err == gorm.ErrRecordNotFound {
304
+			return nil, nil
305
+		} else {
306
+			return nil, err
307
+		}
308
+	}
309
+	return &record, nil
310
+}
311
+
312
+func SaveAdminUserSpecialPermission(permission *models.AdminUserSpecialPermission) error {
313
+	err := writeDb.Save(permission).Error
314
+	return err
315
+}
316
+
317
+func GetAllValidAdminUsersWithSpecialPermission(orgID int64, appID int64, permissionType models.SpecialPermissionType) ([]*models.AdminUserSpecialPermission, error) {
318
+	var records []*models.AdminUserSpecialPermission
319
+	err := readDb.Model(&models.AdminUserSpecialPermission{}).Where("org_id = ? AND app_id = ? AND permission = ? AND status = 1", orgID, appID, permissionType).Find(&records).Error
320
+	if err != nil {
321
+		return nil, err
322
+	}
323
+	return records, nil
324
+}
325
+
326
+func GetAllSpecialPermissionAdminUsersWithoutStatus(orgID int64, appID int64, permissionType models.SpecialPermissionType) ([]*models.AdminUserSpecialPermission, error) {
327
+	var records []*models.AdminUserSpecialPermission
328
+	err := readDb.Model(&models.AdminUserSpecialPermission{}).Where("org_id = ? AND app_id = ? AND permission = ?", orgID, appID, permissionType).Find(&records).Error
329
+	if err != nil {
330
+		return nil, err
331
+	}
332
+	return records, nil
333
+}
334
+
335
+func CancelAllSpecialPermissionAdminUsers(orgID int64, appID int64, permissionType models.SpecialPermissionType) error {
336
+	tx := writeDb.Begin()
337
+	updateTime := time.Now().Unix()
338
+	err := tx.Model(&models.AdminUserSpecialPermission{}).Where("org_id = ? AND app_id = ? AND status = 1 AND permission = ?", orgID, appID, permissionType).Updates(map[string]interface{}{"status": 0, "mtime": updateTime}).Error
339
+	if err != nil {
340
+		tx.Rollback()
341
+		return err
342
+	}
343
+	tx.Commit()
344
+	return nil
345
+}
346
+
347
+func BatchSaveSpecialPermissionAdminUsers(users []*models.AdminUserSpecialPermission) error {
348
+	tx := writeDb.Begin()
349
+	for _, user := range users {
350
+		tx.Save(user)
351
+	}
352
+	return tx.Commit().Error
353
+}

+ 19 - 0
service/app_version.go View File

@@ -0,0 +1,19 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+func GetAppVersionByAppType(apptype int64) (*models.AppVersion, error) {
9
+	var version models.AppVersion
10
+	err := readDb.Model(&models.AppVersion{}).Where("app_type=?", apptype).First(&version).Error
11
+	if err == gorm.ErrRecordNotFound {
12
+		return nil, nil
13
+	}
14
+
15
+	if err != nil {
16
+		return nil, err
17
+	}
18
+	return &version, nil
19
+}

+ 45 - 0
service/auto_clear_schedules_service.go View File

@@ -0,0 +1,45 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"XT_New/utils"
6
+	"time"
7
+
8
+	"github.com/robfig/cron"
9
+)
10
+
11
+// cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
12
+var clearSchedulesCronJob *cron.Cron
13
+
14
+func init() {
15
+	utils.InfoLog("开启自动清除排班定时任务")
16
+	clearSchedulesCronJob = cron.New()
17
+	spec := "0 0 1 * * ?" // 每天凌晨1点清除已排班未上机的排班数据
18
+	clearSchedulesCronJob.AddFunc(spec, func() {
19
+		AutoClearSchedules()
20
+	})
21
+}
22
+
23
+func BeginAutoClearSchedulesJob() {
24
+	clearSchedulesCronJob.Start()
25
+}
26
+
27
+func AutoClearSchedules() {
28
+	utils.TraceLog("自动清除排班任务开始执行")
29
+	//查出所有机构
30
+	var schedules []*models.Schedule
31
+	err = readDb.Table("xt_schedule as s").Where("s.status = 1").Select("distinct(s.user_org_id)").Find(&schedules).Error
32
+	//遍历所有机构
33
+	scheduleDate := utils.ZeroHourTimeOfDay(time.Now())
34
+	for _, item := range schedules {
35
+		//将今天(不包括今天)以前的的排班数据进行软删除
36
+		writeDb.
37
+			Table("xt_schedule as s").
38
+			Where("s.schedule_date < ? AND s.status = 1 AND "+
39
+				"s.user_org_id = ? AND "+
40
+				"NOT EXISTS (Select * FROM `xt_dialysis_order` as d Where  d.`status` = 1 AND"+
41
+				" d.`patient_id` = s.patient_id AND "+
42
+				" d.user_org_id = s.user_org_id AND d.dialysis_date = s.schedule_date)", scheduleDate.Unix(), item.UserOrgId).Updates(map[string]interface{}{"status": 0, "updated_time": time.Now().Unix()})
43
+	}
44
+	utils.SuccessLog("自动清除排班任务完成")
45
+}

+ 261 - 0
service/auto_create_week_disinfection.go View File

@@ -0,0 +1,261 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"XT_New/utils"
6
+	"fmt"
7
+	"github.com/jinzhu/gorm"
8
+	"github.com/robfig/cron"
9
+	"strconv"
10
+	"time"
11
+)
12
+
13
+// cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
14
+var createWeekDisinfectionCronJob *cron.Cron
15
+
16
+func init() {
17
+	createWeekDisinfectionCronJob = cron.New()
18
+	//spec := "0 0 23 * * ?" // 每天23点执行一次
19
+	spec := "0 55 23 * * ?" // 每天23点55执行一次
20
+	//spec := "0 0 5 * * ?" // 每天23点55执行一次
21
+	//spec := "0 */1 * * * ?" // 每1分钟执行一次
22
+	createWeekDisinfectionCronJob.AddFunc(spec, func() {
23
+
24
+		AutoCreateWeekDisinfectionJob()
25
+	})
26
+}
27
+
28
+func BeginAutoCreateWeekDisinfectionJob() {
29
+
30
+	createWeekDisinfectionCronJob.Start()
31
+}
32
+
33
+func AutoCreateWeekDisinfectionJob() {
34
+	timeStr := time.Now().Format("2006-01-02")
35
+	timeLayout := "2006-01-02 15:04:05"
36
+	fmt.Println("timeStr:", timeStr)
37
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
38
+	timenow := timeStringToTime.Unix()
39
+	fmt.Println("timenow是什么", timenow)
40
+	//查询当天排班所有机构
41
+	org, errs := GetAllOrgID(timenow)
42
+	fmt.Print("错误是什么", errs)
43
+	//fmt.Println("查询有机构失败", err)
44
+	for _, item := range org {
45
+		//查询机构是否开启自动使用登记
46
+		remander, errs := GetRemanderDatas(item.UserOrgId)
47
+		fmt.Print("查询自动使用登记错误", errs)
48
+		//开启
49
+		if remander.IsRun == 1 {
50
+			fmt.Println("机构id", item.UserOrgId)
51
+			//查询当天机构的所有下机病人id
52
+			order, _ := GetAllPatientByOrgID(item.UserOrgId, timenow)
53
+			for _, it := range order {
54
+				//fmt.Println("病人", it.PatientId)
55
+
56
+				//查询病人信息
57
+				patients, err := GetPatientInformation(it.PatientId, it.UserOrgId)
58
+				fmt.Println("查询病人信息报错", err)
59
+				var con = ""
60
+				if patients.IsInfectious == 0 {
61
+					con = ""
62
+				}
63
+				if patients.IsInfectious == 1 {
64
+					con = "无"
65
+				}
66
+				if patients.IsInfectious == 2 {
67
+					con = "有"
68
+				}
69
+				//fmt.Print("con------------------------", con)
70
+				//	fmt.Print("传染病", patients.IsInfectious)
71
+				//查询病人的班次
72
+				//schedules, _ := GetAllPatientSchedule(it.PatientId, it.UserOrgId,timenow)
73
+				schedules, _ := GetAllPatientSchedule(it.PatientId, it.UserOrgId, timenow)
74
+				fmt.Println("班次", schedules.ScheduleType)
75
+				//查询病人今日的透析模式
76
+				prescription, _ := GetDialysisPrescription(it.PatientId, it.UserOrgId, timenow)
77
+				fmt.Println("透析模式", prescription.ModeId)
78
+
79
+				//查询病人今日透后评估数据
80
+				dislysis, err := GetAssessmentAfterDissData(it.PatientId, it.UserOrgId, timenow)
81
+				fmt.Println("透后评估错误", err)
82
+				fmt.Print("透析时长", dislysis.ActualTreatmentHour+'h'+dislysis.ActualTreatmentMinute+'m'+'i'+'n')
83
+				//			//根据床位号获取设备id
84
+				addmacher, _ := GetEquimentID(schedules.BedId, it.UserOrgId)
85
+				unitype, err := strconv.ParseInt(addmacher.UnitType, 10, 64)
86
+				fmt.Println(" 设备id", addmacher.ID)
87
+				//根据设备id获取设备类型
88
+				//equimentname, _ := GetAddmacher(addmacher.ID, it.UserOrgId)
89
+
90
+				fmt.Println("班次", it.SchedualType)
91
+				//查看该设备是否有消毒计划,无怎返回,有则添加
92
+				plan, errplan := GetDisinfection(unitype, it.SchedualType, it.UserOrgId)
93
+				fmt.Print("plan", plan)
94
+				fmt.Println("错误是什么", errplan)
95
+				if errplan == gorm.ErrRecordNotFound {
96
+					fmt.Println("该设备无消毒计划")
97
+					return
98
+				} else if errplan == nil {
99
+					//fmt.Println("消毒时长", plan.DisinfecTime)
100
+					//fmt.Println("基表消毒方式", plan.Way)
101
+					//fmt.Println("基表消毒液", plan.MachineDisinfectant)
102
+					//fmt.Println("液路消毒方式", plan.DisinfectanWay)
103
+					//fmt.Println("液路消毒液", plan.Disinfectant)
104
+					//fmt.Println("上机时间", it.StartTime)
105
+					//fmt.Println("下机时间", it.EndTime)
106
+					//fmt.Println("传染病", con)
107
+					//fmt.Println("体重减少", strconv.FormatFloat(dislysis.WeightLoss, 'f', -1, 64))
108
+					//fmt.Println("时间超滤量", strconv.FormatFloat(dislysis.ActualUltrafiltration, 'f', -1, 64))
109
+					//fmt.Println("透析时长", strconv.FormatInt(dislysis.ActualTreatmentHour, 10))
110
+					//查询该病人是否有记录,无记录的则添加
111
+					information, errcode := GetInfor(it.PatientId, timenow, it.UserOrgId, it.SchedualType)
112
+					//fmt.Println("errcode是什么", errcode)
113
+					fmt.Println("information", information)
114
+					if errcode == gorm.ErrRecordNotFound {
115
+						information := models.DeviceInformation{
116
+							Date:                  timenow,
117
+							Zone:                  schedules.PartitionId,
118
+							Class:                 it.SchedualType,
119
+							BedNumber:             schedules.BedId,
120
+							PatientId:             schedules.PatientId,
121
+							DialysisMode:          prescription.ModeId,
122
+							LongTime:              strconv.FormatInt(plan.DisinfecTime, 10),
123
+							Disinfection:          1,
124
+							DialysisConcentration: 1,
125
+							DisinfectionStatus:    1,
126
+							Move:                  1,
127
+							UserOrgId:             it.UserOrgId,
128
+							DisinfectType:         plan.Way,                 //基表消毒方式
129
+							DisinfectantType:      plan.MachineDisinfectant, //基表消毒液
130
+							FluidPath:             plan.DisinfectanWay,      //液路消毒方式
131
+							Disinfectant:          plan.Disinfectant,        //液路消毒液
132
+							Ctime:                 time.Now().Unix(),
133
+							Status:                1,
134
+							SignName:              it.FinishNurse,
135
+							EquimentId:            addmacher.ID,
136
+							DisinfectionResidue:   2,
137
+							Bed:                   addmacher.BedNumber,
138
+							StartTime:             it.StartTime,
139
+							EndTime:               it.EndTime,
140
+							Contagion:             con,
141
+							WeightLoss:            strconv.FormatFloat(dislysis.WeightLoss, 'f', -1, 64),
142
+							Hyperfiltratio:        strconv.FormatFloat(dislysis.ActualUltrafiltration, 'f', -1, 64),
143
+							DialysisHour:          strconv.FormatInt(dislysis.ActualTreatmentHour, 10),
144
+							MachineRun:            1,
145
+						}
146
+						err := CreateInformation(&information)
147
+						fmt.Println("报错", err)
148
+					} else if errcode == nil {
149
+
150
+					} else {
151
+
152
+					}
153
+				} else {
154
+
155
+					return
156
+				}
157
+			}
158
+		}
159
+
160
+		//关闭
161
+		if remander.IsRun == 2 {
162
+			fmt.Print("已关闭")
163
+		}
164
+	}
165
+
166
+}
167
+
168
+//
169
+//func GetAllOrgID(status int64) (org []*models.Org, err error) {
170
+//
171
+//	err = UserReadDB().Where("status = ?", status).Find(&org).Error
172
+//
173
+//	return org, err
174
+//}
175
+
176
+//查询当天有排班的所有机构
177
+func GetAllOrgID(time int64) (schedule []*models.XtSchedule, err error) {
178
+
179
+	err = XTReadDB().Raw("select user_org_id,id,partition_id,bed_id,patient_id,schedule_date,schedule_type,schedule_week,mode_id from xt_schedule where schedule_date = ?  group by user_org_id", time).Scan(&schedule).Error
180
+
181
+	return schedule, err
182
+}
183
+
184
+func GetAllPatientByOrgID(orgid int64, timenow int64) (order []*models.DialysisOrder, err error) {
185
+
186
+	err = XTReadDB().Where("user_org_id = ? AND dialysis_date = ? AND stage = 2 AND status = ?", orgid, timenow, 1).Find(&order).Error
187
+	return order, err
188
+}
189
+
190
+func CreateInformation(information *models.DeviceInformation) error {
191
+	err := UserWriteDB().Create(&information).Error
192
+	return err
193
+}
194
+
195
+func GetAllPatientSchedule(patientid int64, orgID int64, timenow int64) (models.Schedule, error) {
196
+	schedules := models.Schedule{}
197
+	err := XTReadDB().Where("patient_id = ? AND user_org_id = ? AND schedule_date = ?", patientid, orgID, timenow).Find(&schedules).Error
198
+	return schedules, err
199
+}
200
+
201
+func GetInfor(patientid int64, timenow int64, orgid int64, class int64) (*models.DeviceInformation, error) {
202
+	var pre models.DeviceInformation
203
+	var err error
204
+	err = readUserDb.Model(&pre).Where("patient_id = ? AND date = ? AND user_org_id = ? AND class = ? AND status = 1", patientid, timenow, orgid, class).Find(&pre).Error
205
+	if err == gorm.ErrRecordNotFound {
206
+		return nil, err
207
+	}
208
+	if err != nil {
209
+		return nil, err
210
+	}
211
+	return &pre, nil
212
+}
213
+
214
+func GetDisinfection(equitType int64, enquitType int64, orgID int64) (*models.DevicePlan, error) {
215
+	var plan models.DevicePlan
216
+	var err error
217
+	err = readUserDb.Model(&plan).Where("device_type = ? AND classtime = ? AND user_org_id = ? AND status = 1", equitType, enquitType, orgID).Find(&plan).Error
218
+	if err == gorm.ErrRecordNotFound {
219
+		return nil, err
220
+	}
221
+	if err != nil {
222
+		return nil, err
223
+	}
224
+	return &plan, nil
225
+}
226
+
227
+func GetDialysisPrescription(patientid int64, orgID int64, timenow int64) (models.DialysisPrescription, error) {
228
+	prescription := models.DialysisPrescription{}
229
+	err := XTReadDB().Model(&prescription).Where("patient_id = ? AND user_org_id = ? AND record_date = ?", patientid, orgID, timenow).Find(&prescription).Error
230
+	return prescription, err
231
+}
232
+
233
+func GetAssessmentAfterDissData(patientid int64, orgID int64, timenow int64) (models.XtAssessmentAfterDislysis, error) {
234
+	dislysis := models.XtAssessmentAfterDislysis{}
235
+	err := XTReadDB().Where("patient_id = ? AND user_org_id = ? AND assessment_date = ?", patientid, orgID, timenow).Find(&dislysis).Error
236
+	return dislysis, err
237
+}
238
+
239
+func GetEquimentID(bedId int64, orgID int64) (models.DeviceAddmacher, error) {
240
+	addmacher := models.DeviceAddmacher{}
241
+	err := readUserDb.Model(&addmacher).Where("bed_id = ? AND user_org_id = ? AND status = ?", bedId, orgID, 1).Find(&addmacher).Error
242
+	return addmacher, err
243
+}
244
+
245
+func GetAddmacher(equitmentid int64, orgid int64) (models.DeviceEquimentname, error) {
246
+	equimentname := models.DeviceEquimentname{}
247
+	err := readUserDb.Model(&equimentname).Where("equitment_id = ? AND user_org_id = ? AND status = 1", equitmentid, orgid).Find(&equimentname).Error
248
+	return equimentname, err
249
+}
250
+
251
+func GetPatientInformation(id int64, orgid int64) (models.Patients, error) {
252
+	patients := models.Patients{}
253
+	err := XTReadDB().Where("id = ? AND user_org_id = ?", id, orgid).Find(&patients).Error
254
+	return patients, err
255
+}
256
+
257
+func GetRemanderDatas(orgid int64) (remander models.DeviceRemander, err error) {
258
+
259
+	err = UserReadDB().Model(&models.DeviceRemander{}).Where("user_org_id = ? and status = 1", orgid).Find(&remander).Error
260
+	return
261
+}

+ 149 - 0
service/auto_create_week_plan.go View File

@@ -0,0 +1,149 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"XT_New/utils"
6
+	"fmt"
7
+	"github.com/jinzhu/gorm"
8
+	"github.com/robfig/cron"
9
+	"strconv"
10
+	"time"
11
+)
12
+
13
+var createWeekPlanCronJob *cron.Cron
14
+
15
+func init() {
16
+	utils.InfoLog("第二次开启自动消毒时任务")
17
+	spec := "0 0 22 * * ?" // 每天22点执行一次
18
+	//spec := "0 */1 * * * ?" // 每1分钟执行一次
19
+	createWeekPlanCronJob = cron.New()
20
+	createWeekDisinfectionCronJob.AddFunc(spec, func() {
21
+		AutoCreateWeekPlanJob()
22
+	})
23
+}
24
+
25
+func BeginAutoCreatePlanJob() {
26
+	createWeekPlanCronJob.Start()
27
+}
28
+
29
+func AutoCreateWeekPlanJob() {
30
+
31
+	timeStr := time.Now().Format("2006-01-02")
32
+	timeLayout := "2006-01-02 15:04:05"
33
+	fmt.Println("timeStr:", timeStr)
34
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
35
+	timenow := timeStringToTime.Unix()
36
+	fmt.Println("timenow是什么", timenow)
37
+	//查询当天排班所有机构
38
+	org, errs := GetAllOrgID(timenow)
39
+	fmt.Print("错误是什么", errs)
40
+	fmt.Println("查询有机构失败", err)
41
+	for _, item := range org {
42
+		//查询机构是否开启自动使用登记
43
+		remander, errs := GetRemanderDatas(item.UserOrgId)
44
+		fmt.Print("查询自动使用登记错误", errs)
45
+		//开启
46
+		if remander.IsRun == 1 {
47
+			fmt.Println("机构id", item.UserOrgId)
48
+			//查询当天机构的所有下机病人id
49
+			order, _ := GetAllPatientByOrgID(item.UserOrgId, timenow)
50
+			for _, it := range order {
51
+				fmt.Println("病人", it.PatientId)
52
+
53
+				//查询病人信息
54
+				patients, err := GetPatientInformation(it.PatientId, it.UserOrgId)
55
+				fmt.Println("查询病人信息报错", err)
56
+				var con = ""
57
+				if patients.IsInfectious == 0 {
58
+					con = ""
59
+				}
60
+				if patients.IsInfectious == 1 {
61
+					con = "无"
62
+				}
63
+				if patients.IsInfectious == 2 {
64
+					con = "有"
65
+				}
66
+
67
+				//查询病人的班次
68
+				//schedules, _ := GetAllPatientSchedule(it.PatientId, it.UserOrgId,timenow)
69
+				schedules, _ := GetAllPatientSchedule(it.PatientId, it.UserOrgId, timenow)
70
+				fmt.Println("班次", schedules.ScheduleType)
71
+				//查询病人今日的透析模式
72
+				prescription, _ := GetDialysisPrescription(it.PatientId, it.UserOrgId, timenow)
73
+				fmt.Println("透析模式", prescription.ModeId)
74
+
75
+				//查询病人今日透后评估数据
76
+				dislysis, err := GetAssessmentAfterDissData(it.PatientId, it.UserOrgId, timenow)
77
+				fmt.Println("透后", err)
78
+				//			//根据床位号获取设备id
79
+				addmacher, _ := GetEquimentID(schedules.BedId, it.UserOrgId)
80
+				unitype, err := strconv.ParseInt(addmacher.UnitType, 10, 64)
81
+				fmt.Println(" 设备id", addmacher.ID)
82
+				//根据设备id获取设备类型
83
+				//equimentname, _ := GetAddmacher(addmacher.ID, it.UserOrgId)
84
+
85
+				fmt.Println("班次", it.SchedualType)
86
+				//查看该设备是否有消毒计划,无怎返回,有则添加
87
+				plan, errplan := GetDisinfection(unitype, it.SchedualType, it.UserOrgId)
88
+				fmt.Print("plan", plan)
89
+				fmt.Println("错误", errplan)
90
+				if errplan == gorm.ErrRecordNotFound {
91
+					fmt.Println("该设备无消毒计划")
92
+					return
93
+				} else if errplan == nil {
94
+					//查询该病人是否有记录,无记录的则添加
95
+					information, errcode := GetInfor(it.PatientId, timenow, it.UserOrgId, it.SchedualType)
96
+					fmt.Println("errcode是什么", errcode)
97
+					fmt.Println("information", information)
98
+					if errcode == gorm.ErrRecordNotFound {
99
+						information := models.DeviceInformation{
100
+							Date:                  timenow,
101
+							Zone:                  schedules.PartitionId,
102
+							Class:                 it.SchedualType,
103
+							BedNumber:             schedules.BedId,
104
+							PatientId:             schedules.PatientId,
105
+							DialysisMode:          prescription.ModeId,
106
+							LongTime:              strconv.FormatInt(plan.DisinfecTime, 10),
107
+							Disinfection:          1,
108
+							DialysisConcentration: 1,
109
+							DisinfectionStatus:    1,
110
+							Move:                  1,
111
+							UserOrgId:             it.UserOrgId,
112
+							DisinfectType:         plan.Way,                 //基表消毒方式
113
+							DisinfectantType:      plan.MachineDisinfectant, //基表消毒液
114
+							FluidPath:             plan.DisinfectanWay,      //液路消毒方式
115
+							Disinfectant:          plan.Disinfectant,        //液路消毒液
116
+							Ctime:                 time.Now().Unix(),
117
+							Status:                1,
118
+							SignName:              it.FinishNurse,
119
+							EquimentId:            addmacher.ID,
120
+							DisinfectionResidue:   2,
121
+							Bed:                   addmacher.BedNumber,
122
+							StartTime:             it.StartTime,
123
+							EndTime:               it.EndTime,
124
+							Contagion:             con,
125
+							WeightLoss:            strconv.FormatFloat(dislysis.WeightLoss, 'f', -1, 64),
126
+							Hyperfiltratio:        strconv.FormatFloat(dislysis.ActualUltrafiltration, 'f', -1, 64),
127
+							DialysisHour:          strconv.FormatInt(dislysis.ActualTreatmentHour, 10),
128
+							MachineRun:            1,
129
+						}
130
+						err := CreateInformation(&information)
131
+						fmt.Println("报错", err)
132
+					} else if errcode == nil {
133
+
134
+					} else {
135
+
136
+					}
137
+				} else {
138
+
139
+					return
140
+				}
141
+			}
142
+		}
143
+
144
+		//关闭
145
+		if remander.IsRun == 2 {
146
+			fmt.Print("已关闭")
147
+		}
148
+	}
149
+}

+ 281 - 0
service/auto_create_week_schedules_service.go View File

@@ -0,0 +1,281 @@
1
+package service
2
+
3
+import (
4
+	"fmt"
5
+	"strings"
6
+	"time"
7
+
8
+	"XT_New/models"
9
+	"XT_New/utils"
10
+
11
+	"github.com/jinzhu/gorm"
12
+	"github.com/robfig/cron"
13
+)
14
+
15
+// cron表达式 https://www.cnblogs.com/zuxingyu/p/6023919.html
16
+var createWeekSchedulesCronJob *cron.Cron
17
+
18
+func init() {
19
+	utils.InfoLog("开启自动排班定时任务")
20
+	createWeekSchedulesCronJob = cron.New()
21
+	spec := "0 0 0 ? * MON" // 每周一凌晨0点生成排班
22
+	createWeekSchedulesCronJob.AddFunc(spec, func() {
23
+		AutoCreateWeekSchedules()
24
+	})
25
+}
26
+
27
+func BeginAutoCreateWeekSchedulesJob() {
28
+	createWeekSchedulesCronJob.Start()
29
+}
30
+
31
+func AutoCreateWeekSchedules() {
32
+	utils.TraceLog("自动排班任务开始执行")
33
+	var modes []*models.PatientScheduleTemplateMode
34
+	getModesErr := readDb.Model(&models.PatientScheduleTemplateMode{}).Where("mode <> 0 AND status = 1").Find(&modes).Error
35
+	if getModesErr != nil {
36
+		utils.ErrorLog("自动排班-获取启用模板模式列表失败:%v", getModesErr)
37
+		CreateDBErrorRecord(0, "自动排班-获取启用模板模式列表失败:%v", getModesErr)
38
+		return
39
+	}
40
+
41
+	for _, mode := range modes {
42
+		templates, getTemplatesErr := GetOrgPatientScheduleTemplateIDs(mode.OrgID)
43
+		if getTemplatesErr != nil {
44
+			utils.ErrorLog("自动排班-org_id: %v :获取模板 ID 失败:%v", mode.OrgID, getTemplatesErr)
45
+			CreateDBErrorRecord(mode.OrgID, "自动排班-org_id: %v :获取模板 ID 失败:%v", mode.OrgID, getTemplatesErr)
46
+			continue
47
+		} else if len(templates) == 0 {
48
+			utils.WarningLog("自动排班-org_id: %v :没有模板", mode.OrgID)
49
+			continue
50
+		}
51
+
52
+		now := time.Now()
53
+		nextSecWeek := now.AddDate(0, 0, 14)
54
+		tx := writeDb.Begin()
55
+
56
+		if mode.Mode == 1 { // 用第一周模板生成下第二周的排班
57
+			items, getItemsErr := GetOrgPatientScheduleTemplateItemsWithoutPatientByTemplateID(mode.OrgID, templates[0].ID)
58
+			if getItemsErr != nil {
59
+				utils.ErrorLog("自动排班-org_id: %v :获取第一周模板Item失败:%v", mode.OrgID, getItemsErr)
60
+				CreateDBErrorRecord(mode.OrgID, "自动排班-org_id: %v :获取第一周模板Item失败:%v", mode.OrgID, getItemsErr)
61
+				continue
62
+			}
63
+			insertErr := _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, nextSecWeek, items, nil)
64
+			if insertErr != nil {
65
+				utils.ErrorLog("自动排班-org_id: %v :使用第一周模板插入下第二周排班失败:%v", mode.OrgID, insertErr)
66
+				CreateDBErrorRecord(mode.OrgID, "自动排班-org_id: %v :使用第一周模板插入下第二周排班失败:%v", mode.OrgID, insertErr)
67
+				tx.Rollback()
68
+				continue
69
+			}
70
+
71
+		} else if mode.Mode == 2 { // mode.ExecuteTimes % 2 的结果,如果为0,用第一周模板生成下第二周的排班,否则用第二周的模板生成排班
72
+			if mode.ExecuteTimes%2 == 0 {
73
+				items, getItemsErr := GetOrgPatientScheduleTemplateItemsWithoutPatientByTemplateID(mode.OrgID, templates[0].ID)
74
+				if getItemsErr != nil {
75
+					utils.ErrorLog("自动排班-org_id: %v :获取第一周模板Item失败:%v", mode.OrgID, getItemsErr)
76
+					CreateDBErrorRecord(mode.OrgID, "自动排班-org_id: %v :获取第一周模板Item失败:%v", mode.OrgID, getItemsErr)
77
+					continue
78
+				}
79
+
80
+				insertErr := _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, nextSecWeek, items, nil)
81
+				if insertErr != nil {
82
+					utils.ErrorLog("自动排班-org_id: %v :使用第一周模板插入下第二周排班失败:%v", mode.OrgID, insertErr)
83
+					CreateDBErrorRecord(mode.OrgID, "自动排班-org_id: %v :使用第一周模板插入下第二周排班失败:%v", mode.OrgID, insertErr)
84
+					tx.Rollback()
85
+					continue
86
+				}
87
+
88
+			} else {
89
+				if len(templates) < 2 {
90
+					utils.WarningLog("自动排班-org_id: %v :没有第二周的模板")
91
+					continue
92
+				}
93
+				items, getItemsErr := GetOrgPatientScheduleTemplateItemsWithoutPatientByTemplateID(mode.OrgID, templates[1].ID)
94
+				if getItemsErr != nil {
95
+					utils.ErrorLog("自动排班-org_id: %v :获取第二周模板Item失败:%v", mode.OrgID, getItemsErr)
96
+					CreateDBErrorRecord(mode.OrgID, "自动排班-org_id: %v :获取第二周模板Item失败:%v", mode.OrgID, getItemsErr)
97
+					continue
98
+				}
99
+
100
+				insertErr := _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, nextSecWeek, items, nil)
101
+				if insertErr != nil {
102
+					utils.ErrorLog("自动排班-org_id: %v :使用第二周模板插入下第二周排班失败:%v", mode.OrgID, insertErr)
103
+					CreateDBErrorRecord(mode.OrgID, "自动排班-org_id: %v :使用第二周模板插入下第二周排班失败:%v", mode.OrgID, insertErr)
104
+					tx.Rollback()
105
+					continue
106
+				}
107
+			}
108
+		}
109
+
110
+		mode.ExecuteTimes += 1
111
+		mode.ModifyTime = now.Unix()
112
+		updateModeErr := tx.Save(mode).Error
113
+		if updateModeErr != nil {
114
+			utils.ErrorLog("自动排班-org_id:%v :更新启用模板模式的执行次数失败:%v", mode.OrgID, updateModeErr)
115
+			CreateDBErrorRecord(mode.OrgID, "自动排班-org_id:%v :更新启用模板模式的执行次数失败:%v", mode.OrgID, updateModeErr)
116
+			tx.Rollback()
117
+			continue
118
+		}
119
+
120
+		tx.Commit()
121
+		utils.SuccessLog("自动排班-插入排班成功:org_id: %v", mode.OrgID)
122
+
123
+		time.Sleep(time.Second * 30)
124
+	}
125
+
126
+	utils.SuccessLog("自动排班任务完成")
127
+}
128
+
129
+func _refreshWeekSchedulesWithTemplateItems(tx *gorm.DB, orgID int64, week time.Time, templateItems []*models.PatientScheduleTemplateItem, deviceNumberMap map[int64]*DeviceNumberViewModel) error {
130
+	if deviceNumberMap == nil {
131
+		deviceNumbers, getDeviceNumbersErr := GetAllValidDeviceNumbers(orgID)
132
+		if getDeviceNumbersErr != nil {
133
+			return getDeviceNumbersErr
134
+		}
135
+		deviceNumberMap = make(map[int64]*DeviceNumberViewModel, 0)
136
+		for _, deviceNumber := range deviceNumbers {
137
+			deviceNumberMap[deviceNumber.ID] = deviceNumber
138
+		}
139
+	}
140
+
141
+	now := time.Now()
142
+	monday, sunday := utils.GetMondayAndSundayOfWeekDate(&week)
143
+	disableErr := tx.Model(&models.Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date >= ? AND schedule_date <= ?", orgID, monday.Unix(), sunday.Unix()).Updates(map[string]interface{}{"status": 0, "mtime": now.Unix()}).Error
144
+	if disableErr != nil {
145
+		return disableErr
146
+	}
147
+
148
+	// 批量插入排班
149
+	if len(templateItems) > 0 {
150
+		valueStrs := make([]string, 0, len(templateItems))
151
+		values := make([]interface{}, 0, len(templateItems)*11)
152
+		for _, item := range templateItems {
153
+			deviceNumber := deviceNumberMap[item.DeviceNumberID]
154
+			if deviceNumber == nil {
155
+				continue
156
+			}
157
+
158
+			valueStrs = append(valueStrs, "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
159
+			values = append(values, orgID)
160
+			values = append(values, deviceNumber.ZoneID)
161
+			values = append(values, item.DeviceNumberID)
162
+			values = append(values, item.PatientID)
163
+			values = append(values, monday.AddDate(0, 0, int(item.Weekday-1)).Unix())
164
+			values = append(values, item.Weekday)
165
+			values = append(values, item.TimeType)
166
+			values = append(values, item.TreatMode)
167
+			values = append(values, 1)
168
+			values = append(values, now.Unix())
169
+			values = append(values, now.Unix())
170
+		}
171
+
172
+		sql := fmt.Sprintf("INSERT INTO xt_schedule (user_org_id, partition_id, bed_id, patient_id, schedule_date, schedule_week, schedule_type, mode_id, status, created_time, updated_time) VALUES %v;", strings.Join(valueStrs, ", "))
173
+		if insertErr := tx.Exec(sql, values...).Error; insertErr != nil {
174
+			return insertErr
175
+		}
176
+	}
177
+	return nil
178
+}
179
+
180
+func FakeAutoCreateNextTwoWeekSchedules(orgID int64) {
181
+	mode, getModeErr := GetOrgPatientScheduleTemplateMode(orgID)
182
+	if getModeErr != nil {
183
+		utils.ErrorLog("%v", getModeErr)
184
+		return
185
+	}
186
+
187
+	templates, getTemplatesErr := GetOrgPatientScheduleTemplateIDs(mode.OrgID)
188
+	if getTemplatesErr != nil {
189
+		utils.ErrorLog("获取模板 ID 失败:%v", getTemplatesErr)
190
+		return
191
+	} else if len(templates) == 0 {
192
+		utils.WarningLog("没有模板")
193
+		return
194
+	}
195
+
196
+	deviceNumbers, getDeviceNumbersErr := GetAllValidDeviceNumbers(orgID)
197
+	if getDeviceNumbersErr != nil {
198
+		utils.ErrorLog("获取床位列表失败:%v", getDeviceNumbersErr)
199
+		return
200
+	}
201
+	deviceNumberMap := make(map[int64]*DeviceNumberViewModel, 0)
202
+	for _, deviceNumber := range deviceNumbers {
203
+		deviceNumberMap[deviceNumber.ID] = deviceNumber
204
+	}
205
+
206
+	now := time.Now()
207
+	tx := writeDb.Begin()
208
+
209
+	if mode.Mode == 1 { // 用第一周模板生成下两周的排班
210
+		items, getItemsErr := GetOrgPatientScheduleTemplateItemsWithoutPatientByTemplateID(mode.OrgID, templates[0].ID)
211
+		if getItemsErr != nil {
212
+			utils.ErrorLog("获取第一周模板Item失败:%v", getItemsErr)
213
+			return
214
+		}
215
+		insertErr := _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, now.AddDate(0, 0, 7), items, deviceNumberMap)
216
+		if insertErr != nil {
217
+			utils.ErrorLog("使用第一周模板插入下第一周排班失败:%v", insertErr)
218
+			tx.Rollback()
219
+			return
220
+		}
221
+		insertErr = _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, now.AddDate(0, 0, 14), items, deviceNumberMap)
222
+		if insertErr != nil {
223
+			utils.ErrorLog("使用第一周模板插入下第二周排班失败:%v", insertErr)
224
+			tx.Rollback()
225
+			return
226
+		}
227
+
228
+	} else if mode.Mode == 2 {
229
+		firstItems, getFirstItemsErr := GetOrgPatientScheduleTemplateItemsWithoutPatientByTemplateID(mode.OrgID, templates[0].ID)
230
+		if getFirstItemsErr != nil {
231
+			utils.ErrorLog("获取第一周模板Item失败:%v", getFirstItemsErr)
232
+			return
233
+		}
234
+		secItems, getSecItemsErr := GetOrgPatientScheduleTemplateItemsWithoutPatientByTemplateID(mode.OrgID, templates[1].ID)
235
+		if getSecItemsErr != nil {
236
+			utils.ErrorLog("获取第一周模板Item失败:%v", getSecItemsErr)
237
+			return
238
+		}
239
+
240
+		if mode.ExecuteTimes%2 == 0 {
241
+			insertErr := _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, now.AddDate(0, 0, 7), firstItems, deviceNumberMap)
242
+			if insertErr != nil {
243
+				utils.ErrorLog("使用第一周模板插入下第一周排班失败:%v", insertErr)
244
+				tx.Rollback()
245
+				return
246
+			}
247
+			insertErr = _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, now.AddDate(0, 0, 14), secItems, deviceNumberMap)
248
+			if insertErr != nil {
249
+				utils.ErrorLog("使用第二周模板插入下第二周排班失败:%v", insertErr)
250
+				tx.Rollback()
251
+				return
252
+			}
253
+
254
+		} else { // mode.ExecuteTimes%2 == 1
255
+			insertErr := _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, now.AddDate(0, 0, 7), secItems, deviceNumberMap)
256
+			if insertErr != nil {
257
+				utils.ErrorLog("使用第二周模板插入下第一周排班失败:%v", mode.OrgID, insertErr)
258
+				tx.Rollback()
259
+				return
260
+			}
261
+			insertErr = _refreshWeekSchedulesWithTemplateItems(tx, mode.OrgID, now.AddDate(0, 0, 14), firstItems, deviceNumberMap)
262
+			if insertErr != nil {
263
+				utils.ErrorLog("使用第一周模板插入下第二周排班失败:%v", mode.OrgID, insertErr)
264
+				tx.Rollback()
265
+				return
266
+			}
267
+		}
268
+	}
269
+
270
+	mode.ExecuteTimes += 2
271
+	mode.ModifyTime = now.Unix()
272
+	updateModeErr := tx.Save(mode).Error
273
+	if updateModeErr != nil {
274
+		utils.ErrorLog("更新启用模板模式的执行次数失败:%v", mode.OrgID, updateModeErr)
275
+		tx.Rollback()
276
+		return
277
+	}
278
+
279
+	tx.Commit()
280
+	utils.SuccessLog("模拟自动更新下两周排班成功")
281
+}

+ 187 - 0
service/data.go View File

@@ -0,0 +1,187 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	_ "github.com/astaxie/beego"
6
+	_ "strconv"
7
+	_ "strings"
8
+	"time"
9
+)
10
+
11
+//GetPatientList 返回患者的列表
12
+func GetConfigList(orgID int64) (dataconfig interface{}, err error) {
13
+	var configList []*models.Dataconfig
14
+
15
+	err = readDb.Model(&models.Dataconfig{}).Where("(org_id in (0,?) and status = 1) or (status = 0 and delete_id_system > 0 and org_id = ?)", orgID, orgID).Order("orders desc, id asc").Find(&configList).Error
16
+	if err != nil {
17
+		return nil, err
18
+	}
19
+
20
+	// configResult := make([]*ConfigViewModel,0)
21
+	childConfig := make(map[int64][]*models.Dataconfig)
22
+	resultConfig := make(map[string][]*models.ConfigViewModel)
23
+	deleteSystemChilds := make([]*models.Dataconfig, 0)
24
+	editSystemChilds := make([]*models.Dataconfig, 0)
25
+	for _, config := range configList {
26
+		if config.Status == 1 && config.DeleteIdSystem > 0 {
27
+			editSystemChilds = append(editSystemChilds, config)
28
+		}
29
+
30
+		if config.Status == 0 && config.DeleteIdSystem > 0 {
31
+			deleteSystemChilds = append(deleteSystemChilds, config)
32
+		}
33
+	}
34
+	continueFlag := false
35
+	for _, config := range configList {
36
+		continueFlag = false
37
+		if config.ParentId == 0 {
38
+			newConfig := &models.ConfigViewModel{
39
+				ID:           config.ID,
40
+				ParentId:     config.ParentId,
41
+				Module:       config.Module,
42
+				OrgId:        config.OrgId,
43
+				Name:         config.Name,
44
+				FieldName:    config.FieldName,
45
+				Value:        config.Value,
46
+				CreateUserId: config.CreateUserId,
47
+				Status:       config.Status,
48
+				Remark:       config.Remark,
49
+				Title:        config.Title,
50
+				Content:      config.Content,
51
+			}
52
+			// configResult = append(configResult,newConfig)
53
+			result := resultConfig[config.Module]
54
+			if result == nil {
55
+				result = make([]*models.ConfigViewModel, 0)
56
+			}
57
+			for _, vm := range editSystemChilds {
58
+				if vm.DeleteIdSystem == config.ID {
59
+					continueFlag = true
60
+					break
61
+				}
62
+			}
63
+
64
+			for _, _vm := range deleteSystemChilds {
65
+				if _vm.DeleteIdSystem == config.ID {
66
+					continueFlag = true
67
+					break
68
+				}
69
+			}
70
+			if config.OrgId != 0 && config.Status == 0 && config.DeleteIdSystem > 0 {
71
+				continue
72
+			}
73
+			if continueFlag {
74
+				continue
75
+			}
76
+			result = append(result, newConfig)
77
+			resultConfig[config.Module] = result
78
+		} else {
79
+			childs := childConfig[config.ParentId]
80
+			if childs == nil {
81
+				childs = make([]*models.Dataconfig, 0)
82
+			}
83
+			continueFlag := false
84
+			for _, vm := range editSystemChilds {
85
+				if vm.DeleteIdSystem == config.ID {
86
+					continueFlag = true
87
+					break
88
+				}
89
+			}
90
+
91
+			for _, _vm := range deleteSystemChilds {
92
+				if _vm.DeleteIdSystem == config.ID {
93
+					continueFlag = true
94
+					break
95
+				}
96
+			}
97
+			if config.OrgId != 0 && config.Status == 0 && config.DeleteIdSystem > 0 {
98
+				continue
99
+			}
100
+			if continueFlag {
101
+				continue
102
+			}
103
+
104
+			childs = append(childs, config)
105
+			childConfig[config.ParentId] = childs
106
+		}
107
+	}
108
+
109
+	for _, vm := range resultConfig {
110
+		for _, _vm := range vm {
111
+			_vm.Childs = childConfig[_vm.ID]
112
+		}
113
+		// vm.Childs = childConfig[vm.ID]
114
+	}
115
+	return resultConfig, err
116
+}
117
+
118
+func FindConfigByFieldname(module string, field_name string, org_id int64) (dataconfig models.Dataconfig, err error) {
119
+	err = readDb.Model(&models.Dataconfig{}).Where("module=? and field_name=? and org_id in (0,?) and status = 1", module, field_name, org_id).First(&dataconfig).Error
120
+	return
121
+}
122
+
123
+func FindConfigByTitle(module string, title string, org_id int64) (dataconfig models.Dataconfig, err error) {
124
+	err = readDb.Model(&models.Dataconfig{}).Where("module=? and title=? and org_id in (0,?) and status = 1", module, title, org_id).First(&dataconfig).Error
125
+	return
126
+}
127
+
128
+func FindConfigByName(module string, name string, parent_id int64, org_id int64) (dataconfig models.Dataconfig, err error) {
129
+	err = readDb.Model(&models.Dataconfig{}).Where("module=? and name=? and parent_id=? and org_id in (0,?) and status = 1", module, name, parent_id, org_id).First(&dataconfig).Error
130
+	return
131
+}
132
+
133
+func FindConfigByNameForUpdate(module string, name string, parent_id int64, org_id int64, id int64) (dataconfig models.Dataconfig, err error) {
134
+	err = readDb.Model(&models.Dataconfig{}).Where("module=? and name=? and parent_id=? and org_id in (0,?) and id != ? and status = 1", module, name, parent_id, org_id, id).First(&dataconfig).Error
135
+	return
136
+}
137
+
138
+func FindConfigByTitleForUpdate(module string, title string, org_id int64, id int64) (dataconfig models.Dataconfig, err error) {
139
+	err = readDb.Model(&models.Dataconfig{}).Where("module=? and title=? and org_id in (0,?) and id != ? and status = 1", module, title, org_id, id).First(&dataconfig).Error
140
+	return
141
+}
142
+
143
+func UpdateChildConfig(dataconfig *models.Dataconfig) (err error) {
144
+	err = readDb.Model(&models.Dataconfig{}).Where("id =?", dataconfig.ID).Update(map[string]interface{}{"name": dataconfig.Name, "update_time": dataconfig.UpdatedTime, "remark": dataconfig.Remark}).Error
145
+	return
146
+}
147
+
148
+func UpdateTemplate(dataconfig *models.Dataconfig) (err error) {
149
+	err = readDb.Model(&models.Dataconfig{}).Where("id =?", dataconfig.ID).Update(map[string]interface{}{"title": dataconfig.Title, "content": dataconfig.Content, "update_time": dataconfig.UpdatedTime, "remark": dataconfig.Remark}).Error
150
+	return
151
+}
152
+
153
+func CreateConfig(dataconfig *models.Dataconfig) (err error) {
154
+	// readDb.Model(&models.Dataconfig{}).Where("module = ? and parent_id = 0 and org_id in (0,?)",dataconfig.Module,dataconfig.OrgId).Count(&total)
155
+	err = readDb.Create(&dataconfig).Error
156
+	return
157
+}
158
+
159
+func GetChildValue(module string, parent_id int64, org_id int64) (value int) {
160
+	readDb.Model(&models.Dataconfig{}).Where("module=? and parent_id=? and org_id in (0,?)", module, parent_id, org_id).Count(&value)
161
+	return
162
+}
163
+
164
+func DeleteChildConfig(dataconfig *models.Dataconfig) (err error) {
165
+	err = readDb.Model(&models.Dataconfig{}).Where("id =?", dataconfig.ID).Update(map[string]interface{}{"status": dataconfig.Status, "update_time": dataconfig.UpdatedTime}).Error
166
+	return
167
+}
168
+
169
+func FindFiledByOrgId(org_id int64) (filedConfig []*models.FiledConfig, err error) {
170
+	err = readDb.Model(&models.FiledConfig{}).Where("org_id =? AND sys_module = 0", org_id).Find(&filedConfig).Error
171
+	return
172
+}
173
+
174
+func BatchInsertFiledConfig(org_id int64) (err error) {
175
+	err = readDb.Exec("INSERT  INTO sgj_xt.xt_filed_config  ( org_id,  module,  filed_name,  filed_name_cn,  is_show ) SELECT ?,  module,  filed_name,  filed_name_cn,  is_show FROM sgj_xt.xt_filed_config  WHERE org_id = 0", org_id).Error
176
+	return
177
+}
178
+
179
+func ShowFiledConfig(org_id int64, isShow int, id int64) (err error) {
180
+	err = readDb.Model(&models.FiledConfig{}).Where("org_id = ? AND id = ?", org_id, id).Updates(map[string]interface{}{"ctime": time.Now().Unix(), "mtime": time.Now().Unix(), "is_show": isShow}).Error
181
+	return
182
+}
183
+
184
+func FindSysDialysisFiledByOrgId() (filedConfig []*models.FiledConfig, err error) {
185
+	err = readDb.Model(&models.FiledConfig{}).Where("org_id =? AND id in (11250,11251,11252,11253,11254,11255,11256,11257,11258,11259,11260,11261,11262)", 0).Find(&filedConfig).Error
186
+	return
187
+}

+ 156 - 0
service/db.go View File

@@ -0,0 +1,156 @@
1
+// Pipe - A small and beautiful blogging platform written in golang.
2
+// Copyright (C) 2017-2018, b3log.org
3
+//
4
+// This program is free software: you can redistribute it and/or modify
5
+// it under the terms of the GNU General Public License as published by
6
+// the Free Software Foundation, either version 3 of the License, or
7
+// (at your option) any later version.
8
+//
9
+// This program is distributed in the hope that it will be useful,
10
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
+// GNU General Public License for more details.
13
+//
14
+// You should have received a copy of the GNU General Public License
15
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
+
17
+package service
18
+
19
+import (
20
+	"fmt"
21
+
22
+	"github.com/astaxie/beego"
23
+	"github.com/jinzhu/gorm"
24
+	_ "github.com/jinzhu/gorm/dialects/mysql" // mysql
25
+)
26
+
27
+var readDb *gorm.DB
28
+var writeDb *gorm.DB
29
+var readUserDb *gorm.DB
30
+var writeUserDb *gorm.DB
31
+
32
+var readMiddleDb *gorm.DB
33
+var writeMiddleDb *gorm.DB
34
+var err error
35
+
36
+func ConnectDB() {
37
+	readHost := beego.AppConfig.String("readmysqlhost")
38
+	readPort := beego.AppConfig.String("readmysqlport")
39
+	readUser := beego.AppConfig.String("readmysqluser")
40
+	readPass := beego.AppConfig.String("readmysqlpass")
41
+	readName := beego.AppConfig.String("readmysqlname")
42
+
43
+	writeHost := beego.AppConfig.String("writemysqlhost")
44
+	writePort := beego.AppConfig.String("writemysqlport")
45
+	writeUser := beego.AppConfig.String("writemysqluser")
46
+	writePass := beego.AppConfig.String("writemysqlpass")
47
+	writeName := beego.AppConfig.String("writemysqlname")
48
+
49
+	readUserHost := beego.AppConfig.String("readuserhost")
50
+	readUserPort := beego.AppConfig.String("readuserport")
51
+	readUserUser := beego.AppConfig.String("readuseruser")
52
+	readUserPass := beego.AppConfig.String("readuserpass")
53
+	readUserName := beego.AppConfig.String("readusername")
54
+
55
+	writeUserHost := beego.AppConfig.String("writeuserhost")
56
+	writeUserPort := beego.AppConfig.String("writeuserport")
57
+	writeUserUser := beego.AppConfig.String("writeuseruser")
58
+	writeUserPass := beego.AppConfig.String("writeuserpass")
59
+	writeUserName := beego.AppConfig.String("writeusername")
60
+
61
+	readMiddleHost := beego.AppConfig.String("readmiddlehost")
62
+	readMiddlePort := beego.AppConfig.String("readmiddleport")
63
+	readMiddleUser := beego.AppConfig.String("readmiddleuser")
64
+	readMiddlePass := beego.AppConfig.String("readmiddlepass")
65
+	readMiddleName := beego.AppConfig.String("readmiddlename")
66
+
67
+	writeMiddleHost := beego.AppConfig.String("writemiddlehost")
68
+	writeMiddlePort := beego.AppConfig.String("writemiddleport")
69
+	writeMiddleUser := beego.AppConfig.String("writemiddleuser")
70
+	writeMiddlePass := beego.AppConfig.String("writemiddlepass")
71
+	writeMiddleName := beego.AppConfig.String("writemiddlename")
72
+
73
+	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
74
+	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
75
+
76
+	rudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUserUser, readUserPass, readUserHost, readUserPort, readUserName)
77
+	wudsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUserUser, writeUserPass, writeUserHost, writeUserPort, writeUserName)
78
+
79
+	rmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readMiddleUser, readMiddlePass, readMiddleHost, readMiddlePort, readMiddleName)
80
+	wmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeMiddleUser, writeMiddlePass, writeMiddleHost, writeMiddlePort, writeMiddleName)
81
+
82
+	readDb, err = gorm.Open("mysql", rdsn)
83
+	if err != nil {
84
+		//beego.Error(err)
85
+	}
86
+	readDb.DB().SetMaxIdleConns(10)
87
+	readDb.DB().SetMaxOpenConns(100)
88
+	readDb.LogMode(true)
89
+
90
+	writeDb, err = gorm.Open("mysql", wdsn)
91
+	if err != nil {
92
+		//beego.Error(err)
93
+	}
94
+	writeDb.DB().SetMaxIdleConns(10)
95
+	writeDb.DB().SetMaxOpenConns(100)
96
+	writeDb.LogMode(true)
97
+
98
+	readUserDb, err = gorm.Open("mysql", rudsn)
99
+	if err != nil {
100
+		//beego.Error(err)
101
+	}
102
+	readUserDb.DB().SetMaxIdleConns(10)
103
+	readUserDb.DB().SetMaxOpenConns(100)
104
+	readUserDb.LogMode(true)
105
+
106
+	writeUserDb, err = gorm.Open("mysql", wudsn)
107
+	if err != nil {
108
+		//beego.Error(err)
109
+	}
110
+	writeUserDb.DB().SetMaxIdleConns(10)
111
+	writeUserDb.DB().SetMaxOpenConns(100)
112
+	writeUserDb.LogMode(true)
113
+
114
+	readMiddleDb, err = gorm.Open("mysql", rmdsn)
115
+	if err != nil {
116
+		//beego.Error(err)
117
+	}
118
+	readMiddleDb.DB().SetMaxIdleConns(10)
119
+	readMiddleDb.DB().SetMaxOpenConns(100)
120
+	readMiddleDb.LogMode(true)
121
+
122
+	writeMiddleDb, err = gorm.Open("mysql", wmdsn)
123
+	if err != nil {
124
+		//beego.Error(err)
125
+	}
126
+	writeMiddleDb.DB().SetMaxIdleConns(10)
127
+	writeMiddleDb.DB().SetMaxOpenConns(100)
128
+	writeMiddleDb.LogMode(true)
129
+
130
+}
131
+
132
+//func DisconnectDB() {
133
+//	if err := readDb.Close(); nil != err {
134
+//		beego.Error("Disconnect from database failed: " + err.Error())
135
+//	}
136
+//}
137
+
138
+func XTReadDB() *gorm.DB {
139
+	return readDb
140
+}
141
+func XTWriteDB() *gorm.DB {
142
+	return writeDb
143
+}
144
+func UserReadDB() *gorm.DB {
145
+	return readUserDb
146
+}
147
+func UserWriteDB() *gorm.DB {
148
+	return writeUserDb
149
+}
150
+
151
+func MiddleReadDB() *gorm.DB {
152
+	return readMiddleDb
153
+}
154
+func MiddleWriteDB() *gorm.DB {
155
+	return writeMiddleDb
156
+}

+ 27 - 0
service/db_err_service.go View File

@@ -0,0 +1,27 @@
1
+package service
2
+
3
+import (
4
+	"fmt"
5
+	"time"
6
+
7
+	"XT_New/models"
8
+	"XT_New/utils"
9
+)
10
+
11
+func CreateDBErrorRecord(orgID int64, decsFormat string, v ...interface{}) {
12
+	if orgID < 0 {
13
+		orgID = 0
14
+	}
15
+	now := time.Now()
16
+	record := models.DBErrorRecord{
17
+		OrgID:      orgID,
18
+		ErrDesc:    fmt.Sprintf(decsFormat, v...),
19
+		Status:     1,
20
+		CreateTime: now.Unix(),
21
+		ModifyTime: now.Unix(),
22
+	}
23
+	insertErr := writeDb.Save(&record).Error
24
+	if insertErr != nil {
25
+		utils.ErrorLog("插入数据库执行错误记录失败:%v", insertErr)
26
+	}
27
+}

+ 646 - 0
service/device_service.go View File

@@ -0,0 +1,646 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"fmt"
6
+	"github.com/jinzhu/gorm"
7
+	"strings"
8
+	"time"
9
+)
10
+
11
+//////// 设备基本信息
12
+
13
+func GetValidDevicesBy(orgID int64, deviceType int, zoneID int64) ([]*models.Device, error) {
14
+	var devices []*models.Device
15
+	db := readDb.Model(&models.Device{}).Where("org_id = ? AND status = 1", orgID)
16
+	if deviceType != 0 {
17
+		db = db.Where("device_type = ?", deviceType)
18
+	}
19
+	if zoneID != 0 {
20
+		db = db.Where("device_zone_id = ?", zoneID)
21
+	}
22
+	err := db.Find(&devices).Error
23
+	if err != nil {
24
+		return nil, err
25
+	}
26
+	return devices, nil
27
+}
28
+
29
+// 根据设备关联表的 id,获取设备关联信息
30
+func GetDeviceByID(orgID int64, deviceID int64) (*models.Device, error) {
31
+	var device models.Device
32
+	err := readDb.Model(&models.Device{}).Where("org_id = ? AND id = ?", orgID, deviceID).First(&device).Error
33
+	if err != nil {
34
+		if err == gorm.ErrRecordNotFound {
35
+			return nil, nil
36
+		} else {
37
+			return nil, err
38
+		}
39
+	}
40
+	return &device, nil
41
+}
42
+
43
+func GetDMDeviceByID(orgID int64, id int64) (*models.DeviceDM, error) {
44
+	var device models.DeviceDM
45
+	err := readDb.Model(&models.DeviceDM{}).Where("org_id = ? AND id = ?", orgID, id).First(&device).Error
46
+	if err != nil {
47
+		if err == gorm.ErrRecordNotFound {
48
+			return nil, nil
49
+		} else {
50
+			return nil, err
51
+		}
52
+	}
53
+	return &device, nil
54
+}
55
+
56
+func GetWTEDeviceByID(orgID int64, id int64) (*models.DeviceWTE, error) {
57
+	var device models.DeviceWTE
58
+	err := readDb.Model(&models.DeviceWTE{}).Where("org_id = ? AND id = ?", orgID, id).First(&device).Error
59
+	if err != nil {
60
+		if err == gorm.ErrRecordNotFound {
61
+			return nil, nil
62
+		} else {
63
+			return nil, err
64
+		}
65
+	}
66
+	return &device, nil
67
+}
68
+
69
+// type DeviceBaseInfoViewModel struct {
70
+// 	DeviceType     int   `json:"device_type"`
71
+// 	DeviceNumberID int64 `gorm:"column:device_number_id" json:"device_number_id"`
72
+
73
+// 	ID                 int64  `gorm:"column:id" json:"id"`
74
+// 	SerialNumber       string `json:"serial_number"`        // 序列号
75
+// 	Name               string `json:"name"`                 // 设备名
76
+// 	Manufacturer       string `json:"manufacturer"`         // 生产厂家
77
+// 	RepairFactory      string `json:"repair_factory"`       // 维修厂家
78
+// 	Model              string `json:"model"`                // 型号
79
+// 	Department         string `json:"department"`           // 使用科室
80
+// 	DepartmentNumber   string `json:"department_number"`    // 科室编号
81
+// 	PurchaseDate       int64  `json:"purchase_date"`        // 购买日期
82
+// 	InstallDate        int64  `json:"install_date"`         // 安装日期
83
+// 	CommissioningDate  int64  `json:"commissioning_date"`   // 启用日期
84
+// 	Maintainer         string `json:"maintainer"`           // 维修工程师
85
+// 	MaintenanceCall    string `json:"maintenance_call"`     // 维修联系电话
86
+// 	WarrantyPeriod     string `json:"warranty_period"`      // 保修期限
87
+// 	DeviceStatus       int    `json:"device_status"`        // 机器状态 1.使用机 2.备用机 3.急诊机 4.报废机
88
+// 	InitialUseTimes    int    `json:"initial_use_times"`    // 初始使用次数
89
+// 	Mark               string `json:"mark"`                 // 备注
90
+// 	RetirementDate     int64  `json:"retirement_date"`      // 报废日期
91
+// 	RetirementReason   string `json:"retirement_reason"`    // 报废原因
92
+// 	ServiceLife        int    `json:"service_life"`         // 使用年限
93
+// 	WorkingTime        int    `json:"working_time"`         // 工作时长
94
+// 	TreatmentMode      string `json:"treatment_mode"`       // 治疗模式  DeviceType = 1
95
+// 	ReverseOsmosisMode int    `json:"reverse_osmosis_mode"` // 反渗模式  DeviceType = 2
96
+// }
97
+
98
+// // TODO
99
+// func GetDeviceBaseInfoByDeviceID(deviceID int64) (*DeviceBaseInfoViewModel, error) {
100
+// 	return nil, nil
101
+// }
102
+
103
+// 创建透析机
104
+func CreateDMDevice(dmDevice *models.DeviceDM, deviceNumber *models.DeviceNumber) (*models.Device, error) {
105
+	now := time.Now().Unix()
106
+	dmDevice.Status = 1
107
+	dmDevice.CreateTime = now
108
+	dmDevice.ModifyTime = now
109
+	tx := writeDb.Begin()
110
+	createDMErr := tx.Model(&models.DeviceDM{}).Create(dmDevice).Error
111
+	if createDMErr != nil {
112
+		tx.Rollback()
113
+		return nil, createDMErr
114
+	}
115
+	device := models.Device{
116
+		OrgID:        dmDevice.OrgID,
117
+		DeviceType:   1,
118
+		DMID:         dmDevice.ID,
119
+		SerialNumber: dmDevice.SerialNumber,
120
+		Name:         dmDevice.Name,
121
+		Model:        dmDevice.Model,
122
+		Status:       1,
123
+		CreateTime:   now,
124
+		ModifyTime:   now,
125
+	}
126
+	if deviceNumber != nil {
127
+		device.DeviceNumber = deviceNumber.Number
128
+		device.DeviceNumberID = deviceNumber.ID
129
+		device.DeviceZoneID = deviceNumber.ZoneID
130
+		device.DeviceGroupID = deviceNumber.GroupID
131
+	}
132
+	createDeviceErr := tx.Model(&models.Device{}).Create(&device).Error
133
+	if createDeviceErr != nil {
134
+		tx.Rollback()
135
+		return nil, createDeviceErr
136
+	}
137
+	tx.Commit()
138
+	return &device, nil
139
+}
140
+
141
+// 创建水处理机
142
+func CreateWTEDevice(wteDevice *models.DeviceWTE, deviceNumber *models.DeviceNumber) (*models.Device, error) {
143
+	now := time.Now().Unix()
144
+	wteDevice.Status = 1
145
+	wteDevice.CreateTime = now
146
+	wteDevice.ModifyTime = now
147
+	tx := writeDb.Begin()
148
+	createWTEErr := tx.Model(&models.DeviceWTE{}).Create(wteDevice).Error
149
+	if createWTEErr != nil {
150
+		tx.Rollback()
151
+		return nil, createWTEErr
152
+	}
153
+	device := models.Device{
154
+		OrgID:        wteDevice.OrgID,
155
+		DeviceType:   2,
156
+		WTEID:        wteDevice.ID,
157
+		SerialNumber: wteDevice.SerialNumber,
158
+		Name:         wteDevice.Name,
159
+		Model:        wteDevice.Model,
160
+		Status:       1,
161
+		CreateTime:   now,
162
+		ModifyTime:   now,
163
+	}
164
+	if deviceNumber != nil {
165
+		device.DeviceNumber = deviceNumber.Number
166
+		device.DeviceNumberID = deviceNumber.ID
167
+		device.DeviceZoneID = deviceNumber.ZoneID
168
+		device.DeviceGroupID = deviceNumber.GroupID
169
+	}
170
+	createDeviceErr := tx.Model(&models.Device{}).Create(&device).Error
171
+	if createDeviceErr != nil {
172
+		tx.Rollback()
173
+		return nil, createDeviceErr
174
+	}
175
+	tx.Commit()
176
+	return &device, nil
177
+}
178
+
179
+func UpdateDMDevice(dmDevice *models.DeviceDM, deviceNumber *models.DeviceNumber, device *models.Device) error {
180
+	now := time.Now().Unix()
181
+	tx := writeDb.Begin()
182
+	dmDevice.ModifyTime = now
183
+	updateDMErr := tx.Save(dmDevice).Error
184
+	if updateDMErr != nil {
185
+		tx.Rollback()
186
+		return updateDMErr
187
+	}
188
+	device.SerialNumber = dmDevice.SerialNumber
189
+	device.Name = dmDevice.Name
190
+	device.Model = dmDevice.Model
191
+	if deviceNumber != nil {
192
+		device.DeviceNumberID = deviceNumber.ID
193
+		device.DeviceNumber = deviceNumber.Number
194
+		device.DeviceZoneID = deviceNumber.ZoneID
195
+		device.DeviceGroupID = deviceNumber.GroupID
196
+
197
+	} else {
198
+		device.DeviceNumberID = 0
199
+		device.DeviceNumber = ""
200
+		device.DeviceZoneID = 0
201
+		device.DeviceGroupID = 0
202
+	}
203
+	device.ModifyTime = now
204
+	updateDeviceErr := tx.Save(device).Error
205
+	if updateDeviceErr != nil {
206
+		tx.Rollback()
207
+		return updateDeviceErr
208
+	}
209
+	tx.Commit()
210
+	return nil
211
+}
212
+
213
+func UpdateWTEDevice(wteDevice *models.DeviceWTE, deviceNumber *models.DeviceNumber, device *models.Device) error {
214
+	now := time.Now().Unix()
215
+	tx := writeDb.Begin()
216
+	wteDevice.ModifyTime = now
217
+	updateWTEErr := tx.Save(wteDevice).Error
218
+	if updateWTEErr != nil {
219
+		tx.Rollback()
220
+		return updateWTEErr
221
+	}
222
+	device.SerialNumber = wteDevice.SerialNumber
223
+	device.Name = wteDevice.Name
224
+	device.Model = wteDevice.Model
225
+	device.DeviceNumberID = deviceNumber.ID
226
+	device.DeviceNumber = deviceNumber.Number
227
+	device.ModifyTime = now
228
+	updateDeviceErr := tx.Save(device).Error
229
+	if updateDeviceErr != nil {
230
+		tx.Rollback()
231
+		return updateDeviceErr
232
+	}
233
+	tx.Commit()
234
+	return nil
235
+}
236
+
237
+func UpdateDevice(device *models.Device) error {
238
+	err := writeDb.Save(device).Error
239
+	return err
240
+}
241
+
242
+func GetDeviceCountForDeviceNumberID(orgID int64, deviceNumberID int64) (int, error) {
243
+	var count int
244
+	err := readDb.Model(&models.Device{}).Where("device_number_id = ? AND org_id = ? AND status = 1", deviceNumberID, orgID).Count(&count).Error
245
+	if err != nil {
246
+		return 0, err
247
+	}
248
+	return count, nil
249
+}
250
+
251
+//////// 分区 Zone
252
+
253
+func GetAllValidDeviceZones(orgID int64) ([]*models.DeviceZone, error) {
254
+	var zones []*models.DeviceZone
255
+	err := readDb.Model(&models.DeviceZone{}).Where("org_id = ? AND status = 1", orgID).Find(&zones).Error
256
+	if err != nil {
257
+		return nil, err
258
+	}
259
+	return zones, nil
260
+}
261
+
262
+func GetDeviceZoneByID(orgID int64, zoneID int64) (*models.DeviceZone, error) {
263
+	var zone models.DeviceZone
264
+	err := readDb.Model(&models.DeviceZone{}).Where("org_id = ? AND id = ?", orgID, zoneID).First(&zone).Error
265
+	if err != nil {
266
+		if err == gorm.ErrRecordNotFound {
267
+			return nil, nil
268
+		} else {
269
+			return nil, err
270
+		}
271
+	}
272
+	return &zone, nil
273
+}
274
+
275
+func CreateDeviceZone(orgID int64, name string, type_ int) (*models.DeviceZone, error) {
276
+	now := time.Now().Unix()
277
+	zone := models.DeviceZone{
278
+		OrgID:      orgID,
279
+		Name:       name,
280
+		Type:       type_,
281
+		Status:     1,
282
+		CreateTime: now,
283
+		ModifyTime: now,
284
+	}
285
+	err := writeDb.Model(&models.DeviceZone{}).Create(&zone).Error
286
+	if err != nil {
287
+		return nil, err
288
+	}
289
+	return &zone, nil
290
+}
291
+
292
+func UpdateDeviceZone(zone *models.DeviceZone) error {
293
+	err := writeDb.Save(zone).Error
294
+	return err
295
+}
296
+
297
+//////// 分组 Group
298
+
299
+func GetAllValidDeviceGroups(orgID int64) ([]*models.DeviceGroup, error) {
300
+	var groups []*models.DeviceGroup
301
+	err := readDb.Model(&models.DeviceGroup{}).Where("org_id = ? AND status = 1", orgID).Find(&groups).Error
302
+	if err != nil {
303
+		return nil, err
304
+	}
305
+	return groups, nil
306
+}
307
+
308
+func GetDeviceGroupByID(orgID int64, groupID int64) (*models.DeviceGroup, error) {
309
+	var group models.DeviceGroup
310
+	err := readDb.Model(&models.DeviceGroup{}).Where("org_id = ? AND id = ?", orgID, groupID).First(&group).Error
311
+	if err != nil {
312
+		if err == gorm.ErrRecordNotFound {
313
+			return nil, nil
314
+		} else {
315
+			return nil, err
316
+		}
317
+	}
318
+	return &group, nil
319
+}
320
+
321
+func CreateDeviceGroup(orgID int64, name string) (*models.DeviceGroup, error) {
322
+	now := time.Now().Unix()
323
+	group := models.DeviceGroup{
324
+		OrgID:      orgID,
325
+		Name:       name,
326
+		Status:     1,
327
+		CreateTime: now,
328
+		ModifyTime: now,
329
+	}
330
+	err := writeDb.Model(&models.DeviceGroup{}).Create(&group).Error
331
+	if err != nil {
332
+		return nil, err
333
+	}
334
+	return &group, nil
335
+}
336
+
337
+func UpdateDeviceGroup(group *models.DeviceGroup) error {
338
+	err := writeDb.Save(group).Error
339
+	return err
340
+}
341
+
342
+//////// 机号 Number
343
+
344
+type DeviceNumberViewModel struct {
345
+	models.DeviceNumber
346
+	ZoneName  string `gorm:"column:zone_name" json:"zone_name"`
347
+	GroupName string `gorm:"column:group_name" json:"group_name"`
348
+}
349
+
350
+func GetAllValidDeviceNumbers(orgID int64) ([]*DeviceNumberViewModel, error) {
351
+	var vms []*DeviceNumberViewModel = make([]*DeviceNumberViewModel, 0)
352
+	rows, err := readDb.Raw("SELECT n.*, z.name as zone_name, g.name as group_name FROM xt_device_number as n join xt_device_zone as z on z.id = n.zone_id AND z.status = 1 join xt_device_group as g on g.id = n.group_id WHERE (n.org_id = ? AND n.status = 1)", orgID).Rows()
353
+	defer rows.Close()
354
+	if err != nil {
355
+		return nil, err
356
+	}
357
+	for rows.Next() {
358
+		var vm DeviceNumberViewModel
359
+		readDb.ScanRows(rows, &vm)
360
+		vms = append(vms, &vm)
361
+	}
362
+	return vms, nil
363
+}
364
+
365
+func GetAllBedNumber(orgId int64) (devicenumber []*models.XtDeviceNumber, err error) {
366
+
367
+	err = XTReadDB().Raw("select id as bed_id,org_id,number as bed_number,group_id,zone_id from xt_device_number as n Where NOT EXISTS (select id,bed_id from sgj_users.xt_device_addmacher as a where a.bed_id = n.id and a.status = 1) AND n.org_id = ? AND n.status = 1 ", orgId).Scan(&devicenumber).Error
368
+	return devicenumber, err
369
+}
370
+
371
+func GetAllBedNumberTwo(orgId int64, id int64) (devicenumber []*models.XtDeviceNumber, err error) {
372
+
373
+	err = XTReadDB().Raw("select id as bed_id,org_id,number as bed_number,group_id,zone_id from xt_device_number as n Where NOT EXISTS (select id,bed_id from sgj_users.xt_device_addmacher as a where a.bed_id = n.id and a.status = 1 and a.id <> ?) AND n.org_id = ? AND n.status = 1 ", id, orgId).Scan(&devicenumber).Error
374
+	return devicenumber, err
375
+}
376
+
377
+func GetAllMachineByOrgId(orgid int64) (addmacher []*models.DeviceAddmacher, err error) {
378
+
379
+	err = UserReadDB().Where("user_org_id = ? AND status = 1", orgid).Find(&addmacher).Error
380
+	return addmacher, err
381
+}
382
+
383
+func GetAllDeviceNumbers(orgID int64, record_date int64, schedule_type int64) ([]*DeviceNumberViewModel, error) {
384
+	var vms []*DeviceNumberViewModel = make([]*DeviceNumberViewModel, 0)
385
+	rows, err := readDb.Raw("SELECT n.*, z.name as zone_name, g.name as group_name FROM xt_device_number as n join xt_device_zone as z on z.id = n.zone_id join xt_device_group as g on g.id = n.group_id  WHERE (n.org_id = ? AND n.status = 1) AND NOT EXISTS (Select * FROM xt_schedule as s, `xt_dialysis_order` as d Where d.`dialysis_date` = ? AND d.`status` = 1 AND d.`patient_id` = s.`patient_id` AND   s.user_org_id = n.org_id AND s.`bed_id` = n.id AND s.`schedule_date` = ? AND s.`schedule_type` = ? AND s.status = 1 )", orgID, record_date, record_date, schedule_type).Rows()
386
+	defer rows.Close()
387
+	if err != nil {
388
+		return nil, err
389
+	}
390
+	for rows.Next() {
391
+		var vm DeviceNumberViewModel
392
+		readDb.ScanRows(rows, &vm)
393
+		vms = append(vms, &vm)
394
+	}
395
+	return vms, nil
396
+}
397
+
398
+func GetDeviceNumberByID(orgID int64, numberID int64) (*models.DeviceNumber, error) {
399
+	var number models.DeviceNumber
400
+	err := readDb.Model(&models.DeviceNumber{}).Where("org_id = ? AND id = ?", orgID, numberID).First(&number).Error
401
+	if err != nil {
402
+		if err == gorm.ErrRecordNotFound {
403
+			return nil, nil
404
+		} else {
405
+			return nil, err
406
+		}
407
+	}
408
+	return &number, nil
409
+}
410
+
411
+func CreateDeviceNumber(orgID int64, number string, zoneID int64, groupID int64) (*models.DeviceNumber, error) {
412
+	now := time.Now().Unix()
413
+	numberModel := models.DeviceNumber{
414
+		OrgID:      orgID,
415
+		Number:     number,
416
+		ZoneID:     zoneID,
417
+		GroupID:    groupID,
418
+		Status:     1,
419
+		CreateTime: now,
420
+		ModifyTime: now,
421
+	}
422
+	err := writeDb.Model(&models.DeviceNumber{}).Create(&numberModel).Error
423
+	if err != nil {
424
+		return nil, err
425
+	}
426
+	return &numberModel, nil
427
+}
428
+
429
+func UpdateDeviceNumber(number *models.DeviceNumber) error {
430
+	now := time.Now().Unix()
431
+	number.ModifyTime = now
432
+	tx := writeDb.Begin()
433
+	updateNumberErr := tx.Save(number).Error
434
+	if updateNumberErr != nil {
435
+		tx.Rollback()
436
+		return updateNumberErr
437
+	}
438
+	updateDeviceErr := tx.Model(&models.Device{}).Where("org_id = ? AND device_number_id = ?", number.OrgID, number.ID).Updates(map[string]interface{}{"device_number": number.Number}).Error
439
+	if updateDeviceErr != nil {
440
+		tx.Rollback()
441
+		return updateDeviceErr
442
+	}
443
+	tx.Commit()
444
+	return nil
445
+}
446
+
447
+func GetDeviceNumberCountForZoneID(orgID int64, zoneID int64) (int, error) {
448
+	var count int
449
+	err := readDb.Model(&models.DeviceNumber{}).Where("zone_id = ? AND org_id = ? AND status = 1", zoneID, orgID).Count(&count).Error
450
+	if err != nil {
451
+		return 0, err
452
+	}
453
+	return count, nil
454
+}
455
+
456
+func GetDeviceNumberCountForGroupID(orgID int64, groupID int64) (int, error) {
457
+	var count int
458
+	err := readDb.Model(&models.DeviceNumber{}).Where("group_id = ? AND org_id = ? AND status = 1", groupID, orgID).Count(&count).Error
459
+	if err != nil {
460
+		return 0, err
461
+	}
462
+	return count, nil
463
+}
464
+
465
+func GetScheduleCountForDeviceNumber(orgID int64, deviceNumberID int64, beginDate int64) (int, error) {
466
+	var count int
467
+	err := readDb.Model(&models.Schedule{}).Where("bed_id = ? AND user_org_id = ? AND schedule_date >= ? AND status = 1", deviceNumberID, orgID, beginDate).Count(&count).Error
468
+	if err != nil {
469
+		return 0, err
470
+	}
471
+	return count, nil
472
+}
473
+
474
+func GetScheduleTemplateItemCountForDeviceNumber(orgID int64, deviceNumberID int64) (int, error) {
475
+	var count int
476
+	err := readDb.Model(&models.PatientScheduleTemplateItem{}).Where("device_number_id = ? AND org_id = ? AND status = 1", deviceNumberID, orgID).Count(&count).Error
477
+	if err != nil {
478
+		return 0, err
479
+	}
480
+	return count, nil
481
+}
482
+
483
+func GetZoneId(bednumber int64, orgid int64) (models.DeviceNumber, error) {
484
+
485
+	number := models.DeviceNumber{}
486
+	err := XTReadDB().Model(&number).Where("id = ? AND org_id = ?", bednumber, orgid).Find(&number).Error
487
+	return number, err
488
+}
489
+
490
+//func AddMacher(deviceaddmacher *models.DeviceAddmacher) error{
491
+//	fmt.Println("进来了没哟")
492
+//	tx := writeDb.Begin()
493
+//	err := tx.Model(&models.DeviceAddmachers{}).Create(&deviceaddmacher).Error
494
+//	fmt.Println("错误是什么",err)
495
+//	if err !=nil{
496
+//		tx.Rollback()
497
+//	}
498
+//	tx.Commit()
499
+//	return err
500
+//}
501
+
502
+// func CreateMacher(machers *models.DeviceAddmacher) error {
503
+//      fmt.Println("进来了米有")
504
+// 	begin := writeDb.Begin()
505
+// 	fmt.Println("hhhhhhhh",begin)
506
+// 	err := begin.Model(&models.DeviceAddmacher{}).Create(machers).Error
507
+// 	fmt.Println("err",err)
508
+// 	if err !=nil{
509
+// 		begin.Rollback()
510
+// 	}
511
+// 	begin.Commit()
512
+// 	fmt.Println("执行了没有")
513
+// 	return err
514
+// }
515
+
516
+func GetLastMacherData(orgid int64) (models.DeviceAddmacher, error) {
517
+	addmacher := models.DeviceAddmacher{}
518
+	err := UserReadDB().Model(&addmacher).Where("user_org_id = ? AND status = ?", orgid, 1).Last(&addmacher).Error
519
+	return addmacher, err
520
+}
521
+
522
+func AddTreatMode(machineid int64, orgid int64, treatmodes []int64) (err error) {
523
+	utx := XTWriteDB().Begin()
524
+	if len(treatmodes) > 0 {
525
+		thisSQL := "INSERT INTO xt_device_treatmentmode(machine_id,treate_mode,status,ctime,user_org_id) VALUES "
526
+		insertParams := make([]string, 0)
527
+		insertData := make([]interface{}, 0)
528
+		for _, contagion := range treatmodes {
529
+			insertParams = append(insertParams, "(?, ?, ?, ?, ?)")
530
+			insertData = append(insertData, machineid)
531
+			insertData = append(insertData, contagion)
532
+			insertData = append(insertData, 1)
533
+			insertData = append(insertData, time.Now().Unix())
534
+			insertData = append(insertData, orgid)
535
+		}
536
+		thisSQL += strings.Join(insertParams, ",")
537
+		err = utx.Exec(thisSQL, insertData...).Error
538
+		if err != nil {
539
+			utx.Rollback()
540
+			return
541
+		}
542
+	}
543
+	utx.Commit()
544
+	return
545
+}
546
+
547
+//func DeleteBedNumber(id int64,orgid int64)(error){
548
+//	//err := writeDb.Model(&models.DeviceNumber{}).Where("id = ? AND org_id = ?", id, orgid).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
549
+//	err := writeDb.Model(&models.DeviceNumber{}).Where("id = ? AND org_id = ?", id, orgid).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
550
+//
551
+//
552
+//	fmt.Println("错误是什么",err)
553
+//	return  err
554
+//
555
+//}
556
+//
557
+//func DeleteZoneId(id int64,orgid int64)(error)  {
558
+//	err := writeDb.Model(&models.DeviceZone{}).Where("id = ? AND org_id = ?", id, orgid).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
559
+//	return  err
560
+//}
561
+
562
+func GetAllMachineInfo(page int64, limit int64, keyword string, zoneid int64, equimentid int64, statusid int64, orgid int64) (addmahcer []*models.DeviceAddmachers, total int64, err error) {
563
+
564
+	//db := readUserDb().Table("xt_device_addmacher as a").Where("a.status = 1")
565
+	db := readUserDb.Table("xt_device_addmacher as a").Where("a.status = 1")
566
+	table := XTReadDB().Table("xt_device_zone as x")
567
+	d := readUserDb.Table("xt_device_mode as m")
568
+	fmt.Print("d", d)
569
+	fmt.Println("table", table)
570
+	if orgid > 0 {
571
+		db = db.Where("a.user_org_id = ?", orgid)
572
+	}
573
+	if zoneid > 0 {
574
+		db = db.Where("a.zone_id = ?", zoneid)
575
+	}
576
+	if equimentid > 0 {
577
+		db = db.Where("a.device_type = ?", equimentid)
578
+	}
579
+	if statusid > 0 {
580
+		db = db.Where("a.machine_status = ?", statusid)
581
+	}
582
+
583
+	if len(keyword) > 0 {
584
+		keyword = "%" + keyword + "%"
585
+		db = db.Where("a.serial_number LIKE ? OR a.device_name LIKE ? OR a.unit_type LIKE ?", keyword, keyword, keyword)
586
+	}
587
+
588
+	offset := (page - 1) * limit
589
+
590
+	err = db.Order("a.ctime asc").Select("a.id,a.serial_number,a.device_type,a.bed_number,a.device_name,a.manufacture_factory,a.service_manufacturer,a.unit_type,a.use_section,a.section_number,a.buy_date,a.install_date,a.start_date,a.maintenace_engineer,a.telephone,a.guarantee_date,a.machine_status,a.user_total,a.disinfection_mode,a.remarks,a.rubbish_date,a.rubbish_reason,a.user_year,a.work_time,a.revers_mode,a.user_org_id,a.status,a.ctime,a.mtime,a.bed_id,x.name,m.device_mode").Count(&total).
591
+		Joins("Left JOIN sgj_xt.xt_device_zone as x On x.id = a.zone_id").Joins("Left JOIN xt_device_mode as m on m.id = a.unit_type ").Offset(offset).Limit(limit).Scan(&addmahcer).Error
592
+
593
+	if err != nil {
594
+
595
+		return
596
+	}
597
+	return
598
+}
599
+
600
+func GetAllMachine(zoneid int64, classid int64, deviceid int64, timenow int64, orgid int64) (addmahcer []*models.DeviceAddmachers, err error) {
601
+	fmt.Println("timenow", timenow)
602
+	db := readUserDb.Table("xt_device_addmacher as a").Where("a.status = 1")
603
+	//db := XTReadDB().Table("xt_device_addmacher as a").Where("a.status = 1")
604
+	tab := XTReadDB().Table("xt_schedule as x")
605
+	fmt.Println("tab", tab)
606
+	d := readUserDb.Table("xt_device_mode as m")
607
+	fmt.Print("d", d)
608
+	if orgid > 0 {
609
+		db = db.Where("a.user_org_id = ?", orgid)
610
+	}
611
+	if zoneid > 0 {
612
+		db = db.Where("a.zone_id = ?", zoneid)
613
+	}
614
+
615
+	if deviceid > 0 {
616
+		db = db.Where("a.device_type = ?", deviceid)
617
+	}
618
+	if classid > 0 {
619
+		error := db.Joins("LEFT JOIN sgj_xt.xt_schedule as x On x.bed_id = a.bed_id").Joins("LEFT JOIN xt_device_mode as d on d.id = a.unit_type").Where("x.user_org_id = ? AND x.schedule_date = ? AND x.schedule_type = ? AND x.status = ?", orgid, timenow, classid, 1).Order("a.ctime desc").Select("a.id,a.serial_number,a.device_type,a.bed_number,a.device_name,a.manufacture_factory,a.service_manufacturer,a.unit_type,a.use_section,a.section_number,a.buy_date,a.install_date,a.start_date,a.maintenace_engineer,a.telephone,a.guarantee_date,a.machine_status,a.user_total,a.disinfection_mode,a.remarks,a.rubbish_date,a.rubbish_reason,a.user_year,a.work_time,a.revers_mode,a.user_org_id,a.status,a.ctime,a.mtime,d.device_mode").Find(&addmahcer).Error
620
+		fmt.Println("err", error)
621
+	} else {
622
+		err = db.Order("a.ctime asc").Select("a.id,a.serial_number,a.device_type,a.bed_number,a.device_name,a.manufacture_factory,a.service_manufacturer,a.unit_type,a.use_section,a.section_number,a.buy_date,a.install_date,a.start_date,a.maintenace_engineer,a.telephone,a.guarantee_date,a.machine_status,a.user_total,a.disinfection_mode,a.remarks,a.rubbish_date,a.rubbish_reason,a.user_year,a.work_time,a.revers_mode,a.user_org_id,a.status,a.ctime,a.mtime,a.bed_id,d.device_mode").Joins("LEFT JOIN xt_device_mode as d on d.id = a.unit_type").Find(&addmahcer).Error
623
+		fmt.Println("错误是什么", err)
624
+		if err != nil {
625
+
626
+			return
627
+		}
628
+	}
629
+	return
630
+}
631
+
632
+func GetMachineDetail(id int64, orgid int64) (models.DeviceAddmachers, error) {
633
+	addmacher := models.DeviceAddmachers{}
634
+	//  //	//err := readUserDb.Model(&addmacher).Where("id = ? AND user_org_id = ? AND status = 1", id, orgid).Find(&addmacher).Error
635
+	db := readUserDb.Table("xt_device_addmacher as a").Where("a.status =1")
636
+	d := readUserDb.Table("xt_device_mode as d")
637
+	fmt.Print("d", d)
638
+	err := db.Select("a.id,a.serial_number,a.device_type,a.bed_number,a.device_name,a.manufacture_factory,a.service_manufacturer,a.unit_type as device_mode,a.use_section,a.section_number,a.buy_date,a.install_date,a.start_date,a.maintenace_engineer,a.telephone,a.guarantee_date,a.machine_status,a.user_total,a.disinfection_mode,a.remarks,a.rubbish_date,a.rubbish_reason,a.user_year,a.work_time,a.revers_mode,a.user_org_id,a.status,a.ctime,a.mtime,a.zone_id,a.bed_id").Joins("left join xt_device_mode as d on d.id = a.unit_type ").Where("a.id = ? and a.user_org_id = ?", id, orgid).Find(&addmacher).Error
639
+	return addmacher, err
640
+}
641
+
642
+func GetTreatModel(id int64, orgid int64) (mode []*models.DeviceTreatmentmode, err error) {
643
+	err = XTReadDB().Model(&mode).Where("machine_id = ? AND user_org_id = ? AND status = 1 ", id, orgid).Find(&mode).Error
644
+
645
+	return mode, err
646
+}

+ 0 - 0
service/dialysis_service.go View File


Some files were not shown because too many files changed in this diff