Skip to content

Commit

Permalink
Merge pull request #193 from pangyyen/fix-PE-issues
Browse files Browse the repository at this point in the history
Fix pe issues
  • Loading branch information
pangyyen authored Nov 12, 2023
2 parents 5d8f860 + 6ddf100 commit da8fcbe
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class AddMedicalHistoryEventCommand extends Command {
+ PREFIX_TREATMENT + "Insulin";

public static final String MESSAGE_SUCCESS = "New medical history event added: \n%1$s";
public static final String MESSAGE_DATE_IN_FUTURE = "Medical History Date should not be in the future";

private final MedicalHistoryEvent eventToAdd;
private final Index patientIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class EditMedicalHistoryEventCommand extends Command {
+ PREFIX_TREATMENT + "Insulin ";

public static final String MESSAGE_EDIT_EVENT_SUCCESS = "Edited Medical History Event: %1$s";
public static final String MESSAGE_DATE_IN_FUTURE = "Medical History Date should not be in the future";

private final Index patientIndex;
private final Index eventIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public AddMedicalHistoryEventCommand parse(String args) throws ParseException {
}

if (ParserUtil.parseDate(argMultimap.getValue(PREFIX_DATE).get()).isFutureDate()) {
throw new ParseException(String.format("Medical History Date should not be in the future"));
throw new ParseException(String.format(AddMedicalHistoryEventCommand.MESSAGE_DATE_IN_FUTURE));
}

MedicalCondition medicalCondition = ParserUtil.parseMedicalCondition(argMultimap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public EditMedicalHistoryEventCommand parse(String args) throws ParseException {
.getValue(PREFIX_DATE).get()));
}

if (ParserUtil.parseDate(argMultimap.getValue(PREFIX_DATE).get()).isFutureDate()) {
throw new ParseException(String.format(EditMedicalHistoryEventCommand.MESSAGE_DATE_IN_FUTURE));
}

return new EditMedicalHistoryEventCommand(eventIndex, patientIndex, editMedicalHistoryEventDescriptor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@


/**
* A list of medical history events that enforces uniqueness between its elements and does not allow nulls.
* A medical history event is considered unique by comparing using {@code AppointmentEvent#equals(Object)}.
* A list of appointment events that enforces uniqueness between its elements and does not allow nulls.
* A appointment event is considered unique by comparing using {@code AppointmentEvent#equals(Object)}.
*/
public class ClinicBookAppointmentList implements Iterable<AppointmentEvent> {

Expand All @@ -27,14 +27,14 @@ public class ClinicBookAppointmentList implements Iterable<AppointmentEvent> {
private Patient currentPatient = null;

/**
* Returns true if the list contains an equivalent medical history event as the given argument.
* Returns true if the list contains an equivalent appointment event as the given argument.
*/
public boolean contains(AppointmentEvent toCheck) {
return internalList.contains(toCheck);
}

/**
* Adds a medical history event to the list.
* Adds a appointment event to the list.
* The event must not already exist in the list.
*/
public void add(AppointmentEvent toAdd, Patient patient) {
Expand All @@ -47,9 +47,9 @@ public void add(AppointmentEvent toAdd, Patient patient) {
}

/**
* Replaces the given medical history event {@code target} in the list with {@code editedEvent}.
* Replaces the given appointment event {@code target} in the list with {@code editedEvent}.
* {@code target} must exist in the list.
* The medical history event must not be the same as another existing event in the list.
* The appointment event must not be the same as another existing event in the list.
*/
public void setAppointment(AppointmentEvent target, AppointmentEvent editedEvent, Patient patient) {
int index = internalList.indexOf(target);
Expand All @@ -69,7 +69,7 @@ public void setAppointment(AppointmentEvent target, AppointmentEvent editedEvent
}

/**
* Deletes the given medical history event.
* Deletes the given appointment event.
* The event must exist in the list.
*/
public void delete(AppointmentEvent toDelete, Patient patient) {
Expand All @@ -85,9 +85,9 @@ public void delete(AppointmentEvent toDelete, Patient patient) {
}

/**
* Lists all medical history events associated with a specific patient.
* Lists all appointment events associated with a specific patient.
*
* @param patient The patient for whom to list the medical history events.
* @param patient The patient for whom to list the appointment events.
*/
public void listAppointments(Patient patient) {
requireNonNull(patient);
Expand All @@ -96,7 +96,7 @@ public void listAppointments(Patient patient) {
}

/**
* Returns a list of all medical history events in this list.
* Returns a list of all appointment events in this list.
*/
public List<AppointmentEvent> getAllAppointments() {
return new ArrayList<>(internalList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class JsonAdaptedAppointmentEvent {
private final String time;

/**
* Constructs a {@code JsonAdaptedAppointmentEvent} with the given medical history event details.
* Constructs a {@code JsonAdaptedAppointmentEvent} with the given appointment event details.
*/
@JsonCreator
public JsonAdaptedAppointmentEvent(@JsonProperty("date") String date,
Expand Down Expand Up @@ -57,7 +57,7 @@ public JsonAdaptedAppointmentEvent(AppointmentEvent source) {
* Converts this Jackson-friendly adapted appointment event object into the model's {@code AppointmentEvent}
* object.
*
* @throws IllegalValueException if there were any data constraints violated in the adapted medical history event.
* @throws IllegalValueException if there were any data constraints violated in the adapted appointment event.
*/
public AppointmentEvent toModelType() throws IllegalValueException {

Expand Down

0 comments on commit da8fcbe

Please sign in to comment.