From eac826e5670394ec0873dd329afc9b4fed8d90ed Mon Sep 17 00:00:00 2001 From: Joakim Taule Kartveit Date: Wed, 23 Aug 2023 13:07:14 +0200 Subject: [PATCH 1/2] Bumped some dependencies --- build.gradle.kts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c5c4ab0d..a7c53cbe 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,5 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile group = "no.nav.syfo" version = "1.0.0" @@ -13,7 +12,7 @@ val jacksonVersion = "2.15.2" val jaxbApiVersion = "2.4.0-b180830.0359" val kafkaVersion = "3.4.0" val ktorVersion = "2.3.3" -val logbackVersion = "1.4.9" +val logbackVersion = "1.4.11" val logstashEncoderVersion = "7.4" val prometheusVersion = "0.16.0" val smCommonVersion = "1.0.12" @@ -23,9 +22,9 @@ val javaxAnnotationApiVersion = "1.3.2" val jaxwsToolsVersion = "2.3.2" val jaxbRuntimeVersion = "2.4.0-b180830.0438" val javaTimeAdapterVersion = "1.1.3" -val mockkVersion = "1.13.5" +val mockkVersion = "1.13.7" val kotlinVersion = "1.9.0" -val googleCloudStorageVersion = "2.26.0" +val googleCloudStorageVersion = "2.26.1" val junitJupiterVersion = "5.10.0" val flywayVersion = "9.21.1" val hikariVersion = "5.0.1" From 78038b7c69575f7cf73e68eefceba0bae3762823 Mon Sep 17 00:00:00 2001 From: Joakim Taule Kartveit Date: Wed, 23 Aug 2023 13:08:17 +0200 Subject: [PATCH 2/2] Avvis sykmelding if gendate is before current date --- .../application/BlockingApplicationRunner.kt | 37 +++- .../syfo/handlestatus/HandleStatusInvalid.kt | 31 +++ .../BlockingApplicationRunnerTest.kt | 19 ++ ...ng2013Regelsettversjon3gendatefremitid.xml | 191 ++++++++++++++++++ 4 files changed, 268 insertions(+), 10 deletions(-) create mode 100644 src/test/resources/sykemelding2013Regelsettversjon3gendatefremitid.xml diff --git a/src/main/kotlin/no/nav/syfo/application/BlockingApplicationRunner.kt b/src/main/kotlin/no/nav/syfo/application/BlockingApplicationRunner.kt index 96c00ad2..4beef20c 100644 --- a/src/main/kotlin/no/nav/syfo/application/BlockingApplicationRunner.kt +++ b/src/main/kotlin/no/nav/syfo/application/BlockingApplicationRunner.kt @@ -1,6 +1,7 @@ package no.nav.syfo.application import java.io.StringReader +import java.time.LocalDateTime import java.time.ZoneOffset import java.util.UUID import javax.jms.MessageConsumer @@ -26,6 +27,7 @@ import no.nav.syfo.client.getHelsepersonellKategori import no.nav.syfo.duplicationcheck.model.Duplicate import no.nav.syfo.duplicationcheck.model.DuplicateCheck import no.nav.syfo.handlestatus.handleDuplicateSM2013Content +import no.nav.syfo.handlestatus.handleSignaturDatoInTheFuture import no.nav.syfo.handlestatus.handleStatusINVALID import no.nav.syfo.handlestatus.handleStatusMANUALPROCESSING import no.nav.syfo.handlestatus.handleStatusOK @@ -116,7 +118,7 @@ class BlockingApplicationRunner( is TextMessage -> message.text else -> throw RuntimeException( - "Incoming message needs to be a byte message or text message" + "Incoming message needs to be a byte message or text message", ) } INCOMING_MESSAGE_COUNTER.inc() @@ -211,7 +213,7 @@ class BlockingApplicationRunner( if (erVirksomhetSykmelding) { logger.info( "Mottatt virksomhetssykmelding, {}", - StructuredArguments.fields(loggingMeta) + StructuredArguments.fields(loggingMeta), ) VIRKSOMHETSYKMELDING.inc() val hpr = extractHpr(fellesformat)?.id @@ -259,7 +261,7 @@ class BlockingApplicationRunner( val identer = pdlPersonService.getIdenter( listOf(signaturFnr, originaltPasientFnr), - loggingMeta + loggingMeta, ) val tssIdEmottak = @@ -267,7 +269,7 @@ class BlockingApplicationRunner( signaturFnr, legekontorOrgName, loggingMeta, - sykmeldingId + sykmeldingId, ) val tssIdInfotrygd = if (!tssIdEmottak.isNullOrEmpty()) { @@ -277,17 +279,17 @@ class BlockingApplicationRunner( signaturFnr, legekontorOrgName, loggingMeta, - sykmeldingId + sykmeldingId, ) } logger.info( "tssIdEmottak is $tssIdEmottak {}", - StructuredArguments.fields(loggingMeta) + StructuredArguments.fields(loggingMeta), ) logger.info( "tssIdInfotrygd is $tssIdInfotrygd {}", - StructuredArguments.fields(loggingMeta) + StructuredArguments.fields(loggingMeta), ) handleEmottakSubscription( @@ -355,7 +357,7 @@ class BlockingApplicationRunner( val signerendeBehandler = norskHelsenettClient.getByFnr( fnr = signaturFnr, - loggingMeta = loggingMeta + loggingMeta = loggingMeta, ) val behandlenedeBehandler = @@ -433,6 +435,21 @@ class BlockingApplicationRunner( } } + if (sykmelding.signaturDato.isAfter(LocalDateTime.now())) { + handleSignaturDatoInTheFuture( + loggingMeta, + fellesformat, + ediLoggId, + msgId, + msgHead, + env, + kafkaproducerApprec, + duplicationService, + duplicateCheck, + ) + continue@loop + } + val vedleggListe: List = if (vedlegg.isNotEmpty()) { bucketUploadService.lastOppVedlegg( @@ -459,7 +476,7 @@ class BlockingApplicationRunner( personNrPasient = pasient.fnr!!, tlfPasient = extractTlfFromKontaktInfo( - healthInformation.pasient.kontaktInfo + healthInformation.pasient.kontaktInfo, ), personNrLege = signaturFnr, navLogId = ediLoggId, @@ -499,7 +516,7 @@ class BlockingApplicationRunner( val validationResult = syfoSykemeldingRuleClient.executeRuleValidation( receivedSykmelding, - loggingMeta + loggingMeta, ) when (validationResult.status) { diff --git a/src/main/kotlin/no/nav/syfo/handlestatus/HandleStatusInvalid.kt b/src/main/kotlin/no/nav/syfo/handlestatus/HandleStatusInvalid.kt index 5d93818a..6402d82f 100644 --- a/src/main/kotlin/no/nav/syfo/handlestatus/HandleStatusInvalid.kt +++ b/src/main/kotlin/no/nav/syfo/handlestatus/HandleStatusInvalid.kt @@ -746,6 +746,37 @@ fun handleVedleggContainsVirus( sendApprec(apprec, env, kafkaproducerApprec, loggingMeta, duplicationService, duplicateCheck) } +fun handleSignaturDatoInTheFuture( + loggingMeta: LoggingMeta, + fellesformat: XMLEIFellesformat, + ediLoggId: String, + msgId: String, + msgHead: XMLMsgHead, + env: EnvironmentVariables, + kafkaproducerApprec: KafkaProducer, + duplicationService: DuplicationService, + duplicateCheck: DuplicateCheck, +) { + logger.warn( + "Sykmeldingen er avvist fordi signaturdatoen(GenDate) er frem i tid {} {}", + fields(loggingMeta), + keyValue("avvistAv", env.applicationName), + ) + + val apprec = + fellesformatToAppprec( + fellesformat, + "Sykmeldingen kan ikke rettes, det må skrives en ny." + + "Pasienten har ikke fått beskjed, men venter på ny sykmelding fra deg. Grunnet følgende:" + + "Signaturdatoen(GenDate) er frem i tid. Kontakt din EPJ-leverandør", + ediLoggId, + msgId, + msgHead, + ) + + sendApprec(apprec, env, kafkaproducerApprec, loggingMeta, duplicationService, duplicateCheck) +} + private fun sendApprec( apprec: Apprec, env: EnvironmentVariables, diff --git a/src/test/kotlin/no/nav/syfo/application/BlockingApplicationRunnerTest.kt b/src/test/kotlin/no/nav/syfo/application/BlockingApplicationRunnerTest.kt index e5810d5d..11c13c85 100644 --- a/src/test/kotlin/no/nav/syfo/application/BlockingApplicationRunnerTest.kt +++ b/src/test/kotlin/no/nav/syfo/application/BlockingApplicationRunnerTest.kt @@ -216,4 +216,23 @@ internal class BlockingApplicationRunnerTest { } } } + + @Test + internal fun `Sykmelding med gendate frem i tid skal gi avvist apprec`() { + every { applicationState.ready } returns true andThen false + val stringInput = + getFileAsString( + "src/test/resources/sykemelding2013Regelsettversjon3gendatefremitid.xml" + ) + val textMessage = mockk(relaxed = true) + every { textMessage.text } returns stringInput + every { inputconsumer.receive(1000) } returns textMessage + runBlocking { + blockingApplicationRunner.run(inputconsumer, backoutProducer) + + coVerify { + kafkaproducerApprec.send(match { it.value().apprecStatus == ApprecStatus.AVVIST }) + } + } + } } diff --git a/src/test/resources/sykemelding2013Regelsettversjon3gendatefremitid.xml b/src/test/resources/sykemelding2013Regelsettversjon3gendatefremitid.xml new file mode 100644 index 00000000..7818baed --- /dev/null +++ b/src/test/resources/sykemelding2013Regelsettversjon3gendatefremitid.xml @@ -0,0 +1,191 @@ + + + + + + v1.2 2006-05-24 + 9999-07-31T10:26:10 + 28e0d505-ee5b-40d7-8488-354eb25ca99d + + + + + Kule helsetjenester AS + + 1234634567 + + + + 223456789 + + + + 0123 + + +
+ + TESTVEIEN 1 + 1337 + SANDVIKA +
+ + Frost + Perma + Frida + + 1234356 + + + + 10987654321 + + + + 007778888 + + + + + + + +
+
+ + + + NAV IKT + + 1234556 + + + + 1234556 + + +
+ + Postboks 5 St Olavs plass + 0130 + OSLO +
+
+
+ + DUCK + ANDERS + DONALD + 1989-12-12 + + 12345678912 + + +
+ + Oppdiktet gate 32 + 1349 + RYKKINN +
+
+
+ + + + + + 3 + 2018-07-31 + + + DUCK + ANDERS + DONALD + + + 12345678912 + + + + + + Pridok As + Test Yrke Pasient 9 + 100 + + + + + + + + + 2018-07-31 + 2018-08-04 + + + + + + + + + + true + + + Test Ønsker Bistand + + + 2018-07-31T00:00:00+02:00 + + + + Frost + Frida + + + 10987654321 + + + + 123456 + + + + + + + + + + Flott EPJ + 1.0.0 + + 000210713120031072018040820160 + + + + + + + + + + + + + + QlR2pL73ef1VBxa0jRN3ECV6oi+RDGPP+8vETLlKjjU= + + + fdgljndfsgnjlljnfdgljndfgljnølnjcblvnxjnjlcbnjknjkbdfxnkjxcfkjnjdfnbluiseajdsjf + + + tersjndgfnjknjkdfgnjkdfgkndfsgnjkldfgkjndgfknjnjkfdgnm,m ,xvm,fjvcxjknjnkcvxjncvxjnxcvjkncxvjnkjkncvxjkfdgjkdfgjknjn + + + +
+ +