zh_his_api_controller.go 79KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362
  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. var allTotal string
  1092. if record.OutHospitalStatus == 0 && order.ID == 0 {
  1093. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  1094. var total float64
  1095. for _, item := range orders {
  1096. total = total + item.DetItemFeeSumamt
  1097. }
  1098. allTotal = fmt.Sprintf("%.4f", total)
  1099. } else {
  1100. allTotal = fmt.Sprintf("%.4f", order.MedfeeSumamt)
  1101. }
  1102. 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)
  1103. //saveLog()
  1104. saveLog(result, src_resquest, "2304", "住院结算")
  1105. var dat map[string]interface{}
  1106. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1107. fmt.Println(dat)
  1108. } else {
  1109. fmt.Println(err)
  1110. }
  1111. userJSONBytes, _ := json.Marshal(dat)
  1112. var res ResultSeven
  1113. var resSeven10265 ResultSeven10265
  1114. if miConfig.Code == "H15049901371" {
  1115. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  1116. utils.ErrorLog("解析失败:%v", err)
  1117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1118. return
  1119. }
  1120. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  1121. res.Infcode = Infcode
  1122. res.InfRefmsgid = resSeven10265.InfRefmsgid
  1123. res.RespondTime = resSeven10265.RespondTime
  1124. res.ErrMsg = resSeven10265.ErrMsg
  1125. res.Output = resSeven10265.Output
  1126. res.WarnMsg = resSeven10265.WarnMsg
  1127. res.Cainfo = resSeven10265.Cainfo
  1128. } else {
  1129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1130. utils.ErrorLog("解析失败:%v", err)
  1131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1132. return
  1133. }
  1134. }
  1135. if res.Infcode != 0 {
  1136. errlog := &models.HisOrderError{
  1137. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1138. Ctime: time.Now().Unix(),
  1139. Mtime: time.Now().Unix(),
  1140. Number: chrg_bchno,
  1141. ErrMsg: res.ErrMsg,
  1142. Status: 1,
  1143. PatientId: patient_id,
  1144. RecordTime: time.Now().Unix(),
  1145. Stage: 6,
  1146. }
  1147. service.CreateErrMsgLog(errlog)
  1148. c.ServeSuccessJSON(map[string]interface{}{
  1149. "failed_code": -10,
  1150. "msg": res.ErrMsg,
  1151. })
  1152. return
  1153. } else {
  1154. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1155. order.OrderStatus = 2
  1156. order.DiscountPrice = discount_price
  1157. order.MedicalInsurancePrice = medical_insurance_price
  1158. order.FaPiaoNumber = fapiao_number
  1159. order.FaPiaoCode = fapiao_code
  1160. order.PayWay = pay_way
  1161. order.PayPrice = pay_price
  1162. order.PayCardNo = pay_card_no
  1163. order.PreferentialPrice = preferential_price
  1164. order.RealityPrice = reality_price
  1165. order.FoundPrice = found_price
  1166. order.PrivatePrice = private_price
  1167. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1168. order.SetlId = res.Output.Setlinfo.SetlID
  1169. order.PsnNo = res.Output.Setlinfo.PsnNo
  1170. order.PsnName = res.Output.Setlinfo.PsnName
  1171. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1172. order.Certno = res.Output.Setlinfo.Certno
  1173. order.Gend = res.Output.Setlinfo.Gend
  1174. order.Naty = res.Output.Setlinfo.Naty
  1175. order.Age = res.Output.Setlinfo.Age
  1176. order.Insutype = res.Output.Setlinfo.Insutype
  1177. order.PsnType = res.Output.Setlinfo.PsnType
  1178. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1179. order.SetlTime = res.Output.Setlinfo.SetlTime
  1180. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1181. if res.Output.Setlinfo.MedType == "140104" {
  1182. order.MedType = "14"
  1183. } else {
  1184. order.MedType = res.Output.Setlinfo.MedType
  1185. }
  1186. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1187. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1188. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1189. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1190. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1191. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1192. order.HifpPay = res.Output.Setlinfo.HifpPay
  1193. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1194. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1195. order.HifesPay = res.Output.Setlinfo.HifesPay
  1196. order.HifobPay = res.Output.Setlinfo.HifobPay
  1197. order.MafPay = res.Output.Setlinfo.MafPay
  1198. order.OthPay = res.Output.Setlinfo.OthPay
  1199. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1200. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1201. order.AcctPay = res.Output.Setlinfo.AcctPay
  1202. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1203. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1204. order.Balc = res.Output.Setlinfo.Balc
  1205. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1206. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1207. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1208. order.ClrWay = res.Output.Setlinfo.ClrWay
  1209. order.Creator = order.Creator
  1210. order.Modify = roles.AdminUserId
  1211. order.RequestLog = src_resquest
  1212. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1213. detailStr := string(setlDetail)
  1214. order.SetlDetail = detailStr
  1215. err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  1216. err = service.UpDateOrder(order)
  1217. if err == nil {
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "msg": "结算成功",
  1220. })
  1221. } else {
  1222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1223. return
  1224. }
  1225. }
  1226. }
  1227. func (c *ZHHisApiController) GetPreSettleInfo() {
  1228. order_id, _ := c.GetInt64("order_id")
  1229. patient_id, _ := c.GetInt64("patient_id")
  1230. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1231. admin_user_id, _ := c.GetInt64("admin_user_id")
  1232. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1233. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1234. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1235. order, _ := service.GetHisOrderByID(order_id)
  1236. var allTotal string
  1237. if record.OutHospitalStatus == 0 && order.ID == 0 {
  1238. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  1239. var total float64
  1240. for _, item := range orders {
  1241. total = total + item.DetItemFeeSumamt
  1242. }
  1243. allTotal = fmt.Sprintf("%.4f", total)
  1244. } else {
  1245. allTotal = fmt.Sprintf("%.4f", order.MedfeeSumamt)
  1246. }
  1247. var rf []*ResultFive
  1248. json.Unmarshal([]byte(record.Iinfo), &rf)
  1249. chrg_bchno := order.Number
  1250. cert_no := record.Certno
  1251. if record.ID == 0 {
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1253. return
  1254. }
  1255. //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1256. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1257. // return
  1258. //}
  1259. if record.IdCardType == 1 {
  1260. } else {
  1261. cert_no = record.Certno
  1262. }
  1263. var result string
  1264. var src_resquest string
  1265. 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)
  1266. saveLog(result, src_resquest, "2303", "住院预结算")
  1267. var dat map[string]interface{}
  1268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1269. fmt.Println(dat)
  1270. } else {
  1271. fmt.Println(err)
  1272. }
  1273. userJSONBytes, _ := json.Marshal(dat)
  1274. var res ResultSeven
  1275. var resSeven10265 ResultSeven10265
  1276. if miConfig.Code == "H15049901371" {
  1277. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  1278. utils.ErrorLog("解析失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. return
  1281. }
  1282. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  1283. res.Infcode = Infcode
  1284. res.InfRefmsgid = resSeven10265.InfRefmsgid
  1285. res.RespondTime = resSeven10265.RespondTime
  1286. res.ErrMsg = resSeven10265.ErrMsg
  1287. res.Output = resSeven10265.Output
  1288. res.WarnMsg = resSeven10265.WarnMsg
  1289. res.Cainfo = resSeven10265.Cainfo
  1290. } else {
  1291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1292. utils.ErrorLog("解析失败:%v", err)
  1293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1294. return
  1295. }
  1296. }
  1297. if res.Infcode != 0 {
  1298. errlog := &models.HisOrderError{
  1299. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1300. Ctime: time.Now().Unix(),
  1301. Mtime: time.Now().Unix(),
  1302. Number: chrg_bchno,
  1303. ErrMsg: res.ErrMsg,
  1304. Status: 1,
  1305. PatientId: patient_id,
  1306. RecordTime: time.Now().Unix(),
  1307. Stage: 6,
  1308. }
  1309. service.CreateErrMsgLog(errlog)
  1310. c.ServeSuccessJSON(map[string]interface{}{
  1311. "failed_code": -10,
  1312. "msg": res.ErrMsg,
  1313. })
  1314. return
  1315. } else {
  1316. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1317. order.OrderStatus = 1
  1318. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1319. order.SetlId = res.Output.Setlinfo.SetlID
  1320. order.PsnNo = res.Output.Setlinfo.PsnNo
  1321. order.PsnName = res.Output.Setlinfo.PsnName
  1322. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1323. order.Certno = res.Output.Setlinfo.Certno
  1324. order.Gend = res.Output.Setlinfo.Gend
  1325. order.Naty = res.Output.Setlinfo.Naty
  1326. order.Age = res.Output.Setlinfo.Age
  1327. order.Insutype = res.Output.Setlinfo.Insutype
  1328. order.PsnType = res.Output.Setlinfo.PsnType
  1329. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1330. order.SetlTime = res.Output.Setlinfo.SetlTime
  1331. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1332. if res.Output.Setlinfo.MedType == "140104" {
  1333. order.MedType = "14"
  1334. } else {
  1335. order.MedType = res.Output.Setlinfo.MedType
  1336. }
  1337. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1338. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1339. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1340. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1341. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1342. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1343. order.HifpPay = res.Output.Setlinfo.HifpPay
  1344. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1345. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1346. order.HifesPay = res.Output.Setlinfo.HifesPay
  1347. order.HifobPay = res.Output.Setlinfo.HifobPay
  1348. order.MafPay = res.Output.Setlinfo.MafPay
  1349. order.OthPay = res.Output.Setlinfo.OthPay
  1350. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1351. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1352. order.AcctPay = res.Output.Setlinfo.AcctPay
  1353. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1354. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1355. order.Balc = res.Output.Setlinfo.Balc
  1356. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1357. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1358. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1359. order.ClrWay = res.Output.Setlinfo.ClrWay
  1360. order.Creator = order.Creator
  1361. order.Modify = roles.AdminUserId
  1362. order.RequestLog = src_resquest
  1363. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1364. detailStr := string(setlDetail)
  1365. order.SetlDetail = detailStr
  1366. //err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  1367. if record.OutHospitalStatus == 1 && order.ID > 0 {
  1368. err := service.UpDateOrder(order)
  1369. if err == nil {
  1370. c.ServeSuccessJSON(map[string]interface{}{
  1371. "msg": "预结算成功",
  1372. "order_way": 1,
  1373. })
  1374. } else {
  1375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1376. return
  1377. }
  1378. } else if record.OutHospitalStatus == 0 && order.ID == 0 {
  1379. c.ServeSuccessJSON(map[string]interface{}{
  1380. "msg": "预结算成功",
  1381. "order": order,
  1382. "order_way": 2,
  1383. })
  1384. }
  1385. }
  1386. }
  1387. func (c *ZHHisApiController) GetUploadInfo() {
  1388. id, _ := c.GetInt64("id")
  1389. record_time := c.GetString("record_time")
  1390. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1391. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1392. admin_user_id, _ := c.GetInt64("admin_user_id")
  1393. timeLayout := "2006-01-02"
  1394. loc, _ := time.LoadLocation("Local")
  1395. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1396. if err != nil {
  1397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1398. return
  1399. }
  1400. recordDateTime := theTime.Unix()
  1401. adminUser := c.GetAdminUserInfo()
  1402. var prescriptions []*models.HisPrescription
  1403. data := make(map[string]interface{})
  1404. if settle_accounts_type == 1 { //日结
  1405. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1406. } else { //月结
  1407. start_time_str := c.GetString("start_time")
  1408. end_time_str := c.GetString("end_time")
  1409. timeLayout := "2006-01-02"
  1410. loc, _ := time.LoadLocation("Local")
  1411. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1412. if err != nil {
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1414. return
  1415. }
  1416. recordStartTime := theStartTime.Unix()
  1417. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1418. if err != nil {
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1420. return
  1421. }
  1422. recordEndTime := theEndTime.Unix()
  1423. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1424. }
  1425. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1426. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1427. if record.ID == 0 {
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1429. return
  1430. }
  1431. //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1432. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1433. // return
  1434. //}
  1435. timestamp := time.Now().Unix()
  1436. tempTime := time.Unix(timestamp, 0)
  1437. timeFormat := tempTime.Format("20060102150405")
  1438. chrgBchno := rand.Intn(100000) + 10000
  1439. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
  1440. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1441. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1442. department, _ := service.GetDepartMentDetail(record.Departments)
  1443. strconv.FormatInt(record.PatientId, 10)
  1444. //client := &http.Client{}
  1445. data["psn_no"] = record.PsnNo
  1446. data["mdtrt_id"] = record.Number
  1447. data["chrg_bchno"] = chrg_bchno
  1448. data["org_name"] = miConfig.OrgName
  1449. data["doctor"] = roles.UserName
  1450. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1451. data["dept"] = strconv.FormatInt(department.ID, 10)
  1452. data["fixmedins_code"] = miConfig.Code
  1453. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1454. data["dept_code"] = "15"
  1455. } else {
  1456. data["dept_code"] = department.Number
  1457. }
  1458. if miConfig.Code == "H15049901371" {
  1459. if record.MedType == 14 {
  1460. if record.InsutypeType == "390" {
  1461. data["med_type"] = "9933"
  1462. } else if record.InsutypeType == "310" {
  1463. data["med_type"] = "990502"
  1464. }
  1465. } else if record.MedType == 11 {
  1466. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1467. }
  1468. } else {
  1469. if record.MedType == 1112 {
  1470. data["med_type"] = strconv.FormatInt(11, 10)
  1471. } else {
  1472. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1473. }
  1474. }
  1475. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  1476. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1477. data["secret_key"] = miConfig.SecretKey
  1478. var ids []int64
  1479. fmt.Println(data)
  1480. for _, item := range prescriptions {
  1481. ids = append(ids, item.ID)
  1482. }
  1483. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1484. if config.IsOpen == 1 { //对接了医保,走医保流程
  1485. var pagesize int = 100
  1486. var start int = 1
  1487. var stop int
  1488. var pagecount int
  1489. var curpage int
  1490. var isSuccess bool = true
  1491. var customs []*models.NewCustom
  1492. for _, item := range prescriptions {
  1493. tm := time.Unix(item.PreTime, 0)
  1494. if item.Type == 1 { //药品
  1495. for _, subItem := range item.HisDoctorAdviceInfo {
  1496. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 && subItem.BaseDrugLib.IsUser != 1 {
  1497. //var randNum int
  1498. //randNum = rand.Intn(10000) + 1000
  1499. cus := &models.NewCustom{
  1500. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1501. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1502. FeedetlSn: subItem.FeedetlSn,
  1503. Price: fmt.Sprintf("%.4f", subItem.Price),
  1504. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1505. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  1506. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1507. }
  1508. customs = append(customs, cus)
  1509. }
  1510. }
  1511. }
  1512. if item.Type == 2 { //项目
  1513. for _, subItem := range item.HisPrescriptionProject {
  1514. //var randNum int
  1515. //randNum = rand.Intn(10000) + 1000
  1516. if subItem.Type == 2 {
  1517. if len(subItem.HisProject.MedicalCode) > 0 {
  1518. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1519. cus := &models.NewCustom{
  1520. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1521. Cut: fmt.Sprintf("%.4f", cnt),
  1522. FeedetlSn: subItem.FeedetlSn,
  1523. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1524. MedListCodg: subItem.HisProject.MedicalCode,
  1525. HospApprFlag: -1,
  1526. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1527. }
  1528. customs = append(customs, cus)
  1529. }
  1530. } else if subItem.Type == 3 {
  1531. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
  1532. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1533. cus := &models.NewCustom{
  1534. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1535. Cut: fmt.Sprintf("%.4f", cnt),
  1536. FeedetlSn: subItem.FeedetlSn,
  1537. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1538. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1539. HospApprFlag: -1,
  1540. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  1541. }
  1542. customs = append(customs, cus)
  1543. }
  1544. }
  1545. }
  1546. }
  1547. //for _, subItem := range item.HisAdditionalCharge {
  1548. // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1549. // cus := &models.NewCustom{
  1550. // DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1551. // Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1552. // FeedetlSn: subItem.FeedetlSn,
  1553. // Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1554. // MedListCodg: subItem.XtHisAddtionConfig.Code,
  1555. // HospApprFlag: -1,
  1556. //
  1557. // }
  1558. // customs = append(customs, cus)
  1559. // }
  1560. //}
  1561. }
  1562. //总页数,向上取整,注意除之前要先转换类型为float64
  1563. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1564. var ress []*ResultFour
  1565. for curpage = 1; curpage <= pagecount; curpage++ {
  1566. if curpage == 1 {
  1567. start = 1
  1568. } else {
  1569. start = (curpage-1)*pagesize + 1
  1570. }
  1571. stop = curpage * pagesize
  1572. if stop > len(customs) {
  1573. stop = len(customs)
  1574. }
  1575. //data["pre"] = customs[start-1 : stop]
  1576. //bytesData, _ := json.Marshal(data)
  1577. //req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/zh/five", bytes.NewReader(bytesData))
  1578. //resp, _ := client.Do(req)
  1579. //defer resp.Body.Close()
  1580. //body, ioErr := ioutil.ReadAll(resp.Body)
  1581. //if ioErr != nil {
  1582. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1584. // return
  1585. //}
  1586. 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))
  1587. saveLog(resultLog, requestLog, "2301", "上传明细")
  1588. var dat map[string]interface{}
  1589. if err := json.Unmarshal([]byte(resultLog), &dat); err == nil {
  1590. fmt.Println(dat)
  1591. } else {
  1592. fmt.Println(err)
  1593. }
  1594. userJSONBytes, _ := json.Marshal(dat)
  1595. var res ResultFour
  1596. var resFour10265 ResultFour10265
  1597. if miConfig.Code == "H15049901371" {
  1598. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  1599. utils.ErrorLog("解析失败:%v", err)
  1600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1601. return
  1602. }
  1603. res.WarnMsg = resFour10265.WarnMsg
  1604. res.Output = resFour10265.Output
  1605. res.ErrMsg = resFour10265.ErrMsg
  1606. res.RespondTime = resFour10265.RespondTime
  1607. res.InfRefmsgid = resFour10265.InfRefmsgid
  1608. Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  1609. res.Infcode = Infcode
  1610. } else {
  1611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1612. utils.ErrorLog("解析失败:%v", err)
  1613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1614. return
  1615. }
  1616. }
  1617. if res.Infcode == 0 {
  1618. ress = append(ress, &res)
  1619. } else {
  1620. isSuccess = false
  1621. errlog := &models.HisOrderError{
  1622. UserOrgId: adminUser.CurrentOrgId,
  1623. Ctime: time.Now().Unix(),
  1624. Mtime: time.Now().Unix(),
  1625. Number: chrg_bchno,
  1626. ErrMsg: "",
  1627. Status: 1,
  1628. PatientId: id,
  1629. RecordTime: recordDateTime,
  1630. Stage: 4,
  1631. }
  1632. service.CreateErrMsgLog(errlog)
  1633. c.ServeSuccessJSON(map[string]interface{}{
  1634. "failed_code": -10,
  1635. "msg": "上传明细错误,请联系his厂商",
  1636. })
  1637. return
  1638. }
  1639. }
  1640. if isSuccess == true {
  1641. if settle_accounts_type == 1 {
  1642. for _, subItem := range ress {
  1643. for _, item := range subItem.Output.Result {
  1644. temp := strings.Split(item.FeedetlSn, "-")
  1645. var advice_id int64 = 0
  1646. var project_id int64 = 0
  1647. var types int64 = 0
  1648. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1649. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1650. if temp[1] == "1" {
  1651. advice_id = id
  1652. project_id = 0
  1653. } else if temp[1] == "2" {
  1654. advice_id = 0
  1655. project_id = id
  1656. }
  1657. info := &models.HisOrderInfo{
  1658. OrderNumber: record.Number,
  1659. FeedetlSn: item.FeedetlSn,
  1660. UploadDate: recordDateTime,
  1661. AdviceId: advice_id,
  1662. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1663. Cnt: item.Cnt,
  1664. Pric: float64(item.Pric),
  1665. PatientId: record.PatientId,
  1666. PricUplmtAmt: item.PricUplmtAmt,
  1667. SelfpayProp: item.SelfpayProp,
  1668. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1669. OverlmtAmt: item.OverlmtAmt,
  1670. PreselfpayAmt: item.PreselfpayAmt,
  1671. BasMednFlag: item.BasMednFlag,
  1672. MedChrgitmType: item.MedChrgitmType,
  1673. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1674. Status: 1,
  1675. Memo: item.Memo,
  1676. Mtime: time.Now().Unix(),
  1677. InscpScpAmt: item.InscpScpAmt,
  1678. DrtReimFlag: item.DrtReimFlag,
  1679. Ctime: time.Now().Unix(),
  1680. ListSpItemFlag: item.ListSpItemFlag,
  1681. ChldMedcFlag: item.ChldMedcFlag,
  1682. LmtUsedFlag: item.LmtUsedFlag,
  1683. ChrgitmLv: item.ChrgitmLv,
  1684. UserOrgId: adminUser.CurrentOrgId,
  1685. HisPatientId: record.ID,
  1686. OrderId: 0,
  1687. ProjectId: project_id,
  1688. Type: types,
  1689. SettleType: settle_accounts_type,
  1690. }
  1691. service.CreateOrderInfo(info)
  1692. }
  1693. }
  1694. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1695. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1696. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1697. if err == nil {
  1698. c.ServeSuccessJSON(map[string]interface{}{
  1699. "msg": "上传费用明细成功",
  1700. })
  1701. return
  1702. } else {
  1703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1704. return
  1705. }
  1706. } else {
  1707. for _, subItem := range ress {
  1708. for _, item := range subItem.Output.Result {
  1709. temp := strings.Split(item.FeedetlSn, "-")
  1710. var advice_id int64 = 0
  1711. var project_id int64 = 0
  1712. var types int64 = 0
  1713. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1714. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1715. if temp[1] == "1" {
  1716. advice_id = id
  1717. project_id = 0
  1718. } else if temp[1] == "2" {
  1719. advice_id = 0
  1720. project_id = id
  1721. }
  1722. info := &models.HisOrderInfo{
  1723. OrderNumber: record.Number,
  1724. FeedetlSn: item.FeedetlSn,
  1725. UploadDate: time.Now().Unix(),
  1726. AdviceId: advice_id,
  1727. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1728. Cnt: item.Cnt,
  1729. Pric: float64(item.Pric),
  1730. PatientId: record.PatientId,
  1731. PricUplmtAmt: item.PricUplmtAmt,
  1732. SelfpayProp: item.SelfpayProp,
  1733. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1734. OverlmtAmt: item.OverlmtAmt,
  1735. PreselfpayAmt: item.PreselfpayAmt,
  1736. BasMednFlag: item.BasMednFlag,
  1737. MedChrgitmType: item.MedChrgitmType,
  1738. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1739. Status: 1,
  1740. Memo: item.Memo,
  1741. Mtime: time.Now().Unix(),
  1742. InscpScpAmt: item.InscpScpAmt,
  1743. DrtReimFlag: item.DrtReimFlag,
  1744. Ctime: time.Now().Unix(),
  1745. ListSpItemFlag: item.ListSpItemFlag,
  1746. ChldMedcFlag: item.ChldMedcFlag,
  1747. LmtUsedFlag: item.LmtUsedFlag,
  1748. ChrgitmLv: item.ChrgitmLv,
  1749. UserOrgId: adminUser.CurrentOrgId,
  1750. HisPatientId: record.ID,
  1751. ProjectId: project_id,
  1752. Type: types,
  1753. SettleType: settle_accounts_type,
  1754. }
  1755. service.CreateOrderInfo(info)
  1756. }
  1757. }
  1758. service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1759. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1760. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1761. c.ServeSuccessJSON(map[string]interface{}{
  1762. "msg": "上传费用明细成功",
  1763. })
  1764. }
  1765. }
  1766. }
  1767. }
  1768. func (c *ZHHisApiController) ZHRefund() {
  1769. order_id, _ := c.GetInt64("order_id")
  1770. admin_user_id, _ := c.GetInt64("admin_user_id")
  1771. adminUser := c.GetAdminUserInfo()
  1772. var order models.HisOrder
  1773. order, _ = service.GetHisOrderByID(order_id)
  1774. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1775. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1776. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1777. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1778. if config.IsOpen == 1 { //对接了医保,走医保流程
  1779. result, src_resquest := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1780. saveLog(result, src_resquest, "2305", "退费")
  1781. var dat map[string]interface{}
  1782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1783. fmt.Println(dat)
  1784. } else {
  1785. fmt.Println(err)
  1786. }
  1787. userJSONBytes, _ := json.Marshal(dat)
  1788. var res ResultSixteen
  1789. var resSixteen ResultSixteen10265
  1790. if miConfig.Code == "H15049901371" {
  1791. if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  1792. utils.ErrorLog("解析失败:%v", err)
  1793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1794. return
  1795. }
  1796. res.Cainfo = resSixteen.Cainfo
  1797. res.WarnMsg = resSixteen.WarnMsg
  1798. res.Output = resSixteen.Output
  1799. res.ErrMsg = resSixteen.ErrMsg
  1800. res.RespondTime = resSixteen.RespondTime
  1801. Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  1802. res.Infcode = Infcode
  1803. } else {
  1804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1805. utils.ErrorLog("解析失败:%v", err)
  1806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1807. return
  1808. }
  1809. }
  1810. if res.Infcode == 0 {
  1811. err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  1812. record.OutHospitalStatus = 0
  1813. service.CreateHospitalRecord(&record)
  1814. service.UpdataOrderStatusByNumber(record.Number)
  1815. if err == nil {
  1816. c.ServeSuccessJSON(map[string]interface{}{
  1817. "msg": "退费成功",
  1818. })
  1819. } else {
  1820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1821. return
  1822. }
  1823. } else {
  1824. c.ServeSuccessJSON(map[string]interface{}{
  1825. "code": -10,
  1826. "msg": res.ErrMsg,
  1827. })
  1828. }
  1829. } else {
  1830. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  1831. if err == nil {
  1832. c.ServeSuccessJSON(map[string]interface{}{
  1833. "msg": "退费成功",
  1834. })
  1835. } else {
  1836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1837. return
  1838. }
  1839. }
  1840. }
  1841. func (c *ZHHisApiController) ZHRefundDetail() {
  1842. patient_id, _ := c.GetInt64("patient_id")
  1843. his_patient_id, _ := c.GetInt64("his_patient_id")
  1844. record_time := c.GetString("record_time")
  1845. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1846. //order_id, _ := c.GetInt64("order_id")
  1847. admin_user_id, _ := c.GetInt64("admin_user_id")
  1848. timeLayout := "2006-01-02"
  1849. loc, _ := time.LoadLocation("Local")
  1850. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1851. if err != nil {
  1852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1853. return
  1854. }
  1855. recordDateTime := theTime.Unix()
  1856. adminUser := c.GetAdminUserInfo()
  1857. theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
  1858. if err != nil {
  1859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1860. return
  1861. }
  1862. recordDateTimeTwo := theTimeTwo.Unix()
  1863. //var prescriptions []*models.HisPrescription
  1864. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1865. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1866. if settle_accounts_type == 1 { //日结
  1867. record, _ := service.GetInHospitalRecord(his_patient_id)
  1868. infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime, recordDateTimeTwo, record.Number)
  1869. var isSuccess bool = true
  1870. for _, item := range infos {
  1871. result, requestLog := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
  1872. saveLog(result, requestLog, "2302", "日结退明细")
  1873. var dat map[string]interface{}
  1874. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1875. fmt.Println(dat)
  1876. } else {
  1877. fmt.Println(err)
  1878. }
  1879. userJSONBytes, _ := json.Marshal(dat)
  1880. var res2 ResultEmpty
  1881. var resEmpty10265 ResultEmpty10265
  1882. if miConfig.Code == "H15049901371" {
  1883. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1884. utils.ErrorLog("解析失败:%v", err)
  1885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1886. return
  1887. }
  1888. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1889. res2.Infcode = Infcode
  1890. res2.RespondTime = resEmpty10265.RespondTime
  1891. res2.ErrMsg = resEmpty10265.ErrMsg
  1892. res2.Output = resEmpty10265.Output
  1893. res2.WarnMsg = resEmpty10265.WarnMsg
  1894. } else {
  1895. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1896. utils.ErrorLog("解析失败:%v", err)
  1897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1898. return
  1899. }
  1900. }
  1901. if res2.Infcode == -1 {
  1902. isSuccess = false
  1903. }
  1904. }
  1905. if isSuccess {
  1906. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
  1907. if err != nil {
  1908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1909. return
  1910. }
  1911. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1912. if err1 != nil {
  1913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1914. return
  1915. }
  1916. c.ServeSuccessJSON(map[string]interface{}{
  1917. "msg": "撤销明细成功",
  1918. })
  1919. }
  1920. } else {
  1921. //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1922. //var order models.HisOrder
  1923. //order, _ = service.GetHisOrderByID(order_id)
  1924. //record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1925. record, _ := service.GetInHospitalRecord(his_patient_id)
  1926. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1927. if config.IsOpen == 1 { //对接了医保,走医保流程
  1928. result, requestLog := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  1929. //saveLog(result,requestLog,)
  1930. saveLog(result, requestLog, "2302", "月结退明细")
  1931. var dat map[string]interface{}
  1932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1933. fmt.Println(dat)
  1934. } else {
  1935. fmt.Println(err)
  1936. }
  1937. userJSONBytes, _ := json.Marshal(dat)
  1938. var res2 ResultEmpty
  1939. var resEmpty10265 ResultEmpty10265
  1940. if miConfig.Code == "H15049901371" {
  1941. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1942. utils.ErrorLog("解析失败:%v", err)
  1943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1944. return
  1945. }
  1946. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1947. res2.Infcode = Infcode
  1948. res2.RespondTime = resEmpty10265.RespondTime
  1949. res2.ErrMsg = resEmpty10265.ErrMsg
  1950. res2.Output = resEmpty10265.Output
  1951. res2.WarnMsg = resEmpty10265.WarnMsg
  1952. } else {
  1953. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1954. utils.ErrorLog("解析失败:%v", err)
  1955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1956. return
  1957. }
  1958. }
  1959. if res2.Infcode == 0 {
  1960. err := service.UpdataHospitalOrderStatus(record.Number, adminUser.CurrentOrgId)
  1961. if err == nil {
  1962. c.ServeSuccessJSON(map[string]interface{}{
  1963. "msg": "撤销明细成功",
  1964. })
  1965. } else {
  1966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1967. return
  1968. }
  1969. } else {
  1970. c.ServeSuccessJSON(map[string]interface{}{
  1971. "code": -10,
  1972. "msg": res2.ErrMsg,
  1973. })
  1974. }
  1975. }
  1976. }
  1977. }
  1978. func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
  1979. id, _ := this.GetInt64("id")
  1980. admin_user_id, _ := this.GetInt64("admin_user_id")
  1981. adminInfo := this.GetAdminUserInfo()
  1982. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1983. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1984. record, _ := service.GetInHospitalRecord(id)
  1985. if record.ID == 0 {
  1986. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1987. return
  1988. }
  1989. result, requestLog := service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1990. saveLog(result, requestLog, "2405", "出院登记撤销")
  1991. var dat map[string]interface{}
  1992. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1993. fmt.Println(dat)
  1994. } else {
  1995. fmt.Println(err)
  1996. }
  1997. userJSONBytes, _ := json.Marshal(dat)
  1998. var res ResultEmpty
  1999. var resEmpty10265 ResultEmpty10265
  2000. if miConfig.Code == "H15049901371" {
  2001. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  2002. utils.ErrorLog("解析失败:%v", err)
  2003. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2004. return
  2005. }
  2006. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2007. res.Infcode = Infcode
  2008. res.RespondTime = resEmpty10265.RespondTime
  2009. res.ErrMsg = resEmpty10265.ErrMsg
  2010. res.Output = resEmpty10265.Output
  2011. res.WarnMsg = resEmpty10265.WarnMsg
  2012. } else {
  2013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2014. utils.ErrorLog("解析失败:%v", err)
  2015. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2016. return
  2017. }
  2018. }
  2019. if res.Infcode == 0 {
  2020. record.OutHospitalStatus = 0
  2021. service.CreateHospitalRecord(&record)
  2022. service.UpdataOrderStatusByNumber(record.Number)
  2023. this.ServeSuccessJSON(map[string]interface{}{
  2024. "msg": "撤销出院成功",
  2025. })
  2026. } else {
  2027. this.ServeSuccessJSON(map[string]interface{}{
  2028. "failed_code": -10,
  2029. "msg": res.ErrMsg,
  2030. })
  2031. }
  2032. }
  2033. func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
  2034. id, _ := this.GetInt64("id")
  2035. admin_user_id, _ := this.GetInt64("admin_user_id")
  2036. adminInfo := this.GetAdminUserInfo()
  2037. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2038. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  2039. record, _ := service.GetInHospitalRecord(id)
  2040. if record.ID == 0 {
  2041. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  2042. return
  2043. }
  2044. result, requestLog := service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  2045. //saveLog()
  2046. saveLog(result, requestLog, "2404", "入院登记撤销")
  2047. var dat map[string]interface{}
  2048. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2049. fmt.Println(dat)
  2050. } else {
  2051. fmt.Println(err)
  2052. }
  2053. userJSONBytes, _ := json.Marshal(dat)
  2054. var res ResultEmpty
  2055. var resEmpty10265 ResultEmpty10265
  2056. if miConfig.Code == "H15049901371" {
  2057. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  2058. utils.ErrorLog("解析失败:%v", err)
  2059. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2060. return
  2061. }
  2062. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  2063. res.Infcode = Infcode
  2064. res.RespondTime = resEmpty10265.RespondTime
  2065. res.ErrMsg = resEmpty10265.ErrMsg
  2066. res.Output = resEmpty10265.Output
  2067. res.WarnMsg = resEmpty10265.WarnMsg
  2068. } else {
  2069. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2070. utils.ErrorLog("解析失败:%v", err)
  2071. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2072. return
  2073. }
  2074. }
  2075. if res.Infcode == 0 {
  2076. record.Status = 0
  2077. service.CreateHospitalRecord(&record)
  2078. this.ServeSuccessJSON(map[string]interface{}{
  2079. "msg": "撤销入院成功",
  2080. })
  2081. } else {
  2082. this.ServeSuccessJSON(map[string]interface{}{
  2083. "failed_code": -10,
  2084. "msg": res.ErrMsg,
  2085. })
  2086. }
  2087. }
  2088. func saveLog(result string, request string, infno string, desc string) {
  2089. org_id, _ := beego.AppConfig.Int64("org_id")
  2090. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  2091. dir := miConfig.OrgName + "日志"
  2092. utils.Mkdir(dir)
  2093. month := time.Unix(1557042972, 0).Format("1")
  2094. year := time.Now().Format("2006")
  2095. month = time.Now().Format("01")
  2096. day := time.Now().Format("02")
  2097. hour := time.Now().Format("15")
  2098. min := time.Now().Format("04")
  2099. sec := time.Now().Format("05")
  2100. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  2101. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  2102. file_name := file + ".txt"
  2103. file_path := miConfig.OrgName + "日志" + "/" + file_name
  2104. exist, _ := utils.PathExists(file_path)
  2105. if exist { //存在
  2106. fmt.Println("存在")
  2107. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  2108. if err != nil {
  2109. fmt.Println("read fail")
  2110. }
  2111. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  2112. n, _ := f.Seek(0, 2)
  2113. _, err = f.WriteAt([]byte(content), n)
  2114. } else { //不存在
  2115. fmt.Println("文件不存在,创建文件")
  2116. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  2117. defer f.Close()
  2118. if err != nil {
  2119. } else {
  2120. _, err = f.Write([]byte("记录日志"))
  2121. }
  2122. }
  2123. }
  2124. type Charset string
  2125. const (
  2126. UTF8 = Charset("UTF-8")
  2127. GB18030 = Charset("GB18030")
  2128. )
  2129. func ConvertToString(src string, srcCode string, tagCode string) string {
  2130. srcCoder := mahonia.NewDecoder(srcCode)
  2131. srcResult := srcCoder.ConvertString(src)
  2132. tagCoder := mahonia.NewDecoder(tagCode)
  2133. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  2134. result := string(cdata)
  2135. return result
  2136. }