Complex types

Complex Structure Type

A ComplexStructureType is a crucial part of stapi.ai's StructureSchema, which forms the foundation for intuitive, declarative, Domain-Driven Design (DDD) business logic modeling. Essentially, ComplexStructureType organizes and manages sets of related data fields derived from the FHIR StructureDefinition.

FHIR Connection and Domain-Driven Design

In FHIR, complex types group related elements together. Similarly, in stapi.ai, ComplexStructureType echoes this concept, bundling related fields together. This structure enables stapi.ai to take advantage of the extensive data modeling capabilities of FHIR, providing a more accessible layer for managing and interacting with not only healthcare data, but any data indeed.

The ComplexStructureType does more than mirror the FHIR complex types structure—it also maintains their relationships. For instance, if a FHIR complex type inherits fields from another type, the equivalent ComplexStructureType in stapi.ai maintains this relationship, as reflected in the parent attribute.

When we consider DDD, these complex types could be thought of as Value Objects initially—immutable objects that are defined by their state (or their properties) rather than an individual identity. This provides a convenient and robust way of encapsulating related data fields into meaningful and reusable structures.

However, when the kind of ComplexStructureType is a 'resource', it is represented as child ResourceStructureType. This will later help us to represent an Aggregate—a cluster of associated objects treated as a unit for the purpose of data changes. Each aggregate has a root, the Aggregate Root, which in our context, would be the FHIR resource. This highlights how ComplexStructureType assists in applying DDD concepts while maintaining a clear alignment with the FHIR standard.

Role in Declarative Programming

ComplexStructureType forms the backbone for declarative programming in stapi.ai Core. By defining the data structure, it specifies the 'what' part of the system, while the 'how' part is managed by the system build upon schema. As schemas are composed of these complex types, they offer a declarative description of the software's functionality.

With complex types directly mapped to FHIR's equivalents, they enable users to articulate their system in terms of healthcare-specific data models, promoting clear intent and interoperability.

Remember that ComplexStructureType is part of a larger system—the StructureSchema. For a comprehensive understanding, explore related components such as PrimitiveStructureType and FieldDefinition.