diff --git a/Dockerfile b/Dockerfile
index a5e1bdc..ca3cd6d 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
@@ -15,10 +27,13 @@ RUN apk upgrade
RUN apk add bash
RUN apk add gettext
-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/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/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/README.md b/README.md
index 3d349f6..b009763 100644
--- a/README.md
+++ b/README.md
@@ -82,6 +82,71 @@ 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/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 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-icd10.json". This file contains the dictionary data that you will need for importing in the next step.
+
+### 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 ..
+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 ICD10-GM/codesystem-icd10.json $CTR:/var/tmp/icd10/codesystem-icd10.json
+
+docker exec -it $CTR bash
+# You are now in the container
+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/fhir/ValueSet/$expand?url=http://hl7.org/fhir/sid/icd-10-gm&filter=blut'
+exit
+
+```
+
+Note that you will need to precede the "docker exec" with "winpty" if you are using git bash on Windows.
+
## License
Copyright 2020 The Samply Development Community
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..9429748
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,36 @@
+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"
+ image: "samply/icd-dictionary:0.3.1"
+ environment:
+ ICD_DB_HOST: "icd-postgres"
+ ICD_DB_USER: "icd10"
+ ICD_DB_PASSWORD: "icd10"
+ ICD_DB_NAME: "icd10"
+ networks:
+ - "icd-net"
+ ports:
+ - "8081:8080"
+ restart: "always"
+
+networks:
+ icd-net:
+ driver: "bridge"
+
+volumes:
+ icd-postgres-data:
+ name: "icd-postgres-data"
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
diff --git a/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java b/src/main/java/de/samply/icd10dictionary/api/IcdCodeRestController.java
index feeccf0..9bd71af 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.
*
@@ -48,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: