zh_his_api_controller.go 71KB

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