瀏覽代碼

更新代码

XMLWAN 4 年之前
父節點
當前提交
64e49d1b84

+ 14 - 0
conf/app.conf 查看文件

@@ -152,6 +152,20 @@ writemiddleuser = root
152 152
 writemiddlepass = 1Q2W3e4r!@#$
153 153
 writemiddlename = ky_xt_middle
154 154
 
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
+
155 169
 #redishost = 120.77.235.13
156 170
 #redishost = 112.74.16.180
157 171
 redishost = localhost

+ 440 - 58
controllers/new_mobile_api_controllers/new_dialysis_api_controller.go 查看文件

@@ -46,7 +46,6 @@ func (this *NewDialysisApiController) GetPatient() {
46 46
 }
47 47
 
48 48
 func (this *NewDialysisApiController) GetAllPatient() {
49
-	fmt.Print("--------------------触发了没有")
50 49
 	adminInfo := this.GetMobileAdminUserInfo()
51 50
 	orgid := adminInfo.Org.Id
52 51
 	page, _ := this.GetInt64("page")
@@ -54,7 +53,6 @@ func (this *NewDialysisApiController) GetAllPatient() {
54 53
 	limit, _ := this.GetInt64("limit")
55 54
 	fmt.Print("limit", limit)
56 55
 	patient, err := service.GetAllPatient(orgid)
57
-	fmt.Print("err--------------------", err)
58 56
 	if err != nil {
59 57
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
60 58
 		return
@@ -88,6 +86,66 @@ func (this *NewDialysisApiController) GetGeneratedialysisno() {
88 86
 	return
89 87
 }
90 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
+
91 149
 func (this *NewDialysisApiController) SavePatient() {
92 150
 	adminInfo := this.GetMobileAdminUserInfo()
93 151
 	orgid := adminInfo.Org.Id
@@ -123,6 +181,12 @@ func (this *NewDialysisApiController) SavePatient() {
123 181
 	fmt.Print("留置状态", lapseto)
124 182
 	contagions := dataBody["resultTwo"].([]interface{})
125 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)
126 190
 	adminssionNumber := dataBody["admissionNumber"].(string)
127 191
 	fmt.Print("住院号", adminssionNumber)
128 192
 	fistdate := dataBody["fistDate"].(string)
@@ -139,8 +203,19 @@ func (this *NewDialysisApiController) SavePatient() {
139 203
 	fmt.Print("设备ID", requipmentId)
140 204
 	slowContagions := dataBody["resultThree"].([]interface{})
141 205
 	fmt.Print("慢性传染病", slowContagions)
142
-	slowDisease := int64(dataBody["slowDisease"].(float64))
143
-	fmt.Print("slowDisease", slowDisease)
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
+
144 219
 	bloodPatient := int64(dataBody["bloodPatient"].(float64))
145 220
 	fmt.Print("血透病人", bloodPatient)
146 221
 	slowpatient := int64(dataBody["slowPatient"].(float64))
@@ -158,65 +233,210 @@ func (this *NewDialysisApiController) SavePatient() {
158 233
 	treatmentmethod := int64(dataBody["treatmentMethod"].(float64))
159 234
 	fmt.Print("治疗方式", treatmentmethod)
160 235
 
161
-	_, errcode := service.GetPatientData(phone, orgid)
162
-	if errcode == gorm.ErrRecordNotFound {
163
-		patients := models.Patients{
164
-			Name:              name,
165
-			Gender:            sex,
166
-			Birthday:          birth,
167
-			Age:               ages,
168
-			Phone:             phone,
169
-			Lapseto:           lapseto,
170
-			AdmissionNumber:   adminssionNumber,
171
-			FirstDialysisDate: fisttime,
172
-			Diagnose:          diagonse,
173
-			Source:            patientsoure,
174
-			DialysisNo:        dialysis,
175
-			UserOrgId:         orgid,
176
-			Status:            1,
177
-			CreatedTime:       time.Now().Unix(),
178
-			Avatar:            avatar,
179
-		}
180
-		err := service.CreateOldPatient(&patients)
181
-		fmt.Print("报错-------------", err)
182
-		patient, err := service.GetLastOldPatient(7957)
183
-		fmt.Print("病人ID", patient.ID)
184
-		patientsNew := models.XtPatientsNew{
185
-			Name:              name,
186
-			Gender:            sex,
187
-			Birthday:          birth,
188
-			Age:               ages,
189
-			Phone:             phone,
190
-			Lapseto:           lapseto,
191
-			AdmissionNumber:   adminssionNumber,
192
-			FirstDialysisDate: fisttime,
193
-			Diagnose:          diagonse,
194
-			Source:            patientsoure,
195
-			DialysisNo:        dialysis,
196
-			UserOrgId:         orgid,
197
-			Status:            1,
198
-			CreatedTime:       time.Now().Unix(),
199
-			Avatar:            avatar,
200
-			MemberPatients:    memberpatient,
201
-			BloodPatients:     bloodPatient,
202
-			SlowPatients:      slowpatient,
203
-			BloodId:           patient.ID,
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
+
204 300
 		}
205
-		err = service.CreateNewPatient(&patientsNew)
206
-		fmt.Print("报错", err)
207
-		if err != nil {
208
-			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
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("病人已存在")
209 370
 			return
371
+		} else {
372
+
210 373
 		}
211
-		this.ServeSuccessJSON(map[string]interface{}{
212
-			"patient": patientsNew,
213
-		})
214
-	} else if errcode == nil {
215
-		fmt.Print("病人已存在")
216
-		return
217
-	} else {
218 374
 
219 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
+
220 440
 }
221 441
 
222 442
 func (this *NewDialysisApiController) GetPatientDetail() {
@@ -312,3 +532,165 @@ func (this *NewDialysisApiController) ToSearch() {
312 532
 		"search": search,
313 533
 	})
314 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
+}
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
+	})
696
+}

+ 12 - 0
controllers/new_mobile_api_controllers/new_mobile_api_router_register.go 查看文件

@@ -8,10 +8,22 @@ func NewMobileAPIControllersRegisterRouters() {
8 8
 	beego.Router("m/api/patient/getillnesslist", &NewDialysisApiController{}, "Get:GetIllnesslist")
9 9
 	beego.Router("/m/api/patients/generatedialysisnotwo", &NewDialysisApiController{}, "Get:GetGeneratedialysisno")
10 10
 	beego.Router("/m/api/patient/getbloodDialysisPatient", &NewDialysisApiController{}, "Get:GetPatient")
11
+	beego.Router("/m/api/patient/getbloodpatientinfo", &NewDialysisApiController{}, "Get:GetBloodPatientInfo")
12
+	beego.Router("/m/api/patient/getslowpatientinfo", &NewDialysisApiController{}, "Get:GetSlowPatientInfo")
13
+	beego.Router("/m/api/patient/getmemberpatientinfo", &NewDialysisApiController{}, "Get:GetMemberpatientInfo")
11 14
 	beego.Router("/m/api/patient/savepatient", &NewDialysisApiController{}, "Post:SavePatient")
12 15
 	beego.Router("/m/api/patient/getpatientdetail", &NewDialysisApiController{}, "Get:GetPatientDetail")
13 16
 	beego.Router("/m/api/patient/getdoctoradvices", &NewDialysisApiController{}, "Get:GetDoctorAdvices")
14 17
 	beego.Router("/m/api/paitent/getdryweight", &NewDialysisApiController{}, "Get:GetDryWeight")
15 18
 	beego.Router("m/api/patient/getbloodDialysisPatientwo", &NewDialysisApiController{}, "Get:GetAllPatient")
16 19
 	beego.Router("m/api/patient/tosearch", &NewDialysisApiController{}, "Get:ToSearch")
20
+	beego.Router("/m/api/patient/getcoursemanagement", &NewDialysisApiController{}, "Get:GetCourseManagement")
21
+	beego.Router("/m/api/patient/delelecousemanage", &NewDialysisApiController{}, "Delete:DeleteCourseManagement")
22
+	beego.Router("/m/api/patient/getcousemanagementdetail", &NewDialysisApiController{}, "Get:GetCouseManagentDetail")
23
+	beego.Router("/m/api/patient/getallblooddialysispatient", &NewDialysisApiController{}, "Get:GetAllBloodDialysisPatient")
24
+	beego.Router("/m/api/patient/getallslowpatient", &NewDialysisApiController{}, "Get:GetAllSlowPatent")
25
+	beego.Router("/m/api/patient/getallmemberpatient", &NewDialysisApiController{}, "Get:GetAllMemberPatient")
26
+	beego.Router("/m/api/patient/deletedryweight", &NewDialysisApiController{}, "Delete:DeleteDryWeight")
27
+	beego.Router("/m/api/patient/getdryweightdetail", &NewDialysisApiController{}, "Get:GetDryWeightDetail")
28
+	beego.Router("/m/api/patient/getlongdialysisrecord", &NewDialysisApiController{}, "Get:GetlongDialysisrecord")
17 29
 }

+ 126 - 0
models/patient_models.go 查看文件

@@ -489,3 +489,129 @@ type PatientsNew struct {
489 489
 	ID   int64  `gorm:"column:id" json:"id" form:"id"`
490 490
 	Name string `gorm:"column:name" json:"name" form:"name"`
491 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 查看文件

@@ -88,6 +88,22 @@ func (SgjPatientDryweight) TableName() string {
88 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 107
 type XtPatientDryweight struct {
92 108
 	ID            int64   `gorm:"column:id" json:"id" form:"id"`
93 109
 	DryWeight     float64 `gorm:"column:dry_weight" json:"dry_weight" form:"dry_weight"`
@@ -102,3 +118,222 @@ type XtPatientDryweight struct {
102 118
 	UserId        int64   `gorm:"column:user_id" json:"user_id" form:"user_id"`
103 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
+}

+ 41 - 0
service/db.go 查看文件

@@ -31,6 +31,9 @@ var writeUserDb *gorm.DB
31 31
 
32 32
 var readMiddleDb *gorm.DB
33 33
 var writeMiddleDb *gorm.DB
34
+
35
+var readPatientDb *gorm.DB
36
+var writePatientDb *gorm.DB
34 37
 var err error
35 38
 
36 39
 func ConnectDB() {
@@ -70,6 +73,18 @@ func ConnectDB() {
70 73
 	writeMiddlePass := beego.AppConfig.String("writemiddlepass")
71 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 88
 	rdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readUser, readPass, readHost, readPort, readName)
74 89
 	wdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", writeUser, writePass, writeHost, writePort, writeName)
75 90
 
@@ -79,6 +94,9 @@ func ConnectDB() {
79 94
 	rmdsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=true", readMiddleUser, readMiddlePass, readMiddleHost, readMiddlePort, readMiddleName)
80 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 100
 	readDb, err = gorm.Open("mysql", rdsn)
83 101
 	if err != nil {
84 102
 		//beego.Error(err)
@@ -127,6 +145,21 @@ func ConnectDB() {
127 145
 	writeMiddleDb.DB().SetMaxOpenConns(100)
128 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 165
 //func DisconnectDB() {
@@ -154,3 +187,11 @@ func MiddleReadDB() *gorm.DB {
154 187
 func MiddleWriteDB() *gorm.DB {
155 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
+}

+ 272 - 3
service/patientmanage_service.go 查看文件

@@ -6,6 +6,7 @@ import (
6 6
 	"github.com/jinzhu/gorm"
7 7
 	"strconv"
8 8
 	"strings"
9
+	"time"
9 10
 )
10 11
 
11 12
 func GetIllnessListTwo() (ills []*models.Illness, err error) {
@@ -25,6 +26,42 @@ func GetBloodDialysisPatient(orgid int64, page int64, limit int64) (patients []*
25 26
 	return
26 27
 }
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
+
28 65
 func GetAllPatient(orgid int64) (patients []*models.PatientsNew, err error) {
29 66
 	db := XTReadDB().Table("xt_patients_new as x")
30 67
 
@@ -46,6 +83,44 @@ func ChechLastDialysisNoTwo(orgID int64) (dialysisNo int64) {
46 83
 	return
47 84
 }
48 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
+
49 124
 func CreateOldPatient(patients *models.Patients) error {
50 125
 
51 126
 	err := XTWriteDB().Create(&patients).Error
@@ -58,11 +133,103 @@ func GetLastOldPatient(orgid int64) (models.Patients, error) {
58 133
 	return patients, err
59 134
 }
60 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
+
61 211
 func CreateNewPatient(patientsNew *models.XtPatientsNew) error {
62 212
 	err := XTWriteDB().Create(&patientsNew).Error
63 213
 	return err
64 214
 }
65 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
+
66 233
 func GetPatientDetailTwo(id int64) (models.XtPatientsNew, error) {
67 234
 	patients := models.XtPatientsNew{}
68 235
 	err := XTReadDB().Where("id=? and status = 1", id).Find(&patients).Error
@@ -189,10 +356,46 @@ func CreatePatientTwo(patient *models.Patients, contagions []int64, diseases []i
189 356
 	return
190 357
 }
191 358
 
192
-func GetPatientData(phone string, orgid int64) (*models.Patients, error) {
193
-	var patientnew models.Patients
359
+func GetPatientData(phone string, orgid int64) (*models.XtPatientsNew, error) {
360
+	var patientnew models.XtPatientsNew
194 361
 	var err error
195
-	err = XTReadDB().Model(&patientnew).Where("user_org_id = ? and phone = ? and status =?", orgid, phone, 1).Find(&patientnew).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
196 399
 	if err == gorm.ErrRecordNotFound {
197 400
 		return nil, err
198 401
 	}
@@ -251,3 +454,69 @@ func ToSearch(orgId int64, name string) (patient []*models.XtPatientsNew, err er
251 454
 	err = XTReadDB().Where("name like ? and user_org_id = ?", likeKey, orgId).Find(&patient).Error
252 455
 	return patient, err
253 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
520
+
521
+	return
522
+}