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-2831: Count irrelevant field content #251

Merged
merged 1 commit into from
Nov 26, 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
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)