-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,529 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# This workflow will build a Java project with Maven | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: Java CI with Maven | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '21' | ||
- name: Cache Maven packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Build with Maven | ||
run: mvn install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/* | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
|
||
### local misc files ### | ||
settings.yml | ||
|
||
### Test data files ### | ||
file_*.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM docker.io/maven:3-eclipse-temurin-21 as build | ||
COPY $PWD /openehr-obds | ||
WORKDIR /openehr-obds | ||
RUN mvn -DskipTests clean package | ||
|
||
FROM gcr.io/distroless/java21-debian12 | ||
COPY --from=build /openehr-obds/target/openehr-obds-*-jar-with-dependencies.jar /app/openehr-obds.jar | ||
ENTRYPOINT ["java", "-jar", "/app/openehr-obds.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: "3" | ||
services: | ||
openehr-obds: | ||
restart: unless-stopped | ||
build: ./ | ||
command: "/app/settings.yml" | ||
volumes: | ||
- "./settings.yml:/app/settings.yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>de.uksh.medic.etl</groupId> | ||
<artifactId>openehr-obds</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>21</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<junit.version>5.10.2</junit.version> | ||
<maven-enforcer-plugin.version>3.4.1</maven-enforcer-plugin.version> | ||
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version> | ||
<maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version> | ||
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version> | ||
<maven-source-plugin.version>3.3.0</maven-source-plugin.version> | ||
<exec.mainClass>de.uksh.medic.etl.OpenEhrObds</exec.mainClass> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>ca.uhn.hapi.fhir</groupId> | ||
<artifactId>hapi-fhir-base</artifactId> | ||
<version>7.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ca.uhn.hapi.fhir</groupId> | ||
<artifactId>hapi-fhir-client</artifactId> | ||
<version>7.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ca.uhn.hapi.fhir</groupId> | ||
<artifactId>hapi-fhir-structures-r4</artifactId> | ||
<version>7.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>2.16.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>2.16.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-yaml</artifactId> | ||
<version>2.16.1</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
<version>6.1.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.tinylog</groupId> | ||
<artifactId>tinylog-api</artifactId> | ||
<version>2.6.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.tinylog</groupId> | ||
<artifactId>tinylog-impl</artifactId> | ||
<version>2.6.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.tinylog</groupId> | ||
<artifactId>slf4j-tinylog</artifactId> | ||
<version>2.6.2</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
<version>${maven-enforcer-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>enforce</goal> | ||
</goals> | ||
<configuration> | ||
<rules> | ||
<requireMavenVersion> | ||
<version>3.6.3</version> | ||
</requireMavenVersion> | ||
</rules> | ||
<fail>true</fail> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${maven-surefire-plugin.version}</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>${maven-javadoc-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>${maven-source-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
<archive> | ||
<manifest> | ||
<mainClass>de.uksh.medic.etl.OpenEhrObds</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-checkstyle-plugin</artifactId> | ||
<version>3.3.1</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.puppycrawl.tools</groupId> | ||
<artifactId>checkstyle</artifactId> | ||
<version>10.13.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.github.ngeor</groupId> | ||
<artifactId>checkstyle-rules</artifactId> | ||
<version>7.0.0</version> | ||
</dependency> | ||
</dependencies> | ||
<configuration> | ||
<configLocation>com/github/ngeor/checkstyle.xml</configLocation> | ||
<skip>false</skip> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>checkstyle</id> | ||
<phase>validate</phase> | ||
<goals> | ||
<goal>check</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.uksh.medic.etl; | ||
|
||
import de.uksh.medic.etl.jobs.mdr.centraxx.CxxMdrLogin; | ||
import de.uksh.medic.etl.settings.ConfigurationLoader; | ||
import de.uksh.medic.etl.settings.CxxMdrSettings; | ||
import de.uksh.medic.etl.settings.Settings; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import org.tinylog.Logger; | ||
|
||
public final class OpenEhrObds { | ||
|
||
private OpenEhrObds() {} | ||
|
||
public static void main(String[] args) throws IOException { | ||
InputStream settingsYaml = ClassLoader.getSystemClassLoader().getResourceAsStream("settings.yml"); | ||
if (args.length == 1) { | ||
settingsYaml = new FileInputStream(args[0]); | ||
} | ||
|
||
ConfigurationLoader configLoader = new ConfigurationLoader(); | ||
configLoader.loadConfiguration(settingsYaml, Settings.class); | ||
|
||
//ToDo: Replace with Kafka consumer | ||
|
||
CxxMdrSettings mdrSettings = Settings.getCxxmdr(); | ||
if (mdrSettings != null) { | ||
CxxMdrLogin.login(mdrSettings); | ||
} | ||
|
||
Logger.info("OpenEhrObds started!"); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
src/main/java/de/uksh/medic/etl/jobs/mdr/centraxx/CxxMdrConvert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.uksh.medic.etl.jobs.mdr.centraxx; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import de.uksh.medic.etl.model.mdr.centraxx.RelationConvert; | ||
import de.uksh.medic.etl.settings.CxxMdrSettings; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
/** | ||
* Class for data conversion using Kairos CentraXX MDR. | ||
*/ | ||
public final class CxxMdrConvert { | ||
|
||
private CxxMdrConvert() { | ||
} | ||
|
||
/** | ||
* Converts data from a source profile to a target profile using Kairos CentraXX MDR. | ||
* @param mdr Configuration for MDR. | ||
* @param input Relation with input data | ||
* @return Relation with output data | ||
* @throws JsonProcessingException | ||
*/ | ||
public static RelationConvert convert(CxxMdrSettings mdr, RelationConvert input) throws JsonProcessingException { | ||
|
||
if (mdr.isTokenExpired()) { | ||
CxxMdrLogin.login(mdr); | ||
} | ||
|
||
RestTemplate rt = new RestTemplate(); | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON.toString()); | ||
headers.add(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON.toString()); | ||
headers.add("Authorization", "Bearer " + mdr.getToken()); | ||
ObjectMapper om = new ObjectMapper(); | ||
om.setSerializationInclusion(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) | ||
.writeValueAsString(input); | ||
return rt.postForObject(mdr.getUrl() + "/rest/v1/relations/convert", | ||
new HttpEntity<>(om.writeValueAsString(input), headers), | ||
RelationConvert.class); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.