-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Omskriving til bruk av BehandlingshistorikkRequest
- Loading branch information
Showing
14 changed files
with
233 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
api-kontrakt/src/main/kotlin/no/nav/aap/oppgave/AvsluttOppgaveDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
package no.nav.aap.oppgave | ||
|
||
import no.nav.aap.oppgave.verdityper.AvklaringsbehovType | ||
import no.nav.aap.oppgave.verdityper.AvklaringsbehovKode | ||
import java.util.UUID | ||
|
||
data class AvsluttOppgaveDto( | ||
val saksnummer: String? = null, | ||
val behandlingRef: UUID? = null, | ||
val journalpostId: Long? = null, | ||
val avklaringsbehovType: AvklaringsbehovType, | ||
val avklaringsbehovKode: AvklaringsbehovKode, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
api-kontrakt/src/main/kotlin/no/nav/aap/oppgave/filter/FilterDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package no.nav.aap.oppgave.filter | ||
|
||
import no.nav.aap.oppgave.verdityper.AvklaringsbehovType | ||
import no.nav.aap.oppgave.verdityper.AvklaringsbehovKode | ||
|
||
data class FilterDto( | ||
val id: Long, | ||
val navn: String, | ||
val avklaringsbehovKoder: Set<AvklaringsbehovType> = emptySet() | ||
val avklaringsbehovKoder: Set<AvklaringsbehovKode> = emptySet() | ||
) |
94 changes: 94 additions & 0 deletions
94
api-kontrakt/src/main/kotlin/no/nav/aap/oppgave/opprett/BehandlingshistorikkRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package no.nav.aap.oppgave.opprett | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore | ||
import java.time.LocalDateTime | ||
|
||
//TODO skal ligge behandlingsflyt.api-kontrakt, fjernes når det er klart | ||
data class BehandlingshistorikkRequest( | ||
val personident: String, | ||
val saksnummer: String, | ||
val referanse: String, | ||
val behandlingType: Behandlingstype, | ||
val status: Behandlingstatus, | ||
val opprettetTidspunkt: LocalDateTime, | ||
val avklaringsbehov: List<AvklaringsbehovDto>, | ||
) { | ||
fun erLukket() = | ||
(status == Behandlingstatus.AVSLUTTET) || | ||
avklaringsbehov.all { it.status == Avklaringsbehovstatus.AVSLUTTET } | ||
|
||
@JsonIgnore | ||
fun getÅpentAvklaringsbehov() = avklaringsbehov.firstOrNull { | ||
it.status in setOf( | ||
Avklaringsbehovstatus.OPPRETTET, | ||
Avklaringsbehovstatus.SENDT_TILBAKE_FRA_BESLUTTER, | ||
Avklaringsbehovstatus.SENDT_TILBAKE_FRA_KVALITETSSIKRER | ||
) | ||
} | ||
} | ||
|
||
enum class Behandlingstype { | ||
Førstegangsbehandling, | ||
Revurdering, | ||
Tilbakekreving, | ||
Klage | ||
} | ||
|
||
enum class Behandlingstatus { | ||
OPPRETTET, | ||
UTREDES, | ||
AVSLUTTET, | ||
PÅ_VENT | ||
} | ||
|
||
enum class Avklaringsbehovstatus { | ||
OPPRETTET, | ||
AVSLUTTET, | ||
KVALITETSSIKRET, | ||
SENDT_TILBAKE_FRA_KVALITETSSIKRER, | ||
TOTRINNS_VURDERT, | ||
SENDT_TILBAKE_FRA_BESLUTTER, | ||
AVBRUTT | ||
} | ||
|
||
enum class Avklaringsbehovtype(val kode: String) { | ||
MANUELT_SATT_PÅ_VENT("9001"), | ||
AVKLAR_STUDENT("5001"), | ||
AVKLAR_SYKDOM("5003"), | ||
FASTSETT_ARBEIDSEVNE("5004"), | ||
FRITAK_MELDEPLIKT("5005"), | ||
AVKLAR_BISTANDSBEHOV("5006"), | ||
VURDER_SYKEPENGEERSTATNING("5007"), | ||
FASTSETT_BEREGNINGSTIDSPUNKT("5008"), | ||
AVKLAR_BARN("5009"), | ||
AVKLAR_SONINGSFORRHOLD("5010"), | ||
AVKLAR_HELSEINSTITUSJON("5011"), | ||
KVALITETSSIKRING("5097"), | ||
FORESLÅ_VEDTAK("5098"), | ||
FATTE_VEDTAK("5099"); | ||
|
||
companion object { | ||
private val map = entries.associateBy(Avklaringsbehovtype::kode) | ||
fun fraKode(kode: String) = | ||
map[kode] ?: throw IllegalArgumentException("Finner ikke Avklaringsbehovtype for kode: $kode") | ||
} | ||
} | ||
|
||
data class AvklaringsbehovDto( | ||
val definisjon: Definisjon, | ||
val status: Avklaringsbehovstatus, | ||
val endringer: List<AvklaringsbehovhendelseEndring> | ||
) { | ||
fun getOpprettelsestidspunkt() = endringer.find { it.status == Avklaringsbehovstatus.OPPRETTET }?.tidsstempel | ||
?: throw IllegalArgumentException("Avklaringsbehov mangler ") | ||
} | ||
|
||
data class Definisjon( | ||
val type: String | ||
) | ||
|
||
data class AvklaringsbehovhendelseEndring( | ||
val status: Avklaringsbehovstatus, | ||
val tidsstempel: LocalDateTime, | ||
val endretAv: String | ||
) |
13 changes: 0 additions & 13 deletions
13
api-kontrakt/src/main/kotlin/no/nav/aap/oppgave/opprett/OpprettOppgaveDto.kt
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...oppgave/verdityper/AvklaringsbehovType.kt → ...oppgave/verdityper/AvklaringsbehovKode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package no.nav.aap.oppgave.verdityper | ||
|
||
@JvmInline | ||
value class AvklaringsbehovType(val kode: String) | ||
value class AvklaringsbehovKode(val kode: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
app/src/main/kotlin/no/nav/aap/oppgave/filter/FilterRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
app/src/main/kotlin/no/nav/aap/oppgave/opprette/BehandlingshistorikkTilOppgaveConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package no.nav.aap.oppgave.opprette | ||
|
||
import no.nav.aap.oppgave.OppgaveDto | ||
import no.nav.aap.oppgave.opprett.AvklaringsbehovDto | ||
import no.nav.aap.oppgave.opprett.Avklaringsbehovstatus | ||
import no.nav.aap.oppgave.opprett.BehandlingshistorikkRequest | ||
import no.nav.aap.oppgave.verdityper.AvklaringsbehovKode | ||
import java.time.LocalDateTime | ||
import java.util.UUID | ||
|
||
object BehandlingshistorikkTilOppgaveConverter { | ||
|
||
fun lagOppgave(behandlingshistorikk: BehandlingshistorikkRequest, ident: String): OppgaveDto? { | ||
val åpentAvklaringsbehov = behandlingshistorikk.getÅpentAvklaringsbehov() | ||
if (åpentAvklaringsbehov == null) { | ||
return null | ||
} | ||
return when (åpentAvklaringsbehov.status) { | ||
Avklaringsbehovstatus.OPPRETTET -> | ||
opprettNyOppgave(behandlingshistorikk, åpentAvklaringsbehov, ident) | ||
Avklaringsbehovstatus.SENDT_TILBAKE_FRA_KVALITETSSIKRER, Avklaringsbehovstatus.SENDT_TILBAKE_FRA_BESLUTTER -> | ||
gjenopprettOppgave(behandlingshistorikk, åpentAvklaringsbehov, ident) | ||
else -> return null | ||
} | ||
} | ||
|
||
private fun opprettNyOppgave(behandlingshistorikkRequest: BehandlingshistorikkRequest, | ||
avklaringsbehov: AvklaringsbehovDto, | ||
ident: String | ||
): OppgaveDto { | ||
return OppgaveDto( | ||
saksnummer = behandlingshistorikkRequest.saksnummer, | ||
behandlingRef = UUID.fromString(behandlingshistorikkRequest.referanse), | ||
behandlingOpprettet = behandlingshistorikkRequest.opprettetTidspunkt, | ||
avklaringsbehovKode = AvklaringsbehovKode(avklaringsbehov.definisjon.type), | ||
opprettetAv = ident, | ||
opprettetTidspunkt = LocalDateTime.now() | ||
) | ||
} | ||
|
||
private fun gjenopprettOppgave(behandlingshistorikkRequest: BehandlingshistorikkRequest, | ||
avklaringsbehov: AvklaringsbehovDto, | ||
ident: String | ||
): OppgaveDto? { | ||
val oppgaveDto = opprettNyOppgave(behandlingshistorikkRequest, avklaringsbehov, ident) | ||
val sistEndretAv = avklaringsbehov.sistEndretAv() | ||
oppgaveDto.copy(reservertAv = sistEndretAv, reservertTidspunkt = LocalDateTime.now()) | ||
return oppgaveDto | ||
} | ||
|
||
private fun AvklaringsbehovDto.sistEndretAv(): String? { | ||
return endringer | ||
.sortedByDescending { it.tidsstempel } | ||
.filter { it.status == this.status } | ||
.map { it.endretAv } | ||
.firstOrNull() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.