Browse Source

Séparation connect/get Ovalide. Corrections supplémentaires.

master
Maxime Wack 8 years ago
parent
commit
63acafa472
1 changed files with 20 additions and 16 deletions
  1. +20
    -16
      functionsOvalide.R

+ 20
- 16
functionsOvalide.R View File

@@ -16,14 +16,20 @@ extractOvalide <- function(annee, mois, table, subtable = "")
# Extraction de la table
if (table == "1.D.2.EDMS")
{
current %>%
current %<>%
str_extract(str_c('<td class="c systemtitle">Tableau \\[', table, '\\] ', subtable, '(.*?<\\/table>){3}')) %>%
str_replace_all("(\\d) (\\d)", "\\1\\2") %>%
str_replace_all("\\.<\\/td>", "<\\/td>") %>%
str_replace_all("&nbsp;", " ") %>%
str_replace_all("<thead>.*?<\\/thead>", "") %>%
read_html %>%
html_table(trim = T, dec = ",", header = F) %>%
bind_rows
html_table(trim = T, dec = ",")
current[[1]]$X1 <- str_c(current[[1]]$X1, " - avant mars", sep = "")
current[[2]]$X1 <- str_c(current[[2]]$X1, " - après mars", sep = "")
if (mois < 3)
current[[1]]
else
current %>% bind_rows
} else
{
current %>%
@@ -37,7 +43,7 @@ extractOvalide <- function(annee, mois, table, subtable = "")
}
}

getOvalide <- function(CHUuser, CHUpass, ATIHuser, ATIHpass, annee, mois)
connectOvalide <- function(CHUuser, CHUpass, ATIHuser, ATIHpass)
{
curlopts <- list(proxy = str_c(CHUuser, ':', CHUpass, '@ssl-proxy.chu-nancy.fr:8080'),
follow = T,
@@ -69,6 +75,16 @@ getOvalide <- function(CHUuser, CHUpass, ATIHuser, ATIHpass, annee, mois)
# Auth
print("ePMSI : AUTH")
system(str_c(curl, epmsi, 'authenticate.do'))
}

getOvalide <- function(CHUuser, CHUpass, annee, mois)
{
curlopts <- list(proxy = str_c(CHUuser, ':', CHUpass, '@ssl-proxy.chu-nancy.fr:8080'),
follow = T,
cookiejar = 'cookie.jar',
cookiefile = 'cookie.jar')

epmsi <- 'https://epmsi.atih.sante.fr/'

# Applis
print("ePMSI : APPLIS")
@@ -104,17 +120,5 @@ getOvalide <- function(CHUuser, CHUpass, ATIHuser, ATIHpass, annee, mois)
.opts = curlopts) %>%
writeBin(con=str_c(annee, '_', mois, '.zip'))

# Resultats pour annee/mois
getURL(str_c(epmsi, 'appli_05.do?year=', annee - 1, '&period=', mois),
referer = str_c(epmsi, 'appli_16.do?champPmsi=1&statut=1&applicationType=3'),
.opts = curlopts)

# Tableaux
getBinaryURL(str_c(epmsi, 'appli_05.zip?action=4&win=1'),
referer = str_c(epmsi, 'appli_05.do?year=', annee - 1, '&period=', mois),
.opts = curlopts) %>%
writeBin(con=str_c(annee - 1, '_', mois, '.zip'))

unzip(str_c(annee, '_', mois, '.zip'))
unzip(str_c(annee - 1, '_', mois, '.zip'))
}

Loading…
Cancel
Save