Skip to content

Commit

Permalink
R - Skiller ut egen metode for uthenting av krrperson
Browse files Browse the repository at this point in the history
Co-authored-by: Mariam Pervez <[email protected]>
  • Loading branch information
dskarpas and MariamPervez committed Nov 6, 2024
1 parent dec7ab1 commit 85b73d1
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions src/main/kotlin/no/nav/eessi/pensjon/prefill/PrefillService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,7 @@ class PrefillService(
try {
logger.info(" Buc:${request.buc}, sed: ${request.sed}, RinaID:${request.euxCaseId}, sed: ${request.documentid}, versjon: ${request.processDefinitionVersion}, gjenny: ${request.gjenny}")
val norskIdent = innhentingService.hentFnrEllerNpidFraAktoerService(request.aktoerId)!!
val krrPerson = krrService.hentPersonFraKrr(norskIdent).let { personResponse ->
KrrPerson(
reservert = personResponse.reservert,
epostadresse = personResponse.epostadresse.validateEmail(request.processDefinitionVersion),
mobiltelefonnummer = personResponse.mobiltelefonnummer
)
}

val personInfo = if (krrPerson.reservert == true) {
PersonInfo(norskIdent, request.aktoerId).also { logger.info("Personen har reservert seg mot digital kommunikasjon")}
} else {
PersonInfo(norskIdent, request.aktoerId, krrPerson.reservert, krrPerson.epostadresse, krrPerson.mobiltelefonnummer)
.also { logger.info("Hentet telefon og epost fra KRR: ${krrPerson.toJson()}") }
}
val personInfo = hentKrrPerson(norskIdent, request)

val prefillData = ApiRequest.buildPrefillDataModelOnExisting(request, personInfo, innhentingService.getAvdodAktoerIdPDL(request))

Expand Down Expand Up @@ -97,4 +84,31 @@ class PrefillService(
}
}

private fun hentKrrPerson(norskIdent: String, request: ApiRequest): PersonInfo {
val krrPerson = krrService.hentPersonFraKrr(norskIdent).let { personResponse ->
KrrPerson(
reservert = personResponse.reservert,
epostadresse = personResponse.epostadresse.validateEmail(request.processDefinitionVersion),
mobiltelefonnummer = personResponse.mobiltelefonnummer
)
}

val personInfo = if (krrPerson.reservert == true) {
PersonInfo(
norskIdent,
request.aktoerId
).also { logger.info("Personen har reservert seg mot digital kommunikasjon") }
} else {
PersonInfo(
norskIdent,
request.aktoerId,
krrPerson.reservert,
krrPerson.epostadresse,
krrPerson.mobiltelefonnummer
)
.also { logger.info("Hentet telefon og epost fra KRR: ${krrPerson.toJson()}") }
}
return personInfo
}

}

0 comments on commit 85b73d1

Please sign in to comment.