nm_service.go 38KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998
  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. "strings"
  12. "time"
  13. )
  14. // 门诊挂号
  15. func Nmyb2201(psnNo string, insutype string, certNo string, org_name string, opera string, ipt_otp_no string, dept string, fixmedins_code string, dept_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, id_card_type int64, doctor_name string, verify_number string, cainfo string) (string, string) {
  16. // 生成签名
  17. // 生成签名
  18. nonce := GetRandomString(32)
  19. timestamp := time.Now().Unix()
  20. signature := setSignature(timestamp, nonce, secret_key)
  21. tempTime := time.Unix(timestamp, 0)
  22. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  23. inputMessage := SetInputMessage(nonce, timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  24. // 生成输入报文
  25. //inputMessage := SetInputMessage(timestamp, org_name, opera, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  26. input := make(map[string]interface{})
  27. inputData := make(map[string]interface{})
  28. inputMessage["infno"] = "2201" // 交易编码
  29. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  30. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  31. inputData["begntime"] = timeFormatOne // 开始时间
  32. if id_card_type == 1 {
  33. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  34. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  35. } else if id_card_type == 3 {
  36. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  37. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  38. } else if id_card_type == 4 {
  39. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  40. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  41. } else {
  42. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  43. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  44. }
  45. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  46. inputData["atddr_no"] = doctor_id // 医师编码
  47. inputData["dr_name"] = doctor_name // 医师姓名
  48. inputData["dept_code"] = dept_code // 科室编码
  49. inputData["dept_name"] = dept // 科室名称
  50. inputData["caty"] = "A03.06" // 科别
  51. inputData["exp_content"] = "" //
  52. input["data"] = inputData
  53. inputMessage["input"] = input //交易输入
  54. var requestLog string
  55. bytesData, err := json.Marshal(inputMessage)
  56. requestLog = string(bytesData)
  57. fmt.Println(string(bytesData))
  58. if err != nil {
  59. fmt.Println(err.Error())
  60. return err.Error(), ""
  61. }
  62. reader := bytes.NewReader(bytesData)
  63. gdyb_url := beego.AppConfig.String("gdyb_url")
  64. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  65. request, err := http.NewRequest("POST", gdyb_url, reader)
  66. if err != nil {
  67. fmt.Println(err.Error())
  68. return err.Error(), ""
  69. }
  70. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  71. request.Header.Set("x-tif-paasid", gdyb_paasid)
  72. request.Header.Set("x-tif-signature", signature)
  73. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  74. request.Header.Set("x-tif-nonce", nonce)
  75. client := http.Client{}
  76. resp, err := client.Do(request)
  77. if err != nil {
  78. fmt.Println(err.Error())
  79. return err.Error(), ""
  80. }
  81. respBytes, err := ioutil.ReadAll(resp.Body)
  82. if err != nil {
  83. fmt.Println(err.Error())
  84. return err.Error(), ""
  85. }
  86. str := string(respBytes)
  87. fmt.Println(str)
  88. return str, requestLog
  89. }
  90. // 门诊挂号撤销
  91. func Nmyb2202(psnNo string, mdtrtId string, ipt_otp_no string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, cainfo string) (string, string) {
  92. // 生成签名
  93. // 生成签名
  94. nonce := GetRandomString(32)
  95. timestamp := time.Now().Unix()
  96. signature := setSignature(timestamp, nonce, secret_key)
  97. // 生成输入报文
  98. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  99. //inputMessage := SetInputMessage(timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  100. input := make(map[string]interface{})
  101. inputData := make(map[string]interface{})
  102. inputMessage["infno"] = "2202" // 交易编码
  103. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  104. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  105. inputData["ipt_otp_no"] = ipt_otp_no // 住院/门诊号
  106. inputData["exp_content"] = "" //
  107. input["data"] = inputData
  108. inputMessage["input"] = input //交易输入
  109. var requestLog string
  110. bytesData, err := json.Marshal(inputMessage)
  111. fmt.Println(string(bytesData))
  112. requestLog = string(bytesData)
  113. if err != nil {
  114. fmt.Println(err.Error())
  115. return err.Error(), ""
  116. }
  117. reader := bytes.NewReader(bytesData)
  118. gdyb_url := beego.AppConfig.String("gdyb_url")
  119. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  120. request, err := http.NewRequest("POST", gdyb_url, reader)
  121. if err != nil {
  122. fmt.Println(err.Error())
  123. return err.Error(), ""
  124. }
  125. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  126. request.Header.Set("x-tif-paasid", gdyb_paasid)
  127. request.Header.Set("x-tif-signature", signature)
  128. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  129. request.Header.Set("x-tif-nonce", nonce)
  130. client := http.Client{}
  131. resp, err := client.Do(request)
  132. if err != nil {
  133. fmt.Println(err.Error())
  134. return err.Error(), ""
  135. }
  136. respBytes, err := ioutil.ReadAll(resp.Body)
  137. if err != nil {
  138. fmt.Println(err.Error())
  139. return err.Error(), ""
  140. }
  141. str := string(respBytes)
  142. fmt.Println(str)
  143. return str, requestLog
  144. }
  145. // 门诊就诊信息上传
  146. func Nmyb2203(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string, cainfo string) (string, string) {
  147. // 生成签名
  148. // 生成签名
  149. nonce := GetRandomString(32)
  150. timestamp := time.Now().Unix()
  151. signature := setSignature(timestamp, nonce, secret_key)
  152. //tempTime := time.Unix(timestamp, 0)
  153. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  154. // 生成输入报文
  155. tempTime := time.Unix(timestamp, 0)
  156. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  157. // 生成输入报文
  158. inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  159. input := make(map[string]interface{})
  160. inputData := make(map[string]interface{})
  161. diseinfo := make([]map[string]interface{}, 0)
  162. if med_type == "1111" || med_type == "1112" {
  163. med_type = "11"
  164. }
  165. inputMessage["infno"] = "2203A" // 交易编码
  166. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  167. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  168. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  169. inputData["begntime"] = begin_time // 开始时间
  170. inputData["main_cond_dscr"] = "" // 主要病情描述
  171. inputData["dise_codg"] = sick_code // 病种编码
  172. inputData["dise_name"] = sick_name // 病种名称
  173. inputData["birctrl_type"] = "" // 计划生育手术类别
  174. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  175. for index, item := range config {
  176. diseinfo_sun := make(map[string]interface{})
  177. diseinfo_sun["diag_type"] = "1" // 诊断类别
  178. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  179. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  180. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  181. diseinfo_sun["diag_dept"] = department // 诊断科室
  182. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  183. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  184. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  185. diseinfo_sun["vali_flag"] = "1" // 有效标志
  186. diseinfo = append(diseinfo, diseinfo_sun)
  187. }
  188. //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  189. inputData["exp_content"] = "" //
  190. input["diseinfo"] = diseinfo
  191. input["mdtrtinfo"] = inputData
  192. inputMessage["input"] = input //交易输入
  193. var requestLog string
  194. bytesData, err := json.Marshal(inputMessage)
  195. fmt.Println(string(bytesData))
  196. requestLog = string(bytesData)
  197. if err != nil {
  198. fmt.Println(err.Error())
  199. return err.Error(), ""
  200. }
  201. reader := bytes.NewReader(bytesData)
  202. gdyb_url := beego.AppConfig.String("gdyb_url")
  203. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  204. request, err := http.NewRequest("POST", gdyb_url, reader)
  205. if err != nil {
  206. fmt.Println(err.Error())
  207. return err.Error(), ""
  208. }
  209. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  210. request.Header.Set("x-tif-paasid", gdyb_paasid)
  211. request.Header.Set("x-tif-signature", signature)
  212. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  213. request.Header.Set("x-tif-nonce", nonce)
  214. client := http.Client{}
  215. resp, err := client.Do(request)
  216. if err != nil {
  217. fmt.Println(err.Error())
  218. return err.Error(), ""
  219. }
  220. respBytes, err := ioutil.ReadAll(resp.Body)
  221. if err != nil {
  222. fmt.Println(err.Error())
  223. return err.Error(), ""
  224. }
  225. str := string(respBytes)
  226. fmt.Println(str)
  227. return str, requestLog
  228. }
  229. func Nmyb2203C(psnNo string, mdtrtId string, doctor string, department string, org_name string, med_type string, doctor_id string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_code string, sick_name string, dept string, config []*models.HisXtDiagnoseConfig, begin_time string, cainfo string) (string, string) {
  230. // 生成签名
  231. // 生成签名
  232. nonce := GetRandomString(32)
  233. timestamp := time.Now().Unix()
  234. signature := setSignature(timestamp, nonce, secret_key)
  235. //tempTime := time.Unix(timestamp, 0)
  236. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  237. // 生成输入报文
  238. tempTime := time.Unix(timestamp, 0)
  239. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  240. // 生成输入报文
  241. inputMessage := SetJSInputMessage(timestamp, org_name, dept, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs, cainfo)
  242. input := make(map[string]interface{})
  243. inputData := make(map[string]interface{})
  244. diseinfo := make([]map[string]interface{}, 0)
  245. if med_type == "1111" || med_type == "1112" {
  246. med_type = "11"
  247. }
  248. inputMessage["infno"] = "2203A" // 交易编码
  249. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  250. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  251. inputData["med_type"] = med_type // 医疗类别 16门诊特殊病
  252. inputData["begntime"] = begin_time // 开始时间
  253. inputData["main_cond_dscr"] = "" // 主要病情描述
  254. inputData["dise_codg"] = sick_code // 病种编码
  255. inputData["dise_name"] = sick_name // 病种名称
  256. inputData["birctrl_type"] = "" // 计划生育手术类别
  257. inputData["birctrl_matn_date"] = "" // 计划生育手术或生育日期
  258. for index, item := range config {
  259. diseinfo_sun := make(map[string]interface{})
  260. diseinfo_sun["diag_type"] = "1" // 诊断类别
  261. diseinfo_sun["diag_srt_no"] = index // 诊断排序号
  262. diseinfo_sun["diag_code"] = item.CountryCode // 诊断代码
  263. diseinfo_sun["diag_name"] = item.ClassName // 诊断名称
  264. diseinfo_sun["diag_dept"] = department // 诊断科室
  265. diseinfo_sun["dise_dor_no"] = doctor_id // 诊断医生编码
  266. diseinfo_sun["dise_dor_name"] = doctor // 诊断医生姓名
  267. diseinfo_sun["diag_time"] = timeFormatOne // 诊断时间
  268. diseinfo_sun["vali_flag"] = "0" // 有效标志
  269. diseinfo = append(diseinfo, diseinfo_sun)
  270. }
  271. //inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  272. inputData["exp_content"] = "" //
  273. input["diseinfo"] = diseinfo
  274. input["mdtrtinfo"] = inputData
  275. inputMessage["input"] = input //交易输入
  276. var requestLog string
  277. bytesData, err := json.Marshal(inputMessage)
  278. fmt.Println(string(bytesData))
  279. requestLog = string(bytesData)
  280. if err != nil {
  281. fmt.Println(err.Error())
  282. return err.Error(), ""
  283. }
  284. reader := bytes.NewReader(bytesData)
  285. gdyb_url := beego.AppConfig.String("gdyb_url")
  286. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  287. request, err := http.NewRequest("POST", gdyb_url, reader)
  288. if err != nil {
  289. fmt.Println(err.Error())
  290. return err.Error(), ""
  291. }
  292. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  293. request.Header.Set("x-tif-paasid", gdyb_paasid)
  294. request.Header.Set("x-tif-signature", signature)
  295. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  296. request.Header.Set("x-tif-nonce", nonce)
  297. client := http.Client{}
  298. resp, err := client.Do(request)
  299. if err != nil {
  300. fmt.Println(err.Error())
  301. return err.Error(), ""
  302. }
  303. respBytes, err := ioutil.ReadAll(resp.Body)
  304. if err != nil {
  305. fmt.Println(err.Error())
  306. return err.Error(), ""
  307. }
  308. str := string(respBytes)
  309. fmt.Println(str)
  310. return str, requestLog
  311. }
  312. // 门诊费用明细信息上传
  313. func Nmyb2204(psnNo string, mdtrtId string, hisPrescription []*models.HisPrescription, 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, balance_accounts_type string, diag_code string, request_url string, access_key string, new_doctor_name string, time_stamp_2203 string, cainfo string) (string, string) {
  314. // 生成签名
  315. timestamp := time.Now().Unix()
  316. // 生成签名
  317. nonce := GetRandomString(32)
  318. signature := setSignature(timestamp, nonce, secret_key)
  319. var customs []*Custom
  320. for _, item := range hisPrescription {
  321. tm := time.Unix(item.PreTime, 0)
  322. if item.Type == 1 { //药品
  323. for _, subItem := range item.HisDoctorAdviceInfo {
  324. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  325. //var randNum int
  326. //randNum = rand.Intn(10000) + 1000
  327. cus := &Custom{
  328. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  329. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  330. FeedetlSn: subItem.FeedetlSn,
  331. Price: fmt.Sprintf("%.4f", subItem.Price),
  332. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  333. HospApprFlag: subItem.HospApprFlag,
  334. DoctorNumber: doctor_id,
  335. DoctorName: new_doctor_name,
  336. ProvinceDrugMedListCodg: "",
  337. ProvinceGoodMedListCodg: "",
  338. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  339. }
  340. if subItem.BaseDrugLib.DrugClassify == "2" {
  341. cus.ProvinceDrugMedListCodg = subItem.BaseDrugLib.ProvincesCode
  342. }
  343. customs = append(customs, cus)
  344. }
  345. }
  346. }
  347. if item.Type == 2 { //项目
  348. for _, subItem := range item.HisPrescriptionProject {
  349. //var randNum int
  350. //randNum = rand.Intn(10000) + 1000
  351. if subItem.Type == 2 {
  352. if len(subItem.HisProject.MedicalCode) > 0 {
  353. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  354. cus := &Custom{
  355. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  356. Cut: fmt.Sprintf("%.4f", cnt),
  357. FeedetlSn: subItem.FeedetlSn,
  358. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  359. MedListCodg: subItem.HisProject.MedicalCode,
  360. DoctorNumber: doctor_id,
  361. DoctorName: new_doctor_name,
  362. HospApprFlag: -1,
  363. ProvinceDrugMedListCodg: "",
  364. ProvinceGoodMedListCodg: "",
  365. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  366. }
  367. customs = append(customs, cus)
  368. }
  369. } else if subItem.Type == 3 {
  370. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  371. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  372. cus := &Custom{
  373. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  374. Cut: fmt.Sprintf("%.4f", cnt),
  375. FeedetlSn: subItem.FeedetlSn,
  376. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  377. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  378. HospApprFlag: -1,
  379. DoctorNumber: doctor_id,
  380. DoctorName: new_doctor_name,
  381. ProvinceDrugMedListCodg: "",
  382. ProvinceGoodMedListCodg: subItem.GoodInfo.ProvincesCode,
  383. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  384. }
  385. customs = append(customs, cus)
  386. }
  387. }
  388. }
  389. }
  390. for _, subItem := range item.HisAdditionalCharge {
  391. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  392. cus := &Custom{
  393. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  394. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  395. FeedetlSn: subItem.FeedetlSn,
  396. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  397. MedListCodg: subItem.XtHisAddtionConfig.Code,
  398. HospApprFlag: -1,
  399. DoctorNumber: doctor_id,
  400. DoctorName: new_doctor_name,
  401. }
  402. customs = append(customs, cus)
  403. }
  404. }
  405. }
  406. // 生成输入报文
  407. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  408. input := make(map[string]interface{})
  409. feedetail := make([]map[string]interface{}, 0)
  410. inputMessage["infno"] = "2204" // 交易编码
  411. //chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  412. for _, item := range customs {
  413. feedetailInfo := make(map[string]interface{})
  414. subfeedetailInfo := make(map[string]interface{})
  415. feedetailInfo["feedetl_sn"] = item.FeedetlSn
  416. feedetailInfo["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  417. feedetailInfo["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  418. feedetailInfo["chrg_bchno"] = chrg_bchno // 收费批次号
  419. feedetailInfo["dise_codg"] = diag_code // 病种编码
  420. feedetailInfo["rxno"] = "" // 处方号
  421. feedetailInfo["rx_circ_flag"] = "0" // 外购处方标志
  422. feedetailInfo["fee_ocur_time"] = item.FeeOcurTime // 费用发生时间
  423. feedetailInfo["med_list_codg"] = item.MedListCodg // 医疗目录编码
  424. feedetailInfo["medins_list_codg"] = fixmedins_code // 医药机构目录编码
  425. feedetailInfo["det_item_fee_sumamt"] = item.DetItemFeeSumamt // 明细项目费用总额
  426. feedetailInfo["cnt"] = item.Cut // 数量
  427. feedetailInfo["pric"] = item.Price // 单价
  428. feedetailInfo["sin_dos_dscr"] = "" // 单次剂量描述
  429. feedetailInfo["used_frqu_dscr"] = "" // 使用频次描述
  430. feedetailInfo["prd_days"] = "0" // 周期天数
  431. feedetailInfo["medc_way_dscr"] = "" // 用药途径描述
  432. feedetailInfo["bilg_dept_codg"] = dept_code // 开单科室编码
  433. feedetailInfo["bilg_dept_name"] = dept // 开单科室名称
  434. feedetailInfo["bilg_dr_codg"] = doctor_id // 开单医生编码
  435. feedetailInfo["bilg_dr_name"] = new_doctor_name // 开单医师姓名
  436. feedetailInfo["acord_dept_codg"] = dept_code // 受单科室编码
  437. feedetailInfo["acord_dept_name"] = dept // 受单科室名称
  438. feedetailInfo["orders_dr_code"] = doctor_id // 受单医生编码
  439. feedetailInfo["orders_dr_name"] = new_doctor_name // 受单医生姓名
  440. if balance_accounts_type == "8" {
  441. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  442. } else {
  443. if item.HospApprFlag != -1 {
  444. if item.HospApprFlag == 1 {
  445. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  446. } else if item.HospApprFlag == 2 {
  447. feedetailInfo["hosp_appr_flag"] = "2" // 医院审批标志
  448. } else if item.HospApprFlag == 3 {
  449. feedetailInfo["hosp_appr_flag"] = "0" // 医院审批标志
  450. } else {
  451. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  452. }
  453. } else {
  454. feedetailInfo["hosp_appr_flag"] = "1" // 医院审批标志
  455. }
  456. }
  457. feedetailInfo["tcmdrug_used_way"] = "" // 中药使用方式
  458. feedetailInfo["etip_flag"] = "" // 外检标志
  459. feedetailInfo["etip_hosp_code"] = "" // 外检医院编码
  460. feedetailInfo["dscg_tkdrug_flag"] = "" // 出院带药标志
  461. feedetailInfo["matn_fee_flag"] = "" // 生育费用标志
  462. subfeedetailInfo["tcmherb_prov_code"] = item.ProvinceDrugMedListCodg
  463. subfeedetailInfo["mcs_prov_code"] = item.ProvinceGoodMedListCodg
  464. feedetailInfo["exp_content"] = subfeedetailInfo
  465. feedetail = append(feedetail, feedetailInfo)
  466. }
  467. input["feedetail"] = feedetail
  468. inputMessage["input"] = input //交易输入
  469. var requestLog string
  470. bytesData, err := json.Marshal(inputMessage)
  471. requestLog = string(bytesData)
  472. fmt.Println(string(bytesData))
  473. if err != nil {
  474. fmt.Println(err.Error())
  475. return "", ""
  476. }
  477. reader := bytes.NewReader(bytesData)
  478. gdyb_url := beego.AppConfig.String("gdyb_url")
  479. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  480. request, err := http.NewRequest("POST", gdyb_url, reader)
  481. if err != nil {
  482. fmt.Println(err.Error())
  483. return "", ""
  484. }
  485. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  486. request.Header.Set("x-tif-paasid", gdyb_paasid)
  487. request.Header.Set("x-tif-signature", signature)
  488. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  489. request.Header.Set("x-tif-nonce", nonce)
  490. client := http.Client{}
  491. resp, err := client.Do(request)
  492. if err != nil {
  493. fmt.Println(err.Error())
  494. return "", ""
  495. }
  496. respBytes, err := ioutil.ReadAll(resp.Body)
  497. if err != nil {
  498. fmt.Println(err.Error())
  499. return "", ""
  500. }
  501. return string(respBytes), requestLog
  502. }
  503. // 门诊费用明细信息撤销
  504. func Nmyb2205(psnNo string, mdtrtId string, chrgBchno string, org_name string, doctor string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, fixmedins_code string, request_url string, access_key string, cainfo string) (string, string) {
  505. // 生成签名
  506. nonce := GetRandomString(32)
  507. timestamp := time.Now().Unix()
  508. signature := setSignature(timestamp, nonce, secret_key)
  509. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  510. input := make(map[string]interface{})
  511. inputData := make(map[string]interface{})
  512. inputMessage["infno"] = "2205" // 交易编码
  513. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  514. inputData["chrg_bchno"] = "0000" // 收费批次号(来自2204生成的)
  515. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  516. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  517. input["data"] = inputData
  518. inputMessage["input"] = input //交易输入
  519. bytesData, err := json.Marshal(inputMessage)
  520. fmt.Println(string(bytesData))
  521. var requestLog string
  522. requestLog = string(bytesData)
  523. if err != nil {
  524. fmt.Println(err.Error())
  525. return err.Error(), ""
  526. }
  527. reader := bytes.NewReader(bytesData)
  528. gdyb_url := beego.AppConfig.String("gdyb_url")
  529. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  530. request, err := http.NewRequest("POST", gdyb_url, reader)
  531. fmt.Println(err)
  532. fmt.Println(request)
  533. if err != nil {
  534. fmt.Println(err.Error())
  535. return err.Error(), ""
  536. }
  537. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  538. request.Header.Set("x-tif-paasid", gdyb_paasid)
  539. request.Header.Set("x-tif-signature", signature)
  540. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  541. request.Header.Set("x-tif-nonce", nonce)
  542. client := http.Client{}
  543. resp, err := client.Do(request)
  544. if err != nil {
  545. fmt.Println(err.Error())
  546. return err.Error(), ""
  547. }
  548. respBytes, err := ioutil.ReadAll(resp.Body)
  549. if err != nil {
  550. fmt.Println(err.Error())
  551. return err.Error(), ""
  552. }
  553. str := string(respBytes)
  554. fmt.Println(str)
  555. return str, requestLog
  556. }
  557. // 门诊预结算
  558. func Nmyb2206(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, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, request_url string, access_key string, verify_number string, cainfo string, mdtrt_grp_type string) (string, string) {
  559. if !strings.Contains(insuplc_admdvs, "150") {
  560. chrgBchno = "0000"
  561. }
  562. // 生成签名
  563. nonce := GetRandomString(32)
  564. timestamp := time.Now().Unix()
  565. signature := setSignature(timestamp, nonce, secret_key)
  566. // 生成输入报文
  567. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  568. input := make(map[string]interface{})
  569. inputData := make(map[string]interface{})
  570. inputMessage["infno"] = "2206" // 交易编码
  571. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  572. if certificates == 3 {
  573. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  574. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  575. } else {
  576. if id_card_type == 1 {
  577. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  578. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  579. } else if id_card_type == 3 {
  580. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  581. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  582. } else if id_card_type == 4 {
  583. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  584. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  585. } else {
  586. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  587. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  588. }
  589. }
  590. if insuplc_admdvs == "421300" {
  591. if med_type == "11" || med_type == "1112" || med_type == "1111" {
  592. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  593. } else if med_type == "14" {
  594. inputData["med_type"] = "140110" // 医疗类别 11 普通门诊 12 门诊挂号
  595. }
  596. } else {
  597. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  598. }
  599. inputData["medfee_sumamt"] = total // 医疗费总额
  600. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  601. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  602. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  603. inputData["acct_used_flag"] = "0" // 个人账户使用标志 0否 1是
  604. inputData["insutype"] = insutype // 险种类型
  605. inputData["invono"] = "" // 发票号
  606. inputData2 := make(map[string]interface{})
  607. inputData2["trum_flag"] = ""
  608. inputData2["rel_ttp_flag"] = ""
  609. inputData2["otp_er_refl_flag"] = ""
  610. inputData2["mdtrt_grp_type"] = mdtrt_grp_type
  611. inputData2["need_ipt_flag"] = ""
  612. inputData["exp_content"] = inputData2
  613. input["data"] = inputData
  614. inputMessage["input"] = input //交易输入
  615. var requestLog string
  616. bytesData, err := json.Marshal(inputMessage)
  617. requestLog = string(bytesData)
  618. fmt.Println(string(bytesData))
  619. if err != nil {
  620. fmt.Println(err.Error())
  621. return err.Error(), ""
  622. }
  623. reader := bytes.NewReader(bytesData)
  624. gdyb_url := beego.AppConfig.String("gdyb_url")
  625. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  626. request, err := http.NewRequest("POST", gdyb_url, reader)
  627. if err != nil {
  628. fmt.Println(err.Error())
  629. return err.Error(), ""
  630. }
  631. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  632. request.Header.Set("x-tif-paasid", gdyb_paasid)
  633. request.Header.Set("x-tif-signature", signature)
  634. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  635. request.Header.Set("x-tif-nonce", nonce)
  636. client := http.Client{}
  637. resp, err := client.Do(request)
  638. if err != nil {
  639. fmt.Println(err.Error())
  640. return err.Error(), ""
  641. }
  642. respBytes, err := ioutil.ReadAll(resp.Body)
  643. if err != nil {
  644. fmt.Println(err.Error())
  645. return err.Error(), ""
  646. }
  647. str := string(respBytes)
  648. fmt.Println(str)
  649. return str, requestLog
  650. }
  651. // 门诊结算
  652. func Nmyb2207(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, med_type string, id_card_type int64, fulamt_ownpay_amt float64, overlmt_selfpay float64, preselfpay_amt float64, inscp_scp_amt float64, certificates int64, acct_used_flag string, request_url string, access_key string, verify_number string, cainfo string, mdtrt_grp_type string) (string, string) {
  653. if !strings.Contains(insuplc_admdvs, "150") {
  654. chrgBchno = "0000"
  655. }
  656. // 生成签名
  657. nonce := GetRandomString(32)
  658. timestamp := time.Now().Unix()
  659. signature := setSignature(timestamp, nonce, secret_key)
  660. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  661. input := make(map[string]interface{})
  662. inputData := make(map[string]interface{})
  663. inputMessage["infno"] = "2207" // 交易编码
  664. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  665. if certificates == 3 {
  666. inputData["mdtrt_cert_type"] = "99" // 就诊凭证类型
  667. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  668. } else {
  669. if id_card_type == 1 {
  670. inputData["mdtrt_cert_type"] = "03" // 就诊凭证类型
  671. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  672. } else if id_card_type == 3 {
  673. inputData["mdtrt_cert_type"] = "04" // 就诊凭证类型
  674. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  675. } else if id_card_type == 4 {
  676. inputData["mdtrt_cert_type"] = "01" // 就诊凭证类型
  677. inputData["mdtrt_cert_no"] = verify_number // 就诊凭证编号
  678. } else {
  679. inputData["mdtrt_cert_type"] = "02" // 就诊凭证类型
  680. inputData["mdtrt_cert_no"] = certNo // 就诊凭证编号
  681. }
  682. }
  683. if med_type == "1111" || med_type == "1112" {
  684. med_type = "11"
  685. }
  686. if insuplc_admdvs == "421300" {
  687. if med_type == "11" {
  688. inputData["med_type"] = "110104" // 医疗类别 11 普通门诊 12 门诊挂号
  689. } else if med_type == "14" {
  690. inputData["med_type"] = "140101" // 医疗类别 11 普通门诊 12 门诊挂号
  691. }
  692. } else {
  693. inputData["med_type"] = med_type // 医疗类别 11 普通门诊 12 门诊挂号
  694. }
  695. inputData["medfee_sumamt"] = total // 医疗费总额
  696. inputData["psn_setlway"] = "01" // 个人结算方式 01 按项目结 02 按定额结算
  697. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  698. inputData["chrg_bchno"] = chrgBchno // 收费批次号(来自2204生成的)
  699. inputData["acct_used_flag"] = acct_used_flag // 个人账户使用标志 0否 1是
  700. inputData["insutype"] = insutype // 险种类型
  701. inputData["invono"] = "12345" // 发票号
  702. inputData["fulamt_ownpay_amt"] = fulamt_ownpay_amt //
  703. inputData["overlmt_selfpay"] = overlmt_selfpay //
  704. inputData["preselfpay_amt"] = preselfpay_amt //
  705. inputData["inscp_scp_amt"] = inscp_scp_amt //
  706. inputData2 := make(map[string]interface{})
  707. inputData2["trum_flag"] = ""
  708. inputData2["rel_ttp_flag"] = ""
  709. inputData2["otp_er_refl_flag"] = ""
  710. inputData2["mdtrt_grp_type"] = mdtrt_grp_type
  711. inputData2["need_ipt_flag"] = ""
  712. inputData["exp_content"] = inputData2
  713. input["data"] = inputData
  714. inputMessage["input"] = input //交易输入
  715. bytesData, err := json.Marshal(inputMessage)
  716. fmt.Println(string(bytesData))
  717. if err != nil {
  718. fmt.Println(err.Error())
  719. return err.Error(), ""
  720. }
  721. reader := bytes.NewReader(bytesData)
  722. gdyb_url := beego.AppConfig.String("gdyb_url")
  723. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  724. request, err := http.NewRequest("POST", gdyb_url, reader)
  725. if err != nil {
  726. fmt.Println(err.Error())
  727. return err.Error(), ""
  728. }
  729. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  730. request.Header.Set("x-tif-paasid", gdyb_paasid)
  731. request.Header.Set("x-tif-signature", signature)
  732. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  733. request.Header.Set("x-tif-nonce", nonce)
  734. client := http.Client{}
  735. resp, err := client.Do(request)
  736. if err != nil {
  737. fmt.Println(err.Error())
  738. return err.Error(), ""
  739. }
  740. respBytes, err := ioutil.ReadAll(resp.Body)
  741. if err != nil {
  742. fmt.Println(err.Error())
  743. return err.Error(), ""
  744. }
  745. str := string(respBytes)
  746. fmt.Println(str)
  747. mjson, _ := json.Marshal(inputMessage)
  748. str2 := string(mjson)
  749. return str, str2
  750. }
  751. // 门诊结算撤销
  752. func Nmyb2208(psnNo string, mdtrtId string, setlId string, org_name string, doctor string, secret_key string, fixmedins_code string, insuplc_admdvs string, mdtrtarea_admvs string, request_url string, access_key string, cainfo string) (string, string) {
  753. // 生成签名
  754. nonce := GetRandomString(32)
  755. timestamp := time.Now().Unix()
  756. signature := setSignature(timestamp, nonce, secret_key)
  757. // 生成输入报文
  758. inputMessage := SetInputMessage(nonce, timestamp, org_name, doctor, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  759. input := make(map[string]interface{})
  760. inputData := make(map[string]interface{})
  761. inputMessage["infno"] = "2208" // 交易编码
  762. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  763. inputData["mdtrt_id"] = mdtrtId // 就诊 ID(来自2201接口返回)
  764. inputData["setl_id"] = setlId // 结算 ID
  765. inputData["exp_content"] = "" // 人员编号 (来自1101接口返回)
  766. input["data"] = inputData
  767. inputMessage["input"] = input //交易输入
  768. bytesData, err := json.Marshal(inputMessage)
  769. fmt.Println(string(bytesData))
  770. if err != nil {
  771. fmt.Println(err.Error())
  772. return err.Error(), ""
  773. }
  774. reader := bytes.NewReader(bytesData)
  775. gdyb_url := beego.AppConfig.String("gdyb_url")
  776. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  777. request, err := http.NewRequest("POST", gdyb_url, reader)
  778. if err != nil {
  779. fmt.Println(err.Error())
  780. return err.Error(), ""
  781. }
  782. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  783. request.Header.Set("x-tif-paasid", gdyb_paasid)
  784. request.Header.Set("x-tif-signature", signature)
  785. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  786. request.Header.Set("x-tif-nonce", nonce)
  787. client := http.Client{}
  788. resp, err := client.Do(request)
  789. if err != nil {
  790. fmt.Println(err.Error())
  791. return err.Error(), ""
  792. }
  793. respBytes, err := ioutil.ReadAll(resp.Body)
  794. if err != nil {
  795. fmt.Println(err.Error())
  796. return err.Error(), ""
  797. }
  798. str := string(respBytes)
  799. fmt.Println(str)
  800. mjson, _ := json.Marshal(inputMessage)
  801. str2 := string(mjson)
  802. return str, str2
  803. }
  804. func Nmyb2503(psnNo string, insutype string, org_name string, op string, doctor string, fixmedins_code string, doctor_id string, insuplc_admdvs string, mdtrtarea_admvs string, secret_key string, sick_name string, sick_code string, start_time string, end_time string, check_time string, hospital_code string, hospital_name string) string {
  805. // 生成签名
  806. nonce := GetRandomString(32)
  807. timestamp := time.Now().Unix()
  808. signature := setSignature(timestamp, nonce, secret_key)
  809. //tempTime := time.Unix(timestamp, 0)
  810. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  811. //timeFormatTwo := tempTime.Format("2006-01-02")
  812. //t := time.Now()
  813. //last := time.Date(t.Year(), time.December, 31, 0, 0, 0, 0, time.UTC)
  814. //tm := time.Unix(last.Unix(), 0)
  815. // 生成输入报文
  816. inputMessage := SetInputMessage(nonce, timestamp, org_name, op, fixmedins_code, insuplc_admdvs, mdtrtarea_admvs)
  817. input := make(map[string]interface{})
  818. inputData := make(map[string]interface{})
  819. inputMessage["infno"] = "2503" // 交易编码
  820. inputData["psn_no"] = psnNo // 人员编号 (来自1101接口返回)
  821. inputData["insutype"] = insutype // 险种类型(来自1101接口返回)
  822. inputData["opsp_dise_code"] = sick_code // 险种类型(来自1101接口返回)
  823. inputData["opsp_dise_name"] = sick_name // 险种类型(来自1101接口返回)
  824. inputData["insu_optins"] = insuplc_admdvs // 险种类型(来自1101接口返回)
  825. inputData["ide_fixmedins_no"] = hospital_code // 险种类型(来自1101接口返回)
  826. inputData["ide_fixmedins_name"] = hospital_name // 险种类型(来自1101接口返回)
  827. inputData["hosp_ide_date"] = check_time // 险种类型(来自1101接口返回)
  828. inputData["diag_dr_codg"] = doctor_id // 开始时间
  829. inputData["diag_dr_name"] = doctor // 开始时间
  830. inputData["begndate"] = start_time // 医师编码
  831. inputData["tel"] = "" // 医师编码
  832. inputData["addr"] = "" // 医师编码
  833. inputData["enddate"] = end_time // 医师编码
  834. input["data"] = inputData
  835. inputMessage["input"] = input //交易输入
  836. bytesData, err := json.Marshal(inputMessage)
  837. fmt.Println(string(bytesData))
  838. if err != nil {
  839. fmt.Println(err.Error())
  840. return err.Error()
  841. }
  842. reader := bytes.NewReader(bytesData)
  843. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/2503"
  844. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_inf/poc/hsa/hgs/2503"
  845. gdyb_url := beego.AppConfig.String("gdyb_url")
  846. gdyb_paasid := beego.AppConfig.String("gdyb_paasid")
  847. //url := "http://igb.hsa.gdgov.cn/ebus/gdyb_api/prd/hsa/hgs/1101"
  848. //url := gdyb_url + "2503"
  849. var url string
  850. if fixmedins_code == "H15049901371" {
  851. url = gdyb_url
  852. } else {
  853. url = gdyb_url + "2503"
  854. }
  855. request, err := http.NewRequest("POST", url, reader)
  856. if err != nil {
  857. fmt.Println(err.Error())
  858. return err.Error()
  859. }
  860. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  861. request.Header.Set("x-tif-paasid", gdyb_paasid)
  862. request.Header.Set("x-tif-signature", signature)
  863. request.Header.Set("x-tif-timestamp", strconv.FormatInt(timestamp, 10))
  864. request.Header.Set("x-tif-nonce", nonce)
  865. client := http.Client{}
  866. resp, err := client.Do(request)
  867. if err != nil {
  868. fmt.Println(err.Error())
  869. return err.Error()
  870. }
  871. respBytes, err := ioutil.ReadAll(resp.Body)
  872. if err != nil {
  873. fmt.Println(err.Error())
  874. return err.Error()
  875. }
  876. str := string(respBytes)
  877. fmt.Println(str)
  878. return str
  879. }