Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #1980 - Introduce fhir-term-graph module #1997

Merged
merged 54 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
93f7ef5
Issue #1980 - Introduce fhir-term-graph module
JohnTimm Feb 26, 2021
2edd11b
Issue #1980 - updated fhir-parent/pom.xml
JohnTimm Feb 26, 2021
17b7ebd
Implement UMLSTermGraphLoader
Mar 2, 2021
366b0cd
Issue #1980 - updates
JohnTimm Mar 2, 2021
7ca7f7e
Merge branch 'main' into johntimm-main
JohnTimm Mar 2, 2021
bb3aa9f
Issue #1980 - removed unused import
JohnTimm Mar 2, 2021
a7e76a2
Issue #1980 - add property support to GraphTermServiceProvider
JohnTimm Mar 2, 2021
08c8810
Issue #1980 - sort members
JohnTimm Mar 3, 2021
1018221
Issue #1980 - updates
JohnTimm Mar 3, 2021
49f1491
Issue #1980 - updates
JohnTimm Mar 5, 2021
e65dad6
Issue #1980 - updates
JohnTimm Mar 8, 2021
9e914ee
Issue #1980 - fixed incompatible type issue
JohnTimm Mar 8, 2021
9bac1af
Issue #1980 - updates
JohnTimm Mar 10, 2021
13a5f48
Issue #1980 - unit tests
JohnTimm Mar 11, 2021
1653a58
Issue #1980 - minor update
JohnTimm Mar 11, 2021
f1481d5
Issue #1980 - more unit tests
JohnTimm Mar 11, 2021
50617bf
Issue #1980 - added Javadoc
JohnTimm Mar 11, 2021
bc3e38f
Issue #1980 - update docs
JohnTimm Mar 11, 2021
a194450
Issue #1980 - more doc updates
JohnTimm Mar 11, 2021
c832782
Apply suggestions from code review
JohnTimm Mar 12, 2021
4108a18
Issue #1980 - changes per PR review
JohnTimm Mar 12, 2021
5553872
Issue #1980 - removed commented out lines of code
JohnTimm Mar 12, 2021
65ed664
Issue #1980 - changes per PR review
JohnTimm Mar 12, 2021
22b1079
Merge pull request #2080 from IBM/main
JohnTimm Mar 12, 2021
dd0aea4
Issue #1980 - don't add version to contains if CodeSystem has none
JohnTimm Mar 12, 2021
f79a867
Issue #1980 - added support for time limit
JohnTimm Mar 15, 2021
e1b524d
Issue #1980, Issue #2092 - added support for implicit SNOMED value sets
JohnTimm Mar 15, 2021
11d9dd2
Issue #1980, Issue #2092 - fixed UnsupportedOperationException issue
JohnTimm Mar 16, 2021
44941bc
Issue #1980, Issue #2092 - additional updates / clean-up
JohnTimm Mar 16, 2021
4c1e7ce
Issue #1980, Issue #2092 - removed System.out
JohnTimm Mar 16, 2021
e11c1bf
Issue #1980 - fix issue in CodeSystem validate-code operation
JohnTimm Mar 16, 2021
21ffe8a
Issue #1980 - update copyright
JohnTimm Mar 16, 2021
9b8db11
Issue #1980 - additional updates and clean-up
JohnTimm Mar 17, 2021
d1248c5
Issue #1980 - moved FHIRTermGraphUtil.normalize to CodeSystemSupport
JohnTimm Mar 17, 2021
965b878
Issue #1980 - removed System.out
JohnTimm Mar 17, 2021
a0f9c08
Issue #1980 - updated ValueSet support to use normalize
JohnTimm Mar 17, 2021
7682d62
Issue #1980 - updates
JohnTimm Mar 18, 2021
9fff883
Merge branch 'main' into johntimm-main
lmsurpre Mar 18, 2021
4b8a0cf
Issue #1980 - updates
JohnTimm Mar 18, 2021
f172e9d
Merge branch 'johntimm-main' of https://github.com/IBM/FHIR.git into …
JohnTimm Mar 18, 2021
b7b4840
Issue #1980 - performance improvements
JohnTimm Mar 19, 2021
5fa8f93
Issue #1980 - sort members
JohnTimm Mar 19, 2021
aeb927b
Issue #1980 - updated copyright headers
JohnTimm Mar 20, 2021
dc9b125
Issue #1980 - formatting
JohnTimm Mar 20, 2021
b2a25e1
Issue #1980 - updated GraphTermServiceProvider.closure
JohnTimm Mar 22, 2021
12873e6
Issue #1980 - fixed issue when using multiple filters
JohnTimm Mar 22, 2021
a6ee31f
Issue #1980 - fixed issue with is-not-a filter
JohnTimm Mar 22, 2021
46ab053
Issue #1980 - updated "parent" / "child" equals behavior
JohnTimm Mar 23, 2021
21b8b3d
Issue #1980 - formatting / clean-up
JohnTimm Mar 23, 2021
d7bdc20
Issue #1980 - additional argument checking
JohnTimm Mar 23, 2021
ae51b1e
Issue #1980 - formatting
JohnTimm Mar 23, 2021
d8e3f7b
Issue #1980 - more clean-up
JohnTimm Mar 23, 2021
f164092
Issue #1980 - removed commented code
JohnTimm Mar 23, 2021
ed1d16b
Issue #1980 - formatting
JohnTimm Mar 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/src/pages/guides/FHIRServerUsersGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -1953,6 +1953,9 @@ This section contains reference information about each of the configuration prop
|`fhirServer/core/capabilityStatementCacheTimeout`|integer|The number of minutes that a tenant's CapabilityStatement is cached for the metadata endpoint. |
|`fhirServer/core/extendedCodeableConceptValidation`|boolean|A boolean flag which indicates whether extended validation is performed by the server during object construction for code, Coding, CodeableConcept, Quantity, Uri, and String elements which have required bindings to value sets.|
|`fhirServer/core/disabledOperations`|string|A comma-separated list of operations which are not allowed to run on the IBM FHIR Server, for example, `validate,import`. Note, do not include the dollar sign `$`|
|`fhirServer/term/graphTermServiceProvider/enabled`|boolean|Indicates whether the graph term service provider should be used by the FHIR term service to access code system content|
|`fhirServer/term/graphTermServiceProvider/timeLimit`|integer|Graph traversal time limit (in milliseconds)|
|`fhirServer/term/graphTermServiceProvider/configuration`|object (name/value pairs)|A JSON object that contains the name/value pairs used to configure the graph database behind the graph term service provider see: [https://docs.janusgraph.org/basics/configuration-reference/](https://docs.janusgraph.org/basics/configuration-reference/)|
|`fhirServer/resources/open`|boolean|Whether resources that are not explicitly listed in the configuration should be supported by the FHIR Server REST layer. When open is set to `false`, only the resources listed in fhir-server-config.json are supported.|
|`fhirServer/resources/Resource/interactions`|string list|A list of strings that represent the RESTful interactions (create, read, vread, update, patch, delete, history, and/or search) supported for resource types. Omitting this property is equivalent to supporting all FHIR interactions for the supported resources. An empty list, `[]`, can be used to indicate that no REST methods are supported. This property can be overridden for specific resource types via the `fhirServer/resources/<resourceType>/interactions` property.|
|`fhirServer/resources/Resource/searchParameters`|object|The set of search parameters to support for all supported resource types. Omitting this property is equivalent to supporting all search parameters in the server's registry that apply to resource type "Resource" (all resources). An empty object, `{}`, can be used to indicate that no global search parameters are supported.|
Expand Down Expand Up @@ -2073,6 +2076,8 @@ This section contains reference information about each of the configuration prop
|`fhirServer/core/conditionalDeleteMaxNumber`|10|
|`fhirServer/core/capabilityStatementCacheTimeout`|60|
|`fhirServer/core/extendedCodeableConceptValidation`|true|
|`fhirServer/term/graphTermServiceProvider/enabled`|false|
|`fhirServer/term/graphTermServiceProvider/timeLimit`|90000|
|`fhirServer/resources/open`|true|
|`fhirServer/resources/Resource/interactions`|null (all interactions supported)|
|`fhirServer/resources/Resource/searchParameters`|null (all global search parameters supported)|
Expand Down Expand Up @@ -2182,6 +2187,9 @@ must restart the server for that change to take effect.
|`fhirServer/core/capabilityStatementCacheTimeout`|Y|Y|
|`fhirServer/core/extendedCodeableConceptValidation`|N|N|
|`fhirServer/core/disabledOperations`|N|N|
|`fhirServer/term/graphTermServiceProvider/enabled`|N|N|
|`fhirServer/term/graphTermServiceProvider/timeLimit`|N|N|
|`fhirServer/term/graphTermServiceProvider/configuration`|N|N|
|`fhirServer/resources/open`|Y|Y|
|`fhirServer/resources/Resource/interactions`|Y|Y|
|`fhirServer/resources/Resource/searchParameters`|Y|Y|
Expand Down
82 changes: 51 additions & 31 deletions docs/src/pages/guides/FHIRTerminologyGuide.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
slug: "/FHIR/guides/FHIRTerminologyGuide/"
title: "FHIR Terminology Guide"
date: "2020-06-04 12:00:00 -0400"
date: "2021-03-11"
---

## Overview
Expand All @@ -10,23 +10,37 @@ The IBM FHIR Server Terminology module ([fhir-term](https://github.com/IBM/FHIR/

## FHIR Terminology Service Provider Interface (SPI)

The FHIR Terminology Service Provider interface provides a mechanism for implementers to provide terminology capabilities via the Java ServiceLoader. The interface includes method signatures for `expand`, `lookup`, `subsumes`, `closure`, `validateCode` (CodeSystem) and `validateCode` (ValueSet). Here is an excerpt (for brevity) of the SPI:
The FHIR Terminology Service Provider interface provides a mechanism for implementers to provide terminology capabilities via the Java ServiceLoader. The interface includes method signatures for `closure`, `getConcept`, `getConcepts`, `hasConcept`, `isSupported` and `subsumes`:

```java
public interface FHIRTermServiceProvider {
boolean isExpandable(ValueSet valueSet);
ValueSet expand(ValueSet valueSet, ExpansionParameters parameters);
LookupOutcome lookup(Coding coding, LookupParameters parameters);
ConceptSubsumptionOutcome subsumes(Coding codingA, Coding codingB);
Set<Concept> closure(Coding coding);
ValidationOutcome validateCode(CodeSystem codeSystem, Coding coding, ValidationParameters parameters);
ValidationOutcome validateCode(CodeSystem codeSystem, CodeableConcept codeableConcept, ValidationParameters parameters);
ValidationOutcome validateCode(ValueSet valueSet, Coding coding, ValidationParameters parameters);
ValidationOutcome validateCode(ValueSet valueSet, CodeableConcept codeableConcept, ValidationParameters parameters);
TranslationOutcome translate(ConceptMap conceptMap, Coding coding, TranslationParameters parameters);
TranslationOutcome translate(ConceptMap conceptMap, CodeableConcept codeableConcept, TranslationParameters parameters);
Set<Concept> closure(CodeSystem codeSystem, Code code);
Concept getConcept(CodeSystem codeSystem, Code code);
Set<Concept> getConcepts(CodeSystem codeSystem);
Set<Concept> getConcepts(CodeSystem codeSystem, List<Filter> filters);
boolean hasConcept(CodeSystem codeSystem, Code code);
boolean isSupported(CodeSystem codeSystem);
boolean subsumes(CodeSystem codeSystem, Code codeA, Code codeB);
}
```

## Default Terminology Service Provider Implementation

The default implementation of `FHIRTermServiceProvider` ([DefaultTermServiceProvider](https://github.com/IBM/FHIR/blob/main/fhir-term/src/main/java/com/ibm/fhir/term/service/provider/DefaultTermServiceProvider.java)) leverages terminology resources (`CodeSystem`, `ValueSet`, and `ConceptMap`) that have been made available through the FHIR registry module ([fhir-registry](https://github.com/IBM/FHIR/tree/main/fhir-registry)). It supports `CodeSystem` resources with *complete* content (`CodeSystem.content = 'complete'`) and `ValueSet` resources that reference `CodeSystem` resources that have complete content.

## FHIR Terminology Service Singleton facade

The FHIR Terminology Service Singleton facade ([FHIRTermService](https://github.com/IBM/FHIR/blob/main/fhir-term/src/main/java/com/ibm/fhir/term/service/FHIRTermService.java)) loads a list of `FHIRTermServiceProvider` instances from the ServiceLoader and includes an instance of the `DefaultTermServiceProvider`. Client code (Java) that requires terminology capabilities should access them via the `FHIRTermService` singleton facade. Here is an example:

```java
ValueSet valueSet = ValueSetSupport.getValueSet("http://ibm.com/fhir/ValueSet/vs1");
Coding coding = Coding.builder()
.system(Uri.of("http://ibm.com/fhir/CodeSystem/cs1"))
.version(string("1.0.0"))
.code(Code.of("a")
.display(string("concept a")
.build();
ValidationOutcome outcome = FHIRTermService.getInstance().validateCode(valueSet, coding);
```

The `expand `, `lookup`, `validateCode` (CodeSystem), `validateCode` (ValueSet), and `translate` methods support the passing of optional parameters (e.g. `ExpansionParameters`, `LookupParameters`, etc.). Many of the methods also return an "outcome" object. These "parameter" and "outcome" objects are modeled after the input/output parameters specified in the terminology operations from the FHIR Terminology module: [http://hl7.org/fhir/terminology-module.html](http://hl7.org/fhir/terminology-module.html).
Expand All @@ -47,24 +61,7 @@ Parameters parameters = outcome.toParameters();

This bridge to/from the `Parameters` resource enables implementers to build both native implementations of the SPI and implementations that access an existing external terminology service.

## Default Terminology Service Provider Implementation

The default implementation of `FHIRTermServiceProvider` ([DefaultTermServiceProvider](https://github.com/IBM/FHIR/blob/main/fhir-term/src/main/java/com/ibm/fhir/term/service/provider/DefaultTermServiceProvider.java)) leverages terminology resources (`CodeSystem`, `ValueSet`, and `ConceptMap`) that have been made available through the FHIR registry module ([fhir-registry](https://github.com/IBM/FHIR/tree/main/fhir-registry)). It supports `CodeSystem` resources with *complete* content (`CodeSystem.content = 'complete'`) and `ValueSet` resources that reference `CodeSystem` resources that have complete content. The default implementation does not support for optional parameters (e.g. `ExpansionParameters`, `TranslationParameters`, `ValidationParameters`, etc.).

## FHIR Terminology Service Singleton facade

The FHIR Terminology Service Singleton facade ([FHIRTermService](https://github.com/IBM/FHIR/blob/main/fhir-term/src/main/java/com/ibm/fhir/term/service/FHIRTermService.java)) loads a `FHIRTermServiceProvider` from the ServiceLoader, if one exists. Otherwise, it will instantiate a `DefaultTermServiceProvider`. Other FHIR server components and user code (Java) that requires terminology capabilities should access them via the `FHIRTermService` singleton facade. Here is an example:

```java
ValueSet valueSet = ValueSetSupport.getValueSet("http://ibm.com/fhir/ValueSet/vs1");
Coding coding = Coding.builder()
.system(Uri.of("http://ibm.com/fhir/CodeSystem/cs1"))
.version(string("1.0.0"))
.code(Code.of("a")
.display(string("concept a")
.build();
ValidationOutcome outcome = FHIRTermService.getInstance().validateCode(valueSet, coding);
```
NOTE: The current implementation does not support for optional parameters (e.g. `ExpansionParameters`, `TranslationParameters`, `ValidationParameters`, etc.).

## FHIR Server Terminology Extended Operations

Expand Down Expand Up @@ -99,3 +96,26 @@ Collection<FHIRPathNode> result = evaluator.evaluate("%terminologies.validateCod
```

Additionally, the FHIRPath functions `subsumedBy` and `subsumes` have been implemented per: [http://hl7.org/fhir/fhirpath.html#functions](http://hl7.org/fhir/fhirpath.html#functions)

## Graph Terminology Service Provider Implementation (experimental)

The FHIR term graph module [fhir-term-graph](https://github.com/IBM/FHIR/tree/main/fhir-term-graph) provides an implementation of `FHIRTermServiceProvider` that is backed by a graph database ([JanusGraph](https://janusgraph.org)). The module also contains term graph loaders for SNOMED-CT Release Format 2 (RF2) files (SnomedTermGraphLoader), UMLS Rich Release Format (RRF) files (UMLSTermGraphLoader), and FHIR CodeSystem resources (CodeSystemTermGraphLoader). The GraphTermServiceProvider can be enabled through the `fhir-server-config.json` file per the configuration properties specified in the [FHIR Server User's Guide](https://ibm.github.io/FHIR/guides/FHIRServerUsersGuide#51-configuration-properties-reference). Example configuration:

``` json
"term": {
"graphTermServiceProvider": {
"enabled": true,
"timeLimit": 30000,
"configuration": {
"storage.backend": "cql",
"storage.hostname": "127.0.0.1",
"index.search.backend": "elasticsearch",
"index.search.hostname": "127.0.0.1:9200",
"storage.read-only": true,
"query.batch": true,
"query.batch-property-prefetch": true,
"query.fast-property": true
}
}
}
```
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public class FHIRConfiguration {
public static final String PROPERTY_EXTENDED_CODEABLE_CONCEPT_VALIDATION = "fhirServer/core/extendedCodeableConceptValidation";
public static final String PROPERTY_DISABLED_OPERATIONS = "fhirServer/core/disabledOperations";

// Terminology service properties
public static final String PROPERTY_GRAPH_TERM_SERVICE_PROVIDER_ENABLED = "fhirServer/term/graphTermServiceProvider/enabled";
public static final String PROPERTY_GRAPH_TERM_SERVICE_PROVIDER_TIME_LIMIT = "fhirServer/term/graphTermServiceProvider/timeLimit";
public static final String PROPERTY_GRAPH_TERM_SERVICE_PROVIDER_CONFIGURATION = "fhirServer/term/graphTermServiceProvider/configuration";

// Resources properties
public static final String PROPERTY_RESOURCES = "fhirServer/resources";
public static final String PROPERTY_FIELD_RESOURCES_OPEN = "open";
Expand Down
31 changes: 31 additions & 0 deletions fhir-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<module>../fhir-model</module>
<module>../fhir-registry</module>
<module>../fhir-term</module>
<module>../fhir-term-graph</module>
JohnTimm marked this conversation as resolved.
Show resolved Hide resolved
<module>../fhir-path</module>
<module>../fhir-profile</module>
<module>../fhir-validation</module>
Expand Down Expand Up @@ -438,6 +439,36 @@
<artifactId>commons-text</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-core</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-berkeleyje</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-cql</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-lucene</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.janusgraph</groupId>
<artifactId>janusgraph-es</artifactId>
<version>0.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>3.4.6</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Loading