Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lagt til støtte for å kopiere journalpost #1117

Merged
merged 24 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bf1027d
WIP Støtte for å kopiere journalpost
albrektsson Feb 27, 2024
4e3d07c
Testjobb
albrektsson Feb 27, 2024
7e46415
Merge branch 'master' into kopierjournalpost
albrektsson Feb 27, 2024
793a400
Merge branch 'master' into kopierjournalpost
ramrock93 Sep 10, 2024
0cd3393
Fikser kopiering av journalpost
ramrock93 Sep 12, 2024
b7cf734
Refaktorerer ut krav for kopiering.
ramrock93 Sep 12, 2024
4e9b31a
Merge branch 'master' into kopierjournalpost
ramrock93 Sep 12, 2024
aeba051
Merge branch 'master' into kopierjournalpost
ramrock93 Sep 12, 2024
2a32b4f
Fjerner ubrukt felt.
ramrock93 Sep 12, 2024
49b5875
Fjerner rapid og ubrukte klasser.
ramrock93 Sep 12, 2024
4e7e2e5
Fikser circular reference.
ramrock93 Sep 12, 2024
c993a41
Lagrer journalpostkopi gjennom hendelseMottaker.
ramrock93 Sep 12, 2024
23d592e
Etterspørr datoOpprettet ved kall mot SAF.
ramrock93 Sep 12, 2024
24e5bab
Legger på TODO...
ramrock93 Sep 12, 2024
4bf1622
Fjerner konsumering fra punsjbolle topic.
ramrock93 Sep 12, 2024
19bcdb4
Fikser feilhåndtering ved kopiering av journalpost.
ramrock93 Sep 13, 2024
23d5137
Rydder opp kode
ramrock93 Sep 13, 2024
46d5f78
Merge branch 'master' into kopierjournalpost
ramrock93 Sep 13, 2024
e7af1c7
Merge branch 'master' into kopierjournalpost
ramrock93 Sep 17, 2024
14364d3
Bruker enum for string verdier.
ramrock93 Sep 17, 2024
d3fb32e
Fjerner ubrukt variabel.
ramrock93 Sep 17, 2024
d4472a0
Bruker enum for string verdier.
ramrock93 Sep 17, 2024
88e83ff
Forenkler logikk.
ramrock93 Sep 17, 2024
99f748d
Returnerer mer detaljert respons ved kopiering av JP.
ramrock93 Sep 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions nais/dev-fss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ spec:
value: api://dev-fss.teamdokumenthandtering.dokarkiv-q1/.default

# Integrasjoner (Kafka)
- name: K9_RAPID_TOPIC
value: "omsorgspenger.k9-rapid-v2"
- name: SEND_AKSJONSPUNKTHENDELSE_TIL_K9LOS
value: "k9saksbehandling.punsj-aksjonspunkthendelse-v1"
- name: SEND_BREVBESTILLING_TIL_K9_FORMIDLING
Expand All @@ -156,8 +154,6 @@ spec:
value: "k9saksbehandling.k9-punsj-til-los"
- name: K9_FORDEL_TOPIC
value: "k9saksbehandling.fordel-journalforing"
- name: K9_PUNSJBOLLE_TOPIC
value: "k9saksbehandling.punsjbar-journalpost"

# Div
- name: SETT_PAA_VENT_TID
Expand Down
4 changes: 0 additions & 4 deletions nais/prod-fss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ spec:
value: api://prod-fss.teamdokumenthandtering.dokarkiv/.default

# Integrasjoner (Kafka)
- name: K9_RAPID_TOPIC
value: "omsorgspenger.k9-rapid-v2"
- name: SEND_AKSJONSPUNKTHENDELSE_TIL_K9LOS
value: "k9saksbehandling.punsj-aksjonspunkthendelse-v1"
- name: SEND_BREVBESTILLING_TIL_K9_FORMIDLING
Expand All @@ -149,8 +147,6 @@ spec:
value: "k9saksbehandling.k9-punsj-til-los"
- name: K9_FORDEL_TOPIC
value: "k9saksbehandling.fordel-journalforing"
- name: K9_PUNSJBOLLE_TOPIC
value: "k9saksbehandling.punsjbar-journalpost"

# Feature toggles
- name: FERDIGSTILL_GOSYSOPPGAVE_ENABLED
Expand Down
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
<k9-sak.version>4.2.0</k9-sak.version>
<k9-formidling.version>10.1.0</k9-formidling.version>
<k9-format.version>9.5.2</k9-format.version>
<k9-rapid.version>1.20240510083323-9f05ca1</k9-rapid.version>

<!-- database -->
<postgresql.version>42.7.4</postgresql.version>
Expand Down Expand Up @@ -126,11 +125,6 @@
<artifactId>soknad</artifactId>
<version>${k9-format.version}</version>
</dependency>
<dependency>
<groupId>no.nav.k9.rapid</groupId>
<artifactId>behov</artifactId>
<version>${k9-rapid.version}</version>
</dependency>

<!-- kotlin -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class SoknadService(

val journalposter = safGateway.hentJournalposter(journalpostIdListe)
val journalposterMedTypeUtgaaende = journalposter.filterNotNull()
.filter { it.journalposttype == SafDtos.JournalpostType.U.toString() }
.filter { it.journalposttype == SafDtos.JournalpostType.UTGAAENDE.kode }
.map { it.journalpostId }
.toSet()
if (journalposterMedTypeUtgaaende.isNotEmpty()) {
Expand Down Expand Up @@ -339,7 +339,7 @@ class SoknadService(
private suspend fun hentOgSjekkJournalpostene(journalpostIdListe: List<String>): Pair<List<SafDtos.Journalpost?>, Set<String>> {
val journalposter = safGateway.hentJournalposter(journalpostIdListe)
val journalposterMedTypeUtgaaende = journalposter.filterNotNull()
.filter { it.journalposttype == SafDtos.JournalpostType.U.toString() }
.filter { it.journalposttype == SafDtos.JournalpostType.UTGAAENDE.kode }
.map { it.journalpostId }
.toSet()
return Pair(journalposter, journalposterMedTypeUtgaaende)
Expand Down
12 changes: 12 additions & 0 deletions src/main/kotlin/no/nav/k9punsj/felles/PunsjFagsakYtelseType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,17 @@ enum class PunsjFagsakYtelseType(@JsonValue val kode: String, val navn: String,
fun fraNavn(navn: String): PunsjFagsakYtelseType {
return values().firstOrNull { it.name == navn } ?: UDEFINERT
}

fun FagsakYtelseType.somPunsjFagsakYtelseType(): PunsjFagsakYtelseType = when(this) {
FagsakYtelseType.PLEIEPENGER_SYKT_BARN -> PLEIEPENGER_SYKT_BARN
FagsakYtelseType.PLEIEPENGER_NÆRSTÅENDE -> PLEIEPENGER_LIVETS_SLUTTFASE
FagsakYtelseType.OMSORGSPENGER -> OMSORGSPENGER
FagsakYtelseType.OMSORGSPENGER_KS -> OMSORGSPENGER_KRONISK_SYKT_BARN
FagsakYtelseType.OMSORGSPENGER_MA -> OMSORGSPENGER_MIDLERTIDIG_ALENE
FagsakYtelseType.OMSORGSPENGER_AO -> OMSORGSPENGER_ALENE_OMSORGEN
FagsakYtelseType.OPPLÆRINGSPENGER -> OPPLÆRINGSPENGER
FagsakYtelseType.UDEFINERT -> UKJENT
else -> throw IllegalStateException("Ikke støttet fagsakytelsetype: $this")
}
}
}
69 changes: 0 additions & 69 deletions src/main/kotlin/no/nav/k9punsj/innsending/InnsendingClient.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.stereotype.Service
import org.springframework.web.reactive.function.BodyInserters
import org.springframework.web.reactive.function.client.ClientResponse
import org.springframework.web.reactive.function.client.ExchangeStrategies
import org.springframework.web.reactive.function.client.WebClient
import org.springframework.web.reactive.function.client.toEntity
import java.net.URI
import java.util.*
import kotlin.coroutines.coroutineContext
Expand Down Expand Up @@ -208,6 +206,56 @@ class DokarkivGateway(
}
}

internal suspend fun knyttTilAnnenSak(
journalpostId: JournalpostId,
identitetsnummer: Identitetsnummer,
saksnummer: String
): JournalpostId {
val accessToken = cachedAccessTokenClient
.getAccessToken(
scopes = dokarkivScope,
onBehalfOf = coroutineContext.hentAuthentication().accessToken
)

@Language("JSON")
val dto = """
ramrock93 marked this conversation as resolved.
Show resolved Hide resolved
{
"sakstype": "${SafDtos.Sakstype.FAGSAK}",
"fagsaksystem": "${FagsakSystem.K9}",
"fagsakId": "$saksnummer",
"journalfoerendeEnhet": "9999",
espenjv marked this conversation as resolved.
Show resolved Hide resolved
"tema": "${Tema.OMS}",
"bruker": {
"idType": "${IdType.FNR}",
"id": "$identitetsnummer"
}
}
""".trimIndent()
val body = BodyInserters.fromValue(dto)
val url = URI.create(knyttTilAnnenSakUrl(journalpostId))

val response = client
.put()
.uri(url)
.header(ConsumerIdHeaderKey, ConsumerIdHeaderValue)
.header(CorrelationIdHeader, coroutineContext.hentCorrelationId())
.header(HttpHeaders.AUTHORIZATION, accessToken.asAuthoriationHeader())
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.body(body)
.retrieve()
.toEntity(String::class.java)
.awaitFirst()

check(response.statusCode.is2xxSuccessful) {
"Feil ved kopiering av journalpost. HttpStatus=[${response.statusCode.value()}, Response=[${response.body}], Url=[$url]"
}

val nyJournalpostId = JSONObject(response.body).get("nyJournalpostId").toString().somJournalpostId()

return nyJournalpostId
}

private companion object {
private val logger: Logger = LoggerFactory.getLogger(DokarkivGateway::class.java)
private const val ConsumerIdHeaderKey = "Nav-Consumer-Id"
Expand All @@ -233,6 +281,8 @@ class DokarkivGateway(
private fun String.oppdaterJournalpostUrl() = "$baseUrl/rest/journalpostapi/v1/journalpost/$this"
private val opprettOgFerdigstillJournalpostUrl = "$baseUrl/rest/journalpostapi/v1/journalpost?forsoekFerdigstill=true"
private fun String.ferdigstillJournalpostUrl() = "$baseUrl/rest/journalpostapi/v1/journalpost/$this/ferdigstill"
private fun knyttTilAnnenSakUrl(journalpostId: JournalpostId) =
"$baseUrl/rest/journalpostapi/v1/journalpost/$journalpostId/knyttTilAnnenSak"

private fun JSONObject.stringOrNull(key: String) = when (notNullNotBlankString(key)) {
true -> getString(key)
Expand Down Expand Up @@ -371,6 +421,7 @@ data class JournalPostRequest(
}

enum class Tema { OMS }
enum class IdType { FNR }
enum class JournalpostType { NOTAT }
enum class DokumentKategori { IS }
enum class FagsakSystem { K9 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal object SafDtos {
tema
tittel
journalposttype
datoOpprettet
relevanteDatoer {
dato
datotype
Expand Down Expand Up @@ -89,8 +90,8 @@ internal object SafDtos {
OMS
}

enum class JournalpostType {
I, N, U
enum class JournalpostType(val kode: String) {
INNGAAENDE("I"), NOTAT("N"), UTGAAENDE("U")
}

internal enum class AvsenderType {
Expand All @@ -117,6 +118,9 @@ internal object SafDtos {
GENERELL_SAK, FAGSAK
}

internal enum class K9Type { SØKNAD, ETTERSENDELSE }
internal enum class K9Kilde { DIGITAL }

internal data class Bruker(
val id: String?,
val type: String?
Expand Down Expand Up @@ -164,18 +168,24 @@ internal object SafDtos {
val avsenderMottaker: AvsenderMottaker?,
val dokumenter: List<Dokument>,
val relevanteDatoer: List<RelevantDato>,
val datoOpprettet: LocalDateTime,
private val tilleggsopplysninger: List<Tilleggsopplysning> = emptyList()
) {
val k9Kilde = tilleggsopplysninger.firstOrNull { it.nokkel == "k9.kilde" }?.verdi
val k9Type = tilleggsopplysninger.firstOrNull { it.nokkel == "k9.type" }?.verdi
private val erDigital = "DIGITAL" == k9Kilde
private val erEttersendelse = "ETTERSENDELSE" == k9Type
private val erSøknad = "SØKNAD" == k9Type
val erUtgående = journalposttype == JournalpostType.UTGAAENDE.kode
private val erDigital = K9Kilde.DIGITAL.name == k9Kilde
val erEttersendelse = K9Type.ETTERSENDELSE.name == k9Type
private val erSøknad = K9Type.SØKNAD.name == k9Type
val erIkkeStøttetDigitalJournalpost = when (erDigital) {
true -> !(erEttersendelse || erSøknad)
false -> false
}
val ikkeErTemaOMS = tema?.let { Tema.OMS.name != it } ?: false

private val erInngående = journalposttype == JournalpostType.INNGAAENDE.kode
private val erNotat = journalposttype == JournalpostType.NOTAT.kode
internal val kanKopieres = erInngående || erNotat
}

internal data class Tilleggsopplysning(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class SafGateway(
}

// Kan ikke oppdatere eller ferdigstille Notater som er under redigering.
if (journalpost?.journalposttype == "N" &&
if (journalpost?.journalposttype == SafDtos.JournalpostType.NOTAT.kode &&
journalpost.journalstatus?.equals("UNDER_ARBEID") == true
) throw NotatUnderArbeidFeil().also {
logger.warn("Ikke støttet journalpost: Type NOTAT med status UNDER_ARBEID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal class GosysService(
?: return ServerResponse.status(HttpStatus.NOT_FOUND).buildAndAwait()
.also { logger.warn("Kunne ikke finne journalpost med id {}", oppgaveRequest.journalpostId) }

if (!(journalpostInfo.journalpostType == SafDtos.JournalpostType.I.name
if (!(journalpostInfo.journalpostType == SafDtos.JournalpostType.INNGAAENDE.kode
&& journalpostInfo.journalpostStatus == SafDtos.Journalstatus.MOTTATT.name)
) {
logger.warn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import no.nav.k9punsj.felles.dto.PeriodeDto
import no.nav.k9punsj.felles.dto.SaksnummerDto
import no.nav.k9punsj.felles.dto.SøknadEntitet
import no.nav.k9punsj.integrasjoner.k9sak.dto.Fagsak
import no.nav.k9punsj.integrasjoner.k9sak.dto.HentK9SaksnummerGrunnlag
import no.nav.k9punsj.integrasjoner.k9sak.dto.ReservertSaksnummerDto
import no.nav.k9punsj.integrasjoner.k9sak.dto.ReserverSaksnummerDto

Expand Down Expand Up @@ -42,6 +43,10 @@ interface K9SakService {
punsjFagsakYtelseType: PunsjFagsakYtelseType
): Pair<String?, String?>

suspend fun hentEllerOpprettSaksnummer(
hentK9SaksnummerGrunnlag: HentK9SaksnummerGrunnlag
): String

suspend fun sendInnSoeknad(
soknad: Søknad,
journalpostId: String,
Expand Down
Loading