Skip to content

Commit bed6616

Browse files
committed
IS-2271: WIP
1 parent 4c40278 commit bed6616

File tree

9 files changed

+106
-6
lines changed

9 files changed

+106
-6
lines changed

src/main/kotlin/no/nav/syfo/App.kt

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import no.nav.syfo.cronjob.behandlendeenhet.PersonBehandlendeEnhetService
1919
import no.nav.syfo.cronjob.launchCronjobModule
2020
import no.nav.syfo.kafka.launchKafkaModule
2121
import no.nav.syfo.personstatus.PersonoversiktStatusService
22+
import no.nav.syfo.personstatus.infrastructure.database.PersonOversiktStatusRepository
2223
import org.slf4j.LoggerFactory
2324
import java.util.concurrent.TimeUnit
2425

@@ -67,9 +68,11 @@ fun main() {
6768
databaseModule(
6869
databaseEnvironment = environment.database,
6970
)
71+
val personoversiktStatusRepository = PersonOversiktStatusRepository(database = database)
7072
personoversiktStatusService = PersonoversiktStatusService(
7173
database = database,
7274
pdlClient = pdlClient,
75+
personoversiktStatusRepository = personoversiktStatusRepository,
7376
)
7477
personBehandlendeEnhetService = PersonBehandlendeEnhetService(
7578
database = database,

src/main/kotlin/no/nav/syfo/personstatus/PersonoversiktStatusService.kt

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import no.nav.syfo.client.pdl.PdlClient
55
import no.nav.syfo.domain.PersonIdent
66
import no.nav.syfo.oppfolgingstilfelle.domain.PersonOppfolgingstilfelleVirksomhet
77
import no.nav.syfo.personoppgavehendelse.kafka.*
8+
import no.nav.syfo.personstatus.application.IPersonOversiktStatusRepository
89
import no.nav.syfo.personstatus.db.*
910
import no.nav.syfo.personstatus.domain.*
1011
import java.sql.Connection
@@ -13,6 +14,7 @@ import java.time.LocalDate
1314
class PersonoversiktStatusService(
1415
private val database: DatabaseInterface,
1516
private val pdlClient: PdlClient,
17+
private val personoversiktStatusRepository: IPersonOversiktStatusRepository,
1618
) {
1719
private val isUbehandlet = true
1820
private val isBehandlet = false
@@ -83,6 +85,10 @@ class PersonoversiktStatusService(
8385
}
8486
}
8587

88+
fun updateArbeidsuforhetVurderingStatus(personident: PersonIdent, isAktivVurdering: Boolean) {
89+
personoversiktStatusRepository.updateArbeidsuforhetVurderingStatus(personident, isAktivVurdering)
90+
}
91+
8692
private fun createOrUpdatePersonOversiktStatus(
8793
connection: Connection,
8894
personident: PersonIdent,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package no.nav.syfo.personstatus.application
2+
3+
import no.nav.syfo.domain.PersonIdent
4+
5+
interface IPersonOversiktStatusRepository {
6+
7+
fun updateArbeidsuforhetVurderingStatus(personIdent: PersonIdent, isAktivVurdering: Boolean)
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package no.nav.syfo.personstatus.infrastructure.database
2+
3+
import no.nav.syfo.application.database.DatabaseInterface
4+
import no.nav.syfo.domain.PersonIdent
5+
import no.nav.syfo.personstatus.application.IPersonOversiktStatusRepository
6+
7+
class PersonOversiktStatusRepository(private val database: DatabaseInterface) : IPersonOversiktStatusRepository {
8+
9+
override fun updateArbeidsuforhetVurderingStatus(personIdent: PersonIdent, isAktivVurdering: Boolean) {
10+
database.connection.use { connection ->
11+
connection.prepareStatement(UPDATE_ARBEIDSUFORHET_VURDERING_STATUS).use {
12+
it.setBoolean(1, isAktivVurdering)
13+
it.setString(2, personIdent.value)
14+
it.executeQuery()
15+
connection.commit()
16+
}
17+
}
18+
}
19+
20+
companion object {
21+
private const val UPDATE_ARBEIDSUFORHET_VURDERING_STATUS = """
22+
UPDATE person_oversikt_status
23+
SET arbeidsuforhet_aktiv_vurdering = ?
24+
WHERE fnr = ?
25+
"""
26+
}
27+
}

src/main/kotlin/no/nav/syfo/personstatus/infrastructure/kafka/ArbeidsuforhetVurderingConsumer.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package no.nav.syfo.personstatus.infrastructure.kafka
33
import no.nav.syfo.application.ApplicationState
44
import no.nav.syfo.application.kafka.KafkaEnvironment
55
import no.nav.syfo.application.kafka.kafkaAivenConsumerConfig
6+
import no.nav.syfo.domain.PersonIdent
67
import no.nav.syfo.kafka.KafkaConsumerService
78
import no.nav.syfo.kafka.launchKafkaTask
89
import no.nav.syfo.personstatus.PersonoversiktStatusService
@@ -35,11 +36,10 @@ class ArbeidsuforhetVurderingConsumer(
3536
val validRecords = records.requireNoNulls()
3637
validRecords.map { record ->
3738
val recordValue = record.value()
38-
log.info("ArbeidsuforhetVurderingConsumer record value:\n$recordValue")
39-
// personoversiktStatusService.updateArbeidsuforhetVurderingStatus(
40-
// personident = PersonIdent(recordValue.personident),
41-
// isFinalVurdering = recordValue.isFinalVurdering,
42-
// )
39+
personoversiktStatusService.updateArbeidsuforhetVurderingStatus(
40+
personident = PersonIdent(recordValue.personident),
41+
isAktivVurdering = !recordValue.isFinalVurdering,
42+
)
4343
}
4444
}
4545

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ALTER TABLE person_oversikt_status
2+
ADD COLUMN arbeidsuforhet_aktiv_vurdering BOOLEAN DEFAULT FALSE;
3+
4+
DROP INDEX IX_PERSON_OVERSIKT_STATUS_ENHETENS_OVERSIKT;
5+
6+
CREATE INDEX IX_PERSON_OVERSIKT_STATUS_ENHETENS_OVERSIKT
7+
ON PERSON_OVERSIKT_STATUS (tildelt_enhet, dialogmotekandidat_generated_at)
8+
WHERE (motebehov_ubehandlet
9+
OR oppfolgingsplan_lps_bistand_ubehandlet
10+
OR dialogmotesvar_ubehandlet
11+
OR dialogmotekandidat
12+
OR ((aktivitetskrav = 'NY' OR aktivitetskrav = 'AVVENT') AND aktivitetskrav_stoppunkt > '2023-03-10')
13+
OR behandlerdialog_svar_ubehandlet
14+
OR behandlerdialog_ubesvart_ubehandlet
15+
OR behandlerdialog_avvist_ubehandlet
16+
OR aktivitetskrav_vurder_stans_ubehandlet
17+
OR trenger_oppfolging
18+
OR behandler_bistand_ubehandlet
19+
OR arbeidsuforhet_vurder_avslag_ubehandlet
20+
OR arbeidsuforhet_aktiv_vurdering
21+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package no.nav.syfo.personstatus.infrastructure
2+
3+
import io.ktor.server.testing.*
4+
import no.nav.syfo.personstatus.infrastructure.database.PersonOversiktStatusRepository
5+
import no.nav.syfo.testutil.ExternalMockEnvironment
6+
import org.spekframework.spek2.Spek
7+
import org.spekframework.spek2.style.specification.describe
8+
9+
class PersonOversiktStatusRepositorySpek : Spek({
10+
11+
12+
describe(PersonOversiktStatusRepository::class.java.simpleName) {
13+
with(TestApplicationEngine()) {
14+
start()
15+
val externalMockEnvironment = ExternalMockEnvironment.instance
16+
val database = externalMockEnvironment.database
17+
val personOversiktStatusRepository = PersonOversiktStatusRepository(database = database)
18+
19+
afterEachTest {
20+
// drop data
21+
}
22+
23+
describe("Successfully updates arbeidsuforhet vurdering status") {
24+
// Store person_oversikt_status to be changed
25+
// Edit the stored db row
26+
// Retrieve and see the difference
27+
}
28+
}
29+
}
30+
})

src/test/kotlin/no/nav/syfo/testutil/InternalMockEnvironment.kt

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import no.nav.syfo.cronjob.behandlendeenhet.PersonBehandlendeEnhetService
1010
import no.nav.syfo.cronjob.virksomhetsnavn.PersonOppfolgingstilfelleVirksomhetnavnCronjob
1111
import no.nav.syfo.cronjob.virksomhetsnavn.PersonOppfolgingstilfelleVirksomhetsnavnService
1212
import no.nav.syfo.personstatus.PersonoversiktStatusService
13+
import no.nav.syfo.personstatus.infrastructure.database.PersonOversiktStatusRepository
1314

1415
class InternalMockEnvironment private constructor() {
1516
private val externalMockEnvironment: ExternalMockEnvironment = ExternalMockEnvironment.instance
@@ -52,9 +53,11 @@ class InternalMockEnvironment private constructor() {
5253
val personOppfolgingstilfelleVirksomhetnavnCronjob = PersonOppfolgingstilfelleVirksomhetnavnCronjob(
5354
personOppfolgingstilfelleVirksomhetsnavnService = personOppfolgingstilfelleVirksomhetsnavnService,
5455
)
56+
val personoversiktRepository = PersonOversiktStatusRepository(database = database)
5557
val personoversiktStatusService = PersonoversiktStatusService(
5658
database = database,
5759
pdlClient = pdlClient,
60+
personoversiktStatusRepository = personoversiktRepository,
5861
)
5962

6063
companion object {

src/test/kotlin/no/nav/syfo/testutil/TestApiModule.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import no.nav.syfo.application.cache.RedisStore
66
import no.nav.syfo.client.azuread.AzureAdClient
77
import no.nav.syfo.client.pdl.PdlClient
88
import no.nav.syfo.personstatus.PersonoversiktStatusService
9+
import no.nav.syfo.personstatus.infrastructure.database.PersonOversiktStatusRepository
910

1011
fun Application.testApiModule(
1112
externalMockEnvironment: ExternalMockEnvironment
@@ -20,10 +21,11 @@ fun Application.testApiModule(
2021
azureAdClient = azureAdClient,
2122
clientEnvironment = externalMockEnvironment.environment.clients.pdl,
2223
)
23-
24+
val personoversiktRepository = PersonOversiktStatusRepository(database = externalMockEnvironment.database)
2425
val personoversiktStatusService = PersonoversiktStatusService(
2526
database = externalMockEnvironment.database,
2627
pdlClient = pdlClient,
28+
personoversiktStatusRepository = personoversiktRepository
2729
)
2830

2931
this.apiModule(

0 commit comments

Comments
 (0)