Class ResourceTypeUtil
- java.lang.Object
-
- org.linuxforhealth.fhir.core.util.ResourceTypeUtil
-
public class ResourceTypeUtil extends java.lang.Object
Helper methods for working with FHIR Resource Type Strings
-
-
Constructor Summary
Constructors Constructor Description ResourceTypeUtil()
-
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 fhirVersionsourceFhirVersion
is expected to be valid in fhirVersiontargetFhirVersion
.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 typeresourceType
is known to be valid in fhirVersionknownValidFhirVersion
, is it expected to also be valid for fhirVersionfhirVersionUnderTest
?
-
-
-
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 fhirVersionsourceFhirVersion
is expected to be valid in fhirVersiontargetFhirVersion
. Does not include any abstract types.- Parameters:
sourceFhirVersion
- The source fhirVersion for the compatibility checkstargetFhirVersion
- 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 typeresourceType
is known to be valid in fhirVersionknownValidFhirVersion
, is it expected to also be valid for fhirVersionfhirVersionUnderTest
?Sample usage:
isCompatible("Evidence", VERSION_40, VERSION_43)
returns 'false' because this resource type has numerous breaking changes in FHIR 4.3isCompatible("ActivityDefinition", VERSION_40, VERSION_43)
returns 'true' because a valid ActivityDefinition in FHIR 4.0 is also expected to be valid in FHIR 4.3isCompatible("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.0isCompatible("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 stringknownValidFhirVersion
- the source fhirVersion for the compatibility checkfhirVersionUnderTest
- the target fhirVersion for the compatibility check- Returns:
- whether
resourceType
instances of fhirVersionknownValidFhirVersion
are expected to be compatible with the targetfhirVersionUnderTest
- 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:
-
-