Browse Source

Correction rattachement RUM à RSS pour date de sortie

master
Maxime Wack 8 years ago
parent
commit
3ea87f2206
2 changed files with 11 additions and 7 deletions
  1. +1
    -2
      cloture.Rmd
  2. +10
    -5
      donnees.R

+ 1
- 2
cloture.Rmd View File

@@ -83,9 +83,8 @@ data_frame(Dates = rep(date, 5),
rum %>%
filter(annee_sortie == annee) %>%
tally %>%
bind_rows(rum %>%
bind_rows(rss %>%
filter(annee_sortie == annee) %>%
distinct(idrss) %>%
tally) %>%

datatable(rownames = c("RUM", "RSS"),


+ 10
- 5
donnees.R View File

@@ -55,10 +55,7 @@ src_mysql("pmsi_dim", "localhost", user = user, password = password) %>%
SELECT idhosp, idrss, idrum, date_entree, date_sortie, cmd, um FROM fix117")) %>%
collect %>%
mutate(date_entree = date_entree %>% as.Date,
date_sortie = date_sortie %>% as.Date,
annee_sortie = year(date_sortie),
mois_sortie = month(date_sortie)) %>%
filter(annee_sortie > annee - 3) %>% # Données rum/rss depuis 3 ans
date_sortie = date_sortie %>% as.Date) %>%
left_join(src_mysql("pmsi_dim_nom", "localhost", user = user, password = password) %>%
tbl("structure") %>%
filter(um != "") %>%
@@ -77,10 +74,18 @@ src_mysql("pmsi_dim", "localhost", user = user, password = password) %>%
left_join(group_by(., idrss) %>%
summarise(duree_rss = sum(duree_rum))) -> rum

# RSS
print("Création des RSS")
rum %>%
group_by(idrss) %>%
filter(idrum == max(idrum)) %>%
ungroup -> rss
ungroup %>%
mutate(annee_sortie = year(date_sortie),
mois_sortie = month(date_sortie)) %>%
filter(annee_sortie > annee - 3) -> rss

rum %<>%
right_join(rss %>% select(idrss, annee_sortie, mois_sortie))

# GAM et structure --> hospit non codées
print("LIVENNE : GAM")


Loading…
Cancel
Save