Skip to content

Commit

Permalink
🐛 Fullmakt løsningen er et objekt med en liste av fullmakter
Browse files Browse the repository at this point in the history
Co-authored-by: Øyvind Hagen <[email protected]>
  • Loading branch information
MartinMekk and oyvindhagen committed Aug 22, 2024
1 parent 1acc582 commit 365442a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ internal class Fullmaktløsning(
it.demandKey("fødselsnummer")
it.requireKey("@id")
it.require("@opprettet") { node -> node.asLocalDateTime() }
it.requireArray("@løsning") {
requireArray("fullmakt") {
interestedIn("gyldigFraOgMed", "gyldigTilOgMed")
it.require("@løsning") { node ->
node["fullmakt"].map { fullmaktNode ->
Fullmakt(
gyldigFraOgMed = fullmaktNode["gyldigFraOgMed"].asLocalDate(),
gyldigTilOgMed = fullmaktNode["gyldigTilOgMed"].asOptionalLocalDate(),
)
}
}
}
Expand All @@ -47,11 +50,9 @@ internal class Fullmaktløsning(

val= LocalDate.now()
val harFullmakt =
packet["@løsning"].any { fullmaktNode ->
val fullmakt = fullmaktNode.path("fullmakt")
fullmakt.size() > 0 &&
fullmakt[0]["gyldigFraOgMed"].asLocalDate().isSameOrBefore(nå) &&
fullmakt[0]["gyldigTilOgMed"].asOptionalLocalDate()?.isSameOrAfter(nå) ?: true
packet["@løsning"]["fullmakt"].any { fullmaktNode ->
fullmaktNode["gyldigFraOgMed"].asLocalDate().isSameOrBefore(nå) &&
fullmaktNode["gyldigTilOgMed"].asOptionalLocalDate()?.isSameOrAfter(nå) ?: true
}

val fullmaktløsning =
Expand All @@ -70,6 +71,8 @@ internal class Fullmaktløsning(
}
}

data class Fullmakt(val gyldigFraOgMed: LocalDate, val gyldigTilOgMed: LocalDate?)

fun LocalDate.isSameOrBefore(other: LocalDate) = this.isEqual(other) || this.isBefore(other)

fun LocalDate.isSameOrAfter(other: LocalDate) = this.isEqual(other) || this.isAfter(other)
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,15 @@ internal object Testmeldingfabrikk {
"@behov" to listOf("Fullmakt"),
"contextId" to "${UUID.randomUUID()}",
"hendelseId" to "${UUID.randomUUID()}",
"@løsning" to listOf(
mapOf(
"fullmakt" to listOf(
mapOf(
"omraade" to listOf("SYK", "SYM"),
"gyldigFraOgMed" to fom,
"gyldigTilOgMed" to tom,
)
"@løsning" to mapOf(
"fullmakt" to listOf(
mapOf(
"omraade" to listOf("SYK", "SYM"),
"gyldigFraOgMed" to fom,
"gyldigTilOgMed" to tom,
)
)

)
)
)
Expand All @@ -126,10 +125,8 @@ internal object Testmeldingfabrikk {
"@behov" to listOf("Fullmakt"),
"contextId" to "${UUID.randomUUID()}",
"hendelseId" to "${UUID.randomUUID()}",
"@løsning" to listOf(
mapOf(
"fullmakt" to emptyList<Map<String, String>>()
)
"@løsning" to mapOf(
"fullmakt" to emptyList<Map<String, String>>()
)
)
)
Expand Down

0 comments on commit 365442a

Please sign in to comment.