fj_service.go 111KB

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