Hermes: "Herald of the gods."
Hermes provides a set of terminology tools built around SNOMED CT including:
- a fast RESTful terminology server with full-text search functionality; ideal for driving autocompletion in user interfaces
- an inference engine in order to analyse SNOMED CT expressions and concepts and derive meaning
- cross-mapping to and from other code systems
It is designed as both library for embedding into larger applications, or as a microservice.
It replaces previous similar tools written in java and golang and is designed to fit into a wider architecture with identifier resolution, mapping and semantics as first-class abstractions.
Ensure you have a pre-built jar file, or the source code checked out from github. See below for build instructions.
In the UK, we can obtain these from TRUD.
For example, you can download the UK "Clinical Edition", containing the International and UK clinical distributions as part of TRUD pack 26/subpack 101.
Optionally, you can also download the UK SNOMED CT drug extension, that contains the dictionary of medicines and devices (dm+d) is available as part of TRUD pack 26/subpack 101.
Depending on where you live in the World, download the most appropriate distribution(s) for your needs.
Once you have downloaded what you need, unzip them to a common directory and
then you can use hermes
to create a file-based database.
If you are running using the jar file:
java -jar hermes.jar -d snomed.db import ~/Downloads/snomed-2020
If you are running from source code:
clj -m com.eldrix.hermes.core -d snomed.db import ~/Downloads/snomed-2020/
The import of distribution files takes about 50 minutes on my 8 year old laptop.
Run
clj -m com.eldrix.hermes.core -d snomed.db index
This will:
- Build entity indices (about 15 minutes)
- Build search index (about 10 minutes)
This reduces the file size by around 20%. It takes considerable memory (heap) to do this although it takes only 3 minutes.
clj -J-X-mx8g com.eldrix.hermes.core -d snomed.db compact
You will usually need to increase the heap space (by using -Xmx8g) in order to complete the compaction step which will reduce the database size by up to 20%.
When I first built terminology tools, either in java or in golang, I needed to also build a custom command-line interface in order to explore the ontology. This is not necessary as most developers using Clojure quickly learn the value of the REPL; a read-evaluate-print-loop in which one can issue arbitrary commands to execute. As such, one has a full Turing-complete language (a lisp) in which to explore the domain.
Run a REPL and use the terminology services interactively.
clj -A:dev
java -jar hermes.jar -d snomed.db -p 8080 serve
or
clj -M -m com.eldrix.hermes.core -d snomed.db -p 8080 serve
In your deps.edn
file (make sure you change the commit-id):
[com.eldrix.hermes {:git/url "https://github.com/wardle/hermes.git"
:sha "097e3094070587dc9362ca4564401a924bea952c"}
clj -M:check
clj -M:test
You will get help text.
clj -M -m com.eldrix.hermes.core
clj -M:outdated
You can view a complete list of dependencies; try:
clj -X:deps tree
Create a POM from the dependencies (or create manually - changing the groupId, artifactId and version):
clj -Spom``
Build the uberjar:
clojure -X:uberjar