Ejemplo n.º 1
0
  protected RegularCPRPersonType createCensoredRegularPerson(
      String cpr, CPRProtectionLevel cprProtection) {
    RegularCPRPersonType regularCprPerson = new RegularCPRPersonType();
    SimpleCPRPersonType simpleCprPerson = new SimpleCPRPersonType();

    // PERSON NAME STRUCTURE SECTION

    PersonNameStructureType personName = new PersonNameStructureType();
    simpleCprPerson.setPersonNameStructure(personName);

    personName.setPersonGivenName(ADRESSEBESKYTTET);
    personName.setPersonMiddleName(null);
    personName.setPersonSurnameName(ADRESSEBESKYTTET);

    // For some searches we also need to censor the CPR number.

    boolean isCPRHidden = cprProtection == CPRProtectionLevel.CensorCPR;
    simpleCprPerson.setPersonCivilRegistrationIdentifier(isCPRHidden ? PROTECTED_CPR : cpr);

    regularCprPerson.setSimpleCPRPerson(simpleCprPerson);
    regularCprPerson.setPersonNameForAddressingName(ADRESSEBESKYTTET);

    // Even though the CPR can be read from the CPR (when the CPR is
    // included),
    // we might as well always protect it.
    regularCprPerson.setPersonGenderCode(PersonGenderCodeType.UNKNOWN);
    regularCprPerson.setPersonInformationProtectionIndicator(true);

    // BIRTH DATE
    PersonBirthDateStructureType personBirthDate = new PersonBirthDateStructureType();
    personBirthDate.setBirthDate(newXMLGregorianCalendar(new Date(0)));
    personBirthDate.setBirthDateUncertaintyIndicator(true);
    regularCprPerson.setPersonBirthDateStructure(personBirthDate);

    // CIVIL STATUS
    PersonCivilRegistrationStatusStructureType personCivil =
        new PersonCivilRegistrationStatusStructureType();
    personCivil.setPersonCivilRegistrationStatusCode(BigInteger.ONE);
    personCivil.setPersonCivilRegistrationStatusStartDate(newXMLGregorianCalendar(new Date(0)));
    regularCprPerson.setPersonCivilRegistrationStatusStructure(personCivil);

    return regularCprPerson;
  }
Ejemplo n.º 2
0
  protected RegularCPRPersonType createRegularPerson(Person person) {
    RegularCPRPersonType regularCprPerson = new RegularCPRPersonType();
    SimpleCPRPersonType simpleCprPerson = new SimpleCPRPersonType();
    regularCprPerson.setSimpleCPRPerson(simpleCprPerson);

    // PERSON NAME STRUCTURE SECTION
    //
    // Many of these values might not be present in the database
    // this is because that 'Such is life' and sometimes we simply
    // don't know a person's first name, address or birthday.
    PersonNameStructureType personName = new PersonNameStructureType();
    simpleCprPerson.setPersonNameStructure(personName);
    personName.setPersonGivenName(actualOrUnknown(person.fornavn));

    // Middle name is optional.
    personName.setPersonMiddleName(actualOrNull(person.mellemnavn));
    personName.setPersonSurnameName(actualOrUnknown(person.efternavn));
    simpleCprPerson.setPersonCivilRegistrationIdentifier(person.cpr);

    regularCprPerson.setPersonNameForAddressingName(
        actualOrUnknown(person.getNavnTilAdressering()));
    regularCprPerson.setPersonGenderCode(mapGenderToGenderCode(person.koen));
    regularCprPerson.setPersonInformationProtectionIndicator(false);

    // BIRTH DATE
    PersonBirthDateStructureType personBirthDate = new PersonBirthDateStructureType();

    personBirthDate.setBirthDate(newXMLGregorianCalendar(person.foedselsdato));
    personBirthDate.setBirthDateUncertaintyIndicator(person.getFoedselsdatoMarkering());
    regularCprPerson.setPersonBirthDateStructure(personBirthDate);

    // CIVIL STATUS
    PersonCivilRegistrationStatusStructureType personCivil =
        new PersonCivilRegistrationStatusStructureType();
    personCivil.setPersonCivilRegistrationStatusCode(new BigInteger(person.getStatus()));
    personCivil.setPersonCivilRegistrationStatusStartDate(
        newXMLGregorianCalendar(person.getStatusDato()));

    regularCprPerson.setPersonCivilRegistrationStatusStructure(personCivil);
    return regularCprPerson;
  }