From 55ae0d07f5912e5ffb6f99d240a496aa53442086 Mon Sep 17 00:00:00 2001 From: Alexander Kiel Date: Mon, 13 Dec 2021 15:13:46 +0100 Subject: [PATCH 1/8] Bump Dev Version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index dca7aba..c45a900 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ icd10-dictionary - 0.3.1 + 0.4.0-SNAPSHOT icd10-dictionary REST Service for ICD10 lookups From 10aea11f16bc84acf9947df20a7ad7c4287856cd Mon Sep 17 00:00:00 2001 From: Deniz Tas Date: Fri, 22 Oct 2021 09:50:03 +0200 Subject: [PATCH 2/8] Add Health Check --- .../de/samply/icd10dictionary/api/IcdCodeRestController.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java b/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java index feeccf0..6e5c36d 100644 --- a/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java +++ b/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java @@ -34,6 +34,11 @@ public IcdCodeRestController( this.searchIcdCodeService = searchIcdCodeService; } + @GetMapping("/health") + public ResponseEntity check(){ + return new ResponseEntity<>("System running", HttpStatus.OK); + } + /** * Loads ICD-10 catalog from specified location 'clamlFileUri' on server. * From 9f9f7802f7817024cdc1b0ecf8d876fe289d006d Mon Sep 17 00:00:00 2001 From: Croft Date: Mon, 12 Jul 2021 15:02:59 +0200 Subject: [PATCH 3/8] Helpful additions for admins of an ICD10 dictionary service The main things added are: * A docker-compose.yml file, that builds the JAR and provides both the dictionary itself and also a database. * A Docker-based conversion tool for generating the dictionary in JSON format. --- Dockerfile | 20 +++++++++-- ICD10-GM/Dockerfile | 24 +++++++++++++ ICD10-GM/fhir-claml.sh | 3 ++ ICD10-GM/run-fhir-claml-in-container.sh | 14 ++++++++ docker-compose.yml | 34 +++++++++++++++++++ .../api/IcdCodeRestController.java | 2 +- 6 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 ICD10-GM/Dockerfile create mode 100644 ICD10-GM/fhir-claml.sh create mode 100644 ICD10-GM/run-fhir-claml-in-container.sh create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index a5e1bdc..88d79f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,19 @@ +FROM maven:3.8.1-openjdk-11 AS build + +COPY ./ /workingdir/ +WORKDIR /workingdir + +# Build the JAR file. Use -B and -ntp options, to keep the log file +# under 1MB, because Docker has a built-in log file limit that +# kills the build otherwise. +RUN mvn clean +RUN mvn -B -ntp package + FROM openjdk:14-ea-alpine +COPY --from=build /workingdir/target/icd10-dictionary.jar app.jar + ENV SPRING_PROFILES_ACTIVE=docker -ARG JAR_FILE=target/icd10-dictionary.jar ENV ICD_DB_HOST=localhost ENV ICD_DB_PORT=5432 @@ -14,11 +26,15 @@ RUN apk update RUN apk upgrade RUN apk add bash RUN apk add gettext +RUN apk add curl -COPY ${JAR_FILE} app.jar COPY ./docker/start.sh . RUN chmod +x ./start.sh RUN mkdir config COPY ./docker/docker.template.yml config +# Temp directory for uploading dictionary +RUN mkdir -p /var/tmp/icd10 +RUN chmod a+rx /var/tmp/icd10 + CMD ["./start.sh"] diff --git a/ICD10-GM/Dockerfile b/ICD10-GM/Dockerfile new file mode 100644 index 0000000..41282c7 --- /dev/null +++ b/ICD10-GM/Dockerfile @@ -0,0 +1,24 @@ +FROM maven:3.8.1-openjdk-11 AS build + +RUN mkdir -p /workingdir +WORKDIR /workingdir + +RUN apt update -y && apt install -y git + +# Clone fhir-claml repo +# Build the JAR file for fhir-claml +RUN git clone https://github.com/aehrc/fhir-claml.git && cd fhir-claml && mvn clean && mvn install + +FROM openjdk:11-jdk-slim AS convert + +RUN mkdir -p /workingdir +WORKDIR /workingdir + +RUN apt update -y && apt install -y zip unzip + +COPY --from=build /workingdir/fhir-claml/target/*.jar /workingdir +COPY run-fhir-claml-in-container.sh /workingdir/run-fhir-claml-in-container.sh +RUN chmod a+rx /workingdir/run-fhir-claml-in-container.sh + +RUN ls -la /workingdir + diff --git a/ICD10-GM/fhir-claml.sh b/ICD10-GM/fhir-claml.sh new file mode 100644 index 0000000..2160e3e --- /dev/null +++ b/ICD10-GM/fhir-claml.sh @@ -0,0 +1,3 @@ +ICD10GM_ZIP=$1 +docker build -t local/icd10-gm . # --no-cache +cat $ICD10GM_ZIP | docker run -i local/icd10-gm sh //workingdir/run-fhir-claml-in-container.sh > codesystem-icd10gm.json diff --git a/ICD10-GM/run-fhir-claml-in-container.sh b/ICD10-GM/run-fhir-claml-in-container.sh new file mode 100644 index 0000000..a49d593 --- /dev/null +++ b/ICD10-GM/run-fhir-claml-in-container.sh @@ -0,0 +1,14 @@ +cat > /workingdir/icd10gm-syst-claml.zip +cd /workingdir +unzip icd10gm-syst-claml.zip > /dev/null +cp Klassifikationsdateien/icd10gm2021syst_claml_20200918_20201111.xml /workingdir/icd10gm_syst_claml.xml + +java -jar fhir-claml-0.0.1-SNAPSHOT.jar \ + -i /workingdir/icd10gm_syst_claml.xml \ + -designations preferredLong \ + -o codesystem-icd10gm.json \ + -id icd10gm2020 \ + -url http://hl7.org/fhir/sid/icd-10-gm \ + -valueSet http://hl7.org/fhir/sid/icd-10-gm/vs > /dev/null +cat codesystem-icd10gm.json + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..fc5fd3a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +version: '3.4' +services: + icd-postgres: + container_name: "icd-postgres" + image: "postgres:alpine" + environment: + POSTGRES_USER: "icd10" + POSTGRES_PASSWORD: "icd10" + POSTGRES_DB: "icd10" + networks: + - "icd-net" + volumes: + - "icd-postgres-data:/var/lib/postgresql/data" + restart: "always" + icd-dictionary: + container_name: "icd-dictionary" + image: "icd-dictionary" + environment: + ICD_DB_HOST: "icd-postgres" + ICD_DB_USER: "icd10" + ICD_DB_PASSWORD: "icd10" + ICD_DB_NAME: "icd10" + networks: + - "icd-net" + ports: + - "8080:8080" + +networks: + icd-net: + driver: "bridge" + +volumes: + icd-postgres-data: + name: "icd-postgres-data" diff --git a/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java b/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java index 6e5c36d..9bd71af 100644 --- a/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java +++ b/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java @@ -53,7 +53,7 @@ public ResponseEntity loadFromFile(@RequestBody String clamlFileUri) { case OK: break; case FILE_NOT_FOUND: - return new ResponseEntity<>("File not found", HttpStatus.BAD_REQUEST); + return new ResponseEntity<>("File not found: " + clamlFileUri, HttpStatus.BAD_REQUEST); case DB_NOT_EMPTY: return new ResponseEntity<>("Database not empty", HttpStatus.CONFLICT); case OTHER: From 5daa335c0ce178206b0eed820cda8900bf792c16 Mon Sep 17 00:00:00 2001 From: Croft Date: Mon, 12 Jul 2021 15:47:10 +0200 Subject: [PATCH 4/8] Documented the new functionality --- README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.md b/README.md index 3d349f6..0b6ff00 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,56 @@ docker run --rm -d -e "ICD_DB_HOST=icd-postgres" -p 8080:8080 --network=icd-net This project uses lombok. Though it is not neccessary it is recomended to install a suitable lombok plugin for your IDE (e.g. for IntelliJ Idea install https://plugins.jetbrains.com/plugin/6317-lombok). +## Example usage + +In this section, you will see how to do the following: + +- Generate the dictionary data. +- Start the icd-dictionary using docker-compose +- Import the dictionary data into a running icd-dictionary. + +### Generate dictionary data + +First visit the [BMBF website hosting the data](https://www.dimdi.de/dynamic/.downloads/klassifikationen/icd-10-gm/version2021/icd10gm2021syst-claml-20201111.zip). Scroll to the bottom of the page, click on the checkbox "Ich habe die Downloadbedingungen gelesen und stimme diesen ausdrücklich zu", then click the button "Senden". Save the ZIP file in the folder "ICD10-GM". + +Run the following in the command line console: + +``` +cd ICD10-GM +sh fhir-claml.sh +``` +It will take a few minutes. When it is ready, you should find a new file in the folder: "codesystem-icd10gm.json". This file contains the directory data that you will need for importing in the next step. + +### Start icd-dictionary + +Go back up a level in the folder hierarchy and start icd-dictionary: + +``` +cd .. +docker build -t icd-dictionary . +docker-compose up -d +``` + +### Import dictionary data + +You will need to execute the following steps. They involve copying the data to the running icd-dictionary container, opening a terminal on the container and uploading the data. + +``` +CTR=`docker ps | grep icd-dictionary | awk '{print $1}'` + +docker cp codesystem-icd10gm.json $CTR:/var/tmp/icd10/codesystem-icd10gm.json + +winpty docker exec -it $CTR bash +# You are now in the container +curl -H 'Content-Type:text/plain' -d '/var/tmp/icd10/codesystem-icd10gm.json' http://localhost:8080/api/v1/icd/load +# The following command is a test to make sure that there is content +curl 'http://localhost:8080/icd10/ValueSet/$expand?url=http://hl7.org/fhir/sid/icd-10-gm&filter=blut' +exit + +``` + +Note that you only need to use "winpty" if you are using git bash on Windows. Otherwise, you can use vanilla docker. + ## License Copyright 2020 The Samply Development Community From ec412128d407524f4fab242867eb0c0fa4b8a1a6 Mon Sep 17 00:00:00 2001 From: Croft Date: Mon, 12 Jul 2021 15:51:13 +0200 Subject: [PATCH 5/8] Minor corrections to documentation --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b6ff00..63cac0b 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Run the following in the command line console: cd ICD10-GM sh fhir-claml.sh ``` -It will take a few minutes. When it is ready, you should find a new file in the folder: "codesystem-icd10gm.json". This file contains the directory data that you will need for importing in the next step. +It will take a few minutes. When it is ready, you should find a new file in the folder: "codesystem-icd10gm.json". This file contains the dictionary data that you will need for importing in the next step. ### Start icd-dictionary @@ -124,6 +124,7 @@ docker cp codesystem-icd10gm.json $CTR:/var/tmp/icd10/codesystem-icd10gm.json winpty docker exec -it $CTR bash # You are now in the container curl -H 'Content-Type:text/plain' -d '/var/tmp/icd10/codesystem-icd10gm.json' http://localhost:8080/api/v1/icd/load +rm /var/tmp/icd10/codesystem-icd10gm.json # The following command is a test to make sure that there is content curl 'http://localhost:8080/icd10/ValueSet/$expand?url=http://hl7.org/fhir/sid/icd-10-gm&filter=blut' exit From 6bbac9dcca7bcec1b601dd9fdde0caaad068a8e4 Mon Sep 17 00:00:00 2001 From: David Croft Date: Tue, 9 Nov 2021 12:48:29 +0000 Subject: [PATCH 6/8] Improved documentation Added a README to the ICD10-GM directory Made the README.md more general, so that it will also work for the WHO dictionary. --- ICD10-GM/README.txt | 22 ++++++++++++++++++++++ README.md | 32 +++++++++++++++++++++++--------- docker-compose.yml | 6 ++++-- 3 files changed, 49 insertions(+), 11 deletions(-) create mode 100644 ICD10-GM/README.txt diff --git a/ICD10-GM/README.txt b/ICD10-GM/README.txt new file mode 100644 index 0000000..f3601de --- /dev/null +++ b/ICD10-GM/README.txt @@ -0,0 +1,22 @@ +Convert CLAML to FHIR +--------------------- + +ICD10 dictionaries can be downloaded from: + +https://www.dimdi.de/dynamic/de/klassifikationen/downloads/ + +in CLAML format. However, the ICD10 chooser requires data in FHIR format. + +This directory contains everything you need to do the conversion in one +step, using the fhir-claml.sh script like this: + +sh fhir-claml.sh CLAML-format-dictionary.zip > FHIR-format-dictionary.json + +Files +----- + +Dockerfile Builds conversion image +fhir-claml.sh Runs conversion, using container +run-fhir-claml-in-container.sh Conversion script that runs inside container +*.zip Input to conversion script +*.json Output from conversion script diff --git a/README.md b/README.md index 63cac0b..a978f75 100644 --- a/README.md +++ b/README.md @@ -92,19 +92,33 @@ In this section, you will see how to do the following: ### Generate dictionary data -First visit the [BMBF website hosting the data](https://www.dimdi.de/dynamic/.downloads/klassifikationen/icd-10-gm/version2021/icd10gm2021syst-claml-20201111.zip). Scroll to the bottom of the page, click on the checkbox "Ich habe die Downloadbedingungen gelesen und stimme diesen ausdrücklich zu", then click the button "Senden". Save the ZIP file in the folder "ICD10-GM". +First visit the [BMBF website hosting the data](https://www.dimdi.de/dynamic/de/downloads/). + +Scroll down to the choosers. Click on the one labelled "ICD-10-GM" for the German language dictionary, or the one labelled "ICD-10-WHO" for the English language dictionary. + +Pick the most recent version. + +You will see a list of files to the right of the choosers. Click on the ClaML/XML file. + +You will be brought to a new page. Scroll to the bottom, click on the checkbox "Ich habe die Downloadbedingungen gelesen und stimme diesen ausdrücklich zu", then click the button "Senden". Change the name of the ZIP file to "codesystem-icd10.zip" and save it in the folder "ICD10-GM". Run the following in the command line console: ``` cd ICD10-GM -sh fhir-claml.sh +sh fhir-claml.sh codesystem-icd10.zip > codesystem-icd10.json ``` -It will take a few minutes. When it is ready, you should find a new file in the folder: "codesystem-icd10gm.json". This file contains the dictionary data that you will need for importing in the next step. +It will take a few minutes. When it is ready, you should find a new file in the folder: "codesystem-icd10.json". This file contains the dictionary data that you will need for importing in the next step. ### Start icd-dictionary -Go back up a level in the folder hierarchy and start icd-dictionary: +If this is not the first time that you have loaded data to the ICD10 chooser, you will need to wipe the database clean: + +``` +docker volume rm icd-postgres-data +``` + +Now go back up a level in the folder hierarchy and start icd-dictionary: ``` cd .. @@ -119,19 +133,19 @@ You will need to execute the following steps. They involve copying the data to t ``` CTR=`docker ps | grep icd-dictionary | awk '{print $1}'` -docker cp codesystem-icd10gm.json $CTR:/var/tmp/icd10/codesystem-icd10gm.json +docker cp ICD10-GM/codesystem-icd10.json $CTR:/var/tmp/icd10/codesystem-icd10.json -winpty docker exec -it $CTR bash +docker exec -it $CTR bash # You are now in the container -curl -H 'Content-Type:text/plain' -d '/var/tmp/icd10/codesystem-icd10gm.json' http://localhost:8080/api/v1/icd/load -rm /var/tmp/icd10/codesystem-icd10gm.json +curl -H 'Content-Type:text/plain' -d '/var/tmp/icd10/codesystem-icd10.json' http://localhost:8080/api/v1/icd/load +rm /var/tmp/icd10/codesystem-icd10.json # The following command is a test to make sure that there is content curl 'http://localhost:8080/icd10/ValueSet/$expand?url=http://hl7.org/fhir/sid/icd-10-gm&filter=blut' exit ``` -Note that you only need to use "winpty" if you are using git bash on Windows. Otherwise, you can use vanilla docker. +Note that you will need to precede the "docker exec" with "winpty" if you are using git bash on Windows. ## License diff --git a/docker-compose.yml b/docker-compose.yml index fc5fd3a..9429748 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,8 @@ services: restart: "always" icd-dictionary: container_name: "icd-dictionary" - image: "icd-dictionary" + #image: "icd-dictionary" + image: "samply/icd-dictionary:0.3.1" environment: ICD_DB_HOST: "icd-postgres" ICD_DB_USER: "icd10" @@ -23,7 +24,8 @@ services: networks: - "icd-net" ports: - - "8080:8080" + - "8081:8080" + restart: "always" networks: icd-net: From 7d12794c6aa310fc7cc65ded68b75739efcbda70 Mon Sep 17 00:00:00 2001 From: Croft Date: Mon, 12 Jul 2021 16:39:03 +0200 Subject: [PATCH 7/8] Further corrections to documentation ...because I tried it out for real, and it didn't work! --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a978f75..b009763 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ docker exec -it $CTR bash curl -H 'Content-Type:text/plain' -d '/var/tmp/icd10/codesystem-icd10.json' http://localhost:8080/api/v1/icd/load rm /var/tmp/icd10/codesystem-icd10.json # The following command is a test to make sure that there is content -curl 'http://localhost:8080/icd10/ValueSet/$expand?url=http://hl7.org/fhir/sid/icd-10-gm&filter=blut' +curl 'http://localhost:8080/fhir/ValueSet/$expand?url=http://hl7.org/fhir/sid/icd-10-gm&filter=blut' exit ``` From 36cfee28f11624b01193dd465f3a0ec68fd6189d Mon Sep 17 00:00:00 2001 From: Croft Date: Fri, 16 Jul 2021 14:15:33 +0200 Subject: [PATCH 8/8] Curl not needed --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 88d79f1..ca3cd6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,6 @@ RUN apk update RUN apk upgrade RUN apk add bash RUN apk add gettext -RUN apk add curl COPY ./docker/start.sh . RUN chmod +x ./start.sh