Class IdType
-
- All Implemented Interfaces:
ca.uhn.fhir.model.api.IElement,Externalizable,Serializable,org.hl7.fhir.instance.model.api.IBase,org.hl7.fhir.instance.model.api.IBaseDatatype,org.hl7.fhir.instance.model.api.IBaseElement,org.hl7.fhir.instance.model.api.IBaseHasExtensions,org.hl7.fhir.instance.model.api.IIdType,org.hl7.fhir.instance.model.api.IPrimitiveType<String>
public final class IdType extends UriType implements org.hl7.fhir.instance.model.api.IPrimitiveType<String>, org.hl7.fhir.instance.model.api.IIdType
This class represents the logical identity for a resource, or as much of that identity is known. In FHIR, every resource must have a "logical ID" which is defined by the FHIR specification as:Any combination of upper or lower case ASCII letters ('A'..'Z', and 'a'..'z', numerals ('0'..'9'), '-' and '.', with a length limit of 64 characters. (This might be an integer, an un-prefixed OID, UUID or any other identifier pattern that meets these constraints.)This class contains that logical ID, and can optionally also contain a relative or absolute URL representing the resource identity. For example, the following are all valid values for IdType, and all might represent the same resource:
123(just a resource's ID)Patient/123(a relative identity)http://example.com/Patient/123 (an absolute identity)-
http://example.com/Patient/123/_history/1 (an absolute identity with a version id) -
Patient/123/_history/1 (a relative identity with a version id)
Note that the 64 character limit applies only to the ID portion ("123" in the examples above).
In most situations, you only need to populate the resource's ID (e.g.
123) in resources you are constructing and the encoder will infer the rest from the context in which the object is being used. On the other hand, the parser will always try to populate the complete absolute identity on objects it creates as a convenience.Regex for ID: [a-z0-9\-\.]{1,36}
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_LENGTHThis is the maximum length for the IDstatic StringURN_PREFIX
-
Constructor Summary
Constructors Constructor Description IdType()Create a new empty IDIdType(long theId)Create a new ID using a longIdType(String theValue)Create a new ID using a string.IdType(String theResourceType, Long theIdPart)ConstructorIdType(String theResourceType, String theId)ConstructorIdType(String theResourceType, String theId, String theVersionId)ConstructorIdType(String theBaseUrl, String theResourceType, String theId, String theVersionId)ConstructorIdType(String theResourceType, BigDecimal theIdPart)ConstructorIdType(BigDecimal thePid)Create a new ID, using a BigDecimal input.IdType(UriType theUrl)Creates an ID based on a given URL
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidapplyTo(org.hl7.fhir.instance.model.api.IBaseResource theResouce)BigDecimalasBigDecimal()Deprecated.UsegetIdPartAsBigDecimal()instead (this method was deprocated because its name is ambiguous)IdTypecopy()booleanequals(Object theArg0)booleanequalsIgnoreBase(IdType theId)Returns true if this IdType matches the given IdType in terms of resource type and ID, but ignores the URL baseStringfhirType()StringgetBaseUrl()Returns the portion of this resource ID which corresponds to the server base URL.StringgetIdPart()Returns only the logical ID part of this ID.BigDecimalgetIdPartAsBigDecimal()Returns the unqualified portion of this ID as a big decimal, ornullif the value is nullLonggetIdPartAsLong()Returns the unqualified portion of this ID as aLong, ornullif the value is nullStringgetResourceType()StringgetValue()Returns the value of this ID.StringgetValueAsString()StringgetVersionIdPart()LonggetVersionIdPartAsLong()booleanhasBaseUrl()Returns true if this ID has a base urlinthashCode()booleanhasIdPart()booleanhasResourceType()booleanhasVersionIdPart()booleanisAbsolute()Returnstrueif this ID contains an absolute URL (in other words, a URL starting with "http://" or "https://"booleanisEmpty()booleanisIdPartValid()booleanisIdPartValidLong()Returnstrueif the unqualified ID is a validLongvalue (in other words, it consists only of digits)booleanisLocal()Returnstrueif the ID is a local reference (in other words, it begins with the '#' character)booleanisUrn()booleanisVersionIdPartValidLong()static IdTypenewRandomUuid()Construct a new ID with with form "urn:uuid:[UUID]" where [UUID] is a new, randomly created UUID generated byUUID.randomUUID()static IdTypeof(org.hl7.fhir.instance.model.api.IBaseResource theResouce)Retrieves the ID from the given resource instanceorg.hl7.fhir.instance.model.api.IIdTypesetParts(String theBaseUrl, String theResourceType, String theIdPart, String theVersionIdPart)IdTypesetValue(String theValue)Set the valuevoidsetValueAsString(String theValue)Set the valueStringtoString()IdTypetoUnqualified()Returns a new IdType containing this IdType's values but with no server base URL if one is present in this IdType.IdTypetoUnqualifiedVersionless()IdTypetoVersionless()IdTypewithResourceType(String theResourceName)IdTypewithServerBase(String theServerBase, String theResourceType)Returns a view of this ID as a fully qualified URL, given a server base and resource name (which will only be used if the ID does not already contain those respective parts).IdTypewithVersion(String theVersion)Creates a new instance of this ID which is identical, but refers to the specific version of this resource ID noted by theVersion.-
Methods inherited from class org.hl7.fhir.r4.model.UriType
encode, equals, equalsDeep, fromOid, parse
-
Methods inherited from class org.hl7.fhir.r4.model.PrimitiveType
asStringValue, equalsShallow, forceStringValue, fromStringValue, getProperty, getTypesForProperty, hasPrimitiveValue, hasValue, isPrimitive, makeProperty, primitiveValue, readExternal, setProperty, setProperty, typedCopy, updateStringValue, writeExternal
-
Methods inherited from class org.hl7.fhir.r4.model.Element
addChild, addExtension, addExtension, addExtension, copyValues, getExtension, getExtensionByUrl, getExtensionFirstRep, getExtensionsByUrl, getExtensionString, getId, getIdBase, getIdElement, getNamedProperty, hasExtension, hasExtension, hasId, hasIdElement, isDisallowExtensions, listChildren, noExtensions, removeExtension, setDisallowExtensions, setExtension, setId, setIdBase, setIdElement
-
Methods inherited from class org.hl7.fhir.r4.model.Base
castToAddress, castToAnnotation, castToAttachment, castToBase64Binary, castToBoolean, castToCanonical, castToCode, castToCodeableConcept, castToCoding, castToContactDetail, castToContactPoint, castToContributor, castToDataRequirement, castToDate, castToDateTime, castToDecimal, castToDosage, castToDuration, castToElementDefinition, castToExpression, castToExtension, castToHumanName, castToId, castToIdentifier, castToInstant, castToInteger, castToMarkdown, castToMarketingStatus, castToMeta, castToMoney, castToNarrative, castToOid, castToParameterDefinition, castToPeriod, castToPopulation, castToPositiveInt, castToProdCharacteristic, castToProductShelfLife, castToQuantity, castToRange, castToRatio, castToReference, castToRelatedArtifact, castToResource, castToSampledData, castToSignature, castToSimpleQuantity, castToString, castToSubstanceAmount, castToTime, castToTiming, castToTriggerDefinition, castToType, castToUnsignedInt, castToUri, castToUrl, castToUsageContext, castToXhtml, castToXhtmlString, children, clearUserData, compareDeep, compareDeep, compareDeep, compareDeep, compareValues, compareValues, dateTimeValue, equals, getChildByName, getFormatCommentsPost, getFormatCommentsPre, getNamedProperty, getUserData, getUserInt, getUserString, hasFormatComment, hasType, hasUserData, isBooleanPrimitive, isDateTime, isMetadataBased, isResource, listChildrenByName, listChildrenByName, setUserData, setUserDataINN
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hl7.fhir.instance.model.api.IBase
getFormatCommentsPost, getFormatCommentsPre, getUserData, hasFormatComment, setUserData
-
Methods inherited from interface org.hl7.fhir.instance.model.api.IBaseElement
getUserData, setUserData
-
-
-
-
Field Detail
-
URN_PREFIX
public static final String URN_PREFIX
- See Also:
- Constant Field Values
-
MAX_LENGTH
public static final int MAX_LENGTH
This is the maximum length for the ID- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IdType
public IdType()
Create a new empty ID
-
IdType
public IdType(BigDecimal thePid)
Create a new ID, using a BigDecimal input. UsesBigDecimal.toPlainString()to generate the string representation.
-
IdType
public IdType(long theId)
Create a new ID using a long
-
IdType
public IdType(String theValue)
Create a new ID using a string. This String may contain a simple ID (e.g. "1234") or it may contain a complete URL (http://example.com/fhir/Patient/1234).Description: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
regex: [a-z0-9\-\.]{1,36}
-
IdType
public IdType(String theResourceType, BigDecimal theIdPart)
Constructor- Parameters:
theResourceType- The resource type (e.g. "Patient")theIdPart- The ID (e.g. "123")
-
IdType
public IdType(String theResourceType, Long theIdPart)
Constructor- Parameters:
theResourceType- The resource type (e.g. "Patient")theIdPart- The ID (e.g. "123")
-
IdType
public IdType(String theResourceType, String theId)
Constructor- Parameters:
theResourceType- The resource type (e.g. "Patient")theId- The ID (e.g. "123")
-
IdType
public IdType(String theResourceType, String theId, String theVersionId)
Constructor- Parameters:
theResourceType- The resource type (e.g. "Patient")theId- The ID (e.g. "123")theVersionId- The version ID ("e.g. "456")
-
IdType
public IdType(String theBaseUrl, String theResourceType, String theId, String theVersionId)
Constructor- Parameters:
theBaseUrl- The server base URL (e.g. "http://example.com/fhir")theResourceType- The resource type (e.g. "Patient")theId- The ID (e.g. "123")theVersionId- The version ID ("e.g. "456")
-
-
Method Detail
-
applyTo
public void applyTo(org.hl7.fhir.instance.model.api.IBaseResource theResouce)
- Specified by:
applyToin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
asBigDecimal
@Deprecated public BigDecimal asBigDecimal()
Deprecated.UsegetIdPartAsBigDecimal()instead (this method was deprocated because its name is ambiguous)
-
equalsIgnoreBase
public boolean equalsIgnoreBase(IdType theId)
Returns true if this IdType matches the given IdType in terms of resource type and ID, but ignores the URL base
-
getBaseUrl
public String getBaseUrl()
Returns the portion of this resource ID which corresponds to the server base URL. For example given the resource IDhttp://example.com/fhir/Patient/123the base URL would behttp://example.com/fhir.This method may return null if the ID contains no base (e.g. "Patient/123")
- Specified by:
getBaseUrlin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
getIdPart
public String getIdPart()
Returns only the logical ID part of this ID. For example, given the ID "http://example,.com/fhir/Patient/123/_history/456", this method would return "123".- Specified by:
getIdPartin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
getIdPartAsBigDecimal
public BigDecimal getIdPartAsBigDecimal()
Returns the unqualified portion of this ID as a big decimal, ornullif the value is null- Throws:
NumberFormatException- If the value is not a valid BigDecimal
-
getIdPartAsLong
public Long getIdPartAsLong()
Returns the unqualified portion of this ID as aLong, ornullif the value is null- Specified by:
getIdPartAsLongin interfaceorg.hl7.fhir.instance.model.api.IIdType- Throws:
NumberFormatException- If the value is not a valid Long
-
getResourceType
public String getResourceType()
- Specified by:
getResourceTypein interfaceorg.hl7.fhir.instance.model.api.IIdType
-
getValue
public String getValue()
Returns the value of this ID. Note that this value may be a fully qualified URL, a relative/partial URL, or a simple ID. UsegetIdPart()to get just the ID portion.- Specified by:
getValuein interfaceorg.hl7.fhir.instance.model.api.IIdType- Specified by:
getValuein interfaceorg.hl7.fhir.instance.model.api.IPrimitiveType<String>- Overrides:
getValuein classPrimitiveType<String>- See Also:
getIdPart()
-
setValue
public IdType setValue(String theValue)
Set the valueDescription: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
regex: [a-z0-9\-\.]{1,36}
- Specified by:
setValuein interfaceorg.hl7.fhir.instance.model.api.IIdType- Specified by:
setValuein interfaceorg.hl7.fhir.instance.model.api.IPrimitiveType<String>- Overrides:
setValuein classPrimitiveType<String>
-
getValueAsString
public String getValueAsString()
- Specified by:
getValueAsStringin interfaceorg.hl7.fhir.instance.model.api.IPrimitiveType<String>- Overrides:
getValueAsStringin classPrimitiveType<String>
-
setValueAsString
public void setValueAsString(String theValue)
Set the valueDescription: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
regex: [a-z0-9\-\.]{1,36}
- Specified by:
setValueAsStringin interfaceorg.hl7.fhir.instance.model.api.IPrimitiveType<String>- Overrides:
setValueAsStringin classPrimitiveType<String>
-
getVersionIdPart
public String getVersionIdPart()
- Specified by:
getVersionIdPartin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
getVersionIdPartAsLong
public Long getVersionIdPartAsLong()
- Specified by:
getVersionIdPartAsLongin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
hasBaseUrl
public boolean hasBaseUrl()
Returns true if this ID has a base url- Specified by:
hasBaseUrlin interfaceorg.hl7.fhir.instance.model.api.IIdType- See Also:
getBaseUrl()
-
hasIdPart
public boolean hasIdPart()
- Specified by:
hasIdPartin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
hasResourceType
public boolean hasResourceType()
- Specified by:
hasResourceTypein interfaceorg.hl7.fhir.instance.model.api.IIdType
-
hasVersionIdPart
public boolean hasVersionIdPart()
- Specified by:
hasVersionIdPartin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
isAbsolute
public boolean isAbsolute()
Returnstrueif this ID contains an absolute URL (in other words, a URL starting with "http://" or "https://"- Specified by:
isAbsolutein interfaceorg.hl7.fhir.instance.model.api.IIdType
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfaceorg.hl7.fhir.instance.model.api.IBase- Specified by:
isEmptyin interfaceorg.hl7.fhir.instance.model.api.IIdType- Overrides:
isEmptyin classPrimitiveType<String>
-
isIdPartValid
public boolean isIdPartValid()
- Specified by:
isIdPartValidin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
isIdPartValidLong
public boolean isIdPartValidLong()
Returnstrueif the unqualified ID is a validLongvalue (in other words, it consists only of digits)- Specified by:
isIdPartValidLongin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
isLocal
public boolean isLocal()
Returnstrueif the ID is a local reference (in other words, it begins with the '#' character)- Specified by:
isLocalin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
isUrn
public boolean isUrn()
-
isVersionIdPartValidLong
public boolean isVersionIdPartValidLong()
- Specified by:
isVersionIdPartValidLongin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
setParts
public org.hl7.fhir.instance.model.api.IIdType setParts(String theBaseUrl, String theResourceType, String theIdPart, String theVersionIdPart)
- Specified by:
setPartsin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
toString
public String toString()
- Overrides:
toStringin classPrimitiveType<String>
-
toUnqualified
public IdType toUnqualified()
Returns a new IdType containing this IdType's values but with no server base URL if one is present in this IdType. For example, if this IdType contains the ID "http://foo/Patient/1", this method will return a new IdType containing ID "Patient/1".- Specified by:
toUnqualifiedin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
toUnqualifiedVersionless
public IdType toUnqualifiedVersionless()
- Specified by:
toUnqualifiedVersionlessin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
toVersionless
public IdType toVersionless()
- Specified by:
toVersionlessin interfaceorg.hl7.fhir.instance.model.api.IIdType
-
withResourceType
public IdType withResourceType(String theResourceName)
- Specified by:
withResourceTypein interfaceorg.hl7.fhir.instance.model.api.IIdType
-
withServerBase
public IdType withServerBase(String theServerBase, String theResourceType)
Returns a view of this ID as a fully qualified URL, given a server base and resource name (which will only be used if the ID does not already contain those respective parts). Essentially, because IdType can contain either a complete URL or a partial one (or even jut a simple ID), this method may be used to translate into a complete URL.- Specified by:
withServerBasein interfaceorg.hl7.fhir.instance.model.api.IIdType- Parameters:
theServerBase- The server base (e.g. "http://example.com/fhir")theResourceType- The resource name (e.g. "Patient")- Returns:
- A fully qualified URL for this ID (e.g. "http://example.com/fhir/Patient/1")
-
withVersion
public IdType withVersion(String theVersion)
Creates a new instance of this ID which is identical, but refers to the specific version of this resource ID noted by theVersion.- Specified by:
withVersionin interfaceorg.hl7.fhir.instance.model.api.IIdType- Parameters:
theVersion- The actual version string, e.g. "1". If theVersion is blank or null, returns the same astoVersionless()}- Returns:
- A new instance of IdType which is identical, but refers to the specific version of this resource ID noted by theVersion.
-
newRandomUuid
public static IdType newRandomUuid()
Construct a new ID with with form "urn:uuid:[UUID]" where [UUID] is a new, randomly created UUID generated byUUID.randomUUID()
-
-