Skip to content

Commit

Permalink
la på caching av PDL-oppslag
Browse files Browse the repository at this point in the history
  • Loading branch information
jankroken-nav committed Oct 15, 2024
1 parent cf6a862 commit 076017c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import no.nav.pensjon.opptjening.omsorgsopptjening.felles.domene.kafka.Rådata
import no.nav.pensjon.opptjening.omsorgsopptjening.felles.domene.kafka.RådataFraKilde
import no.nav.pensjon.opptjening.omsorgsopptjening.felles.domene.kafka.messages.domene.PersongrunnlagMelding
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.external.barnetrygd.BarnetrygdClient
import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.external.pdl.PdlService
import org.springframework.stereotype.Service

@Service
class KompletteringsService(
val pdlService: PdlService,
val personIdService: PersonIdService,
private val client: BarnetrygdClient,
private val hjelpestønadService: HjelpestønadService,
) {
Expand All @@ -18,7 +17,8 @@ class KompletteringsService(
val filter = GyldigÅrsintervallFilter(barnetrygdmottakerUtenPdlData.år)

val barnetrygdmottaker = barnetrygdmottakerUtenPdlData.withPerson(
pdlService.hentPerson(barnetrygdmottakerUtenPdlData.ident)
// TODO: håndter manglende svar
personIdService.personFromIdent(barnetrygdmottakerUtenPdlData.ident)!!
)

val barnetrygdData: BarnetrygdData = hentBarnetrygd(barnetrygdmottaker, filter)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.domain

import no.nav.pensjon.opptjening.omsorgsopptjening.start.innlesning.barnetrygd.external.pdl.PdlService
import org.springframework.stereotype.Service

@Service
class PersonIdService(
val pdlService: PdlService,
) {
val personIdMap: MutableMap<String, PersonId> = mutableMapOf()

// TODO: håndter personer som ikke finnes i PDL
fun personFromIdent(fnr: String): PersonId? {
if (!personIdMap.containsKey(fnr)) {
val personId = pdlService.hentPerson(fnr)
personId.historiske.forEach {
personIdMap[it] = personId
}
}
return personIdMap[fnr]
}

}

0 comments on commit 076017c

Please sign in to comment.