-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IS-2276: Correct formating behandlernavn for journalforing
- Loading branch information
1 parent
a707ec3
commit d2ea92d
Showing
9 changed files
with
114 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/kotlin/no/nav/syfo/client/helsenett/HelsenettProxyBehandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
src/main/kotlin/no/nav/syfo/services/SignerendeLegeService.kt
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
src/test/kotlin/no/nav/syfo/client/helsenett/HelsenettProxyBehandlerSpek.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters