{"service":"twin_api","version":"0.1.0","engine_entrypoint":"simulation_engine.core.runner.SimulationRunner","database":null,"auth":null,"docs":"/docs","endpoints":{"GET /":"this index","GET /health":"liveness probe -- is this process able to respond at all (no dependency checks, single-digit-ms)","GET /health/ready":"readiness probe -- is this instance able to serve real requests right now (checks the drug registry and the engine import; 503 naming which check failed if not)","POST /simulate":"run the whole twin synchronously and return results inline","GET /patients/presets":"list ready-to-run patient presets","GET /patients/presets/{name}":"full request body for a preset","GET /scenarios":"list demonstration scenarios","POST /simulate/scenario/{name}":"run a scenario + matched control","GET /organs":"organ metadata for dynamic forms","POST /pd-override/check":"check a pharma-provided PD value (citation + plausibility) with no simulation run","POST /pd-class-estimate/check":"look up a same-class PD estimate (no simulation run, no registry write)","POST /pd-class-estimate/accept":"accept a class estimate -- WRITES to the shared registry (ESTIMATE/CLASS_EXTRAPOLATION/VERIFIED)","POST /api/homa":"compute HOMA-IR / HOMA-B from paired fasting bloods (no simulation run)","GET /api/drugs":"list simulation-ready registry drugs, for a frontend drug selector","GET /api/drugs/{drug_name}":"drug detail -- class, engaged mechanisms, dosing, half-life, clearance route, contraindications","POST /api/drug-effect-check":"select a patient + a registry drug, run the with/without comparison, return the applicable numeric effects","POST /api/drug-effect-plots":"select a patient + a registry drug, return the with/without-drug effect charts as base64 PNG images","POST /api/drug-pd-check":"lightweight per-drug PD-availability check (real / class_inferred / none) -- call each time a drug is added to an arm","POST /api/cohort-studies":"[DEPRECATED, use POST /api/pharma/studies + POST /api/pharma/studies/{study_id}/arms] save a cohort/arm study definition (validates every arm's drug via load_drug_doc())","GET /api/cohort-studies":"list saved cohort/arm studies (summary only) -- not deprecated, no equivalent under the new prefix","GET /api/cohort-studies/{study_id}":"[DEPRECATED, use GET /api/pharma/studies/{study_id}/arms] fetch one saved cohort/arm study in full","POST /api/cohort-studies/{study_id}/run":"[DEPRECATED, use POST /api/pharma/studies/{study_id}/run] start a background cohort run (capped, real-patient sample this week -- see cohort.py's own docstring) -- returns a job_id immediately","GET /api/cohort-jobs/{job_id}":"[DEPRECATED, use GET /api/pharma/studies/{study_id}/jobs/{job_id}] poll a cohort run's status and per-arm progress","GET /api/cohort-jobs/{job_id}/result":"[DEPRECATED, use GET /api/pharma/studies/{study_id}/jobs/{job_id}/result] fetch a completed cohort run's aggregate result (real hba1c_distribution, one representative_twin)","POST /api/pharma/studies":"create a pharma Study setup draft (study_name only required) -- validates therapy_areas against GET /api/reference/therapy-areas","GET /api/pharma/studies/{study_id}":"fetch a pharma Study setup draft -- reports setup_complete/fields_missing, not a wizard-step index","PATCH /api/pharma/studies/{study_id}":"update a pharma Study setup draft incrementally (shallow-merge, only fields present in the request body)","POST /api/pharma/studies/{study_id}/arms":"canonical path -- attach/replace a study's drug arms and cohort reference (study_id must already exist)","GET /api/pharma/studies/{study_id}/arms":"canonical path -- fetch a study's drug arms and cohort reference in full","POST /api/pharma/studies/{study_id}/run":"canonical path -- start a background cohort run, returns a job_id immediately","GET /api/pharma/studies/{study_id}/jobs/{job_id}":"canonical path -- poll a cohort run's status and per-arm progress","GET /api/pharma/studies/{study_id}/jobs/{job_id}/result":"canonical path -- fetch a completed cohort run's aggregate result","GET /api/pharma/studies/{study_id}/cohort/filter":"fetch a study's cohort filter (WHO is included) -- age band/eGFR tier/CKD stage/comorbidity flags/exclusions, separate from drug arms","PUT /api/pharma/studies/{study_id}/cohort/filter":"set a study's cohort filter (whole-filter replace) -- validates every value against GET /api/reference/cohort-options","POST /api/pharma/studies/{study_id}/cohort/preview":"live-preview a cohort filter's matched patient count against the synthetic sampler (cached population after the first call, ~30-40ms per call)","POST /api/pharma/studies/{study_id}/cohort/generate-demo":"stopgap demo cohort -- generate a fixed, reproducible 100-patient synthetic cohort matching this study's filter, attach it as the real cohort_reference, honest if fewer than 100 match","POST /api/pharma/studies/{study_id}/cohort/saved":"save the study's current active cohort filter into a GLOBAL, named library (reusable across studies -- confirmed against the live site)","GET /api/pharma/studies/{study_id}/cohort/saved":"list saved cohorts (the full global library, not scoped to study_id)","POST /api/pharma/studies/{study_id}/cohort/saved/{cohort_id}/load":"load a saved cohort's filter into this study's active filter slot, overwriting it","POST /api/mapping/analyse":"classify a raw source-field list against the pharma study-setup canonical schema (all 7 tables -- Identity & Body Measurements, Diabetes Profile & Fasting Bloods, Kidney Function, Liver Labs & Imaging, Blood Pressure & Cardiovascular, Daily Pattern, Medications)","POST /api/mapping/resolve/manual":"resolve a required field by manually mapping it to a caller-specified source field, with a type/format plausibility warning","POST /api/mapping/resolve/default":"resolve a required field with a single default value across the cohort (carries the flattens-the-model warning in the response)","POST /api/pharma/studies/{study_id}/deidentification/confirm":"confirm the de-identification method for this study, audit-logged (who/when, actor optional)","GET /api/pharma/studies/{study_id}/deidentification/confirm":"get this study's current de-identification confirmation status","POST /api/pharma/studies/{study_id}/mapping/confirm":"commit a study's mapping -- independently re-verifies both continue-gates server-side (required fields mapped, de-identification confirmed), never trusts a client-supplied flag","GET /api/drug-system/frequencies":"dosing frequencies available for a regimen","GET /api/drug-system/classes":"pharmacological classes the twin can reason about","GET /api/drug-system/classes/{code_or_name}":"one class in full, every declared effect","GET /api/drug-system/coverage":"what the twin can and cannot simulate today","GET /api/drug-system/search":"search drugs, tier-labelled","GET /api/novel-compounds/requirements":"what a novel compound must supply, and why","POST /api/drug-resolution":"resolve a drug's PK/PD through the three-scenario cascade","POST /api/drug-resolution/{resolution_id}/answer":"answer one pending resolution question (D2 consent)","POST /api/drug-simulation":"choose drug + dose + frequency + duration, see the effect on the twin","GET /api/reference/frequencies":"dosing frequency options (value + doses_per_day), reused from cohort.py's own arm-resolution dict","GET /api/reference/durations":"treatment duration options (value + days) -- the UI's own presented set, not a hard validation enum","GET /api/reference/therapy-areas":"the 13 SNOMED-grouped therapy areas used in pharma study setup","GET /api/reference/cohort-options":"pick lists a pharma cohort filter is built from (diagnoses, age bands, eGFR tiers, comorbidity flags, exclusions)","GET /api/reference/clinical-fields":"the clinician add-patient wizard's 23-field clinical schema (label/unit/type/required/normal_range), shared by both portals","POST /api/reference/clinical-fields/validate":"validate a raw clinical-data payload against clinical-fields' own required/type/range metadata","GET /api/reference/safety-rules":"the 17 GP prescribing safety rules generate_gp_alerts() checks, restructured for lookup","POST /api/reference/safety-check":"cross-check one drug's dosing against the renal-function safety rules, reusing generate_gp_alerts()","GET /docs":"Swagger UI (interactive API docs)","GET /openapi.json":"OpenAPI schema"}}