From 8233415c5131ae5ba8204f95e8d85a6b58701e17 Mon Sep 17 00:00:00 2001 From: Jingya Date: Wed, 18 Oct 2023 01:59:04 +0800 Subject: [PATCH 1/4] Fix inconsistencies in EditCommand and EditCommandParser Currently, the EditCommand and EditCommandParser classes are inconsistent in that they contain methods that process patient attributes that are not parameters into the Edit command, or certain parts lack the processing of important attributes. Fixing this issue will prevent further bugs and lead to neater code. Let's, * Add and remove attributes in the two classes for consistency * Make sure that important attributes are mentioned in parts that were previously lacking them --- .../address/logic/commands/EditCommand.java | 82 ++++++++----------- .../logic/parser/EditCommandParser.java | 18 +--- 2 files changed, 38 insertions(+), 62 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index d8595735a98..1f1a635a1ab 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -2,7 +2,10 @@ import static java.util.Objects.requireNonNull; 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; @@ -22,7 +25,6 @@ import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; 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; @@ -30,7 +32,6 @@ 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; /** @@ -43,10 +44,16 @@ public class EditCommand extends Command { public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the patient identified " + "by the index number used in the displayed patient list. " + "Existing values will be overwritten by the input values.\n" - + "Parameters: INDEX (must be a positive integer) " + "[" + PREFIX_NAME + "NAME] " + "[" + PREFIX_PHONE - + "PHONE] " + "[" + PREFIX_EMAIL + "EMAIL] " + "[" + PREFIX_ADDRESS + "ADDRESS] " + "[" + PREFIX_TAG - + "TAG]...\n" + "Example: " + COMMAND_WORD + " 1 " + PREFIX_PHONE + "91234567 " + PREFIX_EMAIL - + "johndoe@example.com"; + + "Parameters: INDEX (must be a positive integer) " + + "[" + PREFIX_NAME + "NAME] " + + "[" + PREFIX_PHONE + "PHONE] " + + "[" + PREFIX_EMAIL + "EMAIL] " + + "[" + PREFIX_GENDER + "GENDER] " + + "[" + PREFIX_IC_NUMBER + "IC_NUMBER] " + + "[" + PREFIX_BIRTHDAY + "BIRTHDAY] " + + "[" + PREFIX_ADDRESS + "ADDRESS] " + + "[" + PREFIX_TAG + "TAG]...\n" + + "Example: " + COMMAND_WORD + " 1 " + PREFIX_PHONE + "91234567 " + PREFIX_EMAIL + "johndoe@example.com"; public static final String MESSAGE_EDIT_PATIENT_SUCCESS = "Edited Patient: %1$s"; public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; @@ -102,13 +109,10 @@ private static Patient createEditedPatient(Patient patientToEdit, EditPatientDes IcNumber updatedIcNumber = editPatientDescriptor.getIcNumber().orElse(patientToEdit.getIcNumber()); Birthday updatedBirthday = editPatientDescriptor.getBirthday().orElse(patientToEdit.getBirthday()); Address updatedAddress = editPatientDescriptor.getAddress().orElse(patientToEdit.getAddress()); -// AssignedDepartment updatedDepartment = editPatientDescriptor.getDepartment() -// .orElse(patientToEdit.getAssignedDepartment()); Set updatedTags = editPatientDescriptor.getTags().orElse(patientToEdit.getTags()); -// Record updatedRecord = editPatientDescriptor.getRecord().orElse(patientToEdit.getRecord()); return new Patient(updatedName, updatedPhone, updatedEmail, updatedGender, updatedIcNumber, updatedBirthday, - updatedAddress, updatedTags); + updatedAddress, updatedTags); } @@ -147,8 +151,6 @@ public static class EditPatientDescriptor { private Birthday birthday; private Address address; private Set tags; - private AssignedDepartment department; - private Record record; public EditPatientDescriptor() { } @@ -161,6 +163,9 @@ public EditPatientDescriptor(EditPatientDescriptor toCopy) { setName(toCopy.name); setPhone(toCopy.phone); setEmail(toCopy.email); + setGender(toCopy.gender); + setIcNumber(toCopy.icNumber); + setBirthday(toCopy.birthday); setAddress(toCopy.address); setTags(toCopy.tags); } @@ -169,7 +174,7 @@ public EditPatientDescriptor(EditPatientDescriptor toCopy) { * Returns true if at least one field is edited. */ public boolean isAnyFieldEdited() { - return CollectionUtil.isAnyNonNull(name, phone, email, address, tags); + return CollectionUtil.isAnyNonNull(name, phone, email, gender, icNumber, birthday, address, tags); } public void setName(Name name) { @@ -204,26 +209,6 @@ public Optional
getAddress() { return Optional.ofNullable(address); } - public void setRecord(Record record) { - this.record = record; - } - - public void setInitialObservation(String initialObservation) { - record.setInitialObservations(initialObservation); - } - - public void setTreatmentPlan(String treatmentPlan) { - record.setTreatmentPlan(treatmentPlan); - } - - public void setDiagnosis(String diagnosis) { - record.setDiagnosis(diagnosis); - } - - public Optional getRecord() { - return Optional.ofNullable(record); - } - /** * Sets {@code tags} to this object's {@code tags}. * A defensive copy of {@code tags} is used internally. @@ -253,10 +238,14 @@ public boolean equals(Object other) { } EditPatientDescriptor otherEditPatientDescriptor = (EditPatientDescriptor) other; - return Objects.equals(name, otherEditPatientDescriptor.name) && Objects.equals(phone, - otherEditPatientDescriptor.phone) && Objects.equals(email, otherEditPatientDescriptor.email) - && Objects.equals(address, otherEditPatientDescriptor.address) && Objects.equals(tags, - otherEditPatientDescriptor.tags); + return Objects.equals(name, otherEditPatientDescriptor.name) + && Objects.equals(phone, otherEditPatientDescriptor.phone) + && Objects.equals(email, otherEditPatientDescriptor.email) + && Objects.equals(gender, otherEditPatientDescriptor.gender) + && Objects.equals(icNumber, otherEditPatientDescriptor.icNumber) + && Objects.equals(birthday, otherEditPatientDescriptor.birthday) + && Objects.equals(address, otherEditPatientDescriptor.address) + && Objects.equals(tags, otherEditPatientDescriptor.tags); } public void setGender(Gender gender) { @@ -283,18 +272,17 @@ public Optional getIcNumber() { return Optional.ofNullable(icNumber); } - public void setDepartment(AssignedDepartment department) { - this.department = department; - } - - public Optional getDepartment() { - return Optional.ofNullable(department); - } - @Override public String toString() { - return new ToStringBuilder(this).add("name", name).add("phone", phone).add("email", email) - .add("address", address).add("tags", tags).toString(); + return new ToStringBuilder(this) + .add("name", name) + .add("phone", phone) + .add("email", email) + .add("gender", gender) + .add("icNumber", icNumber) + .add("birthday", birthday) + .add("address", address) + .add("tags", tags).toString(); } } } diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index e212ea952d9..4a6548bea7d 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -41,7 +41,7 @@ public class EditCommandParser implements Parser { public EditCommand parse(String args) throws ParseException { requireNonNull(args); ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, - PREFIX_ADDRESS, PREFIX_TAG, PREFIX_GENDER, PREFIX_BIRTHDAY, PREFIX_IC_NUMBER, PREFIX_DEPARTMENT); + PREFIX_ADDRESS, PREFIX_TAG, PREFIX_GENDER, PREFIX_BIRTHDAY, PREFIX_IC_NUMBER); Index index; @@ -51,7 +51,8 @@ public EditCommand parse(String args) throws ParseException { throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe); } - argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS); + argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_GENDER, + PREFIX_IC_NUMBER, PREFIX_BIRTHDAY, PREFIX_ADDRESS); EditPatientDescriptor editPatientDescriptor = new EditPatientDescriptor(); @@ -76,19 +77,6 @@ public EditCommand parse(String args) throws ParseException { if (argMultimap.getValue(PREFIX_IC_NUMBER).isPresent()) { editPatientDescriptor.setIcNumber(ParserUtil.parseIcNumber(argMultimap.getValue(PREFIX_IC_NUMBER).get())); } - if (argMultimap.getValue(PREFIX_DEPARTMENT).isPresent()) { - editPatientDescriptor.setDepartment( - ParserUtil.parseAssignedDepartment(argMultimap.getValue(PREFIX_DEPARTMENT).get())); - } - if (argMultimap.getValue(PREFIX_INITIAL_OBSERVATION).isPresent()) { - editPatientDescriptor.setInitialObservation(argMultimap.getValue(PREFIX_INITIAL_OBSERVATION).get()); - } - if (argMultimap.getValue(PREFIX_DIAGNOSIS).isPresent()) { - editPatientDescriptor.setDiagnosis(argMultimap.getValue(PREFIX_DIAGNOSIS).get()); - } - if (argMultimap.getValue(PREFIX_TREATMENT_PLAN).isPresent()) { - editPatientDescriptor.setTreatmentPlan(argMultimap.getValue(PREFIX_TREATMENT_PLAN).get()); - } parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPatientDescriptor::setTags); From 5363de701125ad364fefcb9a3841ccb0c7318899 Mon Sep 17 00:00:00 2001 From: Jingya Date: Wed, 18 Oct 2023 02:49:00 +0800 Subject: [PATCH 2/4] Fix StackOverflow bug involving PatientBuilder and RecordBuilder There is an issue where after PatientBuilder() is called, it will call RecordBuilder(), which in turn calls PatientBuilder() again, causing a StackOverflow error. We need to fix this to get our test cases to pass. Let's * Add a new constructor to RecordBuilder that takes in a PatientBuilder to initialize its patient, instead of calling PatientBuilder again * Add new attributes to TypicalPatients Note that not all of the fields in Typical Patients are updated! AMY and BOB still need to be updated, which involves adding new attributes into CommandTestUtilgit add --all --- .../address/testutil/PatientBuilder.java | 2 +- .../seedu/address/testutil/RecordBuilder.java | 10 ++ .../address/testutil/TypicalPatients.java | 107 ++++++++++++++---- 3 files changed, 96 insertions(+), 23 deletions(-) diff --git a/src/test/java/seedu/address/testutil/PatientBuilder.java b/src/test/java/seedu/address/testutil/PatientBuilder.java index fa02ebfbd39..92ddab0fd3d 100644 --- a/src/test/java/seedu/address/testutil/PatientBuilder.java +++ b/src/test/java/seedu/address/testutil/PatientBuilder.java @@ -44,7 +44,7 @@ public PatientBuilder() { address = new Address(DEFAULT_ADDRESS); tags = new HashSet<>(); assignedDepartment = new AssignedDepartment(); - record = new RecordBuilder().build(); + record = new RecordBuilder(this).build(); } /** diff --git a/src/test/java/seedu/address/testutil/RecordBuilder.java b/src/test/java/seedu/address/testutil/RecordBuilder.java index 734b3bf2d99..6ad0b33b535 100644 --- a/src/test/java/seedu/address/testutil/RecordBuilder.java +++ b/src/test/java/seedu/address/testutil/RecordBuilder.java @@ -23,6 +23,16 @@ public RecordBuilder() { this.treatmentPlan = Record.DEFAULT_TREATMENT_PLAN; } + /** + * Creates a {@code RecordBuilder} with the specified {@code PatientBuilder} and the default details. + */ + public RecordBuilder(PatientBuilder patient) { + this.patient = patient.build(); + this.initialObservations = Record.DEFAULT_INITIAL_OBSERVATIONS; + this.diagnosis = Record.DEFAULT_DIAGNOSIS; + this.treatmentPlan = Record.DEFAULT_TREATMENT_PLAN; + } + /** * Initializes the RecordBuilder with the data of {@code recordToCopy}. */ diff --git a/src/test/java/seedu/address/testutil/TypicalPatients.java b/src/test/java/seedu/address/testutil/TypicalPatients.java index cb26142db02..f13bb985c78 100644 --- a/src/test/java/seedu/address/testutil/TypicalPatients.java +++ b/src/test/java/seedu/address/testutil/TypicalPatients.java @@ -23,36 +23,99 @@ */ public class TypicalPatients { - public static final Patient ALICE = new PatientBuilder().withName("Alice Pauline") - .withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com") + public static final Patient ALICE = new PatientBuilder() + .withName("Alice Pauline") + .withAddress("123, Jurong West Ave 6, #08-111") + .withEmail("alice@example.com") + .withGender("female") + .withBirthday("23/09/2000") + .withIcNumber("T0032415E") .withPhone("94351253") .withTags("friends").build(); - public static final Patient BENSON = new PatientBuilder().withName("Benson Meier") + public static final Patient BENSON = new PatientBuilder() + .withName("Benson Meier") .withAddress("311, Clementi Ave 2, #02-25") - .withEmail("johnd@example.com").withPhone("98765432") + .withEmail("johnd@example.com") + .withGender("male") + .withBirthday("17/03/1987") + .withIcNumber("S2091742P") + .withPhone("98765432") .withTags("owesMoney", "friends").build(); - public static final Patient CARL = new PatientBuilder().withName("Carl Kurz").withPhone("95352563") - .withEmail("heinz@example.com").withAddress("wall street").build(); - public static final Patient DANIEL = new PatientBuilder().withName("Daniel Meier").withPhone("87652533") - .withEmail("cornelia@example.com").withAddress("10th street").withTags("friends").build(); - public static final Patient ELLE = new PatientBuilder().withName("Elle Meyer").withPhone("9482224") - .withEmail("werner@example.com").withAddress("michegan ave").build(); - public static final Patient FIONA = new PatientBuilder().withName("Fiona Kunz").withPhone("9482427") - .withEmail("lydia@example.com").withAddress("little tokyo").build(); - public static final Patient GEORGE = new PatientBuilder().withName("George Best").withPhone("9482442") - .withEmail("anna@example.com").withAddress("4th street").build(); + public static final Patient CARL = new PatientBuilder() + .withName("Carl Kurz") + .withPhone("95352563") + .withGender("male") + .withBirthday("08/06/1997") + .withIcNumber("S2780456R") + .withEmail("heinz@example.com") + .withAddress("wall street").build(); + public static final Patient DANIEL = new PatientBuilder() + .withName("Daniel Meier") + .withPhone("87652533") + .withGender("male") + .withBirthday("29/01/2001") + .withIcNumber("T0163826D") + .withEmail("cornelia@example.com") + .withAddress("10th street") + .withTags("friends").build(); + public static final Patient ELLE = new PatientBuilder() + .withName("Elle Meyer") + .withPhone("9482224") + .withGender("female") + .withBirthday("12/11/1995") + .withIcNumber("S1839267A") + .withEmail("werner@example.com") + .withAddress("michegan ave") + .build(); + public static final Patient FIONA = new PatientBuilder() + .withName("Fiona Kunz") + .withPhone("9482427") + .withEmail("lydia@example.com") + .withGender("female") + .withBirthday("29/06/1982") + .withIcNumber("S3729462N") + .withAddress("little tokyo") + .build(); + public static final Patient GEORGE = new PatientBuilder() + .withName("George Best") + .withPhone("9482442") + .withGender("male") + .withBirthday("03/07/1997") + .withIcNumber("S4839258F") + .withEmail("anna@example.com") + .withAddress("4th street").build(); // Manually added - public static final Patient HOON = new PatientBuilder().withName("Hoon Meier").withPhone("8482424") - .withEmail("stefan@example.com").withAddress("little india").build(); - public static final Patient IDA = new PatientBuilder().withName("Ida Mueller").withPhone("8482131") - .withEmail("hans@example.com").withAddress("chicago ave").build(); + public static final Patient HOON = new PatientBuilder() + .withName("Hoon Meier") + .withPhone("8482424") + .withGender("male") + .withBirthday("07/04/2002") + .withIcNumber("T0247382S") + .withEmail("stefan@example.com") + .withAddress("little india").build(); + public static final Patient IDA = new PatientBuilder() + .withName("Ida Mueller") + .withPhone("8482131") + .withGender("female") + .withBirthday("29/04/1984") + .withIcNumber("S5729346L") + .withEmail("hans@example.com") + .withAddress("chicago ave").build(); // Manually added - Patient's details found in {@code CommandTestUtil} - public static final Patient AMY = new PatientBuilder().withName(VALID_NAME_AMY).withPhone(VALID_PHONE_AMY) - .withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY).withTags(VALID_TAG_FRIEND).build(); - public static final Patient BOB = new PatientBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB) - .withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) + public static final Patient AMY = new PatientBuilder() + .withName(VALID_NAME_AMY) + .withPhone(VALID_PHONE_AMY) + .withEmail(VALID_EMAIL_AMY) + .withAddress(VALID_ADDRESS_AMY) + .withTags(VALID_TAG_FRIEND).build(); + public static final Patient BOB = new PatientBuilder() + .withName(VALID_NAME_BOB) + .withPhone(VALID_PHONE_BOB) + .withEmail(VALID_EMAIL_BOB) + .withAddress(VALID_ADDRESS_BOB) + .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND) .build(); public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER From 9e0710cc9ef25dd045a69ec9552907c02eb75c13 Mon Sep 17 00:00:00 2001 From: Jingya Date: Wed, 18 Oct 2023 03:01:04 +0800 Subject: [PATCH 3/4] Add new attributes to some console messages The existing console messages do not display the new attributes, confusing the user as to what attributes are available. Adding them to the messages allow them to view all the patient's attributes even without the updated GUI. Let's update the Add command and patient messages. --- src/main/java/seedu/address/logic/Messages.java | 8 ++++++++ .../java/seedu/address/logic/commands/AddCommand.java | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java index 297aee7f3f5..2bc71375c85 100644 --- a/src/main/java/seedu/address/logic/Messages.java +++ b/src/main/java/seedu/address/logic/Messages.java @@ -43,8 +43,16 @@ public static String format(Patient patient) { .append(patient.getPhone()) .append("; Email: ") .append(patient.getEmail()) + .append("; Gender: ") + .append(patient.getGender()) + .append("; IC Number: ") + .append(patient.getIcNumber()) + .append("; Birthday: ") + .append(patient.getBirthday()) .append("; Address: ") .append(patient.getAddress()) + .append("; Department: ") + .append(patient.getAssignedDepartment()) .append("; Tags: "); patient.getTags().forEach(builder::append); return builder.toString(); diff --git a/src/main/java/seedu/address/logic/commands/AddCommand.java b/src/main/java/seedu/address/logic/commands/AddCommand.java index d41e67de48e..a8a0d2175d2 100644 --- a/src/main/java/seedu/address/logic/commands/AddCommand.java +++ b/src/main/java/seedu/address/logic/commands/AddCommand.java @@ -2,7 +2,10 @@ import static java.util.Objects.requireNonNull; 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; @@ -25,12 +28,18 @@ public class AddCommand extends Command { + PREFIX_NAME + "NAME " + PREFIX_PHONE + "PHONE " + PREFIX_EMAIL + "EMAIL " + + PREFIX_GENDER + "GENDER " + + PREFIX_IC_NUMBER + "IC_NUMBER " + + PREFIX_BIRTHDAY + "BIRTHDAY " + PREFIX_ADDRESS + "ADDRESS " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " " + PREFIX_NAME + "John Doe " + PREFIX_PHONE + "98765432 " + PREFIX_EMAIL + "johnd@example.com " + + PREFIX_GENDER + "MALE " + + PREFIX_IC_NUMBER + "S2840182A " + + PREFIX_BIRTHDAY + "02/01/1998 " + PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 " + PREFIX_TAG + "friends " + PREFIX_TAG + "owesMoney"; From fe155627ac6c03f46498fe7cfb0f81b737d858b7 Mon Sep 17 00:00:00 2001 From: Jingya Date: Wed, 18 Oct 2023 03:35:02 +0800 Subject: [PATCH 4/4] Fix CheckStyle Issues --- .../logic/parser/AddCommandParser.java | 24 +++++++-- .../logic/parser/EditCommandParser.java | 4 -- .../seedu/address/model/patient/Address.java | 2 +- .../java/seedu/address/model/patient/Age.java | 2 +- .../seedu/address/model/patient/Birthday.java | 2 +- .../seedu/address/model/patient/Email.java | 3 +- .../seedu/address/model/patient/Gender.java | 2 +- .../seedu/address/model/patient/IcNumber.java | 2 +- .../seedu/address/model/patient/Phone.java | 2 +- .../seedu/address/model/patient/Record.java | 9 ++-- .../address/model/util/SampleDataUtil.java | 52 ++++++++++++------- .../address/storage/JsonAdaptedPatient.java | 9 +++- .../address/testutil/PatientBuilder.java | 11 +++- 13 files changed, 85 insertions(+), 39 deletions(-) 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;