Skip to contents

Retrieve HMIS data for one or more indicators with optional filters for state, time period, sector, and category. Uses Apache Arrow for efficient filtering of the bundled parquet file.

Usage

get_hmis(
  indicator,
  geography = c("state", "district"),
  state = NULL,
  district = NULL,
  sector = NULL,
  category = NULL,
  from = NULL,
  to = NULL,
  geometry = FALSE,
  data_path = NULL,
  match = c("fixed", "regex", "fuzzy")
)

Arguments

indicator

Character string to match against canonical_name (case-insensitive). Matching behavior depends on match: "fixed" (default) for plain substring, "regex" for regular expressions, "fuzzy" for approximate matching.

geography

One of "state" or "district". Default "state".

state

Optional character vector of state names to filter. Case-insensitive; common aliases are resolved via normalize_state_name().

district

Optional character vector of district names to filter. Only valid when geography = "district".

sector

Optional character vector. One or more of "Total", "Public", "Private", "Rural", "Urban". Default: all sectors.

category

Optional character string to filter the indicator sub-category column (e.g., "Total", "Number Tested", "Number Positive", age groups). Default: all.

from

Optional start date as "Mon YYYY" (e.g., "Apr 2015").

to

Optional end date as "Mon YYYY" (e.g., "Mar 2020").

geometry

If TRUE, attach LGD boundaries and return an sf object. Default FALSE.

data_path

Optional path to an external parquet file. Default uses the bundled state-level or cached district-level parquet.

match

One of "fixed" (default, plain substring), "regex", or "fuzzy" (approximate matching).

Value

A tibble (or sf object if geometry = TRUE) with columns: canonical_name, code_desc, category, monyear, state, sector, value (and district for district-level queries).

Examples

if (FALSE) { # \dontrun{
# All live birth data (state level, default)
get_hmis("Total number of male and female live births")

# Indicator names with special characters work without escaping
get_hmis("Malaria (Microscopy Tests) - Plasmodium Falciparum test positive")

# Filter by state and time
get_hmis("malaria", state = "Bihar", from = "Apr 2015", to = "Mar 2020")

# District-level query
get_hmis("live birth", geography = "district", state = "Bihar")

# District-level with district filter
get_hmis("malaria", geography = "district", state = "Bihar", district = "Patna")

# Fuzzy matching for approximate names
get_hmis("Plsmodium Vivax", match = "fuzzy", category = "Total")

# Regex matching
get_hmis("live.birth", match = "regex", category = "Total")

# With geometry
get_hmis("live birth", sector = "Total", geometry = TRUE)
get_hmis("live birth", geography = "district", state = "Bihar", geometry = TRUE)
} # }