dianzichufang.go 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. package service
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "io/ioutil"
  8. "net/http"
  9. "strconv"
  10. "time"
  11. )
  12. func GetCFYLJG001(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG001 models.CFYLJG001) (string, string) {
  13. //生成签名
  14. nonce := GetRandomString(32)
  15. timestamp := time.Now().Unix()
  16. signature := setSignature(timestamp, nonce, secret_key)
  17. //生成输入报文
  18. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  19. //input := make(map[string]interface{})
  20. inputData := make(map[string]interface{}, 0)
  21. inputMessage["infno"] = "CFYLJG001"
  22. inputData["mdtrt_cert_type"] = cFYLJG001.MdtrtCertType
  23. inputData["mdtrt_cert_no"] = cFYLJG001.MdtrtCertNo
  24. inputData["card_sn"] = cFYLJG001.CardSn
  25. inputData["ec_token"] = cFYLJG001.EcToken
  26. inputData["auth_no"] = cFYLJG001.AuthNo
  27. inputData["biz_type_code"] = cFYLJG001.BizTypeCode
  28. inputData["insu_admdvs"] = cFYLJG001.InsuAdmdvs
  29. inputData["hosp_rxno"] = cFYLJG001.HospRxno
  30. inputData["init_rxno"] = cFYLJG001.InitRxno
  31. inputData["rx_type_code"] = cFYLJG001.RxTypeCode
  32. inputData["prsc_time"] = cFYLJG001.PrscTime
  33. inputData["rx_drug_cnt"] = cFYLJG001.RxDrugCnt
  34. inputData["rx_used_way_codg"] = cFYLJG001.RxUsedWayCodg
  35. inputData["rx_used_way_name"] = cFYLJG001.RxUsedWayName
  36. inputData["rx_frqu_codg"] = cFYLJG001.RxFrquCodg
  37. inputData["rx_frqu_name"] = cFYLJG001.RxFrquName
  38. inputData["rx_dosunt"] = cFYLJG001.RxDosunt
  39. inputData["rx_doscnt"] = cFYLJG001.RxDoscnt
  40. inputData["rx_drord_dscr"] = cFYLJG001.RxDrordDscr
  41. inputData["vali_days"] = cFYLJG001.ValiDays
  42. inputData["vali_end_time"] = cFYLJG001.ValiEndTime
  43. inputData["rept_flag"] = cFYLJG001.ReptFlag
  44. inputData["max_rept_cnt"] = cFYLJG001.MaxReptCnt
  45. inputData["reptd_cnt"] = cFYLJG001.ReptdCnt
  46. inputData["min_inrv_days"] = cFYLJG001.MinInrvDays
  47. inputData["rx_cotn_flag"] = cFYLJG001.RxCotnFlag
  48. inputData["long_rx_flag"] = cFYLJG001.LongRxFlag
  49. inputData["mdtrtareaNo"] = cFYLJG001.MdtrtareaNo
  50. rxdrugdetail := make([]map[string]interface{}, 0)
  51. rxdrug := make(map[string]interface{})
  52. for _, item := range cFYLJG001.List {
  53. rxdrug["med_list_codg"] = item.MedListCodg
  54. rxdrug["medins_list_codg"] = item.MedinsListCodg
  55. rxdrug["hosp_prep_flag"] = item.HospPrepFlag
  56. rxdrug["rx_item_type_code"] = item.RxItemTypeCode
  57. rxdrug["rx_item_type_name"] = item.RxItemTypeName
  58. rxdrug["tcmdrug_type_name"] = item.TcmdrugTypeName
  59. rxdrug["tcmdrug_type_code"] = item.TcmdrugTypeCode
  60. rxdrug["tcmherb_foote"] = item.TcmherbFoote
  61. rxdrug["medn_type_code"] = item.MednTypeCode
  62. rxdrug["medn_type_name"] = item.MednTypeName
  63. rxdrug["main_medc_flag"] = item.MainMedcFlag
  64. rxdrug["urgt_flag"] = item.UrgtFlag
  65. rxdrug["bas_medn_flag"] = item.BasMednFlag
  66. rxdrug["imp_drug_flag"] = item.ImpDrugFlag
  67. rxdrug["drug_prodname"] = item.DrugProdname
  68. rxdrug["genname_codg"] = item.GennameCodg
  69. rxdrug["drug_genname"] = item.DrugGenname
  70. rxdrug["drug_dosform"] = item.DrugDosform
  71. rxdrug["drug_spec"] = item.DrugSpec
  72. rxdrug["prdr_name"] = item.PrdrName
  73. rxdrug["medc_way_codg"] = item.MedcWayCodg
  74. rxdrug["medc_way_dscr"] = item.MedcWayDscr
  75. rxdrug["medc_begntime"] = item.MedcBegntime
  76. rxdrug["medc_endtime"] = item.MedcEndtime
  77. rxdrug["medc_days"] = item.MedcDays
  78. rxdrug["drug_pric"] = item.DrugPric
  79. rxdrug["drug_sumamt"] = item.DrugSumamt
  80. rxdrug["drug_cnt"] = item.DrugCnt
  81. rxdrug["drug_dosunt"] = item.DrugDosunt
  82. rxdrug["sin_doscnt"] = item.SinDoscnt
  83. rxdrug["sin_dosunt"] = item.SinDosunt
  84. rxdrug["used_frqu_codg"] = item.UsedFrquCodg
  85. rxdrug["used_frqu_name"] = item.UsedFrquName
  86. rxdrug["drug_totlcnt_emp"] = item.DrugTotlcntEmp
  87. rxdrug["hosp_appr_flag"] = item.HospApprFlag
  88. rxdrug["extras"] = item.Extras
  89. rxdrugdetail = append(rxdrugdetail, rxdrug)
  90. }
  91. inputData["list"] = rxdrugdetail
  92. mdtrtinfo := make(map[string]interface{})
  93. mdtrtinfo["fixmedins_code"] = cFYLJG001.Mdtrtinfo.FixmedinsCode
  94. mdtrtinfo["fixmedins_name"] = cFYLJG001.Mdtrtinfo.FixmedinsName
  95. mdtrtinfo["mdtrt_id"] = cFYLJG001.Mdtrtinfo.MdtrtID
  96. mdtrtinfo["med_type"] = cFYLJG001.Mdtrtinfo.MedType
  97. mdtrtinfo["ipt_otp_no"] = cFYLJG001.Mdtrtinfo.IptOtpNo
  98. mdtrtinfo["otp_ipt_flag"] = cFYLJG001.Mdtrtinfo.OtpIptFlag
  99. mdtrtinfo["psn_no"] = cFYLJG001.Mdtrtinfo.PsnNo
  100. mdtrtinfo["patn_name"] = cFYLJG001.Mdtrtinfo.PatnName
  101. mdtrtinfo["psn_cert_type"] = cFYLJG001.Mdtrtinfo.PsnCertType
  102. mdtrtinfo["certno"] = cFYLJG001.Mdtrtinfo.Certno
  103. mdtrtinfo["patn_age"] = cFYLJG001.Mdtrtinfo.PatnAge
  104. mdtrtinfo["patn_hgt"] = cFYLJG001.Mdtrtinfo.PatnHgt
  105. mdtrtinfo["patn_wt"] = cFYLJG001.Mdtrtinfo.PatnWt
  106. mdtrtinfo["gend"] = cFYLJG001.Mdtrtinfo.Gend
  107. mdtrtinfo["birctrlType"] = cFYLJG001.Mdtrtinfo.BirctrlType
  108. mdtrtinfo["birctrlMatnDate"] = cFYLJG001.Mdtrtinfo.BirctrlMatnDate
  109. mdtrtinfo["matnType"] = cFYLJG001.Mdtrtinfo.MatnType
  110. mdtrtinfo["geso_val"] = cFYLJG001.Mdtrtinfo.GesoVal
  111. mdtrtinfo["nwb_flag"] = cFYLJG001.Mdtrtinfo.NwbFlag
  112. mdtrtinfo["nwb_age"] = cFYLJG001.Mdtrtinfo.NwbAge
  113. mdtrtinfo["suck_prd_flag"] = cFYLJG001.Mdtrtinfo.SuckPrdFlag
  114. mdtrtinfo["algs_his"] = cFYLJG001.Mdtrtinfo.AlgsHis
  115. mdtrtinfo["prsc_dept_name"] = cFYLJG001.Mdtrtinfo.PrscDeptName
  116. mdtrtinfo["prsc_dept_code"] = cFYLJG001.Mdtrtinfo.PrscDeptCode
  117. mdtrtinfo["dr_code"] = cFYLJG001.Mdtrtinfo.DrCode
  118. mdtrtinfo["prsc_dr_name"] = cFYLJG001.Mdtrtinfo.PrscDrName
  119. mdtrtinfo["prsc_dr_cert_type"] = cFYLJG001.Mdtrtinfo.PrscDrCertType
  120. mdtrtinfo["prsc_dr_certno"] = cFYLJG001.Mdtrtinfo.PrscDrCertno
  121. mdtrtinfo["dr_profttl_codg"] = cFYLJG001.Mdtrtinfo.DrProfttlCodg
  122. mdtrtinfo["dr_profttl_name"] = cFYLJG001.Mdtrtinfo.DrProfttlName
  123. mdtrtinfo["dr_dept_code"] = cFYLJG001.Mdtrtinfo.DrDeptCode
  124. mdtrtinfo["dr_dept_name"] = cFYLJG001.Mdtrtinfo.DrDeptName
  125. mdtrtinfo["caty"] = cFYLJG001.Mdtrtinfo.Caty
  126. mdtrtinfo["mdtrt_time"] = cFYLJG001.Mdtrtinfo.MdtrtTime
  127. mdtrtinfo["dise_codg"] = cFYLJG001.Mdtrtinfo.DiseCodg
  128. mdtrtinfo["dise_name"] = cFYLJG001.Mdtrtinfo.DiseName
  129. mdtrtinfo["sp_dise_flag"] = cFYLJG001.Mdtrtinfo.SpDiseFlag
  130. mdtrtinfo["maindiag_code"] = cFYLJG001.Mdtrtinfo.MaindiagCode
  131. mdtrtinfo["maindiag_name"] = cFYLJG001.Mdtrtinfo.MaindiagName
  132. mdtrtinfo["dise_cond_dscr"] = cFYLJG001.Mdtrtinfo.DiseCondDscr
  133. mdtrtinfo["hi_feesetl_flag"] = cFYLJG001.Mdtrtinfo.HiFeesetlFlag
  134. mdtrtinfo["hi_feesetl_name"] = cFYLJG001.Mdtrtinfo.HiFeesetlName
  135. mdtrtinfo["rgst_fee"] = cFYLJG001.Mdtrtinfo.RgstFee
  136. mdtrtinfo["medfee_sumamt"] = cFYLJG001.Mdtrtinfo.MedfeeSumamt
  137. mdtrtinfo["fstdiag_flag"] = cFYLJG001.Mdtrtinfo.FstdiagFlag
  138. mdtrtinfo["extras"] = cFYLJG001.Mdtrtinfo.Extras
  139. inputData["mdtrtinfo"] = mdtrtinfo
  140. diseinfos := make([]map[string]interface{}, 0)
  141. for _, item := range cFYLJG001.Diseinfo {
  142. diseinfo := make(map[string]interface{})
  143. diseinfo["diag_type"] = item.DiagType
  144. diseinfo["maindiag_flag"] = item.MaindiagFlag
  145. diseinfo["diag_srt_no"] = item.DiagSrtNo
  146. diseinfo["diag_code"] = item.DiagCode
  147. diseinfo["diag_name"] = item.DiagName
  148. diseinfo["diag_dept"] = item.DiagDept
  149. diseinfo["diag_dr_no"] = item.DiagDrNo
  150. diseinfo["diag_dr_name"] = item.DiagDrName
  151. diseinfo["diag_time"] = item.DiagTime
  152. diseinfo["tcm_dise_code"] = item.TcmDiseCode
  153. diseinfo["tcm_dise_name"] = item.TcmDiseName
  154. diseinfo["tcmsymp_code"] = item.TcmsympCode
  155. diseinfo["tcmsymp"] = item.Tcmsymp
  156. diseinfos = append(diseinfos, diseinfo)
  157. }
  158. inputData["diseinfo"] = diseinfos
  159. inputMessage["input"] = inputData
  160. var inputLog string
  161. bytesData, err := json.Marshal(inputMessage)
  162. inputLog = string(bytesData)
  163. fmt.Println(string(bytesData))
  164. if err != nil {
  165. fmt.Println(err.Error())
  166. return err.Error(), ""
  167. }
  168. reader := bytes.NewReader(bytesData)
  169. gdyb_url := beego.AppConfig.String("gdyb_url")
  170. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  171. var url string
  172. if fixmedins_code == "H15049901371" {
  173. url = gdyb_url
  174. } else {
  175. url = gdyb_url + "CFYLJG001"
  176. }
  177. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  178. request, err := http.NewRequest("POST", url, reader)
  179. if err != nil {
  180. fmt.Println(err.Error())
  181. return err.Error(), ""
  182. }
  183. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  184. request.Header.Set("x-tif-paasid", gdyb_paasid)
  185. request.Header.Set("x-tif-signature", signature)
  186. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  187. request.Header.Set("x-tif-nonce", nonce)
  188. client := http.Client{}
  189. resp, err := client.Do(request)
  190. if err != nil {
  191. fmt.Println(err.Error())
  192. return err.Error(), ""
  193. }
  194. respBytes, err := ioutil.ReadAll(resp.Body)
  195. if err != nil {
  196. fmt.Println(err.Error())
  197. return err.Error(), ""
  198. }
  199. fmt.Println(string(respBytes))
  200. str := string(respBytes)
  201. return str, inputLog
  202. }
  203. func GetCFYLJG002(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, original_value string, original_rx_file string, extras string) (string, string) {
  204. //生成签名
  205. nonce := GetRandomString(32)
  206. timestamp := time.Now().Unix()
  207. signature := setSignature(timestamp, nonce, secret_key)
  208. //生成输入报文
  209. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  210. inputData := make(map[string]interface{})
  211. //inputData := makemap[string]interface{})
  212. inputMessage["infno"] = "CFYLJG002"
  213. inputData["fixmedins_code"] = fixmedins_code
  214. inputData["original_value"] = original_value
  215. inputData["original_rx_file"] = original_rx_file
  216. inputData["extras"] = extras
  217. inputMessage["rx_sign_info"] = inputData
  218. var inputLog string
  219. bytesData, err := json.Marshal(inputMessage)
  220. inputLog = string(bytesData)
  221. fmt.Println(string(bytesData))
  222. if err != nil {
  223. fmt.Println(err.Error())
  224. return err.Error(), ""
  225. }
  226. reader := bytes.NewReader(bytesData)
  227. gdyb_url := beego.AppConfig.String("gdyb_url")
  228. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  229. var url string
  230. if fixmedins_code == "H15049901371" {
  231. url = gdyb_url
  232. } else {
  233. url = gdyb_url + "CFYLJG002"
  234. }
  235. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  236. request, err := http.NewRequest("POST", url, reader)
  237. if err != nil {
  238. fmt.Println(err.Error())
  239. return err.Error(), ""
  240. }
  241. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  242. request.Header.Set("x-tif-paasid", gdyb_paasid)
  243. request.Header.Set("x-tif-signature", signature)
  244. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  245. request.Header.Set("x-tif-nonce", nonce)
  246. client := http.Client{}
  247. resp, err := client.Do(request)
  248. if err != nil {
  249. fmt.Println(err.Error())
  250. return err.Error(), ""
  251. }
  252. respBytes, err := ioutil.ReadAll(resp.Body)
  253. if err != nil {
  254. fmt.Println(err.Error())
  255. return err.Error(), ""
  256. }
  257. fmt.Println(string(respBytes))
  258. str := string(respBytes)
  259. return str, inputLog
  260. }
  261. func GetCFYLJG003(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG003 models.CFYLJG003) (string, string) {
  262. //生成签名
  263. nonce := GetRandomString(32)
  264. timestamp := time.Now().Unix()
  265. signature := setSignature(timestamp, nonce, secret_key)
  266. //生成输入报文
  267. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  268. input := make(map[string]interface{})
  269. inputDatas := make([]map[string]interface{}, 0)
  270. inputMessage["infno"] = "CFYLJG003"
  271. inputData["rx_trace_code"] = cFYLJG003.RxTraceCode
  272. inputData["hi_rxno"] = cFYLJG003.HiRxno
  273. inputData["mdtrt_id"] = cFYLJG003.MdtrtID
  274. inputData["patn_name"] = cFYLJG003.PatnName
  275. inputData["psn_cert_type"] = cFYLJG003.PsnCertType
  276. inputData["certno"] = cFYLJG003.Certno
  277. inputData["fixmedins_name"] = cFYLJG003.FixmedinsName
  278. inputData["fixmedins_code"] = cFYLJG003.FixmedinsCode
  279. inputData["dr_code"] = cFYLJG003.DrCode
  280. inputData["prsc_dr_name"] = cFYLJG003.PrscDrName
  281. inputData["phar_dept_name"] = cFYLJG003.PharDeptName
  282. inputData["phar_dept_code"] = cFYLJG003.PharDeptCode
  283. inputData["phar_profttl_codg"] = cFYLJG003.PharProfttlCodg
  284. inputData["phar_profttl_name"] = cFYLJG003.PharProfttlName
  285. inputData["phar_code"] = cFYLJG003.PharCode
  286. inputData["rx_frqu_name"] = cFYLJG003.RxFrquName
  287. inputData["phar_cert_type"] = cFYLJG003.PsnCertType
  288. inputData["phar_certno"] = cFYLJG003.PharCertno
  289. inputData["phar_name"] = cFYLJG003.PharName
  290. inputData["phar_prac_cert_no"] = cFYLJG003.PharPracCertNo
  291. inputData["phar_chk_time"] = cFYLJG003.PharChkTime
  292. inputData["rx_file"] = cFYLJG003.RxFile
  293. inputData["sign_digest"] = cFYLJG003.SignDigest
  294. inputMessage["rx_upload_info"] = inputData
  295. var inputLog string
  296. bytesData, err := json.Marshal(inputMessage)
  297. inputLog = string(bytesData)
  298. fmt.Println(string(bytesData))
  299. if err != nil {
  300. fmt.Println(err.Error())
  301. return err.Error(), ""
  302. }
  303. reader := bytes.NewReader(bytesData)
  304. gdyb_url := beego.AppConfig.String("gdyb_url")
  305. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  306. var url string
  307. if fixmedins_code == "H15049901371" {
  308. url = gdyb_url
  309. } else {
  310. url = gdyb_url + "CFYLJG003"
  311. }
  312. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  313. request, err := http.NewRequest("POST", url, reader)
  314. if err != nil {
  315. fmt.Println(err.Error())
  316. return err.Error(), ""
  317. }
  318. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  319. request.Header.Set("x-tif-paasid", gdyb_paasid)
  320. request.Header.Set("x-tif-signature", signature)
  321. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  322. request.Header.Set("x-tif-nonce", nonce)
  323. client := http.Client{}
  324. resp, err := client.Do(request)
  325. if err != nil {
  326. fmt.Println(err.Error())
  327. return err.Error(), ""
  328. }
  329. respBytes, err := ioutil.ReadAll(resp.Body)
  330. if err != nil {
  331. fmt.Println(err.Error())
  332. return err.Error(), ""
  333. }
  334. fmt.Println(string(respBytes))
  335. str := string(respBytes)
  336. return str, inputLog
  337. }
  338. func GetCFYLJG004(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG004 models.CFYLJG004) (string, string) {
  339. //生成签名
  340. nonce := GetRandomString(32)
  341. timestamp := time.Now().Unix()
  342. signature := setSignature(timestamp, nonce, secret_key)
  343. //生成输入报文
  344. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  345. input := make(map[string]interface{})
  346. inputDatas := make([]map[string]interface{}, 0)
  347. inputMessage["infno"] = "CFYLJG004"
  348. inputData["hi_rxno"] = cFYLJG004.HiRxno
  349. inputData["undo_dr_code"] = cFYLJG004.UndoDrCode
  350. inputData["undo_dr_name"] = cFYLJG004.UndoDrName
  351. inputData["undo_dr_cert_type"] = cFYLJG004.UndoDrCertType
  352. inputData["undo_dr_certno"] = cFYLJG004.UndoDrCertno
  353. inputData["undo_rea"] = cFYLJG004.UndoRea
  354. inputData["undo_time"] = cFYLJG004.UndoTime
  355. inputData["fixmedins_code"] = cFYLJG004.FixmedinsCode
  356. inputMessage["rx_cancel_info"] = inputData
  357. var inputLog string
  358. bytesData, err := json.Marshal(inputMessage)
  359. inputLog = string(bytesData)
  360. fmt.Println(string(bytesData))
  361. if err != nil {
  362. fmt.Println(err.Error())
  363. return err.Error(), ""
  364. }
  365. reader := bytes.NewReader(bytesData)
  366. gdyb_url := beego.AppConfig.String("gdyb_url")
  367. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  368. var url string
  369. if fixmedins_code == "H15049901371" {
  370. url = gdyb_url
  371. } else {
  372. url = gdyb_url + "CFYLJG004"
  373. }
  374. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  375. request, err := http.NewRequest("POST", url, reader)
  376. if err != nil {
  377. fmt.Println(err.Error())
  378. return err.Error(), ""
  379. }
  380. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  381. request.Header.Set("x-tif-paasid", gdyb_paasid)
  382. request.Header.Set("x-tif-signature", signature)
  383. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  384. request.Header.Set("x-tif-nonce", nonce)
  385. client := http.Client{}
  386. resp, err := client.Do(request)
  387. if err != nil {
  388. fmt.Println(err.Error())
  389. return err.Error(), ""
  390. }
  391. respBytes, err := ioutil.ReadAll(resp.Body)
  392. if err != nil {
  393. fmt.Println(err.Error())
  394. return err.Error(), ""
  395. }
  396. fmt.Println(string(respBytes))
  397. str := string(respBytes)
  398. return str, inputLog
  399. }
  400. func GetCFYLJG005(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG005 models.CFYLJG005) (string, string) {
  401. //生成签名
  402. nonce := GetRandomString(32)
  403. timestamp := time.Now().Unix()
  404. signature := setSignature(timestamp, nonce, secret_key)
  405. //生成输入报文
  406. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  407. input := make(map[string]interface{})
  408. inputDatas := make([]map[string]interface{}, 0)
  409. inputMessage["infno"] = "CFYLJG005"
  410. inputData["fixmedins_code"] = cFYLJG005.FixmedinsCode
  411. inputData["hi_rxno"] = cFYLJG005.HiRxno
  412. inputData["mdtrt_id"] = cFYLJG005.MdtrtID
  413. inputData["ec_token"] = cFYLJG005.EcToken
  414. inputData["psn_name"] = cFYLJG005.PsnName
  415. inputData["psn_cert_type"] = cFYLJG005.PsnCertType
  416. inputData["certno"] = cFYLJG005.Certno
  417. inputMessage["rx_detl_query"] = inputData
  418. var inputLog string
  419. bytesData, err := json.Marshal(inputMessage)
  420. inputLog = string(bytesData)
  421. fmt.Println(string(bytesData))
  422. if err != nil {
  423. fmt.Println(err.Error())
  424. return err.Error(), ""
  425. }
  426. reader := bytes.NewReader(bytesData)
  427. gdyb_url := beego.AppConfig.String("gdyb_url")
  428. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  429. var url string
  430. if fixmedins_code == "H15049901371" {
  431. url = gdyb_url
  432. } else {
  433. url = gdyb_url + "CFYLJG005"
  434. }
  435. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  436. request, err := http.NewRequest("POST", url, reader)
  437. if err != nil {
  438. fmt.Println(err.Error())
  439. return err.Error(), ""
  440. }
  441. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  442. request.Header.Set("x-tif-paasid", gdyb_paasid)
  443. request.Header.Set("x-tif-signature", signature)
  444. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  445. request.Header.Set("x-tif-nonce", nonce)
  446. client := http.Client{}
  447. resp, err := client.Do(request)
  448. if err != nil {
  449. fmt.Println(err.Error())
  450. return err.Error(), ""
  451. }
  452. respBytes, err := ioutil.ReadAll(resp.Body)
  453. if err != nil {
  454. fmt.Println(err.Error())
  455. return err.Error(), ""
  456. }
  457. fmt.Println(string(respBytes))
  458. str := string(respBytes)
  459. return str, inputLog
  460. }
  461. func GetCFYLJG006(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG006 models.CFYLJG006) (string, string) {
  462. //生成签名
  463. nonce := GetRandomString(32)
  464. timestamp := time.Now().Unix()
  465. signature := setSignature(timestamp, nonce, secret_key)
  466. //生成输入报文
  467. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  468. input := make(map[string]interface{})
  469. inputDatas := make([]map[string]interface{}, 0)
  470. inputMessage["infno"] = "CFYLJG006"
  471. inputData["fixmedins_code"] = cFYLJG006.FixmedinsCode
  472. inputData["hi_rxno"] = cFYLJG006.HiRxno
  473. inputData["mdtrt_id"] = cFYLJG006.MdtrtID
  474. inputData["psn_cert_type"] = cFYLJG006.PsnCertType
  475. inputData["certno"] = cFYLJG006.Certno
  476. inputData["psn_name"] = cFYLJG006.PsnName
  477. inputMessage["rx_chk_info"] = inputData
  478. var inputLog string
  479. bytesData, err := json.Marshal(inputMessage)
  480. inputLog = string(bytesData)
  481. fmt.Println(string(bytesData))
  482. if err != nil {
  483. fmt.Println(err.Error())
  484. return err.Error(), ""
  485. }
  486. reader := bytes.NewReader(bytesData)
  487. gdyb_url := beego.AppConfig.String("gdyb_url")
  488. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  489. var url string
  490. if fixmedins_code == "H15049901371" {
  491. url = gdyb_url
  492. } else {
  493. url = gdyb_url + "CFYLJG006"
  494. }
  495. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  496. request, err := http.NewRequest("POST", url, reader)
  497. if err != nil {
  498. fmt.Println(err.Error())
  499. return err.Error(), ""
  500. }
  501. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  502. request.Header.Set("x-tif-paasid", gdyb_paasid)
  503. request.Header.Set("x-tif-signature", signature)
  504. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  505. request.Header.Set("x-tif-nonce", nonce)
  506. client := http.Client{}
  507. resp, err := client.Do(request)
  508. if err != nil {
  509. fmt.Println(err.Error())
  510. return err.Error(), ""
  511. }
  512. respBytes, err := ioutil.ReadAll(resp.Body)
  513. if err != nil {
  514. fmt.Println(err.Error())
  515. return err.Error(), ""
  516. }
  517. fmt.Println(string(respBytes))
  518. str := string(respBytes)
  519. return str, inputLog
  520. }
  521. func GetCFYLJG007(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG007 models.CFYLJG007) (string, string) {
  522. //生成签名
  523. nonce := GetRandomString(32)
  524. timestamp := time.Now().Unix()
  525. signature := setSignature(timestamp, nonce, secret_key)
  526. //生成输入报文
  527. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  528. input := make(map[string]interface{})
  529. inputDatas := make([]map[string]interface{}, 0)
  530. inputMessage["infno"] = "CFYLJG007"
  531. inputData["fixmedins_code"] = cFYLJG007.FixmedinsCode
  532. inputData["hi_rxno"] = cFYLJG007.HiRxno
  533. inputData["mdtrt_id"] = cFYLJG007.MdtrtID
  534. inputData["psn_no"] = cFYLJG007.PsnNo
  535. inputData["psn_cert_type"] = cFYLJG007.PsnCertType
  536. inputData["certno"] = cFYLJG007.Certno
  537. inputMessage["rx_setl_query"] = inputData
  538. var inputLog string
  539. bytesData, err := json.Marshal(inputMessage)
  540. inputLog = string(bytesData)
  541. fmt.Println(string(bytesData))
  542. if err != nil {
  543. fmt.Println(err.Error())
  544. return err.Error(), ""
  545. }
  546. reader := bytes.NewReader(bytesData)
  547. gdyb_url := beego.AppConfig.String("gdyb_url")
  548. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  549. var url string
  550. if fixmedins_code == "H15049901371" {
  551. url = gdyb_url
  552. } else {
  553. url = gdyb_url + "CFYLJG007"
  554. }
  555. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  556. request, err := http.NewRequest("POST", url, reader)
  557. if err != nil {
  558. fmt.Println(err.Error())
  559. return err.Error(), ""
  560. }
  561. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  562. request.Header.Set("x-tif-paasid", gdyb_paasid)
  563. request.Header.Set("x-tif-signature", signature)
  564. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  565. request.Header.Set("x-tif-nonce", nonce)
  566. client := http.Client{}
  567. resp, err := client.Do(request)
  568. if err != nil {
  569. fmt.Println(err.Error())
  570. return err.Error(), ""
  571. }
  572. respBytes, err := ioutil.ReadAll(resp.Body)
  573. if err != nil {
  574. fmt.Println(err.Error())
  575. return err.Error(), ""
  576. }
  577. fmt.Println(string(respBytes))
  578. str := string(respBytes)
  579. return str, inputLog
  580. }