Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/rydde opp i innsender for persongalleri #6886

Merged
merged 6 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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,10 +10,12 @@ 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
import no.nav.etterlatte.libs.testdata.grunnlag.GrunnlagTestData
import no.nav.etterlatte.libs.testdata.grunnlag.kilde
import org.junit.jupiter.api.Test

class GrunnlagHenterTest {
Expand Down Expand Up @@ -63,6 +65,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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doit after #7052

data class Persongalleri(
val soeker: String,
val innsender: String? = null,
Expand Down