fj_service.go 141KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276
  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, acct 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"] = acct //个人账户支付金额
  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"] = "12345678912345678901"
  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. inputMessage["infno"] = "3502" // 交易编码
  2763. inputData["med_list_codg"] = struct3502.MedListCodg // 定点医药机构目录编号
  2764. inputData["inv_chg_type"] = struct3502.InvChgType // 定点医药机构目录编号
  2765. inputData["fixmedins_hilist_id"] = struct3502.FixmedinsCode // 定点医药机构目录编号
  2766. inputData["fixmedins_hilist_name"] = struct3502.OrgName // 定点医药机构目录名称
  2767. inputData["fixmedins_bchno"] = struct3502.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2768. inputData["pric"] = struct3502.Pric // 人员编号 (来自1101接口返回)
  2769. inputData["cnt"] = struct3502.Cnt // 人员编号 (来自1101接口返回)
  2770. inputData["rx_flag"] = struct3502.RxFlag //
  2771. inputData["inv_chg_time"] = struct3502.InvChgTime // 人员编号 (来自1101接口返回)
  2772. inputData["inv_chg_opter_name"] = "" // 人员编号 (来自1101接口返回)
  2773. inputData["memo"] = struct3502.Memo // 人员编号 (来自1101接口返回)
  2774. inputData["trdn_flag"] = "" // 人员编号 (来自1101接口返回)
  2775. druginputData["drug_trac_codg"] = "12345678912345678901"
  2776. inputData["drug_trac_info"] = druginputData
  2777. input["invinfo"] = inputData
  2778. inputMessage["input"] = input //交易输入
  2779. bytesData, err := json.Marshal(inputMessage)
  2780. var requestLog string
  2781. //bytesData, err := json.Marshal(inputMessage)
  2782. requestLog = string(bytesData)
  2783. fmt.Println(string(bytesData))
  2784. if err != nil {
  2785. fmt.Println(err.Error())
  2786. return err.Error(), "", ""
  2787. }
  2788. enc := mahonia.NewEncoder("gbk")
  2789. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2790. return output, requestLog, err_msg
  2791. }
  2792. func FJyb3505(struct3505 models.Struct3505) (string, string, string) {
  2793. timestamp := time.Now().Unix()
  2794. nonce := GetRandomString(32)
  2795. //inputMessage := SetInputMessage(nonce, timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs)
  2796. inputMessage := SetFjInputMessage(nonce, timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Url, struct3505.AppId, struct3505.AppSecret, struct3505.SignKey, struct3505.Enckey)
  2797. // 生成输入报文
  2798. //inputMessage := SetJSInputMessage(timestamp, struct3505.OrgName, struct3505.Opter, struct3505.FixmedinsHilistId, struct3505.InsuplcAdmdvs, struct3505.MdtrtareaAdmvs, struct3505.Cainfo)
  2799. input := make(map[string]interface{})
  2800. inputData := make(map[string]interface{})
  2801. druginputData := make(map[string]interface{})
  2802. druginputData2 := make(map[string]interface{})
  2803. inputMessage["infno"] = "3505" // 交易编码
  2804. inputData["med_list_codg"] = struct3505.MedListCodg // 定点医药机构目录编号
  2805. inputData["fixmedins_hilist_id"] = struct3505.FixmedinsHilistId // 定点医药机构目录编号
  2806. inputData["fixmedins_hilist_name"] = struct3505.OrgName // 定点医药机构目录名称
  2807. inputData["fixmedins_bchno"] = struct3505.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2808. inputData["prsc_dr_cert_type"] = struct3505.PrscDrCertType // 人员编号 (来自1101接口返回)
  2809. inputData["prsc_dr_certno"] = struct3505.PrscDrCertno // 人员编号 (来自1101接口返回)
  2810. inputData["prsc_dr_name"] = struct3505.PrscDrName // 人员编号 (来自1101接口返回)
  2811. inputData["phar_cert_type"] = struct3505.PharCertType // 人员编号 (来自1101接口返回)
  2812. inputData["phar_certno"] = struct3505.PharCertno // 人员编号 (来自1101接口返回)
  2813. inputData["phar_name"] = struct3505.PharName // 人员编号 (来自1101接口返回)
  2814. inputData["phar_prac_cert_no"] = struct3505.PharPracCertNo // 人员编号 (来自1101接口返回)
  2815. //inputData["hi_feesetl_type"] = struct3505.HiFeesetlType // 人员编号 (来自1101接口返回)
  2816. inputData["setl_id"] = struct3505.SetlId // 人员编号 (来自1101接口返回)
  2817. inputData["mdtrt_sn"] = struct3505.MdtrtSn // 人员编号 (来自1101接口返回)
  2818. inputData["psn_no"] = struct3505.PsnNo // 人员编号 (来自1101接口返回)
  2819. inputData["psn_cert_type"] = struct3505.PsnCertType // 人员编号 (来自1101接口返回)
  2820. inputData["certno"] = struct3505.CertNo // 人员编号 (来自1101接口返回)
  2821. inputData["psn_name"] = struct3505.PsnName // 人员编号 (来自1101接口返回)
  2822. inputData["manu_lotnum"] = struct3505.ManuLotnum // 人员编号 (来自1101接口返回)
  2823. inputData["manu_date"] = struct3505.ManuDate // 人员编号 (来自1101接口返回)
  2824. inputData["expy_end"] = struct3505.ExpyEnd // 人员编号 (来自1101接口返回)
  2825. inputData["rx_flag"] = struct3505.RxFlag // 人员编号 (来自1101接口返回)
  2826. inputData["trdn_flag"] = struct3505.TrdnFlag // 人员编号 (来自1101接口返回)
  2827. inputData["finl_trns_pric"] = struct3505.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2828. inputData["rxno"] = struct3505.Rxno // 人员编号 (来自1101接口返回)
  2829. inputData["rx_circ_flag"] = struct3505.RxCircFlag // 人员编号 (来自1101接口返回)
  2830. inputData["rtal_docno"] = struct3505.RtalDocno // 人员编号 (来自1101接口返回)
  2831. inputData["stoout_no"] = struct3505.StooutNo // 人员编号 (来自1101接口返回)
  2832. inputData["bchno"] = struct3505.Bchno // 人员编号 (来自1101接口返回)
  2833. //inputData["drug_trac_codg"] = struct3505.DrugTracCodg // 人员编号 (来自1101接口返回)
  2834. inputData["drug_prod_barc"] = struct3505.DrugProdBarc // 人员编号 (来自1101接口返回)
  2835. inputData["shelf_posi"] = struct3505.ShelfPosi // 人员编号 (来自1101接口返回)
  2836. inputData["sel_retn_cnt"] = struct3505.SelRetnCnt // 人员编号 (来自1101接口返回)
  2837. inputData["sel_retn_time"] = struct3505.SelRetnTime // 人员编号 (来自1101接口返回)
  2838. inputData["sel_retn_opter_name"] = struct3505.SelRetnOpterName // 人员编号 (来自1101接口返回)
  2839. inputData["memo"] = struct3505.Memo // 人员编号 (来自1101接口返回)
  2840. druginputData["drug_trac_codg"] = ""
  2841. druginputData2["drugtracinfo"] = druginputData
  2842. inputData["drug_trac_info"] = druginputData2
  2843. input["selinfo"] = inputData
  2844. inputMessage["input"] = input //交易输入
  2845. bytesData, err := json.Marshal(inputMessage)
  2846. var requestLog string
  2847. //bytesData, err := json.Marshal(inputMessage)
  2848. requestLog = string(bytesData)
  2849. fmt.Println(string(bytesData))
  2850. if err != nil {
  2851. fmt.Println(err.Error())
  2852. return err.Error(), "", ""
  2853. }
  2854. enc := mahonia.NewEncoder("gbk")
  2855. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2856. return output, requestLog, err_msg
  2857. }
  2858. func FJyb3506(struct3506 models.Struct3506) (string, string, string) {
  2859. timestamp := time.Now().Unix()
  2860. nonce := GetRandomString(32)
  2861. //inputMessage := SetInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsHilistId, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs)
  2862. inputMessage := SetFjInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsHilistId, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Url, struct3506.AppId, struct3506.AppSecret, struct3506.SignKey, struct3506.Enckey)
  2863. // 生成输入报文
  2864. input := make(map[string]interface{})
  2865. inputData := make(map[string]interface{})
  2866. druginputData := make(map[string]interface{})
  2867. druginputData2 := make(map[string]interface{})
  2868. inputMessage["infno"] = "3506" // 交易编码
  2869. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  2870. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  2871. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  2872. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2873. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  2874. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  2875. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  2876. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  2877. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  2878. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  2879. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  2880. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  2881. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  2882. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  2883. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2884. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  2885. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  2886. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  2887. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  2888. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  2889. inputData["mdtrt_sn"] = "" // 人员编号 (来自1101接口返回)
  2890. druginputData["drug_trac_codg"] = ""
  2891. druginputData2["drugtracinfo"] = druginputData
  2892. inputData["drug_trac_info"] = druginputData2
  2893. input["selinfo"] = inputData
  2894. inputMessage["input"] = input //交易输入
  2895. bytesData, err := json.Marshal(inputMessage)
  2896. var requestLog string
  2897. //bytesData, err := json.Marshal(inputMessage)
  2898. requestLog = string(bytesData)
  2899. fmt.Println(string(bytesData))
  2900. if err != nil {
  2901. fmt.Println(err.Error())
  2902. return err.Error(), "", ""
  2903. }
  2904. enc := mahonia.NewEncoder("gbk")
  2905. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2906. return output, requestLog, err_msg
  2907. }
  2908. func FJyb3507(struct3507 models.Struct3507) (string, string, string) {
  2909. timestamp := time.Now().Unix()
  2910. nonce := GetRandomString(32)
  2911. inputMessage := SetFjInputMessage(nonce, timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Url, struct3507.AppId, struct3507.AppSecret, struct3507.SignKey, struct3507.Enckey)
  2912. input := make(map[string]interface{})
  2913. inputData := make(map[string]interface{})
  2914. inputMessage["infno"] = "3507" // 交易编码
  2915. inputData["fixmedins_bchno"] = struct3507.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2916. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  2917. input["data"] = inputData
  2918. inputMessage["input"] = input //交易输入
  2919. bytesData, err := json.Marshal(inputMessage)
  2920. var requestLog string
  2921. //bytesData, err := json.Marshal(inputMessage)
  2922. requestLog = string(bytesData)
  2923. fmt.Println(string(bytesData))
  2924. if err != nil {
  2925. fmt.Println(err.Error())
  2926. return err.Error(), "", ""
  2927. }
  2928. enc := mahonia.NewEncoder("gbk")
  2929. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2930. return output, requestLog, err_msg
  2931. }
  2932. func SaveW(w *models.NewDrugWarehouseInfo) (err error) {
  2933. err = writeDb.Save(&w).Error
  2934. return
  2935. }