package sz import ( "gdyb/controllers" "gdyb/enums" "gdyb/service" "github.com/astaxie/beego" "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() { 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 { //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 // // var start_time int64 // var end_time int64 // // 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() // start_time = recordStartTime // 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() // end_time = recordEndTime // 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) // department, _ := service.GetDepartMentDetail(patientPrescription.Departments) // strconv.FormatInt(his.PatientId, 10) // 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 // } // } //}