View source: R/fhir_table_description.R
fhir_table_description | R Documentation |
A fhir_table_description
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 in a bundle. See Details.
fhir_table_description(
resource,
cols = fhir_columns(),
sep = ":::",
brackets = character(),
rm_empty_cols = FALSE,
format = "compact",
keep_attr = FALSE,
style = deprecated()
)
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 |
sep |
A character of length one containing the separator string used for separating multiple entries in cells when |
brackets |
A character of length one or two used for the indices of multiple entries. The first one is the opening bracket
and the second one the closing bracket. Vectors of length one will be recycled.
Defaults to |
rm_empty_cols |
A logical of length one indicating whether empty columns should be removed from the resulting table or not. Defaults to |
format |
A character of length one indicating whether the resulting table should be cracked to a |
keep_attr |
A logical of length one indicating whether the attribute name of the respective element ( |
style |
A fhir_table_description
consists of
the following elements:
The resource element: Defines the resource type (e.g. Patient
or Observation
). See fhir_resource_type()
.
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 sep element: A character of length one containing the separator string used for separating multiple entries in cells.
The brackets element: A character of length one or two used for the indices of multiple entries. The first one is the opening bracket
and the second one the closing bracket. Vectors of length one will be recycled.
Defaults to character(0)
, i.e. no brackets, meaning that multiple entries won't be indexed.
The rm_empty_cols element: A logical of length one indicating whether empty columns should be removed in the resulting table or not. Defaults to FALSE
.
The format element: A character of length one indicating whether the resulting table should be cracked to a wide
or compact
format.
wide
means multiple entries will be distributed over several columns with indexed names. compact
means multiple entries will be pasted into one cell/column separated by sep
.
Defaults to compact
.
The keep_attr element: A logical of length one indicating whether the attribute name of the respective element (@value
in most cases)
should be attached to the name of the variable in the resulting table. Defaults to FALSE
.
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 sep: ':::' brackets: '[', ']' rm_empty_cols: FALSE format: 'compact' keep_attr: FALSE
An object of class fhir_table_description.
# a minimal table description
fhir_table_description(
resource = "Patient"
)
# named list for cols
fhir_table_description(
resource = "Patient",
cols = list(
id = "id",
name = "name/family",
gender = "gender"
)
)
#unnamed character for cols, colnames are generated automatically
fhir_table_description(
resource = "Patient",
cols = c(
"id",
"name/family",
"gender"
)
)
# named character for cols, and overwritten default for other arguments
fhir_table_description(
resource = "Patient",
cols = c(
id = "id",
name = "name/family",
gender = "gender"
),
brackets = c("[", "]"),
rm_empty_cols = TRUE,
format = "wide"
)
# no column arguments is given -> creates a column for all available elements
fhir_table_description(
resource = "Patient",
sep = " <~> ",
brackets = c("<<<", ">>>"),
rm_empty_cols = FALSE,
format = "wide"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.