fj_service.go 98KB

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