|
|
@@ -1,7 +1,7 @@ |
|
|
|
library(dplyr) |
|
|
|
library(tidyverse) |
|
|
|
library(magrittr) |
|
|
|
library(RCurl) |
|
|
|
library(readr) |
|
|
|
library(httr) |
|
|
|
#library(RCurl) |
|
|
|
library(stringr) |
|
|
|
library(rvest) |
|
|
|
|
|
|
@@ -45,80 +45,53 @@ extractOvalide <- function(annee, mois, table, subtable = "") |
|
|
|
|
|
|
|
connectOvalide <- function(CHUuser, CHUpass, ATIHuser, ATIHpass) |
|
|
|
{ |
|
|
|
curlopts <- list(proxy = str_c(CHUuser, ':', CHUpass, '@ssl-proxy.chu-nancy.fr:8080'), |
|
|
|
follow = T, |
|
|
|
cookiejar = 'cookie.jar', |
|
|
|
cookiefile = 'cookie.jar') |
|
|
|
|
|
|
|
curl <- str_c('curl -x "', CHUuser, ':', CHUpass, '@ssl-proxy.chu-nancy.fr:8080" -b cookie.jar -c cookie.jar -L ') |
|
|
|
pasrel <- 'https://pasrel.atih.sante.fr/cas/login' |
|
|
|
epmsi <- 'https://epmsi.atih.sante.fr/' |
|
|
|
|
|
|
|
unlink("cookie.jar") |
|
|
|
|
|
|
|
# Cookie |
|
|
|
print("ePMSI : COOKIE") |
|
|
|
system(str_c(curl, pasrel)) |
|
|
|
|
|
|
|
# Config proxy |
|
|
|
set_config(use_proxy(url = "ssl-proxy.chu-nancy.fr", port = 8080, username = CHUuser, password = CHUpass)) |
|
|
|
|
|
|
|
# Token |
|
|
|
print("ePMSI : TOKEN") |
|
|
|
getURL(pasrel, .opts = curlopts) %>% |
|
|
|
read_html %>% |
|
|
|
GET(pasrel) %>% |
|
|
|
content %>% |
|
|
|
html_node("input[name='lt']") %>% |
|
|
|
html_attr("value") -> token |
|
|
|
print(token) |
|
|
|
|
|
|
|
# Login |
|
|
|
print("ePMSI : LOGIN") |
|
|
|
system(str_c(curl, '-d "username=', ATIHuser, '&password=', curlPercentEncode(ATIHpass), '<=', token, '&_eventId=submit&submit=SE+CONNECTER" ', pasrel)) |
|
|
|
POST(pasrel, body = list(username = ATIHuser, password = ATIHpass, lt = token, "_eventId" = "submit", submit = "SE+CONNECTER"), encode = "form") %>% cookies -> cookie |
|
|
|
|
|
|
|
# Auth |
|
|
|
print("ePMSI : AUTH") |
|
|
|
system(str_c(curl, epmsi, 'authenticate.do')) |
|
|
|
GET(str_c(epmsi, 'authenticate.do'), set_cookies(cookie$value %>% setNames(cookie$name))) %>% cookies |
|
|
|
} |
|
|
|
|
|
|
|
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") |
|
|
|
getURL(str_c(epmsi, 'jsp/epmsi/applis/applis.jsp'), |
|
|
|
.opts = curlopts) %>% |
|
|
|
cat |
|
|
|
|
|
|
|
GET(str_c(epmsi, 'jsp/epmsi/applis/applis.jsp')) |
|
|
|
|
|
|
|
# Ovalide |
|
|
|
print("ePMSI : OVALIDE") |
|
|
|
getURL(str_c(epmsi, 'jsp/epmsi/applis/applisMat2a.jsp'), |
|
|
|
referer = str_c(epmsi, 'jsp/epmsi/applis/applis.jsp'), |
|
|
|
.opts = curlopts) %>% |
|
|
|
cat |
|
|
|
|
|
|
|
GET(str_c(epmsi, 'jsp/epmsi/applis/applisMat2a.jsp')) |
|
|
|
|
|
|
|
# Ovalide MCO T2A |
|
|
|
print("ePMSI : MCO T2A") |
|
|
|
getURL(str_c(epmsi, 'appli_16.do?champPmsi=1&statut=1&applicationType=3'), |
|
|
|
referer = str_c(epmsi, 'jsp/epmsi/applis/applisMat2a.jsp'), |
|
|
|
.opts = curlopts) %>% |
|
|
|
cat |
|
|
|
|
|
|
|
GET(str_c(epmsi, 'appli_16.do?champPmsi=1&statut=1&applicationType=3')) |
|
|
|
|
|
|
|
# Resultats pour annee/mois |
|
|
|
print("ePMSI : RESULTATS") |
|
|
|
getURL(str_c(epmsi, 'appli_05.do?year=', annee, '&period=', mois), |
|
|
|
referer = str_c(epmsi, 'appli_16.do?champPmsi=1&statut=1&applicationType=3'), |
|
|
|
.opts = curlopts) %>% |
|
|
|
cat |
|
|
|
|
|
|
|
GET(str_c(epmsi, 'appli_05.do?year=', annee, '&period=', mois)) |
|
|
|
|
|
|
|
# Tableaux |
|
|
|
print("ePMSI : TABLEAUX") |
|
|
|
getBinaryURL(str_c(epmsi, 'appli_05.zip?action=4&win=1'), |
|
|
|
referer = str_c(epmsi, 'appli_05.do?year=', annee, '&period=', mois), |
|
|
|
.opts = curlopts) %>% |
|
|
|
writeBin(con = str_c('ePMSI/', annee, '_', mois, '.zip')) |
|
|
|
GET(str_c(epmsi, 'appli_05.zip?action=4&win=1')) %>% |
|
|
|
content %>% |
|
|
|
writeBin(con = str_c('ePMSI/', annee, '_', mois, '.zip')) |
|
|
|
|
|
|
|
unzip(str_c('ePMSI/', annee, '_', mois, '.zip')) |
|
|
|
} |