1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786 |
- package sz
-
- import (
- "encoding/json"
- "fmt"
- "gdyb/controllers"
- "gdyb/enums"
- "gdyb/models"
- "gdyb/service"
- "gdyb/utils"
- "github.com/astaxie/beego"
- "io/ioutil"
- "math"
- "math/rand"
- "net/http"
- "strconv"
- "time"
- )
-
- type SZHisApiController struct {
- controllers.BaseAuthAPIController
- }
-
- func SZHisManagerApiRegistRouters() {
-
- //beego.Router("/sz/api/card/get", &SZHisApiController{}, "get:GetCardInfo")
- beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
- beego.Router("/sz/api/upload/get", &SZHisApiController{}, "get:GetUploadInfo")
- beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
- //beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
-
- }
-
- //func (c *SZHisApiController) Sscard() {
- // id_card_type, _ := c.GetInt64("id_card_type")
- // adminUser := c.GetAdminUserInfo()
- // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- //
- // r := CardInit()
- // fmt.Println(r)
- // //if r == 0 {
- // switch id_card_type {
- // case 1:
- // basStr, err := GetBasBaseInfo()
- //
- // if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- // return
- //
- // } else {
- // fmt.Println(basStr)
- //
- // bas := strings.Split(basStr, "|")
- //
- // basNumber := bas[1]
- //
- // //basNumber := bas[2]
- // card_sn := bas[3]
- //
- // appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
- //
- // api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + basNumber + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10) + "&card_sn=" + card_sn
- // resp, requestErr := http.Get(api)
- // if requestErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // defer resp.Body.Close()
- // body, ioErr := ioutil.ReadAll(resp.Body)
- // if ioErr != nil {
- // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // var respJSON map[string]interface{}
- //
- // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- //
- // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- // userJSONBytes, _ := json.Marshal(userJSON)
- // var res ResultTwo
- // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // Iinfos, _ := json.Marshal(res.Output.Iinfo)
- // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- // infoStr := string(Iinfos)
- // idetinfoStr := string(Idetinfos)
- //
- // if res.Infcode == 0 {
- // his := models.VMHisPatient{
- // Status: 1,
- // Ctime: time.Now().Unix(),
- // Mtime: time.Now().Unix(),
- // PsnNo: res.Output.Baseinfo.PsnNo,
- // PsnCertType: res.Output.Baseinfo.PsnCertType,
- // Certno: res.Output.Baseinfo.Certno,
- // PsnName: res.Output.Baseinfo.PsnName,
- // Gend: res.Output.Baseinfo.Gend,
- // Naty: res.Output.Baseinfo.Naty,
- // Brdy: res.Output.Baseinfo.Brdy,
- // Age: res.Output.Baseinfo.Age,
- // Iinfo: infoStr,
- // Idetinfo: idetinfoStr,
- // UserOrgId: adminUser.CurrentOrgId,
- // IsReturn: 1,
- // IdCardType: id_card_type,
- // }
- //
- // patient, err := service.GetPatientByNumber(basNumber, adminUser.CurrentOrgId)
- // if err == gorm.ErrRecordNotFound {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- // return
- //
- // } else if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- // return
- //
- // } else {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "patient": patient,
- // "his": his,
- // "number": basNumber,
- // })
- // }
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
- // return
- // }
- //
- // }
- //
- // break
- // case 2:
- // ////SFZStr, err := GetSFZBaseInfo()
- // //if err != nil {
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- // // return
- // //
- // //} else {
- // //
- // // id_card_str := strings.Split(SFZStr, "^")
- // // id_card_number := id_card_str[0]
- // //appRole, _ := service.GetAppRole(adminUser.CurrentOrgId)
- // //
- // //api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + id_card_number + "&org_name=" + miConfig.OrgName + "&doctor=" + appRole.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
- // //resp, requestErr := http.Get(api)
- // //if requestErr != nil {
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // // return
- // //}
- // //defer resp.Body.Close()
- // //body, ioErr := ioutil.ReadAll(resp.Body)
- // //if ioErr != nil {
- // // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // // return
- // //}
- // //var respJSON map[string]interface{}
- // //
- // //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- // // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // // return
- // //}
- // //
- // //userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- // //userJSONBytes, _ := json.Marshal(userJSON)
- // //var res ResultTwo
- // //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- // // utils.ErrorLog("解析失败:%v", err)
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // // return
- // //}
- // //Iinfos, _ := json.Marshal(res.Output.Iinfo)
- // //Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
- // //infoStr := string(Iinfos)
- // //idetinfoStr := string(Idetinfos)
- // //
- // //if res.Infcode == 0 {
- // // his := models.VMHisPatient{
- // // Status: 1,
- // // Ctime: time.Now().Unix(),
- // // Mtime: time.Now().Unix(),
- // // PsnNo: res.Output.Baseinfo.PsnNo,
- // // PsnCertType: res.Output.Baseinfo.PsnCertType,
- // // Certno: res.Output.Baseinfo.Certno,
- // // PsnName: res.Output.Baseinfo.PsnName,
- // // Gend: res.Output.Baseinfo.Gend,
- // // Naty: res.Output.Baseinfo.Naty,
- // // Brdy: res.Output.Baseinfo.Brdy,
- // // Age: res.Output.Baseinfo.Age,
- // // Iinfo: infoStr,
- // // Idetinfo: idetinfoStr,
- // // UserOrgId: adminUser.CurrentOrgId,
- // // IsReturn: 1,
- // // IdCardType: id_card_type,
- // // }
- //
- // // patient, err := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
- // // if err == gorm.ErrRecordNotFound {
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
- // // return
- // //
- // // } else if err != nil {
- // // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- // // return
- // //
- // // } else {
- // // c.ServeSuccessJSON(map[string]interface{}{
- // // "patient": patient,
- // // "number": id_card_number,
- // // })
- // // }
- // //}
- // break
- // case 3:
- //
- // break
- //
- // }
- //}
-
- //func GetBasBaseInfo() (jsonStr string, err error) {
- //
- // handle, err := syscall.LoadLibrary("SSCard.dll")
- // if err != nil {
- // fmt.Printf("Error: %s\n", err)
- // return "", err
- // }
- // defer syscall.FreeLibrary(handle)
- // str := make([]byte, 256)
- // str1 := make([]byte, 256)
- // add, err := syscall.GetProcAddress(handle, "ReadCardBas")
- // if err != nil {
- // fmt.Printf("Error: %s\n", err)
- // return "", err
- // }
- // ret, _, _ := syscall.Syscall(add, (uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
- // if err != nil {
- // fmt.Printf("Error: %s\n", err)
- // }
- // fmt.Println("> Add(4,5)的结果为:", ret)
- // //return nil
- //
- // //
- // //handle := syscall.NewLazyDLL("SSCard.dll")
- // //ReadCardBas := handle.NewProc("ReadCardBas")
- // //
- // //var str2 [1024]C.char
- // //var str3 [1024]C.char
- // //
- // //
- // //
- // ////sssssswwwww
- // ////a := 256
- // //
- // //r, _, _ := ReadCardBas.Call(&str2, 1024, &str3, 1024)
- // //fmt.Println(r)
- // ////p := (*byte)(unsafe.Pointer(r))
- // // define a slice to fill with the p string
- // //data := make([]byte, 0)
- //
- // // loop until find '\0'
- // //if *p != 0 {
- // //
- // // //data = append(data, *p) // append 1 byte
- // // //r += unsafe.Sizeof(byte(0)) // move r to next byte
- // // //p = (*byte)(unsafe.Pointer(r)) // get the byte value
- // //} else {
- // // return "", nil
- // //
- // //}
- //
- // return "", nil
- //
- //}
-
- //func GetSFZBaseInfo() (jsonStr string, err error) {
- // //handle := syscall.MustLoadDLL("SSCard.dll")
- //
- // str := make([]byte, 256)
- // str1 := make([]byte, 256)
- // r, _, _ := ReadIDCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
- //
- // fmt.Println(r)
- // return string(str), nil
- //}
-
- //func GetQRBaseInfo() (jsonStr string, err error) {
- // handle := syscall.LoadDLL("SSCard.dll")
- // ReadCardBas := handle.FindProc("GetQRBase")
- //
- // str := make([]byte, 256)
- // str1 := make([]byte, 256)
- // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
- //
- // fmt.Println(string(str))
- // fmt.Println(r)
- // return string(str), nil
- //}
-
- //func CardInit() int {
- // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
- // add := DllTestDef.MustFindProc("Init")
- // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
- // if err != nil {
- // fmt.Println("SSCard的运算结果为:", ret)
- // }
- // result := int(ret)
- // return result
- //}
-
- //func CardInit() int {
- // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
- // if err != nil {
- // fmt.Println("SSCard的运算结果为:", ret)
- // }
- // fmt.Println(err)
- // result := int(ret)
- // return result
- //}
-
- //func IntPtr(n int) uintptr {
- // return uintptr(n)
- //}
-
- //func StrPtr(s string) uintptr {
- // return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
- //}
-
- type ResultTwo struct {
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Baseinfo struct {
- Age float64 `json:"age"`
- Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- Gend string `json:"gend"`
- Naty string `json:"naty"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- } `json:"baseinfo"`
- Idetinfo []interface{} `json:"idetinfo"`
- Iinfo []struct {
- Balc int64 `json:"balc"`
- CvlservFlag string `json:"cvlserv_flag"`
- EmpName string `json:"emp_name"`
- InsuplcAdmdvs string `json:"insuplc_admdvs"`
- Insutype string `json:"insutype"`
- PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
- PausInsuDate interface{} `json:"paus_insu_date"`
- PsnInsuDate string `json:"psn_insu_date"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- } `json:"insuinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnInfo interface{} `json:"warn_info"`
- }
- type ResultThree struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Data struct {
- IptOtpNo string `json:"ipt_otp_no"`
- MdtrtID string `json:"mdtrt_id"`
- PsnNo string `json:"psn_no"`
- } `json:"data"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultFour struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Result []struct {
- BasMednFlag string `json:"bas_medn_flag"`
- ChldMedcFlag string `json:"chld_medc_flag"`
- ChrgitmLv string `json:"chrgitm_lv"`
- Cnt float64 `json:"cnt"`
- DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
- DrtReimFlag string `json:"drt_reim_flag"`
- FeedetlSn string `json:"feedetl_sn"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ListSpItemFlag string `json:"list_sp_item_flag"`
- LmtUsedFlag string `json:"lmt_used_flag"`
- MedChrgitmType string `json:"med_chrgitm_type"`
- Memo string `json:"memo"`
- OverlmtAmt float64 `json:"overlmt_amt"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- Pric float64 `json:"pric"`
- PricUplmtAmt float64 `json:"pric_uplmt_amt"`
- SelfpayProp float64 `json:"selfpay_prop"`
- } `json:"result"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype string `json:"signtype"`
- WarnMsg string `json:"warn_msg"`
- }
- type ResultFive struct {
- Insutype string `json:"insutype"`
- }
- type ResultSix struct {
- Cainfo interface{} `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultSeven struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Setldetail []interface{} `json:"setldetail"`
- Setlinfo struct {
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- AcctPay float64 `json:"acct_pay"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- Age float64 `json:"age"`
- Balc float64 `json:"balc"`
- Brdy string `json:"brdy"`
- Certno string `json:"certno"`
- ClrOptins string `json:"clr_optins"`
- ClrType string `json:"clr_type"`
- ClrWay string `json:"clr_way"`
- CvlservFlag string `json:"cvlserv_flag"`
- CvlservPay float64 `json:"cvlserv_pay"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- Gend string `json:"gend"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- HifpPay float64 `json:"hifp_pay"`
- HospPartAmt float64 `json:"hosp_part_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- Insutype string `json:"insutype"`
- MafPay float64 `json:"maf_pay"`
- MdtrtCertType string `json:"mdtrt_cert_type"`
- HifobPay float64 `json:"hifob_pay"`
-
- MdtrtID string `json:"mdtrt_id"`
- MedType string `json:"med_type"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- MedinsSetlID string `json:"medins_setl_id"`
- Naty string `json:"naty"`
- OthPay float64 `json:"oth_pay"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- PsnCashPay float64 `json:"psn_cash_pay"`
- PsnCertType string `json:"psn_cert_type"`
- PsnName string `json:"psn_name"`
- PsnNo string `json:"psn_no"`
- PsnPartAmt float64 `json:"psn_part_amt"`
- PsnType string `json:"psn_type"`
- SetlID string `json:"setl_id"`
- SetlTime string `json:"setl_time"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultEight struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Stmtinfo struct {
- SetlOptins string `json:"setl_optins"`
- StmtRslt string `json:"stmt_rslt"`
- StmtRsltDscr string `json:"stmt_rslt_dscr"`
- } `json:"stmtinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultNine struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- FileQuryNo string `json:"file_qury_no"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultTen struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- DldEndtime string `json:"dld_endtime"`
- FileQuryNo string `json:"file_qury_no"`
- Filename string `json:"filename"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultEleven struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- Setlinfo struct {
- FixmedinsName string `json:"fixmedins_name"`
- FixmedinsCode string `json:"fixmedins_code"`
- PsnNo string `json:"psn_no"`
- PsnName string `json:"psn_name"`
- HifobPay float64 `json:"hifob_pay"`
- Gend string `json:"gend"`
- Brdy string `json:"brdy"`
- PsnCertType string `json:"psn_cert_type"`
- PsnType string `json:"psn_type"`
- EmpName string `json:"emp_name"`
- Certno string `json:"certno"`
- Insutype string `json:"insutype"`
- MedfeeSumamt float64 `json:"medfee_sumamt"`
- FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
- OverlmtSelfpay float64 `json:"overlmt_selfpay"`
- PreselfpayAmt float64 `json:"preselfpay_amt"`
- InscpScpAmt float64 `json:"inscp_scp_amt"`
- ActPayDedc float64 `json:"act_pay_dedc"`
- HifpPay float64 `json:"hifp_pay"`
- PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
- CvlservPay float64 `json:"cvlserv_pay"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- MafPay float64 `json:"maf_pay"`
- OthPay float64 `json:"oth_pay"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- PsnPay float64 `json:"psn_pay"`
- AcctPay float64 `json:"acct_pay"`
- CashPayamt float64 `json:"cash_payamt"`
- Balc float64 `json:"balc"`
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- MedinsSetlId string `json:"medins_setl_id"`
- RefdSetlFlag string `json:"refd_setl_flag"`
- SetlTime string `json:"setl_time"`
- MedType string `json:"med_type"`
- HospLv string `json:"hosp_lv"`
- } `json:"setlinfo"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type ResultTwelve struct {
- Cainfo string `json:"cainfo"`
- ErrMsg string `json:"err_msg"`
- InfRefmsgid string `json:"inf_refmsgid"`
- Infcode int64 `json:"infcode"`
- Output struct {
- MdtrtId string `json:"mdtrt_id"`
- ChrgBchno string `json:"chrg_bchno"`
- PsnNo string `json:"psn_no"`
- } `json:"output"`
- RefmsgTime string `json:"refmsg_time"`
- RespondTime string `json:"respond_time"`
- Signtype interface{} `json:"signtype"`
- WarnMsg interface{} `json:"warn_msg"`
- }
- type Custom struct {
- DetItemFeeSumamt string
- Cut string
- FeedetlSn string
- Price string
- MedListCodg string
- Type int64
- AdviceId int64
- ProjectId int64
- ItemId int64
- }
-
- //获取读卡信息 -- 门诊挂号
- func (c *SZHisApiController) GetRegisterInfo() {
- //adminInfo := c.GetAdminUserInfo()
- //admin_user_id, _ := c.GetInt64("admin_user_id")
- //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
- resp_result := service.SzybMZ002("黄亦轩", "1001", "G5540", "013", "%GAAFSAKSXSUKKWDKHDAD?;07734724145330238292?", "000000|e14f1d0ad6acdf00ce4d6b9f69d877b6")
- fmt.Println(resp_result)
-
- //month := time.Unix(1557042972, 0).Format("1")
- //year := time.Now().Format("2006")
- //month = time.Now().Format("01")
- //day := time.Now().Format("02")
-
- //1.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
- //miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- //DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
- //readCards := DllDef2.MustFindProc("iReadCardBas")
- //str := "MZ002|H1110201801031000001|G5540"
- //str3 := make([]byte, 256)
- //ret4, _, err4 := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
- //fmt.Println(":", string(str3))
- //
- //if err4 != nil {
- // fmt.Println("SSCard的运算结果为:", ret4)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- // return
- //}
- //
- //if ret4 == 0 {
- // result := string(str3)
- // fmt.Println(result)
- // result_arr := strings.Split(result, "|")
- // //医疗证号
- // number := result_arr[12]
- // //VerifyCode
- // verifyCode := result_arr[11] + "|" + result_arr[13]
- //
- // //挂号
- // resp_result := service.SzybMZ002(adminRole.UserName, strconv.FormatInt(adminRole.ID, 10), "G5540", "013", number, verifyCode)
- // fmt.Println(resp_result)
- //
- //} else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
- // return
- //}
-
- //id, _ := c.GetInt64("id")
- //record_time := c.GetString("record_time")
- //settlementValue, _ := c.GetInt64("settlement_value")
- //medical_insurance_card := c.GetString("medical_insurance_card")
- //name := c.GetString("name")
- //id_card_type, _ := c.GetInt64("id_card_type")
- //certificates, _ := c.GetInt64("certificates")
- //medical_care, _ := c.GetInt64("medical_care")
- //birthday := c.GetString("birthday")
- //age, _ := c.GetInt64("age")
- //id_card := c.GetString("id_card")
- //register_type, _ := c.GetInt64("register")
- //doctor, _ := c.GetInt64("doctor")
- //department, _ := c.GetInt64("department")
- //gender, _ := c.GetInt64("sex")
- //phone := c.GetString("phone")
- //registration_fee, _ := c.GetFloat("registration_fee")
- //medical_expenses, _ := c.GetFloat("medical_expenses")
- //social_type, _ := c.GetInt64("social_type")
- //admin_user_id, _ := c.GetInt64("admin_user_id")
- //diagnosis_id, _ := c.GetInt64("diagnosis")
- //sick_type, _ := c.GetInt64("sick_type")
- //reg_type := c.GetString("p_type")
- //
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- //birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
- //birthUnix := birthdays.Unix()
- //
- //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- //if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- //}
- //recordDateTime := theTime.Unix()
- //
- //adminInfo := c.GetAdminUserInfo()
- //var patient service.Patients
- //if id == 0 {
- // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
- //} else {
- // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
- //}
- //
- //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
- //if patientPrescription.ID == 0 {
- // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
- //}
- //
- //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
- //
- ////diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
- ////sickConfig, _ := service.FindSickById(sick_type)
- //miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- //if patient.ID == 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- // return
- //}
- //if len(patient.IdCardNo) == 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
- // return
- //}
- //config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
- //
- //if config.IsOpen == 1 {
- // //service.SzybMZ002(patientPrescription.Doctor,patientPrescription.DoctorId,miConfig.Code,patientPrescription.XtHisDepartment.Number,)
- //
- // //c.ServeSuccessJSON(map[string]interface{}{
- // // "his_info": hisPatient,
- // //})
- //}
- }
-
- //上传明细----预结算----确认订单
- func (c *SZHisApiController) GetUploadInfo() {
- //id, _ := c.GetInt64("id")
- //record_time := c.GetString("record_time")
- //pay_way, _ := c.GetInt64("pay_way")
- //pay_price, _ := c.GetFloat("pay_price")
- //pay_card_no := c.GetString("pay_card_no")
- //discount_price, _ := c.GetFloat("discount_price")
- //preferential_price, _ := c.GetFloat("preferential_price")
- //reality_price, _ := c.GetFloat("reality_price")
- //found_price, _ := c.GetFloat("found_price")
- //medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
- //private_price, _ := c.GetFloat("private_price")
- //settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- //admin_user_id, _ := c.GetInt64("admin_user_id")
-
- //timeLayout := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- //if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- //}
- //recordDateTime := theTime.Unix()
- //adminUser := c.GetAdminUserInfo()
- //
- ////
- //var prescriptions []*models.HisPrescription
- ////
- //
- //data := make(map[string]interface{})
- //if settle_accounts_type == 1 { //日结
- // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
- // data["pre"] = prescriptions
- //
- //} else { //月结
- // start_time_str := c.GetString("start_time")
- // end_time_str := c.GetString("end_time")
- // timeLayout := "2006-01-02"
- // loc, _ := time.LoadLocation("Local")
- // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- // if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- // }
- // recordStartTime := theStartTime.Unix()
- // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- // if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- // }
- // recordEndTime := theEndTime.Unix()
- // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
- // data["pre"] = prescriptions
- //
- //}
- //
- //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(10000) + 1000
- chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
- //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
- //department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
- //strconv.FormatInt(his.PatientId, 10)
-
- month := time.Unix(1557042972, 0).Format("1")
- year := time.Now().Format("2006")
- month = time.Now().Format("01")
- day := time.Now().Format("02")
-
- var customs []*models.CustomDetail
- for i := 0; i < 1; i++ {
- cus := &models.CustomDetail{
- PrescriptionNumber: chrg_bchno,
- OrderType: "1",
- ChargeSerialNumber: strconv.FormatInt(int64(rand.Intn(100000)+10000), 10),
- Code: "86901187000367",
- CodeName: "普瑞巴林胶囊剂",
- Flag: "1",
- Price: 12.50,
- Count: 1,
- ChargeOrderDate: year + month + day,
- DoctorCode: "H24962918",
- Total: 12.50,
- }
- customs = append(customs, cus)
- }
-
- //for _, item := range prescriptions {
- // if item.Type == 1 { //药品
- // for _, subItem := range item.HisDoctorAdviceInfo {
- // if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
- // //var randNum int
- // //randNum = rand.Intn(10000) + 1000
- // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
- // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
- // cus := &models.CustomDetail{
- // PrescriptionNumber: chrg_bchno,
- // OrderType: "1",
- // ChargeSerialNumber: subItem.FeedetlSn,
- // Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
- // CodeName: subItem.BaseDrugLib.DrugName,
- // Flag: "1",
- // Price: price,
- // Count: subItem.PrescribingNumber,
- // ChargeOrderDate: year + month + day,
- // DoctorCode: "H24962918",
- // Total: detItemFeeSumamt,
- // }
- // customs = append(customs, cus)
- // }
- // }
- // }
- //
- // if item.Type == 2 { //项目
- // for _, subItem := range item.HisPrescriptionProject {
- // //var randNum int
- // //randNum = rand.Intn(10000) + 1000
- // if len(subItem.HisProject.MedicalCode) > 0 {
- // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
- //
- // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
- //
- // cus := &models.CustomDetail{
- //
- // PrescriptionNumber: chrg_bchno,
- // OrderType: "1",
- // ChargeSerialNumber: subItem.FeedetlSn,
- // Code: subItem.HisProject.MedicalCode,
- // CodeName: subItem.HisProject.ProjectName,
- // Flag: "1",
- // Price: subItem.Price,
- // Count: count,
- // ChargeOrderDate: year + month + day,
- // DoctorCode: "H24962918",
- // Total: detItemFeeSumamt,
- // }
- // customs = append(customs, cus)
- // }
- // }
- // }
- //
- // for _, subItem := range item.HisAdditionalCharge {
- // if len(subItem.XtHisAddtionConfig.Code) > 0 {
- // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
- //
- // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
- // cus := &models.CustomDetail{
- // PrescriptionNumber: chrg_bchno,
- // OrderType: "1",
- // ChargeSerialNumber: subItem.FeedetlSn,
- // Code: subItem.XtHisAddtionConfig.Code,
- // CodeName: subItem.XtHisAddtionConfig.Name,
- // Flag: "1",
- // Price: subItem.Price,
- // Count: count,
- // ChargeOrderDate: year + month + day,
- // DoctorCode: "H24962918",
- // Total: detItemFeeSumamt,
- // }
- // customs = append(customs, cus)
- // }
- // }
- //}
-
- //分页处理
- //ToLimitOffset(50,1,len())
- //pages := 50 / len(customs)
-
- var pagesize int = 50
- var start int = 1
- var stop int
- var pagecount int
- var curpage int
- //总页数,向上取整,注意除之前要先转换类型为float64
- pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
- for curpage = 1; curpage <= pagecount; curpage++ {
- if curpage == 1 {
- start = 1
- } else {
- start = (curpage-1)*pagesize + 1
- }
- stop = curpage * pagesize
- if stop > len(customs) {
- stop = len(customs)
- }
- //这里就可以查看开始和结束了
- fmt.Println(customs[start-1 : stop])
-
- //result := service.SzybFY001("黄亦轩", "1001", "G5540", customs, "000000|c0ccb063d7b0846b0945590520ae1668")
- //fmt.Println("result")
- //fmt.Println(":")
- //fmt.Println(result)
- }
-
- //var total float64
- //for _, item := range prescriptions {
- // if item.Type == 1 { //药品
- // for _, subItem := range item.HisDoctorAdviceInfo {
- // total = total + (subItem.Price * subItem.PrescribingNumber)
- // }
- // }
- // if item.Type == 2 { //项目
- // for _, subItem := range item.HisPrescriptionProject {
- // total = total + (subItem.Price * float64(subItem.Count))
- // }
- // }
- //}
- //
- //for _, item := range prescriptions {
- // for _, subItem := range item.HisAdditionalCharge {
- // total = total + (subItem.Price * float64(subItem.Count))
- // }
- //}
- //totals, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", total), 64)
- result := service.SzybFY004("黄亦轩", "H24962918", "G5540", "", 12.50, chrg_bchno, "000000|abacf56c397f74c0fb603ee09b4f61fb")
- fmt.Println(result)
- //
- results := service.SzybFY005("黄亦轩", "H24962918", "G5540", "", 12.50, chrg_bchno, "000000|abacf56c397f74c0fb603ee09b4f61fb")
- fmt.Println(results)
-
- //client := &http.Client{}
- //data["psn_no"] = his.PsnNo
- //data["mdtrt_id"] = his.Number
- //data["chrg_bchno"] = chrg_bchno
- //data["org_name"] = miConfig.OrgName
- //data["doctor"] = roles.UserName
- //data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
- //data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
- //data["fixmedins_code"] = miConfig.Code
- //data["dept_code"] = department.Number
- //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
- //data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- //data["secret_key"] = miConfig.SecretKey
- //var ids []int64
- //
- //for _, item := range prescriptions {
- // ids = append(ids, item.ID)
- //}
- //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- //if config.IsOpen == 1 { //对接了医保,走医保流程
- // bytesData, _ := json.Marshal(data)
- // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
- // resp, _ := client.Do(req)
- // defer resp.Body.Close()
- // body, ioErr := ioutil.ReadAll(resp.Body)
- // if ioErr != nil {
- // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // var respJSON map[string]interface{}
- // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
- // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- //
- // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- // userJSONBytes, _ := json.Marshal(respJSON)
- // var res ResultFour
- // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- //
- // if res.Infcode == 0 {
- // order := &models.HisOrder{
- // UserOrgId: adminUser.CurrentOrgId,
- // HisPatientId: his.ID,
- // PatientId: his.PatientId,
- // SettleAccountsDate: recordDateTime,
- // Ctime: time.Now().Unix(),
- // Mtime: time.Now().Unix(),
- // Status: 1,
- // Number: chrg_bchno,
- // Infcode: res.Infcode,
- // WarnMsg: res.WarnMsg,
- // Cainfo: res.Cainfo,
- // ErrMsg: res.ErrMsg,
- // RespondTime: res.RefmsgTime,
- // InfRefmsgid: res.InfRefmsgid,
- // OrderStatus: 1,
- // IsMedicineInsurance: 1,
- // SettleType: settle_accounts_type,
- // SettleStartTime: start_time,
- // SettleEndTime: end_time,
- // Creator: roles.ID,
- // Modify: roles.ID,
- // }
- // err = service.CreateOrder(order)
- // if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
- // return
- // }
- //
- // for _, item := range res.Output.Result {
- // temp := strings.Split(item.FeedetlSn, "-")
- // var advice_id int64 = 0
- // var project_id int64 = 0
- // var types int64 = 0
- //
- // id, _ := strconv.ParseInt(temp[2], 10, 64)
- // types, _ = strconv.ParseInt(temp[1], 10, 64)
- //
- // if temp[1] == "1" {
- // advice_id = id
- // project_id = 0
- // } else if temp[1] == "2" {
- // advice_id = 0
- // project_id = id
- // }
- //
- // info := &models.HisOrderInfo{
- // OrderNumber: order.Number,
- // FeedetlSn: item.FeedetlSn,
- // UploadDate: time.Now().Unix(),
- // AdviceId: advice_id,
- // DetItemFeeSumamt: item.DetItemFeeSumamt,
- // Cnt: item.Cnt,
- // Pric: float64(item.Pric),
- // PatientId: his.PatientId,
- // PricUplmtAmt: item.PricUplmtAmt,
- // SelfpayProp: item.SelfpayProp,
- // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
- // OverlmtAmt: item.OverlmtAmt,
- // PreselfpayAmt: item.PreselfpayAmt,
- // BasMednFlag: item.BasMednFlag,
- // MedChrgitmType: item.MedChrgitmType,
- // HiNegoDrugFlag: item.HiNegoDrugFlag,
- // Status: 1,
- // Memo: item.Memo,
- // Mtime: time.Now().Unix(),
- // InscpScpAmt: item.InscpScpAmt,
- // DrtReimFlag: item.DrtReimFlag,
- // Ctime: time.Now().Unix(),
- // ListSpItemFlag: item.ListSpItemFlag,
- // ChldMedcFlag: item.ChldMedcFlag,
- // LmtUsedFlag: item.LmtUsedFlag,
- // ChrgitmLv: item.ChrgitmLv,
- // UserOrgId: adminUser.CurrentOrgId,
- // HisPatientId: his.ID,
- // OrderId: order.ID,
- // ProjectId: project_id,
- // Type: types,
- // }
- // service.CreateOrderInfo(info)
- //
- // }
- // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
- // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
- //
- // var total float64
- // for _, item := range prescriptions {
- // if item.Type == 1 { //药品
- // for _, subItem := range item.HisDoctorAdviceInfo {
- // total = total + (subItem.Price * subItem.PrescribingNumber)
- // }
- // }
- // if item.Type == 2 { //项目
- // for _, subItem := range item.HisPrescriptionProject {
- // total = total + (subItem.Price * float64(subItem.Count))
- // }
- // }
- // }
- //
- // for _, item := range prescriptions {
- // for _, subItem := range item.HisAdditionalCharge {
- // total = total + (subItem.Price * float64(subItem.Count))
- // }
- // }
- //
- // allTotal := fmt.Sprintf("%.2f", total)
- // if res.Infcode == 0 {
- // var rf []*ResultFive
- // json.Unmarshal([]byte(his.Iinfo), &rf)
- // psn_no := his.PsnNo
- // mdtrt_id := his.Number
- // chrg_bchno := chrg_bchno
- // cert_no := his.Certno
- // insutype := rf[0].Insutype
- //
- // if his.IdCardType == 1 {
- // cert_no = his.MedicalInsuranceNumber
- //
- // } else {
- //
- // cert_no = his.Certno
- //
- // }
- //
- // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
- // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
- // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
- // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
- // resp, requestErr := http.Get(api)
- // if requestErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // defer resp.Body.Close()
- // body, ioErr := ioutil.ReadAll(resp.Body)
- // if ioErr != nil {
- // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // var respJSON map[string]interface{}
- // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // fmt.Println(respJSON)
- // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- // userJSONBytes, _ := json.Marshal(respJSON)
- // var res ResultSeven
- // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // if res.Infcode == -1 {
- // errlog := &models.HisOrderError{
- // UserOrgId: adminUser.CurrentOrgId,
- // Ctime: time.Now().Unix(),
- // Mtime: time.Now().Unix(),
- // Number: chrg_bchno,
- // ErrMsg: res.ErrMsg,
- // Status: 1,
- // PatientId: id,
- // RecordTime: recordDateTime,
- // Stage: 7,
- // }
- // service.CreateErrMsgLog(errlog)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
- // return
- // } else {
- // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
- // order.OrderStatus = 1
- // order.MdtrtId = res.Output.Setlinfo.MdtrtID
- // order.SetlId = res.Output.Setlinfo.SetlID
- // order.PsnNo = res.Output.Setlinfo.PsnNo
- // order.PsnName = res.Output.Setlinfo.PsnName
- // order.PsnCertType = res.Output.Setlinfo.PsnCertType
- // order.Certno = res.Output.Setlinfo.Certno
- // order.Gend = res.Output.Setlinfo.Gend
- // order.Naty = res.Output.Setlinfo.Naty
- // order.Age = res.Output.Setlinfo.Age
- // order.Insutype = res.Output.Setlinfo.Insutype
- // order.PsnType = res.Output.Setlinfo.PsnType
- // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
- // order.SetlTime = res.Output.Setlinfo.SetlTime
- // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
- // order.MedType = res.Output.Setlinfo.MedType
- // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
- // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
- // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
- // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
- // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
- // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
- // order.HifpPay = res.Output.Setlinfo.HifpPay
- // order.CvlservPay = res.Output.Setlinfo.CvlservPay
- // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
- // order.HifesPay = res.Output.Setlinfo.HifesPay
- // order.HifobPay = res.Output.Setlinfo.HifobPay
- // order.MafPay = res.Output.Setlinfo.MafPay
- // order.OthPay = res.Output.Setlinfo.OthPay
- // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
- // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
- // order.AcctPay = res.Output.Setlinfo.AcctPay
- // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
- // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
- // order.Balc = res.Output.Setlinfo.Balc
- // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
- // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
- // order.ClrOptins = res.Output.Setlinfo.ClrOptins
- // order.ClrWay = res.Output.Setlinfo.ClrWay
- // order.Creator = order.Creator
- // order.Modify = roles.ID
- // setlDetail, _ := json.Marshal(res.Output.Setldetail)
- // detailStr := string(setlDetail)
- // order.SetlDetail = detailStr
- //
- // //err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
- // err = service.UpDateOrder(order)
- //
- // //订单确认
- // result := service.Gdyb6201(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, order)
- //
- // var dat map[string]interface{}
- // if err := json.Unmarshal([]byte(result), &dat); err == nil {
- // userJSONBytes, _ := json.Marshal(dat)
- // var res ResultTwelve
- // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- // utils.ErrorLog("解析失败:%v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // if res.Infcode == 0 {
- // if err == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "预结算成功",
- // })
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
- // return
- // }
- //
- // } else {
- // adminUser := c.GetAdminUserInfo()
- // errlog := &models.HisOrderError{
- // UserOrgId: adminUser.CurrentOrgId,
- // Ctime: time.Now().Unix(),
- // Mtime: time.Now().Unix(),
- // ErrMsg: res.ErrMsg,
- // Status: 1,
- // PatientId: id,
- // RecordTime: recordDateTime,
- // Stage: 8,
- // }
- // service.CreateErrMsgLog(errlog)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
- // }
- // } else {
- // fmt.Println(err)
- // }
- //
- // }
- // } else {
- // adminUser := c.GetAdminUserInfo()
- // errlog := &models.HisOrderError{
- // UserOrgId: adminUser.CurrentOrgId,
- // Ctime: time.Now().Unix(),
- // Mtime: time.Now().Unix(),
- // ErrMsg: res.ErrMsg,
- // Status: 1,
- // PatientId: id,
- // RecordTime: recordDateTime,
- // Stage: 4,
- // }
- // service.CreateErrMsgLog(errlog)
- //
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
- // return
- // }
- // } else {
- // adminUser := c.GetAdminUserInfo()
- // errlog := &models.HisOrderError{
- // UserOrgId: adminUser.CurrentOrgId,
- // Ctime: time.Now().Unix(),
- // Mtime: time.Now().Unix(),
- // ErrMsg: res.ErrMsg,
- // Status: 1,
- // PatientId: id,
- // RecordTime: recordDateTime,
- // Stage: 4,
- // }
- // service.CreateErrMsgLog(errlog)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
- // return
- // }
- //
- //}
- }
- func (c *SZHisApiController) GetSettleInfo() {
- id, _ := c.GetInt64("id")
- order_id, _ := c.GetInt64("order_id")
-
- record_time := c.GetString("record_time")
- pay_way, _ := c.GetInt64("pay_way")
- pay_price, _ := c.GetFloat("pay_price")
- pay_card_no := c.GetString("pay_card_no")
- discount_price, _ := c.GetFloat("discount_price")
- preferential_price, _ := c.GetFloat("preferential_price")
- reality_price, _ := c.GetFloat("reality_price")
- found_price, _ := c.GetFloat("found_price")
- medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
- private_price, _ := c.GetFloat("private_price")
- settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
- admin_user_id, _ := c.GetInt64("admin_user_id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- adminUser := c.GetAdminUserInfo()
-
- var prescriptions []*models.HisPrescription
-
- data := make(map[string]interface{})
- if settle_accounts_type == 1 { //日结
- prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
- data["pre"] = prescriptions
-
- } else { //月结
- start_time_str := c.GetString("start_time")
- end_time_str := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordStartTime := theStartTime.Unix()
- theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordEndTime := theEndTime.Unix()
- prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
- data["pre"] = prescriptions
-
- }
-
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
-
- his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(100000) + 10000
- chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
- strconv.FormatInt(his.PatientId, 10)
-
- order_src, _ := service.GetHisOrderByID(order_id)
-
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- var total float64
- for _, item := range prescriptions {
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- total = total + (subItem.Price * subItem.PrescribingNumber)
- }
- }
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- total = total + (subItem.Price * float64(subItem.Count))
- }
- }
- }
-
- for _, item := range prescriptions {
- for _, subItem := range item.HisAdditionalCharge {
- total = total + (subItem.Price * float64(subItem.Count))
- }
- }
-
- allTotal := fmt.Sprintf("%.2f", total)
- var rf []*ResultFive
- json.Unmarshal([]byte(his.Iinfo), &rf)
- psn_no := his.PsnNo
- mdtrt_id := his.Number
- chrg_bchno := chrg_bchno
- cert_no := his.Certno
- insutype := rf[0].Insutype
-
- if his.IdCardType == 1 {
- cert_no = his.MedicalInsuranceNumber
- } else {
- cert_no = his.Certno
- }
-
- api := "http://127.0.0.1:9532/" + "gdyb/eight?cert_no=" + cert_no + "&insutype=" +
- insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
- "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
- miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10) + "&fulamt_ownpay_amt=" + strconv.FormatFloat(order_src.FulamtOwnpayAmt, 'E', -1, 64) + "&overlmt_selfpay=" + strconv.FormatFloat(order_src.OverlmtSelfPay, 'E', -1, 64) + "&preselfpay_amt=" + strconv.FormatFloat(order_src.PreselfpayAmt, 'E', -1, 64) + "&inscp_scp_amt=" + strconv.FormatFloat(order_src.InscpScpAmt, 'E', -1, 64)
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- defer resp.Body.Close()
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- fmt.Println(respJSON)
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- userJSONBytes, _ := json.Marshal(respJSON)
- var res ResultSeven
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res.Infcode == -1 {
- errlog := &models.HisOrderError{
- UserOrgId: adminUser.CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: chrg_bchno,
- ErrMsg: res.ErrMsg,
- Status: 1,
- PatientId: id,
- RecordTime: recordDateTime,
- Stage: 6,
- }
- service.CreateErrMsgLog(errlog)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
- return
- } else {
- order_src.OrderStatus = 2
- order_src.PayWay = pay_way
- order_src.PayPrice = pay_price
- order_src.PayCardNo = pay_card_no
- order_src.DiscountPrice = discount_price
- order_src.PreferentialPrice = preferential_price
- order_src.RealityPrice = reality_price
- order_src.FoundPrice = found_price
- order_src.MedicalInsurancePrice = medical_insurance_price
- order_src.PrivatePrice = private_price
- order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
- order_src.SetlId = res.Output.Setlinfo.SetlID
- order_src.PsnNo = res.Output.Setlinfo.PsnNo
- order_src.PsnName = res.Output.Setlinfo.PsnName
- order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
- order_src.Certno = res.Output.Setlinfo.Certno
- order_src.Gend = res.Output.Setlinfo.Gend
- order_src.Naty = res.Output.Setlinfo.Naty
- order_src.Age = res.Output.Setlinfo.Age
- order_src.Insutype = res.Output.Setlinfo.Insutype
- order_src.PsnType = res.Output.Setlinfo.PsnType
- order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
- order_src.SetlTime = res.Output.Setlinfo.SetlTime
- order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
- order_src.MedType = res.Output.Setlinfo.MedType
- order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
- order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
- order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
- order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
- order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
- order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
- order_src.HifpPay = res.Output.Setlinfo.HifpPay
- order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
- order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
- order_src.HifesPay = res.Output.Setlinfo.HifesPay
- order_src.HifobPay = res.Output.Setlinfo.HifobPay
- order_src.MafPay = res.Output.Setlinfo.MafPay
- order_src.OthPay = res.Output.Setlinfo.OthPay
- order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
- order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
- order_src.AcctPay = res.Output.Setlinfo.AcctPay
- order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
- order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
- order_src.Balc = res.Output.Setlinfo.Balc
- order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
- order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
- order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
- order_src.ClrWay = res.Output.Setlinfo.ClrWay
- order_src.Creator = order_src.Creator
- order_src.Modify = roles.ID
- setlDetail, _ := json.Marshal(res.Output.Setldetail)
- detailStr := string(setlDetail)
- order_src.SetlDetail = detailStr
- err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
- err = service.UpDateOrder(order_src)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "结算成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
- return
- }
- }
- }
- }
-
- func (c *SZHisApiController) Refund() {
- order_id, _ := c.GetInt64("order_id")
- number := c.GetString("number")
- record_time := c.GetString("record_time")
- patient_id, _ := c.GetInt64("patient_id")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- adminUser := c.GetAdminUserInfo()
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- fmt.Println(err)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- var order models.HisOrder
- order, _ = service.GetHisOrderByID(order_id)
-
- if order.ID == 0 {
- order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
-
- }
-
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
-
- if config.IsOpen == 1 { //对接了医保,走医保流程
- api := "http://127.0.0.1:9532/" + "gdyb/nine?psn_no=" + his.PsnNo +
- "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&setl_id=" + order.SetlId + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp, requestErr := http.Get(api)
- if requestErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- body, ioErr := ioutil.ReadAll(resp.Body)
- if ioErr != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON map[string]interface{}
- if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
- userJSONBytes, _ := json.Marshal(respJSON)
- fmt.Println(respJSON)
- fmt.Println(userJSONBytes)
-
- api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
- "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp2, requestErr2 := http.Get(api2)
- if requestErr2 != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body2, ioErr2 := ioutil.ReadAll(resp2.Body)
- if ioErr2 != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON2 map[string]interface{}
- if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- //api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
- // "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
- // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- //resp3, requestErr3 := http.Get(api3)
- //if requestErr3 != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- //}
- //
- //body3, ioErr3 := ioutil.ReadAll(resp3.Body)
- //if ioErr3 != nil {
- // utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- //}
- //var respJSON3 map[string]interface{}
- //if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
- // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- //}
- err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
- //service.UpdataRegStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- } else {
- err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
- }
- func (c *SZHisApiController) RefundNumber() {
- record_time := c.GetString("record_time")
- patient_id, _ := c.GetInt64("patient_id")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- adminUser := c.GetAdminUserInfo()
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- fmt.Println(err)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- //order, _ := service.GetHisOrderByID(order_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
-
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
- "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp3, requestErr3 := http.Get(api3)
- if requestErr3 != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body3, ioErr3 := ioutil.ReadAll(resp3.Body)
- if ioErr3 != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON3 map[string]interface{}
- if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
- service.UpdataRegStatus(patient_id, recordDateTime, adminUser.CurrentOrgId)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- } else {
- //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
- //if err == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "退费成功",
- // })
- //} else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- //}
- }
- }
- func (c *SZHisApiController) RefundDetail() {
- order_id, _ := c.GetInt64("order_id")
- number := c.GetString("number")
- record_time := c.GetString("record_time")
- patient_id, _ := c.GetInt64("patient_id")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- adminUser := c.GetAdminUserInfo()
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
- fmt.Println(err)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
- his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
-
- var order models.HisOrder
- order, _ = service.GetHisOrderByID(order_id)
-
- if order.ID == 0 {
- order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
-
- }
-
- if config.IsOpen == 1 { //对接了医保,走医保流程
- api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
- "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
- "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
- resp2, requestErr2 := http.Get(api2)
- if requestErr2 != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- body2, ioErr2 := ioutil.ReadAll(resp2.Body)
- if ioErr2 != nil {
- utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- var respJSON2 map[string]interface{}
- if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
- utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- } else {
- err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
- }
|