hbyb_service.go 125KB

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