Skip to content

Commit

Permalink
strengthen tests and cleanup uneeded pojos (#6468)
Browse files Browse the repository at this point in the history
  • Loading branch information
zdeveloper authored Sep 7, 2023
1 parent f5de49f commit 7620c47
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 560 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static gov.cdc.usds.simplereport.api.Translators.parseEthnicity;
import static gov.cdc.usds.simplereport.api.Translators.parseGender;
import static gov.cdc.usds.simplereport.api.Translators.parseGenderIdentity;
import static gov.cdc.usds.simplereport.api.Translators.parsePersonRole;
import static gov.cdc.usds.simplereport.api.Translators.parsePhoneNumber;
import static gov.cdc.usds.simplereport.api.Translators.parsePhoneNumbers;
import static gov.cdc.usds.simplereport.api.Translators.parseRace;
Expand Down Expand Up @@ -50,38 +51,38 @@ public void register(@RequestBody PatientSelfRegistration body, HttpServletReque
_currentPatientContextHolder.setIsPatientSelfRegistrationRequest(true);

PatientSelfRegistrationLink registrationLink =
_patientRegLinkService.getPatientRegistrationLink(parseString(body.getRegistrationLink()));
_patientRegLinkService.getPatientRegistrationLink(parseString(body.registrationLink()));

List<PhoneNumberInput> backwardsCompatiblePhoneNumbers =
body.getPhoneNumbers() != null
? body.getPhoneNumbers()
: List.of(new PhoneNumberInput(null, parsePhoneNumber(body.getTelephone())));
body.phoneNumbers() != null
? body.phoneNumbers()
: List.of(new PhoneNumberInput(null, parsePhoneNumber(body.telephone())));

var backwardsCompatibleEmails = new PatientEmailsHolder(body.getEmail(), body.getEmails());
var backwardsCompatibleEmails = new PatientEmailsHolder(body.email(), body.emails());

Person p =
_personService.addPatient(
registrationLink,
parseString(body.getLookupId()),
parseString(body.getFirstName()),
parseString(body.getMiddleName()),
parseString(body.getLastName()),
parseString(body.getSuffix()),
body.getBirthDate(),
body.getAddress(),
body.getCountry(),
parseString(body.lookupId()),
parseString(body.firstName()),
parseString(body.middleName()),
parseString(body.lastName()),
parseString(body.suffix()),
body.birthDate(),
body.address(),
body.country(),
parsePhoneNumbers(backwardsCompatiblePhoneNumbers),
body.getRole(),
parsePersonRole(body.role(), false),
parseEmails(backwardsCompatibleEmails.getFullList()),
parseRace(body.getRace()),
parseEthnicity(body.getEthnicity()),
parseTribalAffiliation(body.getTribalAffiliation()),
parseGender(body.getGender()),
parseGenderIdentity(body.getGenderIdentity()),
body.getResidentCongregateSetting(),
body.getEmployedInHealthcare(),
parseString(body.getPreferredLanguage()),
body.getTestResultDelivery());
parseRace(body.race()),
parseEthnicity(body.ethnicity()),
parseTribalAffiliation(body.tribalAffiliation()),
parseGender(body.gender()),
parseGenderIdentity(body.genderIdentity()),
body.residentCongregateSetting(),
body.employedInHealthcare(),
parseString(body.preferredLanguage()),
body.testResultDelivery());

log.info(
"Patient={} self-registered from link={}", p.getInternalId(), registrationLink.getLink());
Expand All @@ -96,9 +97,9 @@ public boolean isExistingPatient(
_patientRegLinkService.getPatientRegistrationLink(patientRegistrationLink);

return _personService.isDuplicatePatient(
body.getFirstName(),
body.getLastName(),
body.getBirthDate(),
body.firstName(),
body.lastName(),
body.birthDate(),
link.getOrganization(),
Optional.ofNullable(link.getFacility()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,131 +1,29 @@
package gov.cdc.usds.simplereport.db.model.auxiliary;

import static gov.cdc.usds.simplereport.api.Translators.parsePersonRole;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import gov.cdc.usds.simplereport.api.model.PersonUpdate;
import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import lombok.Getter;

@Getter
public class PatientSelfRegistration extends PersonUpdate {
private final String registrationLink;
private final String lookupId;
private final String firstName;
private final String middleName;
private final String lastName;
private final String suffix;
private final LocalDate birthDate;

@JsonCreator
public PatientSelfRegistration(
@JsonProperty("registrationLink") String registrationLink,
@JsonProperty("lookupId") String lookupId,
@JsonProperty("firstName") String firstName,
@JsonProperty("middleName") String middleName,
@JsonProperty("lastName") String lastName,
@JsonProperty("suffix") String suffix,
@JsonProperty("birthDate") LocalDate birthDate,
@JsonProperty("address") StreetAddress address,
@JsonProperty("country") String country,
@JsonProperty("telephone") String telephone,
@JsonProperty("phoneNumbers") List<PhoneNumberInput> phoneNumbers,
@JsonProperty("role") String role,
@JsonProperty("email") String email,
@JsonProperty("emails") List<String> emails,
@JsonProperty("race") String race,
@JsonProperty("ethnicity") String ethnicity,
@JsonProperty("tribalAffiliation") String tribalAffiliation,
@JsonProperty("gender") String gender,
@JsonProperty("genderIdentity") String genderIdentity,
@JsonProperty("residentCongregateSetting") Boolean residentCongregateSetting,
@JsonProperty("employedInHealthcare") Boolean employedInHealthcare,
@JsonProperty("preferredLanguage") String preferredLanguage,
@JsonProperty("testResultDelivery") TestResultDeliveryPreference testResultDelivery) {
super(
address,
country,
telephone,
phoneNumbers,
parsePersonRole(role, false),
email,
emails,
race,
ethnicity,
tribalAffiliation,
gender,
genderIdentity,
residentCongregateSetting,
employedInHealthcare,
preferredLanguage,
testResultDelivery);
this.registrationLink = registrationLink;
this.lookupId = lookupId;
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.suffix = suffix;
this.birthDate = birthDate;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
PatientSelfRegistration that = (PatientSelfRegistration) o;
return Objects.equals(registrationLink, that.registrationLink)
&& Objects.equals(lookupId, that.lookupId)
&& Objects.equals(firstName, that.firstName)
&& Objects.equals(middleName, that.middleName)
&& Objects.equals(lastName, that.lastName)
&& Objects.equals(suffix, that.suffix)
&& Objects.equals(birthDate, that.birthDate)
&& Objects.equals(getAddress(), that.getAddress())
&& Objects.equals(getCountry(), that.getCountry())
&& Objects.equals(getTelephone(), that.getTelephone())
&& Objects.equals(getPhoneNumbers(), that.getPhoneNumbers())
&& getRole() == that.getRole()
&& Objects.equals(getEmail(), that.getEmail())
&& Objects.equals(getRace(), that.getRace())
&& Objects.equals(getEthnicity(), that.getEthnicity())
&& Objects.equals(getTribalAffiliation(), that.getTribalAffiliation())
&& Objects.equals(getGender(), that.getGender())
&& Objects.equals(getGenderIdentity(), that.getGenderIdentity())
&& Objects.equals(getResidentCongregateSetting(), that.getResidentCongregateSetting())
&& Objects.equals(getEmployedInHealthcare(), that.getEmployedInHealthcare())
&& Objects.equals(getPreferredLanguage(), that.getPreferredLanguage());
}

@Override
public int hashCode() {
return Objects.hash(
registrationLink,
lookupId,
firstName,
middleName,
lastName,
suffix,
birthDate,
getAddress(),
getCountry(),
getTelephone(),
getPhoneNumbers(),
getRole(),
getEmail(),
getRace(),
getEthnicity(),
getTribalAffiliation(),
getGender(),
getGenderIdentity(),
getResidentCongregateSetting(),
getEmployedInHealthcare(),
getPreferredLanguage());
}
}
public record PatientSelfRegistration(
String registrationLink,
String lookupId,
String firstName,
String middleName,
String lastName,
String suffix,
LocalDate birthDate,
StreetAddress address,
String country,
String telephone,
List<PhoneNumberInput> phoneNumbers,
String role,
String email,
List<String> emails,
String race,
String ethnicity,
String tribalAffiliation,
String gender,
String genderIdentity,
Boolean residentCongregateSetting,
Boolean employedInHealthcare,
String preferredLanguage,
TestResultDeliveryPreference testResultDelivery) {}
Original file line number Diff line number Diff line change
@@ -1,41 +1,6 @@
package gov.cdc.usds.simplereport.service.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.LocalDate;

public class ExistingPatientCheckRequestBody {
private final String firstName;
private final String lastName;
private final LocalDate birthDate;
private final String postalCode;

@JsonCreator
public ExistingPatientCheckRequestBody(
@JsonProperty("firstName") String firstName,
@JsonProperty("lastName") String lastName,
@JsonProperty("birthDate") LocalDate birthDate,
@JsonProperty("postalCode") String postalCode) {

this.firstName = firstName;
this.lastName = lastName;
this.birthDate = birthDate;
this.postalCode = postalCode;
}

public String getFirstName() {
return firstName;
}

public String getLastName() {
return lastName;
}

public LocalDate getBirthDate() {
return birthDate;
}

public String getPostalCode() {
return postalCode;
}
}
public record ExistingPatientCheckRequestBody(
String firstName, String lastName, LocalDate birthDate, String postalCode) {}
Loading

0 comments on commit 7620c47

Please sign in to comment.