Package com.ibm.fhir.search.compartment
Class CompartmentUtil
- java.lang.Object
-
- com.ibm.fhir.search.compartment.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
init()
to initialize static members and avoid a slight performance hit on first use.
-
-
Field Summary
Fields Modifier and Type Field Description static String
CUSTOM_COMPARTMENT_TYPE_EXT
static String
INVALID_COMPARTMENT
static String
INVALID_COMPARTMENT_AND_RESOURCE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.static void
checkValidCompartment(String compartment)
checks that the compartment is valid and throws an exception if notstatic void
checkValidCompartmentAndResource(String compartment, String resourceType)
checks that the compartment and resource are valid and throws an exception if notstatic Map<String,Set<String>>
getCompartmentParamsForResourceType(String resourceType)
Get the map of parameter names used as compartment references for the given resource type.static List<String>
getCompartmentResourceTypeInclusionCriteria(String compartment, String resourceType)
gets the compartment and resource type inclusion criteria.static List<String>
getCompartmentResourceTypes(String compartment)
gets the compartmentstatic void
init()
Loads the class in the classloader to initialize static members.static String
makeCompartmentParamName(String compartmentName)
Create the special parameter name used for references to the given compartment (e.g.
-
-
-
Field Detail
-
CUSTOM_COMPARTMENT_TYPE_EXT
public static final String CUSTOM_COMPARTMENT_TYPE_EXT
- See Also:
- Constant Field Values
-
INVALID_COMPARTMENT
public static final String INVALID_COMPARTMENT
- See Also:
- Constant Field Values
-
INVALID_COMPARTMENT_AND_RESOURCE
public static final String INVALID_COMPARTMENT_AND_RESOURCE
- See Also:
- Constant Field Values
-
-
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 CompartmentCacheresourceCompMap
- map of resource type name to ResourceCompartmentCache
-
getCompartmentResourceTypes
public static List<String> getCompartmentResourceTypes(String compartment) throws FHIRSearchException
gets the compartment- Parameters:
compartment
-- Returns:
- Throws:
FHIRSearchException
-
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
-
-