Shared R package for the Uganda RAMP (Routine Assessment of Malaria Programs) project. Provides metadata tables, shapefiles, and database utilities used by the ETL pipeline (uga-etl-facility-data) and analytics repos (outbreak). An R package providing utility functions and reference data for working with health information systems databases, particularly DHIS2 (District Health Information System 2) data from Uganda.
ramptools simplifies working with versioned health data by providing:
get_latest_version() - Retrieve the most recent data version from a databaseget_version_metadata() - Access metadata for specific data versionsget_data() - Query versioned data with filtering by ID variables and versionget_db_diff() - Identify new or changed data compared to existing database recordsget_id_vars() / get_value_var() - Discover database schema informationget_period_range() - Generate sequences of DHIS2-formatted periods (weekly/monthly)make_week_map() - Create mappings between ISO weeks and datesmake_month_map() - Create mappings between months and datesget_output_dir() - Create versioned output directories with standardized naming (YYYY_MM_DD.VV)get_latest_output_date_index() - Find the latest version index for a given datemake_human_readable() - Merge human-readable location and indicator names onto raw DHIS2 dataThe package includes reference data for Uganda:
| Object | Description |
|---|---|
loc_table |
Location hierarchy — 11,229 facilities and admin units with parent-child relationships (Uganda → Region → District → DLG → Subcounty → Facility) |
health_facility_table |
8,676 health facilities with ownership, status, coordinates, facility type |
indicator_table |
~100 DHIS2 data element mappings (DHIS ID → code_name, display_name, frequency, dhis_version) |
district_pop |
District-level population estimates |
age_sex_table |
Age-sex disaggregated indicator definitions |
uga_district_shp |
District-level shapefile |
uga_subcounty_shp |
Subcounty-level shapefile |
uga_region_shp |
Region-level shapefile |
uga_water_shp |
Water body geometries |
get_data() — Read versioned data from a SQLite databaseget_db_diff() — Compare new pull against stored DB, return only new/changed rowsget_latest_version() — Get latest version number from DBget_version_metadata() — Get metadata for a specific versionget_id_vars() / get_value_var() — Introspect database schemamake_human_readable() — Join DHIS IDs to human-readable namesbq_connect() — Create a BigQuery connectionbq_get_data() — Read raw data from BigQuery (with version/filter support)bq_get_clean_data() — Read clean aggregated data from BigQuerybq_get_db_diff() — Diff new data against BigQuerybq_get_latest_version() — Get latest version from BigQuerybq_append_raw_data() / bq_append_version_metadata() — Append to BigQuerybq_write_clean_data() / bq_write_imputed_data() — Overwrite clean outputsbq_init_tables() — Initialize BigQuery schemaget_period_range() — Generate DHIS-formatted period vectorsmake_week_map() / make_month_map() — Date lookup tables for DHIS periodsget_output_dir() — Create versioned output directoriesThe pipeline stores data in Google BigQuery under project uganda-malaria, dataset uga_facility_data. Tables:
| Table | Description |
|---|---|
raw_{frequency}_data |
Append-only versioned raw DHIS pulls |
raw_{frequency}_version_metadata |
Provenance metadata per version |
clean_{frequency}_data |
Latest clean aggregated data (overwritten each run) |
imputed_{frequency}_facility_data |
Facility-level imputed data (overwritten each run) |
To initialize:
library(ramptools)
bq_init_tables(frequency = "both")devtools::install_github(“yourusername/ramptools”) ```