fj_service.go 141KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280
  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"] = ""
  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
  2840. inputData["mdtrt_setl_type"] = struct3505.MdtrtSetlType // 人员编号 (来自1101接口返回)
  2841. // 人员编号 (来自1101接口返回)
  2842. //druginputData["drug_trac_codg"] = ""
  2843. //druginputData2["drugtracinfo"] = druginputData
  2844. inputData["drug_trac_info"] = druginputData
  2845. input["selinfo"] = inputData
  2846. inputMessage["input"] = input //交易输入
  2847. bytesData, err := json.Marshal(inputMessage)
  2848. var requestLog string
  2849. //bytesData, err := json.Marshal(inputMessage)
  2850. requestLog = string(bytesData)
  2851. fmt.Println(string(bytesData))
  2852. if err != nil {
  2853. fmt.Println(err.Error())
  2854. return err.Error(), "", ""
  2855. }
  2856. enc := mahonia.NewEncoder("gbk")
  2857. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2858. return output, requestLog, err_msg
  2859. }
  2860. func FJyb3506(struct3506 models.Struct3506) (string, string, string) {
  2861. timestamp := time.Now().Unix()
  2862. nonce := GetRandomString(32)
  2863. //inputMessage := SetInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsHilistId, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs)
  2864. inputMessage := SetFjInputMessage(nonce, timestamp, struct3506.OrgName, struct3506.Opter, struct3506.FixmedinsHilistId, struct3506.InsuplcAdmdvs, struct3506.MdtrtareaAdmvs, struct3506.Url, struct3506.AppId, struct3506.AppSecret, struct3506.SignKey, struct3506.Enckey)
  2865. // 生成输入报文
  2866. input := make(map[string]interface{})
  2867. inputData := make(map[string]interface{})
  2868. druginputData := make(map[string]interface{})
  2869. druginputData2 := make(map[string]interface{})
  2870. inputMessage["infno"] = "3506" // 交易编码
  2871. inputData["med_list_codg"] = struct3506.MedListCodg // 定点医药机构目录编号
  2872. inputData["fixmedins_hilist_id"] = struct3506.FixmedinsHilistId // 定点医药机构目录编号
  2873. inputData["fixmedins_hilist_name"] = struct3506.OrgName // 定点医药机构目录名称
  2874. inputData["fixmedins_bchno"] = struct3506.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2875. inputData["setl_id"] = struct3506.SetlId // 人员编号 (来自1101接口返回)
  2876. inputData["psn_no"] = struct3506.PsnNo // 人员编号 (来自1101接口返回)
  2877. inputData["psn_cert_type"] = struct3506.PsnCertType // 人员编号 (来自1101接口返回)
  2878. inputData["certno"] = struct3506.Certno // 人员编号 (来自1101接口返回)
  2879. inputData["psn_name"] = struct3506.PsnName // 人员编号 (来自1101接口返回)
  2880. inputData["manu_lotnum"] = struct3506.ManuLotnum // 人员编号 (来自1101接口返回)
  2881. inputData["manu_date"] = struct3506.ManuDate // 人员编号 (来自1101接口返回)
  2882. inputData["expy_end"] = struct3506.ExpyEnd // 人员编号 (来自1101接口返回)
  2883. inputData["rx_flag"] = struct3506.RxFlag // 人员编号 (来自1101接口返回)
  2884. inputData["trdn_flag"] = struct3506.TrdnFlag // 人员编号 (来自1101接口返回)
  2885. inputData["finl_trns_pric"] = struct3506.FinlTrnsPric // 人员编号 (来自1101接口返回)
  2886. inputData["sel_retn_cnt"] = struct3506.SelRetnCnt // 人员编号 (来自1101接口返回)
  2887. inputData["sel_retn_time"] = struct3506.SelRetnTime // 人员编号 (来自1101接口返回)
  2888. inputData["sel_retn_opter_name"] = struct3506.SelRetnOpterName // 人员编号 (来自1101接口返回)
  2889. inputData["memo"] = "" // 人员编号 (来自1101接口返回)
  2890. inputData["medins_prod_sel_no"] = "" // 人员编号 (来自1101接口返回)
  2891. inputData["mdtrt_sn"] = "" // 人员编号 (来自1101接口返回)
  2892. druginputData["drug_trac_codg"] = ""
  2893. druginputData2["drugtracinfo"] = druginputData
  2894. inputData["drug_trac_info"] = druginputData2
  2895. input["selinfo"] = inputData
  2896. inputMessage["input"] = input //交易输入
  2897. bytesData, err := json.Marshal(inputMessage)
  2898. var requestLog string
  2899. //bytesData, err := json.Marshal(inputMessage)
  2900. requestLog = string(bytesData)
  2901. fmt.Println(string(bytesData))
  2902. if err != nil {
  2903. fmt.Println(err.Error())
  2904. return err.Error(), "", ""
  2905. }
  2906. enc := mahonia.NewEncoder("gbk")
  2907. return "", "", ""
  2908. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2909. return output, requestLog, err_msg
  2910. }
  2911. func FJyb3507(struct3507 models.Struct3507) (string, string, string) {
  2912. timestamp := time.Now().Unix()
  2913. nonce := GetRandomString(32)
  2914. inputMessage := SetFjInputMessage(nonce, timestamp, struct3507.OrgName, struct3507.Opter, struct3507.FixmedinsCode, struct3507.InsuplcAdmdvs, struct3507.MdtrtareaAdmvs, struct3507.Url, struct3507.AppId, struct3507.AppSecret, struct3507.SignKey, struct3507.Enckey)
  2915. input := make(map[string]interface{})
  2916. inputData := make(map[string]interface{})
  2917. inputMessage["infno"] = "3507" // 交易编码
  2918. inputData["fixmedins_bchno"] = struct3507.FixmedinsBchno // 人员编号 (来自1101接口返回)
  2919. inputData["inv_data_type"] = struct3507.InvDataType // 人员编号 (来自1101接口返回)
  2920. input["data"] = inputData
  2921. inputMessage["input"] = input //交易输入
  2922. bytesData, err := json.Marshal(inputMessage)
  2923. var requestLog string
  2924. //bytesData, err := json.Marshal(inputMessage)
  2925. requestLog = string(bytesData)
  2926. fmt.Println(string(bytesData))
  2927. if err != nil {
  2928. fmt.Println(err.Error())
  2929. return err.Error(), "", ""
  2930. }
  2931. enc := mahonia.NewEncoder("gbk")
  2932. output, err_msg := GetFjBusinessHandleInfo([]byte(enc.ConvertString(string(bytesData))))
  2933. return output, requestLog, err_msg
  2934. }
  2935. func SaveW(w *models.NewDrugWarehouseInfo) (err error) {
  2936. err = writeDb.Save(&w).Error
  2937. return
  2938. }