oehrpy

VS Code Extension

Validate openEHR FLAT format compositions against Web Templates directly in VS Code. Catch invalid paths, wrong suffixes, and missing required fields before they reach EHRBase.

Get the Extension

Or install manually: code --install-extension oehrpy-validator-0.1.0.vsix

Features

Inline Diagnostics

Red squiggles on invalid FLAT paths with detailed error messages. Yellow warnings for missing required fields.

Hover Documentation

Hover over any FLAT path to see the RM type, cardinality, whether it’s required, and valid suffixes.

Validate on Save

Automatic validation when you save a FLAT composition JSON file. Configurable and debounced at 500ms.

Quick Fix

“Did you mean?” suggestions via the lightbulb menu. One click to replace an invalid path with the correct one.

Template Auto-Detection

Finds Web Templates from workspace settings, same directory, or templates/ folder automatically.

Status Bar

See validation state at a glance — valid, error count, or “no template” — in the bottom bar.

Getting Started

1

Install Python 3.10+ with oehrpy: pip install oehrpy

2

Install the extension in VS Code

3

Open a FLAT composition JSON file — keys like vital_signs/blood_pressure/systolic|magnitude

4

Place a Web Template (web_template.json or *.wt.json) in the same directory, or configure paths in settings

5

Save the file — diagnostics appear automatically

Commands

Command Keybinding Description
oehrpy: Validate FLAT Composition Ctrl+Shift+F10 Validate the active JSON file
oehrpy: Select Web Template Pick a Web Template for the current file
oehrpy: Show Valid Paths List all valid FLAT paths in the output panel

Web Template Resolution

The extension finds the Web Template for a composition by checking these locations in order:

  1. Explicit configoehrpy.webTemplatePaths in workspace settings
  2. Same directoryweb_template.json or *.wt.json next to the composition
  3. Project rootweb_templates/ or templates/ directory in the workspace
  4. User prompt — asks you to pick a file and remembers the choice

Configuration

Add to .vscode/settings.json:

// CDR platform dialect "oehrpy.platform": "ehrbase", // Validate automatically on save "oehrpy.validateOnSave": true, // Map template IDs to file paths "oehrpy.webTemplatePaths": { "IDCR - Adverse Reaction List.v1": "./templates/adverse_reaction_wt.json" }, // Python interpreter (leave empty to auto-detect) "oehrpy.pythonPath": "", // CLI timeout in milliseconds "oehrpy.validationTimeout": 5000

Roadmap

v0.1.0 — Core Extension Done

  • Inline diagnostics
  • Validate on save
  • Hover documentation
  • Quick Fix
  • Status bar
  • Template auto-detection

v0.2.0 — Enhanced UX Next

  • Path autocomplete
  • Web Template tree view
  • Marketplace publication

v0.3.0 — Template Validation Planned

  • OPT 1.4 XML validation
  • Web Template schema validation
  • OPT hover & FLAT path impact

v0.4.0 — AQL Language Support Planned

  • AQL syntax highlighting
  • AQL validation
  • AQL path autocomplete
  • AQL snippet library