张保健 4 vuotta sitten
vanhempi
commit
d2fd32edab

+ 4 - 4
controllers/base_api_controller.go Näytä tiedosto

@@ -81,7 +81,7 @@ func (this *BaseAuthAPIController) Prepare() {
81 81
 		userAdmin.ModifyTime = 1530786071
82 82
 		var subscibe models.ServeSubscibe
83 83
 		subscibe.ID = 1
84
-		subscibe.OrgId = 3877
84
+		subscibe.OrgId = 4
85 85
 		subscibe.PeriodStart = 1538035409
86 86
 		subscibe.PeriodEnd = 1569571409
87 87
 		subscibe.State = 1
@@ -91,7 +91,7 @@ func (this *BaseAuthAPIController) Prepare() {
91 91
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
92 92
 		subscibes[4] = &subscibe
93 93
 		var adminUserInfo service.AdminUserInfo
94
-		adminUserInfo.CurrentOrgId = 3877
94
+		adminUserInfo.CurrentOrgId = 4
95 95
 		adminUserInfo.CurrentAppId = 18
96 96
 		adminUserInfo.AdminUser = &userAdmin
97 97
 		adminUserInfo.Subscibes = subscibes
@@ -326,7 +326,7 @@ func (this *BaseServeAPIController) Prepare() {
326 326
 		userAdmin.ModifyTime = 1530786071
327 327
 		var subscibe models.ServeSubscibe
328 328
 		subscibe.ID = 1
329
-		subscibe.OrgId = 3877
329
+		subscibe.OrgId = 4
330 330
 		subscibe.PeriodStart = 1538035409
331 331
 		subscibe.PeriodEnd = 1569571409
332 332
 		subscibe.State = 1
@@ -337,7 +337,7 @@ func (this *BaseServeAPIController) Prepare() {
337 337
 		subscibes := make(map[int64]*models.ServeSubscibe, 0)
338 338
 		subscibes[4] = &subscibe
339 339
 		var adminUserInfo service.AdminUserInfo
340
-		adminUserInfo.CurrentOrgId = 3877
340
+		adminUserInfo.CurrentOrgId = 4
341 341
 		adminUserInfo.CurrentAppId = 18
342 342
 		adminUserInfo.AdminUser = &userAdmin
343 343
 		adminUserInfo.Subscibes = subscibes

+ 2 - 1
controllers/data_api_controller.go Näytä tiedosto

@@ -79,6 +79,7 @@ func (c *DataApiController) CreateConfig() {
79 79
 	// 验证关键字段的值是否重复
80 80
 
81 81
 	thisConfig, _ := service.FindConfigByTitle(dataconfig.Module, dataconfig.FieldName, adminUserInfo.CurrentOrgId)
82
+	fmt.Println("99999", thisConfig)
82 83
 	if thisConfig.ID > 0 {
83 84
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
84 85
 		return
@@ -385,7 +386,7 @@ func configFormData(dataconfig *models.Dataconfig, data []byte) (code int) {
385 386
 	}
386 387
 	dataconfig.Module = module
387 388
 
388
-	if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" {
389
+	if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" || module == "special_treatment" {
389 390
 		if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
390 391
 			utils.ErrorLog("title")
391 392
 			code = enums.ErrorCodeParamWrong

+ 538 - 0
controllers/his_api_controller.go Näytä tiedosto

@@ -0,0 +1,538 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"github.com/astaxie/beego"
10
+	"reflect"
11
+	"strconv"
12
+	"time"
13
+)
14
+
15
+type HisApiController struct {
16
+	BaseAuthAPIController
17
+}
18
+
19
+func HisManagerApiRegistRouters() {
20
+
21
+	beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
22
+	beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
23
+	beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
24
+
25
+	beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
26
+
27
+	beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
28
+	beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
29
+	beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "post:CreateHisPatientCaseHistory")
30
+	beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "post:CreateCaseHistoryTemplate")
31
+	beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
32
+	beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
33
+
34
+}
35
+
36
+func (c *HisApiController) GetHisPatientList() {
37
+	types, _ := c.GetInt64("type", 0)
38
+	record_date := c.GetString("record_date")
39
+	timeLayout := "2006-01-02"
40
+	loc, _ := time.LoadLocation("Local")
41
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
42
+	if err != nil {
43
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
44
+		return
45
+	}
46
+	recordDateTime := theTime.Unix()
47
+	adminInfo := c.GetAdminUserInfo()
48
+	patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
49
+	if types == 0 {
50
+		c.ServeSuccessJSON(map[string]interface{}{
51
+			"list": patients,
52
+		})
53
+
54
+	} else if types == 1 { //未就诊
55
+		var patientsOne []*service.Schedule
56
+		for _, item := range patients {
57
+			if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
58
+				patientsOne = append(patientsOne, item)
59
+			}
60
+		}
61
+		c.ServeSuccessJSON(map[string]interface{}{
62
+			"list": patientsOne,
63
+		})
64
+
65
+	} else if types == 2 { //已就诊
66
+		var patientsTwo []*service.Schedule
67
+		for _, item := range patients {
68
+			if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
69
+				patientsTwo = append(patientsTwo, item)
70
+			}
71
+		}
72
+		c.ServeSuccessJSON(map[string]interface{}{
73
+			"list": patientsTwo,
74
+		})
75
+	}
76
+
77
+}
78
+func (c *HisApiController) GetHisPatientInfo() {
79
+	patient_id, _ := c.GetInt64("patient_id")
80
+	record_date := c.GetString("record_date")
81
+	timeLayout := "2006-01-02"
82
+	loc, _ := time.LoadLocation("Local")
83
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
84
+	if err != nil {
85
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
86
+		return
87
+	}
88
+	recordDateTime := theTime.Unix()
89
+
90
+	admin := c.GetAdminUserInfo()
91
+	his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
92
+	xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
93
+
94
+	prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
95
+
96
+	//prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
97
+	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
98
+
99
+	c.ServeSuccessJSON(map[string]interface{}{
100
+		"his_info":     his_patient_info,
101
+		"xt_info":      xt_patient_info,
102
+		"prescription": prescriptions,
103
+		"case_history": case_history,
104
+	})
105
+	return
106
+
107
+}
108
+func (c *HisApiController) GetHisPrescriptionConfig() {
109
+	adminInfo := c.GetAdminUserInfo()
110
+	//获取医嘱模版
111
+	advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
112
+	//获取所有基础药
113
+	drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
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)
121
+
122
+	c.ServeSuccessJSON(map[string]interface{}{
123
+		"drugs":            drugs,
124
+		"advices_template": advices,
125
+		"drugways":         drugways,
126
+		"efs":              efs,
127
+		"doctors":          doctors,
128
+	})
129
+}
130
+func (c *HisApiController) CreateHisPrescription() {
131
+	record_date := c.GetString("record_date")
132
+	patient_id, _ := c.GetInt64("patient_id")
133
+	//diagnose := c.GetString("diagnose")
134
+	//sick_history := c.GetString("sick_history")
135
+	doctor, _ := c.GetInt64("doctor")
136
+	//departm/**/ent, _ := c.GetInt64("department")
137
+
138
+	dataBody := make(map[string]interface{}, 0)
139
+	err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
140
+	if err != nil {
141
+		utils.ErrorLog(err.Error())
142
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
143
+		return
144
+	}
145
+
146
+	timeLayout := "2006-01-02"
147
+	loc, _ := time.LoadLocation("Local")
148
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
149
+	if err != nil {
150
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
151
+		return
152
+	}
153
+	adminInfo := c.GetAdminUserInfo()
154
+	recordDateTime := theTime.Unix()
155
+
156
+	if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
157
+		prescriptions, _ := dataBody["prescriptions"].([]interface{})
158
+
159
+		if len(prescriptions) > 0 {
160
+			for _, item := range prescriptions {
161
+				items := item.(map[string]interface{})
162
+
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))
169
+
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
+						}
216
+					}
217
+				}
218
+
219
+			}
220
+		}
221
+	}
222
+
223
+	if err == nil {
224
+		c.ServeSuccessJSON(map[string]interface{}{
225
+			"msg": "保存成功",
226
+		})
227
+		return
228
+
229
+	} else {
230
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
231
+		return
232
+	}
233
+}
234
+
235
+func (c *HisApiController) CreateHisAdditionalCharge() {
236
+	his_patient_id, _ := c.GetInt64("his_patient_id")
237
+	patient_id, _ := c.GetInt64("patient_id")
238
+	record_date := c.GetString("record_date")
239
+	timeLayout := "2006-01-02"
240
+	loc, _ := time.LoadLocation("Local")
241
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
242
+	if err != nil {
243
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
244
+		return
245
+	}
246
+	adminInfo := c.GetAdminUserInfo()
247
+	recordDateTime := theTime.Unix()
248
+	dataBody := make(map[string]interface{}, 0)
249
+	err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
250
+	if err != nil {
251
+		utils.ErrorLog(err.Error())
252
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
253
+		return
254
+	}
255
+
256
+	var additions []*models.HisAdditionalCharge
257
+	if dataBody["addition"] != nil && reflect.TypeOf(dataBody["addition"]).String() == "[]interface {}" {
258
+		additions, _ := dataBody["addition"].([]interface{})
259
+		if len(additions) > 0 {
260
+			for _, item := range additions {
261
+				items := item.(map[string]interface{})
262
+
263
+				if items["item_id"] == nil || reflect.TypeOf(items["item_id"]).String() != "float64" {
264
+					utils.ErrorLog("item_id")
265
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
266
+					return
267
+				}
268
+				item_id := int64(items["item_id"].(float64))
269
+
270
+				if items["item_name"] == nil || reflect.TypeOf(items["item_name"]).String() != "string" {
271
+					utils.ErrorLog("item_name")
272
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
273
+					return
274
+				}
275
+				item_name := items["item_name"].(string)
276
+
277
+				if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
278
+					utils.ErrorLog("price")
279
+					c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
280
+					return
281
+				}
282
+				price, _ := strconv.ParseFloat(items["price"].(string), 64)
283
+
284
+				ctime := time.Now().Unix()
285
+				additional := &models.HisAdditionalCharge{
286
+					PatientId:    patient_id,
287
+					HisPatientId: his_patient_id,
288
+					UserOrgId:    adminInfo.CurrentOrgId,
289
+					RecordDate:   recordDateTime,
290
+					CreatedTime:  ctime,
291
+					UpdatedTime:  ctime,
292
+					Modifier:     adminInfo.AdminUser.Id,
293
+					Creator:      adminInfo.AdminUser.Id,
294
+					Price:        price,
295
+					ItemName:     item_name,
296
+					ItemId:       item_id,
297
+					Status:       1,
298
+				}
299
+				additions = append(additions, additional)
300
+			}
301
+		}
302
+	}
303
+	for _, item := range additions {
304
+		service.CreateAddtionalCharge(item)
305
+	}
306
+	c.ServeSuccessJSON(map[string]interface{}{
307
+		"msg": "创建成功",
308
+	})
309
+}
310
+
311
+func (c *HisApiController) CreateHisPatientCaseHistory() {
312
+	diagnostic := c.GetString("diagnostic")
313
+	temperature, _ := c.GetFloat("temperature")
314
+	blood_sugar, _ := c.GetFloat("blood_sugar")
315
+	pulse, _ := c.GetFloat("pulse")
316
+	sbp, _ := c.GetFloat("sbp")
317
+	dbp, _ := c.GetFloat("dbp")
318
+	blood_fat, _ := c.GetFloat("blood_fat")
319
+	height, _ := c.GetFloat("height")
320
+	sick_type, _ := c.GetInt64("sick_type")
321
+	symptom := c.GetString("symptom")
322
+	sick_date := c.GetString("sick_date")
323
+	is_infect, _ := c.GetInt64("is_infect")
324
+	chief_conplaint := c.GetString("chief_conplaint")
325
+	history_of_present_illness := c.GetString("history_of_present_illness")
326
+	past_history := c.GetString("past_history")
327
+	personal_history := c.GetString("personal_history")
328
+	family_history := c.GetString("family_history")
329
+	record_date := c.GetString("record_date")
330
+	patient_id, _ := c.GetInt64("patient_id")
331
+	timeLayout := "2006-01-02"
332
+	loc, _ := time.LoadLocation("Local")
333
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
334
+	if err != nil {
335
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
336
+		return
337
+	}
338
+	recordDateTime := theTime.Unix()
339
+	sickTime, err := time.ParseInLocation(timeLayout+" 15:04:05", sick_date+" 00:00:00", loc)
340
+	if err != nil {
341
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
342
+		return
343
+	}
344
+	sickTimes := sickTime.Unix()
345
+	ctime := time.Now().Unix()
346
+	caseHistory := models.HisPatientCaseHistory{
347
+		HisPatientId:            patient_id,
348
+		Temperature:             temperature,
349
+		BloodSugar:              blood_sugar,
350
+		Pulse:                   pulse,
351
+		Sbp:                     sbp,
352
+		Dbp:                     dbp,
353
+		Height:                  height,
354
+		BloodFat:                blood_fat,
355
+		SickType:                sick_type,
356
+		Symptom:                 symptom,
357
+		SickDate:                sickTimes,
358
+		IsInfect:                is_infect,
359
+		HistoryOfPresentIllness: history_of_present_illness,
360
+		PastHistory:             past_history,
361
+		Doctor:                  c.GetAdminUserInfo().AdminUser.Id,
362
+		ChiefConplaint:          chief_conplaint,
363
+		PersonalHistory:         personal_history,
364
+		FamilyHistory:           family_history,
365
+		Diagnostic:              diagnostic,
366
+		UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
367
+		Status:                  1,
368
+		Ctime:                   ctime,
369
+		Mtime:                   ctime,
370
+		RecordDate:              recordDateTime,
371
+	}
372
+	err = service.SaveHisPatientCaseHistory(caseHistory)
373
+	if err != nil {
374
+		c.ServeSuccessJSON(map[string]interface{}{
375
+			"msg": "保存成功",
376
+		})
377
+	}
378
+}
379
+func (c *HisApiController) GetHisPatientCaseHistoryList() {
380
+	patient_id, _ := c.GetInt64("patient_id", 0)
381
+	adminUser := c.GetAdminUserInfo()
382
+	caseHistorys, _ := service.GetHisPatientCaseHistoryList(adminUser.CurrentOrgId, patient_id)
383
+	c.ServeSuccessJSON(map[string]interface{}{
384
+		"list": caseHistorys,
385
+	})
386
+
387
+}
388
+func (c *HisApiController) GetHisPatientCaseHistory() {
389
+	record_date, _ := c.GetInt64("record_date", 0)
390
+	patient_id, _ := c.GetInt64("patient_id", 0)
391
+	admin := c.GetAdminUserInfo()
392
+	info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, record_date)
393
+	case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, record_date)
394
+	c.ServeSuccessJSON(map[string]interface{}{
395
+		"info":         info,
396
+		"case_history": case_history,
397
+	})
398
+
399
+}
400
+func (c *HisApiController) CreateCaseHistoryTemplate() {
401
+	template_name := c.GetString("template_name")
402
+	template_remark := c.GetString("template_remark")
403
+	doctor := c.GetAdminUserInfo().AdminUser.Id
404
+	diagnostic := c.GetString("diagnostic")
405
+	chief_conplaint := c.GetString("chief_conplaint")
406
+	history_of_present_illness := c.GetString("history_of_present_illness")
407
+	past_history := c.GetString("past_history")
408
+	personal_history := c.GetString("personal_history")
409
+	family_history := c.GetString("family_history")
410
+	record_date := c.GetString("record_date")
411
+
412
+	timeLayout := "2006-01-02"
413
+	loc, _ := time.LoadLocation("Local")
414
+
415
+	theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
416
+	if err != nil {
417
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
418
+		return
419
+	}
420
+	recordDateTime := theTime.Unix()
421
+
422
+	ctime := time.Now().Unix()
423
+
424
+	template := models.HisCaseHistoryTemplate{
425
+		HistoryOfPresentIllness: history_of_present_illness,
426
+		PastHistory:             past_history,
427
+		ChiefConplaint:          chief_conplaint,
428
+		PersonalHistory:         personal_history,
429
+		FamilyHistory:           family_history,
430
+		Diagnostic:              diagnostic,
431
+		UserOrgId:               c.GetAdminUserInfo().CurrentOrgId,
432
+		Status:                  1,
433
+		Ctime:                   ctime,
434
+		Mtime:                   ctime,
435
+		RecordDate:              recordDateTime,
436
+		TemplateName:            template_name,
437
+		TemplateRemark:          template_remark,
438
+		Creator:                 doctor,
439
+		Modifier:                doctor,
440
+	}
441
+
442
+	err = service.SaveHisPatientCaseHistoryTemplate(template)
443
+
444
+	if err == nil {
445
+		c.ServeSuccessJSON(map[string]interface{}{
446
+			"msg": "保存成功",
447
+		})
448
+
449
+	} else {
450
+		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
451
+		return
452
+	}
453
+
454
+}
455
+func (c *HisApiController) GetCaseHistoryTemplate() {
456
+	admin := c.GetAdminUserInfo()
457
+	template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId)
458
+	c.ServeSuccessJSON(map[string]interface{}{
459
+		"template": template,
460
+	})
461
+
462
+}
463
+func (c *HisApiController) GetPrintHisPatientCaseHistory() {
464
+
465
+}
466
+func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
467
+
468
+	if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
469
+		utils.ErrorLog("drug_name")
470
+		return enums.ErrorCodeParamWrong
471
+	}
472
+	adviceName, _ := json["drug_name"].(string)
473
+	if len(adviceName) == 0 {
474
+		utils.ErrorLog("len(advice_name) == 0")
475
+		return enums.ErrorCodeParamWrong
476
+	}
477
+	advice.AdviceName = adviceName
478
+	adviceDesc, _ := json["advice_desc"].(string)
479
+	advice.AdviceDesc = adviceDesc
480
+	if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
481
+		drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
482
+		advice.DrugSpec = drugSpec
483
+	}
484
+	if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
485
+		remark, _ := json["remark"].(string)
486
+		advice.Remark = remark
487
+	}
488
+	if json["id"] == nil {
489
+		advice.DrugId = 0
490
+	} else {
491
+		if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
492
+			drug_id := int64(json["id"].(float64))
493
+			advice.DrugId = drug_id
494
+		}
495
+	}
496
+
497
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
498
+		drugSpecUnit, _ := json["min_unit"].(string)
499
+		advice.DrugSpecUnit = drugSpecUnit
500
+	}
501
+	if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
502
+		singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
503
+		advice.SingleDose = singleDose
504
+	}
505
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
506
+		singleDoseUnit, _ := json["min_unit"].(string)
507
+		advice.SingleDoseUnit = singleDoseUnit
508
+	}
509
+	if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
510
+		prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
511
+		advice.PrescribingNumber = prescribingNumber
512
+	}
513
+	if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
514
+		prescribingNumberUnit, _ := json["min_unit"].(string)
515
+		advice.PrescribingNumberUnit = prescribingNumberUnit
516
+	}
517
+	if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
518
+		deliveryWay, _ := json["delivery_way"].(string)
519
+		advice.DeliveryWay = deliveryWay
520
+	}
521
+	if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
522
+		executionFrequency, _ := json["execution_frequency"].(string)
523
+		advice.ExecutionFrequency = executionFrequency
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
+	}
537
+	return 0
538
+}

+ 885 - 0
controllers/his_project_api_controller.go Näytä tiedosto

@@ -0,0 +1,885 @@
1
+package controllers
2
+
3
+import (
4
+	"XT_New/enums"
5
+	"XT_New/models"
6
+	"XT_New/service"
7
+	"XT_New/utils"
8
+	"encoding/json"
9
+	"fmt"
10
+	"github.com/astaxie/beego"
11
+	"github.com/jinzhu/gorm"
12
+	"strconv"
13
+	"strings"
14
+	"time"
15
+)
16
+
17
+type HisProjectApiController struct {
18
+	BaseAuthAPIController
19
+}
20
+
21
+func HisProjectRouters() {
22
+
23
+	beego.Router("/api/his/saveproject", &HisProjectApiController{}, "Get:SaveProject")
24
+	beego.Router("/api/his/getprojectlist", &HisProjectApiController{}, "Get:GetProjectList")
25
+	beego.Router("/api/his/getprojectdetail", &HisProjectApiController{}, "Get:GetProjectDetail")
26
+	beego.Router("/api/his/updatedproject", &HisProjectApiController{}, "Get:UpdatedProject")
27
+	beego.Router("/api/his/deletehisproject", &HisProjectApiController{}, "Get:DeleteHisProject")
28
+	beego.Router("/api/his/saveprojectteam", &HisProjectApiController{}, "Get:SaveProjectTeam")
29
+	beego.Router("/api/his/getprojectteamlist", &HisProjectApiController{}, "Get:GetProjectTeamList")
30
+	beego.Router("/api/his/getprojectteamdetail", &HisProjectApiController{}, "Get:GetProjectTeamDetail")
31
+	beego.Router("/api/his/updateprojectteam", &HisProjectApiController{}, "Get:UpdatedProjectTeam")
32
+	beego.Router("/api/his/deleteprojectteam", &HisProjectApiController{}, "Get:DeleteProjectTeam")
33
+	beego.Router("/api/his/savedepartment", &HisProjectApiController{}, "Get:SaveDePartment")
34
+	beego.Router("/api/his/getdepartmentlist", &HisProjectApiController{}, "Get:GetDepartMentList")
35
+	beego.Router("/api/his/getdepartmentdetail", &HisProjectApiController{}, "Get:GetDepartMentDetail")
36
+	beego.Router("/api/his/updagtedepartment", &HisProjectApiController{}, "Get:UpdatedDeparment")
37
+	beego.Router("/api/his/deletedeparment", &HisProjectApiController{}, "Get:DeleteDepartment")
38
+	beego.Router("/api/his/getallprojectlist", &HisProjectApiController{}, "Get:GetAllProjectList")
39
+	beego.Router("/api/his/addprojectlist", &HisProjectApiController{}, "Get:AddProjectList")
40
+	beego.Router("/api/his/deleteproject", &HisProjectApiController{}, "Get:DeleteProject")
41
+	beego.Router("/api/his/gethisproject", &HisProjectApiController{}, "Get:GetHisProject")
42
+	beego.Router("/api/his/getprojectteam", &HisProjectApiController{}, "Get:GetProjectTeam")
43
+	beego.Router("/api/his/getalldoctorlist", &HisProjectApiController{}, "Get:GetAllDoctorList")
44
+	beego.Router("/api/his/savehispatient", &HisProjectApiController{}, "Get:SaveHisPatient")
45
+	//获取今日血透排班的患者
46
+	beego.Router("/api/his/getbloodpatient", &HisProjectApiController{}, "Get:GetBloodPatientList")
47
+	//获取患者的今日透析处方
48
+	beego.Router("/api/his/gethisprescription", &HisProjectApiController{}, "Get:GetHisPrescription")
49
+	//新增附加费用
50
+	beego.Router("/api/his/additionalcharge", &HisProjectApiController{}, "Post:AdditionalCharge")
51
+	//获取治疗单
52
+	beego.Router("/api/his/gettreatlist", &HisProjectApiController{}, "Get:GetTreatmentList")
53
+	beego.Router("/api/his/getpatientinformation", &HisProjectApiController{}, "Get:GetPatientInformation")
54
+	beego.Router("/api/hist/getallprojecteam", &HisProjectApiController{}, "Get:GetAllProjectTeam")
55
+	beego.Router("/api/his/getprojectlistbyid", &HisProjectApiController{}, "Get:GetProjectListById")
56
+	beego.Router("/api/his/gethispatienthistory", &HisProjectApiController{}, "Get:GetHisPatientHistory")
57
+}
58
+
59
+func (this *HisProjectApiController) SaveProject() {
60
+
61
+	project_name := this.GetString("project_name")
62
+	pinyin := this.GetString("pinyin")
63
+	wubi := this.GetString("wubi")
64
+	price := this.GetString("price")
65
+	price_float, err := strconv.ParseFloat(price, 64)
66
+	unit := this.GetString("unit")
67
+	cost_classify, _ := this.GetInt64("cost_classify")
68
+	executive_section, _ := this.GetInt64("executive_section")
69
+	medical_coverage, _ := this.GetInt64("medical_coverage")
70
+	statistical_classification, _ := this.GetInt64("statistical_classification")
71
+	disease_directory, _ := this.GetInt64("disease_directory")
72
+	is_record, _ := this.GetInt64("is_record")
73
+	medical_code := this.GetString("medical_code")
74
+	tube_color, _ := this.GetInt64("tube_color")
75
+	medical_status, _ := this.GetInt64("medical_status")
76
+	remark := this.GetString("remark")
77
+	sign, _ := this.GetInt64("sign")
78
+	default_number := this.GetString("default_number")
79
+	is_charge, _ := this.GetInt64("is_charge")
80
+	is_estimate, _ := this.GetInt64("is_estimate")
81
+	is_workload, _ := this.GetInt64("is_workload")
82
+	sort := this.GetString("sort")
83
+	is_advice, _ := this.GetInt64("is_advice")
84
+	is_default, _ := this.GetInt64("is_default")
85
+	single_dose := this.GetString("single_dose")
86
+	delivery_way := this.GetString("delivery_way")
87
+	execution_frequency := this.GetString("execution_frequency")
88
+	number_days := this.GetString("number_days")
89
+	total := this.GetString("total")
90
+	adminUserInfo := this.GetAdminUserInfo()
91
+	orgId := adminUserInfo.CurrentOrgId
92
+	hisProject := models.XtHisProject{
93
+		ProjectName:               project_name,
94
+		Pinyin:                    pinyin,
95
+		Wubi:                      wubi,
96
+		Price:                     price_float,
97
+		Unit:                      unit,
98
+		CostClassify:              cost_classify,
99
+		ExecutiveSection:          executive_section,
100
+		MedicalCoverage:           medical_coverage,
101
+		StatisticalClassification: statistical_classification,
102
+		DiseaseDirectory:          disease_directory,
103
+		IsRecord:                  is_record,
104
+		MedicalCode:               medical_code,
105
+		TubeColor:                 tube_color,
106
+		MedicalStatus:             medical_status,
107
+		Remark:                    remark,
108
+		Sign:                      sign,
109
+		DefaultNumber:             default_number,
110
+		IsCharge:                  is_charge,
111
+		IsEstimate:                is_estimate,
112
+		IsWorkload:                is_workload,
113
+		Sort:                      sort,
114
+		DoctorAdvice:              is_advice,
115
+		IsDefault:                 is_default,
116
+		UserOrgId:                 orgId,
117
+		Status:                    1,
118
+		CreatedTime:               time.Now().Unix(),
119
+		SingleDose:                single_dose,
120
+		DeliveryWay:               delivery_way,
121
+		ExecutionFrequency:        execution_frequency,
122
+		NumberDays:                number_days,
123
+		Total:                     total,
124
+	}
125
+	//查询项目名称是否存在
126
+	_, errcode := service.GetHisProjectIsExist(project_name, orgId)
127
+	fmt.Println("9999999999999", errcode)
128
+	if errcode == gorm.ErrRecordNotFound {
129
+		fmt.Println("222")
130
+		err = service.CreateHisProject(&hisProject)
131
+		if err != nil {
132
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
133
+			return
134
+		}
135
+		this.ServeSuccessJSON(map[string]interface{}{
136
+			"hisProject": hisProject,
137
+		})
138
+		return
139
+	} else if errcode == nil {
140
+		fmt.Println("3333")
141
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
142
+		return
143
+	}
144
+}
145
+
146
+func (this *HisProjectApiController) GetProjectList() {
147
+
148
+	adminUserInfo := this.GetAdminUserInfo()
149
+	orgId := adminUserInfo.CurrentOrgId
150
+	limit, _ := this.GetInt64("limit")
151
+	page, _ := this.GetInt64("page")
152
+	is_charge, _ := this.GetInt64("is_charge")
153
+	is_start, _ := this.GetInt64("is_start")
154
+	keyword := this.GetString("keyword")
155
+	projecList, total, err := service.GetHisProjectList(orgId, limit, page, is_charge, is_start, keyword)
156
+	fmt.Println("err", err)
157
+	if err != nil {
158
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
159
+		return
160
+	}
161
+	this.ServeSuccessJSON(map[string]interface{}{
162
+		"projecList": projecList,
163
+		"total":      total,
164
+	})
165
+	return
166
+}
167
+
168
+func (this *HisProjectApiController) GetProjectDetail() {
169
+	id, _ := this.GetInt64("id")
170
+	projectDetail, err := service.GetProjectDetail(id)
171
+	if err != nil {
172
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
173
+		return
174
+	}
175
+	this.ServeSuccessJSON(map[string]interface{}{
176
+		"projecDetail": projectDetail,
177
+	})
178
+	return
179
+}
180
+
181
+func (this *HisProjectApiController) UpdatedProject() {
182
+
183
+	id, _ := this.GetInt64("id")
184
+	project_name := this.GetString("project_name")
185
+	pinyin := this.GetString("pinyin")
186
+	wubi := this.GetString("wubi")
187
+	price := this.GetString("price")
188
+	price_float, _ := strconv.ParseFloat(price, 64)
189
+	unit := this.GetString("unit")
190
+	cost_classify, _ := this.GetInt64("cost_classify")
191
+	executive_section, _ := this.GetInt64("executive_section")
192
+	medical_coverage, _ := this.GetInt64("medical_coverage")
193
+	statistical_classification, _ := this.GetInt64("statistical_classification")
194
+	disease_directory, _ := this.GetInt64("disease_directory")
195
+	is_record, _ := this.GetInt64("is_record")
196
+	medical_code := this.GetString("medical_code")
197
+	tube_color, _ := this.GetInt64("tube_color")
198
+	medical_status, _ := this.GetInt64("medical_status")
199
+	remark := this.GetString("remark")
200
+	sign, _ := this.GetInt64("sign")
201
+	default_number := this.GetString("default_number")
202
+	is_charge, _ := this.GetInt64("is_charge")
203
+	is_estimate, _ := this.GetInt64("is_estimate")
204
+	is_workload, _ := this.GetInt64("is_workload")
205
+	sort := this.GetString("sort")
206
+	is_advice, _ := this.GetInt64("is_advice")
207
+	is_default, _ := this.GetInt64("is_default")
208
+	single_dose := this.GetString("single_dose")
209
+	delivery_way := this.GetString("delivery_way")
210
+	execution_frequency := this.GetString("execution_frequency")
211
+	number_days := this.GetString("number_days")
212
+	total := this.GetString("total")
213
+	hisProject := models.XtHisProject{
214
+		ProjectName:               project_name,
215
+		Pinyin:                    pinyin,
216
+		Wubi:                      wubi,
217
+		Price:                     price_float,
218
+		Unit:                      unit,
219
+		CostClassify:              cost_classify,
220
+		ExecutiveSection:          executive_section,
221
+		MedicalCoverage:           medical_coverage,
222
+		StatisticalClassification: statistical_classification,
223
+		DiseaseDirectory:          disease_directory,
224
+		IsRecord:                  is_record,
225
+		MedicalCode:               medical_code,
226
+		TubeColor:                 tube_color,
227
+		MedicalStatus:             medical_status,
228
+		Remark:                    remark,
229
+		Sign:                      sign,
230
+		DefaultNumber:             default_number,
231
+		IsCharge:                  is_charge,
232
+		IsEstimate:                is_estimate,
233
+		IsWorkload:                is_workload,
234
+		Sort:                      sort,
235
+		DoctorAdvice:              is_advice,
236
+		IsDefault:                 is_default,
237
+		UpdatedTime:               time.Now().Unix(),
238
+		SingleDose:                single_dose,
239
+		DeliveryWay:               delivery_way,
240
+		ExecutionFrequency:        execution_frequency,
241
+		NumberDays:                number_days,
242
+		Total:                     total,
243
+	}
244
+
245
+	err := service.UpdatedProject(id, &hisProject)
246
+	if err != nil {
247
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
248
+		return
249
+	}
250
+	this.ServeSuccessJSON(map[string]interface{}{
251
+		"hisProject": hisProject,
252
+	})
253
+	return
254
+}
255
+
256
+func (this *HisProjectApiController) DeleteHisProject() {
257
+
258
+	id, _ := this.GetInt64("id")
259
+	err := service.DeleteHisProject(id)
260
+	if err != nil {
261
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
262
+		return
263
+	}
264
+	returnData := make(map[string]interface{}, 0)
265
+	returnData["msg"] = "ok"
266
+	this.ServeSuccessJSON(returnData)
267
+	return
268
+}
269
+
270
+func (this *HisProjectApiController) SaveProjectTeam() {
271
+
272
+	project_team := this.GetString("project_team")
273
+
274
+	price := this.GetString("price")
275
+	price_float, _ := strconv.ParseFloat(price, 64)
276
+	pinyin := this.GetString("pinyin")
277
+	wubi := this.GetString("wubi")
278
+	tube_color, _ := this.GetInt64("tube_color")
279
+	team_type, _ := this.GetInt64("team_type")
280
+	remark := this.GetString("remark")
281
+	ids := this.GetString("ids")
282
+
283
+	adminUserInfo := this.GetAdminUserInfo()
284
+	orgId := adminUserInfo.CurrentOrgId
285
+	projectTeam := models.XtHisProjectTeam{
286
+		ProjectTeam: project_team,
287
+		Price:       price_float,
288
+		Pinyin:      pinyin,
289
+		Wubi:        wubi,
290
+		TubeColor:   tube_color,
291
+		TeamType:    team_type,
292
+		Remark:      remark,
293
+		UserOrgId:   orgId,
294
+		Status:      1,
295
+		CreatedTime: time.Now().Unix(),
296
+		ProjectId:   ids,
297
+	}
298
+	fmt.Println(projectTeam)
299
+
300
+	_, errcodes := service.GetHisProjectByNameOne(project_team, orgId)
301
+
302
+	if errcodes == gorm.ErrRecordNotFound {
303
+
304
+		err := service.CreatedProjectTeam(&projectTeam)
305
+		if err != nil {
306
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
307
+			return
308
+		}
309
+		this.ServeSuccessJSON(map[string]interface{}{
310
+			"projectTeam": projectTeam,
311
+		})
312
+		return
313
+	} else if errcodes == nil {
314
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
315
+		return
316
+	}
317
+}
318
+
319
+func (this *HisProjectApiController) GetProjectTeamList() {
320
+
321
+	limit, _ := this.GetInt64("limit")
322
+	page, _ := this.GetInt64("page")
323
+	keyword := this.GetString("keyword")
324
+	adminUserInfo := this.GetAdminUserInfo()
325
+	orgId := adminUserInfo.CurrentOrgId
326
+	projectTeamList, total, err := service.GetProjectTeamList(limit, page, orgId, keyword)
327
+	if err != nil {
328
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
329
+		return
330
+	}
331
+	this.ServeSuccessJSON(map[string]interface{}{
332
+		"projectTeamList": projectTeamList,
333
+		"total":           total,
334
+	})
335
+	return
336
+}
337
+
338
+func (this *HisProjectApiController) GetProjectTeamDetail() {
339
+
340
+	id, _ := this.GetInt64("id")
341
+	projectTeamDetail, err := service.GetProjectTeamDetail(id)
342
+	if err != nil {
343
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
344
+		return
345
+	}
346
+	this.ServeSuccessJSON(map[string]interface{}{
347
+		"projectTeamDetail": projectTeamDetail,
348
+	})
349
+	return
350
+}
351
+
352
+func (this *HisProjectApiController) UpdatedProjectTeam() {
353
+
354
+	id, _ := this.GetInt64("id")
355
+	project_team := this.GetString("project_team")
356
+	price := this.GetString("price")
357
+	price_float, _ := strconv.ParseFloat(price, 64)
358
+	pinyin := this.GetString("pinyin")
359
+	wubi := this.GetString("wubi")
360
+	tube_color, _ := this.GetInt64("tube_color")
361
+	team_type, _ := this.GetInt64("team_type")
362
+	remark := this.GetString("remark")
363
+	ids := this.GetString("ids")
364
+	projectTeam := models.XtHisProjectTeam{
365
+		ProjectTeam: project_team,
366
+		Price:       price_float,
367
+		Pinyin:      pinyin,
368
+		Wubi:        wubi,
369
+		TubeColor:   tube_color,
370
+		TeamType:    team_type,
371
+		Remark:      remark,
372
+		ProjectId:   ids,
373
+	}
374
+
375
+	err := service.UpdatedProjectTeam(id, &projectTeam)
376
+	if err != nil {
377
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
378
+		return
379
+	}
380
+	this.ServeSuccessJSON(map[string]interface{}{
381
+		"projectTeam": projectTeam,
382
+	})
383
+	return
384
+}
385
+
386
+func (this *HisProjectApiController) DeleteProjectTeam() {
387
+
388
+	id, _ := this.GetInt64("id")
389
+	err := service.DeleteProjectTeam(id)
390
+	if err != nil {
391
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
392
+		return
393
+	}
394
+	returnData := make(map[string]interface{}, 0)
395
+	returnData["msg"] = "ok"
396
+	this.ServeSuccessJSON(returnData)
397
+	return
398
+}
399
+
400
+func (this *HisProjectApiController) SaveDePartment() {
401
+
402
+	name := this.GetString("name")
403
+	number := this.GetString("number")
404
+	adminUserInfo := this.GetAdminUserInfo()
405
+	orgId := adminUserInfo.CurrentOrgId
406
+	department := models.XtHisDepartment{
407
+		Name:        name,
408
+		Number:      number,
409
+		UserOrgId:   orgId,
410
+		CreatedTime: time.Now().Unix(),
411
+		Status:      1,
412
+	}
413
+	err := service.CreateDePartment(&department)
414
+	if err != nil {
415
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
416
+		return
417
+	}
418
+	this.ServeSuccessJSON(map[string]interface{}{
419
+		"department": department,
420
+	})
421
+	return
422
+}
423
+
424
+func (this *HisProjectApiController) GetDepartMentList() {
425
+
426
+	limit, _ := this.GetInt64("limit")
427
+	page, _ := this.GetInt64("page")
428
+	adminUserInfo := this.GetAdminUserInfo()
429
+	orgId := adminUserInfo.CurrentOrgId
430
+	departMentList, total, err := service.GetDepartMentList(limit, page, orgId)
431
+	if err != nil {
432
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
433
+		return
434
+	}
435
+	this.ServeSuccessJSON(map[string]interface{}{
436
+		"departMentList": departMentList,
437
+		"total":          total,
438
+	})
439
+	return
440
+}
441
+
442
+func (this *HisProjectApiController) GetDepartMentDetail() {
443
+
444
+	id, _ := this.GetInt64("id")
445
+	departDetail, err := service.GetDepartMentDetail(id)
446
+	if err != nil {
447
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
448
+		return
449
+	}
450
+	this.ServeSuccessJSON(map[string]interface{}{
451
+		"departDetail": departDetail,
452
+	})
453
+	return
454
+}
455
+
456
+func (this *HisProjectApiController) UpdatedDeparment() {
457
+
458
+	id, _ := this.GetInt64("id")
459
+	name := this.GetString("name")
460
+	number := this.GetString("number")
461
+	department := models.XtHisDepartment{
462
+		Name:   name,
463
+		Number: number,
464
+	}
465
+	err := service.UpdatedDepartment(id, &department)
466
+	if err != nil {
467
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
468
+		return
469
+	}
470
+	this.ServeSuccessJSON(map[string]interface{}{
471
+		"department": department,
472
+	})
473
+	return
474
+}
475
+
476
+func (this *HisProjectApiController) DeleteDepartment() {
477
+
478
+	id, _ := this.GetInt64("id")
479
+	err := service.DeleteDepartment(id)
480
+	if err != nil {
481
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
482
+		return
483
+	}
484
+	returnData := make(map[string]interface{}, 0)
485
+	returnData["msg"] = "ok"
486
+	this.ServeSuccessJSON(returnData)
487
+	return
488
+}
489
+
490
+func (this *HisProjectApiController) GetBloodPatientList() {
491
+
492
+	adminUserInfo := this.GetAdminUserInfo()
493
+	orgId := adminUserInfo.CurrentOrgId
494
+	fmt.Println("org", orgId)
495
+	timeStr := time.Now().Format("2006-01-02")
496
+	timeLayout := "2006-01-02 15:04:05"
497
+	fmt.Println("timeStr:", timeStr)
498
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
499
+	timenow := timeStringToTime.Unix()
500
+
501
+	//统计血透排班的患者
502
+	scheduleList, err := service.GetBloodPatientList(orgId, timenow)
503
+	//统计当日挂号的患者
504
+	hisPatient, _ := service.GetHisPatient(orgId, timenow)
505
+	//统计今天开处方的患者
506
+	prescription, _ := service.GetHisPrescriptionOther(orgId, timenow)
507
+	if err != nil {
508
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
509
+		return
510
+	}
511
+	this.ServeSuccessJSON(map[string]interface{}{
512
+		"scheduleList": scheduleList,
513
+		"hisPatient":   hisPatient,
514
+		"prescription": prescription,
515
+	})
516
+	return
517
+}
518
+
519
+func (this *HisProjectApiController) GetHisPrescription() {
520
+
521
+	id, _ := this.GetInt64("id")
522
+	timeStr := time.Now().Format("2006-01-02")
523
+	timeLayout := "2006-01-02 15:04:05"
524
+	fmt.Println("timeStr:", timeStr)
525
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
526
+	timenow := timeStringToTime.Unix()
527
+	prescriptionList, err := service.GetHisPrescriptionByPatientId(id, timenow)
528
+	if err != nil {
529
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
530
+		return
531
+	}
532
+	this.ServeSuccessJSON(map[string]interface{}{
533
+		"prescriptionList": prescriptionList,
534
+	})
535
+	return
536
+}
537
+
538
+func (this *HisProjectApiController) AdditionalCharge() {
539
+
540
+	dataBody := make(map[string]interface{}, 0)
541
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
542
+	fmt.Println(err)
543
+	his_patient_id := int64(dataBody["his_patient_id"].(float64))
544
+	patient_id := int64(dataBody["patient_id"].(float64))
545
+	fmt.Println("patient_id2222222222", patient_id)
546
+	medicineData, _ := dataBody["medicineData"].([]interface{})
547
+	adminUserInfo := this.GetAdminUserInfo()
548
+	orgId := adminUserInfo.CurrentOrgId
549
+	admin_user_id := adminUserInfo.AdminUser.Id
550
+	timeStr := time.Now().Format("2006-01-02")
551
+	timeLayout := "2006-01-02 15:04:05"
552
+	fmt.Println("timeStr:", timeStr)
553
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
554
+	timenow := timeStringToTime.Unix()
555
+	for _, item := range medicineData {
556
+		items := item.(map[string]interface{})
557
+		//drug_id := int64(items["id"].(float64))
558
+		money := items["money"].(string)
559
+		moneys, _ := strconv.ParseInt(money, 10, 64)
560
+		monStr := strconv.FormatInt(moneys, 10)
561
+		monneyStr, _ := strconv.ParseFloat(monStr, 64)
562
+		additionalCharge := models.HisAdditionalCharge{
563
+			HisPatientId: his_patient_id,
564
+			UserOrgId:    orgId,
565
+			PatientId:    patient_id,
566
+			RecordDate:   timenow,
567
+			Price:        monneyStr,
568
+			Status:       1,
569
+			AdminUserId:  admin_user_id,
570
+			CreatedTime:  time.Now().Unix(),
571
+		}
572
+
573
+		err := service.CreateAdditionalCharge(&additionalCharge)
574
+		if err != nil {
575
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
576
+			return
577
+		}
578
+		this.ServeSuccessJSON(map[string]interface{}{
579
+			"additionalCharge": additionalCharge,
580
+		})
581
+		return
582
+	}
583
+}
584
+
585
+func (this *HisProjectApiController) GetTreatmentList() {
586
+
587
+	patient_id, _ := this.GetInt64("patient_id")
588
+	timeStr := time.Now().Format("2006-01-02")
589
+	timeLayout := "2006-01-02 15:04:05"
590
+	fmt.Println("timeStr:", timeStr)
591
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
592
+	timenow := timeStringToTime.Unix()
593
+	treatmentList, err := service.GetTreatmentList(patient_id, timenow)
594
+	if err != nil {
595
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
596
+		return
597
+	}
598
+	this.ServeSuccessJSON(map[string]interface{}{
599
+		"treatmentList": treatmentList,
600
+	})
601
+	return
602
+}
603
+
604
+func (this *HisProjectApiController) GetAllProjectList() {
605
+
606
+	adminUserInfo := this.GetAdminUserInfo()
607
+	orgId := adminUserInfo.CurrentOrgId
608
+	projectList, err := service.GetAllProjectList(orgId)
609
+	//获取列表数据
610
+	hisprojectlist, err := service.GetHisProjectListByOrgId(orgId)
611
+
612
+	if err != nil {
613
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
614
+		return
615
+	}
616
+	this.ServeSuccessJSON(map[string]interface{}{
617
+		"projectList":    projectList,
618
+		"hisprojectlist": hisprojectlist,
619
+	})
620
+	return
621
+}
622
+
623
+func (this *HisProjectApiController) AddProjectList() {
624
+
625
+	id, _ := this.GetInt64("id")
626
+	number, _ := this.GetInt64("number")
627
+	adminUserInfo := this.GetAdminUserInfo()
628
+	orgId := adminUserInfo.CurrentOrgId
629
+	projectList := models.XtHisProjectList{
630
+		ProjectId:   id,
631
+		Number:      number,
632
+		UserOrgId:   orgId,
633
+		Status:      1,
634
+		CreatedTime: time.Now().Unix(),
635
+	}
636
+	err := service.CreateProjectList(&projectList)
637
+
638
+	if err != nil {
639
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
640
+		return
641
+	}
642
+	this.ServeSuccessJSON(map[string]interface{}{
643
+		"projectList": projectList,
644
+	})
645
+	return
646
+}
647
+
648
+func (this *HisProjectApiController) GetPatientInformation() {
649
+
650
+	id, _ := this.GetInt64("id")
651
+	information, err := service.GetHisPatientInformation(id)
652
+	if err != nil {
653
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
654
+		return
655
+	}
656
+	this.ServeSuccessJSON(map[string]interface{}{
657
+		"information": information,
658
+	})
659
+	return
660
+}
661
+
662
+func (this *HisProjectApiController) DeleteProject() {
663
+
664
+	id, _ := this.GetInt64("id")
665
+	err := service.DeleteProjectList(id)
666
+	if err != nil {
667
+		this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
668
+		return
669
+	}
670
+	returnData := make(map[string]interface{}, 0)
671
+	returnData["msg"] = "ok"
672
+	this.ServeSuccessJSON(returnData)
673
+	return
674
+}
675
+
676
+func (this *HisProjectApiController) GetHisProject() {
677
+
678
+	adminUserInfo := this.GetAdminUserInfo()
679
+	orgId := adminUserInfo.CurrentOrgId
680
+	project, err := service.GetHisProject(orgId)
681
+	if err != nil {
682
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
683
+		return
684
+	}
685
+	this.ServeSuccessJSON(map[string]interface{}{
686
+		"project": project,
687
+	})
688
+}
689
+
690
+func (this *HisProjectApiController) GetProjectTeam() {
691
+
692
+	strids := this.GetString("strids")
693
+
694
+	idStrs := strings.Split(strids, ",")
695
+	adminUserInfo := this.GetAdminUserInfo()
696
+	orgId := adminUserInfo.CurrentOrgId
697
+	team, err := service.GetProjectTeam(idStrs, orgId)
698
+	if err != nil {
699
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
700
+		return
701
+	}
702
+	this.ServeSuccessJSON(map[string]interface{}{
703
+		"team": team,
704
+	})
705
+}
706
+
707
+func (this *HisProjectApiController) GetAllDoctorList() {
708
+
709
+	adminUserInfo := this.GetAdminUserInfo()
710
+	orgId := adminUserInfo.CurrentOrgId
711
+	appId := adminUserInfo.CurrentAppId
712
+	//获取所有的医生
713
+	doctor, err := service.GetAllDoctor(orgId, appId)
714
+	//获取所有的科室
715
+	department, err := service.GetAllDepartMent(orgId)
716
+	if err != nil {
717
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
718
+		return
719
+	}
720
+	this.ServeSuccessJSON(map[string]interface{}{
721
+		"doctor":     doctor,
722
+		"department": department,
723
+	})
724
+}
725
+
726
+func (this *HisProjectApiController) SaveHisPatient() {
727
+	timeLayout := "2006-01-02"
728
+	loc, _ := time.LoadLocation("Local")
729
+	age, _ := this.GetInt64("age")
730
+
731
+	birthday := this.GetString("birthDay")
732
+	birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
733
+	birthUnix := birthdays.Unix()
734
+	certificates, _ := this.GetInt64("certificates")
735
+	cost_checked, _ := this.GetInt64("costChecked")
736
+	cost, _ := this.GetInt64("cost")
737
+	costs := strconv.FormatInt(cost, 10)
738
+	cost_float, _ := strconv.ParseFloat(costs, 64)
739
+	department, _ := this.GetInt64("department")
740
+	doctor, _ := this.GetInt64("doctor")
741
+	medicalcare, _ := this.GetInt64("medicalCare")
742
+	idcard := this.GetString("idCard")
743
+	medicalExpenses, _ := this.GetInt64("medicalExpenses")
744
+	medicalExpense := strconv.FormatInt(medicalExpenses, 10)
745
+	medicalExpense_float, _ := strconv.ParseFloat(medicalExpense, 64)
746
+	medicalinsurancecard := this.GetString("medicalInsuranceCard")
747
+
748
+	name := this.GetString("name")
749
+	register, _ := this.GetInt64("register")
750
+	registrationfee, _ := this.GetInt64("registrationFee")
751
+	registrationfees := strconv.FormatInt(registrationfee, 10)
752
+	registrationfees_float, _ := strconv.ParseFloat(registrationfees, 64)
753
+	settlementValue, _ := this.GetInt64("settlementValue")
754
+	sex, _ := this.GetInt64("sex")
755
+	total, _ := this.GetInt64("total")
756
+	totals := strconv.FormatInt(total, 10)
757
+	totals_float, _ := strconv.ParseFloat(totals, 64)
758
+	adminUserInfo := this.GetAdminUserInfo()
759
+	orgId := adminUserInfo.CurrentOrgId
760
+	timeStr := time.Now().Format("2006-01-02")
761
+	fmt.Println("timeStr:", timeStr)
762
+	timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
763
+
764
+	bloodPatient, errcode := service.GetBloodPatientByIdCard(idcard, orgId)
765
+	if errcode == gorm.ErrRecordNotFound {
766
+		patient := models.XtHisPatient{
767
+			Age:                    age,
768
+			Birthday:               birthUnix,
769
+			IdType:                 certificates,
770
+			CostOfProduction:       cost_float,
771
+			Departments:            department,
772
+			AdminUserId:            doctor,
773
+			MedicalTreatmentType:   medicalcare,
774
+			IdCardNo:               idcard,
775
+			IsNeedCostOfProduction: cost_checked,
776
+			TreatmentCost:          medicalExpense_float,
777
+			MedicalInsuranceNumber: medicalinsurancecard,
778
+			Name:                   name,
779
+			RegisterType:           register,
780
+			RegisterCost:           registrationfees_float,
781
+			BalanceAccountsType:    settlementValue,
782
+			Gender:                 sex,
783
+			Total:                  totals_float,
784
+			UserOrgId:              orgId,
785
+			Status:                 1,
786
+			RecordDate:             timeStringToTime.Unix(),
787
+		}
788
+		err := service.CreateHisPatient(&patient)
789
+		if err != nil {
790
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
791
+			return
792
+		}
793
+		this.ServeSuccessJSON(map[string]interface{}{
794
+			"patient": patient,
795
+		})
796
+	} else if errcode == nil {
797
+		patient := models.XtHisPatient{
798
+			Age:                    age,
799
+			Birthday:               birthUnix,
800
+			IdType:                 certificates,
801
+			CostOfProduction:       cost_float,
802
+			Departments:            department,
803
+			AdminUserId:            doctor,
804
+			MedicalTreatmentType:   medicalcare,
805
+			IdCardNo:               idcard,
806
+			IsNeedCostOfProduction: cost_checked,
807
+			TreatmentCost:          medicalExpense_float,
808
+			MedicalInsuranceNumber: medicalinsurancecard,
809
+			Name:                   name,
810
+			RegisterType:           register,
811
+			RegisterCost:           registrationfees_float,
812
+			BalanceAccountsType:    settlementValue,
813
+			Gender:                 sex,
814
+			Total:                  totals_float,
815
+			UserOrgId:              orgId,
816
+			PatientId:              bloodPatient.ID,
817
+		}
818
+		err := service.CreateHisPatient(&patient)
819
+		if err != nil {
820
+			this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
821
+			return
822
+		}
823
+		this.ServeSuccessJSON(map[string]interface{}{
824
+			"patient": patient,
825
+		})
826
+	}
827
+}
828
+
829
+func (this *HisProjectApiController) GetAllProjectTeam() {
830
+
831
+	adminUserInfo := this.GetAdminUserInfo()
832
+	orgId := adminUserInfo.CurrentOrgId
833
+	fmt.Println("aaa")
834
+	team, err := service.GetAllProjectTeam(orgId)
835
+	if err != nil {
836
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
837
+		return
838
+	}
839
+	this.ServeSuccessJSON(map[string]interface{}{
840
+		"team": team,
841
+	})
842
+}
843
+
844
+func (this *HisProjectApiController) GetProjectListById() {
845
+
846
+	adminUserInfo := this.GetAdminUserInfo()
847
+	orgId := adminUserInfo.CurrentOrgId
848
+	project_id := this.GetString("project_id")
849
+	idStrs := strings.Split(project_id, ",")
850
+	project, err := service.GetProjectListById(orgId, idStrs)
851
+	if err != nil {
852
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
853
+		return
854
+	}
855
+	this.ServeSuccessJSON(map[string]interface{}{
856
+		"project": project,
857
+	})
858
+}
859
+
860
+func (this *HisProjectApiController) GetHisPatientHistory() {
861
+	timeLayout := "2006-01-02"
862
+	loc, _ := time.LoadLocation("Local")
863
+	keyword := this.GetString("keyword")
864
+	start_time := this.GetString("start_time")
865
+	end_time := this.GetString("end_time")
866
+	register_type, _ := this.GetInt64("register_type")
867
+	limit, _ := this.GetInt64("limit")
868
+	page, _ := this.GetInt64("page")
869
+	fmt.Println(keyword, start_time, end_time, register_type, limit, page)
870
+	startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
871
+	endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
872
+	adminUserInfo := this.GetAdminUserInfo()
873
+	orgId := adminUserInfo.CurrentOrgId
874
+	history, total, err := service.GetHisPatientHistory(keyword, startTime.Unix(), endTime.Unix(), register_type, limit, page, orgId)
875
+	department, err := service.GetAllDepartMent(orgId)
876
+	if err != nil {
877
+		this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
878
+		return
879
+	}
880
+	this.ServeSuccessJSON(map[string]interface{}{
881
+		"history":    history,
882
+		"total":      total,
883
+		"department": department,
884
+	})
885
+}

+ 120 - 53
controllers/manager_center_api_controller.go Näytä tiedosto

@@ -8,6 +8,7 @@ import (
8 8
 	"encoding/json"
9 9
 	"fmt"
10 10
 	"github.com/astaxie/beego"
11
+	"github.com/jinzhu/gorm"
11 12
 	"reflect"
12 13
 	"strconv"
13 14
 	"time"
@@ -295,73 +296,139 @@ func (c *ManagerCenterApiController) EditBaseDrugLib() {
295 296
 
296 297
 	err := service.UpdateBaseDrugLib(drugLib)
297 298
 
298
-	//修改xt_drug_name 表
299
-	drugName := models.XtDrugName{
300
-		DrugName: drug_name,
299
+	//查询是否存在
300
+	_, errOne := service.GetDrugNameIsExist(id, adminInfo.CurrentOrgId)
301
+	if errOne == gorm.ErrRecordNotFound {
302
+		fmt.Println("进来了吗")
303
+		c.ServeSuccessJSON(map[string]interface{}{
304
+			"msg": "修改成功",
305
+		})
306
+		return
307
+	} else if errOne == nil {
308
+		//修改xt_drug_name 表
309
+		drugName := models.XtDrugName{
310
+			DrugName: drug_name,
311
+		}
312
+		service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
301 313
 	}
302
-	service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
303 314
 
304
-	//修改规格xt_stand_name表
305
-	standName := models.XtStandName{
306
-		DrugName:       drug_name,
307
-		DrugSpec:       drug_spec,
308
-		DrugStockLimit: drug_stock_limit,
309
-		MinUnit:        min_unit,
310
-	}
315
+	//查询是否存在
316
+	_, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
317
+	if errTwo == gorm.ErrRecordNotFound {
318
+		fmt.Println("进来了吗1")
319
+		c.ServeSuccessJSON(map[string]interface{}{
320
+			"msg": "修改成功",
321
+		})
322
+		return
323
+	} else if errTwo == nil {
324
+		//修改规格xt_stand_name表
325
+		standName := models.XtStandName{
326
+			DrugName:       drug_name,
327
+			DrugSpec:       drug_spec,
328
+			DrugStockLimit: drug_stock_limit,
329
+			MinUnit:        min_unit,
330
+		}
311 331
 
312
-	service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
313
-	//修改药品表
314
-	medical := models.XtSelfMedical{
315
-		DrugName:           drug_name,
316
-		DrugSpec:           drug_spec,
317
-		ExecutionFrequency: execution_frequency,
318
-		PrescribingNumber:  prescribing_number,
319
-		DeliveryWay:        delivery_way,
320
-		SingleDose:         single_dose,
321
-		MinUnit:            min_unit,
332
+		service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
322 333
 	}
323 334
 
324
-	service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
335
+	_, errThree := service.GetSelfMedicalIsExist(id, adminInfo.CurrentOrgId)
336
+
337
+	if errThree == gorm.ErrRecordNotFound {
338
+		fmt.Println("进来了吗2")
339
+		c.ServeSuccessJSON(map[string]interface{}{
340
+			"msg": "修改成功",
341
+		})
342
+		return
343
+	} else if errThree == nil {
344
+		//修改药品表
345
+		medical := models.XtSelfMedical{
346
+			DrugName:           drug_name,
347
+			DrugSpec:           drug_spec,
348
+			ExecutionFrequency: execution_frequency,
349
+			PrescribingNumber:  prescribing_number,
350
+			DeliveryWay:        delivery_way,
351
+			SingleDose:         single_dose,
352
+			MinUnit:            min_unit,
353
+		}
325 354
 
326
-	//修改入库表
327
-	//nameId, err := service.GetDrugNameId(id, adminInfo.CurrentOrgId)
355
+		service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
356
+	}
328 357
 
329
-	stock := models.XtSelfStock{
330
-		DrugSpec: drug_spec,
331
-		DrugName: drug_name,
332
-		MinUnit:  min_unit,
358
+	_, errFour := service.GetSelfStosckIsExist(id, adminInfo.CurrentOrgId)
359
+	if errFour == gorm.ErrRecordNotFound {
360
+		fmt.Println("进来了吗3")
361
+		c.ServeSuccessJSON(map[string]interface{}{
362
+			"msg": "修改成功",
363
+		})
364
+		return
365
+	} else if errFour == nil {
366
+		stock := models.XtSelfStock{
367
+			DrugSpec: drug_spec,
368
+			DrugName: drug_name,
369
+			MinUnit:  min_unit,
370
+		}
371
+		service.UpdatedSelfStock(&stock, id, adminInfo.CurrentOrgId)
333 372
 	}
334 373
 
335
-	service.UpdatedSelfStock(&stock, id, adminInfo.CurrentOrgId)
336
-	outStock := models.XtSelfOutStock{
337
-		DrugName: drug_name,
338
-		DrugSpec: drug_spec,
374
+	_, errFive := service.GetOutSelfOutStockIsExist(id, adminInfo.CurrentOrgId)
375
+	if errFive == gorm.ErrRecordNotFound {
376
+		fmt.Println("进来了吗4")
377
+		c.ServeSuccessJSON(map[string]interface{}{
378
+			"msg": "修改成功",
379
+		})
380
+		return
381
+	} else if errFive == nil {
382
+		outStock := models.XtSelfOutStock{
383
+			DrugName: drug_name,
384
+			DrugSpec: drug_spec,
385
+		}
386
+		//修改出库表
387
+		service.UpdatedOutSelfStock(&outStock, id, adminInfo.CurrentOrgId)
339 388
 	}
340
-	//修改出库表
341
-	service.UpdatedOutSelfStock(&outStock, id, adminInfo.CurrentOrgId)
342 389
 
343
-	//查询未执行的医嘱
344
-	advice := models.DoctorAdvice{
345
-		AdviceName:         drug_name,
346
-		AdviceDesc:         drug_spec,
347
-		DeliveryWay:        delivery_way,
348
-		ExecutionFrequency: execution_frequency,
349
-		SingleDose:         single_dose,
350
-		SingleDoseUnit:     min_unit,
390
+	_, errSix := service.GetDoctorAdviceIsExist(id, adminInfo.CurrentOrgId)
391
+	if errSix == gorm.ErrRecordNotFound {
392
+		fmt.Println("进来了吗5")
393
+		c.ServeSuccessJSON(map[string]interface{}{
394
+			"msg": "修改成功",
395
+		})
396
+		return
397
+	} else if errSix == nil {
398
+		//查询未执行的医嘱
399
+		advice := models.DoctorAdvice{
400
+			AdviceName:         drug_name,
401
+			AdviceDesc:         drug_spec,
402
+			DeliveryWay:        delivery_way,
403
+			ExecutionFrequency: execution_frequency,
404
+			SingleDose:         single_dose,
405
+			SingleDoseUnit:     min_unit,
406
+		}
407
+
408
+		service.UpdateNoExcuteDoctorAdvice(id, adminInfo.CurrentOrgId, &advice)
351 409
 	}
352 410
 
353
-	service.UpdateNoExcuteDoctorAdvice(id, adminInfo.CurrentOrgId, &advice)
411
+	_, errSeven := service.GetDoctorAdviceTemplateIsExist(id, adminInfo.CurrentOrgId)
412
+
413
+	if errSeven == gorm.ErrRecordNotFound {
414
+		fmt.Println("进来了吗6")
415
+		c.ServeSuccessJSON(map[string]interface{}{
416
+			"msg": "修改成功",
417
+		})
418
+		return
419
+	} else if errSeven == nil {
420
+		//修改医嘱模板
421
+		template := models.DoctorAdviceTemplate{
422
+			AdviceName:         drug_name,
423
+			AdviceDesc:         drug_spec,
424
+			DeliveryWay:        delivery_way,
425
+			ExecutionFrequency: execution_frequency,
426
+			SingleDose:         single_dose,
427
+			SingleDoseUnit:     min_unit,
428
+		}
429
+		service.UpdatedDoctorAdviceTemplate(id, adminInfo.CurrentOrgId, &template)
354 430
 
355
-	//修改医嘱模板
356
-	template := models.DoctorAdviceTemplate{
357
-		AdviceName:         drug_name,
358
-		AdviceDesc:         drug_spec,
359
-		DeliveryWay:        delivery_way,
360
-		ExecutionFrequency: execution_frequency,
361
-		SingleDose:         single_dose,
362
-		SingleDoseUnit:     min_unit,
363 431
 	}
364
-	service.UpdatedDoctorAdviceTemplate(id, adminInfo.CurrentOrgId, &template)
365 432
 
366 433
 	if err == nil {
367 434
 		c.ServeSuccessJSON(map[string]interface{}{
@@ -1322,7 +1389,7 @@ func (c *ManagerCenterApiController) CreateGoodInfo() {
1322 1389
 
1323 1390
 	adminUserInfo := c.GetAdminUserInfo()
1324 1391
 
1325
-	totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId)
1392
+	totals := service.FindGoodInfoByName(specification_name, adminUserInfo.CurrentOrgId, good_id)
1326 1393
 	if totals > 0 {
1327 1394
 		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
1328 1395
 		return

+ 103 - 109
controllers/mobile_api_controllers/check_weight_api_controller.go Näytä tiedosto

@@ -4,15 +4,15 @@ import (
4 4
 	"XT_New/enums"
5 5
 	"XT_New/models"
6 6
 	"XT_New/service"
7
-	"github.com/astaxie/beego"
8
-	"net/http"
9
-	"net/url"
10
-	"strconv"
11 7
 	_ "XT_New/utils"
12 8
 	_ "encoding/json"
13 9
 	"fmt"
10
+	"github.com/astaxie/beego"
14 11
 	_ "github.com/astaxie/beego"
15 12
 	"github.com/jinzhu/gorm"
13
+	"net/http"
14
+	"net/url"
15
+	"strconv"
16 16
 	_ "strings"
17 17
 
18 18
 	// "fmt"
@@ -67,106 +67,106 @@ func (c *CheckWeightApiController) SaveBloodPressure() {
67 67
 	if dialysistype == 1 {
68 68
 		// 保存透前相关数据
69 69
 		// 获取透析处方
70
-		dialysisPrescribe, getDialysisPrescribeErr := service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
71
-		if getDialysisPrescribeErr != nil {
72
-			c.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
73
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
74
-			return
75
-		}
76
-
77
-		// 获取透析模版
78
-		dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
79
-		if getDialysisSolutionErr != nil {
80
-			c.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
81
-			c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
82
-			return
83
-		}
70
+		//dialysisPrescribe, getDialysisPrescribeErr := service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
71
+		//if getDialysisPrescribeErr != nil {
72
+		//	c.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
73
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
74
+		//	return
75
+		//}
76
+		//
77
+		//// 获取透析模版
78
+		//dialysisSolution, getDialysisSolutionErr := service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
79
+		//if getDialysisSolutionErr != nil {
80
+		//	c.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
81
+		//	c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
82
+		//	return
83
+		//}
84 84
 
85 85
 		// 插入透析处方
86
-		if dialysisPrescribe == nil && dialysisSolution != nil {
87
-			var newprescribe models.DialysisPrescription
88
-			newprescribe.UserOrgId = dialysisSolution.UserOrgId
89
-			newprescribe.PatientId = dialysisSolution.PatientId
90
-			newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
91
-			newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
92
-			newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
93
-			newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
94
-			newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
95
-			newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
96
-			newprescribe.ModeId = dialysisSolution.ModeId
97
-			newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
98
-			newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
99
-			newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
100
-			newprescribe.BloodFilter = dialysisSolution.BloodFilter
101
-			newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
102
-			newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
103
-			newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
104
-			newprescribe.Glucose = dialysisSolution.Glucose
105
-			newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
106
-			newprescribe.Kalium = dialysisSolution.Kalium
107
-			newprescribe.Sodium = dialysisSolution.Sodium
108
-			newprescribe.Calcium = dialysisSolution.Calcium
109
-			newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
110
-			newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
111
-			newprescribe.Conductivity = dialysisSolution.Conductivity
112
-			newprescribe.BodyFluid = dialysisSolution.BodyFluid
113
-			newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
114
-			newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
115
-			newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
116
-			newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
117
-			newprescribe.BloodAccess = dialysisSolution.BloodAccess
118
-			newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
119
-			newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
120
-			newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
121
-			newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
122
-			newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
123
-			newprescribe.Dialyzer = dialysisSolution.Dialyzer
124
-			newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
125
-			newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
126
-			newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
127
-			newprescribe.TargetKtv = dialysisSolution.TargetKtv
128
-
129
-			newprescribe.CreatedTime = time.Now().Unix()
130
-			newprescribe.UpdatedTime = time.Now().Unix()
131
-			newprescribe.RecordDate = theAssessmentDateTime
132
-			// newprescribe.DewaterAmount = dewater_amount
133
-			// newprescribe.TargetUltrafiltration = dewater_amount
134
-			newprescribe.Status = 1
135
-
136
-			err := service.AddSigleRecord(&newprescribe)
137
-			if err != nil {
138
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
139
-			}
140
-		}
141
-
142
-		if dialysisPrescribe == nil && dialysisSolution == nil {
143
-			var newprescribe models.DialysisPrescription
144
-			newprescribe.UserOrgId = adminUserInfo.Org.Id
145
-			newprescribe.PatientId = id
146
-			newprescribe.CreatedTime = time.Now().Unix()
147
-			newprescribe.UpdatedTime = time.Now().Unix()
148
-			newprescribe.RecordDate = theAssessmentDateTime
149
-			// newprescribe.DewaterAmount = dewater_amount
150
-			// newprescribe.TargetUltrafiltration = dewater_amount
151
-			newprescribe.Status = 1
152
-
153
-			err := service.AddSigleRecord(&newprescribe)
154
-			if err != nil {
155
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
156
-			}
157
-		}
158
-
159
-		if dialysisPrescribe != nil {
160
-			dialysisPrescribe.UpdatedTime = time.Now().Unix()
161
-			dialysisPrescribe.RecordDate = theAssessmentDateTime
162
-			// dialysisPrescribe.DewaterAmount = dewater_amount
163
-			// dialysisPrescribe.TargetUltrafiltration = dewater_amount
164
-			dialysisPrescribe.Status = 1
165
-			updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
166
-			if updateErr != nil {
167
-				c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
168
-			}
169
-		}
86
+		//if dialysisPrescribe == nil && dialysisSolution != nil {
87
+		//	var newprescribe models.DialysisPrescription
88
+		//	newprescribe.UserOrgId = dialysisSolution.UserOrgId
89
+		//	newprescribe.PatientId = dialysisSolution.PatientId
90
+		//	newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
91
+		//	newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
92
+		//	newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
93
+		//	newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
94
+		//	newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
95
+		//	newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
96
+		//	newprescribe.ModeId = dialysisSolution.ModeId
97
+		//	newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
98
+		//	newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
99
+		//	newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
100
+		//	newprescribe.BloodFilter = dialysisSolution.BloodFilter
101
+		//	newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
102
+		//	newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
103
+		//	newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
104
+		//	newprescribe.Glucose = dialysisSolution.Glucose
105
+		//	newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
106
+		//	newprescribe.Kalium = dialysisSolution.Kalium
107
+		//	newprescribe.Sodium = dialysisSolution.Sodium
108
+		//	newprescribe.Calcium = dialysisSolution.Calcium
109
+		//	newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
110
+		//	newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
111
+		//	newprescribe.Conductivity = dialysisSolution.Conductivity
112
+		//	newprescribe.BodyFluid = dialysisSolution.BodyFluid
113
+		//	newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
114
+		//	newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
115
+		//	newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
116
+		//	newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
117
+		//	newprescribe.BloodAccess = dialysisSolution.BloodAccess
118
+		//	newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
119
+		//	newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
120
+		//	newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
121
+		//	newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
122
+		//	newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
123
+		//	newprescribe.Dialyzer = dialysisSolution.Dialyzer
124
+		//	newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
125
+		//	newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
126
+		//	newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
127
+		//	newprescribe.TargetKtv = dialysisSolution.TargetKtv
128
+		//
129
+		//	newprescribe.CreatedTime = time.Now().Unix()
130
+		//	newprescribe.UpdatedTime = time.Now().Unix()
131
+		//	newprescribe.RecordDate = theAssessmentDateTime
132
+		//	// newprescribe.DewaterAmount = dewater_amount
133
+		//	// newprescribe.TargetUltrafiltration = dewater_amount
134
+		//	newprescribe.Status = 1
135
+		//
136
+		//	err := service.AddSigleRecord(&newprescribe)
137
+		//	if err != nil {
138
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
139
+		//	}
140
+		//}
141
+
142
+		//if dialysisPrescribe == nil && dialysisSolution == nil {
143
+		//	var newprescribe models.DialysisPrescription
144
+		//	newprescribe.UserOrgId = adminUserInfo.Org.Id
145
+		//	newprescribe.PatientId = id
146
+		//	newprescribe.CreatedTime = time.Now().Unix()
147
+		//	newprescribe.UpdatedTime = time.Now().Unix()
148
+		//	newprescribe.RecordDate = theAssessmentDateTime
149
+		//	// newprescribe.DewaterAmount = dewater_amount
150
+		//	// newprescribe.TargetUltrafiltration = dewater_amount
151
+		//	newprescribe.Status = 1
152
+		//
153
+		//	err := service.AddSigleRecord(&newprescribe)
154
+		//	if err != nil {
155
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
156
+		//	}
157
+		//}
158
+
159
+		//if dialysisPrescribe != nil {
160
+		//	dialysisPrescribe.UpdatedTime = time.Now().Unix()
161
+		//	dialysisPrescribe.RecordDate = theAssessmentDateTime
162
+		//	// dialysisPrescribe.DewaterAmount = dewater_amount
163
+		//	// dialysisPrescribe.TargetUltrafiltration = dewater_amount
164
+		//	dialysisPrescribe.Status = 1
165
+		//	updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
166
+		//	if updateErr != nil {
167
+		//		c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
168
+		//	}
169
+		//}
170 170
 
171 171
 		theEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, theAssessmentDateTime)
172 172
 		if getPEErr != nil {
@@ -696,7 +696,6 @@ func (c *CheckWeightApiController) SavePatientInfoDialysis() {
696 696
 		}
697 697
 	}
698 698
 }
699
-
700 699
 func (c *CheckWeightApiController) GetPatientList() {
701 700
 	syncTime, _ := c.GetInt64("synctime", 0)
702 701
 	force, _ := c.GetInt64("force", 0)
@@ -714,7 +713,6 @@ func (c *CheckWeightApiController) GetPatientList() {
714 713
 		"servicetime": serviceTime,
715 714
 	})
716 715
 }
717
-
718 716
 func (c *CheckWeightApiController) GetPatientListById() {
719 717
 	patientId, _ := c.GetInt64("patient_id", 0)
720 718
 	if patientId <= 0 {
@@ -733,7 +731,6 @@ func (c *CheckWeightApiController) GetPatientListById() {
733 731
 		"patientinfo": patient,
734 732
 	})
735 733
 }
736
-
737 734
 func (c *CheckWeightApiController) GetPatientInfoDialysis() {
738 735
 	id, _ := c.GetInt64("patient", 0)
739 736
 	if id <= 0 {
@@ -801,7 +798,7 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
801 798
 
802 799
 		// 排队叫号的签到
803 800
 		ssoDomain := beego.AppConfig.String("call_domain")
804
-		api := ssoDomain + "/index/patientsign/"+strconv.FormatInt(adminUserInfo.Org.Id, 10)+"/"+strconv.FormatInt(id, 10)
801
+		api := ssoDomain + "/index/patientsign/" + strconv.FormatInt(adminUserInfo.Org.Id, 10) + "/" + strconv.FormatInt(id, 10)
805 802
 		values := make(url.Values)
806 803
 
807 804
 		http.PostForm(api, values)
@@ -968,8 +965,6 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
968 965
 		}
969 966
 	}
970 967
 
971
-
972
-
973 968
 	c.ServeSuccessJSON(map[string]interface{}{
974 969
 		"dialysistype":     dialysistype,
975 970
 		"patient":          dialysisinfo,
@@ -979,7 +974,6 @@ func (c *CheckWeightApiController) GetPatientInfoDialysis() {
979 974
 	})
980 975
 	return
981 976
 }
982
-
983 977
 func (c *CheckWeightApiController) GetPatientInfoBeforeDialysis() {
984 978
 	id, _ := c.GetInt64("patient", 0)
985 979
 	if id <= 0 {

+ 22 - 10
controllers/mobile_api_controllers/dialysis_api_controller.go Näytä tiedosto

@@ -2350,25 +2350,25 @@ func (c *DialysisAPIController) GetLongAdvice() {
2350 2350
 			if advice.FrequencyType == 3 {
2351 2351
 				t := time.Now()
2352 2352
 				week := int(t.Weekday())
2353
+				fmt.Println(t.Weekday())
2354
+
2355
+				fmt.Println(week)
2353 2356
 
2354 2357
 				switch week {
2355 2358
 				case 1:
2356 2359
 					if strings.Index(advice.WeekDay, "周一") == -1 {
2357 2360
 						advice_three = append(advice_three, advice)
2358 2361
 					}
2359
-
2360 2362
 					break
2361 2363
 				case 2:
2362 2364
 					if strings.Index(advice.WeekDay, "周二") == -1 {
2363 2365
 						advice_three = append(advice_three, advice)
2364 2366
 					}
2365
-
2366 2367
 					break
2367 2368
 				case 3:
2368 2369
 					if strings.Index(advice.WeekDay, "周三") == -1 {
2369 2370
 						advice_three = append(advice_three, advice)
2370 2371
 					}
2371
-
2372 2372
 					break
2373 2373
 				case 4:
2374 2374
 					if strings.Index(advice.WeekDay, "周四") == -1 {
@@ -2384,7 +2384,6 @@ func (c *DialysisAPIController) GetLongAdvice() {
2384 2384
 					if strings.Index(advice.WeekDay, "周六") == -1 {
2385 2385
 						advice_three = append(advice_three, advice)
2386 2386
 					}
2387
-
2388 2387
 					break
2389 2388
 				case 0:
2390 2389
 					if strings.Index(advice.WeekDay, "周日") == -1 {
@@ -3581,17 +3580,13 @@ func (c *DialysisAPIController) EditConsumables() {
3581 3580
 					for _, before := range beforePrepares {
3582 3581
 
3583 3582
 						if consumable.GoodId == before.GoodId {
3584
-							fmt.Println(consumable.Count)
3585
-							fmt.Println(before.Count)
3586 3583
 
3587 3584
 							if consumable.Count != before.Count {
3588
-								fmt.Println("111111111")
3589 3585
 								_, out := service.FindStockOutOrderNumberByTime(record_time, adminInfo.Org.Id)
3590 3586
 								//_, out := service.FindOldOrderInfoByGoodId(record_time, adminInfo.Org.Id)
3591 3587
 								//判断前端更改后的商品id的出库记录在数据库中是否存在
3592 3588
 								err, newOut := service.FindOrderInfoByGoodId(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id)
3593 3589
 								if err == gorm.ErrRecordNotFound { //不存在,则新增出库记录,并更改使用人商品信息
3594
-									fmt.Println("222222222")
3595 3590
 
3596 3591
 									warehouseOutInfo := &models.WarehouseOutInfo{
3597 3592
 										WarehouseOutOrderNumber: out.WarehouseOutOrderNumber,
@@ -3614,7 +3609,7 @@ func (c *DialysisAPIController) EditConsumables() {
3614 3609
 									err := service.AddSigleWarehouseOutInfo(warehouseOutInfo)
3615 3610
 									if err == nil {
3616 3611
 										//可能存在商品使用人不存在的情况,需要先判断商品使用人是否存在
3617
-										user, err := service.FindGoodUserById(before.GoodTypeId, before.GoodId, patient_id, adminInfo.Org.Id, out.WarehouseOutOrderNumber)
3612
+										user, err := service.FindGoodUserById(before.GoodTypeId, before.GoodId, patient_id, adminInfo.Org.Id, record_time)
3618 3613
 										if err == gorm.ErrRecordNotFound {
3619 3614
 											details := &models.AutomaticReduceDetail{
3620 3615
 												WarehouseOutId:          warehouseOutInfo.ID,
@@ -3655,7 +3650,7 @@ func (c *DialysisAPIController) EditConsumables() {
3655 3650
 										} else if consumable.Count < before.Count { //增加
3656 3651
 											service.UpdateOrderCountAdd(consumable.GoodTypeId, consumable.GoodId, out.WarehouseOutOrderNumber, adminInfo.Org.Id, before.Count-consumable.Count)
3657 3652
 										}
3658
-										user, err := service.FindGoodUserById(consumable.GoodTypeId, consumable.GoodId, patient_id, adminInfo.Org.Id, out.WarehouseOutOrderNumber)
3653
+										user, err := service.FindGoodUserById(consumable.GoodTypeId, consumable.GoodId, patient_id, adminInfo.Org.Id, record_time)
3659 3654
 										if err == gorm.ErrRecordNotFound {
3660 3655
 											details := &models.AutomaticReduceDetail{
3661 3656
 												WarehouseOutId:          newOut.ID,
@@ -4267,3 +4262,20 @@ func (c *DialysisAPIController) GetAllDrug() {
4267 4262
 	})
4268 4263
 
4269 4264
 }
4265
+
4266
+func RemoveRepeatedGoodTwo(arr []*models.DialysisBeforePrepare) (newArr []*models.DialysisBeforePrepare) {
4267
+	newArr = make([]*models.DialysisBeforePrepare, 0)
4268
+	for i := 0; i < len(arr); i++ {
4269
+		repeat := false
4270
+		for j := i + 1; j < len(arr); j++ {
4271
+			if arr[i].GoodId == arr[j].GoodId {
4272
+				repeat = true
4273
+				break
4274
+			}
4275
+		}
4276
+		if !repeat {
4277
+			newArr = append(newArr, arr[i])
4278
+		}
4279
+	}
4280
+	return
4281
+}

+ 15 - 18
controllers/mobile_api_controllers/patient_api_controller.go Näytä tiedosto

@@ -552,11 +552,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
552 552
 	//}
553 553
 
554 554
 	var advice models.DoctorAdvice
555
-	var tempAdvices []models.DoctorAdvice
556 555
 
557 556
 	if groupno > 0 {
558
-		advices, _ := service.FindAllDoctorAdviceByGoroupNoTwo(adminUserInfo.Org.Id, groupno)
559
-		tempAdvices = advices
557
+		advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
560 558
 		for _, item := range advices {
561 559
 			if item.ExecutionState == 2 {
562 560
 				advice = item
@@ -564,9 +562,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
564 562
 			}
565 563
 		}
566 564
 	} else {
567
-		advices, _ := service.FindDoctorAdviceByIdsTwo(adminUserInfo.Org.Id, ids)
568
-		tempAdvices = advices
569
-
565
+		advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
570 566
 		for _, item := range advices {
571 567
 			if item.ExecutionState == 2 {
572 568
 				advice = item
@@ -626,10 +622,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
626 622
 
627 623
 	if drugStockConfig.IsOpen == 1 {
628 624
 		if groupno > 0 {
629
-			//advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
625
+			advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
630 626
 			isHasWay := false //用来判断是否包含来自药品库的医嘱
631 627
 			record_time := int64(0)
632
-			for _, item := range tempAdvices {
628
+			for _, item := range advices {
633 629
 				if item.Way == 1 {
634 630
 					isHasWay = true
635 631
 					record_time = item.RecordDate
@@ -666,7 +662,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
666 662
 					if err != nil {
667 663
 						utils.TraceLog("创建出库单失败 err = %v", err)
668 664
 					} else {
669
-						for _, item := range tempAdvices {
665
+						for _, item := range advices {
670 666
 							if item.Way == 1 {
671 667
 								if item.PrescribingNumber > 0 {
672 668
 									warehouseOutInfo := &models.DrugWarehouseOutInfo{
@@ -711,7 +707,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
711 707
 					}
712 708
 
713 709
 				} else if err == nil {
714
-					for _, item := range tempAdvices {
710
+					for _, item := range advices {
715 711
 						if item.Way == 1 {
716 712
 							outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
717 713
 							if err == gorm.ErrRecordNotFound {
@@ -785,10 +781,10 @@ func (c *PatientApiController) ExecDoctorAdvice() {
785 781
 
786 782
 			}
787 783
 		} else {
788
-			//advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
784
+			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
789 785
 			isHasWay := false //用来判断是否包含来自药品库的医嘱
790 786
 			record_time := int64(0)
791
-			for _, item := range tempAdvices {
787
+			for _, item := range advices {
792 788
 				if item.Way == 1 {
793 789
 					isHasWay = true
794 790
 					record_time = item.RecordDate
@@ -825,7 +821,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
825 821
 					if err != nil {
826 822
 						utils.TraceLog("创建出库单失败 err = %v", err)
827 823
 					} else {
828
-						for _, item := range tempAdvices {
824
+						for _, item := range advices {
829 825
 							if item.Way == 1 {
830 826
 								if item.PrescribingNumber > 0 {
831 827
 									warehouseOutInfo := &models.DrugWarehouseOutInfo{
@@ -870,7 +866,7 @@ func (c *PatientApiController) ExecDoctorAdvice() {
870 866
 					}
871 867
 
872 868
 				} else if err == nil {
873
-					for _, item := range tempAdvices {
869
+					for _, item := range advices {
874 870
 						if item.Way == 1 {
875 871
 							outInfo, err := service.FindDrugStockOutInfoByTypeId(adminUserInfo.Org.Id, item.DrugId, out.ID, out.WarehouseOutOrderNumber)
876 872
 							if err == gorm.ErrRecordNotFound {
@@ -954,8 +950,8 @@ func (c *PatientApiController) ExecDoctorAdvice() {
954 950
 
955 951
 	if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
956 952
 		if groupno > 0 {
957
-			//advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
958
-			for _, item := range tempAdvices {
953
+			advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
954
+			for _, item := range advices {
959 955
 
960 956
 				if item.ExecutionState == 1 && item.Way == 2 {
961 957
 					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
@@ -991,7 +987,9 @@ func (c *PatientApiController) ExecDoctorAdvice() {
991 987
 			}
992 988
 		} else {
993 989
 
994
-			for _, item := range tempAdvices {
990
+			advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
991
+			for _, item := range advices {
992
+				fmt.Println("item222222222222", item.ExecutionState)
995 993
 				if item.ExecutionState == 1 && item.Way == 2 {
996 994
 
997 995
 					prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
@@ -2792,7 +2790,6 @@ func (c *PatientApiController) GetPrintDialysisOrder() {
2792 2790
 
2793 2791
 func (c *PatientApiController) CreateGroupAdvice() {
2794 2792
 	is_child, _ := c.GetInt64("is_child", 0)
2795
-	fmt.Println("is_child------------------------------", is_child)
2796 2793
 	if is_child == 1 {
2797 2794
 		patient, _ := c.GetInt64("id", 0)
2798 2795
 		if patient <= 0 {

+ 6 - 5
controllers/new_mobile_api_controllers/dialysis_parameter_api_controller.go Näytä tiedosto

@@ -42,6 +42,7 @@ func (this *DialysisParamerterApiController) GetMobileDialysisParameters() {
42 42
 	fmt.Println("partiontype", partitionType)
43 43
 	scheduleType, _ := this.GetInt64("scheduleType")
44 44
 	fmt.Println(scheduleType)
45
+
45 46
 	theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
46 47
 	if len(keywords) > 0 {
47 48
 
@@ -151,7 +152,7 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
151 152
 	orgId := this.GetMobileAdminUserInfo().Org.Id
152 153
 	keyword := this.GetString("keyword")
153 154
 	//获取透析参数数据
154
-	schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
155
+	//schedule, err, _ := service.GetCollectList(limit, page, partitiontype, scheduletype, startime.Unix(), orgId, keyword)
155 156
 	//查询今日排班的病人
156 157
 	patient, err := service.GetDialysisTodaySchedulePatient(orgId, startime.Unix(), page, limit, keyword)
157 158
 	var vlist []interface{}
@@ -176,9 +177,9 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
176 177
 			"dialysis_goods": dialysisGoods,
177 178
 			"good_type":      goodTypes,
178 179
 			"total":          total,
179
-			"schedule":       schedule,
180
-			"prescription":   vlist,
181
-			"patient":        patient,
180
+			//"schedule":       schedule,
181
+			"prescription": vlist,
182
+			"patient":      patient,
182 183
 		})
183 184
 		return
184 185
 
@@ -200,7 +201,7 @@ func (this *DialysisParamerterApiController) GetMobileCollectList() {
200 201
 				"dialysis_goods": dialysisGoods,
201 202
 				"good_type":      goodTypes,
202 203
 				"total":          total,
203
-				"schedule":       schedule,
204
+				//"schedule":       schedule,
204 205
 				//"consumables":    consumables,
205 206
 				"prescription": vlist,
206 207
 				"reducelist":   clist,

+ 5 - 2
controllers/schedule_api_controller.go Näytä tiedosto

@@ -689,8 +689,10 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
689 689
 		for index := weekStart1; index <= weekEnd1; index++ {
690 690
 			theDay := thisTime1.AddDate(0, 0, index)
691 691
 			days = append(days, theDay.Format("2006-01-02"))
692
-			if index == 0 {
692
+
693
+			if index == -1 {
693 694
 				start_time = theDay.Format("2006-01-02")
695
+				fmt.Println(start_time)
694 696
 			}
695 697
 
696 698
 			end_time = theDay.Format("2006-01-02")
@@ -729,7 +731,7 @@ func (this *ScheduleApiController) SearchSchedulePatients() {
729 731
 		for index := weekStart2; index <= weekEnd2; index++ {
730 732
 			theDay := thisTime2.AddDate(0, 0, index)
731 733
 			days = append(days, theDay.Format("2006-01-02"))
732
-			if index == 0 {
734
+			if index == -1 {
733 735
 				start_time = theDay.Format("2006-01-02")
734 736
 			}
735 737
 
@@ -1277,6 +1279,7 @@ func (this *ScheduleApiController) ExportSchedule() {
1277 1279
 				date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
1278 1280
 				sch.ScheduleDate = date.Unix()
1279 1281
 			}
1282
+
1280 1283
 			sch.CreatedTime = time.Now().Unix()
1281 1284
 			sch.UpdatedTime = time.Now().Unix()
1282 1285
 			sch.ModeId = 1

+ 496 - 0
models/his_models.go Näytä tiedosto

@@ -0,0 +1,496 @@
1
+package models
2
+
3
+type XtHisProject struct {
4
+	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
5
+	ProjectName               string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
6
+	Pinyin                    string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
7
+	Wubi                      string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
8
+	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
9
+	Unit                      string  `gorm:"column:unit" json:"unit" form:"unit"`
10
+	CostClassify              int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
11
+	ExecutiveSection          int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
12
+	MedicalCoverage           int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
13
+	StatisticalClassification int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
14
+	DiseaseDirectory          int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
15
+	IsRecord                  int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
16
+	MedicalCode               string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
17
+	TubeColor                 int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
18
+	MedicalStatus             int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
19
+	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
20
+	Sign                      int64   `gorm:"column:sign" json:"sign" form:"sign"`
21
+	DefaultNumber             string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
22
+	IsDefault                 int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
23
+	IsCharge                  int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
24
+	IsEstimate                int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
25
+	IsWorkload                int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
26
+	Sort                      string  `gorm:"column:sort" json:"sort" form:"sort"`
27
+	DoctorAdvice              int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
28
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
29
+	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
30
+	CreatedTime               int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
31
+	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
32
+	SingleDose                string  `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
33
+	ExecutionFrequency        string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
34
+	DeliveryWay               string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
35
+	NumberDays                string  `gorm:"column:number_days" json:"number_days" form:"number_days"`
36
+	Total                     string  `gorm:"column:total" json:"total" form:"total"`
37
+}
38
+
39
+func (XtHisProject) TableName() string {
40
+	return "xt_his_project"
41
+}
42
+
43
+type XtHisProjectTeam struct {
44
+	ID          int64   `gorm:"column:id" json:"id" form:"id"`
45
+	ProjectTeam string  `gorm:"column:project_team" json:"project_team" form:"project_team"`
46
+	Price       float64 `gorm:"column:price" json:"price" form:"price"`
47
+	Pinyin      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
48
+	Wubi        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
49
+	TubeColor   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
50
+	TeamType    int64   `gorm:"column:team_type" json:"team_type" form:"team_type"`
51
+	Remark      string  `gorm:"column:remark" json:"remark" form:"remark"`
52
+	UserOrgId   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
53
+	Status      int64   `gorm:"column:status" json:"status" form:"status"`
54
+	CreatedTime int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
55
+	UpdatedTime int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
56
+	ProjectId   string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
57
+}
58
+
59
+func (XtHisProjectTeam) TableName() string {
60
+	return "xt_his_project_team"
61
+}
62
+
63
+type XtHisDepartment struct {
64
+	ID          int64  `gorm:"column:id" json:"id" form:"id"`
65
+	Name        string `gorm:"column:name" json:"name" form:"name"`
66
+	Number      string `gorm:"column:number" json:"number" form:"number"`
67
+	UserOrgId   int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
68
+	Status      int64  `gorm:"column:status" json:"status" form:"status"`
69
+	CreatedTime int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
70
+	UpdatedTime int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
71
+}
72
+
73
+func (XtHisDepartment) TableName() string {
74
+	return "xt_his_department"
75
+}
76
+
77
+type HisPatient struct {
78
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
79
+	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
80
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
81
+	Name                   string  `gorm:"column:name" json:"name" form:"name"`
82
+	Gender                 int64   `gorm:"column:gender" json:"gender" form:"gender"`
83
+	IdType                 int64   `gorm:"column:id_type" json:"id_type" form:"id_type"`
84
+	Birthday               int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
85
+	RecordDate             int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
86
+	Age                    int64   `gorm:"column:age" json:"age" form:"age"`
87
+	PhoneNumber            string  `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
88
+	IdNumber               string  `gorm:"column:id_number" json:"id_number" form:"id_number"`
89
+	RegisterType           int64   `gorm:"column:register_type" json:"register_type" form:"register_type"`
90
+	Doctor                 int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
91
+	Departments            int64   `gorm:"column:departments" json:"departments" form:"departments"`
92
+	IsNeedCostOfProduction int64   `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
93
+	RegisterCost           float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
94
+	TreatmentCost          float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
95
+	CostOfProduction       float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
96
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
97
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
98
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
99
+	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
100
+	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
101
+}
102
+
103
+func (HisPatient) TableName() string {
104
+	return "his_patient"
105
+}
106
+
107
+type HisPrescriptionVm struct {
108
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
109
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
110
+	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
111
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
112
+	HisPatientId int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
113
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
114
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
115
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
116
+	Number       string `gorm:"column:number" json:"number" form:"number"`
117
+	Type         int64  `gorm:"column:type" json:"type" form:"type"`
118
+	Doctor       int64  `gorm:"column:doctor" json:"doctor" form:"doctor"`
119
+	Creator      int64  `gorm:"column:creator" json:"creator" form:"creator"`
120
+	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
121
+	Name         string
122
+}
123
+
124
+type HisCaseHistoryTemplate struct {
125
+	ID                      int64  `gorm:"column:id" json:"id" form:"id"`
126
+	HistoryOfPresentIllness string `gorm:"column:history_of_present_illness" json:"history_of_present_illness" form:"history_of_present_illness"`
127
+	PastHistory             string `gorm:"column:past_history" json:"past_history" form:"past_history"`
128
+	ChiefConplaint          string `gorm:"column:chief_conplaint" json:"chief_conplaint" form:"chief_conplaint"`
129
+	PersonalHistory         string `gorm:"column:personal_history" json:"personal_history" form:"personal_history"`
130
+	FamilyHistory           string `gorm:"column:family_history" json:"family_history" form:"family_history"`
131
+	Diagnostic              string `gorm:"column:diagnostic" json:"diagnostic" form:"diagnostic"`
132
+	UserOrgId               int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
133
+	Status                  int64  `gorm:"column:status" json:"status" form:"status"`
134
+	Ctime                   int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
135
+	Mtime                   int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
136
+	RecordDate              int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
137
+	TemplateName            string `gorm:"column:template_name" json:"template_name" form:"template_name"`
138
+	TemplateRemark          string `gorm:"column:template_remark" json:"template_remark" form:"template_remark"`
139
+	Creator                 int64  `gorm:"column:creator" json:"creator" form:"creator"`
140
+	Modifier                int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
141
+}
142
+
143
+func (HisCaseHistoryTemplate) TableName() string {
144
+	return "his_patient"
145
+}
146
+
147
+type HisDoctorAdviceInfo struct {
148
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
149
+	UserOrgId             int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
150
+	PatientId             int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
151
+	HisPatientId          int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
152
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
153
+	AdviceDate            int64   `gorm:"column:advice_date" json:"advice_date" form:"advice_date"`
154
+	StartTime             int64   `gorm:"column:start_time" json:"start_time" form:"start_time"`
155
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
156
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
157
+	ReminderDate          int64   `gorm:"column:reminder_date" json:"reminder_date" form:"reminder_date"`
158
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
159
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
160
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
161
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
162
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
163
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
164
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
165
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
166
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
167
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
168
+	AdviceAffirm          string  `gorm:"column:advice_affirm" json:"advice_affirm" form:"advice_affirm"`
169
+	Remark                string  `gorm:"column:remark" json:"remark" form:"remark"`
170
+	StopTime              int64   `gorm:"column:stop_time" json:"stop_time" form:"stop_time"`
171
+	StopReason            string  `gorm:"column:stop_reason" json:"stop_reason" form:"stop_reason"`
172
+	StopDoctor            int64   `gorm:"column:stop_doctor" json:"stop_doctor" form:"stop_doctor"`
173
+	StopState             int64   `gorm:"column:stop_state" json:"stop_state" form:"stop_state"`
174
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
175
+	ExecutionTime         int64   `gorm:"column:execution_time" json:"execution_time" form:"execution_time"`
176
+	ExecutionStaff        int64   `gorm:"column:execution_staff" json:"execution_staff" form:"execution_staff"`
177
+	ExecutionState        int64   `gorm:"column:execution_state" json:"execution_state" form:"execution_state"`
178
+	Checker               int64   `gorm:"column:checker" json:"checker" form:"checker"`
179
+	RecordDate            int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
180
+	DialysisOrderId       int64   `gorm:"column:dialysis_order_id" json:"dialysis_order_id" form:"dialysis_order_id"`
181
+	CheckTime             int64   `gorm:"column:check_time" json:"check_time" form:"check_time"`
182
+	CheckState            int64   `gorm:"column:check_state" json:"check_state" form:"check_state"`
183
+	DrugSpec              float64 `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
184
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
185
+	Groupno               int64   `gorm:"column:groupno" json:"groupno" form:"groupno"`
186
+	RemindType            int64   `gorm:"column:remind_type" json:"remind_type" form:"remind_type"`
187
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
188
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
189
+	WeekDay               string  `gorm:"column:week_day" json:"week_day" form:"week_day"`
190
+	TemplateId            string  `gorm:"column:template_id" json:"template_id" form:"template_id"`
191
+	Modifier              int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
192
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
193
+	Price                 float64 `gorm:"column:price" json:"price" form:"price"`
194
+	PrescriptionId        int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
195
+}
196
+
197
+func (HisDoctorAdviceInfo) TableName() string {
198
+	return "his_doctor_advice_info"
199
+}
200
+
201
+type HisGroupAdvice struct {
202
+	HisDoctorAdviceInfo
203
+	Children []*HisGroupAdvice
204
+}
205
+
206
+type HisPatientCaseHistory struct {
207
+	ID                      int64   `gorm:"column:id" json:"id" form:"id"`
208
+	PatientId               int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
209
+	HisPatientId            int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
210
+	Temperature             float64 `gorm:"column:temperature" json:"temperature" form:"temperature"`
211
+	BloodSugar              float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
212
+	Pulse                   float64 `gorm:"column:pulse" json:"pulse" form:"pulse"`
213
+	Sbp                     float64 `gorm:"column:sbp" json:"sbp" form:"sbp"`
214
+	Dbp                     float64 `gorm:"column:dbp" json:"dbp" form:"dbp"`
215
+	Height                  float64 `gorm:"column:height" json:"height" form:"height"`
216
+	BloodFat                float64 `gorm:"column:blood_fat" json:"blood_fat" form:"blood_fat"`
217
+	SickType                int64   `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
218
+	Symptom                 string  `gorm:"column:symptom" json:"symptom" form:"symptom"`
219
+	SickDate                int64   `gorm:"column:sick_date" json:"sick_date" form:"sick_date"`
220
+	IsInfect                int64   `gorm:"column:is_infect" json:"is_infect" form:"is_infect"`
221
+	HistoryOfPresentIllness string  `gorm:"column:history_of_present_illness" json:"history_of_present_illness" form:"history_of_present_illness"`
222
+	PastHistory             string  `gorm:"column:past_history" json:"past_history" form:"past_history"`
223
+	Doctor                  int64   `gorm:"column:doctor" json:"doctor" form:"doctor"`
224
+	ChiefConplaint          string  `gorm:"column:chief_conplaint" json:"chief_conplaint" form:"chief_conplaint"`
225
+	PersonalHistory         string  `gorm:"column:personal_history" json:"personal_history" form:"personal_history"`
226
+	FamilyHistory           string  `gorm:"column:family_history" json:"family_history" form:"family_history"`
227
+	Diagnostic              string  `gorm:"column:diagnostic" json:"diagnostic" form:"diagnostic"`
228
+	UserOrgId               int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
229
+	Status                  int64   `gorm:"column:status" json:"status" form:"status"`
230
+	Ctime                   int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
231
+	Mtime                   int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
232
+	RecordDate              int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
233
+}
234
+
235
+func (HisPatientCaseHistory) TableName() string {
236
+	return "his_patient_case_history"
237
+}
238
+
239
+type HisPatientInfo struct {
240
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
241
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
242
+	RecordDate   int64  `gorm:"column:record_date" json:"record_date" form:"record_date"`
243
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
244
+	HisPatientId int64  `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
245
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
246
+	Ctime        int64  `gorm:"column:ctime" json:"ctime" form:"ctime"`
247
+	Mtime        int64  `gorm:"column:mtime" json:"mtime" form:"mtime"`
248
+	Creator      int64  `gorm:"column:creator" json:"creator" form:"creator"`
249
+	Modifier     int64  `gorm:"column:modifier" json:"modifier" form:"modifier"`
250
+	Diagnosis    string `gorm:"column:diagnosis" json:"diagnosis" form:"diagnosis"`
251
+	SickType     string `gorm:"column:sick_type" json:"sick_type" form:"sick_type"`
252
+	PType        string `gorm:"column:p_type" json:"p_type" form:"p_type"`
253
+}
254
+
255
+func (HisPatientInfo) TableName() string {
256
+	return "his_patient_info"
257
+}
258
+
259
+type HisPrescription struct {
260
+	ID                     int64                     `gorm:"column:id" json:"id" form:"id"`
261
+	UserOrgId              int64                     `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
262
+	RecordDate             int64                     `gorm:"column:record_date" json:"record_date" form:"record_date"`
263
+	PatientId              int64                     `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
264
+	HisPatientId           int64                     `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
265
+	Status                 int64                     `gorm:"column:status" json:"status" form:"status"`
266
+	Ctime                  int64                     `gorm:"column:ctime" json:"ctime" form:"ctime"`
267
+	Mtime                  int64                     `gorm:"column:mtime" json:"mtime" form:"mtime"`
268
+	Number                 string                    `gorm:"column:number" json:"number" form:"number"`
269
+	Type                   int64                     `gorm:"column:type" json:"type" form:"type"`
270
+	Doctor                 int64                     `gorm:"column:doctor" json:"doctor" form:"doctor"`
271
+	Creator                int64                     `gorm:"column:creator" json:"creator" form:"creator"`
272
+	Modifier               int64                     `gorm:"column:modifier" json:"modifier" form:"modifier"`
273
+	HisDoctorAdviceInfo    []*HisDoctorAdviceInfo    `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"advices"`
274
+	HisPrescriptionProject []*HisPrescriptionProject `gorm:"ForeignKey:PatientId,RecordDate,PrescriptionId;AssociationForeignKey:PatientId,RecordDate,ID" json:"project"`
275
+}
276
+
277
+func (HisPrescription) TableName() string {
278
+	return "his_prescription"
279
+}
280
+
281
+type HisProject struct {
282
+	ID                        int64   `gorm:"column:id" json:"id" form:"id"`
283
+	ProjectName               string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
284
+	Pinyin                    string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
285
+	Wubi                      string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
286
+	Price                     float64 `gorm:"column:price" json:"price" form:"price"`
287
+	Unit                      string  `gorm:"column:unit" json:"unit" form:"unit"`
288
+	CostClassify              int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
289
+	ExecutiveSection          int64   `gorm:"column:executive_section" json:"executive_section" form:"executive_section"`
290
+	MedicalCoverage           int64   `gorm:"column:medical_coverage" json:"medical_coverage" form:"medical_coverage"`
291
+	StatisticalClassification int64   `gorm:"column:statistical_classification" json:"statistical_classification" form:"statistical_classification"`
292
+	DiseaseDirectory          int64   `gorm:"column:disease_directory" json:"disease_directory" form:"disease_directory"`
293
+	IsRecord                  int64   `gorm:"column:is_record" json:"is_record" form:"is_record"`
294
+	MedicalCode               string  `gorm:"column:medical_code" json:"medical_code" form:"medical_code"`
295
+	TubeColor                 int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
296
+	MedicalStatus             int64   `gorm:"column:medical_status" json:"medical_status" form:"medical_status"`
297
+	Remark                    string  `gorm:"column:remark" json:"remark" form:"remark"`
298
+	Sign                      int64   `gorm:"column:sign" json:"sign" form:"sign"`
299
+	DefaultNumber             string  `gorm:"column:default_number" json:"default_number" form:"default_number"`
300
+	IsDefault                 int64   `gorm:"column:is_default" json:"is_default" form:"is_default"`
301
+	IsCharge                  int64   `gorm:"column:is_charge" json:"is_charge" form:"is_charge"`
302
+	IsEstimate                int64   `gorm:"column:is_estimate" json:"is_estimate" form:"is_estimate"`
303
+	IsWorkload                int64   `gorm:"column:is_workload" json:"is_workload" form:"is_workload"`
304
+	Sort                      string  `gorm:"column:sort" json:"sort" form:"sort"`
305
+	DoctorAdvice              int64   `gorm:"column:doctor_advice" json:"doctor_advice" form:"doctor_advice"`
306
+	UserOrgId                 int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
307
+	Status                    int64   `gorm:"column:status" json:"status" form:"status"`
308
+	CreatedTime               int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
309
+	UpdatedTime               int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
310
+}
311
+
312
+func (HisProject) TableName() string {
313
+	return "xt_his_project"
314
+}
315
+
316
+type HisProjectTeam struct {
317
+	ID          int64   `gorm:"column:id" json:"id" form:"id"`
318
+	ProjectTeam string  `gorm:"column:project_team" json:"project_team" form:"project_team"`
319
+	Price       float64 `gorm:"column:price" json:"price" form:"price"`
320
+	Pinyin      string  `gorm:"column:pinyin" json:"pinyin" form:"pinyin"`
321
+	Wubi        string  `gorm:"column:wubi" json:"wubi" form:"wubi"`
322
+	TubeColor   int64   `gorm:"column:tube_color" json:"tube_color" form:"tube_color"`
323
+	TeamType    int64   `gorm:"column:team_type" json:"team_type" form:"team_type"`
324
+	Remark      string  `gorm:"column:remark" json:"remark" form:"remark"`
325
+	UserOrgId   int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
326
+	Status      int64   `gorm:"column:status" json:"status" form:"status"`
327
+	CreatedTime int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
328
+	UpdatedTime int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
329
+	ProjectId   string  `gorm:"column:project_id" json:"project_id" form:"project_id"`
330
+}
331
+
332
+func (HisProjectTeam) TableName() string {
333
+	return "xt_his_project_team"
334
+}
335
+
336
+type HisAdditionalCharge struct {
337
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
338
+	PatientId    int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
339
+	Price        float64 `gorm:"column:price" json:"price" form:"price"`
340
+	AdminUserId  int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
341
+	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
342
+	RecordDate   int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
343
+	CreatedTime  int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
344
+	UpdatedTime  int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
345
+	Status       int64   `gorm:"column:status" json:"status" form:"status"`
346
+	ItemName     string  `gorm:"column:item_name" json:"item_name" form:"item_name"`
347
+	HisPatientId int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
348
+	ItemId       int64   `gorm:"column:item_id" json:"item_id" form:"item_id"`
349
+	Creator      int64   `gorm:"column:creator" json:"creator" form:"creator"`
350
+	Modifier     int64   `gorm:"column:modifier" json:"modifier" form:"modifier"`
351
+}
352
+
353
+func (HisAdditionalCharge) TableName() string {
354
+	return "his_additional_charge"
355
+}
356
+
357
+type HisDoctorAdviceParentTemplate struct {
358
+	ID                      int64                      `gorm:"column:id" json:"id" form:"id"`
359
+	OrgId                   int64                      `gorm:"column:org_id" json:"org_id" form:"org_id"`
360
+	Name                    string                     `gorm:"column:name" json:"name" form:"name"`
361
+	Status                  int64                      `gorm:"column:status" json:"status" form:"status"`
362
+	CreatedTime             int64                      `gorm:"column:created_time" json:"created_time" form:"created_time"`
363
+	UpdatedTime             int64                      `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
364
+	AdviceType              int64                      `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
365
+	HisDoctorAdviceTemplate []*HisDoctorAdviceTemplate `gorm:"ForeignKey:TemplateId;AssociationForeignKey:ID" json:"advices"`
366
+}
367
+
368
+func (HisDoctorAdviceParentTemplate) TableName() string {
369
+	return "his_doctor_advice_parent_template"
370
+}
371
+
372
+type HisDoctorAdviceTemplate struct {
373
+	ID                    int64   `gorm:"column:id" json:"id" form:"id"`
374
+	OrgId                 int64   `gorm:"column:org_id" json:"org_id" form:"org_id"`
375
+	AdviceName            string  `gorm:"column:advice_name" json:"advice_name" form:"advice_name"`
376
+	AdviceDesc            string  `gorm:"column:advice_desc" json:"advice_desc" form:"advice_desc"`
377
+	SingleDose            float64 `gorm:"column:single_dose" json:"single_dose" form:"single_dose"`
378
+	SingleDoseUnit        string  `gorm:"column:single_dose_unit" json:"single_dose_unit" form:"single_dose_unit"`
379
+	PrescribingNumber     float64 `gorm:"column:prescribing_number" json:"prescribing_number" form:"prescribing_number"`
380
+	PrescribingNumberUnit string  `gorm:"column:prescribing_number_unit" json:"prescribing_number_unit" form:"prescribing_number_unit"`
381
+	DeliveryWay           string  `gorm:"column:delivery_way" json:"delivery_way" form:"delivery_way"`
382
+	ExecutionFrequency    string  `gorm:"column:execution_frequency" json:"execution_frequency" form:"execution_frequency"`
383
+	AdviceDoctor          int64   `gorm:"column:advice_doctor" json:"advice_doctor" form:"advice_doctor"`
384
+	Status                int64   `gorm:"column:status" json:"status" form:"status"`
385
+	CreatedTime           int64   `gorm:"column:created_time" json:"created_time" form:"created_time"`
386
+	UpdatedTime           int64   `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
387
+	TemplateId            int64   `gorm:"column:template_id" json:"template_id" form:"template_id"`
388
+	DrugSpec              string  `gorm:"column:drug_spec" json:"drug_spec" form:"drug_spec"`
389
+	DrugSpecUnit          string  `gorm:"column:drug_spec_unit" json:"drug_spec_unit" form:"drug_spec_unit"`
390
+	ParentId              int64   `gorm:"column:parent_id" json:"parent_id" form:"parent_id"`
391
+	AdviceType            int64   `gorm:"column:advice_type" json:"advice_type" form:"advice_type"`
392
+	DayCount              int64   `gorm:"column:day_count" json:"day_count" form:"day_count"`
393
+	WeekDays              string  `gorm:"column:week_days" json:"week_days" form:"week_days"`
394
+	FrequencyType         int64   `gorm:"column:frequency_type" json:"frequency_type" form:"frequency_type"`
395
+	DrugId                int64   `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
396
+	Way                   int64   `gorm:"column:way" json:"way" form:"way"`
397
+	DrugNameId            int64   `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
398
+}
399
+
400
+func (HisDoctorAdviceTemplate) TableName() string {
401
+	return "his_doctor_advice_template"
402
+}
403
+
404
+type HisPrescriptionProject struct {
405
+	ID             int64   `gorm:"column:id" json:"id" form:"id"`
406
+	ProjectId      int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
407
+	Price          float64 `gorm:"column:price" json:"price" form:"price"`
408
+	UserOrgId      int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
409
+	Status         int64   `gorm:"column:status" json:"status" form:"status"`
410
+	Ctime          int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
411
+	Mtime          int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
412
+	PatientId      int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
413
+	HisPatientId   int64   `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
414
+	RecordDate     int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
415
+	PrescriptionId int64   `gorm:"column:prescription_id" json:"prescription_id" form:"prescription_id"`
416
+}
417
+
418
+func (HisPrescriptionProject) TableName() string {
419
+	return "his_prescription_project"
420
+}
421
+
422
+type SchedulesVm struct {
423
+	ID           int64  `gorm:"column:id" json:"id" form:"id"`
424
+	UserOrgId    int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
425
+	PartitionId  int64  `gorm:"column:partition_id" json:"partition_id" form:"partition_id"`
426
+	BedId        int64  `gorm:"column:bed_id" json:"bed_id" form:"bed_id"`
427
+	PatientId    int64  `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
428
+	ScheduleDate int64  `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
429
+	ScheduleType int64  `gorm:"column:schedule_type" json:"schedule_type" form:"schedule_type"`
430
+	ScheduleWeek int64  `gorm:"column:schedule_week" json:"schedule_week" form:"schedule_week"`
431
+	ModeId       int64  `gorm:"column:mode_id" json:"mode_id" form:"mode_id"`
432
+	Status       int64  `gorm:"column:status" json:"status" form:"status"`
433
+	CreatedTime  int64  `gorm:"column:created_time" json:"created_time" form:"created_time"`
434
+	UpdatedTime  int64  `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
435
+	Name         string `gorm:"column:name" json:"name" form:"name"`
436
+	IdCardNo     string `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
437
+}
438
+
439
+type HisProjectListVm struct {
440
+	ID           int64   `gorm:"column:id" json:"id" form:"id"`
441
+	Number       int64   `gorm:"column:number" json:"number" form:"number"`
442
+	UserOrgId    int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
443
+	ProjectId    int64   `gorm:"column:project_id" json:"project_id" form:"project_id"`
444
+	Status       int64   `gorm:"column:status" json:"status" form:"status"`
445
+	Price        float64 `gorm:"column:price" json:"price" form:"price"`
446
+	Unit         string  `gorm:"column:unit" json:"unit" form:"unit"`
447
+	ProjectName  string  `gorm:"column:project_name" json:"project_name" form:"project_name"`
448
+	CostClassify int64   `gorm:"column:cost_classify" json:"cost_classify" form:"cost_classify"`
449
+}
450
+
451
+type XtHisProjectList struct {
452
+	ID          int64 `gorm:"column:id" json:"id" form:"id"`
453
+	Number      int64 `gorm:"column:number" json:"number" form:"number"`
454
+	UserOrgId   int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
455
+	ProjectId   int64 `gorm:"column:project_id" json:"project_id" form:"project_id"`
456
+	Status      int64 `gorm:"column:status" json:"status" form:"status"`
457
+	CreatedTime int64 `gorm:"column:created_time" json:"created_time" form:"created_time"`
458
+	UpdatedTime int64 `gorm:"column:updated_time" json:"updated_time" form:"updated_time"`
459
+}
460
+
461
+func (XtHisProjectList) TableName() string {
462
+	return "xt_his_project_list"
463
+}
464
+
465
+type XtHisPatient struct {
466
+	ID                     int64   `gorm:"column:id" json:"id" form:"id"`
467
+	BalanceAccountsType    int64   `gorm:"column:balance_accounts_type" json:"balance_accounts_type" form:"balance_accounts_type"`
468
+	MedicalInsuranceNumber string  `gorm:"column:medical_insurance_number" json:"medical_insurance_number" form:"medical_insurance_number"`
469
+	Name                   string  `gorm:"column:name" json:"name" form:"name"`
470
+	Gender                 int64   `gorm:"column:gender" json:"gender" form:"gender"`
471
+	IdType                 int64   `gorm:"column:id_type" json:"id_type" form:"id_type"`
472
+	MedicalTreatmentType   int64   `gorm:"column:medical_treatment_type" json:"medical_treatment_type" form:"medical_treatment_type"`
473
+	Birthday               int64   `gorm:"column:birthday" json:"birthday" form:"birthday"`
474
+	RecordDate             int64   `gorm:"column:record_date" json:"record_date" form:"record_date"`
475
+	Age                    int64   `gorm:"column:age" json:"age" form:"age"`
476
+	PhoneNumber            string  `gorm:"column:phone_number" json:"phone_number" form:"phone_number"`
477
+	IdCardNo               string  `gorm:"column:id_card_no" json:"id_card_no" form:"id_card_no"`
478
+	RegisterType           int64   `gorm:"column:register_type" json:"register_type" form:"register_type"`
479
+	AdminUserId            int64   `gorm:"column:admin_user_id" json:"admin_user_id" form:"admin_user_id"`
480
+	Departments            int64   `gorm:"column:departments" json:"departments" form:"departments"`
481
+	IsNeedCostOfProduction int64   `gorm:"column:is_need_cost_of_production" json:"is_need_cost_of_production" form:"is_need_cost_of_production"`
482
+	RegisterCost           float64 `gorm:"column:register_cost" json:"register_cost" form:"register_cost"`
483
+	TreatmentCost          float64 `gorm:"column:treatment_cost" json:"treatment_cost" form:"treatment_cost"`
484
+	CostOfProduction       float64 `gorm:"column:cost_of_production" json:"cost_of_production" form:"cost_of_production"`
485
+	Total                  float64 `gorm:"column:total" json:"total" form:"total"`
486
+	UserOrgId              int64   `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
487
+	Status                 int64   `gorm:"column:status" json:"status" form:"status"`
488
+	Ctime                  int64   `gorm:"column:ctime" json:"ctime" form:"ctime"`
489
+	Mtime                  int64   `gorm:"column:mtime" json:"mtime" form:"mtime"`
490
+	PatientId              int64   `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
491
+	Number                 string  `gorm:"column:number" json:"number" form:"number"`
492
+}
493
+
494
+func (XtHisPatient) TableName() string {
495
+	return "his_patient"
496
+}

+ 3 - 1
routers/router.go Näytä tiedosto

@@ -53,7 +53,7 @@ func init() {
53 53
 	controllers.PCIndexEvaluationApiControllersRegisterRouters()
54 54
 	controllers.ManagerCenterRegistRouters()
55 55
 	controllers.DrugStockManagerApiRegistRouters()
56
-	controllers.GdybRegistRouters()
56
+	controllers.HisManagerApiRegistRouters()
57 57
 
58 58
 	m_api.MobileAPIControllersRegisterRouters()
59 59
 	new_m_api.NewMobileAPIControllersRegisterRouters()
@@ -71,4 +71,6 @@ func init() {
71 71
 	new_m_api.DialysisParameterApiControllersRegisterRouters()
72 72
 	controllers.SelfDrugRouters()
73 73
 	new_m_api.NewDrugApiControllersRegisterRouters()
74
+	controllers.HisProjectRouters()
75
+	controllers.GdybRegistRouters()
74 76
 }

+ 2 - 3
service/dialysis_service.go Näytä tiedosto

@@ -171,7 +171,6 @@ func FindQueueCallInfo(orgID int64) (queueConfig models.QueueCallConfig, err err
171 171
 	return
172 172
 }
173 173
 
174
-
175 174
 //修改机构叫号配置
176 175
 func UpDateQueueCallInfo(queueConfig models.QueueCallConfig) error {
177 176
 	err := writeDb.Save(&queueConfig).Error
@@ -981,8 +980,8 @@ func FindOrderInfoByGoodId(good_type_id int64, good_id int64, number string, org
981 980
 	return
982 981
 }
983 982
 
984
-func FindGoodUserById(good_type_id int64, good_id int64, id int64, org_id int64, number string) (user models.AutomaticReduceDetail, err error) {
985
-	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND patient_id = ? AND org_id = ? AND warehouse_out_order_number = ? ", good_id, good_type_id, id, org_id, number).First(&user).Error
983
+func FindGoodUserById(good_type_id int64, good_id int64, id int64, org_id int64, record_time int64) (user models.AutomaticReduceDetail, err error) {
984
+	err = readDb.Model(&models.AutomaticReduceDetail{}).Where("good_id = ? AND good_type_id = ? AND patient_id = ? AND org_id = ? AND record_time = ? ", good_id, good_type_id, id, org_id, record_time).First(&user).Error
986 985
 	return
987 986
 }
988 987
 

+ 3 - 0
service/doctor_advice_service.go Näytä tiedosto

@@ -324,6 +324,9 @@ type DoctorAdvice struct {
324 324
 	TemplateId            string          `gorm:"column:template_id" json:"template_id"`
325 325
 	Modifier              int64           `gorm:"column:modifier" json:"modifier" form:"modifier"`
326 326
 	IsCheck               int64           `gorm:"-" json:"is_check" form:"is_check"`
327
+	Way                   int64           `gorm:"column:way" json:"way" form:"way"`
328
+	DrugId                int64           `gorm:"column:drug_id" json:"drug_id" form:"drug_id"`
329
+	DrugNameId            int64           `gorm:"column:drug_name_id" json:"drug_name_id" form:"drug_name_id"`
327 330
 }
328 331
 
329 332
 func (DoctorAdvice) TableName() string {

+ 309 - 0
service/his_project_service.go Näytä tiedosto

@@ -0,0 +1,309 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+	"time"
7
+)
8
+
9
+func GetHisProjectIsExist(projectName string, orgid int64) (*models.XtHisProject, error) {
10
+
11
+	var project models.XtHisProject
12
+	var err error
13
+	err = XTReadDB().Model(&project).Where("project_name = ? and user_org_id = ? and status = 1", projectName, orgid).Find(&project).Error
14
+	if err == gorm.ErrRecordNotFound {
15
+		return nil, err
16
+	}
17
+
18
+	if err != nil {
19
+		return nil, err
20
+	}
21
+
22
+	return &project, nil
23
+}
24
+
25
+func CreateHisProject(project *models.XtHisProject) error {
26
+
27
+	err := XTWriteDB().Model(&project).Create(&project).Error
28
+	return err
29
+}
30
+
31
+func GetHisProjectList(orgid int64, limit int64, page int64, start int64, charge int64, keyword string) (hisproject []*models.XtHisProject, total int64, err error) {
32
+	offset := (page - 1) * limit
33
+	likeKey := "%" + keyword + "%"
34
+	db := XTReadDB().Table("xt_his_project as x").Where("x.status = 1")
35
+	if orgid > 0 {
36
+		db = db.Where("x.user_org_id = ?", orgid)
37
+	}
38
+	if start > 0 {
39
+		db = db.Where("x.medical_status = ?", start)
40
+	}
41
+	if charge > 0 {
42
+		db = db.Where("x.is_charge = ? ", charge)
43
+	}
44
+	if len(keyword) > 0 {
45
+		db = db.Where("x.project_name like ?", likeKey)
46
+	}
47
+	err = db.Select("x.id,x.project_name,x.pinyin,x.wubi,x.price,x.unit,x.cost_classify,x.executive_section,x.medical_coverage,x.statistical_classification,x.disease_directory,x.is_record,x.medical_code,x.tube_color,x.medical_status,x.remark,x.sign,x.default_number,x.is_default,x.is_charge,x.is_estimate,x.is_workload,x.sort,x.doctor_advice,x.user_org_id,x.status,x.created_time").Count(&total).Offset(offset).Limit(limit).Find(&hisproject).Error
48
+	return hisproject, total, err
49
+}
50
+
51
+func GetProjectDetail(id int64) (models.XtHisProject, error) {
52
+	project := models.XtHisProject{}
53
+	err := XTReadDB().Model(&project).Where("id=? and status = 1", id).Find(&project).Error
54
+	return project, err
55
+}
56
+
57
+func UpdatedProject(id int64, pro *models.XtHisProject) error {
58
+
59
+	err := XTWriteDB().Model(&pro).Where("id=?", id).Updates(map[string]interface{}{"project_name": pro.ProjectName, "pinyin": pro.Pinyin, "wubi": pro.Pinyin, "price": pro.Price, "unit": pro.Unit, "cost_classify": pro.CostClassify, "executive_section": pro.ExecutiveSection, "medical_coverage": pro.MedicalCoverage, "statistical_classification": pro.MedicalCoverage, "disease_directory": pro.DiseaseDirectory, "is_record": pro.DiseaseDirectory, "medical_code": pro.MedicalCode, "tube_color": pro.TubeColor, "medical_status": pro.MedicalStatus, "remark": pro.Remark, "sign": pro.Sign, "default_number": pro.DefaultNumber, "is_default": pro.IsDefault, "is_charge": pro.IsCharge, "is_estimate": pro.IsEstimate, "is_workload": pro.IsWorkload, "sort": pro.Sort, "doctor_advice": pro.DoctorAdvice, "single_dose": pro.SingleDose, "execution_frequency": pro.ExecutionFrequency, "delivery_way": pro.ExecutionFrequency, "number_days": pro.ExecutionFrequency, "total": pro.Total, "updated_time": pro.UpdatedTime}).Error
60
+	return err
61
+}
62
+
63
+func DeleteHisProject(id int64) error {
64
+	project := models.XtHisProject{}
65
+	err := XTWriteDB().Model(&project).Where("id=?", id).Updates(map[string]interface{}{"status": 0}).Error
66
+	return err
67
+}
68
+
69
+func GetHisProjectByNameOne(projectName string, orgid int64) (*models.XtHisProjectTeam, error) {
70
+
71
+	projectTeam := models.XtHisProjectTeam{}
72
+	err := XTReadDB().Model(&projectTeam).Where("project_team = ? and user_org_id = ? and status = 1", projectName, orgid).Find(&projectTeam).Error
73
+	if err != nil {
74
+		if err == gorm.ErrRecordNotFound {
75
+			return nil, err
76
+		} else {
77
+			return nil, err
78
+		}
79
+	}
80
+	return &projectTeam, nil
81
+
82
+}
83
+
84
+func CreatedProjectTeam(team *models.XtHisProjectTeam) error {
85
+
86
+	err := XTWriteDB().Model(&team).Create(&team).Error
87
+	return err
88
+}
89
+
90
+func GetProjectTeamList(limit int64, page int64, orgid int64, keyword string) (projectTeam []*models.XtHisProjectTeam, total int64, err error) {
91
+	offset := (page - 1) * limit
92
+	likeKey := "%" + keyword + "%"
93
+	db := XTReadDB().Model(&projectTeam)
94
+	if len(keyword) > 0 {
95
+		db = db.Where("project_team like ?", likeKey)
96
+	}
97
+	err = db.Where("user_org_id = ? and status = 1", orgid).Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&projectTeam).Error
98
+	return projectTeam, total, err
99
+}
100
+
101
+func GetProjectTeamDetail(id int64) (models.XtHisProjectTeam, error) {
102
+
103
+	projectTeam := models.XtHisProjectTeam{}
104
+	err := XTReadDB().Model(&projectTeam).Where("id= ? and status = 1", id).Find(&projectTeam).Error
105
+	return projectTeam, err
106
+}
107
+
108
+func UpdatedProjectTeam(id int64, team *models.XtHisProjectTeam) error {
109
+
110
+	err := XTWriteDB().Model(&team).Where("id=? and status = 1", id).Updates(map[string]interface{}{"project_team": team.ProjectTeam, "price": team.Price, "pinyin": team.Pinyin, "wubi": team.Wubi, "tube_color": team.TubeColor, "team_type": team.TeamType, "remark": team.Remark, "project_id": team.ProjectId}).Error
111
+	return err
112
+}
113
+
114
+func DeleteProjectTeam(id int64) error {
115
+
116
+	team := models.XtHisProjectTeam{}
117
+	err := XTWriteDB().Model(&team).Where("id = ? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
118
+	return err
119
+}
120
+
121
+func CreateDePartment(department *models.XtHisDepartment) error {
122
+
123
+	err := XTWriteDB().Model(&department).Create(&department).Error
124
+	return err
125
+}
126
+
127
+func GetDepartMentList(limit int64, page int64, orgid int64) (departMent []*models.XtHisDepartment, total int64, err error) {
128
+
129
+	offset := (page - 1) * limit
130
+	err = XTReadDB().Model(&departMent).Where("user_org_id = ? and status = 1", orgid).Count(&total).Offset(offset).Limit(limit).Order("created_time desc").Find(&departMent).Error
131
+	return departMent, total, err
132
+}
133
+
134
+func GetDepartMentDetail(id int64) (models.XtHisDepartment, error) {
135
+
136
+	department := models.XtHisDepartment{}
137
+	err := XTReadDB().Model(&department).Where("id=? and status = 1", id).Find(&department).Error
138
+	return department, err
139
+}
140
+
141
+func UpdatedDepartment(id int64, department *models.XtHisDepartment) error {
142
+
143
+	err := XTWriteDB().Model(&department).Where("id=? and status = 1", id).Updates(map[string]interface{}{"name": department.Name, "number": department.Number, "updated_time": time.Now().Unix()}).Error
144
+	return err
145
+}
146
+
147
+func DeleteDepartment(id int64) error {
148
+	department := models.XtHisDepartment{}
149
+	err := XTReadDB().Model(&department).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
150
+	return err
151
+}
152
+
153
+func GetBloodPatientList(orgid int64, startime int64) (schedule []*models.SchedulesVm, err error) {
154
+
155
+	db := XTReadDB().Table("xt_schedule as x").Where("x.status = 1")
156
+	if orgid > 0 {
157
+		db = db.Where("x.user_org_id = ?", orgid)
158
+	}
159
+	if startime > 0 {
160
+		db = db.Where("x.schedule_date = ?", startime)
161
+	}
162
+	err = db.Select("x.id,x.user_org_id,x.patient_id,x.schedule_date,x.schedule_type,x.schedule_week,x.mode_id,p.name,p.id_card_no").Joins("left join xt_patients as p on p.id = x.patient_id").Scan(&schedule).Error
163
+	return schedule, err
164
+}
165
+
166
+func GetHisPatient(orgid int64, recorddate int64) (paitent []*models.HisPatient, err error) {
167
+
168
+	err = XTReadDB().Model(&paitent).Where("user_org_id = ?  and record_date = ? and status = 1", orgid, recorddate).Find(&paitent).Error
169
+	return paitent, err
170
+}
171
+
172
+func GetHisPrescriptionOther(orgid int64, recorddate int64) (prescription []*models.HisPrescriptionVm, err error) {
173
+
174
+	db := XTReadDB().Table("his_prescription as x").Where("x.status = 1")
175
+	if orgid > 0 {
176
+		db = db.Where("x.user_org_id = ?", orgid)
177
+	}
178
+	if recorddate > 0 {
179
+		db = db.Where("x.record_date = ? ", recorddate)
180
+	}
181
+	err = db.Select("x.id,x.user_org_id,x.record_date,x.patient_id,x.his_patient_id,x.number,x.type,x.doctor,x.creator,x.modifier,t.name").Joins("left join his_patient as t on t.id = x.his_patient_id").Scan(&prescription).Error
182
+	return prescription, err
183
+}
184
+
185
+func GetHisPrescriptionByPatientId(id int64, recordate int64) (prescription []*models.HisPrescription, err error) {
186
+
187
+	err = XTReadDB().Model(&prescription).Where("his_patient_id = ? and record_date = ? and status= 1", id, recordate).Find(&prescription).Error
188
+	return prescription, err
189
+}
190
+
191
+func CreateAdditionalCharge(charge *models.HisAdditionalCharge) error {
192
+
193
+	err = XTWriteDB().Model(&charge).Create(&charge).Error
194
+	return err
195
+}
196
+
197
+func GetTreatmentList(id int64, startime int64) (prescription []*models.HisPrescription, err error) {
198
+
199
+	err = XTReadDB().Model(&prescription).Where("id = ? and record_date = ? and status = 1", id, startime).Find(&prescription).Error
200
+	return prescription, err
201
+}
202
+
203
+//func GetAllProjectList(orgid int64) (project []*models.XtHisProject, err error) {
204
+//
205
+//	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
206
+//	return project, err
207
+//}
208
+
209
+func CreateProjectList(list *models.XtHisProjectList) error {
210
+
211
+	err := XTWriteDB().Model(&list).Create(&list).Error
212
+	return err
213
+}
214
+
215
+func GetHisProjectListByOrgId(orgid int64) (projectlist []*models.HisProjectListVm, err error) {
216
+
217
+	db := XTReadDB().Table("xt_his_project_list as x").Where("x.status = 1")
218
+	if orgid > 0 {
219
+		db = db.Where("x.user_org_id = ? ", orgid)
220
+	}
221
+	err = db.Select("x.id,x.number,x.user_org_id,x.project_id,t.price,t.unit,t.cost_classify,t.project_name").Joins("left join xt_his_project as t on t.id = x.project_id").Scan(&projectlist).Error
222
+	return projectlist, err
223
+}
224
+
225
+func GetHisPatientInformation(id int64) (models.HisPatient, error) {
226
+
227
+	patient := models.HisPatient{}
228
+	err := XTReadDB().Model(&patient).Where("id= ? and status = 1", id).Find(&patient).Error
229
+	return patient, err
230
+}
231
+
232
+func DeleteProjectList(id int64) error {
233
+	list := models.XtHisProjectList{}
234
+	err := XTWriteDB().Model(&list).Where("id=? and status = 1", id).Updates(map[string]interface{}{"status": 0}).Error
235
+	return err
236
+}
237
+
238
+func GetHisProject(orgid int64) (project []*models.XtHisProject, err error) {
239
+
240
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status =1", orgid).Find(&project).Error
241
+	return project, err
242
+}
243
+
244
+func GetProjectTeam(ids []string, orgid int64) (project []*models.XtHisProject, err error) {
245
+
246
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
247
+	return project, err
248
+}
249
+
250
+func GetAllDepartMent(orgid int64) (department []*models.XtHisDepartment, err error) {
251
+
252
+	err = XTReadDB().Model(&department).Where("user_org_id = ? and status =1", orgid).Find(&department).Error
253
+	return department, err
254
+}
255
+
256
+func CreateHisPatient(patient *models.XtHisPatient) error {
257
+
258
+	err := XTReadDB().Model(&patient).Create(&patient).Error
259
+	return err
260
+}
261
+
262
+func GetBloodPatientByIdCard(idcard string, orgid int64) (*models.XtPatients, error) {
263
+	var patients models.XtPatients
264
+	var err error
265
+	err = XTReadDB().Model(&patients).Where("id_card_no = ? and user_org_id = ? and status = 1", idcard, orgid).Find(&patients).Error
266
+	if err != nil {
267
+		if err == gorm.ErrRecordNotFound {
268
+			return nil, err
269
+		} else {
270
+			return nil, err
271
+		}
272
+	}
273
+	return &patients, nil
274
+}
275
+
276
+func GetAllProjectTeam(orgid int64) (project []*models.XtHisProjectTeam, err error) {
277
+
278
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and status = 1", orgid).Find(&project).Error
279
+	return project, err
280
+}
281
+
282
+func GetProjectListById(orgid int64, ids []string) (project []*models.XtHisProject, err error) {
283
+	err = XTReadDB().Model(&project).Where("user_org_id = ? and id in (?)", orgid, ids).Find(&project).Error
284
+	return project, err
285
+}
286
+
287
+func GetHisPatientHistory(keyword string, startime int64, endtime int64, registtype int64, limit int64, page int64, orgid int64) (hisPatient []*models.XtHisPatient, total int64, err error) {
288
+	offset := (page - 1) * limit
289
+	likeKey := "%" + keyword + "%"
290
+	db := XTReadDB().Table("his_patient as x").Where("x.status = 1")
291
+
292
+	if len(keyword) > 0 {
293
+		db = db.Where("x.name like ?", likeKey)
294
+	}
295
+	if startime > 0 {
296
+		db = db.Where("x.record_date >= ?", startime)
297
+	}
298
+	if endtime > 0 {
299
+		db = db.Where("x.record_date<=?", endtime)
300
+	}
301
+	if registtype > 0 {
302
+		db = db.Where("x.register_type = ?", registtype)
303
+	}
304
+	if orgid > 0 {
305
+		db = db.Where("x.user_org_id = ?", orgid)
306
+	}
307
+	err = db.Select("x.id,x.balance_accounts_type,x.medical_insurance_number,x.name,x.gender,x.id_type,x.medical_treatment_type,x.birthday,x.record_date,x.age,x.phone_number,x.id_card_no,x.register_type,x.admin_user_id,x.departments,x.is_need_cost_of_production,x.register_cost,x.treatment_cost,x.cost_of_production,x.total,x.user_org_id,x.patient_id,x.number").Count(&total).Offset(offset).Limit(limit).Find(&hisPatient).Error
308
+	return hisPatient, total, err
309
+}

+ 158 - 0
service/his_service.go Näytä tiedosto

@@ -0,0 +1,158 @@
1
+package service
2
+
3
+import (
4
+	"XT_New/models"
5
+	"github.com/jinzhu/gorm"
6
+)
7
+
8
+type HisPatient struct {
9
+	ID              int64              `gorm:"column:id" json:"id" form:"id"`
10
+	Name            string             `gorm:"column:name" json:"name" form:"name"`
11
+	Gender          int64              `gorm:"column:gender" json:"gender" form:"gender"`
12
+	Total           float64            `gorm:"column:total" json:"total" form:"total"`
13
+	UserOrgId       int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
14
+	Status          int64              `gorm:"column:status" json:"status" form:"status"`
15
+	RecordDate      int64              `gorm:"column:record_date" json:"record_date" form:"record_date"`
16
+	HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:ID,RecordDate" json:"prescription"`
17
+	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
18
+	Number          string             `gorm:"column:name" json:"name" form:"name"`
19
+}
20
+
21
+func (HisPatient) TableName() string {
22
+	return "his_patient"
23
+}
24
+
25
+type Schedule struct {
26
+	ID              int64              `gorm:"column:id" json:"id" form:"id"`
27
+	UserOrgId       int64              `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
28
+	PatientId       int64              `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
29
+	Status          int64              `gorm:"column:status" json:"status" form:"status"`
30
+	ScheduleDate    int64              `gorm:"column:schedule_date" json:"schedule_date" form:"schedule_date"`
31
+	Patients        Patients           `gorm:"ForeignKey:ID;AssociationForeignKey:PatientId" json:"patients"`
32
+	HisPatient      HisPatient         `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"his_patient"`
33
+	HisPrescription []*HisPrescription `gorm:"ForeignKey:PatientId,RecordDate;AssociationForeignKey:PatientId,ScheduleDate" json:"prescription"`
34
+}
35
+
36
+func (Schedule) TableName() string {
37
+	return "xt_schedule"
38
+}
39
+
40
+type Patients struct {
41
+	ID        int64  `gorm:"column:id" json:"id" form:"id"`
42
+	UserOrgId int64  `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
43
+	Name      string `gorm:"column:name" json:"name" form:"name"`
44
+	Status    int64  `gorm:"column:status" json:"status" form:"status"`
45
+}
46
+
47
+func (Patients) TableName() string {
48
+	return "xt_patients"
49
+}
50
+
51
+type HisPrescription struct {
52
+	ID           int64 `gorm:"column:id" json:"id" form:"id"`
53
+	UserOrgId    int64 `gorm:"column:user_org_id" json:"user_org_id" form:"user_org_id"`
54
+	RecordDate   int64 `gorm:"column:record_date" json:"record_date" form:"record_date"`
55
+	PatientId    int64 `gorm:"column:patient_id" json:"patient_id" form:"patient_id"`
56
+	HisPatientId int64 `gorm:"column:his_patient_id" json:"his_patient_id" form:"his_patient_id"`
57
+	Status       int64 `gorm:"column:status" json:"status" form:"status"`
58
+}
59
+
60
+func (HisPrescription) TableName() string {
61
+	return "his_prescription"
62
+}
63
+
64
+func GetHisPatientList(org_id int64, keywords string, record_date int64) (patients []*Schedule, err error) {
65
+	db := readDb.Model(&Schedule{}).Where("user_org_id = ? AND status = 1 AND schedule_date = ?", org_id, record_date)
66
+	db = db.Preload("Patients", "user_org_id = ? AND status = 1", org_id)
67
+	db = db.Preload("HisPatient", "user_org_id = ? AND status = 1", org_id)
68
+	err = db.Preload("HisPrescription", "user_org_id = ? AND status = 1", org_id).Find(&patients).Error
69
+	return
70
+}
71
+
72
+func GetAllBaseDrugStockList(org_id int64) (drugs []*models.BaseDrugLib, err error) {
73
+	err = readDb.Model(&models.BaseDrugLib{}).Where("user_org_id = ? AND status = 1", org_id).Find(&drugs).Error
74
+	return
75
+}
76
+
77
+func GetHisPatientInfo(org_id int64, patient_id int64, record_date int64) (info HisPatient, err error) {
78
+	err = readDb.Model(&models.HisPatient{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND id = ?", org_id, record_date, patient_id).First(&info).Error
79
+	return
80
+}
81
+
82
+func GetXTPatientInfo(org_id int64, patient_id int64) (info models.Patients, err error) {
83
+	err = readDb.Model(&models.Patients{}).Where("user_org_id = ? AND status = 1  AND id = ?", org_id, patient_id).First(&info).Error
84
+	return
85
+}
86
+
87
+func GetHisPatientCaseHistoryInfo(org_id int64, patient_id int64, record_date int64) (info models.HisPatientCaseHistory, err error) {
88
+	err = readDb.Model(&models.HisPatientCaseHistory{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).First(&info).Error
89
+	return
90
+}
91
+
92
+func GetHisPatientCaseHistoryList(org_id int64, patient_id int64) (caseHistorys []*models.HisPatientCaseHistory, err error) {
93
+	db := readDb.Model(&models.HisPatientCaseHistory{}).Where("user_org_id = ? AND status = 1  AND his_patient_id = ?", org_id, patient_id)
94
+	err = db.Find(&caseHistorys).Error
95
+	return
96
+}
97
+
98
+func GetHisPatientCaseHistoryTemplate(org_id int64) (caseHistorys []*models.HisCaseHistoryTemplate, err error) {
99
+	db := readDb.Model(&models.HisCaseHistoryTemplate{}).Where("user_org_id = ? AND status = 1", org_id)
100
+	err = db.Find(&caseHistorys).Error
101
+	return
102
+}
103
+
104
+func SaveHisPatientCaseHistoryTemplate(template models.HisCaseHistoryTemplate) (err error) {
105
+	err = writeDb.Create(&template).Error
106
+	return
107
+}
108
+
109
+func SaveHisPatientCaseHistory(caseHistory models.HisPatientCaseHistory) (err error) {
110
+	err = writeDb.Create(&caseHistory).Error
111
+	return
112
+}
113
+
114
+func SaveHisPrescription(prescription *models.HisPrescription) (err error) {
115
+	err = writeDb.Create(&prescription).Error
116
+	return
117
+}
118
+
119
+func GetHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
120
+	err = readDb.Model(&models.HisPrescription{}).
121
+		Preload("HisDoctorAdviceInfo", "status = 1 AND user_org_id = ?", org_id).
122
+		Preload("HisPrescriptionProject", "status = 1 AND user_org_id = ?", org_id).
123
+		Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ?", org_id, record_date, patient_id).
124
+		First(&prescription).Error
125
+	return
126
+}
127
+
128
+func GetAllDrugLibList(org_id int64) (list []*models.BaseDrugLib, err error) {
129
+	err = readDb.Model(&models.BaseDrugLib{}).Where("org_id = ?  AND status = 1", org_id).Find(&list).Error
130
+	return
131
+}
132
+
133
+func GetAllProjectList(org_id int64) (list []*models.HisProject, err error) {
134
+	err = readDb.Model(&models.HisProject{}).Where("user_org_id = ?  AND status = 1", org_id).Find(&list).Error
135
+	return
136
+}
137
+
138
+func CreateAddtionalCharge(charge *models.HisAdditionalCharge) (err error) {
139
+	err = writeDb.Create(&charge).Error
140
+	return
141
+}
142
+
143
+func FindAllHisAdviceTemplate(org_id int64) (temps []*models.HisDoctorAdviceParentTemplate, err error) {
144
+	err = readDb.Model(&models.HisDoctorAdviceParentTemplate{}).Preload("HisDoctorAdviceTemplate", func(db *gorm.DB) *gorm.DB {
145
+		return db.Select("id,advice_name,advice_desc,single_dose,single_dose_unit,prescribing_number,prescribing_number_unit,delivery_way,execution_frequency,status,created_time,updated_time,parent_id,template_id,drug_spec,drug_spec_unit,advice_type,day_count,week_days,frequency_type,way,drug_id,drug_name_id, IF(parent_id>0, parent_id, id) as advice_order").Where("status = 1").Order("advice_order desc, id")
146
+	}).Where("org_id = ? AND status=1 ", org_id).Find(&temps).Error
147
+	return
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
+}

+ 13 - 0
service/mobile_dialysis_service.go Näytä tiedosto

@@ -639,6 +639,19 @@ func MobileGetDialysisPrescribe(orgID int64, patientID int64, recordDate int64)
639 639
 	return &record, nil
640 640
 }
641 641
 
642
+func MobileGetDialysisSchedual(orgID int64, patientID int64, scheduleDate int64) (*models.XtSchedule, error) {
643
+	var schedule models.XtSchedule
644
+	err := readDb.Model(&models.XtSchedule{}).Where("patient_id = ? and user_org_id = ? and status = 1 and schedule_date = ?", patientID, orgID, scheduleDate).First(&schedule).Error
645
+	if err != nil {
646
+		if err == gorm.ErrRecordNotFound {
647
+			return nil, nil
648
+		} else {
649
+			return nil, err
650
+		}
651
+	}
652
+	return &schedule, nil
653
+}
654
+
642 655
 // 透析方案
643 656
 func MobileGetDialysisSolution(orgID int64, patientID int64) (*models.DialysisSolution, error) {
644 657
 	var record models.DialysisSolution

+ 37 - 1
service/patient_service.go Näytä tiedosto

@@ -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
@@ -1369,3 +1369,39 @@ func FindDoctorAdviceByIdsTwo(orgID int64, ids []string) (advice []models.Doctor
1369 1369
 	err = readDb.Model(&models.DoctorAdvice{}).Where("user_org_id = ? AND status = 1 AND execution_state = 2 AND (id IN (?) OR parent_id IN (?))", orgID, ids, ids).Find(&advice).Error
1370 1370
 	return
1371 1371
 }
1372
+
1373
+func CreateHisGroupAdvice(orgId int64, advices []*models.HisGroupAdvice, groupNo int64) (list []*models.HisGroupAdvice, err error) {
1374
+	if groupNo <= 0 {
1375
+		group := GetMaxAdviceGroupID(orgId)
1376
+		groupNo = group + 1
1377
+	}
1378
+	tx := writeDb.Begin()
1379
+	defer func() {
1380
+		if r := recover(); r != nil {
1381
+			tx.Rollback()
1382
+		}
1383
+	}()
1384
+	for _, advice := range advices {
1385
+		advice.Groupno = groupNo
1386
+		if err = tx.Create(advice).Error; err != nil {
1387
+			tx.Rollback()
1388
+			return
1389
+		}
1390
+		list = append(list, advice)
1391
+		if len(advice.Children) > 0 {
1392
+			for _, child := range advice.Children {
1393
+				child.Groupno = groupNo
1394
+				child.ParentId = advice.ID
1395
+				fmt.Println(child)
1396
+				if err = tx.Create(&child).Error; err != nil {
1397
+					tx.Rollback()
1398
+					return
1399
+				}
1400
+				list = append(list, child)
1401
+			}
1402
+		}
1403
+
1404
+	}
1405
+	tx.Commit()
1406
+	return
1407
+}

+ 1 - 1
service/schedule_service.go Näytä tiedosto

@@ -13,7 +13,7 @@ import (
13 13
 //GetSchedulePartitionPanel 取出排班面板,分区-机号
14 14
 func GetSchedulePartitionPanel(orgID int64) (partitions []*models.Partition, err error) {
15 15
 
16
-	err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1", orgID).Where("org_id=? and status=1", orgID).Find(&partitions).Error
16
+	err = readDb.Model(&models.DeviceZone{}).Preload("Jihaos", "org_id=? and status=1", orgID).Where("org_id=? and status=1", orgID).Order("").Find(&partitions).Error
17 17
 
18 18
 	return
19 19
 }

+ 93 - 7
service/self_drug_service.go Näytä tiedosto

@@ -358,12 +358,12 @@ func GetAllPatientStockList(drug_name string, drug_spec string, startime int64,
358 358
 	if len(drug_spec) > 0 {
359 359
 		db = db.Where("x.drug_spec = ?", drug_spec)
360 360
 	}
361
-	if startime > 0 {
362
-		db = db.Where("x.storck_time >= ?", startime)
363
-	}
364
-	if endtime > 0 {
365
-		db = db.Where("x.storck_time <= ?", endtime)
366
-	}
361
+	//if startime > 0 {
362
+	//	db = db.Where("x.storck_time >= ?", startime)
363
+	//}
364
+	//if endtime > 0 {
365
+	//	db = db.Where("x.storck_time <= ?", endtime)
366
+	//}
367 367
 	if orgid > 0 {
368 368
 		db = db.Where("x.user_org_id = ?", orgid)
369 369
 	}
@@ -566,7 +566,7 @@ func (PrivateDrug) TableName() string {
566 566
 }
567 567
 
568 568
 func GetPrivateDrugList(patient_id int64, org_id int64) (pds []*PrivateDrug, err error) {
569
-	err = XTReadDB().Model(&PrivateDrug{}).Preload("PrivateDrug", "status = 1 AND user_org_id = ? AND patient_id = ? ", org_id, patient_id).Where("patient_id = ? and status = 1 AND user_org_id = ?", patient_id, org_id).Group("drug_name").Find(&pds).Error
569
+	err = XTReadDB().Model(&PrivateDrug{}).Preload("PrivateDrug", "status = 1 AND user_org_id = ? AND patient_id = ? ", org_id, patient_id).Where("patient_id = ? and status = 1 AND user_org_id = ?", patient_id, org_id).Group("drug_name_id").Find(&pds).Error
570 570
 	return
571 571
 }
572 572
 
@@ -583,18 +583,54 @@ func DeleteDrugNameById(id int64) (models.XtSelfMedical, error) {
583 583
 	return medical, err
584 584
 }
585 585
 
586
+func GetDrugNameIsExist(drugid int64, orgid int64) (*models.XtDrugName, error) {
587
+	drugName := models.XtDrugName{}
588
+	err := XTReadDB().Model(&drugName).Where("drug_id = ? and user_org_id = ? and status = 1", drugid, orgid).Find(&drugName).Error
589
+	if err == gorm.ErrRecordNotFound {
590
+		return nil, err
591
+	}
592
+	if err != nil {
593
+		return nil, err
594
+	}
595
+	return &drugName, nil
596
+}
597
+
586 598
 func UpdatedDrugName(id int64, orgid int64, drugName *models.XtDrugName) error {
587 599
 
588 600
 	err := XTWriteDB().Model(&drugName).Where("drug_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_name": drugName.DrugName}).Error
589 601
 	return err
590 602
 }
591 603
 
604
+func GetStandNameIsExist(id int64, orgid int64) (*models.XtStandName, error) {
605
+	standName := models.XtStandName{}
606
+	err := XTReadDB().Model(&standName).Where("drug_name_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&standName).Error
607
+	if err == gorm.ErrRecordNotFound {
608
+		return nil, err
609
+	}
610
+	if err != nil {
611
+		return nil, err
612
+	}
613
+	return &standName, nil
614
+}
615
+
592 616
 func UpdateStandName(id int64, orgid int64, standName *models.XtStandName) error {
593 617
 
594 618
 	err := XTWriteDB().Model(&standName).Where("drug_name_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_name": standName.DrugName, "drug_spec": standName.DrugSpec, "drug_stock_limit": standName.DrugStockLimit, "min_unit": standName.MinUnit}).Error
595 619
 	return err
596 620
 }
597 621
 
622
+func GetSelfMedicalIsExist(id int64, orgid int64) (*models.XtSelfMedical, error) {
623
+	medical := models.XtSelfMedical{}
624
+	err := XTReadDB().Model(&medical).Where("drug_name_id = ? and user_org_id = ? and status =1", id, orgid).Find(&medical).Error
625
+	if err == gorm.ErrRecordNotFound {
626
+		return nil, err
627
+	}
628
+	if err != nil {
629
+		return nil, err
630
+	}
631
+	return &medical, nil
632
+}
633
+
598 634
 func UpdateSelfMedical(id int64, orgid int64, medical *models.XtSelfMedical) error {
599 635
 
600 636
 	err := XTWriteDB().Model(&medical).Where("drug_name_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_name": medical.DrugName, "drug_spec": medical.DrugSpec, "execution_frequency": medical.ExecutionFrequency, "prescribing_number": medical.PrescribingNumber, "delivery_way": medical.DeliveryWay, "single_dose": medical.SingleDose, "min_unit": medical.MinUnit}).Error
@@ -608,23 +644,73 @@ func GetDrugNameId(id int64, orgid int64) (models.XtSelfMedical, error) {
608 644
 	return medical, err
609 645
 }
610 646
 
647
+func GetSelfStosckIsExist(id int64, orgid int64) (*models.XtSelfStock, error) {
648
+
649
+	medical := models.XtSelfStock{}
650
+	err := XTReadDB().Model(&medical).Where("drug_name_id = ? and user_org_id = ? and status  =1", id, orgid).Find(&medical).Error
651
+	if err == gorm.ErrRecordNotFound {
652
+		return nil, err
653
+	}
654
+	if err != nil {
655
+		return nil, err
656
+	}
657
+	return &medical, nil
658
+}
659
+
611 660
 func UpdatedSelfStock(stock *models.XtSelfStock, id int64, orgid int64) error {
612 661
 	err := XTWriteDB().Model(&stock).Where("drug_name_id=? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_name": stock.DrugName, "min_unit": stock.MinUnit, "drug_spec": stock.DrugSpec}).Error
613 662
 	return err
614 663
 }
615 664
 
665
+func GetOutSelfOutStockIsExist(id int64, orgid int64) (*models.XtSelfOutStock, error) {
666
+
667
+	outStock := models.XtSelfOutStock{}
668
+	err := XTReadDB().Model(&outStock).Where("drug_name_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&outStock).Error
669
+	if err == gorm.ErrRecordNotFound {
670
+		return nil, err
671
+	}
672
+	if err != nil {
673
+		return nil, err
674
+	}
675
+	return &outStock, nil
676
+}
677
+
616 678
 func UpdatedOutSelfStock(stock *models.XtSelfOutStock, id int64, orgid int64) error {
617 679
 
618 680
 	err := XTWriteDB().Model(&stock).Where("drug_name_id = ? and user_org_id = ? and status = 1", id, orgid).Update(map[string]interface{}{"drug_name": stock.DrugName, "drug_spec": stock.DrugSpec}).Error
619 681
 	return err
620 682
 }
621 683
 
684
+func GetDoctorAdviceIsExist(id int64, orgid int64) (*models.DoctorAdvice, error) {
685
+	advice := models.DoctorAdvice{}
686
+	err := XTReadDB().Model(&advice).Where("drug_id = ? and user_org_id = ? and status = 1", id, orgid).Find(&advice).Error
687
+	if err == gorm.ErrRecordNotFound {
688
+		return nil, err
689
+	}
690
+	if err != nil {
691
+		return nil, err
692
+	}
693
+	return &advice, nil
694
+}
695
+
622 696
 func UpdateNoExcuteDoctorAdvice(id int64, orgid int64, advice *models.DoctorAdvice) error {
623 697
 
624 698
 	err := XTWriteDB().Model(&advice).Where("drug_id = ? and user_org_id = ? and status = 1 and  execution_state = 2", id, orgid).Updates(map[string]interface{}{"advice_name": advice.AdviceName, "advice_desc": advice.AdviceDesc, "single_dose": advice.SingleDose, "single_dose_unit": advice.SingleDoseUnit, "delivery_way": advice.DeliveryWay, "execution_frequency": advice.ExecutionFrequency}).Error
625 699
 	return err
626 700
 }
627 701
 
702
+func GetDoctorAdviceTemplateIsExist(id int64, orgid int64) (*models.DoctorAdviceTemplate, error) {
703
+	template := models.DoctorAdviceTemplate{}
704
+	err := XTReadDB().Model(&template).Where("drug_id = ? and org_id = ? and status = 1", id, orgid).Find(&template).Error
705
+	if err == gorm.ErrRecordNotFound {
706
+		return nil, err
707
+	}
708
+	if err != nil {
709
+		return nil, err
710
+	}
711
+	return &template, nil
712
+}
713
+
628 714
 func UpdatedDoctorAdviceTemplate(id int64, orgid int64, template *models.DoctorAdviceTemplate) error {
629 715
 
630 716
 	err := XTWriteDB().Model(&template).Where("drug_id = ? and org_id = ? and status = 1", id, orgid).Updates(map[string]interface{}{"advice_name": template.AdviceName, "advice_desc": template.AdviceDesc, "single_dose": template.SingleDose, "single_dose_unit": template.SingleDoseUnit, "delivery_way": template.DeliveryWay, "execution_frequency": template.ExecutionFrequency}).Error

+ 2 - 2
service/stock_service.go Näytä tiedosto

@@ -1874,8 +1874,8 @@ func FindGoodTypeByName(name string, org_id int64) (total int64) {
1874 1874
 	readDb.Model(&models.GoodsType{}).Where("org_id = ? AND status = 1 AND type_name = ? ", org_id, name).Count(&total)
1875 1875
 	return
1876 1876
 }
1877
-func FindGoodInfoByName(name string, org_id int64) (total int64) {
1878
-	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? ", org_id, name).Count(&total)
1877
+func FindGoodInfoByName(name string, org_id int64, good_type_id int64) (total int64) {
1878
+	readDb.Model(&models.GoodInfo{}).Where("org_id = ? AND status = 1 AND specification_name = ? AND good_type_id = ? ", org_id, name, good_type_id).Count(&total)
1879 1879
 	return
1880 1880
 }
1881 1881