hbyb_service.go 128KB

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