Package com.ibm.fhir.search.compartment
Class CompartmentUtil
- java.lang.Object
-
- com.ibm.fhir.search.compartment.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
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.
-
-
Field Summary
Fields Modifier and Type Field Description static StringFHIR_PATH_BUNDLE_ENTRYstatic StringFROM_STREAMstatic StringINVALID_COMPARTMENTstatic StringINVALID_COMPARTMENT_AND_RESOURCEstatic StringIO_EXCEPTIONstatic StringPARSE_EXCEPTIONstatic StringRESOURCE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbuildCompositeBundle(PrintStream out)builds the bundle and the resources for the compartments.json and puts out to the output stream.static voidbuildMaps(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.static voidbuildMaps(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 voidcheckValidCompartment(String compartment)checks that the compartment is valid, and throws and exception if, notstatic voidcheckValidCompartmentAndResource(String compartment, String resourceType)checks that the compartment and resource are valid, and throws and 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 voidinit()Loads the class in the classloader to initialize static members.static StringmakeCompartmentParamName(String compartmentName)Create the special parameter name used for references to the given compartment (e.g.
-
-
-
Field Detail
-
FHIR_PATH_BUNDLE_ENTRY
public static final String FHIR_PATH_BUNDLE_ENTRY
- See Also:
- Constant Field Values
-
RESOURCE
public static final String RESOURCE
- See Also:
- Constant Field Values
-
PARSE_EXCEPTION
public static final String PARSE_EXCEPTION
- See Also:
- Constant Field Values
-
IO_EXCEPTION
public static final String IO_EXCEPTION
- 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
-
FROM_STREAM
public static final String FROM_STREAM
- 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- 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 getResourceAsStreamcompMap- map of compartment name to CompartmentCacheresourceCompMap- map of resource type name to ResourceCompartmentCache- Throws:
IOException
-
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 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
-
buildCompositeBundle
public static void buildCompositeBundle(PrintStream out) throws FHIRGeneratorException
builds the bundle and the resources for the compartments.json and puts out to the output stream.- Throws:
FHIRGeneratorException
-
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
-
-