AI MedAgent
◆ Patent Pending
SDK Docs
This page describes the architecture and reasoning method of a pending patent filing. It is a concept reference, not documentation for a deployed or commercially available system. Sandbox requests on this site return fixed, scripted example responses, not live AI or database results. Shown to illustrate a new and unique possible approach to managing patients that may improve outcomes and reduce costs. Not for clinical use.
Overview

AI MedAgent Developer Sandbox

The AI MedAgent Sandbox is a scripted demonstration environment that illustrates how the platform's clinical reasoning method is designed to work. It lets hospital IT teams, biomedical engineers, and medication management device manufacturers see the intended request/response shape and workflow described in a pending patent filing.

No credentials, no hospital infrastructure, and no installation required. You submit a structured JSON event in the UPES schema, and the demo returns a fixed, pre-written example decision response illustrating the intended action, recommended dose, confidence score, clinical rationale, and the IHE transaction the Gateway is designed to fire next. This is a scripted example, not a live AI call or a connection to real clinical data.

Design principle: This sandbox follows the same documentation model used by open.epic.com for EHR developers. Every request type has a pre-built example payload, a complete field-level schema reference, and annotated response output. You learn the API by sending real requests and reading real responses.
▶ Open the Sandbox Console

How It Works

The sandbox simulates the full AI MedAgent signal chain. When you click Run Request, the following sequence fires in real time:

  1. UPES schema validation. The sandbox Gateway validates the envelope fields, checks required parameters, and confirms clinical value ranges are physiologically plausible.
  2. PHI boundary enforcement. patient_id and encounter_id are confirmed local. Only de-identified clinical features cross to the AI engine.
  3. Agent routing. The request_type field directs the event to the correct AI component: a Reactive Agent, the DL Optimizer, the Pharmacy Router, the CPOE Intercept Agent, or the Alarm Manager.
  4. Claude AI engine evaluation. The clinical context is evaluated against evidence-based protocols (SCCAM, AHA, SSC guidelines). Formulary constraints, co-safety rules, and confidence thresholds are applied.
  5. Structured decision returned. The response includes action, dose recommendation, confidence score, clinical rationale, and the Gateway Routing section showing which IHE transaction fires next.
  6. Gateway log. The log panel traces every step the on-premise Gateway would execute: TLS handshake, JWT token validation, agent dispatch, pharmacy notification queuing, and audit log write.

In production, this entire sequence runs in under 100 milliseconds on the on-premise Gateway for Reactive Agent decisions, and under 500 milliseconds end-to-end including the cloud round trip.

Getting Started

The fastest path to a working result is four steps:

  1. Open the sandbox console. No login. No API key entry. sandbox.html connects to a live Claude engine with credentials already configured.
  2. Select CABG ICU — Vasopressor. This is the primary reference scenario. It covers the most common Reactive Agent use case: MAP declining below threshold on a post-cardiac surgery patient with an active vasopressor infusion.
  3. Click Run Request. Watch the Gateway Log trace the signal chain. The response renders as a structured decision card with action, recommended dose, confidence bar, and clinical rationale.
  4. Switch to the Schema tab. Every field in the request is documented with type, required/optional status, clinical validation rules, and an example value. Modify the JSON and re-run to test your own scenarios.

Reading the Request JSON

Every request to the AI MedAgent engine is a UPES event (Unified Patient Event Schema). The schema normalizes data from any source protocol — IHE PCD-01 monitor observations, IHE PCD-10 pump events, HL7 LRI lab results, FHIR R4 medication orders — into a single consistent structure that the AI engine reasons over, as described in the patent filing.

Reading the Response

The response is a structured clinical decision object. The sandbox renders it as a decision card. The raw JSON underneath contains every field the production Gateway would act on. The Gateway Routing section below the card describes exactly which IHE transaction fires next and whether pharmacy approval is required before pump programming begins.

Test Scenarios

Eight pre-built scenarios cover the full AI MedAgent adoption stage spectrum. Each loads a complete, clinically valid UPES payload. The Custom scenario lets you build your own.

CABG_ICU_01
Post-cardiac surgery Day 1. MAP trending below 65 mmHg over 3 consecutive PCD-01 readings. Norepinephrine infusion at 0.06 mcg/kg/min. Reactive Agent fires escalation recommendation.
Stage 5 — Full Closed Loop
SEPSIS_ICU_01
Septic shock with rising lactate (3.4 mmol/L) and dual vasopressor support at near-maximum dose. DL Optimizer evaluation with renal impairment context (Cr 2.1).
Stage 4 — DL Optimizer
GLYCEMIC_01
Post-surgical hyperglycemia (glucose 218 mg/dL) with low potassium (K+ 3.2). Demonstrates mandatory co-safety monitoring: insulin titration blocked until hypokalemia addressed.
Stage 2 — Labs + Monitor
STAGE1_MONITOR
Monitors only. No pump integration. Validates that AI MedAgent delivers clinical value at the earliest adoption stage, with no PCD-10 data present.
Stage 1 — Monitors Only
PHARMACY_REVIEW_01
DL Optimizer 4-hour cycle complete. Proactive therapy adjustment at 91% confidence. Demonstrates pharmacy approval gate: no PCD-03 pump order transmits without pharmacist sign-off.
DL Optimizer
SEDATION_SUBSTITUTION_01
CPOE intercept: Propofol ordered at 1.5 mg/kg/hr with 18 cumulative hours and triglycerides 310. AI recommends Dexmedetomidine substitution based on PRIS risk markers and RASS targets.
CPOE Intercept
ALARM_CRITICAL_01
PCD-04 critical alarm: pump occlusion on active vasopressor. Tests immediate agent safety hold pathway. MAP at 66 mmHg. Expected response: SAFETY_HOLD with nurse PCD-06 alert.
PCD-04 Critical
Custom
Build your own UPES event. Edit the JSON directly in the console. All SDK v2.0 schema fields are supported. Use this to test your own device data or clinical scenario.
Free-form

Request Schema

UPES v2.0 — Envelope Fields

Every request to the AI MedAgent engine uses the Unified Patient Event Schema (UPES) defined in SDK v2.0 Section 7. These top-level envelope fields are required on every request regardless of event type.

FieldTypeReqDescription & Validation
upes_versionstringRequired Schema version. Must be "2.0" for SDK v2.0 compatibility. Gateway rejects mismatched versions with HTTP 400.
scenario_idstringRequired Unique identifier for this event or test scenario. Written to the audit log. Used for sandbox scenario matching and troubleshooting.
request_typeenumRequired Routing directive. Determines which AI component handles this request. See Request Type Values below.
UPES v2.0 — patient_context

patient_context

Clinical context for the patient. All fields are required. patient_id and encounter_id remain inside the hospital network. The AI engine never receives direct patient identifiers.

FieldTypeReqDescription & Validation
patient_idstringRequired Patient MRN or sandbox patient identifier. Never transmitted to the cloud AI engine. Stays inside the Gateway local audit trail only.
encounter_idstringRequired Active encounter reference. Used to correlate all UPES events for this patient stay and validate continuity across requests.
care_unitstringRequired Care unit code configured during Gateway onboarding. Drives protocol selection. Examples: CARDIAC_ICU, MEDICAL_ICU, SURGICAL_ICU, STEP_DOWN.
care_dayintegerRequired Day of current admission. Used by the DL Optimizer for hemodynamic trajectory modeling and population cohort matching.
icd10_codesarray[string]Required Active ICD-10 diagnosis codes. Activates condition-specific AI protocols. Z95.1 (post-CABG) activates cardiac surgery vasopressor protocol. At least one code required for DL Optimizer requests.
weight_kgnumberRequired Patient weight in kilograms. Used for all weight-based dose calculations (mcg/kg/min). Valid range: 20–300 kg. Values outside this range return HTTP 422 PATIENT_CONTEXT_INVALID.
UPES v2.0 — device_observations

device_observations (IHE PCD-01)

Array of vital sign and device parameter observations from patient monitors and ventilators. Maps to IHE PCD-01 (DEC profile) ORU^R01 messages normalized by the Gateway. Multiple observations representing a trend are passed as an array; the AI agent evaluates direction and rate of change, not just the most recent value.

FieldTypeReqDescription & Validation
event_typestringRequired Must be "DeviceObservation" for PCD-01 events.
source_protocolenumRequired "IHE_PCD_01" for monitors and ventilators. "IHE_PCD_10" for infusion pumps (use active_infusions array instead).
source_systemstringRequired System identifier configured during Gateway onboarding. Written to audit log for device accountability. Example: "ICU_MONITOR_BED4".
timestampdatetimeRequired UTC ISO 8601. Observations older than 5 minutes return STALE_OBSERVATION warning. Observations older than 30 minutes are rejected (HTTP 422).
payload.MAPnumberOptional Mean arterial pressure in mmHg. MDC code 150021. Required for vasopressor agent activation. Valid range: 30–200 mmHg. Below 30 returns MAP_BELOW_MINIMUM_THRESHOLD (HTTP 422).
payload.SBP / DBPnumberOptional Systolic and diastolic blood pressure in mmHg. MDC codes 150017 / 150018. Used by vasodilator agent when SBP exceeds target.
payload.HRnumberOptional Heart rate in beats per minute. MDC code 147842. Used by rate control agent. Valid range: 20–300 bpm.
payload.SpO2numberOptional Peripheral oxygen saturation percent. MDC code 150456. Informs opioid and ventilator agents.
payload.RRnumberOptional Respiratory rate in breaths per minute. MDC code 151562. Required for opioid titration agent; threshold 10 br/min.
payload.Temp_CnumberOptional Temperature in Celsius. Used in sepsis protocol contextualization.
UPES v2.0 — active_infusions

active_infusions (IHE PCD-10)

Array of active infusion pump events. Maps to IHE PCD-10 (IPEC profile) ORU^R42 messages. Provides the AI engine with current drug, concentration, and infusion rate for dose delta calculations. Required for Stage 5+ deployments with closed-loop pump integration. Pass an empty array [] for Stage 1–4 deployments.

FieldTypeReqDescription & Validation
event_typestringRequired Must be "InfusionPumpEvent".
source_protocolstringRequired Must be "IHE_PCD_10".
medicationstringRequired Drug name from the pump drug library. Matched against the formulary during pharmacy routing. Must match a registered formulary entry.
concentration_mcg_mlnumberRequired Drug concentration in micrograms per milliliter. Combined with weight_kg to convert between mL/hr and mcg/kg/min. Use concentration_units_ml for unit-dosed drugs (e.g., Vasopressin, Insulin).
current_rate_mcg_kg_minnumberRequired Current infusion rate in mcg/kg/min. Primary input to Reactive Agent dose delta calculation. Validated against formulary maximum rate. Exceeding max returns RATE_EXCEEDS_FORMULARY_MAX (HTTP 422).
pump_idstringRequired Pump identifier matching a system registered in the Gateway onboarding portal. Required for outbound PCD-03 pump programming order routing.
UPES v2.0 — lab_results

lab_results (HL7 LRI / FHIR R4)

Array of laboratory results. Maps to HL7 v2.5.1 LRI ORU^R01 messages via MLLP or FHIR R4 Observation resources via SMART on FHIR subscription. The Gateway filters for medication-relevant analytes using the LOINC codes in SDK v2.0 Section 5.3. Pass an empty array [] for Stage 1 (monitors-only) deployments.

FieldTypeReqDescription & Validation
loinc_codestringRequired LOINC code for the analyte. Priority analytes: Glucose 1554-5, Potassium 2823-3, Lactate 2519-9, Creatinine 2160-0. Full list in SDK Section 5.3.
analytestringRequired Human-readable analyte name. Used in pharmacy notifications and nurse alerts.
valuenumberRequired Numeric result value.
unitstringRequired UCUM unit string. Examples: "mg/dL", "mmol/L", "mEq/L", "mg/dL".
flagenumRequired HL7 abnormal flag. Critical flags (HH / LL / C) trigger immediate agent evaluation and nurse notification regardless of other conditions, bypassing normal evaluation queue. Values: N, L, H, LL, HH, C.
timestampdatetimeRequired Result collection time. UTC ISO 8601. The Gateway uses this for recency validation: a glucose result 5 minutes old is treated differently from one 2 hours old when making titration decisions.
UPES v2.0 — Routing

request_type Values

The request_type field routes the event to the correct AI engine component.

ValueRoutes ToDescription
REACTIVE_AGENT_EVALUATIONReactive Agent (Gateway-local) As designed: real-time titration evaluation, running entirely on the Gateway, no cloud connectivity required, targeting under 100ms response in a future production deployment. Not implemented in this demo.
DL_OPTIMIZER_EVALUATIONDL Optimizer (Cloud — AWS) As designed: 4-hour trajectory analysis, sending a de-identified feature vector to a cloud model (SageMaker in the designed architecture), with pharmacy approval required before any PCD-03 order. Not implemented in this demo — no cloud model is called.
PHARMACY_REVIEWPharmacy Router Routes a pending DL Optimizer recommendation through the pharmacy approval workflow. Includes formulary check, drug interaction scan, and renal/hepatic adjustment evaluation.
CPOE_INTERCEPTCPOE Intercept Agent Evaluates a medication order at the point of entry. Surfaces substitution recommendations, dose adjustments, or contraindications before the order reaches pharmacy.
DEVICE_ALARMAlarm Manager (PCD-04) Processes a PCD-04 device alarm event. Critical alarms always return SAFETY_HOLD for the affected agent. Never rate-limited.

Response Structure

Every AI MedAgent decision response returns a structured JSON object followed by a plain-text Gateway Routing section. The sandbox renders the JSON as a decision card.

Decision Response Object — All Fields
"decision_id":Unique decision identifier. Format: dec_[8 hex chars]. Written to audit log.
"scenario_id":Echo of the request scenario_id.
"request_type":Echo of the routing directive used.
"agent":The specific agent that generated this decision (e.g., MAP_REACTIVE_AGENT, GLUCOSE_REACTIVE_AGENT).
"action":The recommended clinical action. See Action Values below.Required field for all response types.
"medication":Drug name the decision applies to.
"current_dose":Current dose with units as received in the request.
"recommended_dose":Recommended dose with units, or "MAINTAIN" if no change.
"delta":Change amount with units (e.g., "+0.02 mcg/kg/min"), or null for MAINTAIN / SAFETY_HOLD.
"confidence":Confidence score 0.0–1.0. DL Optimizer threshold is 0.85 by default; below threshold returns no recommendation.Displayed as percentage in sandbox.
"nurse_notify":Boolean. Whether to send a PCD-06 handheld alert to nursing.
"requires_pharmacy_approval":Boolean. DL Optimizer recommendations always true. Reactive Agent escalations for critical parameters are false (notification simultaneous with pump programming).
"expiry_sec":Decision validity window in seconds. 300s for reactive decisions, 600s for DL Optimizer. Expired decisions are discarded without action.
"clinical_flags":Array of clinical safety notes (e.g., hypokalemia co-safety warning). Empty array if none.
"evidence_basis":Array of guideline or study references supporting the recommendation.
"rationale":2–4 sentences of plain clinical reasoning. Written as a clinical expert would in a chart note, not AI register.
Response — action field

Action Values

ActionMeaningPCD-03 Fires?
INCREASE_RATEIncrease infusion rate by delta amount.Yes, after approvals
DECREASE_RATEDecrease infusion rate by delta amount.Yes, after approvals
MAINTAIN_RATENo change. Current rate is within target range.No
HOLDClinical concern detected; do not increase. Current rate maintained pending review.No
SAFETY_HOLDCritical alarm or safety rule triggered. Agent suspended. Nurse notification immediate.No
SUBSTITUTECPOE intercept: different drug recommended in place of ordered drug.Routes to pharmacy first
NOTIFY_ONLYClinical situation warrants nurse awareness but no autonomous dose change. Stage 1–4 deployments only.No
PHARMACY_APPROVAL_REQUIREDDL Optimizer recommendation awaiting pharmacist sign-off before any pump action.After pharmacy approves
Response — Gateway Routing section

Gateway Routing

Below the decision JSON, the sandbox returns a plain-text Gateway Routing section. This describes exactly what the on-premise Gateway would do next with this decision in a production deployment: which IHE transaction fires, whether pharmacy approval is required before pump programming, and how the nurse is notified.

Key distinction: For Reactive Agent decisions, pharmacy notification is simultaneous with nurse alert and pump pre-programming — not a prerequisite. For DL Optimizer decisions, pharmacy approval is a hard gate: the PCD-03 pump order does not transmit until a pharmacist approves in the pharmacy information system.

Clinical Safety Rules

The AI engine enforces these rules on every request. They cannot be overridden by request parameters. Understanding them prevents confusion when the engine returns a different action than expected.

RuleTriggerEngine Response
Formulary maximum rate Requested or recommended dose would exceed formulary maximum Returns HOLD. clinical_flags explains why. No dose increase generated.
Hypokalemia co-safety K+ < 3.5 mEq/L present in lab results Insulin dose increase blocked. HOLD returned with potassium co-safety flag. Replaces active dose change recommendation.
Critical alarm safety hold PCD-04 alarm with severity CRITICAL received SAFETY_HOLD returned immediately. Affected agent suspended. Nurse PCD-06 alert sent regardless of other conditions.
DL Optimizer pharmacy gate request_type is DL_OPTIMIZER_EVALUATION Always returns requires_pharmacy_approval: true. No PCD-03 pump order generated until pharmacist approves.
Extreme MAP / vasopressor limit MAP < 55 mmHg or Norepinephrine equivalent > 0.3 mcg/kg/min NOTIFY_ONLY returned. Requires physician order for dose increase beyond this threshold. AI does not act unilaterally at extreme parameters.
Stale observation Observation timestamp > 30 minutes old Event rejected with HTTP 422 STALE_OBSERVATION. No decision generated.

Error Codes

Full error reference is in SDK Supplement v2.1 Section B. Key codes relevant to sandbox testing:

CodeHTTPMeaning
MAP_BELOW_MINIMUM_THRESHOLD422MAP value below physiological minimum (30 mmHg).
RATE_EXCEEDS_FORMULARY_MAX422Infusion rate exceeds registered formulary maximum for this drug.
PATIENT_CONTEXT_INVALID422weight_kg outside valid range (20–300 kg).
STALE_OBSERVATION422Observation timestamp more than 30 minutes old.
PUMP_ACK_LEVEL2_FAILED422PCD-03 not acknowledged by pump controller. Agent enters safety hold.
PHARMACY_APPROVAL_TIMEOUT422DL Optimizer recommendation expired (300s) without pharmacy response. Discarded.
NURSE_OVERRIDE_RECEIVED200Nurse overrode AI decision. Agent resumes monitoring. Will not re-recommend same action for 30 minutes.
PATIENT_CONTEXT_MISMATCH422patient_id does not match active encounter. Event quarantined. No clinical action.

What This Represents

This sandbox illustrates a proof-of-concept architecture, not a production-ready integration path. It demonstrates a new and unique possible approach to closed-loop medication management that may improve outcomes and reduce costs, described in a pending patent filing. It is not a commercial product, and there is no support offering, SDK download, or integration engagement associated with it at this time.