diff --git a/apps/etterlatte-behandling/src/main/kotlin/behandling/BehandlingFactory.kt b/apps/etterlatte-behandling/src/main/kotlin/behandling/BehandlingFactory.kt index 26263d0803a..607d500e204 100644 --- a/apps/etterlatte-behandling/src/main/kotlin/behandling/BehandlingFactory.kt +++ b/apps/etterlatte-behandling/src/main/kotlin/behandling/BehandlingFactory.kt @@ -107,22 +107,11 @@ class BehandlingFactory( } } - val persongalleri = - with(request) { - if (kilde?.foerstOpprettaIPesys() == true) { - persongalleri.copy(innsender = kilde!!.name) - } else if (persongalleri.innsender == null) { - persongalleri.copy(innsender = brukerTokenInfo.ident()) - } else { - persongalleri - } - } - val behandling = inTransaction { opprettBehandling( sak.id, - persongalleri, + request.persongalleri, request.mottattDato, request.kilde ?: Vedtaksloesning.GJENNY, request = hentDataForOpprettBehandling(sak.id), @@ -239,7 +228,7 @@ class BehandlingFactory( grunnlagService.leggInnNyttGrunnlag( behandling, persongalleri, - HardkodaSystembruker.opprettGrunnlag, + brukerTokenInfo, ) } @@ -355,7 +344,7 @@ class BehandlingFactory( grunnlagService.leggInnNyttGrunnlag( behandlingerForOmgjoering.nyFoerstegangsbehandling, persongalleri, - HardkodaSystembruker.opprettGrunnlag, + brukerTokenInfo = saksbehandler, ) } diff --git a/apps/etterlatte-behandling/src/main/kotlin/behandling/revurdering/RevurderingService.kt b/apps/etterlatte-behandling/src/main/kotlin/behandling/revurdering/RevurderingService.kt index 83366973bc1..6a60547a40b 100644 --- a/apps/etterlatte-behandling/src/main/kotlin/behandling/revurdering/RevurderingService.kt +++ b/apps/etterlatte-behandling/src/main/kotlin/behandling/revurdering/RevurderingService.kt @@ -1,6 +1,7 @@ package no.nav.etterlatte.behandling.revurdering import kotlinx.coroutines.runBlocking +import no.nav.etterlatte.Kontekst import no.nav.etterlatte.behandling.BehandlingDao import no.nav.etterlatte.behandling.BehandlingHendelserKafkaProducer import no.nav.etterlatte.behandling.GrunnlagService @@ -213,7 +214,7 @@ class RevurderingService( grunnlagService.leggInnNyttGrunnlag( it, persongalleri, - HardkodaSystembruker.opprettGrunnlag, + Kontekst.get().brukerTokenInfo ?: HardkodaSystembruker.opprettGrunnlag, // Yolo ) } else { grunnlagService.laasTilGrunnlagIBehandling( diff --git a/apps/etterlatte-behandling/src/main/kotlin/grunnlagsendring/doedshendelse/DoedshendelseJobService.kt b/apps/etterlatte-behandling/src/main/kotlin/grunnlagsendring/doedshendelse/DoedshendelseJobService.kt index 489e94a4db4..426bbc790fa 100644 --- a/apps/etterlatte-behandling/src/main/kotlin/grunnlagsendring/doedshendelse/DoedshendelseJobService.kt +++ b/apps/etterlatte-behandling/src/main/kotlin/grunnlagsendring/doedshendelse/DoedshendelseJobService.kt @@ -18,7 +18,6 @@ import no.nav.etterlatte.grunnlagsendring.doedshendelse.kontrollpunkt.Doedshende import no.nav.etterlatte.grunnlagsendring.doedshendelse.kontrollpunkt.finnOppgaveId import no.nav.etterlatte.grunnlagsendring.doedshendelse.kontrollpunkt.finnSak import no.nav.etterlatte.inTransaction -import no.nav.etterlatte.libs.common.Vedtaksloesning import no.nav.etterlatte.libs.common.behandling.Persongalleri import no.nav.etterlatte.libs.common.behandling.SakType import no.nav.etterlatte.libs.common.behandling.Saksrolle @@ -181,18 +180,17 @@ class DoedshendelseJobService( SakType.BARNEPENSJON -> hentAnnenForelder(doedshendelse) SakType.OMSTILLINGSSTOENAD -> null } - val galleri = + val persongalleri = Persongalleri( soeker = doedshendelse.beroertFnr, avdoed = listOf(doedshendelse.avdoedFnr), gjenlevende = listOfNotNull(gjenlevende), - innsender = Vedtaksloesning.GJENNY.name, ) runBlocking { grunnlagService.leggInnNyttGrunnlagSak( sak = opprettetSak, - galleri, + persongalleri, HardkodaSystembruker.doedshendelse, ) } diff --git a/apps/etterlatte-grunnlag/src/main/kotlin/grunnlag/GrunnlagHenter.kt b/apps/etterlatte-grunnlag/src/main/kotlin/grunnlag/GrunnlagHenter.kt index c8fa90b5fb9..bd1b2c25bdb 100644 --- a/apps/etterlatte-grunnlag/src/main/kotlin/grunnlag/GrunnlagHenter.kt +++ b/apps/etterlatte-grunnlag/src/main/kotlin/grunnlag/GrunnlagHenter.kt @@ -6,7 +6,6 @@ import kotlinx.coroutines.Deferred import kotlinx.coroutines.async import kotlinx.coroutines.coroutineScope import no.nav.etterlatte.grunnlag.klienter.PdlTjenesterKlientImpl -import no.nav.etterlatte.libs.common.Vedtaksloesning import no.nav.etterlatte.libs.common.behandling.Persongalleri import no.nav.etterlatte.libs.common.behandling.SakType import no.nav.etterlatte.libs.common.grunnlag.Grunnlagsopplysning @@ -20,11 +19,14 @@ import no.nav.etterlatte.libs.common.person.Person import no.nav.etterlatte.libs.common.person.PersonRolle import no.nav.etterlatte.libs.common.tidspunkt.Tidspunkt import no.nav.etterlatte.libs.common.toJsonNode +import org.slf4j.LoggerFactory import java.util.UUID class GrunnlagHenter( private val pdltjenesterKlient: PdlTjenesterKlientImpl, ) { + private val logger = LoggerFactory.getLogger(this::class.java) + suspend fun hentGrunnlagsdata(opplysningsbehov: Opplysningsbehov): HentetGrunnlag = coroutineScope { val persongalleri = opplysningsbehov.persongalleri @@ -137,34 +139,25 @@ class GrunnlagHenter( }, ) - private fun Persongalleri.tilGrunnlagsopplysningFraSoeknad( - overstyrtKilde: Grunnlagsopplysning.Kilde? = null, - ): Grunnlagsopplysning = - Grunnlagsopplysning( - id = UUID.randomUUID(), - kilde = - overstyrtKilde - ?: if (this.innsender == null) { - Grunnlagsopplysning.UkjentInnsender(Tidspunkt.now()) - } else if (this.innsender == Vedtaksloesning.PESYS.name) { - Grunnlagsopplysning.Pesys.create() - } else if (this.innsender!!.matches(Regex("[A-Z][0-9]+"))) { - Grunnlagsopplysning.Saksbehandler(this.innsender!!, Tidspunkt.now()) - } else { - Grunnlagsopplysning.Privatperson(this.innsender!!, Tidspunkt.now()) - }, + private fun Persongalleri.tilGrunnlagsopplysningFraSoeknad(overstyrtKilde: Grunnlagsopplysning.Kilde): Grunnlagsopplysning { + val opplysningid = UUID.randomUUID() + return Grunnlagsopplysning( + id = opplysningid, + kilde = overstyrtKilde, opplysningType = Opplysningstype.PERSONGALLERI_V1, meta = objectMapper.createObjectNode(), opplysning = if (Folkeregisteridentifikator.isValid(this.innsender)) { this.toJsonNode() } else { + logger.error("Ugyldig ident er lagret, se relatert for opplysninstypeid: $opplysningid") this.copy(innsender = null).toJsonNode() }, attestering = null, fnr = null, periode = null, ) + } private fun Persongalleri.tilGrunnlagsopplysningFraPdl(): Grunnlagsopplysning = Grunnlagsopplysning( diff --git a/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/BehandlingGrunnlagRoutesKtTest.kt b/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/BehandlingGrunnlagRoutesKtTest.kt index 3a0c22b4612..efd676cb375 100644 --- a/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/BehandlingGrunnlagRoutesKtTest.kt +++ b/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/BehandlingGrunnlagRoutesKtTest.kt @@ -256,7 +256,8 @@ internal class BehandlingGrunnlagRoutesKtTest { val sakId = randomSakId() val behandlingId = UUID.randomUUID() val persongalleri = GrunnlagTestData().hentPersonGalleri() - val opplysningsbehov = Opplysningsbehov(sakId, SakType.BARNEPENSJON, persongalleri) + val opplysningsbehov = + Opplysningsbehov(sakId, SakType.BARNEPENSJON, persongalleri, Grunnlagsopplysning.Saksbehandler.create("ident")) coEvery { grunnlagService.opprettGrunnlag(any(), any()) } just Runs diff --git a/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/GrunnlagHenterTest.kt b/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/GrunnlagHenterTest.kt index 83479dc8b54..3e4ae7d8344 100644 --- a/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/GrunnlagHenterTest.kt +++ b/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/GrunnlagHenterTest.kt @@ -10,6 +10,7 @@ import no.nav.etterlatte.behandling.sakId1 import no.nav.etterlatte.grunnlag.klienter.PdlTjenesterKlientImpl import no.nav.etterlatte.libs.common.behandling.Persongalleri import no.nav.etterlatte.libs.common.behandling.SakType +import no.nav.etterlatte.libs.common.grunnlag.Grunnlagsopplysning import no.nav.etterlatte.libs.common.grunnlag.Opplysningsbehov import no.nav.etterlatte.libs.common.pdl.OpplysningDTO import no.nav.etterlatte.libs.common.person.Person @@ -63,6 +64,7 @@ class GrunnlagHenterTest { grunnlagTestData.avdoede.map { it.foedselsnummer.value }, listOf(grunnlagTestData.gjenlevende.foedselsnummer.value), ), + kilde = Grunnlagsopplysning.Saksbehandler.create("ident"), ), ) } diff --git a/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/GrunnlagServiceTest.kt b/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/GrunnlagServiceTest.kt index e9147976454..20ef7cf9f9f 100644 --- a/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/GrunnlagServiceTest.kt +++ b/apps/etterlatte-grunnlag/src/test/kotlin/grunnlag/GrunnlagServiceTest.kt @@ -242,7 +242,7 @@ internal class GrunnlagServiceTest { every { opplysningDaoMock.finnHendelserIGrunnlag(sakId) } returns emptyList() every { opplysningDaoMock.leggOpplysningTilGrunnlag(any(), any(), any()) } returns sakId.sakId - val opplysningsbehov = Opplysningsbehov(sakId, SakType.BARNEPENSJON, galleri) + val opplysningsbehov = Opplysningsbehov(sakId, SakType.BARNEPENSJON, galleri, kilde) runBlocking { grunnlagService.opprettEllerOppdaterGrunnlagForSak(sakId, opplysningsbehov) } diff --git a/libs/etterlatte-behandling-model/src/main/kotlin/no/nav/etterlatte/libs/common/grunnlag/Opplysningsbehov.kt b/libs/etterlatte-behandling-model/src/main/kotlin/no/nav/etterlatte/libs/common/grunnlag/Opplysningsbehov.kt index 43ede6fe22f..e46846cd69c 100644 --- a/libs/etterlatte-behandling-model/src/main/kotlin/no/nav/etterlatte/libs/common/grunnlag/Opplysningsbehov.kt +++ b/libs/etterlatte-behandling-model/src/main/kotlin/no/nav/etterlatte/libs/common/grunnlag/Opplysningsbehov.kt @@ -8,5 +8,5 @@ data class Opplysningsbehov( val sakId: SakId, val sakType: SakType, val persongalleri: Persongalleri, - val kilde: Grunnlagsopplysning.Kilde? = null, + val kilde: Grunnlagsopplysning.Kilde, ) diff --git a/libs/saksbehandling-common/src/main/kotlin/behandling/Persongalleri.kt b/libs/saksbehandling-common/src/main/kotlin/behandling/Persongalleri.kt index 7676d3bf20c..82fd7cea304 100644 --- a/libs/saksbehandling-common/src/main/kotlin/behandling/Persongalleri.kt +++ b/libs/saksbehandling-common/src/main/kotlin/behandling/Persongalleri.kt @@ -7,6 +7,7 @@ import java.time.LocalDate /* innsender: Denne brukes til å indikere system eller saksbehandler ident(manuelt opprettet behandling) i tillegg til faktisk innsender(innbygger) */ +// TODO: gjøre om alle strings her til Folkeregister identifikator data class Persongalleri( val soeker: String, val innsender: String? = null,