summaryrefslogtreecommitdiff
path: root/src/main/kotlin/dev/dnpm
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2023-08-09 12:26:57 +0200
committerPaul-Christian Volkmer2023-08-09 12:26:57 +0200
commit7f048e2483138deecc28208af42546097ef929d7 (patch)
tree785cd5676e5c2683d4e17203c12a82ebba6742ef /src/main/kotlin/dev/dnpm
parent47830ed9f7774c84674e9399cd347d12424f4f42 (diff)
Do not append custom prefix to gPAS pseudonym
Diffstat (limited to 'src/main/kotlin/dev/dnpm')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/pseudonym/PseudonymizeService.kt36
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/pseudonym/extensions.kt50
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt14
3 files changed, 62 insertions, 38 deletions
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/pseudonym/PseudonymizeService.kt b/src/main/kotlin/dev/dnpm/etl/processor/pseudonym/PseudonymizeService.kt
index 1a79850..ab8ce2f 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/pseudonym/PseudonymizeService.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/pseudonym/PseudonymizeService.kt
@@ -19,7 +19,6 @@
package dev.dnpm.etl.processor.pseudonym
-import de.ukw.ccc.bwhc.dto.MtbFile
import dev.dnpm.etl.processor.config.PseudonymizeConfigProperties
class PseudonymizeService(
@@ -27,38 +26,11 @@ class PseudonymizeService(
private val configProperties: PseudonymizeConfigProperties
) {
- fun pseudonymize(mtbFile: MtbFile): MtbFile {
- val patientPseudonym = patientPseudonym(mtbFile.patient.id)
-
- mtbFile.episode.patient = patientPseudonym
- mtbFile.carePlans.forEach { it.patient = patientPseudonym }
- mtbFile.patient.id = patientPseudonym
- mtbFile.claims.forEach { it.patient = patientPseudonym }
- mtbFile.consent.patient = patientPseudonym
- mtbFile.claimResponses.forEach { it.patient = patientPseudonym }
- mtbFile.diagnoses.forEach { it.patient = patientPseudonym }
- mtbFile.ecogStatus.forEach { it.patient = patientPseudonym }
- mtbFile.familyMemberDiagnoses.forEach { it.patient = patientPseudonym }
- mtbFile.geneticCounsellingRequests.forEach { it.patient = patientPseudonym }
- mtbFile.histologyReevaluationRequests.forEach { it.patient = patientPseudonym }
- mtbFile.histologyReports.forEach { it.patient = patientPseudonym }
- mtbFile.lastGuidelineTherapies.forEach { it.patient = patientPseudonym }
- mtbFile.molecularPathologyFindings.forEach { it.patient = patientPseudonym }
- mtbFile.molecularTherapies.forEach { it.history.forEach { it.patient = patientPseudonym } }
- mtbFile.ngsReports.forEach { it.patient = patientPseudonym }
- mtbFile.previousGuidelineTherapies.forEach { it.patient = patientPseudonym }
- mtbFile.rebiopsyRequests.forEach { it.patient = patientPseudonym }
- mtbFile.recommendations.forEach { it.patient = patientPseudonym }
- mtbFile.recommendations.forEach { it.patient = patientPseudonym }
- mtbFile.responses.forEach { it.patient = patientPseudonym }
- mtbFile.specimens.forEach { it.patient = patientPseudonym }
- mtbFile.specimens.forEach { it.patient = patientPseudonym }
-
- return mtbFile
- }
-
fun patientPseudonym(patientId: String): String {
- return "${configProperties.prefix}_${generator.generate(patientId)}"
+ return when (generator) {
+ is GpasPseudonymGenerator -> generator.generate(patientId)
+ else -> "${configProperties.prefix}_${generator.generate(patientId)}"
+ }
}
} \ No newline at end of file
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/pseudonym/extensions.kt b/src/main/kotlin/dev/dnpm/etl/processor/pseudonym/extensions.kt
new file mode 100644
index 0000000..580785d
--- /dev/null
+++ b/src/main/kotlin/dev/dnpm/etl/processor/pseudonym/extensions.kt
@@ -0,0 +1,50 @@
+/*
+ * This file is part of ETL-Processor
+ *
+ * Copyright (c) 2023 Comprehensive Cancer Center Mainfranken, Datenintegrationszentrum Philipps-Universität Marburg and Contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package dev.dnpm.etl.processor.pseudonym
+
+import de.ukw.ccc.bwhc.dto.MtbFile
+
+infix fun MtbFile.pseudonymizeWith(pseudonymizeService: PseudonymizeService) {
+ val patientPseudonym = pseudonymizeService.patientPseudonym(this.patient.id)
+
+ this.episode.patient = patientPseudonym
+ this.carePlans.forEach { it.patient = patientPseudonym }
+ this.patient.id = patientPseudonym
+ this.claims.forEach { it.patient = patientPseudonym }
+ this.consent.patient = patientPseudonym
+ this.claimResponses.forEach { it.patient = patientPseudonym }
+ this.diagnoses.forEach { it.patient = patientPseudonym }
+ this.ecogStatus.forEach { it.patient = patientPseudonym }
+ this.familyMemberDiagnoses.forEach { it.patient = patientPseudonym }
+ this.geneticCounsellingRequests.forEach { it.patient = patientPseudonym }
+ this.histologyReevaluationRequests.forEach { it.patient = patientPseudonym }
+ this.histologyReports.forEach { it.patient = patientPseudonym }
+ this.lastGuidelineTherapies.forEach { it.patient = patientPseudonym }
+ this.molecularPathologyFindings.forEach { it.patient = patientPseudonym }
+ this.molecularTherapies.forEach { it.history.forEach { it.patient = patientPseudonym } }
+ this.ngsReports.forEach { it.patient = patientPseudonym }
+ this.previousGuidelineTherapies.forEach { it.patient = patientPseudonym }
+ this.rebiopsyRequests.forEach { it.patient = patientPseudonym }
+ this.recommendations.forEach { it.patient = patientPseudonym }
+ this.recommendations.forEach { it.patient = patientPseudonym }
+ this.responses.forEach { it.patient = patientPseudonym }
+ this.specimens.forEach { it.patient = patientPseudonym }
+ this.specimens.forEach { it.patient = patientPseudonym }
+} \ No newline at end of file
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt
index 936c1bf..6465e82 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt
@@ -27,6 +27,7 @@ import dev.dnpm.etl.processor.monitoring.RequestStatus
import dev.dnpm.etl.processor.monitoring.RequestType
import dev.dnpm.etl.processor.output.MtbFileSender
import dev.dnpm.etl.processor.pseudonym.PseudonymizeService
+import dev.dnpm.etl.processor.pseudonym.pseudonymizeWith
import org.apache.commons.codec.binary.Base32
import org.apache.commons.codec.digest.DigestUtils
import org.slf4j.LoggerFactory
@@ -47,12 +48,13 @@ class RequestProcessor(
fun processMtbFile(mtbFile: MtbFile) {
val pid = mtbFile.patient.id
- val pseudonymized = pseudonymizeService.pseudonymize(mtbFile)
- if (isDuplication(pseudonymized)) {
+ mtbFile pseudonymizeWith pseudonymizeService
+
+ if (isDuplication(mtbFile)) {
requestService.save(
Request(
- patientId = pseudonymized.patient.id,
+ patientId = mtbFile.patient.id,
pid = pid,
fingerprint = fingerprint(mtbFile),
status = RequestStatus.DUPLICATION,
@@ -64,19 +66,19 @@ class RequestProcessor(
return
}
- val request = MtbFileSender.MtbFileRequest(UUID.randomUUID().toString(), pseudonymized)
+ val request = MtbFileSender.MtbFileRequest(UUID.randomUUID().toString(), mtbFile)
val responseStatus = sender.send(request)
if (responseStatus.status == MtbFileSender.ResponseStatus.SUCCESS || responseStatus.status == MtbFileSender.ResponseStatus.WARNING) {
logger.info(
"Sent file for Patient '{}' using '{}'",
- pseudonymized.patient.id,
+ mtbFile.patient.id,
sender.javaClass.simpleName
)
} else {
logger.error(
"Error sending file for Patient '{}' using '{}'",
- pseudonymized.patient.id,
+ mtbFile.patient.id,
sender.javaClass.simpleName
)
}