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

IS-2701-2: Refactor functions into more correctly layer #32

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -1,7 +1,5 @@
package no.nav.syfo.domain

import no.nav.syfo.infrastructure.clients.dokarkiv.dto.BrevkodeType
import no.nav.syfo.infrastructure.clients.dokarkiv.dto.JournalpostType
import java.time.LocalDate
import java.time.OffsetDateTime
import java.util.UUID
Expand Down Expand Up @@ -148,19 +146,6 @@ enum class VurderingType(val isActive: Boolean) {
STANS(false),
IKKE_AKTUELL(false),
UNNTAK(false);

fun brevkode(): BrevkodeType =
when (this) {
FORHANDSVARSEL -> BrevkodeType.MANGLENDE_MEDVIRKNING_FORHANDSVARSEL
OPPFYLT, IKKE_AKTUELL, UNNTAK -> BrevkodeType.MANGLENDE_MEDVIRKNING_VURDERING
STANS -> BrevkodeType.MANGLENDE_MEDVIRKNING_STANS
}

fun journalpostType(): JournalpostType =
when (this) {
FORHANDSVARSEL, OPPFYLT, IKKE_AKTUELL, UNNTAK -> JournalpostType.UTGAAENDE
STANS -> JournalpostType.NOTAT
}
}

data class Varsel(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
package no.nav.syfo.infrastructure.clients.dokarkiv.dto

import no.nav.syfo.domain.VurderingType

enum class BrevkodeType(
val value: String,
) {
MANGLENDE_MEDVIRKNING_FORHANDSVARSEL("OPPF_MANGLENDE_MEDVIRKNING_FORHANDSVARSEL"),
MANGLENDE_MEDVIRKNING_VURDERING("OPPF_MANGLENDE_MEDVIRKNING_VURDERING"),
MANGLENDE_MEDVIRKNING_STANS("OPPF_MANGLENDE_MEDVIRKNING_STANS"),
MANGLENDE_MEDVIRKNING_STANS("OPPF_MANGLENDE_MEDVIRKNING_STANS");

companion object {
fun fromVurderingType(vurderingType: VurderingType): BrevkodeType =
when (vurderingType) {
VurderingType.FORHANDSVARSEL -> MANGLENDE_MEDVIRKNING_FORHANDSVARSEL
VurderingType.OPPFYLT, VurderingType.IKKE_AKTUELL, VurderingType.UNNTAK -> MANGLENDE_MEDVIRKNING_VURDERING
VurderingType.STANS -> MANGLENDE_MEDVIRKNING_STANS
}
}
}

data class Dokument(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package no.nav.syfo.infrastructure.clients.dokarkiv.dto

import no.nav.syfo.domain.VurderingType

private const val JOURNALFORENDE_ENHET = 9999

enum class JournalpostType {
UTGAAENDE,
NOTAT,
NOTAT;

companion object {
fun fromVurderingType(vurderingType: VurderingType): JournalpostType =
when (vurderingType) {
VurderingType.FORHANDSVARSEL, VurderingType.OPPFYLT, VurderingType.IKKE_AKTUELL, VurderingType.UNNTAK -> UTGAAENDE
VurderingType.STANS -> NOTAT
}
}
}

enum class JournalpostTema(val value: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ class JournalforingService(
pdf: ByteArray,
vurdering: ManglendeMedvirkningVurdering,
): JournalpostRequest {
val avsenderMottaker = if (vurdering.vurderingType.journalpostType() != JournalpostType.NOTAT) {
val journalpostType = JournalpostType.fromVurderingType(vurdering.vurderingType)
val avsenderMottaker = if (journalpostType == JournalpostType.NOTAT) {
null
} else {
AvsenderMottaker(
id = personIdent.value,
idType = BrukerIdType.PERSON_IDENT.value,
navn = navn,
)
} else {
null
}
val bruker = Bruker(
id = personIdent.value,
Expand All @@ -50,7 +51,7 @@ class JournalforingService(

val dokumenter = listOf(
Dokument(
brevkode = vurdering.vurderingType.brevkode().value,
brevkode = BrevkodeType.fromVurderingType(vurdering.vurderingType).value,
dokumentvarianter = listOf(
Dokumentvariant(
filnavn = dokumentTittel,
Expand All @@ -64,7 +65,7 @@ class JournalforingService(
)

return JournalpostRequest(
journalpostType = vurdering.vurderingType.journalpostType().name,
journalpostType = JournalpostType.fromVurderingType(vurdering.vurderingType).name,
avsenderMottaker = avsenderMottaker,
tittel = dokumentTittel,
bruker = bruker,
Expand Down