|
|
@@ -0,0 +1,109 @@ |
|
|
|
library(tidyverse) |
|
|
|
library(rmarkdown) |
|
|
|
library(lubridate) |
|
|
|
library(magrittr) |
|
|
|
library(stringr) |
|
|
|
library(shiny) |
|
|
|
library(DT) |
|
|
|
|
|
|
|
options(shiny.maxRequestSize = 100*1024^2) |
|
|
|
|
|
|
|
# CCAM ==== |
|
|
|
read_csv("CCAM.csv") %>% |
|
|
|
`names<-`(c("code", "libelle", "classant", "ICR", "phase")) %>% |
|
|
|
arrange(code) %>% |
|
|
|
distinct %>% |
|
|
|
group_by(code) %>% |
|
|
|
summarize(libelle = first(libelle), |
|
|
|
classant = max(classant), |
|
|
|
ICR = max(ICR, na.rm = T)) -> ccam |
|
|
|
|
|
|
|
# UI ==== |
|
|
|
ui <- fluidPage( |
|
|
|
titlePanel("Actes manquants collact → pims"), |
|
|
|
sidebarLayout( |
|
|
|
sidebarPanel( |
|
|
|
a(href = "README.html", "Manuel d'utilisation"), |
|
|
|
hr(), |
|
|
|
numericInput("annee", "Année", Sys.Date() %>% year), |
|
|
|
fileInput("collact", "Fichier collact", accept = "text/csv"), |
|
|
|
fileInput("webpims", "Fichier webpims", accept = "text/csv"), |
|
|
|
width = 3 |
|
|
|
), |
|
|
|
mainPanel( |
|
|
|
DT::dataTableOutput("resultat") |
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
# SERVER ==== |
|
|
|
server <- function(input, output) |
|
|
|
{ |
|
|
|
# collact ==== |
|
|
|
collact <- reactive({ |
|
|
|
req(input$collact) |
|
|
|
|
|
|
|
read_csv(input$collact$datapath, col_types = "cccc") %>% |
|
|
|
`names<-`(c("idhosp", "code", "date", "internum")) %>% |
|
|
|
#mutate(date = date %>% as.Date(format = "%d/%m/%Y") + years(2000)) %>% |
|
|
|
mutate(date = date %>% as.Date(format = "%d/%m/%Y")) %>% |
|
|
|
filter(date <= as.Date(str_c(input$annee, "-12-31"))) |
|
|
|
}) |
|
|
|
|
|
|
|
# webpims ==== |
|
|
|
pims <- reactive({ |
|
|
|
req(input$webpims) |
|
|
|
|
|
|
|
read_csv(input$webpims$datapath, col_types = "ccc") %>% |
|
|
|
`names<-`(c("idhosp", "code", "date")) %>% |
|
|
|
#mutate(date = date %>% as.Date(format = "%Y/%m/%d"), |
|
|
|
mutate(date = date %>% as.Date(format = "%d/%m/%Y"), |
|
|
|
code = code %>% str_sub(1,7)) %>% |
|
|
|
filter(date <= as.Date(str_c(input$annee, "-12-31"))) |
|
|
|
}) |
|
|
|
|
|
|
|
# Output |
|
|
|
output$resultat <- DT::renderDataTable( |
|
|
|
{ |
|
|
|
req(collact(), pims()) |
|
|
|
|
|
|
|
withProgress(message = "Calcul…", |
|
|
|
value = 0.25, |
|
|
|
detail = "Différence collact-pims", |
|
|
|
{ |
|
|
|
|
|
|
|
# Collact - PIMS ==== |
|
|
|
collact() %>% |
|
|
|
filter(!((code %>% str_detect("^JVJF")) & (date < str_c(input$annee, "-01-01")))) %>% |
|
|
|
anti_join(pims()) %>% |
|
|
|
left_join(ccam, by = "code") -> collact_pims |
|
|
|
|
|
|
|
setProgress(.5, detail = "Agrégation") |
|
|
|
# Summary ==== |
|
|
|
collact_pims %>% |
|
|
|
filter(classant == "Oui") %>% |
|
|
|
group_by(code, libelle) %>% |
|
|
|
summarize(n = n(), |
|
|
|
ICR = sum(ICR)) %>% |
|
|
|
ungroup %>% |
|
|
|
arrange(desc(ICR)) -> summ_actes |
|
|
|
|
|
|
|
setProgress(.75, detail = "Liste finale") |
|
|
|
# Liste finale ==== |
|
|
|
collact_pims %>% |
|
|
|
inner_join(summ_actes, by = c("code", "libelle")) %>% |
|
|
|
rename(`ICR acte` = ICR.x, |
|
|
|
`ICR total` = ICR.y) %>% |
|
|
|
arrange(desc(`ICR total`)) %>% |
|
|
|
mutate(code = code %>% factor) %>% |
|
|
|
select(-classant) |
|
|
|
})}, |
|
|
|
extensions = "Buttons", |
|
|
|
filter = "top", |
|
|
|
options = list(paging = F, |
|
|
|
searching = T, |
|
|
|
dom = "Bfrtip", |
|
|
|
buttons = c("copy", "excel"))) |
|
|
|
} |
|
|
|
|
|
|
|
shinyApp(ui = ui, server = server) |