import_teis: Import Tracked Entity Instances (TEIs) on a DHIS2 server

View source: R/import_teis.R

import_teisR Documentation

Import Tracked Entity Instances (TEIs) on a DHIS2 server

Description

A generic function to upload Tracked Entity Instances on a DHIS2 server.

Usage

import_teis(teis, strategy = c("create_and_update", "create", "update"), ...)

create_and_update_teis(teis, ...)

create_teis(
  teis,
  baseurl = NULL,
  user = NULL,
  pass = NULL,
  tracked_entity_type = NULL,
  tea = NULL,
  tea_mapping = NULL,
  is_a360connect_type = TRUE,
  is_a360connect_enrollment_type = TRUE
)

update_teis(
  teis,
  baseurl = NULL,
  user = NULL,
  pass = NULL,
  tracked_entity_type = NULL,
  tea = NULL,
  tea_mapping = NULL,
  is_a360connect_type = TRUE,
  is_a360connect_enrollment_type = TRUE
)

Arguments

teis

A data.frame or data.table object containing a list of tracked entity instances to import.

strategy

A character string specifying the import strategy. Currently only three options are specified, create_and_update, create and update. The default is create_and_update.

...

Additional params passed to create_teis() and update_teis().

baseurl

The DHIS2 server, default is psi-clone server.

user

DHIS2 User Account, used in the pass key.

pass

Password of the user account, used in the pass key.

tracked_entity_type

DHIS2 ID, the type of tracked entity attribute.

tea

A vector, specifies the tracked attributes.

tea_mapping

A data.frame object containing the tracked entity attributes and their uids.

is_a360connect_type

Logical. Use this to bypass a360connect settings.

is_a360connect_enrollment_type

Logical, Use this to bypass a360connect settings.

Details

import_teis() uploads a list of tracked entity instances to a DHIS2 server. It provides options to specify the import strategy, point to a DHIS2 instance using the baseurl, and pass authentication. By default, the basic authentication is supported, and all the teis will be created or updated where possible.

create_and_update_teis() Checks for the existence of a tracked entity instance on a DHIS2 server before sending a request to create or update the object. By default, the tracked entity instances are created or updated on the psi-clone server - this can be changed by supplying the baseurl.

create_teis() Generates the payload directly from a data.frame with a list of tracked entity instances, and posts them to a DHIS2 instance. By default, the tracked entity instances are posted to the psi-clone server - this can be changed by supplying the baseurl.

update_teis() Generates the payload directly from a data.frame with a list of existing tracked entity instances, and updates them on a DHIS2 instance. By default, it updates the tracked entity instances to the psi-clone server - this can be changed by supplying the baseurl.

The baseurl and authentication, if not specified explicitly, will be pulled from the r environment.

Value

An S3 object with a DHIS2 response, API endpoint and content of the parsed response.

Functions

  • import_teis: Imports Tracked Entity Instances (TEIs) on a DHIS2 server

  • create_and_update_teis: Create and Update Tracked Entity Instances (TEIs) on a DHIS2 server

  • create_teis: Create Tracked Entity Instances (TEIs) on a DHIS2 server

  • update_teis: Update Tracked Entity Instances (TEIs) on a DHIS2 server

Examples

## Not run: 
import_teis(teis)
server_url <- "https://dhis-instance.org/"
user <- "admin"
pass <- "district"
# creates and updates the teis
import_teis(teis, baseurl = server_url, user = user, pass = pass)
# creates the teis
import_teis(teis, strategy = "create", baseurl = server_url, user = user, pass = pass)
# updates the teis
import_teis(teis, strategy = "update", baseurl = server_url, user = user, pass = pass)

## End(Not run)
## Not run: 
create_and_update_teis(teis)
server_url <- "https://dhis-instance.org/"
user <- "admin"
pass <- "district"
create_and_update_teis(teis, baseurl = server_url, user = user, pass = pass)

## End(Not run)
## Not run: 
create_teis(teis)
server_url <- "https://dhis-instance.org/"
user <- "admin"
pass <- "district"
create_teis(teis, baseurl = server_url, user = user, pass = pass)

## End(Not run)
## Not run: 
update_teis(teis)
server_url <- "https://dhis-instance.org/"
user <- "admin"
pass <- "district"
update_teis(teis, baseurl = server_url, user = user, pass = pass)

## End(Not run)

psi-mis/a360connect documentation built on Nov. 22, 2022, 12:36 p.m.