Learn R Programming

fhircrackr (version 2.3.0)

fhir_is_empty: 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 fhir_bundle_list fhir_is_empty(bundles)

# S4 method for fhir_bundle_xml fhir_is_empty(bundles)

Value

TRUE if the bundle/bundle list is empty, FALSE if it is not empty.

Arguments

bundles

A FHIR search result as returned by fhir_search()

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)

Examples

Run this code
#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)

Run the code above in your browser using DataLab