zh_his_api_controller.go 68KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029
  1. package zh
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/controllers"
  7. "gdyb/enums"
  8. "gdyb/models"
  9. "gdyb/service"
  10. "gdyb/utils"
  11. "github.com/astaxie/beego"
  12. "io/ioutil"
  13. "math"
  14. "math/rand"
  15. "net/http"
  16. "strconv"
  17. "strings"
  18. "time"
  19. )
  20. type ZHHisApiController struct {
  21. controllers.BaseAuthAPIController
  22. }
  23. type ResultTwo struct {
  24. ErrMsg string `json:"err_msg"`
  25. InfRefmsgid string `json:"inf_refmsgid"`
  26. Infcode int64 `json:"infcode"`
  27. Output struct {
  28. Baseinfo struct {
  29. Age float64 `json:"age"`
  30. Brdy string `json:"brdy"`
  31. Certno string `json:"certno"`
  32. Gend string `json:"gend"`
  33. Naty string `json:"naty"`
  34. PsnCertType string `json:"psn_cert_type"`
  35. PsnName string `json:"psn_name"`
  36. PsnNo string `json:"psn_no"`
  37. } `json:"baseinfo"`
  38. Idetinfo []interface{} `json:"idetinfo"`
  39. Iinfo []struct {
  40. Balc float64 `json:"balc"`
  41. CvlservFlag string `json:"cvlserv_flag"`
  42. EmpName string `json:"emp_name"`
  43. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  44. Insutype string `json:"insutype"`
  45. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  46. PausInsuDate string `json:"paus_insu_date"`
  47. PsnInsuDate string `json:"psn_insu_date"`
  48. PsnInsuStas string `json:"psn_insu_stas"`
  49. PsnType string `json:"psn_type"`
  50. } `json:"insuinfo"`
  51. } `json:"output"`
  52. RefmsgTime string `json:"refmsg_time"`
  53. RespondTime string `json:"respond_time"`
  54. Signtype interface{} `json:"signtype"`
  55. WarnInfo interface{} `json:"warn_info"`
  56. }
  57. type ResultTwo10265 struct {
  58. ErrMsg string `json:"err_msg"`
  59. InfRefmsgid string `json:"inf_refmsgid"`
  60. Infcode string `json:"infcode"`
  61. Output struct {
  62. Baseinfo struct {
  63. Age float64 `json:"age"`
  64. Brdy string `json:"brdy"`
  65. Certno string `json:"certno"`
  66. Gend string `json:"gend"`
  67. Naty string `json:"naty"`
  68. PsnCertType string `json:"psn_cert_type"`
  69. PsnName string `json:"psn_name"`
  70. PsnNo string `json:"psn_no"`
  71. } `json:"baseinfo"`
  72. Idetinfo []interface{} `json:"idetinfo"`
  73. Iinfo []struct {
  74. Balc float64 `json:"balc"`
  75. CvlservFlag string `json:"cvlserv_flag"`
  76. EmpName string `json:"emp_name"`
  77. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  78. Insutype string `json:"insutype"`
  79. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  80. PausInsuDate string `json:"paus_insu_date"`
  81. PsnInsuDate string `json:"psn_insu_date"`
  82. PsnInsuStas string `json:"psn_insu_stas"`
  83. PsnType string `json:"psn_type"`
  84. } `json:"insuinfo"`
  85. } `json:"output"`
  86. RefmsgTime string `json:"refmsg_time"`
  87. RespondTime string `json:"respond_time"`
  88. Signtype interface{} `json:"signtype"`
  89. WarnInfo interface{} `json:"warn_info"`
  90. }
  91. type ResultThree struct {
  92. Cainfo interface{} `json:"cainfo"`
  93. ErrMsg string `json:"err_msg"`
  94. InfRefmsgid string `json:"inf_refmsgid"`
  95. Infcode int64 `json:"infcode"`
  96. Output struct {
  97. Result struct {
  98. MdtrtID string `json:"mdtrt_id"`
  99. } `json:"result"`
  100. } `json:"output"`
  101. RefmsgTime string `json:"refmsg_time"`
  102. RespondTime string `json:"respond_time"`
  103. Signtype interface{} `json:"signtype"`
  104. WarnMsg interface{} `json:"warn_msg"`
  105. }
  106. type ResultThree10265 struct {
  107. Cainfo interface{} `json:"cainfo"`
  108. ErrMsg string `json:"err_msg"`
  109. InfRefmsgid string `json:"inf_refmsgid"`
  110. Infcode string `json:"infcode"`
  111. Output struct {
  112. Result struct {
  113. MdtrtID string `json:"mdtrt_id"`
  114. } `json:"result"`
  115. } `json:"output"`
  116. RefmsgTime string `json:"refmsg_time"`
  117. RespondTime string `json:"respond_time"`
  118. Signtype interface{} `json:"signtype"`
  119. WarnMsg interface{} `json:"warn_msg"`
  120. }
  121. type ResultFour struct {
  122. Cainfo string `json:"cainfo"`
  123. ErrMsg string `json:"err_msg"`
  124. InfRefmsgid string `json:"inf_refmsgid"`
  125. Infcode int64 `json:"infcode"`
  126. Output struct {
  127. Result []struct {
  128. BasMednFlag string `json:"bas_medn_flag"`
  129. ChldMedcFlag string `json:"chld_medc_flag"`
  130. ChrgitmLv string `json:"chrgitm_lv"`
  131. Cnt float64 `json:"cnt"`
  132. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  133. DrtReimFlag string `json:"drt_reim_flag"`
  134. FeedetlSn string `json:"feedetl_sn"`
  135. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  136. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  137. InscpScpAmt float64 `json:"inscp_scp_amt"`
  138. ListSpItemFlag string `json:"list_sp_item_flag"`
  139. LmtUsedFlag string `json:"lmt_used_flag"`
  140. MedChrgitmType string `json:"med_chrgitm_type"`
  141. Memo string `json:"memo"`
  142. OverlmtAmt float64 `json:"overlmt_amt"`
  143. PreselfpayAmt float64 `json:"preselfpay_amt"`
  144. Pric float64 `json:"pric"`
  145. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  146. SelfpayProp float64 `json:"selfpay_prop"`
  147. } `json:"result"`
  148. } `json:"output"`
  149. RefmsgTime string `json:"refmsg_time"`
  150. RespondTime string `json:"respond_time"`
  151. Signtype string `json:"signtype"`
  152. WarnMsg string `json:"warn_msg"`
  153. }
  154. type ResultFour10265 struct {
  155. Cainfo string `json:"cainfo"`
  156. ErrMsg string `json:"err_msg"`
  157. InfRefmsgid string `json:"inf_refmsgid"`
  158. Infcode string `json:"infcode"`
  159. Output struct {
  160. Result []struct {
  161. BasMednFlag string `json:"bas_medn_flag"`
  162. ChldMedcFlag string `json:"chld_medc_flag"`
  163. ChrgitmLv string `json:"chrgitm_lv"`
  164. Cnt float64 `json:"cnt"`
  165. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  166. DrtReimFlag string `json:"drt_reim_flag"`
  167. FeedetlSn string `json:"feedetl_sn"`
  168. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  169. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  170. InscpScpAmt float64 `json:"inscp_scp_amt"`
  171. ListSpItemFlag string `json:"list_sp_item_flag"`
  172. LmtUsedFlag string `json:"lmt_used_flag"`
  173. MedChrgitmType string `json:"med_chrgitm_type"`
  174. Memo string `json:"memo"`
  175. OverlmtAmt float64 `json:"overlmt_amt"`
  176. PreselfpayAmt float64 `json:"preselfpay_amt"`
  177. Pric float64 `json:"pric"`
  178. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  179. SelfpayProp float64 `json:"selfpay_prop"`
  180. } `json:"result"`
  181. } `json:"output"`
  182. RefmsgTime string `json:"refmsg_time"`
  183. RespondTime string `json:"respond_time"`
  184. Signtype string `json:"signtype"`
  185. WarnMsg string `json:"warn_msg"`
  186. }
  187. type ResultFive struct {
  188. Balc float64 `json:"balc"`
  189. CvlservFlag string `json:"cvlserv_flag"`
  190. EmpName string `json:"emp_name"`
  191. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  192. Insutype string `json:"insutype"`
  193. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  194. PausInsuDate string `json:"paus_insu_date"`
  195. PsnInsuDate string `json:"psn_insu_date"`
  196. PsnInsuStas string `json:"psn_insu_stas"`
  197. PsnType string `json:"psn_type"`
  198. }
  199. type ResultSeven struct {
  200. Cainfo string `json:"cainfo"`
  201. ErrMsg string `json:"err_msg"`
  202. InfRefmsgid string `json:"inf_refmsgid"`
  203. Infcode int64 `json:"infcode"`
  204. Output struct {
  205. Setldetail []interface{} `json:"setldetail"`
  206. Setlinfo struct {
  207. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  208. AcctPay float64 `json:"acct_pay"`
  209. ActPayDedc float64 `json:"act_pay_dedc"`
  210. Age float64 `json:"age"`
  211. Balc float64 `json:"balc"`
  212. Brdy string `json:"brdy"`
  213. Certno string `json:"certno"`
  214. ClrOptins string `json:"clr_optins"`
  215. ClrType string `json:"clr_type"`
  216. ClrWay string `json:"clr_way"`
  217. CvlservFlag string `json:"cvlserv_flag"`
  218. CvlservPay float64 `json:"cvlserv_pay"`
  219. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  220. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  221. Gend string `json:"gend"`
  222. HifesPay float64 `json:"hifes_pay"`
  223. HifmiPay float64 `json:"hifmi_pay"`
  224. HifpPay float64 `json:"hifp_pay"`
  225. HospPartAmt float64 `json:"hosp_part_amt"`
  226. InscpScpAmt float64 `json:"inscp_scp_amt"`
  227. Insutype string `json:"insutype"`
  228. MafPay float64 `json:"maf_pay"`
  229. MdtrtCertType string `json:"mdtrt_cert_type"`
  230. HifobPay float64 `json:"hifob_pay"`
  231. MdtrtID string `json:"mdtrt_id"`
  232. MedType string `json:"med_type"`
  233. MedfeeSumamt float64 `json:"medfee_sumamt"`
  234. MedinsSetlID string `json:"medins_setl_id"`
  235. Naty string `json:"naty"`
  236. OthPay float64 `json:"oth_pay"`
  237. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  238. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  239. PreselfpayAmt float64 `json:"preselfpay_amt"`
  240. PsnCashPay float64 `json:"psn_cash_pay"`
  241. PsnCertType string `json:"psn_cert_type"`
  242. PsnName string `json:"psn_name"`
  243. PsnNo string `json:"psn_no"`
  244. PsnPartAmt float64 `json:"psn_part_amt"`
  245. PsnType string `json:"psn_type"`
  246. SetlID string `json:"setl_id"`
  247. SetlTime string `json:"setl_time"`
  248. } `json:"setlinfo"`
  249. } `json:"output"`
  250. RefmsgTime string `json:"refmsg_time"`
  251. RespondTime string `json:"respond_time"`
  252. Signtype interface{} `json:"signtype"`
  253. WarnMsg interface{} `json:"warn_msg"`
  254. }
  255. type ResultSeven10265 struct {
  256. Cainfo string `json:"cainfo"`
  257. ErrMsg string `json:"err_msg"`
  258. InfRefmsgid string `json:"inf_refmsgid"`
  259. Infcode string `json:"infcode"`
  260. Output struct {
  261. Setldetail []interface{} `json:"setldetail"`
  262. Setlinfo struct {
  263. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  264. AcctPay float64 `json:"acct_pay"`
  265. ActPayDedc float64 `json:"act_pay_dedc"`
  266. Age float64 `json:"age"`
  267. Balc float64 `json:"balc"`
  268. Brdy string `json:"brdy"`
  269. Certno string `json:"certno"`
  270. ClrOptins string `json:"clr_optins"`
  271. ClrType string `json:"clr_type"`
  272. ClrWay string `json:"clr_way"`
  273. CvlservFlag string `json:"cvlserv_flag"`
  274. CvlservPay float64 `json:"cvlserv_pay"`
  275. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  276. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  277. Gend string `json:"gend"`
  278. HifesPay float64 `json:"hifes_pay"`
  279. HifmiPay float64 `json:"hifmi_pay"`
  280. HifpPay float64 `json:"hifp_pay"`
  281. HospPartAmt float64 `json:"hosp_part_amt"`
  282. InscpScpAmt float64 `json:"inscp_scp_amt"`
  283. Insutype string `json:"insutype"`
  284. MafPay float64 `json:"maf_pay"`
  285. MdtrtCertType string `json:"mdtrt_cert_type"`
  286. HifobPay float64 `json:"hifob_pay"`
  287. MdtrtID string `json:"mdtrt_id"`
  288. MedType string `json:"med_type"`
  289. MedfeeSumamt float64 `json:"medfee_sumamt"`
  290. MedinsSetlID string `json:"medins_setl_id"`
  291. Naty string `json:"naty"`
  292. OthPay float64 `json:"oth_pay"`
  293. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  294. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  295. PreselfpayAmt float64 `json:"preselfpay_amt"`
  296. PsnCashPay float64 `json:"psn_cash_pay"`
  297. PsnCertType string `json:"psn_cert_type"`
  298. PsnName string `json:"psn_name"`
  299. PsnNo string `json:"psn_no"`
  300. PsnPartAmt float64 `json:"psn_part_amt"`
  301. PsnType string `json:"psn_type"`
  302. SetlID string `json:"setl_id"`
  303. SetlTime string `json:"setl_time"`
  304. } `json:"setlinfo"`
  305. } `json:"output"`
  306. RefmsgTime string `json:"refmsg_time"`
  307. RespondTime string `json:"respond_time"`
  308. Signtype interface{} `json:"signtype"`
  309. WarnMsg interface{} `json:"warn_msg"`
  310. }
  311. type ResultSixteen struct {
  312. Cainfo string `json:"cainfo"`
  313. ErrMsg string `json:"err_msg"`
  314. InfRefmsgid string `json:"inf_refmsgid"`
  315. Infcode int64 `json:"infcode"`
  316. Output struct {
  317. Setldetail []interface{} `json:"setldetail"`
  318. Setlinfo struct {
  319. MdtrtID string `json:"mdtrt_id"`
  320. SetlID string `json:"setl_id"`
  321. ClrOptins string `json:"clr_optins"`
  322. SetlTime string `json:"setl_time"`
  323. MedfeeSumamt float64 `json:"medfee_sumamt"`
  324. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  325. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  326. PreselfpayAmt float64 `json:"preselfpay_amt"`
  327. InscpScpAmt float64 `json:"inscp_scp_amt"`
  328. ActPayDedc float64 `json:"act_pay_dedc"`
  329. HifpPay float64 `json:"hifp_pay"`
  330. PoolPropSe float64 `json:"pool_prop_selfpay"`
  331. Lfpay float64 `json:"selfpay"`
  332. CvlservPay float64 `json:"cvlserv_pay"`
  333. HifesPay float64 `json:"hifes_pay"`
  334. HifmiPay float64 `json:"hifmi_pay"`
  335. HifobPay float64 `json:"hifob_pay"`
  336. MafPay float64 `json:"maf_pay"`
  337. OthPay float64 `json:"oth_pay"`
  338. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  339. PsnPartAmt float64 `json:"psn_part_amt"`
  340. AcctPay float64 `json:"acct_pay"`
  341. Balc float64 `json:"balc"`
  342. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  343. HospPartAmt float64 `json:"hosp_part_amt"`
  344. MedinsSetlID string `json:"medins_setl_id"`
  345. PdnCashPay string `json:"pdn_cash_pay"`
  346. } `json:"setlinfo"`
  347. } `json:"output"`
  348. RefmsgTime string `json:"refmsg_time"`
  349. RespondTime string `json:"respond_time"`
  350. Signtype interface{} `json:"signtype"`
  351. WarnMsg interface{} `json:"warn_msg"`
  352. }
  353. type ResultSixteen10265 struct {
  354. Cainfo string `json:"cainfo"`
  355. ErrMsg string `json:"err_msg"`
  356. InfRefmsgid string `json:"inf_refmsgid"`
  357. Infcode string `json:"infcode"`
  358. Output struct {
  359. Setldetail []interface{} `json:"setldetail"`
  360. Setlinfo struct {
  361. MdtrtID string `json:"mdtrt_id"`
  362. SetlID string `json:"setl_id"`
  363. ClrOptins string `json:"clr_optins"`
  364. SetlTime string `json:"setl_time"`
  365. MedfeeSumamt float64 `json:"medfee_sumamt"`
  366. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  367. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  368. PreselfpayAmt float64 `json:"preselfpay_amt"`
  369. InscpScpAmt float64 `json:"inscp_scp_amt"`
  370. ActPayDedc float64 `json:"act_pay_dedc"`
  371. HifpPay float64 `json:"hifp_pay"`
  372. PoolPropSe float64 `json:"pool_prop_selfpay"`
  373. Lfpay float64 `json:"selfpay"`
  374. CvlservPay float64 `json:"cvlserv_pay"`
  375. HifesPay float64 `json:"hifes_pay"`
  376. HifmiPay float64 `json:"hifmi_pay"`
  377. HifobPay float64 `json:"hifob_pay"`
  378. MafPay float64 `json:"maf_pay"`
  379. OthPay float64 `json:"oth_pay"`
  380. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  381. PsnPartAmt float64 `json:"psn_part_amt"`
  382. AcctPay float64 `json:"acct_pay"`
  383. Balc float64 `json:"balc"`
  384. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  385. HospPartAmt float64 `json:"hosp_part_amt"`
  386. MedinsSetlID string `json:"medins_setl_id"`
  387. PdnCashPay string `json:"pdn_cash_pay"`
  388. } `json:"setlinfo"`
  389. } `json:"output"`
  390. RefmsgTime string `json:"refmsg_time"`
  391. RespondTime string `json:"respond_time"`
  392. Signtype interface{} `json:"signtype"`
  393. WarnMsg interface{} `json:"warn_msg"`
  394. }
  395. type Custom struct {
  396. DetItemFeeSumamt string
  397. Cut string
  398. FeedetlSn string
  399. Price string
  400. MedListCodg string
  401. Type int64
  402. AdviceId int64
  403. ProjectId int64
  404. ItemId int64
  405. }
  406. type ResultEmpty struct {
  407. Cainfo interface{} `json:"cainfo"`
  408. ErrMsg string `json:"err_msg"`
  409. InfRefmsgid string `json:"inf_refmsgid"`
  410. Infcode int64 `json:"infcode"`
  411. Output struct {
  412. } `json:"output"`
  413. RefmsgTime string `json:"refmsg_time"`
  414. RespondTime string `json:"respond_time"`
  415. Signtype interface{} `json:"signtype"`
  416. WarnMsg interface{} `json:"warn_msg"`
  417. }
  418. type ResultEmpty10265 struct {
  419. Cainfo interface{} `json:"cainfo"`
  420. ErrMsg string `json:"err_msg"`
  421. InfRefmsgid string `json:"inf_refmsgid"`
  422. Infcode string `json:"infcode"`
  423. Output struct {
  424. } `json:"output"`
  425. RefmsgTime string `json:"refmsg_time"`
  426. RespondTime string `json:"respond_time"`
  427. Signtype interface{} `json:"signtype"`
  428. WarnMsg interface{} `json:"warn_msg"`
  429. }
  430. type CustomResult struct {
  431. BasMednFlag string `json:"bas_medn_flag"`
  432. ChldMedcFlag string `json:"chld_medc_flag"`
  433. ChrgitmLv string `json:"chrgitm_lv"`
  434. Cnt float64 `json:"cnt"`
  435. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  436. DrtReimFlag string `json:"drt_reim_flag"`
  437. FeedetlSn string `json:"feedetl_sn"`
  438. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  439. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  440. InscpScpAmt float64 `json:"inscp_scp_amt"`
  441. ListSpItemFlag string `json:"list_sp_item_flag"`
  442. LmtUsedFlag string `json:"lmt_used_flag"`
  443. MedChrgitmType string `json:"med_chrgitm_type"`
  444. Memo string `json:"memo"`
  445. OverlmtAmt float64 `json:"overlmt_amt"`
  446. PreselfpayAmt float64 `json:"preselfpay_amt"`
  447. Pric float64 `json:"pric"`
  448. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  449. SelfpayProp float64 `json:"selfpay_prop"`
  450. }
  451. func ZHHisManagerApiRegistRouters() {
  452. beego.Router("/zh/api/inhopitalcheck/get", &ZHHisApiController{}, "get:GetZHInHospitalCheck")
  453. beego.Router("/zh/api/outhopitalcheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalCheck")
  454. beego.Router("/zh/api/uploadinfo/get", &ZHHisApiController{}, "get:GetUploadInfo")
  455. beego.Router("/zh/api/settle/get", &ZHHisApiController{}, "get:GetSettleInfo")
  456. beego.Router("/zh/api/inthopitaluncheck/get", &ZHHisApiController{}, "get:GetZHInHospitalUnCheck")
  457. beego.Router("/zh/api/outhopitaluncheck/get", &ZHHisApiController{}, "get:GetZHOutHospitalUnCheck")
  458. beego.Router("/zh/api/refund", &ZHHisApiController{}, "get:ZHRefund")
  459. beego.Router("/zh/api/refunddetail", &ZHHisApiController{}, "get:ZHRefundDetail")
  460. beego.Router("/zh/api/patient/info", &ZHHisApiController{}, "get:GetZHPatientInfo")
  461. }
  462. func (c *ZHHisApiController) GetZHPatientInfo() {
  463. id_card_no := c.GetString("id_card_no")
  464. admin_user_id, _ := c.GetInt64("admin_user_id")
  465. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  466. if patient.ID == 0 {
  467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  468. return
  469. }
  470. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  471. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  472. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  473. if config.IsOpen == 1 {
  474. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  475. var dat map[string]interface{}
  476. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  477. fmt.Println(dat)
  478. } else {
  479. fmt.Println(err)
  480. }
  481. userJSONBytes, _ := json.Marshal(dat)
  482. var res ResultTwo
  483. var resTwo10265 ResultTwo10265
  484. if miConfig.Code == "H15049901371" {
  485. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  486. utils.ErrorLog("解析失败:%v", err)
  487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  488. return
  489. }
  490. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  491. res.Infcode = Infcode
  492. res.ErrMsg = resTwo10265.ErrMsg
  493. res.Output = resTwo10265.Output
  494. res.InfRefmsgid = resTwo10265.InfRefmsgid
  495. res.RespondTime = resTwo10265.RespondTime
  496. res.WarnInfo = resTwo10265.WarnInfo
  497. } else {
  498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  499. utils.ErrorLog("解析失败:%v", err)
  500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  501. return
  502. }
  503. }
  504. var insutypes []string
  505. var insutype string
  506. var is390 int = 0
  507. var is310 int = 0
  508. for _, item := range res.Output.Iinfo {
  509. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  510. insutypes = append(insutypes, item.Insutype)
  511. }
  512. }
  513. if len(insutypes) == 1 {
  514. insutype = insutypes[0]
  515. } else {
  516. for _, i := range insutypes {
  517. if i == "390" {
  518. is390 = 1
  519. }
  520. if i == "310" {
  521. is310 = 1
  522. }
  523. }
  524. }
  525. if is390 == 1 {
  526. insutype = "390"
  527. }
  528. if is310 == 1 {
  529. insutype = "310"
  530. }
  531. if len(insutypes) == 0 {
  532. insutype = "310"
  533. }
  534. if res.Infcode != 0 {
  535. c.ServeSuccessJSON(map[string]interface{}{
  536. "failed_code": -10,
  537. "msg": res.ErrMsg,
  538. })
  539. } else {
  540. c.ServeSuccessJSON(map[string]interface{}{
  541. "failed_code": 0,
  542. "info": res,
  543. "insutype": insutype,
  544. })
  545. }
  546. }
  547. }
  548. func (c *ZHHisApiController) GetZHInHospitalCheck() {
  549. id, _ := c.GetInt64("id")
  550. record_time := c.GetString("record_time")
  551. name := c.GetString("name")
  552. phone := c.GetString("phone")
  553. id_card_type, _ := c.GetInt64("id_card_type")
  554. certificates, _ := c.GetInt64("certificates")
  555. id_card_no := c.GetString("id_card_no")
  556. doctor, _ := c.GetInt64("doctor")
  557. admin_user_id, _ := c.GetInt64("admin_user_id")
  558. department, _ := c.GetInt64("department")
  559. adm_bed, _ := c.GetInt64("adm_bed")
  560. diagnosis_ids := c.GetString("diagnosis")
  561. sick_type, _ := c.GetInt64("sick_type")
  562. start_time := c.GetString("start_time")
  563. balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
  564. social_type, _ := c.GetInt64("social_type")
  565. psn_type, _ := c.GetInt64("psn_type")
  566. //reg_type, _ := c.GetInt64("p_type")
  567. med_type, _ := c.GetInt64("med_type")
  568. diagnosis_ids_arr := strings.Split(diagnosis_ids, "-")
  569. timeLayout := "2006-01-02"
  570. loc, _ := time.LoadLocation("Local")
  571. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  572. if err != nil {
  573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  574. return
  575. }
  576. recordDateTime := theTime.Unix()
  577. adminInfo := c.GetAdminUserInfo()
  578. record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
  579. if record.ID != 0 {
  580. if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
  581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
  582. return
  583. }
  584. }
  585. var patient service.Patients
  586. if id == 0 {
  587. patient, _ = service.GetPatientByIDCard(id_card_no, adminInfo.CurrentOrgId)
  588. } else {
  589. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  590. }
  591. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  592. sickConfig, _ := service.FindSickById(sick_type)
  593. departmentInfo, _ := service.GetDepartMentDetail(department)
  594. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  595. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  596. result := service.ZHGdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", certificates, name)
  597. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  598. deviceNumber, _ := service.GetDeviceNumberByID(adm_bed, adminInfo.CurrentOrgId)
  599. var dat map[string]interface{}
  600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  601. fmt.Println(dat)
  602. } else {
  603. fmt.Println(err)
  604. }
  605. userJSONBytes, _ := json.Marshal(dat)
  606. //
  607. //var res2 ResultTwo
  608. //if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  609. // utils.ErrorLog("解析失败:%v", err)
  610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  611. // return
  612. //}
  613. var res2 ResultTwo
  614. var resTwo10265 ResultTwo10265
  615. if miConfig.Code == "H15049901371" {
  616. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  617. utils.ErrorLog("解析失败:%v", err)
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  619. return
  620. }
  621. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  622. res2.Infcode = Infcode
  623. res2.ErrMsg = resTwo10265.ErrMsg
  624. res2.Output = resTwo10265.Output
  625. res2.InfRefmsgid = resTwo10265.InfRefmsgid
  626. res2.RespondTime = resTwo10265.RespondTime
  627. res2.WarnInfo = resTwo10265.WarnInfo
  628. } else {
  629. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  630. utils.ErrorLog("解析失败:%v", err)
  631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  632. return
  633. }
  634. }
  635. //InsuplcAdmdvs = res2.Output.
  636. if social_type != 0 {
  637. } else {
  638. }
  639. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  640. infoStr := string(Iinfos)
  641. var rf []*ResultFive
  642. json.Unmarshal([]byte(infoStr), &rf)
  643. var insutypes []*ResultFive
  644. var insutype string
  645. var insuplc_admdvs string
  646. var is390 int = 0
  647. var is310 int = 0
  648. for _, item := range rf {
  649. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  650. insutypes = append(insutypes, item)
  651. }
  652. }
  653. if len(insutypes) == 1 {
  654. insutype = insutypes[0].Insutype
  655. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  656. } else {
  657. for _, i := range insutypes {
  658. if i.Insutype == "390" {
  659. is390 = 1
  660. }
  661. if i.Insutype == "310" {
  662. is310 = 1
  663. }
  664. }
  665. }
  666. if is390 == 1 {
  667. insutype = "390"
  668. }
  669. if is310 == 1 {
  670. insutype = "310"
  671. }
  672. if len(insutypes) == 0 {
  673. insutype = "310"
  674. }
  675. if len(insutypes) == 2 {
  676. insutype = strconv.FormatInt(social_type, 10)
  677. }
  678. for _, item := range rf {
  679. if item.Insutype == insutype {
  680. insuplc_admdvs = item.InsuplcAdmdvs
  681. }
  682. }
  683. if res2.Infcode == 0 {
  684. //var insutypes []string
  685. //
  686. //var insutype string
  687. //var is390 int = 0
  688. //var is310 int = 0
  689. //for _, item := range res2.Output.Iinfo {
  690. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  691. // insutypes = append(insutypes, item.Insutype)
  692. // }
  693. //}
  694. //if len(insutypes) == 1 {
  695. // insutype = insutypes[0]
  696. //} else {
  697. // for _, i := range insutypes {
  698. // if i == "390" {
  699. // is390 = 1
  700. // }
  701. //
  702. // if i == "310" {
  703. // is310 = 1
  704. // }
  705. // }
  706. //}
  707. //if is390 == 1 {
  708. // insutype = "390"
  709. //}
  710. //if is310 == 1 {
  711. // insutype = "310"
  712. //}
  713. //
  714. //if len(insutypes) == 0 {
  715. // insutype = "310"
  716. //}
  717. timestamp := time.Now().Unix()
  718. tempTime := time.Unix(timestamp, 0)
  719. timeFormat := tempTime.Format("20060102150405")
  720. chrgBchno := rand.Intn(100000) + 10000
  721. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
  722. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  723. var struct2401 service.Struct2401
  724. struct2401.PsnNo = res2.Output.Baseinfo.PsnNo
  725. struct2401.Insutype = insutype
  726. struct2401.MdtrtCertType = "02"
  727. struct2401.MdtrtCertNo = res2.Output.Baseinfo.Certno
  728. if miConfig.Code == "H15049901371" {
  729. if med_type == 14 {
  730. struct2401.MedType = "140104"
  731. } else if med_type == 11 {
  732. struct2401.MedType = "11"
  733. }
  734. } else {
  735. struct2401.MedType = strconv.FormatInt(int64(med_type), 10)
  736. }
  737. struct2401.IptNo = ipt_otp_no
  738. struct2401.AtddrNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  739. struct2401.ChfpdrName = doctorInfo.UserName
  740. struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
  741. struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  742. struct2401.AdmDeptName = departmentInfo.Name
  743. struct2401.AdmBed = deviceNumber.Number
  744. struct2401.AdmBed = "待定"
  745. struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
  746. struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
  747. struct2401.Begntime = start_time
  748. struct2401.DiseCodg = sickConfig.CountryCode
  749. struct2401.DiseName = sickConfig.ClassName
  750. var dises []service.DiseinfoStruct
  751. for index, item := range diagnosisConfig {
  752. var dise service.DiseinfoStruct
  753. dise.PsnNo = res2.Output.Baseinfo.PsnNo
  754. dise.DiagType = "1"
  755. if index == 0 {
  756. dise.MaindiagFlag = "1"
  757. } else {
  758. dise.MaindiagFlag = "2"
  759. }
  760. dise.DiagSrtNo = strconv.FormatInt(int64(index), 10)
  761. dise.DiseDorName = doctorInfo.UserName
  762. dise.DiagCode = item.CountryCode
  763. dise.DiagName = item.ClassName
  764. dise.DiagDept = departmentInfo.Name
  765. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  766. dise.DiagTime = timeFormatOne
  767. dises = append(dises, dise)
  768. }
  769. struct2401.Diseinfo = dises
  770. result := service.ZHGdyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs)
  771. var dat map[string]interface{}
  772. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  773. fmt.Println(dat)
  774. } else {
  775. fmt.Println(err)
  776. }
  777. userJSONBytes, _ := json.Marshal(dat)
  778. var res ResultThree
  779. var resThree10265 ResultThree10265
  780. if miConfig.Code == "H15049901371" {
  781. if err := json.Unmarshal(userJSONBytes, &resThree10265); err != nil {
  782. utils.ErrorLog("解析失败:%v", err)
  783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  784. return
  785. }
  786. Infcode, _ := strconv.ParseInt(resThree10265.Infcode, 10, 64)
  787. res.Infcode = Infcode
  788. res.ErrMsg = resThree10265.ErrMsg
  789. res.Output = resThree10265.Output
  790. res.InfRefmsgid = resThree10265.InfRefmsgid
  791. res.RespondTime = resThree10265.RespondTime
  792. } else {
  793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  794. utils.ErrorLog("解析失败:%v", err)
  795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  796. return
  797. }
  798. }
  799. if res.Infcode == 0 {
  800. result2 := service.Gdyb5301Two(res2.Output.Baseinfo.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  801. fmt.Println(result2)
  802. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  803. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  804. infoStr := string(Iinfos)
  805. idetinfoStr := string(Idetinfos)
  806. inHospital := &models.HisHospitalCheckRecord{
  807. PatientId: id,
  808. Name: name,
  809. MedicalTreatmentType: med_type,
  810. RecordDate: recordDateTime,
  811. IdCardNo: id_card_no,
  812. AdminUserId: admin_user_id,
  813. Departments: department,
  814. UserOrgId: adminInfo.CurrentOrgId,
  815. Status: 1,
  816. Ctime: time.Now().Unix(),
  817. Mtime: time.Now().Unix(),
  818. Number: res.Output.Result.MdtrtID,
  819. Doctor: doctor,
  820. PsnNo: res2.Output.Baseinfo.PsnNo,
  821. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  822. Certno: res2.Output.Baseinfo.Certno,
  823. PsnName: res2.Output.Baseinfo.PsnName,
  824. Gend: res2.Output.Baseinfo.Gend,
  825. Naty: res2.Output.Baseinfo.Naty,
  826. MedType: med_type,
  827. InsutypeType: insutype,
  828. Brdy: res2.Output.Baseinfo.Brdy,
  829. Iinfo: infoStr,
  830. Idetinfo: idetinfoStr,
  831. IptOtpNo: ipt_otp_no,
  832. AdmBed: adm_bed,
  833. IdCardType: id_card_type,
  834. Diagnosis: diagnosis_ids,
  835. SickType: sick_type,
  836. MdtrtCertType: "02",
  837. InHosptialTime: start_time,
  838. OutHosptialTime: "",
  839. InHospitalStatus: 1,
  840. Certificates: certificates,
  841. Phone: phone,
  842. BalanceAccountsType: balance_accounts_type,
  843. PsnType: psn_type,
  844. InsuplcAdmdvs: insuplc_admdvs,
  845. }
  846. service.CreateHospitalRecord(inHospital)
  847. c.ServeSuccessJSON(map[string]interface{}{
  848. "msg": "办理入院成功",
  849. "info": inHospital,
  850. })
  851. } else {
  852. c.ServeSuccessJSON(map[string]interface{}{
  853. "failed_code": -10,
  854. "msg": res.ErrMsg,
  855. })
  856. }
  857. } else {
  858. c.ServeSuccessJSON(map[string]interface{}{
  859. "failed_code": -10,
  860. "msg": res2.ErrMsg,
  861. })
  862. return
  863. }
  864. }
  865. func (this *ZHHisApiController) GetZHOutHospitalCheck() {
  866. id, _ := this.GetInt64("id")
  867. patient_id, _ := this.GetInt64("patient_id")
  868. admin_user_id, _ := this.GetInt64("admin_user_id")
  869. record_time := this.GetString("record_time")
  870. adminInfo := this.GetAdminUserInfo()
  871. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  872. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  873. record, _ := service.GetInHospitalRecord(id)
  874. if record.ID == 0 {
  875. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  876. return
  877. }
  878. timeLayout := "2006-01-02"
  879. loc, _ := time.LoadLocation("Local")
  880. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  881. if err != nil {
  882. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  883. return
  884. }
  885. recordDateTime := theTime.Unix()
  886. var patient service.Patients
  887. if patient_id == 0 {
  888. patient, _ = service.GetPatientByIDCard(record.IdCardNo, adminInfo.CurrentOrgId)
  889. } else {
  890. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  891. }
  892. fmt.Println(patient)
  893. diagnosis_ids_arr := strings.Split(record.Diagnosis, "-")
  894. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  895. departmentInfo, _ := service.GetDepartMentDetail(record.Departments)
  896. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, record.Doctor)
  897. //deviceNumber, _ := service.GetDeviceNumberByID(record.AdmBed, adminInfo.CurrentOrgId)
  898. sickConfig, _ := service.FindSickById(record.SickType)
  899. var struct2402 service.Struct2402
  900. timestamp := time.Now().Unix()
  901. tempTime := time.Unix(timestamp, 0)
  902. //timeFormat := tempTime.Format("20060102150405")
  903. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  904. struct2402.PsnNo = record.PsnNo
  905. struct2402.Insutype = record.InsutypeType
  906. struct2402.DscgWay = "1"
  907. struct2402.Endtime = timeFormatOne
  908. struct2402.DscgDeptName = departmentInfo.Number
  909. struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  910. struct2402.MdtrtId = record.Number
  911. var dises []service.Diseinfo2402Struct
  912. for index, item := range diagnosisConfig {
  913. var dise service.Diseinfo2402Struct
  914. dise.PsnNo = record.PsnNo
  915. dise.DiagType = "1"
  916. if index == 0 {
  917. dise.MaindiagFlag = "1"
  918. } else {
  919. dise.MaindiagFlag = "2"
  920. }
  921. dise.MdtrtId = record.Number
  922. dise.DiagSrtNo = strconv.FormatInt(int64(item.ID), 10)
  923. dise.DiseDorName = doctorInfo.UserName
  924. dise.DiagCode = item.CountryCode
  925. dise.DiagName = item.ClassName
  926. dise.DiagDept = departmentInfo.Name
  927. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  928. dise.DiagTime = timeFormatOne
  929. dises = append(dises, dise)
  930. }
  931. struct2402.Diseinfo = dises
  932. struct2402.DiseName = sickConfig.ClassName
  933. struct2402.DiseCode = sickConfig.CountryCode
  934. result := service.ZHGdyb2402(struct2402, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  935. var dat map[string]interface{}
  936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  937. fmt.Println(dat)
  938. } else {
  939. fmt.Println(err)
  940. }
  941. userJSONBytes, _ := json.Marshal(dat)
  942. var res ResultEmpty
  943. var resEmpty10265 ResultEmpty10265
  944. if miConfig.Code == "H15049901371" {
  945. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  946. utils.ErrorLog("解析失败:%v", err)
  947. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  948. return
  949. }
  950. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  951. res.Infcode = Infcode
  952. res.RespondTime = resEmpty10265.RespondTime
  953. res.ErrMsg = resEmpty10265.ErrMsg
  954. res.Output = resEmpty10265.Output
  955. res.WarnMsg = resEmpty10265.WarnMsg
  956. } else {
  957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  958. utils.ErrorLog("解析失败:%v", err)
  959. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  960. return
  961. }
  962. }
  963. if res.Infcode == 0 {
  964. record.OutHospitalStatus = 1
  965. record.OutHosptialTime = struct2402.Endtime
  966. record.OutWay = 1
  967. service.CreateHospitalRecord(&record)
  968. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  969. var total float64
  970. for _, item := range orders {
  971. total = total + item.DetItemFeeSumamt
  972. }
  973. order := &models.HisOrder{
  974. UserOrgId: adminInfo.CurrentOrgId,
  975. HisPatientId: record.ID,
  976. PatientId: record.PatientId,
  977. SettleAccountsDate: recordDateTime,
  978. Ctime: time.Now().Unix(),
  979. Mtime: time.Now().Unix(),
  980. Status: 1,
  981. Number: record.Number,
  982. Infcode: 0,
  983. WarnMsg: "",
  984. Cainfo: "",
  985. ErrMsg: "",
  986. RespondTime: "",
  987. InfRefmsgid: "",
  988. OrderStatus: 1,
  989. MdtrtId: record.Number,
  990. IsMedicineInsurance: 1,
  991. PType: 1,
  992. MedfeeSumamt: total,
  993. }
  994. err = service.CreateOrder(order)
  995. if err != nil {
  996. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  997. return
  998. }
  999. this.ServeSuccessJSON(map[string]interface{}{
  1000. "msg": "出院成功",
  1001. })
  1002. } else {
  1003. this.ServeSuccessJSON(map[string]interface{}{
  1004. "failed_code": -10,
  1005. "msg": res.ErrMsg,
  1006. })
  1007. }
  1008. }
  1009. func (c *ZHHisApiController) GetSettleInfo() {
  1010. order_id, _ := c.GetInt64("order_id")
  1011. patient_id, _ := c.GetInt64("patient_id")
  1012. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1013. admin_user_id, _ := c.GetInt64("admin_user_id")
  1014. pay_way, _ := c.GetInt64("pay_way")
  1015. pay_price, _ := c.GetFloat("pay_price")
  1016. pay_card_no := c.GetString("pay_card_no")
  1017. discount_price, _ := c.GetFloat("discount_price")
  1018. preferential_price, _ := c.GetFloat("preferential_price")
  1019. reality_price, _ := c.GetFloat("reality_price")
  1020. found_price, _ := c.GetFloat("found_price")
  1021. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1022. private_price, _ := c.GetFloat("private_price")
  1023. fapiao_code := c.GetString("fapiao_code")
  1024. fapiao_number := c.GetString("fapiao_number")
  1025. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1026. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1027. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1028. order, _ := service.GetHisOrderByID(order_id)
  1029. allTotal := fmt.Sprintf("%.4f", order.MedfeeSumamt)
  1030. var rf []*ResultFive
  1031. json.Unmarshal([]byte(record.Iinfo), &rf)
  1032. chrg_bchno := order.Number
  1033. cert_no := record.Certno
  1034. if record.ID == 0 {
  1035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1036. return
  1037. }
  1038. if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1040. return
  1041. }
  1042. if record.IdCardType == 1 {
  1043. } else {
  1044. cert_no = record.Certno
  1045. }
  1046. var result string
  1047. var src_resquest string
  1048. result, src_resquest = service.ZHGdyb2304(record.PsnNo, record.Number, chrg_bchno, cert_no, record.InsutypeType, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "0", record.IdCardType, 0, 0, 0, 0, record.Certificates)
  1049. var dat map[string]interface{}
  1050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1051. fmt.Println(dat)
  1052. } else {
  1053. fmt.Println(err)
  1054. }
  1055. userJSONBytes, _ := json.Marshal(dat)
  1056. var res ResultSeven
  1057. var resSeven10265 ResultSeven10265
  1058. if miConfig.Code == "H15049901371" {
  1059. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  1060. utils.ErrorLog("解析失败:%v", err)
  1061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1062. return
  1063. }
  1064. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  1065. res.Infcode = Infcode
  1066. res.InfRefmsgid = resSeven10265.InfRefmsgid
  1067. res.RespondTime = resSeven10265.RespondTime
  1068. res.ErrMsg = resSeven10265.ErrMsg
  1069. res.Output = resSeven10265.Output
  1070. res.WarnMsg = resSeven10265.WarnMsg
  1071. res.Cainfo = resSeven10265.Cainfo
  1072. } else {
  1073. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1074. utils.ErrorLog("解析失败:%v", err)
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1076. return
  1077. }
  1078. }
  1079. if res.Infcode != 0 {
  1080. errlog := &models.HisOrderError{
  1081. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1082. Ctime: time.Now().Unix(),
  1083. Mtime: time.Now().Unix(),
  1084. Number: chrg_bchno,
  1085. ErrMsg: res.ErrMsg,
  1086. Status: 1,
  1087. PatientId: patient_id,
  1088. RecordTime: time.Now().Unix(),
  1089. Stage: 6,
  1090. }
  1091. service.CreateErrMsgLog(errlog)
  1092. c.ServeSuccessJSON(map[string]interface{}{
  1093. "failed_code": -10,
  1094. "msg": res.ErrMsg,
  1095. })
  1096. return
  1097. } else {
  1098. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1099. order.OrderStatus = 2
  1100. order.DiscountPrice = discount_price
  1101. order.MedicalInsurancePrice = medical_insurance_price
  1102. order.FaPiaoNumber = fapiao_number
  1103. order.FaPiaoCode = fapiao_code
  1104. order.PayWay = pay_way
  1105. order.PayPrice = pay_price
  1106. order.PayCardNo = pay_card_no
  1107. order.PreferentialPrice = preferential_price
  1108. order.RealityPrice = reality_price
  1109. order.FoundPrice = found_price
  1110. order.PrivatePrice = private_price
  1111. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1112. order.SetlId = res.Output.Setlinfo.SetlID
  1113. order.PsnNo = res.Output.Setlinfo.PsnNo
  1114. order.PsnName = res.Output.Setlinfo.PsnName
  1115. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1116. order.Certno = res.Output.Setlinfo.Certno
  1117. order.Gend = res.Output.Setlinfo.Gend
  1118. order.Naty = res.Output.Setlinfo.Naty
  1119. order.Age = res.Output.Setlinfo.Age
  1120. order.Insutype = res.Output.Setlinfo.Insutype
  1121. order.PsnType = res.Output.Setlinfo.PsnType
  1122. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1123. order.SetlTime = res.Output.Setlinfo.SetlTime
  1124. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1125. if res.Output.Setlinfo.MedType == "140104" {
  1126. order.MedType = "14"
  1127. } else {
  1128. order.MedType = res.Output.Setlinfo.MedType
  1129. }
  1130. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1131. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1132. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1133. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1134. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1135. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1136. order.HifpPay = res.Output.Setlinfo.HifpPay
  1137. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1138. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1139. order.HifesPay = res.Output.Setlinfo.HifesPay
  1140. order.HifobPay = res.Output.Setlinfo.HifobPay
  1141. order.MafPay = res.Output.Setlinfo.MafPay
  1142. order.OthPay = res.Output.Setlinfo.OthPay
  1143. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1144. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1145. order.AcctPay = res.Output.Setlinfo.AcctPay
  1146. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1147. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1148. order.Balc = res.Output.Setlinfo.Balc
  1149. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1150. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1151. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1152. order.ClrWay = res.Output.Setlinfo.ClrWay
  1153. order.Creator = order.Creator
  1154. order.Modify = roles.AdminUserId
  1155. order.RequestLog = src_resquest
  1156. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1157. detailStr := string(setlDetail)
  1158. order.SetlDetail = detailStr
  1159. err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  1160. err = service.UpDateOrder(order)
  1161. if err == nil {
  1162. c.ServeSuccessJSON(map[string]interface{}{
  1163. "msg": "结算成功",
  1164. })
  1165. } else {
  1166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1167. return
  1168. }
  1169. }
  1170. }
  1171. func (c *ZHHisApiController) GetUploadInfo() {
  1172. id, _ := c.GetInt64("id")
  1173. record_time := c.GetString("record_time")
  1174. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1175. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1176. admin_user_id, _ := c.GetInt64("admin_user_id")
  1177. timeLayout := "2006-01-02"
  1178. loc, _ := time.LoadLocation("Local")
  1179. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1180. if err != nil {
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1182. return
  1183. }
  1184. recordDateTime := theTime.Unix()
  1185. adminUser := c.GetAdminUserInfo()
  1186. var prescriptions []*models.HisPrescription
  1187. data := make(map[string]interface{})
  1188. if settle_accounts_type == 1 { //日结
  1189. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1190. } else { //月结
  1191. start_time_str := c.GetString("start_time")
  1192. end_time_str := c.GetString("end_time")
  1193. timeLayout := "2006-01-02"
  1194. loc, _ := time.LoadLocation("Local")
  1195. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1196. if err != nil {
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1198. return
  1199. }
  1200. recordStartTime := theStartTime.Unix()
  1201. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1202. if err != nil {
  1203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1204. return
  1205. }
  1206. recordEndTime := theEndTime.Unix()
  1207. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1208. }
  1209. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1210. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1211. if record.ID == 0 {
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1213. return
  1214. }
  1215. //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1217. // return
  1218. //}
  1219. timestamp := time.Now().Unix()
  1220. tempTime := time.Unix(timestamp, 0)
  1221. timeFormat := tempTime.Format("20060102150405")
  1222. chrgBchno := rand.Intn(100000) + 10000
  1223. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
  1224. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1225. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1226. department, _ := service.GetDepartMentDetail(record.Departments)
  1227. strconv.FormatInt(record.PatientId, 10)
  1228. client := &http.Client{}
  1229. data["psn_no"] = record.PsnNo
  1230. data["mdtrt_id"] = record.Number
  1231. data["chrg_bchno"] = chrg_bchno
  1232. data["org_name"] = miConfig.OrgName
  1233. data["doctor"] = roles.UserName
  1234. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1235. data["dept"] = strconv.FormatInt(department.ID, 10)
  1236. data["fixmedins_code"] = miConfig.Code
  1237. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1238. data["dept_code"] = "15"
  1239. } else {
  1240. data["dept_code"] = department.Number
  1241. }
  1242. if miConfig.Code == "H15049901371" {
  1243. if record.MedType == 14 {
  1244. data["med_type"] = "140104"
  1245. } else if record.MedType == 11 {
  1246. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1247. }
  1248. } else {
  1249. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1250. }
  1251. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  1252. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1253. data["secret_key"] = miConfig.SecretKey
  1254. var ids []int64
  1255. fmt.Println(data)
  1256. for _, item := range prescriptions {
  1257. ids = append(ids, item.ID)
  1258. }
  1259. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1260. if config.IsOpen == 1 { //对接了医保,走医保流程
  1261. var pagesize int = 100
  1262. var start int = 1
  1263. var stop int
  1264. var pagecount int
  1265. var curpage int
  1266. var isSuccess bool = true
  1267. var customs []*models.NewCustom
  1268. for _, item := range prescriptions {
  1269. if item.Type == 1 { //药品
  1270. for _, subItem := range item.HisDoctorAdviceInfo {
  1271. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1272. //var randNum int
  1273. //randNum = rand.Intn(10000) + 1000
  1274. cus := &models.NewCustom{
  1275. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1276. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1277. FeedetlSn: subItem.FeedetlSn,
  1278. Price: fmt.Sprintf("%.4f", subItem.Price),
  1279. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1280. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  1281. }
  1282. customs = append(customs, cus)
  1283. }
  1284. }
  1285. }
  1286. if item.Type == 2 { //项目
  1287. for _, subItem := range item.HisPrescriptionProject {
  1288. //var randNum int
  1289. //randNum = rand.Intn(10000) + 1000
  1290. if subItem.Type == 2 {
  1291. if len(subItem.HisProject.MedicalCode) > 0 {
  1292. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1293. cus := &models.NewCustom{
  1294. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1295. Cut: fmt.Sprintf("%.4f", cnt),
  1296. FeedetlSn: subItem.FeedetlSn,
  1297. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1298. MedListCodg: subItem.HisProject.MedicalCode,
  1299. HospApprFlag: -1,
  1300. }
  1301. customs = append(customs, cus)
  1302. }
  1303. } else if subItem.Type == 3 {
  1304. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1305. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1306. cus := &models.NewCustom{
  1307. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1308. Cut: fmt.Sprintf("%.4f", cnt),
  1309. FeedetlSn: subItem.FeedetlSn,
  1310. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1311. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1312. HospApprFlag: -1,
  1313. }
  1314. customs = append(customs, cus)
  1315. }
  1316. }
  1317. }
  1318. }
  1319. for _, subItem := range item.HisAdditionalCharge {
  1320. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1321. cus := &models.NewCustom{
  1322. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1323. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1324. FeedetlSn: subItem.FeedetlSn,
  1325. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1326. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1327. HospApprFlag: -1,
  1328. }
  1329. customs = append(customs, cus)
  1330. }
  1331. }
  1332. }
  1333. //总页数,向上取整,注意除之前要先转换类型为float64
  1334. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1335. var ress []*ResultFour
  1336. for curpage = 1; curpage <= pagecount; curpage++ {
  1337. if curpage == 1 {
  1338. start = 1
  1339. } else {
  1340. start = (curpage-1)*pagesize + 1
  1341. }
  1342. stop = curpage * pagesize
  1343. if stop > len(customs) {
  1344. stop = len(customs)
  1345. }
  1346. data["pre"] = customs[start-1 : stop]
  1347. bytesData, _ := json.Marshal(data)
  1348. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/zh/five", bytes.NewReader(bytesData))
  1349. resp, _ := client.Do(req)
  1350. defer resp.Body.Close()
  1351. body, ioErr := ioutil.ReadAll(resp.Body)
  1352. if ioErr != nil {
  1353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1355. return
  1356. }
  1357. var respJSON map[string]interface{}
  1358. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1361. return
  1362. }
  1363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1364. userJSONBytes, _ := json.Marshal(respJSON)
  1365. var res ResultFour
  1366. var resFour10265 ResultFour10265
  1367. if miConfig.Code == "H15049901371" {
  1368. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  1369. utils.ErrorLog("解析失败:%v", err)
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1371. return
  1372. }
  1373. res.WarnMsg = resFour10265.WarnMsg
  1374. res.Output = resFour10265.Output
  1375. res.ErrMsg = resFour10265.ErrMsg
  1376. res.RespondTime = resFour10265.RespondTime
  1377. res.InfRefmsgid = resFour10265.InfRefmsgid
  1378. Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  1379. res.Infcode = Infcode
  1380. } else {
  1381. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1382. utils.ErrorLog("解析失败:%v", err)
  1383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1384. return
  1385. }
  1386. }
  1387. if res.Infcode == 0 {
  1388. ress = append(ress, &res)
  1389. } else {
  1390. isSuccess = false
  1391. errlog := &models.HisOrderError{
  1392. UserOrgId: adminUser.CurrentOrgId,
  1393. Ctime: time.Now().Unix(),
  1394. Mtime: time.Now().Unix(),
  1395. Number: chrg_bchno,
  1396. ErrMsg: "",
  1397. Status: 1,
  1398. PatientId: id,
  1399. RecordTime: recordDateTime,
  1400. Stage: 4,
  1401. }
  1402. service.CreateErrMsgLog(errlog)
  1403. c.ServeSuccessJSON(map[string]interface{}{
  1404. "failed_code": -10,
  1405. "msg": "上传明细错误,请联系his厂商",
  1406. })
  1407. return
  1408. }
  1409. }
  1410. if isSuccess == true {
  1411. if settle_accounts_type == 1 {
  1412. for _, subItem := range ress {
  1413. for _, item := range subItem.Output.Result {
  1414. temp := strings.Split(item.FeedetlSn, "-")
  1415. var advice_id int64 = 0
  1416. var project_id int64 = 0
  1417. var types int64 = 0
  1418. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1419. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1420. if temp[1] == "1" {
  1421. advice_id = id
  1422. project_id = 0
  1423. } else if temp[1] == "2" {
  1424. advice_id = 0
  1425. project_id = id
  1426. }
  1427. info := &models.HisOrderInfo{
  1428. OrderNumber: record.Number,
  1429. FeedetlSn: item.FeedetlSn,
  1430. UploadDate: time.Now().Unix(),
  1431. AdviceId: advice_id,
  1432. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1433. Cnt: item.Cnt,
  1434. Pric: float64(item.Pric),
  1435. PatientId: record.PatientId,
  1436. PricUplmtAmt: item.PricUplmtAmt,
  1437. SelfpayProp: item.SelfpayProp,
  1438. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1439. OverlmtAmt: item.OverlmtAmt,
  1440. PreselfpayAmt: item.PreselfpayAmt,
  1441. BasMednFlag: item.BasMednFlag,
  1442. MedChrgitmType: item.MedChrgitmType,
  1443. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1444. Status: 1,
  1445. Memo: item.Memo,
  1446. Mtime: time.Now().Unix(),
  1447. InscpScpAmt: item.InscpScpAmt,
  1448. DrtReimFlag: item.DrtReimFlag,
  1449. Ctime: time.Now().Unix(),
  1450. ListSpItemFlag: item.ListSpItemFlag,
  1451. ChldMedcFlag: item.ChldMedcFlag,
  1452. LmtUsedFlag: item.LmtUsedFlag,
  1453. ChrgitmLv: item.ChrgitmLv,
  1454. UserOrgId: adminUser.CurrentOrgId,
  1455. HisPatientId: record.ID,
  1456. OrderId: 0,
  1457. ProjectId: project_id,
  1458. Type: types,
  1459. SettleType: settle_accounts_type,
  1460. }
  1461. service.CreateOrderInfo(info)
  1462. }
  1463. }
  1464. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1465. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1466. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1467. if err == nil {
  1468. c.ServeSuccessJSON(map[string]interface{}{
  1469. "msg": "上传费用明细成功",
  1470. })
  1471. return
  1472. } else {
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1474. return
  1475. }
  1476. } else {
  1477. for _, subItem := range ress {
  1478. for _, item := range subItem.Output.Result {
  1479. temp := strings.Split(item.FeedetlSn, "-")
  1480. var advice_id int64 = 0
  1481. var project_id int64 = 0
  1482. var types int64 = 0
  1483. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1484. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1485. if temp[1] == "1" {
  1486. advice_id = id
  1487. project_id = 0
  1488. } else if temp[1] == "2" {
  1489. advice_id = 0
  1490. project_id = id
  1491. }
  1492. info := &models.HisOrderInfo{
  1493. OrderNumber: record.Number,
  1494. FeedetlSn: item.FeedetlSn,
  1495. UploadDate: time.Now().Unix(),
  1496. AdviceId: advice_id,
  1497. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1498. Cnt: item.Cnt,
  1499. Pric: float64(item.Pric),
  1500. PatientId: record.PatientId,
  1501. PricUplmtAmt: item.PricUplmtAmt,
  1502. SelfpayProp: item.SelfpayProp,
  1503. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1504. OverlmtAmt: item.OverlmtAmt,
  1505. PreselfpayAmt: item.PreselfpayAmt,
  1506. BasMednFlag: item.BasMednFlag,
  1507. MedChrgitmType: item.MedChrgitmType,
  1508. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1509. Status: 1,
  1510. Memo: item.Memo,
  1511. Mtime: time.Now().Unix(),
  1512. InscpScpAmt: item.InscpScpAmt,
  1513. DrtReimFlag: item.DrtReimFlag,
  1514. Ctime: time.Now().Unix(),
  1515. ListSpItemFlag: item.ListSpItemFlag,
  1516. ChldMedcFlag: item.ChldMedcFlag,
  1517. LmtUsedFlag: item.LmtUsedFlag,
  1518. ChrgitmLv: item.ChrgitmLv,
  1519. UserOrgId: adminUser.CurrentOrgId,
  1520. HisPatientId: record.ID,
  1521. ProjectId: project_id,
  1522. Type: types,
  1523. SettleType: settle_accounts_type,
  1524. }
  1525. service.CreateOrderInfo(info)
  1526. }
  1527. }
  1528. service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1529. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1530. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1531. c.ServeSuccessJSON(map[string]interface{}{
  1532. "msg": "上传费用明细成功",
  1533. })
  1534. }
  1535. }
  1536. }
  1537. }
  1538. func (c *ZHHisApiController) ZHRefund() {
  1539. order_id, _ := c.GetInt64("order_id")
  1540. admin_user_id, _ := c.GetInt64("admin_user_id")
  1541. adminUser := c.GetAdminUserInfo()
  1542. var order models.HisOrder
  1543. order, _ = service.GetHisOrderByID(order_id)
  1544. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1545. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1546. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1547. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1548. if config.IsOpen == 1 { //对接了医保,走医保流程
  1549. result, src_resquest := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1550. var dat map[string]interface{}
  1551. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1552. fmt.Println(dat)
  1553. } else {
  1554. fmt.Println(err)
  1555. }
  1556. userJSONBytes, _ := json.Marshal(dat)
  1557. var res ResultSixteen
  1558. var resSixteen ResultSixteen10265
  1559. if miConfig.Code == "H15049901371" {
  1560. if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  1561. utils.ErrorLog("解析失败:%v", err)
  1562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1563. return
  1564. }
  1565. res.Cainfo = resSixteen.Cainfo
  1566. res.WarnMsg = resSixteen.WarnMsg
  1567. res.Output = resSixteen.Output
  1568. res.ErrMsg = resSixteen.ErrMsg
  1569. res.RespondTime = resSixteen.RespondTime
  1570. Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  1571. res.Infcode = Infcode
  1572. } else {
  1573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1574. utils.ErrorLog("解析失败:%v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. }
  1579. if res.Infcode == 0 {
  1580. err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  1581. if err == nil {
  1582. c.ServeSuccessJSON(map[string]interface{}{
  1583. "msg": "退费成功",
  1584. })
  1585. } else {
  1586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1587. return
  1588. }
  1589. } else {
  1590. c.ServeSuccessJSON(map[string]interface{}{
  1591. "code": -10,
  1592. "msg": res.ErrMsg,
  1593. })
  1594. }
  1595. } else {
  1596. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  1597. if err == nil {
  1598. c.ServeSuccessJSON(map[string]interface{}{
  1599. "msg": "退费成功",
  1600. })
  1601. } else {
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1603. return
  1604. }
  1605. }
  1606. }
  1607. func (c *ZHHisApiController) ZHRefundDetail() {
  1608. patient_id, _ := c.GetInt64("patient_id")
  1609. his_patient_id, _ := c.GetInt64("his_patient_id")
  1610. record_time := c.GetString("record_time")
  1611. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1612. //order_id, _ := c.GetInt64("order_id")
  1613. admin_user_id, _ := c.GetInt64("admin_user_id")
  1614. timeLayout := "2006-01-02"
  1615. loc, _ := time.LoadLocation("Local")
  1616. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1617. if err != nil {
  1618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1619. return
  1620. }
  1621. recordDateTime := theTime.Unix()
  1622. adminUser := c.GetAdminUserInfo()
  1623. theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
  1624. if err != nil {
  1625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1626. return
  1627. }
  1628. recordDateTimeTwo := theTimeTwo.Unix()
  1629. //var prescriptions []*models.HisPrescription
  1630. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1631. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1632. if settle_accounts_type == 1 { //日结
  1633. infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime, recordDateTimeTwo)
  1634. record, _ := service.GetInHospitalRecord(his_patient_id)
  1635. var isSuccess bool = true
  1636. for _, item := range infos {
  1637. result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
  1638. var dat map[string]interface{}
  1639. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1640. fmt.Println(dat)
  1641. } else {
  1642. fmt.Println(err)
  1643. }
  1644. userJSONBytes, _ := json.Marshal(dat)
  1645. var res2 ResultEmpty
  1646. var resEmpty10265 ResultEmpty10265
  1647. if miConfig.Code == "H15049901371" {
  1648. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1649. utils.ErrorLog("解析失败:%v", err)
  1650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1651. return
  1652. }
  1653. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1654. res2.Infcode = Infcode
  1655. res2.RespondTime = resEmpty10265.RespondTime
  1656. res2.ErrMsg = resEmpty10265.ErrMsg
  1657. res2.Output = resEmpty10265.Output
  1658. res2.WarnMsg = resEmpty10265.WarnMsg
  1659. } else {
  1660. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1661. utils.ErrorLog("解析失败:%v", err)
  1662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1663. return
  1664. }
  1665. }
  1666. if res2.Infcode == -1 {
  1667. isSuccess = false
  1668. }
  1669. }
  1670. if isSuccess {
  1671. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
  1672. if err != nil {
  1673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1674. return
  1675. }
  1676. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1677. if err1 != nil {
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. return
  1680. }
  1681. c.ServeSuccessJSON(map[string]interface{}{
  1682. "msg": "撤销明细成功",
  1683. })
  1684. }
  1685. } else {
  1686. //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1687. //var order models.HisOrder
  1688. //order, _ = service.GetHisOrderByID(order_id)
  1689. //record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1690. record, _ := service.GetInHospitalRecord(his_patient_id)
  1691. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1692. if config.IsOpen == 1 { //对接了医保,走医保流程
  1693. result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  1694. var dat map[string]interface{}
  1695. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1696. fmt.Println(dat)
  1697. } else {
  1698. fmt.Println(err)
  1699. }
  1700. userJSONBytes, _ := json.Marshal(dat)
  1701. var res2 ResultEmpty
  1702. var resEmpty10265 ResultEmpty10265
  1703. if miConfig.Code == "H15049901371" {
  1704. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1705. utils.ErrorLog("解析失败:%v", err)
  1706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1707. return
  1708. }
  1709. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1710. res2.Infcode = Infcode
  1711. res2.RespondTime = resEmpty10265.RespondTime
  1712. res2.ErrMsg = resEmpty10265.ErrMsg
  1713. res2.Output = resEmpty10265.Output
  1714. res2.WarnMsg = resEmpty10265.WarnMsg
  1715. } else {
  1716. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1717. utils.ErrorLog("解析失败:%v", err)
  1718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1719. return
  1720. }
  1721. }
  1722. if res2.Infcode == 0 {
  1723. err := service.UpdataHospitalOrderStatus(record.Number, adminUser.CurrentOrgId)
  1724. if err == nil {
  1725. c.ServeSuccessJSON(map[string]interface{}{
  1726. "msg": "撤销明细成功",
  1727. })
  1728. } else {
  1729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1730. return
  1731. }
  1732. } else {
  1733. c.ServeSuccessJSON(map[string]interface{}{
  1734. "code": -10,
  1735. "msg": res2.ErrMsg,
  1736. })
  1737. }
  1738. }
  1739. }
  1740. }
  1741. func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
  1742. id, _ := this.GetInt64("id")
  1743. admin_user_id, _ := this.GetInt64("admin_user_id")
  1744. adminInfo := this.GetAdminUserInfo()
  1745. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1746. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1747. record, _ := service.GetInHospitalRecord(id)
  1748. if record.ID == 0 {
  1749. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1750. return
  1751. }
  1752. result := service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1753. var dat map[string]interface{}
  1754. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1755. fmt.Println(dat)
  1756. } else {
  1757. fmt.Println(err)
  1758. }
  1759. userJSONBytes, _ := json.Marshal(dat)
  1760. var res ResultEmpty
  1761. var resEmpty10265 ResultEmpty10265
  1762. if miConfig.Code == "H15049901371" {
  1763. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1764. utils.ErrorLog("解析失败:%v", err)
  1765. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1766. return
  1767. }
  1768. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1769. res.Infcode = Infcode
  1770. res.RespondTime = resEmpty10265.RespondTime
  1771. res.ErrMsg = resEmpty10265.ErrMsg
  1772. res.Output = resEmpty10265.Output
  1773. res.WarnMsg = resEmpty10265.WarnMsg
  1774. } else {
  1775. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. }
  1781. if res.Infcode == 0 {
  1782. record.OutHospitalStatus = 0
  1783. service.CreateHospitalRecord(&record)
  1784. service.UpdataOrderStatusByNumber(record.Number)
  1785. this.ServeSuccessJSON(map[string]interface{}{
  1786. "msg": "撤销出院成功",
  1787. })
  1788. } else {
  1789. this.ServeSuccessJSON(map[string]interface{}{
  1790. "failed_code": -10,
  1791. "msg": res.ErrMsg,
  1792. })
  1793. }
  1794. }
  1795. func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
  1796. id, _ := this.GetInt64("id")
  1797. admin_user_id, _ := this.GetInt64("admin_user_id")
  1798. adminInfo := this.GetAdminUserInfo()
  1799. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1800. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1801. record, _ := service.GetInHospitalRecord(id)
  1802. if record.ID == 0 {
  1803. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1804. return
  1805. }
  1806. result := service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1807. var dat map[string]interface{}
  1808. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1809. fmt.Println(dat)
  1810. } else {
  1811. fmt.Println(err)
  1812. }
  1813. userJSONBytes, _ := json.Marshal(dat)
  1814. var res ResultEmpty
  1815. var resEmpty10265 ResultEmpty10265
  1816. if miConfig.Code == "H15049901371" {
  1817. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1818. utils.ErrorLog("解析失败:%v", err)
  1819. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1820. return
  1821. }
  1822. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1823. res.Infcode = Infcode
  1824. res.RespondTime = resEmpty10265.RespondTime
  1825. res.ErrMsg = resEmpty10265.ErrMsg
  1826. res.Output = resEmpty10265.Output
  1827. res.WarnMsg = resEmpty10265.WarnMsg
  1828. } else {
  1829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1830. utils.ErrorLog("解析失败:%v", err)
  1831. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1832. return
  1833. }
  1834. }
  1835. if res.Infcode == 0 {
  1836. record.Status = 0
  1837. service.CreateHospitalRecord(&record)
  1838. this.ServeSuccessJSON(map[string]interface{}{
  1839. "msg": "撤销入院成功",
  1840. })
  1841. } else {
  1842. this.ServeSuccessJSON(map[string]interface{}{
  1843. "failed_code": -10,
  1844. "msg": res.ErrMsg,
  1845. })
  1846. }
  1847. }