zh_his_api_controller.go 78KB

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