These function produces MSF OCA dictionaries based on DHIS2 data sets defining the data element name, code, short names, types, and key/value pairs for translating the codes into human-readable format.

msf_dict(
  disease,
  name = "MSF-outbreak-dict.xlsx",
  tibble = TRUE,
  compact = TRUE,
  long = TRUE
)

msf_dict_survey(
  disease,
  name = "MSF-survey-dict.xlsx",
  tibble = TRUE,
  compact = FALSE
)

Arguments

disease

Specify which disease you would like to use.

  • msf_dict() supports "AJS", "Cholera", "Measles", "Meningitis"

  • msf_dict_survey() supports "Mortality", "Nutrition", and "Vaccination"

name

the name of the dictionary stored in the package.

tibble

Return data dictionary as a tidyverse tibble (default is TRUE)

compact

if TRUE (default), then a nested data frame is returned where each row represents a single variable and a nested data frame column called "options", which can be expanded with tidyr::unnest(). This only works if long = TRUE.

long

If TRUE (default), the returned data dictionary is in long format with each option getting one row. If FALSE, then two data frames are returned, one with variables and the other with content options.

See also

Examples

if (require("dplyr") & require("matchmaker")) { withAutoprint({ # You will often want to use MSF dictionaries to translate codes to human- # readable variables. Here, we generate a data set of 20 cases: dat <- gen_data( dictionary = "Cholera", varnames = "data_element_shortname", numcases = 20, org = "MSF" ) print(dat) # We want the expanded dictionary, so we will select `compact = FALSE` dict <- msf_dict(disease = "Cholera", long = TRUE, compact = FALSE, tibble = TRUE) print(dict) # Now we can use matchmaker to filter the data: dat_clean <- matchmaker::match_df(dat, dict, from = "option_code", to = "option_name", by = "data_element_shortname", order = "option_order_in_set" ) print(dat_clean) }) }
#> > dat <- gen_data(dictionary = "Cholera", varnames = "data_element_shortname", #> + numcases = 20, org = "MSF") #> > print(dat) #> # A tibble: 20 x 45 #> trimester exit_status treatment_facil… dehydration_lev… comments_on_lab… #> <fct> <fct> <lgl> <fct> <lgl> #> 1 NA DD NA SE NA #> 2 NA DD NA UN NA #> 3 NA DH NA SO NA #> 4 NA DD NA SE NA #> 5 NA LA NA UN NA #> 6 NA DH NA SO NA #> 7 NA DOA NA NO NA #> 8 NA TR NA SO NA #> 9 NA DOA NA SE NA #> 10 NA TR NA NO NA #> 11 NA TR NA NO NA #> 12 NA TR NA NO NA #> 13 NA DD NA SE NA #> 14 NA TR NA SE NA #> 15 NA AD NA SE NA #> 16 NA TR NA NO NA #> 17 NA DOA NA NO NA #> 18 NA DH NA SO NA #> 19 3 DOA NA UN NA #> 20 NA DD NA SO NA #> # … with 40 more variables: fluids_treatment_plan <fct>, time_to_death <fct>, #> # malaria_rdt_at_admission <fct>, previously_vaccinated <fct>, #> # cholera_pcr_result <fct>, iv_fluids_received_litres <int>, #> # patient_origin_free_text <chr>, previous_vaccine_doses_received <fct>, #> # age_years <int>, arrival_date_in_area_if_3m <date>, age_days <int>, #> # msf_involvement <fct>, date_lab_sample_taken <date>, readmission <fct>, #> # age_months <int>, date_of_last_vaccination <date>, case_number <chr>, #> # sex <fct>, patient_origin <chr>, prescribed_zinc_supplement <fct>, #> # delivery_event <fct>, pregnancy_outcome_at_exit <fct>, date_of_exit <date>, #> # date_of_consultation_admission <date>, oedema <fct>, event_file_type <fct>, #> # residential_status_brief <fct>, pregnant <fct>, cholera_rdt_result <fct>, #> # dehydration_severity_during_stay <fct>, cholera_culture_result <fct>, #> # foetus_alive_at_admission <fct>, treatment_facility_site <int>, #> # prescribed_antibiotics <fct>, cholera_referred_to <fct>, #> # ors_consumed_litres <int>, treatment_location <chr>, #> # cholera_referred_from <fct>, cholera_treatment_facility_type <fct>, #> # date_of_onset <date> #> > dict <- msf_dict(disease = "Cholera", long = TRUE, compact = FALSE, tibble = TRUE) #> > print(dict) #> # A tibble: 182 x 11 #> data_element_uid data_element_na… data_element_sh… data_element_de… #> <chr> <chr> <chr> <chr> #> 1 FF7d81Zy0yQ egen_013_pregna… trimester If pregnant, tr… #> 2 FF7d81Zy0yQ egen_013_pregna… trimester If pregnant, tr… #> 3 FF7d81Zy0yQ egen_013_pregna… trimester If pregnant, tr… #> 4 ADfNqpCL5kf egen_015_exit_s… exit_status Final status of… #> 5 ADfNqpCL5kf egen_015_exit_s… exit_status Final status of… #> 6 ADfNqpCL5kf egen_015_exit_s… exit_status Final status of… #> 7 ADfNqpCL5kf egen_015_exit_s… exit_status Final status of… #> 8 ADfNqpCL5kf egen_015_exit_s… exit_status Final status of… #> 9 ADfNqpCL5kf egen_015_exit_s… exit_status Final status of… #> 10 wjCDTwXmtix egen_064_treatm… treatment_facil… Name of facilit… #> # … with 172 more rows, and 7 more variables: data_element_valuetype <chr>, #> # data_element_formname <chr>, used_optionset_uid <chr>, option_code <chr>, #> # option_name <chr>, option_uid <chr>, option_order_in_set <dbl> #> > dat_clean <- matchmaker::match_df(dat, dict, from = "option_code", to = "option_name", #> + by = "data_element_shortname", order = "option_order_in_set") #> > print(dat_clean) #> # A tibble: 20 x 45 #> trimester exit_status treatment_facil… dehydration_lev… comments_on_lab… #> <fct> <fct> <lgl> <fct> <lgl> #> 1 NA Dead in fa… NA Severe NA #> 2 NA Dead in fa… NA Unknown NA #> 3 NA Discharged… NA Some NA #> 4 NA Dead in fa… NA Severe NA #> 5 NA Left again… NA Unknown NA #> 6 NA Discharged… NA Some NA #> 7 NA Dead on ar… NA None NA #> 8 NA Transferre… NA Some NA #> 9 NA Dead on ar… NA Severe NA #> 10 NA Transferre… NA None NA #> 11 NA Transferre… NA None NA #> 12 NA Transferre… NA None NA #> 13 NA Dead in fa… NA Severe NA #> 14 NA Transferre… NA Severe NA #> 15 NA Transferre… NA Severe NA #> 16 NA Transferre… NA None NA #> 17 NA Dead on ar… NA None NA #> 18 NA Discharged… NA Some NA #> 19 3rd trim… Dead on ar… NA Unknown NA #> 20 NA Dead in fa… NA Some NA #> # … with 40 more variables: fluids_treatment_plan <fct>, time_to_death <fct>, #> # malaria_rdt_at_admission <fct>, previously_vaccinated <fct>, #> # cholera_pcr_result <fct>, iv_fluids_received_litres <int>, #> # patient_origin_free_text <chr>, previous_vaccine_doses_received <fct>, #> # age_years <int>, arrival_date_in_area_if_3m <date>, age_days <int>, #> # msf_involvement <fct>, date_lab_sample_taken <date>, readmission <fct>, #> # age_months <int>, date_of_last_vaccination <date>, case_number <chr>, #> # sex <fct>, patient_origin <chr>, prescribed_zinc_supplement <fct>, #> # delivery_event <fct>, pregnancy_outcome_at_exit <fct>, date_of_exit <date>, #> # date_of_consultation_admission <date>, oedema <fct>, event_file_type <fct>, #> # residential_status_brief <fct>, pregnant <fct>, cholera_rdt_result <fct>, #> # dehydration_severity_during_stay <fct>, cholera_culture_result <fct>, #> # foetus_alive_at_admission <fct>, treatment_facility_site <chr>, #> # prescribed_antibiotics <fct>, cholera_referred_to <fct>, #> # ors_consumed_litres <int>, treatment_location <chr>, #> # cholera_referred_from <fct>, cholera_treatment_facility_type <fct>, #> # date_of_onset <date>