dhis2_import: Downloads a dataset from a DHIS2 server. Currently works on...

View source: R/dhis2_import.R

dhis2_importR Documentation

Downloads a dataset from a DHIS2 server. Currently works on datasets organized weekly or monthly.

Description

dhis2_import downloads a dataset from a DHIS2 server. It works on datasets that are organized weekly or monthly.

Usage

dhis2_import(
  df,
  dataset,
  api_url,
  username,
  password,
  year_initial,
  year_final,
  period = c("weekly", "monthly")
)

Arguments

df

a dhis2_datasets object.

dataset

string. The name of an available dataset from a DHIS2 server obtained from a dhis2_datasets object.

api_url

the URL of the DHIS2 api. Usually it is the server URL ending with "/api/"

username

the username required to access the DHIS2 server.

password

the password required to access the DHIS2 server.

year_initial

the initial year available in the dataset to import data from.

year_final

the last year available in the dataset to import data from.

period

either "weekly" or "monthly" periods are supported.

Value

A dataset containing all available data.

Warning

A Internet connection is needed to use this function. It might take a while depending on the connection.

Watch out for hardcoded login and password.

Examples

## Not run: 
# Demo available at https://play.dhis2.org/demo/
library("r-epigraphhub")
api_url <- "https://play.dhis2.org/demo/api/"
username <- "admin"
password <- "district"
datasets <- dhis2_datasets(api_url = api_url, username = username, password = password)
my_dataset <- datasets$displayName[2]
df_dhis2 <- dhis2_import(df = datasets, dataset = my_dataset, api_url = api_url, username = username, password = password, year_initial = 2021, year_final = 2022, period = "monthly")
head(df_dhis2)

## End(Not run)

thegraphnetwork/r-epigraphhub documentation built on May 23, 2022, 7:45 p.m.