Case study · AYUVA

Medical reports, in words patients understand. Without playing doctor.

AYUVA is a UK healthcare navigation app that helps patients organise their records and understand their care. For First500days, I built its AI layer: four APIs that triage symptoms, map out care journeys, explain medical reports in plain language and answer questions, all behind guardrails that never let the AI play doctor.

Role
AI Engineer, freelance
Client
First500days, for AYUVA
Timeline
Aug 2026 – present
Scope
The AI layer, end to end

One report, explained

What the patient uploads

Serology report

Test
C-reactive protein (CRP)
Specimen
Serum
Result
20.90 mg/L
Reference range
0 – 6.0 mg/L

What AYUVA explains

Your CRP result is 20.90 mg/L, which is above the laboratory's stated range of 0 to 6.0 mg/L.

C-reactive protein20.90 mg/LHigh
C-reactive proteinSerumReference range

Ask your doctor: What could cause my CRP to be raised?

01The problem

Patients get the paperwork, not the meaning.

Navigating healthcare means reading documents written for clinicians and making decisions about where to go next. AI can help with both, but only if it knows its limits.

Reports are written for doctors

Lab results, discharge notes and scans are full of abbreviations and reference ranges. Patients get the paper, not the meaning.

Patients don't know where to go

Is this self-care, a GP visit or A&E? Getting it wrong either clogs the system or delays real care.

Health AI can't overstep

The product must never diagnose or advise on treatment, and emergencies have to escalate every time, no matter what the model says.

First500days was building AYUVA's apps and backend. They needed an AI layer that their team could integrate quickly, that would answer reliably in a fixed format, and that would stay safe by design. I owned that layer, from the API contracts to the evaluation.

02What I built

Four AI capabilities, each with a safety rule built in.

Each one answers in a fixed, typed format the app can rely on, and each has a guardrail that holds even when the model gets it wrong.

Symptom navigation

Turns a description like "fever for five days" into extracted symptoms, an urgency level and the right place for care.

Emergency phrases like chest pain force an A&E recommendation, whatever the model says.

Care journey

Turns the triage result into a step-by-step pathway, from self-care to specialist or emergency care.

Steps come back as structured data, never as free text the app has to parse.

Report interpreter

Reads lab reports, prescriptions, scans and discharge notes, including multi-page PDFs and photos, and explains them in plain language.

Values can only be marked normal, high or low. No diagnosis, ever.

Assistant

Answers questions about using AYUVA, like booking an appointment or finding a lab report.

Clinical questions get a fixed redirect to a professional, without calling the model at all.

03How it fits

A separate AI service behind the client's gateway.

The client's backend keeps logins, patient records and audit logs. My service only generates answers, so patient data never lives in AI code.

  1. 01

    App

    Patient uses the AYUVA web or mobile app

  2. 02

    Gateway

    Backend checks the login, loads the record and logs every AI call

  3. 03

    AI service

    My FastAPI service builds the prompt for one of four tasks

  4. 04

    Structured output

    The model must answer in a fixed, typed schema

  5. 05

    Guardrails

    Safety rules and the disclaimer are applied in code

Every response carries the same medical disclaimer, and every AI call is logged by the gateway. The safety rules live in code, not in the prompt.

04My role

The whole AI layer. From contract to cost report.

I designed, built, tested and documented the AI service, and wired it into the client's backend.

AI APIs
4
live report calls passed
55/55
average report latency
6.3s
average cost per report
1.1¢
test coverage
82%

AI microservice

Built

The single place where every AI answer in AYUVA is produced.

  • Four internal APIs, each with its own prompt, schema and safety rules.
  • Structured outputs, so every response matches the backend's types exactly.
  • A fallback model, and per-task model choice through configuration instead of code changes.
  • Stateless by design: the backend owns patient data, the AI service only generates.
  • Python
  • FastAPI
  • Pydantic
  • OpenAI

Safety guardrails

Built

Rules that hold even when the model is wrong.

  • Emergency phrases override any triage to emergency care.
  • Clinical questions are redirected before the model is ever called.
  • Report values are limited to normal, high or low, with no room for a diagnosis.
  • The same medical disclaimer is attached to every single response.
  • Python
  • Keyword rules
  • Typed enums

Report reading

Built

Handles the messy reality of what patients upload.

  • Reads photos and scanned PDFs, including several images or pages in one request.
  • Glossary terms and three suggested questions to take to the doctor.
  • Tested on a public medical document dataset of 50 images and 54 PDFs.
  • Vision OCR
  • PyMuPDF
  • Multi-page PDFs

Contracts & gateway integration

Contributed

Let the client's team build in parallel from the first week.

  • Schemas that mirror the backend's types one to one, exported as contracts for the app and database.
  • Wired the backend gateway to the AI service behind an internal secret.
  • JSON Schema
  • NestJS
  • TypeScript

Evaluation & cost telemetry

Built

Real numbers on quality, speed and cost before launch.

  • Token usage and cost recorded for every model call.
  • Live test runs for each API, written up per capability.
  • A stakeholder report with results, samples, cost and time analysis.
  • pytest
  • Telemetry
  • Reports

05Key decisions

Five calls that shaped the work.

01/Collaboration

Contracts before code

1:1

schemas match backend types

The problem
The app, backend and database teams were waiting on the AI layer before they could build anything that used it.
What I did
In the first days I fixed the exact shape of every request and response, mirrored the backend's types one to one, and exported them as JSON schema contracts.
What happened
The client's team built and mocked against stable contracts while I implemented the AI behind them.

02/Safety

Safety can't depend on the model

≤5 ms

clinical redirect, no model call

The problem
A language model can be talked into giving medical advice, or can underrate a real emergency.
What I did
I put the critical rules in code around the model. Emergency phrases force emergency care, clinical questions are redirected before any model call, and the disclaimer is attached to every response.
What happened
Crushing chest pain is routed to A&E every time, and clinical questions are turned away in a few milliseconds.

03/Architecture

A separate service behind the gateway

0

patient tables owned by the AI

The problem
Patient data, logins and audit logs belong in one place, and AI code shouldn't touch them.
What I did
The AI runs as its own stateless service. The client's backend stays the gateway for auth, storage and audit, and calls the AI service over an internal, secret-protected route.
What happened
Models can be swapped per task through configuration, and the AI never owns patient data.

04/Quality

Test on documents patients actually upload

55/55

live calls passed

The problem
The first test set of scanned forms didn't look like real medical paperwork.
What I did
I replaced it with a public medical document dataset, added vision OCR for photos and multi-page PDFs, and ran every file through the live service.
What happened
All 55 live calls passed, and prescriptions correctly came back with no values to flag.

05/Cost

Know the bill before launch

1.1¢

average cost per report

The problem
Healthcare startups need predictable costs, and AI usage can quietly grow.
What I did
I logged tokens and cost for every model call, measured them across the full test run, and projected monthly spend at different volumes.
What happened
About 1.1¢ per report on average, half of the input tokens served from cache, and a clear monthly projection for the client.

06Results

Measured, not assumed.

55/55

live report interpretations passed, across labs, scans, prescriptions and multi-page PDFs

Run against the running service over real HTTP, not mocked, using a public, MIT-licensed medical document dataset. Every response returned the right structure, the disclaimer, and an explanation.

average report latency, 10.4s at p95
6.3s
average cost per report
1.1¢
prescriptions correctly returned no values to flag
13/13
triage levels produced a care journey
4/4
test coverage, model calls mocked in CI
82%

07Stack

The right tool for each layer.

AI service
PythonFastAPIPydanticuv
AI
OpenAI Structured OutputsVision OCRPyMuPDF
Integration
NestJSTypeScriptMongoDB
Quality
pytestruffDocker

08Reflection

What I took away.

In health AI, the guardrails are the product.

The model is the easy part. The work that mattered was everything around it: contracts the team could build against, rules that hold when the model is wrong, and real measurements of quality, speed and cost.

AYUVA is still being built. The AI layer is integrated with the backend, and the next step is taking it from a tested service to patients in production.

Let's work together

Building something that has to be exactly right? Let's talk.