Skip to content

Commit

Permalink
Merge pull request #121 from LimJH2002/branch-ui
Browse files Browse the repository at this point in the history
Branch UI
  • Loading branch information
LimJH2002 authored Nov 2, 2023
2 parents 493a357 + 5d4d9b8 commit 43ffe88
Show file tree
Hide file tree
Showing 28 changed files with 309 additions and 59 deletions.
10 changes: 5 additions & 5 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ professionals manage their patients' medical journey.
3. Copy the file to the folder you want to use as the home folder for CareCentral.
4. Double-click the file to start the app. The GUI similar to the below should appear in a few seconds.
![Ui](images/Ui.png)
5. For Mac users encountering this issue, follow this[guide](https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Run-JAR-file-example-windows-linux-ubuntu).
5. For Mac users encountering this issue, follow this [guide](https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Run-JAR-file-example-windows-linux-ubuntu).
<img width="275" height="280" src="images/mac_issue.png">
6. Type the command in the command box and press Enter to execute it.
e.g. typing `help` and pressing Enter will open the help window.
Some example commands you can try:

* `add-p n/John Doe ic/S1234567A a/45 p/91234567`
* `list-p`
* `delete-p 1`
* `add-patient n/John Doe ic/S1234567A p/98765432 e/[email protected] a/25 t/Diabetic`
* `list-pateints`
* `delete-patient 1`
* `exit`


Expand Down
6 changes: 4 additions & 2 deletions src/main/java/seedu/cc/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class Messages {

public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
public static final String MESSAGE_INVALID_PATIENT_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
public static final String MESSAGE_INVALID_PATIENT_DISPLAYED_INDEX = "The patient index provided is invalid";
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d patients listed!";
public static final String MESSAGE_DUPLICATE_FIELDS =
"Multiple values specified for the following single-valued field(s): ";

Expand All @@ -44,6 +44,8 @@ public static String getErrorMessageForDuplicatePrefixes(Prefix... duplicatePref
public static String format(Patient patient) {
final StringBuilder builder = new StringBuilder();
builder.append(patient.getName())
.append("; NRIC: ")
.append(patient.getNric())
.append("; Phone: ")
.append(patient.getPhone())
.append("; Email: ")
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/seedu/cc/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AddCommand extends Command {
public static final String COMMAND_WORD = "add-patient";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a patient to the clinic book. "
+ "Parameters: "
+ "\nParameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_NRIC + "NRIC "
+ PREFIX_PHONE + "PHONE "
Expand All @@ -32,10 +32,11 @@ public class AddCommand extends Command {
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_NRIC + "S1234567A "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "[email protected] "
+ PREFIX_AGE + "25 "
+ PREFIX_TAG + "friends "
+ PREFIX_TAG + "Bad Breath "
+ PREFIX_TAG + "owesMoney";

public static final String MESSAGE_SUCCESS = "New patient added: %1$s";
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/seedu/cc/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@
import seedu.cc.model.patient.Patient;

/**
* Deletes a person identified using it's displayed index from the address book.
* Deletes a patient identified using it's displayed index from the clinic book.
*/
public class DeleteCommand extends Command {

public static final String COMMAND_WORD = "delete-patient";

public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Deletes the person identified by the index number used in the displayed person list.\n"
+ ": Deletes the patient identified by the index number used in the displayed patient list.\n"
+ "Parameters: INDEX (must be a positive integer)\n"
+ "Example: " + COMMAND_WORD + " 1";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Patient: %1$s";
private final Index targetIndex;

public DeleteCommand(Index targetIndex) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/seedu/cc/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static seedu.cc.logic.parser.CliSyntax.PREFIX_AGE;
import static seedu.cc.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.cc.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.cc.logic.parser.CliSyntax.PREFIX_NRIC;
import static seedu.cc.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.cc.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.cc.model.Model.PREDICATE_SHOW_ALL_PERSONS;
Expand All @@ -30,17 +31,18 @@
import seedu.cc.model.tag.Tag;

/**
* Edits the details of an existing person in the clinic book.
* Edits the details of an existing patient in the clinic book.
*/
public class EditCommand extends Command {

public static final String COMMAND_WORD = "edit-patient";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified "
+ "by the index number used in the displayed person list. "
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_NRIC + "NRIC] "
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_EMAIL + "EMAIL] "
+ "[" + PREFIX_AGE + "AGE] "
Expand Down Expand Up @@ -161,7 +163,7 @@ public EditPatientDescriptor(EditPatientDescriptor toCopy) {
* Returns true if at least one field is edited.
*/
public boolean isAnyFieldEdited() {
return CollectionUtil.isAnyNonNull(name, phone, email, age, tags);
return CollectionUtil.isAnyNonNull(name, nric, phone, email, age, tags);
}

public void setName(Name name) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/cc/logic/commands/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ExitCommand extends Command {

public static final String COMMAND_WORD = "exit";

public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Address Book as requested ...";
public static final String MESSAGE_EXIT_ACKNOWLEDGEMENT = "Exiting Clinic Book as requested ...";

@Override
public CommandResult execute(Model model) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/cc/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all patients whose names contain any of "
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " alice bob charlie";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@


/**
* Edits the details of an existing person in the address book.
* Adds a prescription to an appointment event in the clinic book.
*/
public class AddPrescriptionCommand extends Command {

public static final String COMMAND_WORD = "add-prescription";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a prescription to the appointment "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds prescriptions to the appointment "
+ "by the index number used in the displayed appointment list.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ PREFIX_PATIENT_INDEX + "PATIENT INDEX "
+ PREFIX_MEDICINE_NAME + "MEDICINE NAME\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ "[" + PREFIX_PATIENT_INDEX + "PATIENT INDEX] "
+ "[" + PREFIX_MEDICINE_NAME + "MEDICINE NAME]"
+ "\nExample: " + COMMAND_WORD + " 1 "
+ PREFIX_PATIENT_INDEX + "1 "
+ PREFIX_MEDICINE_NAME + "Panadol";

public static final String MESSAGE_ADD_APPOINTMENT_SUCCESS = "Successfully added a prescription: \n%1$s";
public static final String MESSAGE_INVALID_INPUT = "Invalid input. Please enter a valid medicine.";
private final Index patientIndex;
private final Index eventIndex;
private final EditAppointmentEventCommand.EditAppointmentEventDescriptor editAppointmentEventDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DeleteAppointmentEventCommand extends Command {
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PATIENT_INDEX + "PATIENT INDEX ";

public static final String MESSAGE_DELETE_APPOINTMENT_SUCCESS = "Deleted Appointment: %1$s";
public static final String MESSAGE_DELETE_APPOINTMENT_SUCCESS = "Deleted Appointment:\n %1$s";

private final Index eventIndex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@ public class EditAppointmentEventCommand extends Command {
public static final String COMMAND_WORD = "edit-appt";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the appointment "
+ "identified by the index number used in the displayed appointment list. "
+ "Existing values will be overwritten by the input values.\n"
+ "\nExisting values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "Example: " + COMMAND_WORD + " 1"
+ PREFIX_PATIENT_INDEX + "PATIENT INDEX "
+ PREFIX_APPT_DATE + "DATE"
+ PREFIX_APPT_TIME + "TIME ";
+ "[" + PREFIX_PATIENT_INDEX + "PATIENT INDEX] "
+ "[" + PREFIX_APPT_DATE + "YYYY-MM-DD] "
+ "[" + PREFIX_APPT_TIME + "HH:MM] "
+ "\nExample: " + COMMAND_WORD + " 1 "
+ PREFIX_PATIENT_INDEX + "1 "
+ PREFIX_APPT_DATE + "2024-01-01 "
+ PREFIX_APPT_TIME + "15:00 ";

public static final String MESSAGE_EDIT_EVENT_SUCCESS = "Edited Appointment event: %1$s";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package seedu.cc.logic.commands.appointmentcommands;

import static java.util.Objects.requireNonNull;
import static seedu.cc.logic.commands.appointmentcommands.EditAppointmentEventCommand.createEditedAppointmentEvent;
import static seedu.cc.logic.parser.CliSyntax.PREFIX_MEDICINE_NAME;
import static seedu.cc.logic.parser.CliSyntax.PREFIX_PATIENT_INDEX;

import java.util.List;

import seedu.cc.commons.core.index.Index;
import seedu.cc.commons.util.ToStringBuilder;
import seedu.cc.logic.Messages;
import seedu.cc.logic.commands.Command;
import seedu.cc.logic.commands.CommandResult;
import seedu.cc.logic.commands.exceptions.CommandException;
import seedu.cc.model.Model;
import seedu.cc.model.appointment.AppointmentEvent;
import seedu.cc.model.patient.Patient;


/**
* Edit the prescription of an appointment event in the clinic book.
*/
public class EditPrescriptionCommand extends Command {

public static final String COMMAND_WORD = "edit-prescription";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edit a prescription in the appointment "
+ "by the index number used in the displayed appointment list.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "[" + PREFIX_PATIENT_INDEX + "PATIENT INDEX] "
+ "[" + PREFIX_MEDICINE_NAME + "MEDICINE NAME]"
+ "\nExample: " + COMMAND_WORD + " 1 "
+ PREFIX_PATIENT_INDEX + "1 "
+ PREFIX_MEDICINE_NAME + "Panadol";

public static final String MESSAGE_ADD_APPOINTMENT_SUCCESS = "Successfully edited a prescription: \n%1$s";
private final Index patientIndex;
private final Index eventIndex;
private final EditAppointmentEventCommand.EditAppointmentEventDescriptor editAppointmentEventDescriptor;

/**
* Edits an appointment event to the patient at {@code index}.
* @param eventIndex of the appointment event in the filtered appointment event list to edit
* @param patientIndex of the patient in the filtered patient list to edit
* @param editAppointmentEventDescriptor details to edit the appointment with
*/
public EditPrescriptionCommand(Index eventIndex, Index patientIndex,
EditAppointmentEventCommand
.EditAppointmentEventDescriptor editAppointmentEventDescriptor) {
requireNonNull(eventIndex);
requireNonNull(eventIndex);
this.patientIndex = patientIndex;
this.eventIndex = eventIndex;
this.editAppointmentEventDescriptor = editAppointmentEventDescriptor;
}

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
List<Patient> lastShownList = model.getFilteredPatientList();

if (patientIndex.getZeroBased() >= lastShownList.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_PATIENT_DISPLAYED_INDEX);
}

if (eventIndex.getZeroBased() >= lastShownList.get(patientIndex.getZeroBased()).getClinicBookAppointmentList()
.size()) {
throw new CommandException(Messages.MESSAGE_INVALID_APPOINTMENT_EVENT_DISPLAYED_INDEX);
}

Patient patientToEditPrescription = lastShownList.get(patientIndex.getZeroBased());
AppointmentEvent appointmentEvent = patientToEditPrescription.getClinicBookAppointmentList()
.get(eventIndex.getZeroBased());

AppointmentEvent editedEvent = createEditedAppointmentEvent(appointmentEvent, editAppointmentEventDescriptor);
model.setAppointmentEventForPatient(patientToEditPrescription, appointmentEvent, editedEvent);
return new CommandResult(String.format(MESSAGE_ADD_APPOINTMENT_SUCCESS,
Messages.format(appointmentEvent, patientToEditPrescription)));
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof EditPrescriptionCommand)) {
return false;
}

EditPrescriptionCommand otherEditPrescriptionCommand = (EditPrescriptionCommand) other;
return this.patientIndex.equals(otherEditPrescriptionCommand.patientIndex)
&& this.eventIndex.equals(otherEditPrescriptionCommand.eventIndex);
}

@Override
public String toString() {
return new ToStringBuilder(this)
.add("eventIndex", eventIndex)
.add("patientIndex", patientIndex)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ public class AddMedicalHistoryEventCommand extends Command {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a medical history event to the patient's "
+ "medical history.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ PREFIX_DATE + "DATE "
+ PREFIX_DATE + "YYYY-MM-DD "
+ PREFIX_MEDICAL_CONDITION + "MEDICAL CONDITION "
+ PREFIX_TREATMENT + "TREATMENT ";

+ PREFIX_TREATMENT + "TREATMENT "
+ "\nExample: " + COMMAND_WORD + " 1 "
+ PREFIX_DATE + "2023-10-01 "
+ PREFIX_MEDICAL_CONDITION + "Diabetes "
+ PREFIX_TREATMENT + "Insulin";

public static final String MESSAGE_SUCCESS = "New medical history event added: \n%1$s";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class DeleteMedicalHistoryEventCommand extends Command {
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PATIENT_INDEX + "PATIENT INDEX ";

public static final String MESSAGE_DELETE_MEDICAL_HISTORY_SUCCESS = "Deleted Medical History: %1$s";
public static final String MESSAGE_DELETE_MEDICAL_HISTORY_SUCCESS = "Deleted Medical History:\n %1$s";

private final Index eventIndex;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ public class EditMedicalHistoryEventCommand extends Command {
+ "identified by the index number used in the displayed medical history event list. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "Example: " + COMMAND_WORD + " 1"
+ PREFIX_PATIENT_INDEX + "PATIENT INDEX "
+ PREFIX_DATE + "DATE "
+ PREFIX_MEDICAL_CONDITION + "MEDICAL CONDITION "
+ PREFIX_TREATMENT + "TREATMENT ";
+ "[" + PREFIX_PATIENT_INDEX + "PATIENT INDEX] "
+ "[" + PREFIX_DATE + "YYYY-MM-DD] "
+ "[" + PREFIX_MEDICAL_CONDITION + "MEDICAL CONDITION] "
+ "[" + PREFIX_TREATMENT + "TREATMENT] "
+ "\nExample: " + COMMAND_WORD + " 1 "
+ PREFIX_PATIENT_INDEX + "1 "
+ PREFIX_DATE + "2023-01-01 "
+ PREFIX_MEDICAL_CONDITION + "Diabetes "
+ PREFIX_TREATMENT + "Insulin ";

public static final String MESSAGE_EDIT_EVENT_SUCCESS = "Edited Medical History Event: %1$s";

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/seedu/cc/logic/parser/ClinicBookParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import seedu.cc.logic.commands.appointmentcommands.DeleteAppointmentEventCommand;
import seedu.cc.logic.commands.appointmentcommands.DeletePrescriptionCommand;
import seedu.cc.logic.commands.appointmentcommands.EditAppointmentEventCommand;
import seedu.cc.logic.commands.appointmentcommands.EditPrescriptionCommand;
import seedu.cc.logic.commands.appointmentcommands.ListAppointmentEventsCommand;
import seedu.cc.logic.commands.medhisteventcommands.AddMedicalHistoryEventCommand;
import seedu.cc.logic.commands.medhisteventcommands.DeleteMedicalHistoryEventCommand;
Expand All @@ -33,6 +34,7 @@
import seedu.cc.logic.parser.appointment.DeleteAppointmentEventCommandParser;
import seedu.cc.logic.parser.appointment.DeletePrescriptionCommandParser;
import seedu.cc.logic.parser.appointment.EditAppointmentEventCommandParser;
import seedu.cc.logic.parser.appointment.EditPrescriptionCommandParser;
import seedu.cc.logic.parser.appointment.ListAppointmentEventsCommandParser;
import seedu.cc.logic.parser.exceptions.ParseException;
import seedu.cc.logic.parser.medicalhistory.AddMedicalHistoryEventCommandParser;
Expand Down Expand Up @@ -115,6 +117,9 @@ public Command parseCommand(String userInput) throws ParseException {
case AddPrescriptionCommand.COMMAND_WORD:
return new AddPrescriptionCommandParser().parse(arguments);

case EditPrescriptionCommand.COMMAND_WORD:
return new EditPrescriptionCommandParser().parse(arguments);

case DeletePrescriptionCommand.COMMAND_WORD:
return new DeletePrescriptionCommandParser().parse(arguments);

Expand Down
Loading

0 comments on commit 43ffe88

Please sign in to comment.