Same patient, same flags, two ways¶
This track implements predictive-medicine rules on Oystehr for use beside Ottehr. It does not claim that an authenticated Ottehr session or a cloud deployment has been verified. All clinical examples are synthetic and educational, not for clinical use.
Pinned sources and local setup¶
Ottehr is a React/TypeScript EHR backed by Oystehr. This track uses a scripted clone at ehr-track/ottehr, excluded from Git, pinned to b78016c8324362751d83c2710430788c67b2f739. ehr-track/ottehr-pin.json is the pin record. No node_modules are vendored. See the pinned README.
Use Node 22, at least 22.13.0, and npm ci for the pinned Ottehr workspace. See its package manifest. Upstream supports macOS, Linux and WSL; native Windows PowerShell is unsupported. Development uses Vite and a local Express Zambda service. See development documentation.
An Oystehr project, M2M client and appropriate access policies are required for cloud data access. Create them through the getting-started guide and M2M documentation. M2M uses client credentials at https://auth.zapehr.com/oauth/token with audience https://api.zapehr.com; API calls use a bearer token. Browser users use application login instead of the M2M secret. See authentication.
The FHIR R4 base is https://fhir-api.zapehr.com/r4, not a project-specific hostname. The client identity and applicable project context select the project. See FHIR API basics and project header rules.
The current pinned startup differs from older examples: npm run apps:start includes infrastructure provisioning. Do not use it as a harmless smoke test. The wrapper runs npm run apps:start:no-apply, starting the EHR on http://localhost:4002, intake, and the local Zambda backend after the environment exists. The backend is required because the generated local EHR configuration points its Zambda URL to http://localhost:3000/local. See pinned scripts and deployment README.
# From the repository root. These checks do not authenticate or write to Oystehr.
pwsh -File ehr-track/scripts/setup.ps1
pwsh -File ehr-track/scripts/seed.ps1
pwsh -File ehr-track/scripts/run.ps1 -DryRun
pwsh -File ehr-track/scripts/deploy.ps1
For local installation, run PowerShell 7 inside WSL with Node 22 installed there. Set OYSTEHR_CLIENT_ID, OYSTEHR_CLIENT_SECRET, OYSTEHR_PROJECT_ID in that process, then run setup.ps1 -Apply. It clones the exact revision, runs npm ci, and writes ignored config/.env/local.json and deploy/local.tfvars.json. It refuses existing configuration files and tracked targets. The three variables cannot supply application IDs, users or all provisioned services: Andrew must complete the upstream Terraform 1.16 configuration workflow, explicitly using -var-file=local.tfvars.json, and generate apps/ehr/env/.env.local, apps/intake/env/.env.local, and packages/zambdas/.env/zambda-secrets-local.json before running run.ps1. Consult the pinned configuration template and deployment instructions. Setup deliberately does not provision cloud resources.
Seeding the same cohort¶
The fixture and Way 1 source baseline is 8d1dd5fdcfa80f8795cd6d0a03c2e82e6a398a95 from origin/wt/WT-dc65/fhir-demo. Scripts read it using Git, without editing Way 1. The cohort includes ten Synthea patients and two Ottehr sample patients, plus their associated JSON resources. The Ottehr booking-questionnaire sample is an item fragment; seed normalizes it into a draft Questionnaire and reports this transformation.
seed.ps1 prints every intended conditional create. Only -Apply and OYSTEHR_SEED_CONFIRM=I_OWN_THIS_PROJECT permit writes. It uses one FHIR transaction, deterministic fixture tags, and transaction fullUrls so Oystehr can assign IDs while keeping in-cohort references connected. Repeating the same seed uses conditional creates rather than overwriting existing clinical resources. External references absent from the fixture set are reported. See Oystehr batch and transaction semantics.
After an authorized live seed, use the returned SEEDED ... -> Patient/<id> location in Ottehr and the card viewer. The script saves this mapping in ignored ehr-track/artifacts/seed-id-map.json. Offline parity compares original fixture IDs; live citations use the server-assigned IDs. No seed apply has been run by this worker. The 3,192-resource transaction's acceptance and unresolved external references still need live validation.
Rules and deployment¶
ehr-track/risk/ contains the pure rules, FHIR mapper, authenticated handler, CLI and tests. TypeScript is an explicit C#-first deviation: it is Ottehr's platform language and allows the rule module to run directly in a Node Zambda. The tiny standalone viewer uses browser JavaScript and Node for the same reason. The parity harness uses C# and compiles the original Way 1 engine and mapper, not another translation.
The rules match Way 1's thresholds and chronology:
| Rule | Behavior |
|---|---|
| A1c | Dated, nonfuture LOINC 4548-4 in percent; 5.7 to <6.5 prediabetes range, >=6.5 diabetes range; not a diagnosis |
| A1c trend | Strict increase across the last three eligible results, with deterministic ID tie-breaks |
| Repeated BP | At least two of the last three complete panels have systolic >=140 OR diastolic >=90 mmHg; never pair components from different observations |
| Flu gap | No completed vaccination with a listed CVX code within the inclusive prior twelve calendar months; absence only describes this dataset |
| ASCVD | Original 2013 PCE coefficients, age 40–79, validated numeric inputs, explicit supported sex/race coefficients and known smoking/diabetes/treatment statuses; missing values remain unknown |
These are the demo's rules, not a claim that these thresholds constitute current clinical guidance. ASCVD reference cases come from Goff et al., Appendix 4. All cards carry the educational disclaimer and cited FHIR references. The card shape is Way 1's {summary, indicator, detail, source:{label,url}}; the response also includes {patientId, asOf, flags} for inspection.
Known parity conflict: Way 1's FHIR mapper infers negative diabetes/treatment statuses when it sees unrelated entries in a nonempty condition/medication history. This violates the requested explicit-input constraint. Way 2 keeps such statuses null; there is no hidden legacy switch. Explicit positive evidence remains supported. The pure ASCVD calculator accepts explicit false inputs and passes all four published reference-case tests. A future FHIR adapter for explicit negative assertions must define and validate their coding/profile before using them.
Three fixture ASCVD score differences are predicted: 2b729cb8… 6.86539013163197 → null; 4db03e6a… 0.559605335465585 → null; ab47f921… 19.6925181095396 → null. These predictions came from the initially faithful TypeScript mapper; they are not a successful .NET parity run. Details are in ehr-track/risk/expected-mapping-differences.json. Way 1 needs the same explicit-input correction, or real explicit inputs must be added to both tracks, before claiming identical scores. This worker did not edit Way 1.
npm --prefix ehr-track/risk ci --ignore-scripts
npm --prefix ehr-track/risk test
npm --prefix ehr-track/risk run build
pwsh -File ehr-track/scripts/parity.ps1
The risk package supports Node 22.13–24; direct TypeScript execution uses --experimental-strip-types for Node 22. Actual local verification used Node 24.18.0. Build emits dist/index.js, mapping.js, rules.js and package.json; all belong at the ZIP root. The handler exports index, receives event.body, and returns {statusCode, headers, body}. See writing Zambdas.
Deploy is dry-run by default. An operator must supply the three Oystehr variables plus OYSTEHR_EXECUTION_ROLE_ID, then deliberately set OYSTEHR_DEPLOY_CONFIRM=I_OWN_THIS_PROJECT and run deploy.ps1 -Apply. It creates a named http_auth function with raw:true, uploads the ZIP using a presigned URL, and reports the function ID. It does not silently replace an existing function; repeated creation will fail and requires inspection in Console. See create-function API, upload API, and raw mode.
The existing execution role must permit only the necessary FHIR Read/Search operations for Patient, Observation, Condition, MedicationRequest and Immunization in the synthetic demo project. Oystehr supplies its token as event.accessToken; no M2M secret is bundled. Invocation is limited to authorized demo actors; a project-wide role is not a substitute for per-patient authorization in a production application. See execution roles and authenticated invocation permissions. The handler follows pagination, rejects foreign origins/redirects, and returns no cards if reads fail or remain incomplete.
Card viewer and Ottehr mounting point¶
No documented plug-in slot was verified in the pinned patient page. This track therefore supplies the requested standalone viewer rather than modifying the upstream EHR. Run node ehr-track/viewer/serve.mjs, open http://127.0.0.1:4010, enter the seeded patient ID, project UUID, function ID and short-lived authorized actor token, then fetch cards. It calls the fixed Oystehr Zambda endpoint; it never accepts a client secret or persists tokens. The token field clears after each request. All returned text renders as text, not executable HTML.
For an Ottehr fork, the exact proposed insertion point is the first column in PatientAccountComponent, immediately after {aboutPatientSection} and before <ContactContainer> in PatientInformationPage.tsx. Add a PredictiveMedicineCards component receiving patient?.id; use the authenticated Oystehr client from useApiClients, request the function with {patientId,asOf}, and render the returned card fields using MUI text components. Query key must include patient ID and as-of; disable until patient is loaded, cancel stale requests, and render loading/error/empty states. Grant the staff actor permission to invoke this function. This is an exact integration plan, not an implemented or visually verified chart panel.
Offline viewer data can be generated after parity's fixture extraction step:
node --experimental-strip-types ehr-track/risk/cli.ts `
--fixtures ehr-track/parity-dotnet/.generated/data/fixtures `
--as-of 2026-11-12T12:00:00Z `
--patient-id 010fd829-1ef3-49c9-98c4-df7561709bc7 `
> ehr-track/artifacts/patient-cards.json
Choose that file using the viewer's local JSON picker. This displays real local rule output; it is not evidence of cloud execution.
Running Ottehr without an Oystehr account¶
NO verified account-free Ottehr chart is delivered in this worktree. This is not a claim that endpoints are hardcoded or that self-hosting an adapter is impossible. Endpoint configuration exists, but replacing Oystehr requires more than the proposed static token and FHIR proxy.
| Pinned source evidence | Consequence |
|---|---|
| packages/ui-components/lib/utils/oystehr.ts:4–18 | SDK reads configurable FHIR, project and Zambda URLs |
| apps/ehr/src/index.tsx:50–59 | Auth0Provider requires domain, client ID, redirect and audience |
| apps/ehr/src/hooks/useAuthToken.tsx:8–12 | Existing app requires authenticated Auth0 state and silent token retrieval |
| apps/ehr/src/hooks/useGetPatient.ts:44–94 | Patient search/reverse includes and duplicate search are needed |
| apps/ehr/src/hooks/useGetPatientVisitHistory.ts:15–20 | Visit-history Zambda is another dependency |
| apps/ehr/src/hooks/useEvolveUser.tsx:81–228 | User/practitioner bootstrap and last-login update need project/FHIR behavior |
Read-only machine inventory found Docker Desktop and Ubuntu WSL (.NET SDK 10.0.110), but no HAPI container/image or listener on the checked FHIR ports. An account-free proof still needs HAPI, an explicitly local-only authentication adapter or proper OIDC authorization-code/PKCE emulator, project/Zambda adapters and browser validation. No shim or Ottehr screenshot is claimed. Windows Application Control also blocks the newly built .NET parity assembly, and the browser-access host was unavailable. No security controls were disabled to obtain a screenshot or passing result.
60-second demo script¶
Prerequisite: complete credentialed provisioning and deployment for a live demo; otherwise label the second window local rule output, not Ottehr cloud execution. Pick fixture 010fd829-1ef3-49c9-98c4-df7561709bc7 and fixed as-of 2026-11-12T12:00:00Z.
- 0–15 seconds: Open the patient in Way 1. “This is our synthetic patient; the custom .NET pipeline computes these educational flags.”
- 15–30 seconds: Open the same patient's server-assigned ID in Ottehr and the standalone card viewer, or load the saved local JSON. “The second implementation uses the same fixture and the same rule thresholds.”
- 30–45 seconds: Compare A1c, BP and flu cards and their cited Observation/Immunization IDs. Explain live ID remapping. “Both paths can show the records behind the flag.”
- 45–60 seconds: Show the parity report or current blocker. “We found an ASCVD input-assumption mismatch affecting three other patients. Way 2 does not invent negative history. We will not claim universal parity until Way 1 is corrected and the .NET check executes.”
Way 1 versus Way 2¶
This is an architectural comparison, not a vendor price quote or a claim about Innovare's deployment contracts.
| Concern | Way 1: custom integration | Way 2: on Ottehr/Oystehr |
|---|---|---|
| UI owner | Team maintains Vue UI | Team customizes open-source Ottehr React UI; standalone demo cards supplied here |
| Data store | Pipeline-owned EF Core operational store and analytical outputs; EHR remains upstream | Oystehr-hosted FHIR project |
| Auth | Team operates app/integration auth; local demo settings are not production identity | Oystehr application users, M2M clients and IAM roles |
| Rules execute | .NET engine in owned service/process | TypeScript in authenticated Oystehr Zambda |
| Deployment | Owned application, database and frontend hosting | Ottehr UI hosting/provisioning plus Oystehr function deployment |
| Cost | Hosting/storage plus maintenance and integration effort; no measured production total | Usage charges plus support plan; production requires Silver or above per current pricing; no total estimated |
| Lock-in | Custom code and source-EHR integration contracts | FHIR data is portable; auth/project/Zambda APIs and Ottehr customizations still need migration work |
| Choose when | Keep the existing EHR and own the pipeline and UX | Adopt Ottehr workflow/UI and accept Oystehr-managed backend services |
The lock-in and fit rows are engineering judgments from the architectures above. Hosting and service ownership for Way 2 are described in Ottehr's README, Oystehr services, and deployment documentation.
Verification¶
Actual local runs on 2026-11-12; no -Apply or Oystehr writes performed.
npm --prefix ehr-track/risk test (exit 0), followed by npm --prefix ehr-track/risk run build (exit 0):
tests 49
suites 0
pass 49
fail 0
cancelled 0
skipped 0
todo 0
Coverage includes all cases ported from tests/FhirDemo.Tests/RiskTests.cs, the same twelve fixture patients, same-panel BP, invalid/future/nonfinal inputs, explicit-status requirements, and mocked handler pagination/failure/origin protection. Mocked requests do not establish live Oystehr compatibility.
pwsh -NoProfile -File ehr-track/scripts/setup.ps1 (exit 0):
Mode: DRY RUN (no writes or network calls)
Ottehr pin: b78016c8324362751d83c2710430788c67b2f739
Node: 24.18.0; required Node 22 >= 22.13.0
Planned: clone ehr-track/ottehr and checkout the recorded SHA detached
Planned: npm ci; write ignored config/.env/local.json and deploy/local.tfvars.json
Still required for EHR login: operator Terraform 1.16 provisioning, generated apps/ehr/env/.env.local, and an Administrator EHR user
Provisioning is separate: setup never runs terraform apply or npm run apps:start.
Missing: Node 22.13+ on the Node 22 line; OYSTEHR_CLIENT_ID; OYSTEHR_CLIENT_SECRET; OYSTEHR_PROJECT_ID; Supported Unix shell: run this script using pwsh inside WSL (upstream does not support Windows PowerShell)
Dry-run complete. No credentials used; no files changed.
pwsh -NoProfile -File ehr-track/scripts/seed.ps1 (exit 0, excerpt after individual planned writes):
NORMALIZE booking-questionnaire.json: wrap upstream items as a draft Questionnaire.
Plan: 3192 resources; 12 patients (10 Synthea + 2 Ottehr); one atomic transaction POST https://fhir-api.zapehr.com/r4
DRY RUN: no token request and no Oystehr writes. Apply requires OYSTEHR_SEED_CONFIRM=I_OWN_THIS_PROJECT.
pwsh -NoProfile -File ehr-track/scripts/deploy.ps1 (exit 0):
Plan: build risk/dist; ZIP all runtime files at archive root.
Plan: create predictive-medicine-demo (nodejs22.x, http_auth, raw=true, existing read-only execution role).
Plan: POST https://zambda-api.zapehr.com/v1/zambda; request upload URL; PUT ZIP to signed URL.
Missing: OYSTEHR_CLIENT_ID, OYSTEHR_CLIENT_SECRET, OYSTEHR_PROJECT_ID, OYSTEHR_EXECUTION_ROLE_ID
DRY RUN: no build, authentication or cloud writes performed.
pwsh -NoProfile -File ehr-track/scripts/run.ps1 -DryRun (exit 0):
Local apps: npm run apps:start:no-apply (EHR http://localhost:4002; intake and Zambda backend included). No Terraform apply.
Requires pinned clone, npm ci, generated EHR/intake env and Zambda secrets, and pwsh inside WSL on Windows.
pwsh -File ehr-track/scripts/parity.ps1: original Way 1 sources compiled with zero warnings and errors, but execution failed:
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'C:\Users\fives\source\repos\fhir-pipeline-demo-wt-WT-dc65-ottehr\ehr-track\parity-dotnet\bin\Debug\net10.0\Parity.dll'. An Application Control policy has blocked this file. (0x800711C7)
File name: 'C:\Users\fives\source\repos\fhir-pipeline-demo-wt-WT-dc65-ottehr\ehr-track\parity-dotnet\bin\Debug\net10.0\Parity.dll'
The exception above is the observed runtime output. No patient-by-patient .NET diff was produced, so parity is blocked, not passed. The script reports field-level differences and fails on a mismatch once execution is permitted. It compares patient presence, flag names, indicator, numeric score (tolerance 1e-9), cited FHIR IDs and as-of; it excludes prose formatting. Request normal operator allowlisting before rerunning, then reconcile the documented ASCVD discrepancy.
CLI single-patient output contained five cards and five flags. Viewer HTTP check returned 200 with the configured Content-Security-Policy; both viewer JavaScript files passed node --check. Browser visual verification could not run: The browser access host is unavailable.
Still requiring Andrew's account/configuration: actual Ottehr dependency installation on supported Node/OS, provisioning, EHR login, transaction acceptance, server-ID map, execution role, function deployment/Active state, authenticated invocation, browser CORS and live cards. Still requiring local environment repair: parity assembly allowlisting and browser access. Account-free Ottehr emulation remains unimplemented, not verified.
Review and delivery status¶
Independent Codex review found a missing local Zambda backend in the initial startup wrapper. Fixed by using upstream apps:start:no-apply and checking all generated environment files; final review found no additional actionable P1/P2 issues. All five PowerShell files parsed with zero errors. Build outputs, dependency folders, environment files and local artifacts are ignored.
The mandatory council gate is not complete, so no commits or push have been made. Gaming-PC council timed out after 300 seconds; no streaming-PC council tool was available. Jenny's CLI required authentication and timed out. The local Ollama response proposed a refactor rather than providing a usable correctness review. Clahadore's chair review was rejected by the usage governor:
USAGE-GOVERNOR: native state unavailable - refusing automated `claude -p` spend (fail-closed).
usage-governor: DENIED external claude call.
The installed council-code-review skill requires review before every commit and Clahadore to chair synthesis. Normal governor-state repair has been requested; no bypass variable was set. After gate completion, commit the setup, rules/viewer, and parity/docs steps with the requested Andrew Jones author identity and Cedric (Codex) / Claude Opus 5.5 trailers, then use the required fleet sync push flow. No claim of completed delivery is made before those steps.