summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/config/AppWebConfig.kt13
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt24
-rw-r--r--src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt35
-rw-r--r--src/main/resources/templates/index.html13
4 files changed, 77 insertions, 8 deletions
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/config/AppWebConfig.kt b/src/main/kotlin/dev/dnpm/etl/processor/config/AppWebConfig.kt
new file mode 100644
index 0000000..3aa50f2
--- /dev/null
+++ b/src/main/kotlin/dev/dnpm/etl/processor/config/AppWebConfig.kt
@@ -0,0 +1,13 @@
+package dev.dnpm.etl.processor.config
+
+import org.springframework.boot.convert.ApplicationConversionService
+import org.springframework.context.annotation.Configuration
+import org.springframework.format.FormatterRegistry
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
+
+@Configuration
+class AppWebConfig : WebMvcConfigurer {
+ override fun addFormatters(registry: FormatterRegistry) {
+ ApplicationConversionService.configure(registry)
+ }
+}
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 3a2ea35..7174974 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/services/RequestService.kt
@@ -25,6 +25,7 @@ import dev.dnpm.etl.processor.Tan
import dev.dnpm.etl.processor.monitoring.*
import java.util.*
import org.springframework.data.domain.Page
+import org.springframework.data.domain.PageImpl
import org.springframework.data.domain.Pageable
import org.springframework.stereotype.Service
@@ -85,4 +86,27 @@ class RequestService(private val requestRepository: RequestRepository) {
.maxByOrNull { it.processedAt }
?.type == RequestType.DELETE
}
+
+ enum class Filter(val value: String) {
+ ALL_DIP("all-dip"),
+ CONFIRMED("confirmed"),
+ UNCONFIRMED("unconfirmed");
+ }
+}
+
+fun Page<Request>.filter(filter: RequestService.Filter): Page<Request> {
+ val list =
+ this
+ .toList()
+ .filter {
+ it.type == RequestType.MTB_FILE
+ && sequenceOf(RequestStatus.SUCCESS, RequestStatus.WARNING).contains(it.status)
+ }
+ .filter {
+ filter == RequestService.Filter.ALL_DIP
+ || filter == RequestService.Filter.CONFIRMED && it.submissionAccepted
+ || filter == RequestService.Filter.UNCONFIRMED && !it.submissionAccepted
+ }
+
+ return PageImpl(list, this.pageable, list.size.toLong())
}
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 3092367..35045da 100644
--- a/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt
+++ b/src/main/kotlin/dev/dnpm/etl/processor/web/HomeController.kt
@@ -26,18 +26,16 @@ 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 dev.dnpm.etl.processor.services.filter
+import org.springframework.core.convert.converter.Converter
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.Component
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
-import org.springframework.web.bind.annotation.DeleteMapping
-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
+import org.springframework.web.bind.annotation.*
@Controller
@RequestMapping(path = ["/"])
@@ -49,6 +47,7 @@ class HomeController(
@GetMapping
fun index(
@RequestParam(name = "q", required = false) queryString: String?,
+ @RequestParam(name = "f", required = false) filter: RequestService.Filter?,
@PageableDefault(page = 0, size = 10, sort = ["processedAt"], direction = Sort.Direction.DESC)
pageable: Pageable,
model: Model,
@@ -64,10 +63,20 @@ class HomeController(
// Only available for logged-in admins or users
if (null != queryString && isAdminOrUser) {
model.addAttribute("query", queryString)
- requestService.searchRequestLike(PatientPseudonym(queryString), Tan(queryString), pageable)
+ if (null != filter) {
+ model.addAttribute("filter", filter.value)
+ requestService
+ .searchRequestLike(PatientPseudonym(queryString), Tan(queryString), pageable)
+ .filter(filter)
+ } else {
+ requestService
+ .searchRequestLike(PatientPseudonym(queryString), Tan(queryString), pageable)
+ }
+
} else {
requestService.findAll(pageable)
}
+
model.addAttribute("requests", requests)
model.addAttribute("postInitialSubmissionBlock", appConfigProperties.postInitialSubmissionBlock)
return "index"
@@ -129,4 +138,16 @@ class HomeController(
return "fragments :: request"
}
+
+ @Component
+ class FilterConverter : Converter<String, RequestService.Filter?> {
+ override fun convert(source: String): RequestService.Filter? {
+ return when (source) {
+ "all-dip" -> RequestService.Filter.ALL_DIP
+ "confirmed" -> RequestService.Filter.CONFIRMED
+ "unconfirmed" -> RequestService.Filter.UNCONFIRMED
+ else -> null
+ }
+ }
+ }
}
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html
index 7245a8b..40fb90a 100644
--- a/src/main/resources/templates/index.html
+++ b/src/main/resources/templates/index.html
@@ -12,12 +12,23 @@
<div class="search-form" sec:authorize="hasRole('USER') or hasRole('ADMIN')">
<form th:action="@{/}" method="get">
<input id="search-input" type="text" name="q" maxlength="64" placeholder="Suche nach Patienten-Pseudonym oder TAN" th:value="${query}"/>
+ <select name="f" onchange="this.form.submit()">
+ <option value="">in allen Anfragen</option>
+ <option th:selected="${filter == 'all-dip'}" th:value="all-dip">in DNPM:DIP</option>
+ <option th:if="${postInitialSubmissionBlock}" th:selected="${filter == 'confirmed'}" th:value="confirmed">in DNPM:DIP mit Meldebestätigung</option>
+ <option th:if="${postInitialSubmissionBlock}" th:selected="${filter == 'unconfirmed'}" th:value="unconfirmed">in DNPM:DIP ohne Meldebestätigung</option>
+ </select>
<a th:href="@{/}">🞫</a>
</form>
</div>
<h1>
- Alle Anfragen
+ <th:block th:switch="${filter}">
+ <th:block th:case="null">Alle Anfragen</th:block>
+ <th:block th:case="'all-dip'">Alle Anfragen in DNPM:DIP</th:block>
+ <th:block th:case="'confirmed'">Alle Anfragen in DNPM:DIP mit Meldebestätigung</th:block>
+ <th:block th:case="'unconfirmed'">Alle Anfragen in DNPM:DIP ohne Meldebestätigung</th:block>
+ </th:block>
<a id="reload-notify" class="btn btn-red reload" title="Neue Anfragen laden" th:href="@{/}">
<span>Neue Anfragen laden</span>
</a>