Browse Source

Merge branch 'master' of http://git.shengws.com/csx/XT_New

csx 5 years ago
parent
commit
25daece719

+ 17 - 8
conf/app.conf View File

152
 writemiddlepass = 1Q2W3e4r!@#$
152
 writemiddlepass = 1Q2W3e4r!@#$
153
 writemiddlename = ky_xt_middle
153
 writemiddlename = ky_xt_middle
154
 
154
 
155
-redishost = 120.77.235.13
156
-redishost = 112.74.16.180
155
+
156
+
157
+readpatienthost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
158
+readpatientport = 3306
159
+readpatientuser = root
160
+readpatientpass = 1Q2W3e4r!@#$
161
+readpatientname = sgj_cdm
162
+
163
+writepatienthost = rm-wz9rg531npf61q03tro.mysql.rds.aliyuncs.com
164
+writepatientport = 3306
165
+writepatientuser = root
166
+writepatientpass = 1Q2W3e4r!@#$
167
+writepatientname = sgj_cdm
168
+
169
+#redishost = 120.77.235.13
170
+#redishost = 112.74.16.180
157
 redishost = localhost
171
 redishost = localhost
158
 redisport = 6379
172
 redisport = 6379
159
 redispasswrod = syh@#$%123456!
173
 redispasswrod = syh@#$%123456!
160
 redisdb = 0
174
 redisdb = 0
161
-#redishost = 349e580b2a524290.redis.rds.aliyuncs.com
162
-#redisport = 6379
163
-#redispasswrod = TZtBW098WId3i27clkpj3q8dnUaVFP
164
-#redisdb = 0
165
-
166
 
175
 
167
-        niprocart =  83
176
+niprocart =  83
168
 jms = 80
177
 jms = 80
169
 fistula_needle_set = 81
178
 fistula_needle_set = 81
170
 fistula_needle_set_16 = 82
179
 fistula_needle_set_16 = 82

+ 682 - 3
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go View File

1
 package new_mobile_api_controllers
1
 package new_mobile_api_controllers
2
 
2
 
3
 import (
3
 import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
4
 	"XT_New/service"
6
 	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
5
 	"fmt"
9
 	"fmt"
10
+	"github.com/jinzhu/gorm"
11
+	"strconv"
12
+	"strings"
13
+	"time"
6
 )
14
 )
7
 
15
 
8
 type NewDialysisApiController struct {
16
 type NewDialysisApiController struct {
9
 	NewMobileBaseAPIAuthController
17
 	NewMobileBaseAPIAuthController
10
 }
18
 }
11
 
19
 
20
+func (this *NewDialysisApiController) GetIllnesslist() {
21
+
22
+	illnesslist, err := service.GetIllnessListTwo()
23
+	if err != nil {
24
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
25
+		return
26
+	}
27
+	this.ServeSuccessJSON(map[string]interface{}{
28
+		"illnesslist": illnesslist,
29
+	})
30
+}
31
+
12
 func (this *NewDialysisApiController) GetPatient() {
32
 func (this *NewDialysisApiController) GetPatient() {
13
-	patient, err := service.GetBloodDialysisPatient(7957)
14
-	fmt.Print(patient)
15
-	fmt.Print("报错------------------", err)
33
+	adminInfo := this.GetMobileAdminUserInfo()
34
+	orgid := adminInfo.Org.Id
35
+	page, _ := this.GetInt64("page")
36
+	limit, _ := this.GetInt64("limit")
37
+	patient, total, err := service.GetBloodDialysisPatient(orgid, page, limit)
38
+	if err != nil {
39
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
40
+		return
41
+	}
42
+	this.ServeSuccessJSON(map[string]interface{}{
43
+		"patient": patient,
44
+		"total":   total,
45
+	})
46
+}
47
+
48
+func (this *NewDialysisApiController) GetAllPatient() {
49
+	adminInfo := this.GetMobileAdminUserInfo()
50
+	orgid := adminInfo.Org.Id
51
+	page, _ := this.GetInt64("page")
52
+	fmt.Print("page", page)
53
+	limit, _ := this.GetInt64("limit")
54
+	fmt.Print("limit", limit)
55
+	patient, err := service.GetAllPatient(orgid)
56
+	if err != nil {
57
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
58
+		return
59
+	}
60
+	this.ServeSuccessJSON(map[string]interface{}{
61
+		"patient": patient,
62
+	})
63
+}
64
+
65
+func (this *NewDialysisApiController) GetGeneratedialysisno() {
66
+	adminInfo := this.GetMobileAdminUserInfo()
67
+	orgid := adminInfo.Org.Id
68
+	dialysisNo := service.ChechLastDialysisNoTwo(orgid)
69
+	//fmt.Print("机构ID",adminUserInfo.CurrentOrgId)
70
+	if dialysisNo == 0 {
71
+		dialysisNo = 1
72
+	} else {
73
+		dialysisNo++
74
+	}
75
+	no := strconv.FormatInt(dialysisNo, 10)
76
+
77
+	rep := 3 - len(no)
78
+
79
+	if rep > 0 {
80
+		no = strings.Repeat("0", rep) + no
81
+	}
82
+
83
+	this.ServeSuccessJSON(map[string]interface{}{
84
+		"no": no,
85
+	})
86
+	return
87
+}
88
+
89
+func (this *NewDialysisApiController) GetBloodPatientInfo() {
90
+	adminInfo := this.GetMobileAdminUserInfo()
91
+	orgId := adminInfo.Org.Id
92
+	fmt.Print("机构ID", orgId)
93
+	phone := this.GetString("phone")
94
+	_, errcode := service.GetBloodPatientInfo(orgId, phone)
95
+	fmt.Print("errcode-----------------", errcode)
96
+	if errcode == gorm.ErrRecordNotFound {
97
+		returnData := make(map[string]interface{}, 0)
98
+		returnData["msg"] = "ok"
99
+		this.ServeSuccessJSON(returnData)
100
+		return
101
+	} else if errcode == nil {
102
+		return
103
+	} else {
104
+
105
+	}
106
+}
107
+
108
+func (this *NewDialysisApiController) GetSlowPatientInfo() {
109
+	adminInfo := this.GetMobileAdminUserInfo()
110
+	orgId := adminInfo.Org.Id
111
+	fmt.Print("机构ID", orgId)
112
+	phone := this.GetString("phone")
113
+	fmt.Print("phone", phone)
114
+	_, errcode := service.GetSlowPatientInfo(orgId, phone)
115
+	fmt.Print("errcode -----------------------", errcode)
116
+	if errcode == gorm.ErrRecordNotFound {
117
+		returnData := make(map[string]interface{}, 0)
118
+		returnData["msg"] = "ok"
119
+		this.ServeSuccessJSON(returnData)
120
+		return
121
+	} else if errcode == nil {
122
+		return
123
+	} else {
124
+
125
+	}
126
+
127
+}
128
+
129
+func (this *NewDialysisApiController) GetMemberpatientInfo() {
130
+	adminInfo := this.GetMobileAdminUserInfo()
131
+	orgId := adminInfo.Org.Id
132
+	fmt.Print("机构ID", orgId)
133
+	phone := this.GetString("phone")
134
+	fmt.Print("phone", phone)
135
+	_, errcode := service.GetMemberPatientInfo(orgId, phone)
136
+	fmt.Print("errcode --------------", errcode)
137
+	if errcode == gorm.ErrRecordNotFound {
138
+		returnData := make(map[string]interface{}, 0)
139
+		returnData["msg"] = "ok"
140
+		this.ServeSuccessJSON(returnData)
141
+		return
142
+	} else if errcode == nil {
143
+		return
144
+	} else {
145
+
146
+	}
147
+}
148
+
149
+func (this *NewDialysisApiController) SavePatient() {
150
+	adminInfo := this.GetMobileAdminUserInfo()
151
+	orgid := adminInfo.Org.Id
152
+	dataBody := make(map[string]interface{}, 0)
153
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
154
+	fmt.Print("err", err)
155
+	name := dataBody["name"].(string)
156
+	fmt.Println("姓名", name)
157
+	sex := int64(dataBody["sex"].(float64))
158
+	fmt.Print("性别", sex)
159
+	idCard := dataBody["idCard"].(string)
160
+	fmt.Print("身份证", idCard)
161
+	birthday := dataBody["birthday"].(string)
162
+	births := strings.Split(birthday, "-")
163
+	fmt.Print("生日", birthday)
164
+	birYear, _ := strconv.Atoi(births[0])
165
+	age := time.Now().Year() - birYear
166
+	ages := int64(age)
167
+	fmt.Println("age是多少", ages)
168
+	timeLayout := "2006-01-02 15:04:05"
169
+	theTime, err := utils.ParseTimeStringToTime(timeLayout, birthday+" 00:00:00")
170
+	birth := theTime.Unix()
171
+	fmt.Print(birth)
172
+	phone := dataBody["phone"].(string)
173
+	fmt.Print("电话号码", phone)
174
+	patientType := dataBody["result"].([]interface{})
175
+	fmt.Print("患者标签", patientType)
176
+	dialysis := dataBody["dialysis"].(string)
177
+	fmt.Print("透析号", dialysis)
178
+	patientsoure := int64(dataBody["patientsoure"].(float64))
179
+	fmt.Print("患者来源", patientsoure)
180
+	lapseto := int64(dataBody["lapseto"].(float64))
181
+	fmt.Print("留置状态", lapseto)
182
+	contagions := dataBody["resultTwo"].([]interface{})
183
+	fmt.Print("传染病", contagions)
184
+	ids := make([]int64, 0)
185
+	for _, contagion := range contagions {
186
+		id, _ := strconv.ParseInt(contagion.(string), 10, 64)
187
+		ids = append(ids, id)
188
+	}
189
+	fmt.Print("传染病2", contagions)
190
+	adminssionNumber := dataBody["admissionNumber"].(string)
191
+	fmt.Print("住院号", adminssionNumber)
192
+	fistdate := dataBody["fistDate"].(string)
193
+	fmt.Print("首次透析日期", fistdate)
194
+	times, err := utils.ParseTimeStringToTime(timeLayout, fistdate+"00:00:00")
195
+	fisttime := times.Unix()
196
+	fmt.Print(fisttime)
197
+	diagonse := dataBody["diagnose"].(string)
198
+	fmt.Print("诊断", diagonse)
199
+	avatar := dataBody["avatar"].(string)
200
+	fmt.Print("头像", avatar)
201
+	//慢性病
202
+	requipmentId := dataBody["requipmentId"].(string)
203
+	fmt.Print("设备ID", requipmentId)
204
+	slowContagions := dataBody["resultThree"].([]interface{})
205
+	fmt.Print("慢性传染病", slowContagions)
206
+	idss := make([]int64, 0)
207
+	for _, contagion := range slowContagions {
208
+		id, _ := strconv.ParseInt(contagion.(string), 10, 64)
209
+		idss = append(ids, id)
210
+	}
211
+	slowDiseases := dataBody["resultFour"].([]interface{})
212
+	idsss := make([]int64, 0)
213
+	for _, contagion := range slowDiseases {
214
+		id, _ := strconv.ParseInt(contagion.(string), 10, 64)
215
+		idsss = append(ids, id)
216
+	}
217
+	fmt.Print("慢性病", slowDiseases)
218
+
219
+	bloodPatient := int64(dataBody["bloodPatient"].(float64))
220
+	fmt.Print("血透病人", bloodPatient)
221
+	slowpatient := int64(dataBody["slowPatient"].(float64))
222
+	fmt.Print("慢病病人", slowpatient)
223
+	memberpatient := int64(dataBody["memberPatient"].(float64))
224
+	fmt.Print("会员病人", memberpatient)
225
+	//会员
226
+	memberFistDate := dataBody["memberFistDate"].(string)
227
+	fmt.Print("首次透析日期", memberFistDate)
228
+	membertimes, err := utils.ParseTimeStringToTime(timeLayout, memberFistDate+"00:00:00")
229
+	memtime := membertimes.Unix()
230
+	fmt.Print(memtime)
231
+	patient_type := int64(dataBody["patientType"].(float64))
232
+	fmt.Print("病种", patient_type)
233
+	treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
234
+	fmt.Print("治疗方式", treatmentmethod)
235
+
236
+	//如果是血透病人
237
+	if bloodPatient == 1 {
238
+		_, errcode := service.GetPatientData(phone, orgid)
239
+		if errcode == gorm.ErrRecordNotFound {
240
+			patients := models.Patients{
241
+				Name:              name,
242
+				Gender:            sex,
243
+				Birthday:          birth,
244
+				Age:               ages,
245
+				Phone:             phone,
246
+				Lapseto:           lapseto,
247
+				AdmissionNumber:   adminssionNumber,
248
+				FirstDialysisDate: fisttime,
249
+				Diagnose:          diagonse,
250
+				Source:            patientsoure,
251
+				DialysisNo:        dialysis,
252
+				UserOrgId:         orgid,
253
+				Status:            1,
254
+				CreatedTime:       time.Now().Unix(),
255
+				Avatar:            avatar,
256
+				IdCardNo:          idCard,
257
+			}
258
+			err := service.CreateOldPatient(&patients)
259
+			fmt.Print("报错", err)
260
+			patient, err := service.GetLastOldPatient(orgid)
261
+			fmt.Print("病人ID", patient.ID)
262
+			err = service.AddContagions(patient.ID, patient.CreatedTime, patient.UpdatedTime, ids)
263
+			fmt.Println("添加传染病失败", err)
264
+
265
+			patientsNew := models.XtPatientsNew{
266
+				Name:              name,
267
+				Gender:            sex,
268
+				Birthday:          birth,
269
+				Age:               ages,
270
+				Phone:             phone,
271
+				Lapseto:           lapseto,
272
+				AdmissionNumber:   adminssionNumber,
273
+				FirstDialysisDate: fisttime,
274
+				Diagnose:          diagonse,
275
+				Source:            patientsoure,
276
+				DialysisNo:        dialysis,
277
+				UserOrgId:         orgid,
278
+				Status:            1,
279
+				CreatedTime:       time.Now().Unix(),
280
+				Avatar:            avatar,
281
+				MemberPatients:    memberpatient,
282
+				BloodPatients:     bloodPatient,
283
+				SlowPatients:      slowpatient,
284
+				BloodId:           patient.ID,
285
+			}
286
+			err = service.CreateNewPatient(&patientsNew)
287
+			fmt.Print("报错", err)
288
+			if err != nil {
289
+				this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
290
+				return
291
+			}
292
+			this.ServeSuccessJSON(map[string]interface{}{
293
+				"patient": patientsNew,
294
+			})
295
+		} else if errcode == nil {
296
+			fmt.Print("病人已存在")
297
+			return
298
+		} else {
299
+
300
+		}
301
+	}
302
+
303
+	fmt.Print("slowpatient----------------", slowpatient)
304
+	//如果是慢病病人
305
+	if slowpatient == 1 {
306
+		_, errcodetwo := service.GetSlowPatientData(phone, orgid)
307
+		fmt.Print("查询慢慢是吧", errcodetwo)
308
+		if errcodetwo == gorm.ErrRecordNotFound {
309
+			patients := models.CdmPatients{
310
+				Name:        name,
311
+				Gender:      sex,
312
+				Birthday:    birth,
313
+				Phone:       phone,
314
+				Diagnose:    diagonse,
315
+				Source:      patientsoure,
316
+				UserOrgId:   orgid,
317
+				Status:      1,
318
+				CreatedTime: time.Now().Unix(),
319
+				Avatar:      avatar,
320
+				IdCardNo:    idCard,
321
+			}
322
+			errcodetwo := service.CreateCdmPatient(&patients)
323
+			fmt.Print("报错", errcodetwo)
324
+			patient, errcodetwo := service.GetOldCdmPatient(orgid)
325
+			errcodetwo = service.AddSlowContagions(patient.ID, patient.CreatedTime, patient.UpdatedTime, idss, orgid)
326
+			fmt.Print("添加慢病传染病失败", errcodetwo)
327
+			errcodethree := service.AddSlowDiseases(patient.ID, patient.CreatedTime, patient.UpdatedTime, idsss, orgid)
328
+			fmt.Print("添加慢性病失败", errcodethree)
329
+
330
+			_, errcodefour := service.GetLastNewSlowPatient(phone, orgid)
331
+			if errcodefour == gorm.ErrRecordNotFound {
332
+				patientsNew := models.XtPatientsNew{
333
+					Name:              name,
334
+					Gender:            sex,
335
+					Birthday:          birth,
336
+					Age:               ages,
337
+					Phone:             phone,
338
+					Lapseto:           lapseto,
339
+					AdmissionNumber:   adminssionNumber,
340
+					FirstDialysisDate: fisttime,
341
+					Diagnose:          diagonse,
342
+					Source:            patientsoure,
343
+					DialysisNo:        dialysis,
344
+					UserOrgId:         orgid,
345
+					Status:            1,
346
+					CreatedTime:       time.Now().Unix(),
347
+					Avatar:            avatar,
348
+					MemberPatients:    memberpatient,
349
+					BloodPatients:     bloodPatient,
350
+					SlowPatients:      slowpatient,
351
+					BloodId:           patient.ID,
352
+				}
353
+				err = service.CreateNewPatient(&patientsNew)
354
+				if err != nil {
355
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
356
+					return
357
+				}
358
+				this.ServeSuccessJSON(map[string]interface{}{
359
+					"patient": patientsNew,
360
+				})
361
+			} else if errcodetwo == nil {
362
+				fmt.Print("病人已存在")
363
+				return
364
+			} else {
365
+
366
+			}
367
+
368
+		} else if errcodetwo == nil {
369
+			fmt.Print("病人已存在")
370
+			return
371
+		} else {
372
+
373
+		}
374
+
375
+	}
376
+
377
+	if memberpatient == 1 {
378
+		_, errmembercode := service.GetMemberPatientInfo(orgid, phone)
379
+		if errmembercode == gorm.ErrRecordNotFound {
380
+			customer := models.SgjUserCustomer{
381
+				Name:        name,
382
+				UserOrgId:   orgid,
383
+				Mobile:      phone,
384
+				Gender:      sex,
385
+				Birthday:    birth,
386
+				IllDate:     memtime,
387
+				Status:      1,
388
+				CreatedTime: time.Now().Unix(),
389
+				Avatar:      avatar,
390
+				IllnessId:   patient_type,
391
+				TreatType:   treatmentmethod,
392
+			}
393
+			errmembercode := service.CreateMemberPatient(&customer)
394
+			fmt.Print("创建会员病人失败", errmembercode)
395
+			patient, errmembercodetwo := service.GetMemberNewPatient(phone, orgid)
396
+			if errmembercodetwo == gorm.ErrRecordNotFound {
397
+				patientsNew := models.XtPatientsNew{
398
+					Name:              name,
399
+					Gender:            sex,
400
+					Birthday:          birth,
401
+					Age:               ages,
402
+					Phone:             phone,
403
+					Lapseto:           lapseto,
404
+					AdmissionNumber:   adminssionNumber,
405
+					FirstDialysisDate: fisttime,
406
+					Diagnose:          diagonse,
407
+					Source:            patientsoure,
408
+					DialysisNo:        dialysis,
409
+					UserOrgId:         orgid,
410
+					Status:            1,
411
+					CreatedTime:       time.Now().Unix(),
412
+					Avatar:            avatar,
413
+					MemberPatients:    memberpatient,
414
+					BloodPatients:     bloodPatient,
415
+					SlowPatients:      slowpatient,
416
+					BloodId:           patient.ID,
417
+				}
418
+				err = service.CreateNewPatient(&patientsNew)
419
+				if err != nil {
420
+					this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
421
+					return
422
+				}
423
+				this.ServeSuccessJSON(map[string]interface{}{
424
+					"patient": patientsNew,
425
+				})
426
+			} else if errmembercode == nil {
427
+				fmt.Print("病人已存在")
428
+				return
429
+			} else {
430
+
431
+			}
432
+		} else if errmembercode == nil {
433
+			fmt.Print("病人已存在")
434
+			return
435
+		} else {
436
+
437
+		}
438
+	}
439
+
440
+}
441
+
442
+func (this *NewDialysisApiController) GetPatientDetail() {
443
+	id, _ := this.GetInt64("id")
444
+	//获取病人详情信息
445
+	detail, err := service.GetPatientDetailTwo(id)
446
+	//获取血透医嘱管理
447
+	if err != nil {
448
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
449
+		return
450
+	}
451
+	this.ServeSuccessJSON(map[string]interface{}{
452
+		"patientDetail": detail,
453
+	})
454
+}
455
+
456
+func (this *NewDialysisApiController) GetDoctorAdvices() {
457
+	timeLayout := "2006-01-02"
458
+	loc, _ := time.LoadLocation("Local")
459
+	adminInfo := this.GetMobileAdminUserInfo()
460
+	orgid := adminInfo.Org.Id
461
+	id, _ := this.GetInt64("id")
462
+	fmt.Print("id", id)
463
+	//跟据新表id获取老表id
464
+	newPatientInfo, _ := service.GetPatientDetailTwo(id)
465
+	//获取病人ID
466
+	doctor_type, _ := this.GetInt64("type")
467
+	fmt.Print("医嘱内型", doctor_type)
468
+	start := this.GetString("startime")
469
+	fmt.Print("start", start)
470
+	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
471
+	startime := startTimes.Unix()
472
+	fmt.Print("开始时间", startime)
473
+	end := this.GetString("endtime")
474
+	fmt.Print("end", end)
475
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
476
+	endtime := endTimes.Unix()
477
+	fmt.Print("结束时间", endtime)
478
+	limit, _ := this.GetInt64("limit")
479
+	page, _ := this.GetInt64("page")
480
+	advice, total, err := service.GetNewDoctorAdvice(newPatientInfo.BloodId, doctor_type, startime, endtime, limit, page, orgid)
481
+	if err != nil {
482
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
483
+		return
484
+	}
485
+	this.ServeSuccessJSON(map[string]interface{}{
486
+		"advice": advice,
487
+		"total":  total,
488
+	})
489
+}
490
+
491
+func (this *NewDialysisApiController) GetDryWeight() {
492
+	timeLayout := "2006-01-02"
493
+	loc, _ := time.LoadLocation("Local")
494
+	id, _ := this.GetInt64("id")
495
+	fmt.Print("id", id)
496
+	patient, _ := service.GetPatientDetailTwo(id)
497
+	start := this.GetString("startime")
498
+	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
499
+	startime := startTimes.Unix()
500
+	fmt.Print("startime", startime)
501
+	end := this.GetString("endtime")
502
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
503
+	endtime := endTimes.Unix()
504
+	fmt.Print("endtime", endtime)
505
+	limit, _ := this.GetInt64("limit")
506
+	fmt.Print("limit", limit)
507
+	page, _ := this.GetInt64("page")
508
+	fmt.Print("page", page)
509
+	adminInfo := this.GetMobileAdminUserInfo()
510
+	orgid := adminInfo.Org.Id
511
+	dryweight, total, err := service.GetDryWeight(patient.BloodId, startime, endtime, limit, page, orgid)
512
+	if err != nil {
513
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
514
+		return
515
+	}
516
+	this.ServeSuccessJSON(map[string]interface{}{
517
+		"dryweight": dryweight,
518
+		"total":     total,
519
+	})
520
+}
521
+
522
+func (this *NewDialysisApiController) ToSearch() {
523
+	adminUser := this.GetMobileAdminUserInfo()
524
+	orgId := adminUser.Org.Id
525
+	name := this.GetString("name")
526
+	search, err := service.ToSearch(orgId, name)
527
+	if err != nil {
528
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
529
+		return
530
+	}
531
+	this.ServeSuccessJSON(map[string]interface{}{
532
+		"search": search,
533
+	})
534
+}
535
+
536
+func (this *NewDialysisApiController) GetCourseManagement() {
537
+	timeLayout := "2006-01-02"
538
+	loc, _ := time.LoadLocation("Local")
539
+	id, _ := this.GetInt64("id")
540
+	fmt.Print("id", id)
541
+	patient, _ := service.GetPatientDetailTwo(id)
542
+	start := this.GetString("startime")
543
+	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
544
+	startime := startTimes.Unix()
545
+	fmt.Print("startime", startime)
546
+	end := this.GetString("endtime")
547
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
548
+	endtime := endTimes.Unix()
549
+	fmt.Print("endtime", endtime)
550
+	limit, _ := this.GetInt64("limit")
551
+	fmt.Print("limit", limit)
552
+	page, _ := this.GetInt64("page")
553
+	fmt.Print("page", page)
554
+	adminInfo := this.GetMobileAdminUserInfo()
555
+	orgid := adminInfo.Org.Id
556
+	management, total, err := service.GetCourseManagement(patient.BloodId, startime, endtime, limit, page, orgid)
557
+	if err != nil {
558
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
559
+		return
560
+	}
561
+	this.ServeSuccessJSON(map[string]interface{}{
562
+		"coursemanagement": management,
563
+		"total":            total,
564
+	})
565
+}
566
+
567
+func (this *NewDialysisApiController) DeleteCourseManagement() {
568
+	id, _ := this.GetInt64("id")
569
+	err := service.DeleteCouseManagement(id)
570
+	fmt.Println("错误是什么", err)
571
+	returnData := make(map[string]interface{}, 0)
572
+	returnData["msg"] = "ok"
573
+	this.ServeSuccessJSON(returnData)
574
+	return
575
+}
576
+
577
+func (this *NewDialysisApiController) GetCouseManagentDetail() {
578
+	id, _ := this.GetInt64("id")
579
+	detail, err := service.GetCouseManagentDetail(id)
580
+	if err != nil {
581
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
582
+		return
583
+	}
584
+	this.ServeSuccessJSON(map[string]interface{}{
585
+		"couseDetail": detail,
586
+	})
587
+}
588
+
589
+func (this *NewDialysisApiController) GetAllBloodDialysisPatient() {
590
+	page, _ := this.GetInt64("page")
591
+	fmt.Print("page", page)
592
+	limit, _ := this.GetInt64("limit")
593
+	fmt.Print("limit", limit)
594
+	adminUserInfo := this.GetMobileAdminUserInfo()
595
+	orgid := adminUserInfo.Org.Id
596
+	patient, total, err := service.GetAllBloodDialysisPatient(orgid, page, limit)
597
+	if err != nil {
598
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
599
+		return
600
+	}
601
+	this.ServeSuccessJSON(map[string]interface{}{
602
+		"bloodpatient": patient,
603
+		"total":        total,
604
+	})
605
+}
606
+
607
+func (this *NewDialysisApiController) GetAllSlowPatent() {
608
+	page, _ := this.GetInt64("page")
609
+	fmt.Print("page", page)
610
+	limit, _ := this.GetInt64("limit")
611
+	fmt.Print("limit", limit)
612
+	adminUserInfo := this.GetMobileAdminUserInfo()
613
+	orgid := adminUserInfo.Org.Id
614
+	patient, total, err := service.GetAllSlowPatient(orgid, page, limit)
615
+	fmt.Print("err", err)
616
+	if err != nil {
617
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
618
+		return
619
+	}
620
+	this.ServeSuccessJSON(map[string]interface{}{
621
+		"slowpatient": patient,
622
+		"total":       total,
623
+	})
624
+}
625
+
626
+func (this *NewDialysisApiController) GetAllMemberPatient() {
627
+	page, _ := this.GetInt64("page")
628
+	fmt.Print("page", page)
629
+	limit, _ := this.GetInt64("limit")
630
+	fmt.Print("limit", limit)
631
+	adminUserInfo := this.GetMobileAdminUserInfo()
632
+	orgid := adminUserInfo.Org.Id
633
+	patient, total, err := service.GetAllMemberPatient(orgid, page, limit)
634
+	if err != nil {
635
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
636
+		return
637
+	}
638
+	this.ServeSuccessJSON(map[string]interface{}{
639
+		"memberpatient": patient,
640
+		"total":         total,
641
+	})
642
+}
643
+
644
+func (this *NewDialysisApiController) DeleteDryWeight() {
645
+	id, _ := this.GetInt64("id")
646
+	err := service.DeleteDryWeight(id)
647
+	fmt.Println("错误是什么", err)
648
+	returnData := make(map[string]interface{}, 0)
649
+	returnData["msg"] = "ok"
650
+	this.ServeSuccessJSON(returnData)
651
+	return
652
+}
653
+
654
+func (this *NewDialysisApiController) GetDryWeightDetail() {
655
+	id, _ := this.GetInt64("id")
656
+	fmt.Print("id", id)
657
+	drydetail, err := service.GetDryWeightDetail(id)
658
+	if err != nil {
659
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
660
+		return
661
+	}
662
+	this.ServeSuccessJSON(map[string]interface{}{
663
+		"drydetail": drydetail,
664
+	})
665
+}
16
 
666
 
667
+func (this *NewDialysisApiController) GetlongDialysisrecord() {
668
+	timeLayout := "2006-01-02"
669
+	loc, _ := time.LoadLocation("Local")
670
+	id, _ := this.GetInt64("id")
671
+	fmt.Print("id", id)
672
+	patient, _ := service.GetPatientDetailTwo(id)
673
+	start := this.GetString("startime")
674
+	startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start+" 00:00:00", loc)
675
+	startime := startTimes.Unix()
676
+	fmt.Print("startime", startime)
677
+	end := this.GetString("endtime")
678
+	endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end+" 00:00:00", loc)
679
+	endtime := endTimes.Unix()
680
+	fmt.Print("endtime", endtime)
681
+	limit, _ := this.GetInt64("limit")
682
+	fmt.Print("limit", limit)
683
+	page, _ := this.GetInt64("page")
684
+	fmt.Print("page", page)
685
+	adminInfo := this.GetMobileAdminUserInfo()
686
+	orgid := adminInfo.Org.Id
687
+	dialysisrecord, total, err := service.GetlongDialysisrecord(patient.BloodId, startime, endtime, limit, page, orgid)
688
+	if err != nil {
689
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
690
+		return
691
+	}
692
+	this.ServeSuccessJSON(map[string]interface{}{
693
+		"dialysisrecord": dialysisrecord,
694
+		"total":          total,
695
+	})
17
 }
696
 }

+ 20 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go View File

5
 // 平板端路由,以 /m/api 为前缀
5
 // 平板端路由,以 /m/api 为前缀
6
 func NewMobileAPIControllersRegisterRouters() {
6
 func NewMobileAPIControllersRegisterRouters() {
7
 
7
 
8
+	beego.Router("m/api/patient/getillnesslist", &NewDialysisApiController{}, "Get:GetIllnesslist")
9
+	beego.Router("/m/api/patients/generatedialysisnotwo", &NewDialysisApiController{}, "Get:GetGeneratedialysisno")
8
 	beego.Router("/m/api/patient/getbloodDialysisPatient", &NewDialysisApiController{}, "Get:GetPatient")
10
 	beego.Router("/m/api/patient/getbloodDialysisPatient", &NewDialysisApiController{}, "Get:GetPatient")
9
 
11
 
10
 	beego.Router("/m/api/islogin", &NewLoginApiController{}, "Get:GetLogin")
12
 	beego.Router("/m/api/islogin", &NewLoginApiController{}, "Get:GetLogin")
27
 
29
 
28
 	beego.Router("/m/api/org/create", &MobileRegistController{}, "post:CreateOrg")
30
 	beego.Router("/m/api/org/create", &MobileRegistController{}, "post:CreateOrg")
29
 
31
 
32
+	beego.Router("/m/api/patient/getbloodpatientinfo", &NewDialysisApiController{}, "Get:GetBloodPatientInfo")
33
+	beego.Router("/m/api/patient/getslowpatientinfo", &NewDialysisApiController{}, "Get:GetSlowPatientInfo")
34
+	beego.Router("/m/api/patient/getmemberpatientinfo", &NewDialysisApiController{}, "Get:GetMemberpatientInfo")
35
+	beego.Router("/m/api/patient/savepatient", &NewDialysisApiController{}, "Post:SavePatient")
36
+	beego.Router("/m/api/patient/getpatientdetail", &NewDialysisApiController{}, "Get:GetPatientDetail")
37
+	beego.Router("/m/api/patient/getdoctoradvices", &NewDialysisApiController{}, "Get:GetDoctorAdvices")
38
+	beego.Router("/m/api/paitent/getdryweight", &NewDialysisApiController{}, "Get:GetDryWeight")
39
+	beego.Router("m/api/patient/getbloodDialysisPatientwo", &NewDialysisApiController{}, "Get:GetAllPatient")
40
+	beego.Router("m/api/patient/tosearch", &NewDialysisApiController{}, "Get:ToSearch")
41
+	beego.Router("/m/api/patient/getcoursemanagement", &NewDialysisApiController{}, "Get:GetCourseManagement")
42
+	beego.Router("/m/api/patient/delelecousemanage", &NewDialysisApiController{}, "Delete:DeleteCourseManagement")
43
+	beego.Router("/m/api/patient/getcousemanagementdetail", &NewDialysisApiController{}, "Get:GetCouseManagentDetail")
44
+	beego.Router("/m/api/patient/getallblooddialysispatient", &NewDialysisApiController{}, "Get:GetAllBloodDialysisPatient")
45
+	beego.Router("/m/api/patient/getallslowpatient", &NewDialysisApiController{}, "Get:GetAllSlowPatent")
46
+	beego.Router("/m/api/patient/getallmemberpatient", &NewDialysisApiController{}, "Get:GetAllMemberPatient")
47
+	beego.Router("/m/api/patient/deletedryweight", &NewDialysisApiController{}, "Delete:DeleteDryWeight")
48
+	beego.Router("/m/api/patient/getdryweightdetail", &NewDialysisApiController{}, "Get:GetDryWeightDetail")
49
+	beego.Router("/m/api/patient/getlongdialysisrecord", &NewDialysisApiController{}, "Get:GetlongDialysisrecord")
30
 }
50
 }

+ 236 - 0
models/patient_models.go View File

379
 	RangeType   int64  `json:"range_type"`
379
 	RangeType   int64  `json:"range_type"`
380
 	Value       string `json:"value"`
380
 	Value       string `json:"value"`
381
 }
381
 }
382
+
383
+type SgjUserIllness struct {
384
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
385
+	IllnessName string `gorm:"column:illness_name" json:"illness_name" form:"illness_name"`
386
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
387
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
388
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
389
+}
390
+
391
+func (SgjUserIllness) TableName() string {
392
+	return "sgj_user_illness"
393
+}
394
+
395
+type XtPatientsNew struct {
396
+	ID                           int64   `gorm:"column:id" json:"id" form:"id"`
397
+	UserOrgId                    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
398
+	UserId                       int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
399
+	Avatar                       string  `gorm:"column:avatar" json:"avatar" form:"avatar"`
400
+	PatientType                  int64   `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
401
+	DialysisNo                   string  `gorm:"column:dialysis_no" json:"dialysis_no" form:"dialysis_no"`
402
+	AdmissionNumber              string  `gorm:"column:admission_number" json:"admission_number" form:"admission_number"`
403
+	Source                       int64   `gorm:"column:source" json:"source" form:"source"`
404
+	Lapseto                      int64   `gorm:"column:lapseto" json:"lapseto" form:"lapseto"`
405
+	PartitionId                  int64   `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
406
+	BedId                        int64   `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
407
+	Name                         string  `gorm:"column:name" json:"name" form:"name"`
408
+	Alias                        string  `gorm:"column:alias" json:"alias" form:"alias"`
409
+	Gender                       int64   `gorm:"column:gender" json:"gender" form:"gender"`
410
+	MaritalStatus                int64   `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
411
+	IdCardNo                     string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
412
+	Birthday                     int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
413
+	ReimbursementWayId           int64   `gorm:"column:reimbursement_way_id" json:"reimbursement_way_id" form:"reimbursement_way_id"`
414
+	HealthCareType               int64   `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
415
+	HealthCareNo                 string  `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
416
+	HealthCareDueDate            int64   `gorm:"column:health_care_due_date" json:"health_care_due_date" form:"health_care_due_date"`
417
+	Height                       int64   `gorm:"column:height" json:"height" form:"height"`
418
+	BloodType                    int64   `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
419
+	Rh                           int64   `gorm:"column:rh" json:"rh" form:"rh"`
420
+	HealthCareDueAlertDate       int64   `gorm:"column:health_care_due_alert_date" json:"health_care_due_alert_date" form:"health_care_due_alert_date"`
421
+	EducationLevel               int64   `gorm:"column:education_level" json:"education_level" form:"education_level"`
422
+	Profession                   int64   `gorm:"column:profession" json:"profession" form:"profession"`
423
+	Phone                        string  `gorm:"column:phone" json:"phone" form:"phone"`
424
+	HomeTelephone                string  `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
425
+	RelativePhone                string  `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
426
+	RelativeRelations            string  `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
427
+	HomeAddress                  string  `gorm:"column:home_address" json:"home_address" form:"home_address"`
428
+	WorkUnit                     string  `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
429
+	UnitAddress                  string  `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
430
+	Children                     int64   `gorm:"column:children" json:"children" form:"children"`
431
+	ReceivingDate                int64   `gorm:"column:receiving_date" json:"receiving_date" form:"receiving_date"`
432
+	IsHospitalFirstDialysis      int64   `gorm:"column:is_hospital_first_dialysis" json:"is_hospital_first_dialysis" form:"is_hospital_first_dialysis"`
433
+	FirstDialysisDate            int64   `gorm:"column:first_dialysis_date" json:"first_dialysis_date" form:"first_dialysis_date"`
434
+	FirstDialysisHospital        string  `gorm:"column:first_dialysis_hospital" json:"first_dialysis_hospital" form:"first_dialysis_hospital"`
435
+	PredialysisCondition         string  `gorm:"column:predialysis_condition" json:"predialysis_condition" form:"predialysis_condition"`
436
+	PreHospitalDialysisFrequency string  `gorm:"column:pre_hospital_dialysis_frequency" json:"pre_hospital_dialysis_frequency" form:"pre_hospital_dialysis_frequency"`
437
+	PreHospitalDialysisTimes     int64   `gorm:"column:pre_hospital_dialysis_times" json:"pre_hospital_dialysis_times" form:"pre_hospital_dialysis_times"`
438
+	HospitalFirstDialysisDate    int64   `gorm:"column:hospital_first_dialysis_date" json:"hospital_first_dialysis_date" form:"hospital_first_dialysis_date"`
439
+	InductionPeriod              int64   `gorm:"column:induction_period" json:"induction_period" form:"induction_period"`
440
+	InitialDialysis              int64   `gorm:"column:initial_dialysis" json:"initial_dialysis" form:"initial_dialysis"`
441
+	TotalDialysis                int64   `gorm:"column:total_dialysis" json:"total_dialysis" form:"total_dialysis"`
442
+	AttendingDoctorId            int64   `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
443
+	HeadNurseId                  int64   `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
444
+	Evaluate                     string  `gorm:"column:evaluate" json:"evaluate" form:"evaluate"`
445
+	Diagnose                     string  `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
446
+	Remark                       string  `gorm:"column:remark" json:"remark" form:"remark"`
447
+	RegistrarsId                 int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
448
+	Registrars                   string  `gorm:"column:registrars" json:"registrars" form:"registrars"`
449
+	QrCode                       string  `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
450
+	BindingState                 int64   `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
451
+	PatientComplains             string  `gorm:"column:patient_complains" json:"patient_complains" form:"patient_complains"`
452
+	PresentHistory               string  `gorm:"column:present_history" json:"present_history" form:"present_history"`
453
+	PastHistory                  string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
454
+	Temperature                  float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
455
+	Pulse                        int64   `gorm:"column:pulse" json:"pulse" form:"pulse"`
456
+	Respiratory                  int64   `gorm:"column:respiratory" json:"respiratory" form:"respiratory"`
457
+	Sbp                          int64   `gorm:"column:sbp" json:"sbp" form:"sbp"`
458
+	Dbp                          int64   `gorm:"column:dbp" json:"dbp" form:"dbp"`
459
+	Status                       int64   `gorm:"column:status" json:"status" form:"status"`
460
+	CreatedTime                  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
461
+	UpdatedTime                  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
462
+	Nation                       string  `gorm:"column:nation" json:"nation" form:"nation"`
463
+	NativePlace                  string  `gorm:"column:native_place" json:"native_place" form:"native_place"`
464
+	Age                          int64   `gorm:"column:age" json:"age" form:"age"`
465
+	InfectiousNextRecordTime     int64   `gorm:"column:infectious_next_record_time" json:"infectious_next_record_time" form:"infectious_next_record_time"`
466
+	IsInfectious                 int64   `gorm:"column:is_infectious" json:"is_infectious" form:"is_infectious"`
467
+	RemindCycle                  int64   `gorm:"column:remind_cycle" json:"remind_cycle" form:"remind_cycle"`
468
+	ResponseResult               string  `gorm:"column:response_result" json:"response_result" form:"response_result"`
469
+	IsOpenRemind                 int64   `gorm:"column:is_open_remind" json:"is_open_remind" form:"is_open_remind"`
470
+	FirstTreatmentDate           int64   `gorm:"column:first_treatment_date" json:"first_treatment_date" form:"first_treatment_date"`
471
+	DialysisAge                  int64   `gorm:"column:dialysis_age" json:"dialysis_age" form:"dialysis_age"`
472
+	ExpenseKind                  int64   `gorm:"column:expense_kind" json:"expense_kind" form:"expense_kind"`
473
+	TellPhone                    string  `gorm:"column:tell_phone" json:"tell_phone" form:"tell_phone"`
474
+	ContactName                  string  `gorm:"column:contact_name" json:"contact_name" form:"contact_name"`
475
+	BloodPatients                int64   `gorm:"column:blood_patients" json:"blood_patients" form:"blood_patients"`
476
+	SlowPatients                 int64   `gorm:"column:slow_patients" json:"slow_patients" form:"slow_patients"`
477
+	MemberPatients               int64   `gorm:"column:member_patients" json:"member_patients" form:"member_patients"`
478
+	EcommerPatients              string  `gorm:"column:ecommer_patients" json:"ecommer_patients" form:"ecommer_patients"`
479
+	BloodId                      int64   `gorm:"column:blood_id" json:"blood_id" form:"blood_id"`
480
+	SlowId                       int64   `gorm:"column:slow_id" json:"slow_id" form:"slow_id"`
481
+	MemberId                     int64   `gorm:"column:member_id" json:"member_id" form:"member_id"`
482
+}
483
+
484
+func (XtPatientsNew) TableName() string {
485
+	return "xt_patients_new"
486
+}
487
+
488
+type PatientsNew struct {
489
+	ID   int64  `gorm:"column:id" json:"id" form:"id"`
490
+	Name string `gorm:"column:name" json:"name" form:"name"`
491
+}
492
+
493
+type CdmPatients struct {
494
+	ID                int64  `gorm:"column:id" json:"id" form:"id"`
495
+	UserOrgId         int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
496
+	UserId            int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
497
+	Avatar            string `gorm:"column:avatar" json:"avatar" form:"avatar"`
498
+	PatientType       int64  `gorm:"column:patient_type" json:"patient_type" form:"patient_type"`
499
+	Source            int64  `gorm:"column:source" json:"source" form:"source"`
500
+	Name              string `gorm:"column:name" json:"name" form:"name"`
501
+	Alias             string `gorm:"column:alias" json:"alias" form:"alias"`
502
+	Gender            int64  `gorm:"column:gender" json:"gender" form:"gender"`
503
+	MaritalStatus     int64  `gorm:"column:marital_status" json:"marital_status" form:"marital_status"`
504
+	IdCardNo          string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
505
+	Birthday          int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
506
+	HealthCareType    int64  `gorm:"column:health_care_type" json:"health_care_type" form:"health_care_type"`
507
+	HealthCareNo      string `gorm:"column:health_care_no" json:"health_care_no" form:"health_care_no"`
508
+	Height            int64  `gorm:"column:height" json:"height" form:"height"`
509
+	BloodType         int64  `gorm:"column:blood_type" json:"blood_type" form:"blood_type"`
510
+	Rh                int64  `gorm:"column:rh" json:"rh" form:"rh"`
511
+	EducationLevel    int64  `gorm:"column:education_level" json:"education_level" form:"education_level"`
512
+	Profession        int64  `gorm:"column:profession" json:"profession" form:"profession"`
513
+	Phone             string `gorm:"column:phone" json:"phone" form:"phone"`
514
+	HomeTelephone     string `gorm:"column:home_telephone" json:"home_telephone" form:"home_telephone"`
515
+	RelativePhone     string `gorm:"column:relative_phone" json:"relative_phone" form:"relative_phone"`
516
+	RelativeRelations string `gorm:"column:relative_relations" json:"relative_relations" form:"relative_relations"`
517
+	HomeAddress       string `gorm:"column:home_address" json:"home_address" form:"home_address"`
518
+	WorkUnit          string `gorm:"column:work_unit" json:"work_unit" form:"work_unit"`
519
+	UnitAddress       string `gorm:"column:unit_address" json:"unit_address" form:"unit_address"`
520
+	Children          int64  `gorm:"column:children" json:"children" form:"children"`
521
+	AttendingDoctorId int64  `gorm:"column:attending_doctor_id" json:"attending_doctor_id" form:"attending_doctor_id"`
522
+	HeadNurseId       int64  `gorm:"column:head_nurse_id" json:"head_nurse_id" form:"head_nurse_id"`
523
+	Diagnose          string `gorm:"column:diagnose" json:"diagnose" form:"diagnose"`
524
+	Remark            string `gorm:"column:remark" json:"remark" form:"remark"`
525
+	RegistrarsId      int64  `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
526
+	Registrars        string `gorm:"column:registrars" json:"registrars" form:"registrars"`
527
+	QrCode            string `gorm:"column:qr_code" json:"qr_code" form:"qr_code"`
528
+	BindingState      int64  `gorm:"column:binding_state" json:"binding_state" form:"binding_state"`
529
+	Status            int64  `gorm:"column:status" json:"status" form:"status"`
530
+	CreatedTime       int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
531
+	UpdatedTime       int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
532
+}
533
+
534
+func (CdmPatients) TableName() string {
535
+	return "xt_patients"
536
+}
537
+
538
+type SgjUserCustomer struct {
539
+	ID              int64  `gorm:"column:id" json:"id" form:"id"`
540
+	UserOrgId       int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
541
+	UserId          int64  `gorm:"column:user_id" json:"user_id" form:"user_id"`
542
+	Mobile          string `gorm:"column:mobile" json:"mobile" form:"mobile"`
543
+	Name            string `gorm:"column:name" json:"name" form:"name"`
544
+	Gender          int64  `gorm:"column:gender" json:"gender" form:"gender"`
545
+	ProvinceId      int64  `gorm:"column:province_id" json:"province_id" form:"province_id"`
546
+	CityId          int64  `gorm:"column:city_id" json:"city_id" form:"city_id"`
547
+	Address         string `gorm:"column:address" json:"address" form:"address"`
548
+	Birthday        int64  `gorm:"column:birthday" json:"birthday" form:"birthday"`
549
+	TreatType       int64  `gorm:"column:treat_type" json:"treat_type" form:"treat_type"`
550
+	Relationship    int64  `gorm:"column:relationship" json:"relationship" form:"relationship"`
551
+	IllnessId       int64  `gorm:"column:illness_id" json:"illness_id" form:"illness_id"`
552
+	WechatOpenid    string `gorm:"column:wechat_openid" json:"wechat_openid" form:"wechat_openid"`
553
+	Membership      int64  `gorm:"column:membership" json:"membership" form:"membership"`
554
+	Sources         int64  `gorm:"column:sources" json:"sources" form:"sources"`
555
+	Status          int64  `gorm:"column:status" json:"status" form:"status"`
556
+	CreatedTime     int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
557
+	UpdatedTime     int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
558
+	Avatar          string `gorm:"column:avatar" json:"avatar" form:"avatar"`
559
+	WechatUnionid   string `gorm:"column:wechat_unionid" json:"wechat_unionid" form:"wechat_unionid"`
560
+	Remark          string `gorm:"column:remark" json:"remark" form:"remark"`
561
+	MedicalDiagnose string `gorm:"column:medical_diagnose" json:"medical_diagnose" form:"medical_diagnose"`
562
+	YzUid           int64  `gorm:"column:yz_uid" json:"yz_uid" form:"yz_uid"`
563
+	Tttime          int64  `gorm:"column:tttime" json:"tttime" form:"tttime"`
564
+	IllDate         int64  `gorm:"column:ill_date" json:"ill_date" form:"ill_date"`
565
+	DistrictId      int64  `gorm:"column:district_id" json:"district_id" form:"district_id"`
566
+}
567
+
568
+func (SgjUserCustomer) TableName() string {
569
+	return "sgj_user_customer"
570
+}
571
+
572
+type PatientCourseOfDiseases struct {
573
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
574
+	OrgId      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
575
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
576
+	Recorder   int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
577
+	RecordTime int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
578
+	Content    string `gorm:"column:content" json:"content" form:"content"`
579
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
580
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
581
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
582
+	Title      string `gorm:"column:title" json:"title" form:"title"`
583
+	UserName   string `gorm:"column:user_name" json:"user_name" form:"user_name"`
584
+}
585
+
586
+type PatientCourseOfDiseasess struct {
587
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
588
+	OrgId      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
589
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
590
+	Recorder   int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
591
+	RecordTime int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
592
+	Content    string `gorm:"column:content" json:"content" form:"content"`
593
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
594
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
595
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
596
+	Title      string `gorm:"column:title" json:"title" form:"title"`
597
+	UserName   string `gorm:"column:user_name" json:"user_name" form:"user_name"`
598
+	Name       string `gorm:"column:name" json:"name" form:"name"`
599
+}
600
+
601
+type PatientCourseOfDisease struct {
602
+	ID         int64  `gorm:"column:id" json:"id" form:"id"`
603
+	OrgId      int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
604
+	PatientId  int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
605
+	Recorder   int64  `gorm:"column:recorder" json:"recorder" form:"recorder"`
606
+	RecordTime int64  `gorm:"column:record_time" json:"record_time" form:"record_time"`
607
+	Content    string `gorm:"column:content" json:"content" form:"content"`
608
+	Status     int64  `gorm:"column:status" json:"status" form:"status"`
609
+	Ctime      int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
610
+	Mtime      int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
611
+	Title      string `gorm:"column:title" json:"title" form:"title"`
612
+}
613
+
614
+func (PatientCourseOfDisease) TableName() string {
615
+
616
+	return "xt_patient_course_of_disease"
617
+}

+ 235 - 0
models/user_models.go View File

88
 	return "xt_patient_dryweight"
88
 	return "xt_patient_dryweight"
89
 }
89
 }
90
 
90
 
91
+type SgjPatientDryweights 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
+	Name          string  `gorm:"column:name" json:"name" form:"name"`
105
+}
106
+
91
 type XtPatientDryweight struct {
107
 type XtPatientDryweight struct {
92
 	ID            int64   `gorm:"column:id" json:"id" form:"id"`
108
 	ID            int64   `gorm:"column:id" json:"id" form:"id"`
93
 	DryWeight     float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
109
 	DryWeight     float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
102
 	UserId        int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
118
 	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"`
119
 	UserName      string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
104
 }
120
 }
121
+
122
+type XtDialysisPrescription struct {
123
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
124
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
125
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
126
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialyzer"`
127
+	MachineType                string  `gorm:"column:machine_type" json:"machine_type" form:"machine_type"`
128
+	DewaterAmount              float64 `gorm:"column:dewater_amount" json:"dewater_amount" form:"dewater_amount"`
129
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
130
+	PrescriptionDewatering     float64 `gorm:"column:prescription_dewatering" json:"prescription_dewatering" form:"prescription_dewatering"`
131
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
132
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
133
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
134
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
135
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
136
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
137
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
138
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
139
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
140
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
141
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total" form:"replacement_total"`
142
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
143
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
144
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
145
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
146
+	DryWeight                  float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
147
+	VascularAccessMode         int64   `gorm:"column:vascular_access_mode" json:"vascular_access_mode" form:"vascular_access_mode"`
148
+	VascularAccess             int64   `gorm:"column:vascular_access" json:"vascular_access" form:"vascular_access"`
149
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
150
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
151
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
152
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
153
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
154
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
155
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
156
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
157
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
158
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
159
+	PrescriptionDoctor         int64   `gorm:"column:prescription_doctor" json:"prescription_doctor" form:"prescription_doctor"`
160
+	Creater                    int64   `gorm:"column:creater" json:"creater" form:"creater"`
161
+	Modifier                   int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
162
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
163
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
164
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
165
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
166
+	RecordDate                 int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
167
+	RecordId                   int64   `gorm:"column:record_id" json:"record_id" form:"record_id"`
168
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
169
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
170
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid" form:"body_fluid"`
171
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine" form:"special_medicine"`
172
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other" form:"special_medicine_other"`
173
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part" form:"displace_liqui_part"`
174
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access" form:"blood_access"`
175
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
176
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
177
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
178
+	Niprocart                  int64   `gorm:"column:niprocart" json:"niprocart" form:"niprocart"`
179
+	Jms                        int64   `gorm:"column:jms" json:"jms" form:"jms"`
180
+	FistulaNeedleSet           int64   `gorm:"column:fistula_needle_set" json:"fistula_needle_set" form:"fistula_needle_set"`
181
+	FistulaNeedleSet16         int64   `gorm:"column:fistula_needle_set_16" json:"fistula_needle_set_16" form:"fistula_needle_set_16"`
182
+	Hemoperfusion              int64   `gorm:"column:hemoperfusion" json:"hemoperfusion" form:"hemoperfusion"`
183
+	DialyserSterilised         int64   `gorm:"column:dialyser_sterilised" json:"dialyser_sterilised" form:"dialyser_sterilised"`
184
+	Filtryzer                  int64   `gorm:"column:filtryzer" json:"filtryzer" form:"filtryzer"`
185
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
186
+	Dialyzers                  int64   `gorm:"column:dialyzers" json:"dialyzers" form:"dialyzers"`
187
+	Injector                   int64   `gorm:"column:injector" json:"injector" form:"injector"`
188
+	Bloodlines                 int64   `gorm:"column:bloodlines" json:"bloodlines" form:"bloodlines"`
189
+	TubingHemodialysis         int64   `gorm:"column:tubing_hemodialysis" json:"tubing_hemodialysis" form:"tubing_hemodialysis"`
190
+	Package                    int64   `gorm:"column:package" json:"package" form:"package"`
191
+	ALiquid                    int64   `gorm:"column:a_liquid" json:"a_liquid" form:"a_liquid"`
192
+}
193
+
194
+func (XtDialysisPrescription) TableName() string {
195
+
196
+	return "xt_dialysis_prescription"
197
+}
198
+
199
+type XtDialysisPrescriptions struct {
200
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
201
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
202
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
203
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialyzer"`
204
+	MachineType                string  `gorm:"column:machine_type" json:"machine_type" form:"machine_type"`
205
+	DewaterAmount              float64 `gorm:"column:dewater_amount" json:"dewater_amount" form:"dewater_amount"`
206
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
207
+	PrescriptionDewatering     float64 `gorm:"column:prescription_dewatering" json:"prescription_dewatering" form:"prescription_dewatering"`
208
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
209
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
210
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
211
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
212
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
213
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
214
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
215
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
216
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
217
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
218
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total" form:"replacement_total"`
219
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
220
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
221
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
222
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
223
+	DryWeight                  float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
224
+	VascularAccessMode         int64   `gorm:"column:vascular_access_mode" json:"vascular_access_mode" form:"vascular_access_mode"`
225
+	VascularAccess             int64   `gorm:"column:vascular_access" json:"vascular_access" form:"vascular_access"`
226
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
227
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
228
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
229
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
230
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
231
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
232
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
233
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
234
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
235
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
236
+	PrescriptionDoctor         int64   `gorm:"column:prescription_doctor" json:"prescription_doctor" form:"prescription_doctor"`
237
+	Creater                    int64   `gorm:"column:creater" json:"creater" form:"creater"`
238
+	Modifier                   int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
239
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
240
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
241
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
242
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
243
+	RecordDate                 int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
244
+	RecordId                   int64   `gorm:"column:record_id" json:"record_id" form:"record_id"`
245
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
246
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
247
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid" form:"body_fluid"`
248
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine" form:"special_medicine"`
249
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other" form:"special_medicine_other"`
250
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part" form:"displace_liqui_part"`
251
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access" form:"blood_access"`
252
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
253
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
254
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
255
+	Niprocart                  int64   `gorm:"column:niprocart" json:"niprocart" form:"niprocart"`
256
+	Jms                        int64   `gorm:"column:jms" json:"jms" form:"jms"`
257
+	FistulaNeedleSet           int64   `gorm:"column:fistula_needle_set" json:"fistula_needle_set" form:"fistula_needle_set"`
258
+	FistulaNeedleSet16         int64   `gorm:"column:fistula_needle_set_16" json:"fistula_needle_set_16" form:"fistula_needle_set_16"`
259
+	Hemoperfusion              int64   `gorm:"column:hemoperfusion" json:"hemoperfusion" form:"hemoperfusion"`
260
+	DialyserSterilised         int64   `gorm:"column:dialyser_sterilised" json:"dialyser_sterilised" form:"dialyser_sterilised"`
261
+	Filtryzer                  int64   `gorm:"column:filtryzer" json:"filtryzer" form:"filtryzer"`
262
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
263
+	Dialyzers                  int64   `gorm:"column:dialyzers" json:"dialyzers" form:"dialyzers"`
264
+	Injector                   int64   `gorm:"column:injector" json:"injector" form:"injector"`
265
+	Bloodlines                 int64   `gorm:"column:bloodlines" json:"bloodlines" form:"bloodlines"`
266
+	TubingHemodialysis         int64   `gorm:"column:tubing_hemodialysis" json:"tubing_hemodialysis" form:"tubing_hemodialysis"`
267
+	Package                    int64   `gorm:"column:package" json:"package" form:"package"`
268
+	ALiquid                    int64   `gorm:"column:a_liquid" json:"a_liquid" form:"a_liquid"`
269
+	UserName                   string  `gorm:"column:user_name" json:"user_name" form:"user_name"`
270
+}
271
+
272
+type XtDialysisSolution struct {
273
+	ID                         int64   `gorm:"column:id" json:"id" form:"id"`
274
+	Name                       string  `gorm:"column:name" json:"name" form:"name"`
275
+	SubName                    string  `gorm:"column:sub_name" json:"sub_name" form:"sub_name"`
276
+	UserOrgId                  int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
277
+	PatientId                  int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
278
+	ParentId                   int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
279
+	Type                       int64   `gorm:"column:type" json:"type" form:"type"`
280
+	Period                     string  `gorm:"column:period" json:"period" form:"period"`
281
+	Times                      string  `gorm:"column:times" json:"times" form:"times"`
282
+	Anticoagulant              int64   `gorm:"column:anticoagulant" json:"anticoagulant" form:"anticoagulant"`
283
+	AnticoagulantShouji        float64 `gorm:"column:anticoagulant_shouji" json:"anticoagulant_shouji" form:"anticoagulant_shouji"`
284
+	AnticoagulantWeichi        float64 `gorm:"column:anticoagulant_weichi" json:"anticoagulant_weichi" form:"anticoagulant_weichi"`
285
+	AnticoagulantZongliang     float64 `gorm:"column:anticoagulant_zongliang" json:"anticoagulant_zongliang" form:"anticoagulant_zongliang"`
286
+	AnticoagulantGaimingcheng  string  `gorm:"column:anticoagulant_gaimingcheng" json:"anticoagulant_gaimingcheng" form:"anticoagulant_gaimingcheng"`
287
+	AnticoagulantGaijiliang    string  `gorm:"column:anticoagulant_gaijiliang" json:"anticoagulant_gaijiliang" form:"anticoagulant_gaijiliang"`
288
+	ModeName                   string  `gorm:"column:mode_name" json:"mode_name" form:"mode_name"`
289
+	ModeId                     int64   `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
290
+	DialysisDuration           float64 `gorm:"column:dialysis_duration" json:"dialysis_duration" form:"dialysis_duration"`
291
+	ReplacementWay             int64   `gorm:"column:replacement_way" json:"replacement_way" form:"replacement_way"`
292
+	HemodialysisMachine        int64   `gorm:"column:hemodialysis_machine" json:"hemodialysis_machine" form:"hemodialysis_machine"`
293
+	BloodFilter                int64   `gorm:"column:blood_filter" json:"blood_filter" form:"blood_filter"`
294
+	PerfusionApparatus         int64   `gorm:"column:perfusion_apparatus" json:"perfusion_apparatus" form:"perfusion_apparatus"`
295
+	BloodFlowVolume            float64 `gorm:"column:blood_flow_volume" json:"blood_flow_volume" form:"blood_flow_volume"`
296
+	Dewater                    float64 `gorm:"column:dewater" json:"dewater" form:"dewater"`
297
+	DisplaceLiqui              float64 `gorm:"column:displace_liqui" json:"displace_liqui" form:"displace_liqui"`
298
+	Glucose                    float64 `gorm:"column:glucose" json:"glucose" form:"glucose"`
299
+	DryWeight                  float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
300
+	DialysateFlow              float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
301
+	Kalium                     float64 `gorm:"column:kalium" json:"kalium" form:"kalium"`
302
+	Sodium                     float64 `gorm:"column:sodium" json:"sodium" form:"sodium"`
303
+	Calcium                    float64 `gorm:"column:calcium" json:"calcium" form:"calcium"`
304
+	Bicarbonate                float64 `gorm:"column:bicarbonate" json:"bicarbonate" form:"bicarbonate"`
305
+	Doctor                     int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
306
+	FirstDialysis              int64   `gorm:"column:first_dialysis" json:"first_dialysis" form:"first_dialysis"`
307
+	Remark                     string  `gorm:"column:remark" json:"remark" form:"remark"`
308
+	InitiateMode               int64   `gorm:"column:initiate_mode" json:"initiate_mode" form:"initiate_mode"`
309
+	AffirmState                int64   `gorm:"column:affirm_state" json:"affirm_state" form:"affirm_state"`
310
+	UseState                   int64   `gorm:"column:use_state" json:"use_state" form:"use_state"`
311
+	Status                     int64   `gorm:"column:status" json:"status" form:"status"`
312
+	RegistrarsId               int64   `gorm:"column:registrars_id" json:"registrars_id" form:"registrars_id"`
313
+	CreatedTime                int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
314
+	UpdatedTime                int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
315
+	SolutionType               int64   `gorm:"column:solution_type" json:"solution_type" form:"solution_type"`
316
+	DialysateTemperature       float64 `gorm:"column:dialysate_temperature" json:"dialysate_temperature" form:"dialysate_temperature"`
317
+	Conductivity               float64 `gorm:"column:conductivity" json:"conductivity" form:"conductivity"`
318
+	DialysisDurationHour       int64   `gorm:"column:dialysis_duration_hour" json:"dialysis_duration_hour" form:"dialysis_duration_hour"`
319
+	DialysisDurationMinute     int64   `gorm:"column:dialysis_duration_minute" json:"dialysis_duration_minute" form:"dialysis_duration_minute"`
320
+	TargetUltrafiltration      float64 `gorm:"column:target_ultrafiltration" json:"target_ultrafiltration" form:"target_ultrafiltration"`
321
+	DialysateFormulation       int64   `gorm:"column:dialysate_formulation" json:"dialysate_formulation" form:"dialysate_formulation"`
322
+	Dialyzer                   int64   `gorm:"column:dialyzer" json:"dialyzer" form:"dialyzer"`
323
+	ReplacementTotal           float64 `gorm:"column:replacement_total" json:"replacement_total" form:"replacement_total"`
324
+	DialyzerPerfusionApparatus string  `gorm:"column:dialyzer_perfusion_apparatus" json:"dialyzer_perfusion_apparatus" form:"dialyzer_perfusion_apparatus"`
325
+	BodyFluid                  int64   `gorm:"column:body_fluid" json:"body_fluid" form:"body_fluid"`
326
+	SpecialMedicine            int64   `gorm:"column:special_medicine" json:"special_medicine" form:"special_medicine"`
327
+	SpecialMedicineOther       string  `gorm:"column:special_medicine_other" json:"special_medicine_other" form:"special_medicine_other"`
328
+	DisplaceLiquiPart          int64   `gorm:"column:displace_liqui_part" json:"displace_liqui_part" form:"displace_liqui_part"`
329
+	DisplaceLiquiValue         float64 `gorm:"column:displace_liqui_value" json:"displace_liqui_value" form:"displace_liqui_value"`
330
+	BloodAccess                int64   `gorm:"column:blood_access" json:"blood_access" form:"blood_access"`
331
+	Ultrafiltration            float64 `gorm:"column:ultrafiltration" json:"ultrafiltration" form:"ultrafiltration"`
332
+	BodyFluidOther             string  `gorm:"column:body_fluid_other" json:"body_fluid_other" form:"body_fluid_other"`
333
+	TargetKtv                  float64 `gorm:"column:target_ktv" json:"target_ktv" form:"target_ktv"`
334
+}
335
+
336
+func (XtDialysisSolution) TableName() string {
337
+
338
+	return "xt_dialysis_prescription"
339
+}

+ 0 - 1
routers/router.go View File

5
 	//admin_api "XT_New/controllers/admin_api_controllers"
5
 	//admin_api "XT_New/controllers/admin_api_controllers"
6
 	m_api "XT_New/controllers/mobile_api_controllers"
6
 	m_api "XT_New/controllers/mobile_api_controllers"
7
 	new_m_api "XT_New/controllers/new_mobile_api_controllers"
7
 	new_m_api "XT_New/controllers/new_mobile_api_controllers"
8
-
9
 	"github.com/astaxie/beego"
8
 	"github.com/astaxie/beego"
10
 	"github.com/astaxie/beego/plugins/cors"
9
 	"github.com/astaxie/beego/plugins/cors"
11
 )
10
 )

+ 41 - 0
service/db.go View File

31
 
31
 
32
 var readMiddleDb *gorm.DB
32
 var readMiddleDb *gorm.DB
33
 var writeMiddleDb *gorm.DB
33
 var writeMiddleDb *gorm.DB
34
+
35
+var readPatientDb *gorm.DB
36
+var writePatientDb *gorm.DB
34
 var err error
37
 var err error
35
 
38
 
36
 func ConnectDB() {
39
 func ConnectDB() {
70
 	writeMiddlePass := beego.AppConfig.String("writemiddlepass")
73
 	writeMiddlePass := beego.AppConfig.String("writemiddlepass")
71
 	writeMiddleName := beego.AppConfig.String("writemiddlename")
74
 	writeMiddleName := beego.AppConfig.String("writemiddlename")
72
 
75
 
76
+	readPatientHost := beego.AppConfig.String("readpatienthost")
77
+	readPatientPort := beego.AppConfig.String("readpatientport")
78
+	readPatientUser := beego.AppConfig.String("readpatientuser")
79
+	readPatientPass := beego.AppConfig.String("readpatientpass")
80
+	readPatientName := beego.AppConfig.String("readpatientname")
81
+
82
+	writePatientHost := beego.AppConfig.String("writepatienthost")
83
+	writePatientPort := beego.AppConfig.String("writepatientport")
84
+	writePatientUser := beego.AppConfig.String("writepatientuser")
85
+	writePatientPass := beego.AppConfig.String("writepatientpass")
86
+	writePatientName := beego.AppConfig.String("writepatientname")
87
+
73
 	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
88
 	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)
89
 	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
75
 
90
 
79
 	rmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readMiddleUser, readMiddlePass, readMiddleHost, readMiddlePort, readMiddleName)
94
 	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)
95
 	wmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeMiddleUser, writeMiddlePass, writeMiddleHost, writeMiddlePort, writeMiddleName)
81
 
96
 
97
+	rpdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readPatientUser, readPatientPass, readPatientHost, readPatientPort, readPatientName)
98
+	wpdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writePatientUser, writePatientPass, writePatientHost, writePatientPort, writePatientName)
99
+
82
 	readDb, err = gorm.Open("mysql", rdsn)
100
 	readDb, err = gorm.Open("mysql", rdsn)
83
 	if err != nil {
101
 	if err != nil {
84
 		//beego.Error(err)
102
 		//beego.Error(err)
127
 	writeMiddleDb.DB().SetMaxOpenConns(100)
145
 	writeMiddleDb.DB().SetMaxOpenConns(100)
128
 	writeMiddleDb.LogMode(true)
146
 	writeMiddleDb.LogMode(true)
129
 
147
 
148
+	readPatientDb, err = gorm.Open("mysql", rpdsn)
149
+	if err != nil {
150
+		beego.Error(err)
151
+	}
152
+	readPatientDb.DB().SetMaxIdleConns(10)
153
+	readPatientDb.DB().SetMaxOpenConns(100)
154
+	readPatientDb.LogMode(true)
155
+
156
+	writePatientDb, err = gorm.Open("mysql", wpdsn)
157
+	if err != nil {
158
+		beego.Error(err)
159
+	}
160
+	writePatientDb.DB().SetMaxIdleConns(10)
161
+	writePatientDb.DB().SetMaxOpenConns(100)
162
+	writePatientDb.LogMode(true)
130
 }
163
 }
131
 
164
 
132
 //func DisconnectDB() {
165
 //func DisconnectDB() {
154
 func MiddleWriteDB() *gorm.DB {
187
 func MiddleWriteDB() *gorm.DB {
155
 	return writeMiddleDb
188
 	return writeMiddleDb
156
 }
189
 }
190
+
191
+func PatientReadDB() *gorm.DB {
192
+	return readPatientDb
193
+}
194
+
195
+func PatientWriteDB() *gorm.DB {
196
+	return writePatientDb
197
+}

+ 517 - 4
service/patientmanage_service.go View File

1
 package service
1
 package service
2
 
2
 
3
-import "XT_New/models"
3
+import (
4
+	"XT_New/models"
5
+	"fmt"
6
+	"github.com/jinzhu/gorm"
7
+	"strconv"
8
+	"strings"
9
+	"time"
10
+)
4
 
11
 
5
-func GetBloodDialysisPatient(orgid int64) (paitents []*models.Patients, err error) {
12
+func GetIllnessListTwo() (ills []*models.Illness, err error) {
13
+	err = readUserDb.Where("status=1").Find(&ills).Error
14
+	return
15
+}
16
+
17
+func GetBloodDialysisPatient(orgid int64, page int64, limit int64) (patients []*models.Patients, total int64, err error) {
18
+	db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
19
+	if orgid > 0 {
20
+		db = db.Where("x.user_org_id = ?", orgid)
21
+	}
22
+	offset := (page - 1) * limit
23
+	err = db.Count(&total).Order("x.created_time desc").Offset(offset).Limit(limit).
24
+		Select("x.id,x.user_org_id,x.user_id,x.avatar,x.patient_type,x.dialysis_no,x.admission_number,x.source,x.lapseto,x.partition_id,x.bed_id,x.name,x.alias,x.gender,x.marital_status,x.id_card_no,x.birthday,x.reimbursement_way_id,x.health_care_type,x.health_care_no,x.health_care_due_date,x.height,x.blood_type,x.rh,x.health_care_due_alert_date,x.education_level,x.profession,x.phone,x.home_telephone,x.relative_phone,x.relative_relations,x.home_address,x.work_unit,x.unit_address,x.children,x.receiving_date,x.is_hospital_first_dialysis,x.first_dialysis_date,x.first_dialysis_hospital,x.predialysis_condition,x.pre_hospital_dialysis_frequency,x.pre_hospital_dialysis_times,x.hospital_first_dialysis_date,x.induction_period,x.initial_dialysis,x.total_dialysis,x.attending_doctor_id,x.head_nurse_id,x.evaluate,x.diagnose,x.remark,x.registrars_id,x.registrars,x.qr_code,x.binding_state,x.patient_complains,x.present_history,x.past_history,x.temperature,x.pulse,x.respiratory,x.sbp,x.dbp,x.status,x.created_time,x.updated_time,x.nation,x.native_place,x.age,x.blood_patients,x.slow_patients,x.member_patients,x.ecommer_patients,x.blood_id,x.slow_id,x.member_id").Find(&patients).Error
25
+	fmt.Println("err是什么", err)
26
+	return
27
+}
28
+
29
+func GetAllBloodDialysisPatient(orgid int64, page int64, limit int64) (patients []*models.XtPatientsNew, total int64, err error) {
30
+	db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
31
+	if orgid > 0 {
32
+		db = db.Where("x.user_org_id = ? and x.blood_patients = 1", orgid)
33
+	}
34
+	offset := (page - 1) * limit
35
+	err = db.Count(&total).Order("x.created_time desc").Offset(offset).Limit(limit).
36
+		Select("x.id,x.user_org_id,x.user_id,x.avatar,x.patient_type,x.dialysis_no,x.admission_number,x.source,x.lapseto,x.partition_id,x.bed_id,x.name,x.alias,x.gender,x.marital_status,x.id_card_no,x.birthday,x.reimbursement_way_id,x.health_care_type,x.health_care_no,x.health_care_due_date,x.height,x.blood_type,x.rh,x.health_care_due_alert_date,x.education_level,x.profession,x.phone,x.home_telephone,x.relative_phone,x.relative_relations,x.home_address,x.work_unit,x.unit_address,x.children,x.receiving_date,x.is_hospital_first_dialysis,x.first_dialysis_date,x.first_dialysis_hospital,x.predialysis_condition,x.pre_hospital_dialysis_frequency,x.pre_hospital_dialysis_times,x.hospital_first_dialysis_date,x.induction_period,x.initial_dialysis,x.total_dialysis,x.attending_doctor_id,x.head_nurse_id,x.evaluate,x.diagnose,x.remark,x.registrars_id,x.registrars,x.qr_code,x.binding_state,x.patient_complains,x.present_history,x.past_history,x.temperature,x.pulse,x.respiratory,x.sbp,x.dbp,x.status,x.created_time,x.updated_time,x.nation,x.native_place,x.age,x.blood_patients,x.slow_patients,x.member_patients,x.ecommer_patients,x.blood_id,x.slow_id,x.member_id").Find(&patients).Error
37
+	fmt.Println("err是什么", err)
38
+	return
39
+}
40
+
41
+func GetAllSlowPatient(orgid int64, page int64, limit int64) (patients []*models.XtPatientsNew, total int64, err error) {
42
+	db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
43
+	if orgid > 0 {
44
+		db = db.Where("x.user_org_id = ? and x.slow_patients = 1", orgid)
45
+	}
46
+	offset := (page - 1) * limit
47
+	err = db.Count(&total).Order("x.created_time desc").Offset(offset).Limit(limit).
48
+		Select("x.id,x.user_org_id,x.user_id,x.avatar,x.patient_type,x.dialysis_no,x.admission_number,x.source,x.lapseto,x.partition_id,x.bed_id,x.name,x.alias,x.gender,x.marital_status,x.id_card_no,x.birthday,x.reimbursement_way_id,x.health_care_type,x.health_care_no,x.health_care_due_date,x.height,x.blood_type,x.rh,x.health_care_due_alert_date,x.education_level,x.profession,x.phone,x.home_telephone,x.relative_phone,x.relative_relations,x.home_address,x.work_unit,x.unit_address,x.children,x.receiving_date,x.is_hospital_first_dialysis,x.first_dialysis_date,x.first_dialysis_hospital,x.predialysis_condition,x.pre_hospital_dialysis_frequency,x.pre_hospital_dialysis_times,x.hospital_first_dialysis_date,x.induction_period,x.initial_dialysis,x.total_dialysis,x.attending_doctor_id,x.head_nurse_id,x.evaluate,x.diagnose,x.remark,x.registrars_id,x.registrars,x.qr_code,x.binding_state,x.patient_complains,x.present_history,x.past_history,x.temperature,x.pulse,x.respiratory,x.sbp,x.dbp,x.status,x.created_time,x.updated_time,x.nation,x.native_place,x.age,x.blood_patients,x.slow_patients,x.member_patients,x.ecommer_patients,x.blood_id,x.slow_id,x.member_id").Find(&patients).Error
49
+	fmt.Println("err是什么", err)
50
+	return
51
+}
52
+
53
+func GetAllMemberPatient(orgid int64, page int64, limit int64) (patients []*models.XtPatientsNew, total int64, err error) {
54
+	db := XTReadDB().Table("xt_patients_new as x").Where("x.status = 1")
55
+	if orgid > 0 {
56
+		db = db.Where("x.user_org_id = ? and x.member_patients = 1", orgid)
57
+	}
58
+	offset := (page - 1) * limit
59
+	err = db.Count(&total).Order("x.created_time desc").Offset(offset).Limit(limit).
60
+		Select("x.id,x.user_org_id,x.user_id,x.avatar,x.patient_type,x.dialysis_no,x.admission_number,x.source,x.lapseto,x.partition_id,x.bed_id,x.name,x.alias,x.gender,x.marital_status,x.id_card_no,x.birthday,x.reimbursement_way_id,x.health_care_type,x.health_care_no,x.health_care_due_date,x.height,x.blood_type,x.rh,x.health_care_due_alert_date,x.education_level,x.profession,x.phone,x.home_telephone,x.relative_phone,x.relative_relations,x.home_address,x.work_unit,x.unit_address,x.children,x.receiving_date,x.is_hospital_first_dialysis,x.first_dialysis_date,x.first_dialysis_hospital,x.predialysis_condition,x.pre_hospital_dialysis_frequency,x.pre_hospital_dialysis_times,x.hospital_first_dialysis_date,x.induction_period,x.initial_dialysis,x.total_dialysis,x.attending_doctor_id,x.head_nurse_id,x.evaluate,x.diagnose,x.remark,x.registrars_id,x.registrars,x.qr_code,x.binding_state,x.patient_complains,x.present_history,x.past_history,x.temperature,x.pulse,x.respiratory,x.sbp,x.dbp,x.status,x.created_time,x.updated_time,x.nation,x.native_place,x.age,x.blood_patients,x.slow_patients,x.member_patients,x.ecommer_patients,x.blood_id,x.slow_id,x.member_id").Find(&patients).Error
61
+	fmt.Println("err是什么", err)
62
+	return
63
+}
64
+
65
+func GetAllPatient(orgid int64) (patients []*models.PatientsNew, err error) {
66
+	db := XTReadDB().Table("xt_patients_new as x")
67
+
68
+	err = db.Raw("select id,name from xt_patients_new where user_org_id = ? and status =1", orgid).Scan(&patients).Error
69
+	return
70
+}
71
+
72
+func ChechLastDialysisNoTwo(orgID int64) (dialysisNo int64) {
73
+	var patient models.Patients
74
+	err := readDb.Model(&models.Patients{}).Where("user_org_id=? and status = 1", orgID).Order("dialysis_no desc").First(&patient).Error
75
+	if err != nil {
76
+		return
77
+	}
78
+
79
+	if patient.ID == 0 {
80
+		return
81
+	}
82
+	dialysisNo, _ = strconv.ParseInt(patient.DialysisNo, 10, 64)
83
+	return
84
+}
85
+
86
+func GetBloodPatientInfo(orgid int64, phone string) (*models.Patients, error) {
87
+	patients := models.Patients{}
88
+	var err error
89
+	err = XTReadDB().Model(&patients).Where("user_org_id = ? and phone = ? and status = 1", orgid, phone).Find(&patients).Error
90
+	if err == gorm.ErrRecordNotFound {
91
+		return nil, err
92
+	}
93
+	if err != nil {
94
+		return nil, err
95
+	}
96
+	return &patients, nil
97
+}
98
+
99
+func GetSlowPatientInfo(orgid int64, phone string) (*models.CdmPatients, error) {
100
+	patients := models.CdmPatients{}
101
+	var err error
102
+	err = PatientReadDB().Model(&patients).Where("user_org_id = ? and phone = ? and status = 1", orgid, phone).Find(&patients).Error
103
+	if err == gorm.ErrRecordNotFound {
104
+		return nil, err
105
+	}
106
+	if err != nil {
107
+		return nil, err
108
+	}
109
+	return &patients, nil
110
+}
111
+
112
+func GetMemberPatientInfo(orgid int64, phone string) (*models.SgjUserCustomer, error) {
113
+	customer := models.SgjUserCustomer{}
114
+	err := UserReadDB().Model(&customer).Where("user_org_id = ? and mobile = ? and status =1", orgid, phone).Find(&customer).Error
115
+	if err == gorm.ErrRecordNotFound {
116
+		return nil, err
117
+	}
118
+	if err != nil {
119
+		return nil, err
120
+	}
121
+	return &customer, nil
122
+}
123
+
124
+func CreateOldPatient(patients *models.Patients) error {
125
+
126
+	err := XTWriteDB().Create(&patients).Error
127
+	return err
128
+}
129
+
130
+func GetLastOldPatient(orgid int64) (models.Patients, error) {
131
+	patients := models.Patients{}
132
+	err := XTReadDB().Model(&patients).Where("user_org_id = ? and status =1", orgid).Last(&patients).Error
133
+	return patients, err
134
+}
135
+
136
+func AddContagions(patienid int64, createdtime int64, updatedtime int64, contagions []int64) (err error) {
137
+	utx := writeDb.Begin()
138
+	if len(contagions) > 0 {
139
+		thisSQL := "INSERT INTO xt_patients_infectious_diseases (patient_id, disease_id, status, created_time, updated_time) VALUES "
140
+		insertParams := make([]string, 0)
141
+		insertData := make([]interface{}, 0)
142
+		for _, contagion := range contagions {
143
+			insertParams = append(insertParams, "(?, ?, ?, ?, ?)")
144
+			insertData = append(insertData, patienid)
145
+			insertData = append(insertData, contagion)
146
+			insertData = append(insertData, 1)
147
+			insertData = append(insertData, createdtime)
148
+			insertData = append(insertData, updatedtime)
149
+		}
150
+		thisSQL += strings.Join(insertParams, ",")
151
+		err = utx.Exec(thisSQL, insertData...).Error
152
+		fmt.Println("这个错误err", err)
153
+	}
154
+	utx.Commit()
155
+	return
156
+}
157
+
158
+func AddSlowContagions(patienid int64, createdtime int64, updatedtime int64, contagions []int64, orgid int64) (err error) {
159
+	utx := PatientWriteDB().Begin()
160
+	if len(contagions) > 0 {
161
+		thisSQL := "INSERT INTO xt_patients_infectious_diseases (patient_id, disease_id, status, created_time, updated_time,user_org_id) VALUES "
162
+		insertParams := make([]string, 0)
163
+		insertData := make([]interface{}, 0)
164
+		for _, contagion := range contagions {
165
+			insertParams = append(insertParams, "(?, ?, ?, ?, ?,?)")
166
+			insertData = append(insertData, patienid)
167
+			insertData = append(insertData, contagion)
168
+			insertData = append(insertData, 1)
169
+			insertData = append(insertData, createdtime)
170
+			insertData = append(insertData, updatedtime)
171
+			insertData = append(insertData, orgid)
172
+		}
173
+		thisSQL += strings.Join(insertParams, ", ")
174
+		err = utx.Exec(thisSQL, insertData...).Error
175
+		if err != nil {
176
+			utx.Rollback()
177
+			utx.Rollback()
178
+			return
179
+		}
180
+	}
181
+	utx.Commit()
182
+	return
183
+}
184
+
185
+func AddSlowDiseases(patienid int64, createdtime int64, updatedtime int64, diseases []int64, orgid int64) (err error) {
186
+	utx := PatientWriteDB().Begin()
187
+	if len(diseases) > 0 {
188
+		thisSQL := "INSERT INTO xt_patients_chronic_diseases (patient_id, disease_id, status, created_time, updated_time,user_org_id) VALUES "
189
+		insertParams := make([]string, 0)
190
+		insertData := make([]interface{}, 0)
191
+		for _, disease := range diseases {
192
+			insertParams = append(insertParams, "(?, ?, ?, ?, ?,?)")
193
+			insertData = append(insertData, patienid)
194
+			insertData = append(insertData, disease)
195
+			insertData = append(insertData, 1)
196
+			insertData = append(insertData, createdtime)
197
+			insertData = append(insertData, updatedtime)
198
+			insertData = append(insertData, orgid)
199
+		}
200
+		thisSQL += strings.Join(insertParams, ", ")
201
+		err = utx.Exec(thisSQL, insertData...).Error
202
+		if err != nil {
203
+			utx.Rollback()
204
+			return
205
+		}
206
+	}
207
+	utx.Commit()
208
+	return
209
+}
210
+
211
+func CreateNewPatient(patientsNew *models.XtPatientsNew) error {
212
+	err := XTWriteDB().Create(&patientsNew).Error
213
+	return err
214
+}
215
+
216
+func CreateCdmPatient(cdmpatient *models.CdmPatients) error {
217
+	err := PatientWriteDB().Create(&cdmpatient).Error
218
+	return err
219
+}
220
+
221
+func CreateMemberPatient(customer *models.SgjUserCustomer) error {
222
+
223
+	err := UserWriteDB().Create(&customer).Error
224
+	return err
225
+}
226
+
227
+func GetOldCdmPatient(orgid int64) (models.CdmPatients, error) {
228
+	patients := models.CdmPatients{}
229
+	err := XTReadDB().Model(&patients).Where("user_org_id = ? and status =1", orgid).Last(&patients).Error
230
+	return patients, err
231
+}
232
+
233
+func GetPatientDetailTwo(id int64) (models.XtPatientsNew, error) {
234
+	patients := models.XtPatientsNew{}
235
+	err := XTReadDB().Where("id=? and status = 1", id).Find(&patients).Error
236
+	return patients, err
237
+}
238
+
239
+func CreatePatientTwo(patient *models.Patients, contagions []int64, diseases []int64) (err error) {
240
+
241
+	user, _ := GetSgjUserByMobild(patient.Phone)
242
+	customer, _ := GetSgjCoustomerByMobile(patient.UserOrgId, patient.Phone)
243
+
244
+	utx := writeDb.Begin()
245
+	btx := writeUserDb.Begin()
246
+
247
+	if user.ID == 0 {
248
+
249
+		user.Mobile = patient.Phone
250
+		user.Avatar = patient.Avatar
251
+		user.AvatarThumb = patient.Avatar
252
+		user.Birthday = patient.Birthday
253
+		user.Username = patient.Name
254
+		user.Gender = patient.Gender
255
+		user.Sources = 11
256
+		user.Introduce = patient.Remark
257
+		user.Status = 1
258
+		user.UpdatedTime = patient.UpdatedTime
259
+		user.CreatedTime = patient.CreatedTime
260
+		err = btx.Create(&user).Error
261
+		if err != nil {
262
+			utx.Rollback()
263
+			btx.Rollback()
264
+			return
265
+		}
266
+	}
267
+	patient.UserId = user.ID
268
+
269
+	if customer == nil {
270
+		err = btx.Create(&models.SgjCustomer{
271
+			UserOrgId:   patient.UserOrgId,
272
+			UserId:      user.ID,
273
+			Mobile:      patient.Phone,
274
+			Name:        patient.Name,
275
+			Gender:      patient.Gender,
276
+			Birthday:    patient.Birthday,
277
+			Sources:     11,
278
+			Status:      1,
279
+			CreatedTime: patient.CreatedTime,
280
+			UpdatedTime: patient.UpdatedTime,
281
+			Avatar:      patient.Avatar,
282
+			Remark:      patient.Remark,
283
+		}).Error
284
+		if err != nil {
285
+			utx.Rollback()
286
+			btx.Rollback()
287
+			return
288
+		}
289
+	}
290
+
291
+	err = utx.Create(patient).Error
292
+	if err != nil {
293
+		utx.Rollback()
294
+		btx.Rollback()
295
+		return
296
+	}
297
+
298
+	var lapseto models.PatientLapseto
299
+	lapseto.PatientId = patient.ID
300
+	lapseto.LapsetoType = patient.Lapseto
301
+	lapseto.CreatedTime = patient.CreatedTime
302
+	lapseto.UpdatedTime = patient.CreatedTime
303
+	lapseto.Status = 1
304
+	lapseto.LapsetoTime = patient.CreatedTime
305
+
306
+	err = utx.Create(&lapseto).Error
307
+	if err != nil {
308
+		utx.Rollback()
309
+		btx.Rollback()
310
+		return
311
+	}
312
+
313
+	if len(contagions) > 0 {
314
+		thisSQL := "INSERT INTO xt_patients_infectious_diseases (patient_id, disease_id, status, created_time, updated_time) VALUES "
315
+		insertParams := make([]string, 0)
316
+		insertData := make([]interface{}, 0)
317
+		for _, contagion := range contagions {
318
+			insertParams = append(insertParams, "(?, ?, ?, ?, ?)")
319
+			insertData = append(insertData, patient.ID)
320
+			insertData = append(insertData, contagion)
321
+			insertData = append(insertData, 1)
322
+			insertData = append(insertData, patient.CreatedTime)
323
+			insertData = append(insertData, patient.UpdatedTime)
324
+		}
325
+		thisSQL += strings.Join(insertParams, ", ")
326
+		err = utx.Exec(thisSQL, insertData...).Error
327
+		if err != nil {
328
+			utx.Rollback()
329
+			btx.Rollback()
330
+			return
331
+		}
332
+	}
333
+	if len(diseases) > 0 {
334
+		thisSQL := "INSERT INTO xt_patients_chronic_diseases (patient_id, disease_id, status, created_time, updated_time) VALUES "
335
+		insertParams := make([]string, 0)
336
+		insertData := make([]interface{}, 0)
337
+		for _, disease := range diseases {
338
+			insertParams = append(insertParams, "(?, ?, ?, ?, ?)")
339
+			insertData = append(insertData, patient.ID)
340
+			insertData = append(insertData, disease)
341
+			insertData = append(insertData, 1)
342
+			insertData = append(insertData, patient.CreatedTime)
343
+			insertData = append(insertData, patient.UpdatedTime)
344
+		}
345
+		thisSQL += strings.Join(insertParams, ", ")
346
+		err = utx.Exec(thisSQL, insertData...).Error
347
+		if err != nil {
348
+			utx.Rollback()
349
+			btx.Rollback()
350
+			return
351
+		}
352
+	}
353
+	utx.Commit()
354
+	btx.Commit()
355
+
356
+	return
357
+}
358
+
359
+func GetPatientData(phone string, orgid int64) (*models.XtPatientsNew, error) {
360
+	var patientnew models.XtPatientsNew
361
+	var err error
362
+	err = XTReadDB().Model(&patientnew).Where("user_org_id = ? and phone = ? and status =? and blood_patients = ?", orgid, phone, 1, 1).Find(&patientnew).Error
363
+	if err == gorm.ErrRecordNotFound {
364
+		return nil, err
365
+	}
366
+	if err != nil {
367
+		return nil, err
368
+	}
369
+	return &patientnew, nil
370
+}
371
+
372
+func GetSlowPatientData(phone string, orgid int64) (*models.CdmPatients, error) {
373
+	var patientnew models.CdmPatients
374
+	err = PatientReadDB().Model(&patientnew).Where("user_org_id = ? and phone = ? and status = ?", orgid, phone, 1).Find(&patientnew).Error
375
+	if err == gorm.ErrRecordNotFound {
376
+		return nil, err
377
+	}
378
+	if err != nil {
379
+		return nil, err
380
+	}
381
+	return &patientnew, nil
382
+}
383
+
384
+func GetMemberNewPatient(phone string, orgid int64) (*models.XtPatientsNew, error) {
385
+	var patientnew models.XtPatientsNew
386
+	err = XTReadDB().Model(&patientnew).Where("user_org_id = ? and phone = ? and status = ? and member_patients = ?", orgid, phone, 1, 1).Find(&patientnew).Error
387
+	if err == gorm.ErrRecordNotFound {
388
+		return nil, err
389
+	}
390
+	if err != nil {
391
+		return nil, err
392
+	}
393
+	return &patientnew, nil
394
+}
395
+
396
+func GetLastNewSlowPatient(phone string, orgid int64) (*models.XtPatientsNew, error) {
397
+	var patientnew models.XtPatientsNew
398
+	err = XTReadDB().Model(&patientnew).Where("user_org_id = ? and phone = ? and status = ? and slow_patients = ?", orgid, phone, 1, 1).Find(&patientnew).Error
399
+	if err == gorm.ErrRecordNotFound {
400
+		return nil, err
401
+	}
402
+	if err != nil {
403
+		return nil, err
404
+	}
405
+	return &patientnew, nil
406
+}
407
+
408
+func GetNewDoctorAdvice(patientid int64, doctype int64, startime int64, endtime int64, limit int64, page int64, orgId int64) (doctoradvice []*models.DoctorAdvices, total int64, err error) {
409
+	db := XTReadDB().Table("xt_doctor_advice as x").Where("x.status = 1")
410
+	if orgId > 0 {
411
+		db = db.Where("x.user_org_id = ?", orgId)
412
+	}
413
+
414
+	if patientid > 0 {
415
+		db = db.Where("x.patient_id = ?", patientid)
416
+	}
417
+	if startime != 0 {
418
+		db = db.Where("x.record_date>= ?", startime)
419
+	}
420
+	if endtime != 0 {
421
+		db = db.Where("x.record_date<=?", endtime)
422
+	}
423
+
424
+	if doctype > 0 {
425
+		db = db.Where("x.advice_type = ?", doctype)
426
+	}
427
+	offset := (page - 1) * limit
428
+	err = db.Count(&total).Order("x.record_date desc").Offset(offset).Limit(limit).Group("x.id").Select("x.id, x.user_org_id, x.patient_id, x.advice_type, x.advice_date, x.record_date, x.start_time, x.advice_name,x.advice_desc, x.reminder_date, x.drug_spec, x.drug_spec_unit, x.single_dose, x.single_dose_unit, x.prescribing_number, x.prescribing_number_unit, x.delivery_way, x.execution_frequency, x.advice_doctor, x.created_time,x.updated_time, x.advice_affirm, x.remark, x.stop_time, x.stop_reason, x.stop_doctor, x.stop_state, x.parent_id, x.execution_time, x.execution_staff, x.execution_state, x.checker, x.check_state, x.check_time, x.groupno,x.remind_type,x.frequency_type,x.day_count,x.week_day,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.advice_doctor").Scan(&doctoradvice).Error
429
+	return
430
+}
431
+
432
+func GetDryWeight(patientid int64, startime int64, endtime int64, limit int64, page int64, orgId int64) (dryWeight []*models.XtPatientDryweight, total int64, err error) {
433
+	db := XTReadDB().Table("xt_patient_dryweight as x").Where("x.status = 1")
434
+	if orgId > 0 {
435
+		db = db.Where("x.user_org_id = ?", orgId)
436
+	}
437
+	if patientid > 0 {
438
+		db = db.Where("x.patient_id = ?", patientid)
439
+	}
440
+	if startime > 0 {
441
+		db = db.Where("x.ctime >= ?", startime)
442
+	}
443
+	if endtime > 0 {
444
+		db = db.Where("x.ctime <=?", endtime)
445
+	}
446
+	offset := (page - 1) * limit
447
+	err = db.Count(&total).Order("x.ctime desc").Offset(offset).Limit(limit).Group("x.id").
448
+		Select("x.id,x.dry_weight,x.creator,x.remakes,x.patient_id,x.ctime,x.adjusted_value,x.user_id,x.user_org_id,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.creator").Scan(&dryWeight).Error
449
+	return dryWeight, total, err
450
+}
451
+
452
+func ToSearch(orgId int64, name string) (patient []*models.XtPatientsNew, err error) {
453
+	likeKey := "%" + name + "%"
454
+	err = XTReadDB().Where("name like ? and user_org_id = ?", likeKey, orgId).Find(&patient).Error
455
+	return patient, err
456
+}
457
+
458
+func GetCourseManagement(patientid int64, startime int64, endtime int64, limit int64, page int64, orgid int64) (patientCourse []*models.PatientCourseOfDiseases, total int64, err error) {
459
+	db := XTReadDB().Table("xt_patient_course_of_disease as x").Where("x.status = 1")
460
+	if patientid > 0 {
461
+		db = db.Where("x.patient_id = ?", patientid)
462
+	}
463
+	if orgid > 0 {
464
+		db = db.Where("x.org_id = ?", orgid)
465
+	}
466
+	if startime > 0 {
467
+		db = db.Where("x.record_time >=?", startime)
468
+	}
469
+	if endtime > 0 {
470
+		db = db.Where("x.record_time <= ?", endtime)
471
+	}
472
+	offset := (page - 1) * limit
473
+	err = db.Count(&total).Order("x.ctime desc").Offset(offset).Limit(limit).Group("x.id").
474
+		Select("x.id,x.org_id,x.patient_id,x.recorder,x.record_time,x.content,x.title,r.user_name").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.recorder").Scan(&patientCourse).Error
475
+	return patientCourse, total, err
476
+}
477
+
478
+func DeleteCouseManagement(patientid int64) error {
479
+
480
+	err := XTWriteDB().Model(models.PatientCourseOfDisease{}).Where("id = ?", patientid).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
481
+	return err
482
+}
483
+
484
+func GetCouseManagentDetail(id int64) (models.PatientCourseOfDiseasess, error) {
485
+	disease := models.PatientCourseOfDiseasess{}
486
+	db := XTReadDB().Table("xt_patient_course_of_disease as x")
487
+	err := db.Select("x.id,x.org_id,x.patient_id,x.recorder,x.record_time,x.content,x.title,s.name,r.user_name").Joins("left join xt_patients as s on s.id = x.patient_id ").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.recorder").Where("x.id = ?", id).Scan(&disease).Error
488
+	return disease, err
489
+}
490
+
491
+func DeleteDryWeight(id int64) error {
492
+	err := XTWriteDB().Model(models.SgjPatientDryweight{}).Where("id=?", id).Update(map[string]interface{}{"status": 0, "mtime": time.Now().Unix()}).Error
493
+	return err
494
+}
495
+
496
+func GetDryWeightDetail(id int64) (models.SgjPatientDryweights, error) {
497
+	dryweight := models.SgjPatientDryweights{}
498
+	db := XTReadDB().Table("xt_patient_dryweight as x")
499
+	err := db.Select("x.id,x.dry_weight,x.creator,x.remakes,x.patient_id,x.adjusted_value,x.user_org_id,x.user_id,x.ctime,s.name,r.user_name").Joins("left join xt_patients as s on s.id = x.patient_id").Joins("left join sgj_users.sgj_user_admin_role as r on r.admin_user_id = x.user_id").Where("x.id = ?", id).Scan(&dryweight).Error
500
+	return dryweight, err
501
+}
502
+
503
+func GetlongDialysisrecord(patientid int64, startime int64, endtime int64, limit int64, page int64, orgid int64) (prescription []*models.XtDialysisSolution, total int64, err error) {
504
+	db := XTReadDB().Table("xt_dialysis_solution as x").Where("x.status = 1")
505
+	if patientid > 0 {
506
+		db = db.Where("x.patient_id = ?", patientid)
507
+	}
508
+	if orgid > 0 {
509
+		db = db.Where("x.user_org_id = ?", orgid)
510
+	}
511
+	if startime > 0 {
512
+		db = db.Where("x.created_time >=?", startime)
513
+	}
514
+	if endtime > 0 {
515
+		db = db.Where("x.created_time <= ?", endtime)
516
+	}
517
+	offset := (page - 1) * limit
518
+	err = db.Count(&total).Order("x.created_time desc").Offset(offset).Limit(limit).Group("x.id").
519
+		Select("x.id,x.name,x.sub_name,x.user_org_id,x.patient_id,x.parent_id,x.type,x.period,x.times,x.anticoagulant,x.anticoagulant_shouji,x.anticoagulant_weichi,x.anticoagulant_zongliang,x.anticoagulant_gaimingcheng,x.anticoagulant_gaijiliang,x.mode_name,x.mode_id,x.dialysis_duration,x.replacement_way,x.hemodialysis_machine,x.blood_filter,x.perfusion_apparatus,x.blood_flow_volume,x.dewater,x.displace_liqui,x.glucose,x.dry_weight,x.dialysate_flow,x.kalium,x.sodium,x.calcium,x.bicarbonate,x.doctor,x.first_dialysis,x.remark,x.initiate_mode,x.affirm_state,x.use_state,x.status,x.registrars_id,x.created_time,x.updated_time,x.solution_type,x.dialysate_temperature,x.conductivity,x.dialysis_duration_hour,x.dialysis_duration_minute,x.target_ultrafiltration,x.dialysate_formulation,x.dialyzer,x.replacement_total,x.dialyzer_perfusion_apparatus,x.body_fluid,x.special_medicine,x.special_medicine_other,x.displace_liqui_part,x.displace_liqui_value,x.blood_access,x.ultrafiltration,x.body_fluid_other,x.target_ktv").Find(&prescription).Error
6
 
520
 
7
-	err = XTReadDB().Model(&paitents).Where("user_org_id = ? and status =1", orgid).Find(&paitents).Error
8
-	return paitents, err
521
+	return
9
 }
522
 }