zh_his_service.go 53KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422
  1. package service
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "github.com/astaxie/beego"
  8. "github.com/jinzhu/gorm"
  9. "io/ioutil"
  10. "net/http"
  11. "strconv"
  12. "time"
  13. _ "unsafe"
  14. )
  15. // 人员基本信息
  16. func ZHGdyb1101(certNo string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, card_sn string, certificates int64, name string) (string, string, string) {
  17. //生成签名
  18. var requestLog string
  19. var resultLog string
  20. nonce := GetRandomString(32)
  21. timestamp := time.Now().Unix()
  22. signature := setSignature(timestamp, nonce, secret_key)
  23. //生成输入报文
  24. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  25. input := make(map[string]interface{})
  26. inputData := make(map[string]interface{})
  27. inputMessage["infno"] = "1101" // 交易编码
  28. if certificates == 3 {
  29. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  30. inputData["certno"] = certNo // 证件号码
  31. inputData["psn_cert_type"] = "99" // 人员证件类型
  32. } else {
  33. if id_card_type == 1 {
  34. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  35. inputData["card_sn"] = card_sn // 卡识别码
  36. inputData["certno"] = certNo // 证件号码
  37. inputData["psn_cert_type"] = "01" // 人员证件类型
  38. } else {
  39. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  40. inputData["card_sn"] = "" // 卡识别码
  41. inputData["certno"] = certNo // 证件号码
  42. inputData["psn_cert_type"] = "01" // 人员证件类型
  43. }
  44. }
  45. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  46. inputData["begntime"] = "" // 开始时间
  47. inputData["psn_name"] = name // 人员姓名
  48. input["data"] = inputData
  49. inputMessage["input"] = input //交易输入
  50. bytesData, err := json.Marshal(inputMessage)
  51. fmt.Println(string(bytesData))
  52. requestLog = string(bytesData)
  53. if err != nil {
  54. fmt.Println(err.Error())
  55. return err.Error(), "", ""
  56. }
  57. reader := bytes.NewReader(bytesData)
  58. gdyb_url := beego.AppConfig.String("gdyb_url")
  59. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  60. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  61. url := gdyb_url + "1101"
  62. if mdtrtarea_admvs == "150499" {
  63. url = gdyb_url
  64. }
  65. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/1101"
  66. request, err := http.NewRequest("POST", url, reader)
  67. if err != nil {
  68. fmt.Println(err.Error())
  69. return err.Error(), "", ""
  70. }
  71. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  72. request.Header.Set("x-tif-paasid", gdyb_paasid)
  73. request.Header.Set("x-tif-signature", signature)
  74. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  75. request.Header.Set("x-tif-nonce", nonce)
  76. client := http.Client{}
  77. resp, err := client.Do(request)
  78. if err != nil {
  79. fmt.Println(err.Error())
  80. return err.Error(), "", ""
  81. }
  82. respBytes, err := ioutil.ReadAll(resp.Body)
  83. if err != nil {
  84. fmt.Println(err.Error())
  85. return err.Error(), "", ""
  86. }
  87. fmt.Println(string(respBytes))
  88. str := string(respBytes)
  89. resultLog = str
  90. return str, requestLog, resultLog
  91. }
  92. type DiseinfoStruct struct {
  93. PsnNo string
  94. DiagType string
  95. MaindiagFlag string
  96. DiagSrtNo string
  97. DiagCode string
  98. DiagName string
  99. DiagDept string
  100. DiseDorNo string
  101. DiseDorName string
  102. DiagTime string
  103. }
  104. type Struct2401 struct {
  105. PsnNo string
  106. Insutype string
  107. MdtrtCertType string
  108. MdtrtCertNo string
  109. MedType string
  110. IptNo string
  111. AtddrNo string
  112. ChfpdrName string
  113. AdmDiagDscr string
  114. AdmDeptCodg string
  115. AdmDeptName string
  116. AdmBed string
  117. DscgMaindiagCode string
  118. DscgMaindiagName string
  119. Diseinfo []DiseinfoStruct
  120. Begntime string
  121. DiseCodg string
  122. DiseName string
  123. }
  124. // 住院登记
  125. func ZHGdyb2401(struct2401 Struct2401, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  126. // 生成签名
  127. nonce := GetRandomString(32)
  128. timestamp := time.Now().Unix()
  129. signature := setSignature(timestamp, nonce, secret_key)
  130. //tempTime := time.Unix(timestamp, 0)
  131. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  132. // 生成输入报文
  133. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  134. input := make(map[string]interface{})
  135. inputData := make(map[string]interface{})
  136. inputMessage["infno"] = "2401" // 交易编码
  137. inputData["psn_no"] = struct2401.PsnNo // 人员编号 (来自1101接口返回)
  138. inputData["insutype"] = struct2401.Insutype // 险种类型(来自1101接口返回)
  139. inputData["tel"] = ""
  140. inputData["coner_name"] = ""
  141. inputData["begntime"] = struct2401.Begntime // 开始时间
  142. inputData["mdtrt_cert_type"] = struct2401.MdtrtCertType // 就诊凭证类型
  143. inputData["mdtrt_cert_no"] = struct2401.MdtrtCertNo // 就诊凭证编号
  144. inputData["med_type"] = struct2401.MedType // 就诊凭证编号
  145. inputData["ipt_no"] = struct2401.IptNo // 住院/门诊号
  146. inputData["medrcdno"] = ""
  147. inputData["atddr_no"] = struct2401.AtddrNo
  148. inputData["chfpdr_name"] = struct2401.ChfpdrName
  149. inputData["adm_diag_dscr"] = struct2401.AdmDiagDscr
  150. inputData["adm_dept_codg"] = struct2401.AdmDeptCodg
  151. inputData["adm_dept_name"] = struct2401.AdmDeptName
  152. inputData["adm_bed"] = struct2401.AdmBed
  153. inputData["dscg_maindiag_code"] = struct2401.DscgMaindiagCode
  154. inputData["dscg_maindiag_name"] = struct2401.DscgMaindiagName
  155. inputData["main_cond_dscr"] = ""
  156. inputData["dise_codg"] = struct2401.DiseCodg
  157. inputData["dise_name"] = struct2401.DiseName
  158. inputData["oprn_oprt_code"] = ""
  159. inputData["oprn_oprt_name"] = ""
  160. inputData["fpsc_no"] = ""
  161. inputData["matn_type"] = ""
  162. inputData["birctrl_type"] = ""
  163. inputData["latechb_flag"] = ""
  164. inputData["geso_val"] = ""
  165. inputData["fetts"] = ""
  166. inputData["fetus_cnt"] = ""
  167. inputData["pret_flag"] = ""
  168. inputData["birctrl_matn_date"] = ""
  169. inputData["dise_type_code"] = ""
  170. inputDataArr := make([]map[string]interface{}, 0)
  171. for _, item := range struct2401.Diseinfo {
  172. inputDataTwo := make(map[string]interface{})
  173. inputDataTwo["psn_no"] = item.PsnNo
  174. inputDataTwo["diag_type"] = item.DiagType
  175. inputDataTwo["maindiag_flag"] = item.MaindiagFlag
  176. inputDataTwo["diag_srt_no"] = item.DiagSrtNo
  177. inputDataTwo["diag_code"] = item.DiagCode
  178. inputDataTwo["diag_name"] = item.DiagName
  179. inputDataTwo["adm_cond"] = ""
  180. inputDataTwo["diag_dept"] = item.DiagDept
  181. inputDataTwo["dise_dor_no"] = item.DiseDorNo
  182. inputDataTwo["dise_dor_name"] = item.DiseDorName
  183. inputDataTwo["diag_time"] = item.DiagTime
  184. inputDataArr = append(inputDataArr, inputDataTwo)
  185. }
  186. input["mdtrtinfo"] = inputData
  187. input["diseinfo"] = inputDataArr
  188. inputMessage["input"] = input //交易输入
  189. bytesData, err := json.Marshal(inputMessage)
  190. fmt.Println(string(bytesData))
  191. requestLog := string(bytesData)
  192. if err != nil {
  193. fmt.Println(err.Error())
  194. return err.Error(), ""
  195. }
  196. reader := bytes.NewReader(bytesData)
  197. gdyb_url := beego.AppConfig.String("gdyb_url")
  198. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  199. url := gdyb_url + "2401"
  200. if mdtrtarea_admvs == "150499" {
  201. url = gdyb_url
  202. }
  203. request, err := http.NewRequest("POST", url, reader)
  204. if err != nil {
  205. fmt.Println(err.Error())
  206. return err.Error(), ""
  207. }
  208. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  209. request.Header.Set("x-tif-paasid", gdyb_paasid)
  210. request.Header.Set("x-tif-signature", signature)
  211. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  212. request.Header.Set("x-tif-nonce", nonce)
  213. client := http.Client{}
  214. resp, err := client.Do(request)
  215. if err != nil {
  216. fmt.Println(err.Error())
  217. return err.Error(), ""
  218. }
  219. respBytes, err := ioutil.ReadAll(resp.Body)
  220. if err != nil {
  221. fmt.Println(err.Error())
  222. return err.Error(), ""
  223. }
  224. str := string(respBytes)
  225. fmt.Println(str)
  226. return str, requestLog
  227. }
  228. //住院撤销
  229. func ZHGdyb2404(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  230. // 生成签名
  231. nonce := GetRandomString(32)
  232. timestamp := time.Now().Unix()
  233. signature := setSignature(timestamp, nonce, secret_key)
  234. // 生成输入报文
  235. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  236. input := make(map[string]interface{})
  237. inputData := make(map[string]interface{})
  238. inputMessage["infno"] = "2404" // 交易编码
  239. inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
  240. inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
  241. input["data"] = inputData
  242. inputMessage["input"] = input //交易输入
  243. bytesData, err := json.Marshal(inputMessage)
  244. fmt.Println(string(bytesData))
  245. requestLog := string(bytesData)
  246. if err != nil {
  247. fmt.Println(err.Error())
  248. return err.Error(), ""
  249. }
  250. reader := bytes.NewReader(bytesData)
  251. gdyb_url := beego.AppConfig.String("gdyb_url")
  252. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  253. url := gdyb_url + "2404"
  254. if mdtrtarea_admvs == "150499" {
  255. url = gdyb_url
  256. }
  257. request, err := http.NewRequest("POST", url, reader)
  258. if err != nil {
  259. fmt.Println(err.Error())
  260. return err.Error(), ""
  261. }
  262. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  263. request.Header.Set("x-tif-paasid", gdyb_paasid)
  264. request.Header.Set("x-tif-signature", signature)
  265. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  266. request.Header.Set("x-tif-nonce", nonce)
  267. client := http.Client{}
  268. resp, err := client.Do(request)
  269. if err != nil {
  270. fmt.Println(err.Error())
  271. return err.Error(), ""
  272. }
  273. respBytes, err := ioutil.ReadAll(resp.Body)
  274. if err != nil {
  275. fmt.Println(err.Error())
  276. return err.Error(), ""
  277. }
  278. str := string(respBytes)
  279. fmt.Println(str)
  280. return str, requestLog
  281. }
  282. //出院撤销
  283. func ZHGdyb2405(mdtrt_id string, psn_no string, secret_key string, org_name string, fixmedins_code string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  284. // 生成签名
  285. nonce := GetRandomString(32)
  286. timestamp := time.Now().Unix()
  287. signature := setSignature(timestamp, nonce, secret_key)
  288. // 生成输入报文
  289. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  290. input := make(map[string]interface{})
  291. inputData := make(map[string]interface{})
  292. inputMessage["infno"] = "2405" // 交易编码
  293. inputData["mdtrt_id"] = mdtrt_id // 人员编号 (来自1101接口返回)
  294. inputData["psn_no"] = psn_no // 人员编号 (来自1101接口返回)
  295. input["data"] = inputData
  296. inputMessage["input"] = input //交易输入
  297. bytesData, err := json.Marshal(inputMessage)
  298. fmt.Println(string(bytesData))
  299. requestLog := 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. url := gdyb_url + "2405"
  308. if mdtrtarea_admvs == "150499" {
  309. url = gdyb_url
  310. }
  311. request, err := http.NewRequest("POST", url, reader)
  312. if err != nil {
  313. fmt.Println(err.Error())
  314. return err.Error(), ""
  315. }
  316. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  317. request.Header.Set("x-tif-paasid", gdyb_paasid)
  318. request.Header.Set("x-tif-signature", signature)
  319. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  320. request.Header.Set("x-tif-nonce", nonce)
  321. client := http.Client{}
  322. resp, err := client.Do(request)
  323. if err != nil {
  324. fmt.Println(err.Error())
  325. return err.Error(), ""
  326. }
  327. respBytes, err := ioutil.ReadAll(resp.Body)
  328. if err != nil {
  329. fmt.Println(err.Error())
  330. return err.Error(), ""
  331. }
  332. str := string(respBytes)
  333. fmt.Println(str)
  334. return str, requestLog
  335. }
  336. type Diseinfo2402Struct struct {
  337. MdtrtId string
  338. PsnNo string
  339. DiagType string
  340. MaindiagFlag string
  341. DiagSrtNo string
  342. DiagCode string
  343. DiagName string
  344. DiagDept string
  345. DiseDorNo string
  346. DiseDorName string
  347. DiagTime string
  348. }
  349. type Struct2402 struct {
  350. MdtrtId string
  351. PsnNo string
  352. Insutype string
  353. Endtime string
  354. DscgDeptCodg string
  355. DscgDeptName string
  356. DscgWay string
  357. Diseinfo []Diseinfo2402Struct
  358. DiseName string
  359. DiseCode string
  360. }
  361. // 出院
  362. func ZHGdyb2402(struct2402 Struct2402, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string) (string, string) {
  363. // 生成签名
  364. nonce := GetRandomString(32)
  365. timestamp := time.Now().Unix()
  366. signature := setSignature(timestamp, nonce, secret_key)
  367. //tempTime := time.Unix(timestamp, 0)
  368. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  369. // 生成输入报文
  370. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  371. input := make(map[string]interface{})
  372. inputData := make(map[string]interface{})
  373. inputMessage["infno"] = "2402" // 交易编码
  374. inputData["mdtrt_id"] = struct2402.MdtrtId // 人员编号 (来自1101接口返回)
  375. inputData["psn_no"] = struct2402.PsnNo // 人员编号 (来自1101接口返回)
  376. inputData["insutype"] = struct2402.Insutype // 险种类型(来自1101接口返回)
  377. inputData["endtime"] = struct2402.Endtime // 结束时间
  378. inputData["dise_codg"] = struct2402.DiseCode // 就诊凭证类型
  379. inputData["dise_name"] = struct2402.DiseName // 就诊凭证类型
  380. inputData["oprn_oprt_code"] = "" // 就诊凭证类型
  381. inputData["oprn_oprt_name"] = "" // 就诊凭证类型
  382. inputData["fpsc_no"] = "" // 就诊凭证类型
  383. inputData["matn_type"] = "" // 就诊凭证类型
  384. inputData["birctrl_type"] = "" // 就诊凭证类型
  385. inputData["latechb_flag"] = "" // 就诊凭证类型
  386. inputData["geso_val"] = ""
  387. inputData["fetts"] = ""
  388. inputData["fetus_cnt"] = ""
  389. inputData["pret_flag"] = ""
  390. inputData["birctrl_matn_date"] = ""
  391. inputData["cop_flag"] = ""
  392. inputData["dscg_dept_codg"] = struct2402.DscgDeptCodg
  393. inputData["dscg_dept_name"] = struct2402.DscgDeptName
  394. inputData["dscg_bed"] = "待定"
  395. inputData["dscg_way"] = struct2402.DscgWay
  396. inputData["die_date"] = ""
  397. inputDataArr := make([]map[string]interface{}, 0)
  398. for _, item := range struct2402.Diseinfo {
  399. inputDataTwo := make(map[string]interface{})
  400. inputDataTwo["psn_no"] = item.PsnNo
  401. inputDataTwo["mdtrt_id"] = item.MdtrtId
  402. inputDataTwo["diag_type"] = item.DiagType
  403. inputDataTwo["maindiag_flag"] = item.MaindiagFlag
  404. inputDataTwo["diag_srt_no"] = item.DiagSrtNo
  405. inputDataTwo["diag_code"] = item.DiagCode
  406. inputDataTwo["diag_name"] = item.DiagName
  407. inputDataTwo["diag_dept"] = item.DiagDept
  408. inputDataTwo["dise_dor_no"] = item.DiseDorNo
  409. inputDataTwo["dise_dor_name"] = item.DiseDorName
  410. inputDataTwo["diag_time"] = item.DiagTime
  411. inputDataArr = append(inputDataArr, inputDataTwo)
  412. }
  413. input["dscginfo"] = inputData
  414. input["diseinfo"] = inputDataArr
  415. inputMessage["input"] = input //交易输入
  416. bytesData, err := json.Marshal(inputMessage)
  417. fmt.Println(string(bytesData))
  418. request_log := string(bytesData)
  419. if err != nil {
  420. fmt.Println(err.Error())
  421. return err.Error(), ""
  422. }
  423. reader := bytes.NewReader(bytesData)
  424. gdyb_url := beego.AppConfig.String("gdyb_url")
  425. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  426. url := gdyb_url + "2402"
  427. if mdtrtarea_admvs == "150499" {
  428. url = gdyb_url
  429. }
  430. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2202"
  431. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  432. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2202"
  433. request, err := http.NewRequest("POST", url, reader)
  434. if err != nil {
  435. fmt.Println(err.Error())
  436. return err.Error(), ""
  437. }
  438. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  439. //request.Header.Set("x-tif-paasid", "test_hosp")
  440. request.Header.Set("x-tif-paasid", gdyb_paasid)
  441. request.Header.Set("x-tif-signature", signature)
  442. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  443. request.Header.Set("x-tif-nonce", nonce)
  444. client := http.Client{}
  445. resp, err := client.Do(request)
  446. if err != nil {
  447. fmt.Println(err.Error())
  448. return err.Error(), ""
  449. }
  450. respBytes, err := ioutil.ReadAll(resp.Body)
  451. if err != nil {
  452. fmt.Println(err.Error())
  453. return err.Error(), ""
  454. }
  455. str := string(respBytes)
  456. fmt.Println(str)
  457. return str, request_log
  458. }
  459. type ZHCustom struct {
  460. DetItemFeeSumamt string
  461. Cut string
  462. FeedetlSn string
  463. Price string
  464. MedListCodg string
  465. LmtUsedFlag int64
  466. HospApprFlag int64
  467. }
  468. type ZHRequestResult struct {
  469. Output ZHOutput `json:"output" form:"output"`
  470. Infcode int64 `gorm:"column:infcode" json:"infcode" form:"infcode"`
  471. WarnMsg string `gorm:"column:warn_msg" json:"warn_msg" form:"warn_msg"`
  472. Cainfo string `gorm:"column:cainfo" json:"cainfo" form:"cainfo"`
  473. ErrMsg string `gorm:"column:err_msg" json:"err_msg" form:"err_msg"`
  474. RespondTime string `gorm:"column:respond_time" json:"respond_time" form:"respond_time"`
  475. InfRefmsgid string `gorm:"column:inf_refmsgid" json:"inf_refmsgid" form:"inf_refmsgid"`
  476. }
  477. type ZHOutput struct {
  478. Result Result `json:"result" form:"result"`
  479. }
  480. type ZHResult struct {
  481. BasMednFlag string `json:"bas_medn_flag" form:"bas_medn_flag"`
  482. MedChrgitmType string `json:"med_chrgitm_type" form:"med_chrgitm_type"`
  483. DetItemFeeSumamt int64 `json:"det_item_fee_sumamt" form:"det_item_fee_sumamt"`
  484. HiNegoDrugFlag string `json:"hi_nego_drug_flag" form:"hi_nego_drug_flag"`
  485. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt" form:"fulamt_ownpay_amt"`
  486. FeedtlSn int64 `json:"feedtl_sn" form:"feedtl_sn"`
  487. UploadDate int64 `json:"upload_date" form:"upload_date"`
  488. AdviceId int64 `json:"advice_id" form:"advice_id"`
  489. Cnt int64 `json:"cnt" form:"cnt"`
  490. Pric float64 `json:"pric" form:"pric"`
  491. PatientId int64 `json:"patient_id" form:"patient_id"`
  492. PricUplmtAmt float64 `json:"pric_uplmt_amt" form:"pric_uplmt_amt"`
  493. SelfpayProp float64 `json:"selfpay_prop" form:"selfpay_prop"`
  494. OverlmtAmt float64 `json:"overlmt_amt" form:"overlmt_amt"`
  495. PreselfpayAmt float64 `json:"preselfpay_amt" form:"preselfpay_amt"`
  496. Status int64 `json:"status" form:"status"`
  497. Memo string `json:"memo" form:"memo"`
  498. FeedetlSn string `json:"feedetl_sn" form:"feedetl_sn"`
  499. Mtime int64 `json:"mtime" form:"mtime"`
  500. InscpScpAmt float64 `json:"inscp_scp_amt" form:"inscp_scp_amt"`
  501. DrtReimFlag string `json:"drt_reim_flag" form:"drt_reim_flag"`
  502. Ctime int64 `json:"ctime" form:"ctime"`
  503. ListSpItemFlag string `json:"list_sp_item_flag" form:"list_sp_item_flag"`
  504. ChldMedcFlag string `json:"chld_medc_flag" form:"chld_medc_flag"`
  505. LmtUsedFlag string `json:"lmt_used_flag" form:"lmt_used_flag"`
  506. ChrgitmLv string `json:"chrgitm_lv" form:"chrgitm_lv"`
  507. UserOrgId int64 `json:"user_org_id" form:"user_org_id"`
  508. HisPatientId int64 `json:"his_patient_id" form:"his_patient_id"`
  509. OrderId int64 `json:"order_id" form:"order_id"`
  510. }
  511. // 住院费用明细信息上传
  512. func ZHGdyb2301(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, doctor_name string, doctor_number string) (string, string) {
  513. // 生成签名
  514. nonce := GetRandomString(32)
  515. timestamp := time.Now().Unix()
  516. signature := setSignature(timestamp, nonce, secret_key)
  517. //tempTime := time.Unix(timestamp, 0)
  518. //timeFormat := tempTime.Format("20060102150405")
  519. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  520. //chrgBchno := rand.Intn(100000) + 10000
  521. var customs []*models.NewCustom
  522. customs = hisPrescription
  523. // 生成输入报文
  524. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  525. input := make(map[string]interface{})
  526. feedetail := make([]map[string]interface{}, 0)
  527. inputMessage["infno"] = "2301" // 交易编码
  528. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  529. for _, item := range customs {
  530. org_id, _ := beego.AppConfig.Int64("org_id")
  531. doctor_info, _ := GetAdminUserInfoByID(org_id, item.DoctorId)
  532. feedetailInfo := make(map[string]interface{})
  533. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  534. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  535. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  536. feedetailInfo["med_type"] = med_type
  537. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  538. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  539. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  540. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  541. feedetailInfo["cnt"] = item.Cut // 数量
  542. feedetailInfo["pric"] = item.Price // 单价
  543. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  544. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  545. feedetailInfo["bilg_dr_codg"] = doctor_info.DoctorNumber // 开单医生编码
  546. feedetailInfo["bilg_dr_name"] = doctor_info.UserName
  547. feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
  548. feedetailInfo["acord_dept_name"] = dept // 受单科室名称
  549. feedetailInfo["orders_dr_code"] = doctor_info.DoctorNumber // 受单医生编码
  550. feedetailInfo["orders_dr_name"] = doctor_info.UserName // 受单医生姓名
  551. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  552. feedetailInfo["dise_codg"] = "" // 病种编码
  553. feedetailInfo["rxno"] = "" // 处方号
  554. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  555. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  556. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  557. feedetailInfo["prd_days"] = "0" // 周期天数
  558. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  559. // 开单医师姓名
  560. if item.HospApprFlag != -1 {
  561. if item.HospApprFlag == 1 {
  562. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  563. } else if item.HospApprFlag == 2 {
  564. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  565. } else if item.HospApprFlag == 3 {
  566. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  567. } else {
  568. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  569. }
  570. } else {
  571. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  572. }
  573. //feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  574. feedetailInfo["etip_flag"] = "" // 外检标志
  575. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  576. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  577. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  578. feedetail = append(feedetail, feedetailInfo)
  579. }
  580. input["feedetail"] = feedetail
  581. inputMessage["input"] = input //交易输入
  582. bytesData, err := json.Marshal(inputMessage)
  583. fmt.Println("----------")
  584. fmt.Println(string(bytesData))
  585. fmt.Println("----------")
  586. requestLog := string(bytesData)
  587. if err != nil {
  588. fmt.Println(err.Error())
  589. return "", ""
  590. }
  591. reader := bytes.NewReader(bytesData)
  592. gdyb_url := beego.AppConfig.String("gdyb_url")
  593. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  594. url := gdyb_url + "2301"
  595. if mdtrtarea_admvs == "150499" {
  596. url = gdyb_url
  597. }
  598. request, err := http.NewRequest("POST", url, reader)
  599. if err != nil {
  600. fmt.Println(err.Error())
  601. return "", ""
  602. }
  603. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  604. request.Header.Set("x-tif-paasid", gdyb_paasid)
  605. request.Header.Set("x-tif-signature", signature)
  606. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  607. request.Header.Set("x-tif-nonce", nonce)
  608. client := http.Client{}
  609. resp, err := client.Do(request)
  610. if err != nil {
  611. fmt.Println(err.Error())
  612. return "", ""
  613. }
  614. respBytes, err := ioutil.ReadAll(resp.Body)
  615. if err != nil {
  616. fmt.Println(err.Error())
  617. return "", ""
  618. }
  619. return string(respBytes), requestLog
  620. }
  621. func ZHGdyb2301A(psnNo string, mdtrtId string, hisPrescription []*models.NewCustom, chrg_bchno string, org_name string, doctor string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, med_type string, opertor string) (string, string) {
  622. // 生成签名
  623. nonce := GetRandomString(32)
  624. timestamp := time.Now().Unix()
  625. signature := setSignature(timestamp, nonce, secret_key)
  626. //tempTime := time.Unix(timestamp, 0)
  627. //timeFormat := tempTime.Format("20060102150405")
  628. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  629. //chrgBchno := rand.Intn(100000) + 10000
  630. var customs []*models.NewCustom
  631. customs = hisPrescription
  632. // 生成输入报文
  633. inputMessage := SetInputMessage(nonce, timestamp, org_name, opertor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  634. input := make(map[string]interface{})
  635. feedetail := make([]map[string]interface{}, 0)
  636. inputMessage["infno"] = "2301" // 交易编码
  637. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  638. for _, item := range customs {
  639. feedetailInfo := make(map[string]interface{})
  640. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  641. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  642. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  643. feedetailInfo["med_type"] = ""
  644. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  645. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  646. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  647. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  648. feedetailInfo["cnt"] = item.Cut // 数量
  649. feedetailInfo["pric"] = item.Price // 单价
  650. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  651. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  652. feedetailInfo["bilg_dr_codg"] = doctor_id // 开单医生编码
  653. feedetailInfo["bilg_dr_name"] = doctor
  654. feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
  655. feedetailInfo["acord_dept_name"] = dept // 受单科室名称
  656. feedetailInfo["orders_dr_code"] = doctor_id // 受单医生编码
  657. feedetailInfo["orders_dr_name"] = doctor // 受单医生姓名
  658. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  659. feedetailInfo["dise_codg"] = "" // 病种编码
  660. feedetailInfo["rxno"] = "" // 处方号
  661. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  662. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  663. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  664. feedetailInfo["prd_days"] = "0" // 周期天数
  665. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  666. // 开单医师姓名
  667. if item.HospApprFlag != -1 {
  668. if item.HospApprFlag == 1 {
  669. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  670. } else if item.HospApprFlag == 2 {
  671. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  672. } else if item.HospApprFlag == 3 {
  673. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  674. } else {
  675. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  676. }
  677. } else {
  678. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  679. }
  680. feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  681. feedetailInfo["etip_flag"] = "" // 外检标志
  682. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  683. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  684. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  685. feedetail = append(feedetail, feedetailInfo)
  686. }
  687. input["feedetail"] = feedetail
  688. inputMessage["input"] = input //交易输入
  689. bytesData, err := json.Marshal(inputMessage)
  690. fmt.Println("----------")
  691. fmt.Println(string(bytesData))
  692. fmt.Println("----------")
  693. requestLog := string(bytesData)
  694. if err != nil {
  695. fmt.Println(err.Error())
  696. return "", ""
  697. }
  698. reader := bytes.NewReader(bytesData)
  699. gdyb_url := beego.AppConfig.String("gdyb_url")
  700. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  701. url := gdyb_url + "2301"
  702. if mdtrtarea_admvs == "150499" {
  703. url = gdyb_url
  704. }
  705. request, err := http.NewRequest("POST", url, reader)
  706. if err != nil {
  707. fmt.Println(err.Error())
  708. return "", ""
  709. }
  710. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  711. request.Header.Set("x-tif-paasid", gdyb_paasid)
  712. request.Header.Set("x-tif-signature", signature)
  713. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  714. request.Header.Set("x-tif-nonce", nonce)
  715. client := http.Client{}
  716. resp, err := client.Do(request)
  717. if err != nil {
  718. fmt.Println(err.Error())
  719. return "", ""
  720. }
  721. respBytes, err := ioutil.ReadAll(resp.Body)
  722. if err != nil {
  723. fmt.Println(err.Error())
  724. return "", ""
  725. }
  726. return string(respBytes), requestLog
  727. }
  728. // 住院费用明细信息撤销
  729. func Gdyb2302(psnNo string, mdtrtId string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, number string, refund_type int64) (string, string) {
  730. // 生成签名
  731. nonce := GetRandomString(32)
  732. timestamp := time.Now().Unix()
  733. signature := setSignature(timestamp, nonce, secret_key)
  734. // 生成输入报文
  735. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  736. input := make(map[string]interface{})
  737. inputData := make(map[string]interface{})
  738. inputMessage["infno"] = "2302" // 交易编码
  739. if refund_type == 1 {
  740. inputData["feedetl_sn"] = number //
  741. } else {
  742. inputData["feedetl_sn"] = "0000" //
  743. }
  744. inputData["mdtrt_id"] = mdtrtId // 就诊 ID
  745. inputData["psn_no"] = psnNo // 人员编号
  746. input["data"] = inputData
  747. inputMessage["input"] = input //交易输入
  748. bytesData, err := json.Marshal(inputMessage)
  749. fmt.Println(string(bytesData))
  750. requestLog := string(bytesData)
  751. if err != nil {
  752. fmt.Println(err.Error())
  753. return err.Error(), ""
  754. }
  755. reader := bytes.NewReader(bytesData)
  756. gdyb_url := beego.AppConfig.String("gdyb_url")
  757. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  758. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  759. url := gdyb_url + "2302"
  760. if mdtrtarea_admvs == "150499" {
  761. url = gdyb_url
  762. }
  763. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2205"
  764. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  765. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2205"
  766. request, err := http.NewRequest("POST", url, reader)
  767. fmt.Println(err)
  768. fmt.Println(request)
  769. if err != nil {
  770. fmt.Println(err.Error())
  771. return err.Error(), ""
  772. }
  773. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  774. request.Header.Set("x-tif-paasid", gdyb_paasid)
  775. request.Header.Set("x-tif-signature", signature)
  776. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  777. request.Header.Set("x-tif-nonce", nonce)
  778. client := http.Client{}
  779. resp, err := client.Do(request)
  780. if err != nil {
  781. fmt.Println(err.Error())
  782. return err.Error(), ""
  783. }
  784. respBytes, err := ioutil.ReadAll(resp.Body)
  785. if err != nil {
  786. fmt.Println(err.Error())
  787. return err.Error(), ""
  788. }
  789. str := string(respBytes)
  790. fmt.Println(str)
  791. return str, requestLog
  792. }
  793. func ZHGdyb2303(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64) (string, string) {
  794. // 生成签名
  795. nonce := GetRandomString(32)
  796. timestamp := time.Now().Unix()
  797. signature := setSignature(timestamp, nonce, secret_key)
  798. // 生成输入报文
  799. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  800. input := make(map[string]interface{})
  801. inputData := make(map[string]interface{})
  802. inputMessage["infno"] = "2303" // 交易编码
  803. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  804. if certificates == 3 {
  805. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  806. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  807. } else {
  808. if id_card_type == 1 {
  809. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  810. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  811. } else {
  812. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  813. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  814. }
  815. }
  816. inputData["mdtrt_cert_sn"] = ""
  817. inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
  818. inputData["medfee_sumamt"] = total // 医疗费总额
  819. inputData["psn_setlway"] = "02" // 个人结算方式 01 按项目结 02 按定额结算
  820. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  821. inputData["acct_used_flag"] = "1" // 个人账户使用标志 0否 1是
  822. inputData["insutype"] = insutype // 险种类型
  823. inputData["invono"] = "" // 发票号
  824. inputData["dise_codg"] = "M07803" // 发票号
  825. input["data"] = inputData
  826. inputMessage["input"] = input //交易输入
  827. bytesData, err := json.Marshal(inputMessage)
  828. fmt.Println(string(bytesData))
  829. if err != nil {
  830. fmt.Println(err.Error())
  831. return err.Error(), ""
  832. }
  833. reader := bytes.NewReader(bytesData)
  834. gdyb_url := beego.AppConfig.String("gdyb_url")
  835. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  836. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  837. url := gdyb_url + "2303"
  838. if mdtrtarea_admvs == "150499" {
  839. url = gdyb_url
  840. }
  841. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  842. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  843. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  844. request, err := http.NewRequest("POST", url, reader)
  845. if err != nil {
  846. fmt.Println(err.Error())
  847. return err.Error(), ""
  848. }
  849. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  850. request.Header.Set("x-tif-paasid", gdyb_paasid)
  851. request.Header.Set("x-tif-signature", signature)
  852. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  853. request.Header.Set("x-tif-nonce", nonce)
  854. client := http.Client{}
  855. resp, err := client.Do(request)
  856. if err != nil {
  857. fmt.Println(err.Error())
  858. return err.Error(), ""
  859. }
  860. respBytes, err := ioutil.ReadAll(resp.Body)
  861. if err != nil {
  862. fmt.Println(err.Error())
  863. return err.Error(), ""
  864. }
  865. str := string(respBytes)
  866. fmt.Println(str)
  867. mjson, _ := json.Marshal(inputMessage)
  868. str2 := string(mjson)
  869. return str, str2
  870. }
  871. // 住院结算
  872. func ZHGdyb2304(psnNo string, mdtrtId string, chrgBchno string, certNo string, insutype string, total string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, mid_setl_flag string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, fapiao_number string, acct_used_flag string) (string, string) {
  873. // 生成签名
  874. nonce := GetRandomString(32)
  875. timestamp := time.Now().Unix()
  876. signature := setSignature(timestamp, nonce, secret_key)
  877. // 生成输入报文
  878. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  879. input := make(map[string]interface{})
  880. inputData := make(map[string]interface{})
  881. inputMessage["infno"] = "2304" // 交易编码
  882. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  883. if certificates == 3 {
  884. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  885. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  886. } else {
  887. if id_card_type == 1 {
  888. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  889. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  890. } else {
  891. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  892. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  893. }
  894. }
  895. inputData["mdtrt_cert_sn"] = ""
  896. inputData["mid_setl_flag"] = mid_setl_flag // 中途退费标志
  897. inputData["medfee_sumamt"] = total // 医疗费总额
  898. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  899. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  900. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  901. inputData["insutype"] = insutype // 险种类型
  902. inputData["invono"] = fapiao_number // 发票号
  903. input["data"] = inputData
  904. inputMessage["input"] = input //交易输入
  905. bytesData, err := json.Marshal(inputMessage)
  906. fmt.Println(string(bytesData))
  907. if err != nil {
  908. fmt.Println(err.Error())
  909. return err.Error(), ""
  910. }
  911. reader := bytes.NewReader(bytesData)
  912. gdyb_url := beego.AppConfig.String("gdyb_url")
  913. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  914. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  915. url := gdyb_url + "2304"
  916. if mdtrtarea_admvs == "150499" {
  917. url = gdyb_url
  918. }
  919. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2207"
  920. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  921. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2207"
  922. request, err := http.NewRequest("POST", url, reader)
  923. if err != nil {
  924. fmt.Println(err.Error())
  925. return err.Error(), ""
  926. }
  927. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  928. request.Header.Set("x-tif-paasid", gdyb_paasid)
  929. request.Header.Set("x-tif-signature", signature)
  930. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  931. request.Header.Set("x-tif-nonce", nonce)
  932. client := http.Client{}
  933. resp, err := client.Do(request)
  934. if err != nil {
  935. fmt.Println(err.Error())
  936. return err.Error(), ""
  937. }
  938. respBytes, err := ioutil.ReadAll(resp.Body)
  939. if err != nil {
  940. fmt.Println(err.Error())
  941. return err.Error(), ""
  942. }
  943. str := string(respBytes)
  944. fmt.Println(str)
  945. mjson, _ := json.Marshal(inputMessage)
  946. str2 := string(mjson)
  947. return str, str2
  948. }
  949. func Gdyb26011(psnNo string, omsgid string, oinfno string, org_name string, doctor string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string) string {
  950. // 生成签名
  951. nonce := GetRandomString(32)
  952. timestamp := time.Now().Unix()
  953. signature := setSignature(timestamp, nonce, secret_key)
  954. // 生成输入报文
  955. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  956. input := make(map[string]interface{})
  957. inputData := make(map[string]interface{})
  958. inputMessage["infno"] = "2601" // 交易编码
  959. inputData["psn_no"] = psnNo
  960. inputData["omsgid"] = omsgid
  961. inputData["oinfno"] = oinfno
  962. input["data"] = inputData
  963. inputMessage["input"] = input //交易输入
  964. bytesData, err := json.Marshal(inputMessage)
  965. fmt.Println(string(bytesData))
  966. if err != nil {
  967. fmt.Println(err.Error())
  968. return err.Error()
  969. }
  970. reader := bytes.NewReader(bytesData)
  971. gdyb_url := beego.AppConfig.String("gdyb_url")
  972. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  973. url := gdyb_url + "2601"
  974. if mdtrtarea_admvs == "150499" {
  975. url = gdyb_url
  976. }
  977. request, err := http.NewRequest("POST", url, reader)
  978. if err != nil {
  979. fmt.Println(err.Error())
  980. return err.Error()
  981. }
  982. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  983. request.Header.Set("x-tif-paasid", gdyb_paasid)
  984. request.Header.Set("x-tif-signature", signature)
  985. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  986. request.Header.Set("x-tif-nonce", nonce)
  987. client := http.Client{}
  988. resp, err := client.Do(request)
  989. if err != nil {
  990. fmt.Println(err.Error())
  991. return err.Error()
  992. }
  993. respBytes, err := ioutil.ReadAll(resp.Body)
  994. if err != nil {
  995. fmt.Println(err.Error())
  996. return err.Error()
  997. }
  998. str := string(respBytes)
  999. fmt.Println(str)
  1000. return str
  1001. }
  1002. // 住院结算撤销
  1003. func Gdyb2305(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  1004. // 生成签名
  1005. nonce := GetRandomString(32)
  1006. timestamp := time.Now().Unix()
  1007. signature := setSignature(timestamp, nonce, secret_key)
  1008. // 生成输入报文
  1009. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1010. input := make(map[string]interface{})
  1011. inputData := make(map[string]interface{})
  1012. inputMessage["infno"] = "2305" // 交易编码
  1013. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1014. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  1015. inputData["setl_id"] = setlId // 结算 ID
  1016. input["data"] = inputData
  1017. inputMessage["input"] = input //交易输入
  1018. bytesData, err := json.Marshal(inputMessage)
  1019. fmt.Println(string(bytesData))
  1020. if err != nil {
  1021. fmt.Println(err.Error())
  1022. return err.Error(), ""
  1023. }
  1024. reader := bytes.NewReader(bytesData)
  1025. gdyb_url := beego.AppConfig.String("gdyb_url")
  1026. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1027. url := gdyb_url + "2305"
  1028. if mdtrtarea_admvs == "150499" {
  1029. url = gdyb_url
  1030. }
  1031. request, err := http.NewRequest("POST", url, reader)
  1032. if err != nil {
  1033. fmt.Println(err.Error())
  1034. return err.Error(), ""
  1035. }
  1036. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1037. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1038. request.Header.Set("x-tif-signature", signature)
  1039. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1040. request.Header.Set("x-tif-nonce", nonce)
  1041. client := http.Client{}
  1042. resp, err := client.Do(request)
  1043. if err != nil {
  1044. fmt.Println(err.Error())
  1045. return err.Error(), ""
  1046. }
  1047. respBytes, err := ioutil.ReadAll(resp.Body)
  1048. if err != nil {
  1049. fmt.Println(err.Error())
  1050. return err.Error(), ""
  1051. }
  1052. str := string(respBytes)
  1053. fmt.Println(str)
  1054. mjson, _ := json.Marshal(inputMessage)
  1055. str2 := string(mjson)
  1056. return str, str2
  1057. }
  1058. func Gdyb90306(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string) (string, string) {
  1059. // 生成签名
  1060. nonce := GetRandomString(32)
  1061. timestamp := time.Now().Unix()
  1062. signature := setSignature(timestamp, nonce, secret_key)
  1063. // 生成输入报文
  1064. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  1065. input := make(map[string]interface{})
  1066. inputData := make(map[string]interface{})
  1067. inputMessage["infno"] = "90306" // 交易编码
  1068. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  1069. inputData["setl_id"] = setlId // 结算 ID
  1070. input["data"] = inputData
  1071. inputMessage["input"] = input //交易输入
  1072. bytesData, err := json.Marshal(inputMessage)
  1073. fmt.Println(string(bytesData))
  1074. if err != nil {
  1075. fmt.Println(err.Error())
  1076. return err.Error(), ""
  1077. }
  1078. reader := bytes.NewReader(bytesData)
  1079. gdyb_url := beego.AppConfig.String("gdyb_url")
  1080. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1081. url := gdyb_url + "90306"
  1082. if mdtrtarea_admvs == "150499" {
  1083. url = gdyb_url
  1084. }
  1085. request, err := http.NewRequest("POST", url, reader)
  1086. if err != nil {
  1087. fmt.Println(err.Error())
  1088. return err.Error(), ""
  1089. }
  1090. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1091. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1092. request.Header.Set("x-tif-signature", signature)
  1093. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1094. request.Header.Set("x-tif-nonce", nonce)
  1095. client := http.Client{}
  1096. resp, err := client.Do(request)
  1097. if err != nil {
  1098. fmt.Println(err.Error())
  1099. return err.Error(), ""
  1100. }
  1101. respBytes, err := ioutil.ReadAll(resp.Body)
  1102. if err != nil {
  1103. fmt.Println(err.Error())
  1104. return err.Error(), ""
  1105. }
  1106. str := string(respBytes)
  1107. fmt.Println(str)
  1108. mjson, _ := json.Marshal(inputMessage)
  1109. str2 := string(mjson)
  1110. return str, str2
  1111. }
  1112. func CreateHospitalRecord(record *models.HisHospitalCheckRecord) (err error) {
  1113. err = writeDb.Save(&record).Error
  1114. return
  1115. }
  1116. func GetInHospitalRecord(id int64) (record models.HisHospitalCheckRecord, err error) {
  1117. err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1", id).First(&record).Error
  1118. return
  1119. }
  1120. func GetInHospitalRecordByNumber(number string) (record models.HisHospitalCheckRecord, err error) {
  1121. err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("number = ? AND status = 1", number).First(&record).Error
  1122. return
  1123. }
  1124. func GetLastHospitalRecord(id int64, user_org_id int64) (record models.HisHospitalCheckRecord, err error) {
  1125. err = readDb.Model(&models.HisHospitalCheckRecord{}).Where("id = ? AND status = 1 AND user_org_id = ?", id, user_org_id).Last(&record).Error
  1126. return
  1127. }
  1128. func GetZHHisPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
  1129. err = readDb.Model(&models.HisPrescription{}).
  1130. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1131. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1132. }).
  1133. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1134. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1135. }).
  1136. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1137. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
  1138. }).
  1139. Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND p_type = 1", org_id, record_date, patient_id).
  1140. Find(&prescription).Error
  1141. return
  1142. }
  1143. func GetZHMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
  1144. err = readDb.Model(&models.HisPrescription{}).
  1145. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1146. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1147. }).
  1148. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1149. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1150. }).
  1151. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1152. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
  1153. }).
  1154. Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
  1155. Find(&prescription).Error
  1156. return
  1157. }
  1158. func GetZHHisUploadPrescription(org_id int64, patient_id int64, record_date int64) (prescription []*models.HisPrescription, err error) {
  1159. err = readDb.Model(&models.HisPrescription{}).
  1160. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1161. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1162. }).
  1163. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1164. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1165. }).
  1166. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1167. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
  1168. }).
  1169. Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND order_status = 4 AND p_type = 1", org_id, record_date, patient_id).
  1170. Find(&prescription).Error
  1171. return
  1172. }
  1173. func GetZHMonthHisUploadPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
  1174. err = readDb.Model(&models.HisPrescription{}).
  1175. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1176. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1177. }).
  1178. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1179. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1180. }).
  1181. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1182. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1")
  1183. }).
  1184. Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status == 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
  1185. Find(&prescription).Error
  1186. return
  1187. }
  1188. func GetZHHisUploadOrderInfo(org_id int64, patient_id int64, record_date int64, record_end_date int64, number string) (infos []*models.HisOrderInfo, err error) {
  1189. err = readDb.Model(&models.HisOrderInfo{}).
  1190. Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ? AND order_number = ? ", org_id, record_end_date, record_date, patient_id, number).
  1191. Find(&infos).Error
  1192. return
  1193. }
  1194. func UpDateOrderInfoStatus(patient_id int64, record_date int64, org_id int64, record_two_date int64) (err error) {
  1195. err = writeDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND status = 1 AND upload_date <= ? AND upload_date >= ? AND patient_id = ?", org_id, record_two_date, record_date, patient_id).Updates(map[string]interface{}{"status": 0}).Error
  1196. return
  1197. }
  1198. func UpDatePrescriptionOrderStatusTwo(patient_id int64, record_date int64, org_id int64) (err error) {
  1199. err = writeDb.Model(&models.HisPrescription{}).Where("user_org_id = ? AND status = 1 AND record_date = ? AND patient_id = ? AND p_type = 1", org_id, record_date, patient_id).Updates(map[string]interface{}{"order_status": 1}).Error
  1200. return
  1201. }
  1202. //func GetAllOrderInfoByNumber(number string) (infos []*models.HisOrderInfo, err error){
  1203. //
  1204. // err = readDb.Model(&models.HisOrderInfo{}).Where("user_org_id = ? AND ")
  1205. //}
  1206. func GetZHSettleMonthHisPrescription(org_id int64, patient_id int64, start_time int64, end_time int64) (prescription []*models.HisPrescription, err error) {
  1207. err = readDb.Model(&models.HisPrescription{}).
  1208. Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
  1209. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
  1210. }).
  1211. Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
  1212. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("BaseDrugLib", "status=1")
  1213. }).
  1214. Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
  1215. return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject", "status=1").Preload("GoodInfo", "status = 1")
  1216. }).
  1217. Where("user_org_id = ? AND record_date >= ? AND record_date <= ? AND patient_id = ? AND order_status <> 2 AND order_status <> 4 AND status = 1 AND p_type = 1 ", org_id, start_time, end_time, patient_id).
  1218. Find(&prescription).Error
  1219. return
  1220. }
  1221. func ZHyb5203(baseParams models.BaseParams, businessParams models.BusinessParams) string {
  1222. fmt.Println("~~~~~~1")
  1223. fmt.Println(baseParams)
  1224. fmt.Println(businessParams)
  1225. // 生成签名
  1226. nonce := GetRandomString(32)
  1227. timestamp := time.Now().Unix()
  1228. signature := setSignature(timestamp, nonce, baseParams.SecretKey)
  1229. fmt.Println("~~~~~~2")
  1230. // 生成输入报文
  1231. inputMessage := SetInputMessage(nonce, timestamp, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs)
  1232. input := make(map[string]interface{})
  1233. inputData := make(map[string]interface{})
  1234. inputMessage["infno"] = "5203" // 交易编码
  1235. inputData["psn_no"] = businessParams.PsnNo
  1236. inputData["setl_id"] = businessParams.SetlId
  1237. inputData["mdtrt_id"] = businessParams.MdtrtId
  1238. input["data"] = inputData
  1239. inputMessage["input"] = input //交易输入
  1240. bytesData, err := json.Marshal(inputMessage)
  1241. fmt.Println(string(bytesData))
  1242. fmt.Println("~~~~~~")
  1243. fmt.Println("~~~~~~")
  1244. fmt.Println(string(bytesData))
  1245. if err != nil {
  1246. fmt.Println(err.Error())
  1247. return err.Error()
  1248. }
  1249. reader := bytes.NewReader(bytesData)
  1250. gdyb_url := beego.AppConfig.String("gdyb_url")
  1251. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  1252. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  1253. //url := gdyb_url + "5203"
  1254. var url string
  1255. if baseParams.FixmedinsCode == "H15049901371" {
  1256. url = gdyb_url
  1257. } else {
  1258. url = gdyb_url + "5203"
  1259. }
  1260. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/5203"
  1261. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1262. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/5203"
  1263. request, err := http.NewRequest("POST", url, reader)
  1264. if err != nil {
  1265. fmt.Println(err.Error())
  1266. return err.Error()
  1267. }
  1268. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1269. request.Header.Set("x-tif-paasid", gdyb_paasid)
  1270. request.Header.Set("x-tif-signature", signature)
  1271. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  1272. request.Header.Set("x-tif-nonce", nonce)
  1273. client := http.Client{}
  1274. resp, err := client.Do(request)
  1275. if err != nil {
  1276. fmt.Println(err.Error())
  1277. return err.Error()
  1278. }
  1279. respBytes, err := ioutil.ReadAll(resp.Body)
  1280. if err != nil {
  1281. fmt.Println(err.Error())
  1282. return err.Error()
  1283. }
  1284. str := string(respBytes)
  1285. fmt.Println(str)
  1286. return str
  1287. }