Skip to content

feat(studio): SQL analogy panel in CQL tab — spec-derived illustrative preview#66

Merged
Taleef7 merged 2 commits into
mainfrom
feat/cql-sql-preview
Jun 8, 2026
Merged

feat(studio): SQL analogy panel in CQL tab — spec-derived illustrative preview#66
Taleef7 merged 2 commits into
mainfrom
feat/cql-sql-preview

Conversation

@Taleef7
Copy link
Copy Markdown
Owner

@Taleef7 Taleef7 commented Jun 8, 2026

Summary

  • Adds SqlPreviewPanel component (new file: frontend/features/studio/components/SqlPreviewPanel.tsx) wired into CqlTab below the compile results block
  • Panel is collapsed by default; opens/closes with a ▶ SQL Analogy toggle
  • SQL is a static template derived entirely from spec_json fields already on the MeasureDetail prop — no backend call, no CQL parser

What the panel shows

Spec field SQL slot
policyRef header comment
complianceWindow INTERVAL '...' in CASE WHEN OVERDUE / DUE_SOON
eligibilityCriteria.programEnrollmentText JOIN comment
eligibilityCriteria.roleFilter AND e.role = '...'
eligibilityCriteria.siteFilter AND e.site = '...'
exclusions[0].criteriaText CASE WHEN EXCLUDED
requiredDataElements -- required: comment on SELECT

Guardrails

  • Amber "Illustrative only — not executed. CQL is the compliance source of truth." banner always visible when expanded
  • DUE_SOON = windowDays - 30 (approximation); always paired with comment -- DUE_SOON threshold approximate; see CQL for exact window
  • Fallback: if complianceWindow has no numeric value, raw string passed through as a SQL comment

Tests

7-assertion Vitest smoke suite: collapsed default, banner text, SQL content (policy ref, INTERVAL values, role/site filters, approximation comment), toggle off, non-numeric-window fallback.
All 7 pass. Frontend build clean.

Scope

Frontend-only. No backend, no schema, no new dependencies, no audit events.

🤖 Generated with Claude Code

…ative preview

Adds SqlPreviewPanel component below the Monaco editor in the Studio CQL tab.
Panel is collapsed by default; expands to show a SQL-shaped analogy derived
entirely from spec_json fields (complianceWindow, eligibilityCriteria, exclusions,
requiredDataElements, policyRef) with no backend calls and no CQL parsing.

Key constraints honoured:
- Amber 'Illustrative only — CQL is the compliance source of truth' banner
  always visible when expanded
- DUE_SOON threshold computed as window - 30d with explicit approximation
  comment: 'DUE_SOON threshold approximate; see CQL for exact window'
- Falls back gracefully when complianceWindow contains no numeric value

Includes 7-test Vitest suite covering collapsed default, banner, SQL content
(policy ref, window, role/site filters, approximation comment), toggle, and
non-numeric-window fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
workwell-measure-studio Ready Ready Preview, Comment Jun 8, 2026 4:59pm

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e94cb17562

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +20 to +22
const windowMatch = complianceWindow?.match(/(\d+)/);
const windowDays = windowMatch ? parseInt(windowMatch[1], 10) : null;
const dueSoonDays = windowDays ? windowDays - 30 : null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Parse only day-based compliance windows

When a compliance window contains a numeric value that is not a day count, this grabs the first number and renders it as days. I checked the seeded Hepatitis B measure (backend/src/main/resources/db/migration/V017__seed_additional_measures.sql lines 84-86), whose window is Series of 3 doses over 6 months; expanding this panel would show INTERVAL '3 days' and a -27 days due-soon threshold, making the spec-derived preview materially misleading for an existing measure. Only convert strings that explicitly describe day counts, otherwise use the existing raw-string fallback.

Useful? React with 👍 / 👎.

Tighten regex from /(\d+)/ to /(\d+)\s*days?\b/i so strings like
"Series of 3 doses over 6 months" fall through to the raw-string
fallback instead of rendering a misleading INTERVAL '3 days'.
Add test case covering the multi-number non-day window pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Taleef7 Taleef7 merged commit cc03cb9 into main Jun 8, 2026
30 checks passed
@Taleef7 Taleef7 deleted the feat/cql-sql-preview branch June 8, 2026 17:21
Taleef7 pushed a commit that referenced this pull request Jun 8, 2026
…#66)

Records the 7 merged PRs (ADR-003, workwell.os redirect, CQL code-filter
tightening, CMS125/CMS122 Active promotion, trend per-bucket chart, case
code explorer, SQL analogy panel). Updates measure catalog count to 10
runnable measures in Current Focus.

Co-Authored-By: Claude Sonnet 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.

1 participant