dd-harp / ramptools

Shared tools for the RAMP team
Other
0 stars 0 forks source link

Add old monthly indicators for key indicators #18

Open d-hergott opened 1 month ago

d-hergott commented 1 month ago

Add in indicators for malaria testing variables, using old_dhis_data_elements.csv shared by Austin.

library(data.table)
path <- "~/old_dhis_data_elements.csv"
dt <- fread(path)
names(dt)
dt[grepl("alaria", displayName)]
d-hergott commented 3 weeks ago

The goal of this task is to determine which indicators from the old_dhis map to the new dhis. There are a few tools/previous work to help with this. Putting here to keep all in one place:

## Set up
library(httr); library(jsonlite); library(data.table); library(ggplot2)
cred <- jsonlite::read_json("dhis2_credentials.json")
options(dhis2_username = cred$old$username)
options(dhis2_password = cred$old$password)
options(dhis2_base = cred$old$base)

url <- paste0(getOption("dhis2_base"), "dataElements?paging=false")
get <- GET(url, authenticate(getOption("dhis2_username"), getOption("dhis2_password")))
get_text <- content(get, "text")
get_json <- fromJSON(get_text, flatten = T)
dhis_names <- unique(get_json$dataElements$displayName)

old_dhis <- get_json$dataElements
write.csv(old_dhis, "~/Downloads/old_dhis_data_elements.csv", row.names = F)

When possible, make the code_names for weekly match with monthly (and ensure the same across versions).

As a first step, will pull in all the codes, and not use age divisions (can use the age_sex_table for this and figure that out later).

If not sure two elements are the same, will flag for team discussion