|
@@ -9,7 +9,6 @@ import (
|
9
|
9
|
"github.com/astaxie/beego"
|
10
|
10
|
"reflect"
|
11
|
11
|
"strconv"
|
12
|
|
- "strings"
|
13
|
12
|
"time"
|
14
|
13
|
)
|
15
|
14
|
|
|
@@ -24,10 +23,6 @@ func HisManagerApiRegistRouters() {
|
24
|
23
|
beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
|
25
|
24
|
|
26
|
25
|
beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
|
27
|
|
- beego.Router("/api/hisdoctoradvice/create", &HisApiController{}, "post:CreateHisDoctorAdvice")
|
28
|
|
- //beego.Router("/api/hisproject/create", &HisApiController{}, "post:CreateHisProject")
|
29
|
|
- //beego.Router("/api/hisorder/create", &HisApiController{}, "post:CreateHisOrder")
|
30
|
|
- //beego.Router("/api/hisadditional/create", &HisApiController{}, "post:CreateHisAdditionalCharge")
|
31
|
26
|
|
32
|
27
|
beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
|
33
|
28
|
beego.Router("/api/doctorworkstation/casehistory/get", &HisApiController{}, "get:GetHisPatientCaseHistory")
|
|
@@ -121,25 +116,24 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
|
121
|
116
|
//drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
|
122
|
117
|
drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
|
123
|
118
|
efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
|
124
|
|
- //获取所有项目
|
125
|
|
- projects, _ := service.GetAllProjectList(adminInfo.CurrentOrgId)
|
126
|
|
- //获取所有项目组套
|
|
119
|
+
|
|
120
|
+ doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
|
127
|
121
|
|
128
|
122
|
c.ServeSuccessJSON(map[string]interface{}{
|
129
|
123
|
"drugs": drugs,
|
130
|
124
|
"advices_template": advices,
|
131
|
|
- "projects": projects,
|
132
|
125
|
"drugways": drugways,
|
133
|
126
|
"efs": efs,
|
|
127
|
+ "doctors": doctors,
|
134
|
128
|
})
|
135
|
129
|
}
|
136
|
130
|
func (c *HisApiController) CreateHisPrescription() {
|
137
|
131
|
record_date := c.GetString("record_date")
|
138
|
132
|
patient_id, _ := c.GetInt64("patient_id")
|
|
133
|
+ //diagnose := c.GetString("diagnose")
|
|
134
|
+ //sick_history := c.GetString("sick_history")
|
139
|
135
|
doctor, _ := c.GetInt64("doctor")
|
140
|
|
-
|
141
|
|
- diagnose := c.GetString("diagnose")
|
142
|
|
- special_sick_history := c.GetString("special_sick_history")
|
|
136
|
+ //departm/**/ent, _ := c.GetInt64("department")
|
143
|
137
|
|
144
|
138
|
dataBody := make(map[string]interface{}, 0)
|
145
|
139
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
@@ -159,11 +153,9 @@ func (c *HisApiController) CreateHisPrescription() {
|
159
|
153
|
adminInfo := c.GetAdminUserInfo()
|
160
|
154
|
recordDateTime := theTime.Unix()
|
161
|
155
|
|
162
|
|
- //types, _ := c.GetInt64("type")
|
163
|
|
- var prescriptions []*models.HisPrescription
|
|
156
|
+ if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
|
157
|
+ prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
164
|
158
|
|
165
|
|
- if dataBody["prescription"] != nil && reflect.TypeOf(dataBody["prescription"]).String() == "[]interface {}" {
|
166
|
|
- prescriptions, _ := dataBody["prescription"].([]interface{})
|
167
|
159
|
if len(prescriptions) > 0 {
|
168
|
160
|
for _, item := range prescriptions {
|
169
|
161
|
items := item.(map[string]interface{})
|
|
@@ -188,21 +180,38 @@ func (c *HisApiController) CreateHisPrescription() {
|
188
|
180
|
Status: 1,
|
189
|
181
|
Doctor: doctor,
|
190
|
182
|
}
|
191
|
|
- //prescriptions = append(prescriptions, prescription)
|
192
|
183
|
service.SaveHisPrescription(prescription)
|
193
|
184
|
|
194
|
185
|
if items["advices"] != nil && reflect.TypeOf(items["advices"]).String() == "[]interface {}" {
|
195
|
186
|
advices := items["advices"].([]interface{})
|
|
187
|
+ group := service.GetMaxAdviceGroupID(adminInfo.CurrentOrgId)
|
|
188
|
+ groupNo := group + 1
|
|
189
|
+ ctime := time.Now().Unix()
|
|
190
|
+ mtime := ctime
|
196
|
191
|
if len(advices) > 0 {
|
197
|
192
|
for _, advice := range advices {
|
198
|
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
|
199
|
208
|
|
200
|
209
|
errcode := c.setAdviceWithJSON(&s, advice.(map[string]interface{}))
|
201
|
210
|
if errcode > 0 {
|
202
|
211
|
c.ServeFailJSONWithSGJErrorCode(errcode)
|
203
|
212
|
return
|
204
|
213
|
}
|
205
|
|
- advice.Children = append(advice.Children, &s)
|
|
214
|
+ service.CreateHisDoctorAdvice(&s)
|
206
|
215
|
}
|
207
|
216
|
}
|
208
|
217
|
}
|
|
@@ -456,91 +465,74 @@ func (c *HisApiController) GetPrintHisPatientCaseHistory() {
|
456
|
465
|
}
|
457
|
466
|
func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo, json map[string]interface{}) int {
|
458
|
467
|
|
459
|
|
- if json["advice_name"] == nil || reflect.TypeOf(json["advice_name"]).String() != "string" {
|
460
|
|
- utils.ErrorLog("advice_name")
|
|
468
|
+ if json["drug_name"] == nil || reflect.TypeOf(json["drug_name"]).String() != "string" {
|
|
469
|
+ utils.ErrorLog("drug_name")
|
461
|
470
|
return enums.ErrorCodeParamWrong
|
462
|
471
|
}
|
463
|
|
- adviceName, _ := json["advice_name"].(string)
|
|
472
|
+ adviceName, _ := json["drug_name"].(string)
|
464
|
473
|
if len(adviceName) == 0 {
|
465
|
474
|
utils.ErrorLog("len(advice_name) == 0")
|
466
|
475
|
return enums.ErrorCodeParamWrong
|
467
|
476
|
}
|
468
|
477
|
advice.AdviceName = adviceName
|
469
|
|
-
|
470
|
478
|
adviceDesc, _ := json["advice_desc"].(string)
|
471
|
479
|
advice.AdviceDesc = adviceDesc
|
472
|
|
-
|
473
|
480
|
if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
|
474
|
481
|
drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
|
475
|
482
|
advice.DrugSpec = drugSpec
|
476
|
483
|
}
|
477
|
|
-
|
478
|
484
|
if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
|
479
|
485
|
remark, _ := json["remark"].(string)
|
480
|
486
|
advice.Remark = remark
|
481
|
487
|
}
|
482
|
|
-
|
483
|
|
- if json["way"] == nil {
|
484
|
|
- advice.Way = 0
|
485
|
|
-
|
486
|
|
- } else {
|
487
|
|
- if json["way"] != nil || reflect.TypeOf(json["way"]).String() == "float64" {
|
488
|
|
- way := int64(json["way"].(float64))
|
489
|
|
- advice.Way = way
|
490
|
|
- }
|
491
|
|
-
|
492
|
|
- }
|
493
|
|
-
|
494
|
|
- if json["drug_id"] == nil {
|
|
488
|
+ if json["id"] == nil {
|
495
|
489
|
advice.DrugId = 0
|
496
|
490
|
} else {
|
497
|
|
- if json["drug_id"] != nil || reflect.TypeOf(json["drug_id"]).String() == "float64" {
|
498
|
|
- drug_id := int64(json["drug_id"].(float64))
|
|
491
|
+ if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
|
|
492
|
+ drug_id := int64(json["id"].(float64))
|
499
|
493
|
advice.DrugId = drug_id
|
500
|
494
|
}
|
501
|
495
|
}
|
502
|
496
|
|
503
|
|
- if json["drug_name_id"] == nil {
|
504
|
|
- advice.DrugNameId = 0
|
505
|
|
- } else {
|
506
|
|
- if json["drug_name_id"] != nil || reflect.TypeOf(json["drug_name_id"]).String() == "float64" {
|
507
|
|
- drug_name_id := int64(json["drug_name_id"].(float64))
|
508
|
|
- advice.DrugNameId = drug_name_id
|
509
|
|
- }
|
510
|
|
- }
|
511
|
|
-
|
512
|
|
- if json["drug_spec_unit"] != nil && reflect.TypeOf(json["drug_spec_unit"]).String() == "string" {
|
513
|
|
- drugSpecUnit, _ := json["drug_spec_unit"].(string)
|
|
497
|
+ if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
|
|
498
|
+ drugSpecUnit, _ := json["min_unit"].(string)
|
514
|
499
|
advice.DrugSpecUnit = drugSpecUnit
|
515
|
500
|
}
|
516
|
|
-
|
517
|
501
|
if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
|
518
|
502
|
singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
|
519
|
503
|
advice.SingleDose = singleDose
|
520
|
504
|
}
|
521
|
|
-
|
522
|
|
- if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
|
523
|
|
- singleDoseUnit, _ := json["single_dose_unit"].(string)
|
|
505
|
+ if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
|
|
506
|
+ singleDoseUnit, _ := json["min_unit"].(string)
|
524
|
507
|
advice.SingleDoseUnit = singleDoseUnit
|
525
|
508
|
}
|
526
|
|
-
|
527
|
509
|
if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
|
528
|
510
|
prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
|
529
|
511
|
advice.PrescribingNumber = prescribingNumber
|
530
|
512
|
}
|
531
|
|
-
|
532
|
|
- if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
|
533
|
|
- prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
|
|
513
|
+ if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
|
|
514
|
+ prescribingNumberUnit, _ := json["min_unit"].(string)
|
534
|
515
|
advice.PrescribingNumberUnit = prescribingNumberUnit
|
535
|
516
|
}
|
536
|
517
|
if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
|
537
|
518
|
deliveryWay, _ := json["delivery_way"].(string)
|
538
|
519
|
advice.DeliveryWay = deliveryWay
|
539
|
520
|
}
|
540
|
|
-
|
541
|
521
|
if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
|
542
|
522
|
executionFrequency, _ := json["execution_frequency"].(string)
|
543
|
523
|
advice.ExecutionFrequency = executionFrequency
|
544
|
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
|
+ }
|
545
|
537
|
return 0
|
546
|
538
|
}
|