Objectif

Importer le tableau 1.V.5.EMM de Ovalide pour pouvoir par la suite comparer avec les résultats produits à partir des données de VisualValoSej.

Option 1 : automatique

La fonction import_emm_from_epmsi permet de récupérer les tableaux EMM directement sur l'application EPMSI

emm <- lapply(1:12, function(x) vvs::import_emm_from_epmsi(
    user = nom_utilisateur, 
    pass = mot_de_passe, 
    annee = 2017,
    mois = x
    ))
emm <- dplyr::bind_rows(emm)

Option 2 : manuel

Prérequis

Dans e-PMSI sélectionner Applications -> Ovalide MCO -> Année concernée -> M12 -> Résultats -> Tableau [1.V.5.EMM]: Evolution des montants mensuel par période de transmission par type de prestation

Sauvegarder cette page de manière brute (html seul).

Traitement

La fonction vvs::import_emm permet d'importer les tableaux présents sur cette page web en une liste de data.frames (une pour chaque tableau).

emm <- vvs::import_emm('../raw_data/1V5EMM_2017.htm')

head(emm)

On retrouve les tableaux mais de manière manipulable

emml <- aggregate(valorisation ~ mois_envoi + mois_sortie, data = emm, FUN = sum)
xtabs(valorisation ~ mois_envoi + mois_sortie, data = emml)
sum(emml$valorisation)
library(magrittr)
library(ggplot2)
library(dplyr)

plot_valo_mois <- function(df) {

  # somme en million
  df$valorisation <- df$valorisation / 10^6
  somme_mois <- df %>%
    group_by(mois_sortie) %>%
    summarise(valo_mensuelle = sum(valorisation))

ggplot(df) +
  geom_histogram(
    aes(x = as.factor(mois_sortie), y = valorisation, fill = type_table), 
    stat = "identity") +
  labs(x = "Mois de sortie",
       y = "Valorisation (millions €)",
       fill = "Type") +
  geom_text(aes(x = mois_sortie, label = format(valo_mensuelle, digits = 2), y = valo_mensuelle), data = somme_mois, vjust = 0) 

}

plot_valo_mois(emm)

Sauvegarde

saveRDS(emm, '../produced_data/emm2017.rds')


jomuller/vvs documentation built on May 21, 2019, 2:05 p.m.