This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sjekk om nytt foedselsnummer finnes i database hvis nei hent aktorid …
…fra PDL og sett inn
- Loading branch information
1 parent
a44221a
commit 6b04115
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/kotlin/no/nav/fo/veilarbregistrering/aktorIdCache/AktorIdCacheService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package no.nav.fo.veilarbregistrering.aktorIdCache | ||
|
||
import no.nav.fo.veilarbregistrering.bruker.AktorId | ||
import no.nav.fo.veilarbregistrering.bruker.Foedselsnummer | ||
import no.nav.fo.veilarbregistrering.bruker.Gruppe | ||
import no.nav.fo.veilarbregistrering.bruker.PdlOppslagGateway | ||
import java.time.LocalDateTime | ||
|
||
class AktorIdCacheService( | ||
private val pdlOppslagGateway: PdlOppslagGateway, | ||
private val aktorIdCacheRepository: AktorIdCacheRepository, | ||
) { | ||
fun sjekkFoedselsnummerOgHvisNeiSettInn(foedselsnummer: Foedselsnummer) { | ||
if (aktorIdCacheRepository.hentAktørId(foedselsnummer) != null) return | ||
val identer = pdlOppslagGateway.hentIdenter(foedselsnummer) | ||
|
||
// hente ut | ||
val aktorId = identer.identer.first { !it.isHistorisk && it.gruppe == Gruppe.AKTORID }.ident | ||
// sette inn | ||
|
||
val aktorIdCache = AktorIdCache( | ||
foedselsnummer = foedselsnummer, | ||
aktorId = AktorId(aktorId), | ||
opprettetDato = LocalDateTime.now() | ||
) | ||
|
||
aktorIdCacheRepository.lagre(aktorIdCache) | ||
} | ||
|
||
|
||
} |