feat(studio): SQL analogy panel in CQL tab — spec-derived illustrative preview#66
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
💡 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".
| const windowMatch = complianceWindow?.match(/(\d+)/); | ||
| const windowDays = windowMatch ? parseInt(windowMatch[1], 10) : null; | ||
| const dueSoonDays = windowDays ? windowDays - 30 : null; |
There was a problem hiding this comment.
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>
…#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>
Summary
SqlPreviewPanelcomponent (new file:frontend/features/studio/components/SqlPreviewPanel.tsx) wired intoCqlTabbelow the compile results block▶ SQL Analogytogglespec_jsonfields already on theMeasureDetailprop — no backend call, no CQL parserWhat the panel shows
policyRefcomplianceWindowINTERVAL '...'in CASE WHEN OVERDUE / DUE_SOONeligibilityCriteria.programEnrollmentTexteligibilityCriteria.roleFilterAND e.role = '...'eligibilityCriteria.siteFilterAND e.site = '...'exclusions[0].criteriaTextrequiredDataElements-- required:comment on SELECTGuardrails
windowDays - 30(approximation); always paired with comment-- DUE_SOON threshold approximate; see CQL for exact windowcomplianceWindowhas no numeric value, raw string passed through as a SQL commentTests
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