hb_service.go 146KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071
  1. package service
  2. import (
  3. "bytes"
  4. "crypto/sha256"
  5. "encoding/hex"
  6. "encoding/json"
  7. "fmt"
  8. "gdyb/models"
  9. "github.com/astaxie/beego"
  10. "github.com/google/uuid"
  11. "io/ioutil"
  12. "net/http"
  13. "os/exec"
  14. "strconv"
  15. "time"
  16. )
  17. //机构信息
  18. func HeBeiyb1201(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string) string {
  19. // 生成签名
  20. nonce := GetRandomString(32)
  21. timestamp := time.Now().Unix()
  22. signature := setSignature(timestamp, nonce, secret_key)
  23. // 生成输入报文
  24. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  25. input := make(map[string]interface{})
  26. inputData := make(map[string]interface{})
  27. inputMessage["infno"] = "1201" // 交易编码
  28. inputData["fixmedins_type"] = "1"
  29. inputData["fixmedins_name"] = org_name
  30. inputData["fixmedins_code"] = fixmedins_code
  31. input["medinsinfo"] = inputData
  32. inputMessage["input"] = input //交易输入
  33. bytesData, err := json.Marshal(inputMessage)
  34. fmt.Println(string(bytesData))
  35. if err != nil {
  36. fmt.Println(err.Error())
  37. return err.Error()
  38. }
  39. reader := bytes.NewReader(bytesData)
  40. gdyb_url := beego.AppConfig.String("gdyb_url")
  41. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  42. url := gdyb_url + "1201"
  43. request, err := http.NewRequest("POST", url, reader)
  44. if err != nil {
  45. fmt.Println(err.Error())
  46. return err.Error()
  47. }
  48. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  49. request.Header.Set("x-tif-paasid", gdyb_paasid)
  50. request.Header.Set("x-tif-signature", signature)
  51. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  52. request.Header.Set("x-tif-nonce", nonce)
  53. client := http.Client{}
  54. resp, err := client.Do(request)
  55. if err != nil {
  56. fmt.Println(err.Error())
  57. return err.Error()
  58. }
  59. respBytes, err := ioutil.ReadAll(resp.Body)
  60. if err != nil {
  61. fmt.Println(err.Error())
  62. return err.Error()
  63. }
  64. fmt.Println(string(respBytes))
  65. str2 := string(respBytes)
  66. return str2
  67. }
  68. // 人员基本信息
  69. func HeBeiyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, psn_name string) (string, string) {
  70. //生成签名
  71. nonce := GetRandomString(32)
  72. timestamp := time.Now().Unix()
  73. signature := setSignature(timestamp, nonce, secret_key)
  74. //生成输入报文
  75. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  76. input := make(map[string]interface{})
  77. inputData := make(map[string]interface{})
  78. inputMessage["infno"] = "1101" // 交易编码
  79. if certificates == "3" {
  80. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  81. inputData["certno"] = certNo // 证件号码
  82. inputData["psn_cert_type"] = "" // 人员证件类型
  83. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  84. } else {
  85. if id_card_type == 1 {
  86. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  87. inputData["card_sn"] = card_sn // 卡识别码
  88. inputData["certno"] = certNo // 证件号码
  89. inputData["psn_cert_type"] = "" // 人员证件类型
  90. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  91. } else {
  92. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  93. inputData["card_sn"] = "" // 卡识别码
  94. inputData["certno"] = certNo // 证件号码
  95. inputData["psn_cert_type"] = "" // 人员证件类型
  96. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  97. }
  98. }
  99. inputData["begntime"] = "" // 开始时间
  100. inputData["psn_name"] = "" // 人员姓名
  101. input["data"] = inputData
  102. inputMessage["input"] = input //交易输入
  103. var inputLog string
  104. bytesData, err := json.Marshal(inputMessage)
  105. inputLog = string(bytesData)
  106. fmt.Println(string(bytesData))
  107. if err != nil {
  108. fmt.Println(err.Error())
  109. return err.Error(), ""
  110. }
  111. reader := bytes.NewReader(bytesData)
  112. gdyb_url := beego.AppConfig.String("gdyb_url")
  113. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  114. var url string
  115. if fixmedins_code == "H15049901371" {
  116. url = gdyb_url
  117. } else {
  118. url = "http://test.inner.getway.ylbzj.hebei.gov.cn/ebus/mbs_fsi_auth" + "/fsi/api/fsiPsnInfoService/queryPsnInfo"
  119. //url = gdyb_url + "/fsi/api/fsiPsnInfoService/queryPsnInfo"
  120. }
  121. fmt.Println(url)
  122. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  123. request, err := http.NewRequest("POST", url, reader)
  124. if err != nil {
  125. fmt.Println(err.Error())
  126. return err.Error(), ""
  127. }
  128. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  129. request.Header.Set("x-tif-paasid", gdyb_paasid)
  130. request.Header.Set("x-tif-signature", signature)
  131. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  132. request.Header.Set("x-tif-nonce", nonce)
  133. client := http.Client{}
  134. resp, err := client.Do(request)
  135. if err != nil {
  136. fmt.Println(err.Error())
  137. return err.Error(), ""
  138. }
  139. respBytes, err := ioutil.ReadAll(resp.Body)
  140. if err != nil {
  141. fmt.Println(err.Error())
  142. return err.Error(), ""
  143. }
  144. fmt.Println(string(respBytes))
  145. str := string(respBytes)
  146. return str, inputLog
  147. }
  148. func HeBeiyb1101A(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, name string) string {
  149. //生成签名
  150. nonce := GetRandomString(32)
  151. timestamp := time.Now().Unix()
  152. signature := setSignature(timestamp, nonce, secret_key)
  153. //生成输入报文
  154. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  155. input := make(map[string]interface{})
  156. inputData := make(map[string]interface{})
  157. inputMessage["infno"] = "1101" // 交易编码
  158. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  159. inputData["card_sn"] = "" // 卡识别码
  160. inputData["certno"] = certNo // 证件号码
  161. inputData["psn_cert_type"] = "1" // 人员证件类型
  162. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  163. inputData["begntime"] = "" // 开始时间
  164. inputData["psn_name"] = name // 人员姓名
  165. input["data"] = inputData
  166. inputMessage["input"] = input //交易输入
  167. bytesData, err := json.Marshal(inputMessage)
  168. fmt.Println(string(bytesData))
  169. if err != nil {
  170. fmt.Println(err.Error())
  171. return err.Error()
  172. }
  173. reader := bytes.NewReader(bytesData)
  174. gdyb_url := beego.AppConfig.String("gdyb_url")
  175. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  176. var url string
  177. if fixmedins_code == "H15049901371" {
  178. url = gdyb_url
  179. } else {
  180. url = gdyb_url + "1101"
  181. }
  182. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  183. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  184. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  185. if insuplc_admdvs == "421300" {
  186. var json2 string
  187. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101A", string(bytesData), json2)
  188. out, err := cmd.Output()
  189. if err != nil {
  190. fmt.Println("error:", err.Error())
  191. }
  192. fmt.Println(string(out))
  193. return hex.EncodeToString(out)
  194. } else {
  195. request, err := http.NewRequest("POST", url, reader)
  196. if err != nil {
  197. fmt.Println(err.Error())
  198. return err.Error()
  199. }
  200. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  201. request.Header.Set("x-tif-paasid", gdyb_paasid)
  202. request.Header.Set("x-tif-signature", signature)
  203. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  204. request.Header.Set("x-tif-nonce", nonce)
  205. client := http.Client{}
  206. resp, err := client.Do(request)
  207. if err != nil {
  208. fmt.Println(err.Error())
  209. return err.Error()
  210. }
  211. respBytes, err := ioutil.ReadAll(resp.Body)
  212. if err != nil {
  213. fmt.Println(err.Error())
  214. return err.Error()
  215. }
  216. fmt.Println(string(respBytes))
  217. str := string(respBytes)
  218. return str
  219. }
  220. }
  221. // 门诊挂号
  222. func HeBeiyb2201(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) (string, string) {
  223. fmt.Println(opera)
  224. // 生成签名
  225. nonce := GetRandomString(32)
  226. timestamp := time.Now().Unix()
  227. signature := setSignature(timestamp, nonce, secret_key)
  228. tempTime := time.Unix(timestamp, 0)
  229. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  230. // 生成输入报文
  231. inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  232. input := make(map[string]interface{})
  233. inputData := make(map[string]interface{})
  234. inputMessage["infno"] = "2201" // 交易编码
  235. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  236. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  237. inputData["begntime"] = timeFormatOne // 开始时间
  238. if id_card_type == 1 {
  239. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  240. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  241. } else {
  242. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  243. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  244. }
  245. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  246. inputData["atddr_no"] = doctor_id // 医师编码
  247. inputData["dr_name"] = doctor_name // 医师姓名
  248. inputData["dept_code"] = dept_code // 科室编码
  249. inputData["dept_name"] = dept // 科室名称
  250. inputData["caty"] = "A03.06" // 科别
  251. input["data"] = inputData
  252. inputMessage["input"] = input //交易输入
  253. var requestLog string
  254. bytesData, err := json.Marshal(inputMessage)
  255. requestLog = string(bytesData)
  256. fmt.Println(string(bytesData))
  257. if err != nil {
  258. fmt.Println(err.Error())
  259. return err.Error(), ""
  260. }
  261. reader := bytes.NewReader(bytesData)
  262. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  263. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  264. gdyb_url := beego.AppConfig.String("gdyb_url")
  265. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  266. var url string
  267. if fixmedins_code == "H15049901371" {
  268. url = gdyb_url
  269. } else {
  270. url = gdyb_url + "/fsi/api/outpatientDocInfoService/outpatientRregistration"
  271. }
  272. if insuplc_admdvs == "421300" {
  273. var json2 string
  274. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  275. out, err := cmd.Output()
  276. if err != nil {
  277. fmt.Println("error:", err.Error())
  278. }
  279. fmt.Println(string(out))
  280. return hex.EncodeToString(out), requestLog
  281. } else {
  282. request, err := http.NewRequest("POST", url, reader)
  283. if err != nil {
  284. fmt.Println(err.Error())
  285. return err.Error(), ""
  286. }
  287. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  288. request.Header.Set("x-tif-paasid", gdyb_paasid)
  289. request.Header.Set("x-tif-signature", signature)
  290. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  291. request.Header.Set("x-tif-nonce", nonce)
  292. client := http.Client{}
  293. resp, err := client.Do(request)
  294. if err != nil {
  295. fmt.Println(err.Error())
  296. return err.Error(), ""
  297. }
  298. respBytes, err := ioutil.ReadAll(resp.Body)
  299. if err != nil {
  300. fmt.Println(err.Error())
  301. return err.Error(), ""
  302. }
  303. str := string(respBytes)
  304. fmt.Println(str)
  305. return str, requestLog
  306. }
  307. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  308. }
  309. func HeBeiyb2201A(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, record_time string, token string) (string, string) {
  310. fmt.Println(opera)
  311. // 生成签名
  312. nonce := GetRandomString(32)
  313. timestamp := time.Now().Unix()
  314. signature := setSignature(timestamp, nonce, secret_key)
  315. //tempTime := time.Unix(timestamp, 0)
  316. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  317. // 生成输入报文
  318. inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  319. input := make(map[string]interface{})
  320. inputData := make(map[string]interface{})
  321. inputMessage["infno"] = "2201" // 交易编码
  322. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  323. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  324. inputData["begntime"] = record_time // 开始时间
  325. if id_card_type == 1 {
  326. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  327. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  328. } else if id_card_type == 4 {
  329. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  330. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  331. } else {
  332. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  333. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  334. }
  335. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  336. inputData["atddr_no"] = doctor_id // 医师编码
  337. inputData["dr_name"] = doctor_name // 医师姓名
  338. inputData["dept_code"] = dept_code // 科室编码
  339. inputData["dept_name"] = dept // 科室名称
  340. inputData["caty"] = "A03.06" // 科别
  341. input["data"] = inputData
  342. inputMessage["input"] = input //交易输入
  343. var requestLog string
  344. bytesData, err := json.Marshal(inputMessage)
  345. requestLog = string(bytesData)
  346. fmt.Println(string(bytesData))
  347. if err != nil {
  348. fmt.Println(err.Error())
  349. return err.Error(), ""
  350. }
  351. reader := bytes.NewReader(bytesData)
  352. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2201"
  353. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  354. gdyb_url := beego.AppConfig.String("gdyb_url")
  355. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  356. var url string
  357. if fixmedins_code == "H15049901371" {
  358. url = gdyb_url
  359. } else {
  360. url = gdyb_url + "2201"
  361. }
  362. if insuplc_admdvs == "421300" {
  363. var json2 string
  364. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2201", string(bytesData), json2)
  365. out, err := cmd.Output()
  366. if err != nil {
  367. fmt.Println("error:", err.Error())
  368. }
  369. fmt.Println(string(out))
  370. return hex.EncodeToString(out), requestLog
  371. } else {
  372. request, err := http.NewRequest("POST", url, reader)
  373. if err != nil {
  374. fmt.Println(err.Error())
  375. return err.Error(), ""
  376. }
  377. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  378. request.Header.Set("x-tif-paasid", gdyb_paasid)
  379. request.Header.Set("x-tif-signature", signature)
  380. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  381. request.Header.Set("x-tif-nonce", nonce)
  382. client := http.Client{}
  383. resp, err := client.Do(request)
  384. if err != nil {
  385. fmt.Println(err.Error())
  386. return err.Error(), ""
  387. }
  388. respBytes, err := ioutil.ReadAll(resp.Body)
  389. if err != nil {
  390. fmt.Println(err.Error())
  391. return err.Error(), ""
  392. }
  393. str := string(respBytes)
  394. fmt.Println(str)
  395. return str, requestLog
  396. }
  397. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2201"
  398. }
  399. // 门诊挂号撤销
  400. func HeBeiyb2202(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) (string, string) {
  401. // 生成签名
  402. nonce := GetRandomString(32)
  403. timestamp := time.Now().Unix()
  404. signature := setSignature(timestamp, nonce, secret_key)
  405. // 生成输入报文
  406. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  407. input := make(map[string]interface{})
  408. inputData := make(map[string]interface{})
  409. inputMessage["infno"] = "2202" // 交易编码
  410. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  411. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  412. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  413. input["data"] = inputData
  414. inputMessage["input"] = input //交易输入
  415. var requestLog string
  416. bytesData, err := json.Marshal(inputMessage)
  417. fmt.Println(string(bytesData))
  418. requestLog = string(bytesData)
  419. if err != nil {
  420. fmt.Println(err.Error())
  421. return err.Error(), ""
  422. }
  423. reader := bytes.NewReader(bytesData)
  424. gdyb_url := beego.AppConfig.String("gdyb_url")
  425. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  426. var url string
  427. if fixmedins_code == "H15049901371" {
  428. url = gdyb_url
  429. } else {
  430. url = gdyb_url + "2202"
  431. }
  432. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  433. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  434. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  435. if insuplc_admdvs == "421300" {
  436. var json2 string
  437. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2202", string(bytesData), json2)
  438. out, err := cmd.Output()
  439. if err != nil {
  440. fmt.Println("error:", err.Error())
  441. }
  442. fmt.Println(string(out))
  443. return hex.EncodeToString(out), requestLog
  444. } else {
  445. request, err := http.NewRequest("POST", url, reader)
  446. if err != nil {
  447. fmt.Println(err.Error())
  448. return err.Error(), ""
  449. }
  450. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  451. request.Header.Set("x-tif-paasid", gdyb_paasid)
  452. request.Header.Set("x-tif-signature", signature)
  453. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  454. request.Header.Set("x-tif-nonce", nonce)
  455. client := http.Client{}
  456. resp, err := client.Do(request)
  457. if err != nil {
  458. fmt.Println(err.Error())
  459. return err.Error(), ""
  460. }
  461. respBytes, err := ioutil.ReadAll(resp.Body)
  462. if err != nil {
  463. fmt.Println(err.Error())
  464. return err.Error(), ""
  465. }
  466. str := string(respBytes)
  467. fmt.Println(str)
  468. return str, requestLog
  469. }
  470. }
  471. // 门诊就诊信息上传
  472. func HeBeiyb2203(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) (string, string) {
  473. // 生成签名
  474. nonce := GetRandomString(32)
  475. timestamp := time.Now().Unix()
  476. signature := setSignature(timestamp, nonce, secret_key)
  477. //tempTime := time.Unix(timestamp, 0)
  478. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  479. // 生成输入报文
  480. inputMessage := SetInputMessage(nonce, timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  481. input := make(map[string]interface{})
  482. inputData := make(map[string]interface{})
  483. diseinfo := make([]map[string]interface{}, 0)
  484. if med_type == "1111" || med_type == "1112" {
  485. med_type = "11"
  486. }
  487. inputMessage["infno"] = "2203" // 交易编码
  488. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  489. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  490. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  491. inputData["begntime"] = begin_time // 开始时间
  492. //inputData["begntime"] = // 开始时间
  493. inputData["main_cond_dscr"] = "" // 主要病情描述
  494. inputData["dise_codg"] = sick_code // 病种编码
  495. inputData["dise_name"] = sick_name // 病种名称
  496. inputData["birctrl_type"] = "" // 计划生育手术类别
  497. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  498. for index, item := range config {
  499. diseinfo_sun := make(map[string]interface{})
  500. diseinfo_sun["diag_type"] = "1" // 诊断类别
  501. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  502. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  503. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  504. diseinfo_sun["diag_dept"] = department // 诊断科室
  505. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  506. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  507. diseinfo_sun["diag_time"] = begin_time // 诊断时间
  508. diseinfo_sun["vali_flag"] = "1" // 有效标志
  509. diseinfo = append(diseinfo, diseinfo_sun)
  510. }
  511. input["diseinfo"] = diseinfo
  512. input["mdtrtinfo"] = inputData
  513. inputMessage["input"] = input //交易输入
  514. var requestLog string
  515. bytesData, err := json.Marshal(inputMessage)
  516. fmt.Println(string(bytesData))
  517. requestLog = string(bytesData)
  518. if err != nil {
  519. fmt.Println(err.Error())
  520. return err.Error(), ""
  521. }
  522. reader := bytes.NewReader(bytesData)
  523. gdyb_url := beego.AppConfig.String("gdyb_url")
  524. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  525. var url string
  526. if fixmedins_code == "H15049901371" {
  527. url = gdyb_url
  528. } else {
  529. url = gdyb_url + "2203"
  530. }
  531. if insuplc_admdvs == "421300" {
  532. var json2 string
  533. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203", string(bytesData), json2)
  534. out, err := cmd.Output()
  535. if err != nil {
  536. fmt.Println("error:", err.Error())
  537. }
  538. fmt.Println(string(out))
  539. return hex.EncodeToString(out), requestLog
  540. } else {
  541. request, err := http.NewRequest("POST", url, reader)
  542. if err != nil {
  543. fmt.Println(err.Error())
  544. return err.Error(), ""
  545. }
  546. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  547. request.Header.Set("x-tif-paasid", gdyb_paasid)
  548. request.Header.Set("x-tif-signature", signature)
  549. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  550. request.Header.Set("x-tif-nonce", nonce)
  551. client := http.Client{}
  552. resp, err := client.Do(request)
  553. if err != nil {
  554. fmt.Println(err.Error())
  555. return err.Error(), ""
  556. }
  557. respBytes, err := ioutil.ReadAll(resp.Body)
  558. if err != nil {
  559. fmt.Println(err.Error())
  560. return err.Error(), ""
  561. }
  562. str := string(respBytes)
  563. fmt.Println(str)
  564. return str, requestLog
  565. }
  566. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  567. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  568. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  569. }
  570. // 门诊就诊信息上传
  571. func HeBeiyb2203A(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) (string, string) {
  572. // 生成签名
  573. nonce := GetRandomString(32)
  574. timestamp := time.Now().Unix()
  575. signature := setSignature(timestamp, nonce, secret_key)
  576. tempTime := time.Unix(timestamp, 0)
  577. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  578. // 生成输入报文
  579. inputMessage := SetInputMessage(nonce, timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  580. input := make(map[string]interface{})
  581. inputData := make(map[string]interface{})
  582. diseinfo := make([]map[string]interface{}, 0)
  583. if med_type == "1111" || med_type == "1112" {
  584. med_type = "11"
  585. }
  586. inputMessage["infno"] = "2203A" // 交易编码
  587. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  588. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  589. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  590. inputData["begntime"] = begin_time // 开始时间
  591. inputData["main_cond_dscr"] = "" // 主要病情描述
  592. inputData["dise_codg"] = sick_code // 病种编码
  593. inputData["dise_name"] = sick_name // 病种名称
  594. inputData["birctrl_type"] = "" // 计划生育手术类别
  595. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  596. inputData["matn_type"] = "" // 生育类别
  597. inputData["geso_val"] = "" // 孕周数
  598. for index, item := range config {
  599. diseinfo_sun := make(map[string]interface{})
  600. diseinfo_sun["diag_type"] = "1" // 诊断类别
  601. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  602. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  603. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  604. diseinfo_sun["diag_dept"] = department // 诊断科室
  605. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  606. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  607. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  608. diseinfo_sun["vali_flag"] = "1" // 有效标志
  609. diseinfo = append(diseinfo, diseinfo_sun)
  610. }
  611. input["diseinfo"] = diseinfo
  612. input["mdtrtinfo"] = inputData
  613. inputMessage["input"] = input //交易输入
  614. var requestLog string
  615. bytesData, err := json.Marshal(inputMessage)
  616. fmt.Println(string(bytesData))
  617. requestLog = string(bytesData)
  618. if err != nil {
  619. fmt.Println(err.Error())
  620. return err.Error(), ""
  621. }
  622. reader := bytes.NewReader(bytesData)
  623. gdyb_url := beego.AppConfig.String("gdyb_url")
  624. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  625. var url string
  626. if fixmedins_code == "H15049901371" {
  627. url = gdyb_url
  628. } else {
  629. url = gdyb_url + "2203A"
  630. }
  631. if insuplc_admdvs == "421300" {
  632. var json2 string
  633. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2203A", string(bytesData), json2)
  634. out, err := cmd.Output()
  635. if err != nil {
  636. fmt.Println("error:", err.Error())
  637. }
  638. fmt.Println(string(out))
  639. return hex.EncodeToString(out), requestLog
  640. } else {
  641. request, err := http.NewRequest("POST", url, reader)
  642. if err != nil {
  643. fmt.Println(err.Error())
  644. return err.Error(), ""
  645. }
  646. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  647. request.Header.Set("x-tif-paasid", gdyb_paasid)
  648. request.Header.Set("x-tif-signature", signature)
  649. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  650. request.Header.Set("x-tif-nonce", nonce)
  651. client := http.Client{}
  652. resp, err := client.Do(request)
  653. if err != nil {
  654. fmt.Println(err.Error())
  655. return err.Error(), ""
  656. }
  657. respBytes, err := ioutil.ReadAll(resp.Body)
  658. if err != nil {
  659. fmt.Println(err.Error())
  660. return err.Error(), ""
  661. }
  662. str := string(respBytes)
  663. fmt.Println(str)
  664. return str, requestLog
  665. }
  666. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203A"
  667. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  668. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  669. }
  670. // 门诊费用明细信息上传
  671. func HeBeiyb2204(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, new_doctor_id int64, diag_code string) (string, string) {
  672. // 生成签名
  673. nonce := GetRandomString(32)
  674. timestamp := time.Now().Unix()
  675. signature := setSignature(timestamp, nonce, secret_key)
  676. //tempTime := time.Unix(timestamp, 0)
  677. //timeFormat := tempTime.Format("20060102150405")
  678. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  679. //chrgBchno := rand.Intn(100000) + 10000
  680. var customs []*Custom
  681. for _, item := range hisPrescription {
  682. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  683. tm := time.Unix(item.PreTime, 0)
  684. if item.Type == 1 { //药品
  685. for _, subItem := range item.HisDoctorAdviceInfo {
  686. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  687. //var randNum int
  688. //randNum = rand.Intn(10000) + 1000
  689. role, _ := GetAdminUserInfoByID(item.UserOrgId, new_doctor_id)
  690. cus := &Custom{
  691. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  692. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  693. FeedetlSn: subItem.FeedetlSn,
  694. Price: fmt.Sprintf("%.4f", subItem.Price),
  695. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  696. HospApprFlag: subItem.HospApprFlag,
  697. DoctorNumber: role.DoctorNumber,
  698. DoctorName: role.UserName,
  699. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  700. }
  701. customs = append(customs, cus)
  702. }
  703. }
  704. }
  705. if item.Type == 2 { //项目
  706. for _, subItem := range item.HisPrescriptionProject {
  707. //var randNum int
  708. //randNum = rand.Intn(10000) + 1000
  709. if subItem.Type == 2 {
  710. if len(subItem.HisProject.MedicalCode) > 0 {
  711. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  712. cus := &Custom{
  713. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  714. Cut: fmt.Sprintf("%.4f", cnt),
  715. FeedetlSn: subItem.FeedetlSn,
  716. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  717. MedListCodg: subItem.HisProject.MedicalCode,
  718. DoctorNumber: role.DoctorNumber,
  719. DoctorName: role.UserName,
  720. HospApprFlag: -1,
  721. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  722. }
  723. customs = append(customs, cus)
  724. }
  725. } else if subItem.Type == 3 {
  726. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  727. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  728. cus := &Custom{
  729. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  730. Cut: fmt.Sprintf("%.4f", cnt),
  731. FeedetlSn: subItem.FeedetlSn,
  732. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  733. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  734. HospApprFlag: -1,
  735. DoctorNumber: role.DoctorNumber,
  736. DoctorName: role.UserName,
  737. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  738. }
  739. customs = append(customs, cus)
  740. }
  741. }
  742. }
  743. }
  744. for _, subItem := range item.HisAdditionalCharge {
  745. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  746. cus := &Custom{
  747. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  748. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  749. FeedetlSn: subItem.FeedetlSn,
  750. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  751. MedListCodg: subItem.XtHisAddtionConfig.Code,
  752. HospApprFlag: -1,
  753. DoctorNumber: role.DoctorNumber,
  754. DoctorName: role.UserName,
  755. }
  756. customs = append(customs, cus)
  757. }
  758. }
  759. }
  760. // 生成输入报文
  761. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  762. input := make(map[string]interface{})
  763. feedetail := make([]map[string]interface{}, 0)
  764. inputMessage["infno"] = "2204" // 交易编码
  765. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  766. for _, item := range customs {
  767. feedetailInfo := make(map[string]interface{})
  768. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  769. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  770. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  771. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  772. feedetailInfo["dise_codg"] = diag_code // 病种编码
  773. feedetailInfo["rxno"] = "" // 处方号
  774. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  775. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  776. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  777. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  778. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  779. feedetailInfo["cnt"] = item.Cut // 数量
  780. feedetailInfo["pric"] = item.Price // 单价
  781. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  782. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  783. feedetailInfo["prd_days"] = "0" // 周期天数
  784. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  785. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  786. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  787. feedetailInfo["bilg_dr_codg"] = item.DoctorNumber // 开单医生编码
  788. feedetailInfo["bilg_dr_name"] = item.DoctorName // 开单医师姓名
  789. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  790. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  791. feedetailInfo["orders_dr_code"] = item.DoctorNumber // 受单医生编码
  792. feedetailInfo["orders_dr_name"] = item.DoctorName // 受单医生姓名
  793. if balance_accounts_type == "8" {
  794. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  795. } else {
  796. if item.HospApprFlag != -1 {
  797. if item.HospApprFlag == 1 {
  798. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  799. } else if item.HospApprFlag == 2 {
  800. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  801. } else if item.HospApprFlag == 3 {
  802. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  803. } else {
  804. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  805. }
  806. } else {
  807. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  808. }
  809. }
  810. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  811. feedetailInfo["etip_flag"] = "" // 外检标志
  812. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  813. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  814. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  815. feedetail = append(feedetail, feedetailInfo)
  816. }
  817. input["feedetail"] = feedetail
  818. inputMessage["input"] = input //交易输入
  819. var requestLog string
  820. bytesData, err := json.Marshal(inputMessage)
  821. fmt.Println("----------")
  822. fmt.Println(string(bytesData))
  823. fmt.Println("----------")
  824. requestLog = string(bytesData)
  825. if err != nil {
  826. fmt.Println(err.Error())
  827. return "", ""
  828. }
  829. reader := bytes.NewReader(bytesData)
  830. gdyb_url := beego.AppConfig.String("gdyb_url")
  831. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  832. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  833. var url string
  834. if fixmedins_code == "H15049901371" {
  835. url = gdyb_url
  836. } else {
  837. url = gdyb_url + "2204"
  838. }
  839. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2204"
  840. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  841. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2204"
  842. if insuplc_admdvs == "421300" {
  843. var json2 string
  844. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2204", string(bytesData), json2)
  845. out, err := cmd.Output()
  846. if err != nil {
  847. fmt.Println("error:", err.Error())
  848. }
  849. fmt.Println(string(out))
  850. return hex.EncodeToString(out), requestLog
  851. } else {
  852. request, err := http.NewRequest("POST", url, reader)
  853. if err != nil {
  854. fmt.Println(err.Error())
  855. return "", ""
  856. }
  857. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  858. request.Header.Set("x-tif-paasid", gdyb_paasid)
  859. request.Header.Set("x-tif-signature", signature)
  860. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  861. request.Header.Set("x-tif-nonce", nonce)
  862. client := http.Client{}
  863. resp, err := client.Do(request)
  864. if err != nil {
  865. fmt.Println(err.Error())
  866. return "", ""
  867. }
  868. respBytes, err := ioutil.ReadAll(resp.Body)
  869. if err != nil {
  870. fmt.Println(err.Error())
  871. return "", ""
  872. }
  873. return string(respBytes), requestLog
  874. }
  875. //var result RequestResult
  876. //json.Unmarshal(respBytes, &result)
  877. //return &result
  878. }
  879. // 门诊费用明细信息撤销
  880. func HeBeiyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) (string, string) {
  881. // 生成签名
  882. nonce := GetRandomString(32)
  883. timestamp := time.Now().Unix()
  884. signature := setSignature(timestamp, nonce, secret_key)
  885. // 生成输入报文
  886. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  887. input := make(map[string]interface{})
  888. inputData := make(map[string]interface{})
  889. inputMessage["infno"] = "2205" // 交易编码
  890. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  891. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  892. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  893. input["data"] = inputData
  894. inputMessage["input"] = input //交易输入
  895. bytesData, err := json.Marshal(inputMessage)
  896. fmt.Println(string(bytesData))
  897. var requestLog string
  898. requestLog = string(bytesData)
  899. if err != nil {
  900. fmt.Println(err.Error())
  901. return err.Error(), ""
  902. }
  903. reader := bytes.NewReader(bytesData)
  904. gdyb_url := beego.AppConfig.String("gdyb_url")
  905. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  906. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  907. //url := gdyb_url + "2205"
  908. var url string
  909. if fixmedins_code == "H15049901371" {
  910. url = gdyb_url
  911. } else {
  912. url = gdyb_url + "2205"
  913. }
  914. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  915. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  916. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  917. if insuplc_admdvs == "421300" {
  918. var json2 string
  919. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2205", string(bytesData), json2)
  920. out, err := cmd.Output()
  921. if err != nil {
  922. fmt.Println("error:", err.Error())
  923. }
  924. fmt.Println(string(out))
  925. return hex.EncodeToString(out), requestLog
  926. } else {
  927. request, err := http.NewRequest("POST", url, reader)
  928. fmt.Println(err)
  929. fmt.Println(request)
  930. if err != nil {
  931. fmt.Println(err.Error())
  932. return err.Error(), ""
  933. }
  934. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  935. request.Header.Set("x-tif-paasid", gdyb_paasid)
  936. request.Header.Set("x-tif-signature", signature)
  937. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  938. request.Header.Set("x-tif-nonce", nonce)
  939. client := http.Client{}
  940. resp, err := client.Do(request)
  941. if err != nil {
  942. fmt.Println(err.Error())
  943. return err.Error(), ""
  944. }
  945. respBytes, err := ioutil.ReadAll(resp.Body)
  946. if err != nil {
  947. fmt.Println(err.Error())
  948. return err.Error(), ""
  949. }
  950. str := string(respBytes)
  951. fmt.Println(str)
  952. return str, requestLog
  953. }
  954. }
  955. // 门诊预结算
  956. //func Gdyb2206(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, secret_key string) string {
  957. func HeBeiyb2206(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) (string, string) {
  958. // 生成签名
  959. nonce := GetRandomString(32)
  960. timestamp := time.Now().Unix()
  961. signature := setSignature(timestamp, nonce, secret_key)
  962. // 生成输入报文
  963. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  964. input := make(map[string]interface{})
  965. inputData := make(map[string]interface{})
  966. inputMessage["infno"] = "2206" // 交易编码
  967. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  968. if certificates == 3 {
  969. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  970. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  971. } else {
  972. if id_card_type == 1 {
  973. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  974. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  975. } else if id_card_type == 4 {
  976. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  977. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  978. } else {
  979. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  980. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  981. }
  982. }
  983. if insuplc_admdvs == "421300" {
  984. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  985. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  986. } else if med_type == "14" {
  987. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  988. }
  989. } else {
  990. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  991. }
  992. inputData["medfee_sumamt"] = total // 医疗费总额
  993. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  994. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  995. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  996. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  997. inputData["insutype"] = insutype // 险种类型
  998. inputData["invono"] = "" // 发票号
  999. input["data"] = inputData
  1000. inputMessage["input"] = input //交易输入
  1001. var requestLog string
  1002. bytesData, err := json.Marshal(inputMessage)
  1003. requestLog = string(bytesData)
  1004. fmt.Println(string(bytesData))
  1005. if err != nil {
  1006. fmt.Println(err.Error())
  1007. return err.Error(), ""
  1008. }
  1009. reader := bytes.NewReader(bytesData)
  1010. gdyb_url := beego.AppConfig.String("gdyb_url")
  1011. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1012. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1013. //url := gdyb_url + "2206"
  1014. var url string
  1015. if fixmedins_code == "H15049901371" {
  1016. url = gdyb_url
  1017. } else {
  1018. url = gdyb_url + "2206"
  1019. }
  1020. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2206"
  1021. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1022. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2206"
  1023. if insuplc_admdvs == "421300" {
  1024. var json2 string
  1025. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2206", string(bytesData), json2)
  1026. out, err := cmd.Output()
  1027. if err != nil {
  1028. fmt.Println("error:", err.Error())
  1029. }
  1030. fmt.Println(string(out))
  1031. return hex.EncodeToString(out), requestLog
  1032. } else {
  1033. request, err := http.NewRequest("POST", url, reader)
  1034. if err != nil {
  1035. fmt.Println(err.Error())
  1036. return err.Error(), ""
  1037. }
  1038. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1039. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1040. request.Header.Set("x-tif-signature", signature)
  1041. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1042. request.Header.Set("x-tif-nonce", nonce)
  1043. client := http.Client{}
  1044. resp, err := client.Do(request)
  1045. if err != nil {
  1046. fmt.Println(err.Error())
  1047. return err.Error(), ""
  1048. }
  1049. respBytes, err := ioutil.ReadAll(resp.Body)
  1050. if err != nil {
  1051. fmt.Println(err.Error())
  1052. return err.Error(), ""
  1053. }
  1054. str := string(respBytes)
  1055. fmt.Println(str)
  1056. return str, requestLog
  1057. }
  1058. }
  1059. // 门诊结算
  1060. func HeBeiyb2207(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, token string) (string, string) {
  1061. // 生成签名
  1062. nonce := GetRandomString(32)
  1063. timestamp := time.Now().Unix()
  1064. signature := setSignature(timestamp, nonce, secret_key)
  1065. // 生成输入报文
  1066. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1067. input := make(map[string]interface{})
  1068. inputData := make(map[string]interface{})
  1069. inputMessage["infno"] = "2207" // 交易编码
  1070. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1071. if certificates == 3 {
  1072. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1073. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1074. } else {
  1075. if id_card_type == 1 {
  1076. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1077. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1078. } else if id_card_type == 4 {
  1079. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  1080. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  1081. } else {
  1082. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1083. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1084. }
  1085. }
  1086. if med_type == "1111" || med_type == "1112" {
  1087. med_type = "11"
  1088. }
  1089. if insuplc_admdvs == "421300" {
  1090. if med_type == "11" {
  1091. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1092. } else if med_type == "14" {
  1093. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1094. }
  1095. } else {
  1096. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1097. }
  1098. inputData["medfee_sumamt"] = total // 医疗费总额
  1099. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1100. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1101. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1102. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1103. inputData["insutype"] = insutype // 险种类型
  1104. inputData["invono"] = "" // 发票号
  1105. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1106. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1107. inputData["preselfpay_amt"] = preselfpay_amt //
  1108. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1109. input["data"] = inputData
  1110. inputMessage["input"] = input //交易输入
  1111. bytesData, err := json.Marshal(inputMessage)
  1112. fmt.Println(string(bytesData))
  1113. if err != nil {
  1114. fmt.Println(err.Error())
  1115. return err.Error(), ""
  1116. }
  1117. reader := bytes.NewReader(bytesData)
  1118. gdyb_url := beego.AppConfig.String("gdyb_url")
  1119. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1120. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1121. //url := gdyb_url + "2207"
  1122. var url string
  1123. if fixmedins_code == "H15049901371" {
  1124. url = gdyb_url
  1125. } else {
  1126. url = gdyb_url + "2207"
  1127. }
  1128. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1129. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1130. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1131. if insuplc_admdvs == "421300" {
  1132. var json2 string
  1133. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1134. out, err := cmd.Output()
  1135. if err != nil {
  1136. fmt.Println("error:", err.Error())
  1137. }
  1138. mjson, _ := json.Marshal(inputMessage)
  1139. str2 := string(mjson)
  1140. fmt.Println(string(out))
  1141. return hex.EncodeToString(out), str2
  1142. } else {
  1143. request, err := http.NewRequest("POST", url, reader)
  1144. if err != nil {
  1145. fmt.Println(err.Error())
  1146. return err.Error(), ""
  1147. }
  1148. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1149. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1150. request.Header.Set("x-tif-signature", signature)
  1151. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1152. request.Header.Set("x-tif-nonce", nonce)
  1153. client := http.Client{}
  1154. resp, err := client.Do(request)
  1155. if err != nil {
  1156. fmt.Println(err.Error())
  1157. return err.Error(), ""
  1158. }
  1159. respBytes, err := ioutil.ReadAll(resp.Body)
  1160. if err != nil {
  1161. fmt.Println(err.Error())
  1162. return err.Error(), ""
  1163. }
  1164. str := string(respBytes)
  1165. fmt.Println(str)
  1166. mjson, _ := json.Marshal(inputMessage)
  1167. str2 := string(mjson)
  1168. return str, str2
  1169. }
  1170. }
  1171. func HeBeiyb2207A(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) (string, string) {
  1172. // 生成签名
  1173. nonce := GetRandomString(32)
  1174. timestamp := time.Now().Unix()
  1175. signature := setSignature(timestamp, nonce, secret_key)
  1176. // 生成输入报文
  1177. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1178. input := make(map[string]interface{})
  1179. inputData := make(map[string]interface{})
  1180. inputMessage["infno"] = "2207A" // 交易编码
  1181. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1182. if certificates == 3 {
  1183. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  1184. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1185. } else {
  1186. if id_card_type == 1 {
  1187. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  1188. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1189. } else {
  1190. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  1191. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  1192. }
  1193. }
  1194. if med_type == "1111" || med_type == "1112" {
  1195. med_type = "11"
  1196. }
  1197. if insuplc_admdvs == "421300" {
  1198. if med_type == "11" {
  1199. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  1200. } else if med_type == "14" {
  1201. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  1202. }
  1203. } else {
  1204. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  1205. }
  1206. inputData["medfee_sumamt"] = total // 医疗费总额
  1207. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  1208. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1209. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  1210. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  1211. inputData["insutype"] = insutype // 险种类型
  1212. inputData["invono"] = "" // 发票号
  1213. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  1214. inputData["overlmt_selfpay"] = overlmt_selfpay //
  1215. inputData["preselfpay_amt"] = preselfpay_amt //
  1216. inputData["inscp_scp_amt"] = inscp_scp_amt //
  1217. input["data"] = inputData
  1218. inputMessage["input"] = input //交易输入
  1219. bytesData, err := json.Marshal(inputMessage)
  1220. fmt.Println(string(bytesData))
  1221. if err != nil {
  1222. fmt.Println(err.Error())
  1223. return err.Error(), ""
  1224. }
  1225. reader := bytes.NewReader(bytesData)
  1226. gdyb_url := beego.AppConfig.String("gdyb_url")
  1227. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1228. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1229. //url := gdyb_url + "2207"
  1230. var url string
  1231. if fixmedins_code == "H15049901371" {
  1232. url = gdyb_url
  1233. } else {
  1234. url = gdyb_url + "2207"
  1235. }
  1236. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  1237. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1238. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1239. if insuplc_admdvs == "421300" {
  1240. var json2 string
  1241. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2207", string(bytesData), json2)
  1242. out, err := cmd.Output()
  1243. if err != nil {
  1244. fmt.Println("error:", err.Error())
  1245. }
  1246. mjson, _ := json.Marshal(inputMessage)
  1247. str2 := string(mjson)
  1248. fmt.Println(string(out))
  1249. return hex.EncodeToString(out), str2
  1250. } else {
  1251. request, err := http.NewRequest("POST", url, reader)
  1252. if err != nil {
  1253. fmt.Println(err.Error())
  1254. return err.Error(), ""
  1255. }
  1256. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1257. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1258. request.Header.Set("x-tif-signature", signature)
  1259. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1260. request.Header.Set("x-tif-nonce", nonce)
  1261. client := http.Client{}
  1262. resp, err := client.Do(request)
  1263. if err != nil {
  1264. fmt.Println(err.Error())
  1265. return err.Error(), ""
  1266. }
  1267. respBytes, err := ioutil.ReadAll(resp.Body)
  1268. if err != nil {
  1269. fmt.Println(err.Error())
  1270. return err.Error(), ""
  1271. }
  1272. str := string(respBytes)
  1273. fmt.Println(str)
  1274. mjson, _ := json.Marshal(inputMessage)
  1275. str2 := string(mjson)
  1276. return str, str2
  1277. }
  1278. }
  1279. // 门诊结算撤销
  1280. func HeBeiyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  1281. // 生成签名
  1282. nonce := GetRandomString(32)
  1283. timestamp := time.Now().Unix()
  1284. signature := setSignature(timestamp, nonce, secret_key)
  1285. // 生成输入报文
  1286. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1287. input := make(map[string]interface{})
  1288. inputData := make(map[string]interface{})
  1289. inputMessage["infno"] = "2208" // 交易编码
  1290. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1291. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1292. inputData["setl_id"] = setlId // 结算 ID
  1293. input["data"] = inputData
  1294. inputMessage["input"] = input //交易输入
  1295. bytesData, err := json.Marshal(inputMessage)
  1296. fmt.Println(string(bytesData))
  1297. if err != nil {
  1298. fmt.Println(err.Error())
  1299. return err.Error(), ""
  1300. }
  1301. reader := bytes.NewReader(bytesData)
  1302. gdyb_url := beego.AppConfig.String("gdyb_url")
  1303. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1304. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1305. //url := gdyb_url + "2208"
  1306. var url string
  1307. if fixmedins_code == "H15049901371" {
  1308. url = gdyb_url
  1309. } else {
  1310. url = gdyb_url + "2208"
  1311. }
  1312. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2208"
  1313. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1314. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2208"
  1315. if insuplc_admdvs == "421300" {
  1316. var json2 string
  1317. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "2208", string(bytesData), json2)
  1318. out, err := cmd.Output()
  1319. if err != nil {
  1320. fmt.Println("error:", err.Error())
  1321. }
  1322. mjson, _ := json.Marshal(inputMessage)
  1323. str2 := string(mjson)
  1324. fmt.Println(string(out))
  1325. return hex.EncodeToString(out), str2
  1326. } else {
  1327. request, err := http.NewRequest("POST", url, reader)
  1328. if err != nil {
  1329. fmt.Println(err.Error())
  1330. return err.Error(), ""
  1331. }
  1332. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1333. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1334. request.Header.Set("x-tif-signature", signature)
  1335. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1336. request.Header.Set("x-tif-nonce", nonce)
  1337. client := http.Client{}
  1338. resp, err := client.Do(request)
  1339. if err != nil {
  1340. fmt.Println(err.Error())
  1341. return err.Error(), ""
  1342. }
  1343. respBytes, err := ioutil.ReadAll(resp.Body)
  1344. if err != nil {
  1345. fmt.Println(err.Error())
  1346. return err.Error(), ""
  1347. }
  1348. str := string(respBytes)
  1349. fmt.Println(str)
  1350. mjson, _ := json.Marshal(inputMessage)
  1351. str2 := string(mjson)
  1352. return str, str2
  1353. }
  1354. }
  1355. //确认订单
  1356. func HeBeiyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder) string {
  1357. // 生成签名
  1358. nonce := GetRandomString(32)
  1359. timestamp := time.Now().Unix()
  1360. signature := setSignature(timestamp, nonce, secret_key)
  1361. // 生成输入报文
  1362. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1363. input := make(map[string]interface{})
  1364. inputData := make(map[string]interface{})
  1365. inputMessage["infno"] = "6201" // 交易编码
  1366. inputData["mdtrt_id"] = order.MdtrtId
  1367. inputData["chrg_bchno"] = order.Number
  1368. inputData["psn_no"] = order.PsnNo
  1369. inputData["psn_name"] = order.PsnName
  1370. inputData["psn_cert_type"] = order.PsnCertType
  1371. inputData["certno"] = order.Certno
  1372. inputData["insutype"] = order.Insutype
  1373. inputData["med_type"] = order.MedType
  1374. inputData["medfee_sumamt"] = order.MedfeeSumamt
  1375. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  1376. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  1377. inputData["preselfpay_amt"] = order.PreselfpayAmt
  1378. inputData["inscp_scp_amt"] = order.InscpScpAmt
  1379. inputData["act_pay_dedc"] = order.ActPayDedc
  1380. inputData["hifp_pay"] = order.HifpPay
  1381. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  1382. inputData["cvlserv_pay"] = order.CvlservPay
  1383. inputData["hifes_pay"] = order.HifesPay
  1384. inputData["hifmi_pay"] = order.HifmiPay
  1385. inputData["hifob_pay"] = order.HifobPay
  1386. inputData["maf_pay"] = order.MafPay
  1387. inputData["oth_pay"] = order.OthPay
  1388. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  1389. inputData["psn_part_amt"] = order.PsnPartAmt
  1390. inputData["acct_pay"] = order.AcctPay
  1391. inputData["psn_cash_pay"] = order.PsnCashPay
  1392. inputData["hosp_part_amt"] = order.HospPartAmt
  1393. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  1394. input["data"] = inputData
  1395. inputMessage["input"] = input //交易输入
  1396. bytesData, err := json.Marshal(inputMessage)
  1397. fmt.Println(string(bytesData))
  1398. if err != nil {
  1399. fmt.Println(err.Error())
  1400. return err.Error()
  1401. }
  1402. reader := bytes.NewReader(bytesData)
  1403. gdyb_url := beego.AppConfig.String("gdyb_url")
  1404. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1405. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1406. url := gdyb_url + "6201"
  1407. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  1408. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  1409. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  1410. request, err := http.NewRequest("POST", url, reader)
  1411. if err != nil {
  1412. fmt.Println(err.Error())
  1413. return err.Error()
  1414. }
  1415. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1416. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1417. request.Header.Set("x-tif-signature", signature)
  1418. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1419. request.Header.Set("x-tif-nonce", nonce)
  1420. client := http.Client{}
  1421. resp, err := client.Do(request)
  1422. if err != nil {
  1423. fmt.Println(err.Error())
  1424. return err.Error()
  1425. }
  1426. respBytes, err := ioutil.ReadAll(resp.Body)
  1427. if err != nil {
  1428. fmt.Println(err.Error())
  1429. return err.Error()
  1430. }
  1431. str := string(respBytes)
  1432. fmt.Println(str)
  1433. return str
  1434. }
  1435. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1436. func HeBeiyb3201(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1437. fmt.Println("11222333-----")
  1438. fmt.Println(baseParams)
  1439. fmt.Println(businessParams)
  1440. // 生成签名
  1441. nonce := GetRandomString(32)
  1442. timestamp := time.Now().Unix()
  1443. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1444. // 生成输入报文
  1445. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1446. input := make(map[string]interface{})
  1447. inputData := make(map[string]interface{})
  1448. inputMessage["infno"] = "3201" // 交易编码
  1449. inputData["insutype"] = businessParams.Insutype // 险种
  1450. inputData["clr_type"] = businessParams.ClrType // 就诊 ID(来自2201接口返回)
  1451. inputData["setl_optins"] = businessParams.SetlOptins // 结算经办机构
  1452. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1453. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1454. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1455. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1456. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  1457. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1458. inputData["refd_setl_flag"] = 0 // 就诊 ID(来自2201接口返回)
  1459. input["data"] = inputData
  1460. inputMessage["input"] = input //交易输入
  1461. bytesData, err := json.Marshal(inputMessage)
  1462. fmt.Println(string(bytesData))
  1463. if err != nil {
  1464. fmt.Println(err.Error())
  1465. return err.Error()
  1466. }
  1467. reader := bytes.NewReader(bytesData)
  1468. gdyb_url := beego.AppConfig.String("gdyb_url")
  1469. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1470. var url string
  1471. if baseParams.MdtrtareaAdmvs == "150499" {
  1472. url = gdyb_url
  1473. } else {
  1474. url = gdyb_url + "3201"
  1475. }
  1476. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1477. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3201"
  1478. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1479. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3201"
  1480. request, err := http.NewRequest("POST", url, reader)
  1481. if err != nil {
  1482. fmt.Println(err.Error())
  1483. return err.Error()
  1484. }
  1485. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1486. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1487. request.Header.Set("x-tif-signature", signature)
  1488. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1489. request.Header.Set("x-tif-nonce", nonce)
  1490. client := http.Client{}
  1491. resp, err := client.Do(request)
  1492. if err != nil {
  1493. fmt.Println(err.Error())
  1494. return err.Error()
  1495. }
  1496. respBytes, err := ioutil.ReadAll(resp.Body)
  1497. if err != nil {
  1498. fmt.Println(err.Error())
  1499. return err.Error()
  1500. }
  1501. str := string(respBytes)
  1502. fmt.Println(str)
  1503. return str
  1504. }
  1505. //文件上传
  1506. func HeBeiyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  1507. // 生成签名
  1508. nonce := GetRandomString(32)
  1509. timestamp := time.Now().Unix()
  1510. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1511. //buf := new(bytes.Buffer)
  1512. //buf.ReadFrom(strings.NewReader(string(file_byte)))
  1513. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1514. input := make(map[string]interface{})
  1515. inputData := make(map[string]interface{})
  1516. inputMessage["infno"] = "9101" // 交易编码
  1517. inputData["file_name"] = file_name //文件名
  1518. inputData["in"] = file_byte //文件数据
  1519. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1520. input["fsUploadIn"] = inputData
  1521. inputMessage["input"] = input //交易输入
  1522. bytesData, err := json.Marshal(inputMessage)
  1523. fmt.Println(string(bytesData))
  1524. if err != nil {
  1525. fmt.Println(err.Error())
  1526. return err.Error()
  1527. }
  1528. reader := bytes.NewReader(bytesData)
  1529. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  1530. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1531. gdyb_url := beego.AppConfig.String("gdyb_url")
  1532. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1533. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1534. url := gdyb_url + "9101"
  1535. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  1536. request, err := http.NewRequest("POST", url, reader)
  1537. if err != nil {
  1538. fmt.Println(err.Error())
  1539. return err.Error()
  1540. }
  1541. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1542. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1543. request.Header.Set("x-tif-signature", signature)
  1544. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1545. request.Header.Set("x-tif-nonce", nonce)
  1546. client := http.Client{}
  1547. resp, err := client.Do(request)
  1548. if err != nil {
  1549. fmt.Println(err.Error())
  1550. return err.Error()
  1551. }
  1552. respBytes, err := ioutil.ReadAll(resp.Body)
  1553. if err != nil {
  1554. fmt.Println(err.Error())
  1555. return err.Error()
  1556. }
  1557. str := string(respBytes)
  1558. fmt.Println(str)
  1559. return str
  1560. }
  1561. func HeBeiyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  1562. // 生成签名
  1563. nonce := GetRandomString(32)
  1564. timestamp := time.Now().Unix()
  1565. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1566. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1567. input := make(map[string]interface{})
  1568. inputData := make(map[string]interface{})
  1569. inputMessage["infno"] = "9102" // 交易编码
  1570. inputData["file_name"] = file_name //文件名
  1571. inputData["file_qury_no"] = file_qury_no //文件数据
  1572. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  1573. input["fsDownloadIn"] = inputData
  1574. inputMessage["input"] = input //交易输入
  1575. bytesData, err := json.Marshal(inputMessage)
  1576. fmt.Println(string(bytesData))
  1577. if err != nil {
  1578. fmt.Println(err.Error())
  1579. return err.Error()
  1580. }
  1581. reader := bytes.NewReader(bytesData)
  1582. gdyb_url := beego.AppConfig.String("gdyb_url")
  1583. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1584. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1585. url := gdyb_url + "9102"
  1586. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  1587. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1588. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  1589. request, err := http.NewRequest("POST", url, reader)
  1590. if err != nil {
  1591. fmt.Println(err.Error())
  1592. return err.Error()
  1593. }
  1594. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1595. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1596. request.Header.Set("x-tif-signature", signature)
  1597. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1598. request.Header.Set("x-tif-nonce", nonce)
  1599. client := http.Client{}
  1600. resp, err := client.Do(request)
  1601. if err != nil {
  1602. fmt.Println(err.Error())
  1603. return err.Error()
  1604. }
  1605. respBytes, err := ioutil.ReadAll(resp.Body)
  1606. if err != nil {
  1607. fmt.Println(err.Error())
  1608. return err.Error()
  1609. }
  1610. str := string(respBytes)
  1611. fmt.Println(str)
  1612. return str
  1613. }
  1614. func HeBeiyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1615. // 生成签名
  1616. nonce := GetRandomString(32)
  1617. timestamp := time.Now().Unix()
  1618. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1619. // 生成输入报文
  1620. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1621. input := make(map[string]interface{})
  1622. inputData := make(map[string]interface{})
  1623. inputMessage["infno"] = "3202" // 交易编码
  1624. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  1625. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  1626. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1627. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1628. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1629. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1630. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  1631. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1632. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  1633. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  1634. input["data"] = inputData
  1635. inputMessage["input"] = input //交易输入
  1636. bytesData, err := json.Marshal(inputMessage)
  1637. fmt.Println(string(bytesData))
  1638. if err != nil {
  1639. fmt.Println(err.Error())
  1640. return err.Error()
  1641. }
  1642. reader := bytes.NewReader(bytesData)
  1643. gdyb_url := beego.AppConfig.String("gdyb_url")
  1644. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1645. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1646. url := gdyb_url + "3202"
  1647. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  1648. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1649. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1650. request, err := http.NewRequest("POST", url, reader)
  1651. if err != nil {
  1652. fmt.Println(err.Error())
  1653. return err.Error()
  1654. }
  1655. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1656. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1657. request.Header.Set("x-tif-signature", signature)
  1658. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1659. request.Header.Set("x-tif-nonce", nonce)
  1660. client := http.Client{}
  1661. resp, err := client.Do(request)
  1662. if err != nil {
  1663. fmt.Println(err.Error())
  1664. return err.Error()
  1665. }
  1666. respBytes, err := ioutil.ReadAll(resp.Body)
  1667. if err != nil {
  1668. fmt.Println(err.Error())
  1669. return err.Error()
  1670. }
  1671. str := string(respBytes)
  1672. fmt.Println(str)
  1673. return str
  1674. }
  1675. func HeBeiyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1676. fmt.Println("~~~~~~1")
  1677. fmt.Println(baseParams)
  1678. fmt.Println(businessParams)
  1679. // 生成签名
  1680. nonce := GetRandomString(32)
  1681. timestamp := time.Now().Unix()
  1682. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1683. fmt.Println("~~~~~~2")
  1684. // 生成输入报文
  1685. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1686. input := make(map[string]interface{})
  1687. inputData := make(map[string]interface{})
  1688. inputMessage["infno"] = "5203" // 交易编码
  1689. inputData["psn_no"] = businessParams.PsnNo
  1690. inputData["setl_id"] = businessParams.SetlId
  1691. inputData["mdtrt_id"] = businessParams.MdtrtId
  1692. input["data"] = inputData
  1693. inputMessage["input"] = input //交易输入
  1694. bytesData, err := json.Marshal(inputMessage)
  1695. fmt.Println(string(bytesData))
  1696. fmt.Println("~~~~~~")
  1697. fmt.Println("~~~~~~")
  1698. fmt.Println(string(bytesData))
  1699. if err != nil {
  1700. fmt.Println(err.Error())
  1701. return err.Error()
  1702. }
  1703. reader := bytes.NewReader(bytesData)
  1704. gdyb_url := beego.AppConfig.String("gdyb_url")
  1705. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1706. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1707. //url := gdyb_url + "5203"
  1708. var url string
  1709. if baseParams.FixmedinsCode == "H15049901371" {
  1710. url = gdyb_url
  1711. } else {
  1712. url = gdyb_url + "5203"
  1713. }
  1714. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1715. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1716. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1717. request, err := http.NewRequest("POST", url, reader)
  1718. if err != nil {
  1719. fmt.Println(err.Error())
  1720. return err.Error()
  1721. }
  1722. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1723. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1724. request.Header.Set("x-tif-signature", signature)
  1725. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1726. request.Header.Set("x-tif-nonce", nonce)
  1727. client := http.Client{}
  1728. resp, err := client.Do(request)
  1729. if err != nil {
  1730. fmt.Println(err.Error())
  1731. return err.Error()
  1732. }
  1733. respBytes, err := ioutil.ReadAll(resp.Body)
  1734. if err != nil {
  1735. fmt.Println(err.Error())
  1736. return err.Error()
  1737. }
  1738. str := string(respBytes)
  1739. fmt.Println(str)
  1740. return str
  1741. }
  1742. func HeBeiyb5204(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1743. // 生成签名
  1744. nonce := GetRandomString(32)
  1745. timestamp := time.Now().Unix()
  1746. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1747. // 生成输入报文
  1748. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1749. input := make(map[string]interface{})
  1750. inputData := make(map[string]interface{})
  1751. inputMessage["infno"] = "5204" // 交易编码
  1752. inputData["psn_no"] = businessParams.PsnNo
  1753. inputData["setl_id"] = businessParams.SetlId
  1754. inputData["mdtrt_id"] = businessParams.MdtrtId
  1755. input["data"] = inputData
  1756. inputMessage["input"] = input //交易输入
  1757. bytesData, err := json.Marshal(inputMessage)
  1758. fmt.Println(string(bytesData))
  1759. if err != nil {
  1760. fmt.Println(err.Error())
  1761. return err.Error()
  1762. }
  1763. reader := bytes.NewReader(bytesData)
  1764. gdyb_url := beego.AppConfig.String("gdyb_url")
  1765. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1766. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1767. //url := gdyb_url + "5203"
  1768. var url string
  1769. if baseParams.FixmedinsCode == "H15049901371" {
  1770. url = gdyb_url
  1771. } else {
  1772. url = gdyb_url + "5204"
  1773. }
  1774. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1775. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1776. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1777. request, err := http.NewRequest("POST", url, reader)
  1778. if err != nil {
  1779. fmt.Println(err.Error())
  1780. return err.Error()
  1781. }
  1782. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1783. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1784. request.Header.Set("x-tif-signature", signature)
  1785. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1786. request.Header.Set("x-tif-nonce", nonce)
  1787. client := http.Client{}
  1788. resp, err := client.Do(request)
  1789. if err != nil {
  1790. fmt.Println(err.Error())
  1791. return err.Error()
  1792. }
  1793. respBytes, err := ioutil.ReadAll(resp.Body)
  1794. if err != nil {
  1795. fmt.Println(err.Error())
  1796. return err.Error()
  1797. }
  1798. str := string(respBytes)
  1799. fmt.Println(str)
  1800. return str
  1801. }
  1802. func HeBeiyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  1803. if med_type == "1111" || med_type == "1112" {
  1804. med_type = "11"
  1805. }
  1806. // 生成签名
  1807. nonce := GetRandomString(32)
  1808. timestamp := time.Now().Unix()
  1809. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1810. // 生成输入报文
  1811. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1812. input := make(map[string]interface{})
  1813. inputData := make(map[string]interface{})
  1814. inputMessage["infno"] = "2001" // 交易编码
  1815. inputData["psn_no"] = psn_no
  1816. inputData["insutype"] = insutype
  1817. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  1818. inputData["med_type"] = med_type
  1819. inputData["begntime"] = "2021-01-01 00:00:00"
  1820. input["data"] = inputData
  1821. inputMessage["input"] = input //交易输入
  1822. bytesData, err := json.Marshal(inputMessage)
  1823. fmt.Println(string(bytesData))
  1824. if err != nil {
  1825. fmt.Println(err.Error())
  1826. return err.Error()
  1827. }
  1828. reader := bytes.NewReader(bytesData)
  1829. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1830. gdyb_url := beego.AppConfig.String("gdyb_url")
  1831. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1832. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1833. url := gdyb_url
  1834. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1835. request, err := http.NewRequest("POST", url, reader)
  1836. if err != nil {
  1837. fmt.Println(err.Error())
  1838. return err.Error()
  1839. }
  1840. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1841. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1842. request.Header.Set("x-tif-signature", signature)
  1843. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1844. request.Header.Set("x-tif-nonce", nonce)
  1845. client := http.Client{}
  1846. resp, err := client.Do(request)
  1847. if err != nil {
  1848. fmt.Println(err.Error())
  1849. return err.Error()
  1850. }
  1851. respBytes, err := ioutil.ReadAll(resp.Body)
  1852. if err != nil {
  1853. fmt.Println(err.Error())
  1854. return err.Error()
  1855. }
  1856. str := string(respBytes)
  1857. fmt.Println(str)
  1858. return str
  1859. }
  1860. func HeBeiyb3301(baseParams *models.BaseParams, name string, codg string, list_type_code string, start_time string, ent_time string, list_type string) string {
  1861. // 生成签名
  1862. nonce := GetRandomString(32)
  1863. timestamp := time.Now().Unix()
  1864. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1865. // 生成输入报文
  1866. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1867. input := make(map[string]interface{})
  1868. inputData := make(map[string]interface{})
  1869. inputMessage["infno"] = "3301" // 交易编码
  1870. inputData["fixmedins_hilist_id"] = codg
  1871. inputData["fixmedins_hilist_name"] = name
  1872. inputData["list_type"] = list_type
  1873. inputData["med_list_codg"] = codg
  1874. inputData["begndate"] = start_time
  1875. inputData["enddate"] = ent_time
  1876. inputData["aprvno"] = ""
  1877. inputData["dosform"] = ""
  1878. inputData["exct_cont"] = ""
  1879. inputData["item_cont"] = ""
  1880. inputData["prcunt"] = ""
  1881. inputData["spec"] = ""
  1882. inputData["pacspec"] = ""
  1883. inputData["memo"] = ""
  1884. input["data"] = inputData
  1885. inputMessage["input"] = input //交易输入
  1886. bytesData, err := json.Marshal(inputMessage)
  1887. fmt.Println(string(bytesData))
  1888. if err != nil {
  1889. fmt.Println(err.Error())
  1890. return err.Error()
  1891. }
  1892. reader := bytes.NewReader(bytesData)
  1893. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1894. //
  1895. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1896. gdyb_url := beego.AppConfig.String("gdyb_url")
  1897. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1898. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1899. url := gdyb_url + "3301"
  1900. request, err := http.NewRequest("POST", url, reader)
  1901. if err != nil {
  1902. fmt.Println(err.Error())
  1903. return err.Error()
  1904. }
  1905. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1906. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1907. request.Header.Set("x-tif-signature", signature)
  1908. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1909. request.Header.Set("x-tif-nonce", nonce)
  1910. client := http.Client{}
  1911. resp, err := client.Do(request)
  1912. if err != nil {
  1913. fmt.Println(err.Error())
  1914. return err.Error()
  1915. }
  1916. respBytes, err := ioutil.ReadAll(resp.Body)
  1917. if err != nil {
  1918. fmt.Println(err.Error())
  1919. return err.Error()
  1920. }
  1921. str := string(respBytes)
  1922. fmt.Println(str)
  1923. return str
  1924. }
  1925. func HeBeiyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  1926. // 生成签名
  1927. nonce := GetRandomString(32)
  1928. timestamp := time.Now().Unix()
  1929. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1930. // 生成输入报文
  1931. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1932. input := make(map[string]interface{})
  1933. inputData := make(map[string]interface{})
  1934. inputMessage["infno"] = "3302" // 交易编码
  1935. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  1936. inputData["fixmedins_hilist_id"] = codg
  1937. inputData["list_type"] = list_type_code
  1938. inputData["med_list_codg"] = codg
  1939. input["data"] = inputData
  1940. inputMessage["input"] = input //交易输入
  1941. bytesData, err := json.Marshal(inputMessage)
  1942. fmt.Println(string(bytesData))
  1943. if err != nil {
  1944. fmt.Println(err.Error())
  1945. return err.Error()
  1946. }
  1947. reader := bytes.NewReader(bytesData)
  1948. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  1949. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  1950. gdyb_url := beego.AppConfig.String("gdyb_url")
  1951. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1952. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1953. url := gdyb_url + "3302"
  1954. request, err := http.NewRequest("POST", url, reader)
  1955. if err != nil {
  1956. fmt.Println(err.Error())
  1957. return err.Error()
  1958. }
  1959. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1960. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1961. request.Header.Set("x-tif-signature", signature)
  1962. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1963. request.Header.Set("x-tif-nonce", nonce)
  1964. client := http.Client{}
  1965. resp, err := client.Do(request)
  1966. if err != nil {
  1967. fmt.Println(err.Error())
  1968. return err.Error()
  1969. }
  1970. respBytes, err := ioutil.ReadAll(resp.Body)
  1971. if err != nil {
  1972. fmt.Println(err.Error())
  1973. return err.Error()
  1974. }
  1975. str := string(respBytes)
  1976. fmt.Println(str)
  1977. return str
  1978. }
  1979. func HeBeiyb2505(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, start_time string, end_time string) string {
  1980. // 生成签名
  1981. nonce := GetRandomString(32)
  1982. timestamp := time.Now().Unix()
  1983. signature := setSignature(timestamp, nonce, secret_key)
  1984. // 生成输入报文
  1985. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1986. input := make(map[string]interface{})
  1987. inputData := make(map[string]interface{})
  1988. inputMessage["infno"] = "2505"
  1989. inputData["psn_no"] = psnNo
  1990. inputData["biz_appy_type"] = "03"
  1991. inputData["begndate"] = start_time
  1992. inputData["enddate"] = end_time
  1993. inputData["fixmedins_code"] = fixmedins_code
  1994. inputData["fixmedins_name"] = org_name
  1995. inputData["tel"] = ""
  1996. inputData["addr"] = ""
  1997. inputData["agnter_name"] = ""
  1998. inputData["agnter_cert_type"] = ""
  1999. inputData["agnter_certno"] = ""
  2000. inputData["agnter_tel"] = ""
  2001. inputData["agnter_addr"] = ""
  2002. inputData["agnter_rlts"] = ""
  2003. inputData["fix_srt_no"] = ""
  2004. inputData["memo"] = ""
  2005. input["data"] = inputData
  2006. inputMessage["input"] = input //交易输入
  2007. bytesData, err := json.Marshal(inputMessage)
  2008. if err != nil {
  2009. fmt.Println(err.Error())
  2010. return err.Error()
  2011. }
  2012. reader := bytes.NewReader(bytesData)
  2013. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  2014. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  2015. gdyb_url := beego.AppConfig.String("gdyb_url")
  2016. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2017. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2018. url := gdyb_url + "2505"
  2019. request, err := http.NewRequest("POST", url, reader)
  2020. if err != nil {
  2021. fmt.Println(err.Error())
  2022. return err.Error()
  2023. }
  2024. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2025. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2026. request.Header.Set("x-tif-signature", signature)
  2027. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2028. request.Header.Set("x-tif-nonce", nonce)
  2029. client := http.Client{}
  2030. resp, err := client.Do(request)
  2031. if err != nil {
  2032. fmt.Println(err.Error())
  2033. return err.Error()
  2034. }
  2035. respBytes, err := ioutil.ReadAll(resp.Body)
  2036. if err != nil {
  2037. fmt.Println(err.Error())
  2038. return err.Error()
  2039. }
  2040. str := string(respBytes)
  2041. fmt.Println(str)
  2042. return str
  2043. }
  2044. func HeBeiyb2506(psnNo string, doctor string, org_name string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, trt_dcla_detl_sn string) string {
  2045. // 生成签名
  2046. nonce := GetRandomString(32)
  2047. timestamp := time.Now().Unix()
  2048. signature := setSignature(timestamp, nonce, secret_key)
  2049. // 生成输入报文
  2050. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2051. input := make(map[string]interface{})
  2052. inputData := make(map[string]interface{})
  2053. inputMessage["infno"] = "2506"
  2054. inputData["psn_no"] = psnNo
  2055. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  2056. inputData["memo"] = ""
  2057. input["data"] = inputData
  2058. inputMessage["input"] = input //交易输入
  2059. bytesData, err := json.Marshal(inputMessage)
  2060. fmt.Println(string(bytesData))
  2061. if err != nil {
  2062. fmt.Println(err.Error())
  2063. return err.Error()
  2064. }
  2065. reader := bytes.NewReader(bytesData)
  2066. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  2067. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  2068. gdyb_url := beego.AppConfig.String("gdyb_url")
  2069. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2070. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2071. url := gdyb_url + "2506"
  2072. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2073. request, err := http.NewRequest("POST", url, reader)
  2074. if err != nil {
  2075. fmt.Println(err.Error())
  2076. return err.Error()
  2077. }
  2078. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2079. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2080. request.Header.Set("x-tif-signature", signature)
  2081. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2082. request.Header.Set("x-tif-nonce", nonce)
  2083. client := http.Client{}
  2084. resp, err := client.Do(request)
  2085. if err != nil {
  2086. fmt.Println(err.Error())
  2087. return err.Error()
  2088. }
  2089. respBytes, err := ioutil.ReadAll(resp.Body)
  2090. if err != nil {
  2091. fmt.Println(err.Error())
  2092. return err.Error()
  2093. }
  2094. str := string(respBytes)
  2095. fmt.Println(str)
  2096. return str
  2097. }
  2098. func HeBeiyb2503(psnNo string, insutype string, org_name 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) string {
  2099. // 生成签名
  2100. nonce := GetRandomString(32)
  2101. timestamp := time.Now().Unix()
  2102. signature := setSignature(timestamp, nonce, secret_key)
  2103. //tempTime := time.Unix(timestamp, 0)
  2104. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2105. //timeFormatTwo := tempTime.Format("2006-01-02")
  2106. //t := time.Now()
  2107. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  2108. //tm := time.Unix(last.Unix(), 0)
  2109. // 生成输入报文
  2110. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2111. input := make(map[string]interface{})
  2112. inputData := make(map[string]interface{})
  2113. inputMessage["infno"] = "2503" // 交易编码
  2114. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2115. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  2116. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  2117. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  2118. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  2119. inputData["ide_fixmedins_no"] = fixmedins_code // 险种类型(来自1101接口返回)
  2120. inputData["ide_fixmedins_name"] = org_name // 险种类型(来自1101接口返回)
  2121. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  2122. inputData["diag_dr_codg"] = doctor_id // 开始时间
  2123. inputData["diag_dr_name"] = doctor // 开始时间
  2124. inputData["begndate"] = start_time // 医师编码
  2125. inputData["tel"] = "" // 医师编码
  2126. inputData["addr"] = "" // 医师编码
  2127. inputData["enddate"] = end_time // 医师编码
  2128. input["data"] = inputData
  2129. inputMessage["input"] = input //交易输入
  2130. bytesData, err := json.Marshal(inputMessage)
  2131. fmt.Println(string(bytesData))
  2132. if err != nil {
  2133. fmt.Println(err.Error())
  2134. return err.Error()
  2135. }
  2136. reader := bytes.NewReader(bytesData)
  2137. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  2138. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  2139. gdyb_url := beego.AppConfig.String("gdyb_url")
  2140. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2141. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2142. //url := gdyb_url + "2503"
  2143. var url string
  2144. if fixmedins_code == "H15049901371" {
  2145. url = gdyb_url
  2146. } else {
  2147. url = gdyb_url + "2503"
  2148. }
  2149. request, err := http.NewRequest("POST", url, reader)
  2150. if err != nil {
  2151. fmt.Println(err.Error())
  2152. return err.Error()
  2153. }
  2154. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2155. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2156. request.Header.Set("x-tif-signature", signature)
  2157. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2158. request.Header.Set("x-tif-nonce", nonce)
  2159. client := http.Client{}
  2160. resp, err := client.Do(request)
  2161. if err != nil {
  2162. fmt.Println(err.Error())
  2163. return err.Error()
  2164. }
  2165. respBytes, err := ioutil.ReadAll(resp.Body)
  2166. if err != nil {
  2167. fmt.Println(err.Error())
  2168. return err.Error()
  2169. }
  2170. str := string(respBytes)
  2171. fmt.Println(str)
  2172. return str
  2173. }
  2174. func HeBeiyb2504(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, trt_dcla_detl_sn string) string {
  2175. // 生成签名
  2176. nonce := GetRandomString(32)
  2177. timestamp := time.Now().Unix()
  2178. signature := setSignature(timestamp, nonce, secret_key)
  2179. // 生成输入报文
  2180. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2181. input := make(map[string]interface{})
  2182. inputData := make(map[string]interface{})
  2183. inputMessage["infno"] = "2504" // 交易编码
  2184. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2185. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  2186. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  2187. input["data"] = inputData
  2188. inputMessage["input"] = input //交易输入
  2189. bytesData, err := json.Marshal(inputMessage)
  2190. fmt.Println(string(bytesData))
  2191. if err != nil {
  2192. fmt.Println(err.Error())
  2193. return err.Error()
  2194. }
  2195. reader := bytes.NewReader(bytesData)
  2196. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  2197. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  2198. gdyb_url := beego.AppConfig.String("gdyb_url")
  2199. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2200. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2201. url := gdyb_url + "2504"
  2202. request, err := http.NewRequest("POST", url, reader)
  2203. if err != nil {
  2204. fmt.Println(err.Error())
  2205. return err.Error()
  2206. }
  2207. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2208. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2209. request.Header.Set("x-tif-signature", signature)
  2210. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2211. request.Header.Set("x-tif-nonce", nonce)
  2212. client := http.Client{}
  2213. resp, err := client.Do(request)
  2214. if err != nil {
  2215. fmt.Println(err.Error())
  2216. return err.Error()
  2217. }
  2218. respBytes, err := ioutil.ReadAll(resp.Body)
  2219. if err != nil {
  2220. fmt.Println(err.Error())
  2221. return err.Error()
  2222. }
  2223. str := string(respBytes)
  2224. fmt.Println(str)
  2225. return str
  2226. }
  2227. //func Gdyb2503(psnNo string, doctor string, department string, diag string, org_name string, med_type string, doctor_id int64, fixmedins_code string, diag_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string) string {
  2228. // // 生成签名
  2229. // nonce := GetRandomString(32)
  2230. // timestamp := time.Now().Unix()
  2231. // signature := setSignature(timestamp, nonce, secret_key)
  2232. // tempTime := time.Unix(timestamp, 0)
  2233. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2234. //
  2235. // // 生成输入报文
  2236. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2237. // input := make(map[string]interface{})
  2238. // inputData := make(map[string]interface{})
  2239. // diseinfo := make([]map[string]interface{}, 0)
  2240. //
  2241. // inputMessage["infno"] = "2203" // 交易编码
  2242. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  2243. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2244. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  2245. // inputData["begntime"] = timeFormatOne // 开始时间
  2246. // inputData["main_cond_dscr"] = "" // 主要病情描述
  2247. // inputData["dise_codg"] = sick_code // 病种编码
  2248. // inputData["dise_name"] = sick_name // 病种名称
  2249. // inputData["birctrl_type"] = "" // 计划生育手术类别
  2250. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  2251. //
  2252. // diseinfo_sun := make(map[string]interface{})
  2253. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  2254. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  2255. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  2256. // diseinfo_sun["diag_name"] = diag // 诊断名称
  2257. // diseinfo_sun["diag_dept"] = department // 诊断科室
  2258. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  2259. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  2260. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  2261. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  2262. //
  2263. // diseinfo = append(diseinfo, diseinfo_sun)
  2264. // input["diseinfo"] = diseinfo
  2265. // input["mdtrtinfo"] = inputData
  2266. // inputMessage["input"] = input //交易输入
  2267. //
  2268. // bytesData, err := json.Marshal(inputMessage)
  2269. // fmt.Println(string(bytesData))
  2270. // if err != nil {
  2271. // fmt.Println(err.Error())
  2272. // return err.Error()
  2273. // }
  2274. // reader := bytes.NewReader(bytesData)
  2275. //
  2276. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  2277. //
  2278. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  2279. // request, err := http.NewRequest("POST", url, reader)
  2280. // if err != nil {
  2281. // fmt.Println(err.Error())
  2282. // return err.Error()
  2283. // }
  2284. //
  2285. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2286. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2287. // request.Header.Set("x-tif-signature", signature)
  2288. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2289. // request.Header.Set("x-tif-nonce", nonce)
  2290. //
  2291. // client := http.Client{}
  2292. // resp, err := client.Do(request)
  2293. // if err != nil {
  2294. // fmt.Println(err.Error())
  2295. // return err.Error()
  2296. // }
  2297. // respBytes, err := ioutil.ReadAll(resp.Body)
  2298. // if err != nil {
  2299. // fmt.Println(err.Error())
  2300. // return err.Error()
  2301. // }
  2302. // str := string(respBytes)
  2303. // fmt.Println(str)
  2304. // return str
  2305. //}
  2306. func HeBeiyb5301(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2307. // 生成签名
  2308. nonce := GetRandomString(32)
  2309. timestamp := time.Now().Unix()
  2310. signature := setSignature(timestamp, nonce, secret_key)
  2311. //tempTime := time.Unix(timestamp, 0)
  2312. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2313. //timeFormatTwo := tempTime.Format("2006-01-02")
  2314. // 生成输入报文
  2315. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2316. input := make(map[string]interface{})
  2317. inputData := make(map[string]interface{})
  2318. inputMessage["infno"] = "5301" // 交易编码
  2319. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2320. input["data"] = inputData
  2321. inputMessage["input"] = input //交易输入
  2322. bytesData, err := json.Marshal(inputMessage)
  2323. fmt.Println(string(bytesData))
  2324. if err != nil {
  2325. fmt.Println(err.Error())
  2326. return err.Error()
  2327. }
  2328. reader := bytes.NewReader(bytesData)
  2329. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2330. gdyb_url := beego.AppConfig.String("gdyb_url")
  2331. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2332. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2333. url := gdyb_url + "5301"
  2334. request, err := http.NewRequest("POST", url, reader)
  2335. if err != nil {
  2336. fmt.Println(err.Error())
  2337. return err.Error()
  2338. }
  2339. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2340. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2341. request.Header.Set("x-tif-signature", signature)
  2342. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2343. request.Header.Set("x-tif-nonce", nonce)
  2344. client := http.Client{}
  2345. resp, err := client.Do(request)
  2346. if err != nil {
  2347. fmt.Println(err.Error())
  2348. return err.Error()
  2349. }
  2350. respBytes, err := ioutil.ReadAll(resp.Body)
  2351. if err != nil {
  2352. fmt.Println(err.Error())
  2353. return err.Error()
  2354. }
  2355. str := string(respBytes)
  2356. fmt.Println(str)
  2357. return str
  2358. }
  2359. func HeBeiyb5301Two(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2360. // 生成签名
  2361. nonce := GetRandomString(32)
  2362. timestamp := time.Now().Unix()
  2363. signature := setSignature(timestamp, nonce, secret_key)
  2364. //tempTime := time.Unix(timestamp, 0)
  2365. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2366. //timeFormatTwo := tempTime.Format("2006-01-02")
  2367. // 生成输入报文
  2368. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2369. input := make(map[string]interface{})
  2370. inputData := make(map[string]interface{})
  2371. inputMessage["infno"] = "5301" // 交易编码
  2372. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  2373. input["data"] = inputData
  2374. inputMessage["input"] = input //交易输入
  2375. bytesData, err := json.Marshal(inputMessage)
  2376. fmt.Println(string(bytesData))
  2377. if err != nil {
  2378. fmt.Println(err.Error())
  2379. return err.Error()
  2380. }
  2381. reader := bytes.NewReader(bytesData)
  2382. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  2383. gdyb_url := beego.AppConfig.String("gdyb_url")
  2384. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2385. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2386. url := gdyb_url
  2387. request, err := http.NewRequest("POST", url, reader)
  2388. if err != nil {
  2389. fmt.Println(err.Error())
  2390. return err.Error()
  2391. }
  2392. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2393. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2394. request.Header.Set("x-tif-signature", signature)
  2395. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2396. request.Header.Set("x-tif-nonce", nonce)
  2397. client := http.Client{}
  2398. resp, err := client.Do(request)
  2399. if err != nil {
  2400. fmt.Println(err.Error())
  2401. return err.Error()
  2402. }
  2403. respBytes, err := ioutil.ReadAll(resp.Body)
  2404. if err != nil {
  2405. fmt.Println(err.Error())
  2406. return err.Error()
  2407. }
  2408. str := string(respBytes)
  2409. fmt.Println(str)
  2410. return str
  2411. }
  2412. //
  2413. func HeBeiyb4101(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, org_id int64) string {
  2414. // 生成签名
  2415. nonce := GetRandomString(32)
  2416. timestamp := time.Now().Unix()
  2417. signature := setSignature(timestamp, nonce, secret_key)
  2418. // 生成输入报文
  2419. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2420. input := make(map[string]interface{})
  2421. inputData := make(map[string]interface{})
  2422. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  2423. inputMessage["infno"] = "4101A" // 交易编码
  2424. } else {
  2425. inputMessage["infno"] = "4101A" // 交易编码
  2426. }
  2427. year := time.Now().Format("2006")
  2428. month := time.Now().Format("01")
  2429. day := time.Now().Format("02")
  2430. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  2431. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  2432. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  2433. inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  2434. inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  2435. inputData["hi_setl_lv"] = "" // 医保结算等级
  2436. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  2437. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  2438. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  2439. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  2440. inputData["gend"] = struct4101.Gend // 性别 必填
  2441. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  2442. inputData["age"] = struct4101.Age // 年龄 必填
  2443. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  2444. inputData["nwb_age"] = "" // 年龄 必填
  2445. inputData["naty"] = struct4101.Naty // 民族 必填
  2446. if org_id == 10138 {
  2447. inputData["dscg_way"] = "9" // 民族 必填
  2448. inputData["resp_nurs_code"] = "N441623001432" // 民族 必填
  2449. }
  2450. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  2451. inputData["certno"] = struct4101.Certno // 证件号码 必填
  2452. inputData["prfs"] = struct4101.Prfs // 职业 必填
  2453. inputData["curr_addr"] = "" // 现住址 必填
  2454. inputData["emp_name"] = "" // 单位名称 必填
  2455. inputData["emp_addr"] = "" // 单位地址 必填
  2456. inputData["emp_tel"] = "" // 单位电话 必填
  2457. inputData["poscode"] = "" // 邮编 必填
  2458. inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  2459. inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  2460. inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  2461. inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  2462. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  2463. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  2464. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  2465. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  2466. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  2467. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  2468. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  2469. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  2470. inputData["ipt_med_type"] = struct4101.IptMedType // 住院医疗类型 必填
  2471. inputData["adm_way"] = "2" // 入院途径 必填
  2472. inputData["trt_type"] = "1" // 治疗类别 必填
  2473. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  2474. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  2475. inputData["refldept_dept"] = "" // 转科科别 必填
  2476. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  2477. inputData["dscg_caty"] = struct4101.AdmCaty // 出院科别 必填
  2478. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  2479. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  2480. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  2481. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  2482. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  2483. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  2484. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  2485. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  2486. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  2487. inputData["bld_cat"] = "" // 输血品种 必填
  2488. inputData["bld_amt"] = "" // 输血量 必填
  2489. inputData["bld_unt"] = "" // 输血计量单位 必填
  2490. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  2491. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  2492. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  2493. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  2494. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  2495. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  2496. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  2497. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  2498. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  2499. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  2500. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  2501. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  2502. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  2503. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  2504. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  2505. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  2506. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  2507. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  2508. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  2509. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  2510. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  2511. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  2512. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  2513. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  2514. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  2515. for _, item := range struct4101.CustomStruct {
  2516. payinfotemp := make(map[string]interface{})
  2517. if item.FundPayType == "310100" || item.FundPayType == "310200" || item.FundPayType == "320100" || item.FundPayType == "330100" || item.FundPayType == "340100" || item.FundPayType == "350100" || item.FundPayType == "370100" || item.FundPayType == "390100" || item.FundPayType == "610100" || item.FundPayType == "640100" || item.FundPayType == "620100" {
  2518. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  2519. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  2520. payinfo = append(payinfo, payinfotemp)
  2521. }
  2522. }
  2523. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  2524. opspdiseinfotemp := make(map[string]interface{})
  2525. opspdiseinfotemp["diag_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 诊断名称 必填
  2526. opspdiseinfotemp["diag_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 诊断代码 必填
  2527. opspdiseinfotemp["oprn_oprt_name"] = "血液透析" // 手术操作名称 必填
  2528. opspdiseinfotemp["oprn_oprt_code"] = "39.9500" // 手术操作代码 必填
  2529. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  2530. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  2531. for _, item := range struct4101.Diseinfo {
  2532. diseinfotemp := make(map[string]interface{})
  2533. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  2534. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  2535. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  2536. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  2537. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  2538. diseinfo = append(diseinfo, diseinfotemp)
  2539. }
  2540. iteminfo := make([]map[string]interface{}, 0)
  2541. for _, item := range struct4101.IteminfoStruct {
  2542. iteminfotemp := make(map[string]interface{})
  2543. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  2544. iteminfotemp["amt"] = item.Amt // 金额 必填
  2545. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  2546. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  2547. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  2548. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  2549. iteminfo = append(iteminfo, iteminfotemp)
  2550. }
  2551. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  2552. oprninfotemp := make(map[string]interface{})
  2553. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  2554. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  2555. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  2556. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  2557. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  2558. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  2559. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  2560. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  2561. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  2562. oprninfo = append(oprninfo, oprninfotemp)
  2563. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  2564. icuinfotemp := make(map[string]interface{})
  2565. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  2566. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  2567. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  2568. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  2569. icuinfo = append(icuinfo, icuinfotemp)
  2570. input["setlinfo"] = inputData
  2571. input["payinfo"] = payinfo
  2572. input["opspdiseinfo"] = oprninfo
  2573. input["diseinfo"] = diseinfo
  2574. input["iteminfo"] = iteminfo
  2575. inputMessage["input"] = input //交易输入
  2576. bytesData, err := json.Marshal(inputMessage)
  2577. fmt.Println(string(bytesData))
  2578. if err != nil {
  2579. fmt.Println(err.Error())
  2580. return err.Error()
  2581. }
  2582. reader := bytes.NewReader(bytesData)
  2583. gdyb_url := beego.AppConfig.String("gdyb_url")
  2584. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2585. //url := gdyb_url + "4101"
  2586. var url string
  2587. if fixmedins_code == "H15049901371" {
  2588. url = gdyb_url
  2589. } else {
  2590. if org_id == 10106 || org_id == 10215 || org_id == 10138 || org_id == 9504 {
  2591. url = gdyb_url + "4101A"
  2592. } else {
  2593. url = gdyb_url + "4101"
  2594. }
  2595. }
  2596. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  2597. request, err := http.NewRequest("POST", url, reader)
  2598. if err != nil {
  2599. fmt.Println(err.Error())
  2600. return err.Error()
  2601. }
  2602. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2603. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2604. request.Header.Set("x-tif-signature", signature)
  2605. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2606. request.Header.Set("x-tif-nonce", nonce)
  2607. client := http.Client{}
  2608. resp, err := client.Do(request)
  2609. if err != nil {
  2610. fmt.Println(err.Error())
  2611. return err.Error()
  2612. }
  2613. respBytes, err := ioutil.ReadAll(resp.Body)
  2614. if err != nil {
  2615. fmt.Println(err.Error())
  2616. return err.Error()
  2617. }
  2618. str := string(respBytes)
  2619. fmt.Println(str)
  2620. return str
  2621. }
  2622. func HeBeiyb2601(psnNo string, omsgid string, oinfno string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2623. // 生成签名
  2624. nonce := GetRandomString(32)
  2625. timestamp := time.Now().Unix()
  2626. signature := setSignature(timestamp, nonce, secret_key)
  2627. // 生成输入报文
  2628. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2629. input := make(map[string]interface{})
  2630. inputData := make(map[string]interface{})
  2631. inputMessage["infno"] = "2601" // 交易编码
  2632. inputData["psn_no"] = psnNo
  2633. inputData["omsgid"] = omsgid
  2634. inputData["oinfno"] = oinfno
  2635. input["data"] = inputData
  2636. inputMessage["input"] = input //交易输入
  2637. bytesData, err := json.Marshal(inputMessage)
  2638. fmt.Println(string(bytesData))
  2639. if err != nil {
  2640. fmt.Println(err.Error())
  2641. return err.Error()
  2642. }
  2643. reader := bytes.NewReader(bytesData)
  2644. gdyb_url := beego.AppConfig.String("gdyb_url")
  2645. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2646. url := gdyb_url + "2601"
  2647. request, err := http.NewRequest("POST", url, reader)
  2648. if err != nil {
  2649. fmt.Println(err.Error())
  2650. return err.Error()
  2651. }
  2652. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2653. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2654. request.Header.Set("x-tif-signature", signature)
  2655. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2656. request.Header.Set("x-tif-nonce", nonce)
  2657. client := http.Client{}
  2658. resp, err := client.Do(request)
  2659. if err != nil {
  2660. fmt.Println(err.Error())
  2661. return err.Error()
  2662. }
  2663. respBytes, err := ioutil.ReadAll(resp.Body)
  2664. if err != nil {
  2665. fmt.Println(err.Error())
  2666. return err.Error()
  2667. }
  2668. str := string(respBytes)
  2669. fmt.Println(str)
  2670. return str
  2671. }
  2672. //人员信息版本3
  2673. func HeBeiyb1101B(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64) string {
  2674. //生成签名
  2675. nonce := GetRandomString(32)
  2676. timestamp := time.Now().Unix()
  2677. signature := setSignature(timestamp, nonce, secret_key)
  2678. //生成输入报文
  2679. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2680. input := make(map[string]interface{})
  2681. inputData := make(map[string]interface{})
  2682. inputMessage["infno"] = "1101" // 交易编码
  2683. if certificates == 3 {
  2684. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  2685. inputData["certno"] = "01836483" // 证件号码
  2686. inputData["psn_cert_type"] = "01" // 人员证件类型
  2687. inputData["mdtrt_cert_no"] = "01836483" // 就诊凭证编号
  2688. } else {
  2689. if certificates == 1 {
  2690. if id_card_type == 1 {
  2691. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2692. inputData["card_sn"] = "" // 卡识别码
  2693. inputData["certno"] = certNo // 证件号码
  2694. inputData["psn_cert_type"] = "01" // 人员证件类型
  2695. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  2696. } else {
  2697. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  2698. inputData["card_sn"] = "" // 卡识别码
  2699. inputData["certno"] = certNo // 证件号码
  2700. inputData["psn_cert_type"] = "01" // 人员证件类型
  2701. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  2702. }
  2703. } else if certificates == 6 {
  2704. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2705. inputData["card_sn"] = "" // 卡识别码
  2706. inputData["certno"] = certNo // 证件号码
  2707. inputData["psn_cert_type"] = "17" // 人员证件类型
  2708. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  2709. }
  2710. }
  2711. inputData["begntime"] = "" // 开始时间
  2712. inputData["psn_name"] = "" // 人员姓名
  2713. input["data"] = inputData
  2714. inputMessage["input"] = input //交易输入
  2715. bytesData, err := json.Marshal(inputMessage)
  2716. fmt.Println(string(bytesData))
  2717. if err != nil {
  2718. fmt.Println(err.Error())
  2719. return err.Error()
  2720. }
  2721. reader := bytes.NewReader(bytesData)
  2722. gdyb_url := beego.AppConfig.String("gdyb_url")
  2723. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2724. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2725. //url := gdyb_url + "1101"
  2726. var url string
  2727. if fixmedins_code == "H15049901371" {
  2728. url = gdyb_url
  2729. } else {
  2730. url = gdyb_url + "1101"
  2731. }
  2732. fmt.Println(url)
  2733. fmt.Println(gdyb_paasid)
  2734. fmt.Println(secret_key)
  2735. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2736. request, err := http.NewRequest("POST", url, reader)
  2737. if err != nil {
  2738. fmt.Println(err.Error())
  2739. return err.Error()
  2740. }
  2741. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2742. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2743. request.Header.Set("x-tif-signature", signature)
  2744. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2745. request.Header.Set("x-tif-nonce", nonce)
  2746. client := http.Client{}
  2747. resp, err := client.Do(request)
  2748. if err != nil {
  2749. fmt.Println(err.Error())
  2750. return err.Error()
  2751. }
  2752. respBytes, err := ioutil.ReadAll(resp.Body)
  2753. if err != nil {
  2754. fmt.Println(err.Error())
  2755. return err.Error()
  2756. }
  2757. fmt.Println(string(respBytes))
  2758. str := string(respBytes)
  2759. return str
  2760. }
  2761. func HeBeiyb1101G(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string, cardNumber string) string {
  2762. //生成签名
  2763. nonce := GetRandomString(32)
  2764. timestamp := time.Now().Unix()
  2765. signature := setSignature(timestamp, nonce, secret_key)
  2766. //生成输入报文
  2767. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2768. input := make(map[string]interface{})
  2769. inputData := make(map[string]interface{})
  2770. inputMessage["infno"] = "1101" // 交易编码
  2771. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2772. inputData["card_sn"] = card_sn // 卡识别码
  2773. inputData["certno"] = certNo // 证件号码
  2774. inputData["psn_cert_type"] = "01" // 人员证件类型
  2775. inputData["mdtrt_cert_no"] = cardNumber // 就诊凭证编号
  2776. inputData["begntime"] = "" // 开始时间
  2777. inputData["psn_name"] = name // 人员姓名
  2778. input["data"] = inputData
  2779. inputMessage["input"] = input //交易输入
  2780. bytesData, err := json.Marshal(inputMessage)
  2781. fmt.Println(string(bytesData))
  2782. if err != nil {
  2783. fmt.Println(err.Error())
  2784. return err.Error()
  2785. }
  2786. reader := bytes.NewReader(bytesData)
  2787. gdyb_url := beego.AppConfig.String("gdyb_url")
  2788. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2789. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2790. //url := gdyb_url + "1101"
  2791. var url string
  2792. if fixmedins_code == "H15049901371" {
  2793. url = gdyb_url
  2794. } else {
  2795. url = gdyb_url + "1101"
  2796. }
  2797. fmt.Println(url)
  2798. fmt.Println(gdyb_paasid)
  2799. fmt.Println(secret_key)
  2800. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2801. request, err := http.NewRequest("POST", url, reader)
  2802. if err != nil {
  2803. fmt.Println(err.Error())
  2804. return err.Error()
  2805. }
  2806. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2807. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2808. request.Header.Set("x-tif-signature", signature)
  2809. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2810. request.Header.Set("x-tif-nonce", nonce)
  2811. client := http.Client{}
  2812. resp, err := client.Do(request)
  2813. if err != nil {
  2814. fmt.Println(err.Error())
  2815. return err.Error()
  2816. }
  2817. respBytes, err := ioutil.ReadAll(resp.Body)
  2818. if err != nil {
  2819. fmt.Println(err.Error())
  2820. return err.Error()
  2821. }
  2822. fmt.Println(string(respBytes))
  2823. str := string(respBytes)
  2824. return str
  2825. }
  2826. func HeBeiyb1101ForEleCert(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, token string) (string, string) {
  2827. //生成签名
  2828. nonce := GetRandomString(32)
  2829. timestamp := time.Now().Unix()
  2830. signature := setSignature(timestamp, nonce, secret_key)
  2831. //生成输入报文
  2832. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2833. input := make(map[string]interface{})
  2834. inputData := make(map[string]interface{})
  2835. inputMessage["infno"] = "1101" // 交易编码
  2836. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  2837. inputData["card_sn"] = "" // 卡识别码
  2838. inputData["certno"] = "" // 证件号码
  2839. inputData["psn_cert_type"] = "01" // 人员证件类型
  2840. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  2841. inputData["begntime"] = "" // 开始时间
  2842. inputData["psn_name"] = "" // 人员姓名
  2843. input["data"] = inputData
  2844. inputMessage["input"] = input //交易输入
  2845. bytesData, err := json.Marshal(inputMessage)
  2846. fmt.Println(string(bytesData))
  2847. if err != nil {
  2848. fmt.Println(err.Error())
  2849. return err.Error(), ""
  2850. }
  2851. reader := bytes.NewReader(bytesData)
  2852. gdyb_url := beego.AppConfig.String("gdyb_url")
  2853. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2854. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2855. //url := gdyb_url + "1101"
  2856. var url string
  2857. if fixmedins_code == "H15049901371" {
  2858. url = gdyb_url
  2859. } else {
  2860. url = gdyb_url + "1101"
  2861. }
  2862. fmt.Println(url)
  2863. fmt.Println(gdyb_paasid)
  2864. fmt.Println(secret_key)
  2865. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2866. request, err := http.NewRequest("POST", url, reader)
  2867. if err != nil {
  2868. fmt.Println(err.Error())
  2869. return err.Error(), ""
  2870. }
  2871. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2872. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2873. request.Header.Set("x-tif-signature", signature)
  2874. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2875. request.Header.Set("x-tif-nonce", nonce)
  2876. client := http.Client{}
  2877. resp, err := client.Do(request)
  2878. if err != nil {
  2879. fmt.Println(err.Error())
  2880. return err.Error(), ""
  2881. }
  2882. respBytes, err := ioutil.ReadAll(resp.Body)
  2883. if err != nil {
  2884. fmt.Println(err.Error())
  2885. return err.Error(), ""
  2886. }
  2887. fmt.Println(string(respBytes))
  2888. str := string(respBytes)
  2889. return str, string(bytesData)
  2890. }
  2891. func HeBeiyb6101(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  2892. //生成签名
  2893. nonce := GetRandomString(32)
  2894. timestamp := time.Now().Unix()
  2895. signature := setSignature(timestamp, nonce, secret_key)
  2896. //生成输入报文
  2897. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2898. input := make(map[string]interface{})
  2899. inputData := make(map[string]interface{})
  2900. inputMessage["infno"] = "6101" // 交易编码
  2901. inputData["orgId"] = fixmedins_code // 就诊凭证类型
  2902. inputData["businessType"] = "01101" // 卡识别码
  2903. inputData["businessInfo"] = "" // 证件号码
  2904. inputData["operateorId"] = "01" // 人员证件类型
  2905. inputData["operateornName"] = doctor // 就诊凭证编号
  2906. inputData["officeId"] = "01" // 开始时间
  2907. inputData["officeName"] = "血透" // 人员姓名
  2908. inputData["deviceType"] = "" // 人员姓名
  2909. input["InData"] = inputData
  2910. inputMessage["input"] = input //交易输入
  2911. bytesData, err := json.Marshal(inputMessage)
  2912. fmt.Println(string(bytesData))
  2913. if err != nil {
  2914. fmt.Println(err.Error())
  2915. return err.Error(), ""
  2916. }
  2917. reader := bytes.NewReader(bytesData)
  2918. gdyb_url := beego.AppConfig.String("gdyb_url")
  2919. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2920. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2921. //url := gdyb_url + "1101"
  2922. var url string
  2923. if fixmedins_code == "H15049901371" {
  2924. url = gdyb_url
  2925. } else {
  2926. url = gdyb_url + "1101"
  2927. }
  2928. fmt.Println(url)
  2929. fmt.Println(gdyb_paasid)
  2930. fmt.Println(secret_key)
  2931. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2932. request, err := http.NewRequest("POST", url, reader)
  2933. if err != nil {
  2934. fmt.Println(err.Error())
  2935. return err.Error(), ""
  2936. }
  2937. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2938. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2939. request.Header.Set("x-tif-signature", signature)
  2940. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2941. request.Header.Set("x-tif-nonce", nonce)
  2942. client := http.Client{}
  2943. resp, err := client.Do(request)
  2944. if err != nil {
  2945. fmt.Println(err.Error())
  2946. return err.Error(), ""
  2947. }
  2948. respBytes, err := ioutil.ReadAll(resp.Body)
  2949. if err != nil {
  2950. fmt.Println(err.Error())
  2951. return err.Error(), ""
  2952. }
  2953. fmt.Println(string(respBytes))
  2954. str := string(respBytes)
  2955. return str, string(bytesData)
  2956. }
  2957. //人员信息版本4
  2958. func HeBeiyb1101C(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64) (string, string) {
  2959. //生成签名
  2960. nonce := GetRandomString(32)
  2961. timestamp := time.Now().Unix()
  2962. //signature := setSignature(timestamp, nonce, secret_key)
  2963. //生成输入报文
  2964. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2965. input := make(map[string]interface{})
  2966. inputData := make(map[string]interface{})
  2967. inputMessage["infno"] = "1101" // 交易编码
  2968. if certificates == 3 {
  2969. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  2970. inputData["certno"] = certNo // 证件号码
  2971. inputData["psn_cert_type"] = "99" // 人员证件类型
  2972. } else {
  2973. if id_card_type == 1 {
  2974. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2975. inputData["card_sn"] = "" // 卡识别码
  2976. inputData["certno"] = "" // 证件号码
  2977. inputData["psn_cert_type"] = "" // 人员证件类型
  2978. } else {
  2979. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  2980. inputData["card_sn"] = "" // 卡识别码
  2981. inputData["certno"] = certNo // 证件号码
  2982. inputData["psn_cert_type"] = "1" // 人员证件类型
  2983. }
  2984. }
  2985. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  2986. inputData["begntime"] = "" // 开始时间
  2987. inputData["psn_name"] = "" // 人员姓名
  2988. input["data"] = inputData
  2989. inputMessage["input"] = input //交易输入
  2990. bytesData, err := json.Marshal(inputMessage)
  2991. fmt.Println(string(bytesData))
  2992. if err != nil {
  2993. fmt.Println(err.Error())
  2994. return err.Error(), ""
  2995. }
  2996. var json2 string
  2997. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  2998. out, err := cmd.Output()
  2999. if err != nil {
  3000. fmt.Println("error:", err.Error())
  3001. }
  3002. fmt.Println(string(out))
  3003. return string(out), string(bytesData)
  3004. }
  3005. func HeBeiyb90991(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, pwd string, card_number string) string {
  3006. //生成签名
  3007. nonce := GetRandomString(32)
  3008. timestamp := time.Now().Unix()
  3009. signature := setSignature(timestamp, nonce, secret_key)
  3010. //生成输入报文
  3011. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3012. input := make(map[string]interface{})
  3013. inputData := make(map[string]interface{})
  3014. inputMessage["infno"] = "90991" // 交易编码
  3015. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  3016. inputData["psn_no"] = psn_no // 开始时间
  3017. inputData["card_pwd"] = pwd // 人员姓名
  3018. inputData["sscno"] = card_number // 人员姓名
  3019. input["data"] = inputData
  3020. inputMessage["input"] = input //交易输入
  3021. bytesData, err := json.Marshal(inputMessage)
  3022. fmt.Println(string(bytesData))
  3023. if err != nil {
  3024. fmt.Println(err.Error())
  3025. return err.Error()
  3026. }
  3027. reader := bytes.NewReader(bytesData)
  3028. gdyb_url := beego.AppConfig.String("gdyb_url")
  3029. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3030. url := gdyb_url + "90991"
  3031. request, err := http.NewRequest("POST", url, reader)
  3032. if err != nil {
  3033. fmt.Println(err.Error())
  3034. return err.Error()
  3035. }
  3036. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3037. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3038. request.Header.Set("x-tif-signature", signature)
  3039. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3040. request.Header.Set("x-tif-nonce", nonce)
  3041. client := http.Client{}
  3042. resp, err := client.Do(request)
  3043. if err != nil {
  3044. fmt.Println(err.Error())
  3045. return err.Error()
  3046. }
  3047. respBytes, err := ioutil.ReadAll(resp.Body)
  3048. if err != nil {
  3049. fmt.Println(err.Error())
  3050. return err.Error()
  3051. }
  3052. fmt.Println(string(respBytes))
  3053. str := string(respBytes)
  3054. return str
  3055. }
  3056. func HeBeiyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  3057. //生成签名
  3058. nonce := GetRandomString(32)
  3059. timestamp := time.Now().Unix()
  3060. signature := setSignature(timestamp, nonce, secret_key)
  3061. //生成输入报文
  3062. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3063. input := make(map[string]interface{})
  3064. inputData := make(map[string]interface{})
  3065. inputMessage["infno"] = "90100" // 交易编码
  3066. inputData["psn_no"] = psn_no // 开始时间
  3067. input["data"] = inputData
  3068. inputMessage["input"] = input //交易输入
  3069. bytesData, err := json.Marshal(inputMessage)
  3070. fmt.Println(string(bytesData))
  3071. if err != nil {
  3072. fmt.Println(err.Error())
  3073. return err.Error()
  3074. }
  3075. reader := bytes.NewReader(bytesData)
  3076. gdyb_url := beego.AppConfig.String("gdyb_url")
  3077. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3078. url := gdyb_url + "90100"
  3079. request, err := http.NewRequest("POST", url, reader)
  3080. if err != nil {
  3081. fmt.Println(err.Error())
  3082. return err.Error()
  3083. }
  3084. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3085. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3086. request.Header.Set("x-tif-signature", signature)
  3087. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3088. request.Header.Set("x-tif-nonce", nonce)
  3089. client := http.Client{}
  3090. resp, err := client.Do(request)
  3091. if err != nil {
  3092. fmt.Println(err.Error())
  3093. return err.Error()
  3094. }
  3095. respBytes, err := ioutil.ReadAll(resp.Body)
  3096. if err != nil {
  3097. fmt.Println(err.Error())
  3098. return err.Error()
  3099. }
  3100. fmt.Println(string(respBytes))
  3101. str := string(respBytes)
  3102. return str
  3103. }
  3104. func HeBeiyb3260(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, sign string) (string, string) {
  3105. //生成签名
  3106. nonce := GetRandomString(32)
  3107. timestamp := time.Now().Unix()
  3108. signature := setSignature(timestamp, nonce, secret_key)
  3109. //生成输入报文
  3110. inputMessage := SetInputMessageTwo(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, sign)
  3111. input := make(map[string]interface{})
  3112. inputData := make(map[string]interface{})
  3113. inputMessage["infno"] = "3260" // 交易编码
  3114. inputData["trt_year"] = year // 就诊凭证编号
  3115. inputData["trt_month"] = month // 开始时间
  3116. inputData["startrow"] = "100" // 人员姓名
  3117. input["data"] = inputData
  3118. inputMessage["input"] = input //交易输入
  3119. var inputLog string
  3120. bytesData, err := json.Marshal(inputMessage)
  3121. inputLog = string(bytesData)
  3122. fmt.Println(string(bytesData))
  3123. if err != nil {
  3124. fmt.Println(err.Error())
  3125. return err.Error(), ""
  3126. }
  3127. reader := bytes.NewReader(bytesData)
  3128. gdyb_url := beego.AppConfig.String("gdyb_url")
  3129. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3130. var url string
  3131. if fixmedins_code == "H15049901371" {
  3132. url = gdyb_url
  3133. } else {
  3134. url = gdyb_url + "3260"
  3135. }
  3136. if insuplc_admdvs == "421300" {
  3137. var json2 string
  3138. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3139. out, err := cmd.Output()
  3140. if err != nil {
  3141. fmt.Println("error:", err.Error())
  3142. }
  3143. fmt.Println(string(out))
  3144. return hex.EncodeToString(out), inputLog
  3145. } else {
  3146. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3147. request, err := http.NewRequest("POST", url, reader)
  3148. if err != nil {
  3149. fmt.Println(err.Error())
  3150. return err.Error(), ""
  3151. }
  3152. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3153. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3154. request.Header.Set("x-tif-signature", signature)
  3155. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3156. request.Header.Set("x-tif-nonce", nonce)
  3157. client := http.Client{}
  3158. resp, err := client.Do(request)
  3159. if err != nil {
  3160. fmt.Println(err.Error())
  3161. return err.Error(), ""
  3162. }
  3163. respBytes, err := ioutil.ReadAll(resp.Body)
  3164. if err != nil {
  3165. fmt.Println(err.Error())
  3166. return err.Error(), ""
  3167. }
  3168. fmt.Println(string(respBytes))
  3169. str := string(respBytes)
  3170. return str, inputLog
  3171. }
  3172. }
  3173. func HeBeiyb3261(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, result3260 models.Result3260) (string, string, string) {
  3174. //生成签名
  3175. nonce := GetRandomString(32)
  3176. timestamp := time.Now().Unix()
  3177. signature := setSignature(timestamp, nonce, secret_key)
  3178. msg_month := time.Unix(1557042972, 0).Format("1")
  3179. msg_year := time.Now().Format("2006")
  3180. msg_month = time.Now().Format("01")
  3181. day := time.Now().Format("02")
  3182. hour := time.Now().Format("15")
  3183. min := time.Now().Format("04")
  3184. sec := time.Now().Format("05")
  3185. msec := time.Now().Format("000")
  3186. msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  3187. //生成输入报文
  3188. inputMessage := SetInputMessageThree(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, msg_id)
  3189. input := make(map[string]interface{})
  3190. inputData := make(map[string]interface{})
  3191. inputMessage["infno"] = "3261" // 交易编码
  3192. inputData["trt_year"] = year // 就诊凭证编号
  3193. inputData["trt_month"] = month // 开始时间
  3194. inputData["startrow"] = len(result3260.Output.Data) // 人员姓名
  3195. feedetail := make([]map[string]interface{}, 0)
  3196. for _, item := range result3260.Output.Data {
  3197. feedetailInfo := make(map[string]interface{})
  3198. feedetailInfo["certno"] = item.Certno
  3199. feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  3200. feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  3201. feedetailInfo["setl_no"] = item.SetlNo // 收费批次号
  3202. feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  3203. feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  3204. feedetail = append(feedetail, feedetailInfo)
  3205. }
  3206. inputData["detail"] = feedetail // 人员姓名
  3207. input["data"] = inputData
  3208. inputMessage["input"] = input //交易输入
  3209. var inputLog string
  3210. bytesData, err := json.Marshal(inputMessage)
  3211. inputLog = string(bytesData)
  3212. fmt.Println(string(bytesData))
  3213. if err != nil {
  3214. fmt.Println(err.Error())
  3215. return err.Error(), "", ""
  3216. }
  3217. reader := bytes.NewReader(bytesData)
  3218. gdyb_url := beego.AppConfig.String("gdyb_url")
  3219. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3220. var url string
  3221. if fixmedins_code == "H15049901371" {
  3222. url = gdyb_url
  3223. } else {
  3224. url = gdyb_url + "3261"
  3225. }
  3226. if insuplc_admdvs == "421300" {
  3227. var json2 string
  3228. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3229. out, err := cmd.Output()
  3230. if err != nil {
  3231. fmt.Println("error:", err.Error())
  3232. }
  3233. fmt.Println(string(out))
  3234. return hex.EncodeToString(out), inputLog, ""
  3235. } else {
  3236. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3237. request, err := http.NewRequest("POST", url, reader)
  3238. if err != nil {
  3239. fmt.Println(err.Error())
  3240. return err.Error(), "", ""
  3241. }
  3242. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3243. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3244. request.Header.Set("x-tif-signature", signature)
  3245. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3246. request.Header.Set("x-tif-nonce", nonce)
  3247. client := http.Client{}
  3248. resp, err := client.Do(request)
  3249. if err != nil {
  3250. fmt.Println(err.Error())
  3251. return err.Error(), "", ""
  3252. }
  3253. respBytes, err := ioutil.ReadAll(resp.Body)
  3254. if err != nil {
  3255. fmt.Println(err.Error())
  3256. return err.Error(), "", ""
  3257. }
  3258. fmt.Println(string(respBytes))
  3259. str := string(respBytes)
  3260. return str, inputLog, msg_id
  3261. }
  3262. }
  3263. func HeBeiyb3262(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, year string, month string, otransid string) (string, string) {
  3264. //生成签名
  3265. nonce := GetRandomString(32)
  3266. timestamp := time.Now().Unix()
  3267. signature := setSignature(timestamp, nonce, secret_key)
  3268. //生成输入报文
  3269. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3270. input := make(map[string]interface{})
  3271. inputData := make(map[string]interface{})
  3272. inputMessage["infno"] = "3262" // 交易编码
  3273. inputData["trt_year"] = year // 就诊凭证编号
  3274. inputData["trt_month"] = "" // 开始时间
  3275. inputData["otransid"] = otransid // 开始时间
  3276. input["data"] = inputData
  3277. inputMessage["input"] = input //交易输入
  3278. var inputLog string
  3279. bytesData, err := json.Marshal(inputMessage)
  3280. inputLog = string(bytesData)
  3281. fmt.Println(string(bytesData))
  3282. if err != nil {
  3283. fmt.Println(err.Error())
  3284. return err.Error(), ""
  3285. }
  3286. reader := bytes.NewReader(bytesData)
  3287. gdyb_url := beego.AppConfig.String("gdyb_url")
  3288. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3289. var url string
  3290. if fixmedins_code == "H15049901371" {
  3291. url = gdyb_url
  3292. } else {
  3293. url = gdyb_url + "3261"
  3294. }
  3295. if insuplc_admdvs == "421300" {
  3296. var json2 string
  3297. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3298. out, err := cmd.Output()
  3299. if err != nil {
  3300. fmt.Println("error:", err.Error())
  3301. }
  3302. fmt.Println(string(out))
  3303. return hex.EncodeToString(out), inputLog
  3304. } else {
  3305. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3306. request, err := http.NewRequest("POST", url, reader)
  3307. if err != nil {
  3308. fmt.Println(err.Error())
  3309. return err.Error(), ""
  3310. }
  3311. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3312. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3313. request.Header.Set("x-tif-signature", signature)
  3314. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3315. request.Header.Set("x-tif-nonce", nonce)
  3316. client := http.Client{}
  3317. resp, err := client.Do(request)
  3318. if err != nil {
  3319. fmt.Println(err.Error())
  3320. return err.Error(), ""
  3321. }
  3322. respBytes, err := ioutil.ReadAll(resp.Body)
  3323. if err != nil {
  3324. fmt.Println(err.Error())
  3325. return err.Error(), ""
  3326. }
  3327. fmt.Println(string(respBytes))
  3328. str := string(respBytes)
  3329. return str, inputLog
  3330. }
  3331. }
  3332. // 生成签名
  3333. func setSignature2(timestamp int64, nonce string, secret_key string) string {
  3334. fmt.Println(timestamp)
  3335. fmt.Println(nonce)
  3336. fmt.Println(secret_key)
  3337. fmt.Println(strconv.FormatInt(timestamp, 10))
  3338. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  3339. fmt.Println(str)
  3340. hash := sha256.New()
  3341. //输入数据
  3342. hash.Write([]byte(str))
  3343. //计算哈希值
  3344. bytes := hash.Sum(nil)
  3345. //将字符串编码为16进制格式,返回字符串
  3346. hashCode := hex.EncodeToString(bytes)
  3347. //返回哈希值
  3348. return hashCode
  3349. }
  3350. func HeBeiyb9001(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, admin_user_id int64) (string, string) {
  3351. //生成签名
  3352. ul := uuid.New()
  3353. nonce := ul.String()
  3354. timestamp := time.Now().Unix()
  3355. //now := time.Now() //获取当前时间
  3356. //t := now.Add(time.Minute * + 8 * 60) // 获取上一分钟时间
  3357. //lastM := t.Unix() - int64(now.Second()) // 上一分钟时间-上一分钟秒数
  3358. //timestamp = lastM
  3359. signature := setSignature2(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  3360. signature = ConvertToString(signature, "gbk", "utf-8")
  3361. //生成输入报文
  3362. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3363. input := make(map[string]interface{})
  3364. inputData := make(map[string]interface{})
  3365. inputMessage["infno"] = "9001" // 交易编码
  3366. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  3367. inputData["mac"] = GetMac() // 开始时间
  3368. inputData["ip"] = GetLocalIp()
  3369. input["signIn"] = inputData
  3370. inputMessage["input"] = input //交易输入
  3371. var inputLog string
  3372. bytesData, err := json.Marshal(inputMessage)
  3373. inputLog = string(bytesData)
  3374. fmt.Println(string(bytesData))
  3375. if err != nil {
  3376. fmt.Println(err.Error())
  3377. return err.Error(), ""
  3378. }
  3379. reader := bytes.NewReader(bytesData)
  3380. gdyb_url := beego.AppConfig.String("gdyb_url")
  3381. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3382. var url string
  3383. if fixmedins_code == "H15049901371" {
  3384. url = gdyb_url
  3385. } else {
  3386. url = "http://inner.getway.ylbzj.hebei.gov.cn/ebus/mbs_fsi_auth/fsi/api/signInSignOutService/signIn"
  3387. }
  3388. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3389. request, err := http.NewRequest("POST", url, reader)
  3390. if err != nil {
  3391. fmt.Println(err.Error())
  3392. return err.Error(), ""
  3393. }
  3394. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3395. //request.Header.Set("x-tif-paasid", "mbs_fsi_auth")
  3396. //request.Header.Set("x-tif-signature", signature)
  3397. //request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3398. //request.Header.Set("x-tif-nonce", nonce)
  3399. request.Header["Content-Type"] = []string{"application/json"}
  3400. request.Header["x-tif-paasid"] = []string{"mbs_fsi_auth"}
  3401. request.Header["x-tif-signature"] = []string{signature}
  3402. request.Header["x-tif-timestamp"] = []string{strconv.FormatInt(timestamp, 10)}
  3403. request.Header["x-tif-nonce"] = []string{nonce}
  3404. fmt.Println(string(bytesData))
  3405. fmt.Println(url)
  3406. fmt.Println(gdyb_paasid)
  3407. fmt.Println(request.Header)
  3408. client := http.Client{}
  3409. resp, err := client.Do(request)
  3410. if err != nil {
  3411. fmt.Println(err.Error())
  3412. return err.Error(), ""
  3413. }
  3414. respBytes, err := ioutil.ReadAll(resp.Body)
  3415. if err != nil {
  3416. fmt.Println(err.Error())
  3417. return err.Error(), ""
  3418. }
  3419. fmt.Println(string(respBytes))
  3420. str := string(respBytes)
  3421. return str, inputLog
  3422. }
  3423. // 人员基本信息
  3424. func HeBeiyb1101D(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, psn_name string, record_date string) (string, string) {
  3425. //生成签名
  3426. nonce := GetRandomString(32)
  3427. timestamp := time.Now().Unix()
  3428. signature := setSignature(timestamp, nonce, secret_key)
  3429. //生成输入报文
  3430. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3431. input := make(map[string]interface{})
  3432. inputData := make(map[string]interface{})
  3433. inputMessage["infno"] = "1101" // 交易编码
  3434. if certificates == "3" {
  3435. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  3436. inputData["certno"] = certNo // 证件号码
  3437. inputData["psn_cert_type"] = "99" // 人员证件类型
  3438. } else {
  3439. if certificates == "1" {
  3440. if id_card_type == 1 {
  3441. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3442. inputData["card_sn"] = "" // 卡识别码
  3443. inputData["certno"] = certNo // 证件号码
  3444. inputData["psn_cert_type"] = "01" // 人员证件类型
  3445. } else if id_card_type == 4 {
  3446. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  3447. inputData["certno"] = certNo // 证件号码
  3448. inputData["psn_cert_type"] = "01" // 人员证件类型
  3449. } else {
  3450. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  3451. inputData["card_sn"] = "" // 卡识别码
  3452. inputData["certno"] = certNo // 证件号码
  3453. inputData["psn_cert_type"] = "01" // 人员证件类型
  3454. }
  3455. } else if certificates == "6" {
  3456. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3457. inputData["card_sn"] = "" // 卡识别码
  3458. inputData["certno"] = certNo // 证件号码
  3459. inputData["psn_cert_type"] = "17" // 人员证件类型
  3460. }
  3461. }
  3462. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3463. inputData["begntime"] = "" // 开始时间
  3464. inputData["psn_name"] = "" // 人员姓名
  3465. input["data"] = inputData
  3466. inputMessage["input"] = input //交易输入
  3467. var inputLog string
  3468. bytesData, err := json.Marshal(inputMessage)
  3469. inputLog = string(bytesData)
  3470. fmt.Println(string(bytesData))
  3471. if err != nil {
  3472. fmt.Println(err.Error())
  3473. return err.Error(), ""
  3474. }
  3475. reader := bytes.NewReader(bytesData)
  3476. gdyb_url := beego.AppConfig.String("gdyb_url")
  3477. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3478. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  3479. //Iinit := DllDef.MustFindProc("yh_hb_call")
  3480. //var str3 string
  3481. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  3482. //fmt.Println(ret)
  3483. //fmt.Println(str3)
  3484. //
  3485. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3486. var url string
  3487. if fixmedins_code == "H15049901371" {
  3488. url = gdyb_url
  3489. } else {
  3490. url = gdyb_url + "1101"
  3491. }
  3492. if insuplc_admdvs == "421300" {
  3493. var json2 string
  3494. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3495. out, err := cmd.Output()
  3496. if err != nil {
  3497. fmt.Println("error:", err.Error())
  3498. }
  3499. fmt.Println(string(out))
  3500. return hex.EncodeToString(out), inputLog
  3501. } else {
  3502. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3503. request, err := http.NewRequest("POST", url, reader)
  3504. if err != nil {
  3505. fmt.Println(err.Error())
  3506. return err.Error(), ""
  3507. }
  3508. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3509. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3510. request.Header.Set("x-tif-signature", signature)
  3511. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3512. request.Header.Set("x-tif-nonce", nonce)
  3513. client := http.Client{}
  3514. resp, err := client.Do(request)
  3515. if err != nil {
  3516. fmt.Println(err.Error())
  3517. return err.Error(), ""
  3518. }
  3519. respBytes, err := ioutil.ReadAll(resp.Body)
  3520. if err != nil {
  3521. fmt.Println(err.Error())
  3522. return err.Error(), ""
  3523. }
  3524. fmt.Println(string(respBytes))
  3525. str := string(respBytes)
  3526. return str, inputLog
  3527. }
  3528. }
  3529. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  3530. // // 生成签名
  3531. // //tempTime := time.Unix(timestamp, 0)
  3532. // //timeFormat := tempTime.Format("20060102150405")
  3533. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3534. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3535. //
  3536. // msec := time.Now().Format("000")
  3537. // fmt.Println(utils.GetNetTime())
  3538. // // 生成输入报文
  3539. // inputMessage := make(map[string]interface{})
  3540. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  3541. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3542. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3543. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3544. // inputMessage["dev_no"] = "" // 设备编号
  3545. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  3546. // inputMessage["cainfo"] = "" // 数字签名信息
  3547. // inputMessage["signtype"] = "SM3" // 签名类型
  3548. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  3549. // inputMessage["opter_type"] = "1" // 经办人类别
  3550. // inputMessage["opter"] = doctor // 经办人
  3551. // inputMessage["opter_name"] = doctor // 经办人姓名
  3552. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  3553. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3554. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3555. // inputMessage["sign_no"] = "" //交易签到流水号
  3556. // return inputMessage
  3557. //}
  3558. func HeBeiyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  3559. // 生成签名
  3560. nonce := GetRandomString(32)
  3561. timestamp := time.Now().Unix()
  3562. signature := setSignature(timestamp, nonce, secret_key)
  3563. // 生成输入报文
  3564. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3565. input := make(map[string]interface{})
  3566. inputData := make(map[string]interface{})
  3567. inputMessage["infno"] = "5302" // 交易编码
  3568. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  3569. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  3570. input["data"] = inputData
  3571. inputMessage["input"] = input //交易输入
  3572. bytesData, err := json.Marshal(inputMessage)
  3573. fmt.Println(string(bytesData))
  3574. if err != nil {
  3575. fmt.Println(err.Error())
  3576. return err.Error()
  3577. }
  3578. reader := bytes.NewReader(bytesData)
  3579. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  3580. gdyb_url := beego.AppConfig.String("gdyb_url")
  3581. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3582. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3583. url := gdyb_url + "5302"
  3584. request, err := http.NewRequest("POST", url, reader)
  3585. if err != nil {
  3586. fmt.Println(err.Error())
  3587. return err.Error()
  3588. }
  3589. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3590. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3591. request.Header.Set("x-tif-signature", signature)
  3592. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3593. request.Header.Set("x-tif-nonce", nonce)
  3594. client := http.Client{}
  3595. resp, err := client.Do(request)
  3596. if err != nil {
  3597. fmt.Println(err.Error())
  3598. return err.Error()
  3599. }
  3600. respBytes, err := ioutil.ReadAll(resp.Body)
  3601. if err != nil {
  3602. fmt.Println(err.Error())
  3603. return err.Error()
  3604. }
  3605. str := string(respBytes)
  3606. fmt.Println(str)
  3607. return str
  3608. }