Terminology layer — scope
Status: Draft scope (not yet approved for build) Date: 2026-07-27
Problem
Several fields need a closed set of choices so the same thing is always recorded the same way: nutrients, symptoms, available tests, conditions, substances. Left free-text they drift — "Vit D", "Vitamin D", "cholecalciferol", "D3" become four things that never join up, and a record that cannot join itself cannot be understood over time.
Some of this is already solved, twice, without being named:
- Value sets.
nutrients.tsimplements Directive 2002/46/EC Annex I/II as a closed vocabulary with EN/SK aliases (ADR-0008).allergens.tsdoes the same for Regulation 1169/2011 Annex II. - Crosswalks.
substancesmaps ATC → RxCUI / UNII / SNOMED with amatch: exact | approximatequalifier, cached per substance rather than per medication, treating rows as a deletable cache (ADR-0007).
What is missing is the layer between them, and a consistent rule for fields that have neither.
Vocabulary, not ontology
The requirement described is stable identifiers and closed choices. That is a
controlled vocabulary problem. An ontology is a different thing — formal
relations (is-a, part-of) and reasoning over them — an order of magnitude
more work, and only worth it for inference.
| Layer | Purpose | State |
|---|---|---|
| Value set | what is selectable in a given field | nutrients.ts, allergens.ts |
| Concept registry | system + code + version + display, one row per concept | missing |
| Crosswalk | mapping between systems, with confidence and provenance | substances |
Do not hand-author an ontology. The relations worth having already exist, curated, in SNOMED and LOINC panels; anything hand-written would be smaller and worse. And n=1 correlation over self-authored relations produces confident nonsense, which the vision explicitly forbids.
Per domain
| Domain | Source | Notes |
|---|---|---|
| Vitamins, minerals | EU Directive 2002/46/EC Annex I/II | Done. Closed by regulation — the ideal case: authoritative, maintained elsewhere, cannot drift. |
| Allergens | Regulation 1169/2011 Annex II | Done. |
| Substances | ATC, RxNorm, UNII | Done (ADR-0007). |
| Conditions | ICD-11 | icd11.ts exists. |
| Available tests | LOINC | loinc.ts exists via NLM. The vocabulary is ~100k terms; a person meets a couple of hundred. The deliverable is a value set, not the vocabulary. |
| Symptoms | SNOMED CT | See below. Preferred over ICD-11 Chapter 21 because medextract already emits SNOMED in its FHIR CodeableConcept, so the extraction bridge lands on matching codes with no crosswalk to maintain. |
SNOMED: two doors, both kept open
GPS (Global Patient Set) — openly available, CC BY-ND 4.0. Contains all International Edition identifiers, fully specified names, preferred terms in international English, and active/inactive flags. Explicitly excludes relationships, hierarchies, additional descriptions, reference sets, maps, extensions and translations. It is a vocabulary, not an ontology, by design.
Full International Edition — free of charge in Slovakia through the National Release Centre (NCZI; member since November 2009), under an Affiliate licence. Application submitted 2026-07-27.
What the full edition adds that matters here, in order of value:
- ECL over the hierarchy. Value sets become expressions that re-evaluate against each release, instead of hand-picked lists that rot. This is the strongest argument, and it removes the curation burden noted against LOINC.
- Synonyms. GPS gives one preferred term per concept; the full description set gives many. medextract parses Slovak, Czech, English and Latin-abbreviated text — for matching, this is close to the difference between working and not.
- Maps to ICD-10/ICD-11, which the record already uses for conditions: an authoritative crosswalk maintained by someone else.
- Reference sets, including IPS — a ready-made starting value set.
To confirm with NCZI while the application is open: whether a Slovak translation exists. Translations are managed per territory and distributed through the NRC, so it is not discoverable from outside. If it exists the display-label problem disappears; if not, the fallback below already covers it.
The licence boundary is an architectural constraint
An Affiliate licence covers use, never redistribution. GPS is CC BY-ND: redistributable only unmodified and attributed, which a generated subset in a repository is not.
This repository is published and the catalogue ships signed data files, so:
- Terminology releases are provisioned locally, never committed — the same
shape already used for
data/, the ŠÚKL mirror and the catalogue snapshot. Third instance of an established pattern, not a new problem. - No catalogue release may carry terminology-derived terms.
Enforced, not merely written down:
/terminology/is gitignored, anchored to the root so it cannot also swallowsrc/lib/terminology/.scripts/terminology-boundary.node-test.mjsfails if any RF2 release artifact is tracked, if anything underterminology/is tracked, or if the ignore rule stops being anchored.- The catalogue side is guarded by the existing contribution allowlist, which enumerates every transmissible field: a SNOMED term cannot reach a release without somebody adding a field to that list deliberately.
Whether a tracked file contains terminology-derived text is not decidable by pattern, and the check does not pretend otherwise.
Design
records store concept IDs ← own data, always present
display own Slovak labels ← own work, licence-independent
terminology content provisioned SQLite artifact ← gitignored, never published
value sets ECL when the full edition is provisioned
materialised list otherwise
- A
conceptstable: system, code, version, display, active, superseded-by.systemholds the canonical identifier of the code system, not a nickname — see below. - A
concept_mapgeneralisingsubstances: source system/code → target system/code, withmatchand provenance.substancesbecomes an instance of it rather than a special case. - Domain tables reference concepts instead of holding free text; each field declares its value set.
- Import codes, never hand-author them. This project has already produced
fabricated UNII identifiers that had to be discarded — the failure mode in
miniature, and the reason
load-unii.mjsis generated and tested. - Feature-detect at runtime. Full edition provisioned → hierarchy queries, synonyms, maps. Absent → GPS-level behaviour. Nothing in basic function may depend on any of it, exactly as the catalogue is optional today.
Name the system the way the standards do
A system column holding 'loinc' or 'snomed' is a local nickname. It works
inside this database and nowhere else, and every export then needs a translation
table that will be wrong for whichever system was added last.
Store the canonical URI instead — http://loinc.org,
http://snomed.info/sct, http://hl7.org/fhir/sid/icd-10,
urn:oid:1.2.840.10008.… for DICOM-registered systems — which is exactly what a
FHIR Coding.system carries, and what an HL7 Europe profile validates against.
The urn:oid: form (ISO/IEC 8824-1 identifiers in the RFC 3061 URN namespace) is
the fallback for any system with a registered OID but no published URI.
This is not a new idea and not a fashionable one: Sachinopoulou et al. (IEEE EMBS 2007) built an entire PHR on OID-tagged concepts for exactly this reason — unambiguous reference to external vocabularies without importing them. The mechanism outlived the architecture around it.
Half the pattern is already in the record by accident: imaging stores Study and
Series Instance UIDs, which are OIDs. Doing the same in concepts and
concept_map makes the two consistent.
Cost now is a column convention. Cost later is a data migration across every coded field plus a translation layer in the export path — and standards-shaped export is on the roadmap precisely because the vision commits to records a receiving system can read.
Storing an identifier the app resolved is ordinary use of the record. Publishing a list of identifiers with their terms is redistribution. The design keeps those apart by construction: IDs live in the record, terms live in the provisioned artifact, labels shown to the user are the project's own.
Open questions
- Version and supersession: codes retire and are remapped. ADR-0007 already met
this (ŠÚKL files pregabalin under
N03AX16, WHO moved it toN02BF02). What happens to a stored code whose concept is inactivated? - Does the Affiliate licence permit the derived Slovak labels to be published with the app, given they are the project's own translations of licensed terms?
- LOINC's own licence notice obligations if any LOINC-derived value set ships.
- Whether ECL is worth an evaluator in-app, or whether value sets are materialised at provision time and stored flat.
- Where DICOM Freeset fits, given the imaging work.
Not in scope
Authoring an ontology. Any inference or causal claim from a hierarchy. Shipping terminology content in the repository or in a catalogue release. Making SNOMED a prerequisite for the app to run.
Relationship to the other plans
This is the substrate under both inbound paths: medextract emits SNOMED and LOINC codes that need somewhere to land, and wearable signals needs a closed metric vocabulary for the same no-drift reason. Sequence it before either grows past a prototype, and after neither.