semvec/pypi-packages huggingface dataset:
pydantic-fhir 0.0.1a18
Generated FHIR model for Pydantic.
License: Apache-2.0
Requires Python: >=3.8,<4.0
Keywords: FHIR,pydantic

This stub for FHIR generated by [fhirzeug](https://github.com/skalarsystems/fhirzeug).

# Format

All profiles are in one file.

# FHIR Specific JSON Representation

Generally this generated code tries to stick as close as possible to the
[FHIR JSON spec](https://www.hl7.org/fhir/json.htm). Another important is the
[FHIR Datatypes spec](https://www.hl7.org/fhir/datatypes.html).

## Empty Strings

> String property values can never be empty. Either the property is absent, or it is present with at
> least one character of content. - https://www.hl7.org/fhir/STU3/json.html

Additionally whitespaces are stripped:

> Note: This means that a string that consists only of whitespace could be trimmed to nothing, which
> would be treated as an invalid element value. Therefore strings SHOULD always contain
> non-whitespace content. - https://www.hl7.org/fhir/datatypes.html#primitive

That means empty strings are interpreted as `null` values.
This could lead to invalid arrays(`[""]`). This follows the behavior from
[HAPI](https://hapifhir.io/) and [Vonk](https://fire.ly/products/vonk/vonk-fhir-server/).

## DateTime Values

Datetime values are strings as well. That means an empty string or a string with whitespaces is
threaded as a `null` value. Which then is not set at all.

## `null` Values

> Just as in XML, JSON objects and arrays are never empty, and properties never have null values
> (except for a special case documented below). Omit a property if it is empty -
> https://www.hl7.org/fhir/json.html#xml

That means specifically that if a property contains a null value it is like it never has been set.

Example:

```python
>>> from r4 import Patient
>>> Patient(name=None).dict()
{}
```

## ValueSets and CodeSystems

FHIR Specification provides different ways to define a `ValueSet`. The implementation varies depending on the use case :
- If a ValueSet is based on a single CodeSystem and this CodeSystem is defined in FHIR, then the ValueSet is validated by an `enum`.
- If a ValueSet is based on a single CodeSystem, that this CodeSystem is not included in the FHIR specification, but FHIR provides an exhaustive list of possible values, then the ValueSet is validated by a `typing.Literal`.
- Otherwise, the field is validated by a very permissive regex `[^\s]+(\s[^\s]+)*`.