Skip to content

Commit

Permalink
IS-2158: Support friskmelding til arbeidsformidling dialogmeldingkode (
Browse files Browse the repository at this point in the history
…#310)

* IS-2158: Support friskmelding til arbeidsformidling

* isfrisktilarbeid dialogmelding bestilling topic access
  • Loading branch information
andersrognstad authored Mar 26, 2024
1 parent f2c05a6 commit 315bc4f
Show file tree
Hide file tree
Showing 7 changed files with 188 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .nais/kafka/behandler-dialogmelding-bestilling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ spec:
- team: teamsykefravr
application: isbehandlerdialog
access: write
- team: teamsykefravr
application: isfrisktilarbeid
access: write
- team: disykefravar
application: dvh-sykefravar-airflow-kafka
access: read
5 changes: 2 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.apache.tools.ant.taskdefs.condition.Os

group = "no.nav.syfo"
version = "1.0.0"
Expand All @@ -25,7 +24,7 @@ object Versions {
const val mq = "9.3.4.1"
const val nimbusjosejwt = "9.37.3"
const val postgres = "42.7.2"
val postgresEmbedded = if (Os.isFamily(Os.FAMILY_MAC)) "1.0.0" else "0.13.4"
const val postgresEmbedded = "2.0.6"
const val spek = "2.0.19"
const val syfotjenester = "1.2021.06.09-13.09-b3d30de9996e"
}
Expand Down Expand Up @@ -127,7 +126,7 @@ dependencies {
implementation("org.flywaydb:flyway-core:${Versions.flyway}")
implementation("com.zaxxer:HikariCP:${Versions.hikari}")
implementation("org.postgresql:postgresql:${Versions.postgres}")
testImplementation("com.opentable.components:otj-pg-embedded:${Versions.postgresEmbedded}")
testImplementation("io.zonky.test:embedded-postgres:${Versions.postgresEmbedded}")

testImplementation("com.nimbusds:nimbus-jose-jwt:${Versions.nimbusjosejwt}")
testImplementation("io.ktor:ktor-server-test-host:${Versions.ktor}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fun createDialogmelding(melding: DialogmeldingToBehandlerBestilling): XMLDialogm
fellesFactory.createXMLCV()
.withDN(
when (kode) {
2 -> "Friskmelding til arbeidsformidling"
3 -> "Retur av legeerklæring"
4 -> "Avlysning dialogmøte"
8 -> "Melding fra NAV"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ object DialogmeldingServiceSpek : Spek({
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }

val melding = generateDialogmeldingToBehandlerBestillingNotatReturLegeerklæringDTO(
val melding = generateDialogmeldingToBehandlerBestillingNotatReturLegeerklaringDTO(
behandlerRef = behandlerRef,
uuid = uuid,
arbeidstakerPersonident = arbeidstakerPersonident,
Expand All @@ -305,6 +305,30 @@ object DialogmeldingServiceSpek : Spek({
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
it("Sends correct message on MQ when friskmelding til arbeidsformidling") {
clearAllMocks()
val messageSlot = slot<String>()
justRun { mqSender.sendMessageToEmottak(capture(messageSlot)) }

val melding = generateDialogmeldingToBehandlerBestillingNotatFriskmeldingTilArbeidsformidlingDTO(
behandlerRef = behandlerRef,
uuid = uuid,
arbeidstakerPersonident = arbeidstakerPersonident,
).toDialogmeldingToBehandlerBestilling(
behandler = behandler,
)

runBlocking {
dialogmeldingService.sendMelding(melding)
}
verify(exactly = 1) { mqSender.sendMessageToEmottak(any()) }

val expectedFellesformatMessageAsRegex = defaultFellesformatDialogmeldingFriskmeldingTilArbeidsformidlingXmlRegex()
val actualFellesformatMessage = messageSlot.captured
assertTrue(
expectedFellesformatMessageAsRegex.matches(actualFellesformatMessage),
)
}
it("Sends correct message on MQ when melding fra NAV") {
clearAllMocks()
val messageSlot = slot<String>()
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/no/nav/syfo/testhelper/TestDatabase.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.nav.syfo.testhelper

import com.opentable.db.postgres.embedded.EmbeddedPostgres
import io.zonky.test.db.postgres.embedded.EmbeddedPostgres
import no.nav.syfo.application.database.DatabaseInterface
import no.nav.syfo.application.database.toList
import no.nav.syfo.behandler.database.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,24 @@ fun generateDialogmeldingToBehandlerBestillingAvlysningDTO(
behandlerRef: UUID,
uuid: UUID,
arbeidstakerPersonident: Personident = Personident("01010112345"),
) = DialogmeldingToBehandlerBestillingDTO(
behandlerRef = behandlerRef.toString(),
personIdent = arbeidstakerPersonident.value,
dialogmeldingUuid = uuid.toString(),
dialogmeldingRefParent = uuid.toString(),
dialogmeldingRefConversation = uuid.toString(),
dialogmeldingType = DialogmeldingType.DIALOG_NOTAT.name,
dialogmeldingKodeverk = DialogmeldingKodeverk.HENVENDELSE.name,
dialogmeldingKode = DialogmeldingKode.KODE4.value,
dialogmeldingTekst = "Møtet er avlyst",
dialogmeldingVedlegg = null,
) = generateDialogmeldingToBehandlerBestillingHenvendelseNotat(
behandlerRef = behandlerRef,
uuid = uuid,
arbeidstakerPersonident = arbeidstakerPersonident,
kode = DialogmeldingKode.KODE4,
tekst = "Møtet er avlyst",
)

fun generateDialogmeldingToBehandlerBestillingReferatDTO(
behandlerRef: UUID,
uuid: UUID,
arbeidstakerPersonident: Personident = Personident("01010112345"),
) = DialogmeldingToBehandlerBestillingDTO(
behandlerRef = behandlerRef.toString(),
personIdent = arbeidstakerPersonident.value,
dialogmeldingUuid = uuid.toString(),
dialogmeldingRefParent = uuid.toString(),
dialogmeldingRefConversation = uuid.toString(),
dialogmeldingType = DialogmeldingType.DIALOG_NOTAT.name,
dialogmeldingKodeverk = DialogmeldingKodeverk.HENVENDELSE.name,
dialogmeldingKode = DialogmeldingKode.KODE9.value,
dialogmeldingTekst = "Dette er et referat",
dialogmeldingVedlegg = null,
) = generateDialogmeldingToBehandlerBestillingHenvendelseNotat(
behandlerRef = behandlerRef,
uuid = uuid,
arbeidstakerPersonident = arbeidstakerPersonident,
kode = DialogmeldingKode.KODE9,
tekst = "Dette er et referat",
)

fun generateDialogmeldingToBehandlerBestillingForesporselDTO(
Expand Down Expand Up @@ -123,21 +113,28 @@ fun generateDialogmeldingToBehandlerBestillingForesporselLegeerklaringDTO(
dialogmeldingVedlegg = null,
)

fun generateDialogmeldingToBehandlerBestillingNotatReturLegeerklæringDTO(
fun generateDialogmeldingToBehandlerBestillingNotatReturLegeerklaringDTO(
behandlerRef: UUID,
uuid: UUID,
arbeidstakerPersonident: Personident = Personident("01010112345"),
) = DialogmeldingToBehandlerBestillingDTO(
behandlerRef = behandlerRef.toString(),
personIdent = arbeidstakerPersonident.value,
dialogmeldingUuid = uuid.toString(),
dialogmeldingRefParent = uuid.toString(),
dialogmeldingRefConversation = uuid.toString(),
dialogmeldingType = DialogmeldingType.DIALOG_NOTAT.name,
dialogmeldingKodeverk = DialogmeldingKodeverk.HENVENDELSE.name,
dialogmeldingKode = DialogmeldingKode.KODE3.value,
dialogmeldingTekst = "Dette er en henvendelse om retur av legeerklæring",
dialogmeldingVedlegg = null,
) = generateDialogmeldingToBehandlerBestillingHenvendelseNotat(
behandlerRef = behandlerRef,
uuid = uuid,
arbeidstakerPersonident = arbeidstakerPersonident,
kode = DialogmeldingKode.KODE3,
tekst = "Dette er en henvendelse om retur av legeerklæring",
)

fun generateDialogmeldingToBehandlerBestillingNotatFriskmeldingTilArbeidsformidlingDTO(
behandlerRef: UUID,
uuid: UUID,
arbeidstakerPersonident: Personident = Personident("01010112345"),
) = generateDialogmeldingToBehandlerBestillingHenvendelseNotat(
behandlerRef = behandlerRef,
uuid = uuid,
arbeidstakerPersonident = arbeidstakerPersonident,
kode = DialogmeldingKode.KODE2,
tekst = "Dette er en henvendelse om friskmelding til arbeidsformidling",
)

fun generateDialogmeldingToBehandlerBestillingOppfolgingsplanDTO(
Expand All @@ -161,6 +158,20 @@ fun generateDialogmeldingToBehandlerBestillingHenvendelseMeldingFraNavDTO(
behandlerRef: UUID,
uuid: UUID,
arbeidstakerPersonident: Personident = Personident("01010112345"),
) = generateDialogmeldingToBehandlerBestillingHenvendelseNotat(
behandlerRef = behandlerRef,
uuid = uuid,
arbeidstakerPersonident = arbeidstakerPersonident,
kode = DialogmeldingKode.KODE8,
tekst = "Dette er en generell henvendelse fra NAV som ikke utløser takst",
)

private fun generateDialogmeldingToBehandlerBestillingHenvendelseNotat(
behandlerRef: UUID,
uuid: UUID,
kode: DialogmeldingKode,
tekst: String,
arbeidstakerPersonident: Personident = Personident("01010112345"),
) = DialogmeldingToBehandlerBestillingDTO(
behandlerRef = behandlerRef.toString(),
personIdent = arbeidstakerPersonident.value,
Expand All @@ -169,7 +180,7 @@ fun generateDialogmeldingToBehandlerBestillingHenvendelseMeldingFraNavDTO(
dialogmeldingRefConversation = uuid.toString(),
dialogmeldingType = DialogmeldingType.DIALOG_NOTAT.name,
dialogmeldingKodeverk = DialogmeldingKodeverk.HENVENDELSE.name,
dialogmeldingKode = DialogmeldingKode.KODE8.value,
dialogmeldingTekst = "Dette er en generell henvendelse fra NAV som ikke utløser takst",
dialogmeldingKode = kode.value,
dialogmeldingTekst = tekst,
dialogmeldingVedlegg = null,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package no.nav.syfo.testhelper.generator

fun defaultFellesformatDialogmeldingFriskmeldingTilArbeidsformidlingXmlRegex(): Regex {
return Regex(
"<\\?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"\\?>\n" +
"<EI_fellesformat xmlns=\"http://www.nav.no/xml/eiff/2/\" xmlns:ns6=\"http://www.kith.no/xmlstds/base64container\" xmlns:ns5=\"http://www.kith.no/xmlstds/felleskomponent1\" xmlns:ns2=\"http://www.kith.no/xmlstds/msghead/2006-05-24\" xmlns:ns4=\"http://www.kith.no/xmlstds/dialog/2006-10-11\" xmlns:ns3=\"http://www.w3.org/2000/09/xmldsig#\">\n" +
" <ns2:MsgHead>\n" +
" <ns2:MsgInfo>\n" +
" <ns2:Type V=\"DIALOG_NOTAT\" DN=\"Notat\"/>\n" +
" <ns2:MIGversion>v1.2 2006-05-24</ns2:MIGversion>\n" +
" <ns2:GenDate>\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{0,9}</ns2:GenDate>\n" +
" <ns2:MsgId>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}</ns2:MsgId>\n" +
" <ns2:Ack V=\"J\" DN=\"Ja\"/>\n" +
" <ns2:ConversationRef>\n" +
" <ns2:RefToParent>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}</ns2:RefToParent>\n" +
" <ns2:RefToConversation>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}</ns2:RefToConversation>\n" +
" </ns2:ConversationRef>\n" +
" <ns2:Sender>\n" +
" <ns2:Organisation>\n" +
" <ns2:OrganisationName>NAV</ns2:OrganisationName>\n" +
" <ns2:Ident>\n" +
" <ns2:Id>889640782</ns2:Id>\n" +
" <ns2:TypeId V=\"ENH\" S=\"2.16.578.1.12.4.1.1.9051\" DN=\"Organisasjonsnummeret i Enhetsregisteret\"/>\n" +
" </ns2:Ident>\n" +
" <ns2:Ident>\n" +
" <ns2:Id>79768</ns2:Id>\n" +
" <ns2:TypeId V=\"HER\" S=\"2.16.578.1.12.4.1.1.9051\" DN=\"Identifikator fra Helsetjenesteenhetsregisteret \\(HER-id\\)\"/>\n" +
" </ns2:Ident>\n" +
" </ns2:Organisation>\n" +
" </ns2:Sender>\n" +
" <ns2:Receiver>\n" +
" <ns2:Organisation>\n" +
" <ns2:Ident>\n" +
" <ns2:Id>99</ns2:Id>\n" +
" <ns2:TypeId V=\"HER\" S=\"2.16.578.1.12.4.1.1.9051\" DN=\"Identifikator fra Helsetjenesteenhetsregisteret \\(HER-id\\)\"/>\n" +
" </ns2:Ident>\n" +
" <ns2:Ident>\n" +
" <ns2:Id>123456789</ns2:Id>\n" +
" <ns2:TypeId V=\"ENH\" S=\"2.16.578.1.12.4.1.1.9051\" DN=\"Organisasjonsnummeret i Enhetsregisteret\"/>\n" +
" </ns2:Ident>\n" +
" <ns2:Address>\n" +
" <ns2:Type V=\"RES\" DN=\"Besøksadresse\"/>\n" +
" <ns2:StreetAdr>adresse</ns2:StreetAdr>\n" +
" <ns2:PostalCode>1234</ns2:PostalCode>\n" +
" <ns2:City>poststed</ns2:City>\n" +
" </ns2:Address>\n" +
" <ns2:HealthcareProfessional>\n" +
" <ns2:FamilyName>Scully</ns2:FamilyName>\n" +
" <ns2:MiddleName>Katherine</ns2:MiddleName>\n" +
" <ns2:GivenName>Dana</ns2:GivenName>\n" +
" <ns2:Ident>\n" +
" <ns2:Id>12125678911</ns2:Id>\n" +
" <ns2:TypeId V=\"FNR\" S=\"2.16.578.1.12.4.1.1.8116\" DN=\"Fødselsnummer\"/>\n" +
" </ns2:Ident>\n" +
" <ns2:Ident>\n" +
" <ns2:Id>9</ns2:Id>\n" +
" <ns2:TypeId V=\"HPR\" S=\"2.16.578.1.12.4.1.1.8116\" DN=\"HPR-nummer\"/>\n" +
" </ns2:Ident>\n" +
" <ns2:Ident>\n" +
" <ns2:Id>77</ns2:Id>\n" +
" <ns2:TypeId V=\"HER\" S=\"2.16.578.1.12.4.1.1.8116\" DN=\"Identifikator fra Helsetjenesteenhetsregisteret\"/>\n" +
" </ns2:Ident>\n" +
" </ns2:HealthcareProfessional>\n" +
" </ns2:Organisation>\n" +
" </ns2:Receiver>\n" +
" <ns2:Patient>\n" +
" <ns2:FamilyName>Etternavn</ns2:FamilyName>\n" +
" <ns2:MiddleName>Mellomnavn</ns2:MiddleName>\n" +
" <ns2:GivenName>Fornavn</ns2:GivenName>\n" +
" <ns2:Ident>\n" +
" <ns2:Id>01010112345</ns2:Id>\n" +
" <ns2:TypeId V=\"FNR\" S=\"2.16.578.1.12.4.1.1.8116\" DN=\"Fødselsnummer\"/>\n" +
" </ns2:Ident>\n" +
" </ns2:Patient>\n" +
" </ns2:MsgInfo>\n" +
" <ns2:Document>\n" +
" <ns2:DocumentConnection V=\"H\" DN=\"Hoveddokument\"/>\n" +
" <ns2:RefDoc>\n" +
" <ns2:IssueDate V=\"\\d{4}-\\d{2}-\\d{2}\"/>\n" +
" <ns2:MsgType V=\"XML\" DN=\"XML-instans\"/>\n" +
" <ns2:MimeType>text/xml</ns2:MimeType>\n" +
" <ns2:Content>\n" +
" <ns4:Dialogmelding>\n" +
" <ns4:Notat>\n" +
" <ns4:TemaKodet V=\"2\" S=\"2.16.578.1.12.4.1.1.8127\" DN=\"Friskmelding til arbeidsformidling\"/>\n" +
" <ns4:TekstNotatInnhold xsi:type=\"xs:string\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">Dette er en henvendelse om friskmelding til arbeidsformidling</ns4:TekstNotatInnhold>\n" +
" <ns4:DokIdNotat>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}</ns4:DokIdNotat>\n" +
" </ns4:Notat>\n" +
" </ns4:Dialogmelding>\n" +
" </ns2:Content>\n" +
" </ns2:RefDoc>\n" +
" </ns2:Document>\n" +
" <ns2:Document>\n" +
" <ns2:DocumentConnection V=\"V\" DN=\"Vedlegg\"/>\n" +
" <ns2:RefDoc>\n" +
" <ns2:IssueDate V=\"\\d{4}-\\d{2}-\\d{2}\"/>\n" +
" <ns2:MsgType V=\"A\" DN=\"Vedlegg\"/>\n" +
" <ns2:MimeType>application/pdf</ns2:MimeType>\n" +
" <ns2:Content>\n" +
" <ns6:Base64Container/>\n" +
" </ns2:Content>\n" +
" </ns2:RefDoc>\n" +
" </ns2:Document>\n" +
" </ns2:MsgHead>\n" +
" <MottakenhetBlokk partnerReferanse=\"1\" ebRole=\"Saksbehandler\" ebService=\"HenvendelseFraSaksbehandler\" ebAction=\"Henvendelse\"/>\n" +
" <SporinformasjonBlokk programID=\"MODIA SYFO\" programVersjonID=\"1.0\" programResultatKoder=\"0\" tidsstempel=\"\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\"/>\n" +
"</EI_fellesformat>\n"
)
}

0 comments on commit 315bc4f

Please sign in to comment.