Learn R Programming

fhircrackr (version 1.0.0)

fhir_table_description: Create '>fhir_table_description object

Description

A fhir_table_description is part of a fhir_design and holds the information fhir_crack() needs to flatten (aka crack) FHIR resources from a FHIR bundle. There should be one fhir_table_description per resource type as fhir_crack() will create one data.frame/data.table per resource type. See Details.

Usage

fhir_table_description(resource, cols = fhir_columns(), style = fhir_style())

Arguments

resource

A character vector of length one or '>fhir_resource_type object indicating which resource type should be extracted.

cols

Optional. A '>fhir_columns object or something that can be coerced to one, like a (named) character vector, a (named) list containing xpath expressions, or a '>fhir_xpath_expression object. See fhir_columns() and the examples. If this argument is omitted, an empty '>fhir_columns object will be supplied. This means that in the call to fhir_crack(), all available elements are extracted in put in automatically named columns.

style

Optional. A '>fhir_style object, as created by fhir_style(). If this argument is omitted, default values will be assumed, see fhir_style().

Value

An object of class '>fhir_table_description.

Details

A fhir_table_description consists of the following elements:

  • The resource element: Defines the resource type (e.g. Patient or Observation). See ?fhir_resource.

  • The cols element: Contains the column names and XPath expressions defining the columns to extract. If this element is empty, fhir_crack() will extract all available elements of the resource and name the columns automatically. See ?fhir_columns.

  • The style element: Defines how to deal with multiple entries to the same element and whether empty columns are removed. See ?fhir_style

A full fhir_table_description looks for example like this:

fhir_resource_type: Patient

fhir_columns: column name | xpath expression ------------------------ name | name/family gender | gender id | id

fhir_style: sep: || brackets: '[' ']' rm_empty_cols: FALSE

Examples

Run this code
# NOT RUN {
#named character for cols
fhir_table_description(resource = "Patient",
                       cols = c(name = "name/family",
                                gender = "gender",
                                id = "id"),
                       style = fhir_style(sep = "||",
                                          brackets = c("[", "]"),
                                          rm_empty_cols = FALSE)
)

#If style is ommitted, default values are assumed
fhir_table_description(resource = "Patient",
                       cols = c(name = "name/family",
                                gender = "gender",
                                id = "id")
)

#named list for cols
fhir_table_description(resource = "Patient",
                       cols = list(name = "name/family",
                                   gender = "gender",
                                   id = "id")
)

#unnamed character for cols, colnames are generated automatically
fhir_table_description(resource = "Patient",
                       cols = c("name/family",
                                "gender",
                                "id")
)
# }

Run the code above in your browser using DataLab