Skip to content

Commit ce8f25b

Browse files
committed
Return legacy motebehov DTOs from V3 controllers
1 parent 782da57 commit ce8f25b

File tree

6 files changed

+67
-8
lines changed

6 files changed

+67
-8
lines changed

src/main/kotlin/no/nav/syfo/motebehov/Motebehov.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ data class Motebehov(
2626
val skjemaType: MotebehovSkjemaType? = null,
2727
) : Serializable
2828

29+
data class MotebehovWithLegacyMotebehovSvarOutputDTO(
30+
val id: UUID,
31+
val opprettetDato: LocalDateTime,
32+
val aktorId: String,
33+
val opprettetAv: String,
34+
val opprettetAvFnr: String,
35+
val arbeidstakerFnr: String,
36+
val virksomhetsnummer: String,
37+
val tildeltEnhet: String? = null,
38+
val behandletTidspunkt: LocalDateTime? = null,
39+
val behandletVeilederIdent: String? = null,
40+
val skjemaType: MotebehovSkjemaType? = null, // make not nullable
41+
val motebehovSvar: MotebehovSvarLegacyDTO,
42+
)
43+
2944
data class MotebehovWithFormValuesOutputDTO(
3045
val id: UUID,
3146
val opprettetDato: LocalDateTime,
@@ -130,3 +145,19 @@ fun Motebehov.toMotebehovWithFormValuesOutputDTO(): MotebehovWithFormValuesOutpu
130145
skjemaType = this.skjemaType,
131146
formValues = this.formSubmission.toMotebehovFormValuesOutputDTO(),
132147
)
148+
149+
fun Motebehov.toMotebehovWithLegacyMotebehovSvarOutputDTO(): MotebehovWithLegacyMotebehovSvarOutputDTO =
150+
MotebehovWithLegacyMotebehovSvarOutputDTO(
151+
id = this.id,
152+
opprettetDato = this.opprettetDato,
153+
aktorId = this.aktorId,
154+
opprettetAv = this.opprettetAv,
155+
opprettetAvFnr = this.opprettetAvFnr,
156+
arbeidstakerFnr = this.arbeidstakerFnr,
157+
virksomhetsnummer = this.virksomhetsnummer,
158+
tildeltEnhet = this.tildeltEnhet,
159+
behandletTidspunkt = this.behandletTidspunkt,
160+
behandletVeilederIdent = this.behandletVeilederIdent,
161+
skjemaType = this.skjemaType,
162+
motebehovSvar = this.formSubmission.toMotebehovSvarLegacyDTO()
163+
)

src/main/kotlin/no/nav/syfo/motebehov/MotebehovFormValuesDTOs.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,10 @@ fun MotebehovFormSubmissionCombinedDTO.toMotebehovFormValuesOutputDTO(): Motebeh
8080
tolkSprak = valuesFromFormSnapshot?.tolkSprak,
8181
)
8282
}
83+
84+
fun MotebehovFormSubmissionCombinedDTO.toMotebehovSvarLegacyDTO(): MotebehovSvarLegacyDTO {
85+
return MotebehovSvarLegacyDTO(
86+
harMotebehov = this.harMotebehov,
87+
forklaring = this.forklaring,
88+
)
89+
}

src/main/kotlin/no/nav/syfo/motebehov/api/MotebehovArbeidsgiverControllerV3.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import no.nav.syfo.motebehov.MotebehovFormSubmissionCombinedDTO
1111
import no.nav.syfo.motebehov.MotebehovOppfolgingstilfelleServiceV2
1212
import no.nav.syfo.motebehov.NyttMotebehovArbeidsgiverDTO
1313
import no.nav.syfo.motebehov.NyttMotebehovArbeidsgiverLegacyDTO
14-
import no.nav.syfo.motebehov.motebehovstatus.MotebehovStatus
1514
import no.nav.syfo.motebehov.motebehovstatus.MotebehovStatusServiceV2
15+
import no.nav.syfo.motebehov.motebehovstatus.MotebehovStatusWithLegacyMotebehovDTO
16+
import no.nav.syfo.motebehov.motebehovstatus.toMotebehovStatusWithLegacyMotebehovDTO
1617
import org.springframework.beans.factory.annotation.Value
1718
import org.springframework.http.MediaType
1819
import org.springframework.web.bind.annotation.*
@@ -43,7 +44,7 @@ class MotebehovArbeidsgiverControllerV3 @Inject constructor(
4344
fun motebehovStatusArbeidsgiver(
4445
@RequestParam(name = "fnr") arbeidstakerFnr: @Pattern(regexp = "^[0-9]{11}$") String,
4546
@RequestParam(name = "virksomhetsnummer") virksomhetsnummer: String,
46-
): MotebehovStatus {
47+
): MotebehovStatusWithLegacyMotebehovDTO {
4748
metric.tellEndepunktKall("call_endpoint_motebehovstatus_arbeidsgiver")
4849
TokenXUtil.validateTokenXClaims(contextHolder, dialogmoteClientId)
4950
brukertilgangService.kastExceptionHvisIkkeTilgangTilAnsatt(arbeidstakerFnr)
@@ -52,6 +53,7 @@ class MotebehovArbeidsgiverControllerV3 @Inject constructor(
5253
val isOwnLeader = arbeidsgiverFnr == arbeidstakerFnr
5354

5455
return motebehovStatusServiceV2.motebehovStatusForArbeidsgiver(arbeidstakerFnr, isOwnLeader, virksomhetsnummer)
56+
.toMotebehovStatusWithLegacyMotebehovDTO()
5557
}
5658

5759
// Currently used POST-endpoint to phase out

src/main/kotlin/no/nav/syfo/motebehov/api/MotebehovArbeidstakerControllerV3.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import no.nav.syfo.motebehov.MotebehovOppfolgingstilfelleServiceV2
1111
import no.nav.syfo.motebehov.MotebehovSvarLegacyDTO
1212
import no.nav.syfo.motebehov.motebehovstatus.MotebehovStatus
1313
import no.nav.syfo.motebehov.motebehovstatus.MotebehovStatusServiceV2
14+
import no.nav.syfo.motebehov.motebehovstatus.MotebehovStatusWithLegacyMotebehovDTO
15+
import no.nav.syfo.motebehov.motebehovstatus.toMotebehovStatusWithLegacyMotebehovDTO
1416
import org.springframework.beans.factory.annotation.Value
1517
import org.springframework.http.MediaType
1618
import org.springframework.web.bind.annotation.*
@@ -61,7 +63,7 @@ class MotebehovArbeidstakerControllerV3 @Inject constructor(
6163
value = ["/motebehov/all"],
6264
produces = [MediaType.APPLICATION_JSON_VALUE],
6365
)
64-
fun motebehovStatusArbeidstakerWithCodeSixUsers(): MotebehovStatus {
66+
fun motebehovStatusArbeidstakerWithCodeSixUsers(): MotebehovStatusWithLegacyMotebehovDTO {
6567
val arbeidstakerFnr = TokenXUtil.validateTokenXClaims(
6668
contextHolder,
6769
dialogmoteClientId,
@@ -72,6 +74,7 @@ class MotebehovArbeidstakerControllerV3 @Inject constructor(
7274
metric.tellEndepunktKall("call_endpoint_motebehovstatus_arbeidstaker_all")
7375

7476
return motebehovStatusServiceV2.motebehovStatusForArbeidstaker(arbeidstakerFnr)
77+
.toMotebehovStatusWithLegacyMotebehovDTO()
7578
}
7679

7780
// Currently used POST-endpoint to phase out

src/main/kotlin/no/nav/syfo/motebehov/api/internad/dto/MotebehovVeilederDTO.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ data class MotebehovVeilederDTOv3(
1414
val opprettetAvNavn: String?,
1515
val arbeidstakerFnr: String,
1616
val virksomhetsnummer: String,
17-
val motebehovSvar: MotebehovSvarLegacyDTO,
1817
val tildeltEnhet: String? = null,
1918
val behandletTidspunkt: LocalDateTime? = null,
2019
val behandletVeilederIdent: String? = null,
21-
val skjemaType: MotebehovSkjemaType? = null
20+
val skjemaType: MotebehovSkjemaType? = null,
21+
val motebehovSvar: MotebehovSvarLegacyDTO,
2222
)
2323

2424
data class MotebehovVeilederDTOv4(

src/main/kotlin/no/nav/syfo/motebehov/motebehovstatus/MotebehovStatus.kt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package no.nav.syfo.motebehov.motebehovstatus
22

33
import no.nav.syfo.motebehov.Motebehov
44
import no.nav.syfo.motebehov.MotebehovWithFormValuesOutputDTO
5+
import no.nav.syfo.motebehov.MotebehovWithLegacyMotebehovSvarOutputDTO
56
import no.nav.syfo.motebehov.isUbehandlet
67
import no.nav.syfo.motebehov.toMotebehovWithFormValuesOutputDTO
8+
import no.nav.syfo.motebehov.toMotebehovWithLegacyMotebehovSvarOutputDTO
79
import java.io.Serializable
810

911
data class MotebehovStatus(
@@ -31,11 +33,17 @@ fun MotebehovStatus.isMotebehovAvailableForAnswer(): Boolean {
3133
this.motebehov == null
3234
}
3335

34-
fun MotebehovStatus.toMotebehovStatusWithFormValuesDTO(): MotebehovStatusWithFormValuesDTO {
35-
return MotebehovStatusWithFormValuesDTO(
36+
data class MotebehovStatusWithLegacyMotebehovDTO(
37+
val visMotebehov: Boolean,
38+
val skjemaType: MotebehovSkjemaType? = null,
39+
val motebehov: MotebehovWithLegacyMotebehovSvarOutputDTO? = null,
40+
)
41+
42+
fun MotebehovStatus.toMotebehovStatusWithLegacyMotebehovDTO(): MotebehovStatusWithLegacyMotebehovDTO {
43+
return MotebehovStatusWithLegacyMotebehovDTO(
3644
visMotebehov = this.visMotebehov,
3745
skjemaType = this.skjemaType,
38-
motebehovWithFormValues = this.motebehov?.toMotebehovWithFormValuesOutputDTO()
46+
motebehov = this.motebehov?.toMotebehovWithLegacyMotebehovSvarOutputDTO()
3947
)
4048
}
4149

@@ -44,3 +52,11 @@ data class MotebehovStatusWithFormValuesDTO(
4452
val skjemaType: MotebehovSkjemaType? = null,
4553
val motebehovWithFormValues: MotebehovWithFormValuesOutputDTO? = null,
4654
)
55+
56+
fun MotebehovStatus.toMotebehovStatusWithFormValuesDTO(): MotebehovStatusWithFormValuesDTO {
57+
return MotebehovStatusWithFormValuesDTO(
58+
visMotebehov = this.visMotebehov,
59+
skjemaType = this.skjemaType,
60+
motebehovWithFormValues = this.motebehov?.toMotebehovWithFormValuesOutputDTO()
61+
)
62+
}

0 commit comments

Comments
 (0)