12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364 |
- package zh
-
- import (
- "bytes"
- "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"
- "strings"
- "time"
- )
-
- type ZHHisApiController struct {
- controllers.BaseAuthAPIController
- }
-
- 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 float64 `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 string `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 {
- Result struct {
- MdtrtID string `json:"mdtrt_id"`
- } `json:"result"`
- } `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 {
- Balc float64 `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 string `json:"paus_insu_date"`
- PsnInsuDate string `json:"psn_insu_date"`
- PsnInsuStas string `json:"psn_insu_stas"`
- PsnType string `json:"psn_type"`
- }
- 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 ResultSixteen 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 {
- MdtrtID string `json:"mdtrt_id"`
- SetlID string `json:"setl_id"`
- ClrOptins string `json:"clr_optins"`
- SetlTime string `json:"setl_time"`
- 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"`
- PoolPropSe float64 `json:"pool_prop_selfpay"`
- Lfpay float64 `json:"selfpay"`
- CvlservPay float64 `json:"cvlserv_pay"`
- HifesPay float64 `json:"hifes_pay"`
- HifmiPay float64 `json:"hifmi_pay"`
- HifobPay float64 `json:"hifob_pay"`
- MafPay float64 `json:"maf_pay"`
- OthPay float64 `json:"oth_pay"`
- FundPaySumamt float64 `json:"fund_pay_sumamt"`
- PsnPartAmt float64 `json:"psn_part_amt"`
- AcctPay float64 `json:"acct_pay"`
- Balc float64 `json:"balc"`
- AcctMulaidPay float64 `json:"acct_mulaid_pay"`
- HospPartAmt float64 `json:"hosp_part_amt"`
- MedinsSetlID string `json:"medins_setl_id"`
- PdnCashPay string `json:"pdn_cash_pay"`
- } `json:"setlinfo"`
- } `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
- }
-
- type ResultEmpty 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 CustomResult 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"`
- }
-
- func ZHHisManagerApiRegistRouters() {
- beego.Router("/zh/api/inhopitalcheck/get", &ZHHisApiController{}, "get:GetZHInHospitalCheck")
- beego.Router("/zh/api/outhopitalcheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalCheck")
- beego.Router("/zh/api/uploadinfo/get", &ZHHisApiController{}, "get:GetUploadInfo")
- beego.Router("/zh/api/settle/get", &ZHHisApiController{}, "get:GetSettleInfo")
- beego.Router("/zh/api/inthopitaluncheck/get", &ZHHisApiController{}, "get:GetZHInHospitalUnCheck")
- beego.Router("/zh/api/outhopitaluncheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalUnCheck")
- beego.Router("/zh/api/refund", &ZHHisApiController{}, "get:ZHRefund")
- beego.Router("/zh/api/refunddetail", &ZHHisApiController{}, "get:ZHRefundDetail")
-
- }
-
- func (c *ZHHisApiController) GetZHInHospitalCheck() {
- id, _ := c.GetInt64("id")
- record_time := c.GetString("record_time")
- name := c.GetString("name")
- phone := c.GetString("phone")
- id_card_type, _ := c.GetInt64("id_card_type")
- certificates, _ := c.GetInt64("certificates")
- id_card_no := c.GetString("id_card_no")
- doctor, _ := c.GetInt64("doctor")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- department, _ := c.GetInt64("department")
- adm_bed, _ := c.GetInt64("adm_bed")
- diagnosis_ids := c.GetString("diagnosis")
- sick_type, _ := c.GetInt64("sick_type")
- start_time := c.GetString("start_time")
-
- //reg_type, _ := c.GetInt64("p_type")
- med_type, _ := c.GetInt64("med_type")
- diagnosis_ids_arr := strings.Split(diagnosis_ids, "-")
- 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()
- adminInfo := c.GetAdminUserInfo()
- record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
- if record.ID != 0 {
- if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
- return
- }
- }
- var patient service.Patients
- if id == 0 {
- patient, _ = service.GetPatientByIDCard(id_card_no, adminInfo.CurrentOrgId)
- } else {
- patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
- }
- diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
- sickConfig, _ := service.FindSickById(sick_type)
- departmentInfo, _ := service.GetDepartMentDetail(department)
-
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
- result := service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates)
-
- doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
-
- deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res2 ResultTwo
- if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res2.Infcode == 0 {
-
- var insutypes []string
-
- var insutype string
- var is390 int = 0
- var is310 int = 0
- for _, item := range res2.Output.Iinfo {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
- if is310 == 1 {
- insutype = "310"
- }
-
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- timeFormat := tempTime.Format("20060102150405")
- chrgBchno := rand.Intn(100000) + 10000
- ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
-
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- var struct2401 service.Struct2401
- struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
- struct2401.Insutype = insutype
- struct2401.MdtrtCertType = "02"
- struct2401.MdtrtCertNo = res2.Output.Baseinfo.Certno
- struct2401.MedType = strconv.FormatInt(int64(med_type), 10)
- struct2401.IptNo = ipt_otp_no
- struct2401.AtddrNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
- struct2401.ChfpdrName = doctorInfo.UserName
- struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
- struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
- struct2401.AdmDeptName = departmentInfo.Name
- struct2401.AdmBed = deviceNumber.Number
- struct2401.AdmBed = "待定"
-
- struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
- struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
- struct2401.Begntime = start_time
- struct2401.DiseCodg = sickConfig.CountryCode
- struct2401.DiseName = sickConfig.ClassName
-
- var dises []service.DiseinfoStruct
-
- for index, item := range diagnosisConfig {
- var dise service.DiseinfoStruct
-
- dise.PsnNo = res2.Output.Baseinfo.PsnNo
- dise.DiagType = "1"
- if index == 0 {
- dise.MaindiagFlag = "1"
- } else {
- dise.MaindiagFlag = "2"
- }
-
- dise.DiagSrtNo = strconv.FormatInt(int64(item.ID), 10)
- dise.DiseDorName = doctorInfo.UserName
- dise.DiagCode = item.CountryCode
- dise.DiagName = item.ClassName
- dise.DiagDept = departmentInfo.Name
- dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
- dise.DiagTime = timeFormatOne
-
- dises = append(dises, dise)
- }
- struct2401.Diseinfo = dises
- result := service.ZHGdyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultThree
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res.Infcode == 0 {
- Iinfos, _ := json.Marshal(res2.Output.Iinfo)
- Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
- infoStr := string(Iinfos)
- idetinfoStr := string(Idetinfos)
- inHospital := &models.HisHospitalCheckRecord{
- PatientId: id,
- Name: name,
- MedicalTreatmentType: med_type,
- RecordDate: recordDateTime,
- IdCardNo: id_card_no,
- AdminUserId: admin_user_id,
- Departments: department,
- UserOrgId: adminInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: res.Output.Result.MdtrtID,
- Doctor: doctor,
- PsnNo: res2.Output.Baseinfo.PsnNo,
- PsnCertType: res2.Output.Baseinfo.PsnCertType,
- Certno: res2.Output.Baseinfo.Certno,
- PsnName: res2.Output.Baseinfo.PsnName,
- Gend: res2.Output.Baseinfo.Gend,
- Naty: res2.Output.Baseinfo.Naty,
- MedType: med_type,
- InsutypeType: insutype,
- Brdy: res2.Output.Baseinfo.Brdy,
- Iinfo: infoStr,
- Idetinfo: idetinfoStr,
- IptOtpNo: ipt_otp_no,
- AdmBed: adm_bed,
- IdCardType: id_card_type,
- Diagnosis: diagnosis_ids,
- SickType: sick_type,
- MdtrtCertType: "02",
- InHosptialTime: start_time,
- OutHosptialTime: "",
- InHospitalStatus: 1,
- Certificates: certificates,
- Phone: phone,
- }
- service.CreateHospitalRecord(inHospital)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "办理入院成功",
- "info": inHospital,
- })
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res2.ErrMsg,
- })
- return
- }
-
- }
- func (this *ZHHisApiController) GetZHOutHospitalCheck() {
- id, _ := this.GetInt64("id")
- patient_id, _ := this.GetInt64("patient_id")
- admin_user_id, _ := this.GetInt64("admin_user_id")
- //record_time := this.GetString("record_time")
-
- adminInfo := this.GetAdminUserInfo()
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
-
- record, _ := service.GetInHospitalRecord(id)
- if record.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
- return
- }
-
- //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 {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- //}
- //recordDateTime := theTime.Unix()
-
- var patient service.Patients
- if patient_id == 0 {
- patient, _ = service.GetPatientByIDCard(record.IdCardNo, adminInfo.CurrentOrgId)
- } else {
- patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
- }
- fmt.Println(patient)
- diagnosis_ids_arr := strings.Split(record.Diagnosis, "-")
-
- diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
- departmentInfo, _ := service.GetDepartMentDetail(record.Departments)
- doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, record.Doctor)
- //deviceNumber, _ := service.GetDeviceNumberByID(record.AdmBed, adminInfo.CurrentOrgId)
- sickConfig, _ := service.FindSickById(record.SickType)
-
- var struct2402 service.Struct2402
- timestamp := time.Now().Unix()
- tempTime := time.Unix(timestamp, 0)
- //timeFormat := tempTime.Format("20060102150405")
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
-
- struct2402.PsnNo = record.PsnNo
- struct2402.Insutype = record.InsutypeType
- struct2402.DscgWay = "1"
- struct2402.Endtime = timeFormatOne
- struct2402.DscgDeptName = departmentInfo.Number
- struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
- struct2402.MdtrtId = record.Number
-
- var dises []service.Diseinfo2402Struct
-
- for index, item := range diagnosisConfig {
- var dise service.Diseinfo2402Struct
-
- dise.PsnNo = record.PsnNo
- dise.DiagType = "1"
- if index == 0 {
- dise.MaindiagFlag = "1"
- } else {
- dise.MaindiagFlag = "2"
- }
-
- dise.MdtrtId = record.Number
- dise.DiagSrtNo = strconv.FormatInt(int64(item.ID), 10)
- dise.DiseDorName = doctorInfo.UserName
- dise.DiagCode = item.CountryCode
- dise.DiagName = item.ClassName
- dise.DiagDept = departmentInfo.Name
- dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
- dise.DiagTime = timeFormatOne
-
- dises = append(dises, dise)
- }
- struct2402.Diseinfo = dises
- struct2402.DiseName = sickConfig.ClassName
- struct2402.DiseCode = sickConfig.CountryCode
- result := service.ZHGdyb2402(struct2402, miConfig.OrgName, role.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultEmpty
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- record.OutHospitalStatus = 1
- record.OutHosptialTime = struct2402.Endtime
- record.OutWay = 1
- service.CreateHospitalRecord(&record)
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "出院成功",
- })
-
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- }
- func (c *ZHHisApiController) GetSettleInfo() {
- order_id, _ := c.GetInt64("order_id")
- patient_id, _ := c.GetInt64("patient_id")
- in_hospital_id, _ := c.GetInt64("in_hospital_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- 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")
- fapiao_code := c.GetString("fapiao_code")
- fapiao_number := c.GetString("fapiao_number")
-
- order, _ := service.GetHisOrderByID(order_id)
- record, _ := service.GetInHospitalRecord(in_hospital_id)
-
- miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
-
- allTotal := fmt.Sprintf("%.2f", order.MedfeeSumamt)
- roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
-
- var rf []*ResultFive
- json.Unmarshal([]byte(record.Iinfo), &rf)
- chrg_bchno := order.Number
- cert_no := record.Certno
-
- var insutypes []string
-
- var insutype string
- var is390 int = 0
- var is310 int = 0
-
- if record.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
- return
- }
-
- for _, item := range rf {
- if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
- insutypes = append(insutypes, item.Insutype)
- }
- }
-
- if len(insutypes) == 1 {
- insutype = insutypes[0]
- } else {
- for _, i := range insutypes {
- if i == "390" {
- is390 = 1
- }
-
- if i == "310" {
- is310 = 1
- }
- }
- }
- if is390 == 1 {
- insutype = "390"
- }
-
- if is310 == 1 {
- insutype = "310"
- }
-
- if len(insutypes) == 0 {
- insutype = "310"
- }
-
- if record.IdCardType == 1 {
-
- } else {
-
- cert_no = record.Certno
-
- }
-
- result, src_resquest := service.ZHGdyb2304(record.PsnNo, record.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
-
- 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: c.GetAdminUserInfo().CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: chrg_bchno,
- ErrMsg: res.ErrMsg,
- Status: 1,
- PatientId: patient_id,
- RecordTime: time.Now().Unix(),
- Stage: 6,
- }
- service.CreateErrMsgLog(errlog)
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- return
- } else {
- //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
- order.OrderStatus = 2
- order.DiscountPrice = discount_price
- order.MedicalInsurancePrice = medical_insurance_price
- order.FaPiaoNumber = fapiao_number
- order.FaPiaoCode = fapiao_code
- order.PayWay = pay_way
- order.PayPrice = pay_price
- order.PayCardNo = pay_card_no
- order.PreferentialPrice = preferential_price
- order.RealityPrice = reality_price
- order.FoundPrice = found_price
- order.PrivatePrice = private_price
- 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.AdminUserId
- order.RequestLog = src_resquest
- setlDetail, _ := json.Marshal(res.Output.Setldetail)
- detailStr := string(setlDetail)
- order.SetlDetail = detailStr
- err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
- err = service.UpDateOrder(order)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "结算成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
- return
- }
- }
-
- }
- func (c *ZHHisApiController) GetUploadInfo() {
- id, _ := c.GetInt64("id")
- record_time := c.GetString("record_time")
- in_hospital_id, _ := c.GetInt64("in_hospital_id")
- 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.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
-
- } 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.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
-
- }
-
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- record, _ := service.GetInHospitalRecord(in_hospital_id)
-
- if record.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
- // return
- //}
-
- 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(record.PatientId, 10)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
- department, _ := service.GetDepartMentDetail(record.Departments)
- strconv.FormatInt(record.PatientId, 10)
-
- client := &http.Client{}
- data["psn_no"] = record.PsnNo
- data["mdtrt_id"] = record.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(department.ID, 10)
- data["fixmedins_code"] = miConfig.Code
- if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
- data["dept_code"] = "15"
- } else {
- data["dept_code"] = department.Number
- }
- data["med_type"] = strconv.FormatInt(record.MedType, 10)
- data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
- data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
- data["secret_key"] = miConfig.SecretKey
- var ids []int64
-
- fmt.Println(data)
-
- for _, item := range prescriptions {
- ids = append(ids, item.ID)
- }
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- var pagesize int = 100
- var start int = 1
- var stop int
- var pagecount int
- var curpage int
- var isSuccess bool = true
-
- var customs []*models.NewCustom
-
- 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
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
- Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", subItem.Price),
- MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
- HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
- }
-
- 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 {
-
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
- Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
- MedListCodg: subItem.HisProject.MedicalCode,
- HospApprFlag: -1,
- }
- customs = append(customs, cus)
- }
- }
- }
-
- for _, subItem := range item.HisAdditionalCharge {
- if len(subItem.XtHisAddtionConfig.Code) > 0 {
- cus := &models.NewCustom{
- DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
- Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
- MedListCodg: subItem.XtHisAddtionConfig.Code,
- HospApprFlag: -1,
- }
- customs = append(customs, cus)
- }
- }
- }
-
- //总页数,向上取整,注意除之前要先转换类型为float64
- pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
- var ress []*ResultFour
- 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)
- }
-
- data["pre"] = customs[start-1 : stop]
- bytesData, _ := json.Marshal(data)
- req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/zh/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 {
- ress = append(ress, &res)
- } else {
- isSuccess = false
- errlog := &models.HisOrderError{
- UserOrgId: adminUser.CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Number: chrg_bchno,
- ErrMsg: "",
- Status: 1,
- PatientId: id,
- RecordTime: recordDateTime,
- Stage: 4,
- }
- service.CreateErrMsgLog(errlog)
- c.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": "上传明细错误,请联系his厂商",
- })
- return
- }
- }
-
- if isSuccess == true {
- 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)
- totals, _ := strconv.ParseFloat(allTotal, 64)
-
- order := &models.HisOrder{
- UserOrgId: adminUser.CurrentOrgId,
- HisPatientId: record.ID,
- PatientId: record.PatientId,
- SettleAccountsDate: recordDateTime,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Status: 1,
- Number: chrg_bchno,
- Infcode: 0,
- WarnMsg: "",
- Cainfo: "",
- ErrMsg: "",
- RespondTime: "",
- InfRefmsgid: "",
- OrderStatus: 1,
- MdtrtId: record.Number,
- IsMedicineInsurance: 1,
- SettleType: settle_accounts_type,
- SettleStartTime: start_time,
- SettleEndTime: end_time,
- Creator: roles.AdminUserId,
- Modify: roles.AdminUserId,
- PType: 1,
- MedfeeSumamt: totals,
- }
- err = service.CreateOrder(order)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
- return
- }
- for _, subItem := range ress {
- for _, item := range subItem.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: record.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: record.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)
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "上传费用明细成功",
- })
- }
-
- }
- }
- func (c *ZHHisApiController) ZHRefund() {
- order_id, _ := c.GetInt64("order_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- adminUser := c.GetAdminUserInfo()
- var order models.HisOrder
- order, _ = service.GetHisOrderByID(order_id)
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- result, src_resquest := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
-
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
-
- var res ResultSixteen
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res.Infcode == 0 {
- err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- } else {
- err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- }
- func (c *ZHHisApiController) ZHRefundDetail() {
- order_id, _ := c.GetInt64("order_id")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- adminUser := c.GetAdminUserInfo()
- var order models.HisOrder
- order, _ = service.GetHisOrderByID(order_id)
- roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
- miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
- config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
- if config.IsOpen == 1 { //对接了医保,走医保流程
-
- result := service.Gdyb2302(order.PsnNo, order.MdtrtId, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
-
- userJSONBytes, _ := json.Marshal(dat)
-
- var res2 ResultEmpty
- if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if res2.Infcode == 0 {
- err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", result)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "code": -10,
- "msg": res2.ErrMsg,
- })
- }
- } else {
- err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "退费成功",
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- }
-
- }
-
- func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
- id, _ := this.GetInt64("id")
- admin_user_id, _ := this.GetInt64("admin_user_id")
-
- adminInfo := this.GetAdminUserInfo()
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
-
- record, _ := service.GetInHospitalRecord(id)
- if record.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
- return
- }
- result := service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultEmpty
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- record.OutHospitalStatus = 0
- service.CreateHospitalRecord(&record)
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销出院成功",
- })
-
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- }
- func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
- id, _ := this.GetInt64("id")
- admin_user_id, _ := this.GetInt64("admin_user_id")
-
- adminInfo := this.GetAdminUserInfo()
- miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
- role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
-
- record, _ := service.GetInHospitalRecord(id)
- if record.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
- return
- }
- result := service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
- var dat map[string]interface{}
- if err := json.Unmarshal([]byte(result), &dat); err == nil {
- fmt.Println(dat)
- } else {
- fmt.Println(err)
- }
- userJSONBytes, _ := json.Marshal(dat)
- var res ResultEmpty
- if err := json.Unmarshal(userJSONBytes, &res); err != nil {
- utils.ErrorLog("解析失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if res.Infcode == 0 {
- record.Status = 0
- service.CreateHospitalRecord(&record)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "撤销入院成功",
- })
-
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "failed_code": -10,
- "msg": res.ErrMsg,
- })
- }
-
- }
|