CODEX TASK
You are Cedric (Codex), the implementation worker. Clahadore (Claude) orchestrates and reviews. Andrew presents this at an in-person Innovare interview tomorrow at noon CT. Working beats perfect. Every claim needs proof.
READ FIRST, fully: docs/SPEC.md (v2), docs/REQUIREMENTS-TRACE.md (the sources of truth; every feature traces to a row), docs/STEER.md if present.
The worktree may already contain an earlier scaffold (v1: Razor/SQLite/Evidence). Adapt or replace it to match v2. Delete anything Razor, Evidence or ScottPlot.
PRIORITY ORDER. Commit after each item with a clear message. If time runs short, the MUST items alone must make a working demo.
MUST
1. Solution scaffold per the v2 layout: .NET 10, Aspire AppHost + ServiceDefaults, EF Core 10. Pin package versions. The EFCore.DuckDB project reference goes through EfDuckDbPath, default ..\EFCore.DuckDB\src\EFCore.DuckDB\EFCore.DuckDB.csproj. If that path is missing on this machine, clone https://github.com/andrewjonesdev-tools/EFCore.DuckDB next to this repo first. If the clone fails, use DuckDB.NET directly and note it in LEARNINGS.
2. capture: 10 Synthea patients plus their Encounter/Observation/Condition/AllergyIntolerance/Immunization/MedicationRequest from https://r4.smarthealthit.org (fallback hapi.fhir.org/baseR4), saved VERBATIM to data/fixtures, with SOURCE.md. Prefer patients with A1c, BP and cholesterol. ALSO fetch Ottehr seed/sample FHIR resources verbatim from github.com/masslight/ottehr (search the repo for seed/test JSON) into data/fixtures/ottehr/, with origin URL and commit noted.
3. Core: mapping + Risk library + unit tests, per the SPEC Tests section.
4. Track B: EF Core AppDbContext (SQL Server; Sqlite fallback via Data:Provider) + migrations, incremental sync, upsert keyed on fhir_id with the version rule, quarantine, outbox, IFhirSource with SandboxFhirSource, FixtureFhirSource and OystehrFhirSource. Oystehr: M2M token POST https://auth.zapehr.com/oauth/token, audience https://api.zapehr.com, header x-oystehr-project-id, env-gated. Check docs.oystehr.com for the FHIR base URL. It is never called without env creds.
5. API: patients, summary, POST allergies → outbox, CDS Hooks (/cds-services, /cds-services/patient-risk), /api/reports/* JSON, OpenAPI.
6. Vue 3 + TS + Vite app in web/: dashboard (with a "Run sync again" button), patient chart with CDS cards + Add-allergy form showing the outbox JSON, compare page (Track A vs B + "Predictive medicine, two ways" + "Allscripts → Ottehr → own EMR"), synthetic banner, mobile-first. Wired into the AppHost (AddNpmApp/AddViteApp) with the API URL from env.
7. Track A: bronze/silver/gold incl. gold_risk_flags, through EFCore.DuckDB, plus the lakehouse run command.
8. README with run steps + a 3-minute demo script that follows REQUIREMENTS-TRACE.
SHOULD
9. Metabase container in the AppHost + bi/metabase/get-driver.ps1 (pinned MotherDuck DuckDB driver release) + metabase provision (local admin from env test creds) + the 5 dashboards as code. If it fails, the /api/reports + Vue SVG charts fallback must exist.
10. A small HL7 v2 ORU → FHIR Observation parser + a test (row A8).
11. infra/FhirDemo.Infra: a cdktn C# Azure stack (Container Apps, Azure SQL, Key Vault, Service Bus, Log Analytics). Synth only. Put the synth result in VERIFY.md. Never apply. No credentials.
12. azure-pipelines.yml + .github/workflows/ci.yml (build + test).
COULD 13. A SQL Server stored procedure for the gold refresh or upsert, via a migration. A data-quality checks table. An SFTP drop-folder stub. The Grok summarizer (env XAI_API_KEY, falling back to the template).
DEFINITION OF DONE: paste REAL outputs into docs/VERIFY.md:
- dotnet build
- dotnet test (with the test count)
- both operational sync runs (the second all unchanged)
- lakehouse run counts
- curl of /api/patients and of POST /cds-services/patient-risk
- npm run build for web/
- AppHost startup log lines showing the resources
Anything not done goes under "NOT DONE" with the error. Do not claim anything you did not run.
RULES:
- Synthetic data only.
- Never POST or PUT to public FHIR servers.
- No secrets in the repo.
- Never create external accounts.
- Update docs/LEARNINGS.md with dated bullets as you learn things about the real APIs.
- When finished: git add -A, commit, git push origin HEAD.