diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 2ecb1050bac..7d825fe55a0 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -5,7 +5,7 @@ title: User Guide MediLink Contacts(MLC) is a **desktop app for managing patients and doctors details, optimized for use via a Command Line Interface** (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, MLC -can get your patients management tasks done faster than traditional GUI apps. +cang get your patients management tasks done faster than traditional GUI apps. ### Table of Contents @@ -145,7 +145,7 @@ Format: `new-appt pic/IC dic/IC time/yyyy-MM-dd HH:mm:ss` **:information_source: Take Note:**
- All fields are Required. -- EMAIL must follow the specified format (ie. `yyyy-MM-dd HH:mm:ss`). +- TIME must follow the specified format (ie. `yyyy-MM-dd HH:mm:ss`). - PATIENT must contain the valid IC of a Patient in the Database. - DOCTOR must contain the valid IC of a Doctor in the Database. @@ -175,13 +175,15 @@ Examples: ### Finding a Appointment : `find-appt` -Locates an existing appointment with involved Doctor or Patient. +Finds all appointments that involve a specific patient/doctor. Format: `find-appt NRIC`
**:information_source: Take Note:**
+- All fields are Required. +- NRIC must contain the valid NRIC of a Patient or Doctor in the Database. - Either Doctor NRIC or Patient NRIC can be used in the search - It is recommended to use `list` to restore the view of all data after a `find` command. diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 968efea858f..0fa472d7d0d 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -8,7 +8,6 @@ import static seedu.address.logic.parser.CliSyntax.PREFIX_EMERGENCY_CONTACT; import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER; import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; -import static seedu.address.logic.parser.CliSyntax.PREFIX_NRIC; import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE; import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK; import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG; @@ -62,7 +61,6 @@ public class EditCommand extends Command { + "[" + PREFIX_GENDER + "GENDER] " + "[" + PREFIX_CONDITION + "CONDITION] " + "[" + PREFIX_BLOODTYPE + "BLOOD TYPE] " - + "[" + PREFIX_NRIC + "NRIC] " + "[" + PREFIX_EMERGENCY_CONTACT + "EMAIL] " + "[" + PREFIX_TAG + "TAG]...\n" + "Example: " + COMMAND_WORD + " T0123456H " @@ -73,6 +71,7 @@ public class EditCommand extends Command { public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided."; public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book."; public static final String MESSAGE_DOESNT_EXIST = "This person hasn't been saved"; + public static final String MESSAGE_IC_CHANGED = "You can't change a person's IC"; private static final Logger logger = LogsCenter.getLogger(EditCommand.class.getName()); private final Ic nric; private final EditPersonDescriptor editPersonDescriptor; @@ -92,6 +91,10 @@ public EditCommand(Ic nric, EditPersonDescriptor editPersonDescriptor) { @Override public CommandResult execute(Model model) throws CommandException { requireNonNull(model); + if (editPersonDescriptor.getIc().isPresent() && !(editPersonDescriptor.getIc().get().equals(nric))) { + throw new CommandException(MESSAGE_IC_CHANGED); + } + // combine doctor list and patient list Person personToEdit = getPersonToEdit(model); Person editedPerson = getEditedPerson(model, personToEdit); @@ -152,7 +155,7 @@ private static Doctor createEditedDoctor(Doctor personToEdit, EditPersonDescript Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); Remark updatedRemarks = editPersonDescriptor.getRemark().orElse(personToEdit.getRemark()); Gender updatedGender = editPersonDescriptor.getGender().orElse(personToEdit.getGender()); - Ic updatedIc = editPersonDescriptor.getIc().orElse(personToEdit.getIc()); + Ic updatedIc = personToEdit.getIc(); // since you can't modify ic Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); Set updatedAppointments = editPersonDescriptor.getAppointments().orElse(personToEdit.getAppointments()); @@ -175,7 +178,7 @@ private static Patient createEditedPatient(Patient personToEdit, EditPersonDescr Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress()); Remark updatedRemarks = editPersonDescriptor.getRemark().orElse(personToEdit.getRemark()); Gender updatedGender = editPersonDescriptor.getGender().orElse(personToEdit.getGender()); - Ic updatedIc = editPersonDescriptor.getIc().orElse(personToEdit.getIc()); + Ic updatedIc = personToEdit.getIc(); // since you can't modify ic Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags()); Set updatedAppointments = editPersonDescriptor.getAppointments().orElse(personToEdit.getAppointments()); diff --git a/src/main/java/seedu/address/logic/commands/FindAppointmentCommand.java b/src/main/java/seedu/address/logic/commands/FindAppointmentCommand.java index 6e470fcadbd..c48ccddb21b 100644 --- a/src/main/java/seedu/address/logic/commands/FindAppointmentCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindAppointmentCommand.java @@ -27,7 +27,7 @@ public class FindAppointmentCommand extends Command { private final Predicate predicate; /** * Finds and lists all persons in address book whose attributes match the predicate. - * Keyword matching is case insensitive. + * Keyword matching is case-insensitive. */ public FindAppointmentCommand(Predicate predicate) { requireNonNull(predicate); diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java index 1fe4072deb8..2c9c51fd093 100644 --- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java @@ -31,6 +31,7 @@ * Parses input arguments and creates a new EditCommand object */ public class EditCommandParser implements Parser { + public static final String CANNOT_CHANGE_IC_MESSAGE = "You cannot modify a person's IC"; private static final Logger logger = LogsCenter.getLogger(EditCommand.class); /** * Parses the given {@code String} of arguments in the context of the EditCommand @@ -58,6 +59,9 @@ public EditCommand parse(String args) throws ParseException { EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor(); + if (argMultimap.getValue(PREFIX_NRIC).isPresent()) { + editPersonDescriptor.setIc(ParserUtil.parseIc(argMultimap.getValue(PREFIX_NRIC).get())); + } if (argMultimap.getValue(PREFIX_NAME).isPresent()) { editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get())); } @@ -73,9 +77,6 @@ public EditCommand parse(String args) throws ParseException { if (argMultimap.getValue(PREFIX_GENDER).isPresent()) { editPersonDescriptor.setGender(ParserUtil.parseGender(argMultimap.getValue(PREFIX_GENDER).get())); } - if (argMultimap.getValue(PREFIX_NRIC).isPresent()) { - editPersonDescriptor.setIc(ParserUtil.parseIc(argMultimap.getValue(PREFIX_NRIC).get())); - } if (argMultimap.getValue(PREFIX_CONDITION).isPresent()) { editPersonDescriptor.setCondition(ParserUtil.parseCondition(argMultimap.getValue(PREFIX_CONDITION).get())); } diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index dd6cd45793d..00f2adb51ae 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -132,22 +132,22 @@ public class CommandTestUtil { DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY) .withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY) .withBloodType(VALID_BLOODTYPE_AMY).withCondition(VALID_CONDITION_AMY) - .withGender(VALID_GENDER_FEMALE).withIc(VALID_NRIC_AMY) + .withGender(VALID_GENDER_FEMALE) .withTags(VALID_TAG_FRIEND).withBloodType(VALID_BLOODTYPE_AMY) .build(); DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB) .withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB) - .withGender(VALID_GENDER_MALE).withIc(VALID_NRIC_BOB) + .withGender(VALID_GENDER_MALE) .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build(); DESC_CHERYL = new EditPersonDescriptorBuilder().withName(VALID_NAME_CHERYL) .withPhone(VALID_PHONE_CHERYL).withEmail(VALID_EMAIL_CHERYL).withAddress(VALID_ADDRESS_CHERYL) - .withGender(VALID_GENDER_FEMALE).withIc(VALID_NRIC_CHERYL).build(); + .withGender(VALID_GENDER_FEMALE).build(); DESC_DEREK = new EditPersonDescriptorBuilder().withName(VALID_NAME_DEREK) .withPhone(VALID_PHONE_DEREK).withEmail(VALID_EMAIL_DEREK).withAddress(VALID_ADDRESS_DEREK) - .withGender(VALID_GENDER_MALE).withIc(VALID_NRIC_DEREK).build(); + .withGender(VALID_GENDER_MALE).build(); } /** diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java index 7610658cf12..ec55543e717 100644 --- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java @@ -41,9 +41,9 @@ public class EditCommandTest { @Test public void execute_patientAllFieldsSpecifiedUnfilteredList_success() { - Person editedPatient = new PatientBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPatient).build(); Ic nricOfFirstPatient = model.getFilteredPatientList().get(0).getIc(); + Person editedPatient = new PatientBuilder(nricOfFirstPatient).build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(nricOfFirstPatient, editedPatient).build(); EditCommand editCommand = new EditCommand(nricOfFirstPatient, descriptor); String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPatient)); @@ -56,9 +56,9 @@ public void execute_patientAllFieldsSpecifiedUnfilteredList_success() { @Test public void execute_doctorAllFieldsSpecifiedUnfilteredList_success() { - Doctor editedDoctor = new DoctorBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedDoctor).build(); Ic nricOfFirstDoctor = model.getFilteredDoctorList().get(0).getIc(); + Doctor editedDoctor = new DoctorBuilder(nricOfFirstDoctor).build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(nricOfFirstDoctor, editedDoctor).build(); EditCommand editCommand = new EditCommand(nricOfFirstDoctor, descriptor); String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDoctor)); @@ -127,11 +127,10 @@ public void execute_duplicatePersonUnfilteredList_failure() { Ic nricOfFirstPerson = model.getFilteredPatientList().get(0).getIc(); Person firstPerson = model.getFilteredPatientList().stream().filter(p -> p.getIc().equals(nricOfFirstPerson)).findFirst().orElse(null); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstPerson).build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(nricOfFirstPerson, firstPerson).build(); Ic nricOfSecondPerson = model.getFilteredPatientList().get(1).getIc(); EditCommand editCommand = new EditCommand(nricOfSecondPerson, descriptor); - - assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); + assertCommandFailure(editCommand, model, EditCommand.MESSAGE_IC_CHANGED); } @Test @@ -142,9 +141,9 @@ public void execute_duplicatePersonFilteredList_failure() { Patient patientInList = model.getAddressBook().getPatientList().get(INDEX_SECOND_PERSON.getZeroBased()); Ic nricOfFirstPerson = model.getFilteredPatientList().get(INDEX_FIRST_PERSON.getZeroBased()).getIc(); EditCommand editCommand = new EditCommand(nricOfFirstPerson, - new EditPersonDescriptorBuilder(patientInList).build()); + new EditPersonDescriptorBuilder(patientInList.getIc(), patientInList).build()); - assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON); + assertCommandFailure(editCommand, model, EditCommand.MESSAGE_IC_CHANGED); } @Test diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java index 6a51ab4b681..1df2dc5704d 100644 --- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java +++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java @@ -60,7 +60,7 @@ public void parseCommand_deleteAppointment() throws Exception { @Test public void parseCommand_edit() throws Exception { Patient person = new PatientBuilder().build(); - EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build(); + EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person.getIc(), person).build(); EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " " + person.getIc() + " " + PersonUtil.getEditPersonDescriptorDetails(descriptor)); assertEquals(new EditCommand(person.getIc(), descriptor), command); diff --git a/src/test/java/seedu/address/testutil/DoctorBuilder.java b/src/test/java/seedu/address/testutil/DoctorBuilder.java index fda34f60f9c..a9a231abdae 100644 --- a/src/test/java/seedu/address/testutil/DoctorBuilder.java +++ b/src/test/java/seedu/address/testutil/DoctorBuilder.java @@ -68,7 +68,20 @@ public DoctorBuilder(Doctor doctorToCopy) { tags = new HashSet<>(doctorToCopy.getTags()); appointments = new HashSet<>(doctorToCopy.getAppointments()); } - + /** + * Initializes the PersonBuilder with an nric. + */ + public DoctorBuilder(Ic nric) { + name = new Name(DEFAULT_NAME); + phone = new Phone(DEFAULT_PHONE); + email = new Email(DEFAULT_EMAIL); + address = new Address(DEFAULT_ADDRESS); + remark = new Remark(DEFAULT_REMARK); + gender = new Gender(DEFAULT_GENDER); + ic = nric; + tags = new HashSet<>(); + appointments = new HashSet<>(); + } /** * Sets the {@code Name} of the {@code Person} that we are building. */ diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java index 91d2800e524..8737aeb11fd 100644 --- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java +++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java @@ -37,14 +37,14 @@ public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) { /** * Returns an {@code EditPersonDescriptor} with fields containing {@code person}'s details */ - public EditPersonDescriptorBuilder(Person person) { + public EditPersonDescriptorBuilder(Ic nric, Person person) { descriptor = new EditPersonDescriptor(); + descriptor.setIc(nric); descriptor.setName(person.getName()); descriptor.setPhone(person.getPhone()); descriptor.setEmail(person.getEmail()); descriptor.setAddress(person.getAddress()); descriptor.setGender(person.getGender()); - descriptor.setIc(person.getIc()); descriptor.setTags(person.getTags()); descriptor.setRemark(person.getRemark()); if (person.isPatient()) { @@ -104,13 +104,6 @@ public EditPersonDescriptorBuilder withRemark(String remark) { return this; } - /** - * Sets the {@code Ic} of the {@code EditPersonDescriptor} that we are building. - */ - public EditPersonDescriptorBuilder withIc(String ic) { - descriptor.setIc(new Ic(ic)); - return this; - } /** * Sets the {@code BloodType} of the {@code EditPersonDescriptor} that we are building. diff --git a/src/test/java/seedu/address/testutil/PatientBuilder.java b/src/test/java/seedu/address/testutil/PatientBuilder.java index cb5de5dd0b3..fd764b25cfa 100644 --- a/src/test/java/seedu/address/testutil/PatientBuilder.java +++ b/src/test/java/seedu/address/testutil/PatientBuilder.java @@ -63,6 +63,23 @@ public PatientBuilder() { tags = new HashSet<>(); appointments = new HashSet<>(); } + /** + * Initializes the PatientBuilder with an nric, + */ + public PatientBuilder(Ic nric) { + name = new Name(DEFAULT_NAME); + phone = new Phone(DEFAULT_PHONE); + emergencyContact = new Phone(DEFAULT_EMERGENCY_CONTACT); + email = new Email(DEFAULT_EMAIL); + address = new Address(DEFAULT_ADDRESS); + remark = new Remark(DEFAULT_REMARK); + gender = new Gender(DEFAULT_GENDER); + ic = nric; + condition = new Condition(DEFAULT_CONDITION); + bloodType = new BloodType(DEFAULT_BLOODTYPE); + tags = new HashSet<>(); + appointments = new HashSet<>(); + } /** * Initializes the PatientBuilder with the data of {@code patientToCopy}.