FTR Specification
Please start a discussion or contact us if you have questions, feedback, or suggestions.
Introduction
FTR (FHIR Terminology Repository) it's a specification for repository layout, formats and algorithms to distribute FHIR terminologies as ValueSets.
Basic unit of distribution is a terminology file which contains expanded ValueSet and CodeSystems used for this ValueSet expansion. Expanded ValueSet is a collection of all Concepts that this ValueSet refers to. Concept must have at least two elements - system and code, but may contain other arbitrary properties.
Design of ValueSets is out of the scope of this specification.
FTR defines following entities:
Terminology File format — to store the content of a specific ValueSet version
Terminology File Patch format — changes between two ValueSet versions
Terminology File Tag format — named reference to a specific version and chain of patches
Tag Index format - index of all ValueSets with specific tag
Terminology File Update algorithm - how to update Terminology File via Tag Index & Terminology File Tag
Tag Sync algorithm - how effectively sync many Terminology Files
Terminology File Publish algorithm - how terminology file should be published
Repository Layout
FTR is a base directory containing module directories (fhir.r4
or loinc
). Each module directory contains vs/
directory with valuesets and tags/
directory with tag indexes.
Terminology File (TF)
Terminology File (TF) is a gzipped ndjson file. First lines of this file are CodeSystems and ValueSet resources and rest are Concept resources. Concept lines must be sorted lexicographically by {{system}}-{{code}}
pattern. JSON must be in the canonical JSON format, i.e. sorted keys and no white-spaces to guarantee reproducible SHA256 hash of files with same content. Terminology File name should follow this pattern vs.{hash}.ndjson.gz
, where hash is a SHA256 hash of gzipped file content.
Terminology Patch File (TFP) & Diff Algorithm
Diff Algorithm
If you have two versions of Terminology Files you can generate patch file (TFP) in one run with following algorithm:
c1.code&system < c2.code&system
and c1.code&system > c2.code&system
means you should compare those strings lexicographically.
Terminology Patch File
Terminology Patch File (TPF) is a gzipped ndjson file. The first line of this file is a JSON object containing the name of the ValueSet for which this patch file was created, and the rest are JSON objects with operations describing how to get a new version of the term file and the contents of the Concept resource.
TPF contains only 3 types of operations:
add
— adds new conceptupdate
— update existing concept propertiesremove
— remove existing concept
Terminology Patch File sample
ValueSet Tag File (VST)
ValueSet Tag File is gziped ndjson file. Where first line is a hash of latest version of ValueSet and the rest is pointers to patch files. It is used to calculate the effective patch between non-adjacent versions.
Tag Index File (TI)
Tag index file is a table of all valueset with specific tag and their actual hashes sorted by valueset name. It is designed to quickly check if anything has changed in the tag and calculate a bulk patch plan.
Client can save last tag index. When client want to check "that something changed" it can compare saved tag index with current tag-index. When tag-indexes are not equal, client can load index file and using previous VS hashes discover which VS should be updated. To update VS client load VST and search for patches to be applied to client version of VS or client may choose just load full version referenced in VST.
Tag Index File Sample
Terminology File Update Algorithm
Tag Sync Algorithm
Terminology File Publish Algorithm
To publish TF under specific tag.
generate TF
check it does not present in current repo - upload it
check tag file of this VS pointing to this version
when not
generate patch file from latest version
update TFP with new hash and migration
update TI file and it's hash file
Last updated