fj_service.go 126KB

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