SHC vNext QR proof of concept

Principles for codecs and lifting

Rendered from PRINCIPLES.md in the repository.

How a codec, its model, and the path from an existing FHIR Bundle to a card should behave. Some of this is built; the last section says what is not yet.

The card

  1. FHIR out, never FHIR in the QR. A card holds a compact encoding of a narrow model. A sandboxed codec turns it into an ordinary FHIR Bundle on the receiving device. No server is involved.
  2. Developers target the model. Each codec publishes a small, typed input model. An app fills it in and never constructs FHIR.
  3. One encoding per dataset. The same facts always give the same bytes, and a decoder accepts only those bytes.
  4. Expected content is cheap; everything else is possible. Built-in tables make common data small. Escapes (any code from any system, card-declared series, components) mean the tables never limit what can be said.
  5. No artificial limits. A card is refused only when it is invalid or does not fit. Size and time get warnings at real outliers, with wide margins.

The FHIR contract

  1. Closed profiles, derived from the model. Each codec publishes FHIR profiles that allow exactly what its model can say and nothing else: every other element, and every extension, is constrained to zero. The profiles are generated from the model, so the two cannot drift.
  2. Conformant means it fits. A Bundle that conforms to the codec's profiles lifts into the model exactly, and the codec's output always conforms. Differences that carry no meaning (order, ids, how a reference is spelled) are written down as a list, and only those are ignored.
  3. Modifier elements are fixed or forbidden. Inside the profiles, every element that changes a resource's meaning has a fixed value or is not allowed, so none can be lost. Outside them, a resource with a modifier the model cannot hold is left out whole, never carried without it.
  4. Everything else is a reduction. A Bundle that goes beyond the profiles can still be lifted, by leaving out what does not fit. That is a loss, it is reported item by item, and it marks the card.

Reducing to fit

  1. A recorded value is changed only where that is defensible. Rounding a clinical measurement by an amount that matters clinically is never offered. Whether any coarsening is offered, for which measure and by how much, is decided measure by measure by the project owner, from the measurement's accuracy, the differences that matter clinically, and the bytes it saves. Until a kind is approved it is not offered.
  2. Leaving things out is the default way to fit. Named omissions: times of day, display text, explicit negatives, extra entries on a day, whole series, the oldest days. Omissions are losses too, and each kind is likewise approved by the owner.
  3. Loss is the sender's explicit choice. Nothing is left out silently. Each step states what a reader will no longer see.
  4. A plan, not a black box. The default takes the mildest omissions first. The result is a replayable list of steps, a frontier of alternatives, and hints a caller can set: never omit this, omit these first. When a record does not fit without omitting something central, the answer is that it does not fit.
  5. Sizes are measured. Every candidate is encoded to see what it saves. Nothing is estimated.

What the receiver can rely on

  1. Reduced is reduced. Any loss, at lifting or at fitting, marks the card.
  2. An absence must be interpretable. "Not recorded" and "explicitly none" are different and stay different. On a reduced card, an absence may also mean "not carried"; the card says only that it was reduced, not how.
  3. A reader never says more than the card does. Retracted, provisional or negated data is shown as such or not at all. Anything computed is labelled as computed.
  4. Damage is refused. A card that was cut or altered fails its check before any codec runs.

Not yet true

  • Principles 10 and 11: the owner has not yet reviewed the kinds of reduction. Until then the planner takes no step that changes a value, and the omission steps are provisional. The deployed site still offers value-changing steps, including one that rounds blood pressure, which is being withdrawn.