Skip to content

Commit

Permalink
Merge pull request #89 from medizininformatik-initiative/release-1.0.0.2
Browse files Browse the repository at this point in the history
Release 1.0.0.2
  • Loading branch information
EmteZogaf authored Dec 5, 2023
2 parents a061d3a + edc99bb commit a0ae79f
Show file tree
Hide file tree
Showing 60 changed files with 2,161 additions and 876 deletions.
15 changes: 7 additions & 8 deletions feasibility-dsf-process-docker-test-setup/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ services:
target: /opt/fhir/log
environment:
TZ: Europe/Berlin
DEV_DSF_SERVER_AUTH_TRUST_CLIENT_CERTIFICATE_CAS: /run/secrets/app_client_trust_certificates.pem
DEV_DSF_FHIR_DB_LIQUIBASE_PASSWORD_FILE: /run/secrets/db_liquibase.password
DEV_DSF_FHIR_DB_USER_PASSWORD_FILE: /run/secrets/db_fhir_dic_3_user.password
DEV_DSF_FHIR_DB_USER_PERMANENT_DELETE_PASSWORD_FILE: /run/secrets/db_fhir_dic_3_user_permanent_delete.password
Expand Down Expand Up @@ -780,6 +781,7 @@ services:
target: /opt/fhir/log
environment:
TZ: Europe/Berlin
DEV_DSF_SERVER_AUTH_TRUST_CLIENT_CERTIFICATE_CAS: /run/secrets/app_client_trust_certificates.pem
DEV_DSF_FHIR_DB_LIQUIBASE_PASSWORD_FILE: /run/secrets/db_liquibase.password
DEV_DSF_FHIR_DB_USER_PASSWORD_FILE: /run/secrets/db_fhir_dic_4_user.password
DEV_DSF_FHIR_DB_USER_PERMANENT_DELETE_PASSWORD_FILE: /run/secrets/db_fhir_dic_4_user_permanent_delete.password
Expand Down Expand Up @@ -891,16 +893,13 @@ services:
timeout: 5s
retries: 5
environment:
SPRING_DATASOURCE_URL: "jdbc:postgresql://dic-4-store-db:5432/fhir?currentSchema=public"
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: postgres
SPRING_DATASOURCE_DRIVERCLASSNAME: org.postgresql.Driver
SPRING_JPA_PROPERTIES_HIBERNATE_DIALECT: org.hibernate.dialect.PostgreSQL10Dialect
VALIDATION_REQUESTS_ENABLED: "false"
HAPI_FHIR_USE_APACHE_ADDRESS_STRATEGY: "true"
HAPI_FHIR_CQL_ENABLED: "true"
SPRING_CONFIG_LOCATION: 'file:///data/hapi/application.yaml'
networks:
dic-4-bpe-backend:
volumes:
- type: bind
source: ./dic-4/fhir/conf/application.yaml
target: /data/hapi/application.yaml
volumes_from:
- hapi-curl-download:ro
depends_on:
Expand Down
10 changes: 5 additions & 5 deletions feasibility-dsf-process/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ This version of the process is compatible with the following components:

| Component | Compatible Version(s) |
|-----------|-----------------------|
| DSF FHIR | `0.9.0` |
| DSF BPE | `0.9.0` |
| DSF FHIR | `>= 1.3.0` |
| DSF BPE | `>= 1.3.0` |
| Blaze | `>= 0.12` |
| Flare | `1.0` |
| Flare | `>= 1.0` |

**Note:** Flare got rewritten. Only the [new project][9] is supported.

Expand All @@ -151,6 +151,6 @@ This version of the process is compatible with the following components:
[5]: <https://www.hl7.org/fhir/operation-measure-evaluate-measure.html>
[6]: <https://www.hl7.org/fhir/measurereport.html>
[7]: <https://en.wikipedia.org/wiki/Business_Process_Model_and_Notation>
[8]: <https://github.com/highmed/highmed-dsf/wiki/DSF-0.5.5-Configuration-Parameters#dsf-bpe>
[9]: <https://github.com/rwth-imi/flare-query>
[8]: <https://dsf.dev/stable/maintain/bpe/configuration.html>
[9]: <https://github.com/medizininformatik-initiative/flare>
[10]: <https://en.wikipedia.org/wiki/ISO_8601#Durations>
2 changes: 1 addition & 1 deletion feasibility-dsf-process/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
<goal>exec</goal>
</goals>
<configuration>
<executable>${basedir}/scripts/create_certs_for_store_client_tests.sh</executable>
<executable>${basedir}/scripts/create_certs_for_client_tests.sh</executable>
</configuration>
</execution>
</executions>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

BASE_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
TARGET_DIR=$(readlink -f "${BASE_DIR}/../src/test/resources/de/medizininformatik_initiative/feasibility_dsf_process/client/store/certs")
TARGET_DIR="${BASE_DIR}/../src/test/resources/de/medizininformatik_initiative/feasibility_dsf_process/client/certs"

mkdir -p "${TARGET_DIR}"

Expand All @@ -19,12 +19,14 @@ openssl pkcs12 -export -out ${TARGET_DIR}/ca.p12 \
# Issue server certificate using said self signed CA
openssl req -nodes -sha256 -new -newkey rsa:2048 -keyout ${TARGET_DIR}/server_cert_key.pem \
-out ${TARGET_DIR}/server_cert_csr.pem \
-subj "/C=DE/ST=Berlin/L=Berlin/O=Bar/CN=localhost"
-subj "/C=DE/ST=Berlin/L=Berlin/O=Bar/CN=localhost" \
-addext "subjectAltName = DNS:localhost, DNS:proxy"

openssl x509 -req -days 7 -sha256 -in ${TARGET_DIR}/server_cert_csr.pem \
-CA ${TARGET_DIR}/ca.pem \
-CAkey ${TARGET_DIR}/ca_key.pem \
-CAcreateserial \
-copy_extensions copyall \
-out ${TARGET_DIR}/server_cert.pem

# Server cert chain
Expand Down Expand Up @@ -56,4 +58,4 @@ rm -f ${TARGET_DIR}/server_cert_csr.pem
rm -f ${TARGET_DIR}/server_cert.pem
rm -f ${TARGET_DIR}/client_cert_csr.pem
rm -f ${TARGET_DIR}/client_cert_key.pem
rm -f ${TARGET_DIR}/client_cert.pem
rm -f ${TARGET_DIR}/client_cert.pem
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.Properties;

import static com.google.common.base.Preconditions.checkNotNull;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.FEASIBILITY_EXECUTE_PROCESS_ID;
import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.FEASIBILITY_REQUEST_PROCESS_ID;

public class FeasibilityProcessPluginDefinition implements ProcessPluginDefinition {

Expand All @@ -30,7 +32,7 @@ public FeasibilityProcessPluginDefinition() {
Properties props = new Properties();
props.load(input);

this.version = props.getProperty("build.version");
this.version = props.getProperty("build.version").replaceFirst("-.*$", "");
this.releaseDate = LocalDate.parse(props.getProperty("build.date"));
} catch (IOException e) {
throw new IllegalStateException("Could not load application properties.", e);
Expand Down Expand Up @@ -84,9 +86,9 @@ public Map<String, List<String>> getFhirResourcesByProcessId() {
var vF = "fhir/ValueSet/feasibility.xml";

return Map.of(
"medizininformatik-initiativede_feasibilityExecute",
FEASIBILITY_EXECUTE_PROCESS_ID,
Arrays.asList(aExe, sTExe, sTResS, vF, cF, sMeasure, sMeasureReport, sLibrary),
"medizininformatik-initiativede_feasibilityRequest",
FEASIBILITY_REQUEST_PROCESS_ID,
Arrays.asList(aReq, sTReq, sTResS, sExtDic, vF, cF, sMeasure, sMeasureReport, sLibrary));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package de.medizininformatik_initiative.feasibility_dsf_process;

import ca.uhn.fhir.rest.client.api.IGenericClient;
import de.medizininformatik_initiative.feasibility_dsf_process.client.flare.FlareWebserviceClient;
import dev.dsf.bpe.v1.ProcessPluginDeploymentStateListener;
import org.hl7.fhir.r4.model.CapabilityStatement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;

import java.io.IOException;
import java.util.List;

import static de.medizininformatik_initiative.feasibility_dsf_process.variables.ConstantsFeasibility.FEASIBILITY_EXECUTE_PROCESS_ID;
import static java.util.Objects.requireNonNull;

/**
* After process deployment starts a connection test if the <i>feasibilityExecute</i> process is active.
* <p>
* The configured {@link EvaluationStrategy} determines which client is used for the connection test.
* </p>
*
* @author <a href="mailto:math2306@hotmail.com">Mathias Rühle</a>
*/
public class FeasibilityProcessPluginDeploymentStateListener
implements ProcessPluginDeploymentStateListener, InitializingBean {

private static final Logger logger = LoggerFactory.getLogger(FeasibilityProcessPluginDeploymentStateListener.class);

private EvaluationStrategy strategy;
private IGenericClient storeClient;
private FlareWebserviceClient flareWebserviceClient;

public FeasibilityProcessPluginDeploymentStateListener(EvaluationStrategy strategy, IGenericClient storeClient,
FlareWebserviceClient flareWebserviceClient) {
this.strategy = strategy;
this.storeClient = storeClient;
this.flareWebserviceClient = flareWebserviceClient;
}

@Override
public void onProcessesDeployed(List<String> processes) {
if (processes.contains(FEASIBILITY_EXECUTE_PROCESS_ID)) {
if (strategy.equals(EvaluationStrategy.CQL)) {
try {
CapabilityStatement statement = storeClient.capabilities().ofType(CapabilityStatement.class)
.execute();
logger.info("Connection test OK ({} - {})", statement.getSoftware().getName(),
statement.getSoftware().getVersion());
} catch (RuntimeException e) {
logger.warn("Connection test FAILED - error: {} - {}", e.getClass().getName(), e.getMessage());
}
} else {
try {
flareWebserviceClient.testConnection();
logger.info("Connection test OK (flare)");
} catch (IOException e) {
logger.warn("Connection test FAILED (flare) - error: {} - {}", e.getClass().getName(),
e.getMessage());
}
}
}
}

@Override
public void afterPropertiesSet() throws Exception {
requireNonNull(storeClient);
requireNonNull(flareWebserviceClient);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.medizininformatik_initiative.feasibility_dsf_process.client.flare;

import org.apache.http.client.ClientProtocolException;

import java.io.IOException;

/**
Expand All @@ -17,4 +19,16 @@ public interface FlareWebserviceClient {
* @throws InterruptedException If the operation is interrupted.
*/
int requestFeasibility(byte[] structuredQuery) throws IOException, InterruptedException;

/**
* Tests the connection to the flare server, and flare server only, using the connection settings defined by spring
* configuration.
* <p>
* Throws an exception if the connection test fails, otherwise the connection test was successful.
* </p>
*
* @throws IOException in case of a problem or the connection was aborted
* @throws ClientProtocolException in case of an http protocol error
*/
void testConnection() throws ClientProtocolException, IOException;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
package de.medizininformatik_initiative.feasibility_dsf_process.client.flare;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.message.BasicHeader;

import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;

import static java.net.http.HttpRequest.BodyPublishers.ofByteArray;
import static java.net.http.HttpResponse.BodyHandlers.ofString;
import static ca.uhn.fhir.rest.api.Constants.HEADER_CONTENT_TYPE;

/**
* Client for communicating with a Flare instance.
*/
public class FlareWebserviceClientImpl implements FlareWebserviceClient {

private final HttpClient httpClient;
private final org.apache.http.client.HttpClient httpClient;
private final URI flareBaseUrl;

public FlareWebserviceClientImpl(HttpClient httpClient, URI flareBaseUrl) {
Expand All @@ -23,13 +28,23 @@ public FlareWebserviceClientImpl(HttpClient httpClient, URI flareBaseUrl) {

@Override
public int requestFeasibility(byte[] structuredQuery) throws IOException, InterruptedException {
var req = HttpRequest.newBuilder()
.POST(ofByteArray(structuredQuery))
.setHeader("Content-Type", "application/sq+json")
.uri(flareBaseUrl.resolve("/query/execute"))
.build();

var res = httpClient.send(req, ofString());
return Integer.parseInt(res.body());
var req = new HttpPost(resolve("/query/execute"));
req.setEntity(new ByteArrayEntity(structuredQuery));
req.setHeader(new BasicHeader(HEADER_CONTENT_TYPE, "application/sq+json"));

var response = httpClient.execute(req, new BasicResponseHandler());

return Integer.parseInt(response);
}

private URI resolve(String path) {
return flareBaseUrl.resolve((flareBaseUrl.getPath() + path).replaceAll("//", "/"));
}

@Override
public void testConnection() throws ClientProtocolException, IOException {
var req = new HttpGet(resolve("/cache/stats"));

httpClient.execute(req, new BasicResponseHandler());
}
}
Loading

0 comments on commit a0ae79f

Please sign in to comment.