#unserialize example bundle
bundles <- fhir_unserialize(medication_bundles)
###Example 1###
#Extract just one resource type
#define attributes to extract
med_desc <- fhir_table_description(
resource = "MedicationStatement",
cols = c(
id = "id",
status = "status",
system = "medicationCodeableConcept/coding/system",
code = "medicationCodeableConcept/coding/code",
display = "medicationCodeableConcept/coding/display"
)
)
med_df <- fhir_crack(bundles = bundles, design = med_desc)
head(med_df) #data.frame
###Example 2###
#extract two resource types at once
pat_desc <- fhir_table_description(
resource = "Patient"
)
design <- fhir_design(med_desc, pat_desc)
df_list <- fhir_crack(bundles = bundles, design = design)
#list of data.frames/fhir_df_list
head(df_list$med_desc)
head(df_list$pat_desc)
#The design that was used can be extracted from a fhir_df_list
fhir_design(df_list)
###Example 3###
#Filter values before extracting
#unserialize example bundle
b <- fhir_unserialize(bundles = example_bundles5)
#only extract codings with loinc system
table_desc <- fhir_table_description(
resource = "Observation",
cols = c(
id = "id",
loinc = "code/coding[system[@value='http://loinc.org']]/code",
display = "code/coding[system[@value='http://loinc.org']]/display"
)
)
table <- fhir_crack(bundles = b,
design = table_desc)
table
Run the code above in your browser using DataLab