123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999 |
- package service
-
- import (
- "bytes"
- "encoding/json"
- "fmt"
- "gdyb/models"
- "github.com/astaxie/beego"
- "io/ioutil"
- "net/http"
- "strconv"
- "strings"
- "time"
- )
-
- // 门诊挂号
- func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, verify_number string, cainfo string) (string, string) {
- // 生成签名
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
- tempTime := time.Unix(timestamp, 0)
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
- // 生成输入报文
- //inputMessage := SetInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2201" // 交易编码
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
- inputData["begntime"] = timeFormatOne // 开始时间
-
- if id_card_type == 1 {
- inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else if id_card_type == 3 {
- inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else if id_card_type == 4 {
- inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else {
- inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
-
- }
-
- inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
- inputData["atddr_no"] = doctor_id // 医师编码
- inputData["dr_name"] = doctor_name // 医师姓名
- inputData["dept_code"] = dept_code // 科室编码
- inputData["dept_name"] = dept // 科室名称
- inputData["caty"] = "A03.06" // 科别
- inputData["exp_content"] = "" //
-
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
-
- var requestLog string
- bytesData, err := json.Marshal(inputMessage)
- requestLog = string(bytesData)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
-
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
-
- request, err := http.NewRequest("POST", gdyb_url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- str := string(respBytes)
- fmt.Println(str)
- return str, requestLog
-
- }
-
- // 门诊挂号撤销
- func Nmyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, cainfo string) (string, string) {
- // 生成签名
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
-
- // 生成输入报文
- inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
-
- //inputMessage := SetInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2202" // 交易编码
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
- inputData["exp_content"] = "" //
-
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
-
- var requestLog string
-
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println(string(bytesData))
- requestLog = string(bytesData)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
-
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
-
- request, err := http.NewRequest("POST", gdyb_url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- str := string(respBytes)
- fmt.Println(str)
- return str, requestLog
- }
-
- // 门诊就诊信息上传
- func Nmyb2203(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string, cainfo string) (string, string) {
- // 生成签名
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
- //tempTime := time.Unix(timestamp, 0)
- //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- // 生成输入报文
-
- tempTime := time.Unix(timestamp, 0)
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- // 生成输入报文
- inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- diseinfo := make([]map[string]interface{}, 0)
-
- if med_type == "1111" || med_type == "1112" {
- med_type = "11"
- }
-
- inputMessage["infno"] = "2203A" // 交易编码
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
- inputData["begntime"] = begin_time // 开始时间
- inputData["main_cond_dscr"] = "" // 主要病情描述
- inputData["dise_codg"] = sick_code // 病种编码
- inputData["dise_name"] = sick_name // 病种名称
- inputData["birctrl_type"] = "" // 计划生育手术类别
- inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
-
- for index, item := range config {
- diseinfo_sun := make(map[string]interface{})
- diseinfo_sun["diag_type"] = "1" // 诊断类别
- diseinfo_sun["diag_srt_no"] = index // 诊断排序号
- diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
- diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
- diseinfo_sun["diag_dept"] = department // 诊断科室
- diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
- diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
- diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
- diseinfo_sun["vali_flag"] = "1" // 有效标志
- diseinfo = append(diseinfo, diseinfo_sun)
- }
- //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
- inputData["exp_content"] = "" //
-
- input["diseinfo"] = diseinfo
- input["mdtrtinfo"] = inputData
- inputMessage["input"] = input //交易输入
- var requestLog string
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println(string(bytesData))
- requestLog = string(bytesData)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
-
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
-
- request, err := http.NewRequest("POST", gdyb_url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- str := string(respBytes)
- fmt.Println(str)
- return str, requestLog
-
- }
- func Nmyb2203C(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string, cainfo string) (string, string) {
- // 生成签名
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
- //tempTime := time.Unix(timestamp, 0)
- //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- // 生成输入报文
-
- tempTime := time.Unix(timestamp, 0)
- timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
- // 生成输入报文
- inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- diseinfo := make([]map[string]interface{}, 0)
-
- if med_type == "1111" || med_type == "1112" {
- med_type = "11"
- }
-
- inputMessage["infno"] = "2203A" // 交易编码
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
- inputData["begntime"] = begin_time // 开始时间
- inputData["main_cond_dscr"] = "" // 主要病情描述
- inputData["dise_codg"] = sick_code // 病种编码
- inputData["dise_name"] = sick_name // 病种名称
- inputData["birctrl_type"] = "" // 计划生育手术类别
- inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
-
- for index, item := range config {
- diseinfo_sun := make(map[string]interface{})
- diseinfo_sun["diag_type"] = "1" // 诊断类别
- diseinfo_sun["diag_srt_no"] = index // 诊断排序号
- diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
- diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
- diseinfo_sun["diag_dept"] = department // 诊断科室
- diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
- diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
- diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
- diseinfo_sun["vali_flag"] = "0" // 有效标志
- diseinfo = append(diseinfo, diseinfo_sun)
- }
- //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
- inputData["exp_content"] = "" //
-
- input["diseinfo"] = diseinfo
- input["mdtrtinfo"] = inputData
- inputMessage["input"] = input //交易输入
- var requestLog string
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println(string(bytesData))
- requestLog = string(bytesData)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
-
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
-
- request, err := http.NewRequest("POST", gdyb_url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- str := string(respBytes)
- fmt.Println(str)
- return str, requestLog
-
- }
-
- // 门诊费用明细信息上传
- func Nmyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, balance_accounts_type string, diag_code string, request_url string, access_key string, new_doctor_name string, time_stamp_2203 string, cainfo string) (string, string) {
-
- // 生成签名
- timestamp := time.Now().Unix()
- // 生成签名
- nonce := GetRandomString(32)
- signature := setSignature(timestamp, nonce, secret_key)
-
- var customs []*Custom
- for _, item := range hisPrescription {
- tm := time.Unix(item.PreTime, 0)
-
- if item.Type == 1 { //药品
- for _, subItem := range item.HisDoctorAdviceInfo {
- if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
- //var randNum int
- //randNum = rand.Intn(10000) + 1000
- cus := &Custom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
- Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", subItem.Price),
- MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
- HospApprFlag: subItem.HospApprFlag,
- DoctorNumber: doctor_id,
- DoctorName: new_doctor_name,
- ProvinceDrugMedListCodg: "",
- ProvinceGoodMedListCodg: "",
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- }
-
- if subItem.BaseDrugLib.DrugClassify == "2" {
- cus.ProvinceDrugMedListCodg = subItem.BaseDrugLib.ProvincesCode
- }
-
- customs = append(customs, cus)
- }
- }
- }
-
- if item.Type == 2 { //项目
- for _, subItem := range item.HisPrescriptionProject {
- //var randNum int
- //randNum = rand.Intn(10000) + 1000
- if subItem.Type == 2 {
- if len(subItem.HisProject.MedicalCode) > 0 {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
- cus := &Custom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
- Cut: fmt.Sprintf("%.4f", cnt),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.HisProject.MedicalCode,
- DoctorNumber: doctor_id,
- DoctorName: new_doctor_name,
- HospApprFlag: -1,
- ProvinceDrugMedListCodg: "",
- ProvinceGoodMedListCodg: "",
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- }
- customs = append(customs, cus)
- }
-
- } else if subItem.Type == 3 {
- if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
- cnt, _ := strconv.ParseFloat(subItem.Count, 64)
-
- cus := &Custom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
- Cut: fmt.Sprintf("%.4f", cnt),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
- HospApprFlag: -1,
- DoctorNumber: doctor_id,
- DoctorName: new_doctor_name,
- ProvinceDrugMedListCodg: "",
- ProvinceGoodMedListCodg: subItem.GoodInfo.ProvincesCode,
- FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
- }
- customs = append(customs, cus)
- }
-
- }
-
- }
- }
-
- for _, subItem := range item.HisAdditionalCharge {
- if len(subItem.XtHisAddtionConfig.Code) > 0 {
- cus := &Custom{
- DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
- Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
- FeedetlSn: subItem.FeedetlSn,
- Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
- MedListCodg: subItem.XtHisAddtionConfig.Code,
- HospApprFlag: -1,
- DoctorNumber: doctor_id,
- DoctorName: new_doctor_name,
- }
- customs = append(customs, cus)
- }
- }
- }
-
- // 生成输入报文
- inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
-
- input := make(map[string]interface{})
- feedetail := make([]map[string]interface{}, 0)
- inputMessage["infno"] = "2204" // 交易编码
-
- //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
- for _, item := range customs {
- feedetailInfo := make(map[string]interface{})
- subfeedetailInfo := make(map[string]interface{})
-
- feedetailInfo["feedetl_sn"] = item.FeedetlSn
- feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
- feedetailInfo["dise_codg"] = diag_code // 病种编码
- feedetailInfo["rxno"] = "" // 处方号
- feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
- feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
- feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
- feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
- feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
- feedetailInfo["cnt"] = item.Cut // 数量
- feedetailInfo["pric"] = item.Price // 单价
- feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
- feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
- feedetailInfo["prd_days"] = "0" // 周期天数
- feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
- feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
- feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
-
- feedetailInfo["bilg_dr_codg"] = doctor_id // 开单医生编码
- feedetailInfo["bilg_dr_name"] = new_doctor_name // 开单医师姓名
- feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
- feedetailInfo["acord_dept_name"] = dept // 受单科室名称
- feedetailInfo["orders_dr_code"] = doctor_id // 受单医生编码
- feedetailInfo["orders_dr_name"] = new_doctor_name // 受单医生姓名
-
- if balance_accounts_type == "8" {
- feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
- } else {
- if item.HospApprFlag != -1 {
- if item.HospApprFlag == 1 {
- feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
- } else if item.HospApprFlag == 2 {
- feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
- } else if item.HospApprFlag == 3 {
- feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
- } else {
- feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
- }
- } else {
- feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
- }
-
- }
-
- feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
- feedetailInfo["etip_flag"] = "" // 外检标志
- feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
- feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
- feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
- subfeedetailInfo["tcmherb_prov_code"] = item.ProvinceDrugMedListCodg
- subfeedetailInfo["mcs_prov_code"] = item.ProvinceGoodMedListCodg
- feedetailInfo["exp_content"] = subfeedetailInfo
- feedetail = append(feedetail, feedetailInfo)
- }
-
- input["feedetail"] = feedetail
- inputMessage["input"] = input //交易输入
- var requestLog string
- bytesData, err := json.Marshal(inputMessage)
- requestLog = string(bytesData)
- fmt.Println(string(bytesData))
-
- if err != nil {
- fmt.Println(err.Error())
- return "", ""
- }
-
- reader := bytes.NewReader(bytesData)
-
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
-
- request, err := http.NewRequest("POST", gdyb_url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return "", ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return "", ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return "", ""
- }
- return string(respBytes), requestLog
- }
-
- // 门诊费用明细信息撤销
- func Nmyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, request_url string, access_key string, cainfo string) (string, string) {
-
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
-
- inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
-
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2205" // 交易编码
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["chrg_bchno"] = "0000" // 收费批次号(来自2204生成的)
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
-
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
-
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println(string(bytesData))
-
- var requestLog string
- requestLog = string(bytesData)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
-
- request, err := http.NewRequest("POST", gdyb_url, reader)
- fmt.Println(err)
-
- fmt.Println(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- str := string(respBytes)
- fmt.Println(str)
- return str, requestLog
-
- }
-
- // 门诊预结算
- func Nmyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, request_url string, access_key string, verify_number string, cainfo string, mdtrt_grp_type string) (string, string) {
- if !strings.Contains(insuplc_admdvs, "150") {
-
- chrgBchno = "0000"
- }
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
-
- // 生成输入报文
- inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
-
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2206" // 交易编码
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- if certificates == 3 {
- inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
- } else {
- if id_card_type == 1 {
- inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else if id_card_type == 3 {
- inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else if id_card_type == 4 {
- inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else {
- inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
- }
- }
- if insuplc_admdvs == "421300" {
- if med_type == "11" || med_type == "1112" || med_type == "1111" {
- inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
- } else if med_type == "14" {
- inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
- }
- } else {
- inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
- }
- inputData["medfee_sumamt"] = total // 医疗费总额
- inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
- inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
- inputData["insutype"] = insutype // 险种类型
- inputData["invono"] = "" // 发票号
- inputData2 := make(map[string]interface{})
- inputData2["trum_flag"] = ""
- inputData2["rel_ttp_flag"] = ""
- inputData2["otp_er_refl_flag"] = ""
- inputData2["mdtrt_grp_type"] = mdtrt_grp_type
- inputData2["need_ipt_flag"] = ""
- inputData["exp_content"] = inputData2
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
-
- var requestLog string
-
- bytesData, err := json.Marshal(inputMessage)
-
- requestLog = string(bytesData)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
-
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
- request, err := http.NewRequest("POST", gdyb_url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- str := string(respBytes)
- fmt.Println(str)
- return str, requestLog
- }
-
- // 门诊结算
- func Nmyb2207(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string, request_url string, access_key string, verify_number string, cainfo string, mdtrt_grp_type string) (string, string) {
- if !strings.Contains(insuplc_admdvs, "150") {
-
- chrgBchno = "0000"
- }
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
- inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2207" // 交易编码
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
-
- if certificates == 3 {
- inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else {
- if id_card_type == 1 {
- inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else if id_card_type == 3 {
- inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else if id_card_type == 4 {
- inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
- } else {
- inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
- inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
- }
- }
- if med_type == "1111" || med_type == "1112" {
- med_type = "11"
- }
- if insuplc_admdvs == "421300" {
- if med_type == "11" {
- inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
- } else if med_type == "14" {
- inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
- }
- } else {
- inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
- }
- inputData["medfee_sumamt"] = total // 医疗费总额
- inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
- inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
- inputData["insutype"] = insutype // 险种类型
- inputData["invono"] = "12345" // 发票号
-
- inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
- inputData["overlmt_selfpay"] = overlmt_selfpay //
- inputData["preselfpay_amt"] = preselfpay_amt //
- inputData["inscp_scp_amt"] = inscp_scp_amt //
- inputData2 := make(map[string]interface{})
- inputData2["trum_flag"] = ""
- inputData2["rel_ttp_flag"] = ""
- inputData2["otp_er_refl_flag"] = ""
- inputData2["mdtrt_grp_type"] = mdtrt_grp_type
- inputData2["need_ipt_flag"] = ""
- inputData["exp_content"] = inputData2
-
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
-
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
-
- request, err := http.NewRequest("POST", gdyb_url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- str := string(respBytes)
- fmt.Println(str)
- mjson, _ := json.Marshal(inputMessage)
- str2 := string(mjson)
- return str, str2
- }
-
- // 门诊结算撤销
- func Nmyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, access_key string, cainfo string) (string, string) {
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
-
- // 生成输入报文
- inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
-
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2208" // 交易编码
-
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
- inputData["setl_id"] = setlId // 结算 ID
- inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
-
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
-
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- reader := bytes.NewReader(bytesData)
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
-
- request, err := http.NewRequest("POST", gdyb_url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error(), ""
- }
- str := string(respBytes)
- fmt.Println(str)
- mjson, _ := json.Marshal(inputMessage)
- str2 := string(mjson)
- return str, str2
- }
-
- func Nmyb2503(psnNo string, insutype string, org_name string, op string, doctor string, fixmedins_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_name string, sick_code string, start_time string, end_time string, check_time string, hospital_code string, hospital_name string) string {
- // 生成签名
- nonce := GetRandomString(32)
- timestamp := time.Now().Unix()
- signature := setSignature(timestamp, nonce, secret_key)
- //tempTime := time.Unix(timestamp, 0)
- //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
-
- //timeFormatTwo := tempTime.Format("2006-01-02")
-
- //t := time.Now()
- //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
- //tm := time.Unix(last.Unix(), 0)
-
- // 生成输入报文
- inputMessage := SetInputMessage(nonce, timestamp, org_name, op, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
- input := make(map[string]interface{})
- inputData := make(map[string]interface{})
- inputMessage["infno"] = "2503" // 交易编码
- inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
- inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
- inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
- inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
- inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
- inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
- inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
- inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
- inputData["diag_dr_codg"] = doctor_id // 开始时间
- inputData["diag_dr_name"] = doctor // 开始时间
- inputData["begndate"] = start_time // 医师编码
- inputData["tel"] = "" // 医师编码
- inputData["addr"] = "" // 医师编码
- inputData["enddate"] = end_time // 医师编码
-
- input["data"] = inputData
- inputMessage["input"] = input //交易输入
- bytesData, err := json.Marshal(inputMessage)
- fmt.Println(string(bytesData))
- if err != nil {
- fmt.Println(err.Error())
- return err.Error()
- }
- reader := bytes.NewReader(bytesData)
- //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
- //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
- gdyb_url := beego.AppConfig.String("gdyb_url")
- gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
- //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
- //url := gdyb_url + "2503"
-
- var url string
- if fixmedins_code == "H15049901371" {
- url = gdyb_url
- } else {
- url = gdyb_url + "2503"
- }
-
- request, err := http.NewRequest("POST", url, reader)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error()
- }
-
- request.Header.Set("Content-Type", "application/json;charset=UTF-8")
- request.Header.Set("x-tif-paasid", gdyb_paasid)
- request.Header.Set("x-tif-signature", signature)
- request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
- request.Header.Set("x-tif-nonce", nonce)
-
- client := http.Client{}
- resp, err := client.Do(request)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error()
- }
- respBytes, err := ioutil.ReadAll(resp.Body)
- if err != nil {
- fmt.Println(err.Error())
- return err.Error()
- }
- str := string(respBytes)
- fmt.Println(str)
- return str
- }
-
|