Class CompartmentUtil


  • public class CompartmentUtil
    extends Object
    The compartments are defined using FHIR R4 CompartmentDefinitions.
    The R4 CompartmentDefintions and boundaries are defined at https://www.hl7.org/fhir/compartmentdefinition.html

    CompartmentDefintion:
    • Patient - https://www.hl7.org/fhir/compartmentdefinition-patient.json
    • Encounter - https://www.hl7.org/fhir/compartmentdefinition-encounter.json
    • RelatedPerson - https://www.hl7.org/fhir/compartmentdefinition-relatedperson.json
    • Practitioner - https://www.hl7.org/fhir/compartmentdefinition-practitioner.json
    • Device - https://www.hl7.org/fhir/compartmentdefinition-device.json
    This class extracts the Compartment Logic from SearchUtil, converts the Custom Compartment logic and format into the ComponentDefintion, adds support for the the default definition.
    Load 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.
    • 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
        Throws:
        IOException
      • buildMaps

        public static final void buildMaps​(String source,
                                           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:
        the - source resource to be read using getResourceAsStream
        compMap - map of compartment name to CompartmentCache
        resourceCompMap - map of resource type name to ResourceCompartmentCache
        Throws:
        IOException
      • 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 and 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 and 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} ... etc.
        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: