Преглед на файлове

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

XMLWAN преди 4 години
родител
ревизия
2e0cf73c53
променени са 4 файла, в които са добавени 119 реда и са изтрити 253 реда
  1. 108 250
      controllers/his_api_controller.go
  2. 0 2
      models/his_models.go
  3. 10 0
      service/his_service.go
  4. 1 1
      service/patient_service.go

+ 108 - 250
controllers/his_api_controller.go Целия файл

@@ -9,7 +9,6 @@ import (
9 9
 	"github.com/astaxie/beego"
10 10
 	"reflect"
11 11
 	"strconv"
12
-	"strings"
13 12
 	"time"
14 13
 )
15 14
 
@@ -24,10 +23,6 @@ func HisManagerApiRegistRouters() {
24 23
 	beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
25 24
 
26 25
 	beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
27
-	beego.Router("/api/hisdoctoradvice/create", &HisApiController{}, "post:CreateHisDoctorAdvice")
28
-	//beego.Router("/api/hisproject/create", &HisApiController{}, "post:CreateHisProject")
29
-	//beego.Router("/api/hisorder/create", &HisApiController{}, "post:CreateHisOrder")
30
-	//beego.Router("/api/hisadditional/create", &HisApiController{}, "post:CreateHisAdditionalCharge")
31 26
 
32 27
 	beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
33 28
 	beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
@@ -116,81 +111,29 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
116 111
 	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
117 112
 	//获取所有基础药
118 113
 	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
119
-	//获取所有项目
120
-	projects, _ := service.GetAllProjectList(adminInfo.CurrentOrgId)
121
-	//获取所有项目组套
114
+
115
+	//drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
116
+	//drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
117
+	drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
118
+	efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
119
+
120
+	doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
122 121
 
123 122
 	c.ServeSuccessJSON(map[string]interface{}{
124 123
 		"drugs":            drugs,
125 124
 		"advices_template": advices,
126
-		"projects":         projects,
125
+		"drugways":         drugways,
126
+		"efs":              efs,
127
+		"doctors":          doctors,
127 128
 	})
128 129
 }
129 130
 func (c *HisApiController) CreateHisPrescription() {
130 131
 	record_date := c.GetString("record_date")
131 132
 	patient_id, _ := c.GetInt64("patient_id")
132
-	his_patient_id, _ := c.GetInt64("his_patient_id")
133
-	types, _ := c.GetInt64("type")
134
-	doctor := c.GetAdminUserInfo().AdminUser.Id
135
-
136
-	timeLayout := "2006-01-02"
137
-	loc, _ := time.LoadLocation("Local")
138
-
139
-	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
140
-	if err != nil {
141
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
142
-		return
143
-	}
144
-	recordDateTime := theTime.Unix()
145
-
146
-	prescription := &models.HisPrescription{
147
-		UserOrgId:    c.GetAdminUserInfo().CurrentOrgId,
148
-		RecordDate:   recordDateTime,
149
-		PatientId:    patient_id,
150
-		HisPatientId: his_patient_id,
151
-		Status:       1,
152
-		Ctime:        time.Now().Unix(),
153
-		Mtime:        time.Now().Unix(),
154
-		Type:         types,
155
-		Doctor:       doctor,
156
-		Creator:      doctor,
157
-		Modifier:     doctor,
158
-	}
159
-
160
-	err = service.SaveHisPrescription(prescription)
161
-	if err == nil {
162
-		c.ServeSuccessJSON(map[string]interface{}{
163
-			"msg": "保存成功",
164
-		})
165
-		return
166
-
167
-	} else {
168
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
169
-		return
170
-	}
171
-}
172
-func (c *HisApiController) CreateHisDoctorAdvice() {
173
-	patient_id, _ := c.GetInt64("patient_id")
174
-	his_patient_id, _ := c.GetInt64("his_patient_id")
175
-	prescription_id, _ := c.GetInt64("prescription_id")
176
-
177
-	//patient, _ := c.GetInt64("id", 0)
178
-	//if patient <= 0 {
179
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
180
-	//	return
181
-	//}
182
-	adminUserInfo := c.GetAdminUserInfo()
183
-
184
-	//patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
185
-	//if patientInfo.ID == 0 {
186
-	//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
187
-	//	return
188
-	//}
189
-
190
-	group_no, _ := c.GetInt64("group_no")
191
-	if group_no <= 0 {
192
-		group_no = 0
193
-	}
133
+	//diagnose := c.GetString("diagnose")
134
+	//sick_history := c.GetString("sick_history")
135
+	doctor, _ := c.GetInt64("doctor")
136
+	//departm/**/ent, _ := c.GetInt64("department")
194 137
 
195 138
 	dataBody := make(map[string]interface{}, 0)
196 139
 	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
@@ -202,155 +145,91 @@ func (c *HisApiController) CreateHisDoctorAdvice() {
202 145
 
203 146
 	timeLayout := "2006-01-02"
204 147
 	loc, _ := time.LoadLocation("Local")
205
-
206
-	if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
207
-		utils.ErrorLog("advice_type")
208
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
209
-		return
210
-	}
211
-	adviceType := int64(dataBody["advice_type"].(float64))
212
-	if adviceType != 1 && adviceType != 2 {
213
-		utils.ErrorLog("advice_type != 1&&2")
214
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
215
-		return
216
-	}
217
-
218
-	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
219
-		utils.ErrorLog("start_time")
220
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
221
-		return
222
-	}
223
-
224
-	startTime2, _ := dataBody["start_time"].(string)
225
-	time_arr := strings.Split(startTime2, " ")
226
-	if len(time_arr) > 0 {
227
-		startTime2 = time_arr[0]
228
-	}
229
-	if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
230
-		utils.ErrorLog("advice_date")
231
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
232
-		return
233
-	}
234
-	adviceDate := startTime2
235
-	if len(adviceDate) == 0 {
236
-		utils.ErrorLog("len(adviceDate) == 0")
237
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
238
-		return
239
-	}
240
-	theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
148
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
241 149
 	if err != nil {
242
-		utils.ErrorLog(err.Error())
243 150
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
244 151
 		return
245 152
 	}
246
-	AdviceDate := theTime.Unix()
247
-	RecordDate := theTime.Unix()
153
+	adminInfo := c.GetAdminUserInfo()
154
+	recordDateTime := theTime.Unix()
248 155
 
249
-	if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
250
-		utils.ErrorLog("start_time")
251
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
252
-		return
253
-	}
254
-	startTime, _ := dataBody["start_time"].(string)
255
-	if len(startTime) == 0 {
256
-		utils.ErrorLog("len(start_time) == 0")
257
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
258
-		return
259
-	}
260
-	theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
261
-	if err != nil {
262
-		utils.ErrorLog(err.Error())
263
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
264
-		return
265
-	}
266
-	StartTime := theTime.Unix()
156
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
157
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
267 158
 
268
-	Remark := ""
269
-	if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
270
-		remark, _ := dataBody["remark"].(string)
271
-		Remark = remark
272
-	}
159
+		if len(prescriptions) > 0 {
160
+			for _, item := range prescriptions {
161
+				items := item.(map[string]interface{})
273 162
 
274
-	var advices []*models.HisGroupAdvice
275
-	// utils.TraceLog("%+v", dataBody["adviceNames"])
276
-	if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
277
-		utils.ErrorLog("adviceNames")
278
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
279
-		return
280
-	}
281
-	adviceNames := dataBody["adviceNames"].([]interface{})
282
-	for _, adviceNameMap := range adviceNames {
283
-		adviceNameM := adviceNameMap.(map[string]interface{})
284
-		var advice models.HisGroupAdvice
285
-		advice.Remark = Remark
286
-		advice.AdviceType = adviceType
287
-		advice.StartTime = StartTime
288
-		advice.AdviceDate = AdviceDate
289
-		advice.RecordDate = RecordDate
290
-		advice.Status = 1
291
-		advice.CreatedTime = time.Now().Unix()
292
-		advice.UpdatedTime = time.Now().Unix()
293
-		advice.StopState = 2
294
-		advice.ExecutionState = 2
295
-		advice.UserOrgId = adminUserInfo.CurrentOrgId
296
-		advice.PatientId = patient_id
297
-		advice.HisPatientId = his_patient_id
298
-		advice.AdviceDoctor = adminUserInfo.AdminUser.Id
299
-		advice.PrescriptionId = prescription_id
300
-
301
-		//入口
302
-		errcode := c.setAdviceWithJSON(&advice, adviceNameM)
303
-		if errcode > 0 {
304
-			c.ServeFailJSONWithSGJErrorCode(errcode)
305
-			return
306
-		}
163
+				if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
164
+					utils.ErrorLog("type")
165
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
166
+					return
167
+				}
168
+				types := int64(items["type"].(float64))
307 169
 
308
-		if adviceNameM["subdrugs"] != nil && reflect.TypeOf(adviceNameM["subdrugs"]).String() == "[]interface {}" {
309
-			subdrugs := adviceNameM["subdrugs"].([]interface{})
310
-			if len(subdrugs) > 0 {
311
-				for _, subdrug := range subdrugs {
312
-					var s models.HisGroupAdvice
313
-					s.Remark = Remark
314
-					s.AdviceType = adviceType
315
-					s.StartTime = StartTime
316
-					s.AdviceDate = AdviceDate
317
-					s.RecordDate = RecordDate
318
-					s.Status = 1
319
-					s.CreatedTime = time.Now().Unix()
320
-					s.UpdatedTime = time.Now().Unix()
321
-					s.StopState = 2
322
-					s.ExecutionState = 2
323
-					s.HisPatientId = his_patient_id
324
-					s.UserOrgId = adminUserInfo.CurrentOrgId
325
-					s.PatientId = patient_id
326
-					s.AdviceDoctor = adminUserInfo.AdminUser.Id
327
-
328
-					errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
329
-					if errcode > 0 {
330
-						c.ServeFailJSONWithSGJErrorCode(errcode)
331
-						return
170
+				ctime := time.Now().Unix()
171
+				prescription := &models.HisPrescription{
172
+					PatientId:  patient_id,
173
+					UserOrgId:  adminInfo.CurrentOrgId,
174
+					RecordDate: recordDateTime,
175
+					Ctime:      ctime,
176
+					Mtime:      ctime,
177
+					Type:       types,
178
+					Modifier:   adminInfo.AdminUser.Id,
179
+					Creator:    adminInfo.AdminUser.Id,
180
+					Status:     1,
181
+					Doctor:     doctor,
182
+				}
183
+				service.SaveHisPrescription(prescription)
184
+
185
+				if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
186
+					advices := items["advices"].([]interface{})
187
+					group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
188
+					groupNo := group + 1
189
+					ctime := time.Now().Unix()
190
+					mtime := ctime
191
+					if len(advices) > 0 {
192
+						for _, advice := range advices {
193
+							var s models.HisDoctorAdviceInfo
194
+							s.PrescriptionId = prescription.ID
195
+							s.AdviceType = 2
196
+							s.AdviceDoctor = adminInfo.AdminUser.Id
197
+							s.StopState = 2
198
+							s.ExecutionState = 2
199
+							s.AdviceDate = recordDateTime
200
+							s.Status = 1
201
+							s.UserOrgId = adminInfo.CurrentOrgId
202
+							s.RecordDate = recordDateTime
203
+							s.StartTime = recordDateTime
204
+							s.Groupno = groupNo
205
+							s.CreatedTime = ctime
206
+							s.UpdatedTime = mtime
207
+							s.PatientId = patient_id
208
+
209
+							errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
210
+							if errcode > 0 {
211
+								c.ServeFailJSONWithSGJErrorCode(errcode)
212
+								return
213
+							}
214
+							service.CreateHisDoctorAdvice(&s)
215
+						}
332 216
 					}
333
-
334
-					advice.Children = append(advice.Children, &s)
335 217
 				}
218
+
336 219
 			}
337 220
 		}
338
-
339
-		advices = append(advices, &advice)
340 221
 	}
341 222
 
342
-	newAdvices, createErr := service.CreateHisGroupAdvice(adminUserInfo.CurrentOrgId, advices, group_no)
343
-	if createErr != nil {
344
-		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
223
+	if err == nil {
224
+		c.ServeSuccessJSON(map[string]interface{}{
225
+			"msg": "保存成功",
226
+		})
345 227
 		return
346
-	}
347
-
348
-	c.ServeSuccessJSON(map[string]interface{}{
349
-		"msg":     "ok",
350
-		"advices": newAdvices,
351
-	})
352
-	return
353 228
 
229
+	} else {
230
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
231
+		return
232
+	}
354 233
 }
355 234
 
356 235
 func (c *HisApiController) CreateHisAdditionalCharge() {
@@ -584,97 +463,76 @@ func (c *HisApiController) GetCaseHistoryTemplate() {
584 463
 func (c *HisApiController) GetPrintHisPatientCaseHistory() {
585 464
 
586 465
 }
587
-func (c *HisApiController) setAdviceWithJSON(advice *models.HisGroupAdvice, json map[string]interface{}) int {
466
+func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
588 467
 
589
-	if json["advice_name"] == nil || reflect.TypeOf(json["advice_name"]).String() != "string" {
590
-		utils.ErrorLog("advice_name")
468
+	if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
469
+		utils.ErrorLog("drug_name")
591 470
 		return enums.ErrorCodeParamWrong
592 471
 	}
593
-	adviceName, _ := json["advice_name"].(string)
472
+	adviceName, _ := json["drug_name"].(string)
594 473
 	if len(adviceName) == 0 {
595 474
 		utils.ErrorLog("len(advice_name) == 0")
596 475
 		return enums.ErrorCodeParamWrong
597 476
 	}
598 477
 	advice.AdviceName = adviceName
599
-
600 478
 	adviceDesc, _ := json["advice_desc"].(string)
601 479
 	advice.AdviceDesc = adviceDesc
602
-
603 480
 	if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
604 481
 		drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
605 482
 		advice.DrugSpec = drugSpec
606 483
 	}
607
-
608 484
 	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
609 485
 		remark, _ := json["remark"].(string)
610 486
 		advice.Remark = remark
611 487
 	}
612
-
613
-	//if json["src_type"] != nil || reflect.TypeOf(json["src_type"]).String() == "float64" {
614
-	//	src_type, _ := strconv.ParseInt(json["src_type"].(string),10)
615
-	//	advice.Way = src_type
616
-	//}
617
-	if json["way"] == nil {
618
-		advice.Way = 0
619
-
620
-	} else {
621
-		if json["way"] != nil || reflect.TypeOf(json["way"]).String() == "float64" {
622
-			way := int64(json["way"].(float64))
623
-			advice.Way = way
624
-		}
625
-
626
-	}
627
-
628
-	if json["drug_id"] == nil {
488
+	if json["id"] == nil {
629 489
 		advice.DrugId = 0
630 490
 	} else {
631
-		if json["drug_id"] != nil || reflect.TypeOf(json["drug_id"]).String() == "float64" {
632
-			drug_id := int64(json["drug_id"].(float64))
491
+		if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
492
+			drug_id := int64(json["id"].(float64))
633 493
 			advice.DrugId = drug_id
634 494
 		}
635 495
 	}
636 496
 
637
-	if json["drug_name_id"] == nil {
638
-		advice.DrugNameId = 0
639
-	} else {
640
-		if json["drug_name_id"] != nil || reflect.TypeOf(json["drug_name_id"]).String() == "float64" {
641
-			drug_name_id := int64(json["drug_name_id"].(float64))
642
-			advice.DrugNameId = drug_name_id
643
-		}
644
-	}
645
-
646
-	if json["drug_spec_unit"] != nil && reflect.TypeOf(json["drug_spec_unit"]).String() == "string" {
647
-		drugSpecUnit, _ := json["drug_spec_unit"].(string)
497
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
498
+		drugSpecUnit, _ := json["min_unit"].(string)
648 499
 		advice.DrugSpecUnit = drugSpecUnit
649 500
 	}
650
-
651 501
 	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
652 502
 		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
653 503
 		advice.SingleDose = singleDose
654 504
 	}
655
-
656
-	if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
657
-		singleDoseUnit, _ := json["single_dose_unit"].(string)
505
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
506
+		singleDoseUnit, _ := json["min_unit"].(string)
658 507
 		advice.SingleDoseUnit = singleDoseUnit
659 508
 	}
660
-
661 509
 	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
662 510
 		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
663 511
 		advice.PrescribingNumber = prescribingNumber
664 512
 	}
665
-
666
-	if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
667
-		prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
513
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
514
+		prescribingNumberUnit, _ := json["min_unit"].(string)
668 515
 		advice.PrescribingNumberUnit = prescribingNumberUnit
669 516
 	}
670 517
 	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
671 518
 		deliveryWay, _ := json["delivery_way"].(string)
672 519
 		advice.DeliveryWay = deliveryWay
673 520
 	}
674
-
675 521
 	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
676 522
 		executionFrequency, _ := json["execution_frequency"].(string)
677 523
 		advice.ExecutionFrequency = executionFrequency
678 524
 	}
525
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
526
+		remark, _ := json["remark"].(string)
527
+		advice.Remark = remark
528
+	}
529
+	//if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
530
+	//	advice.Price = json["retail_price"].(float64)
531
+	//}
532
+
533
+	if json["retail_price"] != nil || reflect.TypeOf(json["retail_price"]).String() == "string" {
534
+		price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
535
+		advice.Price = price
536
+	}
679 537
 	return 0
680 538
 }

+ 0 - 2
models/his_models.go Целия файл

@@ -192,8 +192,6 @@ type HisDoctorAdviceInfo struct {
192 192
 	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
193 193
 	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
194 194
 	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
195
-	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
196
-	DrugNameId            int64   `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
197 195
 }
198 196
 
199 197
 func (HisDoctorAdviceInfo) TableName() string {

+ 10 - 0
service/his_service.go Целия файл

@@ -146,3 +146,13 @@ func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdvicePare
146 146
 	}).Where("org_id = ? AND status=1 ", org_id).Find(&temps).Error
147 147
 	return
148 148
 }
149
+
150
+func GetHisAdminUserDoctors(org_id int64) (doctors []*models.UserAdminRole, err error) {
151
+	err = readUserDb.Model(&models.UserAdminRole{}).Where("org_id = ? AND status = 1 AND (user_type = 1 OR user_type = 2)", org_id).Find(&doctors).Error
152
+	return
153
+}
154
+
155
+func CreateHisDoctorAdvice(s *models.HisDoctorAdviceInfo) (err error) {
156
+	err = writeDb.Create(s).Error
157
+	return
158
+}

+ 1 - 1
service/patient_service.go Целия файл

@@ -547,7 +547,7 @@ func CreateDoctorAdvice(m *models.DoctorAdvice) (err error) {
547 547
 }
548 548
 func GetMaxAdviceGroupID(orgId int64) (group int64) {
549 549
 	var advice models.DoctorAdvice
550
-	err := readDb.Table("xt_doctor_advice").Where("user_org_id=?", orgId).Select("max(groupno) as groupno").First(&advice).Error
550
+	err := readDb.Table("his_doctor_advice_info").Where("user_org_id=?", orgId).Select("max(groupno) as groupno").First(&advice).Error
551 551
 	if err != nil {
552 552
 		fmt.Println(err)
553 553
 		group = 0