Skip to content

Commit

Permalink
Update person status handling in services
Browse files Browse the repository at this point in the history
#deploy-test-pdl-forvalter

Added handling for `FolkeregisterPersonstatus` and its validation dates in `SwopIdentsService`, `PersonArtifactService`, and `FolkeregisterPersonstatusService`. Enhanced `FolkeregisterPersonstatusService` to set `GyldigFraOgMed` based on derived dates from residence address or birth date.
  • Loading branch information
krharum committed Sep 26, 2024
1 parent 4d96160 commit 8848ca9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private FolkeregisterPersonstatusDTO handle(FolkeregisterPersonstatusDTO persons

if (isNotCurrentStatus(MIDLERTIDIG, person)) {
personstatus.setStatus(MIDLERTIDIG);
personstatus.setGyldigFraOgMed(FoedselsdatoUtility.getFoedselsdato(person));
}
return personstatus;

Expand All @@ -146,25 +147,22 @@ private FolkeregisterPersonstatusDTO handle(FolkeregisterPersonstatusDTO persons

if (isNotCurrentStatus(IKKE_BOSATT, person)) {
personstatus.setStatus(IKKE_BOSATT);
personstatus.setGyldigFraOgMed(getBoadresseGyldigFraDato(person));
}

} else if (nonNull(person.getBostedsadresse().getFirst().getUkjentBosted())) {

if (isNotCurrentStatus(FOEDSELSREGISTRERT, person)) {
personstatus.setStatus(FOEDSELSREGISTRERT);
personstatus.setGyldigFraOgMed(getBoadresseGyldigFraDato(person));
}

} else if (isNotCurrentStatus(BOSATT, person)) {

personstatus.setStatus(BOSATT);
personstatus.setGyldigFraOgMed(getBoadresseGyldigFraDato(person));
}

personstatus.setGyldigFraOgMed(person.getBostedsadresse().stream()
.map(BostedadresseDTO::getGyldigFraOgMed)
.filter(Objects::nonNull)
.findFirst()
.orElse(FoedselsdatoUtility.getFoedselsdato(person)));

return personstatus;

} else if (isNotCurrentStatus(FOEDSELSREGISTRERT, person)) {
Expand All @@ -188,10 +186,19 @@ public void validate(FolkeregisterPersonstatusDTO artifact, PersonDTO person) {
// Ingen validering
}

private void setGyldigTilOgMed(List<FolkeregisterPersonstatusDTO> folkeregisterPersonstatus) {
private static LocalDateTime getBoadresseGyldigFraDato(PersonDTO person) {

return person.getBostedsadresse().stream()
.map(BostedadresseDTO::getGyldigFraOgMed)
.filter(Objects::nonNull)
.findFirst()
.orElse(FoedselsdatoUtility.getFoedselsdato(person));
}

private static void setGyldigTilOgMed(List<FolkeregisterPersonstatusDTO> folkeregisterPersonstatus) {

for (var i = 0; i < folkeregisterPersonstatus.size(); i++) {
if (i + 1 < folkeregisterPersonstatus.size()) {
if (i + 1 < folkeregisterPersonstatus.size() && nonNull(folkeregisterPersonstatus.get(i).getGyldigFraOgMed())) {
folkeregisterPersonstatus.get(i + 1)
.setGyldigTilOgMed(folkeregisterPersonstatus.get(i).getGyldigFraOgMed().minusDays(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ public PersonDTO buildPerson(PersonDTO person, Boolean relaxed) {
person.setDoedfoedtBarn(doedfoedtBarnService.convert(person.getDoedfoedtBarn()));
person.setSikkerhetstiltak(sikkerhetstiltakService.convert(person));
person.setNavPersonIdentifikator(navPersonIdentifikatorService.convert(person));
person.setFolkeregisterPersonstatus(folkeregisterPersonstatusService.convert(person));

person = identtypeService.convert(person);

person.setFolkeregisterPersonstatus(folkeregisterPersonstatusService.convert(person));

return person;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private void swopOpplysninger(DbPerson person1, DbPerson person2) {
person1.getPerson().getInnflytting().addAll(person2.getPerson().getInnflytting());
person1.getPerson().setAdressebeskyttelse(person2.getPerson().getAdressebeskyttelse());
person1.getPerson().setNavPersonIdentifikator(person2.getPerson().getNavPersonIdentifikator());
person1.getPerson().setFolkeregisterPersonstatus(person2.getPerson().getFolkeregisterPersonstatus());

if (person1.getPerson().isStrengtFortrolig() || person2.getPerson().isStrengtFortrolig()) {
person1.getPerson().setBostedsadresse(null);
Expand Down

0 comments on commit 8848ca9

Please sign in to comment.