Add ELM-to-SQL library, HAPI FHIR SQL views, and CMS demo fixtures (resolves #16, #21, refs #18)#25
Draft
aks129 wants to merge 6 commits intocqframework:masterfrom
Draft
Add ELM-to-SQL library, HAPI FHIR SQL views, and CMS demo fixtures (resolves #16, #21, refs #18)#25aks129 wants to merge 6 commits intocqframework:masterfrom
aks129 wants to merge 6 commits intocqframework:masterfrom
Conversation
Implements the @cqframework/elm-to-sql package as a pure ESM TypeScript library with zero runtime Node.js dependencies (Apache 2.0). Includes: - ElmToSqlTranspiler: converts HL7 ELM JSON to SQL WITH CTEs - generateMeasureReport: produces FHIR R4 MeasureReport from population counts - STANDARD_VIEW_DEFINITIONS: SQL-on-FHIR ViewDefinition resources + DDL - 24 Jest tests passing against a CMS125 Breast Cancer Screening ELM fixture - FAQ.md documenting current support state, known gaps, and roadmap - CLAUDE.md updated with SQL-on-FHIR tracking table and demo sequence Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Creates scripts/hapi-fhir-sql-on-fhir/ with an idempotent install.sql that runs in a single transaction and registers 8 CREATE OR REPLACE VIEWs (patient, observation, condition, procedure, encounter, medication_request, diagnostic_report, value_set_expansion) over HAPI FHIR JPA 6.x/7.x PostgreSQL tables HFJ_RESOURCE and HFJ_RES_VER. Satisfies the view contracts expected by @cqframework/elm-to-sql. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ework#18) Adds ELM JSON fixture for CMS130 (ages 45-75 colorectal cancer screening) covering Union patterns for Denominator Exclusion (Condition + Procedure) and Numerator (Colonoscopy/FOBT/Sigmoidoscopy). Adds 15 new Jest tests in a CMS130 describe block; total test count is now 39, all passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds packages/elm-to-sql/src/valueset/ with three modules:
- value-set-extractor.ts: extractValueSets() / extractUsedValueSets()
reads valueSets.def from ELM JSON and returns { name, url } references
matching the value_set_expansion view contract
- value-set-loader.ts: loadValueSetExpansions() fetches pre-expanded
ValueSet resources from a FHIR R4 server ($expand with Bundle fallback),
flattens expansion.contains[] including nested hierarchies; zero Node.js
deps (accepts pluggable fetch); per-set errors captured, never thrown
- value-set-sql.ts: generateValueSetTableDdl/InsertSql/UpsertSql/SeedScript
for environments without the HAPI FHIR JPA view (DuckDB, plain PostgreSQL)
27 new tests (66 total, all passing). Tested against CMS125 and CMS130 fixtures.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
HAPI FHIR JPA boot scripts (scripts/hapi-fhir-sql-on-fhir/): - 009_coverage_view.sql — Coverage: type, period, payor, class (plan) - 010_allergy_intolerance_view.sql — AllergyIntolerance: substance, clinical status, reaction severity; US Core 6.1 MustSupport elements - 011_immunization_view.sql — Immunization: CVX vaccine codes, occurrence, statusReason (not-done support), site/route, lot number - 012_service_request_view.sql — ServiceRequest (new in US Core 6.1): orders/referrals, occurrence, doNotPerform flag, insurance reference data-quality/dq_checks.sql — standalone pre-flight DQ script: - 14 sections: views installed, resource volumes, per-resource field nullability (CRITICAL/WARNING), date sanity, code system spot-check, value set expansion coverage - Emits structured RAISE NOTICE report; never aborts the session - CRITICAL = will produce wrong measure results; WARNING = may undercount packages/elm-to-sql/src/views/view-definitions.ts: - serviceRequestViewDefinition() added (11th standard view) - Remove unused colList variable All 66 tests continue to pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…qframework#21/cqframework#18) - scripts/hapi-fhir-sql-on-fhir/test/run_tests.sql: isolated PostgreSQL integration test using a cql_test schema with 17 synthetic FHIR R4 resources; covers all 12 views, edge cases (effectivePeriod, medicationReference, occurrenceString, doNotPerform), deleted-resource exclusion, and value set expansion; always ROLLBACKs for zero side-effects - packages/elm-to-sql/test/elm-to-sql.test.ts: 36 new US Core 6.1 ViewDefinition column contract tests locking down the CQL-critical column set for all 11 standard views; test count grows from 66 to 102 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
|
Could we meet Thursday mid-day or Friday morning for you to do a demo and explain what is going on? 😜 |
Collaborator
Author
|
can use my link https://calendar.app.google/MZcQ2Spm1NYNS72p9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@cqframework/elm-to-sqllibrary — pure ESM TypeScript, zero runtime deps, Apache 2.0. Transpiles ELM JSON → SQL WITH CTEs → FHIR MeasureReport. Pluggable DB adapter, pluggablefetchfor FHIR value set loading.scripts/hapi-fhir-sql-on-fhir/). Idempotentinstall.sqlcreates 12 PostgreSQL views overHFJ_RESOURCE/HFJ_RES_VER. Covers all US Core 6.1 / US CDI v3 eCQM resources.extractValueSets,loadValueSetExpansions(FHIR$expand+ Bundle fallback),generateValueSetSeedScriptfor static PostgreSQL seeding.scripts/hapi-fhir-sql-on-fhir/data-quality/dq_checks.sql— 14 CRITICAL/WARNING/INFO checks covering view existence, patient coverage, null rates, date sanity, and value set expansion completeness.New views (US Core 6.1)
coverage_viewallergy_intolerance_viewimmunization_viewservice_request_viewTest coverage
scripts/hapi-fhir-sql-on-fhir/test/run_tests.sql— PostgreSQL integration test with 17 synthetic FHIR R4 resources, assertions for all 12 views, deleted-resource exclusion; always ROLLBACKs (no side effects)Test plan
npm testinpackages/elm-to-sql/— 102/102 passrun_tests.sqlwritten; run withpsql $DATABASE_URL -f scripts/hapi-fhir-sql-on-fhir/test/run_tests.sqlagainst a HAPI FHIR JPA PostgreSQL instancedata-quality/dq_checks.sql— run before deploying views to catch schema or data issues earlyCQL_STUDIO_DB_URLin server and invokeinstall.sqlon boot (Issue Add server boot scripts to install and/or update SQL views #20)Pending (not in this PR)
Linked issues
Closes #16
Closes #21
References #18
Part of #15
🤖 Generated with Claude Code