Skip to content

Commit

Permalink
fix: fikser diagnosekoder
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasDev committed Oct 7, 2024
1 parent add721b commit c464303
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
33 changes: 30 additions & 3 deletions src/main/kotlin/no/nav/syfo/model/SykmeldingMapper.kt
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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(
Expand Down
22 changes: 22 additions & 0 deletions src/test/kotlin/no/nav/syfo/SykmeldingMapperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit c464303

Please sign in to comment.