Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Delete Command to use IC Number #120

Merged

Conversation

RiyaMehta2211
Copy link

The existing delete command uses the index to delete a patient from the list. This can be very cumbersome especially in very large datasets of patients.

Hence, use IC Number of the patient instead to delete a patient directly from the list like "delete T1234567B"

Let's update the Delete Command and fix tests for the DeleteCommand and Parser tests.

The existing delete command uses the index to delete a patient from the list. This can be very cumbersome especially in very large datasets of patients.

Hence, use IC Number of the patient instead to delete a patient directly from the list like "delete T1234567B"

Let's update the Delete Command and fix tests for the DeleteCommand and Parser tests.
@RiyaMehta2211 RiyaMehta2211 added this to the v1.3 milestone Oct 25, 2023
RiyaMehta2211 added 3 commits October 25, 2023 19:24
The existing edit command uses the index to edit a patient's description in the list. This can be very cumbersome especially in very large datasets of patients.

Hence, use IC Number of the patient instead to edit a patient's description directly from the list like "edit T1234567B n/NEW NAME"

Let's update the EDIT Command and fix tests for the EditCommand and Parser tests.
Making changes to add prefix i/ in front of the IC Numbers for these commands to standardize the command format as per the User Guide
Making changes to add prefix i/ in front of the IC Numbers for these commands to standardize the command format as per the User Guide for the Delete Command
Copy link

@AaronJT1 AaronJT1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall very good effort in your implementation!!! Do take notes of the comments. There are some minor changes needed, but nice job!

@@ -24,23 +24,18 @@ public class DeleteCommand extends Command {
+ "Example: " + COMMAND_WORD + " 1";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, since the implementation of delete command is by ic number, would it be good to also update the message usage accordingly?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


/**
* Parses the given {@code String} of arguments in the context of the DeleteCommand
* and returns a DeleteCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public DeleteCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, REQUIRED_PREFIXES);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you followed the implementation for addcommandparser to update this new DeleteCommandParser, good job!!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Index index = ParserUtil.parseIndex(args);
return new DeleteCommand(index);
IcNumber icNumber = ParserUtil.parseIcNumber(argMultimap.getValue(PREFIX_IC_NUMBER).get());
//IcNumber icNumber = ParserUtil.parseIcNumber(args);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is no longer needed, would it be good to remove it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup!

Comment on lines +158 to +165
public static void showPatientAtIC(Model model, IcNumber icNumber) {
List<Patient> lastShownList = model.getFilteredPatientList();
Patient patient = model.getPatient(icNumber, lastShownList);
final String[] splitName = patient.getName().fullName.split("\\s+");
model.updateFilteredPatientList(new NameContainsKeywordsPredicate(Arrays.asList(splitName[0])));
assertEquals(1, model.getFilteredPatientList().size());
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you tried to implement a testing utility to show the patient of a IC. But considering how you are using the filtered patient list, would it be good if we can use the full list instead? since filtered patient list does not contain all patients

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job updating the EditCommandParserTest!! would be good to find ways to update the testing utility since as per the user guide the format for command is edit i/ number.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that could be our focus point in the next iteration!

Comment on lines +103 to +111
@Override
public Patient getPatient(IcNumber icNumber, List<Patient> patientList){
for (int i = 0; i < patientList.size(); i++) {
if(patientList.get(i).getIcNumber().equals(icNumber))
return patientList.get(i);
}
return null;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you implement your getPatient!! But if the patient could not be found, it could be quite dangerous to return a null. Do ensure that the other party calling this function checks for null. If it does receive a null, would be good to throw an exception!!! Could see my implementation of the exception PatientWithFieldNotFoundException. It has yet to be merged in code base but would be good if we could make use of this exception!!

Comment on lines +30 to +37
/*public Patient getPatient(IcNumber icNumber, List<Patient> patientList){
for (int i = 0; i < patientList.size(); i++) {
if(patientList.get(i).getIcNumber().equals(icNumber))
return patientList.get(i);
}
return null;
}*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good if we remove unused code!!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup noted!

@AaronJT1 AaronJT1 merged commit 49b6a25 into AY2324S1-CS2103T-T14-2:master Oct 26, 2023
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants