dianzichufang.go 22KB

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