Skip to content

Commit

Permalink
Add SNOMED CT Equals Child Filter
Browse files Browse the repository at this point in the history
Also improved the terminology service documentation.
  • Loading branch information
alexanderkiel committed Feb 5, 2025
1 parent 81f0167 commit 11657a0
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 32 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export default defineConfig({
text: 'Terminology Service',
items: [
{ text: 'Overview', link: '/terminology-service' },
{ text: 'FHIR', link: '/terminology-service/fhir' },
{ text: 'LOINC', link: '/terminology-service/loinc' },
{ text: 'SNOMED CT', link: '/terminology-service/snomed-ct' },
{ text: 'UCUM', link: '/terminology-service/ucum' }
Expand Down
29 changes: 19 additions & 10 deletions docs/terminology-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,34 @@
> [!CAUTION]
> The terminology service is currently **beta**. Only the basic functionality, described here, is implemented.
The terminology service is an optional feature that has to be enabled by setting `ENABLE_TERMINOLOGY_SERVICE` to `true`.
> [!NOTE]
> The terminology service is an optional feature that has to be enabled by setting `ENABLE_TERMINOLOGY_SERVICE` to `true`.
## Operations
## Supported Code Systems

* [CodeSystem $validate-code](api/operation/code-system-validate-code.md)
* [ValueSet $expand](api/operation/value-set-expand.md)
* [ValueSet $validate-code](api/operation/value-set-validate-code.md)
### FHIR Code Systems

[FHIR CodeSystem](terminology-service/fhir.md) resources stored in Blaze with `content` of either `complete` or `fragment` are supported.

## Enable LOINC
### External Code Systems

LOINC data is build into the Blaze image. Because LOINC support needs additional memory, it has to be enabled by setting the environment variable `ENABLE_TERMINOLOGY_LOINC` to `true`.
Currently the external code systems shown in the following table are supported.

## Enable SNOMED CT
| Name | Version(s) | Notes |
|-----------------------------------------------|-----------------------|-----------------------------------|
| [LOINC](terminology-service/loinc.md) | 2.78 | has to be enabled |
| [SNOMED CT](terminology-service/snomed-ct.md) | all versions provided | release files have to be provided |
| [UCUM](terminology-service/ucum.md) | 2013.10.21 | enabled by default |

Because SNOMED CT has to be licensed, Blaze doesn't contain the SNOMED CT code system by default. However, by setting the environment variable `ENABLE_TERMINOLOGY_SNOMED_CT` to `true` and `SNOMED_CT_RELEASE_PATH` to a path of an official SNOMED CT release, Blaze will be able to offer terminology services on SNOMED CT. The release files are read into memory on each start of Blaze. So the release path has to be always available.
## Operations

* [CodeSystem $validate-code](api/operation/code-system-validate-code.md)
* [ValueSet $expand](api/operation/value-set-expand.md)
* [ValueSet $validate-code](api/operation/value-set-validate-code.md)

## Graph Cache

For normal stored code systems, a graph will be build before operations like $validate-code are executed. Building those graph is quite expensive. I order to prevent Blaze to build a graph each time an operation is executed, a graph cache is used. The environment variable `TERMINOLOGY_SERVICE_GRAPH_CACHE_SIZE` allows to set the number of concepts, the graph cache should hold. The default is 100,000.
For stored FHIR code systems, a graph will be build before operations like $validate-code are executed. Building those graph is quite expensive. I order to prevent Blaze to build a graph each time an operation is executed, a graph cache is used. The environment variable `TERMINOLOGY_SERVICE_GRAPH_CACHE_SIZE` allows to set the number of concepts, the graph cache should hold. The default is 100,000.

## Memory Requirements

Expand Down
18 changes: 18 additions & 0 deletions docs/terminology-service/fhir.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# FHIR Code Systems <Badge type="warning" text="unreleased"/>

Blaze supports all FHIR CodeSystem resources stored in Blaze with `content` of either `complete` or `fragment`.

## Filters

| Property | Operators | Values |
|----------|---------------------|------------|
| concept | is-a, descendent-of | code |
| parent | exists | true/false |
| parent | = | code |
| parent | regex | *regex* |
| child | exists | true/false |
| child | = | code |
| child | regex | *regex* |
| *any* | exists | true/false |
| *any* | = | *any* |
| *any* | regex | *regex* |
11 changes: 7 additions & 4 deletions docs/terminology-service/loinc.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# LOINC <Badge type="info" text="Feature: TERMINOLOGY_LOINC"/> <Badge type="warning" text="unreleased"/>

> [!NOTE]
> LOINC data is build into the Blaze image. Because LOINC support needs additional memory, it has to be enabled by setting the environment variable `ENABLE_TERMINOLOGY_LOINC` to `true`.
Blaze supports the [LOINC](https://loinc.org) terminology in version 2.78.

## Copyright

This material contains content from [LOINC](http://loinc.org). LOINC is copyright © 1995-2020, Regenstrief Institute, Inc. and the Logical Observation Identifiers Names and Codes (LOINC) Committee and is available at no cost under the license at http://loinc.org/license icon. LOINC® is a registered United States trademark of Regenstrief Institute, Inc.

## FHIR Documentation

[Using LOINC with FHIR](https://terminology.hl7.org/LOINC.html)

## Filters

| Property | Operators | Values |
Expand All @@ -33,3 +32,7 @@ The following implicit value sets are supported.
| Name | Example |
|--------------|------------------------------|
| Answer Lists | http://loinc.org/vs/LL4049-4 |

## Resources

[Using LOINC with FHIR](https://terminology.hl7.org/LOINC.html)
14 changes: 9 additions & 5 deletions docs/terminology-service/snomed-ct.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# SNOMED CT <Badge type="info" text="Feature: TERMINOLOGY_SNOMED_CT"/> <Badge type="warning" text="unreleased"/>

Blaze supports the [SNOMED CT](https://www.snomed.org) terminology in the versions provided in the release files. The environment variable `SNOMED_CT_RELEASE_PATH` has to point to a path of an official SNOMED CT release. The release files are read into memory on each start of Blaze. So the release path has to be always available.
> [!NOTE]
> Because SNOMED CT has to be licensed, Blaze doesn't contain the SNOMED CT code system by default. However, by setting the environment variable `ENABLE_TERMINOLOGY_SNOMED_CT` to `true` and `SNOMED_CT_RELEASE_PATH` to a path of an official SNOMED CT release, Blaze will be able to offer terminology services on SNOMED CT. The release files are read into memory on each start of Blaze. So the release path has to be always available.
Blaze supports the [SNOMED CT](https://www.snomed.org) terminology in the versions provided in the release files.

## Copyright

This documentation includes content from SNOMED Clinical Terms® (SNOMED CT®) is copyright of the International Health Terminology Standards Development Organisation (IHTSDO) (trading as SNOMED International). Users of Blaze must have the appropriate SNOMED CT Affiliate license - for more information access http://www.snomed.org/snomed-ct/get-snomed-ct or contact SNOMED International via email at info@snomed.org.

## FHIR Documentation

[Using SNOMED CT with FHIR](https://terminology.hl7.org/SNOMEDCT.html)

## Filters

| Property | Operators | Values |
|----------|---------------------|----------------|
| concept | is-a, descendent-of | SNOMED CT code |
| parent | = | SNOMED CT code |
| child | = | SNOMED CT code |

## Resources

[Using SNOMED CT with FHIR](https://terminology.hl7.org/SNOMEDCT.html)
2 changes: 1 addition & 1 deletion docs/terminology-service/ucum.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Blaze supports the [UCUM](http://unitsofmeasure.org/) terminology.

UCUM is Copyright © 1999-2013 Regenstrief Institute, Inc. and The UCUM Organization, Indianapolis, IN. All rights reserved. See [TermsOfUse](http://unitsofmeasure.org/trac//wiki/TermsOfUse) for details.

## FHIR Documentation
## Resources

[Using UCUM with FHIR](https://terminology.hl7.org/UCUM.html)
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,50 @@
[blaze.terminology-service.local.code-system.sct.filter.core :as core]
[blaze.terminology-service.local.code-system.sct.type :refer [parse-sctid]]))

(defn- expand-filter-equals-parent
(defn- expand-filter-parent
[{{:keys [child-index]} :sct/context :sct/keys [module-id version]} value]
(if (nil? value)
(ba/incorrect (format "Missing parent = filter value in code system `%s`." url))
(if-let [code (parse-sctid value)]
(context/neighbors child-index module-id version code)
(ba/incorrect (format "Invalid parent = filter value `%s` in code system `%s`." value url)))))

(defn- expand-filter-child
[{{:keys [parent-index]} :sct/context :sct/keys [module-id version]} value]
(if (nil? value)
(ba/incorrect (format "Missing child = filter value in code system `%s`." url))
(if-let [code (parse-sctid value)]
(context/neighbors parent-index module-id version code)
(ba/incorrect (format "Invalid child = filter value `%s` in code system `%s`." value url)))))

(defmethod core/expand-filter :=
[code-system {:keys [property value]}]
(condp = (type/value property)
"parent" (expand-filter-equals-parent code-system (type/value value))
"parent" (expand-filter-parent code-system (type/value value))
"child" (expand-filter-child code-system (type/value value))
nil (ba/incorrect (format "Missing = filter property in code system `%s`." url))
(ba/unsupported (format "Unsupported = filter property `%s` in code system `%s`." (type/value property) url))))

(defn- satisfies-filter
(defn- satisfies-filter-parent
[{{:keys [child-index]} :sct/context :sct/keys [module-id version]} value code]
(if (nil? value)
(ba/incorrect (format "Missing parent = filter value in code system `%s`." url))
(if-let [start-code (parse-sctid value)]
(contains? (context/neighbors child-index module-id version start-code) code)
(ba/incorrect (format "Invalid parent = filter value `%s` in code system `%s`." value url)))))

(defn- satisfies-filter-child
[{{:keys [parent-index]} :sct/context :sct/keys [module-id version]} value code]
(if (nil? value)
(ba/incorrect (format "Missing child = filter value in code system `%s`." url))
(if-let [start-code (parse-sctid value)]
(contains? (context/neighbors parent-index module-id version start-code) code)
(ba/incorrect (format "Invalid child = filter value `%s` in code system `%s`." value url)))))

(defmethod core/satisfies-filter :=
[code-system {:keys [property value]} code]
(condp = (type/value property)
"parent" (satisfies-filter code-system (type/value value) code)
"parent" (satisfies-filter-parent code-system (type/value value) code)
"child" (satisfies-filter-child code-system (type/value value) code)
nil (ba/incorrect (format "Missing = filter property in code system `%s`." url))
(ba/unsupported (format "Unsupported = filter property `%s` in code system `%s`." (type/value property) url))))
Loading

0 comments on commit 11657a0

Please sign in to comment.