|
@@ -0,0 +1,680 @@
|
|
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
|
+ "strings"
|
|
13
|
+ "time"
|
|
14
|
+)
|
|
15
|
+
|
|
16
|
+type HisApiController struct {
|
|
17
|
+ BaseAuthAPIController
|
|
18
|
+}
|
|
19
|
+
|
|
20
|
+func HisManagerApiRegistRouters() {
|
|
21
|
+
|
|
22
|
+ beego.Router("/api/hispatient/list", &HisApiController{}, "get:GetHisPatientList")
|
|
23
|
+ beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
|
|
24
|
+ beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
|
|
25
|
+
|
|
26
|
+ beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
|
|
27
|
+ beego.Router("/api/hisdoctoradvice/create", &HisApiController{}, "post:CreateHisDoctorAdvice")
|
|
28
|
+ //beego.Router("/api/hisproject/create", &HisApiController{}, "post:CreateHisProject")
|
|
29
|
+ //beego.Router("/api/hisorder/create", &HisApiController{}, "post:CreateHisOrder")
|
|
30
|
+ //beego.Router("/api/hisadditional/create", &HisApiController{}, "post:CreateHisAdditionalCharge")
|
|
31
|
+
|
|
32
|
+ beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
|
|
33
|
+ beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
|
|
34
|
+ beego.Router("/api/doctorworkstation/casehistory/create", &HisApiController{}, "post:CreateHisPatientCaseHistory")
|
|
35
|
+ beego.Router("/api/doctorworkstation/casehistorytemplate/create", &HisApiController{}, "post:CreateCaseHistoryTemplate")
|
|
36
|
+ beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
|
|
37
|
+ beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
|
|
38
|
+
|
|
39
|
+}
|
|
40
|
+
|
|
41
|
+func (c *HisApiController) GetHisPatientList() {
|
|
42
|
+ types, _ := c.GetInt64("type", 0)
|
|
43
|
+ record_date := c.GetString("record_date")
|
|
44
|
+ timeLayout := "2006-01-02"
|
|
45
|
+ loc, _ := time.LoadLocation("Local")
|
|
46
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
47
|
+ if err != nil {
|
|
48
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
49
|
+ return
|
|
50
|
+ }
|
|
51
|
+ recordDateTime := theTime.Unix()
|
|
52
|
+ adminInfo := c.GetAdminUserInfo()
|
|
53
|
+ patients, _ := service.GetHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
|
|
54
|
+ if types == 0 {
|
|
55
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
56
|
+ "list": patients,
|
|
57
|
+ })
|
|
58
|
+
|
|
59
|
+ } else if types == 1 { //未就诊
|
|
60
|
+ var patientsOne []*service.Schedule
|
|
61
|
+ for _, item := range patients {
|
|
62
|
+ if item.HisPrescription == nil || len(item.HisPrescription) <= 0 {
|
|
63
|
+ patientsOne = append(patientsOne, item)
|
|
64
|
+ }
|
|
65
|
+ }
|
|
66
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
67
|
+ "list": patientsOne,
|
|
68
|
+ })
|
|
69
|
+
|
|
70
|
+ } else if types == 2 { //已就诊
|
|
71
|
+ var patientsTwo []*service.Schedule
|
|
72
|
+ for _, item := range patients {
|
|
73
|
+ if item.HisPrescription != nil && len(item.HisPrescription) > 0 {
|
|
74
|
+ patientsTwo = append(patientsTwo, item)
|
|
75
|
+ }
|
|
76
|
+ }
|
|
77
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
78
|
+ "list": patientsTwo,
|
|
79
|
+ })
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+}
|
|
83
|
+func (c *HisApiController) GetHisPatientInfo() {
|
|
84
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
85
|
+ record_date := c.GetString("record_date")
|
|
86
|
+ timeLayout := "2006-01-02"
|
|
87
|
+ loc, _ := time.LoadLocation("Local")
|
|
88
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
89
|
+ if err != nil {
|
|
90
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
91
|
+ return
|
|
92
|
+ }
|
|
93
|
+ recordDateTime := theTime.Unix()
|
|
94
|
+
|
|
95
|
+ admin := c.GetAdminUserInfo()
|
|
96
|
+ his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
|
97
|
+ xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
|
|
98
|
+
|
|
99
|
+ prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
|
|
100
|
+
|
|
101
|
+ //prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
|
|
102
|
+ case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
|
103
|
+
|
|
104
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
105
|
+ "his_info": his_patient_info,
|
|
106
|
+ "xt_info": xt_patient_info,
|
|
107
|
+ "prescription": prescriptions,
|
|
108
|
+ "case_history": case_history,
|
|
109
|
+ })
|
|
110
|
+ return
|
|
111
|
+
|
|
112
|
+}
|
|
113
|
+func (c *HisApiController) GetHisPrescriptionConfig() {
|
|
114
|
+ adminInfo := c.GetAdminUserInfo()
|
|
115
|
+ //获取医嘱模版
|
|
116
|
+ advices, _ := service.FindAllHisAdviceTemplate(adminInfo.CurrentOrgId)
|
|
117
|
+ //获取所有基础药
|
|
118
|
+ drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
|
|
119
|
+ //获取所有项目
|
|
120
|
+ projects, _ := service.GetAllProjectList(adminInfo.CurrentOrgId)
|
|
121
|
+ //获取所有项目组套
|
|
122
|
+
|
|
123
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
124
|
+ "drugs": drugs,
|
|
125
|
+ "advices_template": advices,
|
|
126
|
+ "projects": projects,
|
|
127
|
+ })
|
|
128
|
+}
|
|
129
|
+func (c *HisApiController) CreateHisPrescription() {
|
|
130
|
+ record_date := c.GetString("record_date")
|
|
131
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
132
|
+ his_patient_id, _ := c.GetInt64("his_patient_id")
|
|
133
|
+ types, _ := c.GetInt64("type")
|
|
134
|
+ doctor := c.GetAdminUserInfo().AdminUser.Id
|
|
135
|
+
|
|
136
|
+ timeLayout := "2006-01-02"
|
|
137
|
+ loc, _ := time.LoadLocation("Local")
|
|
138
|
+
|
|
139
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
140
|
+ if err != nil {
|
|
141
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
142
|
+ return
|
|
143
|
+ }
|
|
144
|
+ recordDateTime := theTime.Unix()
|
|
145
|
+
|
|
146
|
+ prescription := &models.HisPrescription{
|
|
147
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
148
|
+ RecordDate: recordDateTime,
|
|
149
|
+ PatientId: patient_id,
|
|
150
|
+ HisPatientId: his_patient_id,
|
|
151
|
+ Status: 1,
|
|
152
|
+ Ctime: time.Now().Unix(),
|
|
153
|
+ Mtime: time.Now().Unix(),
|
|
154
|
+ Type: types,
|
|
155
|
+ Doctor: doctor,
|
|
156
|
+ Creator: doctor,
|
|
157
|
+ Modifier: doctor,
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+ err = service.SaveHisPrescription(prescription)
|
|
161
|
+ if err == nil {
|
|
162
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
163
|
+ "msg": "保存成功",
|
|
164
|
+ })
|
|
165
|
+ return
|
|
166
|
+
|
|
167
|
+ } else {
|
|
168
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
169
|
+ return
|
|
170
|
+ }
|
|
171
|
+}
|
|
172
|
+func (c *HisApiController) CreateHisDoctorAdvice() {
|
|
173
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
174
|
+ his_patient_id, _ := c.GetInt64("his_patient_id")
|
|
175
|
+ prescription_id, _ := c.GetInt64("prescription_id")
|
|
176
|
+
|
|
177
|
+ //patient, _ := c.GetInt64("id", 0)
|
|
178
|
+ //if patient <= 0 {
|
|
179
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
180
|
+ // return
|
|
181
|
+ //}
|
|
182
|
+ adminUserInfo := c.GetAdminUserInfo()
|
|
183
|
+
|
|
184
|
+ //patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
|
|
185
|
+ //if patientInfo.ID == 0 {
|
|
186
|
+ // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
|
187
|
+ // return
|
|
188
|
+ //}
|
|
189
|
+
|
|
190
|
+ group_no, _ := c.GetInt64("group_no")
|
|
191
|
+ if group_no <= 0 {
|
|
192
|
+ group_no = 0
|
|
193
|
+ }
|
|
194
|
+
|
|
195
|
+ dataBody := make(map[string]interface{}, 0)
|
|
196
|
+ err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
197
|
+ if err != nil {
|
|
198
|
+ utils.ErrorLog(err.Error())
|
|
199
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
200
|
+ return
|
|
201
|
+ }
|
|
202
|
+
|
|
203
|
+ timeLayout := "2006-01-02"
|
|
204
|
+ loc, _ := time.LoadLocation("Local")
|
|
205
|
+
|
|
206
|
+ if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
|
|
207
|
+ utils.ErrorLog("advice_type")
|
|
208
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
209
|
+ return
|
|
210
|
+ }
|
|
211
|
+ adviceType := int64(dataBody["advice_type"].(float64))
|
|
212
|
+ if adviceType != 1 && adviceType != 2 {
|
|
213
|
+ utils.ErrorLog("advice_type != 1&&2")
|
|
214
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
215
|
+ return
|
|
216
|
+ }
|
|
217
|
+
|
|
218
|
+ if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
|
|
219
|
+ utils.ErrorLog("start_time")
|
|
220
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
221
|
+ return
|
|
222
|
+ }
|
|
223
|
+
|
|
224
|
+ startTime2, _ := dataBody["start_time"].(string)
|
|
225
|
+ time_arr := strings.Split(startTime2, " ")
|
|
226
|
+ if len(time_arr) > 0 {
|
|
227
|
+ startTime2 = time_arr[0]
|
|
228
|
+ }
|
|
229
|
+ if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
|
|
230
|
+ utils.ErrorLog("advice_date")
|
|
231
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
232
|
+ return
|
|
233
|
+ }
|
|
234
|
+ adviceDate := startTime2
|
|
235
|
+ if len(adviceDate) == 0 {
|
|
236
|
+ utils.ErrorLog("len(adviceDate) == 0")
|
|
237
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
238
|
+ return
|
|
239
|
+ }
|
|
240
|
+ theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
|
|
241
|
+ if err != nil {
|
|
242
|
+ utils.ErrorLog(err.Error())
|
|
243
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
244
|
+ return
|
|
245
|
+ }
|
|
246
|
+ AdviceDate := theTime.Unix()
|
|
247
|
+ RecordDate := theTime.Unix()
|
|
248
|
+
|
|
249
|
+ if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
|
|
250
|
+ utils.ErrorLog("start_time")
|
|
251
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
252
|
+ return
|
|
253
|
+ }
|
|
254
|
+ startTime, _ := dataBody["start_time"].(string)
|
|
255
|
+ if len(startTime) == 0 {
|
|
256
|
+ utils.ErrorLog("len(start_time) == 0")
|
|
257
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
258
|
+ return
|
|
259
|
+ }
|
|
260
|
+ theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
|
|
261
|
+ if err != nil {
|
|
262
|
+ utils.ErrorLog(err.Error())
|
|
263
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
264
|
+ return
|
|
265
|
+ }
|
|
266
|
+ StartTime := theTime.Unix()
|
|
267
|
+
|
|
268
|
+ Remark := ""
|
|
269
|
+ if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
|
|
270
|
+ remark, _ := dataBody["remark"].(string)
|
|
271
|
+ Remark = remark
|
|
272
|
+ }
|
|
273
|
+
|
|
274
|
+ var advices []*models.HisGroupAdvice
|
|
275
|
+ // utils.TraceLog("%+v", dataBody["adviceNames"])
|
|
276
|
+ if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
|
|
277
|
+ utils.ErrorLog("adviceNames")
|
|
278
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
279
|
+ return
|
|
280
|
+ }
|
|
281
|
+ adviceNames := dataBody["adviceNames"].([]interface{})
|
|
282
|
+ for _, adviceNameMap := range adviceNames {
|
|
283
|
+ adviceNameM := adviceNameMap.(map[string]interface{})
|
|
284
|
+ var advice models.HisGroupAdvice
|
|
285
|
+ advice.Remark = Remark
|
|
286
|
+ advice.AdviceType = adviceType
|
|
287
|
+ advice.StartTime = StartTime
|
|
288
|
+ advice.AdviceDate = AdviceDate
|
|
289
|
+ advice.RecordDate = RecordDate
|
|
290
|
+ advice.Status = 1
|
|
291
|
+ advice.CreatedTime = time.Now().Unix()
|
|
292
|
+ advice.UpdatedTime = time.Now().Unix()
|
|
293
|
+ advice.StopState = 2
|
|
294
|
+ advice.ExecutionState = 2
|
|
295
|
+ advice.UserOrgId = adminUserInfo.CurrentOrgId
|
|
296
|
+ advice.PatientId = patient_id
|
|
297
|
+ advice.HisPatientId = his_patient_id
|
|
298
|
+ advice.AdviceDoctor = adminUserInfo.AdminUser.Id
|
|
299
|
+ advice.PrescriptionId = prescription_id
|
|
300
|
+
|
|
301
|
+ //入口
|
|
302
|
+ errcode := c.setAdviceWithJSON(&advice, adviceNameM)
|
|
303
|
+ if errcode > 0 {
|
|
304
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
305
|
+ return
|
|
306
|
+ }
|
|
307
|
+
|
|
308
|
+ if adviceNameM["subdrugs"] != nil && reflect.TypeOf(adviceNameM["subdrugs"]).String() == "[]interface {}" {
|
|
309
|
+ subdrugs := adviceNameM["subdrugs"].([]interface{})
|
|
310
|
+ if len(subdrugs) > 0 {
|
|
311
|
+ for _, subdrug := range subdrugs {
|
|
312
|
+ var s models.HisGroupAdvice
|
|
313
|
+ s.Remark = Remark
|
|
314
|
+ s.AdviceType = adviceType
|
|
315
|
+ s.StartTime = StartTime
|
|
316
|
+ s.AdviceDate = AdviceDate
|
|
317
|
+ s.RecordDate = RecordDate
|
|
318
|
+ s.Status = 1
|
|
319
|
+ s.CreatedTime = time.Now().Unix()
|
|
320
|
+ s.UpdatedTime = time.Now().Unix()
|
|
321
|
+ s.StopState = 2
|
|
322
|
+ s.ExecutionState = 2
|
|
323
|
+ s.HisPatientId = his_patient_id
|
|
324
|
+ s.UserOrgId = adminUserInfo.CurrentOrgId
|
|
325
|
+ s.PatientId = patient_id
|
|
326
|
+ s.AdviceDoctor = adminUserInfo.AdminUser.Id
|
|
327
|
+
|
|
328
|
+ errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
|
|
329
|
+ if errcode > 0 {
|
|
330
|
+ c.ServeFailJSONWithSGJErrorCode(errcode)
|
|
331
|
+ return
|
|
332
|
+ }
|
|
333
|
+
|
|
334
|
+ advice.Children = append(advice.Children, &s)
|
|
335
|
+ }
|
|
336
|
+ }
|
|
337
|
+ }
|
|
338
|
+
|
|
339
|
+ advices = append(advices, &advice)
|
|
340
|
+ }
|
|
341
|
+
|
|
342
|
+ newAdvices, createErr := service.CreateHisGroupAdvice(adminUserInfo.CurrentOrgId, advices, group_no)
|
|
343
|
+ if createErr != nil {
|
|
344
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
|
|
345
|
+ return
|
|
346
|
+ }
|
|
347
|
+
|
|
348
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
349
|
+ "msg": "ok",
|
|
350
|
+ "advices": newAdvices,
|
|
351
|
+ })
|
|
352
|
+ return
|
|
353
|
+
|
|
354
|
+}
|
|
355
|
+
|
|
356
|
+func (c *HisApiController) CreateHisAdditionalCharge() {
|
|
357
|
+ his_patient_id, _ := c.GetInt64("his_patient_id")
|
|
358
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
359
|
+ record_date := c.GetString("record_date")
|
|
360
|
+ timeLayout := "2006-01-02"
|
|
361
|
+ loc, _ := time.LoadLocation("Local")
|
|
362
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
363
|
+ if err != nil {
|
|
364
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
365
|
+ return
|
|
366
|
+ }
|
|
367
|
+ adminInfo := c.GetAdminUserInfo()
|
|
368
|
+ recordDateTime := theTime.Unix()
|
|
369
|
+ dataBody := make(map[string]interface{}, 0)
|
|
370
|
+ err = json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
371
|
+ if err != nil {
|
|
372
|
+ utils.ErrorLog(err.Error())
|
|
373
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
374
|
+ return
|
|
375
|
+ }
|
|
376
|
+
|
|
377
|
+ var additions []*models.HisAdditionalCharge
|
|
378
|
+ if dataBody["addition"] != nil && reflect.TypeOf(dataBody["addition"]).String() == "[]interface {}" {
|
|
379
|
+ additions, _ := dataBody["addition"].([]interface{})
|
|
380
|
+ if len(additions) > 0 {
|
|
381
|
+ for _, item := range additions {
|
|
382
|
+ items := item.(map[string]interface{})
|
|
383
|
+
|
|
384
|
+ if items["item_id"] == nil || reflect.TypeOf(items["item_id"]).String() != "float64" {
|
|
385
|
+ utils.ErrorLog("item_id")
|
|
386
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
387
|
+ return
|
|
388
|
+ }
|
|
389
|
+ item_id := int64(items["item_id"].(float64))
|
|
390
|
+
|
|
391
|
+ if items["item_name"] == nil || reflect.TypeOf(items["item_name"]).String() != "string" {
|
|
392
|
+ utils.ErrorLog("item_name")
|
|
393
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
394
|
+ return
|
|
395
|
+ }
|
|
396
|
+ item_name := items["item_name"].(string)
|
|
397
|
+
|
|
398
|
+ if items["price"] == nil || reflect.TypeOf(items["price"]).String() != "string" {
|
|
399
|
+ utils.ErrorLog("price")
|
|
400
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
401
|
+ return
|
|
402
|
+ }
|
|
403
|
+ price, _ := strconv.ParseFloat(items["price"].(string), 64)
|
|
404
|
+
|
|
405
|
+ ctime := time.Now().Unix()
|
|
406
|
+ additional := &models.HisAdditionalCharge{
|
|
407
|
+ PatientId: patient_id,
|
|
408
|
+ HisPatientId: his_patient_id,
|
|
409
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
410
|
+ RecordDate: recordDateTime,
|
|
411
|
+ CreatedTime: ctime,
|
|
412
|
+ UpdatedTime: ctime,
|
|
413
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
414
|
+ Creator: adminInfo.AdminUser.Id,
|
|
415
|
+ Price: price,
|
|
416
|
+ ItemName: item_name,
|
|
417
|
+ ItemId: item_id,
|
|
418
|
+ Status: 1,
|
|
419
|
+ }
|
|
420
|
+ additions = append(additions, additional)
|
|
421
|
+ }
|
|
422
|
+ }
|
|
423
|
+ }
|
|
424
|
+ for _, item := range additions {
|
|
425
|
+ service.CreateAddtionalCharge(item)
|
|
426
|
+ }
|
|
427
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
428
|
+ "msg": "创建成功",
|
|
429
|
+ })
|
|
430
|
+}
|
|
431
|
+
|
|
432
|
+func (c *HisApiController) CreateHisPatientCaseHistory() {
|
|
433
|
+ diagnostic := c.GetString("diagnostic")
|
|
434
|
+ temperature, _ := c.GetFloat("temperature")
|
|
435
|
+ blood_sugar, _ := c.GetFloat("blood_sugar")
|
|
436
|
+ pulse, _ := c.GetFloat("pulse")
|
|
437
|
+ sbp, _ := c.GetFloat("sbp")
|
|
438
|
+ dbp, _ := c.GetFloat("dbp")
|
|
439
|
+ blood_fat, _ := c.GetFloat("blood_fat")
|
|
440
|
+ height, _ := c.GetFloat("height")
|
|
441
|
+ sick_type, _ := c.GetInt64("sick_type")
|
|
442
|
+ symptom := c.GetString("symptom")
|
|
443
|
+ sick_date := c.GetString("sick_date")
|
|
444
|
+ is_infect, _ := c.GetInt64("is_infect")
|
|
445
|
+ chief_conplaint := c.GetString("chief_conplaint")
|
|
446
|
+ history_of_present_illness := c.GetString("history_of_present_illness")
|
|
447
|
+ past_history := c.GetString("past_history")
|
|
448
|
+ personal_history := c.GetString("personal_history")
|
|
449
|
+ family_history := c.GetString("family_history")
|
|
450
|
+ record_date := c.GetString("record_date")
|
|
451
|
+ patient_id, _ := c.GetInt64("patient_id")
|
|
452
|
+ timeLayout := "2006-01-02"
|
|
453
|
+ loc, _ := time.LoadLocation("Local")
|
|
454
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
455
|
+ if err != nil {
|
|
456
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
457
|
+ return
|
|
458
|
+ }
|
|
459
|
+ recordDateTime := theTime.Unix()
|
|
460
|
+ sickTime, err := time.ParseInLocation(timeLayout+" 15:04:05", sick_date+" 00:00:00", loc)
|
|
461
|
+ if err != nil {
|
|
462
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
463
|
+ return
|
|
464
|
+ }
|
|
465
|
+ sickTimes := sickTime.Unix()
|
|
466
|
+ ctime := time.Now().Unix()
|
|
467
|
+ caseHistory := models.HisPatientCaseHistory{
|
|
468
|
+ HisPatientId: patient_id,
|
|
469
|
+ Temperature: temperature,
|
|
470
|
+ BloodSugar: blood_sugar,
|
|
471
|
+ Pulse: pulse,
|
|
472
|
+ Sbp: sbp,
|
|
473
|
+ Dbp: dbp,
|
|
474
|
+ Height: height,
|
|
475
|
+ BloodFat: blood_fat,
|
|
476
|
+ SickType: sick_type,
|
|
477
|
+ Symptom: symptom,
|
|
478
|
+ SickDate: sickTimes,
|
|
479
|
+ IsInfect: is_infect,
|
|
480
|
+ HistoryOfPresentIllness: history_of_present_illness,
|
|
481
|
+ PastHistory: past_history,
|
|
482
|
+ Doctor: c.GetAdminUserInfo().AdminUser.Id,
|
|
483
|
+ ChiefConplaint: chief_conplaint,
|
|
484
|
+ PersonalHistory: personal_history,
|
|
485
|
+ FamilyHistory: family_history,
|
|
486
|
+ Diagnostic: diagnostic,
|
|
487
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
488
|
+ Status: 1,
|
|
489
|
+ Ctime: ctime,
|
|
490
|
+ Mtime: ctime,
|
|
491
|
+ RecordDate: recordDateTime,
|
|
492
|
+ }
|
|
493
|
+ err = service.SaveHisPatientCaseHistory(caseHistory)
|
|
494
|
+ if err != nil {
|
|
495
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
496
|
+ "msg": "保存成功",
|
|
497
|
+ })
|
|
498
|
+ }
|
|
499
|
+}
|
|
500
|
+func (c *HisApiController) GetHisPatientCaseHistoryList() {
|
|
501
|
+ patient_id, _ := c.GetInt64("patient_id", 0)
|
|
502
|
+ adminUser := c.GetAdminUserInfo()
|
|
503
|
+ caseHistorys, _ := service.GetHisPatientCaseHistoryList(adminUser.CurrentOrgId, patient_id)
|
|
504
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
505
|
+ "list": caseHistorys,
|
|
506
|
+ })
|
|
507
|
+
|
|
508
|
+}
|
|
509
|
+func (c *HisApiController) GetHisPatientCaseHistory() {
|
|
510
|
+ record_date, _ := c.GetInt64("record_date", 0)
|
|
511
|
+ patient_id, _ := c.GetInt64("patient_id", 0)
|
|
512
|
+ admin := c.GetAdminUserInfo()
|
|
513
|
+ info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, record_date)
|
|
514
|
+ case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, record_date)
|
|
515
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
516
|
+ "info": info,
|
|
517
|
+ "case_history": case_history,
|
|
518
|
+ })
|
|
519
|
+
|
|
520
|
+}
|
|
521
|
+func (c *HisApiController) CreateCaseHistoryTemplate() {
|
|
522
|
+ template_name := c.GetString("template_name")
|
|
523
|
+ template_remark := c.GetString("template_remark")
|
|
524
|
+ doctor := c.GetAdminUserInfo().AdminUser.Id
|
|
525
|
+ diagnostic := c.GetString("diagnostic")
|
|
526
|
+ chief_conplaint := c.GetString("chief_conplaint")
|
|
527
|
+ history_of_present_illness := c.GetString("history_of_present_illness")
|
|
528
|
+ past_history := c.GetString("past_history")
|
|
529
|
+ personal_history := c.GetString("personal_history")
|
|
530
|
+ family_history := c.GetString("family_history")
|
|
531
|
+ record_date := c.GetString("record_date")
|
|
532
|
+
|
|
533
|
+ timeLayout := "2006-01-02"
|
|
534
|
+ loc, _ := time.LoadLocation("Local")
|
|
535
|
+
|
|
536
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
|
|
537
|
+ if err != nil {
|
|
538
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
539
|
+ return
|
|
540
|
+ }
|
|
541
|
+ recordDateTime := theTime.Unix()
|
|
542
|
+
|
|
543
|
+ ctime := time.Now().Unix()
|
|
544
|
+
|
|
545
|
+ template := models.HisCaseHistoryTemplate{
|
|
546
|
+ HistoryOfPresentIllness: history_of_present_illness,
|
|
547
|
+ PastHistory: past_history,
|
|
548
|
+ ChiefConplaint: chief_conplaint,
|
|
549
|
+ PersonalHistory: personal_history,
|
|
550
|
+ FamilyHistory: family_history,
|
|
551
|
+ Diagnostic: diagnostic,
|
|
552
|
+ UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
|
|
553
|
+ Status: 1,
|
|
554
|
+ Ctime: ctime,
|
|
555
|
+ Mtime: ctime,
|
|
556
|
+ RecordDate: recordDateTime,
|
|
557
|
+ TemplateName: template_name,
|
|
558
|
+ TemplateRemark: template_remark,
|
|
559
|
+ Creator: doctor,
|
|
560
|
+ Modifier: doctor,
|
|
561
|
+ }
|
|
562
|
+
|
|
563
|
+ err = service.SaveHisPatientCaseHistoryTemplate(template)
|
|
564
|
+
|
|
565
|
+ if err == nil {
|
|
566
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
567
|
+ "msg": "保存成功",
|
|
568
|
+ })
|
|
569
|
+
|
|
570
|
+ } else {
|
|
571
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
572
|
+ return
|
|
573
|
+ }
|
|
574
|
+
|
|
575
|
+}
|
|
576
|
+func (c *HisApiController) GetCaseHistoryTemplate() {
|
|
577
|
+ admin := c.GetAdminUserInfo()
|
|
578
|
+ template, _ := service.GetHisPatientCaseHistoryTemplate(admin.CurrentOrgId)
|
|
579
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
580
|
+ "template": template,
|
|
581
|
+ })
|
|
582
|
+
|
|
583
|
+}
|
|
584
|
+func (c *HisApiController) GetPrintHisPatientCaseHistory() {
|
|
585
|
+
|
|
586
|
+}
|
|
587
|
+func (c *HisApiController) setAdviceWithJSON(advice *models.HisGroupAdvice, json map[string]interface{}) int {
|
|
588
|
+
|
|
589
|
+ if json["advice_name"] == nil || reflect.TypeOf(json["advice_name"]).String() != "string" {
|
|
590
|
+ utils.ErrorLog("advice_name")
|
|
591
|
+ return enums.ErrorCodeParamWrong
|
|
592
|
+ }
|
|
593
|
+ adviceName, _ := json["advice_name"].(string)
|
|
594
|
+ if len(adviceName) == 0 {
|
|
595
|
+ utils.ErrorLog("len(advice_name) == 0")
|
|
596
|
+ return enums.ErrorCodeParamWrong
|
|
597
|
+ }
|
|
598
|
+ advice.AdviceName = adviceName
|
|
599
|
+
|
|
600
|
+ adviceDesc, _ := json["advice_desc"].(string)
|
|
601
|
+ advice.AdviceDesc = adviceDesc
|
|
602
|
+
|
|
603
|
+ if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
|
|
604
|
+ drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
|
|
605
|
+ advice.DrugSpec = drugSpec
|
|
606
|
+ }
|
|
607
|
+
|
|
608
|
+ if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
|
|
609
|
+ remark, _ := json["remark"].(string)
|
|
610
|
+ advice.Remark = remark
|
|
611
|
+ }
|
|
612
|
+
|
|
613
|
+ //if json["src_type"] != nil || reflect.TypeOf(json["src_type"]).String() == "float64" {
|
|
614
|
+ // src_type, _ := strconv.ParseInt(json["src_type"].(string),10)
|
|
615
|
+ // advice.Way = src_type
|
|
616
|
+ //}
|
|
617
|
+ if json["way"] == nil {
|
|
618
|
+ advice.Way = 0
|
|
619
|
+
|
|
620
|
+ } else {
|
|
621
|
+ if json["way"] != nil || reflect.TypeOf(json["way"]).String() == "float64" {
|
|
622
|
+ way := int64(json["way"].(float64))
|
|
623
|
+ advice.Way = way
|
|
624
|
+ }
|
|
625
|
+
|
|
626
|
+ }
|
|
627
|
+
|
|
628
|
+ if json["drug_id"] == nil {
|
|
629
|
+ advice.DrugId = 0
|
|
630
|
+ } else {
|
|
631
|
+ if json["drug_id"] != nil || reflect.TypeOf(json["drug_id"]).String() == "float64" {
|
|
632
|
+ drug_id := int64(json["drug_id"].(float64))
|
|
633
|
+ advice.DrugId = drug_id
|
|
634
|
+ }
|
|
635
|
+ }
|
|
636
|
+
|
|
637
|
+ if json["drug_name_id"] == nil {
|
|
638
|
+ advice.DrugNameId = 0
|
|
639
|
+ } else {
|
|
640
|
+ if json["drug_name_id"] != nil || reflect.TypeOf(json["drug_name_id"]).String() == "float64" {
|
|
641
|
+ drug_name_id := int64(json["drug_name_id"].(float64))
|
|
642
|
+ advice.DrugNameId = drug_name_id
|
|
643
|
+ }
|
|
644
|
+ }
|
|
645
|
+
|
|
646
|
+ if json["drug_spec_unit"] != nil && reflect.TypeOf(json["drug_spec_unit"]).String() == "string" {
|
|
647
|
+ drugSpecUnit, _ := json["drug_spec_unit"].(string)
|
|
648
|
+ advice.DrugSpecUnit = drugSpecUnit
|
|
649
|
+ }
|
|
650
|
+
|
|
651
|
+ if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
|
|
652
|
+ singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
|
|
653
|
+ advice.SingleDose = singleDose
|
|
654
|
+ }
|
|
655
|
+
|
|
656
|
+ if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
|
|
657
|
+ singleDoseUnit, _ := json["single_dose_unit"].(string)
|
|
658
|
+ advice.SingleDoseUnit = singleDoseUnit
|
|
659
|
+ }
|
|
660
|
+
|
|
661
|
+ if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
|
|
662
|
+ prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
|
|
663
|
+ advice.PrescribingNumber = prescribingNumber
|
|
664
|
+ }
|
|
665
|
+
|
|
666
|
+ if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
|
|
667
|
+ prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
|
|
668
|
+ advice.PrescribingNumberUnit = prescribingNumberUnit
|
|
669
|
+ }
|
|
670
|
+ if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
|
|
671
|
+ deliveryWay, _ := json["delivery_way"].(string)
|
|
672
|
+ advice.DeliveryWay = deliveryWay
|
|
673
|
+ }
|
|
674
|
+
|
|
675
|
+ if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
|
|
676
|
+ executionFrequency, _ := json["execution_frequency"].(string)
|
|
677
|
+ advice.ExecutionFrequency = executionFrequency
|
|
678
|
+ }
|
|
679
|
+ return 0
|
|
680
|
+}
|