-
Notifications
You must be signed in to change notification settings - Fork 0
feat: scene-based PA demo with cinematic transitions #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rsalus
wants to merge
28
commits into
main
Choose a base branch
from
feat/pa-dashboard-demo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d1fbfa5
feat: deploy EHR demo to Azure via Aspire + azd → ACA
rsalus 68f1807
Merge feat/deploy-ehr-demo: Azure Container Apps deployment via Aspir…
rsalus 05f0b3b
fix: use absolute URL for GraphQL client (graphql-request requires it)
rsalus a11c85a
feat(pa-dashboard-demo): task-001 — DemoProvider context with scene/c…
rsalus 995262d
feat(pa-dashboard-demo): task-002 — SceneNav pill navigation component
rsalus 24ed344
feat(pa-dashboard-demo): task-003 — SceneTransition wrapper and route…
rsalus 1ef87ce
feat(pa-dashboard-demo): task-017 — backend seed script
rsalus ad68826
Merge branch 'worktree-agent-a4317a39'
rsalus 5c0b58c
Merge branch 'worktree-agent-a3594ddb'
rsalus 8f8fa01
feat(pa-dashboard-demo): task-004 -- fleet seed data and KPICards com…
rsalus a09be2f
feat(pa-dashboard-demo): task-008 -- enhanced demo data and ChartTabP…
rsalus 5dc4dfb
feat(pa-dashboard-demo): task-005 -- FleetCard and FleetView components
rsalus 47edb49
feat(pa-dashboard-demo): task-012 — React Flow custom nodes
rsalus ecff8ca
feat(pa-dashboard-demo): task-006 -- CasePipeline component
rsalus addc0ee
feat(pa-dashboard-demo): task-009 -- enhanced EncounterSidebar with c…
rsalus 39f3431
feat(pa-dashboard-demo): task-013 — CaseGraph and AnimatedEdge
rsalus 682176c
feat(pa-dashboard-demo): task-007 -- Fleet route page assembly and Gr…
rsalus 470120a
feat(pa-dashboard-demo): task-010 -- enhanced useEhrDemoFlow state ma…
rsalus 68bfd69
Merge branch 'worktree-agent-adad11f1'
rsalus c5b3783
feat(pa-dashboard-demo): task-011 -- authorization detection banner a…
rsalus 6a48103
feat(pa-dashboard-demo): task-014 — CaseTimeline and case detail route
rsalus a5f953d
Merge branch 'worktree-agent-a178e330'
rsalus 98157da
Merge branch 'worktree-agent-a2fd1d4e'
rsalus 78d11ee
feat(pa-dashboard-demo): task-015 -- scene transitions with shared la…
rsalus 7181c21
feat(pa-dashboard-demo): task-016 -- integration polish and demo entr…
rsalus 965f146
feat(pa-dashboard-demo): merge integration layer with conflict resolu…
rsalus a8a2aa7
fix(pa-dashboard-demo): align SceneNav tests with aria-current implem…
rsalus 1f27f80
fix(pa-dashboard-demo): address all PR review findings
rsalus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # =========================================================================== | ||
| # AuthScript Dashboard - Multi-stage Docker build | ||
| # Stage 1: Build React SPA with Vite | ||
| # Stage 2: Serve via nginx with API reverse proxy | ||
| # Build context: repository root | ||
| # =========================================================================== | ||
|
|
||
| # Build stage | ||
| FROM docker.io/node:20-alpine AS build | ||
| WORKDIR /app | ||
|
|
||
| # Copy all workspace files (node_modules excluded via .dockerignore) | ||
| COPY package.json package-lock.json ./ | ||
| COPY shared/ shared/ | ||
| COPY apps/dashboard/ apps/dashboard/ | ||
|
|
||
| # Install dependencies and build | ||
| RUN npm ci | ||
| RUN npm run build --workspace=shared/types && npm run build --workspace=shared/validation | ||
| RUN npm run build --workspace=apps/dashboard | ||
|
|
||
| # Serve stage | ||
| FROM docker.io/nginx:alpine | ||
|
|
||
| # Copy built SPA assets | ||
| COPY --from=build /app/apps/dashboard/dist /usr/share/nginx/html | ||
|
|
||
| # Copy nginx config template (envsubst resolves $GATEWAY_URL at startup) | ||
| COPY apps/dashboard/nginx.conf /etc/nginx/templates/default.conf.template | ||
|
|
||
| EXPOSE 80 | ||
|
|
||
| HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \ | ||
| CMD wget -q --spider http://localhost/health || exit 1 | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| server { | ||
| listen 80; | ||
| server_name _; | ||
| root /usr/share/nginx/html; | ||
| index index.html; | ||
|
|
||
| # SPA fallback — serve index.html for client-side routes | ||
| location / { | ||
| try_files $uri $uri/ /index.html; | ||
| } | ||
|
|
||
| # Reverse proxy /api to Gateway service (resolved at startup via envsubst) | ||
| location /api/ { | ||
| proxy_pass ${GATEWAY_URL}/api/; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_set_header X-Forwarded-Proto $scheme; | ||
| } | ||
|
|
||
| # Cache static assets | ||
| location /assets/ { | ||
| expires 1y; | ||
| add_header Cache-Control "public, immutable"; | ||
| } | ||
|
|
||
| # Health check | ||
| location /health { | ||
| return 200 'ok'; | ||
| add_header Content-Type text/plain; | ||
| } | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { getSmoothStepPath, BaseEdge, type EdgeProps } from '@xyflow/react'; | ||
|
|
||
| export interface AnimatedEdgeData { | ||
| animationDelay?: number; | ||
| } | ||
|
|
||
| /** | ||
| * Custom React Flow edge with an animated dot traveling along the path. | ||
| * Uses SVG <circle> with <animateMotion> for the animation effect. | ||
| */ | ||
| export function AnimatedEdge({ | ||
| id, | ||
| sourceX, | ||
| sourceY, | ||
| targetX, | ||
| targetY, | ||
| sourcePosition, | ||
| targetPosition, | ||
| style = {}, | ||
| markerEnd, | ||
| data, | ||
| }: EdgeProps & { data?: AnimatedEdgeData }) { | ||
| const [edgePath] = getSmoothStepPath({ | ||
| sourceX, | ||
| sourceY, | ||
| sourcePosition, | ||
| targetX, | ||
| targetY, | ||
| targetPosition, | ||
| }); | ||
|
|
||
| const delay = data?.animationDelay ?? 0; | ||
|
|
||
| return ( | ||
| <> | ||
| <BaseEdge | ||
| id={id} | ||
| path={edgePath} | ||
| markerEnd={markerEnd} | ||
| style={{ | ||
| ...style, | ||
| strokeDasharray: '6 4', | ||
| strokeWidth: 1.5, | ||
| stroke: '#94a3b8', | ||
| }} | ||
| /> | ||
| <circle r="3" fill="#0d9488" opacity="0.8"> | ||
| <animateMotion | ||
| dur="2.5s" | ||
| repeatCount="indefinite" | ||
| path={edgePath} | ||
| begin={`${delay}s`} | ||
| /> | ||
| </circle> | ||
| </> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,235 @@ | ||
| import { useState, useEffect, useCallback } from 'react'; | ||
| import { ReactFlow, ReactFlowProvider, Background, Controls } from '@xyflow/react'; | ||
| import type { Node, Edge } from '@xyflow/react'; | ||
| import { PatientNode } from './PatientNode'; | ||
| import { EvidenceNode } from './EvidenceNode'; | ||
| import { CriteriaNode } from './CriteriaNode'; | ||
| import { DecisionNode } from './DecisionNode'; | ||
| import { AnimatedEdge } from './AnimatedEdge'; | ||
| import { DEMO_PA_RESULT_SOURCES, LCD_L34220_POLICY } from '@/lib/demoData'; | ||
| import type { PARequest } from '@/api/graphqlService'; | ||
|
|
||
| // Register custom node and edge types | ||
| const nodeTypes = { | ||
| patient: PatientNode, | ||
| evidence: EvidenceNode, | ||
| criteria: CriteriaNode, | ||
| decision: DecisionNode, | ||
| }; | ||
|
|
||
| const edgeTypes = { | ||
| animated: AnimatedEdge, | ||
| }; | ||
|
|
||
| /** | ||
| * Maps a criterion's met value (boolean | null) to a node status string. | ||
| */ | ||
| function toStatus(met: boolean | null): 'met' | 'not_met' | 'indeterminate' { | ||
| if (met === true) return 'met'; | ||
| if (met === false) return 'not_met'; | ||
| return 'indeterminate'; | ||
| } | ||
|
|
||
| /** | ||
| * Builds graph nodes and edges from a PARequest. | ||
| * Exported for testability. | ||
| */ | ||
| export function buildCaseGraphData(paRequest: PARequest): { | ||
| nodes: Node[]; | ||
| edges: Edge[]; | ||
| } { | ||
| const nodes: Node[] = []; | ||
| const edges: Edge[] = []; | ||
|
|
||
| // 1. Patient node (top center) | ||
| const patientNodeId = 'patient-1'; | ||
| nodes.push({ | ||
| id: patientNodeId, | ||
| type: 'patient', | ||
| position: { x: 400, y: 0 }, | ||
| data: { | ||
| name: paRequest.patient.name, | ||
| dob: paRequest.patient.dob, | ||
| mrn: paRequest.patient.mrn, | ||
| insurance: paRequest.payer, | ||
| }, | ||
| }); | ||
|
|
||
| // 2. Evidence nodes (left column, stacked) | ||
| const evidenceEntries = paRequest.criteria.map((criterion) => { | ||
| const sourceInfo = DEMO_PA_RESULT_SOURCES[criterion.label]; | ||
| return { | ||
| text: sourceInfo?.evidence ?? criterion.reason ?? criterion.label, | ||
| source: sourceInfo?.source ?? 'Clinical', | ||
| criterionLabel: criterion.label, | ||
| }; | ||
| }); | ||
|
|
||
| const evidenceYStart = 120; | ||
| const evidenceSpacing = 100; | ||
|
|
||
| evidenceEntries.forEach((entry, i) => { | ||
| const nodeId = `evidence-${i}`; | ||
| nodes.push({ | ||
| id: nodeId, | ||
| type: 'evidence', | ||
| position: { x: 0, y: evidenceYStart + i * evidenceSpacing }, | ||
| data: { | ||
| text: entry.text, | ||
| source: entry.source, | ||
| }, | ||
| }); | ||
|
|
||
| // Edge: patient -> evidence (subtle) | ||
| edges.push({ | ||
| id: `edge-patient-evidence-${i}`, | ||
| source: patientNodeId, | ||
| target: nodeId, | ||
| style: { stroke: '#cbd5e1', strokeWidth: 1 }, | ||
| animated: false, | ||
| }); | ||
| }); | ||
|
|
||
| // 3. Criteria nodes (center column, stacked) | ||
| const criteriaYStart = 120; | ||
| const criteriaSpacing = 100; | ||
|
|
||
| paRequest.criteria.forEach((criterion, i) => { | ||
| const nodeId = `criteria-${i}`; | ||
| nodes.push({ | ||
| id: nodeId, | ||
| type: 'criteria', | ||
| position: { x: 350, y: criteriaYStart + i * criteriaSpacing }, | ||
| data: { | ||
| label: criterion.label, | ||
| status: toStatus(criterion.met), | ||
| reasoning: criterion.reason, | ||
| }, | ||
| }); | ||
|
|
||
| // Edge: evidence -> criteria (animated dashed) | ||
| edges.push({ | ||
| id: `edge-evidence-criteria-${i}`, | ||
| source: `evidence-${i}`, | ||
| target: nodeId, | ||
| type: 'animated', | ||
| data: { animationDelay: i * 0.3 }, | ||
| }); | ||
| }); | ||
|
|
||
| // 4. Decision node (right) | ||
| const decisionNodeId = 'decision-1'; | ||
| const decisionY = | ||
| criteriaYStart + | ||
| ((paRequest.criteria.length - 1) * criteriaSpacing) / 2; | ||
|
|
||
| nodes.push({ | ||
| id: decisionNodeId, | ||
| type: 'decision', | ||
| position: { x: 700, y: decisionY }, | ||
| data: { | ||
| payer: paRequest.payer, | ||
| policyId: LCD_L34220_POLICY.policyId, | ||
| confidence: paRequest.confidence, | ||
| status: paRequest.status, | ||
| }, | ||
| }); | ||
|
|
||
| // Edges: criteria -> decision (solid colored) | ||
| paRequest.criteria.forEach((criterion, i) => { | ||
| const statusColor = | ||
| criterion.met === true | ||
| ? '#22c55e' | ||
| : criterion.met === false | ||
| ? '#ef4444' | ||
| : '#f59e0b'; | ||
| edges.push({ | ||
| id: `edge-criteria-decision-${i}`, | ||
| source: `criteria-${i}`, | ||
| target: decisionNodeId, | ||
| style: { stroke: statusColor, strokeWidth: 2 }, | ||
| }); | ||
| }); | ||
|
|
||
| return { nodes, edges }; | ||
| } | ||
|
|
||
| /** Timing tiers for sequential node reveal animation (ms) */ | ||
| const REVEAL_TIERS: Record<string, [number, number]> = { | ||
| patient: [0, 300], | ||
| evidence: [300, 900], | ||
| criteria: [900, 1500], | ||
| decision: [1500, 1800], | ||
| }; | ||
|
|
||
| /** Apply opacity 0 initially, then reveal nodes sequentially by type */ | ||
| function useNodeReveal(baseNodes: Node[]): Node[] { | ||
| const [revealedTypes, setRevealedTypes] = useState<Set<string>>(new Set()); | ||
|
|
||
| const scheduleReveals = useCallback(() => { | ||
| const types = Object.keys(REVEAL_TIERS); | ||
| const timers: ReturnType<typeof setTimeout>[] = []; | ||
|
|
||
| for (const type of types) { | ||
| const [, end] = REVEAL_TIERS[type]; | ||
| timers.push( | ||
| setTimeout(() => { | ||
| setRevealedTypes((prev) => new Set([...prev, type])); | ||
| }, end), | ||
| ); | ||
| } | ||
|
|
||
| return timers; | ||
| }, []); | ||
|
|
||
| useEffect(() => { | ||
| const timers = scheduleReveals(); | ||
| return () => timers.forEach(clearTimeout); | ||
| }, [scheduleReveals]); | ||
|
|
||
| return baseNodes.map((node) => ({ | ||
| ...node, | ||
| style: { | ||
| ...node.style, | ||
| opacity: revealedTypes.has(node.type ?? '') ? 1 : 0, | ||
| transition: 'opacity 0.3s ease-in', | ||
| }, | ||
| })); | ||
| } | ||
|
|
||
| interface CaseGraphProps { | ||
| paRequest: PARequest; | ||
| } | ||
|
|
||
| /** | ||
| * Full case graph visualization for a PA request. | ||
| * Shows patient -> evidence -> criteria -> decision flow. | ||
| * Nodes fade in sequentially: Patient -> Evidence -> Criteria -> Decision. | ||
| */ | ||
| export function CaseGraph({ paRequest }: CaseGraphProps) { | ||
| const { nodes: baseNodes, edges } = buildCaseGraphData(paRequest); | ||
| const nodes = useNodeReveal(baseNodes); | ||
|
|
||
| return ( | ||
| <ReactFlowProvider> | ||
| <ReactFlow | ||
| nodes={nodes} | ||
| edges={edges} | ||
| nodeTypes={nodeTypes} | ||
| edgeTypes={edgeTypes} | ||
| fitView | ||
| nodesDraggable={false} | ||
| nodesConnectable={false} | ||
| elementsSelectable={false} | ||
| panOnDrag={false} | ||
| zoomOnScroll={false} | ||
| zoomOnDoubleClick={false} | ||
| proOptions={{ hideAttribution: true }} | ||
| className="bg-slate-50/50 rounded-xl" | ||
| > | ||
| <Background gap={24} size={1} color="#e2e8f0" /> | ||
| <Controls showInteractive={false} /> | ||
| </ReactFlow> | ||
| </ReactFlowProvider> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Harden runtime image to avoid running as root.
The final stage lacks a
USERdirective, and scanner DS-0002 flags this. Please switch to an unprivileged nginx image/user and align exposed/healthcheck port accordingly.Suggested hardening baseline
Also ensure nginx is configured to listen on
8080to match this change.📝 Committable suggestion
🤖 Prompt for AI Agents