zh_his_service.go 61KB

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