Inspiration

In India, emergency patients can lose valuable time simply because the first hospital they reach may not have the right specialist, procedure support, or ICU capacity.

When that happens, the care team often has to call several hospitals, confirm availability, compare travel time, prepare the handoff, obtain approval, and keep everyone updated. Much of this is still handled through phone calls, spreadsheets, and manual follow-ups.

During a critical emergency, this coordination delay can consume the patient’s golden window for treatment.

We built CareRelay AI to explore a better approach: one workflow that helps teams find a suitable receiving hospital, understand why it was selected, complete clinical approval, prepare the handoff, and track what happens next.

CareRelay AI is a demonstration platform. Hospital names and locations come from public information. The clinical details, hospital capacity, staff, travel estimates, reservations, notifications, and transfer events shown in the application are demonstration data.

What it does

CareRelay AI helps coordinate an urgent transfer from a referring hospital to a suitable receiving facility.

The coordinator enters the required:

medical specialty procedure capability bed type urgency level

CareRelay then reviews the available hospitals and checks whether they meet the required clinical and operational criteria.

The platform:

collects hospital capability, capacity, route, ETA, and transfer-protocol information removes hospitals that fail mandatory requirements ranks the eligible hospitals using a deterministic rules engine recommends the best eligible option and explains the reasoning shows why other hospitals were excluded requires approval from a qualified clinician supports receiving-hospital notification after approval prepares a structured SBAR-style handoff records the workflow in a transfer timeline

In our demonstration, Gauhati Medical College and Hospital is selected because it supports neurology, mechanical thrombectomy, transfer acceptance, and the required Neurological ICU capacity.

One of the important ideas behind the project is that the nearest hospital is not always the right hospital. A closer facility may still be excluded when it cannot provide the required procedure or does not have the necessary bed capacity.

CareRelay AI does not diagnose patients, recommend treatment, approve transfers on its own, reserve real hospital beds, or contact real hospitals.

How we built it

CareRelay AI has a React and TypeScript frontend, a FastAPI backend, and a SQLite database. The frontend and backend are deployed as separate services on Google Cloud Run.

The main components are:

Frontend: React, Vite, and TypeScript Backend: FastAPI and Python Database: SQLite Deployment: Google Cloud Run Agent integration: OpenAI Agents SDK Tool layer: MCP over a stdio client-server connection Decision layer: deterministic eligibility and ranking rules Testing: pytest and Playwright

The CareRelay transfer coordination agent can use MCP tools to gather information about:

available receiving hospitals specialty and procedure support bed and ICU capacity route and ETA context transfer acceptance and protocol requirements

The agent helps coordinate the evidence-gathering process, but it does not control the final eligibility decision.

The deterministic engine remains authoritative. It applies the mandatory rules, excludes unsuitable hospitals, and produces the ranking. A clinician must review and approve the recommendation before the workflow can continue.

We also designed the platform to keep working when live OpenAI runtime access is unavailable. In that situation, CareRelay uses the deterministic path and applies the same eligibility rules, ranking constraints, and approval requirements. The application does not claim that an agent run occurred when it did not.

After approval, the user can continue with notification, reservation tracking, handoff generation, transfer status, and timeline updates within the demonstration workflow.

Notification delivery and hospital acknowledgement are shown as separate states. A delivered message is never treated as confirmation that the receiving hospital has accepted the transfer.

Codex with GPT-5.6 Terra helped us throughout the project. We used it to:

refine the problem and define the safety boundaries design the architecture build the frontend and backend implement the Agents SDK and MCP workflow create and improve automated tests debug API, CORS, runtime configuration, and Cloud Run issues review the interface and improve the wording prepare deployment and submission documentation

Challenges we ran into

One major challenge was balancing agentic coordination with healthcare safety. We wanted the agent to decide which evidence tools to call, but we did not want a model to control clinical eligibility or silently change ranking rules. We solved this by making the deterministic eligibility engine authoritative and treating the agent as a bounded coordinator.

Another challenge was handling unavailable OpenAI runtime quota. Instead of allowing the workflow to fail, we implemented a deterministic fallback that preserves the same eligibility checks, ranking constraints, and human-approval boundary.

Deploying the application also introduced several production issues:

  • Cloud Build service-account permissions
  • Cloud Run CORS configuration
  • Different Cloud Run frontend URL formats
  • Runtime frontend configuration
  • Preventing production requests from falling back to localhost
  • Loading runtime configuration before the React application started

We diagnosed these issues through browser network inspection, health checks, CORS preflight verification, and incremental Cloud Run revisions.

Accomplishments that we're proud of

We are proud that CareRelay AI is more than a static proof of concept. It is a publicly deployed, end-to-end workflow that includes:

  • MCP-based evidence collection
  • OpenAI Agents SDK integration
  • Deterministic eligibility and ranking guardrails
  • Explicit hospital exclusion reasons
  • Qualified human approval
  • Synthetic receiving-hospital notification
  • Structured transfer handoff generation
  • Transfer tracking and audit history
  • Resilient deterministic fallback
  • Responsive desktop and mobile behavior

The final automated validation included:

  • 44 passing backend tests
  • 14 passing Playwright tests across desktop and mobile Chromium
  • A successful frontend production build

We are also proud that the system explains not only which hospital was selected, but why other hospitals were excluded.

What we learned

We learned that safe agentic systems do not need unlimited autonomy. A useful production pattern is to combine:

  • Model-driven tool orchestration
  • Grounded MCP evidence
  • Deterministic decision rules
  • Structured validation
  • Human approval
  • Transparent fallback behavior
  • Auditable events

We also learned that resilience is part of the product experience. A model, API, or external dependency may be temporarily unavailable, but the core workflow should remain safe and understandable.

Codex was especially valuable for working across product design, architecture, implementation, automated testing, debugging, and deployment within one continuous development workflow.

What's next for CareRelay AI

The next phase would focus on production-grade integrations and controlled pilots, including:

  • Real hospital directory and capability integrations
  • Authorized capacity-management systems
  • Secure identity and role-based access
  • Real acknowledgement workflows
  • Policy and transfer-protocol retrieval
  • Persistent managed databases
  • Advanced audit and observability controls
  • Configurable regional hospital networks
  • Real-time ambulance and transfer-status integrations

Before any real clinical deployment, CareRelay AI would require formal security, privacy, clinical-safety, regulatory, and hospital-governance reviews.

Built With

Share this project:

Updates