← Profiling and Validation
Track 1 — FHIR Fundamentals

Validation

Validation checks that a FHIR resource conforms to the specification, a profile, or both. The result is always an OperationOutcome — a structured list of issues with severity, code, and location.

Types of validation

Structural

Is the JSON (or XML) syntactically valid? Does it have a resourceType? Are all required fields present as defined by the base FHIR spec? Is the data type correct — is a date field actually a date?

Always the first check. If structure is broken, further validation stops.

Cardinality

Do elements appear the correct number of times? If a profile says identifier must have at least 1 entry (1..*), does the resource provide at least one?

Applied against base spec + any active profiles.

Terminology

Are coded values from the correct CodeSystem? If gender must be from AdministrativeGender, is the value one of male/female/other/unknown? Does a LOINC code exist in the LOINC CodeSystem?

Requires access to terminology services. May be skipped in lightweight validators.

Profile conformance

Does the resource meet all constraints defined in a StructureDefinition — cardinality, mustSupport, fixedValues, slicing rules, and invariants?

Only when a profile is specified, either via meta.profile[] or via the ?profile= query parameter.

Business rules (invariants)

FHIRPath expressions defined in the spec that enforce cross-field logic. Example: Observation must have either value[x] or dataAbsentReason — not neither. dom-6: resources should have narrative text.

Applied against base spec invariants always. Profile invariants when profiling is active.

OperationOutcome

Every FHIR validation result is an OperationOutcome resource — a list of issues. Each issue has a severity, a code, a human-readable diagnostics message, and optionally an expression path pointing to the exact element that caused the issue.

errorResource is invalid. Cannot be saved to a FHIR server. Must be fixed before the operation can proceed.
warningResource is usable but has a problem worth noting. Servers typically accept it but flag the issue.
informationInformational note — no action required. Often a best-practice recommendation (like dom-6 narrative).
fatalValidation could not proceed at all — e.g. JSON is unparseable. Even more severe than error.
OperationOutcome example
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "required",
      "diagnostics": "Patient.gender: minimum required = 1, but only found 0",
      "expression": ["Patient.gender"]
    },
    {
      "severity": "warning",
      "code": "best-practice",
      "diagnostics": "dom-6: A resource should have narrative for robust management"
    }
  ]
}

The $validate operation

FHIR servers expose a $validate operation that validates a resource without storing it. You POST the resource and get back an OperationOutcome.

# Validate against base FHIR R4
POST /fhir/Patient/$validate
Body: the Patient resource
# Validate against a specific profile
POST /fhir/Patient/$validate?profile=https://fhir.sk/fhir/StructureDefinition/fhirsk-patient
# Declare profile in resource meta (validated on write)
"meta": { "profile": ["https://fhir.sk/fhir/StructureDefinition/fhirsk-patient"] }

Our validation results

We validated Jana Horváth (examples/patients/jana-horvath.json) against the FhirSkPatient profile using HAPI FHIR:

Jana Horváth — passes ✓

1 warning only: dom-6 (no narrative text). All cardinality constraints satisfied. Profile compliant.

{ "resourceType": "Patient", "name": [{ "family": "Test" }] } — fails ✗

4 errors: identifier missing, gender missing, birthDate missing, name.given missing.

Try both in the Validator — use "Load valid" and "Load invalid" buttons.

Validation tools

HAPI FHIRValidates on write by default. Exposes $validate for explicit checks. Supports loading StructureDefinitions from the server.
HL7 FHIR Validator (validator_cli.jar)Official CLI tool from HL7. Validates against base spec, any profile, and any IG. The reference implementation — most accurate but slowest.
InfernoTest suite for Implementation Guide conformance. Used in US ONC certification and EHDS conformance testing.
FHIR.sk ValidatorOur structural validator at /lab/validator. Checks JSON syntax, resourceType, and FhirSkPatient cardinality constraints. Not a full FHIR validator.

See also