Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rydde opplysningstype foedsel #3603

Merged
merged 6 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { UseFormReturn } from 'react-hook-form/dist/types'
const paths = {
fra: 'alder.fra',
til: 'alder.til',
fom: 'foedsel.fom',
tom: 'foedsel.tom',
fom: 'foedselsdato.fom',
tom: 'foedselsdato.tom',
}

type Props = {
Expand Down Expand Up @@ -38,18 +38,8 @@ export const Alder = ({ formMethods }: Props) => (
formMethods.handleSubmit()
}}
/>
<FormDatepicker
name={paths.fom}
label="Fødselsdato fom"
visHvisAvhuket={false}
size="medium"
/>
<FormDatepicker
name={paths.tom}
label="Fødselsdato tom"
visHvisAvhuket={false}
size="medium"
/>
<FormDatepicker name={paths.fom} label="Fødselsdato fom" visHvisAvhuket={false} size="medium" />
<FormDatepicker name={paths.tom} label="Fødselsdato tom" visHvisAvhuket={false} size="medium" />
</section>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const initialValues = {
fra: '',
til: '',
},
foedsel: {
foedselsdato: {
fom: '',
tom: '',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package no.nav.registre.testnorge.personsearchservice.domain;

import no.nav.registre.testnorge.personsearchservice.model.DoedsfallModel;
import no.nav.registre.testnorge.personsearchservice.model.FoedselModel;
import no.nav.registre.testnorge.personsearchservice.model.FoedselsdatoModel;
import no.nav.registre.testnorge.personsearchservice.model.KjoennModel;
import no.nav.registre.testnorge.personsearchservice.model.NavnModel;
import no.nav.registre.testnorge.personsearchservice.model.Response;
import no.nav.registre.testnorge.personsearchservice.model.SivilstandModel;
import no.nav.registre.testnorge.personsearchservice.model.StatsborgerskapModel;
import no.nav.registre.testnorge.personsearchservice.model.WithMetadata;
import no.nav.testnav.libs.dto.personsearchservice.v1.DoedsfallDTO;
import no.nav.testnav.libs.dto.personsearchservice.v1.FoedselDTO;
import no.nav.testnav.libs.dto.personsearchservice.v1.FoedselsdatoDTO;
import no.nav.testnav.libs.dto.personsearchservice.v1.FolkeregisterpersonstatusDTO;
import no.nav.testnav.libs.dto.personsearchservice.v1.PersonDTO;
import no.nav.testnav.libs.dto.personsearchservice.v1.SivilstandDTO;
Expand Down Expand Up @@ -73,7 +72,7 @@ private String getEtternavn() {
}

private LocalDate getFoedselsdato() {
return getCurrent(response.getHentPerson().getFoedsel()).map(FoedselModel::getFoedselsdato).orElse(null);
return getCurrent(response.getHentPerson().getFoedselsdato()).map(FoedselsdatoModel::getFoedselsdato).orElse(null);
}

private LocalDate getDoedsdato() {
Expand Down Expand Up @@ -147,7 +146,7 @@ public PersonDTO toDTO() {
.ident(getIdent())
.kjoenn(getKjoenn())
.tags(getTags())
.foedsel(FoedselDTO.builder().foedselsdato(getFoedselsdato()).build())
.foedselsdato(FoedselsdatoDTO.builder().foedselsdato(getFoedselsdato()).build())
.doedsfall(DoedsfallDTO.builder().doedsdato(getDoedsdato()).build())
.sivilstand(getSivilstand())
.statsborgerskap(toDTO(statsborgerskap))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class FoedselModel implements WithMetadata {
public class FoedselsdatoModel implements WithMetadata {
LocalDate foedselsdato;
Metadata metadata;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class HentPersonModel {
List<NavnModel> navn;
List<KjoennModel> kjoenn;
List<FoedselModel> foedsel;
List<FoedselsdatoModel> foedselsdato;
List<DoedsfallModel> doedsfall;
List<SivilstandModel> sivilstand;
List<StatsborgerskapModel> statsborgerskap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ public class AlderUtils {

public static void addAlderQueries(BoolQueryBuilder queryBuilder, PersonSearch search) {
addAlderQuery(queryBuilder, search);
addFoedselQuery(queryBuilder, search);
addFoedselsdatoQuery(queryBuilder, search);
}

private static void addFoedselQuery(BoolQueryBuilder queryBuilder, PersonSearch search) {
Optional.ofNullable(search.getFoedsel())
private static void addFoedselsdatoQuery(BoolQueryBuilder queryBuilder, PersonSearch search) {
Optional.ofNullable(search.getFoedselsdato())
.ifPresent(value -> {
var tom = isNull(value.getTom()) ? LocalDate.now() : value.getTom();
queryFoedselsdato(value.getFom(), tom, queryBuilder);
Expand All @@ -35,9 +35,9 @@ private static void addAlderQuery(BoolQueryBuilder queryBuilder, PersonSearch se
}

private static void queryFoedselsdato(LocalDate fom, LocalDate tom, BoolQueryBuilder queryBuilder) {
getBetween(fom, tom, "hentPerson.foedsel.foedselsdato")
getBetween(fom, tom, "hentPerson.foedselsdato.foedselsdato")
.ifPresent(rangeQueryBuilder -> queryBuilder.must(QueryBuilders.nestedQuery(
"hentPerson.foedsel",
"hentPerson.foedselsdato",
rangeQueryBuilder,
ScoreMode.Avg
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private boolean isPresent(String ident, PdlAktoer pdlAktoer, String miljoe, Set<
var person = pdlAktoer.getData().getHentPerson();
log.info("Sjekker ident {} i miljø {}, med PDL opplysningId {}, sjekkes for mottatt opplysningId {}", ident, miljoe,
nonNull(person) ?
Stream.of(person.getNavn(), person.getFoedsel(), person.getFolkeregisteridentifikator(), person.getFolkeregisterpersonstatus(), person.getBostedsadresse())
Stream.of(person.getNavn(), person.getFoedselsdato(), person.getKjoenn(), person.getFolkeregisterpersonstatus())
.flatMap(Collection::stream)
.map(MetadataDTO::getMetadata)
.map(MetadataDTO.Metadata::getOpplysningsId)
Expand All @@ -117,7 +117,7 @@ private boolean isPresent(String ident, PdlAktoer pdlAktoer, String miljoe, Set<
if (nonNull(opplysningId)) {

resultat = nonNull(person) &&
Stream.of(person.getNavn(), person.getFoedsel(), person.getFolkeregisteridentifikator(), person.getFolkeregisterpersonstatus(), person.getBostedsadresse())
Stream.of(person.getNavn(), person.getFoedselsdato(), person.getKjoenn(), person.getFolkeregisterpersonstatus())
.flatMap(Collection::stream)
.map(MetadataDTO::getMetadata)
.map(MetadataDTO.Metadata::getOpplysningsId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void opprettAdresse(Person person, String kilde, AccessToken token) {

private void opprettFoedsel(Person person, String kilde, AccessToken token) {
person.toFoedselDTO(kilde)
.ifPresent(value -> new OpprettFoedselCommand(webClient, value, token.getTokenValue(), person.getIdent()).call());
.ifPresent(value -> new OpprettFoedselsdatoCommand(webClient, value, token.getTokenValue(), person.getIdent()).call());
}

private void opprettTags(Person person, AccessToken token) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package no.nav.testnav.apps.personservice.consumer.v1.command;

import lombok.RequiredArgsConstructor;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.FoedselDTO;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.FoedselsdatoDTO;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.HendelseDTO;
import no.nav.testnav.apps.personservice.consumer.v1.header.PdlHeaders;
import no.nav.testnav.libs.commands.utils.WebClientFilter;
Expand All @@ -16,20 +16,20 @@
import java.util.concurrent.Callable;

@RequiredArgsConstructor
public class OpprettFoedselCommand implements Callable<Mono<HendelseDTO>> {
public class OpprettFoedselsdatoCommand implements Callable<Mono<HendelseDTO>> {
private final WebClient webClient;
private final FoedselDTO dto;
private final FoedselsdatoDTO dto;
private final String token;
private final String ident;

@Override
public Mono<HendelseDTO> call() {
return webClient.post()
.uri("/pdl-testdata/api/v1/bestilling/foedsel")
.uri("/pdl-testdata/api/v1/bestilling/foedselsdato")
.accept(MediaType.APPLICATION_JSON)
.header(PdlHeaders.NAV_PERSONIDENT, ident)
.header(HttpHeaders.AUTHORIZATION, "Bearer " + token)
.body(BodyInserters.fromPublisher(Mono.just(dto), FoedselDTO.class))
.body(BodyInserters.fromPublisher(Mono.just(dto), FoedselsdatoDTO.class))
.retrieve()
.bodyToMono(HendelseDTO.class)
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Builder
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class FoedselDTO {
public class FoedselsdatoDTO {
Integer foedselsaar;
LocalDate foedselsdato;
String kilde;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class Foedsel extends MetadataDTO {
public class Foedselsdato extends MetadataDTO {

LocalDate foedselsdato;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
@NoArgsConstructor(force = true)
public class HentPerson {
List<Navn> navn;
List<Foedsel> foedsel;
List<Kjoenn> kjoenn;
List<Foedselsdato> foedselsdato;
List<Bostedsadresse> bostedsadresse;
List<Folkeregisteridentifikator> folkeregisteridentifikator;
List<Folkeregisterpersonstatus> folkeregisterpersonstatus;
Expand All @@ -27,20 +28,20 @@ public List<Navn> getNavn() {
return navn;
}

public List<Foedsel> getFoedsel() {
public List<Foedselsdato> getFoedselsdato() {

if (isNull(foedsel)) {
foedsel = new ArrayList<>();
if (isNull(foedselsdato)) {
foedselsdato = new ArrayList<>();
}
return foedsel;
return foedselsdato;
}

public List<Bostedsadresse> getBostedsadresse() {
public List<Kjoenn> getKjoenn() {

if (isNull(bostedsadresse)) {
bostedsadresse = new ArrayList<>();
if (isNull(kjoenn)) {
kjoenn = new ArrayList<>();
}
return bostedsadresse;
return kjoenn;
}

public List<Folkeregisteridentifikator> getFolkeregisteridentifikator() {
Expand All @@ -51,6 +52,14 @@ public List<Folkeregisteridentifikator> getFolkeregisteridentifikator() {
return folkeregisteridentifikator;
}

public List<Bostedsadresse> getBostedsadresse() {

if(isNull(bostedsadresse)) {
bostedsadresse = new ArrayList<>();
}
return bostedsadresse;
}

public List<Folkeregisterpersonstatus> getFolkeregisterpersonstatus() {

if (isNull(folkeregisterpersonstatus)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package no.nav.testnav.apps.personservice.consumer.v1.pdl.graphql;

import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.Value;

@EqualsAndHashCode(callSuper = true)
@Value
@AllArgsConstructor
@NoArgsConstructor(force = true)
public class Kjoenn extends MetadataDTO {
String kjoenn;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.FoedselDTO;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.graphql.Foedsel;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.FoedselsdatoDTO;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.graphql.Foedselsdato;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.graphql.Folkeregisteridentifikator;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.graphql.HentPerson;
import no.nav.testnav.apps.personservice.consumer.v1.pdl.graphql.Navn;
Expand Down Expand Up @@ -45,14 +45,14 @@ public Person(PersonDTO dto) {
public Person(PdlPerson pdlPerson) {
HentPerson person = pdlPerson.getData().getHentPerson();
Optional<Navn> navn = person.getNavn().stream().findFirst();
Optional<Foedsel> foedsel = person.getFoedsel().stream().findFirst();
Optional<Foedselsdato> foedsel = person.getFoedselsdato().stream().findFirst();

ident = person.getFolkeregisteridentifikator()
.stream()
.findFirst()
.map(Folkeregisteridentifikator::getIdentifikasjonsnummer)
.orElse(null);
foedselsdato = foedsel.map(Foedsel::getFoedselsdato).orElse(null);
foedselsdato = foedsel.map(Foedselsdato::getFoedselsdato).orElse(null);
fornavn = navn.map(Navn::getFornavn).orElse(null);
mellomnavn = navn.map(Navn::getMellomnavn).orElse(null);
etternavn = navn.map(Navn::getEtternavn).orElse(null);
Expand All @@ -75,13 +75,13 @@ public PersonDTO toDTO() {
.build();
}

public Optional<FoedselDTO> toFoedselDTO(String kilde) {
public Optional<FoedselsdatoDTO> toFoedselDTO(String kilde) {
if (foedselsdato == null) {
return Optional.empty();
}

return Optional.of(
FoedselDTO
FoedselsdatoDTO
.builder()
.foedselsaar(foedselsdato.getYear())
.foedselsdato(foedselsdato)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@ type Navn {
originaltNavn: OriginaltNavn
}

type Navspersonidentifikator {
identifikasjonsnummer: String!
metadata: Metadata!
}

type Opphold {
folkeregistermetadata: Folkeregistermetadata!
metadata: Metadata!
Expand Down Expand Up @@ -479,6 +484,7 @@ type Person {
kontaktadresse(historikk: Boolean = false): [Kontaktadresse!]!
kontaktinformasjonForDoedsbo(historikk: Boolean = false): [KontaktinformasjonForDoedsbo!]!
navn(historikk: Boolean = false): [Navn!]!
navspersonidentifikator(historikk: Boolean = false): [Navspersonidentifikator!]!
opphold(historikk: Boolean = false): [Opphold!]!
oppholdsadresse(historikk: Boolean = false): [Oppholdsadresse!]!
rettsligHandleevne(historikk: Boolean = false): [RettsligHandleevne!]!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,6 @@ query($ident: ID!, $historikk: Boolean!) {
...metadataDetails
}
},
foedsel {
foedselsaar,
foedselsdato,
foedeland,
foedested,
foedekommune,
folkeregistermetadata {
...folkeregistermetadataDetails
}
metadata {
...metadataDetails
}
},
foedested {
foedested,
foedekommune,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ query($ident1: ID!) {
opplysningsId
}
}
foedsel {
foedselsdato {
metadata {
opplysningsId
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ query ($ident: ID!, $historikk: Boolean) {
...vegadresseDetails
}
},
foedsel {
foedselsdato{
foedselsdato
foedselsaar
},
folkeregisteridentifikator(historikk: $historikk) {
identifikasjonsnummer,
Expand Down
13 changes: 0 additions & 13 deletions apps/person-service/src/main/resources/pdl/pdlbolkquery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -353,19 +353,6 @@ query($identer: [ID!]!) {
...metadataDetails
}
},
foedsel {
foedselsaar,
foedselsdato,
foedeland,
foedested,
foedekommune,
folkeregistermetadata {
...folkeregistermetadataDetails
}
metadata {
...metadataDetails
}
},
foedselsdato {
foedselsaar,
foedselsdato,
Expand Down
Loading