DocsValidators

fhir_reference validator

FHIR relative reference of the form `ResourceType/id`.

Format

Matches `/^[A-Z][A-Za-z]+\/[A-Za-z0-9-]+$/`. PascalCase resource type, slash, then an id of letters, digits, hyphens.

Examples

  • Patient/123
  • Observation/lab-7f4
  • Encounter/abc-DEF-456

Implementation

Faithful summary of lib/validators.ts. Validators are pure functions and run identically in the worker, the Workbench, and the MCP server.

function validFhirRef(value) {
  return /^[A-Z][A-Za-z]+\/[A-Za-z0-9-]+$/.test(value)
    ? OK
    : fail('fhir_ref_invalid', 'expected ResourceType/id')
}

Use in a template

Validators attach to a field on a custom template. The cascade runs them after mapping but before commit; failures surface in the per-row validation report.

fields:
  - column: subject
    type: string
    validators:
      - type: fhir_reference

Common gotchas

  • Relative form only. `https://server/fhir/Patient/123` fails — strip the base in transform.
  • Underscores and dots in the id are rejected — FHIR allows them, but we do not. Open an issue if your server needs them.
  • No resource-type allow-list. `MyCustomThing/1` passes the shape check.

Related templates

No template in the default catalogue ships with fhir_reference preconfigured. Use it on a custom template via the YAML snippet above, or via the template editor.

Pricing

Validators run on every committed row

Schema-only mode (headers + ≤3 sample rows) is free and unlimited; full-data commits are metered. See plans →