Package com.ibm.fhir.term.util
Class CodeSystemSupport
- java.lang.Object
-
- com.ibm.fhir.term.util.CodeSystemSupport
-
public final class CodeSystemSupport extends java.lang.Object
A utility class for working with FHIR code systems
-
-
Field Summary
Fields Modifier and Type Field Description static CacheManager.Configuration
ANCESTORS_AND_SELF_CACHE_CONFIG
static java.lang.String
ANCESTORS_AND_SELF_CACHE_NAME
static java.util.function.Function<CodeSystem.Concept,java.lang.String>
CODE_VALUE_FUNCTION
A function that maps a code system concept to its code valuestatic java.util.function.Function<CodeSystem.Concept,CodeSystem.Concept>
CONCEPT_NO_CHILDREN_FUNCTION
A function that maps a code system concept to a code system concept with child concepts removedstatic CacheManager.Configuration
DESCENDANTS_AND_SELF_CACHE_CONFIG
static java.lang.String
DESCENDANTS_AND_SELF_CACHE_NAME
static java.util.function.Function<CodeSystem.Concept,java.lang.String>
DISPLAY_VALUE_FUNCTION
A function that maps a code system concept to its display valuestatic java.util.function.Function<CodeSystem.Concept,java.lang.String>
NORMALIZED_CODE_VALUE_FUNCTION
A function that maps a code system concept to its normalized code valuestatic java.util.function.Function<CodeSystem.Concept,java.lang.String>
NORMALIZED_DISPLAY_VALUE_FUNCTION
A function that maps a code system concept to its normalized display valuestatic java.util.function.Function<CodeSystem.Concept,CodeSystem.Concept>
SIMPLE_CONCEPT_FUNCTION
A function that maps a code system concept to a code system concept with only a code and display value
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
convertsToBoolean(String value)
Determine if the given FHIR string value can be converted to a FHIR Boolean value.static CodeSystem.Concept
findConcept(CodeSystem codeSystem, CodeSystem.Concept concept, Code code)
Find the concept in tree rooted by the provided concept that matches the specified code.static CodeSystem.Concept
findConcept(CodeSystem codeSystem, Code code)
Find the concept in the provided code system that matches the specified code.static java.util.Set<java.lang.String>
getAncestorsAndSelf(CodeSystem codeSystem, Code code)
Get all of the concepts, from the provided code system, that subsume the concept with the specified code.static CodeSystem
getCodeSystem(java.lang.String url)
Get the code system associated with the given url from the FHIR registry.static CodeSystem.Filter
getCodeSystemFilter(CodeSystem codeSystem, Code code, FilterOperator operator)
Get the code system filter with the given property code and filter operator.static CodeSystem.Property
getCodeSystemProperty(CodeSystem codeSystem, Code code)
Get the code system property that matches the specified code.static PropertyType
getCodeSystemPropertyType(CodeSystem codeSystem, Code code)
Get the type of the code system property that matches the specified code.static java.util.function.Function<CodeSystem.Concept,java.lang.String>
getCodeValueFunction(CodeSystem codeSystem)
Get the appropriate code value function for the given code system based on its case sensitivity.static CodeSystem.Concept.Property
getConceptProperty(CodeSystem.Concept concept, Code code)
Get the concept property that matches the specified code.static Element
getConceptPropertyValue(CodeSystem.Concept concept, Code code)
Get the value of the concept property that matches the specified code.static java.util.Set<CodeSystem.Concept>
getConcepts(CodeSystem codeSystem)
Get a set containingCodeSystem.Concept
instances where all structural hierarchies have been flattened.static java.util.Set<CodeSystem.Concept>
getConcepts(CodeSystem.Concept concept)
Get a set containingCodeSystem.Concept
instances where all structural hierarchies have been flattened.static <R> java.util.Set<R>
getConcepts(CodeSystem.Concept concept, java.util.function.Function<CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupport
instances mapped from concepts where all structural hierarchies have been flattened.static <R> java.util.Set<R>
getConcepts(CodeSystem codeSystem, java.util.function.Function<CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupport
instances mapped from concepts where all structural hierarchies have been flattened.static java.util.Set<CodeSystem.Concept>
getConcepts(CodeSystem codeSystem, java.util.List<ValueSet.Compose.Include.Filter> filters)
Get a set containingCodeSystem.Concept
instances where all structural hierarchies have been flattened and filtered by the given set of value set include filters.static <R> java.util.Set<R>
getConcepts(CodeSystem codeSystem, java.util.List<ValueSet.Compose.Include.Filter> filters, java.util.function.Function<CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupport
instances mapped from concepts where all structural hierarchies have been flattened and filtered by the given set of value set include filters.static java.util.Set<java.lang.String>
getDescendantsAndSelf(CodeSystem codeSystem, Code code)
Get all of the concepts, from the provided code system, that are subsumed by the concept with the specified code.static boolean
hasCodeSystemFilter(CodeSystem codeSystem, Code code, FilterOperator operator)
Determine whether a code system filter with the specified property code and filter operator exists in the provided code system.static boolean
hasCodeSystemProperty(CodeSystem codeSystem, Code code)
Determine whether a code system property with the specified code exists in the provided code system.static boolean
hasConceptProperty(CodeSystem.Concept concept, Code code)
Determine whether a concept property with the specified code exists on the provided concept.static boolean
isCaseSensitive(CodeSystem codeSystem)
Indicates whether the code system is case sensitivestatic boolean
isCaseSensitive(java.lang.String url)
Indicates whether the code system with the given url is case sensitivestatic java.lang.String
normalize(java.lang.String value)
Normalize the string by making it case and accent insensitive.static Boolean
toBoolean(String value)
Convert the given FHIR string value to a FHIR boolean value.static Element
toElement(String value, PropertyType type)
Convert the given FHIR string value to an Element value based on the provided property type.static Element
toElement(java.lang.String value, PropertyType type)
Convert the given Java string value to an Element based on the provided property type.static java.lang.Long
toLong(DateTime dateTime)
Convert theDateTime
value to a Long value.static java.lang.Object
toObject(Element value)
Convert the given element value to an object value.
-
-
-
Field Detail
-
ANCESTORS_AND_SELF_CACHE_NAME
public static final java.lang.String ANCESTORS_AND_SELF_CACHE_NAME
- See Also:
- Constant Field Values
-
DESCENDANTS_AND_SELF_CACHE_NAME
public static final java.lang.String DESCENDANTS_AND_SELF_CACHE_NAME
- See Also:
- Constant Field Values
-
ANCESTORS_AND_SELF_CACHE_CONFIG
public static final CacheManager.Configuration ANCESTORS_AND_SELF_CACHE_CONFIG
-
DESCENDANTS_AND_SELF_CACHE_CONFIG
public static final CacheManager.Configuration DESCENDANTS_AND_SELF_CACHE_CONFIG
-
CODE_VALUE_FUNCTION
public static final java.util.function.Function<CodeSystem.Concept,java.lang.String> CODE_VALUE_FUNCTION
A function that maps a code system concept to its code value
-
NORMALIZED_CODE_VALUE_FUNCTION
public static final java.util.function.Function<CodeSystem.Concept,java.lang.String> NORMALIZED_CODE_VALUE_FUNCTION
A function that maps a code system concept to its normalized code value
-
DISPLAY_VALUE_FUNCTION
public static final java.util.function.Function<CodeSystem.Concept,java.lang.String> DISPLAY_VALUE_FUNCTION
A function that maps a code system concept to its display value
-
NORMALIZED_DISPLAY_VALUE_FUNCTION
public static final java.util.function.Function<CodeSystem.Concept,java.lang.String> NORMALIZED_DISPLAY_VALUE_FUNCTION
A function that maps a code system concept to its normalized display value
-
CONCEPT_NO_CHILDREN_FUNCTION
public static final java.util.function.Function<CodeSystem.Concept,CodeSystem.Concept> CONCEPT_NO_CHILDREN_FUNCTION
A function that maps a code system concept to a code system concept with child concepts removed
-
SIMPLE_CONCEPT_FUNCTION
public static final java.util.function.Function<CodeSystem.Concept,CodeSystem.Concept> SIMPLE_CONCEPT_FUNCTION
A function that maps a code system concept to a code system concept with only a code and display value
-
-
Method Detail
-
convertsToBoolean
public static boolean convertsToBoolean(String value)
Determine if the given FHIR string value can be converted to a FHIR Boolean value.- Parameters:
value
- the FHIR string value- Returns:
- true if the given FHIR string value can be converted to a FHIR Boolean value, false otherwise
-
findConcept
public static CodeSystem.Concept findConcept(CodeSystem codeSystem, Code code)
Find the concept in the provided code system that matches the specified code.- Parameters:
codeSystem
- the code system to searchcode
- the code to match- Returns:
- the code system concept that matches the specified code, or null if no such concept exists
-
findConcept
public static CodeSystem.Concept findConcept(CodeSystem codeSystem, CodeSystem.Concept concept, Code code)
Find the concept in tree rooted by the provided concept that matches the specified code.- Parameters:
codeSystem
- the code systemconcept
- the root of the tree to searchcode
- the code to match- Returns:
- the code system concept that matches the specified code, or null if not such concept exists
-
getAncestorsAndSelf
public static java.util.Set<java.lang.String> getAncestorsAndSelf(CodeSystem codeSystem, Code code)
Get all of the concepts, from the provided code system, that subsume the concept with the specified code.- Parameters:
codeSystem
- the code systemcode
- the code- Returns:
- a set containing the code value for all concepts that subsume the concept with the specified code
-
getCodeSystem
public static CodeSystem getCodeSystem(java.lang.String url)
Get the code system associated with the given url from the FHIR registry.- Parameters:
url
- the url of the code system- Returns:
- the code system associated with the given input parameter, or null if no such code system exists
-
getCodeSystemFilter
public static CodeSystem.Filter getCodeSystemFilter(CodeSystem codeSystem, Code code, FilterOperator operator)
Get the code system filter with the given property code and filter operator.- Parameters:
codeSystem
- the code systemcode
- the property codeoperator
- the filter operator- Returns:
- the code system filter with the given property code and filter operator, or null if no such filter exists
-
getCodeSystemProperty
public static CodeSystem.Property getCodeSystemProperty(CodeSystem codeSystem, Code code)
Get the code system property that matches the specified code.- Parameters:
codeSystem
- the code systemcode
- the property code to match- Returns:
- the code system property that matches the specified code, or null if no such property exists
-
getCodeSystemPropertyType
public static PropertyType getCodeSystemPropertyType(CodeSystem codeSystem, Code code)
Get the type of the code system property that matches the specified code.- Parameters:
codeSystem
- the code systemcode
- the property code to match- Returns:
- the type of the code system property that matches the specified code, or null if no such property exists
-
getCodeValueFunction
public static java.util.function.Function<CodeSystem.Concept,java.lang.String> getCodeValueFunction(CodeSystem codeSystem)
Get the appropriate code value function for the given code system based on its case sensitivity.- Parameters:
codeSystem
- the code system- Returns:
- the appropriate code value function for the given code system based on its case sensitivity
-
getConceptProperty
public static CodeSystem.Concept.Property getConceptProperty(CodeSystem.Concept concept, Code code)
Get the concept property that matches the specified code.- Parameters:
concept
- the conceptcode
- the property code to match- Returns:
- the concept property that matches the specified code, or null if no such property exists
-
getConceptPropertyValue
public static Element getConceptPropertyValue(CodeSystem.Concept concept, Code code)
Get the value of the concept property that matches the specified code.- Parameters:
concept
- the conceptcode
- the property code to match- Returns:
- the value of the concept property that matches the specified code, or null if no such property exists
-
getConcepts
public static java.util.Set<CodeSystem.Concept> getConcepts(CodeSystem codeSystem)
Get a set containingCodeSystem.Concept
instances where all structural hierarchies have been flattened.- Parameters:
codeSystem
- the code system containing the set of Concept instances to be flattened- Returns:
- flattened set of Concept instances for the given code system
-
getConcepts
public static <R> java.util.Set<R> getConcepts(CodeSystem codeSystem, java.util.function.Function<CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupport
instances mapped from concepts where all structural hierarchies have been flattened.- Type Parameters:
R
- the element type of the result set- Parameters:
codeSystem
- the code system containing the set of Concept instances to be flattenedfunction
- the function to apply to each element of the result set- Returns:
- flattened set of
CodeSystemSupport
instances mapped from concepts for the given code system
-
getConcepts
public static java.util.Set<CodeSystem.Concept> getConcepts(CodeSystem codeSystem, java.util.List<ValueSet.Compose.Include.Filter> filters)
Get a set containingCodeSystem.Concept
instances where all structural hierarchies have been flattened and filtered by the given set of value set include filters.- Parameters:
codeSystem
- the code system containing the set of Concept instances to be flattened / filteredfilters
- the value set include filters- Returns:
- flattened / filtered set of Concept instances for the given code system
-
getConcepts
public static <R> java.util.Set<R> getConcepts(CodeSystem codeSystem, java.util.List<ValueSet.Compose.Include.Filter> filters, java.util.function.Function<CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupport
instances mapped from concepts where all structural hierarchies have been flattened and filtered by the given set of value set include filters.- Type Parameters:
R
- the element type of the result set- Parameters:
codeSystem
- the code system containing the set of Concept instances to be flattened / filteredfilters
- the value set include filtersfunction
- the function to apply to each element of the result set- Returns:
- flattened / filtered set of
CodeSystemSupport
instances mapped from concepts for the given code system
-
getConcepts
public static java.util.Set<CodeSystem.Concept> getConcepts(CodeSystem.Concept concept)
Get a set containingCodeSystem.Concept
instances where all structural hierarchies have been flattened.- Parameters:
concept
- the root of the tree containing the Concept instances to be flattened- Returns:
- flattened set of Concept instances for the given tree
-
getConcepts
public static <R> java.util.Set<R> getConcepts(CodeSystem.Concept concept, java.util.function.Function<CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupport
instances mapped from concepts where all structural hierarchies have been flattened.- Type Parameters:
R
- the element type of the result set- Parameters:
concept
- the root of the tree containing the Concept instances to be flattenedfunction
- the function to apply to each element of the result set- Returns:
- flattened set of
CodeSystemSupport
instances mapped from concepts for the given tree
-
getDescendantsAndSelf
public static java.util.Set<java.lang.String> getDescendantsAndSelf(CodeSystem codeSystem, Code code)
Get all of the concepts, from the provided code system, that are subsumed by the concept with the specified code.- Parameters:
codeSystem
- the code systemcode
- the code- Returns:
- a set containing the code value for all concepts that are subsumed by the concept with the specified code
-
hasCodeSystemFilter
public static boolean hasCodeSystemFilter(CodeSystem codeSystem, Code code, FilterOperator operator)
Determine whether a code system filter with the specified property code and filter operator exists in the provided code system.- Parameters:
codeSystem
- the code systemcode
- the property codeoperator
- the filter operator- Returns:
- true if the code system filter exists, false otherwise
-
hasCodeSystemProperty
public static boolean hasCodeSystemProperty(CodeSystem codeSystem, Code code)
Determine whether a code system property with the specified code exists in the provided code system.- Parameters:
codeSystem
- the code systemcode
- the property code- Returns:
- true if the code system property exists, false otherwise
-
hasConceptProperty
public static boolean hasConceptProperty(CodeSystem.Concept concept, Code code)
Determine whether a concept property with the specified code exists on the provided concept.- Parameters:
concept
- the conceptcode
- the property code- Returns:
- true if the concept property exists, false otherwise
-
isCaseSensitive
public static boolean isCaseSensitive(CodeSystem codeSystem)
Indicates whether the code system is case sensitive- Parameters:
codeSystem
- the code system- Returns:
- true if the code system is case sensitive, false otherwise
-
isCaseSensitive
public static boolean isCaseSensitive(java.lang.String url)
Indicates whether the code system with the given url is case sensitive- Parameters:
url
- the url- Returns:
- true if the code system with the given is case sensitive, false otherwise
-
normalize
public static java.lang.String normalize(java.lang.String value)
Normalize the string by making it case and accent insensitive.- Parameters:
value
- the string value to normalized- Returns:
- the normalized string value
-
toBoolean
public static Boolean toBoolean(String value)
Convert the given FHIR string value to a FHIR boolean value.- Parameters:
value
- the FHIR string value- Returns:
- the FHIR boolean value equivalent of the provided FHIR string value
-
toElement
public static Element toElement(java.lang.String value, PropertyType type)
Convert the given Java string value to an Element based on the provided property type.- Parameters:
value
- the Java string valuetype
- the property type- Returns:
- the Element value equivalent of the given Java string based on the provided property type, or null if the type isn't supported
-
toElement
public static Element toElement(String value, PropertyType type)
Convert the given FHIR string value to an Element value based on the provided property type.- Parameters:
value
- the FHIR string valuetype
- the property type- Returns:
- the Element value equivalent of the given FHIR string based on the provided property type, or null if the type isn't supported
-
toLong
public static java.lang.Long toLong(DateTime dateTime)
Convert theDateTime
value to a Long value.- Parameters:
dateTime
- the dateTime value- Returns:
- the Long equivalent value (milliseconds from the epoch)
-
toObject
public static java.lang.Object toObject(Element value)
Convert the given element value to an object value.- Parameters:
value
- the element value- Returns:
- an object value that is compatible with the graph schema
-
-