Skip to content

Commit

Permalink
Feature/rydde opp i innsender for persongalleri (#6886)
Browse files Browse the repository at this point in the history
* Fiks opp i at random strings settes i persongalleriet

* Egen pr for dette eller ei?

* Fiks logger

* Fiks grunnlagstester

* Ubrukt import

* Fjern ubrukt innsender fra dødshendelsejobb
  • Loading branch information
sebassonav authored Jan 28, 2025
1 parent d89b2c8 commit e761c46
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -239,7 +228,7 @@ class BehandlingFactory(
grunnlagService.leggInnNyttGrunnlag(
behandling,
persongalleri,
HardkodaSystembruker.opprettGrunnlag,
brukerTokenInfo,
)
}

Expand Down Expand Up @@ -355,7 +344,7 @@ class BehandlingFactory(
grunnlagService.leggInnNyttGrunnlag(
behandlingerForOmgjoering.nyFoerstegangsbehandling,
persongalleri,
HardkodaSystembruker.opprettGrunnlag,
brukerTokenInfo = saksbehandler,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -213,7 +214,7 @@ class RevurderingService(
grunnlagService.leggInnNyttGrunnlag(
it,
persongalleri,
HardkodaSystembruker.opprettGrunnlag,
Kontekst.get().brukerTokenInfo ?: HardkodaSystembruker.opprettGrunnlag, // Yolo
)
} else {
grunnlagService.laasTilGrunnlagIBehandling(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
)
}
Expand Down
27 changes: 10 additions & 17 deletions apps/etterlatte-grunnlag/src/main/kotlin/grunnlag/GrunnlagHenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -137,34 +139,25 @@ class GrunnlagHenter(
},
)

private fun Persongalleri.tilGrunnlagsopplysningFraSoeknad(
overstyrtKilde: Grunnlagsopplysning.Kilde? = null,
): Grunnlagsopplysning<JsonNode> =
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<JsonNode> {
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<JsonNode> =
Grunnlagsopplysning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,6 +64,7 @@ class GrunnlagHenterTest {
grunnlagTestData.avdoede.map { it.foedselsnummer.value },
listOf(grunnlagTestData.gjenlevende.foedselsnummer.value),
),
kilde = Grunnlagsopplysning.Saksbehandler.create("ident"),
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e761c46

Please sign in to comment.