|
@@ -53,7 +53,6 @@ func HisManagerApiRegistRouters() {
|
53
|
53
|
beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
|
54
|
54
|
beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
|
55
|
55
|
beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
|
56
|
|
- beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
|
57
|
56
|
beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
|
58
|
57
|
beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
|
59
|
58
|
beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
|
|
@@ -69,31 +68,35 @@ func HisManagerApiRegistRouters() {
|
69
|
68
|
|
70
|
69
|
beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
|
71
|
70
|
|
|
71
|
+ beego.Router("/api/pre_upload/get", &HisApiController{}, "get:GetPreUploadInfo")
|
|
72
|
+
|
|
73
|
+ beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
|
|
74
|
+
|
72
|
75
|
}
|
73
|
76
|
|
74
|
77
|
func (c *HisApiController) TestPay() {
|
75
|
78
|
DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
|
76
|
79
|
readCards := DllDef2.MustFindProc("BankTrans")
|
77
|
|
- //inputData := make(map[string]interface{})
|
78
|
|
- //inputData["transId"] = "05"
|
79
|
|
- //inputData["amount"] = "0.01"
|
80
|
|
- //inputData["traceNo"] = "20210227093601325405377"
|
81
|
|
- //inputData["cardNo"] = "F36084348"
|
82
|
|
- //inputData["id"] = "44022919620927046X"
|
83
|
|
- jsonStr := `
|
84
|
|
- {
|
85
|
|
- "transId": "05",
|
86
|
|
- "amount":"1.00",
|
87
|
|
- "traceNo":"20210227093601325405377",
|
88
|
|
- "cardNo":"F36084348",
|
89
|
|
- "id":"44022919620927046X"
|
90
|
|
-
|
91
|
|
- }
|
92
|
|
- `
|
93
|
|
-
|
94
|
|
- //bytes_arr, _ := json.Marshal(inputData)
|
|
80
|
+ inputData := make(map[string]interface{})
|
|
81
|
+ inputData["transId"] = "05"
|
|
82
|
+ inputData["amount"] = "0.01"
|
|
83
|
+ inputData["traceNo"] = "20210227093601325405377"
|
|
84
|
+ inputData["cardNo"] = "F36084348"
|
|
85
|
+ inputData["id"] = "44022919620927046X"
|
|
86
|
+ //jsonStr := `
|
|
87
|
+ // {
|
|
88
|
+ // "transId": "05",
|
|
89
|
+ // "amount":"1.00",
|
|
90
|
+ // "traceNo":"20210227093601325405377",
|
|
91
|
+ // "cardNo":"F36084348",
|
|
92
|
+ // "id":"44022919620927046X"
|
|
93
|
+ //
|
|
94
|
+ // }
|
|
95
|
+ //`
|
|
96
|
+
|
|
97
|
+ bytes_arr, _ := json.Marshal(inputData)
|
95
|
98
|
str3 := make([]byte, 256)
|
96
|
|
- ret4, _, err4 := readCards.Call(StrPtr(jsonStr), (uintptr)(unsafe.Pointer(&str3[0])))
|
|
99
|
+ ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
|
97
|
100
|
fmt.Println(":", string(str3))
|
98
|
101
|
|
99
|
102
|
if err4 != nil {
|
|
@@ -1724,6 +1727,531 @@ func (c *HisApiController) GetUploadInfo() {
|
1724
|
1727
|
}
|
1725
|
1728
|
}
|
1726
|
1729
|
|
|
1730
|
+func (c *HisApiController) GetPreUploadInfo() {
|
|
1731
|
+ id, _ := c.GetInt64("id")
|
|
1732
|
+ record_time := c.GetString("record_time")
|
|
1733
|
+ settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
|
|
1734
|
+ admin_user_id, _ := c.GetInt64("admin_user_id")
|
|
1735
|
+
|
|
1736
|
+ timeLayout := "2006-01-02"
|
|
1737
|
+ loc, _ := time.LoadLocation("Local")
|
|
1738
|
+ theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
|
|
1739
|
+ if err != nil {
|
|
1740
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1741
|
+ return
|
|
1742
|
+ }
|
|
1743
|
+ recordDateTime := theTime.Unix()
|
|
1744
|
+ adminUser := c.GetAdminUserInfo()
|
|
1745
|
+
|
|
1746
|
+ var prescriptions []*models.HisPrescription
|
|
1747
|
+
|
|
1748
|
+ var start_time int64
|
|
1749
|
+ var end_time int64
|
|
1750
|
+
|
|
1751
|
+ data := make(map[string]interface{})
|
|
1752
|
+ if settle_accounts_type == 1 { //日结
|
|
1753
|
+ prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
|
|
1754
|
+ data["pre"] = prescriptions
|
|
1755
|
+
|
|
1756
|
+ } else { //月结
|
|
1757
|
+ start_time_str := c.GetString("start_time")
|
|
1758
|
+ end_time_str := c.GetString("end_time")
|
|
1759
|
+ timeLayout := "2006-01-02"
|
|
1760
|
+ loc, _ := time.LoadLocation("Local")
|
|
1761
|
+ theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
|
|
1762
|
+ if err != nil {
|
|
1763
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1764
|
+ return
|
|
1765
|
+ }
|
|
1766
|
+ recordStartTime := theStartTime.Unix()
|
|
1767
|
+ start_time = recordStartTime
|
|
1768
|
+ theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
|
|
1769
|
+ if err != nil {
|
|
1770
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
1771
|
+ return
|
|
1772
|
+ }
|
|
1773
|
+ recordEndTime := theEndTime.Unix()
|
|
1774
|
+ end_time = recordEndTime
|
|
1775
|
+ prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
|
|
1776
|
+ data["pre"] = prescriptions
|
|
1777
|
+
|
|
1778
|
+ }
|
|
1779
|
+
|
|
1780
|
+ roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
|
|
1781
|
+
|
|
1782
|
+ his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
|
1783
|
+ timestamp := time.Now().Unix()
|
|
1784
|
+ tempTime := time.Unix(timestamp, 0)
|
|
1785
|
+ timeFormat := tempTime.Format("20060102150405")
|
|
1786
|
+ chrgBchno := rand.Intn(100000) + 10000
|
|
1787
|
+ chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
|
|
1788
|
+ miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
|
|
1789
|
+ patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
|
|
1790
|
+ department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
|
|
1791
|
+ strconv.FormatInt(his.PatientId, 10)
|
|
1792
|
+ client := &http.Client{}
|
|
1793
|
+ data["psn_no"] = his.PsnNo
|
|
1794
|
+ data["mdtrt_id"] = his.Number
|
|
1795
|
+ data["chrg_bchno"] = chrg_bchno
|
|
1796
|
+ data["org_name"] = miConfig.OrgName
|
|
1797
|
+ data["doctor"] = roles.UserName
|
|
1798
|
+ data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
|
|
1799
|
+ data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
|
|
1800
|
+ data["fixmedins_code"] = miConfig.Code
|
|
1801
|
+ data["dept_code"] = department.Number
|
|
1802
|
+ data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
|
|
1803
|
+ data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
|
|
1804
|
+ data["secret_key"] = miConfig.SecretKey
|
|
1805
|
+ var ids []int64
|
|
1806
|
+
|
|
1807
|
+ for _, item := range prescriptions {
|
|
1808
|
+ ids = append(ids, item.ID)
|
|
1809
|
+ }
|
|
1810
|
+ config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
|
|
1811
|
+ if config.IsOpen == 1 { //对接了医保,走医保流程
|
|
1812
|
+ bytesData, _ := json.Marshal(data)
|
|
1813
|
+ req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
|
|
1814
|
+ resp, _ := client.Do(req)
|
|
1815
|
+ defer resp.Body.Close()
|
|
1816
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
1817
|
+ if ioErr != nil {
|
|
1818
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
1819
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1820
|
+ return
|
|
1821
|
+ }
|
|
1822
|
+ var respJSON map[string]interface{}
|
|
1823
|
+ if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
|
|
1824
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
1825
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1826
|
+ return
|
|
1827
|
+ }
|
|
1828
|
+
|
|
1829
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
1830
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
1831
|
+ var res ResultFour
|
|
1832
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1833
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1834
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1835
|
+ return
|
|
1836
|
+ }
|
|
1837
|
+
|
|
1838
|
+ if res.Infcode == 0 {
|
|
1839
|
+ order := &models.HisOrder{
|
|
1840
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
1841
|
+ HisPatientId: his.ID,
|
|
1842
|
+ PatientId: his.PatientId,
|
|
1843
|
+ SettleAccountsDate: recordDateTime,
|
|
1844
|
+ Ctime: time.Now().Unix(),
|
|
1845
|
+ Mtime: time.Now().Unix(),
|
|
1846
|
+ Status: 1,
|
|
1847
|
+ Number: chrg_bchno,
|
|
1848
|
+ Infcode: res.Infcode,
|
|
1849
|
+ WarnMsg: res.WarnMsg,
|
|
1850
|
+ Cainfo: res.Cainfo,
|
|
1851
|
+ ErrMsg: res.ErrMsg,
|
|
1852
|
+ RespondTime: res.RefmsgTime,
|
|
1853
|
+ InfRefmsgid: res.InfRefmsgid,
|
|
1854
|
+ OrderStatus: 1,
|
|
1855
|
+ IsMedicineInsurance: 1,
|
|
1856
|
+ SettleType: settle_accounts_type,
|
|
1857
|
+ SettleStartTime: start_time,
|
|
1858
|
+ SettleEndTime: end_time,
|
|
1859
|
+ Creator: roles.ID,
|
|
1860
|
+ Modify: roles.ID,
|
|
1861
|
+ }
|
|
1862
|
+ err = service.CreateOrder(order)
|
|
1863
|
+ if err != nil {
|
|
1864
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
|
|
1865
|
+ return
|
|
1866
|
+ }
|
|
1867
|
+
|
|
1868
|
+ for _, item := range res.Output.Result {
|
|
1869
|
+ temp := strings.Split(item.FeedetlSn, "-")
|
|
1870
|
+ var advice_id int64 = 0
|
|
1871
|
+ var project_id int64 = 0
|
|
1872
|
+ var types int64 = 0
|
|
1873
|
+
|
|
1874
|
+ id, _ := strconv.ParseInt(temp[2], 10, 64)
|
|
1875
|
+ types, _ = strconv.ParseInt(temp[1], 10, 64)
|
|
1876
|
+
|
|
1877
|
+ if temp[1] == "1" {
|
|
1878
|
+ advice_id = id
|
|
1879
|
+ project_id = 0
|
|
1880
|
+ } else if temp[1] == "2" {
|
|
1881
|
+ advice_id = 0
|
|
1882
|
+ project_id = id
|
|
1883
|
+ }
|
|
1884
|
+
|
|
1885
|
+ info := &models.HisOrderInfo{
|
|
1886
|
+ OrderNumber: order.Number,
|
|
1887
|
+ FeedetlSn: item.FeedetlSn,
|
|
1888
|
+ UploadDate: time.Now().Unix(),
|
|
1889
|
+ AdviceId: advice_id,
|
|
1890
|
+ DetItemFeeSumamt: item.DetItemFeeSumamt,
|
|
1891
|
+ Cnt: item.Cnt,
|
|
1892
|
+ Pric: float64(item.Pric),
|
|
1893
|
+ PatientId: his.PatientId,
|
|
1894
|
+ PricUplmtAmt: item.PricUplmtAmt,
|
|
1895
|
+ SelfpayProp: item.SelfpayProp,
|
|
1896
|
+ FulamtOwnpayAmt: item.FulamtOwnpayAmt,
|
|
1897
|
+ OverlmtAmt: item.OverlmtAmt,
|
|
1898
|
+ PreselfpayAmt: item.PreselfpayAmt,
|
|
1899
|
+ BasMednFlag: item.BasMednFlag,
|
|
1900
|
+ MedChrgitmType: item.MedChrgitmType,
|
|
1901
|
+ HiNegoDrugFlag: item.HiNegoDrugFlag,
|
|
1902
|
+ Status: 1,
|
|
1903
|
+ Memo: item.Memo,
|
|
1904
|
+ Mtime: time.Now().Unix(),
|
|
1905
|
+ InscpScpAmt: item.InscpScpAmt,
|
|
1906
|
+ DrtReimFlag: item.DrtReimFlag,
|
|
1907
|
+ Ctime: time.Now().Unix(),
|
|
1908
|
+ ListSpItemFlag: item.ListSpItemFlag,
|
|
1909
|
+ ChldMedcFlag: item.ChldMedcFlag,
|
|
1910
|
+ LmtUsedFlag: item.LmtUsedFlag,
|
|
1911
|
+ ChrgitmLv: item.ChrgitmLv,
|
|
1912
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
1913
|
+ HisPatientId: his.ID,
|
|
1914
|
+ OrderId: order.ID,
|
|
1915
|
+ ProjectId: project_id,
|
|
1916
|
+ Type: types,
|
|
1917
|
+ }
|
|
1918
|
+ service.CreateOrderInfo(info)
|
|
1919
|
+
|
|
1920
|
+ }
|
|
1921
|
+ service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
|
1922
|
+ service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
|
|
1923
|
+
|
|
1924
|
+ var total float64
|
|
1925
|
+ for _, item := range prescriptions {
|
|
1926
|
+ if item.Type == 1 { //药品
|
|
1927
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
1928
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
1929
|
+ }
|
|
1930
|
+ }
|
|
1931
|
+ if item.Type == 2 { //项目
|
|
1932
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
1933
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
1934
|
+ }
|
|
1935
|
+ }
|
|
1936
|
+ }
|
|
1937
|
+
|
|
1938
|
+ for _, item := range prescriptions {
|
|
1939
|
+ for _, subItem := range item.HisAdditionalCharge {
|
|
1940
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
1941
|
+ }
|
|
1942
|
+ }
|
|
1943
|
+
|
|
1944
|
+ allTotal := fmt.Sprintf("%.2f", total)
|
|
1945
|
+ if res.Infcode == 0 {
|
|
1946
|
+ var rf []*ResultFive
|
|
1947
|
+ json.Unmarshal([]byte(his.Iinfo), &rf)
|
|
1948
|
+ psn_no := his.PsnNo
|
|
1949
|
+ mdtrt_id := his.Number
|
|
1950
|
+ chrg_bchno := chrg_bchno
|
|
1951
|
+ cert_no := his.Certno
|
|
1952
|
+ insutype := rf[0].Insutype
|
|
1953
|
+
|
|
1954
|
+ if his.IdCardType == 1 {
|
|
1955
|
+ cert_no = his.MedicalInsuranceNumber
|
|
1956
|
+
|
|
1957
|
+ } else {
|
|
1958
|
+
|
|
1959
|
+ cert_no = his.Certno
|
|
1960
|
+
|
|
1961
|
+ }
|
|
1962
|
+
|
|
1963
|
+ api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
|
|
1964
|
+ insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
|
|
1965
|
+ "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
|
|
1966
|
+ miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
|
|
1967
|
+ resp, requestErr := http.Get(api)
|
|
1968
|
+ if requestErr != nil {
|
|
1969
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1970
|
+ return
|
|
1971
|
+ }
|
|
1972
|
+ defer resp.Body.Close()
|
|
1973
|
+ body, ioErr := ioutil.ReadAll(resp.Body)
|
|
1974
|
+ if ioErr != nil {
|
|
1975
|
+ utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
|
|
1976
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1977
|
+ return
|
|
1978
|
+ }
|
|
1979
|
+ var respJSON map[string]interface{}
|
|
1980
|
+ if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
|
|
1981
|
+ utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
|
|
1982
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1983
|
+ return
|
|
1984
|
+ }
|
|
1985
|
+ fmt.Println(respJSON)
|
|
1986
|
+ respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
|
|
1987
|
+ userJSONBytes, _ := json.Marshal(respJSON)
|
|
1988
|
+ var res ResultSeven
|
|
1989
|
+ if err := json.Unmarshal(userJSONBytes, &res); err != nil {
|
|
1990
|
+ utils.ErrorLog("解析失败:%v", err)
|
|
1991
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
|
|
1992
|
+ return
|
|
1993
|
+ }
|
|
1994
|
+ if res.Infcode == -1 {
|
|
1995
|
+ errlog := &models.HisOrderError{
|
|
1996
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
1997
|
+ Ctime: time.Now().Unix(),
|
|
1998
|
+ Mtime: time.Now().Unix(),
|
|
1999
|
+ Number: chrg_bchno,
|
|
2000
|
+ ErrMsg: res.ErrMsg,
|
|
2001
|
+ Status: 1,
|
|
2002
|
+ PatientId: id,
|
|
2003
|
+ RecordTime: recordDateTime,
|
|
2004
|
+ Stage: 7,
|
|
2005
|
+ }
|
|
2006
|
+ service.CreateErrMsgLog(errlog)
|
|
2007
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
2008
|
+ return
|
|
2009
|
+ } else {
|
|
2010
|
+ order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
|
|
2011
|
+ order.OrderStatus = 1
|
|
2012
|
+ order.MdtrtId = res.Output.Setlinfo.MdtrtID
|
|
2013
|
+ order.SetlId = res.Output.Setlinfo.SetlID
|
|
2014
|
+ order.PsnNo = res.Output.Setlinfo.PsnNo
|
|
2015
|
+ order.PsnName = res.Output.Setlinfo.PsnName
|
|
2016
|
+ order.PsnCertType = res.Output.Setlinfo.PsnCertType
|
|
2017
|
+ order.Certno = res.Output.Setlinfo.Certno
|
|
2018
|
+ order.Gend = res.Output.Setlinfo.Gend
|
|
2019
|
+ order.Naty = res.Output.Setlinfo.Naty
|
|
2020
|
+ order.Age = res.Output.Setlinfo.Age
|
|
2021
|
+ order.Insutype = res.Output.Setlinfo.Insutype
|
|
2022
|
+ order.PsnType = res.Output.Setlinfo.PsnType
|
|
2023
|
+ order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
|
|
2024
|
+ order.SetlTime = res.Output.Setlinfo.SetlTime
|
|
2025
|
+ order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
|
|
2026
|
+ order.MedType = res.Output.Setlinfo.MedType
|
|
2027
|
+ order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
|
|
2028
|
+ order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
|
|
2029
|
+ order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
|
|
2030
|
+ order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
|
|
2031
|
+ order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
|
|
2032
|
+ order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
|
|
2033
|
+ order.HifpPay = res.Output.Setlinfo.HifpPay
|
|
2034
|
+ order.CvlservPay = res.Output.Setlinfo.CvlservPay
|
|
2035
|
+ order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
|
|
2036
|
+ order.HifesPay = res.Output.Setlinfo.HifesPay
|
|
2037
|
+ order.HifobPay = res.Output.Setlinfo.HifobPay
|
|
2038
|
+ order.MafPay = res.Output.Setlinfo.MafPay
|
|
2039
|
+ order.OthPay = res.Output.Setlinfo.OthPay
|
|
2040
|
+ order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
|
|
2041
|
+ order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
|
|
2042
|
+ order.AcctPay = res.Output.Setlinfo.AcctPay
|
|
2043
|
+ order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
|
|
2044
|
+ order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
|
|
2045
|
+ order.Balc = res.Output.Setlinfo.Balc
|
|
2046
|
+ order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
|
|
2047
|
+ order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
|
|
2048
|
+ order.ClrOptins = res.Output.Setlinfo.ClrOptins
|
|
2049
|
+ order.ClrWay = res.Output.Setlinfo.ClrWay
|
|
2050
|
+ order.Creator = order.Creator
|
|
2051
|
+ order.Modify = roles.ID
|
|
2052
|
+ setlDetail, _ := json.Marshal(res.Output.Setldetail)
|
|
2053
|
+ detailStr := string(setlDetail)
|
|
2054
|
+ order.SetlDetail = detailStr
|
|
2055
|
+ //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
|
2056
|
+ err = service.UpDateOrder(order)
|
|
2057
|
+ if err == nil {
|
|
2058
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
2059
|
+ "msg": "预结算成功",
|
|
2060
|
+ })
|
|
2061
|
+ } else {
|
|
2062
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
|
|
2063
|
+ return
|
|
2064
|
+ }
|
|
2065
|
+ }
|
|
2066
|
+ } else {
|
|
2067
|
+ adminUser := c.GetAdminUserInfo()
|
|
2068
|
+ errlog := &models.HisOrderError{
|
|
2069
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
2070
|
+ Ctime: time.Now().Unix(),
|
|
2071
|
+ Mtime: time.Now().Unix(),
|
|
2072
|
+ ErrMsg: res.ErrMsg,
|
|
2073
|
+ Status: 1,
|
|
2074
|
+ PatientId: id,
|
|
2075
|
+ RecordTime: recordDateTime,
|
|
2076
|
+ Stage: 4,
|
|
2077
|
+ }
|
|
2078
|
+ service.CreateErrMsgLog(errlog)
|
|
2079
|
+
|
|
2080
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
|
|
2081
|
+ return
|
|
2082
|
+ }
|
|
2083
|
+ } else {
|
|
2084
|
+ adminUser := c.GetAdminUserInfo()
|
|
2085
|
+ errlog := &models.HisOrderError{
|
|
2086
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
2087
|
+ Ctime: time.Now().Unix(),
|
|
2088
|
+ Mtime: time.Now().Unix(),
|
|
2089
|
+ ErrMsg: res.ErrMsg,
|
|
2090
|
+ Status: 1,
|
|
2091
|
+ PatientId: id,
|
|
2092
|
+ RecordTime: recordDateTime,
|
|
2093
|
+ Stage: 4,
|
|
2094
|
+ }
|
|
2095
|
+ service.CreateErrMsgLog(errlog)
|
|
2096
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
|
|
2097
|
+ return
|
|
2098
|
+ }
|
|
2099
|
+
|
|
2100
|
+ } else {
|
|
2101
|
+ var total float64
|
|
2102
|
+ for _, item := range prescriptions {
|
|
2103
|
+ if item.Type == 1 { //药品
|
|
2104
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
2105
|
+ total = total + (subItem.Price * subItem.PrescribingNumber)
|
|
2106
|
+ }
|
|
2107
|
+ }
|
|
2108
|
+ if item.Type == 2 { //项目
|
|
2109
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
2110
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
2111
|
+ }
|
|
2112
|
+ }
|
|
2113
|
+
|
|
2114
|
+ for _, subItem := range item.HisAdditionalCharge {
|
|
2115
|
+ total = total + (subItem.Price * float64(subItem.Count))
|
|
2116
|
+ }
|
|
2117
|
+ }
|
|
2118
|
+
|
|
2119
|
+ allTotal := fmt.Sprintf("%.2f", total)
|
|
2120
|
+ totals, _ := strconv.ParseFloat(allTotal, 64)
|
|
2121
|
+ order := &models.HisOrder{
|
|
2122
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
2123
|
+ HisPatientId: his.ID,
|
|
2124
|
+ PatientId: id,
|
|
2125
|
+ SettleAccountsDate: recordDateTime,
|
|
2126
|
+ Ctime: time.Now().Unix(),
|
|
2127
|
+ Mtime: time.Now().Unix(),
|
|
2128
|
+ Status: 1,
|
|
2129
|
+ OrderStatus: 2,
|
|
2130
|
+ Number: chrg_bchno,
|
|
2131
|
+ MedfeeSumamt: totals,
|
|
2132
|
+ }
|
|
2133
|
+ err = service.CreateOrder(order)
|
|
2134
|
+ if err != nil {
|
|
2135
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
|
|
2136
|
+ return
|
|
2137
|
+ }
|
|
2138
|
+
|
|
2139
|
+ var customs []*Custom
|
|
2140
|
+ for _, item := range prescriptions {
|
|
2141
|
+
|
|
2142
|
+ if item.Type == 1 { //药品
|
|
2143
|
+ for _, subItem := range item.HisDoctorAdviceInfo {
|
|
2144
|
+ cus := &Custom{
|
|
2145
|
+ AdviceId: subItem.ID,
|
|
2146
|
+ ProjectId: 0,
|
|
2147
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
|
|
2148
|
+ Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
|
|
2149
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
2150
|
+ Price: fmt.Sprintf("%.2f", subItem.Price),
|
|
2151
|
+ MedListCodg: subItem.MedListCodg,
|
|
2152
|
+ Type: 1,
|
|
2153
|
+ }
|
|
2154
|
+ customs = append(customs, cus)
|
|
2155
|
+ }
|
|
2156
|
+ }
|
|
2157
|
+
|
|
2158
|
+ if item.Type == 2 { //项目
|
|
2159
|
+ for _, subItem := range item.HisPrescriptionProject {
|
|
2160
|
+
|
|
2161
|
+ cus := &Custom{
|
|
2162
|
+ AdviceId: 0,
|
|
2163
|
+ ProjectId: subItem.ID,
|
|
2164
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
|
|
2165
|
+ Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
|
|
2166
|
+ FeedetlSn: subItem.FeedetlSn,
|
|
2167
|
+ Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
|
|
2168
|
+ MedListCodg: subItem.MedListCodg,
|
|
2169
|
+ Type: 2,
|
|
2170
|
+ }
|
|
2171
|
+
|
|
2172
|
+ customs = append(customs, cus)
|
|
2173
|
+ }
|
|
2174
|
+ }
|
|
2175
|
+
|
|
2176
|
+ for _, item := range item.HisAdditionalCharge {
|
|
2177
|
+ cus := &Custom{
|
|
2178
|
+ ItemId: item.ID,
|
|
2179
|
+ AdviceId: 0,
|
|
2180
|
+ ProjectId: 0,
|
|
2181
|
+ DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
|
|
2182
|
+ Cut: fmt.Sprintf("%.2f", float64(item.Count)),
|
|
2183
|
+ FeedetlSn: item.FeedetlSn,
|
|
2184
|
+ Price: fmt.Sprintf("%.2f", float64(item.Price)),
|
|
2185
|
+ MedListCodg: item.XtHisAddtionConfig.Code,
|
|
2186
|
+ Type: 3,
|
|
2187
|
+ }
|
|
2188
|
+
|
|
2189
|
+ customs = append(customs, cus)
|
|
2190
|
+ }
|
|
2191
|
+
|
|
2192
|
+ }
|
|
2193
|
+
|
|
2194
|
+ for _, item := range customs {
|
|
2195
|
+ var advice_id int64 = 0
|
|
2196
|
+ var project_id int64 = 0
|
|
2197
|
+ var item_id int64 = 0
|
|
2198
|
+
|
|
2199
|
+ var types int64 = 0
|
|
2200
|
+
|
|
2201
|
+ if item.Type == 1 {
|
|
2202
|
+ advice_id = item.AdviceId
|
|
2203
|
+ project_id = 0
|
|
2204
|
+ item_id = 0
|
|
2205
|
+ } else if item.Type == 2 {
|
|
2206
|
+ advice_id = 0
|
|
2207
|
+ item_id = 0
|
|
2208
|
+
|
|
2209
|
+ project_id = item.ProjectId
|
|
2210
|
+ } else if item.Type == 3 {
|
|
2211
|
+ advice_id = 0
|
|
2212
|
+ item_id = item.ItemId
|
|
2213
|
+ project_id = 0
|
|
2214
|
+ }
|
|
2215
|
+
|
|
2216
|
+ detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
|
|
2217
|
+ cut, _ := strconv.ParseFloat(item.Cut, 32)
|
|
2218
|
+ pric, _ := strconv.ParseFloat(item.Price, 32)
|
|
2219
|
+
|
|
2220
|
+ info := &models.HisOrderInfo{
|
|
2221
|
+ OrderNumber: order.Number,
|
|
2222
|
+ UploadDate: time.Now().Unix(),
|
|
2223
|
+ AdviceId: advice_id,
|
|
2224
|
+ DetItemFeeSumamt: detItemFeeSumamt,
|
|
2225
|
+ Cnt: cut,
|
|
2226
|
+ Pric: pric,
|
|
2227
|
+ PatientId: id,
|
|
2228
|
+ Status: 1,
|
|
2229
|
+ Mtime: time.Now().Unix(),
|
|
2230
|
+ Ctime: time.Now().Unix(),
|
|
2231
|
+ UserOrgId: adminUser.CurrentOrgId,
|
|
2232
|
+ HisPatientId: his.ID,
|
|
2233
|
+ OrderId: order.ID,
|
|
2234
|
+ ProjectId: project_id,
|
|
2235
|
+ Type: types,
|
|
2236
|
+ ItemId: item_id,
|
|
2237
|
+ }
|
|
2238
|
+ service.CreateOrderInfo(info)
|
|
2239
|
+ }
|
|
2240
|
+ //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
|
2241
|
+ err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
|
|
2242
|
+ err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
|
|
2243
|
+ err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
|
|
2244
|
+ if err == nil {
|
|
2245
|
+ c.ServeSuccessJSON(map[string]interface{}{
|
|
2246
|
+ "msg": "结算成功",
|
|
2247
|
+ })
|
|
2248
|
+ } else {
|
|
2249
|
+ c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
|
|
2250
|
+ return
|
|
2251
|
+ }
|
|
2252
|
+ }
|
|
2253
|
+}
|
|
2254
|
+
|
1727
|
2255
|
func (c *HisApiController) GetSettleInfo() {
|
1728
|
2256
|
id, _ := c.GetInt64("id")
|
1729
|
2257
|
order_id, _ := c.GetInt64("order_id")
|