Build diary Day 7

Day 7: A Demo for People, a Signature for Machines

Built with Giridhar, Venkatakrishna and Preetha

Building the Caladrius PHR with agents Part 7 of 15

16 min read

Hand-drawn sketch of a phone showing a demo, a signed key at an open door, and a sealed health message with a tick beside a crossed-out one

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.

4 November pulled in two directions at once, and both turned out to matter.

One direction was outward, towards people. We put up a public demo that anyone could open without an account, with a guided tour in five languages, and we showed what Personalised Intelligence could look like on top of a PHR: biomarker trends, a mental-health check, preventive cardiology and a Lung Health module.

The other direction was outward too, but towards machines. The PHR started joining UHI, the Unified Health Interface, as a patient-side app. Before a single search can go out on UHI, the app has to sign its requests exactly the way NHA’s gateway checks them. Day 7 is the day we got that signature right, and built the proof that will show it.

In between, the locker work from Day 6 came back with a lesson I hadn’t expected. Seventeen PRs merged: ten into dev, seven promotions to QA, and 74 commits, many of them on UHI branches that would merge the next day.


1. Fixing the fix: when “the same identifier” means different documents

On Day 6 we stopped a health locker from storing the same record twelve times. Part of the fix was to recognise a document by the facility, the visit and the document’s own identifier (the FHIR Composition identifier), and to erase later copies.

Overnight, a QA check found that the clean-up had erased 18 distinct records across four visits, leaving each of those visits with only its invoice. The cause was outside our code. Our counterpart hospital system, our own AI Studio acting as the hospital, serves documents that were uploaded to it with their originator’s Composition identifier, and in the test data 22 different documents in those visits shared one value: a sample id from a published example. A diagnostic report, an immunisation record, a prescription and a wellness record looked like “the same document” to our key, and the clean-up kept only the earliest.

The fix took the identifier out of identity altogether:

The PR states the trade-off plainly, and I agree with it: storing a near-duplicate is a nuisance; erasing a record by mistake is a harm. When in doubt, keep both.

An earlier follow-up, just after midnight, handled the links. Before the clean-up, the locker (which also acts as a facility for the person’s uploads) had linked hundreds of care contexts to the consent manager that now pointed at erased copies, and ABDM publishes no “unlink”. A requester asking for one of those got nothing at all. Each erased copy now records which live record superseded it, and serving resolves through that pointer, with every consent rule (live, unexpired, artefact granted, the right HI type and date range) applied to the record it resolves to. A record erased because its consent was revoked or expired is still never served.

The locker keeps the consent artefacts it has been granted and reuses them, so it doesn’t ask the person again for every new record. A QA trace showed the flaw: a hospital linked a new visit, the locker got the notification, and it fetched under the newest artefact it held, which had been granted before that visit existed. The artefact named 51 care contexts, but not the new one, so the hospital sent nothing for it and the prescription never arrived.

The rule now: reuse a held artefact only when it names every care context concerned. For a subscription event, that’s the care contexts the event names; for a pull, the care contexts linked after the artefact was fetched. Otherwise the locker asks for consent afresh. With auto-approval on, that’s granted at once; with it off, it waits for the person. The care contexts are read from the encrypted artefact in memory; nothing new is stored in clear.

Two smaller ABDM fixes went in that evening, and both show the debugging style that works with agents:

That second pattern is worth stealing: when you don’t know the shape of an answer, log its shape, not its content. You get the diagnosis in one round trip and never put personal data in a log.

3. Personalised Intelligence, as a demo

The PHR’s job under ABDM is to hold and share records. The reason people will open it every week is what it does with them. Day 7 put a first version of that in front of people, in the demo build only, on synthetic data:

Feature What it shows
Biomarkers 138 markers in 14 groups: lab values plus vitals, including a calculated BMI and smoking status
Prescription Tracker Medicines over time
Mental Health Check GAD-7 and PHQ-9
Preventive Cardiology A first-visit assessment
Patient Journal The person’s own notes
Lung Health A capability unlocked per person and ABHA address by a code: lung profile, inhalers with dose counters, breathing exercises, technique check, symptom diary, flare-ups, an action plan, an assessment, and an air-quality badge

A few design decisions carried more weight than the screens:

App permissions became the last onboarding step, once per device and all optional, with a Settings list behind a small registry. The location permission needed a matching Permissions-Policy change in nginx, in the same PR.

The air-quality badge is the one part of Lung Health that touches the real API, and it’s a good example of how a small feature becomes S1 the moment it involves location:

The PR listed what was not ready, and I want that habit everywhere: the free air-quality source isn’t licensed for commercial use, so production needs a licence or an Indian public source; the privacy notice needs an entry for the outbound call; the clinical wording is sample text; four of the five languages are machine-drafted; and the consent wording is a draft for legal review. A demo can go up with those open. A release can’t.

4. Type, text size and a name to be called by

A batch of front-end work merged just after midnight and is easy to underrate.

Text that fits. The standard text size now follows the screen width, clamp(1rem, 5.35vw, 1.4375rem): about 19 px at 360 px wide, 23 px at 430, never below the browser’s base. It’s in rem, so the person’s own browser text-size setting still counts. The size steps were rebased to 80/90/100/110%, and saved preferences migrate to the nearest step that doesn’t shrink text. The top bar fits on one line: the title and description pick their own size within floors, and on a phone some actions become icons.

A second font family, with serif headings, self-hosted (so no CSP change), falling back to Noto Sans per glyph for the Indian scripts.

A nickname. Home now greets the person by the name they choose. It sounds trivial; it’s an S1 change, because it’s personal data:

Building it found a latent bug: a profile sync from ABDM deleted every stored name for the patient. It now spares the nickname, and the legal-name read ignores it.

5. A public demo, built so it can’t leak into the app

The demo build had existed since Day 0 for internal walkthroughs. Day 7 made it public, on our QA site, with production unchanged. The design goal was that the demo can never contaminate the real app, and the real app can never leak into the demo:

Late that night, one more owner decision went into AGENTS.md: the demo is labelled on its Welcome page and in its footer, not with a tab over every screen. Writing that sentence into the rules file meant no agent would “helpfully” add the tab back a week later.

The guided tour has 12 plain-language steps (Home, Records, Link, Consents, Auto-approval, Lockers, Scan and share, Pay, Cally, Profile, Settings, finish) in English, Hindi, Tamil, Telugu and Marathi. One detail I liked: the type checker requires exactly 12 steps per language, so a translation can’t silently fall behind. The tour card has its own colours and a “Guided tour” label, so it reads as separate from the app. It explains and navigates; it never changes data.

6. UHI: signing a request the way the gateway checks it

UHI is the network that lets a patient-side app (an EUA, end-user application) discover and book services from providers: hospitals empanelled under PM-JAY, blood banks, transplant centres, Jan Aushadhi outlets, doctors, ambulances. It works by signed messages through a gateway. If your signature is wrong, nothing else matters, so step U-1 of the new UHI section of our integration plan was the signature alone.

That evening I wrote a new owner rule into AGENTS.md: every UHI API detail comes from NHA’s UHI plugin (uhi-integrators-assistant: its service skills, commands and the documentation server), never from memory or general knowledge of the protocol UHI is built on. Every constant, rule and required string is cited next to the code, in { value, source } modules. Where the plugin is silent or contradicts itself, it goes into the contract’s Open section instead of being guessed.

What landed in packages/abdm:

That third request is my favourite kind of test: a proof isn’t a proof unless it also shows the wrong thing failing. A signature check that accepts everything would pass a test that only sends good requests.

Building it surfaced three disagreements in NHA’s own material, and the agent recorded each as a question for NHA rather than picking silently:

Disagreement What we do until NHA answers
NHA’s Node sample signs differently from its gateway (newline-joined, a different header form) Follow the gateway; the sandbox proof will settle it
The schema requires message times with a zone; the prose example has none Follow the schema, send +05:30
The schema types two participant ids as URIs but describes them as domain names The local schema test relaxes the URI format for those two fields only

The test keys are the public vector from RFC 8032, so no real key ever entered the repository, and the secret scan on the commit came back clean. The src/uhi code finished at 100% line coverage.

7. The evening: Find care on branches

By 8 pm the signing work was committed (the PR merged just before midnight), and the agents moved straight on to the first UHI screens: the database tables, the search routes, the signed callback that receives answers, and four search screens. Those commits sit on 4 November in the log, stacked branch on branch, but they merged on the 5th, so they belong to the next post.

  Day 7
PRs merged into dev 10
Promotions to QA 7
Commits (including UHI branches) 74
Migrations record supersession, air-quality feature, content-only identity re-key
New owner rules in AGENTS.md UHI only from NHA’s UHI plugin, cited (the UHI rule merged just after midnight); demo labelled, no tab over every screen

8. What I learned on Day 7

Next, Day 8 (5 November): Find care goes live in the app: PM-JAY hospitals, blood stock, transplant centres and generic medicines, then booking a doctor and asking for an ambulance, and a new near-black theme called Charcoal.

The team behind Day 7

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

Cally: taxonomy and intent (Giri)

Day 7 widened what Cally will be asked about. The Personalised Intelligence demo added biomarkers, a prescription tracker, a mental-health check, preventive cardiology, a journal and Lung Health, and the guided tour has a step for Cally. For Giri’s area, the design decisions matter more than the screens: capabilities are per person and per ABHA address, and every feature has its own consent, withdrawn when the feature is switched off.

So the same question can be in scope for one family member and out of scope for another, and a topic leaves the scope when its consent does. The pull request also said the clinical wording is sample text, which the taxonomy has to treat as not yet ready for a real answer.

Development, infrastructure and go-live (Krishna)

Day 7 was ten pull requests into dev, seven promotions to QA and 74 commits, many on stacked UHI branches that merged the next day. The public demo went up as a separate build on our QA site, with production unchanged: no service worker, no requests to the API, and a bundle guard that fails the real build if the demo’s invented people appear in it.

UHI signing landed in packages/abdm, with a key script that never prints or overwrites a key, and a proof script that expects a good request accepted and a tampered or expired one refused. On go-live, the air-quality pull request listed what a release would still need: a licence, a privacy-notice entry and legal review.

Narrative and personas (Preetha)

Day 7 was the most narrative day so far. The public demo has two invented personas and no login, says “Nothing you do here is saved or sent anywhere” in five languages, and offers a guided tour of 12 plain-language steps, with the type checker making sure no translation falls behind. The demo is labelled on its Welcome page and footer, not with a tab over every screen.

Home now greets the person by a nickname they choose, up to 10 visible characters counted so Hindi or Tamil names aren’t cut mid-letter. Text now follows the screen width, and serif headings arrived. One honest gap: four of the five languages in the Personalised Intelligence demo are machine-drafted, and need a person’s review.

Product and technology direction (Manish)

The decision of the day was document identity. I agreed with the trade-off the pull request stated: storing a near-duplicate is a nuisance, erasing a record by mistake is a harm, so identity is the content only. I also set the consent rule that the locker reuses a held artefact only when it names every care context concerned.

Two owner rules went into AGENTS.md: every UHI detail comes from NHA’s UHI plugin, cited (the UHI rule merged just after midnight), and the demo is labelled without a tab over every screen. Writing them into the rules file is how I make sure the next agent follows them, not just this one.

Further reading

See all 16 parts