Hoopcare · workspace
·
Members workspace · research use only — not for clinical decision-making · every patient on this site is synthetic
Hoopcare · Preop AI · reference architecture · draft for discussion

Preop AI Platform architecture & options

One picture of the whole system — from questionnaire and uploaded documents, through the LLM readers, the rules, the Mayo ML models and the guideline knowledge base, to the two reports the platform hands back — followed by the decisions that are still open and what each option costs.

version 0.1 · 2026-07-28honours the ai.hoopcare.com decisions of 2026-07-30 (Azure SWA + Container Apps · synthetic only · schema-driven form)nothing here is built yet unless marked decided
1 · Overview

The system in one picture

Read left to right. Intake produces a structured preoperative record; three engines read that record; their outputs are assembled into modules; a clinician approves; two reports go out. Colour encodes which engine produced a thing — that encoding is used everywhere on this page.

Rules — deterministic, versioned ML — Mayo LightGBM models, validated LLM — reads, extracts, drafts Knowledge base — retrieved, cited Human — confirms, signs off
INTAKE READ · LLM RECORD ENGINES MODULES REPORTS · DELIVERY Patient questionnaire history · meds · function · symptoms web form, EN / FR, schema-driven EHR feed (later) SMART on FHIR · CDS Hooks · HL7 structured data + documents Procedure & context CPT search · setting · urgency approach · site · surgeon Documents & uploads ECG · labs · imaging · notes medication lists · PDFs, images LLM document readers one prompt per document type output = JSON, schema-checked ECG reader Labs reader Imaging report reader H&P / consult note reader Medication list reader Case summarizer future: PFT · echo · sleep study Structured preop record one JSON per case · schema v1 provenance per field: entered · extracted · EHR units normalized · -99999 → null CPT resolved: wRVU · ASC / NSQIP derived: is_male · pooled code confirmed before scoring versioned with the contract no PHI fields exist in staging Clinician confirms LLM-extracted fields Reference lists CMS ASC covered list (4,718 CPT) NSQIP list · CPT → wRVU (RBRVS) CPT names for search lookups shipped with the bundle Rules engine deterministic · versioned · testable ASA logic · coded testing criteria medication hold / continue rules CMS ASC & NSQIP list checks risk bands & thresholds (config) ML scoring service Mayo LightGBM bundles (native .txt) postop complications · 80 models = 5 configs × 16 outcomes RBC transfusion · 126 models units ladder P(≥k) · P90 OR time · LoS · ICU time (ops) acuity point card (4 axes, 0–100) calibration · bands · SHAP drivers golden cases verified at start-up LLM reasoning, grounded retrieves → cites → drafts recommendation text · patient wording questions for surgeon · safety critic structured output, schema-checked Knowledge bases (RAG) ASA / ESAIC / society guidelines anesthesia & institutional protocols patient-instruction library (EN / FR) procedure & drug dictionaries versioned snapshots · citations Guardrail — the LLM extracts upstream and drafts around the engines; it never adjusts a validated score. Output modules dots = engines that produce it ASA class estimate Acuity point card 0–100 Procedure risk tier Complication risks ×16 Blood units & order OR time · LoS · ICU ASC eligibility Preop testing plan Referrals & consults Optimization targets Medication plan Anesthesia notes Patient instructions Questions for surgeon Consistency check Follow-up & prehab tasks Clinician sign-off reviews · edits · approves Provider report risks vs reference · drivers tests · referrals · med plan ASC eligibility · blood order open questions · citations contract version · provenance Patient report plain language · EN / FR meds to stop / keep fasting · arrival · prehab when to call reading level checked Web app (now) ai.hoopcare.com · Entra ID SWA + Container Apps EHR (later) SMART app · CDS Hooks card PDF / HL7 write-back Registry & versioning model hashes · prompt versions · rules versions KB snapshots · thresholds · reference rates → one contract version printed on every report Observability & evals traces (redacted) · golden cases in CI extraction evals vs gold labels drift vs shipped reference distributions Security & audit Entra ID gate · audit log · no PHI in logs "research use only" on every output BAA-covered services only in production Environments staging: synthetic patients only, by schema prod: BAA · private network · retention rules second region (France Central) when needed answers FHIR → adapter procedure facts files JSON resolves CPT facts features retrieves · cites flags risks text approves patient version renders later
The record is the hinge: everything upstream exists to fill it with provenance-tagged facts, everything downstream reads it. The three engines never talk to each other directly — the LLM's text and the model's numbers meet only in the assembled module, and the clinician's approval sits between assembly and delivery.

How to read it

  1. Documents go through the LLM; the questionnaire does not. Typed answers and the procedure choice land in the record directly. Only uploaded documents pass through a reader, and every extracted field is confirmed by a clinician before any engine sees it.
  2. The three engines are peers with different kinds of authority. Rules decide what a guideline says; the ML models estimate probabilities and quantities; the LLM reads, retrieves and drafts. Section 2 spells out where each is trusted.
  3. Sign-off precedes reports. The clinician approves the assembled results once; the provider report and its plain-language patient version derive from that approved set, and both carry the same contract version.
2 · Engines

Three engines, three kinds of truth

The architecture works because each engine is asked only the question it can answer well — and because one boundary is never crossed: the LLM does not adjust a validated number.

EngineNatureTrusted forNot trusted forHow it is validatedWhere it lives
RulesDeterministic code and lookup tables: guideline criteria coded as logic, medication hold/continue tables, CMS ASC and NSQIP list checks, risk bands.Anything a guideline states as a criterion; anything that must be identical for two identical inputs; gating (eligibility, contraindications).Estimating a probability; weighing many soft factors at once.Unit tests against worked examples; each rule cites its source and version.Your repo, versioned. Runs inside the API.
ML (Mayo)Gradient-boosted trees released from the enclave as native LightGBM text: postop-complication bundle (80 models), RBC transfusion bundle (126), OR-time / LoS / ICU models, the four-axis acuity card. Calibrated, thresholded, with SHAP drivers.Calibrated risk per outcome; expected blood units and an order-to-cover bound; time and length-of-stay estimates; ranking patients for triage.Producing text; explaining why beyond feature contributions; anything outside its training population or the configuration's input set.Golden test cases reproduce to documented tolerance (5e-7 / 5e-11) under pinned LightGBM 4.6; per-model leaf audit ≥ 10 patients; drift vs shipped reference distributions.Scoring service in your container; artifacts in Blob Storage under versioned, hashed prefixes.
LLM + KBReads documents into schema-checked JSON; retrieves from versioned knowledge bases and drafts cited text; runs a consistency critic over the assembled result.Extraction from unstructured text; turning a decision the rules or model already made into clear provider and patient wording; surfacing open questions; catching contradictions.Changing a score. Deciding eligibility on its own. Uncited recommendations.Extraction evals against gold labels; schema validation on every output; citation check; human confirmation of extracted fields.Orchestrated by code in your repo (§4.2); provider behind a BAA in production.
HumanThe clinician.Confirming extracted fields; overriding any module with a reason; final approval.Override reasons are logged and reviewed; they are the best signal for what to fix next.Two interrupts in the flow: after extraction, before delivery.
Why the boundary matters. The Mayo models carry a validated calibration and a set of published performance claims. A layer that nudges their output — even "within a bound" — replaces a validated number with an unvalidated one, and the badge that says which you are looking at cannot restore the property that was lost. Everything the LLM does happens before the model (extraction) or around it (text, checks), never on it. Section 4.1 draws the difference.
3 · Modules

Output modules and who produces them

These mirror the bottom row of the working sketch. Each card names the engine mix — the same colours as the picture — and the honest state of the piece today.

01

ASA class estimate

Rules over the record propose a class; the LLM explains the drivers in prose. Clinician confirms.

rulesllm
02

Acuity point card, 0–100

Four LLM-extracted acuity axes → integer points → band. Validated against ASA and the UCLA grid; behaves as a rule once fitted.

ml-derivedrules
03

Procedure risk tier

CPT → wRVU, CMS ASC list, NSQIP list, procedure family. Deterministic from reference lists shipped with the bundle.

rules
04

Complication risks (16 outcomes)

Postop-complication bundle: probability, reference rate, band, top drivers per outcome, per selected configuration.

ml
05

Blood units & order

RBC bundle: full unit distribution P(k), expected units, P90 (conformal), gate-then-size order recommendation. Calibration mandatory.

ml
06

OR time · LoS · ICU

Ops models: median and 80 % interval for durations; expected LoS and ICU time. Resource planning, not risk.

ml
07

ASC / same-day eligibility

Gate: CMS ASC list × acuity band × rules exclusions. The card supplies the patient side; the list supplies the procedure side.

rulesml-derived
08

Preop testing plan

Guideline criteria coded as rules decide which tests are indicated; the LLM retrieves the citation and writes the rationale.

ruleskbllm
09

Referrals & consults

Rules flag triggers (cardiology, sleep, anaesthesia clinic); the LLM drafts the referral question with the relevant findings.

rulesllm
10

Optimization targets

Anaemia / iron, glycaemia, smoking, nutrition, prehab. Rules detect; KB supplies the pathway; LLM words it. Never subtracted from a risk number in the headline.

ruleskbllm
11

Medication plan

Hold / continue / bridge tables from the KB applied by rules to the reconciled list; LLM produces the patient-facing schedule.

ruleskbllm
12

Anesthesia notes

Airway, access, monitoring and technique considerations retrieved from protocols and drafted for the anaesthesia team; cited.

llmkb
13

Patient instructions

Fasting, arrival, what to bring, what to stop — assembled from a versioned instruction library, EN / FR, reading level checked.

ruleskb
14

Questions for the surgeon

Open items the record cannot resolve (staging, planned approach, expected blood loss). Drafted by the LLM, listed for the clinician.

llm
15

Consistency & safety check

A critic pass over the assembled result: contradictions, missing confirmations, out-of-range inputs, uncited claims. Rules assert; the LLM explains.

llmrules
16

Follow-up & prehab tasks

Dated tasks for patient and team derived from the plan (repeat labs, stop smoking date, prehab sessions).

rulesllm
4 · Decisions

Decisions and options

Seven choices shape the build. Each is drawn or tabled as a difference, with a recommendation. Tags: decided already settled in the 2026-07-30 plan · recommended · not advised.

4.1 · Where the LLM sits relative to the model

RECOMMENDED · LLM UPSTREAM Documents LLM reader→ JSON, validated Recordclinician confirms fields ML model 4.1 %calibrated · drivers Report extractsscores NOT ALLOWED · LLM ON TOP OF THE SCORE Record ML model 4.1 %calibrated LLM "adjusts within a bound"unvalidated · unauditable 3.6 % ?calibration lost Report the badge cannot restore the property that was lost
The one edge that differs. Upstream, the LLM's output is a set of fields a clinician can see and correct before scoring. On top, its output is a number nobody can trace. The current calculator uses the second pattern for its weight-table score; it must not be carried over to the Mayo models. recommended upstream only.

4.2 · Orchestration: plain services, LangGraph in your repo, or vendor-hosted

A · PLAIN SERVICES your cloud — Azure now, AWS possible Front-end (SWA) FastAPI + background workers Scoring service (LightGBM) portable: everything moves with the container you write retries, state and the confirm step yourself B · LANGGRAPH CODE + LANGSMITH your cloud Front-end (SWA) API + LangGraph graph (code)Postgres checkpointer · confirm interrupt Scoring service (LightGBM) LangSmith — traces · evals · datasetsSaaS or self-hosted · outside the boundary redacted graph = your code · moves with the container · vendor optional human-in-the-loop and state come built in C · VENDOR-HOSTED / NO-CODE your cloud Front-end (SWA) Scoring service Agent Builder / LangGraph Cloudthe workflow lives on the vendor platform calls scores portability = self-host their server (enterprise) or rewrite every payload crosses out of your cloud
What differs is which side of your cloud boundary the workflow lives on. In A and B it is your code in your container and can be redeployed on Azure or AWS unchanged; in B, LangSmith is a side channel you can point elsewhere or switch off. In C the workflow itself is on the vendor's platform. recommended B for the document-reader and report flow, because the clinician-confirmation step is a real stateful interrupt; A is enough for the scoring API alone.
OptionPortable to Azure / AWSPHI exposureHuman-in-the-loop & stateEffortLock-in
A · Plain servicesFully — a containerStays in your cloudHand-builtLow for scoring, medium for the agent flowNone
B · LangGraph code + LangSmithFully — the graph is Python in your repo; LangSmith is an environment variableTraces leave unless redacted or self-hosted; synthetic-only in stagingBuilt in (interrupts, checkpoints)MediumLow; observability is optional
C · Vendor-hosted / no-code builderOnly by self-hosting their runtime (enterprise terms) or rewritingAll payloads cross the boundaryBuilt inLowest to startHigh

4.3 · Hosting

ComponentAzure (chosen tenant)AWS equivalentStatus
Front-endStatic Web Apps (Next.js static export, Entra ID gate, linked /api/*)Amplify Hosting / S3 + CloudFront + Cognitodecided 2026-07-30
API + enginesContainer Apps (scale-to-zero, HTTPS)App Runner / ECS Fargatedecided
Model artifactsBlob Storage, versioned prefixes, immutableS3 with object lockdecided
LLMAzure OpenAI in-region (BAA available) — or the training-time model family for the _LLM configurations, see 4.5Bedrockquota requested
Knowledge base storeAzure AI Search (hybrid vector + keyword) or Postgres + pgvector on Azure DatabaseOpenSearch / Aurora pgvectorpgvector first — one database also serves the LangGraph checkpointer
Workflow stateAzure Database for PostgreSQLRDS Postgresrecommended
ObservabilityApplication Insights (no payloads) + LangSmith (redacted)CloudWatch + LangSmithrecommended
LaterFront Door + France Central region · AKS or Azure ML endpoints only if traffic or governance demandsGlobal Accelerator · EKS / SageMakerdeferred

4.4 · Which model configuration the form can drive

ConfigurationInputs it needsCalculator can supplyVerdict now
light_noICD_noLLM~15 NSQIP-style core variablesNearly all, directlyfirst target
standard_ICD_noLLM~50 + 849 ICD presence flagsCore yes; ICD flags only if checkbox→ICD mapping is documented and validatedsecond, after the mapping audit
light_ICD_LLM · standard_ICD_LLM+ LLM acuity axesOnly via the note drop-zone, and only with the training-time extractor (4.5)after extractor parity
full_ICD_LLM~1,700 features, most EHR-onlyNo — imputing ~1,300 unobserved axes misrepresents the modelnot a calculator model · EHR phase
SUPER LIGHT (21) · WEB-BASED (42)Form-sized tiers already defined in the feature fileYes, by constructiontrain them (2026-07-30 plan, Option A); SUPER LIGHT = NSQIP's 21-input budget, a like-for-like comparison
The deployment session must produce, per configuration, the count of features that are direct, derivable, lookup (table shipped with the bundle) or EHR-only. That table — not this one — decides what the calculator serves. Silent imputation is how a demo quietly lies; every imputed field is named in the response.

4.5 · LLM provider and extractor drift

The llm_* features the models were trained on were produced by one specific instrument — the NB01b decomposed-acuity prompt on Gemini 2.5. An extractor that is a different model or a paraphrased prompt yields axes from a different distribution: no error, wrong risks. Two safe positions:

now Structured first

  • Serve noLLM configurations.
  • The LLM only pre-fills questionnaire fields from a pasted note; the clinician confirms; the badge shows what was pre-filled.
  • Any provider works, behind a BAA in production.

later Parity for the _LLM configurations

  • Same prompt, same model family as training, or
  • a documented agreement study between the training extractor and the serving extractor on the enclave-side gold labels before trusting the axes.
  • State plainly in the UI when the note path is an approximation.

4.6 · EHR integration path

NOW Calculator UIai.hoopcare.com LATER SMART on FHIR applaunched inside Epic CDS Hooks serviceorder-select · patient-view FHIR adapterseparate service · maps resources Scoring API — unchangedPOST /predict · schema v1 · version param JSON, schema v1 FHIR resources hook context same JSON, schema v1 what changes later: EHR-only features arrive, so richer configurations become viable
Design for it now, build it later: the API contract does not change; the adapter is a separate service. The only thing that moves is which configurations the record can feed.

4.7 · Where the "medical brain" lives: Langflow, LangGraph code, or your own console

The question behind this one: should the combined logic — sources, rules, prompts, model calls, integration options — be authored on a visual canvas such as Langflow, with a Hoopcare UI on top, and LangSmith kept only for testing models and collecting metrics? It can. Whether it should depends on which part of the brain you mean.

OptionWhat it isGood atWeak atPortableVerdict
Langflow canvas as the system of recordOpen-source visual flow builder (MIT, self-hostable in Docker); flows export as JSON; custom components are Python; flows run behind Langflow's own API.Prototyping a reader prompt or a RAG chain in minutes; letting non-engineers see the flow; swapping models to compare.Diffing and code-reviewing a JSON canvas; unit-testing branches; expressing deterministic clinical rules; versioning tied to the model contract; a Hoopcare UI on top inherits Langflow's API and component model. Its server has had a critical unauthenticated code-execution vulnerability (2025) — self-host internal-only, authenticated, patched.Yes — Docker on Azure or AWS; JSON + Python travelnot as the source of truth
LangGraph code + LangGraph Studio + your own consoleThe graph is Python in your repo (§4.2 B); Studio renders that graph visually from the code; a thin internal console (the same Next.js stack as the calculator) shows registry, versions, KB snapshots, prompt hashes, eval results.Testable, reviewable, versioned with the models; the picture is generated from the code so it can never drift from it; human-in-the-loop built in.Editing requires a developer; the console is something you build.Yes — the graph moves with the containerrecommended for the brain
Hybrid: Langflow to prototype, code to shipExplore reader prompts, retrieval settings and model choices on the canvas; once a chain is right, promote it into the repo as a graph node with tests and a golden set.Speed of iteration where it helps; rigour where it matters.Two places to look during the transition; needs a rule for what "promoted" means.Yespractical middle
LangSmith for evals and metricsDatasets, model-versus-model comparisons, standard metrics, tracing — for any of the three above.Exactly the "test different models and get standard metrics" job.Traces leave your cloud unless redacted or self-hosted (§5).Datasets and results exportyes, as a side channel
The distinction that settles it. The brain has two kinds of content. Deterministic medical logic — ASA rules, testing criteria, medication tables, eligibility gates, thresholds — is data plus code with tests, cited to its source, versioned with the model contract; it does not belong on a canvas. LLM chains — readers, retrieval, drafting — are where a canvas helps you iterate. Prototype the second on Langflow if you like; keep the first in the repo; and let the picture people look at be generated from what actually runs, so the diagram on this page and the system in production cannot disagree.
5 · Boundary

PHI boundary and environments

Staging (now)Production (later)
PatientsSynthetic only — the schema has no identifier fields, so there is nowhere to put one decidedReal, under BAA-covered services and a private network
Pasted notesProcessed in memory, never persisted; no note text in logs or traces; click-through acknowledgement before the panel opensSame, plus retention rules and audit
LLM callsAzure OpenAI in-regionProvider under BAA; the _LLM configurations require extractor parity (4.5)
Traces / evalsLangSmith with hide_inputs / hide_outputs or an anonymiser, or App Insights without payloadsSelf-hosted observability inside the tenant, or BAA
AccessEntra ID + e-mail allowlist; "research use only — not for clinical decision-making" on every outputInstitution SSO; role-based; audit log
Regulatory postureAuthenticated research tool for named collaboratorsConfirm SaMD / MDR position before any patient-facing use; confirm the export approval covers external hosting
6 · Outputs

The two reports

Provider report

  • Headline risks with reference rate and ratio ("3.2 % vs 1.1 % average"), band, top drivers; expandable to all outcomes.
  • Blood order recommendation with the unit distribution and P90; OR time / LoS estimates.
  • ASC eligibility with the reason it passed or failed.
  • Plan: tests indicated (with citation), referrals, medication schedule, optimization targets.
  • Open questions for the surgeon; consistency-check findings; overrides and reasons.
  • Provenance footer: model configuration and hash, prompt and rules versions, KB snapshot, contract version, "research use only".

Patient report

  • Plain language, EN / FR, reading level checked; no probabilities unless the clinician opts in.
  • What to stop, what to keep taking, and when — as a dated schedule.
  • Fasting, arrival, what to bring; prehab and optimization actions in the patient's own words.
  • When to call, whom to call.
  • Derived from the approved provider plan — the same contract version, so the two never disagree.
7 · Versioning

One contract version

Every report prints one version string. It resolves to a manifest that pins everything that could change the answer:

ComponentVersioned asLives in
Model bundlescontent hash per (bundle, configuration, outcome); manifest with feature order, calibrator, thresholds, reference rates, golden cases, LightGBM versionBlob, immutable prefix; registry.json in the repo
Field schemafield_schema.json — the form, the validation and the API contract are generated from it decidedbundle
Rulessemantic version; each rule cites its source and effective daterepo
Promptshash + name per reader and per drafting task; the training-time extractor prompt is pinned separatelyrepo (LangSmith prompt hub optional, exported)
Knowledge basessnapshot id per KB with document list and datesBlob + vector store
Thresholds & bandsper outcome, per configuration; derived on the test split at training, re-derived per site laterbundle

The bundle layout from the 2026-07-30 plan — MANIFEST.json · models/{outcome}.txt · imputation.json · calibration.json · metrics.json · reference_rates.json · field_schema.json — is the unit that moves. Adding a configuration is a second bundle, not a second front-end.

8 · Path

Recommended path

PhaseWhat shipsEngines liveDepends on
0 · ArtifactInventory the released bundle; reproduce golden cases under pinned LightGBM 4.6; per-configuration feature-availability table; locate calibrators and thresholdsthe bundle files (deployment prompt, §2)
1 · SkeletonSWA + Container Apps + domain + Entra gate; stub predictor; CI with golden cases; API contract v1 with version selectionRules (schema, bands)nothing — start now
2 · ScoringReal bundle behind /predict; schema-driven form; results with reference rates, drivers, named imputations; version selectorRules · ML0 + 1
3 · ReadingNote drop-zone → /extract → visible pre-fill → clinician confirm; document readers one type at a time (ECG, labs first); extraction evals+ LLM (upstream)2
4 · Modules & reportsKB snapshots + retrieval; testing / referral / medication / instruction modules; consistency check; provider report then patient report; sign-off flow+ KB3
5 · ReachFrance Central + Front Door; SUPER LIGHT / WEB-BASED tiers if trained; FHIR adapter design; SaMD position confirmed before any patient-facing usealldemand
Open questions carried from the plan. Which outcomes form the headline set (NSQIP shows ~15 with a clear primary); French clinical wording for the 42 field labels; whether the export approval covers external hosting; who the first users are; and — new — which knowledge bases are in scope for the first release and who curates them.

Sources: working sketch "Hoopcare Preop AI-Agent, August 2026"; ai.hoopcare.com architecture plan (2026-07-30) and setup runbook (2026-08-03); NB12 / NB21 / RBC handoffs; deployment prompt for the released bundle.

9 · Code

Repositories and environments

Today: one personal GitHub account with three private repos. Target: one GitHub organisation, a small number of repos with clear ownership, and one shared brain consumed by every user-facing app as a service with a published contract — never by copying its source.

REPOS · github.com/hoopcare CI PUBLISHES ENVIRONMENTS · approvals per env perioperative-ai rules · prompts · graphs · KB pipeline model registry · service · contract owner: clinical-ai team surgery-risk-calculator NSQIP-like form + Epic-like simulator patient-app (v3) direct-to-patient v2 apps (three repos) + infra clinical-dashboard · patient · back-office owner: platform team · unchanged Container image (ACR)brain service, tagged = release Generated clientsTS + Python, private packages registry.json + manifestshashes → model binaries in Blob Web builds (SWA) v2 builds (their pipeline) dev · stgsynthetic only brain (stg) calculator demo patient-app v3 v2 stg prod-usEast US 2 · BAA brain (us) v2 apps v3 (later) prod-frFrance Central brain (fr) v2 apps v3 (later) data never crosses regions: the brain, its models and the LLM endpoint are deployed once per region from the same image tag; only config differs deploy · gated consumers call the brain over HTTP with a pinned client version — no submodules, no copied source
One brain repo, many consumers, three environment groups. The brain ships as an image plus generated clients; every consumer pins a version. Production is deployed once per region because patient data and the LLM endpoint must stay in-region.

What goes where

RepositoryContainsPublishesOwnerNote
perioperative-aicontract/ field schema, OpenAPI, FHIR mapping, thresholds, reference rates · rules/ with tests and citations · readers/ prompts + eval sets · graphs/ LangGraph flows · knowledge/ KB pipeline + snapshot manifests · models/ registry, loader, calibration, golden cases · reports/ EN/FR templates · service/ FastAPI · evals/container image; @hoopcare/perioperative-ai-client (TS) and a Python client, both generated from the contract; registry.jsonclinical-ai team (you) · CODEOWNERS on rules/ and contract/The single source of truth for medical logic. Semantic versions; the report's contract version = brain release + bundle hash.
surgery-risk-calculatorNSQIP-like calculator, Epic-like browser simulator, demo data; two apps in one small TS workspace if they share componentsSWA buildyouSynthetic only, Entra-gated. Pins a brain client version.
patient-app (v3)direct-to-patient appSWA / mobile buildyouSame brain, patient-report endpoint. Consider whether hoopcare-patients already is this repo.
v2 · clinical-dashboard, patient, back-officeas todaytheir pipelineplatform teamMove into the org unchanged; adopt the brain client when a v2 screen needs a module.
infraBicep / az scripts per environment; GitHub Environments with required reviewers; OIDC federated credentials to Azure (no long-lived secrets)platform teamdev · stg · prod-us · prod-fr; the calculator demo deploys to stg-like resources.
rag-perioperative-guidelinestoday: a separate Python repoyouFold the pipeline code into perioperative-ai/knowledge/; keep the documents and snapshots in Blob (size and licensing), with only manifests in git.

Rules that keep it clean

  1. An organisation, not a personal account. Teams, branch protection, CODEOWNERS, environments with required reviewers, audit log, mandatory 2FA. Transfer the three repos (redirects are kept). GitHub Team plan is enough; environment protection on private repos needs it.
  2. The brain is consumed over HTTP with a pinned client version. No git submodules, no copied source. Breaking contract change = major version; consumers run contract tests against the pinned image in CI.
  3. Not in git: model binaries (2.2 GB exceeds release-asset and LFS limits, and access is governed by the Mayo approval) → Blob, immutable, hashed in registry.json; guideline PDFs → Blob; secrets → Key Vault and environment secrets; anything resembling PHI → nowhere.
  4. Region is an environment, not a branch. The same brain image deploys to prod-us and prod-fr from the same tag; only configuration differs. Data, models and the LLM endpoint stay in-region.
  5. Clinical logic has clinical owners. CODEOWNERS on rules/, readers/ and contract/ requires your review; every rule cites its source and effective date.
10 · Surface

Site map — one members-only subdomain first

ai.hoopcare.com is the internal workspace: one Next.js shell, one auth realm (Entra ID allowlist), route groups per section, the brain linked at /api/v1. Three ideas organise the menu: /brain is everything that defines an answer; /clinical-review is the evidence about those answers; /demo is where you try it. Nested in the menu, flat and deep-linkable in the URLs. The real patient app is the exception — different identity provider, real PHI, per-region — it gets its own host (patients.hoopcare.com) when it ships.

PathSectionWhat it showsReads from
/Homemembers only · environment banner · "research use only"
/docs/Documentationoverview · architecture (this page) · contract · model cards · changelogrepo docs
/demo/Surgical calculator + Epic-like simulatorsynthetic only · version selector · fake patient flowbrain API · /clinical-review/synthetic
/brain/The brainmap engines map generated from the code · chains LLM readers & drafting flows — the visual builder · rules deterministic logic with citations and effective dates · prompts versions + linked eval sets · models registry: bundles, configurations, hashes, golden status, thresholds, reference distributions, model cards · knowledge KB ingestion, snapshots, coverage, citation checks · reports provider / patient templates EN / FR · playground run any module on a synthetic caseperioperative-ai repo · registry.json · Blob
/clinical-review/Benchmark & continuous evaluationmetrics model vs model, extraction evals, calibration, drift · queue clinicians grade outputs against a rubric; disagreements feed the next release · cases every run: inputs, version, outputs, overrides and reasons, trace link · synthetic the shared fake-patient library used by demo, evals and playgroundAPI log · evals · LangSmith (redacted)
/developer/DeveloperOpenAPI · client packages · sandbox keys · FHIR mapping · SMART-launch test in the simulatorcontract
/status/Statusdeployed version per environment · golden-case checks · ML drift alerts · LLM endpoint health · costCI · App Insights · LangSmith
/admin/Adminallowlist · roles · environments · feature flags · region
patients.hoopcare.comReal patient app (v3), laterseparate host: Entra External ID, PHI, per-region; same repo family and pipelinebrain API · patient-report endpoint

Observability: what LangSmith covers and what you build

NeedWhere it surfacesBuild or buy
Tracing — runs, latency, tokens, cost per case/clinical-review/cases → trace linkLangSmith, redacted; App Insights for the ML/API side
Datasets, offline evals, experiment comparison ("test different models")/clinical-review/metricsLangSmith; gold sets live in the repo
Human grading of outputs against a clinical rubric/clinical-review/queuebuild — PHI-safe, override reasons, inter-rater agreement; push scores to LangSmith optionally
Online evaluators on sampled live traces (schema validity, citation present)metrics · driftLangSmith
Feedback from clinicians attached to the runqueue → metricsLangSmith feedback API or your own table, kept in sync
Prompt versions and playground/brain/prompts · /brain/playgroundrepo is the source of truth; hub optional
Trace → dataset ("add this case to the gold set")queue → metricsLangSmith
Regression tests in CI — eval score below threshold blocks the releaseCI gateLangSmith SDK + pytest
ML monitoring — LightGBM calibration drift, input drift vs shipped reference distributions, golden checks per configuration/status · /clinical-review/metricsbuild — LangSmith is LLM-centric
Rules coverage and audit — which rules fired, source, version/clinical-review/casesbuild
Safety evals — prompt injection on readers, out-of-scope inputs, PHI-leak check on the patient reportmetrics · CIbuild, run in CI
Region and retention — prod-fr traces stay in the EULangSmith EU region or self-hosted; short retention