SHC vNext QR proof of concept

Proof of concept for SMART Health Cards vNext

Rich clinical records in one QR code

A phone camera scans a compact code, and a small sandboxed WebAssembly codec runs on the receiving device to rebuild a complete, standard FHIR R4 Bundle. No server holds the data, and no network is needed to read it.

The platform separates QR transport and card framing from domain-specific compression so dozens of clinical use cases can ship their own codecs and visualizations. Featured codec #1 (cycle-log) proves the approach on longitudinal menstrual-cycle and daily health tracking: 17 to 1,976 bytes in a card expanding to 3,087 bytes to 1.15 MB of FHIR JSON. Everything on this site is synthetic sample data, and cards are unsigned.

Featured codec #1 · cycle-log — the copper-iud sample record: copper IUD with temperature and mucus charting, a year.

  1. The QR codeVersion 13-L69 modules a side; a symbol of this version and level holds 428 bytes of data
  2. The card321 bytes1 byte naming codec #1, 318 bytes of codec input, 2 bytes of check
  3. Expanded on the phone254,126 bytesof FHIR JSON, 694 entries, 792 times the card

Open this record from its card Browse codecs

The button opens the universal viewer with the card's digits, as a scan does; pointing a phone camera at the code opens the same record. The digits sit after the “#” in the link, so the browser never sends them to a server. To start from the sample instead, with the other sample records listed beside it: the copper-iud sample record in the viewer.

How it works

Three layers, shown here with the copper-iud record.

  1. The QR code holds a link and digits

    The text is https://joshuamandel.com/shc2-poc/#shc2:/ followed by 780 decimal digits. QR codes store digits compactly (three digits in ten bits) and every scanner and camera app returns them unchanged, which raw binary does not survive. Every 17 digits spell 7 bytes.

    https://joshuamandel.com/shc2-poc/#shc2:/00370089663546541247180290425195081649911781146256007916301695871409… 712 more digits

    For a link that is pasted or sent rather than scanned, the same card has a shorter text form: shc2:/b/ followed by base64url. For this record the link is 471 characters against 821 with digits. A QR code always uses the digits.

  2. The digits are a card: a codec reference, the codec's input, a check

    The first byte names the codec by its registry number: 01 is codec 1, cycle-log. The next 318 bytes are that codec's input. The last 2 are a check, the first 2 bytes of the SHA-256 of everything before them: a card that was cut short or altered is refused before any codec runs (it slips through about 1 time in 65,536). There is no other header. A codec that is not registered is named instead by a zero byte and the SHA-256 of its module.

    01 50 98 36 ee 44 ad 57 d0 ea 9c a0 8d d4 3a 9d dc 38 42 71 … 299 more bytes … 02 3e

  3. The codec is a sandboxed WebAssembly module that emits FHIR

    cycle-log is 353,251 bytes of WebAssembly with 0 imports: it cannot reach the network, storage, the clock or the page, only compute. It exports memory, shc_alloc, shc_decode, shc_encode. The receiving page hands it the card and gets back a FHIR R4 Bundle, the same bytes on every engine.

    For this card: 694 entries, 684 Observation, 8 MedicationStatement, 1 Patient, 1 Procedure. One of them, a single day's fact:

    {
      "fullUrl": "resource:4",
      "resource": {
        "resourceType": "Observation",
        "status": "final",
        "code": {
          "coding": [
            {
              "system": "https://joshuamandel.com/shc2-poc/CodeSystem/cycle-log",
              "code": "menstrual-flow",
              "display": "Patient-reported menstrual flow category"
            }
          ]
        },
        "subject": {
          "reference": "resource:0"
        },
        "effectiveDateTime": "2025-12-08",
        "valueCodeableConcept": {
          "coding": [
            {
              "system": "https://joshuamandel.com/shc2-poc/CodeSystem/cycle-log",
              "code": "flow-light"
            }
          ]
        }
      }
    }

    On the sending side, an app never builds FHIR or bytes by hand. It fills in the codec's input model, 25,709 bytes of JSON for this record, and calls the codec's encoder, shc_encode. Each dataset has exactly one encoding.

The code is the record

Reading a card needs no server and no network: everything is in the code, and the codec runs on the receiving device. That matters where connectivity is limited or filtered, and for sensitive data, which never passes through anyone's server. A SMART Health Link is the other way to share a record from a QR code; the two suit different jobs.

This form compared with a SMART Health Link
QuestionA card in the QR code (this site)SMART Health Link
Where the data isIn the code itselfOn a server, encrypted; the code holds the link and the key
How muchWhat one QR code holds: at most 2,875 bytes of card with this site's link in frontAny amount
Server and networkNone, when shared or when readA server to host it, and a network when it is opened
Update or revokeNot possible: a code that has been shown can be read for goodThe sharer can update it or revoke it

A clinician can read these codes with a dedicated app on their own phone that understands shc2:/. Such an app needs no web browser and no link: it scans the code, ignores anything in front of shc2:/, runs the same codec and gets the same FHIR Bundle this site's viewer shows, because the mapping from card to FHIR lives in the codec, not in this website. The link in front of the digits and the web viewer exist so that a phone without such an app can still open a code with its camera. This site does not include a native app; that is a statement about the design, not a product here.

Explore the platform

Viewer
Universal shc2:/ card decoder with codec-specific visualization plugins. Open a scanned card, paste a FHIR Bundle, or inspect any of Codec #1's twenty sample records: power-tracker, copper-iud, pcos, minimal, perimenopause, combined-pill, near-empty, own-vocabulary, wellness-diary, calendar-only, smart-cup-hmb, wearable, post-ablation, vitals-follow-up, timestamped, bp-twice-daily, med-doses, bbt-exclusions-and-fever, text-tags, offline-displays.
Codecs
Directory and registry of WebAssembly codecs: registered Codec #1 (cycle-log) plus 6 SHA-256 extension codecs (ecg-strip, cgm-agp, ips-summary, dental-chart, pgx-cpic, vision-rx).
Scan test
Test what your phone can scan: codes from Version 15 to 40 that link back to a page which checks every digit arrived.
Developers
Build SHC vNext QR into an app: encode an input model, pack a card, draw the QR code, and decode any registered codec. Includes a runnable browser example.
Reference
Architecture & data flow, Principles, Design, Codec interface (ABI), llms.txt, and research notes.
Get the source
Everything on this site, the Rust codec source, and the test suites, under the MIT licence.

Featured codec #1: cycle-log tools

cycle-log codec hub
Input model, 38 FHIR R4 profiles, CodeSystem, wire format, sample files, and all cycle-log tools in one place.
Import a calendar
Turn the period days in a calendar export (.ics) into a cycle-log card and QR code. The file never leaves your browser.
Squeeze lab
Trim span, toggle categories, and watch the real card size, QR version and byte breakdown react live.
How a card is packed
One real cycle-log card taken apart, from the QR digits down to the bit cost of each day's facts.
Fit a FHIR Bundle
Lift any FHIR Bundle into CycleLog with a per-resource report, and reduce it step by step to fit a chosen QR version. Experimental.

SHA-256 extension codecs: six domains in one QR

Beyond registered Codec #1, any clinical domain can publish a zero-import WebAssembly codec addressed directly by 0x00 || sha256(wasm) — no central registry approval required. Each codec below opens directly in the universal viewer from its real QR card.

ECG Rhythm Strip SHA-256 · 0x00

ecg-strip · Lossless 1D signal codec (LPC + Golomb-Rice)

10-second PhysioNet ECG (3,600 samples at 360 Hz) → 1,848 B (Version 32-L), lossless FHIR SampledData where DEFLATE exceeds QR capacity.

WASM: 42,742 B Samples: 8 SHA-256: b37fa36f53…

Open live demo Codec hub

CGM & Ambulatory Glucose Profile SHA-256 · 0x00

cgm-agp · Lossless time-series + deterministic FHIR summary synthesizer

14-day CGM (4,019 readings, 2.32 MB FHIR) → 1,895 B (1,225×) with deterministic AGP summary metrics.

WASM: 43,565 B Samples: 4 SHA-256: f57b5d846f…

Open live demo Codec hub

International Patient Summary (IPS) SHA-256 · 0x00

ips-summary · Embedded 8,207-concept SNOMED CT IPS + EDQM + LOINC dictionary

8,207 SNOMED CT IPS, EDQM & LOINC terms in WASM → 322 B (Version 13-L, 41 FHIR resources).

WASM: 243,809 B Samples: 4 SHA-256: 47dbedbe2b…

Open live demo Codec hub

Dental & Periodontal Exam SHA-256 · 0x00

dental-chart · 2D spatial anatomical differential coding (32 teeth × 6 sites)

32-tooth periodontal & restorative exam (72 FHIR resources, 197 kB) → 248 B (Version 11-L, 792×).

WASM: 38,290 B Samples: 4 SHA-256: 5068296198…

Open live demo Codec hub

Pharmacogenomics (CPIC Panel) SHA-256 · 0x00

pgx-cpic · Embedded CPIC knowledge base + deterministic CDS expansion

14-gene CPIC diplotype panel & CDS alerts (33 kB FHIR) → 92 B (Version 7-L, 358×).

WASM: 44,707 B Samples: 4 SHA-256: 8a0e73db85…

Open live demo Codec hub

Vision Prescription SHA-256 · 0x00

vision-rx · Bit-packed clinical quantizer (quarter-diopter optical fields)

Bit-packed eyeglasses & contact lens Rx (70–200 B, down to Version 6-L) → FHIR VisionPrescription.

WASM: 29,823 B Samples: 4 SHA-256: 7e6ae21f82…

Open live demo Codec hub

Compare all 6 extension codecs

Codec #1 (cycle-log): twenty sample records, measured

Each record below was encoded by the codec, decoded back, and checked byte for byte against a FHIR Bundle built independently from the same data. QR versions are for the full text, this site's link and the digits, at error correction level L (the level SMART Health Cards 1.x uses) and M. SMART Health Cards 1.x treats Version 22 (949 bytes in this form) as the practical limit; Version 40, the largest QR code, holds 2,875 bytes.

7 of the 20 records need more than Version 22 at level L: power-tracker (Version 26), own-vocabulary (Version 30), wellness-diary (Version 32), timestamped (Version 33), bp-twice-daily (Version 32), med-doses (Version 26), text-tags (Version 28). The three records marked “own vocabulary” keep most of their data in an app's own codes and scales, which a card can carry but must spell out once. DEFLATE, the usual general-purpose compression, fits minimal (Version 19), near-empty (Version 15) and calendar-only (Version 23) into a QR code and none of the others.

Bytes for each record, on a logarithmic scale: the card, DEFLATE of the FHIR JSON, and the FHIR JSON itself. The shaded band is what one QR code holds with this site's link in front; the lines mark Version 22 (949 bytes) and Version 40 (2,875 bytes). The table below has every value.
Card, QR code, FHIR and DEFLATE sizes for each sample record
RecordCard, bytesQR at LQR at MFHIR JSON, bytesEntriesDEFLATE, bytesDEFLATE QR at LFHIR ÷ card
power-trackerpower tracker, fertility awareness then trying to conceive 1,259Version 26Version 30 1,146,6502,840 29,127fits none 911×
copper-iudcopper IUD with temperature and mucus charting, a year 321Version 13Version 15 254,126694 6,422fits none 792×
pcosirregular cycles suggestive of PCOS 298Version 12Version 14 161,707494 5,092fits none 543×
minimalminimal tracker with gaps: bleeding yes/no only, no flow amounts 34Version 4Version 5 19,44861 725Version 19 572×
perimenopauseperimenopausal transition 713Version 19Version 22 499,2491,434 13,101fits none 700×
combined-pillcombined oral contraceptive, 21/7, pill log 260Version 11Version 13 216,342630 5,896fits none 832×
near-emptynear-empty: breastfeeding, one bleed logged 17Version 4Version 4 3,0879 458Version 15 182×
own-vocabulary own vocabularyapp with its own scales and codes throughout 1,624Version 30Version 34 849,0782,225 23,658fits none 523×
wellness-diary own vocabularymigraine and wellness diary, few bleeding facts 1,873Version 32Version 37 762,8322,416 24,334fits none 407×
calendar-onlybleeding days from a calendar export, with completeness statements 55Version 5Version 6 25,12269 1,036Version 23 457×
smart-cup-hmbheavy menstrual bleeding measured with a smart cup, fibroids, myomectomy 347Version 13Version 15 284,412818 7,514fits none 820×
wearablewearable-centric: nightly skin temperature deviation and sleep 704Version 19Version 22 282,126744 7,488fits none 401×
post-ablationafter endometrial ablation: no bleeding, ovarian cycles continue 474Version 16Version 18 238,831615 6,407fits none 504×
vitals-follow-uphypertension follow-up while tracking cycles: heart rate, weight, blood pressure 728Version 19Version 23 486,7141,045 12,635fits none 669×
timestampedan app that timestamps every entry: habitual times, DST, a trip abroad, symptoms at their own times 1,976Version 33Version 38 560,2721,285 18,362fits none 284×
bp-twice-dailyhome blood pressure morning and evening, with heart rate and a daily antihypertensive 1,830Version 32Version 36 729,7551,323 19,996fits none 399×
med-dosesendometriosis & heavy bleeding with exact medication doses and wearable skin temperature exclusions 1,259Version 26Version 30 499,6861,213 13,547fits none 397×
bbt-exclusions-and-feverfertility awareness BBT with disturbed/excluded readings and separate febrile body temperature (LOINC 8310-5) 612Version 18Version 20 305,043709 8,009fits none 498×
text-tags own vocabularytext-only tags and custom scales without synthetic code-system URIs 1,410Version 28Version 32 743,3512,187 22,357fits none 527×
offline-displaysclinic record with offline displays and plain-text labels on standard escape codes 733Version 19Version 23 491,5111,037 12,468fits none 671×

DEFLATE here is raw DEFLATE (no zlib header) at zlib's highest level, 9, computed when this site is built, on the minified FHIR JSON, and written into the QR code the same way as a card. The squeeze lab and the table on the Design page use the browser's CompressionStream, which takes no level and gives zlib's default, 6: 1% to 17% more bytes for these records (copper-iud: 7,469 against 6,422). Card bytes include the 1-byte codec reference and the 2-byte check. Version 25 holds 1,215 bytes and Version 30 holds 1,669 in this form.

Status and limits