hb_service.go 146KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072
  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. //
  3179. // msg_month := time.Unix(1557042972, 0).Format("1")
  3180. // msg_year := time.Now().Format("2006")
  3181. // msg_month = time.Now().Format("01")
  3182. // day := time.Now().Format("02")
  3183. //
  3184. // hour := time.Now().Format("15")
  3185. // min := time.Now().Format("04")
  3186. // sec := time.Now().Format("05")
  3187. //
  3188. // msec := time.Now().Format("000")
  3189. //
  3190. // msg_id := fixmedins_code + msg_year + msg_month + day + hour + min + sec + msec + "0"
  3191. //
  3192. // //生成输入报文
  3193. // inputMessage := SetInputMessageThree(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, msg_id)
  3194. // input := make(map[string]interface{})
  3195. // inputData := make(map[string]interface{})
  3196. // inputMessage["infno"] = "3261" // 交易编码
  3197. // inputData["trt_year"] = year // 就诊凭证编号
  3198. // inputData["trt_month"] = month // 开始时间
  3199. // inputData["startrow"] = len(result3260.Output.Data) // 人员姓名
  3200. //
  3201. // feedetail := make([]map[string]interface{}, 0)
  3202. //
  3203. // for _, item := range result3260.Output.Data {
  3204. // feedetailInfo := make(map[string]interface{})
  3205. // feedetailInfo["certno"] = item.Certno
  3206. // feedetailInfo["mdtrt_id"] = item.MdtrtId // 就诊 ID(来自2201接口返回)
  3207. // feedetailInfo["mdtrt_setl_time"] = item.MdtrtSetlTime // 人员编号 (来自1101接口返回)
  3208. // feedetailInfo["setl_no"] = item.SetlNo // 收费批次号
  3209. // feedetailInfo["medfee_sumamt"] = item.MedfeeSumamt // 病种编码
  3210. // feedetailInfo["optins_pay_sumamt"] = item.OptinsPaySumamt // 处方号
  3211. // feedetail = append(feedetail, feedetailInfo)
  3212. // }
  3213. // inputData["detail"] = feedetail // 人员姓名
  3214. //
  3215. // input["data"] = inputData
  3216. // inputMessage["input"] = input //交易输入
  3217. // var inputLog string
  3218. // bytesData, err := json.Marshal(inputMessage)
  3219. // inputLog = string(bytesData)
  3220. // fmt.Println(string(bytesData))
  3221. // if err != nil {
  3222. // fmt.Println(err.Error())
  3223. // return err.Error(), "", ""
  3224. // }
  3225. // reader := bytes.NewReader(bytesData)
  3226. // gdyb_url := beego.AppConfig.String("gdyb_url")
  3227. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3228. //
  3229. // var url string
  3230. // if fixmedins_code == "H15049901371" {
  3231. // url = gdyb_url
  3232. // } else {
  3233. // url = gdyb_url + "3261"
  3234. // }
  3235. //
  3236. // if insuplc_admdvs == "421300" {
  3237. // var json2 string
  3238. // cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3239. // out, err := cmd.Output()
  3240. // if err != nil {
  3241. // fmt.Println("error:", err.Error())
  3242. // }
  3243. // fmt.Println(string(out))
  3244. // return hex.EncodeToString(out), inputLog, ""
  3245. // } else {
  3246. //
  3247. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3248. // request, err := http.NewRequest("POST", url, reader)
  3249. // if err != nil {
  3250. // fmt.Println(err.Error())
  3251. // return err.Error(), "", ""
  3252. // }
  3253. //
  3254. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3255. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  3256. // request.Header.Set("x-tif-signature", signature)
  3257. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3258. // request.Header.Set("x-tif-nonce", nonce)
  3259. //
  3260. // client := http.Client{}
  3261. // resp, err := client.Do(request)
  3262. // if err != nil {
  3263. // fmt.Println(err.Error())
  3264. // return err.Error(), "", ""
  3265. // }
  3266. // respBytes, err := ioutil.ReadAll(resp.Body)
  3267. // if err != nil {
  3268. // fmt.Println(err.Error())
  3269. // return err.Error(), "", ""
  3270. // }
  3271. // fmt.Println(string(respBytes))
  3272. // str := string(respBytes)
  3273. // return str, inputLog, msg_id
  3274. //
  3275. // }
  3276. //
  3277. //}
  3278. 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) {
  3279. //生成签名
  3280. nonce := GetRandomString(32)
  3281. timestamp := time.Now().Unix()
  3282. signature := setSignature(timestamp, nonce, secret_key)
  3283. //生成输入报文
  3284. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3285. input := make(map[string]interface{})
  3286. inputData := make(map[string]interface{})
  3287. inputMessage["infno"] = "3262" // 交易编码
  3288. inputData["trt_year"] = year // 就诊凭证编号
  3289. inputData["trt_month"] = "" // 开始时间
  3290. inputData["otransid"] = otransid // 开始时间
  3291. input["data"] = inputData
  3292. inputMessage["input"] = input //交易输入
  3293. var inputLog string
  3294. bytesData, err := json.Marshal(inputMessage)
  3295. inputLog = string(bytesData)
  3296. fmt.Println(string(bytesData))
  3297. if err != nil {
  3298. fmt.Println(err.Error())
  3299. return err.Error(), ""
  3300. }
  3301. reader := bytes.NewReader(bytesData)
  3302. gdyb_url := beego.AppConfig.String("gdyb_url")
  3303. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3304. var url string
  3305. if fixmedins_code == "H15049901371" {
  3306. url = gdyb_url
  3307. } else {
  3308. url = gdyb_url + "3261"
  3309. }
  3310. if insuplc_admdvs == "421300" {
  3311. var json2 string
  3312. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3313. out, err := cmd.Output()
  3314. if err != nil {
  3315. fmt.Println("error:", err.Error())
  3316. }
  3317. fmt.Println(string(out))
  3318. return hex.EncodeToString(out), inputLog
  3319. } else {
  3320. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3321. request, err := http.NewRequest("POST", url, reader)
  3322. if err != nil {
  3323. fmt.Println(err.Error())
  3324. return err.Error(), ""
  3325. }
  3326. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3327. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3328. request.Header.Set("x-tif-signature", signature)
  3329. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3330. request.Header.Set("x-tif-nonce", nonce)
  3331. client := http.Client{}
  3332. resp, err := client.Do(request)
  3333. if err != nil {
  3334. fmt.Println(err.Error())
  3335. return err.Error(), ""
  3336. }
  3337. respBytes, err := ioutil.ReadAll(resp.Body)
  3338. if err != nil {
  3339. fmt.Println(err.Error())
  3340. return err.Error(), ""
  3341. }
  3342. fmt.Println(string(respBytes))
  3343. str := string(respBytes)
  3344. return str, inputLog
  3345. }
  3346. }
  3347. // 生成签名
  3348. func setSignature2(timestamp int64, nonce string, secret_key string) string {
  3349. fmt.Println(timestamp)
  3350. fmt.Println(nonce)
  3351. fmt.Println(secret_key)
  3352. fmt.Println(strconv.FormatInt(timestamp, 10))
  3353. str := strconv.FormatInt(timestamp, 10) + secret_key + nonce + strconv.FormatInt(timestamp, 10)
  3354. fmt.Println(str)
  3355. hash := sha256.New()
  3356. //输入数据
  3357. hash.Write([]byte(str))
  3358. //计算哈希值
  3359. bytes := hash.Sum(nil)
  3360. //将字符串编码为16进制格式,返回字符串
  3361. hashCode := hex.EncodeToString(bytes)
  3362. //返回哈希值
  3363. return hashCode
  3364. }
  3365. 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) {
  3366. //生成签名
  3367. ul := uuid.New()
  3368. nonce := ul.String()
  3369. timestamp := time.Now().Unix()
  3370. //now := time.Now() //获取当前时间
  3371. //t := now.Add(time.Minute * + 8 * 60) // 获取上一分钟时间
  3372. //lastM := t.Unix() - int64(now.Second()) // 上一分钟时间-上一分钟秒数
  3373. //timestamp = lastM
  3374. signature := setSignature2(timestamp, nonce, "d6Ad0P1B3z6Dsdst0gYAFPlz8YlIvFDx")
  3375. signature = ConvertToString(signature, "gbk", "utf-8")
  3376. //生成输入报文
  3377. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3378. input := make(map[string]interface{})
  3379. inputData := make(map[string]interface{})
  3380. inputMessage["infno"] = "9001" // 交易编码
  3381. inputData["opter_no"] = admin_user_id // 就诊凭证编号
  3382. inputData["mac"] = GetMac() // 开始时间
  3383. inputData["ip"] = GetLocalIp()
  3384. input["signIn"] = inputData
  3385. inputMessage["input"] = input //交易输入
  3386. var inputLog string
  3387. bytesData, err := json.Marshal(inputMessage)
  3388. inputLog = string(bytesData)
  3389. fmt.Println(string(bytesData))
  3390. if err != nil {
  3391. fmt.Println(err.Error())
  3392. return err.Error(), ""
  3393. }
  3394. reader := bytes.NewReader(bytesData)
  3395. gdyb_url := beego.AppConfig.String("gdyb_url")
  3396. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3397. var url string
  3398. if fixmedins_code == "H15049901371" {
  3399. url = gdyb_url
  3400. } else {
  3401. url = "http://inner.getway.ylbzj.hebei.gov.cn/ebus/mbs_fsi_auth/fsi/api/signInSignOutService/signIn"
  3402. }
  3403. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3404. request, err := http.NewRequest("POST", url, reader)
  3405. if err != nil {
  3406. fmt.Println(err.Error())
  3407. return err.Error(), ""
  3408. }
  3409. //request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3410. //request.Header.Set("x-tif-paasid", "mbs_fsi_auth")
  3411. //request.Header.Set("x-tif-signature", signature)
  3412. //request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3413. //request.Header.Set("x-tif-nonce", nonce)
  3414. request.Header["Content-Type"] = []string{"application/json"}
  3415. request.Header["x-tif-paasid"] = []string{"mbs_fsi_auth"}
  3416. request.Header["x-tif-signature"] = []string{signature}
  3417. request.Header["x-tif-timestamp"] = []string{strconv.FormatInt(timestamp, 10)}
  3418. request.Header["x-tif-nonce"] = []string{nonce}
  3419. fmt.Println(string(bytesData))
  3420. fmt.Println(url)
  3421. fmt.Println(gdyb_paasid)
  3422. fmt.Println(request.Header)
  3423. client := http.Client{}
  3424. resp, err := client.Do(request)
  3425. if err != nil {
  3426. fmt.Println(err.Error())
  3427. return err.Error(), ""
  3428. }
  3429. respBytes, err := ioutil.ReadAll(resp.Body)
  3430. if err != nil {
  3431. fmt.Println(err.Error())
  3432. return err.Error(), ""
  3433. }
  3434. fmt.Println(string(respBytes))
  3435. str := string(respBytes)
  3436. return str, inputLog
  3437. }
  3438. // 人员基本信息
  3439. 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) {
  3440. //生成签名
  3441. nonce := GetRandomString(32)
  3442. timestamp := time.Now().Unix()
  3443. signature := setSignature(timestamp, nonce, secret_key)
  3444. //生成输入报文
  3445. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3446. input := make(map[string]interface{})
  3447. inputData := make(map[string]interface{})
  3448. inputMessage["infno"] = "1101" // 交易编码
  3449. if certificates == "3" {
  3450. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  3451. inputData["certno"] = certNo // 证件号码
  3452. inputData["psn_cert_type"] = "99" // 人员证件类型
  3453. } else {
  3454. if certificates == "1" {
  3455. if id_card_type == 1 {
  3456. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3457. inputData["card_sn"] = "" // 卡识别码
  3458. inputData["certno"] = certNo // 证件号码
  3459. inputData["psn_cert_type"] = "01" // 人员证件类型
  3460. } else if id_card_type == 4 {
  3461. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  3462. inputData["certno"] = certNo // 证件号码
  3463. inputData["psn_cert_type"] = "01" // 人员证件类型
  3464. } else {
  3465. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  3466. inputData["card_sn"] = "" // 卡识别码
  3467. inputData["certno"] = certNo // 证件号码
  3468. inputData["psn_cert_type"] = "01" // 人员证件类型
  3469. }
  3470. } else if certificates == "6" {
  3471. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  3472. inputData["card_sn"] = "" // 卡识别码
  3473. inputData["certno"] = certNo // 证件号码
  3474. inputData["psn_cert_type"] = "17" // 人员证件类型
  3475. }
  3476. }
  3477. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  3478. inputData["begntime"] = "" // 开始时间
  3479. inputData["psn_name"] = "" // 人员姓名
  3480. input["data"] = inputData
  3481. inputMessage["input"] = input //交易输入
  3482. var inputLog string
  3483. bytesData, err := json.Marshal(inputMessage)
  3484. inputLog = string(bytesData)
  3485. fmt.Println(string(bytesData))
  3486. if err != nil {
  3487. fmt.Println(err.Error())
  3488. return err.Error(), ""
  3489. }
  3490. reader := bytes.NewReader(bytesData)
  3491. gdyb_url := beego.AppConfig.String("gdyb_url")
  3492. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3493. //DllDef := syscall.MustLoadDLL("yh_hb_sctrl.dll")
  3494. //Iinit := DllDef.MustFindProc("yh_hb_call")
  3495. //var str3 string
  3496. //ret, _, _ := Iinit.Call(StrPtr("1101"), StrPtr(string(bytesData)), StrPtr(str3))
  3497. //fmt.Println(ret)
  3498. //fmt.Println(str3)
  3499. //
  3500. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3501. var url string
  3502. if fixmedins_code == "H15049901371" {
  3503. url = gdyb_url
  3504. } else {
  3505. url = gdyb_url + "1101"
  3506. }
  3507. if insuplc_admdvs == "421300" {
  3508. var json2 string
  3509. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  3510. out, err := cmd.Output()
  3511. if err != nil {
  3512. fmt.Println("error:", err.Error())
  3513. }
  3514. fmt.Println(string(out))
  3515. return hex.EncodeToString(out), inputLog
  3516. } else {
  3517. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  3518. request, err := http.NewRequest("POST", url, reader)
  3519. if err != nil {
  3520. fmt.Println(err.Error())
  3521. return err.Error(), ""
  3522. }
  3523. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3524. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3525. request.Header.Set("x-tif-signature", signature)
  3526. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3527. request.Header.Set("x-tif-nonce", nonce)
  3528. client := http.Client{}
  3529. resp, err := client.Do(request)
  3530. if err != nil {
  3531. fmt.Println(err.Error())
  3532. return err.Error(), ""
  3533. }
  3534. respBytes, err := ioutil.ReadAll(resp.Body)
  3535. if err != nil {
  3536. fmt.Println(err.Error())
  3537. return err.Error(), ""
  3538. }
  3539. fmt.Println(string(respBytes))
  3540. str := string(respBytes)
  3541. return str, inputLog
  3542. }
  3543. }
  3544. //func SetInputMessageFour(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) map[string]interface{} {
  3545. // // 生成签名
  3546. // //tempTime := time.Unix(timestamp, 0)
  3547. // //timeFormat := tempTime.Format("20060102150405")
  3548. // //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  3549. // //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  3550. //
  3551. // msec := time.Now().Format("000")
  3552. // fmt.Println(utils.GetNetTime())
  3553. // // 生成输入报文
  3554. // inputMessage := make(map[string]interface{})
  3555. // inputMessage["msgid"] = fixmedins_code + utils.GetNetTime() + msec + "0" // 发送方报文 ID
  3556. // inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  3557. // inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  3558. // inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  3559. // inputMessage["dev_no"] = "" // 设备编号
  3560. // inputMessage["dev_safe_info"] = "" // 设备安全信息
  3561. // inputMessage["cainfo"] = "" // 数字签名信息
  3562. // inputMessage["signtype"] = "SM3" // 签名类型
  3563. // inputMessage["infver"] = "V1.0" // 接收方系统代码
  3564. // inputMessage["opter_type"] = "1" // 经办人类别
  3565. // inputMessage["opter"] = doctor // 经办人
  3566. // inputMessage["opter_name"] = doctor // 经办人姓名
  3567. // inputMessage["inf_time"] = utils.GetNetTime() // 交易时间
  3568. // inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  3569. // inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  3570. // inputMessage["sign_no"] = "" //交易签到流水号
  3571. // return inputMessage
  3572. //}
  3573. func HeBeiyb5302(psnNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  3574. // 生成签名
  3575. nonce := GetRandomString(32)
  3576. timestamp := time.Now().Unix()
  3577. signature := setSignature(timestamp, nonce, secret_key)
  3578. // 生成输入报文
  3579. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  3580. input := make(map[string]interface{})
  3581. inputData := make(map[string]interface{})
  3582. inputMessage["infno"] = "5302" // 交易编码
  3583. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  3584. inputData["biz_appy_type"] = "03" // 人员编号 (来自1101接口返回)
  3585. input["data"] = inputData
  3586. inputMessage["input"] = input //交易输入
  3587. bytesData, err := json.Marshal(inputMessage)
  3588. fmt.Println(string(bytesData))
  3589. if err != nil {
  3590. fmt.Println(err.Error())
  3591. return err.Error()
  3592. }
  3593. reader := bytes.NewReader(bytesData)
  3594. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  3595. gdyb_url := beego.AppConfig.String("gdyb_url")
  3596. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  3597. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  3598. url := gdyb_url + "5302"
  3599. request, err := http.NewRequest("POST", url, reader)
  3600. if err != nil {
  3601. fmt.Println(err.Error())
  3602. return err.Error()
  3603. }
  3604. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  3605. request.Header.Set("x-tif-paasid", gdyb_paasid)
  3606. request.Header.Set("x-tif-signature", signature)
  3607. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  3608. request.Header.Set("x-tif-nonce", nonce)
  3609. client := http.Client{}
  3610. resp, err := client.Do(request)
  3611. if err != nil {
  3612. fmt.Println(err.Error())
  3613. return err.Error()
  3614. }
  3615. respBytes, err := ioutil.ReadAll(resp.Body)
  3616. if err != nil {
  3617. fmt.Println(err.Error())
  3618. return err.Error()
  3619. }
  3620. str := string(respBytes)
  3621. fmt.Println(str)
  3622. return str
  3623. }