Class CompartmentHelper


  • public class CompartmentHelper
    extends java.lang.Object
    A helper class with methods for working with HL7 FHIR compartments.
    The compartments are defined by the CompartmentDefinition resources in FHIRRegistry.
    The R4 CompartmentDefintions and boundaries are defined at https://hl7.org/fhir/R4/compartmentdefinition.html

    Default 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void buildMaps​(java.util.Map<java.lang.String,​CompartmentCache> compMap, java.util.Map<java.lang.String,​ResourceCompartmentCache> resourceCompMap)
      Builds an in-memory model of the Compartment map defined in compartments.json, for supporting compartment based FHIR searches.
      void checkValidCompartment​(java.lang.String compartment)
      checks that the compartment is valid and throws an exception if not
      void checkValidCompartmentAndResource​(java.lang.String compartment, java.lang.String resourceType)
      checks that the compartment and resource are valid and throws an exception if not
      java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> getCompartmentParamsForResourceType​(java.lang.String resourceType)
      Get the map of parameter names used as compartment references for the given resource type.
      java.util.Set<java.lang.String> getCompartmentResourceTypeInclusionCriteria​(java.lang.String compartment, java.lang.String resourceType)
      gets the compartment and resource type inclusion criteria.
      java.util.Set<java.lang.String> getCompartmentResourceTypes​(java.lang.String compartment)
      get the resource types that can be in the compartment
      boolean isCompartmentType​(java.lang.String compartment)  
      static java.lang.String makeCompartmentParamName​(java.lang.String compartmentName)
      Create the special parameter name used for references to the given compartment (e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CUSTOM_COMPARTMENT_TYPE_EXT

        public static final java.lang.String CUSTOM_COMPARTMENT_TYPE_EXT
        See Also:
        Constant Field Values
      • INVALID_COMPARTMENT

        public static final java.lang.String INVALID_COMPARTMENT
        See Also:
        Constant Field Values
      • INVALID_COMPARTMENT_AND_RESOURCE

        public static final java.lang.String INVALID_COMPARTMENT_AND_RESOURCE
        See Also:
        Constant Field Values
    • Constructor Detail

      • CompartmentHelper

        public CompartmentHelper()
    • Method Detail

      • buildMaps

        public static final void buildMaps​(java.util.Map<java.lang.String,​CompartmentCache> compMap,
                                           java.util.Map<java.lang.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
      • getCompartmentResourceTypes

        public java.util.Set<java.lang.String> getCompartmentResourceTypes​(java.lang.String compartment)
                                                                    throws FHIRSearchException
        get the resource types that can be in the compartment
        Parameters:
        compartment - the compartment code value (resourceType name) to look up
        Returns:
        Throws:
        FHIRSearchException
      • getCompartmentResourceTypeInclusionCriteria

        public java.util.Set<java.lang.String> getCompartmentResourceTypeInclusionCriteria​(java.lang.String compartment,
                                                                                           java.lang.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
      • isCompartmentType

        public boolean isCompartmentType​(java.lang.String compartment)
        Parameters:
        compartment -
        Returns:
        whether the passed string matches the name of a configured CompartmentDefinition
      • checkValidCompartment

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

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

        public java.util.Map<java.lang.String,​java.util.Set<java.lang.String>> getCompartmentParamsForResourceType​(java.lang.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 from parameter name to the set of compartment names for which that parameter is an inclusion criteria
      • makeCompartmentParamName

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