fhir_build_resource: Build a single FHIR resource

View source: R/build_resources.R

fhir_build_resourceR Documentation

Build a single FHIR resource

Description

This function takes a single row from a wide table as produced by fhir_crack() and builds a fhir_resource_xml object from it. The column names of the table must represent the XPath expression of the respective element with indices for repeating items. A table like this is produced when FHIR resources have been cracked with fhir_crack() without assigning explicit column names in the fhir_design/fhir_table_description and with format set to "wide".

Usage

fhir_build_resource(row, brackets, resource_type)

Arguments

row

Single row from a wide table as produced by fhir_crack() with format="wide"

brackets

A character vector of length one. The brackets used for cracking.

resource_type

A character vector of length one or fhir_resource_type object indicating which resource type the table is build from.

Value

A fhir_resource_xml object.

See Also

fhir_cast(), fhir_crack(), fhir_build_bundle(), fhir_post(), fhir_put()

Examples

#unserialize example
bundles <- fhir_unserialize(bundles = example_bundles1)

#crack fhir resources
Pat <- fhir_table_description(
    resource = "Patient",
    brackets = c("[", "]"),
    sep      = " ",
    format   = "wide"
)

df <- fhir_crack(bundles = bundles, design = Pat)


#build resource
resource <- fhir_build_resource(
                row           = df[1,],
                brackets      = c('[', ']'),
                resource_type = "Patient"
            )

#print to console
resource

TPeschel/fhiR documentation built on April 14, 2024, 7:31 a.m.