fj_service.go 110KB

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