getMechanismView: getMechanismView

View source: R/getMechanismView.R

getMechanismViewR Documentation

getMechanismView

Description

Retrieves a view of mechanisms with partners and agencies The function will attempt to read from a cached file, if defined in the support_files_directory option has been set, and the mechs.rds file is available to be read. Otherwise, if the user is logged in, the view will be obtained from DATIM. Otherwise, an empty dataframe is returned.

Note that only country UIDs are accepted. If Regional Operating Unit uids are supplied, returns entire mechanism list, trimmed to user's DATIM permissions.

Usage

getMechanismView(
  country_uids = NULL,
  cop_year = NULL,
  include_dedupe = FALSE,
  include_MOH = FALSE,
  d2_session = dynGet("d2_default_session", inherits = TRUE),
  cached_mechs_path = paste0(Sys.getenv("support_files_directory"), "mechs.rds"),
  update_stale_cache = FALSE,
  include_default = TRUE
)

Arguments

country_uids

Unique IDs for countries to include in the Data Pack. For full list of these IDs, see datapackr::valid_OrgUnits.

cop_year

COP Year to use for tailoring functions. Remember, FY22 targets = COP21.

include_dedupe

Logical. If TRUE will include deduplication mechanisms. Default is FALSE.

include_MOH

Logical. If TRUE will include MOH mechanisms. Default is FALSE.

d2_session

DHIS2 Session id. R6 datimutils object which handles authentication with DATIM.

cached_mechs_path

Local file path to an RDS file containing a cached copy of the mechanisms SQL view.

update_stale_cache

If the cached_mechs_path file is outdated or unreadable, should a new cache be saved?

include_default

Should the default mechanism also be included?

Value

Mechs


pepfar-datim/datapackr documentation built on April 14, 2024, 10:35 p.m.