Newer
Older
### harmonized_loc.R - Analyse par localisation
date1 <- reactive({
as.Date(paste0(input$HARLOCdates[1],"-01-01"))
})
date2 <- reactive({
as.Date(paste0(input$HARLOCdates[2],"-12-31"))
})
# Préparation des listes de zones pour la Colombie
HARLOC_residencial_area_co <- JSON_area_har %>%
filter(source == "CO") %>%
select(id, name) %>%
arrange(name)
# Création de la liste pour la sélection UI
HARLOC_residencial_area_list_co <- setNames(
as.list(HARLOC_residencial_area_co$id),
HARLOC_residencial_area_co$name
)
# Préparation des listes pour le Brésil
HARLOC_residencial_area_br <- JSON_area_har %>%
filter(source == "BR") %>%
select(id, name) %>%
arrange(name)
HARLOC_residencial_area_list_br <- setNames(
as.list(HARLOC_residencial_area_br$id),
HARLOC_residencial_area_br$name
)
print("Listes de sélection :")
print("Colombie :")
print(str(HARLOC_residencial_area_list_co))
print("Brésil :")
print(str(HARLOC_residencial_area_list_br))
# Préparation des centres de santé
# Pour la Colombie
HARLOC_health_center_co <- JSON_healthcenter_har %>%
filter(source == "CO") %>%
select(id_center, name) %>%
arrange(name)
HARLOC_health_center_list_co <- setNames(
as.list(HARLOC_health_center_co$id_center),
HARLOC_health_center_co$name
)
# Pour le Brésil
HARLOC_health_center_br <- JSON_healthcenter_har %>%
filter(source == "BR") %>%
select(id_center, name) %>%
arrange(name)
HARLOC_health_center_list_br <- setNames(
as.list(HARLOC_health_center_br$id_center),
HARLOC_health_center_br$name
)
##################
### Interface utilisateur réactive
##################
# Interface pour la sélection des localités brésiliennes
output$HARLOClocation_br <- renderUI({
"residence_area" = {
choices <- HARLOC_residencial_area_list_br
selectInput(
"HARLOCselection_br",
tr("BR"),
choices = choices,
multiple = TRUE,
selectize = TRUE
)
},
"center" = {
choices <- HARLOC_health_center_list_br
selectInput(
"HARLOCselection_br",
tr("BR"),
choices = choices,
multiple = TRUE,
selectize = TRUE
)
},
"infection_place" = {
choices <- HARLOC_residencial_area_list_br
selectInput(
"HARLOCselection_br",
tr("BR"),
choices = choices,
multiple = TRUE,
selectize = TRUE
)
}
# Interface pour la sélection des localités colombiennes
output$HARLOClocation_co <- renderUI({
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
"residence_area" = {
choices <- HARLOC_residencial_area_list_co
selectInput(
"HARLOCselection_co",
tr("CO"),
choices = choices,
multiple = TRUE,
selectize = TRUE
)
},
"center" = {
choices <- HARLOC_health_center_list_co
selectInput(
"HARLOCselection_co",
tr("CO"),
choices = choices,
multiple = TRUE,
selectize = TRUE
)
},
"infection_place" = {
choices <- HARLOC_residencial_area_list_co
selectInput(
"HARLOCselection_co",
tr("CO"),
choices = choices,
multiple = TRUE,
selectize = TRUE
)
}
##################
### Filtrage des données
##################
# Données pour la Colombie
HARLOC_sub_co <- reactive({
req(input$HARLOCtype)
req(input$HARLOCselection_co)
# Ajout de messages de diagnostic
print("Filtrage des données colombiennes")
print(paste("Type sélectionné:", input$HARLOCtype))
print(paste("Sélections:", paste(input$HARLOCselection_co, collapse=", ")))
df <- consultation_har_filter(JSON_cons_har,
source = "CO",
new_attack = input$HARLOCnew_attack,
diagn = input$HARLOCdiagn,
sex = input$HARLOCsex,
minAge = input$HARLOCage[1],
maxAge = input$HARLOCage[2]
) %>%
filter(consultation_date >= date1() &
consultation_date <= date2())
# Filtrage selon le type de localisation
df <- switch(input$HARLOCtype,
"center" = df %>% filter(id_center %in% input$HARLOCselection_co),
"residence_area" = df %>% filter(residence_place %in% input$HARLOCselection_co),
"infection_place" = df %>% filter(infection_place %in% input$HARLOCselection_co)
)
print(paste("Nombre de cas après filtrage:", nrow(df)))
# Données pour le Brésil (même structure)
HARLOC_sub_br <- reactive({
# Code similaire pour le Brésil
})