Skip to content

FHIR Primitive Types

Primitive data types.

Base64Binary module-attribute

Base64Binary = TypeAliasType('Base64Binary', Annotated[str, Field(pattern='^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$')])

Boolean module-attribute

Boolean = TypeAliasType('Boolean', Union[bool, Annotated[str, Field(pattern='^(true|false)$'), AfterValidator(lambda x: x == 'true')]])

Canonical module-attribute

Canonical = TypeAliasType('Canonical', Annotated[str, Field(pattern='^\\S+$')])

Code module-attribute

Code = TypeAliasType('Code', Annotated[str, Field(pattern='^[^\\s]+(\\s[^\\s]+)*$')])

Date module-attribute

Date = TypeAliasType('Date', Union[Annotated[date, Field(), AfterValidator(lambda d: isoformat())], Annotated[str, Field(pattern=f'^{YEAR_REGEX}(-{MONTH_REGEX}(-{DAY_REGEX})?)?$')]])

DateTime module-attribute

DateTime = TypeAliasType('DateTime', Union[Annotated[datetime, Field(), AfterValidator(lambda d: isoformat())], Annotated[str, Field(pattern=f'^{YEAR_REGEX}(-{MONTH_REGEX}(-{DAY_REGEX})?)?(T{HOUR_REGEX}(:{MINUTES_REGEX}(:{SECONDS_REGEX}({TIMEZONE_REGEX})?)?)?)?$')]])

Decimal module-attribute

Decimal = TypeAliasType('Decimal', Union[float, Annotated[str, Field(pattern='^-?(0|[1-9][0-9]*)(\\.[0-9]+)?([eE][+-]?[0-9]+)?$'), AfterValidator(float)]])

Id module-attribute

Id = TypeAliasType('Id', Annotated[str, Field(pattern='^[A-Za-z0-9\\-\\.]{1,64}$')])

Instant module-attribute

Instant = TypeAliasType('Instant', Union[Annotated[datetime, Field(), AfterValidator(lambda d: isoformat())], Annotated[str, Field(pattern=f'^{YEAR_REGEX}-{MONTH_REGEX}-{DAY_REGEX}T{HOUR_REGEX}:{MINUTES_REGEX}:{SECONDS_REGEX}({TIMEZONE_REGEX})?$')]])

Integer module-attribute

Integer = TypeAliasType('Integer', Union[Annotated[int, Annotated[str, Field(pattern='^[0]|[-+]?[1-9][0-9]*$')], AfterValidator(__integer_validator(lambda x: x >= MIN_SIGNED_32BIT_INT and x <= MAX_SIGNED_32BIT_INT))],])

Integer64 module-attribute

Integer64 = TypeAliasType('Integer64', Union[Annotated[int, Annotated[str, Field(pattern='^[0]|[-+]?[1-9][0-9]*$')], AfterValidator(__integer_validator(lambda x: x >= MIN_SIGNED_64BIT_INT and x <= MAX_SIGNED_64BIT_INT))],])

Markdown module-attribute

Markdown = TypeAliasType('Markdown', Annotated[str, Field(pattern='^\\s*(\\S|\\s)*$')])

Oid module-attribute

Oid = TypeAliasType('Oid', Annotated[str, Field(pattern='^urn:oid:[0-2](\\.(0|[1-9][0-9]*))+$')])

PositiveInt module-attribute

PositiveInt = TypeAliasType('PositiveInt', Union[Annotated[int, Annotated[str, Field(pattern='\\+?[1-9][0-9]*')], AfterValidator(__integer_validator(lambda x: x >= 1 and x <= MAX_SIGNED_32BIT_INT))],])

String module-attribute

String = TypeAliasType('String', str)

Time module-attribute

Time = TypeAliasType('Time', Union[Annotated[time, Field(), AfterValidator(lambda t: isoformat())], Annotated[str, Field(pattern=f'^{HOUR_REGEX}(:{MINUTES_REGEX}(:{SECONDS_REGEX}({TIMEZONE_REGEX})?)?)?$')]])

UnsignedInt module-attribute

UnsignedInt = TypeAliasType('UnsignedInt', Union[Annotated[int, Annotated[str, Field(pattern='[0]|([1-9][0-9]*)')], AfterValidator(__integer_validator(lambda x: x >= MIN_UNSIGNED_32BIT_INT and x <= MAX_UNSIGNED_32BIT_INT))],])

Uri module-attribute

Uri = TypeAliasType('Uri', Annotated[str, Field(pattern='^\\S+$')])

Url module-attribute

Url = TypeAliasType('Url', Annotated[str, Field(pattern='^\\S+$')])

Uuid module-attribute

Uuid = TypeAliasType('Uuid', Annotated[str, Field(pattern='^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$')])