AWS Builder Center
ClinicoTrace: Building Safer AI for Indian Healthcare

ClinicoTrace: Building Safer AI for Indian Healthcare

How we're building ClinicoTrace with AI, deterministic safety rules and AWS to help doctors reduce clinical workflow friction without replacing human judgment.

CS Student @ KEC | Backend & Distributed Systems | Building Scalable DevTools & Cloud Infrastructure

Healthcare AI has an uncomfortable engineering problem:

The parts of healthcare that benefit most from AI are often the parts where hallucination is least acceptable.
A language model is excellent at interpreting messy language, converting speech into structured information, and generating patient-friendly explanations.
But we don't want a language model deciding whether a drug combination is clinically safe.
That distinction became the foundation of ClinicoTrace, our project for the Bharat Builds Hackathon.
ClinicoTrace is a clinical workflow platform designed for high-throughput outpatient departments (OPDs), particularly environments where doctors work under severe time pressure and prescriptions may be handwritten, abbreviated, or difficult for patients to interpret.
Our architecture deliberately separates:

The Problem: Clinical Throughput Creates a Safety Bottleneck
The problem isn't simply that doctors are busy.
It is that a high-throughput workflow creates multiple opportunities for information to degrade between consultation and medication use.
A clinical interaction can look like:


Consultation time

An Indian primary-care article cites an average consultation time of approximately 1.9 minutes.
Government audit evidence also shows how compressed OPD workflows can become. In test-checked hospitals and community health centres in Uttar Pradesh, the CAG reported that 86% of patients in district/joint hospitals and 69% in district women hospitals received less than five minutes of consultation time. Eleven percent of district/joint-hospital patients received two minutes or less.
A separate study of public health facilities in South India reported an average consultation time of 3.9 minutes, below the WHO-referenced optimal value of more than 10 minutes.
This matters because documentation and communication have to compete for the same few minutes.
Prescription Quality Is Not Just About Handwriting
Our initial assumption was:
"Doctors write illegibly, therefore AI handwriting recognition is the solution."
The literature suggests the problem is more nuanced.
A rural hospital study in Delhi found 95.8% of prescriptions had legible handwriting, but important clinical information was still missing: diagnosis appeared on only 64.2% of prescriptions.
Another Indian outpatient study found only 65.45% of prescriptions were classified as legible.
A study of handwritten prescriptions in a rural Indian setting found only 53.7% had no problem reading all aspects of the prescription, while 17.7% had one aspect that was unclear and 5.4% had more than one unclear aspect.
But an even more interesting finding came from a public hospital in Eastern India.
More than 95% of prescriptions were considered legible, yet 67% of patients had poor or fair comprehension of essential medication information such as dose and frequency. The study specifically noted difficulty understanding standard frequency abbreviations.
That changed our product thinking.
The problem isn't simply:
"Can we read the doctor's handwriting?"
It is:
"Can we reliably transform clinical intent into structured information and then communicate the authorized regimen in a form the patient can actually use?"

Drug–Drug Interactions: Why We Don't Ask an LLM to Decide

Drug interactions are another difficult area.
There isn't one universal Indian percentage that describes every prescription. The prevalence changes significantly depending on:
inpatient vs outpatient number of medications age comorbidities hospital type interaction database definition of an interaction
For example:
A study of 500 outpatient prescriptions found DDIs in 12.8% of prescriptions.
A 2023 study of 382 OPD prescriptions at Government Medical College & Hospital, Nagpur identified potential DDIs in 14.39% of prescriptions.
In contrast, a tertiary-care internal-medicine study found at least one potential DDI in 46% of prescriptions, with older patients and those receiving more than six drugs at higher risk.
Another tertiary-care outpatient study reported potential interactions in 76.2% of prescriptions.
The engineering lesson is important:
DDI detection is a rules-and-knowledge problem, not a text-generation problem.
We therefore don't want:
Prescription → LLM → "Looks safe"
We want:
Prescription
│
▼
Structured medications
│
▼
Deterministic rule evaluation
│
├── DDI
├── Contraindication
├── Dose constraint
└── Missing information
│
▼
Clinical finding
│
▼
Doctor review

Medication Adherence Is a Communication Problem Too

Medication adherence is also not explained by a single factor such as language.
WHO-SAGE India data analysed in a published study found 48.62% non-adherence among people with any morbidity, rising to 62.48% among people with multimorbidity.
A 2026 systematic review and meta-analysis of Indian evidence in type-2 diabetes found pooled medication non-adherence of approximately 48% in studies using MMAS-8, although estimates varied substantially between studies.
This makes patient communication an important part of the system.
A prescription should not end at:
Metformin 500 mg BD
The patient may need:
Metformin 500 mg
Take 1 tablet in the morning
and 1 tablet in the evening
with food.
And potentially in:
Tamil
Hindi
Telugu
But there is another safety principle here:
We should not allow a generative model to invent medical instructions.

Our Architecture

ClinicoTrace therefore uses a layered architecture:


Why Amazon Bedrock?

We use the model for interpretation, not clinical authority.
Amazon Bedrock provides managed access to foundation models through AWS APIs. AWS recommends the  bedrock-runtime  endpoint for new applications.
For ClinicoTrace, the model's job is something like:
"Patient has diabetes.
Continue metformin 500 twice daily.
Start amlodipine 5 mg once daily."
into:
{
"conditions": [
{
"name": "Type 2 Diabetes Mellitus"
},
{
"name": "Hypertension"
}
],
"medications": [
{
"name": "Metformin",
"strength": "500 mg",
"frequency": "BID",
"route": "oral"
},
{
"name": "Amlodipine",
"strength": "5 mg",
"frequency": "OD",
"route": "oral"
}
]
}
The critical design decision is what happens after this JSON is produced.
We don't ask the model:
"Is this prescription safe?"
Instead:
AI-generated structure
│
▼
Schema validation
│
▼
Deterministic evaluator
│
▼
Safety findings

The Deterministic Safety Engine

The core safety engine is deliberately boring.
That's a feature.
A simplified version of our architecture looks like:
def evaluate_prescription(patient, medications):
findings = []

for i, drug_a in enumerate(medications):
for drug_b in medications[i + 1:]:
rule = DDI_RULES.get(
canonical_pair(drug_a.name, drug_b.name)
)

if rule:
findings.append({
"rule_id": rule["id"],
"severity": rule["severity"],
"message": rule["message"],
"evidence": rule["evidence"]
})

findings.extend(
evaluate_contraindications(patient, medications)
)

findings.extend(
evaluate_dose_limits(patient, medications)
)

return {
"status": determine_status(findings),
"findings": findings
}
Our rule repository is conceptually structured like:
DDI_RULES = {
frozenset(["drug_a", "drug_b"]): {
"id": "DDI-0231",
"severity": "moderate",
"message": "Potential interaction detected.",
"action": "Review before authorization"
}
}
This gives us something an LLM cannot provide reliably:
repeatability.
Given the same patient state and the same medication set:
Input A → Finding X
Input A → Finding X
Input A → Finding X
There is no temperature parameter.
There is no creative interpretation.
There is no hallucinated recommendation.

Why We Use the National Formulary of India

We wanted the clinical rules to be grounded in an Indian prescribing context rather than creating an arbitrary list of rules.
The National Formulary of India (NFI) is published by the Indian Pharmacopoeia Commission and is intended as an authoritative guide for prescribing, dispensing and administering medicines. The IPC lists NFI 2021 as the current edition.
The NFI's purpose is to promote rational use of medicines and provide guidance to healthcare professionals including clinicians, pharmacists and nurses.
Our rule pipeline is therefore designed around:
NFI / validated clinical references
│
▼
Rule normalization
│
▼
Machine-readable rules
│
▼
Deterministic evaluator
│
▼
Explainable finding
This is an important distinction:
We don't put the NFI into a prompt and ask an LLM to "reason over it."
We convert applicable rules into structured, versioned logic that our evaluator can execute deterministically.

AWS Strands Agents: Where Agentic AI Fits

During Bharat Builds, we also worked hands-on with AWS Strands Agents, exploring:
  • Agent loops
  • Tools
  • Hooks
  • Skills
  • Steering
  • Session management
  • Multi-agent workflows
  • Evaluations
The important architectural insight for ClinicoTrace was that agentic orchestration and clinical safety don't have to be the same layer.
For example, an agent can orchestrate:
Doctor Input
│
▼
Extraction Tool
│
▼
Normalization Tool
│
▼
Safety Evaluation Tool
│
▼
Authorization Tool
But the agent doesn't get to redefine what constitutes a safety violation.
A simplified Strands-style workflow can look like:
from strands import Agent

agent = Agent(
tools=[
extract_clinical_data,
evaluate_safety,
get_patient_instructions
],
system_prompt="""
You orchestrate the clinical workflow.

Never make or invent clinical safety decisions.
Always call the deterministic safety evaluator
before presenting a prescription for authorization.
"""
)

result = agent(
"Process the doctor's clinical note for patient P-1024."
)
The tool boundary is important.
The agent can invoke:
evaluate_safety(...)
but the implementation of  evaluate_safety()  remains deterministic.

AgentCore for the Deployment Boundary

For production-oriented agent deployment, we designed around Amazon Bedrock AgentCore Runtime.
AWS describes AgentCore Runtime as a secure, serverless environment for deploying and running AI agents or tools. It supports frameworks including Strands and provides isolated sessions.
The current AgentCore workflow supports a code-based agent using frameworks such as Strands and deployment through the AgentCore CLI.
Conceptually:
agentcore create
agentcore dev
agentcore deploy
agentcore invoke
This gives us a clean separation:
Local development
│
▼
Strands Agent
│
▼
AgentCore Runtime
│
▼
Production agent workflow
The agent runtime therefore becomes an orchestration boundary rather than the location where clinical truth is defined.

Fine-Grained Authorization with Cedar

Healthcare workflows have another problem:
Not everyone should be able to do everything.
For example:
Doctor → AUTHORIZE prescription
Pharmacist → DISPENSE medication
Nurse → VIEW administration schedule
Billing → VIEW diagnosis
Instead of scattering authorization checks throughout application code:
if (user.role === "doctor") {
// ...
}
we designed the application around Amazon Verified Permissions and Cedar.
AWS Verified Permissions externalizes fine-grained authorization from application logic and uses Cedar policies to evaluate a principal, action, resource, and context.
A simplified Cedar policy:
permit (
principal,
action == Action::"AuthorizePrescription",
resource
)
when {
principal.role == "Doctor"
};
Another:
permit (
principal,
action == Action::"Dispense",
resource
)
when {
principal.role == "Pharmacist"
};
The application asks:
Can this principal perform this action
on this resource?
rather than embedding the authorization decision inside every business function.
AWS describes this as a way to decouple authorization logic from application business logic.

Voice Input with Amazon Transcribe

A doctor shouldn't have to type a complete structured clinical record.
Our intended workflow is:
Doctor speaks
│
▼
Amazon Transcribe
│
▼
Transcript
│
▼
Clinical extraction
Amazon Transcribe supports Indian English, Hindi, Tamil and Telugu, although language-specific feature support differs.
That makes it particularly relevant to our target environment.
The important architectural decision is that transcription is not clinical interpretation.
Transcribe answers:
"What was said?"
Our extraction layer answers:
"What structured clinical entities are present?"
The safety engine answers:
"Do our deterministic rules identify a safety issue?"
And the doctor answers:
"Should this prescription actually be authorized?"

Regional Patient Communication

Once the clinician has authorized the medication regimen, we generate a patient-facing representation.
We use structured templates such as:
{
"medicine": "Metformin 500 mg",
"dose": "1 tablet",
"frequency": "twice daily",
"timing": "with meals",
"duration": "30 days"
}
Instead of translating arbitrary generated medical prose, we translate validated instructions.
Amazon Translate supports languages including Tamil and Telugu, with Hindi also supported in the service's language catalog.
The pipeline becomes:
Validated prescription
│
▼
Structured instruction
│
▼
Patient-friendly template
│
▼
Amazon Translate
│
▼
Tamil / Hindi / Telugu
This is safer than:
Raw prescription → LLM → translated medical advice
because the translation layer isn't responsible for deciding the medical regimen.

Storage and Application Infrastructure

Our production architecture uses the following AWS components:
Layer
AWS service
Why
Identity
Amazon Cognito
Application authentication
Foundation models
Amazon Bedrock
Clinical information extraction
Agent framework
Strands Agents
Agentic orchestration
Agent runtime
AgentCore Runtime
Production agent execution
Authorization
Verified Permissions + Cedar
Fine-grained policy decisions
Voice
Amazon Transcribe
Doctor voice input
Translation
Amazon Translate
Regional-language instructions
Compute
AWS Lambda
Serverless backend workloads
Object storage
Amazon S3
Audio/images/clinical artifacts
Relational data
Amazon RDS PostgreSQL
Patients, encounters, findings
Infrastructure access
AWS IAM
Service/resource permissions
Observability
Amazon CloudWatch
Logs and operational monitoring
Web deployment
AWS Amplify
Next.js application deployment
The key idea is not to use AWS services simply because they are available.
Each service has a bounded responsibility.

The Most Important Design Decision

The most important part of ClinicoTrace isn't actually the AI.
It's the boundary around the AI.
We designed the system so that:

This means the model can be wrong about an extraction.
The system can detect missing or invalid structured fields.
But the model doesn't get to invent a clinical safety policy.

What We Built During the Hackathon

For the hackathon, we implemented the workflow in Demo Mode so that the presentation remains deterministic and doesn't depend on live model endpoints.
The application contains:
src/
├── app/
│ ├── doctor/
│ ├── pharmacist/
│ ├── nurse/
│ └── admin/
│
├── engine/
│ ├── safetyEngine.ts
│ ├── extractionEngine.ts
│ └── authorizationEngine.ts
│
├── data/
│ ├── demoPatients.ts
│ ├── clinicalRules.ts
│ └── translations.ts
│
└── types/
└── clinical.ts
The advantage of this approach is that the clinical safety logic can be tested independently of the LLM.
For example:
const result = evaluatePrescription(
patient,
medications
);

if (result.status === "BLOCKED") {
return {
authorized: false,
findings: result.findings
};
}
The AI provider can subsequently be replaced without rewriting the safety engine.

Why This Architecture Matters Beyond the Hackathon

There is a temptation in healthcare AI to build:
User → Prompt → LLM → Answer
ClinicoTrace takes a different approach:
Human input
↓
AI interpretation
↓
Schema validation
↓
Deterministic clinical rules
↓
Policy authorization
↓
Human approval
↓
Patient communication
↓
Audit trail
This makes the system more auditable, testable and replaceable.
If we change the foundation model:
Claude → Nova → another model
the clinical safety rules don't change.
If we change the UI:
Web → tablet → hospital workstation
the safety engine doesn't change.
If we change the agent framework:
Strands → another orchestration framework
the clinical rules don't change.
That separation is the real architecture.

Our Takeaway

The biggest lesson from building ClinicoTrace is that responsible healthcare AI isn't about removing humans from the loop.
It's about removing unnecessary friction from the human workflow while making important decisions more explicit and verifiable.
Our architecture can be summarized in one line:
Let AI deal with ambiguity. Let deterministic systems deal with rules. Let clinicians deal with decisions.
That's the engineering principle behind ClinicoTrace.
AI extracts. Rules verify. Doctor decides. Patient understands.

References & further reading

Clinical workload and consultation time
Prescription quality and patient comprehension
Drug–drug interactions and adherence
Indian clinical reference
AWS
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article