Skip to content

Commit

Permalink
IS-2403: Oppdatere behandlere fra AR
Browse files Browse the repository at this point in the history
  • Loading branch information
geir-waagboe committed Aug 2, 2024
1 parent c203882 commit d6b06fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 6 additions & 7 deletions src/main/kotlin/no/nav/syfo/behandler/BehandlerService.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package no.nav.syfo.behandler

import no.nav.syfo.application.database.DatabaseInterface
import no.nav.syfo.behandler.api.behandlerPersonident
import no.nav.syfo.behandler.database.*
import no.nav.syfo.behandler.database.domain.*
import no.nav.syfo.behandler.domain.*
Expand Down Expand Up @@ -194,7 +193,7 @@ class BehandlerService(
relasjonstype = relasjonstype,
)
} else {
updateBehandler(
updateBehandlerTelefon(
behandler = behandler,
existingBehandler = pBehandler,
)
Expand Down Expand Up @@ -282,7 +281,7 @@ class BehandlerService(
mellomnavn = mellomnavn,
etternavn = etternavn,
kategori = kategori,
herId,
herId = herId,
)
}

Expand Down Expand Up @@ -335,7 +334,7 @@ class BehandlerService(
database.connection.use { connection ->
val pBehandlerKontor = connection.getBehandlerKontor(behandler.kontor.partnerId)
val kontorId = if (pBehandlerKontor != null) {
connection.updateBehandlerKontor(
connection.updateBehandlerKontorSystemAndAdresse(
behandler = behandler,
existingBehandler = null,
existingBehandlerKontor = pBehandlerKontor,
Expand All @@ -361,7 +360,7 @@ class BehandlerService(
}
}

private fun updateBehandler(
private fun updateBehandlerTelefon(
behandler: Behandler,
existingBehandler: PBehandler,
) {
Expand All @@ -374,7 +373,7 @@ class BehandlerService(
COUNT_BEHANDLER_UPDATED.increment()
}
val existingBehandlerKontor = connection.getBehandlerKontor(behandler.kontor.partnerId)!!
connection.updateBehandlerKontor(
connection.updateBehandlerKontorSystemAndAdresse(
behandler = behandler,
existingBehandler = existingBehandler,
existingBehandlerKontor = existingBehandlerKontor,
Expand All @@ -383,7 +382,7 @@ class BehandlerService(
}
}

private fun Connection.updateBehandlerKontor(
private fun Connection.updateBehandlerKontorSystemAndAdresse(
behandler: Behandler,
existingBehandler: PBehandler?,
existingBehandlerKontor: PBehandlerKontor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class VerifyBehandlereForKontorCronjob(
aktiveBehandlereForKontor,
behandlerService.getBehandlereForKontor(behandlerKontor).filter { it.invalidated == null },
)

// TODO: Hvis finnes fra før: oppdatere behandlerforekomst med info fra Adresseregisteret/HPR: navn, herId, behandlerKategori
}
} else {
log.warn("VerifyBehandlereForKontorCronjob: Behandlerkontor mer herId ${behandlerKontor.herId} ble ikke funnet i Adresseregisteret")
Expand Down Expand Up @@ -293,7 +291,7 @@ class VerifyBehandlereForKontorCronjob(
it.hprId == behandlerFraAdresseregisteretHprId
}
if (existingBehandlereWithSameHprId.size != 1) {
log.warn("VerifyBehandlereForKontorCronjob: Expected to find exactly one behandler: ${existingBehandlereWithSameHprId.first().behandlerRef}")
log.warn("VerifyBehandlereForKontorCronjob: Expected to find exactly one behandler: ${existingBehandlereWithSameHprId.firstOrNull()?.behandlerRef}")
} else {
val existingBehandler = existingBehandlereWithSameHprId[0]
val hprBehandlerFnr = syfohelsenettproxyClient.finnBehandlerFraHpr(behandlerFraAdresseregisteretHprId)?.fnr
Expand Down

0 comments on commit d6b06fe

Please sign in to comment.