fhir_is_empty {fhircrackr} | R Documentation |
Check if Bundle/Bundlelist is empty
Description
Checks if a fhir_bundle_xml or fhir_bundle_list is empty, i.e. does not contain any resources.
Usage
fhir_is_empty(bundles)
## S4 method for signature 'fhir_bundle_list'
fhir_is_empty(bundles)
## S4 method for signature 'fhir_bundle_xml'
fhir_is_empty(bundles)
Arguments
bundles |
A FHIR search result as returned by |
Details
Empty bundles are returned when a search on a FHIR server does not yield any resources, such as when no resources on the server match the specified search criteria. In this case, the server responds with an empty searchset bundle. This function checks whether:
For objects of type fhir_bundle_xml, the bundle contains at least one "entry" element (if not, the bundle is empty and the functions returns
TRUE
)For objects of type fhir_bundle_list, the first bundle in the list contains at least one "entry" element (if not, the bundle is empty and the functions returns
TRUE
)
Value
TRUE
if the bundle/bundle list is empty, FALSE
if it is not empty.
Examples
#Load empty example bundles
bundles <- fhir_unserialize(example_bundles_empty)
bundles
fhir_is_empty(bundles)
#Load non-empty example bundles
bundles <- fhir_unserialize(patient_bundles)
bundles
fhir_is_empty(bundles)