Skip to content

Add complete mapping framework with JSON tests and per-element specs - #29

Open
niquola wants to merge 8 commits into
masterfrom
issue-28
Open

Add complete mapping framework with JSON tests and per-element specs#29
niquola wants to merge 8 commits into
masterfrom
issue-28

Conversation

@niquola

@niquola niquola commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Added JSON data-driven test suites for all 7 resources (Condition, Encounter, Observation, MedicationRequest, MedicationStatement, AllergyIntolerance) — following the Patient pattern
  • Added per-element mapping docs (mapping/{resource}/*.md) for all resources with decisions, consensus notes, and unmapped element lists
  • Added data-driven test runners (run.test.ts) that auto-run all JSON fixtures in both sequential and hash ID modes
  • Updated spec docs (encounter.md, medication.md, allergy-intolerance.md) with formal unmapped elements tables, status filtering rules, and validation rules
  • Fixed MedicationStatement inconsistency (legacy resolveReferenceAsNumberMappingContext)

Completeness Matrix (before → after)

Resource mapping/ tests/ JSON spec/ unmapped profile
Patient 7 files 8 files yes OmopPatient
Condition 0 → 6 5 + runner yes OmopCondition
Encounter 0 → 5 0 → 5 + runner no → yes OmopEncounter
Observation 0 → 6 0 → 6 + runner partial → yes OmopObservation/Measurement
MedicationRequest 0 → 6 0 → 4 + runner no → yes OmopMedicationRequest
MedicationStatement 0 → 6 0 → 4 + runner no → yes OmopMedicationStatement
AllergyIntolerance 0 → 5 0 → 5 + runner no → yes OmopAllergyIntolerance

Test Results

601 tests pass (up from 375), 2000 expect() calls across 15 test files.

Test plan

  • All 601 tests pass (bun test)
  • JSON tests run in both sequential and hash ID modes
  • All existing inline tests still pass unchanged

Fixes #28

🤖 Generated with Claude Code

Add spec/framework.md documenting the mapping pipeline architecture,
patterns, and identified inconsistencies. Fix MedicationStatement mapper
to use MappingContext (was the only mapper using legacy resolveReferenceAsNumber),
add drug_exposure_id assignment, and add hash mode tests.

375 tests pass (5 new).

Fixes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…nmapped docs for all resources

All 7 mappers now have the full "definition of done" artifacts:
- mapping/{resource}/*.md: per-element mapping specs with decisions and consensus
- tests/{resource}/*.json: declarative JSON test data (FHIR input → OMOP output)
- tests/{resource}/run.test.ts: data-driven test runners (sequential + hash mode)
- spec/*.md: updated with unmapped elements sections and validation rules

New JSON test cases: 226 (113 cases x 2 modes), total tests: 601 (up from 375).

Fixes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@niquola niquola changed the title Analyze mapping framework, fix MedicationStatement inconsistency Add complete mapping framework with JSON tests and per-element specs Feb 15, 2026
niquola and others added 2 commits February 15, 2026 12:58
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… specs

Fixes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@niquola

niquola commented Feb 15, 2026

Copy link
Copy Markdown
Contributor Author

Mapping framework documented in CLAUDE.md

Added Mapping Framework section to CLAUDE.md with:

Definition of Done (4 artifacts per resource)

  1. mapping/{resource}/*.md — per-element mapping specs + nonmapped.md
  2. tests/{resource}/*.json + run.test.ts — JSON data-driven tests (sequential + hash modes)
  3. spec/{resource}.md — consolidated spec with unmapped elements table
  4. profiles/Omop{Resource}.fsh — FHIR Shorthand profile

Also documented

  • Completeness matrix (all 7 resources complete)
  • Mapper architecture (5-stage pipeline)
  • Full repository structure
  • JSON test case format

Updated specs

  • spec/framework.md — fixed outdated inconsistencies section (MedicationStatement already fixed), updated test counts (601 tests, 2000 expect() calls)
  • spec/testing.md — rewritten to reflect JSON data-driven testing as primary approach across all 7 resources

niquola and others added 4 commits February 15, 2026 14:56
…pecs

Patient and Observation specs used informal "Gaps" sections while all other
resource specs (Condition, Encounter, Medication, AllergyIntolerance) had
formal "Unmapped FHIR Elements" tables. Now all 7 specs are consistent.

Fixes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Translates 35 per-element mapping specification files across all 7
resources (patient, condition, encounter, observation, medication-request,
medication-statement, allergy-intolerance) to English for consistency
with the rest of the project documentation.

Previously only nonmapped.md files were translated. This completes the
documentation language consistency effort.

Fixes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… English

Fixes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let's work on mapping framework

1 participant