From 21d3f412207bca685bfde0461b8c101128e3aaba Mon Sep 17 00:00:00 2001 From: Tanja Krasnomovets Date: Tue, 20 Feb 2024 14:55:16 +0100 Subject: [PATCH] Allow isodate format --- .../syfo/api/maxdate/SykepengerMaxDateRest.kt | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/no/nav/syfo/api/maxdate/SykepengerMaxDateRest.kt b/src/main/kotlin/no/nav/syfo/api/maxdate/SykepengerMaxDateRest.kt index 06b1be0b2..97d3974f9 100644 --- a/src/main/kotlin/no/nav/syfo/api/maxdate/SykepengerMaxDateRest.kt +++ b/src/main/kotlin/no/nav/syfo/api/maxdate/SykepengerMaxDateRest.kt @@ -19,11 +19,24 @@ fun Route.registerSykepengerMaxDateRestApi( get("/api/v1/sykepenger/maxdate") { val principal: BrukerPrincipal = call.authentication.principal()!! val sykmeldtFnr = principal.fnr + val isoFormat = call.request.queryParameters["isoformat"]?.toBoolean() ?: false try { val sykepengerMaxDate = sykepengerMaxDateService.getSykepengerMaxDate(sykmeldtFnr) - val maxDate = sykepengerMaxDate?.let { formatDateForLetter(it.forelopig_beregnet_slutt) } - val utbetaltTom = sykepengerMaxDate?.let { formatDateForLetter(it.utbetalt_tom) } + val maxDate = sykepengerMaxDate?.let { + if (isoFormat) { + it.forelopig_beregnet_slutt.toString() + } else { + formatDateForLetter(it.forelopig_beregnet_slutt) + } + } + val utbetaltTom = sykepengerMaxDate?.let { + if (isoFormat) { + it.utbetalt_tom.toString() + } else { + formatDateForLetter(it.utbetalt_tom) + } + } log.info("Fetched sykepengerMaxDate from database: ${sykepengerMaxDate?.forelopig_beregnet_slutt}") call.respond(SykepengerMaxDateResponse(maxDate, utbetaltTom)) } catch (e: Exception) {