gdyb_zifei_service.go 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828
  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. inputData := make(map[string]interface{})
  369. inputMessage["infno"] = "4205" // 交易编码
  370. inputData["fixmedins_mdtrt_id"] = struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID
  371. inputData["fixmedins_code"] = struct4202.OwnPayPatnMdtrtD.FixmedinsCode
  372. inputData["fixmedins_name"] = struct4202.OwnPayPatnMdtrtD.FixmedinsName
  373. inputData["psn_cert_type"] = struct4202.OwnPayPatnMdtrtD.PsnCertType
  374. inputData["certno"] = struct4202.OwnPayPatnMdtrtD.Certno
  375. inputData["psn_name"] = struct4202.OwnPayPatnMdtrtD.PsnName
  376. inputData["gend"] = ""
  377. inputData["naty"] = ""
  378. inputData["brdy"] = ""
  379. inputData["age"] = ""
  380. inputData["coner_name"] = ""
  381. inputData["tel"] = ""
  382. inputData["addr"] = ""
  383. inputData["begntime"] = struct4202.OwnPayPatnMdtrtD.Begntime
  384. inputData["endtime"] = ""
  385. inputData["med_type"] = struct4202.OwnPayPatnMdtrtD.MedType
  386. inputData["main_cond_dscr"] = ""
  387. inputData["dise_codg"] = ""
  388. inputData["dise_name"] = ""
  389. inputData["birctrl_type"] = ""
  390. inputData["birctrl_matn_date"] = ""
  391. inputData["matn_type"] = ""
  392. inputData["geso_val"] = ""
  393. inputData["elec_bill_code"] = ""
  394. inputData["elec_billno_code"] = ""
  395. inputData["elec_bill_chkcode"] = ""
  396. inputData["exp_content"] = ""
  397. diagInfos := make([]map[string]interface{}, 0)
  398. for index, item := range struct4202.ODiagListD {
  399. diagInfo := make(map[string]interface{})
  400. diagInfo["diag_type"] = item.DiagType // 就诊 ID(来自2201接口返回)
  401. diagInfo["diag_srt_no"] = index // 收费批次号
  402. diagInfo["diag_code"] = item.DiagCode // 病种编码
  403. diagInfo["diag_name"] = item.DiagName // 处方号
  404. diagInfo["diag_dept"] = "血透"
  405. diagInfo["diag_dr_code"] = item.DiagDrCode
  406. diagInfo["diag_dr_name"] = item.DiagDrName
  407. diagInfo["diag_time"] = item.DiagTime
  408. diagInfo["vali_flag"] = "1"
  409. diagInfos = append(diagInfos, diagInfo)
  410. }
  411. inputData["diseinfo"] = diagInfos
  412. feedetail := make([]map[string]interface{}, 0)
  413. for _, item := range struct4201A.Fopfd {
  414. inputData := make(map[string]interface{})
  415. inputData["fixmedins_mdtrt_id"] = item.FixmedinsMdtrtID
  416. inputData["med_type"] = item.MedType
  417. inputData["bkkp_sn"] = item.BkkpSn
  418. inputData["fee_ocur_time"] = item.FeeOcurTime
  419. inputData["fixmedins_code"] = item.FixmedinsCode
  420. inputData["fixmedins_name"] = item.FixmedinsName
  421. inputData["cnt"] = item.Cnt
  422. inputData["pric"] = item.Pric
  423. inputData["det_item_fee_sumamt"] = item.DetItemFeeSumamt
  424. inputData["medins_list_name"] = item.MedinsListName
  425. inputData["medins_list_code"] = item.MedinsListCodg
  426. inputData["med_chrgitm_type"] = item.MedChrgitmType
  427. inputData["prodname"] = item.Prodname
  428. inputData["bilg_dept_codg"] = item.BilgDeptCodg
  429. inputData["bilg_dept_name"] = item.BilgDeptName
  430. inputData["bilg_dr_code"] = item.BilgDrCode
  431. inputData["bilg_dr_name"] = item.BilgDrName
  432. inputData["acord_dept_codg"] = ""
  433. inputData["acord_dept_name"] = ""
  434. inputData["acord_dr_code"] = ""
  435. inputData["acord_dr_name"] = ""
  436. inputData["tcmdrug_used_way"] = ""
  437. inputData["etip_flag"] = ""
  438. inputData["etip_hosp_code"] = ""
  439. inputData["dscg_tkdrug_flag"] = ""
  440. inputData["sin_dos_dscr"] = ""
  441. inputData["used_frqu_dscr"] = ""
  442. inputData["prd_days"] = ""
  443. inputData["medc_way_dscr"] = ""
  444. inputData["memo"] = item.Memo
  445. inputData["fulamt_ownpay_amt"] = ""
  446. inputData["overlmt_selfpay"] = ""
  447. inputData["preselfpay_amt"] = ""
  448. inputData["inscp_amt"] = ""
  449. inputData["rxno"] = ""
  450. feedetail = append(feedetail, inputData)
  451. }
  452. inputData["feedetail"] = feedetail
  453. input["data"] = inputData
  454. inputMessage["input"] = input //交易输入
  455. var inputLog string
  456. bytesData, err := json.Marshal(inputMessage)
  457. inputLog = string(bytesData)
  458. fmt.Println(string(bytesData))
  459. if err != nil {
  460. fmt.Println(err.Error())
  461. return err.Error(), ""
  462. }
  463. reader := bytes.NewReader(bytesData)
  464. gdyb_url := beego.AppConfig.String("gdyb_url")
  465. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  466. var url string
  467. if fixmedins_code == "H15049901371" {
  468. url = gdyb_url
  469. } else {
  470. url = gdyb_url + "4205"
  471. }
  472. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  473. request, err := http.NewRequest("POST", url, reader)
  474. if err != nil {
  475. fmt.Println(err.Error())
  476. return err.Error(), ""
  477. }
  478. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  479. request.Header.Set("x-tif-paasid", gdyb_paasid)
  480. request.Header.Set("x-tif-signature", signature)
  481. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  482. request.Header.Set("x-tif-nonce", nonce)
  483. client := http.Client{}
  484. resp, err := client.Do(request)
  485. if err != nil {
  486. fmt.Println(err.Error())
  487. return err.Error(), ""
  488. }
  489. respBytes, err := ioutil.ReadAll(resp.Body)
  490. if err != nil {
  491. fmt.Println(err.Error())
  492. return err.Error(), ""
  493. }
  494. fmt.Println(string(respBytes))
  495. str := string(respBytes)
  496. return str, inputLog
  497. }
  498. func Gdyb4206(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) (string, string) {
  499. //生成签名
  500. nonce := GetRandomString(32)
  501. timestamp := time.Now().Unix()
  502. signature := setSignature(timestamp, nonce, secret_key)
  503. //生成输入报文
  504. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  505. input := make(map[string]interface{})
  506. inputData := make(map[string]interface{})
  507. inputMessage["infno"] = "4206" // 交易编码
  508. inputData["fixmedins_mdtrt_id"] = "" // 开始时间
  509. inputData["fixmedins_code"] = "" // 开始时间
  510. input["input"] = inputData // 开始时间
  511. inputMessage["input"] = input //交易输入
  512. var inputLog string
  513. bytesData, err := json.Marshal(inputMessage)
  514. inputLog = string(bytesData)
  515. fmt.Println(string(bytesData))
  516. if err != nil {
  517. fmt.Println(err.Error())
  518. return err.Error(), ""
  519. }
  520. reader := bytes.NewReader(bytesData)
  521. gdyb_url := beego.AppConfig.String("gdyb_url")
  522. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  523. var url string
  524. if fixmedins_code == "H15049901371" {
  525. url = gdyb_url
  526. } else {
  527. url = gdyb_url + "1101"
  528. }
  529. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  530. request, err := http.NewRequest("POST", url, reader)
  531. if err != nil {
  532. fmt.Println(err.Error())
  533. return err.Error(), ""
  534. }
  535. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  536. request.Header.Set("x-tif-paasid", gdyb_paasid)
  537. request.Header.Set("x-tif-signature", signature)
  538. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  539. request.Header.Set("x-tif-nonce", nonce)
  540. client := http.Client{}
  541. resp, err := client.Do(request)
  542. if err != nil {
  543. fmt.Println(err.Error())
  544. return err.Error(), ""
  545. }
  546. respBytes, err := ioutil.ReadAll(resp.Body)
  547. if err != nil {
  548. fmt.Println(err.Error())
  549. return err.Error(), ""
  550. }
  551. fmt.Println(string(respBytes))
  552. str := string(respBytes)
  553. return str, inputLog
  554. }
  555. func Gdyb4207(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4207 models.Struct4207) (string, string) {
  556. //生成签名
  557. nonce := GetRandomString(32)
  558. timestamp := time.Now().Unix()
  559. signature := setSignature(timestamp, nonce, secret_key)
  560. //生成输入报文
  561. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  562. input := make(map[string]interface{})
  563. inputData := make(map[string]interface{})
  564. inputMessage["infno"] = "4207" // 交易编码
  565. inputData["fixmedins_mdtrt_id"] = struct4207.FixmedinsMdtrtID // 开始时间
  566. inputData["fixmedins_code"] = struct4207.FixmedinsCode // 人员姓名
  567. inputData["page_num"] = struct4207.PageNum // 人员姓名
  568. inputData["page_size"] = struct4207.PageSize // 人员姓名
  569. input["input"] = inputData
  570. inputMessage["input"] = input //交易输入
  571. var inputLog string
  572. bytesData, err := json.Marshal(inputMessage)
  573. inputLog = string(bytesData)
  574. fmt.Println(string(bytesData))
  575. if err != nil {
  576. fmt.Println(err.Error())
  577. return err.Error(), ""
  578. }
  579. reader := bytes.NewReader(bytesData)
  580. gdyb_url := beego.AppConfig.String("gdyb_url")
  581. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  582. var url string
  583. if fixmedins_code == "H15049901371" {
  584. url = gdyb_url
  585. } else {
  586. url = gdyb_url + "4207"
  587. }
  588. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  589. request, err := http.NewRequest("POST", url, reader)
  590. if err != nil {
  591. fmt.Println(err.Error())
  592. return err.Error(), ""
  593. }
  594. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  595. request.Header.Set("x-tif-paasid", gdyb_paasid)
  596. request.Header.Set("x-tif-signature", signature)
  597. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  598. request.Header.Set("x-tif-nonce", nonce)
  599. client := http.Client{}
  600. resp, err := client.Do(request)
  601. if err != nil {
  602. fmt.Println(err.Error())
  603. return err.Error(), ""
  604. }
  605. respBytes, err := ioutil.ReadAll(resp.Body)
  606. if err != nil {
  607. fmt.Println(err.Error())
  608. return err.Error(), ""
  609. }
  610. fmt.Println(string(respBytes))
  611. str := string(respBytes)
  612. return str, inputLog
  613. }
  614. func Gdyb4208(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4208 models.Struct4208) (string, string) {
  615. //生成签名
  616. nonce := GetRandomString(32)
  617. timestamp := time.Now().Unix()
  618. signature := setSignature(timestamp, nonce, secret_key)
  619. //生成输入报文
  620. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  621. input := make(map[string]interface{})
  622. inputData := make(map[string]interface{})
  623. inputMessage["infno"] = "4208" // 交易编码
  624. inputData["psn_cert_type"] = struct4208.PsnCertType // 开始时间
  625. inputData["certno"] = struct4208.Certno // 人员姓名
  626. inputData["psn_name"] = struct4208.PsnName // 人员姓名
  627. inputData["begintime"] = struct4208.Begntime // 人员姓名
  628. inputData["endtime"] = struct4208.Endtime // 人员姓名
  629. inputData["med_type"] = struct4208.MedType // 人员姓名
  630. inputData["medfee_sumamt"] = struct4208.MedfeeSumamt // 人员姓名
  631. inputData["elec_billno_code"] = struct4208.ElecBillnoCode // 人员姓名
  632. inputData["page_num"] = struct4208.PageNum // 人员姓名
  633. inputData["page_size"] = struct4208.PageSize // 人员姓名
  634. input["input"] = inputData
  635. inputMessage["input"] = input //交易输入
  636. var inputLog string
  637. bytesData, err := json.Marshal(inputMessage)
  638. inputLog = string(bytesData)
  639. fmt.Println(string(bytesData))
  640. if err != nil {
  641. fmt.Println(err.Error())
  642. return err.Error(), ""
  643. }
  644. reader := bytes.NewReader(bytesData)
  645. gdyb_url := beego.AppConfig.String("gdyb_url")
  646. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  647. var url string
  648. if fixmedins_code == "H15049901371" {
  649. url = gdyb_url
  650. } else {
  651. url = gdyb_url + "1101"
  652. }
  653. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  654. request, err := http.NewRequest("POST", url, reader)
  655. if err != nil {
  656. fmt.Println(err.Error())
  657. return err.Error(), ""
  658. }
  659. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  660. request.Header.Set("x-tif-paasid", gdyb_paasid)
  661. request.Header.Set("x-tif-signature", signature)
  662. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  663. request.Header.Set("x-tif-nonce", nonce)
  664. client := http.Client{}
  665. resp, err := client.Do(request)
  666. if err != nil {
  667. fmt.Println(err.Error())
  668. return err.Error(), ""
  669. }
  670. respBytes, err := ioutil.ReadAll(resp.Body)
  671. if err != nil {
  672. fmt.Println(err.Error())
  673. return err.Error(), ""
  674. }
  675. fmt.Println(string(respBytes))
  676. str := string(respBytes)
  677. return str, inputLog
  678. }
  679. func Gdyb4209(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, struct4209 models.Struct4209) (string, string) {
  680. //生成签名
  681. nonce := GetRandomString(32)
  682. timestamp := time.Now().Unix()
  683. signature := setSignature(timestamp, nonce, secret_key)
  684. //生成输入报文
  685. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  686. input := make(map[string]interface{})
  687. inputData := make(map[string]interface{})
  688. inputMessage["infno"] = "4209" // 交易编码
  689. inputData["fixmedins_mdtrt_id"] = struct4209.FixmedinsMdtrtID // 开始时间
  690. inputData["fixmedins_code"] = struct4209.FixmedinsCode // 人员姓名
  691. inputData["page_num"] = struct4209.PageNum // 人员姓名
  692. inputData["page_size"] = struct4209.PageSize // 人员姓名
  693. input["input"] = inputData
  694. inputMessage["input"] = input //交易输入
  695. var inputLog string
  696. bytesData, err := json.Marshal(inputMessage)
  697. inputLog = string(bytesData)
  698. fmt.Println(string(bytesData))
  699. if err != nil {
  700. fmt.Println(err.Error())
  701. return err.Error(), ""
  702. }
  703. reader := bytes.NewReader(bytesData)
  704. gdyb_url := beego.AppConfig.String("gdyb_url")
  705. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  706. var url string
  707. if fixmedins_code == "H15049901371" {
  708. url = gdyb_url
  709. } else {
  710. url = gdyb_url + "1101"
  711. }
  712. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  713. request, err := http.NewRequest("POST", url, reader)
  714. if err != nil {
  715. fmt.Println(err.Error())
  716. return err.Error(), ""
  717. }
  718. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  719. request.Header.Set("x-tif-paasid", gdyb_paasid)
  720. request.Header.Set("x-tif-signature", signature)
  721. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  722. request.Header.Set("x-tif-nonce", nonce)
  723. client := http.Client{}
  724. resp, err := client.Do(request)
  725. if err != nil {
  726. fmt.Println(err.Error())
  727. return err.Error(), ""
  728. }
  729. respBytes, err := ioutil.ReadAll(resp.Body)
  730. if err != nil {
  731. fmt.Println(err.Error())
  732. return err.Error(), ""
  733. }
  734. fmt.Println(string(respBytes))
  735. str := string(respBytes)
  736. return str, inputLog
  737. }