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

Feat identifier cols #39

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ccbb0bb
fix(deps): update dependency ca.uhn.hapi.fhir:hapi-fhir-client to v6
renovate[bot] Aug 19, 2022
c9b3ad3
fix(deps): update dependency ca.uhn.hapi.fhir:hapi-fhir-base to v6
renovate[bot] Aug 19, 2022
9c852d8
chore(deps): update docker/build-push-action action to v3
renovate-bot May 15, 2022
2b0dd18
chore(deps): update docker.vectorized.io/vectorized/redpanda docker t…
renovate[bot] Aug 19, 2022
e3cee46
chore(deps): update actions/checkout action to v3
renovate[bot] Aug 19, 2022
91d4d93
chore(deps): update actions/cache action to v3
renovate-bot Mar 26, 2022
a821897
chore(deps): update actions/setup-node action to v3
renovate[bot] Aug 19, 2022
c72305c
chore(deps): update actions/setup-python action to v4
renovate[bot] Jun 18, 2022
7d926e3
chore(deps): update all non-major dependencies docker tags
renovate[bot] Aug 19, 2022
46b8d33
chore(deps): update all non-major dependencies
renovate[bot] Jun 23, 2022
873d315
feat: partitioning by default
kapsner Mar 22, 2022
189c936
chore: updated readme to current schema creation
kapsner Mar 22, 2022
513fa33
feat: new id columns for patient id and encounter id
kapsner Mar 22, 2022
4c2772e
chore: updated todos for https://github.com/miracum/fhir-gateway/issu…
kapsner May 10, 2022
0363f6e
chore(ci): disable sqlfluff in ci bc not working
makampf Aug 19, 2022
2d1bb09
chore(ci): apply spotless to fix ci
makampf Aug 19, 2022
e42f63c
chore(ci): bump codeql action
makampf Aug 19, 2022
cb4d5db
chore(test): replace deprecated h2 init property
makampf Sep 5, 2022
6be9205
chore(deps): updates fhir-pseud
makampf Sep 5, 2022
4b482d2
return to 1.6.0 fhir-pseudonymizer
makampf Sep 19, 2022
c551b61
update gpas in fhir-gw dev env
makampf Sep 19, 2022
f0d5ec8
move wildfly folder to e2e
makampf Sep 19, 2022
14c3298
return to old gpas
makampf Sep 19, 2022
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
17 changes: 9 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
- name: Run pre-commit
uses: pre-commit/[email protected]
- name: Lint code base
Expand All @@ -29,6 +29,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_EXCLUDE: "gradlew"
VALIDATE_JAVA: false
VALIDATE_SQLFLUFF: false
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
Expand All @@ -39,7 +40,7 @@ jobs:
output: "trivy-results.sarif"
severity: "CRITICAL"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v1
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
build:
Expand All @@ -48,7 +49,7 @@ jobs:
needs: lint
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
Expand All @@ -75,7 +76,7 @@ jobs:
username: "robot$miracum-etl+github-actions"
password: ${{ secrets.MIRACUM_HARBOR_ETL_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand All @@ -93,7 +94,7 @@ jobs:
IS_PULL_REQUEST: ${{ github.event_name == 'pull_request' }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
Expand Down Expand Up @@ -145,11 +146,11 @@ jobs:
if: ${{ github.event_name != 'pull_request' }}
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 14
- name: Install semantic release
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM gradle:7.3-jdk17 AS build
FROM gradle:7.5.1-jdk17 AS build
WORKDIR /home/gradle/src
ENV GRADLE_USER_HOME /gradle

Expand All @@ -24,4 +24,4 @@ USER 65532
ARG VERSION=0.0.0
ENV APP_VERSION=${VERSION} \
SPRING_PROFILES_ACTIVE="prod"
ENTRYPOINT ["java", "-XX:MaxRAMPercentage=85", "org.springframework.boot.loader.JarLauncher"]
ENTRYPOINT ["java", "-XX:MaxRAMPercentage=50", "org.springframework.boot.loader.JarLauncher"]
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ partitioning to split the stored resources by type. Run the following **before**
FHIR-Gateway to create the `resources` table with partitions for the most common resource types:

```postgresql
CREATE TABLE resources
CREATE TABLE IF NOT EXISTS resources
(
id serial,
id bigserial PRIMARY KEY,
patient_id varchar(64) NOT NULL,
encounter_id varchar(64) NOT NULL,
fhir_id varchar(64) NOT NULL,
type varchar(64) NOT NULL,
data jsonb NOT NULL,
Expand All @@ -118,9 +120,12 @@ CREATE TABLE resources_medication_administration PARTITION OF resources FOR VALU
CREATE TABLE resources_procedure PARTITION OF resources FOR VALUES IN ('Procedure');
CREATE TABLE resources_others PARTITION OF resources DEFAULT;

CREATE INDEX resource_id_idx ON resources (id);
CREATE INDEX resource_type_idx ON resources (type);
CREATE INDEX last_updated_at_idx ON resources (last_updated_at DESC);
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS resource_id_idx ON resources (id);
CREATE INDEX IF NOT EXISTS resource_type_idx ON resources (type);
CREATE INDEX IF NOT EXISTS last_updated_at_idx ON resources (last_updated_at DESC);

CREATE INDEX IF NOT EXISTS resource_pat_id_idx ON resources (patient_id);
CREATE INDEX IF NOT EXISTS resource_enc_id_idx ON resources (encounter_id);
```

Be sure to set `SPRING_SQL_INIT_MODE=never` before starting the FHIR GW.
Expand Down
33 changes: 15 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id "org.springframework.boot" version "2.5.6"
id "io.spring.dependency-management" version "1.0.11.RELEASE"
id "org.springframework.boot" version "2.7.3"
id "io.spring.dependency-management" version "1.0.13.RELEASE"
id "java"
id "jacoco"
id "com.diffplug.spotless" version "6.0.4"
id "com.diffplug.spotless" version "6.9.1"
}

group = "org.miracum.etl"
Expand All @@ -22,10 +22,7 @@ configurations {
}

ext {
set("springCloudVersion", "2020.0.4")
// Mitigation for CVE-2021-44228
// https://spring.io/blog/2021/12/10/log4j2-vulnerability-and-spring-boot
set("log4j2.version", "2.16.0")
set("springCloudVersion", "2021.0.3")
}

repositories {
Expand All @@ -45,26 +42,26 @@ dependencies {

implementation "org.miracum:kafka-fhir-serializer:1.0.2"

implementation "io.micrometer:micrometer-registry-prometheus:1.8.1"
implementation "io.micrometer:micrometer-core:1.8.1"
implementation "io.micrometer:micrometer-registry-prometheus:1.9.3"
implementation "io.micrometer:micrometer-core:1.9.3"

implementation "net.logstash.logback:logstash-logback-encoder:7.0.1"
implementation "net.logstash.logback:logstash-logback-encoder:7.2"

implementation "ca.uhn.hapi.fhir:hapi-fhir-base:5.6.1"
implementation "ca.uhn.hapi.fhir:hapi-fhir-client:5.6.1"
implementation "ca.uhn.hapi.fhir:org.hl7.fhir.r4:5.6.15"
implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r4:5.6.1"
implementation "ca.uhn.hapi.fhir:hapi-fhir-client-okhttp:5.6.1"
implementation "ca.uhn.hapi.fhir:hapi-fhir-base:6.1.0"
implementation "ca.uhn.hapi.fhir:hapi-fhir-client:6.1.0"
implementation "ca.uhn.hapi.fhir:org.hl7.fhir.r4:5.6.54"
implementation "ca.uhn.hapi.fhir:hapi-fhir-structures-r4:5.7.9"
implementation "ca.uhn.hapi.fhir:hapi-fhir-client-okhttp:5.7.9"

implementation "io.opentracing.contrib:opentracing-spring-web-starter:4.1.0"
implementation "io.opentracing.contrib:opentracing-spring-jaeger-web-starter:3.3.1"
implementation "io.opentracing.contrib:opentracing-spring-jaeger-cloud-starter:3.3.1"
implementation "io.opentracing.contrib:opentracing-okhttp3:3.0.0"
implementation "io.jaegertracing:jaeger-client:1.6.0"
implementation "io.jaegertracing:jaeger-client:1.8.1"

developmentOnly "org.springframework.boot:spring-boot-devtools"
runtimeOnly "org.postgresql:postgresql:42.3.1"
runtimeOnly "com.h2database:h2:2.0.202"
runtimeOnly "org.postgresql:postgresql:42.4.2"
runtimeOnly "com.h2database:h2:2.1.214"
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
testImplementation "org.springframework.boot:spring-boot-starter-test"
}
Expand Down
6 changes: 3 additions & 3 deletions deploy/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"

services:
mock-data-loader:
image: confluentinc/cp-kafkacat:7.0.1
image: confluentinc/cp-kafkacat:7.1.3
entrypoint: [ "/bin/bash", "-c" ]
command: >
"while true; do
Expand All @@ -17,7 +17,7 @@ services:
- kafka1

kafka1:
image: docker.vectorized.io/vectorized/redpanda:v21.11.2
image: docker.vectorized.io/vectorized/redpanda:v22.2.1
container_name: kafka1
command:
- redpanda
Expand All @@ -39,7 +39,7 @@ services:
- 9644:9644

akhq:
image: tchiotludo/akhq:0.19.0
image: tchiotludo/akhq:0.22.0
environment:
AKHQ_CONFIGURATION: |
akhq:
Expand Down
11 changes: 6 additions & 5 deletions deploy/docker-compose.gw-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@ version: "3.9"

services:
jaeger:
image: jaegertracing/all-in-one:1.29
image: jaegertracing/all-in-one:1.37

fhir-pseudonymizer:
image: harbor.miracum.org/miracum-etl/fhir-pseudonymizer:v1.6.0
environment:
JAEGER__HOST: jaeger
JAEGER__PORT: 6831
GPAS__URL: ${GPAS_URL:-http://gpas:8080/gpas/gpasService}
GPAS__VERSION: ${GPAS_VERSION:-1.11.0}
volumes:
- ./anonymization.yaml:/etc/anonymization.yaml:ro
depends_on:
- jaeger
- gpas

loinc-converter:
image: harbor.miracum.org/miracum-etl/loinc-conversion:v1.13.1
image: harbor.miracum.org/miracum-etl/loinc-conversion:v1.13.3
environment:
JAEGER_AGENT_HOST: jaeger
depends_on:
- jaeger

fhir-db:
image: postgres:14.1
image: postgres:14.5
environment:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fhir
Expand All @@ -44,7 +45,7 @@ services:
image: docker.io/hapiproject/hapi:v5.6.0-distroless

gpasinit-patient:
image: curlimages/curl:7.80.0
image: curlimages/curl:7.84.0
command: |
-X POST
-H 'Content-Type:application/xml'
Expand Down Expand Up @@ -73,7 +74,7 @@ services:
- gpas

gpasinit-fall:
image: curlimages/curl:7.80.0
image: curlimages/curl:7.84.0
command: |
-X POST
-H 'Content-Type:application/xml'
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.9"

services:
gateway:
image: ${FHIR_GATEWAY_IMAGE_NAME:-ghcr.io/miracum/fhir-gateway:v3.10.2}
image: ${FHIR_GATEWAY_IMAGE_NAME:-ghcr.io/miracum/fhir-gateway:v3.10.3}
restart: on-failure
environment:
SPRING_DATASOURCE_URL: ${SPRING_DATASOURCE_URL:-jdbc:postgresql://fhir-db:5432/fhir}
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
14 changes: 8 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ private int insertResources(Bundle bundle) {
.map(
resource ->
new Object[] {
// TODO add encounter id / patient id / encounter_start date here
// this would depend also on the resources, e.g.
// type = "Patient": Encounter-ID: NULL, Patient-ID: Patient.id
// type = "Encounter": Encounter-ID: Encounter.id, Patient.id:
// REPLACE(jsonb_path_query(Encounter.DATA, '$.subject') ->> 'reference',
// 'Patient/', '')
// type = "Condition": Encounter-ID: REPLACE(Condition.DATA -> 'encounter' ->>
// 'reference', 'Encounter/', '')
// type = "Procedure": Encounter-ID: REPLACE(Procedure.DATA -> 'encounter' ->>
// 'reference', 'Encounter/', '')
// type = "Observation": Encounter-ID: REPLACE(Observation.DATA -> 'encounter'
// ->> 'reference', 'Encounter/', '')
resource.getIdElement().getIdPart(),
resource.fhirType(),
fhirParser.encodeResourceToString(resource)
Expand Down
17 changes: 16 additions & 1 deletion src/main/resources/schema.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
CREATE TABLE IF NOT EXISTS resources
(
id bigserial PRIMARY KEY,
patient_id varchar(64) NOT NULL,
encounter_id varchar(64) NOT NULL,
fhir_id varchar(64) NOT NULL,
type varchar(64) NOT NULL,
data jsonb NOT NULL,
created_at timestamp NOT NULL DEFAULT NOW(),
last_updated_at timestamp NOT NULL DEFAULT NOW(),
is_deleted boolean NOT NULL DEFAULT FALSE,
CONSTRAINT fhir_id_unique UNIQUE (fhir_id, type)
);
) PARTITION BY LIST (type);

CREATE TABLE resources_patient PARTITION OF resources FOR VALUES IN ('Patient');
CREATE TABLE resources_encounter PARTITION OF resources FOR VALUES IN ('Encounter');
CREATE TABLE resources_condition PARTITION OF resources FOR VALUES IN ('Condition');
CREATE TABLE resources_observation PARTITION OF resources FOR VALUES IN ('Observation');
CREATE TABLE resources_medication PARTITION OF resources FOR VALUES IN ('Medication');
CREATE TABLE resources_medication_statement PARTITION OF resources FOR VALUES IN ('MedicationStatement');
CREATE TABLE resources_medication_administration PARTITION OF resources FOR VALUES IN ('MedicationAdministration');
CREATE TABLE resources_procedure PARTITION OF resources FOR VALUES IN ('Procedure');
CREATE TABLE resources_others PARTITION OF resources DEFAULT;

CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS resource_id_idx ON resources (id);
CREATE INDEX IF NOT EXISTS resource_type_idx ON resources (type);
CREATE INDEX IF NOT EXISTS last_updated_at_idx ON resources (last_updated_at DESC);

CREATE INDEX IF NOT EXISTS resource_pat_id_idx ON resources (patient_id);
CREATE INDEX IF NOT EXISTS resource_enc_id_idx ON resources (encounter_id);
4 changes: 2 additions & 2 deletions src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ spring:
url: jdbc:h2:mem:db;DB_CLOSE_DELAY=-1
username: sa
password: sa
# disabled initialization for now as H2 won't work with the JSONB data type
initialization-mode: never
# disabled initialization for now as H2 won't work with the JSONB data type
sql.init.mode: never
services:
gpas:
enabled: false