Skip to contents

This function provides streamlined API access to PDAP Wave data, the successor to DATIM Genie. PDAP Wave API simplifies the requests that previously needed to be made with DATIM and returns a dataset back that matches the MSD structure. Further documentation can be found at https://wave.test.pdap.pepfar.net/api/docs#/.

Usage

wave_process_query(
  request_body,
  folderpath_dwnld = "Data",
  psd_type = c("psnu_im", "ou_im", "site_im"),
  request_type = c("POST", "GET"),
  username,
  password
)

Arguments

request_body

elements to pass into the PDAP Wave POST API

folderpath_dwnld

where to download, default = "Data"

psd_type

Type of PEPFAR Structured dataset: "psnu_im" (default), "ou_im", or "site_im"

request_type

API request type: "POST" (default) or "GET

username

DATIM username, if blank looks for stored credentials (glamr::set_datim()) and then prompts for credentials if not found

password

DATIM password, if blank looks for stored credentials (glamr::set_datim()) and then prompts for credentials if not found

Value

list of request and stored data in zip

Details

Users must pass their query filter in a list form into request_body, which matches what you would manually do in Genie previously. You can proceed with either POST or GET requests to access PSNUxIM, OUxIM, and SitexIM data.

This function was adapted from code developed and shared by Derek Wood (GHSD/PRIME).

Examples

if (FALSE) { # \dontrun{
 library(tidyverse)
 library(glamr)

 #get country uid for API
cntry_uid <- pepfar_country_list %>%
 filter(country == "Tanzania") %>%
 pull(country_uid)

 #establish parameters to pass into POST API
 post_body <- list(
   daily_frozen='daily',
   fiscal_year=list(2023, 2024),
   funding_agency = list("USAID"),
   indicator=list("TX_CURR","TX_ML","TX_CURR_LAG2", "TX_NET_NEW","TX_NEW",
                  "TX_RTT","PMTCT_STAT", "PMTCT_STAT_POS", "PMTCT_ART"),
   uid_hierarchy_list=list(str_glue('-|-|{cntry_uid}')))

 #run POST API
 wave_process_query(post_body)

 #load data
 df_wave <- return_latest("Data") %>%
    read_psd()
    } # }