mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-19 17:26:51 +00:00
refactor: rename db column name to reflect content
This commit is contained in:
parent
c8f6e6efc8
commit
370ea87095
@ -36,7 +36,7 @@ import java.util.*
|
|||||||
data class Request(
|
data class Request(
|
||||||
@Id val id: Long? = null,
|
@Id val id: Long? = null,
|
||||||
val uuid: RequestId = randomRequestId(),
|
val uuid: RequestId = randomRequestId(),
|
||||||
val patientId: PatientPseudonym,
|
val patientPseudonym: PatientPseudonym,
|
||||||
val pid: PatientId,
|
val pid: PatientId,
|
||||||
@Column("fingerprint")
|
@Column("fingerprint")
|
||||||
val fingerprint: Fingerprint,
|
val fingerprint: Fingerprint,
|
||||||
@ -47,24 +47,24 @@ data class Request(
|
|||||||
) {
|
) {
|
||||||
constructor(
|
constructor(
|
||||||
uuid: RequestId,
|
uuid: RequestId,
|
||||||
patientId: PatientPseudonym,
|
patientPseudonym: PatientPseudonym,
|
||||||
pid: PatientId,
|
pid: PatientId,
|
||||||
fingerprint: Fingerprint,
|
fingerprint: Fingerprint,
|
||||||
type: RequestType,
|
type: RequestType,
|
||||||
status: RequestStatus
|
status: RequestStatus
|
||||||
) :
|
) :
|
||||||
this(null, uuid, patientId, pid, fingerprint, type, status, Instant.now())
|
this(null, uuid, patientPseudonym, pid, fingerprint, type, status, Instant.now())
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
uuid: RequestId,
|
uuid: RequestId,
|
||||||
patientId: PatientPseudonym,
|
patientPseudonym: PatientPseudonym,
|
||||||
pid: PatientId,
|
pid: PatientId,
|
||||||
fingerprint: Fingerprint,
|
fingerprint: Fingerprint,
|
||||||
type: RequestType,
|
type: RequestType,
|
||||||
status: RequestStatus,
|
status: RequestStatus,
|
||||||
processedAt: Instant
|
processedAt: Instant
|
||||||
) :
|
) :
|
||||||
this(null, uuid, patientId, pid, fingerprint, type, status, processedAt)
|
this(null, uuid, patientPseudonym, pid, fingerprint, type, status, processedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmRecord
|
@JvmRecord
|
||||||
@ -81,17 +81,17 @@ data class CountedState(
|
|||||||
|
|
||||||
interface RequestRepository : CrudRepository<Request, Long>, PagingAndSortingRepository<Request, Long> {
|
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 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;")
|
@Query("SELECT count(*) AS count, status FROM request WHERE type = 'MTB_FILE' GROUP BY status ORDER BY status, count DESC;")
|
||||||
fun countStates(): List<CountedState>
|
fun countStates(): List<CountedState>
|
||||||
|
|
||||||
@Query("SELECT count(*) AS count, status FROM (" +
|
@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') " +
|
"WHERE type = 'MTB_FILE' AND status NOT IN ('DUPLICATION') " +
|
||||||
") rank WHERE rank = 1 GROUP BY status ORDER BY status, count DESC;")
|
") rank WHERE rank = 1 GROUP BY status ORDER BY status, count DESC;")
|
||||||
fun findPatientUniqueStates(): List<CountedState>
|
fun findPatientUniqueStates(): List<CountedState>
|
||||||
@ -100,7 +100,7 @@ interface RequestRepository : CrudRepository<Request, Long>, PagingAndSortingRep
|
|||||||
fun countDeleteStates(): List<CountedState>
|
fun countDeleteStates(): List<CountedState>
|
||||||
|
|
||||||
@Query("SELECT count(*) AS count, status FROM (" +
|
@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'" +
|
"WHERE type = 'DELETE'" +
|
||||||
") rank WHERE rank = 1 GROUP BY status ORDER BY status, count DESC;")
|
") rank WHERE rank = 1 GROUP BY status ORDER BY status, count DESC;")
|
||||||
fun findPatientUniqueDeleteStates(): List<CountedState>
|
fun findPatientUniqueDeleteStates(): List<CountedState>
|
||||||
|
@ -149,7 +149,7 @@ class RequestProcessor(
|
|||||||
requestService.save(
|
requestService.save(
|
||||||
Request(
|
Request(
|
||||||
uuid = requestId,
|
uuid = requestId,
|
||||||
patientId = emptyPatientPseudonym(),
|
patientPseudonym = emptyPatientPseudonym(),
|
||||||
pid = patientId,
|
pid = patientId,
|
||||||
fingerprint = Fingerprint.empty(),
|
fingerprint = Fingerprint.empty(),
|
||||||
status = RequestStatus.ERROR,
|
status = RequestStatus.ERROR,
|
||||||
|
@ -41,10 +41,10 @@ class RequestService(
|
|||||||
fun findByUuid(uuid: RequestId): Optional<Request> =
|
fun findByUuid(uuid: RequestId): Optional<Request> =
|
||||||
requestRepository.findByUuidEquals(uuid)
|
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
|
fun allRequestsByPatientPseudonym(patientPseudonym: PatientPseudonym) = requestRepository
|
||||||
.findAllByPatientIdOrderByProcessedAtDesc(patientPseudonym)
|
.findAllByPatientPseudonymOrderByProcessedAtDesc(patientPseudonym)
|
||||||
|
|
||||||
fun lastMtbFileRequestForPatientPseudonym(patientPseudonym: PatientPseudonym) =
|
fun lastMtbFileRequestForPatientPseudonym(patientPseudonym: PatientPseudonym) =
|
||||||
Companion.lastMtbFileRequestForPatientPseudonym(allRequestsByPatientPseudonym(patientPseudonym))
|
Companion.lastMtbFileRequestForPatientPseudonym(allRequestsByPatientPseudonym(patientPseudonym))
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE request RENAME COLUMN patient_id TO patient_pseudonym;
|
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE request RENAME COLUMN patient_id TO patient_pseudonym;
|
@ -62,10 +62,10 @@
|
|||||||
</td>
|
</td>
|
||||||
<td><time th:datetime="${request.processedAt}">[[ ${request.processedAt} ]]</time></td>
|
<td><time th:datetime="${request.processedAt}">[[ ${request.processedAt} ]]</time></td>
|
||||||
<td class="patient-id" th:if="${patientId != null}" sec:authorize="hasRole('USER') or hasRole('ADMIN')">
|
<td class="patient-id" th:if="${patientId != null}" sec:authorize="hasRole('USER') or hasRole('ADMIN')">
|
||||||
[[ ${request.patientId} ]]
|
[[ ${request.patientPseudonym} ]]
|
||||||
</td>
|
</td>
|
||||||
<td class="patient-id" th:if="${patientId == null}" sec:authorize="hasRole('USER') or hasRole('ADMIN')">
|
<td class="patient-id" th:if="${patientId == null}" sec:authorize="hasRole('USER') or hasRole('ADMIN')">
|
||||||
<a th:href="@{/patient/{pid}(pid=${request.patientId})}">[[ ${request.patientId} ]]</a>
|
<a th:href="@{/patient/{pid}(pid=${request.patientPseudonym})}">[[ ${request.patientPseudonym} ]]</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="patient-id" sec:authorize="not (hasRole('USER') or hasRole('ADMIN'))">***</td>
|
<td class="patient-id" sec:authorize="not (hasRole('USER') or hasRole('ADMIN'))">***</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
<td th:style="${request.type.value == 'delete'} ? 'color: red;'"><small>[[ ${request.type} ]]</small></td>
|
<td th:style="${request.type.value == 'delete'} ? 'color: red;'"><small>[[ ${request.type} ]]</small></td>
|
||||||
<td>[[ ${request.uuid} ]]</td>
|
<td>[[ ${request.uuid} ]]</td>
|
||||||
<td><time th:datetime="${request.processedAt}">[[ ${request.processedAt} ]]</time></td>
|
<td><time th:datetime="${request.processedAt}">[[ ${request.processedAt} ]]</time></td>
|
||||||
<td class="patient-id" sec:authorize="authenticated">[[ ${request.patientId} ]]</td>
|
<td class="patient-id" sec:authorize="authenticated">[[ ${request.patientPseudonym} ]]</td>
|
||||||
<td class="patient-id" sec:authorize="not authenticated">***</td>
|
<td class="patient-id" sec:authorize="not authenticated">***</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -206,21 +206,21 @@ class RequestServiceTest {
|
|||||||
fun allRequestsByPatientPseudonymShouldRequestAllRequestsForPatientPseudonym() {
|
fun allRequestsByPatientPseudonymShouldRequestAllRequestsForPatientPseudonym() {
|
||||||
requestService.allRequestsByPatientPseudonym(PatientPseudonym("TEST_12345678901"))
|
requestService.allRequestsByPatientPseudonym(PatientPseudonym("TEST_12345678901"))
|
||||||
|
|
||||||
verify(requestRepository, times(1)).findAllByPatientIdOrderByProcessedAtDesc(anyValueClass())
|
verify(requestRepository, times(1)).findAllByPatientPseudonymOrderByProcessedAtDesc(anyValueClass())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun lastMtbFileRequestForPatientPseudonymShouldRequestAllRequestsForPatientPseudonym() {
|
fun lastMtbFileRequestForPatientPseudonymShouldRequestAllRequestsForPatientPseudonym() {
|
||||||
requestService.lastMtbFileRequestForPatientPseudonym(PatientPseudonym("TEST_12345678901"))
|
requestService.lastMtbFileRequestForPatientPseudonym(PatientPseudonym("TEST_12345678901"))
|
||||||
|
|
||||||
verify(requestRepository, times(1)).findAllByPatientIdOrderByProcessedAtDesc(anyValueClass())
|
verify(requestRepository, times(1)).findAllByPatientPseudonymOrderByProcessedAtDesc(anyValueClass())
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun isLastRequestDeletionShouldRequestAllRequestsForPatientPseudonym() {
|
fun isLastRequestDeletionShouldRequestAllRequestsForPatientPseudonym() {
|
||||||
requestService.isLastRequestWithKnownStatusDeletion(PatientPseudonym("TEST_12345678901"))
|
requestService.isLastRequestWithKnownStatusDeletion(PatientPseudonym("TEST_12345678901"))
|
||||||
|
|
||||||
verify(requestRepository, times(1)).findAllByPatientIdOrderByProcessedAtDesc(anyValueClass())
|
verify(requestRepository, times(1)).findAllByPatientPseudonymOrderByProcessedAtDesc(anyValueClass())
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user