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

Icd10 gm docker #12

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 17 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
FROM maven:3.8.1-openjdk-11 AS build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather use GitHub Actions to build the JAR file instead of a build container. Please see https://github.com/samply/store-fhir-adapter/blob/main/.github/workflows/ci.yml

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with Actions, so it could be some time before I can make the requested change.

Would it be possible to incorporate the build container for the time being, and upgrade to GitHub Actions at a later date?


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
Expand All @@ -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"]
24 changes: 24 additions & 0 deletions ICD10-GM/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

22 changes: 22 additions & 0 deletions ICD10-GM/README.txt
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions ICD10-GM/fhir-claml.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions ICD10-GM/run-fhir-claml-in-container.sh
Original file line number Diff line number Diff line change
@@ -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

65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<artifactId>icd10-dictionary</artifactId>
<version>0.3.1</version>
<version>0.4.0-SNAPSHOT</version>

<name>icd10-dictionary</name>
<description>REST Service for ICD10 lookups</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public IcdCodeRestController(
this.searchIcdCodeService = searchIcdCodeService;
}

@GetMapping("/health")
public ResponseEntity<String> check(){
return new ResponseEntity<>("System running", HttpStatus.OK);
}

/**
* Loads ICD-10 catalog from specified location 'clamlFileUri' on server.
*
Expand All @@ -48,7 +53,7 @@ public ResponseEntity<String> 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:
Expand Down