zh_his_service.go 63KB

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