Data Validation

Models validation

Validate openEHR models (archetypes and templates) before they are used at runtime. Model validation is a static check that ensures the clinical models are syntactically correct, internally consistent and follow constraints such as cardinalities, data types and terminology bindings.

What to check

  • Syntax: ADL2 / OPT / JSON syntax errors.
  • Structural consistency: duplicate node ids, circular references, invalid paths.
  • Constraints: data type constraints, value ranges, cardinalities.
  • Terminology bindings: missing or invalid codes, stale terminology references.
  • Metadata: author, versioning and lifecycle status.

How to validate

  • Use an ADL2 parser/validator (for example Archie in Java) to parse archetypes and templates.
  • Run template validation tools that ensure templates reference valid archetype nodes and respect template-specific constraints.
  • Convert templates to machine-friendly schemas (JSON Schema or POJOs) for additional automated checks.
  • Include model validation as part of CI so broken models are rejected early.

Examples

  • Parse and validate archetypes/templates with an ADL2 parser library in your build step.
  • Add unit tests that load each archetype/template and assert successful parsing.

Template validation

Templates tailor archetypes for specific forms/workflows and must be validated both as models and as the basis for instance validation.

What to check

  • Template references: all archetype nodes referenced by the template must exist and resolve correctly.
  • Constraint tightening: ensure template-level constraints do not contradict archetype constraints.
  • Path correctness: template paths must map to valid composition/data paths.
  • Serialization compatibility: ensure templates can produce valid composition JSON/XML for your CDR.

How to validate

  • Use template validators (Archie or other tooling) to validate the template file itself.
  • Generate a canonical composition instance from the template and validate that instance against the template.
  • Validate mapping files (if you map template nodes to FHIR or other standards) for completeness and consistency.