Skip to content

Commit

Permalink
Noen punkter for statistikk
Browse files Browse the repository at this point in the history
  • Loading branch information
JulieHillRoa committed Feb 10, 2025
1 parent f6d58f5 commit b3ea7c5
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum class BehandlingType {
enum class BehandlingStatus {
UNDER_BEHANDLING,
SENDT_TIL_KVALITETSSIKRING,
SENDT_TIL_VEILEDER,// ???
FATTET,
AVBRUTT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public class BeslutterService {

private final MetricsService metricsService;

private final SakStatistikkService sakStatistikkService;

public void startBeslutterProsess(long vedtakId) {
Vedtak utkast = vedtaksstotteRepository.hentUtkastEllerFeil(vedtakId);
authService.sjekkTilgangTilBrukerOgEnhet(AktorId.of(utkast.getAktorId()));
Expand All @@ -63,6 +65,7 @@ public void startBeslutterProsess(long vedtakId) {
vedtaksstotteRepository.setBeslutterProsessStatus(utkast.getId(), BeslutterProsessStatus.KLAR_TIL_BESLUTTER);
vedtakStatusEndringService.beslutterProsessStartet(utkast);
meldingRepository.opprettSystemMelding(utkast.getId(), SystemMeldingType.BESLUTTER_PROSESS_STARTET, utkast.getVeilederIdent());
sakStatistikkService.startetKvalitetssikring(utkast);
}

public void avbrytBeslutterProsess(long vedtakId) {
Expand Down Expand Up @@ -111,6 +114,8 @@ public void bliBeslutter(long vedtakId) {
vedtakStatusEndringService.tattOverForBeslutter(utkast, innloggetVeilederIdent);
meldingRepository.opprettSystemMelding(utkast.getId(), SystemMeldingType.TATT_OVER_SOM_BESLUTTER, innloggetVeilederIdent);
}

sakStatistikkService.bliEllerTaOverSomKvalitetssikrer(utkast, innloggetVeilederIdent);
}

public void setGodkjentAvBeslutter(long vedtakId) {
Expand All @@ -132,6 +137,7 @@ public void setGodkjentAvBeslutter(long vedtakId) {
vedtakStatusEndringService.godkjentAvBeslutter(utkast);
meldingRepository.opprettSystemMelding(utkast.getId(), SystemMeldingType.BESLUTTER_HAR_GODKJENT, innloggetVeilederIdent);
metricsService.rapporterTidMellomUtkastOpprettetTilGodkjent(utkast);
//TODO her bør det nok også være en rad eller?
}

public void oppdaterBeslutterProsessStatus(long vedtakId) {
Expand All @@ -154,7 +160,7 @@ public void oppdaterBeslutterProsessStatus(long vedtakId) {
}

vedtaksstotteRepository.setBeslutterProsessStatus(utkast.getId(), nyStatus);

// TODO her må vi gjøre noe med tanke på rad i sakstatistikk
if (nyStatus == BeslutterProsessStatus.KLAR_TIL_BESLUTTER) {
beslutteroversiktRepository.oppdaterStatus(utkast.getId(), BeslutteroversiktStatus.KLAR_TIL_BESLUTTER);
meldingRepository.opprettSystemMelding(vedtakId, SystemMeldingType.SENDT_TIL_BESLUTTER, innloggetVeilederIdent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,70 @@ class SakStatistikkService @Autowired constructor(
}
}

fun startetKvalitetssikring (vedtak: Vedtak) {// TODO gidder ikke tracke her alikevle
/*val statistikkPaa = unleashClient.isEnabled(SAK_STATISTIKK_PAA)
if (statistikkPaa) {
val aktorId = AktorId(vedtak.aktorId)
val fnr = aktorOppslagClient.hentFnr(aktorId)
val statistikkRad = SakStatistikk(
behandlingStatus = BehandlingStatus.SENDT_TIL_KVALITETSSIKRING,
behandlingMetode = BehandlingMetode.TOTRINNS,
)
val populertMedStatiskeData = populerSakstatistikkMedStatiskeData(statistikkRad)
val populertMedVedtaksdata = populerSakstatistikkMedVedtakData(populertMedStatiskeData, vedtak)
val ferdigpopulertStatistikkRad = populerSakStatistikkMedOppfolgingsperiodeData(populertMedVedtaksdata, fnr)
try {
ferdigpopulertStatistikkRad.validate()
sakStatistikkRepository.insertSakStatistikkRad(ferdigpopulertStatistikkRad)
bigQueryService.logEvent(ferdigpopulertStatistikkRad)
} catch (e: Exception) {
secureLog.error("Kunne ikke lagre startetKvalitetssikring - sakstatistikk", e)
}
}*/
}

fun bliEllerTaOverSomKvalitetssikrer(vedtak: Vedtak, innloggetVeileder: String) {
val statistikkPaa = unleashClient.isEnabled(SAK_STATISTIKK_PAA)
if (statistikkPaa) {
val aktorId = AktorId(vedtak.aktorId)
val fnr = aktorOppslagClient.hentFnr(aktorId)

val statistikkRad = SakStatistikk(
behandlingStatus = BehandlingStatus.SENDT_TIL_KVALITETSSIKRING,
behandlingMetode = BehandlingMetode.TOTRINNS,
ansvarligBeslutter = innloggetVeileder,
)
val populertMedStatiskeData = populerSakstatistikkMedStatiskeData(statistikkRad)
val populertMedVedtaksdata = populerSakstatistikkMedVedtakData(populertMedStatiskeData, vedtak)
val ferdigpopulertStatistikkRad = populerSakStatistikkMedOppfolgingsperiodeData(populertMedVedtaksdata, fnr)

try {
ferdigpopulertStatistikkRad.validate()
sakStatistikkRepository.insertSakStatistikkRad(ferdigpopulertStatistikkRad)
bigQueryService.logEvent(ferdigpopulertStatistikkRad)
} catch (e: Exception) {
secureLog.error("Kunne ikke lagre startetKvalitetssikring - sakstatistikk", e)
}
}
}

fun sendTilbakeSomVeileder(vedtak: Vedtak, innloggetVeileder: String) {
//Skal noe skje her? (vi ha ene klar for veilederknapp dersom man øsnker det
}

fun godkjentKvalitetssiikring(vedtak: Vedtak, innloggetVeileder: String) {
//Skal noe skje her? egenglig ingenting å oppdatere her?
// kunne vært en behandlingsstatus, burde vi kjøre på med en til? eller skal vi bare la vær å ha det som en rad?
}

fun overtattUtkast(vedtak: Vedtak, innloggetVeilederIdent: String, erAlleredeBeslutter: Boolean) {
//Hva endres her? er det kunn saksbehandler som endres her? enhet?
//denne må sjekkes både forovertaknappen, men også bare ved kontorbytte
}


private fun populerSakstatistikkMedStatiskeData(sakStatistikk: SakStatistikk): SakStatistikk {
return sakStatistikk.copy(
endretTid = Instant.now(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ public void taOverUtkast(long vedtakId) {
vedtaksstotteRepository.oppdaterUtkastVeileder(utkast.getId(), innloggetVeilederIdent);
beslutteroversiktRepository.oppdaterVeileder(utkast.getId(), veileder.getNavn());
meldingRepository.opprettSystemMelding(utkast.getId(), SystemMeldingType.TATT_OVER_SOM_VEILEDER, innloggetVeilederIdent);
sakStatistikkService.overtattUtkast(utkast, innloggetVeilederIdent, erAlleredeBeslutter);
});

vedtakStatusEndringService.tattOverForVeileder(utkast, innloggetVeilederIdent);
Expand Down

0 comments on commit b3ea7c5

Please sign in to comment.