Просмотр исходного кода

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

XMLWAN 4 лет назад
Родитель
Сommit
7614799871

+ 1 - 1
controllers/his_api_controller.go Просмотреть файл

@@ -142,7 +142,7 @@ func (c *HisApiController) GetHisPatientList() {
142 142
 	recordDateTime := theTime.Unix()
143 143
 	adminInfo := c.GetAdminUserInfo()
144 144
 	patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
145
-	patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
145
+	patients_two, _ := service.GetScheduleHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime, 0)
146 146
 	patients = append(patients, patients_two...)
147 147
 	patients = RemoveRepeatedPatient(patients)
148 148
 

+ 2 - 1
controllers/his_project_api_controller.go Просмотреть файл

@@ -1283,11 +1283,12 @@ func (this *HisProjectApiController) GetAllHisPatient() {
1283 1283
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
1284 1284
 	recordDateTime := theTime.Unix()
1285 1285
 	adminUserInfo := this.GetAdminUserInfo()
1286
-	patients, err := service.GetScheduleHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime)
1286
+	patients, err := service.GetScheduleHisPatientList(adminUserInfo.CurrentOrgId, "", recordDateTime, 0)
1287 1287
 	if err != nil {
1288 1288
 		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
1289 1289
 		return
1290 1290
 	}
1291
+
1291 1292
 	this.ServeSuccessJSON(map[string]interface{}{
1292 1293
 		"list": patients,
1293 1294
 	})

+ 8 - 2
controllers/mobile_api_controllers/login_api_controller.go Просмотреть файл

@@ -150,9 +150,13 @@ func (this *LoginAPIController) LoginByPwd() {
150 150
 		this.Ctx.SetCookie("token_cookie", token, expiration, "/")
151 151
 
152 152
 		var configList interface{}
153
+		var dict_config_list interface{}
154
+
153 155
 		var FiledList []*models.FiledConfig
154 156
 
155 157
 		if org.Id > 0 {
158
+			dict_config_list, _ = service.GetDictConfigList(org.Id)
159
+
156 160
 			configList, _ = service.GetConfigList(org.Id)
157 161
 			FiledList, _ = service.FindFiledByOrgId(org.Id)
158 162
 		}
@@ -208,8 +212,10 @@ func (this *LoginAPIController) LoginByPwd() {
208 212
 				"org_id":      templateInfo.OrgId,
209 213
 				"template_id": templateInfo.TemplateId,
210 214
 			},
211
-			"config_list": configList,
212
-			"filed_list":  FiledList,
215
+			"config_list":      configList,
216
+			"dict_config_list": dict_config_list,
217
+
218
+			"filed_list": FiledList,
213 219
 		})
214 220
 	}
215 221
 }

+ 8 - 2
controllers/new_mobile_api_controllers/forget_password_controller.go Просмотреть файл

@@ -160,10 +160,14 @@ func (this *ForgetPwdController) ModifyPassword() {
160 160
 			this.Ctx.SetCookie("token_cookie", token, expiration, "/")
161 161
 
162 162
 			var configList interface{}
163
+			var dict_configList interface{}
164
+
163 165
 			var FiledList []*models.FiledConfig
164 166
 
165 167
 			if org.Id > 0 {
166 168
 				configList, _ = service.GetConfigList(org.Id)
169
+				dict_configList, _ = service.GetDictConfigList(org.Id)
170
+
167 171
 				FiledList, _ = service.FindFiledByOrgId(org.Id)
168 172
 			}
169 173
 			if len(FiledList) == 0 {
@@ -219,8 +223,10 @@ func (this *ForgetPwdController) ModifyPassword() {
219 223
 					"org_id":      templateInfo.OrgId,
220 224
 					"template_id": templateInfo.TemplateId,
221 225
 				},
222
-				"config_list": configList,
223
-				"filed_list":  FiledList,
226
+				"config_list":      configList,
227
+				"dict_config_list": dict_configList,
228
+
229
+				"filed_list": FiledList,
224 230
 			})
225 231
 		}
226 232
 

+ 14 - 5
controllers/new_mobile_api_controllers/home_api_controller.go Просмотреть файл

@@ -222,9 +222,11 @@ func (this *HomeController) ChangeOrg() {
222 222
 		this.Ctx.SetCookie("token_cookie", token, expiration, "/")
223 223
 
224 224
 		var configList interface{}
225
+		var dict_config_list interface{}
225 226
 		var FiledList []*models.FiledConfig
226 227
 
227 228
 		if org.Id > 0 {
229
+			dict_config_list, _ = service.GetDictConfigList(org.Id)
228 230
 			configList, _ = service.GetConfigList(org.Id)
229 231
 			FiledList, _ = service.FindFiledByOrgId(org.Id)
230 232
 		}
@@ -281,8 +283,9 @@ func (this *HomeController) ChangeOrg() {
281 283
 				"org_id":      templateInfo.OrgId,
282 284
 				"template_id": templateInfo.TemplateId,
283 285
 			},
284
-			"config_list": configList,
285
-			"filed_list":  FiledList,
286
+			"config_list":      configList,
287
+			"dict_config_list": dict_config_list,
288
+			"filed_list":       FiledList,
286 289
 		})
287 290
 	}
288 291
 
@@ -537,9 +540,13 @@ func (this *HomeController) CreateOrg() {
537 540
 				this.Ctx.SetCookie("token_cookie", token, expiration, "/")
538 541
 
539 542
 				var configList interface{}
543
+				var dict_config_list interface{}
544
+
540 545
 				var FiledList []*models.FiledConfig
541 546
 
542 547
 				if org.Id > 0 {
548
+					dict_config_list, _ = service.GetDictConfigList(org.Id)
549
+
543 550
 					configList, _ = service.GetConfigList(org.Id)
544 551
 					FiledList, _ = service.FindFiledByOrgId(org.Id)
545 552
 				}
@@ -588,9 +595,11 @@ func (this *HomeController) CreateOrg() {
588 595
 						"org_id":      templateInfo.OrgId,
589 596
 						"template_id": templateInfo.TemplateId,
590 597
 					},
591
-					"config_list": configList,
592
-					"filed_list":  FiledList,
593
-					"status":      1,
598
+					"config_list":      configList,
599
+					"dict_config_list": dict_config_list,
600
+
601
+					"filed_list": FiledList,
602
+					"status":     1,
594 603
 				})
595 604
 			}
596 605
 

+ 37 - 6
controllers/new_mobile_api_controllers/mobile_his_api_controller.go Просмотреть файл

@@ -277,7 +277,10 @@ func (c *MobileHisApiController) CreateHisPrescription() {
277 277
 					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
278 278
 					return
279 279
 				}
280
+				fmt.Println(preTime)
281
+				fmt.Println(theTime2)
280 282
 				pTime := theTime2.Unix()
283
+				fmt.Println(pTime)
281 284
 
282 285
 				ctime := time.Now().Unix()
283 286
 				prescription := &models.HisPrescription{
@@ -321,7 +324,7 @@ func (c *MobileHisApiController) CreateHisPrescription() {
321 324
 							s.Status = 1
322 325
 							s.UserOrgId = adminInfo.Org.Id
323 326
 							s.RecordDate = recordDateTime
324
-							s.StartTime = prescription.PreTime
327
+							s.StartTime = pTime
325 328
 							s.Groupno = groupNo
326 329
 							s.CreatedTime = ctime
327 330
 							s.UpdatedTime = mtime
@@ -458,7 +461,7 @@ func (c *MobileHisApiController) setAdviceWithJSON(advice *models.HisDoctorAdvic
458 461
 					advice.CheckTime = hisAdvice.CheckTime
459 462
 					advice.Checker = hisAdvice.Checker
460 463
 					advice.CheckState = hisAdvice.CheckState
461
-					advice.StartTime = hisAdvice.StartTime
464
+					//advice.StartTime = hisAdvice.StartTime
462 465
 
463 466
 				}
464 467
 			}
@@ -613,6 +616,9 @@ func (c *MobileHisApiController) setProjectWithJSON(project *models.HisPrescript
613 616
 }
614 617
 func (c *MobileHisApiController) GetHisPatientList() {
615 618
 	record_date := c.GetString("record_date")
619
+	sch_type, _ := c.GetInt64("sch_type")
620
+	visit_type, _ := c.GetInt64("visit_type")
621
+
616 622
 	timeLayout := "2006-01-02"
617 623
 	loc, _ := time.LoadLocation("Local")
618 624
 
@@ -623,13 +629,38 @@ func (c *MobileHisApiController) GetHisPatientList() {
623 629
 	}
624 630
 	recordDateTime := theTime.Unix()
625 631
 	adminInfo := c.GetMobileAdminUserInfo()
626
-	patients, _ := service.GetScheduleHisPatientList(adminInfo.Org.Id, "", recordDateTime)
632
+	patients, _ := service.GetScheduleHisPatientList(adminInfo.Org.Id, "", recordDateTime, sch_type)
627 633
 	patients_two, _ := service.GetHisPatientList(adminInfo.Org.Id, "", recordDateTime)
628 634
 	patients = append(patients, patients_two...)
629 635
 	patients = RemoveRepeatedPatient(patients)
630
-	c.ServeSuccessJSON(map[string]interface{}{
631
-		"list": patients,
632
-	})
636
+	if visit_type == 0 {
637
+		c.ServeSuccessJSON(map[string]interface{}{
638
+			"list": patients,
639
+		})
640
+
641
+	} else if visit_type == 1 { //未就诊
642
+		var patientsOne []*service.Patients
643
+		for _, item := range patients {
644
+			if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
645
+				patientsOne = append(patientsOne, item)
646
+			}
647
+		}
648
+		c.ServeSuccessJSON(map[string]interface{}{
649
+			"list": patientsOne,
650
+		})
651
+
652
+	} else if visit_type == 2 { //已就诊
653
+		var patientsTwo []*service.Patients
654
+		for _, item := range patients {
655
+
656
+			if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
657
+				patientsTwo = append(patientsTwo, item)
658
+			}
659
+		}
660
+		c.ServeSuccessJSON(map[string]interface{}{
661
+			"list": patientsTwo,
662
+		})
663
+	}
633 664
 
634 665
 }
635 666
 

+ 10 - 4
controllers/new_mobile_api_controllers/mobile_regist_controller.go Просмотреть файл

@@ -365,9 +365,12 @@ func (this *MobileRegistController) CreateOrg() {
365 365
 
366 366
 			var configList interface{}
367 367
 			var FiledList []*models.FiledConfig
368
+			var dict_configList interface{}
368 369
 
369 370
 			if org.Id > 0 {
370 371
 				configList, _ = service.GetConfigList(org.Id)
372
+				dict_configList, _ = service.GetDictConfigList(org.Id)
373
+
371 374
 				FiledList, _ = service.FindFiledByOrgId(org.Id)
372 375
 			}
373 376
 			if len(FiledList) == 0 {
@@ -415,8 +418,10 @@ func (this *MobileRegistController) CreateOrg() {
415 418
 					"org_id":      templateInfo.OrgId,
416 419
 					"template_id": templateInfo.TemplateId,
417 420
 				},
418
-				"config_list": configList,
419
-				"filed_list":  FiledList,
421
+				"config_list":      configList,
422
+				"dict_config_list": dict_configList,
423
+
424
+				"filed_list": FiledList,
420 425
 			})
421 426
 		}
422 427
 
@@ -849,8 +854,9 @@ func (this *MobileRegistController) Login() {
849 854
 				"org_id":      0,
850 855
 				"template_id": 0,
851 856
 			},
852
-			"config_list": nil,
853
-			"filed_list":  nil,
857
+			"config_list":      nil,
858
+			"dict_config_list": nil,
859
+			"filed_list":       nil,
854 860
 		})
855 861
 		this.ServeJSON()
856 862
 	}

+ 23 - 7
controllers/new_mobile_api_controllers/new_login_api_controller.go Просмотреть файл

@@ -52,6 +52,8 @@ func (this *NewLoginApiController) GetLogin() {
52 52
 			var app *models.OrgApp
53 53
 			var templateInfo models.GobalTemplate
54 54
 			var configList interface{}
55
+			var dict_configList interface{}
56
+
55 57
 			var FiledList []*models.FiledConfig
56 58
 
57 59
 			var getAppRoleErr error
@@ -86,6 +88,8 @@ func (this *NewLoginApiController) GetLogin() {
86 88
 				}
87 89
 				templateInfo, _ = service.GetOrgInfoTemplate(org.Id)
88 90
 				configList, _ = service.GetConfigList(org.Id)
91
+				dict_configList, _ = service.GetDictConfigList(org.Id)
92
+
89 93
 				FiledList, _ = service.FindFiledByOrgId(org.Id)
90 94
 			}
91 95
 
@@ -113,9 +117,11 @@ func (this *NewLoginApiController) GetLogin() {
113 117
 					"org_id":      templateInfo.OrgId,
114 118
 					"template_id": templateInfo.TemplateId,
115 119
 				},
116
-				"config_list": configList,
117
-				"filed_list":  FiledList,
118
-				"isLogin":     true,
120
+				"config_list":      configList,
121
+				"dict_config_list": dict_configList,
122
+
123
+				"filed_list": FiledList,
124
+				"isLogin":    true,
119 125
 			})
120 126
 
121 127
 			this.ServeJSON()
@@ -275,9 +281,13 @@ func (this *NewLoginApiController) LoginByCs() {
275 281
 			this.Ctx.SetCookie("token_cookie", token, expiration, "/")
276 282
 
277 283
 			var configList interface{}
284
+			var dict_configList interface{}
285
+
278 286
 			var FiledList []*models.FiledConfig
279 287
 
280 288
 			if org.Id > 0 {
289
+				dict_configList, _ = service.GetDictConfigList(org.Id)
290
+
281 291
 				configList, _ = service.GetConfigList(org.Id)
282 292
 				FiledList, _ = service.FindFiledByOrgId(org.Id)
283 293
 			}
@@ -358,8 +368,10 @@ func (this *NewLoginApiController) LoginByCs() {
358 368
 					"org_id":      templateInfo.OrgId,
359 369
 					"template_id": templateInfo.TemplateId,
360 370
 				},
361
-				"config_list": configList,
362
-				"filed_list":  FiledList,
371
+				"config_list":      configList,
372
+				"dict_config_list": dict_configList,
373
+
374
+				"filed_list": FiledList,
363 375
 			})
364 376
 		}
365 377
 	} else {
@@ -482,6 +494,8 @@ func (this *NewLoginApiController) LoginByCs() {
482 494
 					this.Ctx.SetCookie("token_cookie", token, expiration, "/")
483 495
 
484 496
 					configList, _ := service.GetConfigList(org.Id)
497
+					dict_configList, _ := service.GetDictConfigList(org.Id)
498
+
485 499
 					var FiledList []*models.FiledConfig
486 500
 					FiledList, _ = service.FindFiledByOrgId(org.Id)
487 501
 					if len(FiledList) == 0 {
@@ -530,8 +544,10 @@ func (this *NewLoginApiController) LoginByCs() {
530 544
 							"org_id":      templateInfo.OrgId,
531 545
 							"template_id": templateInfo.TemplateId,
532 546
 						},
533
-						"config_list": configList,
534
-						"filed_list":  FiledList,
547
+						"config_list":      configList,
548
+						"dict_config_list": dict_configList,
549
+
550
+						"filed_list": FiledList,
535 551
 					})
536 552
 				}
537 553
 

+ 46 - 0
models/data_models.go Просмотреть файл

@@ -23,6 +23,29 @@ func (Dataconfig) TableName() string {
23 23
 	return "xt_data_config"
24 24
 }
25 25
 
26
+type DictDataconfig struct {
27
+	ID             int64  `gorm:"column:id" json:"id" form:"id"`
28
+	ParentId       int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
29
+	Module         string `gorm:"column:module" json:"module" form:"module"`
30
+	OrgId          int64  `gorm:"column:org_id" json:"org_id" form:"org_id"`
31
+	Name           string `gorm:"column:name" json:"name" form:"name"`
32
+	FieldName      string `gorm:"column:field_name" json:"field_name" form:"field_name"`
33
+	Value          int    `gorm:"column:value" json:"value" form:"value"`
34
+	CreatedTime    string `gorm:"column:create_time" json:"create_time" form:"create_time"`
35
+	UpdatedTime    string `gorm:"column:update_time" json:"update_time" form:"update_time"`
36
+	CreateUserId   int64  `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
37
+	Status         int64  `gorm:"column:status" json:"status" form:"status"`
38
+	Remark         string `gorm:"column:remark" json:"remark" form:"remark"`
39
+	DeleteIdSystem int64  `gorm:"column:delete_id_system" json:"delete_id_system" form:"delete_id_system"`
40
+	Title          string `gorm:"column:title" json:"title" form:"title"`
41
+	Content        string `gorm:"column:content" json:"content" form:"content"`
42
+	Order          int64  `gorm:"column:orders" json:"orders" form:"orders"`
43
+}
44
+
45
+func (DictDataconfig) TableName() string {
46
+	return "xt_drug_data_config"
47
+}
48
+
26 49
 type DictionaryDataconfig struct {
27 50
 	ID             int64  `gorm:"column:id" json:"id" form:"id"`
28 51
 	ParentId       int64  `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
@@ -92,6 +115,29 @@ func (ConfigViewModel) TableName() string {
92 115
 	return "xt_data_config"
93 116
 }
94 117
 
118
+type DictConfigViewModel struct {
119
+	ID           int64             `gorm:"column:id" json:"id" form:"id"`
120
+	ParentId     int64             `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
121
+	Module       string            `gorm:"column:module" json:"module" form:"module"`
122
+	OrgId        int64             `gorm:"column:org_id" json:"org_id" form:"org_id"`
123
+	Name         string            `gorm:"column:name" json:"name" form:"name"`
124
+	FieldName    string            `gorm:"column:field_name" json:"field_name" form:"field_name"`
125
+	Value        int               `gorm:"column:value" json:"value" form:"value"`
126
+	CreatedTime  string            `gorm:"column:create_time" json:"create_time" form:"create_time"`
127
+	UpdatedTime  string            `gorm:"column:update_time" json:"update_time" form:"update_time"`
128
+	CreateUserId int64             `gorm:"column:create_user_id" json:"create_user_id" form:"create_user_id"`
129
+	Status       int64             `gorm:"column:status" json:"status" form:"status"`
130
+	Remark       string            `gorm:"column:remark" json:"remark" form:"remark"`
131
+	Title        string            `gorm:"column:title" json:"title" form:"title"`
132
+	Content      string            `gorm:"column:content" json:"content" form:"content"`
133
+	Order        int64             `gorm:"column:orders" json:"orders" form:"orders"`
134
+	Childs       []*DictDataconfig `json:"childs" `
135
+}
136
+
137
+func (DictConfigViewModel) TableName() string {
138
+	return "xt_drug_data_config"
139
+}
140
+
95 141
 type FiledConfig struct {
96 142
 	ID          int64  `gorm:"column:id" json:"id"`
97 143
 	OrgId       int64  `gorm:"column:org_id" json:"org_id"`

+ 106 - 0
service/data.go Просмотреть файл

@@ -115,6 +115,112 @@ func GetConfigList(orgID int64) (dataconfig interface{}, err error) {
115 115
 	return resultConfig, err
116 116
 }
117 117
 
118
+func GetDictConfigList(orgID int64) (dataconfig interface{}, err error) {
119
+	var configList []*models.DictionaryDataconfig
120
+
121
+	err = readDb.Model(&models.DictionaryDataconfig{}).Where("(org_id in (0,?) and status = 1) or (status = 0 and delete_id_system > 0 and org_id = ?)", orgID, orgID).Order("orders asc, id asc").Find(&configList).Error
122
+	if err != nil {
123
+		return nil, err
124
+	}
125
+
126
+	// configResult := make([]*ConfigViewModel,0)
127
+	childConfig := make(map[int64][]*models.DictionaryDataconfig)
128
+	resultConfig := make(map[string][]*models.DictionaryConfigViewModel)
129
+	deleteSystemChilds := make([]*models.DictionaryDataconfig, 0)
130
+	editSystemChilds := make([]*models.DictionaryDataconfig, 0)
131
+	for _, config := range configList {
132
+		if config.Status == 1 && config.DeleteIdSystem > 0 {
133
+			editSystemChilds = append(editSystemChilds, config)
134
+		}
135
+
136
+		if config.Status == 0 && config.DeleteIdSystem > 0 {
137
+			deleteSystemChilds = append(deleteSystemChilds, config)
138
+		}
139
+	}
140
+	continueFlag := false
141
+	for _, config := range configList {
142
+		continueFlag = false
143
+		if config.ParentId == 0 {
144
+			newConfig := &models.DictionaryConfigViewModel{
145
+				ID:           config.ID,
146
+				ParentId:     config.ParentId,
147
+				Module:       config.Module,
148
+				OrgId:        config.OrgId,
149
+				Name:         config.Name,
150
+				FieldName:    config.FieldName,
151
+				Value:        config.Value,
152
+				CreateUserId: config.CreateUserId,
153
+				Status:       config.Status,
154
+				Remark:       config.Remark,
155
+				Title:        config.Title,
156
+				Content:      config.Content,
157
+			}
158
+			// configResult = append(configResult,newConfig)
159
+			result := resultConfig[config.Module]
160
+			if result == nil {
161
+				result = make([]*models.DictionaryConfigViewModel, 0)
162
+			}
163
+			for _, vm := range editSystemChilds {
164
+				if vm.DeleteIdSystem == config.ID {
165
+					continueFlag = true
166
+					break
167
+				}
168
+			}
169
+
170
+			for _, _vm := range deleteSystemChilds {
171
+				if _vm.DeleteIdSystem == config.ID {
172
+					continueFlag = true
173
+					break
174
+				}
175
+			}
176
+			if config.OrgId != 0 && config.Status == 0 && config.DeleteIdSystem > 0 {
177
+				continue
178
+			}
179
+			if continueFlag {
180
+				continue
181
+			}
182
+			result = append(result, newConfig)
183
+			resultConfig[config.Module] = result
184
+		} else {
185
+			childs := childConfig[config.ParentId]
186
+			if childs == nil {
187
+				childs = make([]*models.DictionaryDataconfig, 0)
188
+			}
189
+			continueFlag := false
190
+			for _, vm := range editSystemChilds {
191
+				if vm.DeleteIdSystem == config.ID {
192
+					continueFlag = true
193
+					break
194
+				}
195
+			}
196
+
197
+			for _, _vm := range deleteSystemChilds {
198
+				if _vm.DeleteIdSystem == config.ID {
199
+					continueFlag = true
200
+					break
201
+				}
202
+			}
203
+			if config.OrgId != 0 && config.Status == 0 && config.DeleteIdSystem > 0 {
204
+				continue
205
+			}
206
+			if continueFlag {
207
+				continue
208
+			}
209
+
210
+			childs = append(childs, config)
211
+			childConfig[config.ParentId] = childs
212
+		}
213
+	}
214
+
215
+	for _, vm := range resultConfig {
216
+		for _, _vm := range vm {
217
+			_vm.Childs = childConfig[_vm.ID]
218
+		}
219
+		// vm.Childs = childConfig[vm.ID]
220
+	}
221
+	return resultConfig, err
222
+}
223
+
118 224
 func FindConfigByFieldname(module string, field_name string, org_id int64) (dataconfig models.Dataconfig, err error) {
119 225
 	err = readDb.Model(&models.Dataconfig{}).Where("module=? and field_name=? and org_id in (0,?) and status = 1", module, field_name, org_id).First(&dataconfig).Error
120 226
 	return

+ 5 - 0
service/doctor_advice_service.go Просмотреть файл

@@ -470,3 +470,8 @@ func GetDoctorAdviceByType(change_type int64, record_time int64, org_id int64, p
470 470
 	}
471 471
 	return
472 472
 }
473
+
474
+func GetDict(orgid int64) (drugways []*models.DrugwayDic, total int64, err error) {
475
+	err = readDb.Model(&models.DrugwayDic{}).Where("(org_id =? or org_id = 0) and status=1", orgid).Count(&total).Order("id desc").Find(&drugways).Error
476
+	return
477
+}

+ 28 - 22
service/his_service.go Просмотреть файл

@@ -140,9 +140,15 @@ func (HisPrescription) TableName() string {
140 140
 	return "his_prescription"
141 141
 }
142 142
 
143
-func GetScheduleHisPatientList(org_id int64, keywords string, record_date int64) (patients []*Patients, err error) {
144
-	db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id).
145
-		Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ?", record_date, org_id)
143
+func GetScheduleHisPatientList(org_id int64, keywords string, record_date int64, sch_type int64) (patients []*Patients, err error) {
144
+	db := readDb.Model(&Patients{}).Select("xt_patients.id,xt_patients.user_org_id,xt_patients.name,xt_patients.status,xt_patients.id_card_no,sch.schedule_type as sch_type").Where("xt_patients.user_org_id = ? AND xt_patients.status = 1", org_id)
145
+
146
+	if sch_type != 0 {
147
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? AND sch.schedule_type = ?", record_date, org_id, sch_type)
148
+	} else {
149
+		db = db.Joins("join xt_schedule as sch ON sch.patient_id = xt_patients.id AND sch.schedule_date = ? AND sch.status = 1 AND sch.user_org_id = ? ", record_date, org_id)
150
+	}
151
+
146 152
 	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
147 153
 	db = db.Preload("HisPrescription", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date)
148 154
 	err = db.Preload("VMHisPrescriptionInfo", "user_org_id = ? AND status = 1 AND record_date = ?", org_id, record_date).Group("xt_patients.id").Order("sch_type").Find(&patients).Error
@@ -948,6 +954,8 @@ type VMOtherHisPrescriptionInfo struct {
948 954
 	PatientId         int64                `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
949 955
 	Status            int64                `gorm:"column:status" json:"status" form:"status"`
950 956
 	CheckGroup        []int64              `gorm:"-" json:"check_group" form:"check_group"`
957
+	DoctorId          int64                `gorm:"column:doctor_id" json:"doctor_id" form:"doctor_id"`
958
+	Departments       int64                `gorm:"column:departments" json:"departments" form:"departments"`
951 959
 	VMHisPrescription []*VMHisPrescription `gorm:"ForeignKey:RecordDate,PatientId;AssociationForeignKey:RecordDate,PatientId" json:"prescriptions"`
952 960
 }
953 961
 
@@ -1088,20 +1096,20 @@ func GetHisPrescriptionByPatientID(patientID int64, orgID int64) (info models.Hi
1088 1096
 }
1089 1097
 
1090 1098
 type VMHisProjectTeam struct {
1091
-	ID           int64   `gorm:"column:id" json:"id" form:"id"`
1092
-	ProjectTeam  string  `gorm:"column:project_team" json:"project_team" form:"project_team"`
1093
-	Price        float64 `gorm:"column:price" json:"price" form:"price"`
1094
-	Pinyin       string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
1095
-	Wubi         string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
1096
-	TubeColor    int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
1097
-	TeamType     int64   `gorm:"column:team_type" json:"team_type" form:"team_type"`
1098
-	Remark       string  `gorm:"column:remark" json:"remark" form:"remark"`
1099
-	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1100
-	Status       int64   `gorm:"column:status" json:"status" form:"status"`
1101
-	CreatedTime  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
1102
-	UpdatedTime  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1103
-	ProjectId    string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
1104
-	VMHisProject []*VMHisProject
1099
+	ID           int64           `gorm:"column:id" json:"id" form:"id"`
1100
+	ProjectTeam  string          `gorm:"column:project_team" json:"project_team" form:"project_team"`
1101
+	Price        float64         `gorm:"column:price" json:"price" form:"price"`
1102
+	Pinyin       string          `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
1103
+	Wubi         string          `gorm:"column:wubi" json:"wubi" form:"wubi"`
1104
+	TubeColor    int64           `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
1105
+	TeamType     int64           `gorm:"column:team_type" json:"team_type" form:"team_type"`
1106
+	Remark       string          `gorm:"column:remark" json:"remark" form:"remark"`
1107
+	UserOrgId    int64           `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
1108
+	Status       int64           `gorm:"column:status" json:"status" form:"status"`
1109
+	CreatedTime  int64           `gorm:"column:created_time" json:"created_time" form:"created_time"`
1110
+	UpdatedTime  int64           `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
1111
+	ProjectId    string          `gorm:"column:project_id" json:"project_id" form:"project_id"`
1112
+	VMHisProject []*VMHisProject `gorm:"-" json:"project" form:"project"`
1105 1113
 }
1106 1114
 
1107 1115
 func (VMHisProjectTeam) TableName() string {
@@ -1145,12 +1153,10 @@ func (VMHisPrescriptionTwo) TableName() string {
1145 1153
 func GetAllProjectTeamList(orgid int64) (project []*VMHisProjectTeam, err error) {
1146 1154
 	err = XTReadDB().Model(&VMHisProjectTeam{}).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
1147 1155
 	for _, item := range project {
1148
-		var project_item VMHisProject
1156
+		var project_item []*VMHisProject
1149 1157
 		ids := strings.Split(item.ProjectId, ",")
1150
-		for _, id := range ids {
1151
-			XTReadDB().Model(&VMSchedule{}).Where("user_org_id = ? and status = 1 AND id = ?", orgid, id).First(&project_item)
1152
-			item.VMHisProject = append(item.VMHisProject, &project_item)
1153
-		}
1158
+		XTReadDB().Model(&VMHisProject{}).Where("status = 1 AND id IN (?)", ids).Find(&project_item)
1159
+		item.VMHisProject = append(item.VMHisProject, project_item...)
1154 1160
 	}
1155 1161
 	return
1156 1162
 }

+ 28 - 15
service/mobile_dialysis_service.go Просмотреть файл

@@ -37,7 +37,7 @@ func MobileGetDialysisScheduals(orgID int64, scheduleDate int64, scheduleType in
37 37
 		Preload("DialysisOrder.DeviceNumber", "status = 1 AND org_id = ?", orgID).
38 38
 		Preload("TreatmentSummary", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
39 39
 		Preload("AssessmentAfterDislysis", "status = 1  AND user_org_id = ? AND assessment_date = ?", orgID, scheduleDate).
40
-
40
+		Preload("HisAdvices", "status = 1 AND user_org_id = ? AND advice_date = ? ", orgID, scheduleDate).
41 41
 		// Preload("DialysisOrder.MonitoringRecords", func(rdb *gorm.DB) *gorm.DB {
42 42
 		// 	return rdb.Where("status = 1 AND user_org_id = ?", orgID).Order("operate_time DESC")
43 43
 		// }).
@@ -102,26 +102,25 @@ func (AssessmentAfterDislysis) TableName() string {
102 102
 }
103 103
 
104 104
 type MDialysisScheduleVM struct {
105
-	ID           int64 `gorm:"column:id" json:"id"`
106
-	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id"`
107
-	PartitionId  int64 `gorm:"column:partition_id" json:"partition_id"`
108
-	BedId        int64 `gorm:"column:bed_id" json:"bed_id"`
109
-	PatientId    int64 `gorm:"column:patient_id" json:"patient_id"`
110
-	ScheduleDate int64 `gorm:"column:schedule_date" json:"schedule_date"`
111
-	ScheduleType int64 `gorm:"column:schedule_type" json:"schedule_type"`
112
-	ScheduleWeek int64 `gorm:"column:schedule_week" json:"schedule_week"`
113
-	ModeId       int64 `gorm:"column:mode_id" json:"mode_id"`
114
-	Status       int64 `gorm:"column:status" json:"status"`
115
-
105
+	ID                       int64                             `gorm:"column:id" json:"id"`
106
+	UserOrgId                int64                             `gorm:"column:user_org_id" json:"user_org_id"`
107
+	PartitionId              int64                             `gorm:"column:partition_id" json:"partition_id"`
108
+	BedId                    int64                             `gorm:"column:bed_id" json:"bed_id"`
109
+	PatientId                int64                             `gorm:"column:patient_id" json:"patient_id"`
110
+	ScheduleDate             int64                             `gorm:"column:schedule_date" json:"schedule_date"`
111
+	ScheduleType             int64                             `gorm:"column:schedule_type" json:"schedule_type"`
112
+	ScheduleWeek             int64                             `gorm:"column:schedule_week" json:"schedule_week"`
113
+	ModeId                   int64                             `gorm:"column:mode_id" json:"mode_id"`
114
+	Status                   int64                             `gorm:"column:status" json:"status"`
116 115
 	SchedualPatient          *MSchedualPatientVMList           `gorm:"ForeignKey:PatientId" json:"patient"`
117 116
 	DeviceNumber             *MDeviceNumberVM                  `gorm:"ForeignKey:BedId" json:"device_number"`
118 117
 	DialysisOrder            *MDialysisOrderVMList             `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"dialysis_order"`
119 118
 	Prescription             *models.DialysisPrescriptionList  `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"prescription"`
120 119
 	AssessmentBeforeDislysis *models.PredialysisEvaluationList `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_before_dislysis"`
121 120
 	AssessmentAfterDislysis  *AssessmentAfterDislysis          `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"assessment_after_dislysis"`
122
-
123
-	Advices          []*VMDoctorAdvice   `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
124
-	TreatmentSummary *VMTreatmentSummary `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
121
+	HisAdvices               []*VMHisDoctorAdviceInfo          `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"his_doctor_advice"`
122
+	Advices                  []*VMDoctorAdvice                 `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"doctor_advice"`
123
+	TreatmentSummary         *VMTreatmentSummary               `gorm:"ForeignKey:PatientId;AssociationForeignKey:PatientId" json:"treatment_summary"`
125 124
 }
126 125
 
127 126
 func (MDialysisScheduleVM) TableName() string {
@@ -298,6 +297,20 @@ func (VMDoctorAdvice) TableName() string {
298 297
 	return "xt_doctor_advice"
299 298
 }
300 299
 
300
+type VMHisDoctorAdviceInfo struct {
301
+	ID             int64 `gorm:"column:id" json:"id" form:"id"`
302
+	UserOrgId      int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
303
+	PatientId      int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
304
+	HisPatientId   int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
305
+	ExecutionTime  int64 `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
306
+	ExecutionStaff int64 `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
307
+	ExecutionState int64 `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
308
+}
309
+
310
+func (VMHisDoctorAdviceInfo) TableName() string {
311
+	return "his_doctor_advice_info"
312
+}
313
+
301 314
 // 获取透析记录
302 315
 func MobileGetDialysisRecord(orgID int64, patientID int64, recordDate int64) (*models.DialysisOrder, error) {
303 316
 	var record models.DialysisOrder