Class IdDt
- java.lang.Object
-
- ca.uhn.fhir.model.api.BaseElement
-
- ca.uhn.fhir.model.api.BaseIdentifiableElement
-
- ca.uhn.fhir.model.api.BasePrimitive<String>
-
- ca.uhn.fhir.model.primitive.UriDt
-
- ca.uhn.fhir.model.primitive.IdDt
-
- All Implemented Interfaces:
IDatatype,IElement,IIdentifiableElement,IPrimitiveDatatype<String>,ISupportsUndeclaredExtensions,Externalizable,Serializable,IBase,IBaseDatatype,IIdType,IPrimitiveType<String>
public class IdDt extends UriDt implements IIdType
Represents the FHIR ID type. This is the actual resource ID, meaning the ID that will be used in RESTful URLs, Resource References, etc. to represent a specific instance of a resource.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-z-Z0-9\-\.]{1,36}
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description IdDt()Create a new empty IDIdDt(long theId)Create a new ID using a longIdDt(UriDt theUrl)Creates an ID based on a given URLIdDt(String theValue)Create a new ID using a string.IdDt(String theResourceType, Long theIdPart)ConstructorIdDt(String theResourceType, String theId)ConstructorIdDt(String theResourceType, String theId, String theVersionId)ConstructorIdDt(String theBaseUrl, String theResourceType, String theId, String theVersionId)ConstructorIdDt(String theResourceType, BigDecimal theIdPart)ConstructorIdDt(BigDecimal thePid)Create a new ID, using a BigDecimal input.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidapplyTo(IBaseResource theResouce)BigDecimalasBigDecimal()Deprecated.UsegetIdPartAsBigDecimal()instead (this method was deprocated because its name is ambiguous)booleanequals(Object theArg0)booleanequalsIgnoreBase(IdDt theId)Returns true if this IdDt matches the given IdDt in terms of resource type and ID, but ignores the URL baseStringgetBaseUrl()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()Returns the version ID part of this ID (e.g.booleanhasBaseUrl()Returns true if this ID has a base urlinthashCode()booleanhasIdPart()Returnstrueif this ID contains an actual ID part.booleanhasResourceType()booleanhasVersionIdPart()booleanisAbsolute()Returnstrueif this ID contains an absolute URL (in other words, a URL starting with "http://" or "https://"booleanisEmpty()booleanisIdPartValid()Returnstrueif theID part of this objectis valid according to the FHIR rules for valid IDs.booleanisIdPartValidLong()Returnstrueif theID part of this objectcontains only numbersbooleanisLocal()Returnstrueif the ID is a local reference (in other words, it begins with the '#' character)static booleanisValidLong(String id)booleanisVersionIdPartValidLong()Returnstrueif theversion ID part of this objectcontains only numbersstatic IdDtnewRandomUuid()Construct a new ID with with form "urn:uuid:[UUID]" where [UUID] is a new, randomly created UUID generated byUUID.randomUUID()static IdDtof(IBaseResource theResouce)Retrieves the ID from the given resource instancevoidsetId(IdDt theId)Deprecated.IIdTypesetParts(String theBaseUrl, String theResourceType, String theIdPart, String theVersionIdPart)Sets the value of this ID by combining all of the individual parts.IdDtsetValue(String theValue)Set the valuevoidsetValueAsString(String theValue)Set the valueStringtoString()IdDttoUnqualified()Returns a new IdDt containing this IdDt's values but with no server base URL if one is present in this IdDt.IdDttoUnqualifiedVersionless()IdDttoVersionless()IdDtwithResourceType(String theResourceName)Returns a copy of this object, but with a differentresource type(or if this object does not have a resource type currently, returns a copy of this object with the given resource type).IdDtwithServerBase(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).IdDtwithVersion(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 ca.uhn.fhir.model.api.BasePrimitive
hasValue, readExternal, updateStringValue, writeExternal
-
Methods inherited from class ca.uhn.fhir.model.api.BaseIdentifiableElement
getElementSpecificId, getId, setElementSpecificId, setId
-
Methods inherited from class ca.uhn.fhir.model.api.BaseElement
addUndeclaredExtension, addUndeclaredExtension, addUndeclaredExtension, getAllUndeclaredExtensions, getFormatCommentsPost, getFormatCommentsPre, getUndeclaredExtensions, getUndeclaredExtensionsByUrl, getUndeclaredModifierExtensions, getUserData, hasFormatComment, isBaseEmpty, setUserData
-
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
fhirType, getFormatCommentsPost, getFormatCommentsPre, getUserData, hasFormatComment, setUserData
-
Methods inherited from interface org.hl7.fhir.instance.model.api.IPrimitiveType
hasValue
-
-
-
-
Constructor Detail
-
IdDt
public IdDt()
Create a new empty ID
-
IdDt
public IdDt(BigDecimal thePid)
Create a new ID, using a BigDecimal input. UsesBigDecimal.toPlainString()to generate the string representation.
-
IdDt
public IdDt(long theId)
Create a new ID using a long
-
IdDt
public IdDt(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}
-
IdDt
public IdDt(String theResourceType, BigDecimal theIdPart)
Constructor- Parameters:
theResourceType- The resource type (e.g. "Patient")theIdPart- The ID (e.g. "123")
-
IdDt
public IdDt(String theResourceType, Long theIdPart)
Constructor- Parameters:
theResourceType- The resource type (e.g. "Patient")theIdPart- The ID (e.g. "123")
-
IdDt
public IdDt(String theResourceType, String theId)
Constructor- Parameters:
theResourceType- The resource type (e.g. "Patient")theId- The ID (e.g. "123")
-
IdDt
public IdDt(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")
-
IdDt
public IdDt(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(IBaseResource theResouce)
-
asBigDecimal
@Deprecated public BigDecimal asBigDecimal()
Deprecated.UsegetIdPartAsBigDecimal()instead (this method was deprocated because its name is ambiguous)
-
equalsIgnoreBase
public boolean equalsIgnoreBase(IdDt theId)
Returns true if this IdDt matches the given IdDt 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 interfaceIIdType
-
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".
-
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 interfaceIIdType- Throws:
NumberFormatException- If the value is not a valid Long
-
getResourceType
public String getResourceType()
- Specified by:
getResourceTypein interfaceIIdType
-
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 interfaceIIdType- Specified by:
getValuein interfaceIPrimitiveDatatype<String>- Specified by:
getValuein interfaceIPrimitiveType<String>- Overrides:
getValuein classBasePrimitive<String>- See Also:
getIdPart()
-
setValue
public IdDt setValue(String theValue) throws DataFormatException
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 interfaceIIdType- Specified by:
setValuein interfaceIPrimitiveDatatype<String>- Specified by:
setValuein interfaceIPrimitiveType<String>- Overrides:
setValuein classBasePrimitive<String>- Throws:
DataFormatException
-
getValueAsString
public String getValueAsString()
- Specified by:
getValueAsStringin interfaceIPrimitiveDatatype<String>- Specified by:
getValueAsStringin interfaceIPrimitiveType<String>- Overrides:
getValueAsStringin classBasePrimitive<String>
-
setValueAsString
public void setValueAsString(String theValue) throws DataFormatException
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 interfaceIPrimitiveDatatype<String>- Specified by:
setValueAsStringin interfaceIPrimitiveType<String>- Overrides:
setValueAsStringin classBasePrimitive<String>- Throws:
DataFormatException
-
getVersionIdPart
public String getVersionIdPart()
- Specified by:
getVersionIdPartin interfaceIIdType
-
getVersionIdPartAsLong
public Long getVersionIdPartAsLong()
Description copied from interface:IIdTypeReturns the version ID part of this ID (e.g. in the ID http://example.com/Patient/123/_history/456 this would be the part "456") parsed as aLong.- Specified by:
getVersionIdPartAsLongin interfaceIIdType
-
hasBaseUrl
public boolean hasBaseUrl()
Returns true if this ID has a base url- Specified by:
hasBaseUrlin interfaceIIdType- See Also:
getBaseUrl()
-
hasIdPart
public boolean hasIdPart()
Description copied from interface:IIdTypeReturnstrueif this ID contains an actual ID part. For example, the ID part is the '123' in the following ID:http://example.com/fhir/Patient/123/_history/55
-
hasResourceType
public boolean hasResourceType()
- Specified by:
hasResourceTypein interfaceIIdType
-
hasVersionIdPart
public boolean hasVersionIdPart()
- Specified by:
hasVersionIdPartin interfaceIIdType
-
isAbsolute
public boolean isAbsolute()
Returnstrueif this ID contains an absolute URL (in other words, a URL starting with "http://" or "https://"- Specified by:
isAbsolutein interfaceIIdType
-
isEmpty
public boolean isEmpty()
-
isIdPartValid
public boolean isIdPartValid()
Description copied from interface:IIdTypeReturnstrueif theID part of this objectis valid according to the FHIR rules for valid IDs.The FHIR specification states:
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.) regex: [A-Za-z0-9\-\.]{1,64}- Specified by:
isIdPartValidin interfaceIIdType
-
isIdPartValidLong
public boolean isIdPartValidLong()
Description copied from interface:IIdTypeReturnstrueif theID part of this objectcontains only numbers- Specified by:
isIdPartValidLongin interfaceIIdType
-
isLocal
public boolean isLocal()
Returnstrueif the ID is a local reference (in other words, it begins with the '#' character)
-
isVersionIdPartValidLong
public boolean isVersionIdPartValidLong()
Description copied from interface:IIdTypeReturnstrueif theversion ID part of this objectcontains only numbers- Specified by:
isVersionIdPartValidLongin interfaceIIdType
-
setId
@Deprecated public void setId(IdDt theId)
Deprecated.Copies the value from the given IdDt tothisIdDt. It is generally not neccesary to use this method but it is provided for consistency with the rest of the API.- Specified by:
setIdin interfaceIIdentifiableElement- Overrides:
setIdin classBaseIdentifiableElement
-
setParts
public IIdType setParts(String theBaseUrl, String theResourceType, String theIdPart, String theVersionIdPart)
Description copied from interface:IIdTypeSets the value of this ID by combining all of the individual parts.Required parameters: The following rules apply to the parameters of this method (in this case, populated means a non-empty string and not populated means
nullor an empty string)- All values may be not populated
- If theVersionIdPart is populated, theResourceType and theIdPart must be populated
- If theBaseUrl is populated and theIdPart is populated, theResourceType must be populated
-
toString
public String toString()
- Overrides:
toStringin classBasePrimitive<String>
-
toUnqualified
public IdDt toUnqualified()
Returns a new IdDt containing this IdDt's values but with no server base URL if one is present in this IdDt. For example, if this IdDt contains the ID "http://foo/Patient/1", this method will return a new IdDt containing ID "Patient/1".- Specified by:
toUnqualifiedin interfaceIIdType
-
toUnqualifiedVersionless
public IdDt toUnqualifiedVersionless()
- Specified by:
toUnqualifiedVersionlessin interfaceIIdType
-
toVersionless
public IdDt toVersionless()
- Specified by:
toVersionlessin interfaceIIdType
-
withResourceType
public IdDt withResourceType(String theResourceName)
Description copied from interface:IIdTypeReturns a copy of this object, but with a differentresource type(or if this object does not have a resource type currently, returns a copy of this object with the given resource type).Note that if this object represents a local reference (e.g.
#foo) or a URN (e.g.urn:oid:1.2.3.4) this method will simply return a copy of this object with no modifications.- Specified by:
withResourceTypein interfaceIIdType
-
withServerBase
public IdDt 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 IdDt 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 interfaceIIdType- 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 IdDt 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 interfaceIIdType- Parameters:
theVersion- The actual version string, e.g. "1". If theVersion is blank or null, returns the same astoVersionless()}- Returns:
- A new instance of IdDt which is identical, but refers to the specific version of this resource ID noted by theVersion.
-
isValidLong
public static boolean isValidLong(String id)
-
newRandomUuid
public static IdDt newRandomUuid()
Construct a new ID with with form "urn:uuid:[UUID]" where [UUID] is a new, randomly created UUID generated byUUID.randomUUID()
-
of
public static IdDt of(IBaseResource theResouce)
Retrieves the ID from the given resource instance
-
-