Class CompartmentUtil


  • public class CompartmentUtil
    extends Object
    This class supplements SearchUtil with compartment-specific utilities.
    The compartments are defined using FHIR R4 CompartmentDefinitions.
    The R4 CompartmentDefintions and boundaries are defined at https://hl7.org/fhir/R4/compartmentdefinition.html

    CompartmentDefintion:
    • Patient - https://hl7.org/fhir/R4/compartmentdefinition-patient.json
    • Encounter - https://hl7.org/fhir/R4/compartmentdefinition-encounter.json
    • RelatedPerson - https://hl7.org/fhir/R4/compartmentdefinition-relatedperson.json
    • Practitioner - https://hl7.org/fhir/R4/compartmentdefinition-practitioner.json
    • Device - https://hl7.org/fhir/R4/compartmentdefinition-device.json
    Call init() to initialize static members and avoid a slight performance hit on first use.
    • Method Detail

      • init

        public static void init()
        Loads the class in the classloader to initialize static members. Call this before using the class in order to avoid a slight performance hit on first use.
      • buildMaps

        public static final void buildMaps​(Map<String,​CompartmentCache> compMap,
                                           Map<String,​ResourceCompartmentCache> resourceCompMap)
        Builds an in-memory model of the Compartment map defined in compartments.json, for supporting compartment based FHIR searches.
        Parameters:
        compMap - map of compartment name to CompartmentCache
        resourceCompMap - map of resource type name to ResourceCompartmentCache
      • getCompartmentResourceTypeInclusionCriteria

        public static List<String> getCompartmentResourceTypeInclusionCriteria​(String compartment,
                                                                               String resourceType)
                                                                        throws FHIRSearchException
        gets the compartment and resource type inclusion criteria.
        Parameters:
        compartment -
        resourceType -
        Returns:
        Throws:
        FHIRSearchException - if the passed resourceType does not exist within the passed compartment
      • checkValidCompartment

        public static void checkValidCompartment​(String compartment)
                                          throws FHIRSearchException
        checks that the compartment is valid and throws an exception if not
        Parameters:
        compartment -
        Throws:
        FHIRSearchException
      • checkValidCompartmentAndResource

        public static void checkValidCompartmentAndResource​(String compartment,
                                                            String resourceType)
                                                     throws FHIRSearchException
        checks that the compartment and resource are valid and throws an exception if not
        Parameters:
        compartment -
        Throws:
        FHIRSearchException
      • getCompartmentParamsForResourceType

        public static Map<String,​Set<String>> getCompartmentParamsForResourceType​(String resourceType)
        Get the map of parameter names used as compartment references for the given resource type. For example for CareTeam:
           participant -> {RelatedPerson, Patient}
           patient -> {Patient}
           encounter -> {Encounter}
           ...
         
        Parameters:
        resourceType - the resource type name
        Returns:
        a map of parameter name to set of compartment names
      • makeCompartmentParamName

        public static String makeCompartmentParamName​(String compartmentName)
        Create the special parameter name used for references to the given compartment (e.g. Patient, RelatedPerson etc).
        Parameters:
        compartmentName -
        Returns: