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.
How It Works
The sandbox simulates the full AI MedAgent signal chain. When you click Run Request, the following sequence fires in real time:
- UPES schema validation. The sandbox Gateway validates the envelope fields, checks required parameters, and confirms clinical value ranges are physiologically plausible.
- PHI boundary enforcement.
patient_idandencounter_idare confirmed local. Only de-identified clinical features cross to the AI engine. - Agent routing. The
request_typefield 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. - 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.
- Structured decision returned. The response includes action, dose recommendation, confidence score, clinical rationale, and the Gateway Routing section showing which IHE transaction fires next.
- 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:
- Open the sandbox console. No login. No API key entry. sandbox.html connects to a live Claude engine with credentials already configured.
- 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.
- 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.
- 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.
Request Schema
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.
| Field | Type | Req | Description & Validation |
|---|---|---|---|
| upes_version | string | Required | Schema version. Must be "2.0" for SDK v2.0 compatibility. Gateway rejects mismatched versions with HTTP 400. |
| scenario_id | string | Required | Unique identifier for this event or test scenario. Written to the audit log. Used for sandbox scenario matching and troubleshooting. |
| request_type | enum | Required | Routing directive. Determines which AI component handles this request. See Request Type Values below. |
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.
| Field | Type | Req | Description & Validation |
|---|---|---|---|
| patient_id | string | Required | Patient MRN or sandbox patient identifier. Never transmitted to the cloud AI engine. Stays inside the Gateway local audit trail only. |
| encounter_id | string | Required | Active encounter reference. Used to correlate all UPES events for this patient stay and validate continuity across requests. |
| care_unit | string | Required | Care unit code configured during Gateway onboarding. Drives protocol selection. Examples: CARDIAC_ICU, MEDICAL_ICU, SURGICAL_ICU, STEP_DOWN. |
| care_day | integer | Required | Day of current admission. Used by the DL Optimizer for hemodynamic trajectory modeling and population cohort matching. |
| icd10_codes | array[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_kg | number | Required | 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. |
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.
| Field | Type | Req | Description & Validation |
|---|---|---|---|
| event_type | string | Required | Must be "DeviceObservation" for PCD-01 events. |
| source_protocol | enum | Required | "IHE_PCD_01" for monitors and ventilators. "IHE_PCD_10" for infusion pumps (use active_infusions array instead). |
| source_system | string | Required | System identifier configured during Gateway onboarding. Written to audit log for device accountability. Example: "ICU_MONITOR_BED4". |
| timestamp | datetime | Required | UTC ISO 8601. Observations older than 5 minutes return STALE_OBSERVATION warning. Observations older than 30 minutes are rejected (HTTP 422). |
| payload.MAP | number | Optional | 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 / DBP | number | Optional | Systolic and diastolic blood pressure in mmHg. MDC codes 150017 / 150018. Used by vasodilator agent when SBP exceeds target. |
| payload.HR | number | Optional | Heart rate in beats per minute. MDC code 147842. Used by rate control agent. Valid range: 20–300 bpm. |
| payload.SpO2 | number | Optional | Peripheral oxygen saturation percent. MDC code 150456. Informs opioid and ventilator agents. |
| payload.RR | number | Optional | Respiratory rate in breaths per minute. MDC code 151562. Required for opioid titration agent; threshold 10 br/min. |
| payload.Temp_C | number | Optional | Temperature in Celsius. Used in sepsis protocol contextualization. |
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.
| Field | Type | Req | Description & Validation |
|---|---|---|---|
| event_type | string | Required | Must be "InfusionPumpEvent". |
| source_protocol | string | Required | Must be "IHE_PCD_10". |
| medication | string | Required | Drug name from the pump drug library. Matched against the formulary during pharmacy routing. Must match a registered formulary entry. |
| concentration_mcg_ml | number | Required | 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_min | number | Required | 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_id | string | Required | Pump identifier matching a system registered in the Gateway onboarding portal. Required for outbound PCD-03 pump programming order routing. |
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.
| Field | Type | Req | Description & Validation |
|---|---|---|---|
| loinc_code | string | Required | 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. |
| analyte | string | Required | Human-readable analyte name. Used in pharmacy notifications and nurse alerts. |
| value | number | Required | Numeric result value. |
| unit | string | Required | UCUM unit string. Examples: "mg/dL", "mmol/L", "mEq/L", "mg/dL". |
| flag | enum | Required | 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. |
| timestamp | datetime | Required | 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. |
request_type Values
The request_type field routes the event to the correct AI engine component.
| Value | Routes To | Description |
|---|---|---|
| REACTIVE_AGENT_EVALUATION | Reactive 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_EVALUATION | DL 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_REVIEW | Pharmacy Router | Routes a pending DL Optimizer recommendation through the pharmacy approval workflow. Includes formulary check, drug interaction scan, and renal/hepatic adjustment evaluation. |
| CPOE_INTERCEPT | CPOE Intercept Agent | Evaluates a medication order at the point of entry. Surfaces substitution recommendations, dose adjustments, or contraindications before the order reaches pharmacy. |
| DEVICE_ALARM | Alarm 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.
dec_[8 hex chars]. Written to audit log.scenario_id.MAP_REACTIVE_AGENT, GLUCOSE_REACTIVE_AGENT)."MAINTAIN" if no change."+0.02 mcg/kg/min"), or null for MAINTAIN / SAFETY_HOLD.true. Reactive Agent escalations for critical parameters are false (notification simultaneous with pump programming).Action Values
| Action | Meaning | PCD-03 Fires? |
|---|---|---|
| INCREASE_RATE | Increase infusion rate by delta amount. | Yes, after approvals |
| DECREASE_RATE | Decrease infusion rate by delta amount. | Yes, after approvals |
| MAINTAIN_RATE | No change. Current rate is within target range. | No |
| HOLD | Clinical concern detected; do not increase. Current rate maintained pending review. | No |
| SAFETY_HOLD | Critical alarm or safety rule triggered. Agent suspended. Nurse notification immediate. | No |
| SUBSTITUTE | CPOE intercept: different drug recommended in place of ordered drug. | Routes to pharmacy first |
| NOTIFY_ONLY | Clinical situation warrants nurse awareness but no autonomous dose change. Stage 1–4 deployments only. | No |
| PHARMACY_APPROVAL_REQUIRED | DL Optimizer recommendation awaiting pharmacist sign-off before any pump action. | After pharmacy approves |
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.
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.
| Rule | Trigger | Engine 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:
| Code | HTTP | Meaning |
|---|---|---|
| MAP_BELOW_MINIMUM_THRESHOLD | 422 | MAP value below physiological minimum (30 mmHg). |
| RATE_EXCEEDS_FORMULARY_MAX | 422 | Infusion rate exceeds registered formulary maximum for this drug. |
| PATIENT_CONTEXT_INVALID | 422 | weight_kg outside valid range (20–300 kg). |
| STALE_OBSERVATION | 422 | Observation timestamp more than 30 minutes old. |
| PUMP_ACK_LEVEL2_FAILED | 422 | PCD-03 not acknowledged by pump controller. Agent enters safety hold. |
| PHARMACY_APPROVAL_TIMEOUT | 422 | DL Optimizer recommendation expired (300s) without pharmacy response. Discarded. |
| NURSE_OVERRIDE_RECEIVED | 200 | Nurse overrode AI decision. Agent resumes monitoring. Will not re-recommend same action for 30 minutes. |
| PATIENT_CONTEXT_MISMATCH | 422 | patient_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.