diff --git a/src/main/java/seedu/address/logic/parser/AddCommandParser.java b/src/main/java/seedu/address/logic/parser/AddCommandParser.java index c3ffec4057f..540148627be 100644 --- a/src/main/java/seedu/address/logic/parser/AddCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddCommandParser.java @@ -2,7 +2,14 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.Messages.MESSAGE_REQUIRED_COMMAND_NOT_FOUND_FORMAT; -import static seedu.address.logic.parser.CliSyntax.*; +import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_BIRTHDAY; +import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; +import static seedu.address.logic.parser.CliSyntax.PREFIX_IC_NUMBER; +import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; +import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; +import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; import java.util.ArrayList; import java.util.Arrays; @@ -13,7 +20,14 @@ import seedu.address.logic.commands.AddCommand; import seedu.address.logic.parser.exceptions.ParseException; -import seedu.address.model.patient.*; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Birthday; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Gender; +import seedu.address.model.patient.IcNumber; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; /** @@ -23,8 +37,8 @@ public class AddCommandParser implements Parser { public static final Prefix[] RELEVANT_PREFIXES = new Prefix[]{PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_GENDER, PREFIX_IC_NUMBER, PREFIX_BIRTHDAY, PREFIX_ADDRESS, PREFIX_TAG}; - public static final Prefix[] RELEVANT_PREFIXES_WITHOUT_TAG = new Prefix[]{PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL - , PREFIX_GENDER, PREFIX_IC_NUMBER, PREFIX_BIRTHDAY, PREFIX_ADDRESS}; + public static final Prefix[] RELEVANT_PREFIXES_WITHOUT_TAG = new Prefix[]{PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, + PREFIX_GENDER, PREFIX_IC_NUMBER, PREFIX_BIRTHDAY, PREFIX_ADDRESS}; public static final Prefix[] REQUIRED_PREFIXES = new Prefix[]{PREFIX_NAME}; public static final Prefix[] OPTIONAL_PREFIXES = new Prefix[]{PREFIX_PHONE, PREFIX_EMAIL, PREFIX_GENDER, @@ -60,7 +74,7 @@ public static Prefix[] getPrefixesPresent(ArgumentMultimap argMultimap) { * @throws ParseException if the user input does not conform the expected format */ public static Patient createPatientFromPrefixes(ArgumentMultimap argMultimap, Prefix[] prefixes) - throws ParseException { + throws ParseException { // filling the fields with default values Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()); Phone phone = new Phone(Phone.DEFAULT_PHONE); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 4a6548bea7d..06968d8b10a 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -4,16 +4,12 @@ import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; import static seedu.address.logic.parser.CliSyntax.PREFIX_BIRTHDAY; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DEPARTMENT; -import static seedu.address.logic.parser.CliSyntax.PREFIX_DIAGNOSIS; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; import static seedu.address.logic.parser.CliSyntax.PREFIX_IC_NUMBER; -import static seedu.address.logic.parser.CliSyntax.PREFIX_INITIAL_OBSERVATION; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; -import static seedu.address.logic.parser.CliSyntax.PREFIX_TREATMENT_PLAN; import java.util.Collection; import java.util.Collections; diff --git a/src/main/java/seedu/address/model/patient/Address.java b/src/main/java/seedu/address/model/patient/Address.java index 9fc3a364b42..419eaa72cba 100644 --- a/src/main/java/seedu/address/model/patient/Address.java +++ b/src/main/java/seedu/address/model/patient/Address.java @@ -16,9 +16,9 @@ public class Address { * otherwise " " (a blank string) becomes a valid input. */ public static final String VALIDATION_REGEX = "[^\\s].*"; + public static final String DEFAULT_ADDRESS = "No address was added"; public final String value; - public static String DEFAULT_ADDRESS = "No address was added"; /** * Constructs an {@code Address}. diff --git a/src/main/java/seedu/address/model/patient/Age.java b/src/main/java/seedu/address/model/patient/Age.java index dda957f283b..3c70352dc66 100644 --- a/src/main/java/seedu/address/model/patient/Age.java +++ b/src/main/java/seedu/address/model/patient/Age.java @@ -11,7 +11,7 @@ public class Age { public static final String MESSAGE_CONSTRAINTS = "Age should only contain numbers, and it should not be negative"; public static final String VALIDATION_REGEX = "\\d+"; - public static String DEFAULT_AGE = "00"; + public static final String DEFAULT_AGE = "00"; public final String value; /** diff --git a/src/main/java/seedu/address/model/patient/Birthday.java b/src/main/java/seedu/address/model/patient/Birthday.java index 05f65503e40..d1ad2e82850 100644 --- a/src/main/java/seedu/address/model/patient/Birthday.java +++ b/src/main/java/seedu/address/model/patient/Birthday.java @@ -14,10 +14,10 @@ public class Birthday { public static final String MESSAGE_CONSTRAINTS = "Birth dates should only contain numbers in valid dd/MM/yyyy format"; public static final String VALIDATION_REGEX = "\\d{1,2}\\/\\d{1,2}\\/\\d{2,4}"; + public static final String DEFAULT_BIRTHDAY = "01/01/2000"; public final LocalDate value; public final String strValue; private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - public static String DEFAULT_BIRTHDAY = "01/01/2000"; /** * Constructs a {@code Birthday}. * diff --git a/src/main/java/seedu/address/model/patient/Email.java b/src/main/java/seedu/address/model/patient/Email.java index 1906af4c96f..7bec4e2d014 100644 --- a/src/main/java/seedu/address/model/patient/Email.java +++ b/src/main/java/seedu/address/model/patient/Email.java @@ -9,6 +9,7 @@ */ public class Email { + public static final String DEFAULT_EMAIL = "default_email@gmail.com"; private static final String SPECIAL_CHARACTERS = "+_.-"; public static final String MESSAGE_CONSTRAINTS = "Emails should be of the format local-part@domain " + "and adhere to the following constraints:\n" @@ -30,7 +31,7 @@ public class Email { private static final String DOMAIN_LAST_PART_REGEX = "(" + DOMAIN_PART_REGEX + "){2,}$"; // At least two chars private static final String DOMAIN_REGEX = "(" + DOMAIN_PART_REGEX + "\\.)*" + DOMAIN_LAST_PART_REGEX; public static final String VALIDATION_REGEX = LOCAL_PART_REGEX + "@" + DOMAIN_REGEX; - public static String DEFAULT_EMAIL = "default_email@gmail.com"; + public final String value; /** diff --git a/src/main/java/seedu/address/model/patient/Gender.java b/src/main/java/seedu/address/model/patient/Gender.java index 39e9807fc06..15a0a755128 100644 --- a/src/main/java/seedu/address/model/patient/Gender.java +++ b/src/main/java/seedu/address/model/patient/Gender.java @@ -12,7 +12,7 @@ public class Gender { "Gender should only be MALE, FEMALE or OTHER, and it should not be blank"; public static final String VALIDATION_REGEX = "\\p{Alnum}*"; - public static String DEFAULT_GENDER = "OTHER"; + public static final String DEFAULT_GENDER = "OTHER"; public final String value; enum Genders { diff --git a/src/main/java/seedu/address/model/patient/IcNumber.java b/src/main/java/seedu/address/model/patient/IcNumber.java index c86a3373689..e910c81e8cc 100644 --- a/src/main/java/seedu/address/model/patient/IcNumber.java +++ b/src/main/java/seedu/address/model/patient/IcNumber.java @@ -11,7 +11,7 @@ public class IcNumber { public static final String MESSAGE_CONSTRAINTS = "IC Number should start and end with an alphabet with non negative numbers in between"; public static final String VALIDATION_REGEX = "^[A-Z]\\d{7}[A-Z]$"; - public static String DEFAULT_IC_NUMBER = "t0000000a"; + public static final String DEFAULT_IC_NUMBER = "t0000000a"; public final String value; /** diff --git a/src/main/java/seedu/address/model/patient/Phone.java b/src/main/java/seedu/address/model/patient/Phone.java index a038ff44474..654781a27d5 100644 --- a/src/main/java/seedu/address/model/patient/Phone.java +++ b/src/main/java/seedu/address/model/patient/Phone.java @@ -13,7 +13,7 @@ public class Phone { public static final String MESSAGE_CONSTRAINTS = "Phone numbers should only contain numbers, and it should be at least 3 digits long"; public static final String VALIDATION_REGEX = "\\d{3,}"; - public static String DEFAULT_PHONE = "00000000"; + public static final String DEFAULT_PHONE = "00000000"; public final String value; /** diff --git a/src/main/java/seedu/address/model/patient/Record.java b/src/main/java/seedu/address/model/patient/Record.java index 6867496d360..e7c501fda1e 100644 --- a/src/main/java/seedu/address/model/patient/Record.java +++ b/src/main/java/seedu/address/model/patient/Record.java @@ -8,9 +8,9 @@ */ public class Record { - public static String DEFAULT_INITIAL_OBSERVATIONS = "No initial observations given"; - public static String DEFAULT_DIAGNOSIS = "No diagnosis given"; - public static String DEFAULT_TREATMENT_PLAN = "No treatment plan given"; + public static final String DEFAULT_INITIAL_OBSERVATIONS = "No initial observations given"; + public static final String DEFAULT_DIAGNOSIS = "No diagnosis given"; + public static final String DEFAULT_TREATMENT_PLAN = "No treatment plan given"; private final Patient patient; private String initialObservations; @@ -27,6 +27,9 @@ public Record(Patient patient) { this.treatmentPlan = DEFAULT_TREATMENT_PLAN; } + /** + * Initializes a Record with a null patient and initialise the fields with default values + */ public Record() { this.patient = null; // patient left null, would have to fix when building editing record command this.initialObservations = DEFAULT_INITIAL_OBSERVATIONS; diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 4672a6d5610..97c757067d5 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -6,7 +6,14 @@ import seedu.address.model.AddressBook; import seedu.address.model.ReadOnlyAddressBook; -import seedu.address.model.patient.*; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Birthday; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Gender; +import seedu.address.model.patient.IcNumber; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; /** @@ -14,23 +21,32 @@ */ public class SampleDataUtil { public static Patient[] getSamplePatients() { - return new Patient[]{new Patient(new Name("Alex Yeoh"), new Phone("87438807"), - new Email("alexyeoh@example.com"), new Gender("Male"), new IcNumber("t7654321a"), - new Birthday("05/05/2005"), new Address("Blk 30 Geylang " + "Street " + "29, #06-40"), - getTagSet("friends")), new Patient(new Name("Bernice Yu"), new Phone("99272758"), - new Email("berniceyu@example.com"), new Gender("Female"), new IcNumber("s1234567b"), - new Birthday("06/06/1990"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), - getTagSet("colleagues", "friends")), new Patient(new Name("Charlotte Oliveiro"), new Phone("93210283"), - new Email("charlotte@example.com"), new Gender("Other"), new IcNumber("t1357912g"), - new Birthday("12/12/1989"), new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), - getTagSet("neighbours")), new Patient(new Name("David Li"), new Phone("91031282"), - new Email("lidavid@example.com"), new Gender("Male"), new IcNumber("s7654321p"), new Birthday("01/01/2001"), - new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), getTagSet("family")), new Patient( - new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("irfan@example.com"), new Gender("Male"), - new IcNumber("s0987654e"), new Birthday("10/10/2000"), new Address("Blk 47 Tampines Street 20, #17-35"), - getTagSet("classmates")), new Patient(new Name("Roy Balakrishnan"), new Phone("92624417"), - new Email("royb@example.com"), new Gender("Male"), new IcNumber("t6789031q"), new Birthday("07/11/1976"), - new Address("Blk 45 Aljunied Street 85, #11-31"), getTagSet("colleagues"))}; + return new Patient[]{ + new Patient(new Name("Alex Yeoh"), new Phone("87438807"), + new Email("alexyeoh@example.com"), new Gender("Male"), new IcNumber("t7654321a"), + new Birthday("05/05/2005"), new Address("Blk 30 Geylang " + "Street " + "29, #06-40"), + getTagSet("friends")), + new Patient(new Name("Bernice Yu"), new Phone("99272758"), + new Email("berniceyu@example.com"), new Gender("Female"), new IcNumber("s1234567b"), + new Birthday("06/06/1990"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), + getTagSet("colleagues", "friends")), + new Patient(new Name("Charlotte Oliveiro"), new Phone("93210283"), + new Email("charlotte@example.com"), new Gender("Other"), new IcNumber("t1357912g"), + new Birthday("12/12/1989"), new Address("Blk 11 Ang Mo Kio Street 74, #11-04"), + getTagSet("neighbours")), + new Patient(new Name("David Li"), new Phone("91031282"), + new Email("lidavid@example.com"), new Gender("Male"), + new IcNumber("s7654321p"), new Birthday("01/01/2001"), + new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), getTagSet("family")), + new Patient(new Name("Irfan Ibrahim"), new Phone("92492021"), + new Email("irfan@example.com"), new Gender("Male"), + new IcNumber("s0987654e"), new Birthday("10/10/2000"), + new Address("Blk 47 Tampines Street 20, #17-35"), + getTagSet("classmates")), + new Patient(new Name("Roy Balakrishnan"), new Phone("92624417"), + new Email("royb@example.com"), new Gender("Male"), + new IcNumber("t6789031q"), new Birthday("07/11/1976"), + new Address("Blk 45 Aljunied Street 85, #11-31"), getTagSet("colleagues"))}; } public static ReadOnlyAddressBook getSampleAddressBook() { diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPatient.java b/src/main/java/seedu/address/storage/JsonAdaptedPatient.java index b62b3b8790a..8c28b694f91 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPatient.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPatient.java @@ -10,7 +10,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.patient.*; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.Birthday; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Gender; +import seedu.address.model.patient.IcNumber; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; import seedu.address.model.tag.Tag; /** diff --git a/src/test/java/seedu/address/testutil/PatientBuilder.java b/src/test/java/seedu/address/testutil/PatientBuilder.java index 92ddab0fd3d..d4af378f6bd 100644 --- a/src/test/java/seedu/address/testutil/PatientBuilder.java +++ b/src/test/java/seedu/address/testutil/PatientBuilder.java @@ -3,7 +3,16 @@ import java.util.HashSet; import java.util.Set; -import seedu.address.model.patient.*; +import seedu.address.model.patient.Address; +import seedu.address.model.patient.AssignedDepartment; +import seedu.address.model.patient.Birthday; +import seedu.address.model.patient.Email; +import seedu.address.model.patient.Gender; +import seedu.address.model.patient.IcNumber; +import seedu.address.model.patient.Name; +import seedu.address.model.patient.Patient; +import seedu.address.model.patient.Phone; +import seedu.address.model.patient.Record; import seedu.address.model.tag.Tag; import seedu.address.model.util.SampleDataUtil;