|
@@ -5,9 +5,13 @@ import (
|
5
|
5
|
"XT_New/models"
|
6
|
6
|
"XT_New/service"
|
7
|
7
|
"XT_New/utils"
|
|
8
|
+ "bytes"
|
8
|
9
|
"encoding/json"
|
9
|
10
|
"fmt"
|
10
|
11
|
"github.com/astaxie/beego"
|
|
12
|
+ "io/ioutil"
|
|
13
|
+ "math/rand"
|
|
14
|
+ "net/http"
|
11
|
15
|
"reflect"
|
12
|
16
|
"strconv"
|
13
|
17
|
"time"
|
|
@@ -32,6 +36,9 @@ func HisManagerApiRegistRouters() {
|
32
|
36
|
beego.Router("/api/doctorworkstation/casehistorytemplate/get", &HisApiController{}, "get:GetCaseHistoryTemplate")
|
33
|
37
|
beego.Router("/api/doctorworkstation/printcasehistory/get", &HisApiController{}, "get:GetPrintHisPatientCaseHistory")
|
34
|
38
|
|
|
39
|
+ beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
|
|
40
|
+ beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
|
|
41
|
+
|
35
|
42
|
}
|
36
|
43
|
|
37
|
44
|
func (c *HisApiController) GetHisPatientList() {
|
|
@@ -91,12 +98,8 @@ func (c *HisApiController) GetHisPatientInfo() {
|
91
|
98
|
admin := c.GetAdminUserInfo()
|
92
|
99
|
his_patient_info, _ := service.GetHisPatientInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
93
|
100
|
xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
|
94
|
|
-
|
95
|
101
|
prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
|
96
|
|
-
|
97
|
|
- //prescriptions, _ := service.GetHisPrescription(admin.CurrentOrgId, patient_id, recordDateTime)
|
98
|
102
|
case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
|
99
|
|
-
|
100
|
103
|
c.ServeSuccessJSON(map[string]interface{}{
|
101
|
104
|
"his_info": his_patient_info,
|
102
|
105
|
"xt_info": xt_patient_info,
|
|
@@ -137,7 +140,7 @@ func (c *HisApiController) CreateHisPrescription() {
|
137
|
140
|
//diagnose := c.GetString("diagnose")
|
138
|
141
|
//sick_history := c.GetString("sick_history")
|
139
|
142
|
doctor, _ := c.GetInt64("doctor")
|
140
|
|
- //departm/**/ent, _ := c.GetInt64("department")
|
|
143
|
+ //department, _ := c.GetInt64("department")
|
141
|
144
|
his_patient_id, _ := c.GetInt64("his_patient_id")
|
142
|
145
|
dataBody := make(map[string]interface{}, 0)
|
143
|
146
|
err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
|
|
@@ -157,6 +160,22 @@ func (c *HisApiController) CreateHisPrescription() {
|
157
|
160
|
adminInfo := c.GetAdminUserInfo()
|
158
|
161
|
recordDateTime := theTime.Unix()
|
159
|
162
|
|
|
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
|
+ //
|
|
178
|
+
|
160
|
179
|
if dataBody["prescriptions"] != nil && reflect.TypeOf(dataBody["prescriptions"]).String() == "[]interface {}" {
|
161
|
180
|
prescriptions, _ := dataBody["prescriptions"].([]interface{})
|
162
|
181
|
|
|
@@ -493,6 +512,203 @@ func (c *HisApiController) GetCaseHistoryTemplate() {
|
493
|
512
|
})
|
494
|
513
|
|
495
|
514
|
}
|
|
515
|
+
|
|
516
|
+type ResultTwo struct {
|
|
517
|
+ ErrMsg interface{} `json:"err_msg"`
|
|
518
|
+ InfRefmsgid string `json:"inf_refmsgid"`
|
|
519
|
+ Infcode int64 `json:"infcode"`
|
|
520
|
+ Output struct {
|
|
521
|
+ Baseinfo struct {
|
|
522
|
+ Age float64 `json:"age"`
|
|
523
|
+ Brdy string `json:"brdy"`
|
|
524
|
+ Certno string `json:"certno"`
|
|
525
|
+ Gend string `json:"gend"`
|
|
526
|
+ Naty string `json:"naty"`
|
|
527
|
+ PsnCertType string `json:"psn_cert_type"`
|
|
528
|
+ PsnName string `json:"psn_name"`
|
|
529
|
+ PsnNo string `json:"psn_no"`
|
|
530
|
+ } `json:"baseinfo"`
|
|
531
|
+ Idetinfo []interface{} `json:"idetinfo"`
|
|
532
|
+ Iinfo []struct {
|
|
533
|
+ Balc int64 `json:"balc"`
|
|
534
|
+ CvlservFlag string `json:"cvlserv_flag"`
|
|
535
|
+ EmpName string `json:"emp_name"`
|
|
536
|
+ InsuplcAdmdvs string `json:"insuplc_admdvs"`
|
|
537
|
+ Insutype string `json:"insutype"`
|
|
538
|
+ PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
|
|
539
|
+ PausInsuDate interface{} `json:"paus_insu_date"`
|
|
540
|
+ PsnInsuDate string `json:"psn_insu_date"`
|
|
541
|
+ PsnInsuStas string `json:"psn_insu_stas"`
|
|
542
|
+ PsnType string `json:"psn_type"`
|
|
543
|
+ } `json:"insuinfo"`
|
|
544
|
+ } `json:"output"`
|
|
545
|
+ RefmsgTime string `json:"refmsg_time"`
|
|
546
|
+ RespondTime string `json:"respond_time"`
|
|
547
|
+ Signtype interface{} `json:"signtype"`
|
|
548
|
+ WarnInfo interface{} `json:"warn_info"`
|
|
549
|
+}
|
|
550
|
+
|
|
551
|
+type ResultThree struct {
|
|
552
|
+ Cainfo interface{} `json:"cainfo"`
|
|
553
|
+ ErrMsg interface{} `json:"err_msg"`
|
|
554
|
+ InfRefmsgid string `json:"inf_refmsgid"`
|
|
555
|
+ Infcode int64 `json:"infcode"`
|
|
556
|
+ Output struct {
|
|
557
|
+ Data struct {
|
|
558
|
+ IptOtpNo string `json:"ipt_otp_no"`
|
|
559
|
+ MdtrtID string `json:"mdtrt_id"`
|
|
560
|
+ PsnNo string `json:"psn_no"`
|
|
561
|
+ } `json:"data"`
|
|
562
|
+ } `json:"output"`
|
|
563
|
+ RefmsgTime string `json:"refmsg_time"`
|
|
564
|
+ RespondTime string `json:"respond_time"`
|
|
565
|
+ Signtype interface{} `json:"signtype"`
|
|
566
|
+ WarnMsg interface{} `json:"warn_msg"`
|
|
567
|
+}
|
|
568
|
+
|
|
569
|
+func (c *HisApiController) GetRegisterInfo() {
|
|
570
|
+ id, _ := c.GetInt64("id")
|
|
571
|
+ record_time := c.GetString("record_time")
|
|
572
|
+
|
|
573
|
+ adminInfo := c.GetAdminUserInfo()
|
|
574
|
+ patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
|
|
575
|
+
|
|
576
|
+ if patient == nil {
|
|
577
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
|
|
578
|
+ return
|
|
579
|
+ }
|
|
580
|
+ if len(patient.IdCardNo) == 0 {
|
|
581
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
|
|
582
|
+ return
|
|
583
|
+ }
|
|
584
|
+
|
|
585
|
+ timeLayout := "2006-01-02"
|
|
586
|
+ loc, _ := time.LoadLocation("Local")
|
|
587
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
588
|
+ if err != nil {
|
|
589
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
590
|
+ return
|
|
591
|
+ }
|
|
592
|
+
|
|
593
|
+ api := "http://127.0.0.1:9531/" + "gdyb/one?cert_no=" + "44020219710324062X"
|
|
594
|
+ resp, requestErr := http.Get(api)
|
|
595
|
+
|
|
596
|
+ if requestErr != nil {
|
|
597
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
598
|
+ return
|
|
599
|
+ }
|
|
600
|
+ defer resp.Body.Close()
|
|
601
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
602
|
+ if ioErr != nil {
|
|
603
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
604
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
605
|
+ return
|
|
606
|
+ }
|
|
607
|
+ var respJSON map[string]interface{}
|
|
608
|
+
|
|
609
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
610
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
611
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
612
|
+ return
|
|
613
|
+ }
|
|
614
|
+
|
|
615
|
+ userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
616
|
+ userJSONBytes, _ := json.Marshal(userJSON)
|
|
617
|
+ var res ResultTwo
|
|
618
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
619
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
620
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
621
|
+ return
|
|
622
|
+ }
|
|
623
|
+ Iinfos, _ := json.Marshal(res.Output.Iinfo)
|
|
624
|
+ Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
|
|
625
|
+ infoStr := string(Iinfos)
|
|
626
|
+ idetinfoStr := string(Idetinfos)
|
|
627
|
+
|
|
628
|
+ his := models.VMHisPatient{
|
|
629
|
+ PsnNo: res.Output.Baseinfo.PsnNo,
|
|
630
|
+ PsnCertType: res.Output.Baseinfo.PsnCertType,
|
|
631
|
+ Certno: res.Output.Baseinfo.Certno,
|
|
632
|
+ PsnName: res.Output.Baseinfo.PsnName,
|
|
633
|
+ Gend: res.Output.Baseinfo.Gend,
|
|
634
|
+ Naty: res.Output.Baseinfo.Naty,
|
|
635
|
+ Brdy: res.Output.Baseinfo.Brdy,
|
|
636
|
+ Age: res.Output.Baseinfo.Age,
|
|
637
|
+ Iinfo: infoStr,
|
|
638
|
+ Idetinfo: idetinfoStr,
|
|
639
|
+ PatientId: patient.ID,
|
|
640
|
+ RecordDate: theTime.Unix(),
|
|
641
|
+ }
|
|
642
|
+ fmt.Println(his)
|
|
643
|
+
|
|
644
|
+ if res.Output.Iinfo == nil || len(res.Output.Iinfo) == 0 {
|
|
645
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterOneException)
|
|
646
|
+ return
|
|
647
|
+ }
|
|
648
|
+
|
|
649
|
+ count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
|
|
650
|
+ if count <= 0 {
|
|
651
|
+ api := "http://127.0.0.1:9531/" + "gdyb/two?cert_no=" + patient.IdCardNo + "&insutype=" + res.Output.Iinfo[0].Insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo
|
|
652
|
+ resp, requestErr := http.Get(api)
|
|
653
|
+ if requestErr != nil {
|
|
654
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
655
|
+ return
|
|
656
|
+ }
|
|
657
|
+ defer resp.Body.Close()
|
|
658
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
659
|
+ if ioErr != nil {
|
|
660
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
661
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
662
|
+ return
|
|
663
|
+ }
|
|
664
|
+ var respJSON map[string]interface{}
|
|
665
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
666
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
667
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
668
|
+ return
|
|
669
|
+ }
|
|
670
|
+
|
|
671
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
672
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
673
|
+ var res ResultThree
|
|
674
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
675
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
676
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
677
|
+ return
|
|
678
|
+ }
|
|
679
|
+ if res.Infcode == -1 {
|
|
680
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
|
|
681
|
+ return
|
|
682
|
+ }
|
|
683
|
+ fmt.Println("000!!!!!!")
|
|
684
|
+ fmt.Println(res)
|
|
685
|
+ fmt.Println(res.Output.Data.MdtrtID)
|
|
686
|
+ fmt.Println(res.Output.Data.PsnNo)
|
|
687
|
+ fmt.Println(res.Output.Data.IptOtpNo)
|
|
688
|
+
|
|
689
|
+ his.Number = res.Output.Data.MdtrtID
|
|
690
|
+ his.PsnNo = res.Output.Data.PsnNo
|
|
691
|
+ his.IptOtpNo = res.Output.Data.IptOtpNo
|
|
692
|
+ his.IdCardNo = patient.IdCardNo
|
|
693
|
+ his.PhoneNumber = patient.Phone
|
|
694
|
+ his.UserOrgId = adminInfo.CurrentOrgId
|
|
695
|
+ his.Status = 1
|
|
696
|
+ his.Ctime = time.Now().Unix()
|
|
697
|
+ his.Mtime = time.Now().Unix()
|
|
698
|
+ err := service.CreateHisPatientTwo(&his)
|
|
699
|
+ if err == nil {
|
|
700
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
701
|
+ "his_info": his,
|
|
702
|
+ })
|
|
703
|
+ } else {
|
|
704
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
705
|
+ return
|
|
706
|
+ }
|
|
707
|
+
|
|
708
|
+ }
|
|
709
|
+
|
|
710
|
+}
|
|
711
|
+
|
496
|
712
|
func (c *HisApiController) GetPrintHisPatientCaseHistory() {
|
497
|
713
|
|
498
|
714
|
}
|
|
@@ -567,6 +783,11 @@ func (c *HisApiController) setAdviceWithJSON(advice *models.HisDoctorAdviceInfo,
|
567
|
783
|
price, _ := strconv.ParseFloat(json["retail_price"].(string), 64)
|
568
|
784
|
advice.Price = price
|
569
|
785
|
}
|
|
786
|
+ if json["medical_insurance_number"] != nil || reflect.TypeOf(json["medical_insurance_number"]).String() == "string" {
|
|
787
|
+ med_list_codg, _ := json["medical_insurance_number"].(string)
|
|
788
|
+ advice.MedListCodg = med_list_codg
|
|
789
|
+ }
|
|
790
|
+
|
570
|
791
|
return 0
|
571
|
792
|
}
|
572
|
793
|
|
|
@@ -587,3 +808,160 @@ func (c *HisApiController) setProjectWithJSON(project *models.HisPrescriptionPro
|
587
|
808
|
return 0
|
588
|
809
|
|
589
|
810
|
}
|
|
811
|
+
|
|
812
|
+type ResultFour struct {
|
|
813
|
+ Cainfo string `json:"cainfo"`
|
|
814
|
+ ErrMsg string `json:"err_msg"`
|
|
815
|
+ InfRefmsgid string `json:"inf_refmsgid"`
|
|
816
|
+ Infcode int64 `json:"infcode"`
|
|
817
|
+ Output struct {
|
|
818
|
+ Result []struct {
|
|
819
|
+ BasMednFlag string `json:"bas_medn_flag"`
|
|
820
|
+ ChldMedcFlag string `json:"chld_medc_flag"`
|
|
821
|
+ ChrgitmLv string `json:"chrgitm_lv"`
|
|
822
|
+ Cnt int64 `json:"cnt"`
|
|
823
|
+ DetItemFeeSumamt int64 `json:"det_item_fee_sumamt"`
|
|
824
|
+ DrtReimFlag string `json:"drt_reim_flag"`
|
|
825
|
+ FeedetlSn string `json:"feedetl_sn"`
|
|
826
|
+ FulamtOwnpayAmt int64 `json:"fulamt_ownpay_amt"`
|
|
827
|
+ HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
|
|
828
|
+ InscpScpAmt int64 `json:"inscp_scp_amt"`
|
|
829
|
+ ListSpItemFlag string `json:"list_sp_item_flag"`
|
|
830
|
+ LmtUsedFlag string `json:"lmt_used_flag"`
|
|
831
|
+ MedChrgitmType string `json:"med_chrgitm_type"`
|
|
832
|
+ Memo string `json:"memo"`
|
|
833
|
+ OverlmtAmt int64 `json:"overlmt_amt"`
|
|
834
|
+ PreselfpayAmt int64 `json:"preselfpay_amt"`
|
|
835
|
+ Pric int64 `json:"pric"`
|
|
836
|
+ PricUplmtAmt int64 `json:"pric_uplmt_amt"`
|
|
837
|
+ SelfpayProp int64 `json:"selfpay_prop"`
|
|
838
|
+ } `json:"result"`
|
|
839
|
+ } `json:"output"`
|
|
840
|
+ RefmsgTime string `json:"refmsg_time"`
|
|
841
|
+ RespondTime string `json:"respond_time"`
|
|
842
|
+ Signtype string `json:"signtype"`
|
|
843
|
+ WarnMsg string `json:"warn_msg"`
|
|
844
|
+}
|
|
845
|
+
|
|
846
|
+type ResultFive struct {
|
|
847
|
+ Insutype string `json:"insutype"`
|
|
848
|
+}
|
|
849
|
+
|
|
850
|
+func (c *HisApiController) GetUploadInfo() {
|
|
851
|
+ id, _ := c.GetInt64("id")
|
|
852
|
+ record_time := c.GetString("record_time")
|
|
853
|
+
|
|
854
|
+ //record_date := c.GetString("record_date")
|
|
855
|
+
|
|
856
|
+ timeLayout := "2006-01-02"
|
|
857
|
+ loc, _ := time.LoadLocation("Local")
|
|
858
|
+
|
|
859
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
860
|
+ if err != nil {
|
|
861
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
862
|
+ return
|
|
863
|
+ }
|
|
864
|
+ recordDateTime := theTime.Unix()
|
|
865
|
+ adminUser := c.GetAdminUserInfo()
|
|
866
|
+ prescriptions, _ := service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
|
|
867
|
+
|
|
868
|
+ his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
|
869
|
+
|
|
870
|
+ timestamp := time.Now().Unix()
|
|
871
|
+ tempTime := time.Unix(timestamp, 0)
|
|
872
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
873
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
874
|
+ chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
|
|
875
|
+
|
|
876
|
+ client := &http.Client{}
|
|
877
|
+ data := make(map[string]interface{})
|
|
878
|
+ data["psn_no"] = his.PsnNo
|
|
879
|
+ data["mdtrt_id"] = his.Number
|
|
880
|
+ data["pre"] = prescriptions
|
|
881
|
+ data["chrg_bchno"] = chrg_bchno
|
|
882
|
+ bytesData, _ := json.Marshal(data)
|
|
883
|
+ req, _ := http.NewRequest("POST", "http://127.0.0.1:9531/"+"gdyb/five", bytes.NewReader(bytesData))
|
|
884
|
+ resp, _ := client.Do(req)
|
|
885
|
+
|
|
886
|
+ defer resp.Body.Close()
|
|
887
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
888
|
+ if ioErr != nil {
|
|
889
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
890
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
891
|
+ return
|
|
892
|
+ }
|
|
893
|
+ var respJSON map[string]interface{}
|
|
894
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
895
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
896
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
897
|
+ return
|
|
898
|
+ }
|
|
899
|
+
|
|
900
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
901
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
902
|
+ var res ResultFour
|
|
903
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
904
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
905
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
906
|
+ return
|
|
907
|
+ }
|
|
908
|
+
|
|
909
|
+ var total float64
|
|
910
|
+ for _, item := range prescriptions {
|
|
911
|
+ if item.Type == 1 { //药品
|
|
912
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
913
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
914
|
+ }
|
|
915
|
+ }
|
|
916
|
+ if item.Type == 2 { //项目
|
|
917
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
918
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
919
|
+ }
|
|
920
|
+ }
|
|
921
|
+ }
|
|
922
|
+ allTotal := fmt.Sprintf("%.2f", total)
|
|
923
|
+ fmt.Println(allTotal)
|
|
924
|
+ if res.Infcode == 0 {
|
|
925
|
+ var rf []*ResultFive
|
|
926
|
+ json.Unmarshal([]byte(his.Iinfo), &rf)
|
|
927
|
+ psn_no := his.PsnNo
|
|
928
|
+ mdtrt_id := his.Number
|
|
929
|
+ chrg_bchno := chrg_bchno
|
|
930
|
+ cert_no := his.Certno
|
|
931
|
+ insutype := rf[0].Insutype
|
|
932
|
+ api := "http://127.0.0.1:9531/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
|
|
933
|
+ insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
|
934
|
+ "&total=" + allTotal
|
|
935
|
+ resp, requestErr := http.Get(api)
|
|
936
|
+
|
|
937
|
+ if requestErr != nil {
|
|
938
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
939
|
+ return
|
|
940
|
+ }
|
|
941
|
+ defer resp.Body.Close()
|
|
942
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
943
|
+ if ioErr != nil {
|
|
944
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
945
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
946
|
+ return
|
|
947
|
+ }
|
|
948
|
+ var respJSON map[string]interface{}
|
|
949
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
950
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
951
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
952
|
+ return
|
|
953
|
+ }
|
|
954
|
+ fmt.Println(respJSON)
|
|
955
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
956
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
957
|
+ var res ResultFour
|
|
958
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
959
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
960
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
961
|
+ return
|
|
962
|
+ }
|
|
963
|
+
|
|
964
|
+ } else {
|
|
965
|
+
|
|
966
|
+ }
|
|
967
|
+}
|