fj_service.go 141KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281
  1. package service
  2. import (
  3. "bytes"
  4. "gdyb/models"
  5. "github.com/astaxie/beego"
  6. "github.com/axgle/mahonia"
  7. "golang.org/x/text/encoding/simplifiedchinese"
  8. "io/ioutil"
  9. "net/http"
  10. "regexp"
  11. "strconv"
  12. "strings"
  13. "syscall"
  14. "time"
  15. "unsafe"
  16. )
  17. //import (
  18. // "os/exec"
  19. // "time"
  20. //)
  21. //
  22. import (
  23. "encoding/json"
  24. "fmt"
  25. "os/exec"
  26. )
  27. // 人员基本信息
  28. func FJyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, id_card_type int64, card_sn string, certificates int64, url string, app_id string, app_secret string, sign_key string, enc_key string, name string, id_card_no string) (string, string, string) {
  29. //生成签名
  30. nonce := GetRandomString(32)
  31. timestamp := time.Now().Unix()
  32. //生成输入报文
  33. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, "", mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  34. input := make(map[string]interface{})
  35. inputData := make(map[string]interface{})
  36. inputMessage["infno"] = "1101" // 交易编码
  37. if certificates == 3 {
  38. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  39. inputData["certno"] = certNo // 证件号码
  40. inputData["psn_cert_type"] = "99" // 人员证件类型
  41. } else {
  42. if id_card_type == 1 {
  43. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  44. inputData["card_sn"] = card_sn // 卡识别码
  45. inputData["psn_cert_type"] = "01" // 人员证件类型
  46. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  47. } else if id_card_type == 4 {
  48. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  49. inputData["card_sn"] = "" // 卡识别码
  50. inputData["certno"] = "" // 证件号码
  51. inputData["psn_cert_type"] = "" // 人员证件类型
  52. } else {
  53. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  54. inputData["card_sn"] = "" // 卡识别码
  55. inputData["psn_cert_type"] = "01" // 人员证件类型
  56. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  57. }
  58. }
  59. inputData["certno"] = id_card_no // 证件号码
  60. inputData["begntime"] = "" // 开始时间
  61. inputData["psn_name"] = name // 人员姓名
  62. input["data"] = inputData
  63. inputMessage["input"] = input //交易输入
  64. var inputLog string
  65. bytesData, err := json.Marshal(inputMessage)
  66. inputLog = string(bytesData)
  67. fmt.Println(string(bytesData))
  68. if err != nil {
  69. fmt.Println(err.Error())
  70. return err.Error(), "", ""
  71. }
  72. enc := mahonia.NewEncoder("gbk")
  73. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  74. return output, inputLog, err_msg
  75. }
  76. func FJybidcomfirm(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, id_card_type int64, card_sn string, certificates int64, url string, app_id string, app_secret string, sign_key string, enc_key string, name string) (string, string, string) {
  77. //生成签名
  78. //nonce := GetRandomString(32)
  79. //timestamp := time.Now().Unix()
  80. //生成输入报文
  81. //i nputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  82. //input := make(map[string]interface{})
  83. inputMessage := make(map[string]interface{})
  84. inputData := make(map[string]interface{})
  85. inputMessage["funid"] = "yb04.10.01.16" // 交易编码
  86. inputMessage["info"] = "" // 交易编码
  87. inputData["bkz543"] = "" // 就诊凭证类型
  88. inputData["aaz501"] = card_sn // 卡识别码
  89. inputData["bke284"] = "01" // 人员证件类型
  90. inputData["aaz500"] = certNo // 就诊凭证编号
  91. inputData["aac002"] = certNo // 证件号码
  92. inputData["aac003"] = name // 人员姓名
  93. inputMessage["data"] = inputData //交易输入
  94. var inputLog string
  95. bytesData, err := json.Marshal(inputMessage)
  96. inputLog = string(bytesData)
  97. fmt.Println(string(bytesData))
  98. if err != nil {
  99. fmt.Println(err.Error())
  100. return err.Error(), "", ""
  101. }
  102. enc := mahonia.NewEncoder("gbk")
  103. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  104. return output, inputLog, err_msg
  105. }
  106. func FJyb1101ForEleToken(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, id_card_type int64, card_sn string, certificates int64, url string, app_id string, app_secret string, sign_key string, enc_key string, token string, name string) (string, string, string) {
  107. //生成签名
  108. nonce := GetRandomString(32)
  109. timestamp := time.Now().Unix()
  110. //生成输入报文
  111. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  112. input := make(map[string]interface{})
  113. inputData := make(map[string]interface{})
  114. inputMessage["infno"] = "1101" // 交易编码
  115. if certificates == 3 {
  116. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  117. inputData["certno"] = certNo // 证件号码
  118. inputData["psn_cert_type"] = "99" // 人员证件类型
  119. inputData["psn_name"] = "" // 人员姓名
  120. } else {
  121. if id_card_type == 1 {
  122. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  123. inputData["card_sn"] = card_sn // 卡识别码
  124. inputData["psn_cert_type"] = "" // 人员证件类型
  125. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  126. inputData["psn_name"] = "" // 人员姓名
  127. } else if id_card_type == 4 {
  128. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  129. inputData["card_sn"] = "" // 卡识别码
  130. inputData["mdtrt_cert_no"] = token // 就诊凭证编号
  131. inputData["psn_cert_type"] = "01" // 人员证件类型
  132. inputData["psn_name"] = name // 人员姓名
  133. } else {
  134. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  135. inputData["card_sn"] = "" // 卡识别码
  136. inputData["psn_cert_type"] = "01" // 人员证件类型
  137. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  138. inputData["psn_name"] = "" // 人员姓名
  139. }
  140. }
  141. inputData["certno"] = certNo // 证件号码
  142. inputData["begntime"] = "" // 开始时间
  143. input["data"] = inputData
  144. inputMessage["input"] = input //交易输入
  145. var inputLog string
  146. bytesData, err := json.Marshal(inputMessage)
  147. inputLog = string(bytesData)
  148. fmt.Println(string(bytesData))
  149. if err != nil {
  150. fmt.Println(err.Error())
  151. return err.Error(), "", ""
  152. }
  153. enc := mahonia.NewEncoder("gbk")
  154. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  155. return output, inputLog, err_msg
  156. }
  157. // 门诊挂号
  158. func FJyb2201(psnNo string, insutype string, certNo string, org_name string, doctor 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, opter string, doctor_name string, url string, app_id string, app_secret string, sign_key string, enc_key string, card_number string, record_time string) (string, string, string) {
  159. // 生成签名
  160. nonce := GetRandomString(32)
  161. timestamp := time.Now().Unix()
  162. tempTime := time.Unix(timestamp, 0)
  163. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  164. // 生成输入报文
  165. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, opter, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  166. input := make(map[string]interface{})
  167. inputData := make(map[string]interface{})
  168. inputMessage["infno"] = "2201" // 交易编码
  169. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  170. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  171. inputData["begntime"] = record_time + " " + strings.Split(timeFormatOne, " ")[1] // 开始时间
  172. if id_card_type == 1 {
  173. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  174. inputData["mdtrt_cert_no"] = card_number // 就诊凭证编号
  175. } else if id_card_type == 4 {
  176. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  177. inputData["mdtrt_cert_no"] = card_number // 就诊凭证编号
  178. } else {
  179. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  180. inputData["mdtrt_cert_no"] = card_number // 就诊凭证编号
  181. }
  182. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  183. inputData["atddr_no"] = doctor_id // 医师编码
  184. inputData["dr_name"] = doctor_name // 医师姓名
  185. inputData["dept_code"] = dept_code // 科室编码
  186. inputData["dept_name"] = dept // 科室名称
  187. inputData["caty"] = "A03.06" // 科别
  188. input["data"] = inputData
  189. inputMessage["input"] = input //交易输入
  190. var requestLog string
  191. bytesData, err := json.Marshal(inputMessage)
  192. requestLog = string(bytesData)
  193. fmt.Println(string(bytesData))
  194. if err != nil {
  195. fmt.Println(err.Error())
  196. return err.Error(), "", ""
  197. }
  198. enc := mahonia.NewEncoder("gbk")
  199. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  200. return output, requestLog, err_msg
  201. }
  202. // 门诊挂号撤销
  203. func FJyb2202(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, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  204. // 生成签名
  205. nonce := GetRandomString(32)
  206. timestamp := time.Now().Unix()
  207. // 生成输入报文
  208. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  209. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  210. input := make(map[string]interface{})
  211. inputData := make(map[string]interface{})
  212. inputMessage["infno"] = "2202" // 交易编码
  213. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  214. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  215. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  216. input["data"] = inputData
  217. inputMessage["input"] = input //交易输入
  218. var requestLog string
  219. bytesData, err := json.Marshal(inputMessage)
  220. fmt.Println(string(bytesData))
  221. requestLog = string(bytesData)
  222. if err != nil {
  223. fmt.Println(err.Error())
  224. return err.Error(), "", ""
  225. }
  226. enc := mahonia.NewEncoder("gbk")
  227. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  228. return output, requestLog, err_msg
  229. }
  230. // 门诊就诊信息上传
  231. func FJyb2203(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, doctor_name string, opter string, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  232. // 生成签名
  233. nonce := GetRandomString(32)
  234. timestamp := time.Now().Unix()
  235. tempTime := time.Unix(timestamp, 0)
  236. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  237. // 生成输入报文
  238. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  239. //inputMessage := SetInputMessage(nonce, timestamp, org_name, opter, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  240. input := make(map[string]interface{})
  241. inputData := make(map[string]interface{})
  242. diseinfo := make([]map[string]interface{}, 0)
  243. inputMessage["infno"] = "2203A" // 交易编码
  244. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  245. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  246. //inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  247. inputData["begntime"] = begin_time // 开始时间
  248. //inputData["begntime"] = // 开始时间
  249. inputData["main_cond_dscr"] = "" // 主要病情描述
  250. inputData["dise_codg"] = sick_code // 病种编码
  251. inputData["dise_name"] = sick_name // 病种名称
  252. inputData["birctrl_type"] = "" // 计划生育手术类别
  253. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  254. if insuplc_admdvs == "421300" {
  255. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  256. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  257. } else if med_type == "14" {
  258. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  259. }
  260. } else {
  261. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  262. }
  263. for index, item := range config {
  264. diseinfo_sun := make(map[string]interface{})
  265. diseinfo_sun["diag_type"] = "1" // 诊断类别
  266. diseinfo_sun["diag_srt_no"] = index + 1 // 诊断排序号
  267. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  268. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  269. diseinfo_sun["diag_dept"] = department // 诊断科室
  270. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  271. diseinfo_sun["dise_dor_name"] = doctor_name // 诊断医生姓名
  272. diseinfo_sun["diag_time"] = begin_time + " " + strings.Split(timeFormatOne, " ")[1] // 诊断时间
  273. diseinfo_sun["vali_flag"] = "1" // 有效标志
  274. diseinfo = append(diseinfo, diseinfo_sun)
  275. }
  276. input["diseinfo"] = diseinfo
  277. input["mdtrtinfo"] = inputData
  278. inputMessage["input"] = input //交易输入
  279. var requestLog string
  280. bytesData, err := json.Marshal(inputMessage)
  281. fmt.Println(string(bytesData))
  282. requestLog = string(bytesData)
  283. if err != nil {
  284. fmt.Println(err.Error())
  285. return err.Error(), "", ""
  286. }
  287. enc := mahonia.NewEncoder("gbk")
  288. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  289. return output, requestLog, err_msg
  290. }
  291. // 门诊费用明细信息上传
  292. func FJyb2204(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, opter string, url string, app_id string, app_secret string, sign_key string, enc_key string, dise_code string, doctor_number string) (string, string, string) {
  293. // 生成签名
  294. nonce := GetRandomString(32)
  295. timestamp := time.Now().Unix()
  296. var customs []*Custom
  297. for _, item := range hisPrescription {
  298. tm := time.Unix(item.PreTime, 0)
  299. if item.Type == 1 { //药品
  300. for _, subItem := range item.HisDoctorAdviceInfo {
  301. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  302. //var randNum int
  303. //randNum = rand.Intn(10000) + 1000
  304. cus := &Custom{
  305. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  306. Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  307. FeedetlSn: subItem.FeedetlSn,
  308. Price: fmt.Sprintf("%.2f", subItem.Price),
  309. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  310. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  311. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  312. Unit: subItem.PrescribingNumberUnit,
  313. }
  314. customs = append(customs, cus)
  315. }
  316. }
  317. }
  318. if item.Type == 2 { //项目
  319. for _, subItem := range item.HisPrescriptionProject {
  320. //var randNum int
  321. //randNum = rand.Intn(10000) + 1000
  322. if subItem.Type == 2 {
  323. if len(subItem.HisProject.MedicalCode) > 0 {
  324. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  325. cus := &Custom{
  326. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cnt),
  327. Cut: fmt.Sprintf("%.2f", cnt),
  328. FeedetlSn: subItem.FeedetlSn,
  329. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  330. MedListCodg: subItem.HisProject.MedicalCode,
  331. HospApprFlag: -1,
  332. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  333. Unit: subItem.HisProject.Unit,
  334. }
  335. customs = append(customs, cus)
  336. }
  337. } else if subItem.Type == 3 {
  338. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  339. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  340. cus := &Custom{
  341. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*cnt),
  342. Cut: fmt.Sprintf("%.2f", cnt),
  343. FeedetlSn: subItem.FeedetlSn,
  344. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  345. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  346. HospApprFlag: -1,
  347. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  348. Unit: subItem.GoodInfo.PackingUnit,
  349. }
  350. customs = append(customs, cus)
  351. }
  352. }
  353. }
  354. }
  355. for _, subItem := range item.HisAdditionalCharge {
  356. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  357. cus := &Custom{
  358. DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  359. Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  360. FeedetlSn: subItem.FeedetlSn,
  361. Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  362. MedListCodg: subItem.XtHisAddtionConfig.Code,
  363. HospApprFlag: -1,
  364. }
  365. customs = append(customs, cus)
  366. }
  367. }
  368. }
  369. // 生成输入报文
  370. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  371. //inputMessage := SetInputMessage(nonce, timestamp, org_name, opter, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  372. input := make(map[string]interface{})
  373. feedetail := make([]map[string]interface{}, 0)
  374. inputMessage["infno"] = "2204" // 交易编码
  375. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  376. for _, item := range customs {
  377. feedetailInfo := make(map[string]interface{})
  378. subfeedetail := make(map[string]interface{})
  379. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  380. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  381. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  382. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  383. feedetailInfo["dise_codg"] = dise_code // 病种编码
  384. feedetailInfo["rxno"] = "" // 处方号
  385. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  386. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  387. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  388. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  389. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  390. feedetailInfo["cnt"] = item.Cut // 数量
  391. feedetailInfo["pric"] = item.Price // 单价
  392. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  393. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  394. feedetailInfo["prd_days"] = "0" // 周期天数
  395. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  396. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  397. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  398. feedetailInfo["bilg_dr_codg"] = doctor_number // 开单医生编码
  399. feedetailInfo["bilg_dr_name"] = doctor // 开单医师姓名
  400. feedetailInfo["acord_dept_codg"] = "" // 受单科室编码
  401. feedetailInfo["acord_dept_name"] = "" // 受单科室名称
  402. feedetailInfo["orders_dr_code"] = "" // 受单医生编码
  403. feedetailInfo["orders_dr_name"] = "" // 受单医生姓名
  404. subfeedetail["prcunt"] = item.Unit
  405. feedetailInfo["exp_content"] = subfeedetail // 中药使用方式
  406. if balance_accounts_type == "8" {
  407. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  408. } else {
  409. if item.HospApprFlag != -1 {
  410. if item.HospApprFlag == 1 {
  411. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  412. } else if item.HospApprFlag == 2 {
  413. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  414. } else if item.HospApprFlag == 3 {
  415. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  416. } else {
  417. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  418. }
  419. } else {
  420. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  421. }
  422. }
  423. feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  424. feedetailInfo["etip_flag"] = "" // 外检标志
  425. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  426. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  427. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  428. feedetail = append(feedetail, feedetailInfo)
  429. }
  430. input["feedetail"] = feedetail
  431. inputMessage["input"] = input //交易输入
  432. var requestLog string
  433. bytesData, err := json.Marshal(inputMessage)
  434. requestLog = string(bytesData)
  435. if err != nil {
  436. fmt.Println(err.Error())
  437. return "", "", ""
  438. }
  439. enc := mahonia.NewEncoder("gbk")
  440. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  441. return output, requestLog, err_msg
  442. }
  443. // 门诊费用明细信息撤销
  444. func FJyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  445. // 生成签名
  446. nonce := GetRandomString(32)
  447. timestamp := time.Now().Unix()
  448. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  449. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  450. input := make(map[string]interface{})
  451. inputData := make(map[string]interface{})
  452. inputMessage["infno"] = "2205" // 交易编码
  453. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  454. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  455. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  456. input["data"] = inputData
  457. inputMessage["input"] = input //交易输入
  458. bytesData, err := json.Marshal(inputMessage)
  459. fmt.Println(string(bytesData))
  460. var requestLog string
  461. requestLog = string(bytesData)
  462. if err != nil {
  463. fmt.Println(err.Error())
  464. return err.Error(), "", ""
  465. }
  466. enc := mahonia.NewEncoder("gbk")
  467. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  468. return output, requestLog, err_msg
  469. }
  470. // 门诊预结算
  471. func FJyb2206(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, url string, app_id string, app_secret string, sign_key string, enc_key string, acct_used_flag string) (string, string, string) {
  472. // 生成签名
  473. nonce := GetRandomString(32)
  474. timestamp := time.Now().Unix()
  475. // 生成输入报文
  476. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  477. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  478. input := make(map[string]interface{})
  479. inputData := make(map[string]interface{})
  480. inputMessage["infno"] = "2206" // 交易编码
  481. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  482. if certificates == 3 {
  483. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  484. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  485. } else {
  486. if id_card_type == 1 {
  487. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  488. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  489. } else {
  490. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  491. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  492. }
  493. }
  494. if med_type == "1111" || med_type == "1112" {
  495. med_type = "11"
  496. }
  497. if insuplc_admdvs == "421300" {
  498. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  499. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  500. } else if med_type == "14" {
  501. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  502. }
  503. } else {
  504. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  505. }
  506. inputData["medfee_sumamt"] = total // 医疗费总额
  507. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  508. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  509. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  510. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  511. inputData["insutype"] = insutype // 险种类型
  512. inputData["invono"] = "" // 发票号
  513. inputData2 := make(map[string]interface{})
  514. inputData2["trum_flag"] = "0"
  515. inputData2["rel_ttp_flag"] = ""
  516. inputData2["otp_er_refl_flag"] = ""
  517. inputData["exp_content"] = inputData2 // 发票号
  518. input["data"] = inputData
  519. inputMessage["input"] = input //交易输入
  520. var requestLog string
  521. bytesData, err := json.Marshal(inputMessage)
  522. requestLog = string(bytesData)
  523. fmt.Println(string(bytesData))
  524. if err != nil {
  525. fmt.Println(err.Error())
  526. return err.Error(), "", ""
  527. }
  528. enc := mahonia.NewEncoder("gbk")
  529. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  530. return output, requestLog, err_msg
  531. }
  532. func FJyb2206ForToken(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, url string, app_id string, app_secret string, sign_key string, enc_key string, acct_used_flag string) (string, string, string) {
  533. // 生成签名
  534. nonce := GetRandomString(32)
  535. timestamp := time.Now().Unix()
  536. // 生成输入报文
  537. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  538. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  539. input := make(map[string]interface{})
  540. inputData := make(map[string]interface{})
  541. inputMessage["infno"] = "2206" // 交易编码
  542. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  543. if certificates == 3 {
  544. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  545. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  546. } else {
  547. if id_card_type == 1 {
  548. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  549. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  550. } else if id_card_type == 4 {
  551. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  552. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  553. } else {
  554. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  555. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  556. }
  557. }
  558. if med_type == "1111" || med_type == "1112" {
  559. med_type = "11"
  560. }
  561. if insuplc_admdvs == "421300" {
  562. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  563. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  564. } else if med_type == "14" {
  565. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  566. }
  567. } else {
  568. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  569. }
  570. inputData["medfee_sumamt"] = total // 医疗费总额
  571. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  572. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  573. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  574. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  575. inputData["insutype"] = insutype // 险种类型
  576. inputData["invono"] = "" // 发票号
  577. input["data"] = inputData
  578. inputMessage["input"] = input //交易输入
  579. var requestLog string
  580. bytesData, err := json.Marshal(inputMessage)
  581. requestLog = string(bytesData)
  582. fmt.Println(string(bytesData))
  583. if err != nil {
  584. fmt.Println(err.Error())
  585. return err.Error(), "", ""
  586. }
  587. enc := mahonia.NewEncoder("gbk")
  588. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  589. return output, requestLog, err_msg
  590. }
  591. // 门诊结算
  592. func FJyb2207(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, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  593. // 生成签名
  594. nonce := GetRandomString(32)
  595. timestamp := time.Now().Unix()
  596. // 生成输入报文
  597. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  598. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  599. input := make(map[string]interface{})
  600. inputData := make(map[string]interface{})
  601. inputMessage["infno"] = "2207" // 交易编码
  602. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  603. if certificates == 3 {
  604. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  605. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  606. } else {
  607. if id_card_type == 1 {
  608. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  609. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  610. } else if id_card_type == 4 {
  611. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  612. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  613. } else {
  614. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  615. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  616. }
  617. }
  618. if med_type == "1111" || med_type == "1112" {
  619. med_type = "11"
  620. }
  621. if insuplc_admdvs == "421300" {
  622. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  623. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  624. } else if med_type == "14" {
  625. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  626. }
  627. } else {
  628. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  629. }
  630. inputData["medfee_sumamt"] = total // 医疗费总额
  631. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  632. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  633. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  634. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  635. inputData["insutype"] = insutype // 险种类型
  636. inputData["invono"] = "" // 发票号
  637. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  638. inputData["overlmt_selfpay"] = overlmt_selfpay //
  639. inputData["preselfpay_amt"] = preselfpay_amt //
  640. inputData["inscp_scp_amt"] = inscp_scp_amt //
  641. inputData2 := make(map[string]interface{})
  642. inputData2["trum_flag"] = "0"
  643. inputData2["rel_ttp_flag"] = ""
  644. inputData2["otp_er_refl_flag"] = ""
  645. inputData["exp_content"] = inputData2 // 发票号
  646. input["data"] = inputData
  647. inputMessage["input"] = input //交易输入
  648. bytesData, err := json.Marshal(inputMessage)
  649. fmt.Println(string(bytesData))
  650. if err != nil {
  651. fmt.Println(err.Error())
  652. return err.Error(), "", ""
  653. }
  654. var requestLog string
  655. requestLog = string(bytesData)
  656. enc := mahonia.NewEncoder("gbk")
  657. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  658. return output, requestLog, err_msg
  659. }
  660. func FJyb2207ForToken(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, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  661. // 生成签名
  662. nonce := GetRandomString(32)
  663. timestamp := time.Now().Unix()
  664. // 生成输入报文
  665. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  666. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  667. input := make(map[string]interface{})
  668. inputData := make(map[string]interface{})
  669. inputMessage["infno"] = "2207" // 交易编码
  670. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  671. if certificates == 3 {
  672. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  673. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  674. } else {
  675. if id_card_type == 1 {
  676. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  677. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  678. } else if id_card_type == 4 {
  679. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  680. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  681. } else {
  682. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  683. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  684. }
  685. }
  686. if med_type == "1111" || med_type == "1112" {
  687. med_type = "11"
  688. }
  689. if insuplc_admdvs == "421300" {
  690. if med_type == "11" || med_type == "1111" || med_type == "1112" {
  691. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  692. } else if med_type == "14" {
  693. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  694. }
  695. } else {
  696. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  697. }
  698. inputData["medfee_sumamt"] = total // 医疗费总额
  699. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  700. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  701. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  702. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  703. inputData["insutype"] = insutype // 险种类型
  704. inputData["invono"] = "" // 发票号
  705. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  706. inputData["overlmt_selfpay"] = overlmt_selfpay //
  707. inputData["preselfpay_amt"] = preselfpay_amt //
  708. inputData["inscp_scp_amt"] = inscp_scp_amt //
  709. input["data"] = inputData
  710. inputMessage["input"] = input //交易输入
  711. bytesData, err := json.Marshal(inputMessage)
  712. fmt.Println(string(bytesData))
  713. if err != nil {
  714. fmt.Println(err.Error())
  715. return err.Error(), "", ""
  716. }
  717. var requestLog string
  718. requestLog = string(bytesData)
  719. enc := mahonia.NewEncoder("gbk")
  720. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  721. return output, requestLog, err_msg
  722. }
  723. // 门诊结算撤销
  724. func FJyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  725. // 生成签名
  726. nonce := GetRandomString(32)
  727. timestamp := time.Now().Unix()
  728. // 生成输入报文
  729. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  730. //inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  731. input := make(map[string]interface{})
  732. inputData := make(map[string]interface{})
  733. inputMessage["infno"] = "2208" // 交易编码
  734. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  735. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  736. inputData["setl_id"] = setlId // 结算 ID
  737. input["data"] = inputData
  738. inputMessage["input"] = input //交易输入
  739. bytesData, err := json.Marshal(inputMessage)
  740. fmt.Println(string(bytesData))
  741. if err != nil {
  742. fmt.Println(err.Error())
  743. return err.Error(), "", ""
  744. }
  745. var requestLog string
  746. requestLog = string(bytesData)
  747. enc := mahonia.NewEncoder("gbk")
  748. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  749. return output, requestLog, err_msg
  750. }
  751. func FJyb5203(baseParams models.BaseParams, businessParams models.BusinessParams, url string, app_id string, app_secret string, sign_key string, enc_key string) (string, string, string) {
  752. // 生成签名
  753. nonce := GetRandomString(32)
  754. timestamp := time.Now().Unix()
  755. // 生成输入报文
  756. inputMessage := SetFjInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, url, app_id, app_secret, sign_key, enc_key)
  757. input := make(map[string]interface{})
  758. inputData := make(map[string]interface{})
  759. inputMessage["infno"] = "5203" // 交易编码
  760. inputData["psn_no"] = businessParams.PsnNo
  761. inputData["setl_id"] = businessParams.SetlId
  762. inputData["mdtrt_id"] = businessParams.MdtrtId
  763. //inputData["med_type"] = med_type
  764. input["data"] = inputData
  765. inputMessage["input"] = input //交易输入
  766. bytesData, err := json.Marshal(inputMessage)
  767. if err != nil {
  768. fmt.Println(err.Error())
  769. return err.Error(), "", ""
  770. }
  771. var requestLog string
  772. requestLog = string(bytesData)
  773. enc := mahonia.NewEncoder("gbk")
  774. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  775. return output, requestLog, err_msg
  776. }
  777. // 确认订单
  778. func FJyb6201(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, order models.HisOrder, url string, app_id string, app_secret string, sign_key string, enc_key string) string {
  779. // 生成签名
  780. nonce := GetRandomString(32)
  781. timestamp := time.Now().Unix()
  782. signature := setSignature(timestamp, nonce, secret_key)
  783. // 生成输入报文
  784. inputMessage := SetFjInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, url, app_id, app_secret, sign_key, enc_key)
  785. input := make(map[string]interface{})
  786. inputData := make(map[string]interface{})
  787. inputMessage["infno"] = "6201" // 交易编码
  788. inputData["mdtrt_id"] = order.MdtrtId
  789. inputData["chrg_bchno"] = order.Number
  790. inputData["psn_no"] = order.PsnNo
  791. inputData["psn_name"] = order.PsnName
  792. inputData["psn_cert_type"] = order.PsnCertType
  793. inputData["certno"] = order.Certno
  794. inputData["insutype"] = order.Insutype
  795. inputData["med_type"] = order.MedType
  796. inputData["medfee_sumamt"] = order.MedfeeSumamt
  797. inputData["fulamt_ownpay_amt"] = order.FulamtOwnpayAmt
  798. inputData["overlmt_selfpay"] = order.OverlmtSelfPay
  799. inputData["preselfpay_amt"] = order.PreselfpayAmt
  800. inputData["inscp_scp_amt"] = order.InscpScpAmt
  801. inputData["act_pay_dedc"] = order.ActPayDedc
  802. inputData["hifp_pay"] = order.HifpPay
  803. inputData["pool_prop_selfpay"] = order.PoolPropSelfpay
  804. inputData["cvlserv_pay"] = order.CvlservPay
  805. inputData["hifes_pay"] = order.HifesPay
  806. inputData["hifmi_pay"] = order.HifmiPay
  807. inputData["hifob_pay"] = order.HifobPay
  808. inputData["maf_pay"] = order.MafPay
  809. inputData["oth_pay"] = order.OthPay
  810. inputData["fund_pay_sumamt"] = order.FundPaySumamt
  811. inputData["psn_part_amt"] = order.PsnPartAmt
  812. inputData["acct_pay"] = order.AcctPay
  813. inputData["psn_cash_pay"] = order.PsnCashPay
  814. inputData["hosp_part_amt"] = order.HospPartAmt
  815. inputData["acct_mulaid_pay"] = order.AcctMulaidPay
  816. input["data"] = inputData
  817. inputMessage["input"] = input //交易输入
  818. bytesData, err := json.Marshal(inputMessage)
  819. fmt.Println(string(bytesData))
  820. if err != nil {
  821. fmt.Println(err.Error())
  822. return err.Error()
  823. }
  824. reader := bytes.NewReader(bytesData)
  825. gdyb_url := beego.AppConfig.String("gdyb_url")
  826. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  827. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  828. url = gdyb_url + "6201"
  829. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/6201"
  830. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/6201"
  831. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  832. request, err := http.NewRequest("POST", url, reader)
  833. if err != nil {
  834. fmt.Println(err.Error())
  835. return err.Error()
  836. }
  837. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  838. request.Header.Set("x-tif-paasid", gdyb_paasid)
  839. request.Header.Set("x-tif-signature", signature)
  840. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  841. request.Header.Set("x-tif-nonce", nonce)
  842. client := http.Client{}
  843. resp, err := client.Do(request)
  844. if err != nil {
  845. fmt.Println(err.Error())
  846. return err.Error()
  847. }
  848. respBytes, err := ioutil.ReadAll(resp.Body)
  849. if err != nil {
  850. fmt.Println(err.Error())
  851. return err.Error()
  852. }
  853. str := string(respBytes)
  854. fmt.Println(str)
  855. return str
  856. }
  857. // 医药机构费用结算对总账 func Gdyb3201( org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  858. func FJyb3201(baseParams models.BaseParams, businessParams models.BusinessParams, med string, fund string) (string, string, string) {
  859. fmt.Println(baseParams)
  860. fmt.Println(businessParams)
  861. // 生成签名
  862. nonce := GetRandomString(32)
  863. timestamp := time.Now().Unix()
  864. // 生成输入报文
  865. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  866. input := make(map[string]interface{})
  867. inputData := make(map[string]interface{})
  868. inputMessage["infno"] = "3201" // 交易编码
  869. inputMessage["url"] = baseParams.RequestUrl // 险种
  870. inputMessage["app_id"] = baseParams.AppID // 险种
  871. inputMessage["app_secret"] = baseParams.AppSecret // 险种
  872. inputMessage["sign_key"] = baseParams.SignKey // 险种
  873. inputMessage["enc_key"] = baseParams.EncKey // 险种
  874. inputData["insutype"] = businessParams.Insutype // 险种
  875. fmt.Println(businessParams.ClrType)
  876. if len(businessParams.ClrType) > 0 {
  877. inputData["clr_type"] = "9903"
  878. } else {
  879. inputData["clr_type"] = "11"
  880. }
  881. // 就诊 ID(来自2201接口返回)
  882. inputData["setl_optins"] = "350581" // 结算经办机构
  883. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  884. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  885. inputData["medfee_sumamt"] = med //医疗费总额
  886. inputData["fund_pay_sumamt"] = fund //基金支付总额
  887. inputData["acct_pay"] = businessParams.AcctPay //个人账户支付金额
  888. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  889. inputData["refd_setl_flag"] = "0" // 就诊 ID(来自2201接口返回)
  890. input["data"] = inputData
  891. inputMessage["input"] = input //交易输入
  892. bytesData, err := json.Marshal(inputMessage)
  893. fmt.Println(string(bytesData))
  894. if err != nil {
  895. fmt.Println(err.Error())
  896. return err.Error(), "", ""
  897. }
  898. var requestLog string
  899. requestLog = string(bytesData)
  900. enc := mahonia.NewEncoder("gbk")
  901. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  902. return output, requestLog, err_msg
  903. }
  904. // 文件上传
  905. // 文件上传
  906. func FJyb9101(baseParams models.BaseParams, file_name string, file_byte []byte) string {
  907. // 生成签名
  908. nonce := GetRandomString(32)
  909. timestamp := time.Now().Unix()
  910. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  911. buf := new(bytes.Buffer)
  912. buf.ReadFrom(strings.NewReader(string(file_byte)))
  913. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  914. input := make(map[string]interface{})
  915. inputData := make(map[string]interface{})
  916. inputMessage["infno"] = "9101" // 交易编码
  917. inputData["file_name"] = file_name //文件名
  918. inputData["in"] = file_byte //文件数据
  919. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  920. input["fsUploadIn"] = inputData
  921. inputMessage["input"] = input //交易输入
  922. bytesData, err := json.Marshal(inputMessage)
  923. fmt.Println(string(bytesData))
  924. if err != nil {
  925. fmt.Println(err.Error())
  926. return err.Error()
  927. }
  928. reader := bytes.NewReader(bytesData)
  929. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9101"
  930. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  931. gdyb_url := beego.AppConfig.String("gdyb_url")
  932. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  933. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  934. url := gdyb_url + "9101"
  935. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9101"
  936. request, err := http.NewRequest("POST", url, reader)
  937. if err != nil {
  938. fmt.Println(err.Error())
  939. return err.Error()
  940. }
  941. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  942. request.Header.Set("x-tif-paasid", gdyb_paasid)
  943. request.Header.Set("x-tif-signature", signature)
  944. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  945. request.Header.Set("x-tif-nonce", nonce)
  946. client := http.Client{}
  947. resp, err := client.Do(request)
  948. if err != nil {
  949. fmt.Println(err.Error())
  950. return err.Error()
  951. }
  952. respBytes, err := ioutil.ReadAll(resp.Body)
  953. if err != nil {
  954. fmt.Println(err.Error())
  955. return err.Error()
  956. }
  957. str := string(respBytes)
  958. fmt.Println(str)
  959. return str
  960. }
  961. func FJyb9102(baseParams models.BaseParams, file_name string, file_qury_no string) string {
  962. // 生成签名
  963. nonce := GetRandomString(32)
  964. timestamp := time.Now().Unix()
  965. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  966. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  967. input := make(map[string]interface{})
  968. inputData := make(map[string]interface{})
  969. inputMessage["infno"] = "9102" // 交易编码
  970. inputData["file_name"] = file_name //文件名
  971. inputData["file_qury_no"] = file_qury_no //文件数据
  972. inputData["fixmedins_code"] = baseParams.FixmedinsCode //编码
  973. input["fsDownloadIn"] = inputData
  974. inputMessage["input"] = input //交易输入
  975. bytesData, err := json.Marshal(inputMessage)
  976. fmt.Println(string(bytesData))
  977. if err != nil {
  978. fmt.Println(err.Error())
  979. return err.Error()
  980. }
  981. reader := bytes.NewReader(bytesData)
  982. gdyb_url := beego.AppConfig.String("gdyb_url")
  983. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  984. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  985. url := gdyb_url + "9102"
  986. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/9102"
  987. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  988. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/9102"
  989. request, err := http.NewRequest("POST", url, reader)
  990. if err != nil {
  991. fmt.Println(err.Error())
  992. return err.Error()
  993. }
  994. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  995. request.Header.Set("x-tif-paasid", gdyb_paasid)
  996. request.Header.Set("x-tif-signature", signature)
  997. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  998. request.Header.Set("x-tif-nonce", nonce)
  999. client := http.Client{}
  1000. resp, err := client.Do(request)
  1001. if err != nil {
  1002. fmt.Println(err.Error())
  1003. return err.Error()
  1004. }
  1005. respBytes, err := ioutil.ReadAll(resp.Body)
  1006. if err != nil {
  1007. fmt.Println(err.Error())
  1008. return err.Error()
  1009. }
  1010. str := string(respBytes)
  1011. fmt.Println(str)
  1012. return str
  1013. }
  1014. func FJyb3202(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1015. // 生成签名
  1016. nonce := GetRandomString(32)
  1017. timestamp := time.Now().Unix()
  1018. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1019. // 生成输入报文
  1020. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1021. input := make(map[string]interface{})
  1022. inputData := make(map[string]interface{})
  1023. inputMessage["infno"] = "3202" // 交易编码
  1024. inputData["file_qury_no"] = businessParams.FileQuryNo // 险种
  1025. inputData["setl_optins"] = baseParams.InsuplcAdmdvs // 结算经办机构
  1026. inputData["stmt_begndate"] = businessParams.StmtBegndate // 对帐开始时间
  1027. inputData["stmt_enddate"] = businessParams.StmtEnddate //对帐结束时间
  1028. inputData["medfee_sumamt"] = businessParams.MedfeeSumamt //医疗费总额
  1029. inputData["fund_pay_sumamt"] = businessParams.FundPaySumamt //基金支付总额
  1030. inputData["cash_payamt"] = businessParams.CashPayamt //现金支付金额
  1031. inputData["fixmedins_setl_cnt"] = businessParams.FixmedinsSetlCnt //定点医药机构结算笔数
  1032. inputData["clr_type"] = "11" // 就诊 ID(来自2201接口返回)
  1033. inputData["refd_setl_flag"] = 1 // 就诊 ID(来自2201接口返回)
  1034. input["data"] = inputData
  1035. inputMessage["input"] = input //交易输入
  1036. bytesData, err := json.Marshal(inputMessage)
  1037. fmt.Println(string(bytesData))
  1038. if err != nil {
  1039. fmt.Println(err.Error())
  1040. return err.Error()
  1041. }
  1042. reader := bytes.NewReader(bytesData)
  1043. gdyb_url := beego.AppConfig.String("gdyb_url")
  1044. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1045. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1046. url := gdyb_url + "3202"
  1047. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3202"
  1048. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1049. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3202"
  1050. request, err := http.NewRequest("POST", url, reader)
  1051. if err != nil {
  1052. fmt.Println(err.Error())
  1053. return err.Error()
  1054. }
  1055. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1056. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1057. request.Header.Set("x-tif-signature", signature)
  1058. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1059. request.Header.Set("x-tif-nonce", nonce)
  1060. client := http.Client{}
  1061. resp, err := client.Do(request)
  1062. if err != nil {
  1063. fmt.Println(err.Error())
  1064. return err.Error()
  1065. }
  1066. respBytes, err := ioutil.ReadAll(resp.Body)
  1067. if err != nil {
  1068. fmt.Println(err.Error())
  1069. return err.Error()
  1070. }
  1071. str := string(respBytes)
  1072. fmt.Println(str)
  1073. return str
  1074. }
  1075. //func Hbyb2001(baseParams models.BaseParams, psn_no string, insutype string, med_type string) string {
  1076. // // 生成签名
  1077. // nonce := GetRandomString(32)
  1078. // timestamp := time.Now().Unix()
  1079. // signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1080. //
  1081. // // 生成输入报文
  1082. // inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1083. // input := make(map[string]interface{})
  1084. // inputData := make(map[string]interface{})
  1085. // inputMessage["infno"] = "2001" // 交易编码
  1086. // inputData["psn_no"] = psn_no
  1087. // inputData["insutype"] = insutype
  1088. // inputData["med_type"] = med_type
  1089. // inputData["begntime"] = "2021-01-01 00:00:00"
  1090. // input["data"] = inputData
  1091. // inputMessage["input"] = input //交易输入
  1092. // bytesData, err := json.Marshal(inputMessage)
  1093. // fmt.Println(string(bytesData))
  1094. // if err != nil {
  1095. // fmt.Println(err.Error())
  1096. // return err.Error()
  1097. // }
  1098. // reader := bytes.NewReader(bytesData)
  1099. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1100. //
  1101. // gdyb_url := beego.AppConfig.String("gdyb_url")
  1102. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1103. //
  1104. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1105. // url := gdyb_url + "2001"
  1106. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1107. // request, err := http.NewRequest("POST", url, reader)
  1108. // if err != nil {
  1109. // fmt.Println(err.Error())
  1110. // return err.Error()
  1111. // }
  1112. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1113. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  1114. // request.Header.Set("x-tif-signature", signature)
  1115. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1116. // request.Header.Set("x-tif-nonce", nonce)
  1117. // client := http.Client{}
  1118. // resp, err := client.Do(request)
  1119. // if err != nil {
  1120. // fmt.Println(err.Error())
  1121. // return err.Error()
  1122. // }
  1123. // respBytes, err := ioutil.ReadAll(resp.Body)
  1124. // if err != nil {
  1125. // fmt.Println(err.Error())
  1126. // return err.Error()
  1127. // }
  1128. // str := string(respBytes)
  1129. // fmt.Println(str)
  1130. // return str
  1131. //}
  1132. func FJyb3301(baseParams *models.BaseParams, name string, codg string, list_type_code string, start_time string, ent_time string, list_type string) string {
  1133. // 生成签名
  1134. nonce := GetRandomString(32)
  1135. timestamp := time.Now().Unix()
  1136. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1137. // 生成输入报文
  1138. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1139. input := make(map[string]interface{})
  1140. inputData := make(map[string]interface{})
  1141. inputMessage["infno"] = "3301" // 交易编码
  1142. inputData["fixmedins_hilist_id"] = codg
  1143. inputData["fixmedins_hilist_name"] = name
  1144. inputData["list_type"] = list_type
  1145. inputData["med_list_codg"] = codg
  1146. inputData["begndate"] = start_time
  1147. inputData["enddate"] = ent_time
  1148. inputData["aprvno"] = ""
  1149. inputData["dosform"] = ""
  1150. inputData["exct_cont"] = ""
  1151. inputData["item_cont"] = ""
  1152. inputData["prcunt"] = ""
  1153. inputData["spec"] = ""
  1154. inputData["pacspec"] = ""
  1155. inputData["memo"] = ""
  1156. input["data"] = inputData
  1157. inputMessage["input"] = input //交易输入
  1158. bytesData, err := json.Marshal(inputMessage)
  1159. fmt.Println(string(bytesData))
  1160. if err != nil {
  1161. fmt.Println(err.Error())
  1162. return err.Error()
  1163. }
  1164. reader := bytes.NewReader(bytesData)
  1165. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3301"
  1166. //
  1167. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3301"
  1168. gdyb_url := beego.AppConfig.String("gdyb_url")
  1169. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1170. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1171. url := gdyb_url + "3301"
  1172. request, err := http.NewRequest("POST", url, reader)
  1173. if err != nil {
  1174. fmt.Println(err.Error())
  1175. return err.Error()
  1176. }
  1177. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1178. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1179. request.Header.Set("x-tif-signature", signature)
  1180. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1181. request.Header.Set("x-tif-nonce", nonce)
  1182. client := http.Client{}
  1183. resp, err := client.Do(request)
  1184. if err != nil {
  1185. fmt.Println(err.Error())
  1186. return err.Error()
  1187. }
  1188. respBytes, err := ioutil.ReadAll(resp.Body)
  1189. if err != nil {
  1190. fmt.Println(err.Error())
  1191. return err.Error()
  1192. }
  1193. str := string(respBytes)
  1194. fmt.Println(str)
  1195. return str
  1196. }
  1197. func FJyb3302(baseParams *models.BaseParams, name string, codg string, list_type_code string) string {
  1198. // 生成签名
  1199. nonce := GetRandomString(32)
  1200. timestamp := time.Now().Unix()
  1201. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1202. // 生成输入报文
  1203. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1204. input := make(map[string]interface{})
  1205. inputData := make(map[string]interface{})
  1206. inputMessage["infno"] = "3302" // 交易编码
  1207. inputData["fixmedins_code"] = baseParams.FixmedinsCode
  1208. inputData["fixmedins_hilist_id"] = codg
  1209. inputData["list_type"] = list_type_code
  1210. inputData["med_list_codg"] = codg
  1211. input["data"] = inputData
  1212. inputMessage["input"] = input //交易输入
  1213. bytesData, err := json.Marshal(inputMessage)
  1214. fmt.Println(string(bytesData))
  1215. if err != nil {
  1216. fmt.Println(err.Error())
  1217. return err.Error()
  1218. }
  1219. reader := bytes.NewReader(bytesData)
  1220. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/3302"
  1221. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/3302"
  1222. gdyb_url := beego.AppConfig.String("gdyb_url")
  1223. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1224. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1225. url := gdyb_url + "3302"
  1226. request, err := http.NewRequest("POST", url, reader)
  1227. if err != nil {
  1228. fmt.Println(err.Error())
  1229. return err.Error()
  1230. }
  1231. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1232. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1233. request.Header.Set("x-tif-signature", signature)
  1234. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1235. request.Header.Set("x-tif-nonce", nonce)
  1236. client := http.Client{}
  1237. resp, err := client.Do(request)
  1238. if err != nil {
  1239. fmt.Println(err.Error())
  1240. return err.Error()
  1241. }
  1242. respBytes, err := ioutil.ReadAll(resp.Body)
  1243. if err != nil {
  1244. fmt.Println(err.Error())
  1245. return err.Error()
  1246. }
  1247. str := string(respBytes)
  1248. fmt.Println(str)
  1249. return str
  1250. }
  1251. func FJyb2505(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 {
  1252. // 生成签名
  1253. nonce := GetRandomString(32)
  1254. timestamp := time.Now().Unix()
  1255. signature := setSignature(timestamp, nonce, secret_key)
  1256. // 生成输入报文
  1257. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1258. input := make(map[string]interface{})
  1259. inputData := make(map[string]interface{})
  1260. inputMessage["infno"] = "2505"
  1261. inputData["psn_no"] = psnNo
  1262. inputData["biz_appy_type"] = "03"
  1263. inputData["begndate"] = start_time
  1264. inputData["enddate"] = end_time
  1265. inputData["fixmedins_code"] = fixmedins_code
  1266. inputData["fixmedins_name"] = org_name
  1267. inputData["tel"] = ""
  1268. inputData["addr"] = ""
  1269. inputData["agnter_name"] = ""
  1270. inputData["agnter_cert_type"] = ""
  1271. inputData["agnter_certno"] = ""
  1272. inputData["agnter_tel"] = ""
  1273. inputData["agnter_addr"] = ""
  1274. inputData["agnter_rlts"] = ""
  1275. inputData["fix_srt_no"] = ""
  1276. inputData["memo"] = ""
  1277. input["data"] = inputData
  1278. inputMessage["input"] = input //交易输入
  1279. bytesData, err := json.Marshal(inputMessage)
  1280. if err != nil {
  1281. fmt.Println(err.Error())
  1282. return err.Error()
  1283. }
  1284. reader := bytes.NewReader(bytesData)
  1285. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2505"
  1286. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2505"
  1287. gdyb_url := beego.AppConfig.String("gdyb_url")
  1288. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1289. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1290. url := gdyb_url + "2505"
  1291. request, err := http.NewRequest("POST", url, reader)
  1292. if err != nil {
  1293. fmt.Println(err.Error())
  1294. return err.Error()
  1295. }
  1296. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1297. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1298. request.Header.Set("x-tif-signature", signature)
  1299. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1300. request.Header.Set("x-tif-nonce", nonce)
  1301. client := http.Client{}
  1302. resp, err := client.Do(request)
  1303. if err != nil {
  1304. fmt.Println(err.Error())
  1305. return err.Error()
  1306. }
  1307. respBytes, err := ioutil.ReadAll(resp.Body)
  1308. if err != nil {
  1309. fmt.Println(err.Error())
  1310. return err.Error()
  1311. }
  1312. str := string(respBytes)
  1313. fmt.Println(str)
  1314. return str
  1315. }
  1316. func FJyb2506(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 {
  1317. // 生成签名
  1318. nonce := GetRandomString(32)
  1319. timestamp := time.Now().Unix()
  1320. signature := setSignature(timestamp, nonce, secret_key)
  1321. // 生成输入报文
  1322. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1323. input := make(map[string]interface{})
  1324. inputData := make(map[string]interface{})
  1325. inputMessage["infno"] = "2506"
  1326. inputData["psn_no"] = psnNo
  1327. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn
  1328. inputData["memo"] = ""
  1329. input["data"] = inputData
  1330. inputMessage["input"] = input //交易输入
  1331. bytesData, err := json.Marshal(inputMessage)
  1332. fmt.Println(string(bytesData))
  1333. if err != nil {
  1334. fmt.Println(err.Error())
  1335. return err.Error()
  1336. }
  1337. reader := bytes.NewReader(bytesData)
  1338. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2506"
  1339. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2506"
  1340. gdyb_url := beego.AppConfig.String("gdyb_url")
  1341. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1342. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1343. url := gdyb_url + "2506"
  1344. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  1345. request, err := http.NewRequest("POST", url, reader)
  1346. if err != nil {
  1347. fmt.Println(err.Error())
  1348. return err.Error()
  1349. }
  1350. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1351. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1352. request.Header.Set("x-tif-signature", signature)
  1353. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1354. request.Header.Set("x-tif-nonce", nonce)
  1355. client := http.Client{}
  1356. resp, err := client.Do(request)
  1357. if err != nil {
  1358. fmt.Println(err.Error())
  1359. return err.Error()
  1360. }
  1361. respBytes, err := ioutil.ReadAll(resp.Body)
  1362. if err != nil {
  1363. fmt.Println(err.Error())
  1364. return err.Error()
  1365. }
  1366. str := string(respBytes)
  1367. fmt.Println(str)
  1368. return str
  1369. }
  1370. func FJyb2503(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 {
  1371. // 生成签名
  1372. nonce := GetRandomString(32)
  1373. timestamp := time.Now().Unix()
  1374. signature := setSignature(timestamp, nonce, secret_key)
  1375. tempTime := time.Unix(timestamp, 0)
  1376. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1377. timeFormatTwo := tempTime.Format("2006-01-02")
  1378. t := time.Now()
  1379. last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  1380. tm := time.Unix(last.Unix(), 0)
  1381. // 生成输入报文
  1382. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1383. input := make(map[string]interface{})
  1384. inputData := make(map[string]interface{})
  1385. inputMessage["infno"] = "2503" // 交易编码
  1386. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1387. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  1388. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  1389. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  1390. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  1391. inputData["ide_fixmedins_no"] = fixmedins_code // 险种类型(来自1101接口返回)
  1392. inputData["ide_fixmedins_name"] = org_name // 险种类型(来自1101接口返回)
  1393. inputData["hosp_ide_date"] = timeFormatTwo // 险种类型(来自1101接口返回)
  1394. inputData["diag_dr_codg"] = doctor_id // 开始时间
  1395. inputData["diag_dr_name"] = doctor // 开始时间
  1396. inputData["begndate"] = timeFormatTwo // 医师编码
  1397. inputData["tel"] = "" // 医师编码
  1398. inputData["addr"] = "" // 医师编码
  1399. inputData["enddate"] = tm.Format("2006-01-02") // 医师编码
  1400. input["data"] = inputData
  1401. inputMessage["input"] = input //交易输入
  1402. bytesData, err := json.Marshal(inputMessage)
  1403. fmt.Println(string(bytesData))
  1404. if err != nil {
  1405. fmt.Println(err.Error())
  1406. return err.Error()
  1407. }
  1408. reader := bytes.NewReader(bytesData)
  1409. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  1410. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  1411. gdyb_url := beego.AppConfig.String("gdyb_url")
  1412. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1413. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1414. url := gdyb_url + "2503"
  1415. request, err := http.NewRequest("POST", url, reader)
  1416. if err != nil {
  1417. fmt.Println(err.Error())
  1418. return err.Error()
  1419. }
  1420. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1421. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1422. request.Header.Set("x-tif-signature", signature)
  1423. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1424. request.Header.Set("x-tif-nonce", nonce)
  1425. client := http.Client{}
  1426. resp, err := client.Do(request)
  1427. if err != nil {
  1428. fmt.Println(err.Error())
  1429. return err.Error()
  1430. }
  1431. respBytes, err := ioutil.ReadAll(resp.Body)
  1432. if err != nil {
  1433. fmt.Println(err.Error())
  1434. return err.Error()
  1435. }
  1436. str := string(respBytes)
  1437. fmt.Println(str)
  1438. return str
  1439. }
  1440. func FJyb2504(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 {
  1441. // 生成签名
  1442. nonce := GetRandomString(32)
  1443. timestamp := time.Now().Unix()
  1444. signature := setSignature(timestamp, nonce, secret_key)
  1445. // 生成输入报文
  1446. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1447. input := make(map[string]interface{})
  1448. inputData := make(map[string]interface{})
  1449. inputMessage["infno"] = "2504" // 交易编码
  1450. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1451. inputData["trt_dcla_detl_sn"] = trt_dcla_detl_sn // 人员编号 (来自1101接口返回)
  1452. inputData["memo"] = "撤销备案" // 人员编号 (来自1101接口返回)
  1453. input["data"] = inputData
  1454. inputMessage["input"] = input //交易输入
  1455. bytesData, err := json.Marshal(inputMessage)
  1456. fmt.Println(string(bytesData))
  1457. if err != nil {
  1458. fmt.Println(err.Error())
  1459. return err.Error()
  1460. }
  1461. reader := bytes.NewReader(bytesData)
  1462. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2504"
  1463. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2504"
  1464. gdyb_url := beego.AppConfig.String("gdyb_url")
  1465. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1466. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1467. url := gdyb_url + "2504"
  1468. request, err := http.NewRequest("POST", url, reader)
  1469. if err != nil {
  1470. fmt.Println(err.Error())
  1471. return err.Error()
  1472. }
  1473. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1474. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1475. request.Header.Set("x-tif-signature", signature)
  1476. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1477. request.Header.Set("x-tif-nonce", nonce)
  1478. client := http.Client{}
  1479. resp, err := client.Do(request)
  1480. if err != nil {
  1481. fmt.Println(err.Error())
  1482. return err.Error()
  1483. }
  1484. respBytes, err := ioutil.ReadAll(resp.Body)
  1485. if err != nil {
  1486. fmt.Println(err.Error())
  1487. return err.Error()
  1488. }
  1489. str := string(respBytes)
  1490. fmt.Println(str)
  1491. return str
  1492. }
  1493. //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 {
  1494. // // 生成签名
  1495. // nonce := GetRandomString(32)
  1496. // timestamp := time.Now().Unix()
  1497. // signature := setSignature(timestamp, nonce, secret_key)
  1498. // tempTime := time.Unix(timestamp, 0)
  1499. // timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1500. //
  1501. // // 生成输入报文
  1502. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1503. // input := make(map[string]interface{})
  1504. // inputData := make(map[string]interface{})
  1505. // diseinfo := make([]map[string]interface{}, 0)
  1506. //
  1507. // inputMessage["infno"] = "2203" // 交易编码
  1508. // inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1509. // inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1510. // inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  1511. // inputData["begntime"] = timeFormatOne // 开始时间
  1512. // inputData["main_cond_dscr"] = "" // 主要病情描述
  1513. // inputData["dise_codg"] = sick_code // 病种编码
  1514. // inputData["dise_name"] = sick_name // 病种名称
  1515. // inputData["birctrl_type"] = "" // 计划生育手术类别
  1516. // inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  1517. //
  1518. // diseinfo_sun := make(map[string]interface{})
  1519. // diseinfo_sun["diag_type"] = "1" // 诊断类别
  1520. // diseinfo_sun["diag_srt_no"] = "1" // 诊断排序号
  1521. // diseinfo_sun["diag_code"] = diag_code // 诊断代码
  1522. // diseinfo_sun["diag_name"] = diag // 诊断名称
  1523. // diseinfo_sun["diag_dept"] = department // 诊断科室
  1524. // diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  1525. // diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  1526. // diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  1527. // diseinfo_sun["vali_flag"] = "1" // 有效标志
  1528. //
  1529. // diseinfo = append(diseinfo, diseinfo_sun)
  1530. // input["diseinfo"] = diseinfo
  1531. // input["mdtrtinfo"] = inputData
  1532. // inputMessage["input"] = input //交易输入
  1533. //
  1534. // bytesData, err := json.Marshal(inputMessage)
  1535. // fmt.Println(string(bytesData))
  1536. // if err != nil {
  1537. // fmt.Println(err.Error())
  1538. // return err.Error()
  1539. // }
  1540. // reader := bytes.NewReader(bytesData)
  1541. //
  1542. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2203"
  1543. //
  1544. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2203"
  1545. // request, err := http.NewRequest("POST", url, reader)
  1546. // if err != nil {
  1547. // fmt.Println(err.Error())
  1548. // return err.Error()
  1549. // }
  1550. //
  1551. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1552. // request.Header.Set("x-tif-paasid", "sg03_prd")
  1553. // request.Header.Set("x-tif-signature", signature)
  1554. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1555. // request.Header.Set("x-tif-nonce", nonce)
  1556. //
  1557. // client := http.Client{}
  1558. // resp, err := client.Do(request)
  1559. // if err != nil {
  1560. // fmt.Println(err.Error())
  1561. // return err.Error()
  1562. // }
  1563. // respBytes, err := ioutil.ReadAll(resp.Body)
  1564. // if err != nil {
  1565. // fmt.Println(err.Error())
  1566. // return err.Error()
  1567. // }
  1568. // str := string(respBytes)
  1569. // fmt.Println(str)
  1570. // return str
  1571. //}
  1572. func FJyb5301(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 {
  1573. // 生成签名
  1574. nonce := GetRandomString(32)
  1575. timestamp := time.Now().Unix()
  1576. signature := setSignature(timestamp, nonce, secret_key)
  1577. //tempTime := time.Unix(timestamp, 0)
  1578. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  1579. //timeFormatTwo := tempTime.Format("2006-01-02")
  1580. // 生成输入报文
  1581. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1582. input := make(map[string]interface{})
  1583. inputData := make(map[string]interface{})
  1584. inputMessage["infno"] = "5301" // 交易编码
  1585. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1586. input["data"] = inputData
  1587. inputMessage["input"] = input //交易输入
  1588. bytesData, err := json.Marshal(inputMessage)
  1589. fmt.Println(string(bytesData))
  1590. if err != nil {
  1591. fmt.Println(err.Error())
  1592. return err.Error()
  1593. }
  1594. reader := bytes.NewReader(bytesData)
  1595. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5301"
  1596. gdyb_url := beego.AppConfig.String("gdyb_url")
  1597. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1598. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1599. url := gdyb_url + "5301"
  1600. request, err := http.NewRequest("POST", url, reader)
  1601. if err != nil {
  1602. fmt.Println(err.Error())
  1603. return err.Error()
  1604. }
  1605. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1606. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1607. request.Header.Set("x-tif-signature", signature)
  1608. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1609. request.Header.Set("x-tif-nonce", nonce)
  1610. client := http.Client{}
  1611. resp, err := client.Do(request)
  1612. if err != nil {
  1613. fmt.Println(err.Error())
  1614. return err.Error()
  1615. }
  1616. respBytes, err := ioutil.ReadAll(resp.Body)
  1617. if err != nil {
  1618. fmt.Println(err.Error())
  1619. return err.Error()
  1620. }
  1621. str := string(respBytes)
  1622. fmt.Println(str)
  1623. return str
  1624. }
  1625. func Fjyb4101(struct4101 Struct4101, params models.PublicParams) (string, string, string) {
  1626. timestamp := time.Now().Unix()
  1627. inputMessage := SetHnInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  1628. // 生成输入报文
  1629. input := make(map[string]interface{})
  1630. inputData := make(map[string]interface{})
  1631. inputMessage["infno"] = "4101A" // 交易编码
  1632. year := time.Now().Format("2006")
  1633. month := time.Now().Format("01")
  1634. day := time.Now().Format("02")
  1635. inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  1636. inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  1637. inputData["psn_no"] = struct4101.PsnNo // 结算 ID 必填
  1638. inputData["fixmedins_name"] = params.FixmedinsName // 定点医药机构名称 必填
  1639. inputData["fixmedins_code"] = params.FixmedinsCode // 定点医药机构编码 必填
  1640. inputData["hi_setl_lv"] = "" // 医保结算等级
  1641. inputData["hi_no"] = struct4101.PsnNo // 医保编号
  1642. inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  1643. inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  1644. inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  1645. inputData["gend"] = struct4101.Gend // 性别 必填
  1646. inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  1647. inputData["age"] = struct4101.Age // 年龄 必填
  1648. inputData["ntly"] = struct4101.Ntly // 国籍 必填
  1649. inputData["nwb_age"] = "" // 年龄 必填
  1650. inputData["naty"] = struct4101.Naty // 民族 必填
  1651. inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  1652. inputData["certno"] = struct4101.Certno // 证件号码 必填
  1653. inputData["prfs"] = struct4101.Prfs // 职业 必填
  1654. inputData["curr_addr"] = "" // 现住址 必填
  1655. inputData["emp_name"] = "" // 单位名称 必填
  1656. inputData["emp_addr"] = "" // 单位地址 必填
  1657. inputData["emp_tel"] = "" // 单位电话 必填
  1658. inputData["poscode"] = "" // 邮编 必填
  1659. inputData["coner_name"] = "" // 联系人姓名 必填
  1660. inputData["patn_rlts"] = "" // 与患者关系 必填
  1661. inputData["coner_addr"] = "" // 联系人地址 必填
  1662. inputData["coner_tel"] = "" // 联系人电话 必填
  1663. inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  1664. inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  1665. inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  1666. inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  1667. inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  1668. inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  1669. inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  1670. inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  1671. inputData["ipt_med_type"] = struct4101.IptMedType // 住院医疗类型 必填
  1672. inputData["adm_way"] = "" // 入院途径 必填
  1673. inputData["trt_type"] = "" // 治疗类别 必填
  1674. inputData["adm_time"] = struct4101.AdmTime // 入院时间 必填
  1675. inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  1676. inputData["refldept_dept"] = "" // 转科科别 必填
  1677. inputData["dscg_time"] = struct4101.AdmEndTime // 出院时间 必填
  1678. inputData["dscg_caty"] = struct4101.AdmCaty // 出院科别 必填
  1679. inputData["act_ipt_days"] = "" // 实际住院天数 必填
  1680. inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  1681. inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  1682. inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  1683. inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  1684. inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  1685. inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  1686. inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  1687. inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  1688. inputData["bld_cat"] = "" // 输血品种 必填
  1689. inputData["bld_amt"] = "" // 输血量 必填
  1690. inputData["bld_unt"] = "" // 输血计量单位 必填
  1691. inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  1692. inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  1693. inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  1694. inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  1695. inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  1696. inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  1697. inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  1698. inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  1699. inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  1700. inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  1701. inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  1702. inputData["chfpdr_name"] = struct4101.DoctorName // 主诊医师姓名 必填
  1703. inputData["chfpdr_code"] = struct4101.DoctorCode // 主诊医师代码 必填
  1704. inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  1705. inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  1706. inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  1707. inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  1708. inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  1709. inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  1710. inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  1711. inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  1712. inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  1713. inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  1714. inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  1715. payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  1716. for _, item := range struct4101.CustomStruct {
  1717. payinfotemp := make(map[string]interface{})
  1718. 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" {
  1719. payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  1720. payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  1721. payinfo = append(payinfo, payinfotemp)
  1722. }
  1723. }
  1724. opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  1725. opspdiseinfotemp := make(map[string]interface{})
  1726. opspdiseinfotemp["diag_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 诊断名称 必填
  1727. opspdiseinfotemp["diag_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 诊断代码 必填
  1728. opspdiseinfotemp["oprn_oprt_name"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagName // 手术操作名称 必填
  1729. opspdiseinfotemp["oprn_oprt_code"] = struct4101.OpspdiseinfoStruct[len(struct4101.OpspdiseinfoStruct)-1].DiagCode // 手术操作代码 必填
  1730. opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  1731. diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  1732. for _, item := range struct4101.Diseinfo {
  1733. diseinfotemp := make(map[string]interface{})
  1734. diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  1735. diseinfotemp["diag_type"] = item.DiagType // 诊断类别 必填
  1736. diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  1737. diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  1738. diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  1739. diseinfo = append(diseinfo, diseinfotemp)
  1740. }
  1741. iteminfo := make([]map[string]interface{}, 0)
  1742. for _, item := range struct4101.IteminfoStruct {
  1743. iteminfotemp := make(map[string]interface{})
  1744. iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  1745. iteminfotemp["amt"] = item.Amt // 金额 必填
  1746. iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  1747. iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  1748. iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  1749. iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  1750. iteminfo = append(iteminfo, iteminfotemp)
  1751. }
  1752. oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  1753. oprninfotemp := make(map[string]interface{})
  1754. oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  1755. oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  1756. oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  1757. oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  1758. oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  1759. oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  1760. oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  1761. oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  1762. oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  1763. oprninfo = append(oprninfo, oprninfotemp)
  1764. icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  1765. icuinfotemp := make(map[string]interface{})
  1766. icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  1767. icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  1768. icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  1769. icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  1770. icuinfo = append(icuinfo, icuinfotemp)
  1771. input["setlinfo"] = inputData
  1772. input["payinfo"] = payinfo
  1773. input["opspdiseinfo"] = opspdiseinfo
  1774. input["diseinfo"] = diseinfo
  1775. input["iteminfo"] = iteminfo
  1776. inputMessage["input"] = input //交易输入
  1777. bytesData, _ := json.Marshal(inputMessage)
  1778. fmt.Println(string(bytesData))
  1779. if err != nil {
  1780. fmt.Println(err.Error())
  1781. return err.Error(), "", ""
  1782. }
  1783. var requestLog string
  1784. requestLog = string(bytesData)
  1785. enc := mahonia.NewEncoder("gbk")
  1786. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  1787. return output, requestLog, err_msg
  1788. }
  1789. func Fjyb4102(psn_no string, SetlId string, params models.PublicParams, stas_type string) (string, string, string) {
  1790. timestamp := time.Now().Unix()
  1791. inputMessage := SetHnInputMessage(timestamp, params.FixmedinsName, params.OpterName, params.FixmedinsCode, params.InsuplcAdmdvs, params.MdtrtareaAdmvs, params.Cainfo)
  1792. // 生成输入报文
  1793. input := make(map[string]interface{})
  1794. input2 := make(map[string]interface{})
  1795. inputData := make(map[string]interface{})
  1796. inputMessage["infno"] = "4102" // 交易编码
  1797. inputData["setl_id"] = SetlId // 结算 ID 必填
  1798. inputData["psn_no"] = psn_no // 结算 ID 必填
  1799. inputData["stas_type"] = stas_type // 结算 ID 必填
  1800. input2["stastinfo"] = inputData
  1801. input["data"] = input2
  1802. inputMessage["input"] = input //交易输入
  1803. bytesData, _ := json.Marshal(inputMessage)
  1804. fmt.Println(string(bytesData))
  1805. if err != nil {
  1806. fmt.Println(err.Error())
  1807. return err.Error(), "", ""
  1808. }
  1809. var requestLog string
  1810. requestLog = string(bytesData)
  1811. enc := mahonia.NewEncoder("gbk")
  1812. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  1813. return output, requestLog, err_msg
  1814. }
  1815. //
  1816. //func Hbyb4101(struct4101 Struct4101, secret_key string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) string {
  1817. // // 生成签名
  1818. // nonce := GetRandomString(32)
  1819. // timestamp := time.Now().Unix()
  1820. // signature := setSignature(timestamp, nonce, secret_key)
  1821. //
  1822. // // 生成输入报文
  1823. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1824. // input := make(map[string]interface{})
  1825. // inputData := make(map[string]interface{})
  1826. // inputMessage["infno"] = "4101" // 交易编码
  1827. //
  1828. // year := time.Now().Format("2006")
  1829. // month := time.Now().Format("01")
  1830. // day := time.Now().Format("02")
  1831. //
  1832. // inputData["mdtrt_id"] = struct4101.MdtrtId // 就诊 ID 必填(来自2201接口返回)
  1833. // inputData["setl_id"] = struct4101.SetlId // 结算 ID 必填
  1834. // inputData["fixmedins_name"] = org_name // 定点医药机构名称 必填
  1835. // inputData["fixmedins_code"] = fixmedins_code // 定点医药机构编码 必填
  1836. // inputData["hi_setl_lv"] = "" // 医保结算等级
  1837. // inputData["hi_no"] = "" // 医保编号
  1838. // inputData["medcasno"] = struct4101.PsnNo // 病案号 必填
  1839. // inputData["dcla_time"] = year + "-" + month + "-" + day // 申报时间 必填
  1840. // inputData["psn_name"] = struct4101.PsnName // 人员姓名 必填
  1841. // inputData["gend"] = struct4101.Gend // 性别 必填
  1842. // inputData["brdy"] = struct4101.Brdy // 出生日期 必填
  1843. // inputData["age"] = struct4101.Age // 年龄 必填
  1844. // inputData["ntly"] = struct4101.Ntly // 国籍 必填
  1845. // inputData["nwb_age"] = "" // 年龄 必填
  1846. // inputData["naty"] = struct4101.Naty // 民族 必填
  1847. // inputData["patn_cert_type"] = struct4101.PatnCertType // 患者证件类别 必填
  1848. // inputData["certno"] = struct4101.Certno // 证件号码 必填
  1849. // inputData["prfs"] = struct4101.Prfs // 职业 必填
  1850. // inputData["curr_addr"] = "" // 现住址 必填
  1851. // inputData["emp_name"] = "" // 单位名称 必填
  1852. // inputData["emp_addr"] = "" // 单位地址 必填
  1853. // inputData["emp_tel"] = "" // 单位电话 必填
  1854. // inputData["poscode"] = "" // 邮编 必填
  1855. // inputData["coner_name"] = struct4101.ConerName // 联系人姓名 必填
  1856. // inputData["patn_rlts"] = struct4101.PatnRlts // 与患者关系 必填
  1857. // inputData["coner_addr"] = struct4101.ConerAddr // 联系人地址 必填
  1858. // inputData["coner_tel"] = struct4101.ConerTel // 联系人电话 必填
  1859. // inputData["hi_type"] = struct4101.HiType // 医保类型 必填
  1860. // inputData["insuplc"] = struct4101.Insuplc // 参保地 必填
  1861. // inputData["sp_psn_type"] = "" // 特殊人员类型 必填
  1862. // inputData["nwb_adm_type"] = "" // 新生儿入院类型 必填
  1863. // inputData["nwb_bir_wt"] = "" // 新生儿出生体重 必填
  1864. // inputData["nwb_adm_wt"] = "" // 新生儿入院体重 必填
  1865. // inputData["opsp_diag_caty"] = "" // 门诊慢特病诊断 必填
  1866. // inputData["opsp_mdtrt_date"] = "" // 门诊慢特病就诊日期 必填
  1867. // inputData["ipt_med_type"] = struct4101.IptMedType // 住院医疗类型 必填
  1868. // inputData["adm_way"] = "" // 入院途径 必填
  1869. // inputData["trt_type"] = "" // 治疗类别 必填
  1870. // inputData["adm_time"] = "" // 入院时间 必填
  1871. // inputData["adm_caty"] = struct4101.AdmCaty // 入院科别 必填
  1872. // inputData["refldept_dept"] = "" // 转科科别 必填
  1873. // inputData["dscg_time"] = "" // 出院时间 必填
  1874. // inputData["dscg_caty"] = struct4101.AdmCaty // 出院科别 必填
  1875. // inputData["act_ipt_days"] = "" // 实际住院天数 必填
  1876. // inputData["otp_wm_dise"] = "" // 门(急) 诊西医诊断 必填
  1877. // inputData["wm_dise_code"] = "" // 门(急) 诊中医诊断 必填
  1878. // inputData["otp_tcm_dise"] = "" // 西医诊断疾病代码 必填
  1879. // inputData["tcm_dise_code"] = "" // 中医诊断代码 必填
  1880. // inputData["oprn_oprt_code_cnt"] = "" // 手术操作代码计数 必填
  1881. // inputData["vent_used_dura"] = "" // 呼吸机使用时长 必填
  1882. // inputData["pwcry_bfadm_coma_dura"] = "" // 颅脑损伤患者入院前昏迷时长 必填
  1883. // inputData["pwcry_afadm_coma_dura"] = "" // 颅脑损伤患者入院后昏迷时长 必填
  1884. // inputData["bld_cat"] = "" // 输血品种 必填
  1885. // inputData["bld_amt"] = "" // 输血量 必填
  1886. // inputData["bld_unt"] = "" // 输血计量单位 必填
  1887. // inputData["spga_nurscare_days"] = "" // 特级护理天数 必填
  1888. // inputData["lv1_nurscare_days"] = "" // 一级护理天数 必填
  1889. // inputData["scd_nurscare_days"] = "" // 二级护理天数 必填
  1890. // inputData["lv3_nurscare_days"] = "" // 三级护理天数 必填
  1891. // inputData["acp_medins_name"] = "" // 拟接收机构名称 必填
  1892. // inputData["acp_optins_code"] = "" // 拟接收机构代码 必填
  1893. // inputData["bill_code"] = struct4101.BillCode // 票据代码 必填
  1894. // inputData["bill_no"] = struct4101.BillNo // 票据号码 必填
  1895. // inputData["biz_sn"] = struct4101.BizSn // 业务流水号 必填
  1896. // inputData["days_rinp_flag_31"] = "" // 出院 31 天内再住院计划标志 必填
  1897. // inputData["days_rinp_pup_31"] = "" // 出院 31 天内再住院目的 必填
  1898. // inputData["chfpdr_name"] = "" // 主诊医师姓名 必填
  1899. // inputData["chfpdr_code"] = "" // 主诊医师代码 必填
  1900. // inputData["setl_begn_date"] = struct4101.SetlBegnDate // 结算开始日期 必填
  1901. // inputData["setl_end_date"] = struct4101.SetlEndDate // 结算结束日期 必填
  1902. // inputData["psn_selfpay"] = struct4101.PsnSelfPay // 个人自付 必填
  1903. // inputData["psn_ownpay"] = struct4101.PsnOwnPay // 个人自费 必填
  1904. // inputData["acct_pay"] = struct4101.AcctPay // 个人账户支出 必填
  1905. // inputData["hi_paymtd"] = struct4101.HiPaymtd // 医保支付方式 必填
  1906. // inputData["hsorg"] = struct4101.Hsorg // 医保机构 必填
  1907. // inputData["hsorg_opter"] = struct4101.HsorgOpter // 医保机构经办人 必填
  1908. // inputData["medins_fill_dept"] = struct4101.MedinsFillDept // 医疗机构填报部门 必填
  1909. // inputData["medins_fill_psn"] = struct4101.MedinsFillPsn // 医疗机构填报人 必填
  1910. // inputData["psn_cashpay"] = struct4101.PsnCashpay // 医疗机构填报人 必填
  1911. //
  1912. // payinfo := make([]map[string]interface{}, 0) // 基金支付信息
  1913. // for _, item := range struct4101.CustomStruct {
  1914. // payinfotemp := make(map[string]interface{})
  1915. // 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" {
  1916. // payinfotemp["fund_pay_type"] = item.FundPayType // 基金支付类型 必填
  1917. // payinfotemp["fund_payamt"] = item.FundPayamt // 基金支付金额
  1918. // payinfo = append(payinfo, payinfotemp)
  1919. // }
  1920. // }
  1921. // opspdiseinfo := make([]map[string]interface{}, 0) // 门诊慢特病诊断信息
  1922. // for _, item := range struct4101.OpspdiseinfoStruct {
  1923. // opspdiseinfotemp := make(map[string]interface{})
  1924. // opspdiseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  1925. // opspdiseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  1926. // opspdiseinfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  1927. // opspdiseinfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  1928. //
  1929. // opspdiseinfo = append(opspdiseinfo, opspdiseinfotemp)
  1930. // }
  1931. //
  1932. // diseinfo := make([]map[string]interface{}, 0) // 住院诊断信息
  1933. // for _, item := range struct4101.OpspdiseinfoStruct {
  1934. // fmt.Println(item.DiagName)
  1935. // diseinfotemp := make(map[string]interface{})
  1936. // diseinfotemp["maindiag_flag"] = item.MaindiagFlag // 手术操作代码 必填
  1937. // diseinfotemp["diag_type"] = item.MaindiagFlag // 诊断类别 必填
  1938. // diseinfotemp["diag_code"] = item.DiagCode // 诊断代码 必填
  1939. // diseinfotemp["diag_name"] = item.DiagName // 诊断名称 必填
  1940. // diseinfotemp["adm_cond_type"] = "3" // 入院病情类型 必填
  1941. // diseinfo = append(diseinfo, diseinfotemp)
  1942. // }
  1943. //
  1944. // iteminfo := make([]map[string]interface{}, 0) // 住院诊断信息
  1945. // for _, item := range struct4101.IteminfoStruct {
  1946. // iteminfotemp := make(map[string]interface{})
  1947. // iteminfotemp["med_chrgitm"] = item.MedChrgitm // 医疗收费项目 必填
  1948. // iteminfotemp["amt"] = item.Amt // 金额 必填
  1949. // iteminfotemp["claa_sumfee"] = item.ClaaSumfee // 甲类费用合计 必填
  1950. // iteminfotemp["clab_amt"] = item.ClabAmt // 乙类金额 必填
  1951. // iteminfotemp["fulamt_ownpay_amt"] = item.FulamtOwnpayAmt // 全自费金额 必填
  1952. // iteminfotemp["oth_amt"] = item.OthAmt // 其他金额 必填
  1953. // iteminfo = append(iteminfo, iteminfotemp)
  1954. // }
  1955. //
  1956. // oprninfo := make([]map[string]interface{}, 0) // 手术操作信息
  1957. // oprninfotemp := make(map[string]interface{})
  1958. // oprninfotemp["oprn_oprt_type"] = "" // 手术操作类别 必填
  1959. // oprninfotemp["oprn_oprt_name"] = "" // 手术操作名称 必填
  1960. // oprninfotemp["oprn_oprt_code"] = "" // 手术操作代码 必填
  1961. // oprninfotemp["oprn_oprt_date"] = "" // 手术操作日期 必填
  1962. // oprninfotemp["anst_way"] = "" // 麻醉方式 必填
  1963. // oprninfotemp["oper_dr_name"] = "" // 术者医师姓名 必填
  1964. // oprninfotemp["oper_dr_code"] = "" // 术者医师代码 必填
  1965. // oprninfotemp["anst_dr_name"] = "" // 麻醉医师姓名 必填
  1966. // oprninfotemp["anst_dr_code"] = "" // 麻醉医师代码 必填
  1967. // oprninfo = append(oprninfo, oprninfotemp)
  1968. //
  1969. // icuinfo := make([]map[string]interface{}, 0) // 重症监护信息
  1970. // icuinfotemp := make(map[string]interface{})
  1971. // icuinfotemp["scs_cutd_ward_type"] = "" // 重症监护病房类型 必填
  1972. // icuinfotemp["scs_cutd_inpool_time"] = "" // 重症监护进入时间 必填
  1973. // icuinfotemp["scs_cutd_exit_time"] = "" // 重症监护退出时间 必填
  1974. // icuinfotemp["scs_cutd_sum_dura"] = "" // 重症监护合计时长 必填
  1975. // icuinfo = append(icuinfo, icuinfotemp)
  1976. //
  1977. // input["setlinfo"] = inputData
  1978. // input["payinfo"] = payinfo
  1979. // //input["opspdiseinfo"] = opspdiseinfo
  1980. // input["diseinfo"] = diseinfo
  1981. // input["iteminfo"] = iteminfo
  1982. // //input["oprninfo"] = oprninfo
  1983. // //input["icuinfo"] = icuinfo
  1984. // inputMessage["input"] = input //交易输入
  1985. //
  1986. // bytesData, err := json.Marshal(inputMessage)
  1987. // fmt.Println(string(bytesData))
  1988. // if err != nil {
  1989. // fmt.Println(err.Error())
  1990. // return err.Error()
  1991. // }
  1992. // reader := bytes.NewReader(bytesData)
  1993. //
  1994. // gdyb_url := beego.AppConfig.String("gdyb_url")
  1995. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1996. // url := gdyb_url + "4101"
  1997. //
  1998. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/4101"
  1999. // request, err := http.NewRequest("POST", url, reader)
  2000. // if err != nil {
  2001. // fmt.Println(err.Error())
  2002. // return err.Error()
  2003. // }
  2004. //
  2005. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2006. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  2007. // request.Header.Set("x-tif-signature", signature)
  2008. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2009. // request.Header.Set("x-tif-nonce", nonce)
  2010. //
  2011. // client := http.Client{}
  2012. // resp, err := client.Do(request)
  2013. // if err != nil {
  2014. // fmt.Println(err.Error())
  2015. // return err.Error()
  2016. // }
  2017. // respBytes, err := ioutil.ReadAll(resp.Body)
  2018. // if err != nil {
  2019. // fmt.Println(err.Error())
  2020. // return err.Error()
  2021. // }
  2022. // str := string(respBytes)
  2023. // fmt.Println(str)
  2024. // return str
  2025. //}
  2026. //func Gdyb1201(psnNo string, org_name string, doctor string) string {
  2027. // // 生成签名
  2028. // nonce := GetRandomString(32)
  2029. // timestamp := time.Now().Unix()
  2030. // signature := setSignature(timestamp, nonce)
  2031. //
  2032. // // 生成输入报文
  2033. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, "")
  2034. // input := make(map[string]interface{})
  2035. // inputData := make(map[string]interface{})
  2036. // inputMessage["infno"] = "1201" // 交易编码
  2037. // inputData["fixmedins_type"] = psnNo // 人员编号 (来自1101接口返回)
  2038. // inputData["fixmedins_name"] = org_name // 人员编号 (来自1101接口返回)
  2039. // inputData["fixmedins_code"] = "" // 人员编号 (来自1101接口返回)
  2040. //
  2041. // input["medinsinfo"] = inputData
  2042. // inputMessage["input"] = input //交易输入
  2043. //
  2044. // bytesData, err := json.Marshal(inputMessage)
  2045. // fmt.Println(string(bytesData))
  2046. // if err != nil {
  2047. // fmt.Println(err.Error())
  2048. // return err.Error()
  2049. // }
  2050. // reader := bytes.NewReader(bytesData)
  2051. //
  2052. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  2053. // request, err := http.NewRequest("POST", url, reader)
  2054. // if err != nil {
  2055. // fmt.Println(err.Error())
  2056. // return err.Error()
  2057. // }
  2058. //
  2059. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2060. // request.Header.Set("x-tif-paasid", "test_hosp")
  2061. // request.Header.Set("x-tif-signature", signature)
  2062. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2063. // request.Header.Set("x-tif-nonce", nonce)
  2064. //
  2065. // client := http.Client{}
  2066. // resp, err := client.Do(request)
  2067. // if err != nil {
  2068. // fmt.Println(err.Error())
  2069. // return err.Error()
  2070. // }
  2071. // respBytes, err := ioutil.ReadAll(resp.Body)
  2072. // if err != nil {
  2073. // fmt.Println(err.Error())
  2074. // return err.Error()
  2075. // }
  2076. // str := string(respBytes)
  2077. // fmt.Println(str)
  2078. // return str
  2079. //}
  2080. //func Gdyb5203(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2081. // // 生成签名
  2082. // nonce := GetRandomString(32)
  2083. // timestamp := time.Now().Unix()
  2084. // signature := setSignature(timestamp, nonce, secret_key)
  2085. //
  2086. // // 生成输入报文
  2087. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2088. // input := make(map[string]interface{})
  2089. // inputData := make(map[string]interface{})
  2090. // inputMessage["infno"] = "5203" // 交易编码
  2091. //
  2092. // inputData["fixmedins_type"] = "1"
  2093. // inputData["fixmedins_name"] = org_name
  2094. // inputData["fixmedins_code"] = fixmedins_code
  2095. // input["medinsinfo"] = inputData
  2096. // inputMessage["input"] = input //交易输入
  2097. //
  2098. // bytesData, err := json.Marshal(inputMessage)
  2099. // fmt.Println(string(bytesData))
  2100. // if err != nil {
  2101. // fmt.Println(err.Error())
  2102. // return err.Error()
  2103. // }
  2104. // reader := bytes.NewReader(bytesData)
  2105. // url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1201"
  2106. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1201"
  2107. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2108. // request, err := http.NewRequest("POST", url, reader)
  2109. // if err != nil {
  2110. // fmt.Println(err.Error())
  2111. // return err.Error()
  2112. // }
  2113. //
  2114. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2115. // request.Header.Set("x-tif-paasid", "sg03_prd")
  2116. // request.Header.Set("x-tif-signature", signature)
  2117. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2118. // request.Header.Set("x-tif-nonce", nonce)
  2119. //
  2120. // client := http.Client{}
  2121. // resp, err := client.Do(request)
  2122. // if err != nil {
  2123. // fmt.Println(err.Error())
  2124. // return err.Error()
  2125. // }
  2126. // respBytes, err := ioutil.ReadAll(resp.Body)
  2127. // if err != nil {
  2128. // fmt.Println(err.Error())
  2129. // return err.Error()
  2130. // }
  2131. // fmt.Println(string(respBytes))
  2132. // str := string(respBytes)
  2133. // return str
  2134. //}
  2135. func FJyb2601(psnNo string, omsgid string, oinfno string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2136. // 生成签名
  2137. nonce := GetRandomString(32)
  2138. timestamp := time.Now().Unix()
  2139. signature := setSignature(timestamp, nonce, secret_key)
  2140. // 生成输入报文
  2141. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2142. input := make(map[string]interface{})
  2143. inputData := make(map[string]interface{})
  2144. inputMessage["infno"] = "2601" // 交易编码
  2145. inputData["psn_no"] = psnNo
  2146. inputData["omsgid"] = omsgid
  2147. inputData["oinfno"] = oinfno
  2148. input["data"] = inputData
  2149. inputMessage["input"] = input //交易输入
  2150. bytesData, err := json.Marshal(inputMessage)
  2151. fmt.Println(string(bytesData))
  2152. if err != nil {
  2153. fmt.Println(err.Error())
  2154. return err.Error()
  2155. }
  2156. reader := bytes.NewReader(bytesData)
  2157. gdyb_url := beego.AppConfig.String("gdyb_url")
  2158. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2159. url := gdyb_url + "2601"
  2160. request, err := http.NewRequest("POST", url, reader)
  2161. if err != nil {
  2162. fmt.Println(err.Error())
  2163. return err.Error()
  2164. }
  2165. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2166. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2167. request.Header.Set("x-tif-signature", signature)
  2168. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2169. request.Header.Set("x-tif-nonce", nonce)
  2170. client := http.Client{}
  2171. resp, err := client.Do(request)
  2172. if err != nil {
  2173. fmt.Println(err.Error())
  2174. return err.Error()
  2175. }
  2176. respBytes, err := ioutil.ReadAll(resp.Body)
  2177. if err != nil {
  2178. fmt.Println(err.Error())
  2179. return err.Error()
  2180. }
  2181. str := string(respBytes)
  2182. fmt.Println(str)
  2183. return str
  2184. }
  2185. // 人员信息版本3
  2186. func FJyb1101B(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 {
  2187. //生成签名
  2188. nonce := GetRandomString(32)
  2189. timestamp := time.Now().Unix()
  2190. signature := setSignature(timestamp, nonce, secret_key)
  2191. //生成输入报文
  2192. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2193. input := make(map[string]interface{})
  2194. inputData := make(map[string]interface{})
  2195. inputMessage["infno"] = "1101" // 交易编码
  2196. if certificates == 3 {
  2197. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  2198. inputData["certno"] = certNo // 证件号码
  2199. inputData["psn_cert_type"] = "99" // 人员证件类型
  2200. } else {
  2201. if id_card_type == 1 {
  2202. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2203. inputData["card_sn"] = "" // 卡识别码
  2204. inputData["certno"] = certNo // 证件号码
  2205. inputData["psn_cert_type"] = "01" // 人员证件类型
  2206. } else {
  2207. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  2208. inputData["card_sn"] = "" // 卡识别码
  2209. inputData["certno"] = certNo // 证件号码
  2210. inputData["psn_cert_type"] = "1" // 人员证件类型
  2211. }
  2212. }
  2213. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  2214. inputData["begntime"] = "" // 开始时间
  2215. inputData["psn_name"] = "" // 人员姓名
  2216. input["data"] = inputData
  2217. inputMessage["input"] = input //交易输入
  2218. bytesData, err := json.Marshal(inputMessage)
  2219. fmt.Println(string(bytesData))
  2220. if err != nil {
  2221. fmt.Println(err.Error())
  2222. return err.Error()
  2223. }
  2224. reader := bytes.NewReader(bytesData)
  2225. gdyb_url := beego.AppConfig.String("gdyb_url")
  2226. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2227. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2228. url := gdyb_url + "1101"
  2229. fmt.Println(url)
  2230. fmt.Println(gdyb_paasid)
  2231. fmt.Println(secret_key)
  2232. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2233. request, err := http.NewRequest("POST", url, reader)
  2234. if err != nil {
  2235. fmt.Println(err.Error())
  2236. return err.Error()
  2237. }
  2238. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2239. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2240. request.Header.Set("x-tif-signature", signature)
  2241. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2242. request.Header.Set("x-tif-nonce", nonce)
  2243. client := http.Client{}
  2244. resp, err := client.Do(request)
  2245. if err != nil {
  2246. fmt.Println(err.Error())
  2247. return err.Error()
  2248. }
  2249. respBytes, err := ioutil.ReadAll(resp.Body)
  2250. if err != nil {
  2251. fmt.Println(err.Error())
  2252. return err.Error()
  2253. }
  2254. fmt.Println(string(respBytes))
  2255. str := string(respBytes)
  2256. return str
  2257. }
  2258. // 人员信息版本4
  2259. func FJyb1101C(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) {
  2260. //生成签名
  2261. nonce := GetRandomString(32)
  2262. timestamp := time.Now().Unix()
  2263. //signature := setSignature(timestamp, nonce, secret_key)
  2264. //生成输入报文
  2265. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2266. input := make(map[string]interface{})
  2267. inputData := make(map[string]interface{})
  2268. inputMessage["infno"] = "1101" // 交易编码
  2269. if certificates == 3 {
  2270. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  2271. inputData["certno"] = certNo // 证件号码
  2272. inputData["psn_cert_type"] = "99" // 人员证件类型
  2273. } else {
  2274. if id_card_type == 1 {
  2275. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2276. inputData["card_sn"] = "" // 卡识别码
  2277. inputData["certno"] = "" // 证件号码
  2278. inputData["psn_cert_type"] = "" // 人员证件类型
  2279. } else {
  2280. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  2281. inputData["card_sn"] = "" // 卡识别码
  2282. inputData["certno"] = certNo // 证件号码
  2283. inputData["psn_cert_type"] = "1" // 人员证件类型
  2284. }
  2285. }
  2286. inputData["mdtrt_cert_no"] = "" // 就诊凭证编号
  2287. inputData["begntime"] = "" // 开始时间
  2288. inputData["psn_name"] = "" // 人员姓名
  2289. input["data"] = inputData
  2290. inputMessage["input"] = input //交易输入
  2291. bytesData, err := json.Marshal(inputMessage)
  2292. fmt.Println(string(bytesData))
  2293. if err != nil {
  2294. fmt.Println(err.Error())
  2295. return err.Error(), ""
  2296. }
  2297. var json2 string
  2298. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  2299. out, err := cmd.Output()
  2300. if err != nil {
  2301. fmt.Println("error:", err.Error())
  2302. }
  2303. fmt.Println(string(out))
  2304. return string(out), string(bytesData)
  2305. }
  2306. func FJyb90991(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, pwd string) string {
  2307. //生成签名
  2308. nonce := GetRandomString(32)
  2309. timestamp := time.Now().Unix()
  2310. signature := setSignature(timestamp, nonce, secret_key)
  2311. //生成输入报文
  2312. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2313. input := make(map[string]interface{})
  2314. inputData := make(map[string]interface{})
  2315. inputMessage["infno"] = "90991" // 交易编码
  2316. inputData["fixmedins_code"] = fixmedins_code // 就诊凭证编号
  2317. inputData["psn_no"] = psn_no // 开始时间
  2318. inputData["card_pwd"] = pwd // 人员姓名
  2319. input["data"] = inputData
  2320. inputMessage["input"] = input //交易输入
  2321. bytesData, err := json.Marshal(inputMessage)
  2322. fmt.Println(string(bytesData))
  2323. if err != nil {
  2324. fmt.Println(err.Error())
  2325. return err.Error()
  2326. }
  2327. reader := bytes.NewReader(bytesData)
  2328. gdyb_url := beego.AppConfig.String("gdyb_url")
  2329. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2330. url := gdyb_url + "90991"
  2331. request, err := http.NewRequest("POST", url, reader)
  2332. if err != nil {
  2333. fmt.Println(err.Error())
  2334. return err.Error()
  2335. }
  2336. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2337. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2338. request.Header.Set("x-tif-signature", signature)
  2339. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2340. request.Header.Set("x-tif-nonce", nonce)
  2341. client := http.Client{}
  2342. resp, err := client.Do(request)
  2343. if err != nil {
  2344. fmt.Println(err.Error())
  2345. return err.Error()
  2346. }
  2347. respBytes, err := ioutil.ReadAll(resp.Body)
  2348. if err != nil {
  2349. fmt.Println(err.Error())
  2350. return err.Error()
  2351. }
  2352. fmt.Println(string(respBytes))
  2353. str := string(respBytes)
  2354. return str
  2355. }
  2356. func FJyb90100(psn_no string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  2357. //生成签名
  2358. nonce := GetRandomString(32)
  2359. timestamp := time.Now().Unix()
  2360. signature := setSignature(timestamp, nonce, secret_key)
  2361. //生成输入报文
  2362. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2363. input := make(map[string]interface{})
  2364. inputData := make(map[string]interface{})
  2365. inputMessage["infno"] = "90100" // 交易编码
  2366. inputData["psn_no"] = psn_no // 开始时间
  2367. input["data"] = inputData
  2368. inputMessage["input"] = input //交易输入
  2369. bytesData, err := json.Marshal(inputMessage)
  2370. fmt.Println(string(bytesData))
  2371. if err != nil {
  2372. fmt.Println(err.Error())
  2373. return err.Error()
  2374. }
  2375. reader := bytes.NewReader(bytesData)
  2376. gdyb_url := beego.AppConfig.String("gdyb_url")
  2377. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2378. url := gdyb_url + "90100"
  2379. request, err := http.NewRequest("POST", url, reader)
  2380. if err != nil {
  2381. fmt.Println(err.Error())
  2382. return err.Error()
  2383. }
  2384. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2385. request.Header.Set("x-tif-paasid", gdyb_paasid)
  2386. request.Header.Set("x-tif-signature", signature)
  2387. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2388. request.Header.Set("x-tif-nonce", nonce)
  2389. client := http.Client{}
  2390. resp, err := client.Do(request)
  2391. if err != nil {
  2392. fmt.Println(err.Error())
  2393. return err.Error()
  2394. }
  2395. respBytes, err := ioutil.ReadAll(resp.Body)
  2396. if err != nil {
  2397. fmt.Println(err.Error())
  2398. return err.Error()
  2399. }
  2400. fmt.Println(string(respBytes))
  2401. str := string(respBytes)
  2402. return str
  2403. }
  2404. //func StrPtr(s string) uintptr {
  2405. // return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  2406. //}
  2407. func FJyb2001(secret_key string, org_name string, doctor_name string, code string, insuplcAdmdvs string, mdtrtareaAdmvs string, psn_no string, insutype string, med_type string) (string, string) {
  2408. if med_type == "1111" || med_type == "1112" {
  2409. med_type = "11"
  2410. }
  2411. // 生成签名
  2412. nonce := GetRandomString(32)
  2413. timestamp := time.Now().Unix()
  2414. //signature := setSignature(timestamp, nonce, secret_key)
  2415. tempTime := time.Unix(timestamp, 0)
  2416. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2417. // 生成输入报文
  2418. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor_name, code, insuplcAdmdvs, mdtrtareaAdmvs)
  2419. input := make(map[string]interface{})
  2420. inputData := make(map[string]interface{})
  2421. inputMessage["infno"] = "2001" // 交易编码
  2422. inputData["psn_no"] = psn_no
  2423. inputData["insutype"] = insutype
  2424. inputData["med_type"] = med_type
  2425. inputData["begntime"] = timeFormatOne
  2426. input["data"] = inputData
  2427. inputMessage["input"] = input //交易输入
  2428. bytesData, err := json.Marshal(inputMessage)
  2429. fmt.Println(string(bytesData))
  2430. if err != nil {
  2431. fmt.Println(err.Error())
  2432. return err.Error(), ""
  2433. }
  2434. var json2 string
  2435. cmd := exec.Command("java", "-jar", "yh_hb_fat.jar", "1101", string(bytesData), json2)
  2436. out, err := cmd.Output()
  2437. if err != nil {
  2438. fmt.Println("error:", err.Error())
  2439. }
  2440. return string(out), string(bytesData)
  2441. }
  2442. func SetFjInputMessage(nonce string, timestamp int64, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, url string, app_id string, app_secret string, sign_key string, enc_key string) map[string]interface{} {
  2443. // 生成签名
  2444. tempTime := time.Unix(timestamp, 0)
  2445. //timeFormat := tempTime.Format("20060102150405")
  2446. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2447. //randNum := rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)
  2448. month := time.Unix(1557042972, 0).Format("1")
  2449. year := time.Now().Format("2006")
  2450. month = time.Now().Format("01")
  2451. day := time.Now().Format("02")
  2452. hour := time.Now().Format("15")
  2453. min := time.Now().Format("04")
  2454. sec := time.Now().Format("05")
  2455. msec := time.Now().Format("000")
  2456. // 生成输入报文
  2457. inputMessage := make(map[string]interface{})
  2458. inputMessage["msgid"] = fixmedins_code + year + month + day + hour + min + sec + msec + "0" // 发送方报文 ID
  2459. inputMessage["mdtrtarea_admvs"] = mdtrtarea_admvs // 就医地医保区划
  2460. inputMessage["insuplc_admdvs"] = insuplc_admdvs // 参保地医保区划
  2461. inputMessage["recer_sys_code"] = "1" // 接收方系统代码
  2462. inputMessage["dev_no"] = "" // 设备编号
  2463. inputMessage["dev_safe_info"] = "" // 设备安全信息
  2464. inputMessage["cainfo"] = "" // 数字签名信息
  2465. inputMessage["signtype"] = "SM3" // 签名类型
  2466. inputMessage["infver"] = "V1.0" // 接收方系统代码
  2467. inputMessage["opter_type"] = "1" // 经办人类别
  2468. inputMessage["opter"] = doctor // 经办人
  2469. inputMessage["opter_name"] = doctor // 经办人姓名
  2470. inputMessage["inf_time"] = timeFormatOne // 交易时间
  2471. inputMessage["fixmedins_code"] = fixmedins_code // 定点医药机构编号
  2472. inputMessage["fixmedins_name"] = org_name //定点医药机构名称
  2473. inputMessage["url"] = url //定点医药机构名称
  2474. inputMessage["app_id"] = app_id //定点医药机构名称
  2475. inputMessage["app_secret"] = app_secret //定点医药机构名称
  2476. inputMessage["sign_key"] = sign_key //定点医药机构名称
  2477. inputMessage["enc_key"] = enc_key //定点医药机构名称
  2478. if mdtrtarea_admvs == "440100" {
  2479. inputMessage["sign_no"] = GetSignInInfo(fixmedins_code) //交易签到流水号
  2480. } else {
  2481. inputMessage["sign_no"] = "" //交易签到流水号
  2482. }
  2483. return inputMessage
  2484. }
  2485. //人员信息版本
  2486. //func FjYB1101B(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 {
  2487. // //生成签名
  2488. // nonce := GetRandomString(32)
  2489. // timestamp := time.Now().Unix()
  2490. // signature := setSignature(timestamp, nonce, secret_key)
  2491. // //生成输入报文
  2492. // inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  2493. // input := make(map[string]interface{})
  2494. // inputData := make(map[string]interface{})
  2495. // inputMessage["infno"] = "1101" // 交易编码
  2496. //
  2497. // if certificates == 3 {
  2498. // inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  2499. // inputData["certno"] = certNo // 证件号码
  2500. // inputData["psn_cert_type"] = "99" // 人员证件类型
  2501. //
  2502. // } else {
  2503. // if certificates == 1 {
  2504. // if id_card_type == 1 {
  2505. // inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2506. // inputData["card_sn"] = "" // 卡识别码
  2507. // inputData["certno"] = certNo // 证件号码
  2508. // inputData["psn_cert_type"] = "01" // 人员证件类型
  2509. // } else {
  2510. // inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  2511. // inputData["card_sn"] = "" // 卡识别码
  2512. // inputData["certno"] = certNo // 证件号码
  2513. // inputData["psn_cert_type"] = "01" // 人员证件类型
  2514. // }
  2515. //
  2516. // } else if certificates == 6 {
  2517. // inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  2518. // inputData["card_sn"] = "" // 卡识别码
  2519. // inputData["certno"] = certNo // 证件号码
  2520. // inputData["psn_cert_type"] = "17" // 人员证件类型
  2521. // }
  2522. //
  2523. // }
  2524. //
  2525. // inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  2526. // inputData["begntime"] = "" // 开始时间
  2527. // inputData["psn_name"] = "" // 人员姓名
  2528. // input["data"] = inputData
  2529. // inputMessage["input"] = input //交易输入
  2530. //
  2531. // bytesData, err := json.Marshal(inputMessage)
  2532. // fmt.Println(string(bytesData))
  2533. // if err != nil {
  2534. // fmt.Println(err.Error())
  2535. // return err.Error()
  2536. // }
  2537. // reader := bytes.NewReader(bytesData)
  2538. // gdyb_url := beego.AppConfig.String("gdyb_url")
  2539. // gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  2540. //
  2541. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  2542. // //url := gdyb_url + "1101"
  2543. // var url string
  2544. // if fixmedins_code == "H15049901371" {
  2545. // url = gdyb_url
  2546. // } else {
  2547. // url = gdyb_url + "1101"
  2548. // }
  2549. //
  2550. // fmt.Println(url)
  2551. // fmt.Println(gdyb_paasid)
  2552. // fmt.Println(secret_key)
  2553. // //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  2554. // request, err := http.NewRequest("POST", url, reader)
  2555. // if err != nil {
  2556. // fmt.Println(err.Error())
  2557. // return err.Error()
  2558. // }
  2559. //
  2560. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  2561. // request.Header.Set("x-tif-paasid", gdyb_paasid)
  2562. // request.Header.Set("x-tif-signature", signature)
  2563. // request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  2564. // request.Header.Set("x-tif-nonce", nonce)
  2565. //
  2566. // client := http.Client{}
  2567. // resp, err := client.Do(request)
  2568. // if err != nil {
  2569. // fmt.Println(err.Error())
  2570. // return err.Error()
  2571. // }
  2572. // respBytes, err := ioutil.ReadAll(resp.Body)
  2573. // if err != nil {
  2574. // fmt.Println(err.Error())
  2575. // return err.Error()
  2576. // }
  2577. // fmt.Println(string(respBytes))
  2578. // str := string(respBytes)
  2579. // return str
  2580. //}
  2581. func GetFjBusinessHandleInfo(inputStr []byte) (string, string) {
  2582. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2583. readCard := DllDef.MustFindProc("business_handle")
  2584. if readCard == nil {
  2585. fmt.Println("readcard is nil")
  2586. readCard = DllDef.MustFindProc("read_cardinfo")
  2587. }
  2588. outputStr := make([]byte, 1002288)
  2589. errMessageStr := make([]byte, 2048)
  2590. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&inputStr[0])), uintptr(20000), (uintptr)(unsafe.Pointer(&outputStr[0])), (uintptr)(unsafe.Pointer(&errMessageStr[0])))
  2591. output_info := ConvertByte2String(outputStr, GB18030)
  2592. error_info := ConvertByte2String(errMessageStr, GB18030)
  2593. output_info = Remove0000(output_info)
  2594. error_info = Remove0000(error_info)
  2595. fmt.Println(output_info)
  2596. fmt.Println(error_info)
  2597. if ret2 != 0 {
  2598. return "", ""
  2599. }
  2600. return DeleteExtraSpace(output_info), DeleteExtraSpace(error_info)
  2601. }
  2602. func GetFjAuthorizationInfo(org_id string) {
  2603. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2604. readCard := DllDef.MustFindProc("authorization")
  2605. if readCard == nil {
  2606. fmt.Println("readcard is nil")
  2607. readCard = DllDef.MustFindProc("authorization")
  2608. }
  2609. errMessageStr := make([]byte, 2048)
  2610. psw := org_id[len(org_id)-6 : len(org_id)]
  2611. fmt.Println(psw)
  2612. ret2, _, _ := readCard.Call(StrPtr(org_id), StrPtr(psw), (uintptr)(unsafe.Pointer(&errMessageStr[0])))
  2613. fmt.Println(string(errMessageStr))
  2614. if ret2 != 0 {
  2615. }
  2616. }
  2617. func Remove0000(s string) string {
  2618. str := make([]rune, 0, len(s))
  2619. for _, v := range []rune(s) {
  2620. if v == 0 {
  2621. continue
  2622. }
  2623. str = append(str, v)
  2624. }
  2625. return string(str)
  2626. }
  2627. func ConvertByte2String(byte []byte, charset Charset) string {
  2628. var str string
  2629. switch charset {
  2630. case GB18030:
  2631. decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  2632. str = string(decodeBytes)
  2633. case UTF8:
  2634. fallthrough
  2635. default:
  2636. str = string(byte)
  2637. }
  2638. return str
  2639. }
  2640. func DeleteExtraSpace(s string) string {
  2641. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  2642. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  2643. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  2644. reg, _ := regexp.Compile(regstr) //编译正则表达式
  2645. s2 := make([]byte, len(s1)) //定义字符数组切片
  2646. copy(s2, s1) //将字符串复制到切片
  2647. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  2648. for len(spc_index) > 0 { //找到适配项
  2649. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  2650. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  2651. }
  2652. return string(s2)
  2653. }
  2654. func ReadEleCard(code string) (string, string, string) {
  2655. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2656. readCard := DllDef.MustFindProc("ec_decode")
  2657. //pCardInfo := make([]byte, 8192)
  2658. pBusiCardInfo := make([]byte, 2048)
  2659. pErrMsg := make([]byte, 2048)
  2660. data := make(map[string]interface{})
  2661. inputData := make(map[string]interface{})
  2662. inputData["orgId"] = code
  2663. inputData["businessType"] = "01101"
  2664. inputData["operatorId"] = "1"
  2665. inputData["operatorName"] = "admin"
  2666. inputData["officeId"] = "101"
  2667. inputData["officeName"] = "xt"
  2668. inputData["deviceType"] = ""
  2669. data["data"] = inputData
  2670. data["transType"] = "ec.query"
  2671. data["orgId"] = code
  2672. bytesData, _ := json.Marshal(data)
  2673. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])), (uintptr)(unsafe.Pointer(&pErrMsg[0])))
  2674. fmt.Println(ConvertToString(DeleteExtraSpace(string(pErrMsg)), "gbk", "utf-8"))
  2675. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  2676. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  2677. if ret2 != 0 {
  2678. return "", "", ""
  2679. }
  2680. //readCard.Dll.Release()
  2681. return ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"), ConvertToString(DeleteExtraSpace(string(pErrMsg)), "gbk", "utf-8")
  2682. }
  2683. func ReadEleCardForSettle(code string, user_name string, id int64) (string, string, string) {
  2684. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  2685. readCard := DllDef.MustFindProc("ec_decode")
  2686. pCardInfo := make([]byte, 8192)
  2687. pBusiCardInfo := make([]byte, 8192)
  2688. pErrMsg := make([]byte, 8192)
  2689. data := make(map[string]interface{})
  2690. inputData := make(map[string]interface{})
  2691. inputData["orgId"] = code
  2692. inputData["businessType"] = "01301"
  2693. inputData["operatorId"] = id
  2694. inputData["operatorName"] = user_name
  2695. inputData["officeId"] = "001"
  2696. inputData["officeName"] = "血透科"
  2697. data["data"] = inputData
  2698. data["transType"] = "ec.query"
  2699. data["orgId"] = code
  2700. bytesData, _ := json.Marshal(data)
  2701. pCardInfo = bytesData
  2702. pCardInfo = []byte(ConvertByte2String(pCardInfo, GB18030))
  2703. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])), (uintptr)(unsafe.Pointer(&pErrMsg[0])))
  2704. fmt.Println(ret2)
  2705. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  2706. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  2707. if ret2 != 0 {
  2708. return "", "", ""
  2709. }
  2710. return ConvertByte2String([]byte(DeleteExtraSpace(string(bytesData))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pBusiCardInfo))), GB18030), ConvertByte2String([]byte(DeleteExtraSpace(string(pErrMsg))), GB18030)
  2711. }
  2712. func FJyb3501(struct3501 models.Struct3501) (string, string, string) {
  2713. timestamp := time.Now().Unix()
  2714. nonce := GetRandomString(32)
  2715. // 生成输入报文
  2716. //SetFjInputMessage
  2717. inputMessage := SetFjInputMessage(nonce, timestamp, struct3501.OrgName, struct3501.Opter, struct3501.FixmedinsHilistId, struct3501.InsuplcAdmdvs, struct3501.MdtrtareaAdmvs, struct3501.Url, struct3501.AppId, struct3501.AppSecret, struct3501.SignKey, struct3501.Enckey)
  2718. input := make(map[string]interface{})
  2719. inputData := make(map[string]interface{})
  2720. druginputData := make(map[string]interface{})
  2721. //druginputData2 := make(map[string]interface{})
  2722. inputMessage["infno"] = "3501" // 交易编码
  2723. inputData["med_list_codg"] = struct3501.MedListCodg // 定点医药机构目录编号
  2724. inputData["fixmedins_hilist_id"] = struct3501.FixmedinsHilistId // 定点医药机构目录编号
  2725. inputData["fixmedins_hilist_name"] = struct3501.OrgName // 定点医药机构目录名称
  2726. inputData["rx_flag"] = struct3501.RxFlag //
  2727. inputData["invdate"] = struct3501.Invdate // 人员编号 (来自1101接口返回)
  2728. inputData["inv_cnt"] = struct3501.InvCnt // 人员编号 (来自1101接口返回)
  2729. inputData["manu_lotnum"] = struct3501.ManuLotnum // 人员编号 (来自1101接口返回)
  2730. inputData["fixmedins_bchno"] = struct3501.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2731. inputData["manu_date"] = struct3501.ManuDate // 人员编号 (来自1101接口返回)
  2732. inputData["expy_end"] = struct3501.ExpyEnd // 人员编号 (来自1101接口返回)
  2733. inputData["memo"] = struct3501.Memo // 人员编号 (来自1101接口返回)
  2734. druginputData["drug_trac_codg"] = "123"
  2735. //druginputData2["drugtracinfo"] = druginputData
  2736. inputData["drug_trac_info"] = druginputData
  2737. input["invinfo"] = inputData
  2738. inputMessage["input"] = input //交易输入
  2739. bytesData, err := json.Marshal(inputMessage)
  2740. var requestLog string
  2741. //bytesData, err := json.Marshal(inputMessage)
  2742. requestLog = string(bytesData)
  2743. fmt.Println(string(bytesData))
  2744. if err != nil {
  2745. fmt.Println(err.Error())
  2746. return err.Error(), "", ""
  2747. }
  2748. enc := mahonia.NewEncoder("gbk")
  2749. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2750. return output, requestLog, err_msg
  2751. }
  2752. func FJyb3502(struct3502 models.Struct3502) (string, string, string) {
  2753. timestamp := time.Now().Unix()
  2754. nonce := GetRandomString(32)
  2755. inputMessage := SetFjInputMessage(nonce, timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsHilistId, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Url, struct3502.AppId, struct3502.AppSecret, struct3502.SignKey, struct3502.Enckey)
  2756. //inputMessage := SetInputMessag/**/e(nonce, timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsHilistId, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs)
  2757. // 生成输入报文
  2758. //inputMessage := SetJSInputMessage(timestamp, struct3502.OrgName, struct3502.Opter, struct3502.FixmedinsCode, struct3502.InsuplcAdmdvs, struct3502.MdtrtareaAdmvs, struct3502.Cainfo)
  2759. input := make(map[string]interface{})
  2760. inputData := make(map[string]interface{})
  2761. druginputData := make(map[string]interface{})
  2762. //druginputData2 := make(map[string]interface{})
  2763. inputMessage["infno"] = "3502" // 交易编码
  2764. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  2765. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  2766. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  2767. inputData["fixmedins_hilist_name"] = struct3502.OrgName // 定点医药机构目录名称
  2768. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2769. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  2770. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  2771. inputData["rx_flag"] = struct3502.RxFlag //
  2772. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  2773. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  2774. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  2775. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  2776. druginputData["drug_trac_codg"] = "123"
  2777. //druginputData2["drugtracinfo"] = druginputData
  2778. inputData["drug_trac_info"] = druginputData
  2779. input["invinfo"] = inputData
  2780. inputMessage["input"] = input //交易输入
  2781. bytesData, err := json.Marshal(inputMessage)
  2782. var requestLog string
  2783. //bytesData, err := json.Marshal(inputMessage)
  2784. requestLog = string(bytesData)
  2785. fmt.Println(string(bytesData))
  2786. if err != nil {
  2787. fmt.Println(err.Error())
  2788. return err.Error(), "", ""
  2789. }
  2790. enc := mahonia.NewEncoder("gbk")
  2791. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2792. return output, requestLog, err_msg
  2793. }
  2794. func FJyb3505(struct3505 models.Struct3505) (string, string, string) {
  2795. timestamp := time.Now().Unix()
  2796. nonce := GetRandomString(32)
  2797. //inputMessage := SetInputMessage(nonce, timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs)
  2798. inputMessage := SetFjInputMessage(nonce, timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Url, struct3505.AppId, struct3505.AppSecret, struct3505.SignKey, struct3505.Enckey)
  2799. // 生成输入报文
  2800. //inputMessage := SetJSInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  2801. input := make(map[string]interface{})
  2802. inputData := make(map[string]interface{})
  2803. druginputData := make(map[string]interface{})
  2804. druginputData2 := make(map[string]interface{})
  2805. inputMessage["infno"] = "3505" // 交易编码
  2806. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  2807. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  2808. inputData["fixmedins_hilist_name"] = struct3505.OrgName // 定点医药机构目录名称
  2809. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2810. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  2811. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  2812. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  2813. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  2814. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  2815. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  2816. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  2817. //inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  2818. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  2819. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  2820. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  2821. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  2822. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  2823. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  2824. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  2825. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  2826. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  2827. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  2828. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  2829. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2830. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  2831. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  2832. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  2833. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  2834. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  2835. //inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  2836. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  2837. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  2838. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  2839. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  2840. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  2841. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  2842. druginputData["drug_trac_codg"] = ""
  2843. druginputData2["drugtracinfo"] = druginputData
  2844. inputData["drug_trac_info"] = druginputData2
  2845. input["selinfo"] = inputData
  2846. inputMessage["input"] = input //交易输入
  2847. bytesData, err := json.Marshal(inputMessage)
  2848. var requestLog string
  2849. //bytesData, err := json.Marshal(inputMessage)
  2850. requestLog = string(bytesData)
  2851. fmt.Println(string(bytesData))
  2852. if err != nil {
  2853. fmt.Println(err.Error())
  2854. return err.Error(), "", ""
  2855. }
  2856. enc := mahonia.NewEncoder("gbk")
  2857. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2858. return output, requestLog, err_msg
  2859. }
  2860. func FJyb3506(struct3506 models.Struct3506) (string, string, string) {
  2861. timestamp := time.Now().Unix()
  2862. nonce := GetRandomString(32)
  2863. //inputMessage := SetInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsHilistId, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs)
  2864. inputMessage := SetFjInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsHilistId, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Url, struct3506.AppId, struct3506.AppSecret, struct3506.SignKey, struct3506.Enckey)
  2865. // 生成输入报文
  2866. input := make(map[string]interface{})
  2867. inputData := make(map[string]interface{})
  2868. druginputData := make(map[string]interface{})
  2869. druginputData2 := make(map[string]interface{})
  2870. inputMessage["infno"] = "3506" // 交易编码
  2871. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  2872. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  2873. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  2874. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2875. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  2876. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  2877. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  2878. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  2879. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  2880. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  2881. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  2882. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  2883. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  2884. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  2885. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2886. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  2887. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  2888. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  2889. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  2890. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  2891. inputData["mdtrt_sn"] = "" // 人员编号 (来自1101接口返回)
  2892. druginputData["drug_trac_codg"] = ""
  2893. druginputData2["drugtracinfo"] = druginputData
  2894. inputData["drug_trac_info"] = druginputData2
  2895. input["selinfo"] = inputData
  2896. inputMessage["input"] = input //交易输入
  2897. bytesData, err := json.Marshal(inputMessage)
  2898. var requestLog string
  2899. //bytesData, err := json.Marshal(inputMessage)
  2900. requestLog = string(bytesData)
  2901. fmt.Println(string(bytesData))
  2902. if err != nil {
  2903. fmt.Println(err.Error())
  2904. return err.Error(), "", ""
  2905. }
  2906. enc := mahonia.NewEncoder("gbk")
  2907. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2908. return output, requestLog, err_msg
  2909. }
  2910. func FJyb3507(struct3507 models.Struct3507) (string, string, string) {
  2911. timestamp := time.Now().Unix()
  2912. nonce := GetRandomString(32)
  2913. inputMessage := SetFjInputMessage(nonce, timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Url, struct3507.AppId, struct3507.AppSecret, struct3507.SignKey, struct3507.Enckey)
  2914. input := make(map[string]interface{})
  2915. inputData := make(map[string]interface{})
  2916. inputMessage["infno"] = "3507" // 交易编码
  2917. inputData["fixmedins_bchno"] = struct3507.FixmedinsCode // 人员编号 (来自1101接口返回)
  2918. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  2919. input["data"] = inputData
  2920. inputMessage["input"] = input //交易输入
  2921. bytesData, err := json.Marshal(inputMessage)
  2922. var requestLog string
  2923. //bytesData, err := json.Marshal(inputMessage)
  2924. requestLog = string(bytesData)
  2925. fmt.Println(string(bytesData))
  2926. if err != nil {
  2927. fmt.Println(err.Error())
  2928. return err.Error(), "", ""
  2929. }
  2930. enc := mahonia.NewEncoder("gbk")
  2931. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2932. return output, requestLog, err_msg
  2933. }