zh_his_api_controller.go 69KB

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