dianzichufang.go 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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"] = item.DrugTotlcnt
  88. rxdrug["drug_totlcnt_emp"] = item.DrugTotlcntEmp
  89. rxdrug["hosp_appr_flag"] = item.HospApprFlag
  90. rxdrug["extras"] = item.Extras
  91. rxdrugdetail = append(rxdrugdetail, rxdrug)
  92. }
  93. inputData["rxdrugdetail"] = rxdrugdetail
  94. mdtrtinfo := make(map[string]interface{})
  95. mdtrtinfo["fixmedins_code"] = cFYLJG001.Mdtrtinfo.FixmedinsCode
  96. mdtrtinfo["fixmedins_name"] = cFYLJG001.Mdtrtinfo.FixmedinsName
  97. mdtrtinfo["mdtrt_id"] = cFYLJG001.Mdtrtinfo.MdtrtID
  98. mdtrtinfo["med_type"] = cFYLJG001.Mdtrtinfo.MedType
  99. mdtrtinfo["ipt_otp_no"] = cFYLJG001.Mdtrtinfo.IptOtpNo
  100. mdtrtinfo["otp_ipt_flag"] = cFYLJG001.Mdtrtinfo.OtpIptFlag
  101. mdtrtinfo["psn_no"] = cFYLJG001.Mdtrtinfo.PsnNo
  102. mdtrtinfo["patn_name"] = cFYLJG001.Mdtrtinfo.PatnName
  103. mdtrtinfo["psn_cert_type"] = cFYLJG001.Mdtrtinfo.PsnCertType
  104. mdtrtinfo["certno"] = cFYLJG001.Mdtrtinfo.Certno
  105. mdtrtinfo["patn_age"] = cFYLJG001.Mdtrtinfo.PatnAge
  106. mdtrtinfo["patn_hgt"] = cFYLJG001.Mdtrtinfo.PatnHgt
  107. mdtrtinfo["patn_wt"] = cFYLJG001.Mdtrtinfo.PatnWt
  108. mdtrtinfo["gend"] = cFYLJG001.Mdtrtinfo.Gend
  109. mdtrtinfo["birctrlType"] = cFYLJG001.Mdtrtinfo.BirctrlType
  110. mdtrtinfo["birctrlMatnDate"] = cFYLJG001.Mdtrtinfo.BirctrlMatnDate
  111. mdtrtinfo["matnType"] = cFYLJG001.Mdtrtinfo.MatnType
  112. mdtrtinfo["geso_val"] = cFYLJG001.Mdtrtinfo.GesoVal
  113. mdtrtinfo["nwb_flag"] = cFYLJG001.Mdtrtinfo.NwbFlag
  114. mdtrtinfo["nwb_age"] = cFYLJG001.Mdtrtinfo.NwbAge
  115. mdtrtinfo["suck_prd_flag"] = cFYLJG001.Mdtrtinfo.SuckPrdFlag
  116. mdtrtinfo["algs_his"] = cFYLJG001.Mdtrtinfo.AlgsHis
  117. mdtrtinfo["prsc_dept_name"] = cFYLJG001.Mdtrtinfo.PrscDeptName
  118. mdtrtinfo["prsc_dept_code"] = cFYLJG001.Mdtrtinfo.PrscDeptCode
  119. mdtrtinfo["dr_code"] = cFYLJG001.Mdtrtinfo.DrCode
  120. mdtrtinfo["prsc_dr_name"] = cFYLJG001.Mdtrtinfo.PrscDrName
  121. mdtrtinfo["prsc_dr_cert_type"] = cFYLJG001.Mdtrtinfo.PrscDrCertType
  122. mdtrtinfo["prsc_dr_certno"] = cFYLJG001.Mdtrtinfo.PrscDrCertno
  123. mdtrtinfo["dr_profttl_codg"] = cFYLJG001.Mdtrtinfo.DrProfttlCodg
  124. mdtrtinfo["dr_profttl_name"] = cFYLJG001.Mdtrtinfo.DrProfttlName
  125. mdtrtinfo["dr_dept_code"] = cFYLJG001.Mdtrtinfo.DrDeptCode
  126. mdtrtinfo["dr_dept_name"] = cFYLJG001.Mdtrtinfo.DrDeptName
  127. mdtrtinfo["caty"] = cFYLJG001.Mdtrtinfo.Caty
  128. mdtrtinfo["mdtrt_time"] = cFYLJG001.Mdtrtinfo.MdtrtTime
  129. mdtrtinfo["dise_codg"] = cFYLJG001.Mdtrtinfo.DiseCodg
  130. mdtrtinfo["dise_name"] = cFYLJG001.Mdtrtinfo.DiseName
  131. mdtrtinfo["sp_dise_flag"] = cFYLJG001.Mdtrtinfo.SpDiseFlag
  132. mdtrtinfo["maindiag_code"] = cFYLJG001.Mdtrtinfo.MaindiagCode
  133. mdtrtinfo["maindiag_name"] = cFYLJG001.Mdtrtinfo.MaindiagName
  134. mdtrtinfo["dise_cond_dscr"] = cFYLJG001.Mdtrtinfo.DiseCondDscr
  135. mdtrtinfo["hi_feesetl_flag"] = cFYLJG001.Mdtrtinfo.HiFeesetlFlag
  136. mdtrtinfo["hi_feesetl_name"] = cFYLJG001.Mdtrtinfo.HiFeesetlName
  137. mdtrtinfo["rgst_fee"] = cFYLJG001.Mdtrtinfo.RgstFee
  138. mdtrtinfo["medfee_sumamt"] = cFYLJG001.Mdtrtinfo.MedfeeSumamt
  139. mdtrtinfo["fstdiag_flag"] = cFYLJG001.Mdtrtinfo.FstdiagFlag
  140. mdtrtinfo["extras"] = cFYLJG001.Mdtrtinfo.Extras
  141. inputData["mdtrtinfo"] = mdtrtinfo
  142. diseinfos := make([]map[string]interface{}, 0)
  143. for _, item := range cFYLJG001.Diseinfo {
  144. diseinfo := make(map[string]interface{})
  145. diseinfo["diag_type"] = item.DiagType
  146. diseinfo["maindiag_flag"] = item.MaindiagFlag
  147. diseinfo["diag_srt_no"] = item.DiagSrtNo
  148. diseinfo["diag_code"] = item.DiagCode
  149. diseinfo["diag_name"] = item.DiagName
  150. diseinfo["diag_dept"] = item.DiagDept
  151. diseinfo["diag_dr_no"] = item.DiagDrNo
  152. diseinfo["diag_dr_name"] = item.DiagDrName
  153. diseinfo["diag_time"] = item.DiagTime
  154. diseinfo["tcm_dise_code"] = item.TcmDiseCode
  155. diseinfo["tcm_dise_name"] = item.TcmDiseName
  156. diseinfo["tcmsymp_code"] = item.TcmsympCode
  157. diseinfo["tcmsymp"] = item.Tcmsymp
  158. diseinfos = append(diseinfos, diseinfo)
  159. }
  160. inputData["diseinfo"] = diseinfos
  161. inputMessage["input"] = inputData
  162. var inputLog string
  163. bytesData, err := json.Marshal(inputMessage)
  164. inputLog = string(bytesData)
  165. fmt.Println(string(bytesData))
  166. if err != nil {
  167. fmt.Println(err.Error())
  168. return err.Error(), ""
  169. }
  170. reader := bytes.NewReader(bytesData)
  171. gdyb_url := beego.AppConfig.String("gdyb_url")
  172. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  173. var url string
  174. if fixmedins_code == "H15049901371" {
  175. url = gdyb_url
  176. } else {
  177. url = gdyb_url + "CFYLJG001"
  178. }
  179. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  180. request, err := http.NewRequest("POST", url, reader)
  181. if err != nil {
  182. fmt.Println(err.Error())
  183. return err.Error(), ""
  184. }
  185. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  186. request.Header.Set("x-tif-paasid", gdyb_paasid)
  187. request.Header.Set("x-tif-signature", signature)
  188. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  189. request.Header.Set("x-tif-nonce", nonce)
  190. client := http.Client{}
  191. resp, err := client.Do(request)
  192. if err != nil {
  193. fmt.Println(err.Error())
  194. return err.Error(), ""
  195. }
  196. respBytes, err := ioutil.ReadAll(resp.Body)
  197. if err != nil {
  198. fmt.Println(err.Error())
  199. return err.Error(), ""
  200. }
  201. fmt.Println(string(respBytes))
  202. str := string(respBytes)
  203. return str, inputLog
  204. }
  205. 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) {
  206. //生成签名
  207. nonce := GetRandomString(32)
  208. timestamp := time.Now().Unix()
  209. signature := setSignature(timestamp, nonce, secret_key)
  210. //生成输入报文
  211. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  212. inputData := make(map[string]interface{})
  213. //inputData := makemap[string]interface{})
  214. inputMessage["infno"] = "CFYLJG002"
  215. inputData["fixmedins_code"] = fixmedins_code
  216. inputData["original_value"] = original_value
  217. inputData["original_rx_file"] = original_rx_file
  218. inputData["extras"] = extras
  219. inputMessage["rx_sign_info"] = inputData
  220. var inputLog string
  221. bytesData, err := json.Marshal(inputMessage)
  222. inputLog = string(bytesData)
  223. fmt.Println(string(bytesData))
  224. if err != nil {
  225. fmt.Println(err.Error())
  226. return err.Error(), ""
  227. }
  228. reader := bytes.NewReader(bytesData)
  229. gdyb_url := beego.AppConfig.String("gdyb_url")
  230. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  231. var url string
  232. if fixmedins_code == "H15049901371" {
  233. url = gdyb_url
  234. } else {
  235. url = gdyb_url + "CFYLJG002"
  236. }
  237. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  238. request, err := http.NewRequest("POST", url, reader)
  239. if err != nil {
  240. fmt.Println(err.Error())
  241. return err.Error(), ""
  242. }
  243. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  244. request.Header.Set("x-tif-paasid", gdyb_paasid)
  245. request.Header.Set("x-tif-signature", signature)
  246. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  247. request.Header.Set("x-tif-nonce", nonce)
  248. client := http.Client{}
  249. resp, err := client.Do(request)
  250. if err != nil {
  251. fmt.Println(err.Error())
  252. return err.Error(), ""
  253. }
  254. respBytes, err := ioutil.ReadAll(resp.Body)
  255. if err != nil {
  256. fmt.Println(err.Error())
  257. return err.Error(), ""
  258. }
  259. fmt.Println(string(respBytes))
  260. str := string(respBytes)
  261. return str, inputLog
  262. }
  263. func GetCFYLJG003(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG003 models.CFYLJG003) (string, string) {
  264. //生成签名
  265. nonce := GetRandomString(32)
  266. timestamp := time.Now().Unix()
  267. signature := setSignature(timestamp, nonce, secret_key)
  268. //生成输入报文
  269. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  270. //input := make(map[string]interface{})
  271. inputData := make(map[string]interface{})
  272. inputMessage["infno"] = "CFYLJG003"
  273. inputData["rx_trace_code"] = cFYLJG003.RxTraceCode
  274. inputData["hi_rxno"] = cFYLJG003.HiRxno
  275. inputData["mdtrt_id"] = cFYLJG003.MdtrtID
  276. inputData["patn_name"] = cFYLJG003.PatnName
  277. inputData["psn_cert_type"] = cFYLJG003.PsnCertType
  278. inputData["certno"] = cFYLJG003.Certno
  279. inputData["fixmedins_name"] = cFYLJG003.FixmedinsName
  280. inputData["fixmedins_code"] = cFYLJG003.FixmedinsCode
  281. inputData["dr_code"] = cFYLJG003.DrCode
  282. inputData["prsc_dr_name"] = cFYLJG003.PrscDrName
  283. inputData["phar_dept_name"] = cFYLJG003.PharDeptName
  284. inputData["phar_dept_code"] = cFYLJG003.PharDeptCode
  285. inputData["phar_profttl_codg"] = cFYLJG003.PharProfttlCodg
  286. inputData["phar_profttl_name"] = cFYLJG003.PharProfttlName
  287. inputData["phar_code"] = cFYLJG003.PharCode
  288. inputData["rx_frqu_name"] = cFYLJG003.RxFrquName
  289. inputData["phar_cert_type"] = cFYLJG003.PsnCertType
  290. inputData["phar_certno"] = cFYLJG003.PharCertno
  291. inputData["phar_name"] = cFYLJG003.PharName
  292. inputData["phar_prac_cert_no"] = cFYLJG003.PharPracCertNo
  293. inputData["phar_chk_time"] = cFYLJG003.PharChkTime
  294. inputData["rx_file"] = cFYLJG003.RxFile
  295. inputData["sign_digest"] = cFYLJG003.SignDigest
  296. inputMessage["rx_upload_info"] = inputData
  297. var inputLog string
  298. bytesData, err := json.Marshal(inputMessage)
  299. inputLog = string(bytesData)
  300. fmt.Println(string(bytesData))
  301. if err != nil {
  302. fmt.Println(err.Error())
  303. return err.Error(), ""
  304. }
  305. reader := bytes.NewReader(bytesData)
  306. gdyb_url := beego.AppConfig.String("gdyb_url")
  307. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  308. var url string
  309. if fixmedins_code == "H15049901371" {
  310. url = gdyb_url
  311. } else {
  312. url = gdyb_url + "CFYLJG003"
  313. }
  314. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  315. request, err := http.NewRequest("POST", url, reader)
  316. if err != nil {
  317. fmt.Println(err.Error())
  318. return err.Error(), ""
  319. }
  320. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  321. request.Header.Set("x-tif-paasid", gdyb_paasid)
  322. request.Header.Set("x-tif-signature", signature)
  323. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  324. request.Header.Set("x-tif-nonce", nonce)
  325. client := http.Client{}
  326. resp, err := client.Do(request)
  327. if err != nil {
  328. fmt.Println(err.Error())
  329. return err.Error(), ""
  330. }
  331. respBytes, err := ioutil.ReadAll(resp.Body)
  332. if err != nil {
  333. fmt.Println(err.Error())
  334. return err.Error(), ""
  335. }
  336. fmt.Println(string(respBytes))
  337. str := string(respBytes)
  338. return str, inputLog
  339. }
  340. func GetCFYLJG004(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG004 models.CFYLJG004) (string, string) {
  341. //生成签名
  342. nonce := GetRandomString(32)
  343. timestamp := time.Now().Unix()
  344. signature := setSignature(timestamp, nonce, secret_key)
  345. //生成输入报文
  346. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  347. inputData := make(map[string]interface{})
  348. //inputDatas := make([]map[string]interface{}, 0)
  349. inputMessage["infno"] = "CFYLJG004"
  350. inputData["hi_rxno"] = cFYLJG004.HiRxno
  351. inputData["undo_dr_code"] = cFYLJG004.UndoDrCode
  352. inputData["undo_dr_name"] = cFYLJG004.UndoDrName
  353. inputData["undo_dr_cert_type"] = cFYLJG004.UndoDrCertType
  354. inputData["undo_dr_certno"] = cFYLJG004.UndoDrCertno
  355. inputData["undo_rea"] = cFYLJG004.UndoRea
  356. inputData["undo_time"] = cFYLJG004.UndoTime
  357. inputData["fixmedins_code"] = cFYLJG004.FixmedinsCode
  358. inputMessage["rx_cancel_info"] = inputData
  359. var inputLog string
  360. bytesData, err := json.Marshal(inputMessage)
  361. inputLog = string(bytesData)
  362. fmt.Println(string(bytesData))
  363. if err != nil {
  364. fmt.Println(err.Error())
  365. return err.Error(), ""
  366. }
  367. reader := bytes.NewReader(bytesData)
  368. gdyb_url := beego.AppConfig.String("gdyb_url")
  369. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  370. var url string
  371. if fixmedins_code == "H15049901371" {
  372. url = gdyb_url
  373. } else {
  374. url = gdyb_url + "CFYLJG004"
  375. }
  376. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  377. request, err := http.NewRequest("POST", url, reader)
  378. if err != nil {
  379. fmt.Println(err.Error())
  380. return err.Error(), ""
  381. }
  382. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  383. request.Header.Set("x-tif-paasid", gdyb_paasid)
  384. request.Header.Set("x-tif-signature", signature)
  385. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  386. request.Header.Set("x-tif-nonce", nonce)
  387. client := http.Client{}
  388. resp, err := client.Do(request)
  389. if err != nil {
  390. fmt.Println(err.Error())
  391. return err.Error(), ""
  392. }
  393. respBytes, err := ioutil.ReadAll(resp.Body)
  394. if err != nil {
  395. fmt.Println(err.Error())
  396. return err.Error(), ""
  397. }
  398. fmt.Println(string(respBytes))
  399. str := string(respBytes)
  400. return str, inputLog
  401. }
  402. func GetCFYLJG005(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG005 models.CFYLJG005) (string, string) {
  403. //生成签名
  404. nonce := GetRandomString(32)
  405. timestamp := time.Now().Unix()
  406. signature := setSignature(timestamp, nonce, secret_key)
  407. //生成输入报文
  408. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  409. inputData := make(map[string]interface{})
  410. //inputDatas := make([]map[string]interface{}, 0)
  411. inputMessage["infno"] = "CFYLJG005"
  412. inputData["fixmedins_code"] = cFYLJG005.FixmedinsCode
  413. inputData["hi_rxno"] = cFYLJG005.HiRxno
  414. inputData["mdtrt_id"] = cFYLJG005.MdtrtID
  415. inputData["ec_token"] = cFYLJG005.EcToken
  416. inputData["psn_name"] = cFYLJG005.PsnName
  417. inputData["psn_cert_type"] = cFYLJG005.PsnCertType
  418. inputData["certno"] = cFYLJG005.Certno
  419. inputMessage["rx_detl_query"] = inputData
  420. var inputLog string
  421. bytesData, err := json.Marshal(inputMessage)
  422. inputLog = string(bytesData)
  423. fmt.Println(string(bytesData))
  424. if err != nil {
  425. fmt.Println(err.Error())
  426. return err.Error(), ""
  427. }
  428. reader := bytes.NewReader(bytesData)
  429. gdyb_url := beego.AppConfig.String("gdyb_url")
  430. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  431. var url string
  432. if fixmedins_code == "H15049901371" {
  433. url = gdyb_url
  434. } else {
  435. url = gdyb_url + "CFYLJG005"
  436. }
  437. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  438. request, err := http.NewRequest("POST", url, reader)
  439. if err != nil {
  440. fmt.Println(err.Error())
  441. return err.Error(), ""
  442. }
  443. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  444. request.Header.Set("x-tif-paasid", gdyb_paasid)
  445. request.Header.Set("x-tif-signature", signature)
  446. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  447. request.Header.Set("x-tif-nonce", nonce)
  448. client := http.Client{}
  449. resp, err := client.Do(request)
  450. if err != nil {
  451. fmt.Println(err.Error())
  452. return err.Error(), ""
  453. }
  454. respBytes, err := ioutil.ReadAll(resp.Body)
  455. if err != nil {
  456. fmt.Println(err.Error())
  457. return err.Error(), ""
  458. }
  459. fmt.Println(string(respBytes))
  460. str := string(respBytes)
  461. return str, inputLog
  462. }
  463. func GetCFYLJG006(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG006 models.CFYLJG006) (string, string) {
  464. //生成签名
  465. nonce := GetRandomString(32)
  466. timestamp := time.Now().Unix()
  467. signature := setSignature(timestamp, nonce, secret_key)
  468. //生成输入报文
  469. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  470. inputData := make(map[string]interface{})
  471. //inputDatas := make([]map[string]interface{}, 0)
  472. inputMessage["infno"] = "CFYLJG006"
  473. inputData["fixmedins_code"] = cFYLJG006.FixmedinsCode
  474. inputData["hi_rxno"] = cFYLJG006.HiRxno
  475. inputData["mdtrt_id"] = cFYLJG006.MdtrtID
  476. inputData["psn_cert_type"] = cFYLJG006.PsnCertType
  477. inputData["certno"] = cFYLJG006.Certno
  478. inputData["psn_name"] = cFYLJG006.PsnName
  479. inputMessage["rx_chk_info"] = inputData
  480. var inputLog string
  481. bytesData, err := json.Marshal(inputMessage)
  482. inputLog = string(bytesData)
  483. fmt.Println(string(bytesData))
  484. if err != nil {
  485. fmt.Println(err.Error())
  486. return err.Error(), ""
  487. }
  488. reader := bytes.NewReader(bytesData)
  489. gdyb_url := beego.AppConfig.String("gdyb_url")
  490. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  491. var url string
  492. if fixmedins_code == "H15049901371" {
  493. url = gdyb_url
  494. } else {
  495. url = gdyb_url + "CFYLJG006"
  496. }
  497. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  498. request, err := http.NewRequest("POST", url, reader)
  499. if err != nil {
  500. fmt.Println(err.Error())
  501. return err.Error(), ""
  502. }
  503. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  504. request.Header.Set("x-tif-paasid", gdyb_paasid)
  505. request.Header.Set("x-tif-signature", signature)
  506. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  507. request.Header.Set("x-tif-nonce", nonce)
  508. client := http.Client{}
  509. resp, err := client.Do(request)
  510. if err != nil {
  511. fmt.Println(err.Error())
  512. return err.Error(), ""
  513. }
  514. respBytes, err := ioutil.ReadAll(resp.Body)
  515. if err != nil {
  516. fmt.Println(err.Error())
  517. return err.Error(), ""
  518. }
  519. fmt.Println(string(respBytes))
  520. str := string(respBytes)
  521. return str, inputLog
  522. }
  523. func GetCFYLJG007(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG007 models.CFYLJG007) (string, string) {
  524. //生成签名
  525. nonce := GetRandomString(32)
  526. timestamp := time.Now().Unix()
  527. signature := setSignature(timestamp, nonce, secret_key)
  528. //生成输入报文
  529. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  530. inputData := make(map[string]interface{})
  531. //inputDatas := make([]map[string]interface{}, 0)
  532. inputMessage["infno"] = "CFYLJG007"
  533. inputData["fixmedins_code"] = cFYLJG007.FixmedinsCode
  534. inputData["hi_rxno"] = cFYLJG007.HiRxno
  535. inputData["mdtrt_id"] = cFYLJG007.MdtrtID
  536. inputData["psn_no"] = cFYLJG007.PsnNo
  537. inputData["psn_cert_type"] = cFYLJG007.PsnCertType
  538. inputData["certno"] = cFYLJG007.Certno
  539. inputMessage["rx_setl_query"] = inputData
  540. var inputLog string
  541. bytesData, err := json.Marshal(inputMessage)
  542. inputLog = string(bytesData)
  543. fmt.Println(string(bytesData))
  544. if err != nil {
  545. fmt.Println(err.Error())
  546. return err.Error(), ""
  547. }
  548. reader := bytes.NewReader(bytesData)
  549. gdyb_url := beego.AppConfig.String("gdyb_url")
  550. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  551. var url string
  552. if fixmedins_code == "H15049901371" {
  553. url = gdyb_url
  554. } else {
  555. url = gdyb_url + "CFYLJG007"
  556. }
  557. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  558. request, err := http.NewRequest("POST", url, reader)
  559. if err != nil {
  560. fmt.Println(err.Error())
  561. return err.Error(), ""
  562. }
  563. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  564. request.Header.Set("x-tif-paasid", gdyb_paasid)
  565. request.Header.Set("x-tif-signature", signature)
  566. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  567. request.Header.Set("x-tif-nonce", nonce)
  568. client := http.Client{}
  569. resp, err := client.Do(request)
  570. if err != nil {
  571. fmt.Println(err.Error())
  572. return err.Error(), ""
  573. }
  574. respBytes, err := ioutil.ReadAll(resp.Body)
  575. if err != nil {
  576. fmt.Println(err.Error())
  577. return err.Error(), ""
  578. }
  579. fmt.Println(string(respBytes))
  580. str := string(respBytes)
  581. return str, inputLog
  582. }
  583. func Getflow(id int64) (flow models.HisPrescriptionFlow, err error) {
  584. err = readDb.Model(&models.HisPrescriptionFlow{}).Where("id = ?", id).First(&flow).Error
  585. return
  586. }