Skip to content

Commit

Permalink
IS-2621: Add stansdato to stans vurdering
Browse files Browse the repository at this point in the history
  • Loading branch information
vetlesolgaard committed Oct 3, 2024
1 parent 55b9888 commit f63423a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/no/nav/syfo/api/model/VurderingResponseDTO.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ data class VurderingResponseDTO private constructor(
val vurderingType: VurderingType,
val veilederident: String,
val begrunnelse: String,
val stansdato: LocalDate?,
val document: List<DocumentComponent>,
val varsel: VarselDTO?,
) {
Expand All @@ -24,6 +25,7 @@ data class VurderingResponseDTO private constructor(
vurderingType = vurdering.vurderingType,
veilederident = vurdering.veilederident.value,
begrunnelse = vurdering.begrunnelse,
stansdato = if (vurdering is Vurdering.Stans) vurdering.stansdato else null,
document = vurdering.document,
varsel = if (vurdering is Vurdering.Forhandsvarsel) VarselDTO.fromVarsel(vurdering.varsel) else null,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class VurderingService(
personident = Personident(newVurdering.personident),
veilederident = veilederident,
begrunnelse = newVurdering.begrunnelse,
stansdato = newVurdering.stansdato,
document = newVurdering.document,
)
is NewVurderingRequestDTO.IkkeAktuell ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sealed class NewVurderingRequestDTO {
override val personident: String,
override val begrunnelse: String,
override val document: List<DocumentComponent>,
val stansdato: LocalDate,
) : NewVurderingRequestDTO()

@JsonTypeName("IKKE_AKTUELL")
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/no/nav/syfo/domain/Vurdering.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ sealed class Vurdering(val vurderingType: VurderingType) : IVurdering {
override val begrunnelse: String,
override val document: List<DocumentComponent>,
override val journalpostId: JournalpostId?,
val stansdato: LocalDate,
) : Vurdering(VurderingType.STANS)

data class IkkeAktuell(
Expand Down Expand Up @@ -132,13 +133,15 @@ sealed class Vurdering(val vurderingType: VurderingType) : IVurdering {
personident: Personident,
veilederident: Veilederident,
begrunnelse: String,
stansdato: LocalDate,
document: List<DocumentComponent>,
) = Stans(
uuid = UUID.randomUUID(),
personident = personident,
veilederident = veilederident,
createdAt = OffsetDateTime.now(),
begrunnelse = begrunnelse,
stansdato = stansdato,
document = document,
journalpostId = null,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import no.nav.syfo.domain.Personident
import no.nav.syfo.domain.Veilederident
import no.nav.syfo.domain.Vurdering
import no.nav.syfo.domain.VurderingType
import java.time.LocalDate
import java.time.OffsetDateTime
import java.util.UUID

Expand All @@ -18,6 +19,7 @@ data class PVurdering(
val veilederident: Veilederident,
val type: VurderingType,
val begrunnelse: String,
val stansdato: LocalDate?,
val document: List<DocumentComponent>,
val journalpostId: JournalpostId?,
val publishedAt: OffsetDateTime?,
Expand Down Expand Up @@ -50,6 +52,7 @@ data class PVurdering(
veilederident = veilederident,
createdAt = createdAt,
begrunnelse = begrunnelse,
stansdato = stansdato!!,
document = document,
journalpostId = journalpostId,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ class VurderingRepository(private val database: DatabaseInterface) : IVurderingR
it.setObject(8, mapper.writeValueAsString(vurdering.document))
it.setNull(9, Types.VARCHAR)
it.setNull(10, Types.TIMESTAMP_WITH_TIMEZONE)
when (vurdering) {
is Vurdering.Stans -> it.setDate(11, Date.valueOf(vurdering.stansdato))
else -> it.setNull(11, Types.DATE)
}
it.executeQuery().toList { toPVurdering() }.firstOrNull()
}
if (pVurdering == null) {
Expand Down Expand Up @@ -196,8 +200,9 @@ class VurderingRepository(private val database: DatabaseInterface) : IVurderingR
begrunnelse,
document,
journalpost_id,
published_at
) values (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?::jsonb, ?, ?)
published_at,
stansdato
) values (DEFAULT, ?, ?, ?, ?, ?, ?, ?, ?::jsonb, ?, ?, ?)
RETURNING *
"""

Expand Down Expand Up @@ -286,6 +291,7 @@ internal fun ResultSet.toPVurdering(): PVurdering =
veilederident = Veilederident(getString("veilederident")),
type = VurderingType.valueOf(getString("type")),
begrunnelse = getString("begrunnelse"),
stansdato = getDate("stansdato")?.toLocalDate(),
document = configuredJacksonMapper().readValue(
getString("document"),
object : TypeReference<List<DocumentComponent>>() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ object ManglendeMedvirkningEndpointsSpek : Spek({
val stansVurdering = NewVurderingRequestDTO.Stans(
personident = ARBEIDSTAKER_PERSONIDENT.value,
begrunnelse = "Fin begrunnelse",
stansdato = LocalDate.now().plusDays(5),
document = generateDocumentComponent(
fritekst = begrunnelse,
header = "Stans"
),
)
val json = objectMapper.writeValueAsString(stansVurdering)
with(
handleRequest(HttpMethod.Post, "$urlVurderinger/vurderinger") {
addHeader(HttpHeaders.ContentType, ContentType.Application.Json.toString())
Expand All @@ -119,6 +119,7 @@ object ManglendeMedvirkningEndpointsSpek : Spek({
responseDTO.personident shouldBeEqualTo stansVurdering.personident
responseDTO.vurderingType shouldBeEqualTo VurderingType.STANS
responseDTO.begrunnelse shouldBeEqualTo stansVurdering.begrunnelse
responseDTO.stansdato shouldBeEqualTo stansVurdering.stansdato
responseDTO.veilederident shouldBeEqualTo VEILEDER_IDENT.value
responseDTO.document shouldBeEqualTo stansVurdering.document
responseDTO.varsel?.svarfrist shouldBeEqualTo null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ fun generateVurdering(
personident = personident,
veilederident = UserConstants.VEILEDER_IDENT,
begrunnelse = begrunnelse,
stansdato = LocalDate.now().plusDays(5),
document = document,
journalpostId = null,
)
Expand Down

0 comments on commit f63423a

Please sign in to comment.