Skip to content

Commit

Permalink
IS-2276: Correct formating behandlernavn for journalforing
Browse files Browse the repository at this point in the history
  • Loading branch information
andersrognstad committed May 6, 2024
1 parent a707ec3 commit d2ea92d
Show file tree
Hide file tree
Showing 9 changed files with 114 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import no.nav.syfo.Environment
import no.nav.syfo.application.mq.MQSenderInterface
import no.nav.syfo.client.*
import no.nav.syfo.client.azuread.v2.AzureAdV2Client
import no.nav.syfo.client.helsenett.SyfohelsenettproxyClient
import no.nav.syfo.client.helsenett.fullName
import no.nav.syfo.client.pdl.PdlClient
import no.nav.syfo.db.DatabaseInterface
import no.nav.syfo.domain.PersonIdent
Expand Down Expand Up @@ -67,9 +69,6 @@ class DialogmeldingProcessor(
pdfgenClient = pdfgenClient,
database = database,
)
val signerendeLegeService = SignerendeLegeService(
syfohelsenettproxyClient = syfohelsenettproxyClient,
)
val clamAvClient = ClamAvClient(
endpointUrl = env.clamavURL,
)
Expand Down Expand Up @@ -106,13 +105,15 @@ class DialogmeldingProcessor(
)

val innbyggerOK = pdlClient.personEksisterer(PersonIdent(receivedDialogmelding.personNrPasient))
val legeOK = pdlClient.personEksisterer(PersonIdent(receivedDialogmelding.personNrLege))
val behandlerFnr = receivedDialogmelding.personNrLege
val legeOK = pdlClient.personEksisterer(PersonIdent(behandlerFnr))

val navnSignerendeLege = signerendeLegeService.signerendeLegeNavn(
signerendeLegeFnr = receivedDialogmelding.personNrLege,
val navnSignerendeLege = syfohelsenettproxyClient.finnBehandler(
behandlerFnr = behandlerFnr,
msgId = msgId,
loggingMeta = loggingMeta,
)
)?.fullName() ?: behandlerFnr

val vedleggListe = xmlVedlegg.map { xml -> xml.toVedlegg() }

val validationResult = validateMessage(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package no.nav.syfo.client.helsenett

import java.util.*

data class HelsenettProxyBehandler(
val godkjenninger: List<Godkjenning>,
val fnr: String?,
val hprNummer: Int?,
val fornavn: String?,
val mellomnavn: String?,
val etternavn: String?
)

data class Godkjenning(
val helsepersonellkategori: Kode? = null,
val autorisasjon: Kode? = null
)

data class Kode(
val aktiv: Boolean,
val oid: Int,
val verdi: String?
)

fun HelsenettProxyBehandler.fullName(): String? = when {
fornavn == null && mellomnavn == null && etternavn == null -> {
null
}
mellomnavn == null -> {
"${fornavn?.lowerCapitalize()} ${etternavn?.lowerCapitalize()}"
}
else -> {
"${fornavn?.lowerCapitalize()} ${mellomnavn.lowerCapitalize()} ${etternavn?.lowerCapitalize()}"
}
}

private fun String.lowerCapitalize() =
this.split(" ").joinToString(" ") { name ->
val nameWithDash = name.split("-")
if (nameWithDash.size > 1) {
nameWithDash.joinToString("-") { it.capitalizeName() }
} else {
name.capitalizeName()
}
}

private fun String.capitalizeName() =
this.lowercase(Locale.getDefault()).replaceFirstChar {
if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.nav.syfo.client
package no.nav.syfo.client.helsenett

import io.ktor.client.*
import io.ktor.client.call.*
Expand Down Expand Up @@ -59,23 +59,3 @@ class SyfohelsenettproxyClient(
}
}
}

data class HelsenettProxyBehandler(
val godkjenninger: List<Godkjenning>,
val fnr: String?,
val hprNummer: Int?,
val fornavn: String?,
val mellomnavn: String?,
val etternavn: String?
)

data class Godkjenning(
val helsepersonellkategori: Kode? = null,
val autorisasjon: Kode? = null
)

data class Kode(
val aktiv: Boolean,
val oid: Int,
val verdi: String?
)
2 changes: 1 addition & 1 deletion src/main/kotlin/no/nav/syfo/rules/HPRRuleChain.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.syfo.rules

import no.nav.syfo.client.HelsenettProxyBehandler
import no.nav.syfo.client.helsenett.HelsenettProxyBehandler
import no.nav.syfo.model.HelsepersonellKategori
import no.nav.syfo.model.Status

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/no/nav/syfo/services/RuleService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package no.nav.syfo.services
import java.time.format.DateTimeFormatter
import net.logstash.logback.argument.StructuredArguments.fields
import no.nav.syfo.client.LegeSuspensjonClient
import no.nav.syfo.client.SyfohelsenettproxyClient
import no.nav.syfo.client.helsenett.SyfohelsenettproxyClient
import no.nav.syfo.model.ReceivedDialogmelding
import no.nav.syfo.model.RuleInfo
import no.nav.syfo.model.RuleMetadata
Expand Down
36 changes: 0 additions & 36 deletions src/main/kotlin/no/nav/syfo/services/SignerendeLegeService.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package no.nav.syfo.client.helsenett

import org.amshove.kluent.shouldBeEqualTo
import org.spekframework.spek2.Spek
import org.spekframework.spek2.style.specification.describe

fun generateHelsenettProxyBehandler(fornavn: String, mellomnavn: String?, etternavn: String): HelsenettProxyBehandler {
return HelsenettProxyBehandler(
godkjenninger = emptyList(),
fnr = "12125678911",
hprNummer = 123456,
fornavn = fornavn,
mellomnavn = mellomnavn,
etternavn = etternavn
)
}

class HelsenettProxyBehandlerSpek : Spek({
describe("fullName") {
it("returns full name Fornavn Mellomnavn Etternavn") {
val behandler = generateHelsenettProxyBehandler(
fornavn = "fornavn",
mellomnavn = "mellomnavn",
etternavn = "etternavn"
)
behandler.fullName() shouldBeEqualTo "Fornavn Mellomnavn Etternavn"
}
it("returns full name Fornavn-Navn Mellomnavn Etternavn") {
val behandler = generateHelsenettProxyBehandler(
fornavn = "fornavn-navn",
mellomnavn = "MELLOMNAVN",
etternavn = "EtternAvn"
)

behandler.fullName() shouldBeEqualTo "Fornavn-Navn Mellomnavn Etternavn"
}
it("returns full name Fornavn Etternavn when mellomnavn is null") {
val behandler = generateHelsenettProxyBehandler(
fornavn = "fornavn",
mellomnavn = null,
etternavn = "ETTERNAVN"
)

behandler.fullName() shouldBeEqualTo "Fornavn Etternavn"
}
}
})
4 changes: 3 additions & 1 deletion src/test/kotlin/no/nav/syfo/mock/SyfohelsenettproxyMock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import io.ktor.server.plugins.contentnegotiation.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import no.nav.syfo.UserConstants
import no.nav.syfo.client.*
import no.nav.syfo.client.helsenett.Godkjenning
import no.nav.syfo.client.helsenett.HelsenettProxyBehandler
import no.nav.syfo.client.helsenett.Kode
import no.nav.syfo.getRandomPort
import no.nav.syfo.model.HelsepersonellKategori
import no.nav.syfo.util.configure
Expand Down
6 changes: 3 additions & 3 deletions src/test/kotlin/no/nav/syfo/rules/HPRRuleChainTest.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package no.nav.syfo.rules

import io.mockk.mockk
import no.nav.syfo.client.Godkjenning
import no.nav.syfo.client.HelsenettProxyBehandler
import no.nav.syfo.client.Kode
import no.nav.syfo.client.helsenett.Godkjenning
import no.nav.syfo.client.helsenett.HelsenettProxyBehandler
import no.nav.syfo.client.helsenett.Kode
import no.nav.syfo.model.Dialogmelding
import no.nav.syfo.model.HelsepersonellKategori
import org.amshove.kluent.shouldBeEqualTo
Expand Down

0 comments on commit d2ea92d

Please sign in to comment.