Skip to content

Commit

Permalink
Avvis sykmelding if gendate is before current date
Browse files Browse the repository at this point in the history
  • Loading branch information
MikAoJk committed Aug 23, 2023
1 parent eac826e commit 78038b7
Show file tree
Hide file tree
Showing 4 changed files with 268 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -259,15 +261,15 @@ class BlockingApplicationRunner(
val identer =
pdlPersonService.getIdenter(
listOf(signaturFnr, originaltPasientFnr),
loggingMeta
loggingMeta,
)

val tssIdEmottak =
smtssClient.findBestTssIdEmottak(
signaturFnr,
legekontorOrgName,
loggingMeta,
sykmeldingId
sykmeldingId,
)
val tssIdInfotrygd =
if (!tssIdEmottak.isNullOrEmpty()) {
Expand All @@ -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(
Expand Down Expand Up @@ -355,7 +357,7 @@ class BlockingApplicationRunner(
val signerendeBehandler =
norskHelsenettClient.getByFnr(
fnr = signaturFnr,
loggingMeta = loggingMeta
loggingMeta = loggingMeta,
)

val behandlenedeBehandler =
Expand Down Expand Up @@ -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<String> =
if (vedlegg.isNotEmpty()) {
bucketUploadService.lastOppVedlegg(
Expand All @@ -459,7 +476,7 @@ class BlockingApplicationRunner(
personNrPasient = pasient.fnr!!,
tlfPasient =
extractTlfFromKontaktInfo(
healthInformation.pasient.kontaktInfo
healthInformation.pasient.kontaktInfo,
),
personNrLege = signaturFnr,
navLogId = ediLoggId,
Expand Down Expand Up @@ -499,7 +516,7 @@ class BlockingApplicationRunner(
val validationResult =
syfoSykemeldingRuleClient.executeRuleValidation(
receivedSykmelding,
loggingMeta
loggingMeta,
)

when (validationResult.status) {
Expand Down
31 changes: 31 additions & 0 deletions src/main/kotlin/no/nav/syfo/handlestatus/HandleStatusInvalid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Apprec>,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextMessage>(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 })
}
}
}
}
191 changes: 191 additions & 0 deletions src/test/resources/sykemelding2013Regelsettversjon3gendatefremitid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<?xml version="1.0" encoding="UTF-8"?>
<EI_fellesformat xmlns="http://www.trygdeetaten.no/xml/eiff/1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsgHead xmlns="http://www.kith.no/xmlstds/msghead/2006-05-24" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<MsgInfo>
<Type DN="Medisinsk vurdering av arbeidsmulighet ved sykdom, sykmelding" V="SYKMELD" />
<MIGversion>v1.2 2006-05-24</MIGversion>
<GenDate>9999-07-31T10:26:10</GenDate>
<MsgId>28e0d505-ee5b-40d7-8488-354eb25ca99d</MsgId>
<Ack DN="Ja" V="J" />
<Sender>
<ComMethod DN="EDI" V="EDI" />
<Organisation>
<OrganisationName>Kule helsetjenester AS</OrganisationName>
<Ident>
<Id>1234634567</Id>
<TypeId DN="HER-id" S="2.16.578.1.12.4.1.1.9051" V="HER" />
</Ident>
<Ident>
<Id>223456789</Id>
<TypeId DN="Organisasjonsnummeret i Enhetsregister (Brønnøysund)" S="1.16.578.1.12.3.1.1.9051" V="ENH" />
</Ident>
<Ident>
<Id>0123</Id>
<TypeId DN="Identifikator fra Helsetjenesteenhetsregisteret (HER-id)" V="HER" S="1.23.456.7.89.1.2.3.4567.8912" />
</Ident>
<Address>
<Type DN="Postadresse" V="PST" />
<StreetAdr>TESTVEIEN 1</StreetAdr>
<PostalCode>1337</PostalCode>
<City>SANDVIKA</City>
</Address>
<HealthcareProfessional>
<FamilyName>Frost</FamilyName>
<MiddleName>Perma</MiddleName>
<GivenName>Frida</GivenName>
<Ident>
<Id>1234356</Id>
<TypeId DN="HER-id" S="2.16.578.1.12.4.1.1.8268" V="HER" />
</Ident>
<Ident>
<Id>10987654321</Id>
<TypeId DN="Fødselsnummer" S="2.16.578.1.12.4.1.1.8327" V="FNR" />
</Ident>
<Ident>
<Id>007778888</Id>
<TypeId DN="HPR-nummer" S="6.87.654.3.21.9.8.7.6543.2198" V="HPR" />
</Ident>
<TeleCom>
<TypeTelecom DN="Arbeidsplass, direktenummer" V="WD" />
<TeleAddress V="tel:33333333" />
</TeleCom>
</HealthcareProfessional>
</Organisation>
</Sender>
<Receiver>
<ComMethod DN="EDI" V="EDI" />
<Organisation>
<OrganisationName>NAV IKT</OrganisationName>
<Ident>
<Id>1234556</Id>
<TypeId DN="HER-id" S="2.16.578.1.12.4.1.1.9051" V="HER" />
</Ident>
<Ident>
<Id>1234556</Id>
<TypeId DN="Identifikator fra Helsetjenesteenhetsregisteret" S="1.23.456.7.89.1.2.3.4567.8912" V="HER" />
</Ident>
<Address>
<Type DN="Postadresse" V="PST" />
<StreetAdr>Postboks 5 St Olavs plass</StreetAdr>
<PostalCode>0130</PostalCode>
<City>OSLO</City>
</Address>
</Organisation>
</Receiver>
<Patient>
<FamilyName>DUCK</FamilyName>
<MiddleName>ANDERS</MiddleName>
<GivenName>DONALD</GivenName>
<DateOfBirth>1989-12-12</DateOfBirth>
<Ident>
<Id>12345678912</Id>
<TypeId DN="Fødselsnummer" S="2.16.578.1.12.4.1.1.8327" V="FNR" />
</Ident>
<Address>
<Type DN="Postadresse" V="PST" />
<StreetAdr>Oppdiktet gate 32</StreetAdr>
<PostalCode>1349</PostalCode>
<City>RYKKINN</City>
</Address>
</Patient>
</MsgInfo>
<Document>
<RefDoc>
<MsgType DN="XML-instans" V="XML" />
<Content>
<HelseOpplysningerArbeidsuforhet xmlns="http://www.kith.no/xmlstds/HelseOpplysningerArbeidsuforhet/2013-10-01">
<RegelSettVersjon>3</RegelSettVersjon>
<SyketilfelleStartDato>2018-07-31</SyketilfelleStartDato>
<Pasient>
<Navn>
<Etternavn>DUCK</Etternavn>
<Mellomnavn>ANDERS</Mellomnavn>
<Fornavn>DONALD</Fornavn>
</Navn>
<Fodselsnummer>
<Id xmlns="http://www.kith.no/xmlstds/felleskomponent1">12345678912</Id>
<TypeId xmlns="http://www.kith.no/xmlstds/felleskomponent1" DN="Fødselsnummer" S="2.16.578.1.12.4.1.1.8116" V="FNR" />
</Fodselsnummer>
</Pasient>
<Arbeidsgiver>
<HarArbeidsgiver DN="Én arbeidsgiver" V="1" />
<NavnArbeidsgiver>Pridok As</NavnArbeidsgiver>
<Yrkesbetegnelse>Test Yrke Pasient 9</Yrkesbetegnelse>
<Stillingsprosent>100</Stillingsprosent>
</Arbeidsgiver>
<MedisinskVurdering>
<HovedDiagnose>
<Diagnosekode DN="Luftveissykdom IKA" S="2.16.578.1.12.4.1.1.7170" V="R99" />
</HovedDiagnose>
</MedisinskVurdering>
<Aktivitet>
<Periode>
<PeriodeFOMDato>2018-07-31</PeriodeFOMDato>
<PeriodeTOMDato>2018-08-04</PeriodeTOMDato>
<AktivitetIkkeMulig>
<MedisinskeArsaker>
<Arsakskode DN="Helsetilstanden hindrer pasienten i å være i aktivitet" V="1" />
</MedisinskeArsaker>
<Arbeidsplassen />
</AktivitetIkkeMulig>
</Periode>
</Aktivitet>
<Prognose>
<ArbeidsforEtterEndtPeriode>true</ArbeidsforEtterEndtPeriode>
</Prognose>
<MeldingTilNav>
<BeskrivBistandNAV>Test Ønsker Bistand</BeskrivBistandNAV>
</MeldingTilNav>
<KontaktMedPasient>
<BehandletDato>2018-07-31T00:00:00+02:00</BehandletDato>
</KontaktMedPasient>
<Behandler>
<Navn>
<Etternavn>Frost</Etternavn>
<Fornavn>Frida</Fornavn>
</Navn>
<Id>
<Id xmlns="http://www.kith.no/xmlstds/felleskomponent1">10987654321</Id>
<TypeId xmlns="http://www.kith.no/xmlstds/felleskomponent1" DN="Fødselsnummer" S="2.16.578.1.12.4.1.1.8116" V="FNR" />
</Id>
<Id>
<Id xmlns="http://www.kith.no/xmlstds/felleskomponent1">123456</Id>
<TypeId xmlns="http://www.kith.no/xmlstds/felleskomponent1" DN="HER-id" S="2.16.578.1.12.4.1.1.8116" V="HER" />
</Id>
<Adresse />
<KontaktInfo>
<TypeTelecom xmlns="http://www.kith.no/xmlstds/felleskomponent1" DN="Hovedtelefon" V="HP" />
<TeleAddress xmlns="http://www.kith.no/xmlstds/felleskomponent1" V="tel:33333333" />
</KontaktInfo>
</Behandler>
<AvsenderSystem>
<SystemNavn>Flott EPJ</SystemNavn>
<SystemVersjon>1.0.0</SystemVersjon>
</AvsenderSystem>
<Strekkode>000210713120031072018040820160</Strekkode>
</HelseOpplysningerArbeidsuforhet>
</Content>
</RefDoc>
</Document>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" />
<DigestValue>QlR2pL73ef1VBxa0jRN3ECV6oi+RDGPP+8vETLlKjjU=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>fdgljndfsgnjlljnfdgljndfgljnølnjcblvnxjnjlcbnjknjkbdfxnkjxcfkjnjdfnbluiseajdsjf</SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate>tersjndgfnjknjkdfgnjkdfgkndfsgnjkldfgkjndgfknjnjkfdgnm,m ,xvm,fjvcxjknjnkcvxjncvxjnxcvjkncxvjnkjkncvxjkfdgjkdfgjknjn</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</MsgHead>
<MottakenhetBlokk avsender="10987654321" avsenderFnrFraDigSignatur="10987654321" avsenderRef="SERIALNUMBER=2134125125, CN=TEST-Flott, OU=R&amp;D, O=Flott AS, C=NO" ebAction="Registrering" ebRole="Sykmelder" ebService="Sykmelding" ebXMLSamtaleId="deb6d7d1-139c-4885-aa22-b9362de06205" ediLoggId="1807311226joakim51343.1" herIdentifikator="" meldingsType="xml" mottattDatotid="2018-07-31T12:26:26" partnerReferanse="16524" />
</EI_fellesformat>

0 comments on commit 78038b7

Please sign in to comment.