From c464303c7f6f1e81072260c158cf85144547988e Mon Sep 17 00:00:00 2001 From: Andreas Sagen Aspaas Date: Mon, 7 Oct 2024 12:44:37 +0200 Subject: [PATCH] fix: fikser diagnosekoder --- build.gradle.kts | 2 ++ .../no/nav/syfo/model/SykmeldingMapper.kt | 33 +++++++++++++++++-- .../no/nav/syfo/SykmeldingMapperTest.kt | 22 +++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 07a4bc93..8e2ddeda 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,6 +30,7 @@ val commonsCodecVersion = "1.17.1" val ktfmtVersion = "0.44" val snappyJavaVersion = "1.1.10.6" val opentelemetryVersion = "2.3.0" +val diagnosekoderVersion = "1.2024.0" plugins { id("application") @@ -110,6 +111,7 @@ dependencies { implementation("com.zaxxer:HikariCP:$hikariVersion") compileOnly("org.flywaydb:flyway-core:$flywayVersion") implementation("org.flywaydb:flyway-database-postgresql:$flywayVersion") + implementation("no.nav.helse:diagnosekoder:$diagnosekoderVersion") testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/src/main/kotlin/no/nav/syfo/model/SykmeldingMapper.kt b/src/main/kotlin/no/nav/syfo/model/SykmeldingMapper.kt index 6f35c96c..9ec63b8e 100644 --- a/src/main/kotlin/no/nav/syfo/model/SykmeldingMapper.kt +++ b/src/main/kotlin/no/nav/syfo/model/SykmeldingMapper.kt @@ -1,11 +1,13 @@ package no.nav.syfo.model import java.time.LocalDateTime +import no.nav.helse.diagnosekoder.Diagnosekoder import no.nav.helse.sm2013.Address import no.nav.helse.sm2013.ArsakType import no.nav.helse.sm2013.CS import no.nav.helse.sm2013.CV import no.nav.helse.sm2013.HelseOpplysningerArbeidsuforhet +import no.nav.syfo.logger import no.nav.syfo.util.extractTlfFromKontaktInfo fun HelseOpplysningerArbeidsuforhet.toSykmelding( @@ -83,12 +85,37 @@ fun HelseOpplysningerArbeidsuforhet.MedisinskVurdering.toMedisinskVurdering() = annenFraversArsak = annenFraversArsak?.toAnnenFraversArsak(), ) -fun CV.toDiagnose() = +fun CV.toDiagnose(): Diagnose { if (v.contains(".")) { - Diagnose(s, v.replace(".", "").uppercase(), dn) + return toDiagnoseCode(s, v.replace(".", ""), dn) } else { - Diagnose(s, v.uppercase(), dn) + return toDiagnoseCode(s, v, dn) } +} + +fun toDiagnoseCode(system: String, code: String, dn: String?): Diagnose { + val codes = + when (system) { + Diagnosekoder.ICPC2_CODE -> Diagnosekoder.icpc2 + Diagnosekoder.ICD10_CODE -> Diagnosekoder.icd10 + else -> { + logger.error("Unknown diagnose code system: $system") + emptyMap() + } + } + if (codes.keys.contains(code)) { + return Diagnose(system, code, dn) + } + logger.info("did not find diagnose code: $code, system: $system") + val codeUppercase = codes.entries.firstOrNull { it.key.uppercase() == code.uppercase() } + if (codeUppercase != null) { + logger.info( + "found diagnose code with uppercase check code: $code, uppercase: $codeUppercase" + ) + return Diagnose(system, codeUppercase.key, dn) + } + return Diagnose(system, code, dn) +} fun ArsakType.toAnnenFraversArsak() = AnnenFraversArsak( diff --git a/src/test/kotlin/no/nav/syfo/SykmeldingMapperTest.kt b/src/test/kotlin/no/nav/syfo/SykmeldingMapperTest.kt index fd077a1f..a9cdc27a 100644 --- a/src/test/kotlin/no/nav/syfo/SykmeldingMapperTest.kt +++ b/src/test/kotlin/no/nav/syfo/SykmeldingMapperTest.kt @@ -331,6 +331,28 @@ internal class SykmeldingMapperTest { Assertions.assertEquals("K801", mappetDiagnosekode.kode) } + @Test + internal fun `test T4n code`() { + val originalCode = + CV().apply { + v = "T4n" + s = "2.16.578.1.12.4.1.1.7110" + } + val mappedDiagnosis = originalCode.toDiagnose() + Assertions.assertEquals("T4n", mappedDiagnosis.kode) + } + + @Test + internal fun `test T4N code`() { + val originalCode = + CV().apply { + v = "T4N" + s = "2.16.578.1.12.4.1.1.7110" + } + val mappedDiagnosis = originalCode.toDiagnose() + Assertions.assertEquals("T4n", mappedDiagnosis.kode) + } + @Test internal fun `Setter bistandUmiddelbart til true hvis beskrivBistandNAV er angitt og regelsettversjon 3`() { val originalMeldingTilNAV =