Git Product home page Git Product logo

fhir-gateway's Issues

bigserial for large FHIR-GW Databases

Hi,

we have used the FHIR-GW extensively at our site and the included postgres DB has reached the id limit for the id column.
hence we had to alter the id column from serial to bigserial.

See https://www.postgresql.org/docs/current/datatype-numeric.html

alter sequence resources_id_seq as bigint;
alter table resources alter id type bigint;

These command in our case also resulted in some data loss, which is why we had to reload the data.
Hence I would suggest to add to Database Tuning part, to consider bigserial as for the id column, if more data than 2 billion FHIR resources is expected.
This would avoid having need to create DB Dump, altering the structure and restoring the data for the db.

Fix duplicate `seconds` in pipeline duration metrics name

Currently exported as fhirgateway_pipeline_duration_seconds_seconds_bucket should just be fhirgateway_pipeline_duration_seconds_bucket.

Should be a simple fix in: https://github.com/miracum/fhir-gateway/blob/master/src/main/java/org/miracum/etl/fhirgateway/processors/ResourcePipeline.java#L18

See also: https://github.com/miracum/fhir-gateway/blob/master/src/main/java/org/miracum/etl/fhirgateway/stores/PostgresFhirResourceRepository.java#L32 fhirgateway_postgres_operation_duration_seconds_seconds_bucket

observation code changes

After sending an observation to the gateway the resource is saved, but with differences in the codes.
This happens when I send an observation with two codings. Example:

    "code": {
        "coding": [
            {
                "system": "http://example.de/fhir/CodeSystem/icu/ObservationCode",
                "code": "g-THRO",
                "display": "Eb-THRO"
            },
            {
                "system": "http://loinc.org",
                "code": "777-3"
            }
        ]
    }

After sending the resource via HTTP PUT to the gateway URL, i can find the resource in the database, but with this code:

  "code": {
    "coding": [
      {
        "code": "777-3",
        "system": "http://example.de/fhir/CodeSystem/icu/ObservationCode",
        "display": "Platelets [#/volume] in Blood by Automated count"
      },
      {
        "code": "777-3",
        "system": "http://loinc.org"
      }
    ]
  }

I think this has something to do with the LOINC converter, but as I already have a LOINC code in this resource LOINC converter should not delete my observation code.

Bug: SQL cannot be executed in a reasonable time

This SQL statement takes very very long to return the results:

SELECT 
r1.fhir_id AS "Fall.Versorgungsstellenkontakt.Aufnahmenummer", 
r2.cd_system ->> 'code' AS "Laborbefund.Laboruntersuchung.Code" 
FROM ( SELECT * FROM ( 
SELECT 
fhir_id, 
to_timestamp(jsonb_path_query(DATA, '$.period') ->> 'start', 'YYYY-MM-DDTHH:MI:SS') AS fhir_start_date, 
jsonb_array_elements_text(jsonb_path_query(DATA, '$.meta.profile')) AS fhir_profile 
FROM resources 
WHERE TYPE = 'Encounter') AS r_intermediate ) r1 
LEFT JOIN ( 
SELECT 
REPLACE(jsonbdata2 -> 'encounter' ->> 'reference', 'Encounter/', '') AS eid, 
cd_system FROM ( 
SELECT 
DATA AS jsonbdata2, 
jsonb_array_elements(jsonb_path_query(DATA, '$.code.coding')) AS cd_system, 
jsonb_array_elements(jsonb_path_query(DATA, '$.category.coding')) AS cd_category 
FROM resources 
WHERE TYPE = 'Observation') r3 
WHERE r3.cd_system ->> 'system' = 'http://loinc.org/' AND 
r3.cd_category ->> 'code' = '26436-6' 
) r2 ON 
r2.eid = r1.fhir_id 
WHERE r1.fhir_profile = 'https://fhir.miracum.org/core/StructureDefinition/Versorgungsfall';

It would be great, if the fhir-gateway could somehow be "enhanced" in a way, that this and similar SQL statements can be executed in a reasonable amount of time.

Some suggestions exist already, e.g.

  • introducing ID-columns with indices that can be used for joining: #31
  • setting indices direclty inside the JSON: #42

Message Loop, falls SERVICES_KAFKA_GENERATE_OUTPUT_TOPIC_MATCH_EXPRESSION nicht auf Input Topic Name matcht

inputTopic.replaceFirst(generateTopicMatchExpression, generateTopicReplacement);

replaceFirst() gibt den Input-Topic-Name ohne Änderung zurück, falls generateTopicMatchExpression nicht gefunden wird, wodurch die eingelesenen Messages wieder im Input Topic landen und erneut eingelesen werden -> Infinite Loop

Add new columns to table 'resources'

For performance purposes / faster filtering etc. it would be good to have 3 additional columns available in the 'resources' table, namely:

  • Patient-ID:
    • REPLACE(jsonb_path_query(DATA, '$.subject') ->> 'reference', 'Patient/', '') or
    • DATA ->> 'id' (for resource-type = 'Patient')
  • Encounter-ID:
    • REPLACE(DATA -> 'encounter' ->> 'reference', 'Encounter/', '') [e.g. for resource-type = 'Condition']
    • DATA ->> 'id' (for resource-type = 'Encounter')
  • Encounter-Start-Date
    • to_timestamp(jsonb_path_query(DATA, '$.period') ->> 'start', 'YYYY-MM-DDTHH:MI:SS') [e.g. for resource-type = 'Encounter']

set indices in json

For better performance, set indices on json-items to enhance user-experience and speed when joining:

Patient-ID, e.g.:

  • Patient.DATA ->> 'id'
  • REPLACE(jsonb_path_query(Encounter.DATA, '$.subject') ->> 'reference', 'Patient/', '')

Encounter-ID, e.g.:

  • Encounter.DATA ->> 'id'
  • REPLACE(Condition.DATA -> 'encounter' ->> 'reference', 'Encounter/', '')
  • REPLACE(Procedure.DATA -> 'encounter' ->> 'reference', 'Encounter/', '')
  • REPLACE(Observation.DATA -> 'encounter' ->> 'reference', 'Encounter/', '')

Problems with skipping FHIR-DB

When running the FHIR-GW without FHIR-DB (SPRING_DATASOURCE_URL set empty, SERVICES_PSQL_ENABLED set to false) the FHIR-GW does not start properly.
Instead it continously restarts every X seconds.

The Error Message vom Docker-Log includes:

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'skipPattern' defined in class path resource [io/opentracing/contrib/spring/web/starter/SkipPatternAutoConfiguration.class]

Caused by: org.h2.jdbc.JdbcSQLNonTransientException: Unknown data type: "JSONB";

Is there anything else to do, when trying to run FHIR-GW without FHIR-DB?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update docker.io/bitnami/kafka:3.7.0 docker digest to 9abe5ce
  • chore(deps): update docker.io/library/debian:12.5-slim docker digest to 67f3931
  • chore(deps): update docker.io/library/gradle:8.7.0-jdk21 docker digest to afba668
  • chore(deps): update docker.io/library/postgres:16.2 docker digest to 4aea012
  • chore(deps): update gcr.io/distroless/java21-debian12:nonroot docker digest to 0ba7333
  • chore(deps): update github-actions (actions/checkout, actions/download-artifact, amannn/action-semantic-pull-request, github/codeql-action, miracum/.github, ossf/scorecard-action)
  • chore(deps): update all non-major dependencies (docker.io/curlimages/curl, docker.io/hapiproject/hapi, docker.io/library/gradle, docker.io/library/postgres, ghcr.io/miracum/fhir-pseudonymizer, gradle, tchiotludo/akhq, io.micrometer:micrometer-core, io.micrometer:micrometer-registry-prometheus, org.miracum:kafka-fhir-serializer, ca.uhn.hapi.fhir:hapi-fhir-client-okhttp, ca.uhn.hapi.fhir:hapi-fhir-structures-r4, ca.uhn.hapi.fhir:hapi-fhir-client, ca.uhn.hapi.fhir:hapi-fhir-base, org.springframework.cloud:spring-cloud-dependencies, io.spring.dependency-management, org.springframework.boot)

Detected dependencies

docker-compose
deploy/docker-compose.dev.yml
  • docker.io/edenhill/kcat 1.7.1@sha256:8f16a5fed099931ce1122420b7473efe467ff9841d53680b99db25dd1723d711
  • docker.io/bitnami/kafka 3.7.0@sha256:c1e54c8bc46edfc23c25d53f6de1b1433e2e919870c679fa7a846a8af0b03427
  • tchiotludo/akhq 0.24.0@sha256:6ccf8323ae6e93a893107f857cd9f7210add3569743b2c8528c6567967cc636f
deploy/docker-compose.exposed.yml
deploy/docker-compose.gw-deps.yml
  • ghcr.io/miracum/fhir-pseudonymizer v2.21.9@sha256:0511c4d723e5552fb6dbfbc993bd908fdac77d395fc836eb65dabf5dc3a8260c
  • ghcr.io/miracum/loinc-conversion v1.14.10@sha256:45705e91624a2c4d24e988e742870e07f9b9eb34dc16de7a876f58497b1dc846
  • docker.io/library/postgres 16.2@sha256:6b841c8f6a819884207402f1209a8116844365df15fca8cf556fc54a24c70800
  • ghcr.io/miracum/vfps v1.3.5@sha256:358427b400bd260000396aecb0d4a6f874d394ccb52c62897953493a2b8aac15
  • docker.io/hapiproject/hapi v7.0.3@sha256:73ff82fec42e5cbb7e66338d47af09ba91c140e98beeaee41a5459572d5ae1ce
  • docker.io/library/postgres 16.2@sha256:6b841c8f6a819884207402f1209a8116844365df15fca8cf556fc54a24c70800
  • docker.io/curlimages/curl 8.7.1@sha256:25d29daeb9b14b89e2fa8cc17c70e4b188bca1466086907c2d9a4b56b59d8e21
  • docker.io/curlimages/curl 8.7.1@sha256:25d29daeb9b14b89e2fa8cc17c70e4b188bca1466086907c2d9a4b56b59d8e21
deploy/docker-compose.yml
dockerfile
Dockerfile
  • docker.io/library/gradle 8.7.0-jdk21@sha256:01ec604a8b1748c4678dfc214872487e154e13318f42bc4c01de644dc9c5d447
  • docker.io/library/debian 12.5-slim@sha256:155280b00ee0133250f7159b567a07d7cd03b1645714c3a7458b2287b0ca83cb
  • gcr.io/distroless/java21-debian12 nonroot@sha256:58f89bf86a6d0f71904a14382bab3116f97b77cd07ee44416a6628cfd971f944
github-actions
.github/workflows/ci.yaml
  • miracum/.github v1.8.3@392030c6f94fcfaa509a606af2b0907d022f2257
  • actions/download-artifact v4.1.4@c850b930e6ba138125429b7e5c93fc707a7f8427
  • madrapps/jacoco-report v1.6.1@db72e7e7c96f98d239967958b0a0a6ca7d3bb45f
  • actions/checkout v4.1.4@0ad4b8fadaa221de15dcec353f45205ec38ea70b
  • actions/download-artifact v4.1.7@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
  • miracum/.github v1.8.3@392030c6f94fcfaa509a606af2b0907d022f2257
  • miracum/.github v1.8.3@392030c6f94fcfaa509a606af2b0907d022f2257
  • ubuntu 22.04
  • ubuntu 22.04
.github/workflows/lint-pr-title.yaml
  • amannn/action-semantic-pull-request v5@e9fabac35e210fea40ca5b14c0da95a099eff26f
  • ubuntu 22.04
.github/workflows/schedule.yaml
  • miracum/.github v1.8.3@392030c6f94fcfaa509a606af2b0907d022f2257
.github/workflows/scorecard.yaml
  • actions/checkout v4.1.4@0ad4b8fadaa221de15dcec353f45205ec38ea70b
  • ossf/scorecard-action v2.3.1@0864cf19026789058feabb7e87baa5f140aac736
  • actions/upload-artifact v4.3.3@65462800fd760344b1a7b4382951275a0abb4808
  • github/codeql-action v3.25.3@d39d31e687223d841ef683f52467bd88e9b21c14
gradle
settings.gradle
build.gradle
  • org.springframework.boot 3.2.5
  • io.spring.dependency-management 1.1.4
  • com.diffplug.spotless 6.25.0
  • org.miracum:kafka-fhir-serializer 1.0.5
  • io.micrometer:micrometer-registry-prometheus 1.12.5
  • io.micrometer:micrometer-core 1.12.5
  • net.logstash.logback:logstash-logback-encoder 7.4
  • ca.uhn.hapi.fhir:hapi-fhir-base 7.0.2
  • ca.uhn.hapi.fhir:hapi-fhir-client 7.0.2
  • ca.uhn.hapi.fhir:hapi-fhir-structures-r4 7.0.2
  • ca.uhn.hapi.fhir:hapi-fhir-client-okhttp 7.0.2
  • org.postgresql:postgresql 42.7.3
  • com.h2database:h2 2.2.224
  • org.springframework.cloud:spring-cloud-dependencies 2023.0.1
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 8.7

  • Check this box to trigger a request for Renovate to run again on this repository

application.yml doesn't allow error free start when SERVICES_PSQL_ENABLED is false

Hi,

Error description

when using the given default docker-compose.yml and set SERVICES_PSQL_ENABLED false, the start of the container fails, because of an setting in the application.yml.

start up log.

.... 
gateway-1             | 2023-12-01 12:08:08.939  INFO --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
gateway-1             | 2023-12-01 12:08:09.116  INFO --- [           main] com.zaxxer.hikari.pool.HikariPool        : HikariPool-1 - Added connection conn0: url=jdbc:h2:mem:05d8e72e-3558-4220-9d9a-75b79f6835f0 user=SA
gateway-1             | 2023-12-01 12:08:09.118  INFO --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
gateway-1             | 2023-12-01 12:08:09.138  WARN --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fhirController' defined in file [/opt/fhir-gateway/BOOT-INF/classes/org/miracum/etl/fhirgateway/controllers/FhirController.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'resourcePipeline' defined in file [/opt/fhir-gateway/BOOT-INF/classes/org/miracum/etl/fhirgateway/processors/ResourcePipeline.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'postgresFhirResourceRepository' defined in file [/opt/fhir-gateway/BOOT-INF/classes/org/miracum/etl/fhirgateway/stores/PostgresFhirResourceRepository.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Failed to execute SQL script statement #1 of class path resource [schema.sql]: CREATE TABLE IF NOT EXISTS resources ( id bigserial PRIMARY KEY, 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) )
gateway-1             | 2023-12-01 12:08:09.138  INFO --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
gateway-1             | 2023-12-01 12:08:09.145  INFO --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
gateway-1             | 2023-12-01 12:08:09.148  INFO --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
gateway-1             | 2023-12-01 12:08:09.166  INFO --- [           main] .s.b.a.l.ConditionEvaluationReportLogger :
gateway-1             |
gateway-1             | Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
gateway-1             | 2023-12-01 12:08:09.181 ERROR --- [           main] o.s.boot.SpringApplication               : Application run failed
gateway-1             |
gateway-1             | org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fhirController' defined in file [/opt/fhir-gateway/BOOT-INF/classes/org/miracum/etl/fhirgateway/controllers/FhirController.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'resourcePipeline' defined in file [/opt/fhir-gateway/BOOT-INF/classes/org/miracum/etl/fhirgateway/processors/ResourcePipeline.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'postgresFhirResourceRepository' defined in file [/opt/fhir-gateway/BOOT-INF/classes/org/miracum/etl/fhirgateway/stores/PostgresFhirResourceRepository.class]: Unsatisfied dependency expressed through constructor parameter 1: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Failed to execute SQL script statement #1 of class path resource [schema.sql]: CREATE TABLE IF NOT EXISTS resources ( id bigserial PRIMARY KEY, 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) )
gateway-1             |         at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:801) ~[spring-beans-6.0.13.jar:6.0.13]

Cause:


The SPRING_SQL_INIT_MODE variable or rather spring app setting is set to always which causes the startup of the gateway trying to execute a SQL schema init script, on a none existing DB as far as I understand.

Solution

Set SPRING_SQL_INIT_MODE to never, so the SQL script is disabled, when wanting to deactivate the DB output.
Maybe you have a better solution to it, but the setting used to be on never in previous versions.

I would add to the SPRING_SERVICE_PSQL_ENABLED config in the docu, that the second attribute has to be set addtionally if the DB is to be deactivated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.