Skip to contents

get_metadata retrieves metadata for a specified endpoint of KHIS

Usage

get_metadata(
  endpoint,
  ...,
  fields = c("id", "name"),
  retry = 2,
  verbosity = 0,
  timeout = 60
)

Arguments

endpoint

The KHIS API endpoint for the metadata of interest (e.g. dataElements, organisationUnits).

...

One or more metadata_filter() params in key-value pairs.

fields

The specific columns to be returned in the tibble.

retry

Number of times to retry the API call in case of failure (defaults to 2).

verbosity

Level of HTTP information to print during the call:

  • 0: No output

  • 1: Show headers

  • 2: Show headers and bodies

  • 3: Show headers, bodies, and CURL status message.

timeout

Maximum number of seconds to wait for the API response.

Value

A tibble with the KHIS metadata response.

Examples


# Get the categories metadata
get_metadata('categories')
#> # A tibble: 486 × 2
#>    name                                     id         
#>    <chr>                                    <chr>      
#>  1 "11-14yrs"                               Dql7n14U5XC
#>  2 "15-18yrs"                               PZWbYQY0lnl
#>  3 "2-5yrs"                                 KY9t7YJtAJI
#>  4 "3. Immunology"                          LQeahngW60z
#>  5 "6-10yrs"                                eZsIWKswsN5
#>  6 "6-10 yrs"                               eLTXvFcuiRN
#>  7 "717 Operations(Booked&Operated) "       OzZClNVHXLV
#>  8 "749 Total Isolates"                     mXj1e4ycMBt
#>  9 "751_Child exclusively  breastfed"       oNDNLvqbXtN
#> 10 "751_Early  initiation to breastfeeding" hghdXcQVx7R
#> # ℹ 476 more rows

# Get the datasets metadata with fields 'id,name,organisationUnits' and filter
# only the datasets with id 'WWh5hbCmvND'
get_metadata('dataSets',
             fields = 'id,name,organisationUnits[id,name,path]',
             id %.eq% 'WWh5hbCmvND')
#> # A tibble: 1 × 3
#>   name                                                  id     organisationUnits
#>   <chr>                                                 <chr>  <list>           
#> 1 MoH 745 Cancer Screening Program Monthly Summary Form WWh5h… <list [7,702]>   

# Get data elements filtered by dataElementgroups id
get_metadata('dataElements',
             dataElementGroups.id %.eq% 'IXd7DXxZqzL',
             fields = ':all')
#> # A tibble: 31 × 35
#>    lastUpdated    id    href  created name  shortName aggregationType domainType
#>    <chr>          <chr> <chr> <chr>   <chr> <chr>     <chr>           <chr>     
#>  1 2020-07-14T22… XEX9… http… 2020-0… CBE-… CBE-Abno… SUM             AGGREGATE 
#>  2 2020-07-14T22… cXe6… http… 2020-0… CBE-… CBE-Norm… SUM             AGGREGATE 
#>  3 2020-07-14T22… DtbP… http… 2020-0… Colo… Colonosc… SUM             AGGREGATE 
#>  4 2020-07-14T22… tp8H… http… 2020-0… Colo… Colonosc… SUM             AGGREGATE 
#>  5 2020-07-14T22… zt7c… http… 2020-0… Colo… Colonosc… SUM             AGGREGATE 
#>  6 2020-07-14T22… lqoW… http… 2020-0… Colo… Colonosc… SUM             AGGREGATE 
#>  7 2021-10-08T12… w46X… http… 2020-0… FOBT… FOBT-Neg… SUM             AGGREGATE 
#>  8 2021-10-08T12… qojd… http… 2020-0… FOBT… FOBT-Pos… SUM             AGGREGATE 
#>  9 2020-07-14T22… T3cr… http… 2020-0… Mamm… Mammogra… SUM             AGGREGATE 
#> 10 2020-07-14T22… Sorv… http… 2020-0… Mamm… Mammogra… SUM             AGGREGATE 
#> # ℹ 21 more rows
#> # ℹ 27 more variables: publicAccess <chr>, displayName <chr>,
#> #   displayShortName <chr>, externalAccess <lgl>, valueType <chr>,
#> #   dimensionItem <chr>, zeroIsSignificant <lgl>, displayFormName <chr>,
#> #   favorite <lgl>, dimensionItemType <chr>, optionSetValue <lgl>,
#> #   access <list>, categoryCombo <list>, lastUpdatedBy <list>, sharing <list>,
#> #   createdBy <list>, user <list>, favorites <lgl>, dataSetElements <list>, …