|
@@ -14,6 +14,7 @@ import (
|
14
|
14
|
"net/http"
|
15
|
15
|
"reflect"
|
16
|
16
|
"strconv"
|
|
17
|
+ "strings"
|
17
|
18
|
"time"
|
18
|
19
|
)
|
19
|
20
|
|
|
@@ -27,6 +28,10 @@ func HisManagerApiRegistRouters() {
|
27
|
28
|
beego.Router("/api/hispatient/get", &HisApiController{}, "get:GetHisPatientInfo")
|
28
|
29
|
beego.Router("/api/hisprescription/config", &HisApiController{}, "get:GetHisPrescriptionConfig")
|
29
|
30
|
|
|
31
|
+ beego.Router("/api/hisprescription/delete", &HisApiController{}, "post:DeletePrescription")
|
|
32
|
+ beego.Router("/api/advice/delete", &HisApiController{}, "post:DeleteDoctorAdvice")
|
|
33
|
+ beego.Router("/api/project/delete", &HisApiController{}, "post:DeleteProject")
|
|
34
|
+
|
30
|
35
|
beego.Router("/api/hisprescription/create", &HisApiController{}, "post:CreateHisPrescription")
|
31
|
36
|
|
32
|
37
|
beego.Router("/api/doctorworkstation/casehistory/list", &HisApiController{}, "get:GetHisPatientCaseHistoryList")
|
|
@@ -116,8 +121,6 @@ func (c *HisApiController) GetHisPrescriptionConfig() {
|
116
|
121
|
//获取所有基础药
|
117
|
122
|
drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
|
118
|
123
|
|
119
|
|
- //drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
|
120
|
|
- //drugs, _ := service.GetAllDrugLibList(adminInfo.CurrentOrgId)
|
121
|
124
|
drugways, _, _ := service.GetDrugWayDics(adminInfo.CurrentOrgId)
|
122
|
125
|
efs, _, _ := service.GetExecutionFrequencyDics(adminInfo.CurrentOrgId)
|
123
|
126
|
|
|
@@ -137,10 +140,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
137
|
140
|
record_date := c.GetString("record_date")
|
138
|
141
|
fmt.Println("record_date", record_date)
|
139
|
142
|
patient_id, _ := c.GetInt64("patient_id")
|
140
|
|
- //diagnose := c.GetString("diagnose")
|
141
|
|
- //sick_history := c.GetString("sick_history")
|
|
143
|
+ reg_type, _ := c.GetInt64("reg_type")
|
|
144
|
+
|
|
145
|
+ diagnose := c.GetString("diagnose")
|
|
146
|
+ sick_history := c.GetString("sick_history")
|
142
|
147
|
doctor, _ := c.GetInt64("doctor")
|
143
|
|
- //department, _ := c.GetInt64("department")
|
|
148
|
+ department, _ := c.GetInt64("department")
|
144
|
149
|
his_patient_id, _ := c.GetInt64("his_patient_id")
|
145
|
150
|
dataBody := make(map[string]interface{}, 0)
|
146
|
151
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
@@ -160,21 +165,42 @@ func (c *HisApiController) CreateHisPrescription() {
|
160
|
165
|
adminInfo := c.GetAdminUserInfo()
|
161
|
166
|
recordDateTime := theTime.Unix()
|
162
|
167
|
|
163
|
|
- //hpInfo := models.HisPrescriptionInfo{
|
164
|
|
- // UserOrgId: adminInfo.CurrentOrgId,
|
165
|
|
- // RecordDate: theTime.Unix(),
|
166
|
|
- // PatientId: patient_id,
|
167
|
|
- // Status: 1,
|
168
|
|
- // Ctime: time.Now().Unix(),
|
169
|
|
- // Mtime: time.Now().Unix(),
|
170
|
|
- // Creator: adminInfo.AdminUser.Id,
|
171
|
|
- // Modifier: adminInfo.AdminUser.Id,
|
172
|
|
- // Diagnosis: diagnose,
|
173
|
|
- // SickHistory: sick_history,
|
174
|
|
- // Departments:department,
|
175
|
|
- //
|
176
|
|
- //}
|
177
|
|
- //
|
|
168
|
+ info, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, patient_id, recordDateTime)
|
|
169
|
+ if info.ID == 0 {
|
|
170
|
+ hpInfo := models.HisPrescriptionInfo{
|
|
171
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
172
|
+ RecordDate: theTime.Unix(),
|
|
173
|
+ PatientId: patient_id,
|
|
174
|
+ Status: 1,
|
|
175
|
+ Ctime: time.Now().Unix(),
|
|
176
|
+ Mtime: time.Now().Unix(),
|
|
177
|
+ Creator: adminInfo.AdminUser.Id,
|
|
178
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
179
|
+ Diagnosis: diagnose,
|
|
180
|
+ SickHistory: sick_history,
|
|
181
|
+ Departments: department,
|
|
182
|
+ RegisterType: reg_type,
|
|
183
|
+ }
|
|
184
|
+ service.SavePatientPrescriptionInfo(hpInfo)
|
|
185
|
+
|
|
186
|
+ } else {
|
|
187
|
+ hpInfo := models.HisPrescriptionInfo{
|
|
188
|
+ ID: info.ID,
|
|
189
|
+ UserOrgId: adminInfo.CurrentOrgId,
|
|
190
|
+ RecordDate: info.RecordDate,
|
|
191
|
+ PatientId: info.PatientId,
|
|
192
|
+ Status: 1,
|
|
193
|
+ Ctime: info.Ctime,
|
|
194
|
+ Mtime: time.Now().Unix(),
|
|
195
|
+ Creator: info.Creator,
|
|
196
|
+ Modifier: adminInfo.AdminUser.Id,
|
|
197
|
+ Diagnosis: diagnose,
|
|
198
|
+ SickHistory: sick_history,
|
|
199
|
+ Departments: department,
|
|
200
|
+ RegisterType: reg_type,
|
|
201
|
+ }
|
|
202
|
+ service.SavePatientPrescriptionInfo(hpInfo)
|
|
203
|
+ }
|
178
|
204
|
|
179
|
205
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
180
|
206
|
prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
|
@@ -182,6 +208,12 @@ func (c *HisApiController) CreateHisPrescription() {
|
182
|
208
|
if len(prescriptions) > 0 {
|
183
|
209
|
for _, item := range prescriptions {
|
184
|
210
|
items := item.(map[string]interface{})
|
|
211
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
212
|
+ utils.ErrorLog("id")
|
|
213
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
214
|
+ return
|
|
215
|
+ }
|
|
216
|
+ id := int64(items["id"].(float64))
|
185
|
217
|
|
186
|
218
|
if items["type"] == nil || reflect.TypeOf(items["type"]).String() != "float64" {
|
187
|
219
|
utils.ErrorLog("type")
|
|
@@ -192,6 +224,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
192
|
224
|
|
193
|
225
|
ctime := time.Now().Unix()
|
194
|
226
|
prescription := &models.HisPrescription{
|
|
227
|
+ ID: id,
|
195
|
228
|
PatientId: patient_id,
|
196
|
229
|
UserOrgId: adminInfo.CurrentOrgId,
|
197
|
230
|
RecordDate: recordDateTime,
|
|
@@ -203,6 +236,8 @@ func (c *HisApiController) CreateHisPrescription() {
|
203
|
236
|
Status: 1,
|
204
|
237
|
Doctor: doctor,
|
205
|
238
|
HisPatientId: his_patient_id,
|
|
239
|
+ IsFinish: 1,
|
|
240
|
+ BatchNumber: "",
|
206
|
241
|
}
|
207
|
242
|
service.SaveHisPrescription(prescription)
|
208
|
243
|
|
|
@@ -236,6 +271,14 @@ func (c *HisApiController) CreateHisPrescription() {
|
236
|
271
|
return
|
237
|
272
|
}
|
238
|
273
|
service.CreateHisDoctorAdvice(&s)
|
|
274
|
+ var randNum int
|
|
275
|
+ randNum = rand.Intn(10000) + 1000
|
|
276
|
+ timestamp := time.Now().Unix()
|
|
277
|
+ tempTime := time.Unix(timestamp, 0)
|
|
278
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
279
|
+ s.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "1" + "-" + strconv.FormatInt(s.ID, 10)
|
|
280
|
+ service.CreateHisDoctorAdvice(&s)
|
|
281
|
+
|
239
|
282
|
}
|
240
|
283
|
}
|
241
|
284
|
}
|
|
@@ -258,27 +301,71 @@ func (c *HisApiController) CreateHisPrescription() {
|
258
|
301
|
return
|
259
|
302
|
}
|
260
|
303
|
service.CreateHisProjectTwo(&p)
|
|
304
|
+ var randNum int
|
|
305
|
+ randNum = rand.Intn(10000) + 1000
|
|
306
|
+ timestamp := time.Now().Unix()
|
|
307
|
+ tempTime := time.Unix(timestamp, 0)
|
|
308
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
309
|
+ p.FeedetlSn = timeFormat + strconv.FormatInt(int64(randNum), 10) + "-" + "2" + "-" + strconv.FormatInt(p.ID, 10)
|
|
310
|
+ service.SaveHisProjectTwo(&p)
|
|
311
|
+
|
261
|
312
|
}
|
262
|
313
|
}
|
263
|
314
|
}
|
264
|
315
|
}
|
265
|
316
|
}
|
|
317
|
+ }
|
|
318
|
+ if err == nil {
|
|
319
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
320
|
+ "msg": "保存成功",
|
|
321
|
+ })
|
|
322
|
+ return
|
266
|
323
|
|
267
|
|
- //查询患者今日处方信息
|
268
|
|
- //_, errcode := service.GetHisPrescriptionTwo(his_patient_id, adminInfo.CurrentOrgId, recordDateTime)
|
269
|
|
- //if errcode == nil{
|
270
|
|
- // //改变患者信息状态
|
271
|
|
- // service.UpdatedHisPatient(his_patient_id, adminInfo.CurrentOrgId, recordDateTime)
|
272
|
|
- //
|
273
|
|
- //}
|
|
324
|
+ } else {
|
|
325
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
326
|
+ return
|
274
|
327
|
}
|
|
328
|
+}
|
275
|
329
|
|
|
330
|
+func (c *HisApiController) DeletePrescription() {
|
|
331
|
+ prescription_id, _ := c.GetInt64("id")
|
|
332
|
+ //TODO 需要判断是否已经结算
|
|
333
|
+ err := service.DelelteHisPrescription(prescription_id, c.GetAdminUserInfo().CurrentOrgId)
|
276
|
334
|
if err == nil {
|
277
|
335
|
c.ServeSuccessJSON(map[string]interface{}{
|
278
|
|
- "msg": "保存成功",
|
|
336
|
+ "msg": "删除成功",
|
279
|
337
|
})
|
280
|
338
|
return
|
|
339
|
+ } else {
|
|
340
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
341
|
+ return
|
|
342
|
+ }
|
|
343
|
+}
|
281
|
344
|
|
|
345
|
+func (c *HisApiController) DeleteDoctorAdvice() {
|
|
346
|
+ id, _ := c.GetInt64("id")
|
|
347
|
+ //TODO 需要判断是否已经结算
|
|
348
|
+ err := service.DelelteDoctorAdvice(id, c.GetAdminUserInfo().CurrentOrgId)
|
|
349
|
+ if err == nil {
|
|
350
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
351
|
+ "msg": "删除成功",
|
|
352
|
+ })
|
|
353
|
+ return
|
|
354
|
+ } else {
|
|
355
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
|
356
|
+ return
|
|
357
|
+ }
|
|
358
|
+}
|
|
359
|
+
|
|
360
|
+func (c *HisApiController) DeleteProject() {
|
|
361
|
+ id, _ := c.GetInt64("id")
|
|
362
|
+ //TODO 需要判断是否已经结算
|
|
363
|
+ err := service.DelelteProject(id, c.GetAdminUserInfo().CurrentOrgId)
|
|
364
|
+ if err == nil {
|
|
365
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
366
|
+ "msg": "删除成功",
|
|
367
|
+ })
|
|
368
|
+ return
|
282
|
369
|
} else {
|
283
|
370
|
c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
|
284
|
371
|
return
|
|
@@ -591,7 +678,7 @@ func (c *HisApiController) GetRegisterInfo() {
|
591
|
678
|
return
|
592
|
679
|
}
|
593
|
680
|
|
594
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + "44020219710324062X"
|
|
681
|
+ api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + patient.IdCardNo
|
595
|
682
|
resp, requestErr := http.Get(api)
|
596
|
683
|
|
597
|
684
|
if requestErr != nil {
|
|
@@ -743,6 +830,10 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
|
743
|
830
|
advice.DrugId = drug_id
|
744
|
831
|
}
|
745
|
832
|
}
|
|
833
|
+ if json["advice_id"] != nil && reflect.TypeOf(json["advice_id"]).String() == "float64" {
|
|
834
|
+ advice_id := int64(json["advice_id"].(float64))
|
|
835
|
+ advice.ID = advice_id
|
|
836
|
+ }
|
746
|
837
|
|
747
|
838
|
if json["min_unit"] != nil && reflect.TypeOf(json["min_unit"]).String() == "string" {
|
748
|
839
|
drugSpecUnit, _ := json["min_unit"].(string)
|
|
@@ -795,7 +886,12 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
|
795
|
886
|
func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionProject, json map[string]interface{}) int {
|
796
|
887
|
|
797
|
888
|
if json["id"] != nil || reflect.TypeOf(json["id"]).String() == "float64" {
|
798
|
|
- project_id := int64(json["id"].(float64))
|
|
889
|
+ id := int64(json["id"].(float64))
|
|
890
|
+ project.ID = id
|
|
891
|
+ }
|
|
892
|
+
|
|
893
|
+ if json["project_id"] != nil || reflect.TypeOf(json["project_id"]).String() == "float64" {
|
|
894
|
+ project_id := int64(json["project_id"].(float64))
|
799
|
895
|
project.ProjectId = project_id
|
800
|
896
|
}
|
801
|
897
|
|
|
@@ -811,6 +907,11 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
|
811
|
907
|
totals, _ := strconv.ParseInt(total, 10, 64)
|
812
|
908
|
project.Count = totals
|
813
|
909
|
}
|
|
910
|
+
|
|
911
|
+ if json["medical_code"] != nil && reflect.TypeOf(json["medical_code"]).String() == "string" {
|
|
912
|
+ medical_code, _ := json["medical_code"].(string)
|
|
913
|
+ project.MedListCodg = medical_code
|
|
914
|
+ }
|
814
|
915
|
return 0
|
815
|
916
|
}
|
816
|
917
|
|
|
@@ -821,25 +922,25 @@ type ResultFour struct {
|
821
|
922
|
Infcode int64 `json:"infcode"`
|
822
|
923
|
Output struct {
|
823
|
924
|
Result []struct {
|
824
|
|
- BasMednFlag string `json:"bas_medn_flag"`
|
825
|
|
- ChldMedcFlag string `json:"chld_medc_flag"`
|
826
|
|
- ChrgitmLv string `json:"chrgitm_lv"`
|
827
|
|
- Cnt int64 `json:"cnt"`
|
828
|
|
- DetItemFeeSumamt int64 `json:"det_item_fee_sumamt"`
|
829
|
|
- DrtReimFlag string `json:"drt_reim_flag"`
|
830
|
|
- FeedetlSn string `json:"feedetl_sn"`
|
831
|
|
- FulamtOwnpayAmt int64 `json:"fulamt_ownpay_amt"`
|
832
|
|
- HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
|
833
|
|
- InscpScpAmt int64 `json:"inscp_scp_amt"`
|
834
|
|
- ListSpItemFlag string `json:"list_sp_item_flag"`
|
835
|
|
- LmtUsedFlag string `json:"lmt_used_flag"`
|
836
|
|
- MedChrgitmType string `json:"med_chrgitm_type"`
|
837
|
|
- Memo string `json:"memo"`
|
838
|
|
- OverlmtAmt int64 `json:"overlmt_amt"`
|
839
|
|
- PreselfpayAmt int64 `json:"preselfpay_amt"`
|
840
|
|
- Pric int64 `json:"pric"`
|
841
|
|
- PricUplmtAmt int64 `json:"pric_uplmt_amt"`
|
842
|
|
- SelfpayProp int64 `json:"selfpay_prop"`
|
|
925
|
+ BasMednFlag string `json:"bas_medn_flag"`
|
|
926
|
+ ChldMedcFlag string `json:"chld_medc_flag"`
|
|
927
|
+ ChrgitmLv string `json:"chrgitm_lv"`
|
|
928
|
+ Cnt float64 `json:"cnt"`
|
|
929
|
+ DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
|
|
930
|
+ DrtReimFlag string `json:"drt_reim_flag"`
|
|
931
|
+ FeedetlSn string `json:"feedetl_sn"`
|
|
932
|
+ FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
|
|
933
|
+ HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
|
|
934
|
+ InscpScpAmt float64 `json:"inscp_scp_amt"`
|
|
935
|
+ ListSpItemFlag string `json:"list_sp_item_flag"`
|
|
936
|
+ LmtUsedFlag string `json:"lmt_used_flag"`
|
|
937
|
+ MedChrgitmType string `json:"med_chrgitm_type"`
|
|
938
|
+ Memo string `json:"memo"`
|
|
939
|
+ OverlmtAmt float64 `json:"overlmt_amt"`
|
|
940
|
+ PreselfpayAmt float64 `json:"preselfpay_amt"`
|
|
941
|
+ Pric float64 `json:"pric"`
|
|
942
|
+ PricUplmtAmt float64 `json:"pric_uplmt_amt"`
|
|
943
|
+ SelfpayProp float64 `json:"selfpay_prop"`
|
843
|
944
|
} `json:"result"`
|
844
|
945
|
} `json:"output"`
|
845
|
946
|
RefmsgTime string `json:"refmsg_time"`
|
|
@@ -855,9 +956,6 @@ type ResultFive struct {
|
855
|
956
|
func (c *HisApiController) GetUploadInfo() {
|
856
|
957
|
id, _ := c.GetInt64("id")
|
857
|
958
|
record_time := c.GetString("record_time")
|
858
|
|
-
|
859
|
|
- //record_date := c.GetString("record_date")
|
860
|
|
-
|
861
|
959
|
timeLayout := "2006-01-02"
|
862
|
960
|
loc, _ := time.LoadLocation("Local")
|
863
|
961
|
|
|
@@ -876,7 +974,7 @@ func (c *HisApiController) GetUploadInfo() {
|
876
|
974
|
tempTime := time.Unix(timestamp, 0)
|
877
|
975
|
timeFormat := tempTime.Format("20060102150405")
|
878
|
976
|
chrgBchno := rand.Intn(100000) + 10000
|
879
|
|
- chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
|
|
977
|
+ chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
880
|
978
|
|
881
|
979
|
client := &http.Client{}
|
882
|
980
|
data := make(map[string]interface{})
|
|
@@ -887,7 +985,6 @@ func (c *HisApiController) GetUploadInfo() {
|
887
|
985
|
bytesData, _ := json.Marshal(data)
|
888
|
986
|
req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
|
889
|
987
|
resp, _ := client.Do(req)
|
890
|
|
-
|
891
|
988
|
defer resp.Body.Close()
|
892
|
989
|
body, ioErr := ioutil.ReadAll(resp.Body)
|
893
|
990
|
if ioErr != nil {
|
|
@@ -911,62 +1008,146 @@ func (c *HisApiController) GetUploadInfo() {
|
911
|
1008
|
return
|
912
|
1009
|
}
|
913
|
1010
|
|
914
|
|
- var total float64
|
915
|
|
- for _, item := range prescriptions {
|
916
|
|
- if item.Type == 1 { //药品
|
917
|
|
- for _, subItem := range item.HisDoctorAdviceInfo {
|
918
|
|
- total = total + (subItem.Price * subItem.PrescribingNumber)
|
919
|
|
- }
|
920
|
|
- }
|
921
|
|
- if item.Type == 2 { //项目
|
922
|
|
- for _, subItem := range item.HisPrescriptionProject {
|
923
|
|
- total = total + (subItem.Price * float64(subItem.Count))
|
924
|
|
- }
|
925
|
|
- }
|
926
|
|
- }
|
927
|
|
- allTotal := fmt.Sprintf("%.2f", total)
|
928
|
|
- fmt.Println(allTotal)
|
929
|
1011
|
if res.Infcode == 0 {
|
930
|
|
- var rf []*ResultFive
|
931
|
|
- json.Unmarshal([]byte(his.Iinfo), &rf)
|
932
|
|
- psn_no := his.PsnNo
|
933
|
|
- mdtrt_id := his.Number
|
934
|
|
- chrg_bchno := chrg_bchno
|
935
|
|
- cert_no := his.Certno
|
936
|
|
- insutype := rf[0].Insutype
|
937
|
|
- api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
|
938
|
|
- insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
939
|
|
- "&total=" + allTotal
|
940
|
|
- resp, requestErr := http.Get(api)
|
941
|
|
-
|
942
|
|
- if requestErr != nil {
|
943
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
944
|
|
- return
|
|
1012
|
+ order := &models.HisOrder{
|
|
1013
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
1014
|
+ HisPatientId: his.ID,
|
|
1015
|
+ PatientId: his.PatientId,
|
|
1016
|
+ SettleAccountsDate: recordDateTime,
|
|
1017
|
+ Ctime: time.Now().Unix(),
|
|
1018
|
+ Mtime: time.Now().Unix(),
|
|
1019
|
+ Status: 1,
|
|
1020
|
+ Number: chrg_bchno,
|
|
1021
|
+ Infcode: res.Infcode,
|
|
1022
|
+ WarnMsg: res.WarnMsg,
|
|
1023
|
+ Cainfo: res.Cainfo,
|
|
1024
|
+ ErrMsg: res.ErrMsg,
|
|
1025
|
+ RespondTime: res.RefmsgTime,
|
|
1026
|
+ InfRefmsgid: res.InfRefmsgid,
|
|
1027
|
+ OrderStatus: 1,
|
945
|
1028
|
}
|
946
|
|
- defer resp.Body.Close()
|
947
|
|
- body, ioErr := ioutil.ReadAll(resp.Body)
|
948
|
|
- if ioErr != nil {
|
949
|
|
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
950
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1029
|
+
|
|
1030
|
+ err = service.CreateOrder(order)
|
|
1031
|
+ if err != nil {
|
|
1032
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
|
951
|
1033
|
return
|
952
|
1034
|
}
|
953
|
|
- var respJSON map[string]interface{}
|
954
|
|
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
955
|
|
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
956
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
957
|
|
- return
|
|
1035
|
+
|
|
1036
|
+ for _, item := range res.Output.Result {
|
|
1037
|
+ temp := strings.Split(item.FeedetlSn, "-")
|
|
1038
|
+ var advice_id int64 = 0
|
|
1039
|
+ var project_id int64 = 0
|
|
1040
|
+ var types int64 = 0
|
|
1041
|
+
|
|
1042
|
+ id, _ := strconv.ParseInt(temp[2], 10, 64)
|
|
1043
|
+ types, _ = strconv.ParseInt(temp[1], 10, 64)
|
|
1044
|
+
|
|
1045
|
+ if temp[1] == "1" {
|
|
1046
|
+ advice_id = id
|
|
1047
|
+ project_id = 0
|
|
1048
|
+ } else if temp[1] == "2" {
|
|
1049
|
+ advice_id = 0
|
|
1050
|
+ project_id = id
|
|
1051
|
+ }
|
|
1052
|
+
|
|
1053
|
+ info := &models.HisOrderInfo{
|
|
1054
|
+ OrderNumber: order.Number,
|
|
1055
|
+ FeedetlSn: item.FeedetlSn,
|
|
1056
|
+ UploadDate: time.Now().Unix(),
|
|
1057
|
+ AdviceId: advice_id,
|
|
1058
|
+ DetItemFeeSumamt: item.DetItemFeeSumamt,
|
|
1059
|
+ Cnt: item.Cnt,
|
|
1060
|
+ Pric: float64(item.Pric),
|
|
1061
|
+ PatientId: his.PatientId,
|
|
1062
|
+ PricUplmtAmt: item.PricUplmtAmt,
|
|
1063
|
+ SelfpayProp: item.SelfpayProp,
|
|
1064
|
+ FulamtOwnpayAmt: item.FulamtOwnpayAmt,
|
|
1065
|
+ OverlmtAmt: item.OverlmtAmt,
|
|
1066
|
+ PreselfpayAmt: item.PreselfpayAmt,
|
|
1067
|
+ BasMednFlag: item.BasMednFlag,
|
|
1068
|
+ MedChrgitmType: item.MedChrgitmType,
|
|
1069
|
+ HiNegoDrugFlag: item.HiNegoDrugFlag,
|
|
1070
|
+ Status: 1,
|
|
1071
|
+ Memo: item.Memo,
|
|
1072
|
+ Mtime: time.Now().Unix(),
|
|
1073
|
+ InscpScpAmt: item.InscpScpAmt,
|
|
1074
|
+ DrtReimFlag: item.DrtReimFlag,
|
|
1075
|
+ Ctime: time.Now().Unix(),
|
|
1076
|
+ ListSpItemFlag: item.ListSpItemFlag,
|
|
1077
|
+ ChldMedcFlag: item.ChldMedcFlag,
|
|
1078
|
+ LmtUsedFlag: item.LmtUsedFlag,
|
|
1079
|
+ ChrgitmLv: item.ChrgitmLv,
|
|
1080
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
1081
|
+ HisPatientId: his.ID,
|
|
1082
|
+ OrderId: order.ID,
|
|
1083
|
+ ProjectId: project_id,
|
|
1084
|
+ Type: types,
|
|
1085
|
+ }
|
|
1086
|
+ service.CreateOrderInfo(info)
|
958
|
1087
|
}
|
959
|
|
- fmt.Println(respJSON)
|
960
|
|
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
961
|
|
- userJSONBytes, _ := json.Marshal(respJSON)
|
962
|
|
- var res ResultFour
|
963
|
|
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
964
|
|
- utils.ErrorLog("解析失败:%v", err)
|
965
|
|
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
966
|
|
- return
|
|
1088
|
+
|
|
1089
|
+ var total float64
|
|
1090
|
+ for _, item := range prescriptions {
|
|
1091
|
+ if item.Type == 1 { //药品
|
|
1092
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
1093
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
1094
|
+ }
|
|
1095
|
+ }
|
|
1096
|
+ if item.Type == 2 { //项目
|
|
1097
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
1098
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
1099
|
+ }
|
|
1100
|
+ }
|
967
|
1101
|
}
|
968
|
1102
|
|
|
1103
|
+ allTotal := fmt.Sprintf("%.2f", total)
|
|
1104
|
+ if res.Infcode == 0 {
|
|
1105
|
+ var rf []*ResultFive
|
|
1106
|
+ json.Unmarshal([]byte(his.Iinfo), &rf)
|
|
1107
|
+ psn_no := his.PsnNo
|
|
1108
|
+ mdtrt_id := his.Number
|
|
1109
|
+ chrg_bchno := chrg_bchno
|
|
1110
|
+ cert_no := his.Certno
|
|
1111
|
+ insutype := rf[0].Insutype
|
|
1112
|
+ api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
|
|
1113
|
+ insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
|
1114
|
+ "&total=" + allTotal
|
|
1115
|
+ resp, requestErr := http.Get(api)
|
|
1116
|
+
|
|
1117
|
+ if requestErr != nil {
|
|
1118
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1119
|
+ return
|
|
1120
|
+ }
|
|
1121
|
+ defer resp.Body.Close()
|
|
1122
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
1123
|
+ if ioErr != nil {
|
|
1124
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
1125
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1126
|
+ return
|
|
1127
|
+ }
|
|
1128
|
+ var respJSON map[string]interface{}
|
|
1129
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
1130
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
1131
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1132
|
+ return
|
|
1133
|
+ }
|
|
1134
|
+ fmt.Println(respJSON)
|
|
1135
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
1136
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
1137
|
+ var res ResultFour
|
|
1138
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1139
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1140
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1141
|
+ return
|
|
1142
|
+ }
|
|
1143
|
+ } else {
|
|
1144
|
+
|
|
1145
|
+ }
|
969
|
1146
|
} else {
|
970
|
1147
|
|
|
1148
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
1149
|
+ "msg": res.ErrMsg,
|
|
1150
|
+ })
|
|
1151
|
+
|
971
|
1152
|
}
|
972
|
1153
|
}
|