Build diary Day 8

Day 8: Find Care, Book a Doctor, Call an Ambulance

Built with Giridhar, Venkatakrishna and Preetha

Building the Caladrius PHR with agents Part 8 of 15

14 min read

Hand-drawn sketch of a hospital under a magnifying glass, a calendar with a check-in tag, and an ambulance with a quote, joined by dashed arrows

The PHR is built by a small Caladrius team (Giri, Krishna, Preetha and me) working with AI agents; each post ends with what the day meant for each of our areas.

Up to Day 7, everything the PHR did was about records: creating an identity, linking what hospitals hold, deciding who may read it, keeping it in a locker. Those are the ABDM milestones P1 to P4, and they’re what the app is certified against.

On 5 November the app learned to help a person find and book care. Through UHI, the Unified Health Interface, a person can now search PM-JAY empanelled hospitals, blood stock, transplant hospitals and Jan Aushadhi generic medicines and outlets; book a physical consultation with a doctor; and ask an ambulance provider for a quote. Nine PRs merged, eight into dev and one promotion to QA, but they carried more new surface than any day since Day 0.

The day ended with something much smaller that people noticed more: a near-black theme called Charcoal.


1. Four PRs stacked like floors of a building

UHI arrived as a stack of branches, each built on the one below:

#176 UHI request signing                      (merged on Day 7)
  └─ #178 Find care: tables, routes, signed callback, four search screens
       ├─ #181 UHI settings on QA, permission text, the UHI plugin rule
       └─ #182 a stub UHI gateway and the Find care functional tests
            └─ #183 Book a doctor and every catalogue search
#186 Ambulance booking, phase 1                (separate, the same day)

Stacking is how agents can keep moving while review happens: the next floor is built while the one below is still being inspected. It has a cost, and every PR in the stack says so in its first lines (stacked on #178; retarget to dev once it merges). The agent that built each floor also did the retargeting as the floors below merged. Without that sentence at the top of each PR, a stack becomes a puzzle for whoever merges it.

2. Find care: search only, nothing personal

The first four UHI services (PM-JAY hospitals, blood banks, NOTTO transplant hospitals and Jan Aushadhi) are search only. UHI offers no booking for them. The design rule for all four is that nothing personal leaves the system.

On or off, never half. UHI needs four settings: our subscriber id, our public key id, our private key and the URL where answers come back. All four or none. With none, the patient routes answer 503 UHI_NOT_CONFIGURED and the callback route isn’t mounted at all. In production the private key must load as Ed25519 at startup or the API refuses to start.

The routes. The app posts a search, then reads it back as answers arrive. There are reference lists for states and districts (LGD codes) and the code tables each service uses. A per-account rate-limit tier sits on top of the global limits.

The callback is where the risk is. UHI is asynchronous: the gateway acknowledges the search, then providers answer later by calling us. Anyone on the internet can call a public endpoint, so on_search handles a request in a strict order:

  1. Keep the raw body.
  2. Check the signature against the UHI registry before parsing anything.
  3. Reject replays.
  4. Acknowledge at once, then store the answer.
  5. Fail closed at every step.

Location is personal data. A location search sends the point rounded to two decimal places, about 1 km, rounded by the API before anything else happens; the exact point is never stored, logged or sent. The filters and every received catalogue are encrypted at rest. Answers are purged after 24 hours by default, are never shown past 48 hours whatever the setting (one of the plugin’s go-live checks), and never past the answer’s own time-to-live. Logs and audit carry ids and statuses only, never filters, locations or catalogues.

The browser never talks to UHI. It never holds a key or a raw UHI payload. The API signs, sends, receives and turns each provider’s catalogue into a simple result card. So the content security policy didn’t change at all.

3. Four screens, and the plugin as the referee

The screens follow a design canvas made beforehand: a Find care tile on Home, a hub, and one search per service. They render results as they arrive, because UHI answers trickle in from several providers, with a “so far” state, timeouts, empty results, Try again and client-side paging. Each of those behaviours is a rule in the plugin, cited where it’s used.

The strings NHA requires are used word for word, each with its source next to it: the line telling the person to call ahead, the note that blood stock is “indicative”, and showing the transplant coordinator’s phone first.

The plugin also decided what we couldn’t build yet, and the PR lists those departures from the design rather than hiding them:

Where the plugin is silent or contradicts itself, the item went into the contract’s Open section: the registry lookup’s body (the schema requires a nested object, the example is flat), which registry field carries the signing key, and NACK codes, of which none are published. When the sandbox answers, those items close. Until then nobody, human or agent, has to wonder whether a value was invented.

In the demo build, the four services return invented results, every one marked “(demo)” with a “[Demo address]” and an obviously fake phone number. Synthetic data that looks synthetic is a rule from Day 0, and it’s easy to forget when the data is a list of hospitals.

4. Ready for the sandbox before the sandbox is ready

Our UHI sandbox registration was raised but not yet issued. Two PRs made sure that wouldn’t hold anything up.

QA settings (#181). The QA deploy now forwards the UHI key as a secret and the ids as variables. The deploy checks validate the shape of each value (the key must be one line of base64 PKCS#8; the ids may not contain a separator character) and never print a value. The agent tested four cases with dummy values: off, partial (refused), full, and malformed (refused). The upshot: turning UHI on in QA is a secrets change, not a code change.

The same PR corrected the location permission text in all five languages. It used to say the location was “never stored”. A Find care search keeps its rounded area, encrypted, for at most a day, so “never stored” had become untrue. A privacy statement that’s slightly wrong is worse than one that’s slightly long.

A stub UHI gateway (#182). Until the real one was reachable, the functional tests needed something that behaves like it, strictly:

The Find care spec runs on both the API build and the demo build. It walks Home → Find care → each service, and checks the arriving results, the NHA notices, empty and silent searches, and the gateway’s refusal. UHI has no NHA case ids in our PHR catalogue, so the spec names none, and the NHA gate scripts are unaffected.

A stub is only as good as its strictness. One that accepts any signature tests nothing; this one rejects what NHA’s plugin says the real gateway rejects, using the same signing module, so a signing regression fails CI.

5. Book a doctor: the first flow that sends patient details

Everything so far sent nothing about the person. Book a doctor (UHI Physical Consultation) can’t work that way: the clinic needs to know who is coming. That made #183 the most carefully specified PR of the day.

The flow. The person searches nine ways (the nine doctor searches in NHA’s catalogue), picks a slot, reads the clinic’s five terms, confirms and gets a check-in PIN. The visit then moves through started, completed or no-show; it can be cancelled with a reason; and the person can message the clinic. A completed visit lands in My Records as a linked facility and care context, the same shape P2 uses, so the rest of the app needs to know nothing about UHI.

What is sent, and from where:

The one fix found in review says a lot about how these PRs were checked: the Review screen listed address and email among the details being sent, but the API sends neither. The screen now lists exactly what is sent. A consent screen that over-states is still a consent screen that’s wrong.

The PIN is the check-in secret, so it’s treated like one: there’s no PIN column in the database. It’s held in process memory for at most two minutes, handed over once, and re-requested from the clinic if needed. The agent also checked it’s in no browser storage.

The callbacks (on_init, on_confirm, on_status, on_update, on_cancel, on_message) must each be signed by the order’s own clinic, with its registry key. Another valid UHI participant can’t move your booking.

Every catalogue search. The same PR added the rest of the searches NHA’s catalogue lists: PM-JAY by hospital name and by speciality (from NHA’s speciality API, allow-listed and cached, with nothing personal sent), and blood stock by state and district using the blood bank’s own region codes. That last option is data-driven: it stays hidden until the region list is imported, and a code not in the list is a 400.

Late the evening before, the agents closed the gaps from the plugin’s go-live checklist that the first version had left open: honouring each answer’s time-to-live with the 48-hour ceiling, going back to the slot list when a clinic says a slot is no longer held, and showing the PM-JAY nodal officer’s contact and whether a hospital is government or private. One small commit in that batch is a good sign of the guard rails working: the new order SQL was rewritten “in full, no ${} in statements”, because the SQL rule in our static analysis gate (one of our security-by-design rules) rejects interpolated statements outright.

6. Ambulance, phase 1: a quote, not a dispatch

The ambulance PR was deliberately small: search, then ask one provider for a quote. The UHI plugin defines no confirm, status or cancel for ambulances, so we built none.

7. Small things people notice: the KYC chip and Charcoal

Two front-end PRs closed the day.

KYC status on the ABHA card. Home showed the profile status (“KYC verified” or “self-declared”) as a separate row. It now sits inside the ABHA card as a chip, in on-card white so it reads in both themes against the ABHA brand gradient, with “Link ABHA number” directly under the card for a self-declared profile. These are NHA cases (the KYC indicator, the link prompt and the card itself), so CI picked them out to be re-run on demand.

Charcoal. Our dark theme was blueish. I asked for a near-black option, a third choice beside Light and Dark. The first version used warm neutrals; a second PR later that morning made it darker, on Material Design’s dark-theme values:

Token Value Contrast
Base #121212  
Surfaces (elevation overlays) #1e1e1e, #272727, #2e2e2e  
Text, 87% #e0e0e0 12.6:1
Muted text, 60% #a0a0a0 6.4:1

How it’s wired matters more than the colours:

The same PR deleted the animated canvas backgrounds on Welcome, sign-in and registration. They were pretty, they cost battery on cheap phones, and nothing else used them.

8. What I learned on Day 8

Next, Day 9 (6 to 8 November): three days without a single merge, and the plans that came out of them: shared Caladrius platform packages, on the principle that apps share code, never runtime.

The team behind Day 8

The PHR is built by a small Caladrius team working with AI agents:

Cally: taxonomy and intent (Giri)

Day 8 had no Cally work, but it added a new family of things a person may ask for: find a hospital, check blood stock, book a doctor, get an ambulance. For the Cally taxonomy, which is Giri’s area, that is groundwork. The day settled the guardrails any request in this family would have to respect: a search sends nothing personal, a booking sends only the fields the server builds from the person’s own records, and an emergency gets one answer before any other: “Call 108”. It also drew a line between categories. Finding care is discovery; booking is a disclosure the person agrees to on a screen. A request that sounds like the first but needs the second has to be treated as the second.

Development, infrastructure and go-live (Krishna)

On the infrastructure side, which Krishna leads, Day 8 was about being ready before the sandbox was. UHI arrived as a stack of branches, each saying at the top what it sat on, so the merge order was never a puzzle. The QA deploy learned to forward the UHI settings, checking the shape of each value without ever printing one, so turning UHI on in QA became a secrets change, not a code change. A strict stub gateway, with keys generated at run time and nothing committed, let the functional tests run on both builds while our sandbox registration was still pending. Eight PRs went into dev and one promotion went to QA.

Narrative and personas (Preetha)

Preetha’s area is the person on the other side of the screen, and Day 8 met several of them: someone looking for a PM-JAY hospital or a generic medicine, a family checking blood stock, someone booking a visit, someone who needs an ambulance now. The wording carried much of the weight. NHA’s required lines are used word for word. The location permission text was corrected in all five languages once “never stored” had stopped being true. The Review screen now lists exactly what is sent, no more. Even the demo’s hospitals are written to look invented, marked “(demo)” with a “[Demo address]”. And the smallest change, the Charcoal theme, was the one people noticed.

Product and technology direction (Manish)

My decisions that day were mostly about what not to do. Search services send nothing personal, and the browser never talks to UHI, so the content security policy didn’t change. Ambulance stayed a quote, not a dispatch, because the plugin defines nothing more. Where the plugin was silent, the gap went into the contract’s Open section instead of a guess. And I asked for a near-black theme, on one condition I’d repeat for any visual change: it lives in the PHR’s tokens, changes only the neutrals, and leaves the shared design system and every other app untouched.

Further reading

See all 16 parts