gdyb_service.go 172KB

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