Skip to content

Commit

Permalink
hent adressebeskyttelse i bolk-spørring
Browse files Browse the repository at this point in the history
  • Loading branch information
sondrele committed Oct 30, 2024
1 parent ec338f7 commit 79a5e49
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ enum class TypeGeografiskTilknytning {
UDEFINERT,
UTLAND,
}

enum class PdlGradering {
FORTROLIG,
STRENGT_FORTROLIG,
STRENGT_FORTROLIG_UTLAND,
UGRADERT,
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import io.ktor.server.routing.*
import io.ktor.server.util.*
import io.ktor.util.pipeline.*
import kotlinx.serialization.Serializable
import no.nav.mulighetsrommet.api.clients.pdl.HentPersonBolkPdlQuery
import no.nav.mulighetsrommet.api.clients.pdl.PdlIdent
import no.nav.mulighetsrommet.api.domain.dto.DeltakerDto
import no.nav.mulighetsrommet.api.okonomi.models.DeltakelsePeriode
Expand Down Expand Up @@ -51,7 +50,7 @@ fun Route.arrangorflateRoutes() {
val refusjonskrav: RefusjonskravRepository by inject()
val deltakerRepository: DeltakerRepository by inject()

val pdl: HentPersonBolkPdlQuery by inject()
val pdl: HentAdressebeskyttetPersonBolkPdlQuery by inject()

suspend fun <T : Any> PipelineContext<T, ApplicationCall>.arrangorerMedTilgang(): List<UUID> {
return call.principal<ArrangorflatePrincipal>()
Expand Down Expand Up @@ -165,7 +164,7 @@ fun Route.arrangorflateRoutes() {
}

suspend fun toRefusjonskrav(
pdl: HentPersonBolkPdlQuery,
pdl: HentAdressebeskyttetPersonBolkPdlQuery,
deltakerRepository: DeltakerRepository,
krav: RefusjonskravDto,
) = when (val beregning = krav.beregning) {
Expand Down Expand Up @@ -219,7 +218,7 @@ suspend fun toRefusjonskrav(
}

private suspend fun getPersoner(
pdl: HentPersonBolkPdlQuery,
pdl: HentAdressebeskyttetPersonBolkPdlQuery,
deltakere: List<DeltakerDto>,
): Map<NorskIdent, RefusjonKravDeltakelse.Person> {
val identer = deltakere
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package no.nav.mulighetsrommet.api.clients.pdl
package no.nav.mulighetsrommet.api.okonomi.refusjon

import arrow.core.Either
import arrow.core.NonEmptySet
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import no.nav.mulighetsrommet.api.clients.pdl.*
import no.nav.mulighetsrommet.domain.serializers.LocalDateSerializer
import no.nav.mulighetsrommet.securelog.SecureLog
import no.nav.mulighetsrommet.tokenprovider.AccessType
import org.slf4j.LoggerFactory
import java.time.LocalDate

class HentPersonBolkPdlQuery(
class HentAdressebeskyttetPersonBolkPdlQuery(
private val pdl: PdlClient,
) {
private val log = LoggerFactory.getLogger(javaClass)
Expand All @@ -18,14 +21,21 @@ class HentPersonBolkPdlQuery(
query = """
query(${'$'}identer: [ID!]!) {
hentPersonBolk(identer: ${'$'}identer) {
ident,
ident
person {
navn {
fornavn
mellomnavn
etternavn
}
},
adressebeskyttelse {
gradering
}
foedselsdato {
foedselsdato
foedselsaar
}
}
code
}
}
Expand All @@ -41,7 +51,7 @@ class HentPersonBolkPdlQuery(
val person = requireNotNull(it.person) {
"person forventet siden response var OK"
}
PdlIdent(it.ident) to HentPersonBolkResponse.Person(person.navn)
PdlIdent(it.ident) to person
}

else -> {
Expand All @@ -63,6 +73,20 @@ data class HentPersonBolkResponse(
@Serializable
data class Person(
val navn: List<PdlNavn>,
val adressebeskyttelse: Adressebeskyttelse,
val foedselsdato: List<Foedselsdato>,
)

@Serializable
data class Adressebeskyttelse(
val gradering: PdlGradering?,
)

@Serializable
data class Foedselsdato(
val foedselsaar: Int,
@Serializable(with = LocalDateSerializer::class)
val foedselsdato: LocalDate?,
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import no.nav.mulighetsrommet.api.clients.msgraph.MicrosoftGraphClient
import no.nav.mulighetsrommet.api.clients.norg2.Norg2Client
import no.nav.mulighetsrommet.api.clients.oppfolging.VeilarboppfolgingClient
import no.nav.mulighetsrommet.api.clients.pamOntologi.PamOntologiClient
import no.nav.mulighetsrommet.api.clients.pdl.HentPersonBolkPdlQuery
import no.nav.mulighetsrommet.api.okonomi.refusjon.HentAdressebeskyttetPersonBolkPdlQuery
import no.nav.mulighetsrommet.api.clients.pdl.PdlClient
import no.nav.mulighetsrommet.api.clients.sanity.SanityClient
import no.nav.mulighetsrommet.api.clients.tiltakshistorikk.TiltakshistorikkClient
Expand Down Expand Up @@ -226,7 +226,7 @@ private fun services(appConfig: AppConfig) = module {
tokenProvider = cachedTokenProvider.withScope(appConfig.pdl.scope),
)
}
single { HentPersonBolkPdlQuery(get()) }
single { HentAdressebeskyttetPersonBolkPdlQuery(get()) }
single<PoaoTilgangClient> {
PoaoTilgangHttpClient(
baseUrl = appConfig.poaoTilgang.url,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import io.ktor.http.content.*
import kotlinx.serialization.json.Json
import no.nav.mulighetsrommet.api.okonomi.refusjon.HentAdressebeskyttetPersonBolkPdlQuery
import no.nav.mulighetsrommet.api.okonomi.refusjon.HentPersonBolkResponse
import no.nav.mulighetsrommet.ktor.createMockEngine
import no.nav.mulighetsrommet.ktor.respondJson

Expand Down Expand Up @@ -38,6 +40,15 @@ class HentPersonBolkPdlQueryTest : FunSpec({
"mellomnavn": null,
"etternavn": "Normann"
}
],
"adressebeskyttelse": {
"gradering": null
},
"foedselsdato": [
{
"foedselsaar": 1980,
"foedselsdato": null
}
]
},
"code": "ok"
Expand All @@ -61,7 +72,7 @@ class HentPersonBolkPdlQueryTest : FunSpec({
),
)

val query = HentPersonBolkPdlQuery(pdl)
val query = HentAdressebeskyttetPersonBolkPdlQuery(pdl)

val response = query.hentPersonBolk(identer).shouldBeRight()

Expand All @@ -70,6 +81,15 @@ class HentPersonBolkPdlQueryTest : FunSpec({
navn = listOf(
PdlNavn(fornavn = "Ola", etternavn = "Normann"),
),
adressebeskyttelse = HentPersonBolkResponse.Adressebeskyttelse(
gradering = null,
),
foedselsdato = listOf(
HentPersonBolkResponse.Foedselsdato(
foedselsaar = 1980,
foedselsdato = null,
),
),
),
)
}
Expand Down

0 comments on commit 79a5e49

Please sign in to comment.