#' Download all attributes of the Presepi Program
#'
#'
#' @return the dataframe with attibutes of the Presepi program df_TrackedEntityAttribute
getTrackedEntityAttribute <- function(){
url <-
"http://209.61.231.45:8082/dhis/api/programs/ybHHvBdo1ke.xml?fields=id,name,programTrackedEntityAttributes,organisationUnits[id,name],programStages[id,name]"
rootNode <- queryURL(url)
programTrackedEntityAttribute <- rootNode[["programTrackedEntityAttributes"]]
xmlChildren(programTrackedEntityAttribute[[1]])$trackedEntityAttribute
map(xmlChildren(programTrackedEntityAttribute), function(x){
child <- xmlChildren(x)[["trackedEntityAttribute"]]
trId <- xmlGetAttr(child,"id")
})
#programTrackedEntity
TrackedEntityAttributeId <-
map(xmlChildren(programTrackedEntityAttribute), function(x){
child <- xmlChildren(x)[["trackedEntityAttribute"]]
trId <- xmlGetAttr(child,"id")
})
programTrackedEntityAttributeName <-
as.list(xmlSApply(programTrackedEntityAttribute, xmlGetAttr, "name"))
df_TrackedEntityAttribute <-
do.call(
rbind,
Map(
data.frame,
Id = TrackedEntityAttributeId,
name = programTrackedEntityAttributeName,
stringsAsFactors = FALSE
)
)
return(df_TrackedEntityAttribute)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.