Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feature/EY-5030-behan…
Browse files Browse the repository at this point in the history
…dling-som-brev-proxy
  • Loading branch information
tvsignal committed Feb 26, 2025
2 parents 6fa6d48 + 0210aac commit ed84c17
Show file tree
Hide file tree
Showing 46 changed files with 424 additions and 637 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class BehandlingFactory(
OmgjoerBehandling(nyFoerstegangsbehandling, sisteAvslaatteBehandling, foerstegangsbehandlingViOmgjoerer)
}

val persongalleri = runBlocking { grunnlagService.hentPersongalleri(sakId)!! }
val persongalleri = grunnlagService.hentPersongalleri(sakId)!!

runBlocking {
grunnlagService.opprettGrunnlag(
Expand Down Expand Up @@ -462,10 +462,8 @@ class BehandlingFactory(
"${persongalleri.soesken.size} søsken"
} else if (sak.sakType == SakType.OMSTILLINGSSTOENAD) {
val grunnlag: Grunnlag? =
runBlocking {
grunnlagService
.hentOpplysningsgrunnlag(behandlingId)
}
grunnlagService
.hentOpplysningsgrunnlag(behandlingId)

val avdoede = grunnlag?.hentAvdoede()?.firstOrNull()
val barn = avdoede?.hentAvdoedesbarn()?.verdi?.avdoedesBarn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ internal class BehandlingServiceImpl(
grunnlagsendringshendelseDao.kobleGrunnlagsendringshendelserFraBehandlingId(behandlingId)
}

val persongalleri = runBlocking { grunnlagService.hentPersongalleri(behandlingId)!! }
val persongalleri = grunnlagService.hentPersongalleri(behandlingId)!!

behandlingHendelser.sendMeldingForHendelseStatistikk(
behandling.toStatistikkBehandling(persongalleri = persongalleri),
Expand All @@ -434,9 +434,8 @@ internal class BehandlingServiceImpl(
): DetaljertBehandling? =
hentBehandling(behandlingId)?.let {
val persongalleri: Persongalleri =
runBlocking {
grunnlagService.hentPersongalleri(behandlingId)
} ?: throw NoSuchElementException("Persongalleri mangler for sak ${it.sak.id}")
grunnlagService.hentPersongalleri(behandlingId)
?: throw NoSuchElementException("Persongalleri mangler for sak ${it.sak.id}")

it.toDetaljertBehandlingWithPersongalleri(persongalleri)
}
Expand Down Expand Up @@ -487,7 +486,7 @@ internal class BehandlingServiceImpl(
* https://lovdata.no/dokument/NL/lov/1997-02-28-19/KAPITTEL_8-2#%C2%A722-12
* https://lovdata.no/dokument/NL/lov/1997-02-28-19/KAPITTEL_8-2#%C2%A722-13
*/
private suspend fun erGyldigVirkningstidspunktFoerstegangsbehandling(
private fun erGyldigVirkningstidspunktFoerstegangsbehandling(
request: VirkningstidspunktRequest,
behandling: Behandling,
): Boolean {
Expand Down Expand Up @@ -578,7 +577,7 @@ internal class BehandlingServiceImpl(
}
}

private suspend fun hentFoersteDoedsdato(
private fun hentFoersteDoedsdato(
behandlingId: UUID,
sakType: SakType,
): LocalDate? {
Expand Down Expand Up @@ -970,7 +969,7 @@ internal class BehandlingServiceImpl(
virkningstidspunkt != null &&
virkningstidspunkt.isAfter(opphoerFraOgMed)

private suspend fun endrePersongalleriOgOppdaterGrunnlag(
private fun endrePersongalleriOgOppdaterGrunnlag(
behandlingId: UUID,
brukerTokenInfo: BrukerTokenInfo,
transform: (Persongalleri) -> Persongalleri,
Expand All @@ -993,13 +992,11 @@ internal class BehandlingServiceImpl(
periode = null,
),
)
runBlocking {
grunnlagService.lagreNyeSaksopplysninger(
behandling.sak.id,
behandlingId,
nyeOpplysinger,
)
}
grunnlagService.lagreNyeSaksopplysninger(
behandling.sak.id,
behandlingId,
nyeOpplysinger,
)

runBlocking {
grunnlagService.oppdaterGrunnlag(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ internal fun Route.aktivitetspliktRoutes(

val aktiviteter =
inTransaction {
aktivitetspliktService.slettAktivitet(aktivitetId, brukerTokenInfo, behandlingId)
aktivitetspliktService.slettAktivitet(aktivitetId, behandlingId)
aktivitetspliktService.hentAktiviteter(behandlingId)
}

Expand Down Expand Up @@ -136,7 +136,7 @@ internal fun Route.aktivitetspliktRoutes(

val aktiviteter =
inTransaction {
aktivitetspliktService.slettAktivitet(aktivitetId, brukerTokenInfo, sakId = sakId)
aktivitetspliktService.slettAktivitet(aktivitetId, sakId = sakId)
aktivitetspliktService.hentAktiviteter(sakId = sakId)
}

Expand Down Expand Up @@ -167,12 +167,10 @@ internal fun Route.aktivitetspliktRoutes(
logger.info("Henter hendelser for sak $sakId")
val dto =
inTransaction {
runBlocking {
aktivitetspliktService.hentHendelser(
sakId = sakId,
behandlingId = behandlingId,
)
}
aktivitetspliktService.hentHendelser(
sakId = sakId,
behandlingId = behandlingId,
)
}
call.respond(dto)
}
Expand All @@ -197,7 +195,7 @@ internal fun Route.aktivitetspliktRoutes(

val hendelser =
inTransaction {
aktivitetspliktService.slettHendelse(hendelseId, brukerTokenInfo, sakId = sakId)
aktivitetspliktService.slettHendelse(hendelseId, sakId = sakId)
aktivitetspliktService.hentHendelser(sakId = sakId)
}

Expand Down Expand Up @@ -369,7 +367,6 @@ internal fun Route.aktivitetspliktRoutes(
oppgaveId = oppgaveId,
aktivitetsgradId = aktivitetsgradId,
sakId = sakId,
brukerTokenInfo = brukerTokenInfo,
)
}
call.respond(vurdering)
Expand Down Expand Up @@ -421,7 +418,6 @@ internal fun Route.aktivitetspliktRoutes(
oppgaveId = oppgaveId,
sakId = sakId,
unntakId = unntakId,
brukerTokenInfo = brukerTokenInfo,
)
}
call.respond(vurdering)
Expand Down Expand Up @@ -481,7 +477,6 @@ internal fun Route.aktivitetspliktRoutes(
behandlingId = behandlingId,
aktivitetsgradId = aktivitetsgradId,
sakId = sakId,
brukerTokenInfo = brukerTokenInfo,
)
}
call.respond(vurdering)
Expand Down Expand Up @@ -514,7 +509,6 @@ internal fun Route.aktivitetspliktRoutes(
behandlingId = behandlingId,
sakId = sakId,
unntakId = unntakId,
brukerTokenInfo = brukerTokenInfo,
)
}
call.respond(vurdering)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package no.nav.etterlatte.behandling.aktivitetsplikt

import kotlinx.coroutines.runBlocking
import no.nav.etterlatte.behandling.BehandlingHendelserKafkaProducer
import no.nav.etterlatte.behandling.BehandlingService
import no.nav.etterlatte.behandling.aktivitetsplikt.vurdering.AktivitetspliktAktivitetsgrad
Expand Down Expand Up @@ -72,7 +71,7 @@ class AktivitetspliktService(
fun hentAktivitetspliktOppfolging(behandlingId: UUID): AktivitetspliktOppfolging? =
aktivitetspliktDao.finnSenesteAktivitetspliktOppfolging(behandlingId)

suspend fun hentAktivitetspliktDto(
fun hentAktivitetspliktDto(
sakId: SakId,
behandlingId: UUID?,
): AktivitetspliktDto {
Expand Down Expand Up @@ -270,7 +269,7 @@ class AktivitetspliktService(
} else {
aktivitetspliktDao.opprettAktivitetForBehandling(behandlingId, aktivitet, kilde)
}
runBlocking { sendDtoTilStatistikk(aktivitet.sakId, brukerTokenInfo, behandlingId) }
sendDtoTilStatistikk(aktivitet.sakId, behandlingId)
} else if (sakId != null) {
if (aktivitet.sakId != sakId) {
throw SakidTilhoererIkkeBehandlingException()
Expand All @@ -288,14 +287,13 @@ class AktivitetspliktService(

fun slettAktivitet(
aktivitetId: UUID,
brukerTokenInfo: BrukerTokenInfo,
behandlingId: UUID? = null,
sakId: SakId? = null,
) {
if (behandlingId != null) {
val behandling = hentBehandlingOgSjekkOmRedigerbar(behandlingId)
aktivitetspliktDao.slettAktivitetForBehandling(aktivitetId, behandlingId)
runBlocking { sendDtoTilStatistikk(behandling.sak.id, brukerTokenInfo, behandlingId) }
sendDtoTilStatistikk(behandling.sak.id, behandlingId)
} else if (sakId != null) {
aktivitetspliktDao.slettAktivitetForSak(aktivitetId, sakId)
} else {
Expand Down Expand Up @@ -336,7 +334,7 @@ class AktivitetspliktService(
}
aktivitetspliktDao.upsertHendelse(behandlingId, hendelse, kilde)

runBlocking { sendDtoTilStatistikk(hendelse.sakId, brukerTokenInfo, behandlingId) }
sendDtoTilStatistikk(hendelse.sakId, behandlingId)
} else if (sakId != null) {
if (hendelse.sakId != sakId) {
throw SakidTilhoererIkkeBehandlingException()
Expand All @@ -349,7 +347,6 @@ class AktivitetspliktService(

fun slettHendelse(
hendelseId: UUID,
brukerTokenInfo: BrukerTokenInfo,
sakId: SakId,
) {
val hendelseForSak =
Expand All @@ -365,7 +362,7 @@ class AktivitetspliktService(
throw BehandlingKanIkkeEndres()
}
aktivitetspliktDao.slettHendelse(hendelseId)
runBlocking { sendDtoTilStatistikk(behandling.sak.id, brukerTokenInfo, hendelseForSak.behandlingId) }
sendDtoTilStatistikk(behandling.sak.id, hendelseForSak.behandlingId)
} else {
aktivitetspliktDao.slettHendelse(hendelseId)
}
Expand All @@ -387,8 +384,7 @@ class AktivitetspliktService(
kilde,
oppgaveId = oppgaveId,
)

runBlocking { sendDtoTilStatistikk(sakId, brukerTokenInfo, null) }
sendDtoTilStatistikk(sakId)

val vurdering = hentVurderingForOppgave(oppgaveId)
if (vurdering.erTom()) {
Expand Down Expand Up @@ -438,7 +434,7 @@ class AktivitetspliktService(
oppgaveId = oppgaveId,
)

runBlocking { sendDtoTilStatistikk(sakId, brukerTokenInfo) }
sendDtoTilStatistikk(sakId)
return hentVurderingForOppgave(oppgaveId)
}

Expand Down Expand Up @@ -475,7 +471,7 @@ class AktivitetspliktService(
behandlingId = behandlingId,
)

runBlocking { sendDtoTilStatistikk(sakId, brukerTokenInfo, behandlingId) }
sendDtoTilStatistikk(sakId, behandlingId)
val unntak = aktivitetspliktUnntakDao.hentUnntakForBehandling(behandlingId)
val aktivitet = aktivitetspliktAktivitetsgradDao.hentAktivitetsgradForBehandling(behandlingId)

Expand All @@ -496,12 +492,9 @@ class AktivitetspliktService(

val kilde = Grunnlagsopplysning.Saksbehandler.create(brukerTokenInfo.ident())
aktivitetspliktUnntakDao.upsertUnntak(unntak, sakId, kilde, oppgaveId = oppgaveId)
runBlocking {
sendDtoTilStatistikk(
sakId = sakId,
brukerTokenInfo = brukerTokenInfo,
)
}
sendDtoTilStatistikk(
sakId = sakId,
)

return hentVurderingForOppgave(oppgaveId)
}
Expand All @@ -510,27 +503,25 @@ class AktivitetspliktService(
oppgaveId: UUID,
aktivitetsgradId: UUID,
sakId: SakId,
brukerTokenInfo: BrukerTokenInfo,
): AktivitetspliktVurdering {
val oppgave = oppgaveService.hentOppgave(oppgaveId)
sjekkOppgaveTilhoererSakOgErRedigerbar(oppgave, sakId)

aktivitetspliktAktivitetsgradDao.slettAktivitetsgradForOppgave(aktivitetsgradId, oppgaveId)

runBlocking { sendDtoTilStatistikk(sakId, brukerTokenInfo) }
sendDtoTilStatistikk(sakId)
return hentVurderingForOppgave(oppgaveId)
}

fun slettUnntakForOppgave(
oppgaveId: UUID,
unntakId: UUID,
sakId: SakId,
brukerTokenInfo: BrukerTokenInfo,
): AktivitetspliktVurdering {
val oppgave = oppgaveService.hentOppgave(oppgaveId)
sjekkOppgaveTilhoererSakOgErRedigerbar(oppgave, sakId)

runBlocking { sendDtoTilStatistikk(sakId, brukerTokenInfo, null) }
sendDtoTilStatistikk(sakId)
aktivitetspliktUnntakDao.slettUnntakForOppgave(oppgaveId, unntakId)
return hentVurderingForOppgave(oppgaveId)
}
Expand Down Expand Up @@ -565,7 +556,7 @@ class AktivitetspliktService(
behandlingId = behandlingId,
)

runBlocking { sendDtoTilStatistikk(sakId, brukerTokenInfo, behandlingId = behandlingId) }
sendDtoTilStatistikk(sakId, behandlingId = behandlingId)

return hentVurderingForBehandlingNy(behandlingId)
}
Expand All @@ -574,24 +565,22 @@ class AktivitetspliktService(
behandlingId: UUID,
aktivitetsgradId: UUID,
sakId: SakId,
brukerTokenInfo: BrukerTokenInfo,
): AktivitetspliktVurdering {
hentBehandlingOgSjekkOmRedigerbar(behandlingId)
aktivitetspliktAktivitetsgradDao.slettAktivitetsgradForBehandling(aktivitetsgradId, behandlingId)

runBlocking { sendDtoTilStatistikk(sakId, brukerTokenInfo, behandlingId = behandlingId) }
sendDtoTilStatistikk(sakId, behandlingId = behandlingId)
return hentVurderingForBehandlingNy(behandlingId)
}

fun slettUnntakForBehandling(
behandlingId: UUID,
unntakId: UUID,
sakId: SakId,
brukerTokenInfo: BrukerTokenInfo,
): AktivitetspliktVurdering {
hentBehandlingOgSjekkOmRedigerbar(behandlingId)

runBlocking { sendDtoTilStatistikk(sakId, brukerTokenInfo, behandlingId = behandlingId) }
sendDtoTilStatistikk(sakId, behandlingId = behandlingId)
aktivitetspliktUnntakDao.slettUnntakForBehandling(unntakId = unntakId, behandlingId = behandlingId)
return hentVurderingForBehandlingNy(behandlingId)
}
Expand All @@ -609,12 +598,9 @@ class AktivitetspliktService(

val kilde = Grunnlagsopplysning.Saksbehandler.create(brukerTokenInfo.ident())
aktivitetspliktUnntakDao.upsertUnntak(unntak, sakId, kilde, behandlingId = behandlingId)
runBlocking {
sendDtoTilStatistikk(
sakId = sakId,
brukerTokenInfo = brukerTokenInfo,
)
}
sendDtoTilStatistikk(
sakId = sakId,
)

return hentVurderingForBehandlingNy(behandlingId)
}
Expand Down Expand Up @@ -664,12 +650,10 @@ class AktivitetspliktService(
"Fant ikke forrige behandling i sak ${request.sakId}sakId"
}
val persongalleri =
runBlocking {
krevIkkeNull(
grunnlagService.hentPersongalleri(forrigeBehandling.id),
) {
"Fant ikke persongalleri for behandling ${forrigeBehandling.id}"
}
krevIkkeNull(
grunnlagService.hentPersongalleri(forrigeBehandling.id),
) {
"Fant ikke persongalleri for behandling ${forrigeBehandling.id}"
}

val aktivitetspliktDato = request.behandlingsmaaned.atDay(1).plusMonths(1)
Expand Down Expand Up @@ -779,9 +763,8 @@ class AktivitetspliktService(
}
}

private suspend fun sendDtoTilStatistikk(
private fun sendDtoTilStatistikk(
sakId: SakId,
brukerTokenInfo: BrukerTokenInfo,
behandlingId: UUID? = null,
) {
try {
Expand Down
Loading

0 comments on commit ed84c17

Please sign in to comment.