dianzichufang.go 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  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,isu string) (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"] = ""
  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. type MyData struct {
  141. Insutype string `json:"insutype"`
  142. }
  143. data := MyData{
  144. Insutype: isu,
  145. }
  146. mdtrtinfo["extras"] = data
  147. inputData["mdtrtinfo"] = mdtrtinfo
  148. diseinfos := make([]map[string]interface{}, 0)
  149. for _, item := range cFYLJG001.Diseinfo {
  150. diseinfo := make(map[string]interface{})
  151. diseinfo["diag_type"] = item.DiagType
  152. diseinfo["maindiag_flag"] = item.MaindiagFlag
  153. diseinfo["diag_srt_no"] = item.DiagSrtNo
  154. diseinfo["diag_code"] = item.DiagCode
  155. diseinfo["diag_name"] = item.DiagName
  156. diseinfo["diag_dept"] = item.DiagDept
  157. diseinfo["diag_dr_no"] = item.DiagDrNo
  158. diseinfo["diag_dr_name"] = item.DiagDrName
  159. diseinfo["diag_time"] = item.DiagTime
  160. diseinfo["tcm_dise_code"] = item.TcmDiseCode
  161. diseinfo["tcm_dise_name"] = item.TcmDiseName
  162. diseinfo["tcmsymp_code"] = item.TcmsympCode
  163. diseinfo["tcmsymp"] = item.Tcmsymp
  164. diseinfos = append(diseinfos, diseinfo)
  165. }
  166. inputData["diseinfo"] = diseinfos
  167. inputMessage["input"] = inputData
  168. var inputLog string
  169. bytesData, err := json.Marshal(inputMessage)
  170. inputLog = string(bytesData)
  171. fmt.Println(string(bytesData))
  172. if err != nil {
  173. fmt.Println(err.Error())
  174. return err.Error(), ""
  175. }
  176. reader := bytes.NewReader(bytesData)
  177. gdyb_url := beego.AppConfig.String("gdyb_url")
  178. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  179. var url string
  180. if fixmedins_code == "H15049901371" {
  181. url = gdyb_url
  182. } else {
  183. url = gdyb_url + "CFYLJG001"
  184. }
  185. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  186. request, err := http.NewRequest("POST", url, reader)
  187. if err != nil {
  188. fmt.Println(err.Error())
  189. return err.Error(), ""
  190. }
  191. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  192. request.Header.Set("x-tif-paasid", gdyb_paasid)
  193. request.Header.Set("x-tif-signature", signature)
  194. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  195. request.Header.Set("x-tif-nonce", nonce)
  196. client := http.Client{}
  197. resp, err := client.Do(request)
  198. if err != nil {
  199. fmt.Println(err.Error())
  200. return err.Error(), ""
  201. }
  202. respBytes, err := ioutil.ReadAll(resp.Body)
  203. if err != nil {
  204. fmt.Println(err.Error())
  205. return err.Error(), ""
  206. }
  207. fmt.Println(string(respBytes))
  208. str := string(respBytes)
  209. return str, inputLog
  210. }
  211. 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) {
  212. //生成签名
  213. nonce := GetRandomString(32)
  214. timestamp := time.Now().Unix()
  215. signature := setSignature(timestamp, nonce, secret_key)
  216. //生成输入报文
  217. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  218. inputData := make(map[string]interface{})
  219. inputDatas := make(map[string]interface{})
  220. inputMessage["infno"] = "CFYLJG002"
  221. inputData["fixmedins_code"] = fixmedins_code
  222. inputData["original_value"] = original_value
  223. inputData["original_rx_file"] = original_rx_file
  224. inputData["extras"] = extras
  225. inputDatas["rx_sign_info"] = inputData
  226. inputMessage["input"] = inputDatas
  227. var inputLog string
  228. bytesData, err := json.Marshal(inputMessage)
  229. inputLog = string(bytesData)
  230. fmt.Println(string(bytesData))
  231. if err != nil {
  232. fmt.Println(err.Error())
  233. return err.Error(), ""
  234. }
  235. reader := bytes.NewReader(bytesData)
  236. gdyb_url := beego.AppConfig.String("gdyb_url")
  237. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  238. var url string
  239. if fixmedins_code == "H15049901371" {
  240. url = gdyb_url
  241. } else {
  242. url = gdyb_url + "CFYLJG002"
  243. }
  244. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  245. request, err := http.NewRequest("POST", url, reader)
  246. if err != nil {
  247. fmt.Println(err.Error())
  248. return err.Error(), ""
  249. }
  250. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  251. request.Header.Set("x-tif-paasid", gdyb_paasid)
  252. request.Header.Set("x-tif-signature", signature)
  253. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  254. request.Header.Set("x-tif-nonce", nonce)
  255. client := http.Client{}
  256. resp, err := client.Do(request)
  257. if err != nil {
  258. fmt.Println(err.Error())
  259. return err.Error(), ""
  260. }
  261. respBytes, err := ioutil.ReadAll(resp.Body)
  262. if err != nil {
  263. fmt.Println(err.Error())
  264. return err.Error(), ""
  265. }
  266. fmt.Println(string(respBytes))
  267. str := string(respBytes)
  268. return str, inputLog
  269. }
  270. func GetCFYLJG003(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG003 models.CFYLJG003) (string, string) {
  271. //生成签名
  272. nonce := GetRandomString(32)
  273. timestamp := time.Now().Unix()
  274. signature := setSignature(timestamp, nonce, secret_key)
  275. //生成输入报文
  276. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  277. //input := make(map[string]interface{})
  278. inputData := make(map[string]interface{})
  279. inputData2 := make(map[string]interface{})
  280. inputMessage["infno"] = "CFYLJG003"
  281. inputData["rx_trace_code"] = cFYLJG003.RxTraceCode
  282. inputData["hi_rxno"] = cFYLJG003.HiRxno
  283. inputData["mdtrt_id"] = cFYLJG003.MdtrtID
  284. inputData["patn_name"] = cFYLJG003.PatnName
  285. inputData["psn_cert_type"] = cFYLJG003.PsnCertType
  286. inputData["certno"] = cFYLJG003.Certno
  287. inputData["fixmedins_name"] = cFYLJG003.FixmedinsName
  288. inputData["fixmedins_code"] = cFYLJG003.FixmedinsCode
  289. inputData["dr_code"] = cFYLJG003.DrCode
  290. inputData["prsc_dr_name"] = cFYLJG003.PrscDrName
  291. inputData["phar_dept_name"] = cFYLJG003.PharDeptName
  292. inputData["phar_dept_code"] = cFYLJG003.PharDeptCode
  293. inputData["phar_profttl_codg"] = cFYLJG003.PharProfttlCodg
  294. inputData["phar_profttl_name"] = cFYLJG003.PharProfttlName
  295. inputData["phar_code"] = cFYLJG003.PharCode
  296. inputData["rx_frqu_name"] = cFYLJG003.RxFrquName
  297. inputData["phar_cert_type"] = cFYLJG003.PsnCertType
  298. inputData["phar_certno"] = cFYLJG003.PharCertno
  299. inputData["phar_name"] = cFYLJG003.PharName
  300. inputData["phar_prac_cert_no"] = cFYLJG003.PharPracCertNo
  301. inputData["phar_chk_time"] = cFYLJG003.PharChkTime
  302. inputData["rx_file"] = cFYLJG003.RxFile
  303. inputData["sign_digest"] = cFYLJG003.SignDigest
  304. inputData2["rx_upload_info"] = inputData
  305. inputMessage["input"] = inputData2
  306. var inputLog string
  307. bytesData, err := json.Marshal(inputMessage)
  308. inputLog = string(bytesData)
  309. fmt.Println(string(bytesData))
  310. if err != nil {
  311. fmt.Println(err.Error())
  312. return err.Error(), ""
  313. }
  314. reader := bytes.NewReader(bytesData)
  315. gdyb_url := beego.AppConfig.String("gdyb_url")
  316. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  317. var url string
  318. if fixmedins_code == "H15049901371" {
  319. url = gdyb_url
  320. } else {
  321. url = gdyb_url + "CFYLJG003"
  322. }
  323. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  324. request, err := http.NewRequest("POST", url, reader)
  325. if err != nil {
  326. fmt.Println(err.Error())
  327. return err.Error(), ""
  328. }
  329. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  330. request.Header.Set("x-tif-paasid", gdyb_paasid)
  331. request.Header.Set("x-tif-signature", signature)
  332. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  333. request.Header.Set("x-tif-nonce", nonce)
  334. client := http.Client{}
  335. resp, err := client.Do(request)
  336. if err != nil {
  337. fmt.Println(err.Error())
  338. return err.Error(), ""
  339. }
  340. respBytes, err := ioutil.ReadAll(resp.Body)
  341. if err != nil {
  342. fmt.Println(err.Error())
  343. return err.Error(), ""
  344. }
  345. fmt.Println(string(respBytes))
  346. str := string(respBytes)
  347. return str, inputLog
  348. }
  349. func GetCFYLJG004(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG004 models.CFYLJG004) (string, string) {
  350. //生成签名
  351. nonce := GetRandomString(32)
  352. timestamp := time.Now().Unix()
  353. signature := setSignature(timestamp, nonce, secret_key)
  354. //生成输入报文
  355. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  356. inputData := make(map[string]interface{})
  357. inputData1 := make(map[string]interface{})
  358. //inputDatas := make([]map[string]interface{}, 0)
  359. inputMessage["infno"] = "CFYLJG004"
  360. inputData["hi_rxno"] = cFYLJG004.HiRxno
  361. inputData["undo_dr_code"] = cFYLJG004.UndoDrCode
  362. inputData["undo_dr_name"] = cFYLJG004.UndoDrName
  363. inputData["undo_dr_cert_type"] = cFYLJG004.UndoDrCertType
  364. inputData["undo_dr_certno"] = cFYLJG004.UndoDrCertno
  365. inputData["undo_rea"] = cFYLJG004.UndoRea
  366. inputData["undo_time"] = cFYLJG004.UndoTime
  367. inputData["fixmedins_code"] = cFYLJG004.FixmedinsCode
  368. inputData1["rx_cancel_info"] = inputData
  369. inputMessage["input"] = inputData1
  370. var inputLog string
  371. bytesData, err := json.Marshal(inputMessage)
  372. inputLog = string(bytesData)
  373. fmt.Println(string(bytesData))
  374. if err != nil {
  375. fmt.Println(err.Error())
  376. return err.Error(), ""
  377. }
  378. reader := bytes.NewReader(bytesData)
  379. gdyb_url := beego.AppConfig.String("gdyb_url")
  380. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  381. var url string
  382. if fixmedins_code == "H15049901371" {
  383. url = gdyb_url
  384. } else {
  385. url = gdyb_url + "CFYLJG004"
  386. }
  387. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  388. request, err := http.NewRequest("POST", url, reader)
  389. if err != nil {
  390. fmt.Println(err.Error())
  391. return err.Error(), ""
  392. }
  393. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  394. request.Header.Set("x-tif-paasid", gdyb_paasid)
  395. request.Header.Set("x-tif-signature", signature)
  396. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  397. request.Header.Set("x-tif-nonce", nonce)
  398. client := http.Client{}
  399. resp, err := client.Do(request)
  400. if err != nil {
  401. fmt.Println(err.Error())
  402. return err.Error(), ""
  403. }
  404. respBytes, err := ioutil.ReadAll(resp.Body)
  405. if err != nil {
  406. fmt.Println(err.Error())
  407. return err.Error(), ""
  408. }
  409. fmt.Println(string(respBytes))
  410. str := string(respBytes)
  411. return str, inputLog
  412. }
  413. func GetCFYLJG005(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG005 models.CFYLJG005) (string, string) {
  414. //生成签名
  415. nonce := GetRandomString(32)
  416. timestamp := time.Now().Unix()
  417. signature := setSignature(timestamp, nonce, secret_key)
  418. //生成输入报文
  419. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  420. inputData := make(map[string]interface{})
  421. inputData2 := make(map[string]interface{})
  422. //inputDatas := make([]map[string]interface{}, 0)
  423. inputMessage["infno"] = "CFYLJG005"
  424. inputData["fixmedins_code"] = fixmedins_code
  425. inputData["hi_rxno"] = cFYLJG005.HiRxno
  426. inputData["mdtrt_id"] = cFYLJG005.MdtrtID
  427. inputData["ec_token"] = cFYLJG005.EcToken
  428. inputData["psn_name"] = cFYLJG005.PsnName
  429. inputData["psn_cert_type"] = cFYLJG005.PsnCertType
  430. inputData["certno"] = cFYLJG005.Certno
  431. inputData2["rx_detl_query"] = inputData
  432. inputMessage["input"] = inputData2
  433. var inputLog string
  434. bytesData, err := json.Marshal(inputMessage)
  435. inputLog = string(bytesData)
  436. fmt.Println(string(bytesData))
  437. if err != nil {
  438. fmt.Println(err.Error())
  439. return err.Error(), ""
  440. }
  441. reader := bytes.NewReader(bytesData)
  442. gdyb_url := beego.AppConfig.String("gdyb_url")
  443. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  444. var url string
  445. if fixmedins_code == "H15049901371" {
  446. url = gdyb_url
  447. } else {
  448. url = gdyb_url + "CFYLJG005"
  449. }
  450. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  451. request, err := http.NewRequest("POST", url, reader)
  452. if err != nil {
  453. fmt.Println(err.Error())
  454. return err.Error(), ""
  455. }
  456. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  457. request.Header.Set("x-tif-paasid", gdyb_paasid)
  458. request.Header.Set("x-tif-signature", signature)
  459. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  460. request.Header.Set("x-tif-nonce", nonce)
  461. client := http.Client{}
  462. resp, err := client.Do(request)
  463. if err != nil {
  464. fmt.Println(err.Error())
  465. return err.Error(), ""
  466. }
  467. respBytes, err := ioutil.ReadAll(resp.Body)
  468. if err != nil {
  469. fmt.Println(err.Error())
  470. return err.Error(), ""
  471. }
  472. fmt.Println(string(respBytes))
  473. str := string(respBytes)
  474. return str, inputLog
  475. }
  476. func GetCFYLJG006(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG006 models.CFYLJG006) (string, string) {
  477. //生成签名
  478. nonce := GetRandomString(32)
  479. timestamp := time.Now().Unix()
  480. signature := setSignature(timestamp, nonce, secret_key)
  481. //生成输入报文
  482. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  483. inputData := make(map[string]interface{})
  484. //inputDatas := make([]map[string]interface{}, 0)
  485. inputData2 := make(map[string]interface{})
  486. inputMessage["infno"] = "CFYLJG006"
  487. inputData["fixmedins_code"] = fixmedins_code
  488. inputData["hi_rxno"] = cFYLJG006.HiRxno
  489. inputData["mdtrt_id"] = cFYLJG006.MdtrtID
  490. inputData["psn_cert_type"] = cFYLJG006.PsnCertType
  491. inputData["certno"] = cFYLJG006.Certno
  492. inputData["psn_name"] = cFYLJG006.PsnName
  493. inputData2["rx_chk_info"] =inputData
  494. inputMessage["input"] = inputData2
  495. var inputLog string
  496. bytesData, err := json.Marshal(inputMessage)
  497. inputLog = string(bytesData)
  498. fmt.Println(string(bytesData))
  499. if err != nil {
  500. fmt.Println(err.Error())
  501. return err.Error(), ""
  502. }
  503. reader := bytes.NewReader(bytesData)
  504. gdyb_url := beego.AppConfig.String("gdyb_url")
  505. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  506. var url string
  507. if fixmedins_code == "H15049901371" {
  508. url = gdyb_url
  509. } else {
  510. url = gdyb_url + "CFYLJG006"
  511. }
  512. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  513. request, err := http.NewRequest("POST", url, reader)
  514. if err != nil {
  515. fmt.Println(err.Error())
  516. return err.Error(), ""
  517. }
  518. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  519. request.Header.Set("x-tif-paasid", gdyb_paasid)
  520. request.Header.Set("x-tif-signature", signature)
  521. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  522. request.Header.Set("x-tif-nonce", nonce)
  523. client := http.Client{}
  524. resp, err := client.Do(request)
  525. if err != nil {
  526. fmt.Println(err.Error())
  527. return err.Error(), ""
  528. }
  529. respBytes, err := ioutil.ReadAll(resp.Body)
  530. if err != nil {
  531. fmt.Println(err.Error())
  532. return err.Error(), ""
  533. }
  534. fmt.Println(string(respBytes))
  535. str := string(respBytes)
  536. return str, inputLog
  537. }
  538. func GetCFYLJG007(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG007 models.CFYLJG007) (string, string) {
  539. //生成签名
  540. nonce := GetRandomString(32)
  541. timestamp := time.Now().Unix()
  542. signature := setSignature(timestamp, nonce, secret_key)
  543. //生成输入报文
  544. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  545. inputData := make(map[string]interface{})
  546. inputData2 := make(map[string]interface{})
  547. //inputDatas := make([]map[string]interface{}, 0)
  548. inputMessage["infno"] = "CFYLJG007"
  549. inputData["fixmedins_code"] = fixmedins_code
  550. inputData["hi_rxno"] = cFYLJG007.HiRxno
  551. inputData["mdtrt_id"] = cFYLJG007.MdtrtID
  552. inputData["psn_no"] = cFYLJG007.PsnNo
  553. inputData["psn_cert_type"] = cFYLJG007.PsnCertType
  554. inputData["certno"] = cFYLJG007.Certno
  555. inputData["psn_name"] = cFYLJG007.PsnName
  556. inputData2["rx_setl_query"] = inputData
  557. inputMessage["input"] = inputData2
  558. var inputLog string
  559. bytesData, err := json.Marshal(inputMessage)
  560. inputLog = string(bytesData)
  561. fmt.Println(string(bytesData))
  562. if err != nil {
  563. fmt.Println(err.Error())
  564. return err.Error(), ""
  565. }
  566. reader := bytes.NewReader(bytesData)
  567. gdyb_url := beego.AppConfig.String("gdyb_url")
  568. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  569. var url string
  570. if fixmedins_code == "H15049901371" {
  571. url = gdyb_url
  572. } else {
  573. url = gdyb_url + "CFYLJG007"
  574. }
  575. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  576. request, err := http.NewRequest("POST", url, reader)
  577. if err != nil {
  578. fmt.Println(err.Error())
  579. return err.Error(), ""
  580. }
  581. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  582. request.Header.Set("x-tif-paasid", gdyb_paasid)
  583. request.Header.Set("x-tif-signature", signature)
  584. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  585. request.Header.Set("x-tif-nonce", nonce)
  586. client := http.Client{}
  587. resp, err := client.Do(request)
  588. if err != nil {
  589. fmt.Println(err.Error())
  590. return err.Error(), ""
  591. }
  592. respBytes, err := ioutil.ReadAll(resp.Body)
  593. if err != nil {
  594. fmt.Println(err.Error())
  595. return err.Error(), ""
  596. }
  597. fmt.Println(string(respBytes))
  598. str := string(respBytes)
  599. return str, inputLog
  600. }
  601. func GetCFYLJG008(org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, cFYLJG008 models.CFYLJG008) (string, string) {
  602. //生成签名
  603. nonce := GetRandomString(32)
  604. timestamp := time.Now().Unix()
  605. signature := setSignature(timestamp, nonce, secret_key)
  606. //生成输入报文
  607. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  608. inputData := make(map[string]interface{})
  609. //inputData2 := make(map[string]interface{})
  610. //inputDatas := make([]map[string]interface{}, 0)
  611. inputMessage["infno"] = "CFYLJG008"
  612. inputData["pageNum"] = cFYLJG008.PageNum
  613. inputData["pageSize"] = cFYLJG008.PageSize
  614. inputData["orderType"] = cFYLJG008.OrderType
  615. inputData["poolareaNo"] = cFYLJG008.PoolareaNo
  616. inputData["fixmedinsName"] = cFYLJG008.FixmedinsName
  617. inputData["lng"] = cFYLJG008.Lng
  618. inputData["lat"] = cFYLJG008.Lat
  619. inputData["medinsProdInvChgDDTOList"] = cFYLJG008.MedList
  620. inputMessage["input"] = inputData
  621. var inputLog string
  622. bytesData, err := json.Marshal(inputMessage)
  623. inputLog = string(bytesData)
  624. fmt.Println(string(bytesData))
  625. if err != nil {
  626. fmt.Println(err.Error())
  627. return err.Error(), ""
  628. }
  629. reader := bytes.NewReader(bytesData)
  630. gdyb_url := beego.AppConfig.String("gdyb_url")
  631. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  632. var url string
  633. if fixmedins_code == "H15049901371" {
  634. url = gdyb_url
  635. } else {
  636. url = gdyb_url + "CFYLJG007"
  637. }
  638. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  639. request, err := http.NewRequest("POST", url, reader)
  640. if err != nil {
  641. fmt.Println(err.Error())
  642. return err.Error(), ""
  643. }
  644. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  645. request.Header.Set("x-tif-paasid", gdyb_paasid)
  646. request.Header.Set("x-tif-signature", signature)
  647. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  648. request.Header.Set("x-tif-nonce", nonce)
  649. client := http.Client{}
  650. resp, err := client.Do(request)
  651. if err != nil {
  652. fmt.Println(err.Error())
  653. return err.Error(), ""
  654. }
  655. respBytes, err := ioutil.ReadAll(resp.Body)
  656. if err != nil {
  657. fmt.Println(err.Error())
  658. return err.Error(), ""
  659. }
  660. fmt.Println(string(respBytes))
  661. str := string(respBytes)
  662. return str, inputLog
  663. }
  664. func Getflow(id int64) (flow models.HisPrescriptionFlow, err error) {
  665. err = readDb.Model(&models.HisPrescriptionFlow{}).Where("id = ?", id).First(&flow).Error
  666. return
  667. }