fhir_crack | R Documentation |
Converts a fhir_bundle_list (the result of fhir_search()
to a list of data.frames/data.tables,
i.e. a fhir_df_list/fhir_dt_list if a fhir_design is given in the argument design
.
Creates a single data.frame/data.table, if only a fhir_table_description is given in the argument design
.
There are two main output formats for the table: compact and wide. They differ regarding their handling of multiple entries for
the same FHIR element (e.g. Patient.adress
). In the compact format multiple entries are pasted together into one cell/column,
in the wide format multiple entries are distributed over several (indexed) columns. If none of the resources contains any multiple
values on the extracted elements, the two formats will result in the same basic structure.
To increase speed with larger amounts of data the cracking process can be parallelised over a number of cores defined in the
ncores
argument.
fhir_crack( bundles, design, sep = NULL, brackets = NULL, rm_empty_cols = NULL, verbose = 2, data.table = FALSE, format = NULL, keep_attr = NULL, ncores = 1, remove_empty_columns = deprecated() ) ## S4 method for signature 'ANY,fhir_table_description' fhir_crack( bundles, design, sep = NULL, brackets = NULL, rm_empty_cols = NULL, verbose = 2, data.table = FALSE, format = NULL, keep_attr = NULL, ncores = 1, remove_empty_columns = deprecated() ) ## S4 method for signature 'ANY,fhir_design' fhir_crack( bundles, design, sep = NULL, brackets = NULL, rm_empty_cols = NULL, verbose = 2, data.table = FALSE, format = NULL, keep_attr = NULL, ncores = 1, remove_empty_columns = deprecated() )
bundles |
A FHIR search result as returned by |
design |
A fhir_design or fhir_table_description object. See |
sep |
Optional. A character of length one containing the separator string used for separating multiple entries in cells when |
brackets |
Optional. A character of length one or two used for the indices of multiple entries, which will overwrite the |
rm_empty_cols |
Optional. Remove empty columns? Logical scalar which will overwrite the |
verbose |
An integer vector of length one. If 0, nothing is printed, if 1, only finishing message is printed, if > 1, extraction progress will be printed. Defaults to 2. |
data.table |
A logical vector of length one. If it is set to TRUE the fhir_crack-function returns a data.table, otherwise a data.frame. Defaults to FALSE. |
format |
Optional. A character of length one indicating whether the resulting table should be cracked to a |
keep_attr |
Optional. A logical of length one indicating whether the attribute name of the respective element ( |
ncores |
Either NULL (no parallelisation) or an integer of length 1 containing the number of cpu cores that should be used for parallelised cracking. Defaults to NULL. |
remove_empty_columns |
If a fhir_design was used, the result is a list of data.frames, i.e. a fhir_df_list object, or a list of data.tables, i.e. a fhir_dt_list object. If a fhir_table_description was used, the result is a single data.frame/data.table.
Downloading bundles from a FHIR server: fhir_search()
Creating designs/table_descriptions: fhir_table_description()
and fhir_design()
Dealing with multiple entries: fhir_melt()
, fhir_cast()
, fhir_rm_indices()
#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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.