Content-addressed (0x00 || sha256(wasm)) SHA-256 extension codec conforming to CODEC-ABI.md v0.1.
Encodes a complete 32-tooth adult periodontal and restorative dental examination (6-site probing depths, 6-site gingival margins, 6-site bleeding on probing, Miller mobility grades, furcation grades, active caries surfaces, and restorations/implants/endodontic findings) into 112–213 bytes (QR Version 8–10 at EC Level L, including the 33-byte SHA-256 codec header and 2-byte card check), expanding deterministically in zero-float, zero-panic #![no_std] WebAssembly into 66–75 rich FHIR R4 resources (137–197 KB of FHIR JSON).
WASM Artifact
| Property | Value |
|---|---|
| Binary | codecs/dental-chart/dental-chart.wasm |
| Size | 38,290 bytes (37.4 KiB) |
| SHA-256 | 5068296198af4824ac326e7f50718830b2552e5456a37518d7f1d26d76947335 |
auditWasm violations | 0 (0 imports, 0 floats, 0 SIMD/threads, no start function, max memory 16,384 pages) |
| Core safety | #![no_std], #![forbid(unsafe_code)], link-time zero-panic guard |
Measured Benchmarks (4 Clinical Showcase Samples)
| Sample | FHIR Resources | FHIR JSON (B) | Raw DEFLATE-9 (B) | Codec Input (B) | SHA-256 Card (B) | QR Version-L | Ratio vs FHIR | Decode Time |
|---|---|---|---|---|---|---|---|---|
healthy-adult | 66 | 137,187 | 3,912 | 112 | 147 | V8-L (49×49) | 933× | ~2–3 ms |
stage3-periodontitis | 72 | 196,513 | 5,186 | 213 | 248 | V10-L (57×57) | 792× | ~3 ms |
restorative-implants | 75 | 185,560 | 4,850 | 154 | 189 | V9-L (53×53) | 982× | ~2–4 ms |
caries-recall | 74 | 145,623 | 4,257 | 146 | 181 | V8-L (49×49) | 805× | ~2–4 ms |
(SHA-256 Card = 1 byte 0x00 + 32 bytes sha256(dental-chart.wasm) + codec input + 2 bytes SHA-256 check = codec input + 35 bytes.)
Compression Design: 2D Spatial Arch Differential Coding + Adaptive Range Coder
- Format version byte (
0x01) followed by a canonical 16-bit binary range-coded bitstream. - Metadata:
examDate(days since2000-01-01), optionalpatient(family, up to 4givennames,birthDatesince1900-01-01), optionalprovider.name, optionalnote(≤ 128 UTF-8 bytes) encoded via a 256-symbol adaptive UTF-8 segment-tree model initialized with an ASCII clinical-text prior. - 32-tooth status vector: Adaptive context split between wisdom teeth (
#1, #16, #17, #32) and non-wisdom teeth (#2..15, #18..31). - 2D Spatial Arch Walk for Probing Depths (
0..15 mm) & Gingival Margins (-10..+10 mm):- Sites are traversed in anatomically contiguous order across all four arch sweeps:
- Maxillary Buccal (
#1→#16: Q1DB→B→MB, Q2MB→B→DB) - Maxillary Lingual (
#16→#1: Q2DL→L→ML, Q1ML→L→DL) - Mandibular Buccal (
#17→#32: Q3DB→B→MB, Q4MB→B→DB) - Mandibular Lingual (
#32→#17: Q4DL→L→ML, Q3ML→L→DL)
- Maxillary Buccal (
- Consecutive deltas
d[i] - d[i-1]are coded with a truncated adaptive frequency model restricted to the exact legal range (0..15for probing,-10..+10for margin) conditioned on anatomical transition context (interproximal→interproximal,interproximal→mid,mid→interproximal) to capture the classic 3-2-3 gingival contour.
- Sites are traversed in anatomically contiguous order across all four arch sweeps:
- Depth-Conditioned BOP Coding: Bleeding-on-probing bits walk the same continuous arch, conditioned on
(probing_depth_bucket ∈ {≤3, 4–5, ≥6}, prev_bop). - Mobility, Furcation, Caries & Restorations: Furcation is conditioned on single- vs multi-rooted tooth anatomy; restoration kinds are conditioned on tooth status (e.g.
ponticonmissingteeth); surface bitmasks (M, O, D, B, L) omit the last bit when bits 0–3 are all zero. - Bijective Canonicality:
shc_decodeverifies that re-encoding the decoded chart reproduces the input bytes identically, rejecting trailing padding or non-canonical streams withMALFORMED.
FHIR R4 Output (shc_decode)
Emits a deterministic minified FHIR R4 Bundle (type: "collection"):
Patient(id: "0",fullUrl: "resource:0")- Optional
Practitioner(id: "1",fullUrl: "resource:1") - Deterministic zero-float Periodontal Summary
Observation(id: "perio-summary"): teeth present, missing, implants, sites probed, BOP % (1 decimal place), sites ≥ 4 mm, sites ≥ 6 mm, max probing depth (mm), active caries tooth count, and optional exam note. - Per charted tooth
N(Universal1..32), everyObservation.bodySitecarries SNOMED CT permanent tooth structure SCTID, ISO 3950 FDI (urn:iso:std:iso:3950), and ADA Universal tooth codings:tooth-<N>: Tooth status (present,missing,implant,unerupted,root-tip)perio-<N>: 6-site Periodontal Probing Depth (code: SNOMED736535008), withprobing-*,margin-*,bop-*,mobility, andfurcationcomponents when presentcaries-<N>: Active Dental Caries (code: SNOMED80967001) with affected surfacesrestoration-<N>-<idx>: Existing restoration / endodontic finding with optional surfaces
Build & Test
# Build dental-chart.wasm (requires rustup stable + wasm32-unknown-unknown target; uses wasm-opt if on PATH)
bash codecs/dental-chart/rust/build.sh
# Run full audit, round-trip, fuzz, and benchmark suite
bun test codecs/dental-chart/dental-chart.test.ts