A standalone, zero-import, #![no_std] WebAssembly codec (0x00 || sha256(wasm)) for the HL7 FHIR R4 International Patient Summary (IPS) with 8,207 real official SNOMED CT IPS Free Set + EDQM + LOINC + IPS Absent/Unknown concepts embedded directly inside ips-summary.wasm.
- Module size:
243,809bytes (238.1 KiB) - Module SHA-256:
47dbedbe2b671d9751de871f22506ebc0120da1ea798a26f113c6da61df98e74 - CODEC-ABI v0.1 audit:
0violations,0imports,0floats,0SIMD/threads, link-time zero-panic proof (#![forbid(unsafe_code)]inips_summary_core) - Exports:
memory(max 16,384 pages / 1 GiB),shc_alloc,shc_decode,shc_encode
Embedded Official HL7 IPS Terminology Table (8,207 Unique Concepts)
Harvested and verified live via scripts/fetch-ips-vocab.ts against https://r4.ontoserver.csiro.au/fhir and https://tx.fhir.org/r4:
| Terminology / IPS Subset | Verified Concepts | Wire Index (Primary Section) |
|---|---|---|
SNOMED CT IPS Free Set — Problems (problems-snomed-ct-ips-free-set) | 5,622 | 13 bits |
SNOMED CT IPS Free Set — Procedures (procedures-snomed-ct-ips-free-set) | 690 | 10 bits |
SNOMED CT IPS Vaccines (vaccines-uv-ips ∪ vaccines-snomed-ct-ips-free-set) | 243 | 8 bits |
SNOMED CT IPS Medical Devices (medical-devices-snomed-ct-ips-free-set) | 72 | 7 bits |
| SNOMED CT Blood Group, Presence/Absence, Target Diseases, Pregnancy/Smoking | 56 | 6 bits |
SNOMED CT Common Medications (International Edition < 763158003) | 406 | 9 bits |
SNOMED CT Common Allergen Substances (International Edition < 105590001) | 243 | 8 bits |
SNOMED CT Allergy Reactions (allergy-reaction-gps-uv-ips ∪ curated < 404684003) | 55 | 6 bits |
EDQM Dose Forms (medicine-doseform) | 625 | 10 bits |
EDQM Routes of Administration (medicine-route-of-administration) | 85 | 7 bits |
| Core Clinical LOINC Lab, Vital, OB & IPS Document Observations | 181 | 8 bits |
HL7 IPS Absent/Unknown (absent-unknown-uv-ips) | 15 | 14 bits (global) |
| Global Deduplicated Total | 8,207 | 131.8 KiB compressed |
Storage & Lookup Design (rust/core/src/vocab.rs + vocab_data.rs):
- Codes: Sorted numeric SNOMED CT (
u64) and EDQM (u32) codes stored in 64-entry blocks with ULEB128 deltas (20.0 KB for 7,301 SNOMED SCTIDs — 2.74 B/code); LOINC and IPS Absent codes stored sorted for O(log N) binary search. - Displays: All 8,207 displays sorted lexicographically, blocked front-coded (block size 64), and compressed with 158-rule recursive Byte-Pair Encoding (BPE) (
229,924 Braw →159,168 Bfront-coded →89,421 Bfront-coded + BPE). - Performance: O(log N) binary search on encode, O(64) bounded non-recursive decompression on decode (<0.05 ms per concept, ~1.6–2.5 ms total per full IPS Bundle).
- Lossless Escape Hatch: Any
CodeableConceptoutside the 8,207 embedded concepts (e.g., RxNorm, ICD-10-CM, ATC, multi-coding concepts, custom displays, or text-only{ text: "..." }) falls back cleanly to lossless inline encoding.
Showcase Benchmarks (SHA-256 Content-Addressed Cards)
Each SHA-256 card carries the full content-addressed framing (0x00 + 32-byte sha256(wasm) + raw codec payload + 2-byte SHA-256 check = payload + 35 bytes):
| Sample | Resources | FHIR JSON B | DEFLATE B | Payload B | SHA-256 Card B | QR Version-L | Ratio vs FHIR | Ratio vs DEFLATE |
|---|---|---|---|---|---|---|---|---|
complex-multimorbid | 41 | 31,782 | 3,766 | 287 | 322 | V12-L | 98.7× | 11.7× |
pediatric-asthma | 18 | 13,757 | 2,332 | 161 | 196 | V9-L | 70.2× | 11.9× |
prenatal-summary | 18 | 14,938 | 2,387 | 148 | 183 | V9-L | 81.6× | 13.0× |
healthy-minimal | 9 | 6,777 | 1,512 | 74 | 109 | V6-L | 62.2× | 13.9× |
Output Structure (shc_decode)
shc_decode verifies strict canonical form (re-encoding the decoded model must match the input bytes bit-for-bit) and emits a deterministic minified HL7 FHIR R4 IPS Document Bundle (type: "document"):
- Entry 0:
Composition(LOINC 60591-5Patient summary Document,title: "International Patient Summary",subject: Patient/0,author: Organization/1, mandatory IPS sections48765-2Allergies,10160-0Medications,11450-4Problems with standard"No known ..."narrative +nilknownemptyReasonwhen empty, plus optional11369-6Immunizations,47519-4Procedures,30954-2Results,46264-8Medical Devices). Patient/0,Organization/1(and optional custodianOrganization/2).AllergyIntolerance,MedicationStatement(with containedMedicationcarrying EDQMformwhendoseFormis present),Condition,Immunization,Procedure,Observation(auto-categorized intovital-signsvslaboratory), andDevice+DeviceUseStatementresources.
Bounds & Safety
All allocations and counts are strictly bounded to guarantee total, deterministic termination on arbitrary untrusted byte streams:
- Input card: ≤ 4,096 bytes
given≤ 8,problems≤ 64,allergies≤ 64,medications≤ 64,immunizations≤ 64,procedures≤ 64,results≤ 128,devices≤ 32, escape codings ≤ 8, strings ≤ 512 bytes.
Build & Test
# Re-fetch official terminologies from Ontoserver & tx.fhir.org (or pass --gen to regenerate from snapshot)
bun codecs/ips-summary/scripts/fetch-ips-vocab.ts --gen
# Build ips-summary.wasm (requires rustup stable + wasm32-unknown-unknown)
bash codecs/ips-summary/rust/build.sh
# Run ABI audit, lossless round-trip, escape, fuzzing, and benchmark tests
bun test codecs/ips-summary/ips-summary.test.ts