zh_his_api_controller.go 77KB

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