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