hbyb_service.go 124KB

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