zh_his_api_controller.go 67KB

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