1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// SPDX-FileCopyrightText: Cadasto B.V.
// SPDX-License-Identifier: BUSL-1.1
//! The FHIR `Coding.system` an openEHR terminology id is written as
//! (feature `openehr`).
//!
//! FHIR R4 `Coding.system` is a `uri`, "the identification of the code
//! system that defines the meaning of the symbol in the code"
//! (<https://docs.rs/fhir-types/0.1.108/fhir_types/r4/coding/struct.Coding.html>).
//! openEHR names a terminology by a short identifier, "typically a value
//! like `"snomed_ct"` that is mapped elsewhere to the full URI identifying
//! the terminology" (openEHR BASE Release 1.1.0, Foundation Types,
//! `TERMINOLOGY_CODE.terminology_id`), taken from the US National Library
//! of Medicine UMLS list (openEHR RM Release 1.1.0, Support IM, Terminology
//! Package, Terminology Identifiers). [`fhir_system`] is that mapping:
//!
//! - `local` is the system of the archetype the code is defined in,
//! [`archetype_local`];
//! - an identifier of [`OPENEHR_NAMES`] is the URI it names;
//! - an identifier that is itself an absolute URI is its own system;
//! - any other identifier has no known system, and no coding is written
//! for it.
//!
//! The version part of a terminology id, "Version of this terminology, if
//! versioning supported, else the empty string" (openEHR BASE 1.1.0,
//! `TERMINOLOGY_ID.version_id`), is the FHIR `Coding.version`, "the version
//! of the code system which was used when choosing this code" (FHIR R4
//! `Coding.version`), only in the form the code system's versions take.
//! [`fhir_version`] is that rule.
use LOCAL_TERMINOLOGY_ID;
use ArchetypeId;
use IdError;
use Url;
use crateehn;
/// The base of the system URI of each archetype's local terminology, which
/// the archetype id completes.
///
/// No openEHR, HL7 or FHIRconnect text defines a URI for an archetype's
/// local codes, so this is a code system of the component's own, under the
/// `ferrobridge.eu` domain of the product that publishes the component, one
/// per archetype, described at this base on the FerroBRIDGE site:
/// an archetype id "denotes a single archetype", and two versions of an
/// archetype "are actually two distinct archetypes" (openEHR BASE Release
/// 1.1.0, Base Types, Archetype Identifiers), so two archetypes' `at0003`
/// are two concepts under two systems.
// NOTE: no specification governs this: our own design, a URI under a domain Cadasto B.V. holds.
pub const ARCHETYPE_LOCAL: &str = "https://ferrobridge.eu/fhir/CodeSystem/archetype-local/";
/// The openEHR terminology identifiers this crate maps, each with the FHIR
/// system URI of [`ehn`] it names.
///
/// Each identifier is one the openEHR texts give: `SNOMED-CT` and `LOINC`
/// from the UMLS table of the Support IM, and `ICD10`, the WHO
/// classification, from the Identification Package of BASE 1.1.0, which
/// also says `ICD10AM` is a distinct terminology, so it is not mapped.
pub const OPENEHR_NAMES: = ;
/// Returns the system URI of the local terminology of `archetype`.
///
/// # Errors
///
/// The [`IdError`] of an archetype id that is not one by the `archetype_id`
/// syntax of openEHR BASE, whose characters are letters, digits, `_`, `-`
/// and `.`, all of them unreserved in a URI.
/// Returns the FHIR system URI of the openEHR terminology named `name`, a
/// `local` code read in `archetype` when one is given.
///
/// `None` is a terminology with no known system: `local` with no archetype,
/// and an identifier neither [`OPENEHR_NAMES`] holds nor an absolute URI.
///
/// # Errors
///
/// The [`IdError`] of [`archetype_local`] for a `local` code read in an
/// archetype id that is not one.
/// The base of the URI a SNOMED CT version is written as, which an edition's
/// module id completes, optionally followed by `/version/` and a release.
///
/// The vendored HL7 packages write a SNOMED CT version this way: HL7 France
/// Core 2.2.0 includes SNOMED CT in its value sets at the version
/// `http://snomed.info/sct/900000000000207008/version/20260201`
/// (`ValueSet.compose.include.version`), and HL7 Europe Laboratory Report
/// 2.0.0 expands its value sets at `http://snomed.info/sct/900000000000207008`
/// (`Parameters` `exp-params`, `system-version`).
pub const SNOMED_CT_VERSION: &str = "http://snomed.info/sct/";
/// Returns the FHIR `Coding.version` of a code of `system` recorded under
/// the openEHR terminology version `version_id`, or `None` when none is
/// written.
///
/// - An empty `version_id`, a terminology with no version, writes none.
/// - For SNOMED CT ([`ehn::SNOMED_CT`]), a version is a URI naming an
/// edition ([`SNOMED_CT_VERSION`]). A `version_id` in that form is written
/// as recorded; any other, such as a release date alone, names no edition,
/// so no faithful translation exists and none is written.
/// - For the HL7 systems of [`ehn`], a version is dot-separated digits, as
/// the MyHealth@EU Master Value Sets Catalogue 9.1.0 includes them
/// (`4.0.0` in `eHDSIAdministrativeGender` and `eHDSIPersonalRelationship`,
/// `5.0.0` in `eHDSIRoleClass`, `2.0.0` in `eHDSIObservationCategory`). A
/// `version_id` in that form is written as recorded, and any other is not
/// one of the system's versions, so none is written.
/// - For any other system, no vendored text shows a version form, and
/// `version_id` is written as recorded.
/// Returns whether `version` is a SNOMED CT version URI: an edition's module
/// id under [`SNOMED_CT_VERSION`], optionally followed by `/version/` and a
/// release.
/// Returns whether `version` is digits separated by dots.
/// Returns whether `text` is one or more ASCII digits.