summaryrefslogtreecommitdiff
path: root/src/main/kotlin/dev/dnpm
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2024-07-15 11:44:19 +0200
committerPaul-Christian Volkmer2024-07-15 11:44:19 +0200
commit370ea87095bf6859b3d9623ab0f8252e10c1a9ee (patch)
tree7bb3be941a93b5f8ed312ee9d5910f9d7689cf1a /src/main/kotlin/dev/dnpm
parentc8f6e6efc812cc12d17c2af1cc24a9318180a8fe (diff)
refactor: rename db column name to reflect content
Diffstat (limited to 'src/main/kotlin/dev/dnpm')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt18
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt2
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt4
3 files changed, 12 insertions, 12 deletions
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt
index d26d222..36c9705 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt
@@ -36,7 +36,7 @@ import java.util.*
data class Request(
@Id val id: Long? = null,
val uuid: RequestId = randomRequestId(),
- val patientId: PatientPseudonym,
+ val patientPseudonym: PatientPseudonym,
val pid: PatientId,
@Column("fingerprint")
val fingerprint: Fingerprint,
@@ -47,24 +47,24 @@ data class Request(
) {
constructor(
uuid: RequestId,
- patientId: PatientPseudonym,
+ patientPseudonym: PatientPseudonym,
pid: PatientId,
fingerprint: Fingerprint,
type: RequestType,
status: RequestStatus
) :
- this(null, uuid, patientId, pid, fingerprint, type, status, Instant.now())
+ this(null, uuid, patientPseudonym, pid, fingerprint, type, status, Instant.now())
constructor(
uuid: RequestId,
- patientId: PatientPseudonym,
+ patientPseudonym: PatientPseudonym,
pid: PatientId,
fingerprint: Fingerprint,
type: RequestType,
status: RequestStatus,
processedAt: Instant
) :
- this(null, uuid, patientId, pid, fingerprint, type, status, processedAt)
+ this(null, uuid, patientPseudonym, pid, fingerprint, type, status, processedAt)
}
@JvmRecord
@@ -81,17 +81,17 @@ data class CountedState(
interface RequestRepository : CrudRepository<Request, Long>, PagingAndSortingRepository<Request, Long> {
- fun findAllByPatientIdOrderByProcessedAtDesc(patientId: PatientPseudonym): List<Request>
+ fun findAllByPatientPseudonymOrderByProcessedAtDesc(patientId: PatientPseudonym): List<Request>
fun findByUuidEquals(uuid: RequestId): Optional<Request>
- fun findRequestByPatientId(patientId: PatientPseudonym, pageable: Pageable): Page<Request>
+ fun findRequestByPatientPseudonym(patientPseudonym: PatientPseudonym, pageable: Pageable): Page<Request>
@Query("SELECT count(*) AS count, status FROM request WHERE type = 'MTB_FILE' GROUP BY status ORDER BY status, count DESC;")
fun countStates(): List<CountedState>
@Query("SELECT count(*) AS count, status FROM (" +
- "SELECT status, rank() OVER (PARTITION BY patient_id ORDER BY processed_at DESC) AS rank FROM request " +
+ "SELECT status, rank() OVER (PARTITION BY patient_pseudonym ORDER BY processed_at DESC) AS rank FROM request " +
"WHERE type = 'MTB_FILE' AND status NOT IN ('DUPLICATION') " +
") rank WHERE rank = 1 GROUP BY status ORDER BY status, count DESC;")
fun findPatientUniqueStates(): List<CountedState>
@@ -100,7 +100,7 @@ interface RequestRepository : CrudRepository<Request, Long>, PagingAndSortingRep
fun countDeleteStates(): List<CountedState>
@Query("SELECT count(*) AS count, status FROM (" +
- "SELECT status, rank() OVER (PARTITION BY patient_id ORDER BY processed_at DESC) AS rank FROM request " +
+ "SELECT status, rank() OVER (PARTITION BY patient_pseudonym ORDER BY processed_at DESC) AS rank FROM request " +
"WHERE type = 'DELETE'" +
") rank WHERE rank = 1 GROUP BY status ORDER BY status, count DESC;")
fun findPatientUniqueDeleteStates(): List<CountedState>
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 2cbfd2f..f4e6222 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestProcessor.kt
@@ -149,7 +149,7 @@ class RequestProcessor(
requestService.save(
Request(
uuid = requestId,
- patientId = emptyPatientPseudonym(),
+ patientPseudonym = emptyPatientPseudonym(),
pid = patientId,
fingerprint = Fingerprint.empty(),
status = RequestStatus.ERROR,
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt
index 826b060..757b353 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt
@@ -41,10 +41,10 @@ class RequestService(
fun findByUuid(uuid: RequestId): Optional<Request> =
requestRepository.findByUuidEquals(uuid)
- fun findRequestByPatientId(patientId: PatientPseudonym, pageable: Pageable): Page<Request> = requestRepository.findRequestByPatientId(patientId, pageable)
+ fun findRequestByPatientId(patientPseudonym: PatientPseudonym, pageable: Pageable): Page<Request> = requestRepository.findRequestByPatientPseudonym(patientPseudonym, pageable)
fun allRequestsByPatientPseudonym(patientPseudonym: PatientPseudonym) = requestRepository
- .findAllByPatientIdOrderByProcessedAtDesc(patientPseudonym)
+ .findAllByPatientPseudonymOrderByProcessedAtDesc(patientPseudonym)
fun lastMtbFileRequestForPatientPseudonym(patientPseudonym: PatientPseudonym) =
Companion.lastMtbFileRequestForPatientPseudonym(allRequestsByPatientPseudonym(patientPseudonym))