zh_his_api_controller.go 68KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046
  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. if insutype == "390" {
  731. struct2401.MedType = "9933"
  732. } else if insutype == "310" {
  733. struct2401.MedType = "990502"
  734. }
  735. } else if med_type == 11 {
  736. struct2401.MedType = "11"
  737. }
  738. } else {
  739. struct2401.MedType = strconv.FormatInt(int64(med_type), 10)
  740. }
  741. struct2401.IptNo = ipt_otp_no
  742. struct2401.AtddrNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  743. struct2401.ChfpdrName = doctorInfo.UserName
  744. struct2401.AdmDiagDscr = diagnosisConfig[0].ClassName
  745. struct2401.AdmDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  746. struct2401.AdmDeptName = departmentInfo.Name
  747. struct2401.AdmBed = deviceNumber.Number
  748. struct2401.AdmBed = "待定"
  749. struct2401.DscgMaindiagName = diagnosisConfig[0].ClassName
  750. struct2401.DscgMaindiagCode = diagnosisConfig[0].CountryCode
  751. struct2401.Begntime = start_time
  752. struct2401.DiseCodg = sickConfig.CountryCode
  753. struct2401.DiseName = sickConfig.ClassName
  754. var dises []service.DiseinfoStruct
  755. for index, item := range diagnosisConfig {
  756. var dise service.DiseinfoStruct
  757. dise.PsnNo = res2.Output.Baseinfo.PsnNo
  758. dise.DiagType = "1"
  759. if index == 0 {
  760. dise.MaindiagFlag = "1"
  761. } else {
  762. dise.MaindiagFlag = "2"
  763. }
  764. dise.DiagSrtNo = strconv.FormatInt(int64(index), 10)
  765. dise.DiseDorName = doctorInfo.UserName
  766. dise.DiagCode = item.CountryCode
  767. dise.DiagName = item.ClassName
  768. dise.DiagDept = departmentInfo.Name
  769. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  770. dise.DiagTime = timeFormatOne
  771. dises = append(dises, dise)
  772. }
  773. struct2401.Diseinfo = dises
  774. result := service.ZHGdyb2401(struct2401, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, insuplc_admdvs, miConfig.MdtrtareaAdmvs)
  775. var dat map[string]interface{}
  776. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  777. fmt.Println(dat)
  778. } else {
  779. fmt.Println(err)
  780. }
  781. userJSONBytes, _ := json.Marshal(dat)
  782. var res ResultThree
  783. var resThree10265 ResultThree10265
  784. if miConfig.Code == "H15049901371" {
  785. if err := json.Unmarshal(userJSONBytes, &resThree10265); err != nil {
  786. utils.ErrorLog("解析失败:%v", err)
  787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  788. return
  789. }
  790. Infcode, _ := strconv.ParseInt(resThree10265.Infcode, 10, 64)
  791. res.Infcode = Infcode
  792. res.ErrMsg = resThree10265.ErrMsg
  793. res.Output = resThree10265.Output
  794. res.InfRefmsgid = resThree10265.InfRefmsgid
  795. res.RespondTime = resThree10265.RespondTime
  796. } else {
  797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  798. utils.ErrorLog("解析失败:%v", err)
  799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  800. return
  801. }
  802. }
  803. if res.Infcode == 0 {
  804. result2 := service.Gdyb5301Two(res2.Output.Baseinfo.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  805. fmt.Println(result2)
  806. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  807. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  808. infoStr := string(Iinfos)
  809. idetinfoStr := string(Idetinfos)
  810. inHospital := &models.HisHospitalCheckRecord{
  811. PatientId: id,
  812. Name: name,
  813. MedicalTreatmentType: med_type,
  814. RecordDate: recordDateTime,
  815. IdCardNo: id_card_no,
  816. AdminUserId: admin_user_id,
  817. Departments: department,
  818. UserOrgId: adminInfo.CurrentOrgId,
  819. Status: 1,
  820. Ctime: time.Now().Unix(),
  821. Mtime: time.Now().Unix(),
  822. Number: res.Output.Result.MdtrtID,
  823. Doctor: doctor,
  824. PsnNo: res2.Output.Baseinfo.PsnNo,
  825. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  826. Certno: res2.Output.Baseinfo.Certno,
  827. PsnName: res2.Output.Baseinfo.PsnName,
  828. Gend: res2.Output.Baseinfo.Gend,
  829. Naty: res2.Output.Baseinfo.Naty,
  830. MedType: med_type,
  831. InsutypeType: insutype,
  832. Brdy: res2.Output.Baseinfo.Brdy,
  833. Iinfo: infoStr,
  834. Idetinfo: idetinfoStr,
  835. IptOtpNo: ipt_otp_no,
  836. AdmBed: adm_bed,
  837. IdCardType: id_card_type,
  838. Diagnosis: diagnosis_ids,
  839. SickType: sick_type,
  840. MdtrtCertType: "02",
  841. InHosptialTime: start_time,
  842. OutHosptialTime: "",
  843. InHospitalStatus: 1,
  844. Certificates: certificates,
  845. Phone: phone,
  846. BalanceAccountsType: balance_accounts_type,
  847. PsnType: psn_type,
  848. InsuplcAdmdvs: insuplc_admdvs,
  849. }
  850. service.CreateHospitalRecord(inHospital)
  851. c.ServeSuccessJSON(map[string]interface{}{
  852. "msg": "办理入院成功",
  853. "info": inHospital,
  854. })
  855. } else {
  856. c.ServeSuccessJSON(map[string]interface{}{
  857. "failed_code": -10,
  858. "msg": res.ErrMsg,
  859. })
  860. }
  861. } else {
  862. c.ServeSuccessJSON(map[string]interface{}{
  863. "failed_code": -10,
  864. "msg": res2.ErrMsg,
  865. })
  866. return
  867. }
  868. }
  869. func (this *ZHHisApiController) GetZHOutHospitalCheck() {
  870. id, _ := this.GetInt64("id")
  871. patient_id, _ := this.GetInt64("patient_id")
  872. admin_user_id, _ := this.GetInt64("admin_user_id")
  873. record_time := this.GetString("record_time")
  874. adminInfo := this.GetAdminUserInfo()
  875. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  876. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  877. record, _ := service.GetInHospitalRecord(id)
  878. if record.ID == 0 {
  879. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  880. return
  881. }
  882. timeLayout := "2006-01-02"
  883. loc, _ := time.LoadLocation("Local")
  884. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  885. if err != nil {
  886. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  887. return
  888. }
  889. recordDateTime := theTime.Unix()
  890. var patient service.Patients
  891. if patient_id == 0 {
  892. patient, _ = service.GetPatientByIDCard(record.IdCardNo, adminInfo.CurrentOrgId)
  893. } else {
  894. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  895. }
  896. fmt.Println(patient)
  897. diagnosis_ids_arr := strings.Split(record.Diagnosis, "-")
  898. diagnosisConfig, _ := service.FindDiagnoseByIds(diagnosis_ids_arr)
  899. departmentInfo, _ := service.GetDepartMentDetail(record.Departments)
  900. doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, record.Doctor)
  901. //deviceNumber, _ := service.GetDeviceNumberByID(record.AdmBed, adminInfo.CurrentOrgId)
  902. sickConfig, _ := service.FindSickById(record.SickType)
  903. var struct2402 service.Struct2402
  904. timestamp := time.Now().Unix()
  905. tempTime := time.Unix(timestamp, 0)
  906. //timeFormat := tempTime.Format("20060102150405")
  907. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  908. struct2402.PsnNo = record.PsnNo
  909. struct2402.Insutype = record.InsutypeType
  910. struct2402.DscgWay = "1"
  911. struct2402.Endtime = timeFormatOne
  912. struct2402.DscgDeptName = departmentInfo.Number
  913. struct2402.DscgDeptCodg = strconv.FormatInt(int64(departmentInfo.ID), 10)
  914. struct2402.MdtrtId = record.Number
  915. var dises []service.Diseinfo2402Struct
  916. for index, item := range diagnosisConfig {
  917. var dise service.Diseinfo2402Struct
  918. dise.PsnNo = record.PsnNo
  919. dise.DiagType = "1"
  920. if index == 0 {
  921. dise.MaindiagFlag = "1"
  922. } else {
  923. dise.MaindiagFlag = "2"
  924. }
  925. dise.MdtrtId = record.Number
  926. dise.DiagSrtNo = strconv.FormatInt(int64(item.ID), 10)
  927. dise.DiseDorName = doctorInfo.UserName
  928. dise.DiagCode = item.CountryCode
  929. dise.DiagName = item.ClassName
  930. dise.DiagDept = departmentInfo.Name
  931. dise.DiseDorNo = strconv.FormatInt(int64(doctorInfo.AdminUserId), 10)
  932. dise.DiagTime = timeFormatOne
  933. dises = append(dises, dise)
  934. }
  935. struct2402.Diseinfo = dises
  936. struct2402.DiseName = sickConfig.ClassName
  937. struct2402.DiseCode = sickConfig.CountryCode
  938. result := service.ZHGdyb2402(struct2402, miConfig.OrgName, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  939. var dat map[string]interface{}
  940. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  941. fmt.Println(dat)
  942. } else {
  943. fmt.Println(err)
  944. }
  945. userJSONBytes, _ := json.Marshal(dat)
  946. var res ResultEmpty
  947. var resEmpty10265 ResultEmpty10265
  948. if miConfig.Code == "H15049901371" {
  949. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  950. utils.ErrorLog("解析失败:%v", err)
  951. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  952. return
  953. }
  954. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  955. res.Infcode = Infcode
  956. res.RespondTime = resEmpty10265.RespondTime
  957. res.ErrMsg = resEmpty10265.ErrMsg
  958. res.Output = resEmpty10265.Output
  959. res.WarnMsg = resEmpty10265.WarnMsg
  960. } else {
  961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  962. utils.ErrorLog("解析失败:%v", err)
  963. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  964. return
  965. }
  966. }
  967. if res.Infcode == 0 {
  968. record.OutHospitalStatus = 1
  969. record.OutHosptialTime = struct2402.Endtime
  970. record.OutWay = 1
  971. service.CreateHospitalRecord(&record)
  972. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  973. var total float64
  974. for _, item := range orders {
  975. total = total + item.DetItemFeeSumamt
  976. }
  977. order := &models.HisOrder{
  978. UserOrgId: adminInfo.CurrentOrgId,
  979. HisPatientId: record.ID,
  980. PatientId: record.PatientId,
  981. SettleAccountsDate: recordDateTime,
  982. Ctime: time.Now().Unix(),
  983. Mtime: time.Now().Unix(),
  984. Status: 1,
  985. Number: record.Number,
  986. Infcode: 0,
  987. WarnMsg: "",
  988. Cainfo: "",
  989. ErrMsg: "",
  990. RespondTime: "",
  991. InfRefmsgid: "",
  992. OrderStatus: 1,
  993. MdtrtId: record.Number,
  994. IsMedicineInsurance: 1,
  995. PType: 1,
  996. MedfeeSumamt: total,
  997. }
  998. err = service.CreateOrder(order)
  999. if err != nil {
  1000. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1001. return
  1002. }
  1003. this.ServeSuccessJSON(map[string]interface{}{
  1004. "msg": "出院成功",
  1005. })
  1006. } else {
  1007. this.ServeSuccessJSON(map[string]interface{}{
  1008. "failed_code": -10,
  1009. "msg": res.ErrMsg,
  1010. })
  1011. }
  1012. }
  1013. func (c *ZHHisApiController) GetSettleInfo() {
  1014. order_id, _ := c.GetInt64("order_id")
  1015. patient_id, _ := c.GetInt64("patient_id")
  1016. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1017. admin_user_id, _ := c.GetInt64("admin_user_id")
  1018. pay_way, _ := c.GetInt64("pay_way")
  1019. pay_price, _ := c.GetFloat("pay_price")
  1020. pay_card_no := c.GetString("pay_card_no")
  1021. discount_price, _ := c.GetFloat("discount_price")
  1022. preferential_price, _ := c.GetFloat("preferential_price")
  1023. reality_price, _ := c.GetFloat("reality_price")
  1024. found_price, _ := c.GetFloat("found_price")
  1025. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1026. private_price, _ := c.GetFloat("private_price")
  1027. fapiao_code := c.GetString("fapiao_code")
  1028. fapiao_number := c.GetString("fapiao_number")
  1029. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1030. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1031. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1032. order, _ := service.GetHisOrderByID(order_id)
  1033. allTotal := fmt.Sprintf("%.4f", order.MedfeeSumamt)
  1034. var rf []*ResultFive
  1035. json.Unmarshal([]byte(record.Iinfo), &rf)
  1036. chrg_bchno := order.Number
  1037. cert_no := record.Certno
  1038. if record.ID == 0 {
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1040. return
  1041. }
  1042. if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1044. return
  1045. }
  1046. if record.IdCardType == 1 {
  1047. } else {
  1048. cert_no = record.Certno
  1049. }
  1050. var result string
  1051. var src_resquest string
  1052. 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)
  1053. var dat map[string]interface{}
  1054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1055. fmt.Println(dat)
  1056. } else {
  1057. fmt.Println(err)
  1058. }
  1059. userJSONBytes, _ := json.Marshal(dat)
  1060. var res ResultSeven
  1061. var resSeven10265 ResultSeven10265
  1062. if miConfig.Code == "H15049901371" {
  1063. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  1064. utils.ErrorLog("解析失败:%v", err)
  1065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1066. return
  1067. }
  1068. Infcode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  1069. res.Infcode = Infcode
  1070. res.InfRefmsgid = resSeven10265.InfRefmsgid
  1071. res.RespondTime = resSeven10265.RespondTime
  1072. res.ErrMsg = resSeven10265.ErrMsg
  1073. res.Output = resSeven10265.Output
  1074. res.WarnMsg = resSeven10265.WarnMsg
  1075. res.Cainfo = resSeven10265.Cainfo
  1076. } else {
  1077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1078. utils.ErrorLog("解析失败:%v", err)
  1079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1080. return
  1081. }
  1082. }
  1083. if res.Infcode != 0 {
  1084. errlog := &models.HisOrderError{
  1085. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1086. Ctime: time.Now().Unix(),
  1087. Mtime: time.Now().Unix(),
  1088. Number: chrg_bchno,
  1089. ErrMsg: res.ErrMsg,
  1090. Status: 1,
  1091. PatientId: patient_id,
  1092. RecordTime: time.Now().Unix(),
  1093. Stage: 6,
  1094. }
  1095. service.CreateErrMsgLog(errlog)
  1096. c.ServeSuccessJSON(map[string]interface{}{
  1097. "failed_code": -10,
  1098. "msg": res.ErrMsg,
  1099. })
  1100. return
  1101. } else {
  1102. //order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  1103. order.OrderStatus = 2
  1104. order.DiscountPrice = discount_price
  1105. order.MedicalInsurancePrice = medical_insurance_price
  1106. order.FaPiaoNumber = fapiao_number
  1107. order.FaPiaoCode = fapiao_code
  1108. order.PayWay = pay_way
  1109. order.PayPrice = pay_price
  1110. order.PayCardNo = pay_card_no
  1111. order.PreferentialPrice = preferential_price
  1112. order.RealityPrice = reality_price
  1113. order.FoundPrice = found_price
  1114. order.PrivatePrice = private_price
  1115. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  1116. order.SetlId = res.Output.Setlinfo.SetlID
  1117. order.PsnNo = res.Output.Setlinfo.PsnNo
  1118. order.PsnName = res.Output.Setlinfo.PsnName
  1119. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  1120. order.Certno = res.Output.Setlinfo.Certno
  1121. order.Gend = res.Output.Setlinfo.Gend
  1122. order.Naty = res.Output.Setlinfo.Naty
  1123. order.Age = res.Output.Setlinfo.Age
  1124. order.Insutype = res.Output.Setlinfo.Insutype
  1125. order.PsnType = res.Output.Setlinfo.PsnType
  1126. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  1127. order.SetlTime = res.Output.Setlinfo.SetlTime
  1128. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  1129. if res.Output.Setlinfo.MedType == "140104" {
  1130. order.MedType = "14"
  1131. } else {
  1132. order.MedType = res.Output.Setlinfo.MedType
  1133. }
  1134. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  1135. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  1136. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  1137. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  1138. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  1139. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  1140. order.HifpPay = res.Output.Setlinfo.HifpPay
  1141. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  1142. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  1143. order.HifesPay = res.Output.Setlinfo.HifesPay
  1144. order.HifobPay = res.Output.Setlinfo.HifobPay
  1145. order.MafPay = res.Output.Setlinfo.MafPay
  1146. order.OthPay = res.Output.Setlinfo.OthPay
  1147. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  1148. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  1149. order.AcctPay = res.Output.Setlinfo.AcctPay
  1150. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  1151. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  1152. order.Balc = res.Output.Setlinfo.Balc
  1153. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  1154. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  1155. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  1156. order.ClrWay = res.Output.Setlinfo.ClrWay
  1157. order.Creator = order.Creator
  1158. order.Modify = roles.AdminUserId
  1159. order.RequestLog = src_resquest
  1160. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  1161. detailStr := string(setlDetail)
  1162. order.SetlDetail = detailStr
  1163. err := service.UpdataOrderStatusTwo(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId)
  1164. err = service.UpDateOrder(order)
  1165. if err == nil {
  1166. c.ServeSuccessJSON(map[string]interface{}{
  1167. "msg": "结算成功",
  1168. })
  1169. } else {
  1170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  1171. return
  1172. }
  1173. }
  1174. }
  1175. func (c *ZHHisApiController) GetUploadInfo() {
  1176. id, _ := c.GetInt64("id")
  1177. record_time := c.GetString("record_time")
  1178. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  1179. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1180. admin_user_id, _ := c.GetInt64("admin_user_id")
  1181. timeLayout := "2006-01-02"
  1182. loc, _ := time.LoadLocation("Local")
  1183. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1184. if err != nil {
  1185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1186. return
  1187. }
  1188. recordDateTime := theTime.Unix()
  1189. adminUser := c.GetAdminUserInfo()
  1190. var prescriptions []*models.HisPrescription
  1191. data := make(map[string]interface{})
  1192. if settle_accounts_type == 1 { //日结
  1193. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  1194. } else { //月结
  1195. start_time_str := c.GetString("start_time")
  1196. end_time_str := c.GetString("end_time")
  1197. timeLayout := "2006-01-02"
  1198. loc, _ := time.LoadLocation("Local")
  1199. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1200. if err != nil {
  1201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1202. return
  1203. }
  1204. recordStartTime := theStartTime.Unix()
  1205. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1206. if err != nil {
  1207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1208. return
  1209. }
  1210. recordEndTime := theEndTime.Unix()
  1211. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  1212. }
  1213. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1214. record, _ := service.GetInHospitalRecord(in_hospital_id)
  1215. if record.ID == 0 {
  1216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1217. return
  1218. }
  1219. //if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  1220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  1221. // return
  1222. //}
  1223. timestamp := time.Now().Unix()
  1224. tempTime := time.Unix(timestamp, 0)
  1225. timeFormat := tempTime.Format("20060102150405")
  1226. chrgBchno := rand.Intn(100000) + 10000
  1227. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(record.PatientId, 10)
  1228. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1229. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1230. department, _ := service.GetDepartMentDetail(record.Departments)
  1231. strconv.FormatInt(record.PatientId, 10)
  1232. client := &http.Client{}
  1233. data["psn_no"] = record.PsnNo
  1234. data["mdtrt_id"] = record.Number
  1235. data["chrg_bchno"] = chrg_bchno
  1236. data["org_name"] = miConfig.OrgName
  1237. data["doctor"] = roles.UserName
  1238. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1239. data["dept"] = strconv.FormatInt(department.ID, 10)
  1240. data["fixmedins_code"] = miConfig.Code
  1241. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1242. data["dept_code"] = "15"
  1243. } else {
  1244. data["dept_code"] = department.Number
  1245. }
  1246. if miConfig.Code == "H15049901371" {
  1247. if record.MedType == 14 {
  1248. if record.InsutypeType == "390" {
  1249. data["med_type"] = "9933"
  1250. } else if record.InsutypeType == "310" {
  1251. data["med_type"] = "990502"
  1252. }
  1253. } else if record.MedType == 11 {
  1254. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1255. }
  1256. } else {
  1257. if record.MedType == 1112 {
  1258. data["med_type"] = strconv.FormatInt(11, 10)
  1259. } else {
  1260. data["med_type"] = strconv.FormatInt(record.MedType, 10)
  1261. }
  1262. }
  1263. data["insuplc_admdvs"] = record.InsuplcAdmdvs
  1264. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1265. data["secret_key"] = miConfig.SecretKey
  1266. var ids []int64
  1267. fmt.Println(data)
  1268. for _, item := range prescriptions {
  1269. ids = append(ids, item.ID)
  1270. }
  1271. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1272. if config.IsOpen == 1 { //对接了医保,走医保流程
  1273. var pagesize int = 100
  1274. var start int = 1
  1275. var stop int
  1276. var pagecount int
  1277. var curpage int
  1278. var isSuccess bool = true
  1279. var customs []*models.NewCustom
  1280. for _, item := range prescriptions {
  1281. if item.Type == 1 { //药品
  1282. for _, subItem := range item.HisDoctorAdviceInfo {
  1283. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1284. //var randNum int
  1285. //randNum = rand.Intn(10000) + 1000
  1286. cus := &models.NewCustom{
  1287. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*subItem.PrescribingNumber),
  1288. Cut: fmt.Sprintf("%.4f", subItem.PrescribingNumber),
  1289. FeedetlSn: subItem.FeedetlSn,
  1290. Price: fmt.Sprintf("%.4f", subItem.Price),
  1291. MedListCodg: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1292. HospApprFlag: subItem.BaseDrugLib.HospApprFlag,
  1293. }
  1294. customs = append(customs, cus)
  1295. }
  1296. }
  1297. }
  1298. if item.Type == 2 { //项目
  1299. for _, subItem := range item.HisPrescriptionProject {
  1300. //var randNum int
  1301. //randNum = rand.Intn(10000) + 1000
  1302. if subItem.Type == 2 {
  1303. if len(subItem.HisProject.MedicalCode) > 0 {
  1304. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1305. cus := &models.NewCustom{
  1306. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1307. Cut: fmt.Sprintf("%.4f", cnt),
  1308. FeedetlSn: subItem.FeedetlSn,
  1309. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1310. MedListCodg: subItem.HisProject.MedicalCode,
  1311. HospApprFlag: -1,
  1312. }
  1313. customs = append(customs, cus)
  1314. }
  1315. } else if subItem.Type == 3 {
  1316. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  1317. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1318. cus := &models.NewCustom{
  1319. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*cnt),
  1320. Cut: fmt.Sprintf("%.4f", cnt),
  1321. FeedetlSn: subItem.FeedetlSn,
  1322. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1323. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  1324. HospApprFlag: -1,
  1325. }
  1326. customs = append(customs, cus)
  1327. }
  1328. }
  1329. }
  1330. }
  1331. for _, subItem := range item.HisAdditionalCharge {
  1332. if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1333. cus := &models.NewCustom{
  1334. DetItemFeeSumamt: fmt.Sprintf("%.4f", subItem.Price*float64(subItem.Count)),
  1335. Cut: fmt.Sprintf("%.4f", float64(subItem.Count)),
  1336. FeedetlSn: subItem.FeedetlSn,
  1337. Price: fmt.Sprintf("%.4f", float64(subItem.Price)),
  1338. MedListCodg: subItem.XtHisAddtionConfig.Code,
  1339. HospApprFlag: -1,
  1340. }
  1341. customs = append(customs, cus)
  1342. }
  1343. }
  1344. }
  1345. //总页数,向上取整,注意除之前要先转换类型为float64
  1346. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1347. var ress []*ResultFour
  1348. for curpage = 1; curpage <= pagecount; curpage++ {
  1349. if curpage == 1 {
  1350. start = 1
  1351. } else {
  1352. start = (curpage-1)*pagesize + 1
  1353. }
  1354. stop = curpage * pagesize
  1355. if stop > len(customs) {
  1356. stop = len(customs)
  1357. }
  1358. data["pre"] = customs[start-1 : stop]
  1359. bytesData, _ := json.Marshal(data)
  1360. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/zh/five", bytes.NewReader(bytesData))
  1361. resp, _ := client.Do(req)
  1362. defer resp.Body.Close()
  1363. body, ioErr := ioutil.ReadAll(resp.Body)
  1364. if ioErr != nil {
  1365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1367. return
  1368. }
  1369. var respJSON map[string]interface{}
  1370. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1373. return
  1374. }
  1375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1376. userJSONBytes, _ := json.Marshal(respJSON)
  1377. var res ResultFour
  1378. var resFour10265 ResultFour10265
  1379. if miConfig.Code == "H15049901371" {
  1380. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  1381. utils.ErrorLog("解析失败:%v", err)
  1382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1383. return
  1384. }
  1385. res.WarnMsg = resFour10265.WarnMsg
  1386. res.Output = resFour10265.Output
  1387. res.ErrMsg = resFour10265.ErrMsg
  1388. res.RespondTime = resFour10265.RespondTime
  1389. res.InfRefmsgid = resFour10265.InfRefmsgid
  1390. Infcode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  1391. res.Infcode = Infcode
  1392. } else {
  1393. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1394. utils.ErrorLog("解析失败:%v", err)
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1396. return
  1397. }
  1398. }
  1399. if res.Infcode == 0 {
  1400. ress = append(ress, &res)
  1401. } else {
  1402. isSuccess = false
  1403. errlog := &models.HisOrderError{
  1404. UserOrgId: adminUser.CurrentOrgId,
  1405. Ctime: time.Now().Unix(),
  1406. Mtime: time.Now().Unix(),
  1407. Number: chrg_bchno,
  1408. ErrMsg: "",
  1409. Status: 1,
  1410. PatientId: id,
  1411. RecordTime: recordDateTime,
  1412. Stage: 4,
  1413. }
  1414. service.CreateErrMsgLog(errlog)
  1415. c.ServeSuccessJSON(map[string]interface{}{
  1416. "failed_code": -10,
  1417. "msg": "上传明细错误,请联系his厂商",
  1418. })
  1419. return
  1420. }
  1421. }
  1422. if isSuccess == true {
  1423. if settle_accounts_type == 1 {
  1424. for _, subItem := range ress {
  1425. for _, item := range subItem.Output.Result {
  1426. temp := strings.Split(item.FeedetlSn, "-")
  1427. var advice_id int64 = 0
  1428. var project_id int64 = 0
  1429. var types int64 = 0
  1430. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1431. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1432. if temp[1] == "1" {
  1433. advice_id = id
  1434. project_id = 0
  1435. } else if temp[1] == "2" {
  1436. advice_id = 0
  1437. project_id = id
  1438. }
  1439. info := &models.HisOrderInfo{
  1440. OrderNumber: record.Number,
  1441. FeedetlSn: item.FeedetlSn,
  1442. UploadDate: time.Now().Unix(),
  1443. AdviceId: advice_id,
  1444. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1445. Cnt: item.Cnt,
  1446. Pric: float64(item.Pric),
  1447. PatientId: record.PatientId,
  1448. PricUplmtAmt: item.PricUplmtAmt,
  1449. SelfpayProp: item.SelfpayProp,
  1450. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1451. OverlmtAmt: item.OverlmtAmt,
  1452. PreselfpayAmt: item.PreselfpayAmt,
  1453. BasMednFlag: item.BasMednFlag,
  1454. MedChrgitmType: item.MedChrgitmType,
  1455. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1456. Status: 1,
  1457. Memo: item.Memo,
  1458. Mtime: time.Now().Unix(),
  1459. InscpScpAmt: item.InscpScpAmt,
  1460. DrtReimFlag: item.DrtReimFlag,
  1461. Ctime: time.Now().Unix(),
  1462. ListSpItemFlag: item.ListSpItemFlag,
  1463. ChldMedcFlag: item.ChldMedcFlag,
  1464. LmtUsedFlag: item.LmtUsedFlag,
  1465. ChrgitmLv: item.ChrgitmLv,
  1466. UserOrgId: adminUser.CurrentOrgId,
  1467. HisPatientId: record.ID,
  1468. OrderId: 0,
  1469. ProjectId: project_id,
  1470. Type: types,
  1471. SettleType: settle_accounts_type,
  1472. }
  1473. service.CreateOrderInfo(info)
  1474. }
  1475. }
  1476. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1477. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1478. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1479. if err == nil {
  1480. c.ServeSuccessJSON(map[string]interface{}{
  1481. "msg": "上传费用明细成功",
  1482. })
  1483. return
  1484. } else {
  1485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1486. return
  1487. }
  1488. } else {
  1489. for _, subItem := range ress {
  1490. for _, item := range subItem.Output.Result {
  1491. temp := strings.Split(item.FeedetlSn, "-")
  1492. var advice_id int64 = 0
  1493. var project_id int64 = 0
  1494. var types int64 = 0
  1495. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1496. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1497. if temp[1] == "1" {
  1498. advice_id = id
  1499. project_id = 0
  1500. } else if temp[1] == "2" {
  1501. advice_id = 0
  1502. project_id = id
  1503. }
  1504. info := &models.HisOrderInfo{
  1505. OrderNumber: record.Number,
  1506. FeedetlSn: item.FeedetlSn,
  1507. UploadDate: time.Now().Unix(),
  1508. AdviceId: advice_id,
  1509. DetItemFeeSumamt: item.DetItemFeeSumamt,
  1510. Cnt: item.Cnt,
  1511. Pric: float64(item.Pric),
  1512. PatientId: record.PatientId,
  1513. PricUplmtAmt: item.PricUplmtAmt,
  1514. SelfpayProp: item.SelfpayProp,
  1515. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  1516. OverlmtAmt: item.OverlmtAmt,
  1517. PreselfpayAmt: item.PreselfpayAmt,
  1518. BasMednFlag: item.BasMednFlag,
  1519. MedChrgitmType: item.MedChrgitmType,
  1520. HiNegoDrugFlag: item.HiNegoDrugFlag,
  1521. Status: 1,
  1522. Memo: item.Memo,
  1523. Mtime: time.Now().Unix(),
  1524. InscpScpAmt: item.InscpScpAmt,
  1525. DrtReimFlag: item.DrtReimFlag,
  1526. Ctime: time.Now().Unix(),
  1527. ListSpItemFlag: item.ListSpItemFlag,
  1528. ChldMedcFlag: item.ChldMedcFlag,
  1529. LmtUsedFlag: item.LmtUsedFlag,
  1530. ChrgitmLv: item.ChrgitmLv,
  1531. UserOrgId: adminUser.CurrentOrgId,
  1532. HisPatientId: record.ID,
  1533. ProjectId: project_id,
  1534. Type: types,
  1535. SettleType: settle_accounts_type,
  1536. }
  1537. service.CreateOrderInfo(info)
  1538. }
  1539. }
  1540. service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  1541. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  1542. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, record.Number, recordDateTime)
  1543. c.ServeSuccessJSON(map[string]interface{}{
  1544. "msg": "上传费用明细成功",
  1545. })
  1546. }
  1547. }
  1548. }
  1549. }
  1550. func (c *ZHHisApiController) ZHRefund() {
  1551. order_id, _ := c.GetInt64("order_id")
  1552. admin_user_id, _ := c.GetInt64("admin_user_id")
  1553. adminUser := c.GetAdminUserInfo()
  1554. var order models.HisOrder
  1555. order, _ = service.GetHisOrderByID(order_id)
  1556. record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1557. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1558. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1559. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1560. if config.IsOpen == 1 { //对接了医保,走医保流程
  1561. result, src_resquest := service.Gdyb2305(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1562. var dat map[string]interface{}
  1563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1564. fmt.Println(dat)
  1565. } else {
  1566. fmt.Println(err)
  1567. }
  1568. userJSONBytes, _ := json.Marshal(dat)
  1569. var res ResultSixteen
  1570. var resSixteen ResultSixteen10265
  1571. if miConfig.Code == "H15049901371" {
  1572. if err := json.Unmarshal(userJSONBytes, &resSixteen); err != nil {
  1573. utils.ErrorLog("解析失败:%v", err)
  1574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1575. return
  1576. }
  1577. res.Cainfo = resSixteen.Cainfo
  1578. res.WarnMsg = resSixteen.WarnMsg
  1579. res.Output = resSixteen.Output
  1580. res.ErrMsg = resSixteen.ErrMsg
  1581. res.RespondTime = resSixteen.RespondTime
  1582. Infcode, _ := strconv.ParseInt(resSixteen.Infcode, 10, 64)
  1583. res.Infcode = Infcode
  1584. } else {
  1585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1586. utils.ErrorLog("解析失败:%v", err)
  1587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1588. return
  1589. }
  1590. }
  1591. if res.Infcode == 0 {
  1592. err := service.UpdataOrderStatusThree(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  1593. if err == nil {
  1594. c.ServeSuccessJSON(map[string]interface{}{
  1595. "msg": "退费成功",
  1596. })
  1597. } else {
  1598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1599. return
  1600. }
  1601. } else {
  1602. c.ServeSuccessJSON(map[string]interface{}{
  1603. "code": -10,
  1604. "msg": res.ErrMsg,
  1605. })
  1606. }
  1607. } else {
  1608. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  1609. if err == nil {
  1610. c.ServeSuccessJSON(map[string]interface{}{
  1611. "msg": "退费成功",
  1612. })
  1613. } else {
  1614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1615. return
  1616. }
  1617. }
  1618. }
  1619. func (c *ZHHisApiController) ZHRefundDetail() {
  1620. patient_id, _ := c.GetInt64("patient_id")
  1621. his_patient_id, _ := c.GetInt64("his_patient_id")
  1622. record_time := c.GetString("record_time")
  1623. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1624. //order_id, _ := c.GetInt64("order_id")
  1625. admin_user_id, _ := c.GetInt64("admin_user_id")
  1626. timeLayout := "2006-01-02"
  1627. loc, _ := time.LoadLocation("Local")
  1628. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1629. if err != nil {
  1630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1631. return
  1632. }
  1633. recordDateTime := theTime.Unix()
  1634. adminUser := c.GetAdminUserInfo()
  1635. theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
  1636. if err != nil {
  1637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1638. return
  1639. }
  1640. recordDateTimeTwo := theTimeTwo.Unix()
  1641. //var prescriptions []*models.HisPrescription
  1642. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1643. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1644. if settle_accounts_type == 1 { //日结
  1645. infos, _ := service.GetZHHisUploadOrderInfo(adminUser.CurrentOrgId, patient_id, recordDateTime, recordDateTimeTwo)
  1646. record, _ := service.GetInHospitalRecord(his_patient_id)
  1647. var isSuccess bool = true
  1648. for _, item := range infos {
  1649. result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, item.FeedetlSn, 1)
  1650. var dat map[string]interface{}
  1651. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1652. fmt.Println(dat)
  1653. } else {
  1654. fmt.Println(err)
  1655. }
  1656. userJSONBytes, _ := json.Marshal(dat)
  1657. var res2 ResultEmpty
  1658. var resEmpty10265 ResultEmpty10265
  1659. if miConfig.Code == "H15049901371" {
  1660. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1661. utils.ErrorLog("解析失败:%v", err)
  1662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1663. return
  1664. }
  1665. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1666. res2.Infcode = Infcode
  1667. res2.RespondTime = resEmpty10265.RespondTime
  1668. res2.ErrMsg = resEmpty10265.ErrMsg
  1669. res2.Output = resEmpty10265.Output
  1670. res2.WarnMsg = resEmpty10265.WarnMsg
  1671. } else {
  1672. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1673. utils.ErrorLog("解析失败:%v", err)
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1675. return
  1676. }
  1677. }
  1678. if res2.Infcode == -1 {
  1679. isSuccess = false
  1680. }
  1681. }
  1682. if isSuccess {
  1683. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
  1684. if err != nil {
  1685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1686. return
  1687. }
  1688. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  1689. if err1 != nil {
  1690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1691. return
  1692. }
  1693. c.ServeSuccessJSON(map[string]interface{}{
  1694. "msg": "撤销明细成功",
  1695. })
  1696. }
  1697. } else {
  1698. //prescriptions, _ = service.GetZHMonthHisUploadPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1699. //var order models.HisOrder
  1700. //order, _ = service.GetHisOrderByID(order_id)
  1701. //record, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1702. record, _ := service.GetInHospitalRecord(his_patient_id)
  1703. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1704. if config.IsOpen == 1 { //对接了医保,走医保流程
  1705. result := service.Gdyb2302(record.PsnNo, record.Number, miConfig.OrgName, roles.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, "0000", 0)
  1706. var dat map[string]interface{}
  1707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1708. fmt.Println(dat)
  1709. } else {
  1710. fmt.Println(err)
  1711. }
  1712. userJSONBytes, _ := json.Marshal(dat)
  1713. var res2 ResultEmpty
  1714. var resEmpty10265 ResultEmpty10265
  1715. if miConfig.Code == "H15049901371" {
  1716. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1717. utils.ErrorLog("解析失败:%v", err)
  1718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1719. return
  1720. }
  1721. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1722. res2.Infcode = Infcode
  1723. res2.RespondTime = resEmpty10265.RespondTime
  1724. res2.ErrMsg = resEmpty10265.ErrMsg
  1725. res2.Output = resEmpty10265.Output
  1726. res2.WarnMsg = resEmpty10265.WarnMsg
  1727. } else {
  1728. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  1729. utils.ErrorLog("解析失败:%v", err)
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. return
  1732. }
  1733. }
  1734. if res2.Infcode == 0 {
  1735. err := service.UpdataHospitalOrderStatus(record.Number, adminUser.CurrentOrgId)
  1736. if err == nil {
  1737. c.ServeSuccessJSON(map[string]interface{}{
  1738. "msg": "撤销明细成功",
  1739. })
  1740. } else {
  1741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1742. return
  1743. }
  1744. } else {
  1745. c.ServeSuccessJSON(map[string]interface{}{
  1746. "code": -10,
  1747. "msg": res2.ErrMsg,
  1748. })
  1749. }
  1750. }
  1751. }
  1752. }
  1753. func (this *ZHHisApiController) GetZHOutHospitalUnCheck() {
  1754. id, _ := this.GetInt64("id")
  1755. admin_user_id, _ := this.GetInt64("admin_user_id")
  1756. adminInfo := this.GetAdminUserInfo()
  1757. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1758. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1759. record, _ := service.GetInHospitalRecord(id)
  1760. if record.ID == 0 {
  1761. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1762. return
  1763. }
  1764. result := service.ZHGdyb2405(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1765. var dat map[string]interface{}
  1766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1767. fmt.Println(dat)
  1768. } else {
  1769. fmt.Println(err)
  1770. }
  1771. userJSONBytes, _ := json.Marshal(dat)
  1772. var res ResultEmpty
  1773. var resEmpty10265 ResultEmpty10265
  1774. if miConfig.Code == "H15049901371" {
  1775. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1776. utils.ErrorLog("解析失败:%v", err)
  1777. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1778. return
  1779. }
  1780. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1781. res.Infcode = Infcode
  1782. res.RespondTime = resEmpty10265.RespondTime
  1783. res.ErrMsg = resEmpty10265.ErrMsg
  1784. res.Output = resEmpty10265.Output
  1785. res.WarnMsg = resEmpty10265.WarnMsg
  1786. } else {
  1787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1788. utils.ErrorLog("解析失败:%v", err)
  1789. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1790. return
  1791. }
  1792. }
  1793. if res.Infcode == 0 {
  1794. record.OutHospitalStatus = 0
  1795. service.CreateHospitalRecord(&record)
  1796. service.UpdataOrderStatusByNumber(record.Number)
  1797. this.ServeSuccessJSON(map[string]interface{}{
  1798. "msg": "撤销出院成功",
  1799. })
  1800. } else {
  1801. this.ServeSuccessJSON(map[string]interface{}{
  1802. "failed_code": -10,
  1803. "msg": res.ErrMsg,
  1804. })
  1805. }
  1806. }
  1807. func (this *ZHHisApiController) GetZHInHospitalUnCheck() {
  1808. id, _ := this.GetInt64("id")
  1809. admin_user_id, _ := this.GetInt64("admin_user_id")
  1810. adminInfo := this.GetAdminUserInfo()
  1811. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1812. role, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1813. record, _ := service.GetInHospitalRecord(id)
  1814. if record.ID == 0 {
  1815. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  1816. return
  1817. }
  1818. result := service.ZHGdyb2404(record.Number, record.PsnNo, miConfig.SecretKey, miConfig.OrgName, miConfig.Code, role.UserName, record.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  1819. var dat map[string]interface{}
  1820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1821. fmt.Println(dat)
  1822. } else {
  1823. fmt.Println(err)
  1824. }
  1825. userJSONBytes, _ := json.Marshal(dat)
  1826. var res ResultEmpty
  1827. var resEmpty10265 ResultEmpty10265
  1828. if miConfig.Code == "H15049901371" {
  1829. if err := json.Unmarshal(userJSONBytes, &resEmpty10265); err != nil {
  1830. utils.ErrorLog("解析失败:%v", err)
  1831. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1832. return
  1833. }
  1834. Infcode, _ := strconv.ParseInt(resEmpty10265.Infcode, 10, 64)
  1835. res.Infcode = Infcode
  1836. res.RespondTime = resEmpty10265.RespondTime
  1837. res.ErrMsg = resEmpty10265.ErrMsg
  1838. res.Output = resEmpty10265.Output
  1839. res.WarnMsg = resEmpty10265.WarnMsg
  1840. } else {
  1841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1842. utils.ErrorLog("解析失败:%v", err)
  1843. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1844. return
  1845. }
  1846. }
  1847. if res.Infcode == 0 {
  1848. record.Status = 0
  1849. service.CreateHospitalRecord(&record)
  1850. this.ServeSuccessJSON(map[string]interface{}{
  1851. "msg": "撤销入院成功",
  1852. })
  1853. } else {
  1854. this.ServeSuccessJSON(map[string]interface{}{
  1855. "failed_code": -10,
  1856. "msg": res.ErrMsg,
  1857. })
  1858. }
  1859. }