gdyb_zifei_service.go 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832
  1. package service
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "github.com/astaxie/beego"
  8. "io/ioutil"
  9. "net/http"
  10. "strconv"
  11. "time"
  12. )
  13. // 人员基本信息
  14. func Gdyb4201A(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4201A models.Struct4201A) (string, string) {
  15. //生成签名
  16. nonce := GetRandomString(32)
  17. timestamp := time.Now().Unix()
  18. signature := setSignature(timestamp, nonce, secret_key)
  19. //生成输入报文
  20. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  21. input := make(map[string]interface{})
  22. inputDatas := make([]map[string]interface{}, 0)
  23. inputMessage["infno"] = "4201A" // 交易编码
  24. for _, item := range struct4201A.Fopfd {
  25. inputData := make(map[string]interface{})
  26. inputData["fixmedins_mdtrt_id"] = item.FixmedinsMdtrtID
  27. inputData["med_type"] = item.MedType
  28. inputData["bkkp_sn"] = item.BkkpSn
  29. inputData["fee_ocur_time"] = item.FeeOcurTime
  30. inputData["fixmedins_code"] = item.FixmedinsCode
  31. inputData["fixmedins_name"] = item.FixmedinsName
  32. inputData["cnt"] = item.Cnt
  33. inputData["pric"] = item.Pric
  34. inputData["det_item_fee_sumamt"] = item.DetItemFeeSumamt
  35. inputData["med_list_codg"] = item.MedListCodg
  36. inputData["medins_list_name"] = item.MedinsListName
  37. inputData["medins_list_code"] = item.MedinsListCodg
  38. inputData["med_chrgitm_type"] = item.MedChrgitmType
  39. inputData["prodname"] = item.Prodname
  40. inputData["bilg_dept_codg"] = item.BilgDeptCodg
  41. inputData["bilg_dept_name"] = item.BilgDeptName
  42. inputData["bilg_dr_code"] = item.BilgDrCode
  43. inputData["bilg_dr_name"] = item.BilgDrName
  44. inputData["acord_dept_codg"] = ""
  45. inputData["acord_dept_name"] = ""
  46. inputData["acord_dr_code"] = ""
  47. inputData["acord_dr_name"] = ""
  48. inputData["tcmdrug_used_way"] = ""
  49. inputData["etip_flag"] = ""
  50. inputData["etip_hosp_code"] = ""
  51. inputData["dscg_tkdrug_flag"] = ""
  52. inputData["sin_dos_dscr"] = ""
  53. inputData["used_frqu_dscr"] = ""
  54. inputData["prd_days"] = ""
  55. inputData["medc_way_dscr"] = ""
  56. inputData["memo"] = item.Memo
  57. inputData["fulamt_ownpay_amt"] = ""
  58. inputData["overlmt_selfpay"] = ""
  59. inputData["preselfpay_amt"] = ""
  60. inputData["inscp_amt"] = ""
  61. inputDatas = append(inputDatas, inputData)
  62. }
  63. input["fsiOwnpayPatnFeeListDDTO"] = inputDatas
  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. reader := bytes.NewReader(bytesData)
  74. gdyb_url := beego.AppConfig.String("gdyb_url")
  75. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  76. var url string
  77. if fixmedins_code == "H15049901371" {
  78. url = gdyb_url
  79. } else {
  80. url = gdyb_url + "4201A"
  81. }
  82. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  83. request, err := http.NewRequest("POST", url, reader)
  84. if err != nil {
  85. fmt.Println(err.Error())
  86. return err.Error(), ""
  87. }
  88. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  89. request.Header.Set("x-tif-paasid", gdyb_paasid)
  90. request.Header.Set("x-tif-signature", signature)
  91. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  92. request.Header.Set("x-tif-nonce", nonce)
  93. client := http.Client{}
  94. resp, err := client.Do(request)
  95. if err != nil {
  96. fmt.Println(err.Error())
  97. return err.Error(), ""
  98. }
  99. respBytes, err := ioutil.ReadAll(resp.Body)
  100. if err != nil {
  101. fmt.Println(err.Error())
  102. return err.Error(), ""
  103. }
  104. fmt.Println(string(respBytes))
  105. str := string(respBytes)
  106. return str, inputLog
  107. }
  108. func Gdyb4202(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4202 models.Struct4202) (string, string) {
  109. //生成签名
  110. nonce := GetRandomString(32)
  111. timestamp := time.Now().Unix()
  112. signature := setSignature(timestamp, nonce, secret_key)
  113. //生成输入报文
  114. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  115. input := make(map[string]interface{})
  116. inputData := make(map[string]interface{})
  117. inputMessage["infno"] = "4202" // 交易编码
  118. feedetail := make([]map[string]interface{}, 0)
  119. inputData["fixmedins_mdtrt_id"] = struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID
  120. inputData["fixmedins_code"] = struct4202.OwnPayPatnMdtrtD.FixmedinsCode
  121. inputData["fixmedins_name"] = struct4202.OwnPayPatnMdtrtD.FixmedinsName
  122. inputData["psn_cert_type"] = struct4202.OwnPayPatnMdtrtD.PsnCertType
  123. inputData["certno"] = struct4202.OwnPayPatnMdtrtD.Certno
  124. inputData["psn_name"] = struct4202.OwnPayPatnMdtrtD.PsnName
  125. inputData["gend"] = ""
  126. inputData["naty"] = ""
  127. inputData["brdy"] = ""
  128. inputData["age"] = ""
  129. inputData["coner_name"] = ""
  130. inputData["tel"] = ""
  131. inputData["addr"] = ""
  132. inputData["begntime"] = struct4202.OwnPayPatnMdtrtD.Begntime
  133. inputData["endtime"] = ""
  134. inputData["med_type"] = struct4202.OwnPayPatnMdtrtD.MedType
  135. inputData["ipt_otp_no"] = ""
  136. inputData["medrcdno"] = ""
  137. inputData["chfpdr_code"] = ""
  138. inputData["adm_dept_dscr"] = ""
  139. inputData["adm_dept_codg"] = ""
  140. inputData["adm_dept_name"] = ""
  141. inputData["adm_bed"] = ""
  142. inputData["wardarea_bed"] = ""
  143. inputData["traf_dept_flag"] = ""
  144. inputData["dscg_maindiag_code"] = ""
  145. inputData["dscg_dept_codg"] = ""
  146. inputData["dscg_dept_name"] = ""
  147. inputData["dscg_bed"] = ""
  148. inputData["dscg_way"] = ""
  149. inputData["main_cond_dscr"] = ""
  150. inputData["dise_no"] = ""
  151. inputData["dise_name"] = ""
  152. inputData["oprn_oprt_code"] = ""
  153. inputData["oprn_oprt_name"] = ""
  154. inputData["otp_diag_info"] = ""
  155. inputData["inhosp_stas"] = "0"
  156. inputData["die_date"] = ""
  157. inputData["ipt_days"] = ""
  158. inputData["fpsc_no"] = ""
  159. inputData["matn_type"] = ""
  160. inputData["birctrl_type"] = ""
  161. inputData["latechb_flag"] = ""
  162. inputData["geso_val"] = ""
  163. inputData["fetts"] = ""
  164. inputData["fetus_cnt"] = ""
  165. inputData["pret_flag"] = ""
  166. inputData["prey_time"] = ""
  167. inputData["birctrl_matn_date"] = ""
  168. inputData["cop_flag"] = ""
  169. inputData["vali_flag"] = "1"
  170. inputData["memo"] = ""
  171. inputData["opter_id"] = ""
  172. inputData["opter_name"] = ""
  173. inputData["opt_time"] = ""
  174. inputData["chfpdr_name"] = ""
  175. inputData["dscg_maindiag_name"] = ""
  176. inputData["medfee_sumamt"] = struct4202.OwnPayPatnMdtrtD.MedfeeSumamt
  177. inputData["elec_bill_code"] = ""
  178. inputData["elec_billno_code"] = ""
  179. inputData["exp_content"] = ""
  180. for index, item := range struct4202.ODiagListD {
  181. feedetailInfo := make(map[string]interface{})
  182. feedetailInfo["inout_diag_type"] = item.InoutDiagType
  183. feedetailInfo["diag_type"] = item.DiagType // 就诊 ID(来自2201接口返回)
  184. feedetailInfo["maindiag_flag"] = item.MaindiagFlag // 人员编号 (来自1101接口返回)
  185. feedetailInfo["diag_srt_no"] = index // 收费批次号
  186. feedetailInfo["diag_code"] = item.DiagCode // 病种编码
  187. feedetailInfo["diag_name"] = item.DiagName // 处方号
  188. feedetailInfo["diag_dept"] = ""
  189. feedetailInfo["diag_dr_code"] = ""
  190. feedetailInfo["diag_dr_name"] = ""
  191. feedetailInfo["diag_time"] = ""
  192. feedetailInfo["vali_flag"] = "1"
  193. feedetail = append(feedetail, feedetailInfo)
  194. }
  195. input["ownPayPatnDiagListD"] = feedetail
  196. input["ownPayPatnMdtrtD"] = inputData
  197. inputMessage["input"] = input //交易输入
  198. var inputLog string
  199. bytesData, err := json.Marshal(inputMessage)
  200. inputLog = string(bytesData)
  201. fmt.Println(string(bytesData))
  202. if err != nil {
  203. fmt.Println(err.Error())
  204. return err.Error(), ""
  205. }
  206. reader := bytes.NewReader(bytesData)
  207. gdyb_url := beego.AppConfig.String("gdyb_url")
  208. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  209. var url string
  210. if fixmedins_code == "H15049901371" {
  211. url = gdyb_url
  212. } else {
  213. url = gdyb_url + "4202"
  214. }
  215. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  216. request, err := http.NewRequest("POST", url, reader)
  217. if err != nil {
  218. fmt.Println(err.Error())
  219. return err.Error(), ""
  220. }
  221. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  222. request.Header.Set("x-tif-paasid", gdyb_paasid)
  223. request.Header.Set("x-tif-signature", signature)
  224. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  225. request.Header.Set("x-tif-nonce", nonce)
  226. client := http.Client{}
  227. resp, err := client.Do(request)
  228. if err != nil {
  229. fmt.Println(err.Error())
  230. return err.Error(), ""
  231. }
  232. respBytes, err := ioutil.ReadAll(resp.Body)
  233. if err != nil {
  234. fmt.Println(err.Error())
  235. return err.Error(), ""
  236. }
  237. fmt.Println(string(respBytes))
  238. str := string(respBytes)
  239. return str, inputLog
  240. }
  241. func Gdyb4203(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_mdtrt_id string) (string, string) {
  242. //生成签名
  243. nonce := GetRandomString(32)
  244. timestamp := time.Now().Unix()
  245. signature := setSignature(timestamp, nonce, secret_key)
  246. //生成输入报文
  247. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  248. //input := make(map[string]interface{})
  249. inputData := make(map[string]interface{})
  250. inputMessage["infno"] = "4203" // 交易编码
  251. inputData["fixmedins_mdtrt_id"] = fixmedins_mdtrt_id // 开始时间
  252. inputData["fixmedins_code"] = fixmedins_code // 开始时间
  253. inputData["cplt_flag"] = "1" // 人员姓名
  254. inputMessage["input"] = inputData //交易输入
  255. var inputLog string
  256. bytesData, err := json.Marshal(inputMessage)
  257. inputLog = string(bytesData)
  258. fmt.Println(string(bytesData))
  259. if err != nil {
  260. fmt.Println(err.Error())
  261. return err.Error(), ""
  262. }
  263. reader := bytes.NewReader(bytesData)
  264. gdyb_url := beego.AppConfig.String("gdyb_url")
  265. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  266. var url string
  267. if fixmedins_code == "H15049901371" {
  268. url = gdyb_url
  269. } else {
  270. url = gdyb_url + "4203"
  271. }
  272. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  273. request, err := http.NewRequest("POST", url, reader)
  274. if err != nil {
  275. fmt.Println(err.Error())
  276. return err.Error(), ""
  277. }
  278. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  279. request.Header.Set("x-tif-paasid", gdyb_paasid)
  280. request.Header.Set("x-tif-signature", signature)
  281. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  282. request.Header.Set("x-tif-nonce", nonce)
  283. client := http.Client{}
  284. resp, err := client.Do(request)
  285. if err != nil {
  286. fmt.Println(err.Error())
  287. return err.Error(), ""
  288. }
  289. respBytes, err := ioutil.ReadAll(resp.Body)
  290. if err != nil {
  291. fmt.Println(err.Error())
  292. return err.Error(), ""
  293. }
  294. fmt.Println(string(respBytes))
  295. str := string(respBytes)
  296. return str, inputLog
  297. }
  298. func Gdyb4204(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates string, psn_name string) (string, string) {
  299. //生成签名
  300. nonce := GetRandomString(32)
  301. timestamp := time.Now().Unix()
  302. signature := setSignature(timestamp, nonce, secret_key)
  303. //生成输入报文
  304. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  305. input := make(map[string]interface{})
  306. inputData := make(map[string]interface{})
  307. feedetail := make([]map[string]interface{}, 0)
  308. inputMessage["infno"] = "4204" // 交易编码
  309. inputData["fixmedins_mdtrt_id"] = ""
  310. inputData["fixmedins_code"] = ""
  311. feedetailInfo := make(map[string]interface{})
  312. feedetailInfo["bkkp_sn"] = ""
  313. feedetail = append(feedetail, feedetailInfo)
  314. input["feedetl"] = feedetail
  315. input["feedetail"] = inputData
  316. inputMessage["input"] = input //交易输入
  317. var inputLog string
  318. bytesData, err := json.Marshal(inputMessage)
  319. inputLog = string(bytesData)
  320. fmt.Println(string(bytesData))
  321. if err != nil {
  322. fmt.Println(err.Error())
  323. return err.Error(), ""
  324. }
  325. reader := bytes.NewReader(bytesData)
  326. gdyb_url := beego.AppConfig.String("gdyb_url")
  327. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  328. var url string
  329. if fixmedins_code == "H15049901371" {
  330. url = gdyb_url
  331. } else {
  332. url = gdyb_url + "1101"
  333. }
  334. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  335. request, err := http.NewRequest("POST", url, reader)
  336. if err != nil {
  337. fmt.Println(err.Error())
  338. return err.Error(), ""
  339. }
  340. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  341. request.Header.Set("x-tif-paasid", gdyb_paasid)
  342. request.Header.Set("x-tif-signature", signature)
  343. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  344. request.Header.Set("x-tif-nonce", nonce)
  345. client := http.Client{}
  346. resp, err := client.Do(request)
  347. if err != nil {
  348. fmt.Println(err.Error())
  349. return err.Error(), ""
  350. }
  351. respBytes, err := ioutil.ReadAll(resp.Body)
  352. if err != nil {
  353. fmt.Println(err.Error())
  354. return err.Error(), ""
  355. }
  356. fmt.Println(string(respBytes))
  357. str := string(respBytes)
  358. return str, inputLog
  359. }
  360. func Gdyb4205(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4202 models.Struct4202, struct4201A models.Struct4201A) (string, string) {
  361. //生成签名
  362. nonce := GetRandomString(32)
  363. timestamp := time.Now().Unix()
  364. signature := setSignature(timestamp, nonce, secret_key)
  365. //生成输入报文
  366. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  367. //input := make(map[string]interface{})
  368. inputData0 := make(map[string]interface{})
  369. inputData := make(map[string]interface{})
  370. inputMessage["infno"] = "4205" // 交易编码
  371. inputData["fixmedins_mdtrt_id"] = struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID
  372. inputData["fixmedins_code"] = struct4202.OwnPayPatnMdtrtD.FixmedinsCode
  373. inputData["fixmedins_name"] = struct4202.OwnPayPatnMdtrtD.FixmedinsName
  374. inputData["psn_cert_type"] = struct4202.OwnPayPatnMdtrtD.PsnCertType
  375. inputData["certno"] = struct4202.OwnPayPatnMdtrtD.Certno
  376. inputData["psn_name"] = struct4202.OwnPayPatnMdtrtD.PsnName
  377. inputData["gend"] = ""
  378. inputData["naty"] = ""
  379. inputData["brdy"] = ""
  380. inputData["age"] = ""
  381. inputData["coner_name"] = ""
  382. inputData["tel"] = ""
  383. inputData["addr"] = ""
  384. inputData["begntime"] = struct4202.OwnPayPatnMdtrtD.Begntime
  385. inputData["endtime"] = ""
  386. inputData["med_type"] = struct4202.OwnPayPatnMdtrtD.MedType
  387. inputData["main_cond_dscr"] = ""
  388. inputData["dise_codg"] = ""
  389. inputData["dise_name"] = ""
  390. inputData["birctrl_type"] = ""
  391. inputData["birctrl_matn_date"] = ""
  392. inputData["matn_type"] = ""
  393. inputData["geso_val"] = ""
  394. inputData["elec_bill_code"] = ""
  395. inputData["elec_billno_code"] = ""
  396. inputData["elec_bill_chkcode"] = ""
  397. inputData["exp_content"] = ""
  398. diagInfos := make([]map[string]interface{}, 0)
  399. for index, item := range struct4202.ODiagListD {
  400. diagInfo := make(map[string]interface{})
  401. diagInfo["diag_type"] = item.DiagType // 就诊 ID(来自2201接口返回)
  402. diagInfo["diag_srt_no"] = index // 收费批次号
  403. diagInfo["diag_code"] = item.DiagCode // 病种编码
  404. diagInfo["diag_name"] = item.DiagName // 处方号
  405. diagInfo["diag_dept"] = "血透"
  406. diagInfo["diag_dr_code"] = item.DiagDrCode
  407. diagInfo["diag_dr_name"] = item.DiagDrName
  408. diagInfo["diag_time"] = item.DiagTime
  409. diagInfo["vali_flag"] = "1"
  410. diagInfos = append(diagInfos, diagInfo)
  411. }
  412. inputData0["diseinfo"] = diagInfos
  413. feedetail := make([]map[string]interface{}, 0)
  414. for _, item := range struct4201A.Fopfd {
  415. fmt.Println("item.BkkpSn")
  416. fmt.Println(item.BkkpSn)
  417. inputData := make(map[string]interface{})
  418. inputData["fixmedins_mdtrt_id"] = item.FixmedinsMdtrtID
  419. inputData["med_type"] = item.MedType
  420. inputData["bkkp_sn"] = item.BkkpSn
  421. inputData["fee_ocur_time"] = item.FeeOcurTime
  422. inputData["fixmedins_code"] = item.FixmedinsCode
  423. inputData["fixmedins_name"] = item.FixmedinsName
  424. inputData["cnt"] = item.Cnt
  425. inputData["pric"] = item.Pric
  426. inputData["det_item_fee_sumamt"] = item.DetItemFeeSumamt
  427. inputData["medins_list_name"] = item.MedinsListName
  428. inputData["medins_list_code"] = item.MedinsListCodg
  429. inputData["med_chrgitm_type"] = item.MedChrgitmType
  430. inputData["prodname"] = item.Prodname
  431. inputData["bilg_dept_codg"] = item.BilgDeptCodg
  432. inputData["bilg_dept_name"] = item.BilgDeptName
  433. inputData["bilg_dr_code"] = item.BilgDrCode
  434. inputData["bilg_dr_name"] = item.BilgDrName
  435. inputData["acord_dept_codg"] = ""
  436. inputData["acord_dept_name"] = ""
  437. inputData["acord_dr_code"] = ""
  438. inputData["acord_dr_name"] = ""
  439. inputData["tcmdrug_used_way"] = ""
  440. inputData["etip_flag"] = ""
  441. inputData["etip_hosp_code"] = ""
  442. inputData["dscg_tkdrug_flag"] = ""
  443. inputData["sin_dos_dscr"] = ""
  444. inputData["used_frqu_dscr"] = ""
  445. inputData["prd_days"] = ""
  446. inputData["medc_way_dscr"] = ""
  447. inputData["memo"] = item.Memo
  448. inputData["fulamt_ownpay_amt"] = ""
  449. inputData["overlmt_selfpay"] = ""
  450. inputData["preselfpay_amt"] = ""
  451. inputData["inscp_amt"] = ""
  452. inputData["rxno"] = ""
  453. feedetail = append(feedetail, inputData)
  454. }
  455. inputData0["feedetail"] = feedetail
  456. inputData0["mdtrtinfo"] = inputData
  457. inputMessage["input"] = inputData0 //交易输入
  458. var inputLog string
  459. bytesData, err := json.Marshal(inputMessage)
  460. inputLog = string(bytesData)
  461. fmt.Println(string(bytesData))
  462. if err != nil {
  463. fmt.Println(err.Error())
  464. return err.Error(), ""
  465. }
  466. reader := bytes.NewReader(bytesData)
  467. gdyb_url := beego.AppConfig.String("gdyb_url")
  468. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  469. var url string
  470. if fixmedins_code == "H15049901371" {
  471. url = gdyb_url
  472. } else {
  473. url = gdyb_url + "4205"
  474. }
  475. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  476. request, err := http.NewRequest("POST", url, reader)
  477. if err != nil {
  478. fmt.Println(err.Error())
  479. return err.Error(), ""
  480. }
  481. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  482. request.Header.Set("x-tif-paasid", gdyb_paasid)
  483. request.Header.Set("x-tif-signature", signature)
  484. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  485. request.Header.Set("x-tif-nonce", nonce)
  486. client := http.Client{}
  487. resp, err := client.Do(request)
  488. if err != nil {
  489. fmt.Println(err.Error())
  490. return err.Error(), ""
  491. }
  492. respBytes, err := ioutil.ReadAll(resp.Body)
  493. if err != nil {
  494. fmt.Println(err.Error())
  495. return err.Error(), ""
  496. }
  497. fmt.Println(string(respBytes))
  498. str := string(respBytes)
  499. return str, inputLog
  500. }
  501. func Gdyb4206(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  502. //生成签名
  503. nonce := GetRandomString(32)
  504. timestamp := time.Now().Unix()
  505. signature := setSignature(timestamp, nonce, secret_key)
  506. //生成输入报文
  507. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  508. input := make(map[string]interface{})
  509. inputData := make(map[string]interface{})
  510. inputMessage["infno"] = "4206" // 交易编码
  511. inputData["fixmedins_mdtrt_id"] = "" // 开始时间
  512. inputData["fixmedins_code"] = "" // 开始时间
  513. input["input"] = inputData // 开始时间
  514. inputMessage["input"] = input //交易输入
  515. var inputLog string
  516. bytesData, err := json.Marshal(inputMessage)
  517. inputLog = string(bytesData)
  518. fmt.Println(string(bytesData))
  519. if err != nil {
  520. fmt.Println(err.Error())
  521. return err.Error(), ""
  522. }
  523. reader := bytes.NewReader(bytesData)
  524. gdyb_url := beego.AppConfig.String("gdyb_url")
  525. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  526. var url string
  527. if fixmedins_code == "H15049901371" {
  528. url = gdyb_url
  529. } else {
  530. url = gdyb_url + "1101"
  531. }
  532. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  533. request, err := http.NewRequest("POST", url, reader)
  534. if err != nil {
  535. fmt.Println(err.Error())
  536. return err.Error(), ""
  537. }
  538. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  539. request.Header.Set("x-tif-paasid", gdyb_paasid)
  540. request.Header.Set("x-tif-signature", signature)
  541. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  542. request.Header.Set("x-tif-nonce", nonce)
  543. client := http.Client{}
  544. resp, err := client.Do(request)
  545. if err != nil {
  546. fmt.Println(err.Error())
  547. return err.Error(), ""
  548. }
  549. respBytes, err := ioutil.ReadAll(resp.Body)
  550. if err != nil {
  551. fmt.Println(err.Error())
  552. return err.Error(), ""
  553. }
  554. fmt.Println(string(respBytes))
  555. str := string(respBytes)
  556. return str, inputLog
  557. }
  558. func Gdyb4207(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4207 models.Struct4207) (string, string) {
  559. //生成签名
  560. nonce := GetRandomString(32)
  561. timestamp := time.Now().Unix()
  562. signature := setSignature(timestamp, nonce, secret_key)
  563. //生成输入报文
  564. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  565. input := make(map[string]interface{})
  566. inputData := make(map[string]interface{})
  567. inputMessage["infno"] = "4207" // 交易编码
  568. inputData["fixmedins_mdtrt_id"] = struct4207.FixmedinsMdtrtID // 开始时间
  569. inputData["fixmedins_code"] = struct4207.FixmedinsCode // 人员姓名
  570. inputData["page_num"] = struct4207.PageNum // 人员姓名
  571. inputData["page_size"] = struct4207.PageSize // 人员姓名
  572. input["input"] = inputData
  573. inputMessage["input"] = input //交易输入
  574. var inputLog string
  575. bytesData, err := json.Marshal(inputMessage)
  576. inputLog = string(bytesData)
  577. fmt.Println(string(bytesData))
  578. if err != nil {
  579. fmt.Println(err.Error())
  580. return err.Error(), ""
  581. }
  582. reader := bytes.NewReader(bytesData)
  583. gdyb_url := beego.AppConfig.String("gdyb_url")
  584. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  585. var url string
  586. if fixmedins_code == "H15049901371" {
  587. url = gdyb_url
  588. } else {
  589. url = gdyb_url + "4207"
  590. }
  591. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  592. request, err := http.NewRequest("POST", url, reader)
  593. if err != nil {
  594. fmt.Println(err.Error())
  595. return err.Error(), ""
  596. }
  597. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  598. request.Header.Set("x-tif-paasid", gdyb_paasid)
  599. request.Header.Set("x-tif-signature", signature)
  600. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  601. request.Header.Set("x-tif-nonce", nonce)
  602. client := http.Client{}
  603. resp, err := client.Do(request)
  604. if err != nil {
  605. fmt.Println(err.Error())
  606. return err.Error(), ""
  607. }
  608. respBytes, err := ioutil.ReadAll(resp.Body)
  609. if err != nil {
  610. fmt.Println(err.Error())
  611. return err.Error(), ""
  612. }
  613. fmt.Println(string(respBytes))
  614. str := string(respBytes)
  615. return str, inputLog
  616. }
  617. func Gdyb4208(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4208 models.Struct4208) (string, string) {
  618. //生成签名
  619. nonce := GetRandomString(32)
  620. timestamp := time.Now().Unix()
  621. signature := setSignature(timestamp, nonce, secret_key)
  622. //生成输入报文
  623. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  624. input := make(map[string]interface{})
  625. inputData := make(map[string]interface{})
  626. inputMessage["infno"] = "4208" // 交易编码
  627. inputData["psn_cert_type"] = struct4208.PsnCertType // 开始时间
  628. inputData["certno"] = struct4208.Certno // 人员姓名
  629. inputData["psn_name"] = struct4208.PsnName // 人员姓名
  630. inputData["begintime"] = struct4208.Begntime // 人员姓名
  631. inputData["endtime"] = struct4208.Endtime // 人员姓名
  632. inputData["med_type"] = struct4208.MedType // 人员姓名
  633. inputData["medfee_sumamt"] = struct4208.MedfeeSumamt // 人员姓名
  634. inputData["elec_billno_code"] = struct4208.ElecBillnoCode // 人员姓名
  635. inputData["page_num"] = struct4208.PageNum // 人员姓名
  636. inputData["page_size"] = struct4208.PageSize // 人员姓名
  637. input["input"] = inputData
  638. inputMessage["input"] = input //交易输入
  639. var inputLog string
  640. bytesData, err := json.Marshal(inputMessage)
  641. inputLog = string(bytesData)
  642. fmt.Println(string(bytesData))
  643. if err != nil {
  644. fmt.Println(err.Error())
  645. return err.Error(), ""
  646. }
  647. reader := bytes.NewReader(bytesData)
  648. gdyb_url := beego.AppConfig.String("gdyb_url")
  649. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  650. var url string
  651. if fixmedins_code == "H15049901371" {
  652. url = gdyb_url
  653. } else {
  654. url = gdyb_url + "1101"
  655. }
  656. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  657. request, err := http.NewRequest("POST", url, reader)
  658. if err != nil {
  659. fmt.Println(err.Error())
  660. return err.Error(), ""
  661. }
  662. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  663. request.Header.Set("x-tif-paasid", gdyb_paasid)
  664. request.Header.Set("x-tif-signature", signature)
  665. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  666. request.Header.Set("x-tif-nonce", nonce)
  667. client := http.Client{}
  668. resp, err := client.Do(request)
  669. if err != nil {
  670. fmt.Println(err.Error())
  671. return err.Error(), ""
  672. }
  673. respBytes, err := ioutil.ReadAll(resp.Body)
  674. if err != nil {
  675. fmt.Println(err.Error())
  676. return err.Error(), ""
  677. }
  678. fmt.Println(string(respBytes))
  679. str := string(respBytes)
  680. return str, inputLog
  681. }
  682. func Gdyb4209(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4209 models.Struct4209) (string, string) {
  683. //生成签名
  684. nonce := GetRandomString(32)
  685. timestamp := time.Now().Unix()
  686. signature := setSignature(timestamp, nonce, secret_key)
  687. //生成输入报文
  688. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  689. input := make(map[string]interface{})
  690. inputData := make(map[string]interface{})
  691. inputMessage["infno"] = "4209" // 交易编码
  692. inputData["fixmedins_mdtrt_id"] = struct4209.FixmedinsMdtrtID // 开始时间
  693. inputData["fixmedins_code"] = struct4209.FixmedinsCode // 人员姓名
  694. inputData["page_num"] = struct4209.PageNum // 人员姓名
  695. inputData["page_size"] = struct4209.PageSize // 人员姓名
  696. input["input"] = inputData
  697. inputMessage["input"] = input //交易输入
  698. var inputLog string
  699. bytesData, err := json.Marshal(inputMessage)
  700. inputLog = string(bytesData)
  701. fmt.Println(string(bytesData))
  702. if err != nil {
  703. fmt.Println(err.Error())
  704. return err.Error(), ""
  705. }
  706. reader := bytes.NewReader(bytesData)
  707. gdyb_url := beego.AppConfig.String("gdyb_url")
  708. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  709. var url string
  710. if fixmedins_code == "H15049901371" {
  711. url = gdyb_url
  712. } else {
  713. url = gdyb_url + "1101"
  714. }
  715. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  716. request, err := http.NewRequest("POST", url, reader)
  717. if err != nil {
  718. fmt.Println(err.Error())
  719. return err.Error(), ""
  720. }
  721. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  722. request.Header.Set("x-tif-paasid", gdyb_paasid)
  723. request.Header.Set("x-tif-signature", signature)
  724. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  725. request.Header.Set("x-tif-nonce", nonce)
  726. client := http.Client{}
  727. resp, err := client.Do(request)
  728. if err != nil {
  729. fmt.Println(err.Error())
  730. return err.Error(), ""
  731. }
  732. respBytes, err := ioutil.ReadAll(resp.Body)
  733. if err != nil {
  734. fmt.Println(err.Error())
  735. return err.Error(), ""
  736. }
  737. fmt.Println(string(respBytes))
  738. str := string(respBytes)
  739. return str, inputLog
  740. }