From ccff4aba79d3b509a2db570dceff8a77b888d1ef Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Fri, 8 Mar 2024 08:50:10 +0100 Subject: [PATCH] Update endpoints and add LandkodeEncoder class in tpsmessagingservice #deploy-tps-messaging-service Redesigned endpoints for personhistorikk and doedsmelding to receive request body instead of path variables. Also introduced a new utility class LandkodeEncoder to manage land code. Additionally, several import statements were adjusted to suit the current system configuration. --- .../provider/v1/PersonController.java | 18 +- .../service/AdressehistorikkService.java | 21 +- .../service/DoedsmeldingService.java | 17 +- .../service/FoedselsmeldingService.java | 4 +- .../service/skd/AdresseAppenderService.java | 70 ++-- ...DoedsmeldingAnnulleringBuilderService.java | 2 +- .../skd/DoedsmeldingBuilderService.java | 16 +- .../skd/FoedselsmeldingBuilderService.java | 29 +- .../service/skd/SendSkdMeldinger.java | 4 +- .../utils/LandkodeEncoder.java | 302 ++++++++++++++++++ .../v1/AdressehistorikkDTO.java | 1 + .../v1/AdressehistorikkRequest.java | 18 ++ .../v1/DoedsmeldingRequest.java | 18 ++ .../v1/FoedselsmeldingRequest.java | 1 - 14 files changed, 435 insertions(+), 86 deletions(-) create mode 100644 apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/utils/LandkodeEncoder.java create mode 100644 libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/AdressehistorikkRequest.java create mode 100644 libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/DoedsmeldingRequest.java diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/provider/v1/PersonController.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/provider/v1/PersonController.java index ab57ba063c5..1e3a068ce47 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/provider/v1/PersonController.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/provider/v1/PersonController.java @@ -12,11 +12,13 @@ import no.nav.testnav.apps.tpsmessagingservice.service.SpraakService; import no.nav.testnav.libs.data.kontoregister.v1.BankkontonrNorskDTO; import no.nav.testnav.libs.data.kontoregister.v1.BankkontonrUtlandDTO; -import no.nav.testnav.libs.data.pdlforvalter.v1.PersonDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdressehistorikkDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdressehistorikkRequest; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.DoedsmeldingRequest; import no.nav.testnav.libs.data.tpsmessagingservice.v1.DoedsmeldingResponse; import no.nav.testnav.libs.data.tpsmessagingservice.v1.FoedselsmeldingRequest; import no.nav.testnav.libs.data.tpsmessagingservice.v1.FoedselsmeldingResponse; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonMiljoeDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.SpraakDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.TpsMeldingResponseDTO; @@ -126,12 +128,11 @@ public List opphoerBankkontonrUtland(@PathVariable String return convert(bankkontoUtlandService.opphoerBankkontonrUtland(ident, miljoer)); } - @GetMapping("/{ident}/adressehistorikk") - public List personhistorikk(@PathVariable String ident, - @RequestParam(required = false) LocalDate aksjonsdato, + @GetMapping("/adressehistorikk") + public List personhistorikk(@RequestBody AdressehistorikkRequest request, @RequestParam(required = false) List miljoer) { - return adressehistorikkService.hentIdent(ident, aksjonsdato, isNull(miljoer) ? emptyList() : miljoer); + return adressehistorikkService.hentHistorikk(request, isNull(miljoer) ? emptyList() : miljoer); } @PostMapping("/foedselsmelding") @@ -141,12 +142,11 @@ public FoedselsmeldingResponse sendFoedselsmelding(@RequestParam(required = fals return foedselsmeldingService.sendFoedselsmelding(persondata, isNull(miljoer) ? emptyList() : miljoer); } - @PostMapping("{ident}/doedsmelding") - public DoedsmeldingResponse sendDoedsmelding(@PathVariable String ident, - @RequestParam LocalDate doedsdato, + @PostMapping("/doedsmelding") + public DoedsmeldingResponse sendDoedsmelding(@RequestBody DoedsmeldingRequest request, @RequestParam(required = false) List miljoer) { - return doedsmeldingService.sendDoedsmelding(ident, doedsdato, isNull(miljoer) ? emptyList() : miljoer); + return doedsmeldingService.sendDoedsmelding(request, isNull(miljoer) ? emptyList() : miljoer); } @DeleteMapping("/doedsmelding") diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/AdressehistorikkService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/AdressehistorikkService.java index f590d979d47..77ec1f0c428 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/AdressehistorikkService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/AdressehistorikkService.java @@ -15,6 +15,8 @@ import no.nav.testnav.apps.tpsmessagingservice.utils.ResponseStatus; import no.nav.testnav.apps.tpsmessagingservice.utils.ServiceRutineUtil; import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdressehistorikkDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdressehistorikkRequest; +import no.nav.tps.xjc.ctg.domain.s018.S018PersonType; import no.nav.tps.xjc.ctg.domain.s018.SRnavnType; import org.json.XML; import org.springframework.stereotype.Service; @@ -49,29 +51,40 @@ public AdressehistorikkService(TestmiljoerServiceConsumer testmiljoerServiceCons this.objectMapper = objectMapper; } - public List hentIdent(String ident, LocalDate aksjonsdato, List miljoer) { + public List hentHistorikk(AdressehistorikkRequest request, List miljoer) { if (miljoer.isEmpty()) { miljoer = testmiljoerServiceConsumer.getMiljoer(); } - var tpsPersoner = readFromTps(ident, nonNull(aksjonsdato) ? aksjonsdato : LocalDate.now(), miljoer); + var tpsPersoner = readFromTps(request.getIdent(), + nonNull(request.getAksjonsdato()) ? request.getAksjonsdato() : LocalDate.now(), + miljoer); return tpsPersoner.entrySet().stream() .map(entry -> { - var status = ResponseStatus.decodeStatus(nonNull(entry.getValue()) && nonNull(entry.getValue().getTpsPersonData().getTpsSvar()) ? + var status = ResponseStatus.decodeStatus(nonNull(entry.getValue()) && + nonNull(entry.getValue().getTpsPersonData().getTpsSvar()) ? entry.getValue().getTpsPersonData().getTpsSvar().getSvarStatus() : null); return AdressehistorikkDTO.builder() .miljoe(entry.getKey()) .status(mapperFacade.map(status, AdressehistorikkDTO.TpsMeldingResponse.class)) .persondata("OK".equals(status.getReturStatus()) ? - mapperFacade.map(entry.getValue().getTpsPersonData().getTpsSvar().getPersonDataS018(), AdressehistorikkDTO.PersonData.class) : + mapAdressehistorikk(request.getIdent(), + entry.getValue().getTpsPersonData().getTpsSvar().getPersonDataS018()) : null) .build(); }) .toList(); } + private AdressehistorikkDTO.PersonData mapAdressehistorikk(String ident, S018PersonType persondataS18) { + + var persondata = mapperFacade.map(persondataS18, AdressehistorikkDTO.PersonData.class); + persondata.setIdent(ident); + return persondata; + } + private Map readFromTps(String ident, LocalDate foedselsdato, List miljoer) { var request = TpsServicerutineAksjonsdatoRequest.builder() diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/DoedsmeldingService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/DoedsmeldingService.java index 8c5d95011f4..2c6c68133c5 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/DoedsmeldingService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/DoedsmeldingService.java @@ -3,16 +3,15 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import no.nav.testnav.apps.tpsmessagingservice.consumer.TestmiljoerServiceConsumer; -import no.nav.testnav.apps.tpsmessagingservice.dto.endringsmeldinger.SkdMeldingsheader; import no.nav.testnav.apps.tpsmessagingservice.service.skd.DoedsmeldingAnnulleringBuilderService; import no.nav.testnav.apps.tpsmessagingservice.service.skd.DoedsmeldingBuilderService; import no.nav.testnav.apps.tpsmessagingservice.service.skd.SendSkdMeldinger; import no.nav.testnav.apps.tpsmessagingservice.utils.ResponseStatus; -import no.nav.testnav.libs.data.pdlforvalter.v1.PersonDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.DoedsmeldingRequest; import no.nav.testnav.libs.data.tpsmessagingservice.v1.DoedsmeldingResponse; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonDTO; import org.springframework.stereotype.Service; -import java.time.LocalDate; import java.util.List; import java.util.Map; @@ -26,20 +25,19 @@ public class DoedsmeldingService { private final DoedsmeldingAnnulleringBuilderService doedsmeldingAnnulleringBuilderService; private final TestmiljoerServiceConsumer testmiljoerServiceConsumer; - public DoedsmeldingResponse sendDoedsmelding(String ident, LocalDate doedsdato, List miljoer) { + public DoedsmeldingResponse sendDoedsmelding(DoedsmeldingRequest request, List miljoer) { if (miljoer.isEmpty()) { miljoer = testmiljoerServiceConsumer.getMiljoer(); } - var skdMelding = doedsmeldingBuilderService.build(ident, doedsdato); - var skdMeldingMedHeader = SkdMeldingsheader.appendHeader(skdMelding.toString()); + var skdMelding = doedsmeldingBuilderService.build(request); - var miljoerStatus = sendSkdMeldinger.sendMeldinger(skdMeldingMedHeader, miljoer); + var miljoerStatus = sendSkdMeldinger.sendMeldinger(skdMelding.toString(), miljoer); prepareStatus(miljoerStatus); return DoedsmeldingResponse.builder() - .ident(ident) + .ident(request.getIdent()) .miljoStatus(miljoerStatus) .build(); } @@ -51,9 +49,8 @@ public DoedsmeldingResponse annulerDoedsmelding(PersonDTO person, List m } var skdMelding = doedsmeldingAnnulleringBuilderService.execute(person); - var skdMeldingMedHeader = SkdMeldingsheader.appendHeader(skdMelding.toString()); - var miljoerStatus = sendSkdMeldinger.sendMeldinger(skdMeldingMedHeader, miljoer); + var miljoerStatus = sendSkdMeldinger.sendMeldinger(skdMelding.toString(), miljoer); prepareStatus(miljoerStatus); return DoedsmeldingResponse.builder() diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/FoedselsmeldingService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/FoedselsmeldingService.java index ad54ff1df32..d29c5cf2b3b 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/FoedselsmeldingService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/FoedselsmeldingService.java @@ -2,7 +2,6 @@ import lombok.RequiredArgsConstructor; import no.nav.testnav.apps.tpsmessagingservice.consumer.TestmiljoerServiceConsumer; -import no.nav.testnav.apps.tpsmessagingservice.dto.endringsmeldinger.SkdMeldingsheader; import no.nav.testnav.apps.tpsmessagingservice.service.skd.FoedselsmeldingBuilderService; import no.nav.testnav.apps.tpsmessagingservice.service.skd.SendSkdMeldinger; import no.nav.testnav.apps.tpsmessagingservice.utils.ResponseStatus; @@ -28,9 +27,8 @@ public FoedselsmeldingResponse sendFoedselsmelding(FoedselsmeldingRequest person } var skdMelding = foedselsmeldingBuilderService.build(persondata); - var skdMeldingMedHeader = SkdMeldingsheader.appendHeader(skdMelding.toString()); - var miljoerStatus = sendSkdMeldinger.sendMeldinger(skdMeldingMedHeader, miljoer); + var miljoerStatus = sendSkdMeldinger.sendMeldinger(skdMelding.toString(), miljoer); prepareStatus(miljoerStatus); return FoedselsmeldingResponse.builder() diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/AdresseAppenderService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/AdresseAppenderService.java index 41a0f9258e2..de0fb48d515 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/AdresseAppenderService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/AdresseAppenderService.java @@ -5,9 +5,12 @@ import no.nav.testnav.apps.tpsmessagingservice.utils.ConvertDateToStringUtility; import no.nav.testnav.apps.tpsmessagingservice.utils.HentDatoFraIdentUtility; import no.nav.testnav.apps.tpsmessagingservice.utils.HusbokstavEncoder; +import no.nav.testnav.apps.tpsmessagingservice.utils.LandkodeEncoder; import no.nav.testnav.apps.tpsmessagingservice.utils.NullcheckUtil; -import no.nav.testnav.libs.data.pdlforvalter.v1.PersonDTO; -import no.nav.testnav.libs.data.pdlforvalter.v1.VegadresseDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdresseDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.GateadresseDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.MatrikkeladresseDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonDTO; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -28,37 +31,52 @@ public class AdresseAppenderService { public void execute(SkdMeldingTrans1 skdMeldingTrans1, PersonDTO person) { /* Boadresse */ - if (!person.getBostedsadresse().isEmpty()) { - var boadresse = person.getBostedsadresse().getFirst(); + if (nonNull(person.getBoadresse())) { - if (nonNull(boadresse.getMatrikkeladresse())) { - var matrikkeladresse = boadresse.getMatrikkeladresse(); - skdMeldingTrans1.setAdressetype("M"); - skdMeldingTrans1.setGateGaard(prepad(matrikkeladresse.getGaardsnummer().toString(), 5)); - skdMeldingTrans1.setHusBruk(prepad(matrikkeladresse.getBruksnummer().toString(), 4)); - skdMeldingTrans1.setAdressenavn(matrikkeladresse.getTilleggsnavn()); - skdMeldingTrans1.setKommunenummer(matrikkeladresse.getKommunenummer()); - skdMeldingTrans1.setPostnummer(matrikkeladresse.getPostnummer()); - skdMeldingTrans1.setTilleggsadresse(matrikkeladresse.getTilleggsnavn()); - - } else if (nonNull(boadresse.getVegadresse())) { - var vegadresse = boadresse.getVegadresse(); + if (AdresseDTO.Adressetype.GATE == person.getBoadresse().getAdressetype()) { + + var gateadresse = (GateadresseDTO) person.getBoadresse(); skdMeldingTrans1.setAdressetype("O"); - skdMeldingTrans1.setGateGaard(fixGatekode(vegadresse.getAdressekode())); - addHusBrukAndBokstavFestenr(skdMeldingTrans1, vegadresse); - skdMeldingTrans1.setAdressenavn(StringUtils.abbreviate(vegadresse.getAdressenavn(), 25)); - skdMeldingTrans1.setKommunenummer(vegadresse.getKommunenummer()); - skdMeldingTrans1.setPostnummer(vegadresse.getPostnummer()); - skdMeldingTrans1.setTilleggsadresse(vegadresse.getTilleggsnavn()); + skdMeldingTrans1.setGateGaard(fixGatekode(gateadresse.getGatekode())); + addHusBrukAndBokstavFestenr(skdMeldingTrans1, gateadresse); + skdMeldingTrans1.setAdressenavn(StringUtils.abbreviate(gateadresse.getAdresse(), 25)); + skdMeldingTrans1.setKommunenummer(gateadresse.getKommunenr()); + skdMeldingTrans1.setPostnummer(gateadresse.getPostnr()); + skdMeldingTrans1.setTilleggsadresse(gateadresse.getTilleggsadresse()); + skdMeldingTrans1.setFlyttedatoAdr(ConvertDateToStringUtility.yyyyMMdd( + enforceValidTpsDate(NullcheckUtil.nullcheckSetDefaultValue(gateadresse.getFlyttedato(), + HentDatoFraIdentUtility.extract(person.getIdent()))))); + + } else if (AdresseDTO.Adressetype.MATR == person.getBoadresse().getAdressetype()) { + + var matrikkeladresse = (MatrikkeladresseDTO) person.getBoadresse(); + skdMeldingTrans1.setAdressetype("M"); + skdMeldingTrans1.setGateGaard(prepad(matrikkeladresse.getGardsnr(), 5)); + skdMeldingTrans1.setHusBruk(prepad(matrikkeladresse.getBruksnr(), 4)); + skdMeldingTrans1.setAdressenavn(matrikkeladresse.getMellomnavn()); + skdMeldingTrans1.setKommunenummer(matrikkeladresse.getKommunenr()); + skdMeldingTrans1.setPostnummer(matrikkeladresse.getPostnr()); + skdMeldingTrans1.setTilleggsadresse(matrikkeladresse.getTilleggsadresse()); + skdMeldingTrans1.setFlyttedatoAdr(ConvertDateToStringUtility.yyyyMMdd( + enforceValidTpsDate(NullcheckUtil.nullcheckSetDefaultValue(matrikkeladresse.getFlyttedato(), + HentDatoFraIdentUtility.extract(person.getIdent()))))); + } - skdMeldingTrans1.setFlyttedatoAdr(ConvertDateToStringUtility.yyyyMMdd( - enforceValidTpsDate(NullcheckUtil.nullcheckSetDefaultValue(boadresse.getAngittFlyttedato(), - HentDatoFraIdentUtility.extract(person.getIdent()))))); } else { skdMeldingTrans1.setFlyttedatoAdr(ConvertDateToStringUtility.yyyyMMdd(enforceValidTpsDate( HentDatoFraIdentUtility.extract(person.getIdent())))); } + + /* Postadresse */ + if (nonNull(person.getPostadresse())) { + + var postadresse = person.getPostadresse(); + skdMeldingTrans1.setPostadresse1(postadresse.getPostLinje1()); + skdMeldingTrans1.setPostadresse2(postadresse.getPostLinje2()); + skdMeldingTrans1.setPostadresse3(postadresse.getPostLinje3()); + skdMeldingTrans1.setPostadresseLand(LandkodeEncoder.encode(postadresse.getPostLand())); + } } private static String fixGatekode(String gatekode) { @@ -72,7 +90,7 @@ private static String prepad(String value, int length) { return format(formatter, nonNull(value) ? value : '0').replace(' ', '0'); } - private void addHusBrukAndBokstavFestenr(SkdMeldingTrans1 skdMeldingTrans1, VegadresseDTO gateadresse) { + private void addHusBrukAndBokstavFestenr(SkdMeldingTrans1 skdMeldingTrans1, GateadresseDTO gateadresse) { if (isNotBlank(gateadresse.getHusnummer())) { diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/DoedsmeldingAnnulleringBuilderService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/DoedsmeldingAnnulleringBuilderService.java index 27bc7c1b179..780b7ff4cff 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/DoedsmeldingAnnulleringBuilderService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/DoedsmeldingAnnulleringBuilderService.java @@ -2,7 +2,7 @@ import no.nav.testnav.apps.tpsmessagingservice.dto.endringsmeldinger.SkdMeldingTrans1; import no.nav.testnav.apps.tpsmessagingservice.utils.ConvertDateToStringUtility; -import no.nav.testnav.libs.data.pdlforvalter.v1.PersonDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/DoedsmeldingBuilderService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/DoedsmeldingBuilderService.java index af62a57d26a..9021c61b7ee 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/DoedsmeldingBuilderService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/DoedsmeldingBuilderService.java @@ -5,9 +5,9 @@ import no.nav.testnav.apps.tpsmessagingservice.utils.ConvertDateToStringUtility; import no.nav.testnav.apps.tpsmessagingservice.utils.IdenttypeFraIdentUtility; import no.nav.testnav.libs.data.pdlforvalter.v1.Identtype; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.DoedsmeldingRequest; import org.springframework.stereotype.Service; -import java.time.LocalDate; import java.time.LocalDateTime; @Service @@ -20,22 +20,22 @@ public class DoedsmeldingBuilderService { private static final String STATUSKODE_DNR = "2"; private static final String TILDELINGSKODE_DOEDSMELDING = "0"; - public SkdMeldingTrans1 build(String ident, LocalDate doedsdato) { + public SkdMeldingTrans1 build(DoedsmeldingRequest request) { var skdMeldingTrans1 = new SkdMeldingTrans1(); skdMeldingTrans1.setTildelingskode(TILDELINGSKODE_DOEDSMELDING); - addSkdParametersExtractedFromPerson(skdMeldingTrans1, ident, doedsdato); + addSkdParametersExtractedFromPerson(skdMeldingTrans1, request); return skdMeldingTrans1; } - private void addSkdParametersExtractedFromPerson(SkdMeldingTrans1 skdMeldingTrans1, String ident, LocalDate doedsdato) { + private void addSkdParametersExtractedFromPerson(SkdMeldingTrans1 skdMeldingTrans1, DoedsmeldingRequest request) { - skdMeldingTrans1.setFodselsdato(ident.substring(0, 6)); - skdMeldingTrans1.setPersonnummer(ident.substring(6, 11)); + skdMeldingTrans1.setFodselsdato(request.getIdent().substring(0, 6)); + skdMeldingTrans1.setPersonnummer(request.getIdent().substring(6, 11)); - var datoDoed = ConvertDateToStringUtility.yyyyMMdd(doedsdato.atStartOfDay()); + var datoDoed = ConvertDateToStringUtility.yyyyMMdd(request.getDoedsdato().atStartOfDay()); skdMeldingTrans1.setMaskintid(ConvertDateToStringUtility.hhMMss(LocalDateTime.now())); skdMeldingTrans1.setMaskindato(ConvertDateToStringUtility.yyyyMMdd(LocalDateTime.now())); @@ -45,7 +45,7 @@ private void addSkdParametersExtractedFromPerson(SkdMeldingTrans1 skdMeldingTran skdMeldingTrans1.setDatoDoed(datoDoed); skdMeldingTrans1.setAarsakskode(AARSAKSKODE_FOR_DOEDSMELDING); - skdMeldingTrans1.setStatuskode(Identtype.FNR == IdenttypeFraIdentUtility.getIdenttype(ident) ? + skdMeldingTrans1.setStatuskode(Identtype.FNR == IdenttypeFraIdentUtility.getIdenttype(request.getIdent()) ? STATUSKODE_FNR : STATUSKODE_DNR); skdMeldingTrans1.setTranstype(TRANSTYPE_FOR_DOEDSMELDING); } diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/FoedselsmeldingBuilderService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/FoedselsmeldingBuilderService.java index 260e61b1e07..a6bb9a98566 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/FoedselsmeldingBuilderService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/FoedselsmeldingBuilderService.java @@ -4,15 +4,13 @@ import no.nav.testnav.apps.tpsmessagingservice.dto.endringsmeldinger.SkdMeldingTrans1; import no.nav.testnav.apps.tpsmessagingservice.utils.ConvertDateToStringUtility; import no.nav.testnav.apps.tpsmessagingservice.utils.HentDatoFraIdentUtility; -import no.nav.testnav.libs.data.pdlforvalter.v1.AdressebeskyttelseDTO; -import no.nav.testnav.libs.data.pdlforvalter.v1.PersonDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.FoedselsmeldingRequest; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonDTO; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.server.ResponseStatusException; import java.time.LocalDateTime; -import java.util.List; import static java.util.Objects.isNull; import static java.util.Objects.nonNull; @@ -52,34 +50,19 @@ private void addSkdParametersExtractedFromPerson(SkdMeldingTrans1 skdMeldingTran skdMeldingTrans1.setFoedekommLand("0301"); skdMeldingTrans1.setFoedested("Sykehus"); - skdMeldingTrans1.setFornavn(barn.getNavn().getFirst().getFornavn()); - skdMeldingTrans1.setSlektsnavn(barn.getNavn().getFirst().getEtternavn()); - skdMeldingTrans1.setKjoenn(barn.getKjoenn().getFirst().getKjoenn().name().substring(0,1)); + skdMeldingTrans1.setFornavn(barn.getFornavn()); + skdMeldingTrans1.setSlektsnavn(barn.getEtternavn()); + skdMeldingTrans1.setKjoenn(barn.getKjonn()); skdMeldingTrans1.setRegdatoAdr(regdato); skdMeldingTrans1.setPersonkode("3"); skdMeldingTrans1.setLevendeDoed("1"); skdMeldingTrans1.setStatuskode("1"); - skdMeldingTrans1.setSpesRegType(getSpesregType(barn.getAdressebeskyttelse())); + skdMeldingTrans1.setSpesRegType(barn.getSpesreg()); skdMeldingTrans1.setDatoSpesRegType(regdato); } - private String getSpesregType(List adressebeskyttelse) { - - if (adressebeskyttelse.isEmpty()) { - return null; - } - - return switch (adressebeskyttelse.getFirst().getGradering()) { - - case STRENGT_FORTROLIG -> "6"; - case FORTROLIG -> "7"; - case STRENGT_FORTROLIG_UTLAND -> "19"; - default -> null; - }; - } - private void addSkdParametersExtractedFromForeldre(SkdMeldingTrans1 skdMeldingTrans1, FoedselsmeldingRequest request) { if (isNull(request.getMor())) { @@ -88,7 +71,7 @@ private void addSkdParametersExtractedFromForeldre(SkdMeldingTrans1 skdMeldingTr skdMeldingTrans1.setMorsFodselsdato(getDato(request.getMor())); skdMeldingTrans1.setMorsPersonnummer(getPersonnr(request.getMor())); - skdMeldingTrans1.setSlektsnavn(request.getBarn().getNavn().getFirst().getEtternavn()); + skdMeldingTrans1.setSlektsnavn(request.getBarn().getEtternavn()); skdMeldingTrans1.setFamilienummer(request.getMor().getIdent()); skdMeldingTrans1.setRegdatoFamnr( ConvertDateToStringUtility.yyyyMMdd(HentDatoFraIdentUtility.extract(request.getBarn().getIdent()))); diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/SendSkdMeldinger.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/SendSkdMeldinger.java index 0bd25d96a52..75b7cc6530c 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/SendSkdMeldinger.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/skd/SendSkdMeldinger.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import no.nav.testnav.apps.tpsmessagingservice.consumer.EndringsmeldingConsumer; +import no.nav.testnav.apps.tpsmessagingservice.dto.endringsmeldinger.SkdMeldingsheader; import org.springframework.http.HttpStatus; import org.springframework.jms.JmsException; import org.springframework.stereotype.Service; @@ -21,7 +22,8 @@ public class SendSkdMeldinger { public Map sendMeldinger(String skdMelding , List environments) { try { - return endringsmeldingConsumer.sendMessage(skdMelding, environments); + var skdMeldingMedHeader = SkdMeldingsheader.appendHeader(skdMelding); + return endringsmeldingConsumer.sendMessage(skdMeldingMedHeader, environments); } catch (JmsException jmsException) { log.error(jmsException.getMessage(), jmsException); diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/utils/LandkodeEncoder.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/utils/LandkodeEncoder.java new file mode 100644 index 00000000000..e30b0473319 --- /dev/null +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/utils/LandkodeEncoder.java @@ -0,0 +1,302 @@ +package no.nav.testnav.apps.tpsmessagingservice.utils; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.UtilityClass; + +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; + +import static java.time.LocalDateTime.of; + +@UtilityClass +public class LandkodeEncoder { + + private static final LocalDateTime START_OF_ERA = of(1800, 1, 1, 0, 0); + private static final LocalDateTime FORESEEABLE_FUTURE = of(9999, 12, 31, 0, 0); + + private static final Map landkoderMap = new HashMap<>(); + + private static final LandDetails DEFAULT = new LandDetails("990", START_OF_ERA, FORESEEABLE_FUTURE); + + static { //NOSONAR + landkoderMap.put("???", DEFAULT); + landkoderMap.put("ABW", new LandDetails("657", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("AFG", new LandDetails("404", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("AGO", new LandDetails("204", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("AIA", new LandDetails("660", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ALB", new LandDetails("111", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("AND", new LandDetails("114", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ANT", new LandDetails("656", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ARE", new LandDetails("426", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ARG", new LandDetails("705", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ARM", new LandDetails("406", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ASM", new LandDetails("802", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ATF", new LandDetails("628", START_OF_ERA, of(2000, 1, 1, 0, 0))); + landkoderMap.put("ATG", new LandDetails("603", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("AUS", new LandDetails("805", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("AUT", new LandDetails("153", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("AZE", new LandDetails("407", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BDI", new LandDetails("216", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BEL", new LandDetails("112", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BEN", new LandDetails("229", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BES", new LandDetails("659", of(2011, 12, 1, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("BFA", new LandDetails("393", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BGD", new LandDetails("410", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BGR", new LandDetails("113", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BHR", new LandDetails("409", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BHS", new LandDetails("605", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BIH", new LandDetails("155", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BLM", new LandDetails("687", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BLR", new LandDetails("120", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BLZ", new LandDetails("604", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BMU", new LandDetails("606", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BOL", new LandDetails("710", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BRA", new LandDetails("715", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BRB", new LandDetails("602", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BRN", new LandDetails("416", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BTN", new LandDetails("412", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BVT", new LandDetails("875", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("BWA", new LandDetails("205", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CAF", new LandDetails("337", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CAN", new LandDetails("612", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CCK", new LandDetails("808", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CHE", new LandDetails("141", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CHL", new LandDetails("725", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CHN", new LandDetails("484", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CIV", new LandDetails("239", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CMR", new LandDetails("270", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("COD", new LandDetails("279", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("COG", new LandDetails("278", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("COK", new LandDetails("809", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("COL", new LandDetails("730", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("COM", new LandDetails("220", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CPV", new LandDetails("273", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CRI", new LandDetails("616", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CSK", new LandDetails("142", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CUB", new LandDetails("620", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CUW", new LandDetails("661", of(2011, 12, 1, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("CXR", new LandDetails("807", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CYM", new LandDetails("613", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CYP", new LandDetails("500", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("CZE", new LandDetails("158", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("DDR", new LandDetails("151", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("DEU", new LandDetails("144", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("DJI", new LandDetails("250", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("DMA", new LandDetails("622", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("DNK", new LandDetails("101", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("DOM", new LandDetails("624", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("DZA", new LandDetails("203", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ECU", new LandDetails("735", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("EGY", new LandDetails("249", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ERI", new LandDetails("241", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ESH", new LandDetails("304", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ESP", new LandDetails("137", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("EST", new LandDetails("115", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ETH", new LandDetails("246", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("FIN", new LandDetails("103", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("FJI", new LandDetails("811", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("FLK", new LandDetails("740", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("FRA", new LandDetails("117", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("FRO", new LandDetails("104", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("FSM", new LandDetails("826", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GAB", new LandDetails("254", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GBR", new LandDetails("139", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GEO", new LandDetails("430", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GGY", new LandDetails("162", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GHA", new LandDetails("260", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GIB", new LandDetails("118", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GIN", new LandDetails("264", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GLP", new LandDetails("631", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GMB", new LandDetails("256", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GNB", new LandDetails("266", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GNQ", new LandDetails("235", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GRC", new LandDetails("119", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GRD", new LandDetails("629", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GRL", new LandDetails("102", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GTM", new LandDetails("632", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GUF", new LandDetails("745", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GUM", new LandDetails("817", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("GUY", new LandDetails("720", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("HKG", new LandDetails("436", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("HMD", new LandDetails("870", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("HND", new LandDetails("644", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("HRV", new LandDetails("122", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("HTI", new LandDetails("636", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("HUN", new LandDetails("152", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("IDN", new LandDetails("448", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("IMN", new LandDetails("164", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("IND", new LandDetails("444", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("IOT", new LandDetails("213", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("IRL", new LandDetails("121", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("IRN", new LandDetails("456", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("IRQ", new LandDetails("452", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ISL", new LandDetails("105", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ISR", new LandDetails("460", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ITA", new LandDetails("123", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("JAM", new LandDetails("648", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("JEY", new LandDetails("163", of(2011, 12, 1, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("JOR", new LandDetails("476", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("JPN", new LandDetails("464", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("KAZ", new LandDetails("480", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("KEN", new LandDetails("276", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("KGZ", new LandDetails("502", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("KHM", new LandDetails("478", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("KIR", new LandDetails("815", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("KNA", new LandDetails("677", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("KOR", new LandDetails("492", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("KWT", new LandDetails("496", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LAO", new LandDetails("504", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LBN", new LandDetails("508", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LBR", new LandDetails("283", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LBY", new LandDetails("286", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LCA", new LandDetails("678", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LIE", new LandDetails("128", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LKA", new LandDetails("424", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LSO", new LandDetails("281", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LTU", new LandDetails("136", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LUX", new LandDetails("129", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("LVA", new LandDetails("124", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MAC", new LandDetails("510", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MAF", new LandDetails("686", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MAR", new LandDetails("303", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MCO", new LandDetails("130", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MDA", new LandDetails("138", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MDG", new LandDetails("289", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MDV", new LandDetails("513", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MEX", new LandDetails("652", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MHL", new LandDetails("835", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MKD", new LandDetails("156", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MLI", new LandDetails("299", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MLT", new LandDetails("126", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MMR", new LandDetails("420", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MNE", new LandDetails("160", of(2006, 11, 1, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("MNG", new LandDetails("516", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MNP", new LandDetails("840", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MOZ", new LandDetails("319", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MRT", new LandDetails("306", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MSR", new LandDetails("654", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MTQ", new LandDetails("650", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MUS", new LandDetails("307", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MWI", new LandDetails("296", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MYS", new LandDetails("512", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("MYT", new LandDetails("322", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NAM", new LandDetails("308", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NCL", new LandDetails("833", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NER", new LandDetails("309", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NFK", new LandDetails("822", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NGA", new LandDetails("313", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NIC", new LandDetails("664", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NIU", new LandDetails("821", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NLD", new LandDetails("127", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NOR", new LandDetails("000", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NPL", new LandDetails("528", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NRU", new LandDetails("818", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("NZL", new LandDetails("820", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("OMN", new LandDetails("520", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PAK", new LandDetails("534", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PAN", new LandDetails("668", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PCN", new LandDetails("828", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PER", new LandDetails("760", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PHL", new LandDetails("428", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PLW", new LandDetails("839", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PNG", new LandDetails("827", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("POL", new LandDetails("131", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PRI", new LandDetails("685", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PRK", new LandDetails("488", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PRT", new LandDetails("132", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PRY", new LandDetails("755", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PSE", new LandDetails("524", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("PYF", new LandDetails("814", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("QAT", new LandDetails("540", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("REU", new LandDetails("323", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ROU", new LandDetails("133", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("RUS", new LandDetails("140", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("RWA", new LandDetails("329", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SAU", new LandDetails("544", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SCG", new LandDetails("125", of(1994, 1, 1, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("SDN", new LandDetails("356", of(2011, 12, 1, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("SEN", new LandDetails("336", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SGP", new LandDetails("548", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SGS", new LandDetails("865", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SHN", new LandDetails("209", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SJM", new LandDetails("744", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SLB", new LandDetails("806", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SLE", new LandDetails("339", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SLV", new LandDetails("672", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SMR", new LandDetails("134", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SOM", new LandDetails("346", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SPM", new LandDetails("676", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SRB", new LandDetails("159", of(2006, 11, 1, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("SSD", new LandDetails("355", of(2011,12,1,0,0), FORESEEABLE_FUTURE)); + landkoderMap.put("STP", new LandDetails("333", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SUN", new LandDetails("135", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SUR", new LandDetails("765", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SVK", new LandDetails("157", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SVN", new LandDetails("146", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SWE", new LandDetails("106", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SWZ", new LandDetails("357", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SXM", new LandDetails("658", of(2011, 12, 1, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("SYC", new LandDetails("338", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("SYR", new LandDetails("564", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TCA", new LandDetails("681", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TCD", new LandDetails("373", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TGO", new LandDetails("376", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("THA", new LandDetails("568", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TJK", new LandDetails("550", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TKL", new LandDetails("829", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TKM", new LandDetails("552", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TLS", new LandDetails("537", of(2002, 5, 20, 0, 0), FORESEEABLE_FUTURE)); + landkoderMap.put("TON", new LandDetails("813", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TTO", new LandDetails("680", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TUN", new LandDetails("379", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TUR", new LandDetails("143", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TUV", new LandDetails("816", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TWN", new LandDetails("432", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("TZA", new LandDetails("369", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("UGA", new LandDetails("386", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("UKR", new LandDetails("148", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("UMI", new LandDetails("819", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("URY", new LandDetails("770", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("USA", new LandDetails("684", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("UZB", new LandDetails("554", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("VAT", new LandDetails("154", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("VCT", new LandDetails("679", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("VEN", new LandDetails("775", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("VGB", new LandDetails("608", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("VIR", new LandDetails("601", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("VNM", new LandDetails("575", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("VUT", new LandDetails("812", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("WAK", new LandDetails("831", START_OF_ERA, of(2001, 1, 1, 0, 0))); + landkoderMap.put("WLF", new LandDetails("832", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("WSM", new LandDetails("830", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("XXK", new LandDetails("161", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("XXX", new LandDetails("980", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("YEM", new LandDetails("578", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("YUG", new LandDetails("925", of(1944, 1, 1, 0, 0), of(2003, 11, 30, 0, 0))); + landkoderMap.put("ZAF", new LandDetails("359", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ZMB", new LandDetails("389", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("ZWE", new LandDetails("326", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("349", new LandDetails("349", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("546", new LandDetails("546", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("556", new LandDetails("556", START_OF_ERA, FORESEEABLE_FUTURE)); + landkoderMap.put("669", new LandDetails("669", START_OF_ERA, FORESEEABLE_FUTURE)); + } + + public String encode(String statsborgerskap) { + return landkoderMap.getOrDefault(statsborgerskap, DEFAULT).getTpsCode(); + } + + @Getter + @Setter + @NoArgsConstructor + @AllArgsConstructor + static class LandDetails { + private String tpsCode; + private LocalDateTime fom; + private LocalDateTime tom; + } +} diff --git a/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/AdressehistorikkDTO.java b/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/AdressehistorikkDTO.java index 7759bbf2eaf..a8dba236f46 100644 --- a/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/AdressehistorikkDTO.java +++ b/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/AdressehistorikkDTO.java @@ -40,6 +40,7 @@ public enum PersonStatus { @NoArgsConstructor @AllArgsConstructor public static class PersonData { + private String Ident; private String identType; private List personStatus; private List bostedsAdresse; diff --git a/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/AdressehistorikkRequest.java b/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/AdressehistorikkRequest.java new file mode 100644 index 00000000000..cc03d94cf36 --- /dev/null +++ b/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/AdressehistorikkRequest.java @@ -0,0 +1,18 @@ +package no.nav.testnav.libs.data.tpsmessagingservice.v1; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AdressehistorikkRequest { + + private String ident; + private LocalDate aksjonsdato; +} diff --git a/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/DoedsmeldingRequest.java b/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/DoedsmeldingRequest.java new file mode 100644 index 00000000000..14a81480d20 --- /dev/null +++ b/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/DoedsmeldingRequest.java @@ -0,0 +1,18 @@ +package no.nav.testnav.libs.data.tpsmessagingservice.v1; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class DoedsmeldingRequest { + + private String ident; + private LocalDate doedsdato; +} diff --git a/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/FoedselsmeldingRequest.java b/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/FoedselsmeldingRequest.java index 55868a34784..cc8a798d610 100644 --- a/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/FoedselsmeldingRequest.java +++ b/libs/data-transfer-search-objects/src/main/java/no/nav/testnav/libs/data/tpsmessagingservice/v1/FoedselsmeldingRequest.java @@ -4,7 +4,6 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import no.nav.testnav.libs.data.pdlforvalter.v1.PersonDTO; @Data @Builder