MedConnect Layer by Layer
A walk up the MedConnect stack: what the schema, utility, resource, tool, API and UI layers each contribute to protecting patient data, and why.
Ask who may open a patient's record and you will get a tidy list of roles. Ask why they are opening it and the room goes quiet. MedConnect, the book's healthcare case study, makes that second question a real input to its security design. It also treats the browser with the suspicion most systems keep for strangers.
Role-based checks have a blind spot: a role describes a person, not the task in front of them. In the case study, authorisation lives in the Tools layer and weighs the caller's role together with the purpose of the request. Consent is checked a layer lower, in Resources, before data is fetched at all.
The placement is sensible. A Tool is where a business operation exists as a named thing, so it is the first layer that can say what the caller is trying to do. Lower layers only move data around; they have no idea why.
Here is the same idea in a different setting, a university records system:
type Role = "advisor" | "instructor" | "bursar";
type Purpose = "advising" | "grading" | "billing";
const permitted: Record<Role, Purpose[]> = {
advisor: ["advising"],
instructor: ["grading"],
bursar: ["billing"],
};
export function authoriseRead(ctx: { role: Role; purpose: Purpose }) {
if (!permitted[ctx.role].includes(ctx.purpose)) {
throw new Forbidden(`${ctx.role} may not read for ${ctx.purpose}`);
}
}
A bursar who opens a transcript "to see how the student is doing" is refused, even though the login is perfectly valid. One caution from general practice rather than from the book: the purpose must come from the operation being invoked, not from a field the client fills in. Otherwise you have built a checkbox.
Once purpose travels with the request, every access record can say why as well as who. The book's description of the MedConnect request path includes a step where the purpose is validated, which is what makes its audit chain more than a list of names.
The case study pairs layers with controls that suit their altitude. The pattern worth stealing is simple: place a check at the layer that already holds the information it needs.
The payoff is diagnostic. When a control is missing, you know which folder to open. When a reviewer asks "who owns this check?", the answer is a layer, not a meeting. (The book also ties each control to the regulation it targets. I leave that mapping to the book and to your own compliance team.)
The most interesting design choice is an omission. The UI takes no part in MedConnect's lineage record, the trail that builds up as a request descends through the layers. The browser runs on a device the organisation does not control, so whatever it says about itself counts as a claim, not as evidence.
That reasoning generalises well beyond healthcare. Evidence should be produced by code you operate. If a user clicks "show full value", the click proves nothing; the server-side request that follows is what you can stand behind. In the case study, revealing a masked value is handled as an audited request for exactly that reason.
A cheap way to apply it: when you do collect client-side events, label them as reported rather than observed, and keep them out of any trail you would hand to an auditor. For where the browser's authority ends, see the UI/API boundary.
Good security design in a layered system is mostly a question of placement and trust: put every control where it has the facts, and refuse to treat any untrusted tier as a source of truth. For the structural view of the same system, read MedConnect layer by layer. For the trail these decisions feed, see designing an audit trail, and for the API-layer half of the story, the authentication and authorization sublayer.