Skip to content

Commit

Permalink
B - Retter Apirequest etter oppdatering av PersonInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
dskarpas committed Nov 1, 2024
1 parent 4ca6ee5 commit af14f56
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/kotlin/no/nav/eessi/pensjon/shared/api/ApiRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
private val logger = LoggerFactory.getLogger(ApiRequest::class.java)

//validatate request and convert to PrefillDataModel
fun buildPrefillDataModelOnExisting(request: ApiRequest, fodselsnr: String, avdodaktoerID: String? = null): PrefillDataModel {
fun buildPrefillDataModelOnExisting(request: ApiRequest, personInfo: PersonInfo, avdodaktoerID: String? = null): PrefillDataModel {
logger.debug("*** apirequest: $request ***")
val sedType = if (request.sed == null)
throw ResponseStatusException(HttpStatus.BAD_REQUEST,"SedType mangler")
Expand All @@ -87,7 +87,7 @@
logger.info("ALL SED on existing Rina SED: ${request.sed} -> euxCaseId: ${request.euxCaseId} -> sakNr: ${request.sakId} ")
PrefillDataModel(
penSaksnummer = request.sakId,
bruker = PersonId(fodselsnr, request.aktoerId).also { logger.debug("FNR eller NPID: ${it.norskIdent}") },
bruker = personInfo.also { logger.debug("FNR eller NPID: ${it.norskIdent}") },
avdod = populerAvdodHvisGjenlevendePensjonSak(request, avdodaktoerID),
sedType = sedType,
buc = request.buc,
Expand All @@ -105,25 +105,24 @@
}
}

private fun populerAvdodHvisGjenlevendePensjonSak(request: ApiRequest, avdodaktoerID: String?): PersonId? {
private fun populerAvdodHvisGjenlevendePensjonSak(request: ApiRequest, avdodaktoerID: String?): PersonInfo? {
return when(request.buc) {
P_BUC_02 -> populerAvdodPersonId(request, avdodaktoerID, true)
P_BUC_05,P_BUC_06,P_BUC_10 -> populerAvdodPersonId(request, avdodaktoerID)
else -> null
}
}

private fun populerAvdodPersonId(request: ApiRequest, avdodaktoerID: String?, kreverAvdod: Boolean = false): PersonId? {
private fun populerAvdodPersonId(request: ApiRequest, avdodaktoerID: String?, kreverAvdod: Boolean = false): PersonInfo? {
if (kreverAvdod && avdodaktoerID == null) {
logger.error("Mangler fnr for avdød")
throw ResponseStatusException(HttpStatus.BAD_REQUEST,"Mangler fnr for avdød")
}
request.riktigAvdod() ?: return null
val avdodNorskIdent1 = request.riktigAvdod() ?: throw ResponseStatusException(HttpStatus.BAD_REQUEST,"Mangler Personnr på Avdød")
val avdodAktorId1 = avdodaktoerID ?: throw ResponseStatusException(HttpStatus.BAD_REQUEST,"Mangler AktoerId på Avdød")
return PersonId(avdodNorskIdent1, avdodAktorId1)
return PersonInfo(avdodNorskIdent1, avdodAktorId1)
}

}
}

Expand Down

0 comments on commit af14f56

Please sign in to comment.