Skip to content

FHIR IG generation (dhis2w_fhir)

dhis2w_fhir is the package behind d2w fhir: the fhir.toml document, the emitters that turn DHIS2 metadata into an Implementation Guide - FSH for the definitional artifacts, pre-built R4 JSON for the organisation-unit registry, the option-set terminology, and the category terminology - and the DHIS2 period grammar they share. It mounts onto the CLI and the MCP server through the dhis2.plugins entry point, and every component symbol re-exports from the top-level package, so from dhis2w_fhir import GenerateConfig, parse_period keeps working however the components are arranged internally. The R4 resource models are the one exception: they live in dhis2w_fhir.r4, which is FHIR's own vocabulary rather than part of the plugin surface.

When to reach for it

  • Read or write a project's fhir.toml from Python (load_project, load_fhir_config, find_project_fhir_config, write_fhir_config).
  • Parse a DHIS2 ISO period into its type and date range, or walk backwards from a date (parse_period, recent_periods, PERIOD_TYPE_DEFINITIONS).
  • Carry DHIS2 attribute values onto a generated resource (AttributeValueIn, AttributeCodeIndex, resolve_attribute_code_index, attribute_value_extensions).
  • Build FSH artifacts without the CLI (build_foundation_artifacts, build_questionnaire_artifacts, build_page_artifacts) and sync them to disk (sync_artifacts).
  • Build the pre-built R4 documents - the registry (dhis2w_fhir.r4.Organization, dhis2w_fhir.r4.Location), the option-set terminology (build_option_set_artifacts), and the category terminology (build_category_artifacts), the last two on dhis2w_fhir.r4.CodeSystem and dhis2w_fhir.r4.ValueSet - and sync them to disk (sync_json_artifacts), one owned directory per source.

Worked example — parse a period, then walk backwards

import datetime

from dhis2w_fhir import parse_period, recent_periods

parse_period("2024BiW2")
# PeriodValue(iso='2024BiW2', period_type='BiWeekly',
#             start_date=date(2024, 1, 15), end_date=date(2024, 1, 28))

recent_periods("Monthly", 3, datetime.date(2026, 8, 2))
# ['202607', '202606', '202605']

Reference

Periods

period

DHIS2 reporting periods: the ISO period grammar, its period-type catalogue, the parser, and its inverse.

Classes

PeriodTypeDefinition

Bases: BaseModel

One DHIS2 period type as terminology: its name, its ISO format, and a display phrase.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/period/schemas.py
class PeriodTypeDefinition(BaseModel):
    """One DHIS2 period type as terminology: its name, its ISO format, and a display phrase."""

    model_config = ConfigDict(frozen=True)

    name: str
    iso_format: str
    display: str

PeriodValue

Bases: BaseModel

One DHIS2 reporting period: its ISO identifier, its period type, and the dates it covers.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/period/schemas.py
class PeriodValue(BaseModel):
    """One DHIS2 reporting period: its ISO identifier, its period type, and the dates it covers."""

    model_config = ConfigDict(frozen=True)

    iso: str
    period_type: str
    start_date: datetime.date
    end_date: datetime.date

Functions

parse_period(iso)

Parse a DHIS2 ISO period string into its period type, start date, and end date.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/period/parser.py
def parse_period(iso: str) -> PeriodValue:
    """Parse a DHIS2 ISO period string into its period type, start date, and end date."""
    if len(iso) < _MINIMUM_LENGTH or len(iso) > _MAXIMUM_LENGTH:
        raise ValueError(f"not a DHIS2 ISO period: {iso!r} (expected 4 to 11 characters)")
    year = _digits(iso, 0, 4)
    parsed = _parse_by_length(iso, year)
    if parsed is None:
        raise ValueError(f"not a DHIS2 ISO period: {iso!r}")
    return parsed

recent_periods(period_type, count, today)

The count most recent completed ISO periods of period_type, newest first.

A period counts as completed when its end date falls strictly before today. An unregistered period type, or a non-positive count, yields an empty list rather than raising - the caller is discovering data, not validating configuration.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/period/recent.py
def recent_periods(period_type: str, count: int, today: datetime.date) -> list[str]:
    """The `count` most recent completed ISO periods of `period_type`, newest first.

    A period counts as completed when its end date falls strictly before `today`. An
    unregistered period type, or a non-positive count, yields an empty list rather than
    raising - the caller is discovering data, not validating configuration.
    """
    enumerator = _ISO_ENUMERATORS.get(period_type)
    if enumerator is None or count <= 0:
        return []
    completed: list[PeriodValue] = []
    for year in range(today.year + 1, today.year - count - _EXTRA_YEARS, -1):
        completed.extend(value for value in _parsed(enumerator(year)) if value.end_date < today)
    completed.sort(key=lambda value: (value.end_date, value.iso), reverse=True)
    return [value.iso for value in completed[:count]]

Project configuration

config

The fhir.toml document: its models plus discovery, load, and save.

A FHIR IG project is any directory holding a fhir.toml (scaffolded by d2w fhir init). Discovery walks up from the working directory, mirroring how .dhis2/profiles.toml is found.

The document composes the per-component selection tables, so this module depends on the components and never the other way round - an emitter receives its config as a parameter.

Classes

NoFhirProjectError

Bases: LookupError

Raised when no fhir.toml is found walking up from the working directory.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
class NoFhirProjectError(LookupError):
    """Raised when no `fhir.toml` is found walking up from the working directory."""

IgConfig

Bases: BaseModel

SUSHI IG identity - the [ig] table of fhir.toml.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
class IgConfig(BaseModel):
    """SUSHI IG identity - the `[ig]` table of `fhir.toml`."""

    id: str
    canonical: str
    name: str
    title: str
    publisher: str
    status: IgStatus = "draft"

    _normalize_canonical = field_validator("canonical")(strip_trailing_slash)

NamingConfig

Bases: BaseModel

Configurable FSH naming tokens - the [generate.naming] table of fhir.toml.

Artifact names merge the prefix and kind tokens and underscore the rest (D2 + OS + _BirthType + _CS); ids join the kebab of each non-empty token (d2-os-birth-type-cs). prefix, option_set, category, data_set, program, and program_stage may be empty to drop them; organisation_unit must stay non-empty or the org-unit artifact names would degenerate to bare _CS/_Level_CS. Future group / group-set artifacts follow the same scheme (OUG, OUGS).

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
class NamingConfig(BaseModel):
    """Configurable FSH naming tokens - the `[generate.naming]` table of `fhir.toml`.

    Artifact names merge the prefix and kind tokens and underscore the rest
    (`D2` + `OS` + `_BirthType` + `_CS`); ids join the kebab of each non-empty token
    (`d2-os-birth-type-cs`). `prefix`, `option_set`, `category`, `data_set`, `program`, and
    `program_stage` may be empty to drop them; `organisation_unit` must stay non-empty or the
    org-unit artifact names would degenerate to bare `_CS`/`_Level_CS`. Future group /
    group-set artifacts follow the same scheme (`OUG`, `OUGS`).
    """

    source: Literal["id", "name"] = "id"
    prefix: str = "D2"
    option_set: str = "OS"
    category: str = "CAT"
    organisation_unit: str = "OU"
    data_set: str = "DS"
    program: str = "PR"
    program_stage: str = "PS"

    @field_validator("prefix", "option_set", "category", "data_set", "program", "program_stage")
    @classmethod
    def _optional_token(cls, value: str) -> str:
        """Prefix, option_set, category, data_set, program, and program_stage may be empty or FSH-name-safe."""
        return _validate_fsh_token(value, allow_empty=True)

    @field_validator("organisation_unit")
    @classmethod
    def _required_token(cls, value: str) -> str:
        """organisation_unit must be a non-empty FSH-name-safe token."""
        return _validate_fsh_token(value, allow_empty=False)

GenerateConfig

Bases: BaseModel

Generation behaviour - the [generate] table of fhir.toml.

The three data-definition tables select the three questionnaire form kinds: data_sets picks aggregate data sets, event_programs picks programs without registration, and tracker_programs picks programs with registration, one Questionnaire per program stage.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
class GenerateConfig(BaseModel):
    """Generation behaviour - the `[generate]` table of `fhir.toml`.

    The three data-definition tables select the three questionnaire form kinds: `data_sets`
    picks aggregate data sets, `event_programs` picks programs without registration, and
    `tracker_programs` picks programs with registration, one Questionnaire per program stage.
    """

    identifier_system_base: str = "http://dhis2.org/fhir"
    concept_code_source: Literal["id", "code"] = "id"
    locales: list[str] = Field(default_factory=list)
    naming: NamingConfig = Field(default_factory=NamingConfig)
    option_sets: OptionSetSelection = Field(default_factory=OptionSetSelection)
    categories: CategorySelection = Field(default_factory=CategorySelection)
    organisation_units: OrganisationUnitSelection = Field(default_factory=OrganisationUnitSelection)
    data_sets: TargetSelection = Field(default_factory=TargetSelection)
    event_programs: TargetSelection = Field(default_factory=TargetSelection)
    tracker_programs: TargetSelection = Field(default_factory=TargetSelection)
    examples: ExampleSelection = Field(default_factory=ExampleSelection)

    _normalize_identifier_base = field_validator("identifier_system_base")(strip_trailing_slash)

    @field_validator("locales")
    @classmethod
    def _normalize_locales(cls, value: list[str]) -> list[str]:
        """Accept BCP-47 or DHIS2-style tags and hold them in the BCP-47 form the emitters compare against."""
        return [normalize_locale(locale) for locale in value]

FhirProjectConfig

Bases: BaseModel

The full parsed fhir.toml document.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
class FhirProjectConfig(BaseModel):
    """The full parsed `fhir.toml` document."""

    profile: str | None = None
    ig: IgConfig
    generate: GenerateConfig = Field(default_factory=GenerateConfig)

FhirProject

Bases: BaseModel

A discovered FHIR IG project: parsed config plus where it lives on disk.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
class FhirProject(BaseModel):
    """A discovered FHIR IG project: parsed config plus where it lives on disk."""

    model_config = ConfigDict(frozen=True)

    config: FhirProjectConfig
    config_path: Path

    @property
    def project_root(self) -> Path:
        """Directory containing `fhir.toml`."""
        return self.config_path.parent

    @property
    def ig_directory(self) -> Path:
        """The SUSHI IG directory (`<project_root>/ig`)."""
        return self.project_root / "ig"

    @property
    def fsh_directory(self) -> Path:
        """The FSH source directory (`<project_root>/ig/input/fsh`)."""
        return self.ig_directory / "input" / "fsh"

    @property
    def resources_directory(self) -> Path:
        """The predefined-resource directory (`<project_root>/ig/input/resources`), loaded without a FSH compile."""
        return self.ig_directory / "input" / "resources"
Attributes
project_root property

Directory containing fhir.toml.

ig_directory property

The SUSHI IG directory (<project_root>/ig).

fsh_directory property

The FSH source directory (<project_root>/ig/input/fsh).

resources_directory property

The predefined-resource directory (<project_root>/ig/input/resources), loaded without a FSH compile.

Functions

find_project_fhir_config(start=None)

Walk up from start (defaulting to $PWD) looking for fhir.toml.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
def find_project_fhir_config(start: Path | None = None) -> Path | None:
    """Walk up from `start` (defaulting to `$PWD`) looking for `fhir.toml`."""
    cwd = start or Path.cwd()
    for parent in [cwd, *cwd.parents]:
        candidate = parent / FHIR_CONFIG_FILENAME
        if candidate.exists():
            return candidate
    return None

load_fhir_config(path)

Parse and validate a fhir.toml file.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
def load_fhir_config(path: Path) -> FhirProjectConfig:
    """Parse and validate a `fhir.toml` file."""
    raw = tomllib.loads(path.read_text(encoding="utf-8"))
    return FhirProjectConfig.model_validate(raw)

write_fhir_config(path, config)

Write a fhir.toml with default permissions - it is committed project config, not a credential store.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
def write_fhir_config(path: Path, config: FhirProjectConfig) -> None:
    """Write a `fhir.toml` with default permissions - it is committed project config, not a credential store."""
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(tomli_w.dumps(config.model_dump(exclude_none=True)), encoding="utf-8")

load_project(start=None)

Discover and load the nearest FHIR project, raising NoFhirProjectError when there is none.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/config.py
def load_project(start: Path | None = None) -> FhirProject:
    """Discover and load the nearest FHIR project, raising `NoFhirProjectError` when there is none."""
    path = find_project_fhir_config(start)
    if path is None:
        raise NoFhirProjectError(
            "no fhir.toml found in this directory or any parent. "
            "Run `d2w fhir init [DIRECTORY]` to scaffold a FHIR IG project first."
        )
    return FhirProject(config=load_fhir_config(path), config_path=path.resolve())

DHIS2 attribute values

The projection every generated resource carries its DHIS2 attribute values on, plus the uid -> code index a generate run resolves once against /api/attributes and every emitter joins against. DHIS2 sends an attribute value as an attribute UID and a string, so the code is a lookup rather than part of the value.

attributes

DHIS2 attribute values shared by every component: the projection plus the emit-time code index.

Classes

AttributeValueIn

Bases: BaseModel

One DHIS2 attribute value: the attribute it belongs to, and the value the instance holds.

DHIS2 sends {"attribute": {"id": "ihn1wb9eho8"}, "value": "KE03"} and nothing else - no code, no name, no value type - so the projection carries the UID and the value alone and the attribute's code is joined from AttributeCodeIndex at emit time. The value is a string whatever the attribute's declared DHIS2 value type; a GeoJSON-valued attribute arrives as the serialised document.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/attributes.py
class AttributeValueIn(BaseModel):
    """One DHIS2 attribute value: the attribute it belongs to, and the value the instance holds.

    DHIS2 sends `{"attribute": {"id": "ihn1wb9eho8"}, "value": "KE03"}` and nothing else - no
    code, no name, no value type - so the projection carries the UID and the value alone and
    the attribute's code is joined from `AttributeCodeIndex` at emit time. The value is a
    string whatever the attribute's declared DHIS2 value type; a GeoJSON-valued attribute
    arrives as the serialised document.
    """

    model_config = ConfigDict(frozen=True)

    attribute_uid: str
    value: str

AttributeCodeIndex

Bases: BaseModel

Every DHIS2 attribute's code keyed by its UID - the join one generate run resolves once.

An attribute DHIS2 left without a code is absent from the mapping rather than present with an empty one: most instances code few of their attributes, and some code none of them, so every consumer reads through code_for and decides what a missing code means for it.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/attributes.py
class AttributeCodeIndex(BaseModel):
    """Every DHIS2 attribute's code keyed by its UID - the join one generate run resolves once.

    An attribute DHIS2 left without a code is absent from the mapping rather than present with
    an empty one: most instances code few of their attributes, and some code none of them, so
    every consumer reads through `code_for` and decides what a missing code means for it.
    """

    model_config = ConfigDict(frozen=True)

    codes: dict[str, str] = Field(default_factory=dict)

    def code_for(self, attribute_uid: str) -> str | None:
        """The attribute's DHIS2 code, or None when the instance left it unset."""
        return self.codes.get(attribute_uid)
Functions
code_for(attribute_uid)

The attribute's DHIS2 code, or None when the instance left it unset.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/attributes.py
def code_for(self, attribute_uid: str) -> str | None:
    """The attribute's DHIS2 code, or None when the instance left it unset."""
    return self.codes.get(attribute_uid)

FHIR R4 resource schemas

The models every pre-built JSON document is serialised from - Organization and Location for the registry, CodeSystem and ValueSet for the option-set and category terminology. Every one is frozen, alias-aware, and closed to unknown keys, so Model.model_validate(payload).model_dump_json(exclude_none=True, by_alias=True) reproduces the input document key for key.

schemas

FHIR R4 schemas for the resources this package emits - Organization, Location, CodeSystem, ValueSet - plus elements.

The models mirror the JSON SUSHI produces for the generated implementation guide, so every model round-trips: Model.model_validate(payload).model_dump_json(exclude_none=True, by_alias=True) reproduces the input document key for key. The primitive-extension keys _name and _title are not legal Pydantic field names, so they are carried by name_element and title_element: validation accepts either the underscore key or the field name, and serialisation under by_alias=True writes the underscore key back.

Classes

FhirBase

Bases: BaseModel

Pydantic carrier for every schema here - frozen, alias-aware, closed to unknown keys. Not a FHIR type.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class FhirBase(BaseModel):
    """Pydantic carrier for every schema here - frozen, alias-aware, closed to unknown keys. Not a FHIR type."""

    model_config = ConfigDict(frozen=True, populate_by_name=True, extra="forbid")

Element

Bases: FhirBase

Element - the R4 root for datatypes, and the _x sibling a primitive's extensions hang from.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Element(FhirBase):
    """`Element` - the R4 root for datatypes, and the `_x` sibling a primitive's extensions hang from."""

    extension: list[Extension] | None = None

BackboneElement

Bases: Element

BackboneElement - an element defined inside a resource rather than as a reusable datatype.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class BackboneElement(Element):
    """`BackboneElement` - an element defined inside a resource rather than as a reusable datatype."""

Resource

Bases: FhirBase

Resource - the R4 root for resources, a sibling of Element rather than a subtype of it.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Resource(FhirBase):
    """`Resource` - the R4 root for resources, a sibling of `Element` rather than a subtype of it."""

DomainResource

Bases: Resource

DomainResource - a resource carrying narrative and extensions; every resource emitted here is one.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class DomainResource(Resource):
    """`DomainResource` - a resource carrying narrative and extensions; every resource emitted here is one."""

Meta

Bases: Element

Resource.meta - the profiles a generated instance claims conformance to.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Meta(Element):
    """`Resource.meta` - the profiles a generated instance claims conformance to."""

    profile: list[str] | None = None

Identifier

Bases: Element

A business identifier: the DHIS2 UID or code under its identifier system.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Identifier(Element):
    """A business identifier: the DHIS2 UID or code under its identifier system."""

    system: str | None = None
    value: str | None = None

Coding

Bases: Element

One code drawn from a code system, with the display the system gives it.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Coding(Element):
    """One code drawn from a code system, with the display the system gives it."""

    system: str | None = None
    code: str | None = None
    display: str | None = None

CodeableConcept

Bases: Element

A concept expressed as one or more codings, optionally with free text.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class CodeableConcept(Element):
    """A concept expressed as one or more codings, optionally with free text."""

    coding: list[Coding] | None = None
    text: str | None = None

Reference

Bases: Element

A literal reference to another resource, such as Organization/mOsABqg3Cqw.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Reference(Element):
    """A literal reference to another resource, such as `Organization/mOsABqg3Cqw`."""

    reference: str | None = None
    display: str | None = None

ContactPoint

Bases: Element

A telecom contact point - the phone number or email address of an organisation unit.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class ContactPoint(Element):
    """A telecom contact point - the phone number or email address of an organisation unit."""

    system: Literal["phone", "fax", "email", "pager", "url", "sms", "other"] | None = None
    value: str | None = None

HumanName

Bases: Element

A person's name; the generated contacts carry the DHIS2 free text in text.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class HumanName(Element):
    """A person's name; the generated contacts carry the DHIS2 free text in `text`."""

    text: str | None = None

Attachment

Bases: Element

Attached content - the base64 GeoJSON boundary a Location extension carries.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Attachment(Element):
    """Attached content - the base64 GeoJSON boundary a Location extension carries."""

    contentType: str | None = None
    data: str | None = None
    title: str | None = None
    size: int | None = None

Extension

Bases: Element

One extension: either a nested set of extensions or a single value[x] choice.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Extension(Element):
    """One extension: either a nested set of extensions or a single `value[x]` choice."""

    url: str
    extension: list[Extension] | None = None
    valueCode: str | None = None
    valueString: str | None = None
    valueAttachment: Attachment | None = None

OrganizationContact

Bases: BackboneElement

Organization.contact - a contact party for the organisation unit.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class OrganizationContact(BackboneElement):
    """`Organization.contact` - a contact party for the organisation unit."""

    name: HumanName | None = None
    telecom: list[ContactPoint] | None = None

LocationPosition

Bases: BackboneElement

Location.position - the WGS84 point of an organisation unit.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class LocationPosition(BackboneElement):
    """`Location.position` - the WGS84 point of an organisation unit."""

    longitude: float | None = None
    latitude: float | None = None

CodeSystemProperty

Bases: BackboneElement

CodeSystem.property - the declaration of a property the concepts in the code system may carry.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class CodeSystemProperty(BackboneElement):
    """`CodeSystem.property` - the declaration of a property the concepts in the code system may carry."""

    code: str | None = None
    uri: str | None = None
    description: str | None = None
    type: Literal["code", "Coding", "string", "integer", "boolean", "dateTime", "decimal"] | None = None

CodeSystemConceptProperty

Bases: BackboneElement

CodeSystem.concept.property - one declared property carried by a single concept.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class CodeSystemConceptProperty(BackboneElement):
    """`CodeSystem.concept.property` - one declared property carried by a single concept."""

    code: str | None = None
    valueCode: str | None = None
    valueString: str | None = None

CodeSystemConceptDesignation

Bases: BackboneElement

CodeSystem.concept.designation - the translation of a concept display into one locale.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class CodeSystemConceptDesignation(BackboneElement):
    """`CodeSystem.concept.designation` - the translation of a concept display into one locale."""

    language: str | None = None
    value: str | None = None

CodeSystemConcept

Bases: BackboneElement

CodeSystem.concept - one DHIS2 option, keyed by its option UID.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class CodeSystemConcept(BackboneElement):
    """`CodeSystem.concept` - one DHIS2 option, keyed by its option UID."""

    code: str | None = None
    display: str | None = None
    property: list[CodeSystemConceptProperty] | None = None
    designation: list[CodeSystemConceptDesignation] | None = None

ValueSetInclude

Bases: BackboneElement

ValueSet.compose.include - one code system the value set draws its codes from.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class ValueSetInclude(BackboneElement):
    """`ValueSet.compose.include` - one code system the value set draws its codes from."""

    system: str | None = None

ValueSetCompose

Bases: BackboneElement

ValueSet.compose - the content logic that builds the expansion of the value set.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class ValueSetCompose(BackboneElement):
    """`ValueSet.compose` - the content logic that builds the expansion of the value set."""

    include: list[ValueSetInclude] | None = None

Organization

Bases: DomainResource

A FHIR R4 Organization as generated from one DHIS2 organisation unit.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Organization(DomainResource):
    """A FHIR R4 Organization as generated from one DHIS2 organisation unit."""

    resourceType: Literal["Organization"] = "Organization"
    id: str | None = None
    meta: Meta | None = None
    extension: list[Extension] | None = None
    identifier: list[Identifier] | None = None
    name: str | None = None
    name_element: Element | None = Field(
        default=None, validation_alias=AliasChoices("_name", "name_element"), serialization_alias="_name"
    )
    alias: list[str] | None = None
    type: list[CodeableConcept] | None = None
    partOf: Reference | None = None
    telecom: list[ContactPoint] | None = None
    contact: list[OrganizationContact] | None = None
    active: bool | None = None

Location

Bases: DomainResource

A FHIR R4 Location as generated from the physical place of one DHIS2 organisation unit.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class Location(DomainResource):
    """A FHIR R4 Location as generated from the physical place of one DHIS2 organisation unit."""

    resourceType: Literal["Location"] = "Location"
    id: str | None = None
    meta: Meta | None = None
    identifier: list[Identifier] | None = None
    name: str | None = None
    name_element: Element | None = Field(
        default=None, validation_alias=AliasChoices("_name", "name_element"), serialization_alias="_name"
    )
    description: str | None = None
    status: Literal["active", "suspended", "inactive"] | None = None
    position: LocationPosition | None = None
    extension: list[Extension] | None = None
    managingOrganization: Reference | None = None
    partOf: Reference | None = None

CodeSystem

Bases: DomainResource

A FHIR R4 CodeSystem as generated from one DHIS2 option set, one concept per option.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class CodeSystem(DomainResource):
    """A FHIR R4 CodeSystem as generated from one DHIS2 option set, one concept per option."""

    resourceType: Literal["CodeSystem"] = "CodeSystem"
    id: str | None = None
    extension: list[Extension] | None = None
    url: str | None = None
    identifier: list[Identifier] | None = None
    name: str | None = None
    title: str | None = None
    title_element: Element | None = Field(
        default=None, validation_alias=AliasChoices("_title", "title_element"), serialization_alias="_title"
    )
    description: str | None = None
    status: Literal["draft", "active", "retired", "unknown"] | None = None
    experimental: bool | None = None
    caseSensitive: bool | None = None
    content: Literal["not-present", "example", "fragment", "complete", "supplement"] | None = None
    count: int | None = None
    valueSet: str | None = None
    property: list[CodeSystemProperty] | None = None
    concept: list[CodeSystemConcept] | None = None

ValueSet

Bases: DomainResource

A FHIR R4 ValueSet as generated from one DHIS2 option set, composing the whole matching CodeSystem.

Source code in packages/dhis2w-fhir/src/dhis2w_fhir/r4/schemas.py
class ValueSet(DomainResource):
    """A FHIR R4 ValueSet as generated from one DHIS2 option set, composing the whole matching CodeSystem."""

    resourceType: Literal["ValueSet"] = "ValueSet"
    id: str | None = None
    extension: list[Extension] | None = None
    url: str | None = None
    identifier: list[Identifier] | None = None
    name: str | None = None
    title: str | None = None
    title_element: Element | None = Field(
        default=None, validation_alias=AliasChoices("_title", "title_element"), serialization_alias="_title"
    )
    description: str | None = None
    status: Literal["draft", "active", "retired", "unknown"] | None = None
    experimental: bool | None = None
    compose: ValueSetCompose | None = None

Package surface

The names below re-export from dhis2w_fhir itself; the guide's generate targets section covers what each emitter produces.

dhis2w_fhir

Version-neutral FHIR IG generation: fhir.toml config, FSH emission, and project scaffolding.

Each component owns its schemas; this module is the one stable import surface over them, so from dhis2w_fhir import GenerateConfig keeps working however the components are arranged internally.