Terminology ids and namespaces (again)

Following on from @SevKohler 's original question in the thread Terminology_id name list, we morphed into a discussion about namespaces, version ids and so on, see particularly @erik.sundvall 's post near the end. This is mostly SNOMED-specific.

Terminology pros can skip to the bottom :wink:

Background

A bit of SNOMED CT meta-terminology (doesn’t officially apply to other terminologies):

  • A module is a self-contained collection of Snomed components (hierarchies, related ref-sets) for some content scope (e.g. Swedish ref-sets + translation of international)
  • An Edition is a collection of module(s) and all semantic dependencies, i.e. modules containing hierarchies under which codes were defined in a local extension. An ‘edition’ is what you deploy in some production environment. An edition has to include a Module Dependency Ref Set, i.e. a full manifest of everything in it, including versions.
  • A Release is an Edition on a certain date, i.e. a particular list of modules and their versions. (On some other date, the same edition will be different.)
  • A module version id is a short-form ISO8601 date string, e.g. “20260630”.

Here’s a graphic showing the modules relevant to Region Stockholm and (bottom right) what a ‘Region Stockholm edition’ would consist of). This example would have equivalents in any country.

Following SNOMED and HL7, a coded term is supposed to be represented in data as 3 things:

  1. System: always http://snomed.info/sct, whichever module a code belongs to. An international, Swedish or Stockholm code therefore sits in the same system.
  2. Version: says which edition the code was taken from, as http://snomed.info/sct/[sctid]/version/[YYYYMMDD].
  3. Code: the concept’s SCTID. The module it belongs to can often be read from the namespace inside the SCTID, but only the concept’s moduleId is reliable, since concepts can be promoted across modules, and their original code does not change.

Suppose a Region Stockholm module were created inside Sweden’s namespace 1000052. A made-up but correctly formed ID would be 99991000052100. It breaks down as item number 9999, namespace 1000052, partition 10 (meaning an extension concept) and check digit 0.

So the System+Version URI for a Stockholm Edition based on that RS extension module would be: http://snomed.info/sct/99991000052100/version/20260630. (Just the module would be identified by http://snomed.info/module/99991000052100/version/20260630).

Note that a code originally created in the Stockholm Region or Sweden extension (and thus having either a Sweden or Region Stockholm module name space in its id) could be promoted to the international core. Its code doesn’t change - so those long codes with module ids for various countries etc, only indicate where the code originated, not what module it is in today.

Thus, when a coded term is created in data, the only reliable way to know what version of anything it was obtained from is to know the code and the Edition + version, i.e. what terminology release was being served in the runtime and/or design time (since some codes in data come from archetypes or templates, e.g. choice of BP measurement position or similar).

Editions change over time, so the same terminology concept id could will usually have been taken from different releases of an Edition, and maybe even different Editions say over a 5 year period (the latter if an org started out with just SNOMED Intl core, but subsequently deployed a national extension). Its meaning shouldn’t change in principle, but the answers inferencing or querying produce could be different. E.g. an extension might add a relationship between two international core concepts; to compute with that, something in the data needs to indicate that that extension was in use when the data item was created, if not, it might not even resolve if processed in a different institution or country.

Requirements

I’ll restate Erik’s requirements as I understand them in a summarised form:

  1. From a SNOMED CT code’s id, we can get back to what module it’s from (core, Swedish extension etc) but not what version.
    1. TB: not quite true; only what module it originally came from; it’s the Edition that counts
  2. For medico-legal and research reasons you always want to know which SNOMED Edition was either a) live deployed, for terms obtained from a running service (e.g. UI picklist) or b) used to make a template or archetype, if the term came from there (= informal value-set or hard-coded); ultimately we want to know what the full set of module+version making up the Edition in use
  3. A production environment can have an Edition consisting of multiple levels of extension. @erik.sundvall - I think your concern in this point was that both national and regional codes are then likely to occur mixed in a single patient’s data; the same concept code could occur in data with different terminology URIs (or namespace versions)
    1. TB: it can certainly have different editions visible in the version field
  4. For many queries and logical reasoning of actual instance data you actually don’t want to care about the difference between different modules, but rather treat SNOMED CT as one giant graph.
    1. TB: agree

So I think 2. and 4 are the concrete requirements.

What is needed in openEHR

So, what does this mean for openEHR coded term representation? How much do we care about Edition / version info?

If a terminology code in data is represented the openEHR way, i.e. something like “SNOMED-CT::373873005” (or equivalent openEHR CODE_PHRASE instance), inside a Composition committed on 2025-04-27, then what the “SNOMED-CT” really refers to is defined by the Edition of SNOMED CT deployed, that the code was served from (e.g. for building UI drop downs) and resolved against (e.g, to display “Pharmaceutical / biologic product” to a human); note that it doesn’t actually matter where the Edition was deployed, e.g. Karolinska UH or Lund UH as long as the Edition is well defined and accessible

In this approach, the string “SNOMED-CT::373873005” cannot on its own tell you what versions of anything were available in the environment where it was created.

There is more than one way to solve the problem…

Per-code

In openEHR, the RM class CODE_PHRASE caters for the version as well, but annoyingly (in hindsight) it is not a separate field, but within the TERMINOLOGY_ID part. Also, the reliable way to indicate the ‘version’ is going to be with a SNOMED CT Edition URI, as per above, e.g. http://snomed.info/sct/99991000052100. Or a particular release, with version info included - http://snomed.info/sct/99991000052100/version/20260630

So a ‘fully coded’ openEHR Terminology_id in a coded term could look like this: “SNOMED-CT(http://snomed.info/sct/99991000052100/version/20260630)”

Pretty ugly, and it’s going to make simple lexical matching in a query engine or ETL generator problematic.

Record the Edition elsewhere

We could however record the Edition URI in the Composition. Today it would need to go in the EVENT_CONTEXT, but one could imagine a dedicated field for it, like we have for territory. Then, resolving exactly which version of which module within which edition some code was created would be done by using this information. We assume that the SNOMED edition is actually the same for all codes recorded within a Composition. Is this guaranteed? It would prevent mixing Evaluations created locally with some Observations pulled in from a LIS, if they contained SNOMED codes but from different Editions - but I think this is actually a pretty unlikely scenario.

The downside is that the Edition info is not next to the concept codes themselves, so any querying that wants it has to stitch things together.

What will work in practice?

This might however be exactly what we want. Consider that most computing on coded terms in data will be done within the institution, or (increasingly) region, and 95% of the time, the same country.

Per Erik’s point 4, for normal operations, all Snomed codes are going to resolve just fine against the current release of the Edition in use; we don’t need any version info.

Per point 2 - medico-legal and research - at least medico-legal operations are expected to take a bit of effort. It will be easy enough to use Edition info from a Composition to figure out what Snomed was running when some particular EHR data was created.

The edge cases might theoretically be problematic:

  • data being moved to a new organisation that uses a different Edition of Snomed
  • data being moved to a new country - will every code resolve against what might be a quite different SNOMED Edition?

In such cases, even having perfect Edition information available might not help, since to compute, you need the actual release. Is an Irish jurisdiction going to rebuild a historical Swedish release to make the EHR of a Swede who moves there fully interpretable? Seems unlikely.

Conclusions

I’m not sure how much the edge cases above truly matter. We in IT like to solve for everything, but I doubt that they are economically justifiable. The vast majority of diagnostic and procedure codes that will appear in e.g. an IPS will be from the SNOMED core, or at worst, a National extension.

I am therefore inclined to think that SNOMED version information doesn’t matter for the vast majority of routine computing, of latest data versus most recent SNOMED (local) release.

And if we store a correct SNOMED Edition URI in every Composition containing SNOMED codes, it will serve all realistic medico-legal and research needs.

If doing so doesn’t solve other issues I have not covered here, and storing Edition information on a per-code basis looks unavoidable, I’d opt for a separate field in TERMINOLOGY_ID, and possibly deprecate the use of the “(version)” part of the TERMINOLOGY_ID type as currently defined. This allows routine querying to function easily, but ‘special querying’ or reporting could make use of the new version_id field.

We could actually do both, but generally leave the CODE_PHRASE version field empty - populate it on demand e.g for Compositions passing through an API, or being processed in an ETL service - it is easy to see that the Composition Edition info can be injected into every instance of CODE_PHRASE within it.

Wonderful summary and suggestions @thomas.beale!

Some thoughts:

  • in the EU a lot of data will likely cross borders due to upcoming mandatory EHDS so those usecases are becoming more likley, but for EHDS the SNOMED CT use in FHIR or whatever will likely be regulated so the main need is lieleky being able to somehow lookup data lineage and versions from sytems when exporting and resolve things then.
  • Having different SNOMED upgrade cycles for certain LIS systems and EHR systems is actually highly likley the way things work today at many hospitals with separate teams handling separate systems. This leads me to think that perhaps that proper lineage in FEEDER_AUDIT (or possibly dedicated well specified LINK) is likely a better place to put versoin information since feeder audit can be put at any granularity level in a COMPOSITION and ideally it should be populated at some level (e.g.root) also from forms in an EHR. I would even (sadly) guess that not all hard coded lists with terminology bindings in forms in a big deployed EHR system will be updated in sync at once. (Lists taken from a terminology server are more likely to be updated at once.)
  • If the class LINK would allow pointing to any URI (also outside EHRs) then a certain meaning or possibly type marker of of LINK of course be used to point to the SNOMED URI like http://snomed.info/sct/99991000052100/version/20260630 of the particular version used in this COMPOSITION or subtree under it. This may call for widening the target constraints of LINK to allow pointing to any URI (wich may anyway be good when introducing openEHR URNs.

Questions:
1. What do you all think of FEEDER_AUDIT or LINK (at some level/levels) as a place for SNOMED CT version lineage? Other suggestions? (Ping: @yampeku, @mikael, @siljelb, @ian.mcnicoll, @SevKohler, @Daniel_Karlsson and others?) Lineage/version info at a more granular level could be interpreted as overriding info at a higher more coarse grained level closer to the root of the composition.
2. If we go for FEEDER_AUDIT, should we then recommend a certain structure/attribute name in the FEEDER_AUDIT_DETAILS.other_details’ item_structure of FEEDER_AUDIT.originating_system_audit for this?

Image clip below from section 3.1 of Common Information Model

I’m interested in other people’s input as well, but while this is still in mind, a few further thoughts on Erik’s reply.

My thinking as well: when openEHR data is pulled through an API (and maybe transformed to FHIR for further transmission somewhere), if there is a new version field in CODE_PHRASE (see also Terminology_code), then this would be populated from the Snomed Edition / release info found in the enclosing Composition.

My expectation as well. However… do we really think that coded data based on different terminology sources is going to be mixed in the same Composition? I would hope not - lab results should be committed in their own Composition, separate from those of the care provider receiving the results.

I also think that while technically possible to have different SNOMED Edition/version info in fine-grained FEEDER_AUDITs , it’s really quite unlikely that software will generate or process such meta-data properly. I also think it would be very confusing to determine the true semantics of coded terms coming from different Editions, within the same data commit.

So unless there is strong evidence that a) this scenario is inescapable and b) we can formally specify it and everyone is going to commit to implementing such specifications (seems unlikely to me), we should avoid it altogether.

I can imagine however, that SNOMED Edition info could be received for a whole lab result, i.e. just one Snomed URI; this could be retained in the top FEEDER_AUDIT and also should be copied into the resulting COMPOSITION. But I don’t think it makes sense to record such info in FEEDER_AUDIT for locally generated data (i.e. data originating from native applications).

Probably true, but here I think we have to rely on the basic internal consistency of terminology, such that meanings never change, codes never get reused etc (i.e. the desiderata rules). Otherwise everything just becomes intractable to compute.

Technically possible, but I think the historical use of LINK has always been to point for ‘citing’ other data, not pointing to meta-data.

The more I think about it, the more it makes sense to add a new property to COMPOSITION, called something like knowledge_context, i.e. a special context subtree for recording Snomed edition info; any similar applicable info for other terminologies (e.g. version of lab coding terminology); other knowledge meta-data e.g. CKM / local archetype release set, and so on.

If CODE_PHRASE is also updated to have a version field (like Terminology_code) then we have the mechanism to shared fully specified single codes in data being pulled through an API, no matter how they get mixed up afterward.

I suspect that summaries, multidiciplinary conference notes etc may have compositions with very mixed sources, but one could hope that the sources can be tracked (via feeder_audit, citations or similar) if one really needs to know what was used in a source system. So adding an optional (non-mandatory) version attribute on CODE_PHRASE might be a good idea to be used when versions are mixed in the same composition.


UML from chapter 5 of Data Types Information Model

Regerding…

…I suspect we’ll need more clear evidence (a number of interesting valid use cases) and purpose description before vendors want to add more RM attributes to EVENT_CONTEXT, perhaps a recommended cluster archetype in EVENT_CONTEXT.other_context would do the trick?

Question A: any suggestions for a suitable cluster archetype covering this?

Question(s) B - somewhat but not totally off-topic: Do COMPOSITION templates really need to include a cluster/item_structure under other_context in order for a system to at runtime use other_context or can a CDR platform proxy just shove in some extra stuff there before comitting?
Background for question B; in Sweden we have added som legal “PDL” metadata in other_context and have (perhaps wrongly) assumed that we then neeed to include that cluster in all Swedish composition templates ever used (and that is pretty annoying and repetitive). A reason/assumption is that if you also want to add anything else in other_context you need everything synced in the same ITEM_STRUCTURE template part to avoid AT-code collistions. Would relaxing other_context from current 0..1 to a future 0..* help keeping it open for more outside-template-use without annoying template authors? or would that bring other problems? Is that a reason to rather add a new (perhaps 0..* rather than 0..1) attribute to EVENT_CONTEXT as Thomas suggests


UML from Chapter 5 of EHR Information Model

P.S. Side note: the Swedish legal “PDL” metadata is an example where codes from different SNOMED CT modules have been mixed http://snomed.info/sct/900000000000207008 (international) for care unit and http://snomed.info/sct/45991000052106 SNOMED CT (Sweden NRC maintained module) for legal caregiver organisation above care unit.

There is a Knowledge Base Reference archetype Cluster Archetype: Knowledge base reference [openEHR Clinical Knowledge Manager]

Originally developed to Genomics knowledge sources, we found it worked quite well for a different use case where client wanted to persist detailed metadata about a national drug catalogue in medication records,

Feels that might work in lieu of @thomas.beale idea at least for now? I’m also a but unsure about using feeder_audit to capture this kind of data.

I was actually thinking of a sibling attribute of /context, not something under it, i.e. a clean addition to COMPOSITION.

A minor comment: in the current release format (RF2), the module can only be identified from the moduleId, not from the namespace.

Region Stockholm is not permitted to add content within the Swedish NRC’s namespace. To add its own content, Region Stockholm would need to obtain a namespace of its own.

There are some (unusual) cases where this is not true. For example, when care is provided across regional boundaries, a problem list may contain concepts from editions maintained by different regions.

It is important to keep in mind that a concept always has the same meaning, regardless of the module, edition or version in which it appears. What may vary between modules, editions and versions are the concept’s surrounding relationships and its terms.

For example, the concept 233604007 |Pneumonia (disorder)| always represents the same clinical meaning, but its children or other descendants may differ between modules, editions and versions. Consequently, if a data-entry interface has been designed so that all descendants of the concept 233604007 |Pneumonia (disorder)| are available for selection from a pick list, the contents of that list will depend on the particular module, edition and version of SNOMED CT used as the basis for the data entry.

Namespaces are probably not relevant to this discussion, as their main purpose nowadays is simply to ensure that different organisations do not create concepts with the same identifier.

I knew that… but it appears that Opus 5.5 doesn’t, and I did not review closely enough. That’s what I get for cut&paste of an AI summary :wink: Anyway, I’ll fix that because it is wrong.

This is the kind of edge case I was interested in. I can see that it could technically happen, but it doesn’t look like good practice to me - it would imply that some terms used for diagnosis, problem, etc could exist only in regional Swedish editions rather than in the Swedish national extension. That would imply that the problem list might not be machine interpretable even if it just travelled (following the patient, let’s say) from Stockholm to Gothenburg, unless the receiver environment can get its hands on Region Stockholm Snomed editions. Well, ok we assume it wouldn’t be that hard in principle, but that is surely creating a lot of work, when it would just be easier to agree across Sweden that any new terms for universal things (like Dx & problem) that are somehow specific to Sweden, should go in the Sweden extension. In my understanding, region extensions are really for defining value sets based on historically local configuration of EMR and other systems, not for defining codes for doing medicine as such.

Could you expand a bit on the policy in this area, because I would not like to see us engineer something complicated for use cases that never occur in reality, or even if they do, everyone agrees they are bad practice…

I’m not saying it’s good practice, but stranger things have happened …

The policy is quite clear that a concept should be placed as high up in the edition hierarchy as possible. In other words, if a concept is suitable for international use, it should be included in the International Edition, and if it is applicable throughout Sweden, it should be included in the Swedish Edition.

Unfortunately, the Swedish Release Centre has not always been particularly quick to accept new concepts and has, at times, interpreted the editorial policy differently from those submitting the requests. As a result, there have been cases where the need for new concepts has had to be addressed in other ways. One possible approach is to add the concept to a regional edition.

So is the suggestion to:

  • add a new attribute in COMPOSITION (“sibling attribute of /context”) for terminology version etc. Is there any name suggestion for that attribute?
  • what could the structure/object be that goes into that new attribute?
    • I guess it should be able to carry versions for all/any of the terminologies/ontologies in the COMPOSITION if they have versions
    • Can it include an optional flag warning if this COMPOSITION contains more than one version of a certain terminology?
    • If we want to carry versions for terminology in other objects than COMPOSITIONs should we perhaps from the beginning tather put it in LOCATABLE or any of its (via attributes) attached classes? (see e.g. UML diagram in post 2 above)

I would do three things:

  • add a new attribute in COMPOSITION, called /knowledge_context, i.e. the ‘context of knowledge extant when this COMPOSITION was created’ (if I were German, I’d maybe just want to call it ‘kontext’ :wink:
  • add a new version attribute to CODE_PHRASE, only to be populated when it appears necessary (i.e. it would be a local decision), but mandatory to populate on data coming through the openEHR API; this change makes CODE_PHRASE nearly the same as Terminology_code, which is what will replace it in the future.
  • change the Data types spec deprecate the use of “(xxx)” to represent version info in the terminology_id field of a CODE_PHRASE

For the first, we might imagine something like:

class KNOWLEDGE_CONTEXT 
    /**
     * Table keyed by terminology namespace id e.g. 
     *     "snomedct": [
     *               {"edition", "http://snomed.info/sct/99991000052100/version/20260630"},
     *               {"issuer", "SocialStyrelsen (Sweden)"}
     *                etc
     *     ],
     *    "icd10": [],
     *    etc
     */
    terminologies: Map<String, Map<String, String>>
end

Over time, we can imagine the addition of drug DB, entries, probably an ontologies table, and so on.

I guess it could, although that is another data item to populate, which can therefore be populated wrongly. It would be better IMO to define a function / small heuristic that can be executed on the knowledge context object terminology list, to determine this.

I don’t think we need to do this, since the version field of CODE_PHRASE will take care of that no matter where it appears. I would also be loathe to add more data points, almost never to be used, to LOCATABLE.

I dont have time to wrap my head around the thing you wrote here sadly, as im still busy with clean up and i dont want to provide uninformed comments.

FYI Jira for now i made a problem report to close some other tickets related to our discussion here, so we have a single ticket. We will have to discuss the outcomes in a SEC call once its settled a bit here.

For now moving version to code_phrase is something that seems reasonable about the Kontext im not sure, fhir seems to be getting along other way, but as said uninformed comment :wink:

@SevKohler I am not sure FHIR has solved the problem in a way that would fit the current way openEHR is designed, so we likely need some change. Do people like @mikael ot others know if FHIR has solved version issues for SNOMED in a completely satisfactory way?

FHIR CodeSystem has quite a lot of attributes regarding versioning that openEHR does not

Also the Coding resource has a separate version field

IN section 4.1.3 (Complex Code Systems) of Terminologies - FHIR v5.0.0 they even discuss postcoordinated expressions like

{ 
  "system" : "http://snomed.info/sct",
  "code" : "128045006:{363698007=56459004}"
}

…but perhaps they don’t do much about it, just say you can cram it into the same place?

Post-coordination in openEHR has been discussed over the years, examples:

I think we need to handle or at minimum be able to flag in some sensible way in openEHR that something stored ina a code attribute is an expression rather than a simple code, so that software can avoid or at least warn about wronog assumptions. Example an AQL query processor doing a strict string comparison of a code will not have a clue that it just likely did not understand the intention of somebody that had used a postcoordinated expression in the data it queried.
Perhaps an expression/postcoordination flag (or possilby a subclass?) could be added while we anyway are reconsidering how terminology support works?

FHIR CodeSystem is for the definition of the terminology themselves, not their direct use in data. We can assume those exist and are available. Ideally our list of known strings should match what is is stored in the “name” attribute of the CodeSystem. Coding have version, main difference is that fhir uses system+version and openEHR strings in the form of name(version).

I haven’t had enough time to follow their work. :frowning: However, I am quite sure that Daniel Karlsson know everything about it.

Why do we need a flag? A pre-coordinated SNOMED CT expression (read: a conceptid) is always an integer, whereas a post-coordinated SNOMED CT expression always contains non-numeric characters. It is therefore very easy to determine whether a value is a conceptid or a post-coordinated expression without a flag.