AEGIS CONSENT INTELLIGENCE AGENT
Project: Aegis Consent Intelligence Agent
Hackathon: PromptOpinion Healthcare AI Hackathon
Submitted by: Dr. Bhavna Gupta
AI-generated informed consent that is specific to this patient —
not a template. Every risk referenced. Every value named.
INSPIRATION
Informed consent is one of the oldest ethical principles in medicine.
It is also one of the most consistently violated — not through
negligence, but through system design.
In most hospitals, a busy surgical resident hands a patient a printed
consent form that reads:
"Risks include bleeding, infection, anaesthetic complications,
damage to surrounding structures, and death."
This language is legally defensible but clinically meaningless.
A 72-year-old with congestive heart failure, K+ of 6.1, warfarin
not held, and a predicted difficult airway — gets the same consent
form as a healthy 28-year-old having a laparoscopic appendicectomy.
That is not informed consent. That is documentation of a signature.
The medicolegal consequences of inadequate consent are severe.
The ethical consequences are worse.
I built Aegis Consent Generator because I believe that every patient
deserves to know — in language they can actually understand — what
the specific risks of their specific operation are, given their
specific health conditions. Not the risks of surgery in general.
Their risks. Their values. Their operation.
Aegis makes this achievable in every pre-operative clinic,
for every patient, every time.
WHAT IT DOES
Aegis Consent Intelligence Agent is a PromptOpinion AI agent that receives
a completed preoperative risk assessment from Aegis Perioperative
Copilot (via A2A handoff) and transforms it into a structured,
patient-specific informed consent brief.
The output is not a template with blanks filled in.
It is genuinely patient-specific clinical communication — written
at Grade 8 reading level, with every risk referenced to the
patient's actual lab values, scores, and diagnoses.
WHAT IT PRODUCES (8 STRUCTURED SECTIONS)
SECTION 1 — Consent Header
Patient identity, procedure, Aegis recommendation, and — critically —
a clear warning if recommendation is POSTPONE or ESCALATE before
any consent documentation proceeds.
SECTION 2 — Patient-Specific Risk Summary (plain English)
One paragraph per clinical flag, written for the patient to understand.
Every paragraph references the patient's actual data.
EXAMPLE — K+ 5.6 flag
"Your blood potassium level is slightly higher than we like to see
before surgery (5.6 mmol/L; normal is below 5.0). High potassium
can affect your heart rhythm during anaesthesia. Your anaesthetic
team will check this level again before your operation and will
treat it if it remains elevated. Do not eat foods very high in
potassium (bananas, oranges, potatoes) in the days before surgery."
EXAMPLE — Mallampati 3 + OSA + neck 44cm
"Based on your examination, your anaesthetist has identified that
placing a breathing tube may be more challenging than usual. This
is because of the size of your neck and your previously identified
sleep breathing problem. Your anaesthetist has made a special plan —
additional equipment will be ready and a senior anaesthesiologist
will be present during your operation."
EXAMPLE — HbA1c 8.9%
"Your blood sugar control over the past 3 months has not been as
good as we would ideally like (HbA1c 8.9%; we prefer below 7% for
surgery). This increases your risk of wound infection after surgery
by approximately 2–3 times. Your anaesthetic team will monitor your
blood sugar closely throughout the operation and recovery."
SECTION 3 — Anaesthesia-Specific Consent
Patient-facing language covering:
- Airway management plan (Mallampati referenced if ≥ 3)
- PONV risk (Apfel score cited: "61% chance of nausea")
- Awareness under anaesthesia (< 1 in 19,000)
- Drug interactions (actual medications named)
- Post-op monitoring (OSA → HDU if STOP-BANG ≥ 5)
SECTION 4 — Surgeon Discussion Checklist (clinical level)
Every item references the flag that triggered it.
POSTPONE and ESCALATE items marked: 🔴 URGENT DISCUSSION REQUIRED
Formatted for direct inclusion in pre-operative notes.
SECTION 5 — Optimisation Action Table
For OPTIMIZE and ESCALATE cases:
Specific action, responsible party, and deadline per flag.
EXAMPLE
ACTION: Repeat serum potassium — target < 5.0 mmol/L
RESPONSIBLE: GP
DEADLINE: 3–5 days before surgery
ACTION: Hold Metformin 48h pre-op
RESPONSIBLE: Patient (instructed verbally and in writing)
DEADLINE: [surgery date minus 2 days]
SECTION 6 — Patient Declaration
A readable, signable declaration that the patient can understand
before signing — not legalese, but clear acknowledgement of the
specific risks they have been counselled about.
SECTION 7 — Postponement Letter (only when POSTPONE)
A direct, plain-English letter explaining:
- Why surgery cannot proceed at this time
- The specific finding(s) that triggered postponement
- What needs to happen before surgery can be rebooked
- Who to contact
SECTION 8 — Disclaimer
One clear disclaimer. Once. At the end.
RECOMMENDATION-GATED BEHAVIOUR
PROCEED → Full patient-specific consent brief
OPTIMIZE → Consent + optimisation requirement notice + conditional
surgery date language
ESCALATE → Consent + specialist review notice
POSTPONE → Consent + postponement letter +
"SURGERY CANNOT PROCEED AT THIS TIME" header
HOW WE BUILT IT
Aegis Consent Generator is a PromptOpinion agent — no new MCP tools,
no additional server code. It operates entirely from the assessment
JSON produced by Aegis Perioperative Copilot, received via A2A handoff.
AGENT ARCHITECTURE
Aegis Supervisor (Agent 1)
↓ assessment JSON via A2A
Aegis Safety Reviewer (Agent 2)
↓ final assessment + safety addendum via A2A
Aegis Consent Generator (Agent 3) ← this project
↓
8-section structured consent brief
SYSTEM PROMPT
Defines the agent identity, reading level rules (Grade 8 plain English),
what the agent never does (fabricate, use generic templates, downplay
POSTPONE flags, produce identical output for different patients), and
the recommendation-override rule.
CONSULT PROMPT
Provides the complete 8-section output structure with:
- Exact format for each section
- Worked example paragraphs for every flag type
- Specific language for POSTPONE postponement letters
- Surgeon checklist formatting rules
- Optimisation action table structure
MCP TOOLS
While the Consent Generator operates primarily from the Aegis assessment JSON passed via A2A, the Aegis Anesthesia MCP server remains connected to both consent agents by design.
When additional patient context is needed — a specific lab value not captured in the assessment summary, a medication detail requiring clarification, or a live EHR patient whose full record needs re-querying — the agent can call fetch_patient_from_fhir or normalize_fhir directly without breaking the workflow.
This means the consent agent is not dependent on a perfect upstream handoff.
If the A2A assessment is sparse or a specific clinical detail needs verification before being named in a consent paragraph, the agent has direct access to the same FHIR data source as the Supervisor.
The MCP connection is the safety net that ensures consent language is always grounded in verified patient data — never inferred.
MCP SERVER (Python 3.11 + FastMCP 3.x, deployed on Railway)
Six production-ready MCP tools:
1. fetch_patient_from_fhir
Fetches live patient data via PromptOpinion FHIR context headers:
- X-FHIR-Server-URL
- X-FHIR-Access-Token
- X-Patient-ID
Fires 8 scoped FHIR queries in parallel, assembles a bundle,
normalises to canonical schema.
2. assess_current_patient
One-shot:
fetch → normalise → score
Primary entry point for live clinical workflows.
3. normalize_fhir
FHIR R4 Bundle → canonical Aegis patient JSON.
Handles:
- LOINC code mapping
- text fallback
- valueString numeric extraction
- ServiceRequest fallback for procedure extraction
4. compute_risk_scores
Fully deterministic Python scoring engine.
Computes:
- RCRI
- STOP-BANG
- Apfel
- ASA
using rule-based logic, not by the LLM.
5. fetch_guideline
10 conditions, hardcoded from authoritative sources.
- No external API
- No hallucinated citations
- Urgency-aware variants
6. format_aegis_report
Converts assessment JSON → structured markdown report.
Includes:
- severity-sorted flags
- optimisation steps
- guideline citations
- safety addendum
- missing data checklist
CHALLENGES WE FACED
READING LEVEL IS HARDER THAN IT SOUNDS
Writing at Grade 8 level about complex clinical concepts is genuinely difficult.
"Your blood sugar control as measured by HbA1c"
is not Grade 8.
"Your blood sugar test result"
is.
Getting the level right required iterative prompt refinement with examples.
RECOMMENDATION-GATED LANGUAGE
The consent brief must change substantially based on the recommendation.
A POSTPONE case needs a postponement letter.
An OPTIMIZE case needs conditional surgery date language.
SPECIFIC VS GENERIC
The biggest challenge was preventing generic consent language from creeping back in.
The agent naturally tends toward:
"risks include bleeding and infection"
style outputs.
Embedding worked examples with actual values and actual patient details directly in the consult prompt was the solution.
NOT DOWNPLAYING RISK
Clinical AI systems tend toward reassurance.
We needed the opposite — an agent that states risk clearly, names postponements explicitly, and never softens a POSTPONE into:
"we'd like to delay surgery"
WHAT WE LEARNED
1. PATIENT COMMUNICATION IS A CLINICAL SKILL
Writing consent language that is specific, accurate, Grade 8, and emotionally calibrated requires the same kind of clinical judgment as the risk assessment itself.
2. EXAMPLES IN PROMPTS ARE MORE POWERFUL THAN INSTRUCTIONS
Showing the agent examples works better than simply instructing it.
3. A2A MAKES WORKFLOW COMPOSITION NATURAL
Receiving the Aegis assessment as structured JSON via A2A handoff makes the system feel integrated rather than fragmented.
4. CONSENT IS WHERE AI CAN DO SOMETHING DOCTORS CURRENTLY CANNOT
A clinician can personalize consent mentally.
They cannot always write it down for every patient, every time, at Grade 8 level with every risk referenced.
FUTURE SCOPE
- Regional Indian language expansion
- Voice-generated consent
- Digital consent integration
- Patient Q&A mode
- Family-member version
- Literacy-independent pictographic consent
BUILT WITH
PromptOpinion · A2A Protocol · Claude Sonnet
Aegis Perioperative Copilot (companion project)
Python 3.11 · FastMCP · FHIR R4 · Grade 8 Flesch-Kincaid targeting
LINKS
Demo Video
PromptOpinion Agent
https://app.promptopinion.ai/marketplace/agent/019e100d-eaae-779d-91c1-94b9b3c76c7d
Companion Project
https://devpost.com/software/ai-assisted-perioperative-optimization
TOOLS
PromptOpinion
Agent platform where the Consent Generator agent is configured.
Google gemini lite
The LLM powering the Consent Generator.
A2A Protocol
Receives the Aegis Perioperative Copilot assessment JSON as structured input via A2A handoff.
Aegis Anesthesia MCP (FastMCP 3.2.4 — Railway)
Connected to both consent agents.
FHIR R4
Used for live patient FHIR context verification.
Flesch-Kincaid Grade Level targeting (Grade 8)
The readability standard used to calibrate patient-facing consent language.
Python 3.11 / FastMCP 3.2.4 / Railway / httpx
Underlying MCP infrastructure inherited from Aegis Perioperative Copilot.


Log in or sign up for Devpost to join the conversation.