Skip to content

Commit

Permalink
IS-2831: Count irrelevant field content
Browse files Browse the repository at this point in the history
  • Loading branch information
andersrognstad committed Nov 26, 2024
1 parent 8afbb61 commit d41bda5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import no.nav.syfo.kafka.launchKafkaTask
import no.nav.syfo.personoppgave.domain.PersonOppgave
import no.nav.syfo.personoppgave.domain.PersonOppgaveType
import no.nav.syfo.personoppgave.getPersonOppgaverByReferanseUuid
import no.nav.syfo.sykmelding.ReceivedSykmeldingDTO
import no.nav.syfo.sykmelding.*
import no.nav.syfo.util.configuredJacksonMapper
import org.apache.kafka.clients.consumer.*
import org.apache.kafka.common.serialization.Deserializer
Expand Down Expand Up @@ -81,13 +81,32 @@ class KafkaSykmeldingConsumer(
connection = connection,
receivedSykmeldingDTO = receivedSykmeldingDTO,
)
countIrrelevantSykmeldingFelter(sykmelding)
}
}
}
connection.commit()
}
}

private fun countIrrelevantSykmeldingFelter(sykmelding: Sykmelding) {
val beskrivBistandNav = sykmelding.meldingTilNAV?.beskrivBistand
val tiltakNav = sykmelding.tiltakNAV
val andreTiltak = sykmelding.andreTiltak
if (!beskrivBistandNav.isNullOrEmpty() && isIrrelevant(beskrivBistandNav)) {
COUNT_MOTTATT_SYKMELDING_BESKRIV_BISTAND_NAV_IRRELEVANT.increment()
}
if (!tiltakNav.isNullOrEmpty() && isIrrelevant(tiltakNav)) {
COUNT_MOTTATT_SYKMELDING_TILTAK_NAV_IRRELEVANT.increment()
}
if (!andreTiltak.isNullOrEmpty() && isIrrelevant(andreTiltak)) {
COUNT_MOTTATT_SYKMELDING_ANDRE_TILTAK_IRRELEVANT.increment()
}
}

private fun isIrrelevant(content: String): Boolean =
irrelevantSykmeldingFelterContent.contains(content.lowercase().trim())

private fun createPersonoppgave(
connection: Connection,
receivedSykmeldingDTO: ReceivedSykmeldingDTO,
Expand Down Expand Up @@ -116,6 +135,7 @@ class KafkaSykmeldingConsumer(

companion object {
val log: Logger = LoggerFactory.getLogger(KafkaSykmeldingConsumer::class.java)
val irrelevantSykmeldingFelterContent = listOf(".", "-", "nei")
}
}

Expand Down
20 changes: 19 additions & 1 deletion src/main/kotlin/no/nav/syfo/sykmelding/SykmeldingMetrics.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package no.nav.syfo.behandler.kafka.sykmelding
package no.nav.syfo.sykmelding

import io.micrometer.core.instrument.Counter
import no.nav.syfo.metric.*

const val MOTTATT_SYKMELDING = "${METRICS_NS}_mottatt_sykmelding_count"
const val MOTTATT_SYKMELDING_CREATED_PERSONOPPGAVE = "${METRICS_NS}_mottatt_sykmelding_personoppgave_count"
const val MOTTATT_SYKMELDING_BESKRIV_BISTAND_NAV_IRRELEVANT = "${METRICS_NS}_mottatt_sykmelding_beskriv_bistand_nav_irrelevant_count"
const val MOTTATT_SYKMELDING_TILTAK_NAV_IRRELEVANT = "${METRICS_NS}_mottatt_sykmelding_tiltak_nav_irrelevant_count"
const val MOTTATT_SYKMELDING_ANDRE_TILTAK_IRRELEVANT = "${METRICS_NS}_mottatt_sykmelding_andre_tiltak_irrelevant_count"

val COUNT_MOTTATT_SYKMELDING: Counter = Counter
.builder(MOTTATT_SYKMELDING)
Expand All @@ -15,3 +18,18 @@ val COUNT_MOTTATT_SYKMELDING_SUCCESS: Counter = Counter
.builder(MOTTATT_SYKMELDING_CREATED_PERSONOPPGAVE)
.description("Counts the number of received sykmelding that created personoppgave")
.register(METRICS_REGISTRY)

val COUNT_MOTTATT_SYKMELDING_BESKRIV_BISTAND_NAV_IRRELEVANT: Counter = Counter
.builder(MOTTATT_SYKMELDING_BESKRIV_BISTAND_NAV_IRRELEVANT)
.description("Counts the number of received sykmelding with beskriv bistand Nav that is irrelevant for oppgave")
.register(METRICS_REGISTRY)

val COUNT_MOTTATT_SYKMELDING_TILTAK_NAV_IRRELEVANT: Counter = Counter
.builder(MOTTATT_SYKMELDING_TILTAK_NAV_IRRELEVANT)
.description("Counts the number of received sykmelding with tiltak Nav that is irrelevant for oppgave")
.register(METRICS_REGISTRY)

val COUNT_MOTTATT_SYKMELDING_ANDRE_TILTAK_IRRELEVANT: Counter = Counter
.builder(MOTTATT_SYKMELDING_ANDRE_TILTAK_IRRELEVANT)
.description("Counts the number of received sykmelding with andre tiltak that is irrelevant for oppgave")
.register(METRICS_REGISTRY)

0 comments on commit d41bda5

Please sign in to comment.