gdyb_zifei_service.go 26KB

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