Package com.ibm.fhir.term.util
Class CodeSystemSupport
- java.lang.Object
-
- com.ibm.fhir.term.util.CodeSystemSupport
-
public final class CodeSystemSupport extends Object
A utility class for working with FHIR code systems
-
-
Field Summary
Fields Modifier and Type Field Description static Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String>CODE_VALUE_FUNCTIONA function that maps a code system concept to its code valuestatic Function<com.ibm.fhir.model.resource.CodeSystem.Concept,com.ibm.fhir.model.resource.CodeSystem.Concept>CONCEPT_NO_CHILDREN_FUNCTIONA function that maps a code system concept to a code system concept with child concepts removedstatic Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String>DISPLAY_VALUE_FUNCTIONA function that maps a code system concept to its display valuestatic Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String>NORMALIZED_CODE_VALUE_FUNCTIONA function that maps a code system concept to its normalized code valuestatic Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String>NORMALIZED_DISPLAY_VALUE_FUNCTIONA function that maps a code system concept to its normalized display valuestatic Function<com.ibm.fhir.model.resource.CodeSystem.Concept,com.ibm.fhir.model.resource.CodeSystem.Concept>SIMPLE_CONCEPT_FUNCTIONA 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 booleanconvertsToBoolean(com.ibm.fhir.model.type.String value)Determine if the given FHIR string value can be converted to a FHIR Boolean value.static com.ibm.fhir.model.resource.CodeSystem.ConceptfindConcept(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.resource.CodeSystem.Concept concept, com.ibm.fhir.model.type.Code code)Find the concept in tree rooted by the provided concept that matches the specified code.static com.ibm.fhir.model.resource.CodeSystem.ConceptfindConcept(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code)Find the concept in the provided code system that matches the specified code.static Set<String>getAncestorsAndSelf(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code)static com.ibm.fhir.model.resource.CodeSystemgetCodeSystem(String url)Get the code system associated with the given url from the FHIR registry.static com.ibm.fhir.model.resource.CodeSystem.FiltergetCodeSystemFilter(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code, com.ibm.fhir.model.type.code.FilterOperator operator)Get the code system filter with the given property code and filter operator.static com.ibm.fhir.model.resource.CodeSystem.PropertygetCodeSystemProperty(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code)Get the code system property that matches the specified code.static com.ibm.fhir.model.type.code.PropertyTypegetCodeSystemPropertyType(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code)Get the type of the code system property that matches the specified code.static Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String>getCodeValueFunction(com.ibm.fhir.model.resource.CodeSystem codeSystem)Get the appropriate code value function for the given code system based on its case sensitivity.static com.ibm.fhir.model.resource.CodeSystem.Concept.PropertygetConceptProperty(com.ibm.fhir.model.resource.CodeSystem.Concept concept, com.ibm.fhir.model.type.Code code)Get the concept property that matches the specified code.static com.ibm.fhir.model.type.ElementgetConceptPropertyValue(com.ibm.fhir.model.resource.CodeSystem.Concept concept, com.ibm.fhir.model.type.Code code)Get the value of the concept property that matches the specified code.static Set<com.ibm.fhir.model.resource.CodeSystem.Concept>getConcepts(com.ibm.fhir.model.resource.CodeSystem codeSystem)Get a set containingCodeSystem.Conceptinstances where all structural hierarchies have been flattened.static Set<com.ibm.fhir.model.resource.CodeSystem.Concept>getConcepts(com.ibm.fhir.model.resource.CodeSystem.Concept concept)Get a set containingCodeSystem.Conceptinstances where all structural hierarchies have been flattened.static <R> Set<R>getConcepts(com.ibm.fhir.model.resource.CodeSystem.Concept concept, Function<com.ibm.fhir.model.resource.CodeSystem.Concept,? extends R> function)Get a set containingCodeSystemSupportinstances mapped from concepts where all structural hierarchies have been flattened.static <R> Set<R>getConcepts(com.ibm.fhir.model.resource.CodeSystem codeSystem, Function<com.ibm.fhir.model.resource.CodeSystem.Concept,? extends R> function)Get a set containingCodeSystemSupportinstances mapped from concepts where all structural hierarchies have been flattened.static Set<com.ibm.fhir.model.resource.CodeSystem.Concept>getConcepts(com.ibm.fhir.model.resource.CodeSystem codeSystem, List<com.ibm.fhir.model.resource.ValueSet.Compose.Include.Filter> filters)Get a set containingCodeSystem.Conceptinstances where all structural hierarchies have been flattened and filtered by the given set of value set include filters.static <R> Set<R>getConcepts(com.ibm.fhir.model.resource.CodeSystem codeSystem, List<com.ibm.fhir.model.resource.ValueSet.Compose.Include.Filter> filters, Function<com.ibm.fhir.model.resource.CodeSystem.Concept,? extends R> function)Get a set containingCodeSystemSupportinstances mapped from concepts where all structural hierarchies have been flattened and filtered by the given set of value set include filters.static Set<String>getDescendantsAndSelf(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code)static booleanhasCodeSystemFilter(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code, com.ibm.fhir.model.type.code.FilterOperator operator)Determine whether a code system filter with the specified property code and filter operator exists in the provided code system.static booleanhasCodeSystemProperty(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code)Determine whether a code system property with the specified code exists in the provided code system.static booleanhasConceptProperty(com.ibm.fhir.model.resource.CodeSystem.Concept concept, com.ibm.fhir.model.type.Code code)Determine whether a concept property with the specified code exists on the provided concept.static booleanisCaseSensitive(com.ibm.fhir.model.resource.CodeSystem codeSystem)Indicates whether the code system is case sensitivestatic booleanisCaseSensitive(String url)Indicates whether the code system with the given url is case sensitivestatic Stringnormalize(String value)Normalize the string by making it case and accent insensitive.static com.ibm.fhir.model.type.BooleantoBoolean(com.ibm.fhir.model.type.String value)Convert the given FHIR string value to a FHIR boolean value.static com.ibm.fhir.model.type.ElementtoElement(com.ibm.fhir.model.type.String value, com.ibm.fhir.model.type.code.PropertyType type)Convert the given FHIR string value to an Element value based on the provided property type.static com.ibm.fhir.model.type.ElementtoElement(String value, com.ibm.fhir.model.type.code.PropertyType type)Convert the given Java string value to an Element based on the provided property type.static LongtoLong(com.ibm.fhir.model.type.DateTime dateTime)Convert theDateTimevalue to a Long value.static ObjecttoObject(com.ibm.fhir.model.type.Element value)Convert the given element value to an object value.
-
-
-
Field Detail
-
CODE_VALUE_FUNCTION
public static final Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String> CODE_VALUE_FUNCTION
A function that maps a code system concept to its code value
-
NORMALIZED_CODE_VALUE_FUNCTION
public static final Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String> NORMALIZED_CODE_VALUE_FUNCTION
A function that maps a code system concept to its normalized code value
-
DISPLAY_VALUE_FUNCTION
public static final Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String> DISPLAY_VALUE_FUNCTION
A function that maps a code system concept to its display value
-
NORMALIZED_DISPLAY_VALUE_FUNCTION
public static final Function<com.ibm.fhir.model.resource.CodeSystem.Concept,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 Function<com.ibm.fhir.model.resource.CodeSystem.Concept,com.ibm.fhir.model.resource.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 Function<com.ibm.fhir.model.resource.CodeSystem.Concept,com.ibm.fhir.model.resource.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(com.ibm.fhir.model.type.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 com.ibm.fhir.model.resource.CodeSystem.Concept findConcept(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.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 com.ibm.fhir.model.resource.CodeSystem.Concept findConcept(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.resource.CodeSystem.Concept concept, com.ibm.fhir.model.type.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 Set<String> getAncestorsAndSelf(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code)
-
getCodeSystem
public static com.ibm.fhir.model.resource.CodeSystem getCodeSystem(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 com.ibm.fhir.model.resource.CodeSystem.Filter getCodeSystemFilter(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code, com.ibm.fhir.model.type.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 com.ibm.fhir.model.resource.CodeSystem.Property getCodeSystemProperty(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.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 com.ibm.fhir.model.type.code.PropertyType getCodeSystemPropertyType(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.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 Function<com.ibm.fhir.model.resource.CodeSystem.Concept,String> getCodeValueFunction(com.ibm.fhir.model.resource.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 com.ibm.fhir.model.resource.CodeSystem.Concept.Property getConceptProperty(com.ibm.fhir.model.resource.CodeSystem.Concept concept, com.ibm.fhir.model.type.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 com.ibm.fhir.model.type.Element getConceptPropertyValue(com.ibm.fhir.model.resource.CodeSystem.Concept concept, com.ibm.fhir.model.type.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 Set<com.ibm.fhir.model.resource.CodeSystem.Concept> getConcepts(com.ibm.fhir.model.resource.CodeSystem codeSystem)
Get a set containingCodeSystem.Conceptinstances 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> Set<R> getConcepts(com.ibm.fhir.model.resource.CodeSystem codeSystem, Function<com.ibm.fhir.model.resource.CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupportinstances 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
CodeSystemSupportinstances mapped from concepts for the given code system
-
getConcepts
public static Set<com.ibm.fhir.model.resource.CodeSystem.Concept> getConcepts(com.ibm.fhir.model.resource.CodeSystem codeSystem, List<com.ibm.fhir.model.resource.ValueSet.Compose.Include.Filter> filters)
Get a set containingCodeSystem.Conceptinstances 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> Set<R> getConcepts(com.ibm.fhir.model.resource.CodeSystem codeSystem, List<com.ibm.fhir.model.resource.ValueSet.Compose.Include.Filter> filters, Function<com.ibm.fhir.model.resource.CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupportinstances 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
CodeSystemSupportinstances mapped from concepts for the given code system
-
getConcepts
public static Set<com.ibm.fhir.model.resource.CodeSystem.Concept> getConcepts(com.ibm.fhir.model.resource.CodeSystem.Concept concept)
Get a set containingCodeSystem.Conceptinstances 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> Set<R> getConcepts(com.ibm.fhir.model.resource.CodeSystem.Concept concept, Function<com.ibm.fhir.model.resource.CodeSystem.Concept,? extends R> function)
Get a set containingCodeSystemSupportinstances 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
CodeSystemSupportinstances mapped from concepts for the given tree
-
getDescendantsAndSelf
public static Set<String> getDescendantsAndSelf(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code)
-
hasCodeSystemFilter
public static boolean hasCodeSystemFilter(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.Code code, com.ibm.fhir.model.type.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(com.ibm.fhir.model.resource.CodeSystem codeSystem, com.ibm.fhir.model.type.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(com.ibm.fhir.model.resource.CodeSystem.Concept concept, com.ibm.fhir.model.type.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(com.ibm.fhir.model.resource.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(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 String normalize(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 com.ibm.fhir.model.type.Boolean toBoolean(com.ibm.fhir.model.type.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 com.ibm.fhir.model.type.Element toElement(String value, com.ibm.fhir.model.type.code.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 com.ibm.fhir.model.type.Element toElement(com.ibm.fhir.model.type.String value, com.ibm.fhir.model.type.code.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 Long toLong(com.ibm.fhir.model.type.DateTime dateTime)
Convert theDateTimevalue to a Long value.- Parameters:
dateTime- the dateTime value- Returns:
- the Long equivalent value (milliseconds from the epoch)
-
toObject
public static Object toObject(com.ibm.fhir.model.type.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
-
-