Class ResourceTypeUtil


  • public class ResourceTypeUtil
    extends java.lang.Object
    Helper methods for working with FHIR Resource Type Strings
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Set<java.lang.String> getAbstractResourceTypeNames()  
      static java.util.Set<java.lang.String> getAllResourceTypeNames()
      Get the set of concrete resource type names for all possible FHIRVersionParam values.
      static java.util.Set<java.lang.String> getCompatibleResourceTypes​(FHIRVersionParam sourceFhirVersion, FHIRVersionParam targetFhirVersion)
      Get the set of concrete resource type names for which a valid instance in fhirVersion sourceFhirVersion is expected to be valid in fhirVersion targetFhirVersion.
      static java.util.Set<java.lang.String> getRemovedResourceTypes​(FHIRVersionParam fhirVersion)  
      static java.util.Set<java.lang.String> getResourceTypesFor​(FHIRVersionParam fhirVersion)
      Get the set of concrete resource type names for the passed fhirVersion.
      static boolean isCompatible​(java.lang.String resourceType, FHIRVersionParam knownValidFhirVersion, FHIRVersionParam fhirVersionUnderTest)
      If a resourceType instance of type resourceType is known to be valid in fhirVersion knownValidFhirVersion, is it expected to also be valid for fhirVersion fhirVersionUnderTest?
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ResourceTypeUtil

        public ResourceTypeUtil()
    • Method Detail

      • getAbstractResourceTypeNames

        public static java.util.Set<java.lang.String> getAbstractResourceTypeNames()
        Returns:
        the set of resource type names for all abstract resource types, as of FHIR R4B
      • getRemovedResourceTypes

        public static java.util.Set<java.lang.String> getRemovedResourceTypes​(FHIRVersionParam fhirVersion)
        Parameters:
        fhirVersion - The value of the MIME-type parameter 'fhirVersion' for the current interaction
        Returns:
        the set of resource type names that were retired with, or before, the passed version of FHIR
      • getCompatibleResourceTypes

        public static java.util.Set<java.lang.String> getCompatibleResourceTypes​(FHIRVersionParam sourceFhirVersion,
                                                                                 FHIRVersionParam targetFhirVersion)
        Get the set of concrete resource type names for which a valid instance in fhirVersion sourceFhirVersion is expected to be valid in fhirVersion targetFhirVersion. Does not include any abstract types.
        Parameters:
        sourceFhirVersion - The source fhirVersion for the compatibility checks
        targetFhirVersion - The target fhirVersion for the compatibility checks
        Returns:
        the set of resource type names for which isCompatible(resourceType, sourceFhirVersion, targetFhirVersion) would be true
        See Also:
        isCompatible(String, FHIRVersionParam, FHIRVersionParam)
      • isCompatible

        public static boolean isCompatible​(java.lang.String resourceType,
                                           FHIRVersionParam knownValidFhirVersion,
                                           FHIRVersionParam fhirVersionUnderTest)
        If a resourceType instance of type resourceType is known to be valid in fhirVersion knownValidFhirVersion, is it expected to also be valid for fhirVersion fhirVersionUnderTest?

        Sample usage:

        • isCompatible("Evidence", VERSION_40, VERSION_43) returns 'false' because this resource type has numerous breaking changes in FHIR 4.3
        • isCompatible("ActivityDefinition", VERSION_40, VERSION_43) returns 'true' because a valid ActivityDefinition in FHIR 4.0 is also expected to be valid in FHIR 4.3
        • isCompatible("ActivityDefinition", VERSION_43, VERSION_40) returns 'false' because FHIR 4.3 adds an additional choice type to ActivityDefinition.subject[x] which is not valid in FHIR 4.0
        • isCompatible("Ingredient", VERSION_40, VERSION_43) throws IllegalArgumentException because this resource type was introduced in FHIR 4.3 and therefore fails the "known to be valid in 4.0" precondition
        Parameters:
        resourceType - a valid resource type string
        knownValidFhirVersion - the source fhirVersion for the compatibility check
        fhirVersionUnderTest - the target fhirVersion for the compatibility check
        Returns:
        whether resourceType instances of fhirVersion knownValidFhirVersion are expected to be compatible with the target fhirVersionUnderTest
        Throws:
        java.lang.IllegalArgumentException - if resourceType is not a valid concrete resourceType for fhirVersion knownValidFhirVersion
      • getResourceTypesFor

        public static java.util.Set<java.lang.String> getResourceTypesFor​(FHIRVersionParam fhirVersion)
        Get the set of concrete resource type names for the passed fhirVersion. Does not include any abstract types.
        Parameters:
        fhirVersion - The value of the MIME-type parameter 'fhirVersion' for the current interaction
        Returns:
        a set of resource type names that corresponds to the requested fhirVersion
      • getAllResourceTypeNames

        public static java.util.Set<java.lang.String> getAllResourceTypeNames()
        Get the set of concrete resource type names for all possible FHIRVersionParam values. Does not include any abstract types.
        Returns: