summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--deploy/docker-compose.yaml1
-rw-r--r--deploy/env-sample.env1
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt1
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt21
-rw-r--r--src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt14
6 files changed, 30 insertions, 9 deletions
diff --git a/README.md b/README.md
index 30b4ee8..9fb0164 100644
--- a/README.md
+++ b/README.md
@@ -199,6 +199,7 @@ Folgende Umgebungsvariablen müssen gesetzt sein, damit ein bwHC-MTB-File an das
* `APP_REST_URI`: URI der zu benutzenden API der bwHC-Backend-Instanz. z.B.: `http://localhost:9000/bwhc/etl/api`
* `APP_REST_USERNAME`: Basic-Auth-Benutzername für bwHC-Backend
* `APP_REST_PASSWORD`: Basic-Auth-Passwort für bwHC-Backend
+* `APP_REST_IS_BWHC`: `true` für bwHC, weglassen oder `false` für dnpm:dip
#### Kafka-Topics
diff --git a/deploy/docker-compose.yaml b/deploy/docker-compose.yaml
index 2180786..754bb23 100644
--- a/deploy/docker-compose.yaml
+++ b/deploy/docker-compose.yaml
@@ -20,6 +20,7 @@ services:
APP_REST_URI: ${DNPM_BWHC_REST_URI}
APP_REST_USERNAME: ${DNPM_BWHC_REST_USERNAME}
APP_REST_PASSWORD: ${DNPM_BWHC_REST_PASSWORD}
+ APP_REST_IS_BWHC: ${DNPM_BWHC_REST_IS_BWHC}
APP_SECURITY_ADMIN_USER: ${DNPM_ADMIN_USER}
APP_SECURITY_ADMIN_PASSWORD: ${DNPM_ADMIN_PASSWORD}
SPRING_DATASOURCE_URL: ${DNPM_DATASOURCE_URL}
diff --git a/deploy/env-sample.env b/deploy/env-sample.env
index 9c06341..4888474 100644
--- a/deploy/env-sample.env
+++ b/deploy/env-sample.env
@@ -30,6 +30,7 @@ DNPM_DATASOURCE_URL=jdbc:mariadb://dnpm-monitor-db:3306/$DNPM_MARIADB_DB
DNPM_BWHC_REST_URI=
DNPM_BWHC_REST_USERNAME=
DNPM_BWHC_REST_PASSWORD=
+DNPM_BWHC_REST_IS_BWHC=false
# produce mtb files to this topic - values 'false' disabling kafka processing
DNPM_KAFKA_TOPIC=false
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt b/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt
index dd7e461..7c192c8 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/config/AppConfigProperties.kt
@@ -71,6 +71,7 @@ data class RestTargetProperties(
val uri: String?,
val username: String?,
val password: String?,
+ val isBwhc: Boolean = false,
) {
companion object {
const val NAME = "app.rest"
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt b/src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt
index 58459b9..6dfe0eb 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSender.kt
@@ -21,6 +21,7 @@ package dev.dnpm.etl.processor.output
import dev.dnpm.etl.processor.config.RestTargetProperties
import dev.dnpm.etl.processor.monitoring.RequestStatus
+import dev.dnpm.etl.processor.PatientPseudonym
import org.slf4j.LoggerFactory
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
@@ -37,13 +38,29 @@ class RestMtbFileSender(
private val logger = LoggerFactory.getLogger(RestMtbFileSender::class.java)
+ fun sendUrl(): String {
+ return if(restTargetProperties.isBwhc) {
+ "${restTargetProperties.uri}/MTBFile"
+ } else {
+ "${restTargetProperties.uri}/patient-record"
+ }
+ }
+
+ fun deleteUrl(patientId: PatientPseudonym): String {
+ return if(restTargetProperties.isBwhc) {
+ "${restTargetProperties.uri}/Patient/${patientId.value}"
+ } else {
+ "${restTargetProperties.uri}/patient/${patientId.value}"
+ }
+ }
+
override fun send(request: MtbFileSender.MtbFileRequest): MtbFileSender.Response {
try {
return retryTemplate.execute<MtbFileSender.Response, Exception> {
val headers = getHttpHeaders()
val entityReq = HttpEntity(request.mtbFile, headers)
val response = restTemplate.postForEntity(
- "${restTargetProperties.uri}/MTBFile",
+ sendUrl(),
entityReq,
String::class.java
)
@@ -72,7 +89,7 @@ class RestMtbFileSender(
val headers = getHttpHeaders()
val entityReq = HttpEntity(null, headers)
restTemplate.delete(
- "${restTargetProperties.uri}/Patient/${request.patientId}",
+ deleteUrl(request.patientId),
entityReq,
String::class.java
)
diff --git a/src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt b/src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt
index 8a12186..b3a87b0 100644
--- a/src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt
+++ b/src/test/kotlin/dev/dnpm/etl/processor/output/RestMtbFileSenderTest.kt
@@ -48,7 +48,7 @@ class RestMtbFileSenderTest {
@BeforeEach
fun setup() {
val restTemplate = RestTemplate()
- val restTargetProperties = RestTargetProperties("http://localhost:9000/mtbfile", null, null)
+ val restTargetProperties = RestTargetProperties("http://localhost:9000/", null, null, false)
val retryTemplate = RetryTemplateBuilder().customPolicy(SimpleRetryPolicy(1)).build()
this.mockRestServiceServer = MockRestServiceServer.createServer(restTemplate)
@@ -61,7 +61,7 @@ class RestMtbFileSenderTest {
fun shouldReturnExpectedResponseForDelete(requestWithResponse: RequestWithResponse) {
this.mockRestServiceServer
.expect(method(HttpMethod.DELETE))
- .andExpect(requestTo("http://localhost:9000/mtbfile/Patient/$TEST_PATIENT_PSEUDONYM"))
+ .andExpect(requestTo("http://localhost:9000/patient/$TEST_PATIENT_PSEUDONYM"))
.andRespond {
withStatus(requestWithResponse.httpStatus).body(requestWithResponse.body).createResponse(it)
}
@@ -76,7 +76,7 @@ class RestMtbFileSenderTest {
fun shouldReturnExpectedResponseForMtbFilePost(requestWithResponse: RequestWithResponse) {
this.mockRestServiceServer
.expect(method(HttpMethod.POST))
- .andExpect(requestTo("http://localhost:9000/mtbfile/MTBFile"))
+ .andExpect(requestTo("http://localhost:9000/patient-record"))
.andRespond {
withStatus(requestWithResponse.httpStatus).body(requestWithResponse.body).createResponse(it)
}
@@ -90,7 +90,7 @@ class RestMtbFileSenderTest {
@MethodSource("mtbFileRequestWithResponseSource")
fun shouldRetryOnMtbFileHttpRequestError(requestWithResponse: RequestWithResponse) {
val restTemplate = RestTemplate()
- val restTargetProperties = RestTargetProperties("http://localhost:9000/mtbfile", null, null)
+ val restTargetProperties = RestTargetProperties("http://localhost:9000/", null, null, false)
val retryTemplate = RetryTemplateBuilder().customPolicy(SimpleRetryPolicy(3)).build()
this.mockRestServiceServer = MockRestServiceServer.createServer(restTemplate)
@@ -105,7 +105,7 @@ class RestMtbFileSenderTest {
this.mockRestServiceServer
.expect(expectedCount, method(HttpMethod.POST))
- .andExpect(requestTo("http://localhost:9000/mtbfile/MTBFile"))
+ .andExpect(requestTo("http://localhost:9000/patient-record"))
.andRespond {
withStatus(requestWithResponse.httpStatus).body(requestWithResponse.body).createResponse(it)
}
@@ -119,7 +119,7 @@ class RestMtbFileSenderTest {
@MethodSource("deleteRequestWithResponseSource")
fun shouldRetryOnDeleteHttpRequestError(requestWithResponse: RequestWithResponse) {
val restTemplate = RestTemplate()
- val restTargetProperties = RestTargetProperties("http://localhost:9000/mtbfile", null, null)
+ val restTargetProperties = RestTargetProperties("http://localhost:9000/", null, null, false)
val retryTemplate = RetryTemplateBuilder().customPolicy(SimpleRetryPolicy(3)).build()
this.mockRestServiceServer = MockRestServiceServer.createServer(restTemplate)
@@ -134,7 +134,7 @@ class RestMtbFileSenderTest {
this.mockRestServiceServer
.expect(expectedCount, method(HttpMethod.DELETE))
- .andExpect(requestTo("http://localhost:9000/mtbfile/Patient/$TEST_PATIENT_PSEUDONYM"))
+ .andExpect(requestTo("http://localhost:9000/patient/$TEST_PATIENT_PSEUDONYM"))
.andRespond {
withStatus(requestWithResponse.httpStatus).body(requestWithResponse.body).createResponse(it)
}