zh_his_service.go 64KB

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