summaryrefslogtreecommitdiff
path: root/src/main/kotlin/dev/dnpm/etl/processor
diff options
context:
space:
mode:
authorPaul-Christian Volkmer2026-03-07 11:09:38 +0100
committerGitHub2026-03-07 10:09:38 +0000
commit17262ea8cf9478bab2b5c34d814c8e1519adf33a (patch)
tree3abd2928ea19f8790fc523fa0f54a6ed6bec9c04 /src/main/kotlin/dev/dnpm/etl/processor
parentee5f9096c85f6789078597ba19f7c02e6b24d2c5 (diff)
feat: search by patient pseudonym and TAN (#256)
Diffstat (limited to 'src/main/kotlin/dev/dnpm/etl/processor')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt2
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt4
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt20
3 files changed, 25 insertions, 1 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 9aede20..4ed071d 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/monitoring/Request.kt
@@ -144,4 +144,6 @@ interface RequestRepository :
") rank WHERE rank = 1 GROUP BY status ORDER BY status, count DESC;"
)
fun findPatientUniqueDeleteStates(): List<CountedState>
+
+ fun findByPatientPseudonymContainingIgnoreCaseOrTanContainingIgnoreCase(patientPseudonym: PatientPseudonym, tan: Tan, pageable: Pageable): Page<Request>
}
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 e7cb95f..3a2ea35 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt
@@ -21,6 +21,7 @@ package dev.dnpm.etl.processor.services
import dev.dnpm.etl.processor.PatientPseudonym
import dev.dnpm.etl.processor.RequestId
+import dev.dnpm.etl.processor.Tan
import dev.dnpm.etl.processor.monitoring.*
import java.util.*
import org.springframework.data.domain.Page
@@ -36,6 +37,9 @@ class RequestService(private val requestRepository: RequestRepository) {
fun findAll(pageable: Pageable): Page<Request> = requestRepository.findAll(pageable)
+ fun searchRequestLike(patientPseudonym: PatientPseudonym, tan: Tan, pageable: Pageable): Page<Request> =
+ requestRepository.findByPatientPseudonymContainingIgnoreCaseOrTanContainingIgnoreCase(patientPseudonym, tan, pageable)
+
fun findByUuid(uuid: RequestId): Optional<Request> = requestRepository.findByUuidEquals(uuid)
fun findRequestByPatientId(
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt b/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt
index 9262c29..6a76c38 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt
@@ -22,12 +22,14 @@ package dev.dnpm.etl.processor.web
import dev.dnpm.etl.processor.NotFoundException
import dev.dnpm.etl.processor.PatientPseudonym
import dev.dnpm.etl.processor.RequestId
+import dev.dnpm.etl.processor.Tan
import dev.dnpm.etl.processor.config.AppConfigProperties
import dev.dnpm.etl.processor.monitoring.ReportService
import dev.dnpm.etl.processor.services.RequestService
import org.springframework.data.domain.Pageable
import org.springframework.data.domain.Sort
import org.springframework.data.web.PageableDefault
+import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.DeleteMapping
@@ -35,6 +37,7 @@ import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PutMapping
import org.springframework.web.bind.annotation.RequestMapping
+import org.springframework.web.bind.annotation.RequestParam
@Controller
@RequestMapping(path = ["/"])
@@ -45,11 +48,26 @@ class HomeController(
) {
@GetMapping
fun index(
+ @RequestParam(name = "q", required = false) queryString: String?,
@PageableDefault(page = 0, size = 10, sort = ["processedAt"], direction = Sort.Direction.DESC)
pageable: Pageable,
model: Model,
): String {
- val requests = requestService.findAll(pageable)
+ val isAdminOrUser =
+ SecurityContextHolder
+ .getContext()
+ .authentication
+ ?.authorities
+ ?.any { it.authority == "ROLE_USER" || it.authority == "ROLE_ADMIN" } == true
+
+ val requests =
+ // Only available for logged-in admins or users
+ if (null != queryString && isAdminOrUser) {
+ model.addAttribute("query", queryString)
+ requestService.searchRequestLike(PatientPseudonym(queryString), Tan(queryString), pageable)
+ } else {
+ requestService.findAll(pageable)
+ }
model.addAttribute("requests", requests)
model.addAttribute("postInitialSubmissionBlock", appConfigProperties.postInitialSubmissionBlock)
return "index"