Skip to main content

POST /simulate

Run transplant location simulation for a patient profile across all SRTR centers that perform the requested organ.

Request

POST /simulate?iterations=1000&inference_mode=monte_carlo&copula_theta=1.0&elasticity=0.65
Content-Type: application/json

Query Parameters

ParamTypeDefaultDescription
iterationsint1000Monte Carlo iterations per center (100-10000)
inference_modestringmonte_carloEngine: monte_carlo, bayesian, or mcmc
copula_thetafloatper-organOverride Clayton copula theta (0.1-5.0; requires use_copula: true)
elasticityfloat0.65Override supply-wait elasticity (0.1-1.0)

Request Body

{
"patient": {
"organ": "kidney",
"blood_type": "O+",
"age": 45,
"sex": "male",
"urgency": 2,
"cpra": 35,
"weight_lbs": 180,
"height_inches": 70,
"home_center": "Chicago",
"adjust_for_cause_of_death": false
}
}

PatientProfile Schema

FieldTypeRequiredConstraintsDescription
organstringyeskidney liver heart lung pancreas intestineOrgan type
blood_typestringyesA+ A- B+ B- AB+ AB- O+ O-ABO blood type
ageintegeryes1-99Patient age in years
sexstringyesmale femaleBiological sex
urgencyintegeryes1-4Urgency level (1=elective, 4=emergency)
insurancestringnomedicare medicaid private uninsuredInsurance type
weight_lbsfloatno0-1000Weight in pounds
height_inchesfloatno0-120Height in inches
cpraintegerno0-100cPRA % (kidney only)
meldintegerno6-40MELD score (liver only)
casfloatno0-100Composite Allocation Score (lung only) — the score actually in use since March 2023
lasfloatno0-100Lung Allocation Score (lung only) — the pre-2023 score, retained for back-compatibility and mapped onto an effective CAS internally
peldfloatno-20 to 99PELD score (liver, pediatric under 12). A different scale from MELD, and it can be negative
months_waitingfloatno>= 0Qualified waiting time already accrued. Left-truncates the wait draw rather than restarting the clock
center_codesstring[]noRestrict scoring/simulation to a user-defined center shortlist
bbn_granularitystringnostate, fullBBN region-node granularity
seedintegernoSeed for the stochastic engines; echoed back as seed_used for reproducibility
home_centerstringnoValid city namePatient's current transplant listing center
adjust_for_cause_of_deathbooleannodefault falseApply organ-specific COD donor recovery multiplier

Response

{
"patient": { ... },
"cities": [
{
"city": "University of Minnesota Medical Center",
"state": "Minnesota",
"center_code": "MNMC",
"center_name": "University of Minnesota Medical Center",
"lat": 44.9727,
"lon": -93.2354,
"p_transplant_6mo": 0.18,
"p_transplant_12mo": 0.39,
"p_transplant_24mo": 0.63,
"p_transplant_36mo": 0.78,
"confidence_interval_95": [0.56, 0.70],
"median_wait_months": 19.4,
"competing_risks": {
"p_transplant_24mo": 0.63,
"p_mortality_24mo": 0.07,
"p_delisting_24mo": 0.09,
"p_still_waiting_24mo": 0.21
},
"outcomes": { ... },
"trends": { ... }
},
...
],
"iterations": 1000,
"elapsed_seconds": 2.34,
"inference_mode": "monte_carlo"
}

SimulationResult Schema

FieldTypeDescription
patientPatientProfileEcho of the request patient profile
citiesCityProbability[]Ranked by p_transplant_24mo descending
iterationsintegerNumber of Monte Carlo iterations per center
elapsed_secondsfloatServer-side simulation time
inference_modestringEngine used: monte_carlo, bayesian, or mcmc
seed_usedintegerThe seed actually used, whether supplied or auto-generated. Re-sending it reproduces the run exactly
data_vintageobjectWhich SRTR release the numbers reflect. Estimates describe that release's cohorts, not real-time allocation
data_qualityobjectPer-family counts of centers falling back to national defaults (wait factors, competing risks, observed outcomes, acceptance rates, trend series, pediatric cohort size), so a result never presents partial inputs as complete ones
deterministic_scoresobjectThe non-stochastic scoring component, when requested

CityProbability Schema

FieldTypeDescription
citystringCenter or city name (display label)
statestringFull state name
center_codestringSRTR center code (e.g., PAPT)
center_namestringFull center name
latfloatCenter latitude
lonfloatCenter longitude
p_transplant_6mofloat [0,1]Probability of transplant within 6 months
p_transplant_12mofloat [0,1]Probability of transplant within 12 months
p_transplant_24mofloat [0,1]Probability of transplant within 24 months
p_transplant_36mofloat [0,1]Probability of transplant within 36 months
confidence_interval_95[float, float]Bootstrap 95% CI for 24-month probability
median_wait_monthsfloatMedian wait across all iterations
competing_risksobjectOutcome probabilities at 24 months (sum to 1.0)

competing_risks Object

KeyTypeDescription
p_transplantfloatTransplant probability at 24 months
p_mortalityfloatMortality while waiting at 24 months
p_delistingfloatDelisted probability at 24 months
p_still_waitingfloatStill on list at 24 months

All four values sum to 1.0.

Error Responses

422 Unprocessable Entity

Returned when the request body fails Pydantic validation.

{
"detail": [
{
"type": "value_error",
"loc": ["body", "patient", "blood_type"],
"msg": "String should match pattern '^(A|B|AB|O)[+-]$'",
"input": "O positive"
}
]
}

500 Internal Server Error

This is rare and occurs only if data files are corrupted or missing. Check /health to diagnose.

Example: Kidney Patient

curl -X POST http://localhost:8002/simulate \
-H "Content-Type: application/json" \
-d '{
"patient": {
"organ": "kidney",
"blood_type": "O-",
"age": 52,
"sex": "female",
"urgency": 2,
"cpra": 80
}
}'

Performance

Response time depends on the organ (number of centers) and iteration count:

OrganCenters~Time (1000 iter)
Kidney23310-15s
Heart1497-10s
Liver1487-10s
Pancreas994-6s
Lung743-5s
Intestine21~1s

Reduce iterations (e.g., ?iterations=300) for faster responses with wider confidence intervals. There is no caching; each request recomputes fresh.