gdyb_zifei_service.go 26KB

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