Class CodeSystemSupport


  • public final class CodeSystemSupport
    extends Object
    A utility class for working with FHIR code systems
    • 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 search
        code - 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 system
        concept - the root of the tree to search
        code - 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​(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 system
        code - 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​(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 system
        code - the property code
        operator - 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 system
        code - 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 system
        code - 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<CodeSystem.Concept,​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 concept
        code - 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 concept
        code - 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<CodeSystem.Concept> getConcepts​(CodeSystem codeSystem)
        Get a set containing CodeSystem.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> Set<R> getConcepts​(CodeSystem codeSystem,
                                             Function<CodeSystem.Concept,​? extends R> function)
        Get a set containing CodeSystemSupport 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 flattened
        function - 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 Set<CodeSystem.Concept> getConcepts​(CodeSystem codeSystem,
                                                          List<ValueSet.Compose.Include.Filter> filters)
        Get a set containing CodeSystem.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 / filtered
        filters - the value set include filters
        Returns:
        flattened / filtered set of Concept instances for the given code system
      • getConcepts

        public static <R> Set<R> getConcepts​(CodeSystem codeSystem,
                                             List<ValueSet.Compose.Include.Filter> filters,
                                             Function<CodeSystem.Concept,​? extends R> function)
        Get a set containing CodeSystemSupport 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 / filtered
        filters - the value set include filters
        function - 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 Set<CodeSystem.Concept> getConcepts​(CodeSystem.Concept concept)
        Get a set containing CodeSystem.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> Set<R> getConcepts​(CodeSystem.Concept concept,
                                             Function<CodeSystem.Concept,​? extends R> function)
        Get a set containing CodeSystemSupport 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 flattened
        function - 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 Set<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 system
        code - 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 system
        code - the property code
        operator - 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 system
        code - 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 concept
        code - 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​(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 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​(String value,
                                        PropertyType type)
        Convert the given Java string value to an Element based on the provided property type.
        Parameters:
        value - the Java string value
        type - 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 value
        type - 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​(DateTime dateTime)
        Convert the DateTime value to a Long value.
        Parameters:
        dateTime - the dateTime value
        Returns:
        the Long equivalent value (milliseconds from the epoch)
      • toObject

        public static 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