Skip to content

Commit

Permalink
Merge branch 'master' into update-jsonadaptedperson-optional
Browse files Browse the repository at this point in the history
  • Loading branch information
jovantanyk authored Mar 21, 2024
2 parents 20dee78 + 03498c4 commit e743c02
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/person/DateOfAdmission.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/
public class DateOfAdmission {
public static final String MESSAGE_CONSTRAINTS =
"Date of admission should be in the format of DD/MM/YYYY, and it should not be blank.";
"Date of admission should be in the format of YYYY-MM-DD, and it should not be blank.";

public static final String VALIDATION_REGEX = "^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/\\d{4}$";
public static final String VALIDATION_REGEX = "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$";

private final LocalDate dateOfAdmission;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* Guarantees: details are present and not null, field values are validated, immutable.
*/
public class Person {

//Mandatory fields
//Identity fields
private final Nric nric;
Expand Down Expand Up @@ -51,6 +50,7 @@ public Person(Nric nric, Name name, Phone phone, Address address, DateOfBirth da
this.sex = sex;
this.status = status;
}

public Nric getNric() {
return nric;
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class JsonAdaptedPerson {
public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!";
private final String name;
private final String phone;
//TODO: add final, resolve the "may have not been initialized" error
private final String nric;
private final String sex;
private final String status;
Expand Down
135 changes: 128 additions & 7 deletions src/test/java/seedu/address/testutil/PersonBuilder.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
package seedu.address.testutil;


import seedu.address.model.person.Address;
import seedu.address.model.person.Allergies;
import seedu.address.model.person.BloodType;
import seedu.address.model.person.Condition;
import seedu.address.model.person.Country;
import seedu.address.model.person.DateOfAdmission;
import seedu.address.model.person.DateOfBirth;
import seedu.address.model.person.Diagnosis;
import seedu.address.model.person.Email;
import seedu.address.model.person.Name;
import seedu.address.model.person.Nric;
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.person.Sex;
import seedu.address.model.person.Status;
import seedu.address.model.person.Symptom;

/**
* A utility class to help with building Person objects.
*/
public class PersonBuilder {

// Mandatory fields
public static final String DEFAULT_NRIC = "T1234567B";
public static final String DEFAULT_NAME = "Amy Bee";
public static final String DEFAULT_PHONE = "85355255";
public static final String DEFAULT_EMAIL = "[email protected]";
public static final String DEFAULT_DOB = "1998-07-03";
public static final String DEFAULT_SEX = "M";
// Data fields
public static final String DEFAULT_ADDRESS = "123, Jurong West Ave 6, #08-111";
public static final String DEFAULT_ALLERGIES = "Peanuts";
public static final String[] DEFAULT_BLOODTYPE = {"A", "POSITIVE"};
public static final String DEFAULT_COUNTRY = "Singapore";
// Medical history
public static final String DEFAULT_CONDITION = "High blood pressure";
public static final String DEFAULT_DOA = "2024-01-01";
public static final String DEFAULT_DIAGNOSIS = "Runny nose";
public static final String DEFAULT_STATUS = "HEALTHY";
public static final String DEFAULT_SYMPTOM = "Sneezing, sniffing";

// Mandatory fields
private Nric nric;
private Name name;
private Phone phone;
private Address address;
private DateOfBirth dateOfBirth;
private Sex sex;
// Data fields
private Address address;
private Allergies allergies;
private BloodType bloodType;
private Country country;
private Email email;
//Medical history
private Condition condition;
private DateOfAdmission dateOfAdmission;
private Diagnosis diagnosis;
private Status status;
private Symptom symptom;

/**
* Creates a {@code PersonBuilder} with the default details.
Expand All @@ -40,21 +69,41 @@ public PersonBuilder() {
address = new Address(DEFAULT_ADDRESS);
dateOfBirth = new DateOfBirth(DEFAULT_DOB);
sex = new Sex(DEFAULT_SEX);

address = new Address(DEFAULT_ADDRESS);
allergies = new Allergies(DEFAULT_ALLERGIES);
bloodType = new BloodType(DEFAULT_BLOODTYPE[0], DEFAULT_BLOODTYPE[1]);
country = new Country(DEFAULT_COUNTRY);
email = new Email(DEFAULT_EMAIL);

condition = new Condition(DEFAULT_CONDITION);
dateOfAdmission = new DateOfAdmission(DEFAULT_DOA);
diagnosis = new Diagnosis(DEFAULT_DIAGNOSIS);
status = new Status(DEFAULT_STATUS);
symptom = new Symptom(DEFAULT_SYMPTOM);
}

/**
* Initializes the PersonBuilder with the data of {@code personToCopy}.
*/
public PersonBuilder(Person personToCopy) {
//TODO: Add the missing fields
nric = personToCopy.getNric();
name = personToCopy.getName();
phone = personToCopy.getPhone();
address = personToCopy.getAddress();
dateOfBirth = personToCopy.getDateOfBirth();
sex = personToCopy.getSex();

address = personToCopy.getAddress();
allergies = personToCopy.getAllergies();
bloodType = personToCopy.getBloodType();
country = personToCopy.getCountry();
email = personToCopy.getEmail();

condition = personToCopy.getCondition();
dateOfAdmission = personToCopy.getDateOfAdmission();
diagnosis = personToCopy.getDiagnosis();
status = personToCopy.getStatus();
symptom = personToCopy.getSymptom();
}

/**
Expand All @@ -64,6 +113,7 @@ public PersonBuilder withNric(String nric) {
this.nric = new Nric(nric);
return this;
}

/**
* Sets the {@code Name} of the {@code Person} that we are building.
*/
Expand All @@ -72,6 +122,13 @@ public PersonBuilder withName(String name) {
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withPhone(String phone) {
this.phone = new Phone(phone);
return this;
}

/**
* Sets the {@code Address} of the {@code Person} that we are building.
Expand All @@ -84,8 +141,8 @@ public PersonBuilder withAddress(String address) {
/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withPhone(String phone) {
this.phone = new Phone(phone);
public PersonBuilder withDateOfBirth(String dateOfBirth) {
this.dateOfBirth = new DateOfBirth(dateOfBirth);
return this;
}

Expand All @@ -105,6 +162,70 @@ public PersonBuilder withStatus(String status) {
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withEmail(String email) {
this.email = new Email(email);
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withCountry(String country) {
this.country = new Country(country);
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withAllergies(String allergies) {
this.allergies = new Allergies(allergies);
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withBloodType(String[] bloodType) {
this.bloodType = new BloodType(bloodType[0], bloodType[1]);
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withCondition(String condition) {
this.condition = new Condition(condition);
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withDateOfAdmission(String dateOfAdmission) {
this.dateOfAdmission = new DateOfAdmission(dateOfAdmission);
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withDiagnosis(String diagnosis) {
this.diagnosis = new Diagnosis(diagnosis);
return this;
}

/**
* Sets the {@code Phone} of the {@code Person} that we are building.
*/
public PersonBuilder withSymptom(String symptom) {
this.symptom = new Symptom(symptom);
return this;
}

public Person build() {
return new Person(nric, name, phone, address, dateOfBirth, sex, status);
}
Expand Down

0 comments on commit e743c02

Please sign in to comment.