#unserialize example bundle
bundles <- fhir_unserialize(medication_bundles)
###Example 1###
#Extract just one resource type
#define attributes to extract
medications <- fhir_table_description(
resource = "MedicationStatement",
cols = c(
MS.ID = "id",
STATUS.TEXT = "text/status",
STATUS = "status",
MEDICATION.SYSTEM = "medicationCodeableConcept/coding/system",
MEDICATION.CODE = "medicationCodeableConcept/coding/code",
MEDICATION.DISPLAY = "medicationCodeableConcept/coding/display",
DOSAGE = "dosage/text",
PATIENT = "subject/reference",
LAST.UPDATE = "meta/lastUpdated"
),
sep = " ",
brackets = c("[", "]"),
rm_empty_cols = FALSE
)
med_df <- fhir_crack(bundles = bundles, design = medications)
head(med_df) #data.frame
###Example 2###
#extract more resource types
patients <- fhir_table_description(
resource = "Patient"
)
design <- fhir_design(medications, patients)
df_list <- fhir_crack(bundles = bundles, design = design)
#list of data.frames/fhir_df_list
head(df_list$medications)
head(df_list$patients)
#The design that was used can be extracted from a fhir_df_list
fhir_design(df_list)
Run the code above in your browser using DataLab