Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tanveersingh10 committed Nov 12, 2023
2 parents 347d38c + 6ffae7b commit 1189e53
Show file tree
Hide file tree
Showing 29 changed files with 620 additions and 216 deletions.
237 changes: 157 additions & 80 deletions docs/UserGuide.md

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import seedu.address.logic.parser.Prefix;
import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Patient;
import seedu.address.model.person.Person;

/**
Expand Down Expand Up @@ -46,8 +47,17 @@ public static String format(Person person) {
.append("; Email: ")
.append(person.getEmail())
.append("; Address: ")
.append(person.getAddress())
.append("; Tags: ");
.append(person.getAddress());
if (person instanceof Patient) {
Patient patient = (Patient) person;
builder.append("; Emergency Contact: ")
.append(patient.getEmergencyContact())
.append("; Blood Type: ")
.append(patient.getBloodType())
.append("; Condition: ")
.append(patient.getCondition());
}
builder.append("; Tags: ");
person.getTags().forEach(builder::append);
builder.append("; Appointments: ");
person.getAppointments().forEach(builder::append);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ private void checkPatientAndDoctor(Patient chosenPatient, Doctor chosenDoctor) t
if (chosenDoctor == null) {
throw new CommandException(MESSAGE_INVALID_DOCTOR);
}
// check that patient and doctor are not the same person
if (chosenPatient.isSamePerson(chosenDoctor)) {
throw new CommandException(MESSAGE_SAME_DOCTOR_AND_PATIENT);
}
}

private Patient findPatient(Model model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ public class AddDoctorCommand extends Command {
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Adds a person to the address book. "
+ "Parameters: "
+ PREFIX_NAME + "NAME "
+ PREFIX_NRIC + "NRIC "
+ PREFIX_GENDER + "GENDER "
+ PREFIX_PHONE + "PHONE "
+ PREFIX_EMAIL + "EMAIL "
+ PREFIX_ADDRESS + "ADDRESS "
+ PREFIX_GENDER + "GENDER "
+ PREFIX_NRIC + "NRIC "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
+ PREFIX_NAME + "John Doe "
+ PREFIX_NRIC + "S1234567Z "
+ PREFIX_GENDER + "M "
+ PREFIX_PHONE + "98765432 "
+ PREFIX_EMAIL + "johnd@example.com "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_GENDER + "M "
+ PREFIX_NRIC + "S1234567Z "
+ PREFIX_TAG + "SURGEON";

public static final String MESSAGE_SUCCESS = "New doctor added: %1$s";
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/seedu/address/model/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ public void setDoctor(Doctor target, Doctor editedDoctor) {
doctors.setObject(target, editedDoctor);
}

public void setAppointment(Appointment target, Appointment editedAppointment) {
requireNonNull(editedAppointment);

appointments.setObject(target, editedAppointment);
}

/**
* Removes {@code key} from this {@code AddressBook}.
* {@code key} must exist in the address book.
Expand Down Expand Up @@ -232,6 +226,7 @@ public boolean equals(Object other) {
&& doctors.equals((otherAddressBook.doctors))
&& appointments.equals((otherAddressBook.appointments));
}

@Override
public int hashCode() {
return Objects.hash(patients, doctors, appointments);
Expand Down
7 changes: 0 additions & 7 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,6 @@ public interface Model {

void addAppointment(Appointment appointment);

void setAppointment(Appointment target, Appointment editedAppointment);

/**
* Returns an unmodifiable view of the filtered person list
*/
ObservableList<Person> getFilteredPersonList();

/**
* Returns an unmodifiable view of the filtered patient list
*/
Expand Down
23 changes: 5 additions & 18 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,10 @@ public ReadOnlyAddressBook getAddressBook() {
@Override
public boolean hasPerson(Person person) {
requireNonNull(person);
if (person instanceof Patient) {
if (person.isPatient()) {
return addressBook.hasPatient((Patient) person);
} else if (person instanceof Doctor) {
return addressBook.hasDoctor((Doctor) person);
} else {
return false;
return addressBook.hasDoctor((Doctor) person);
}
}
@Override
Expand Down Expand Up @@ -196,19 +194,6 @@ public void setPerson(Person target, Person editedPerson) {
}
}

@Override
public void setAppointment(Appointment target, Appointment editedAppointment) {
updateBackup();
addressBook.setAppointment(target, editedAppointment);
}

/**
* Returns an unmodifiable view of the filtered person list
*/
@Override
public ObservableList<Person> getFilteredPersonList() {
return null;
}

//=========== Filtered Person List Accessors =============================================================

Expand Down Expand Up @@ -240,6 +225,7 @@ public void updateFilteredPersonList(Predicate<Person> predicate) {
filteredPatients.setPredicate(predicate);
filteredDoctors.setPredicate(predicate);
}

@Override
public void updateFilteredAppointmentList(Predicate<Appointment> predicate) {
requireNonNull(predicate);
Expand All @@ -261,7 +247,8 @@ public boolean equals(Object other) {
return addressBook.equals(otherModelManager.addressBook)
&& userPrefs.equals(otherModelManager.userPrefs)
&& filteredDoctors.equals(otherModelManager.filteredDoctors)
&& filteredPatients.equals(otherModelManager.filteredPatients);
&& filteredPatients.equals(otherModelManager.filteredPatients)
&& filteredAppointments.equals(otherModelManager.filteredAppointments);
}

}
18 changes: 0 additions & 18 deletions src/main/java/seedu/address/model/appointment/Appointment.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ public Appointment(Ic doctorIc, Ic patientIc, AppointmentTime appointmentTime) {
this.appointmentTime = appointmentTime;
}

/**
* Constructs a new appointment with the specified doctor, patient, appointment time, and status.
*
* @param doctorIc The doctor involved in the appointment.
* @param patientIc The patient involved in the appointment.
* @param appointmentTime The date and time of the appointment.
* @param status The status of the appointment.
*/
public Appointment(Ic doctorIc, Ic patientIc, AppointmentTime appointmentTime, String status) {
requireNonNull(doctorIc);
requireNonNull(patientIc);
requireNonNull(appointmentTime);
requireNonNull(status);
this.doctorIc = doctorIc;
this.patientIc = patientIc;
this.appointmentTime = appointmentTime;
}

public AppointmentTime getAppointmentTime() {
return appointmentTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.format.ResolverStyle;


/**
Expand All @@ -14,8 +15,10 @@
*/
public class AppointmentTime implements Comparable<AppointmentTime> {

public static final String MESSAGE_CONSTRAINTS = "AppointmentTime should be in the format of yyyy-mm-dd HH:mm:ss\n";
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
public static final String MESSAGE_CONSTRAINTS =
"AppointmentTime should be valid date and time in the format of yyyy-mm-dd HH:mm:ss\n";
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm")
.withResolverStyle(ResolverStyle.STRICT);
public final LocalDateTime value;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/person/Ic.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Ic {

public static final String MESSAGE_CONSTRAINTS =
"Ic should start with S or T, followed by 7 numbers, and ends with a letter. "
+ "Letters must be in all caps. Empty strings are not allowed\n";
+ "Letters inputs are case-insensitive. Empty strings are not allowed\n";
public static final String VALIDATION_REGEX = "^[TS]\\d{7}[A-Z]$";
public final String value;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/model/person/Patient.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public boolean equals(Object other) {
@Override
public int hashCode() {
// use this method for custom fields hashing instead of implementing your own
return Objects.hash(name, phone, email, address, gender, ic, condition, bloodType, appointments, tags);
return Objects.hash(name, phone, emergencyContact, email, address, gender, ic, condition, bloodType,
appointments, tags);
}

@Override
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/seedu/address/storage/JsonAdaptedDoctor.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import seedu.address.model.tag.Tag;



/**
* Jackson-friendly version of {@link Doctor}.
*/
Expand Down Expand Up @@ -66,10 +65,7 @@ public Doctor toModelType() throws IllegalValueException {
personTags.add(tag.toModelDoctorType());
}
final Set<Tag> modelTags = new HashSet<>(personTags);
final List<Appointment> personAppointments = new ArrayList<>();
for (JsonAdaptedAppointment appointment : this.getAppointments()) {
personAppointments.add(appointment.toModelType());
}
final List<Appointment> personAppointments = checkAppointments();
final Set<Appointment> modelAppointments = new HashSet<>(personAppointments);
return new Doctor(modelName, modelPhone, modelEmail, modelAddress, modelRemark, modelGender, modelIc,
modelAppointments, modelTags);
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/seedu/address/storage/JsonAdaptedPatient.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ public Patient toModelType() throws IllegalValueException {
final Set<Tag> modelTags = new HashSet<>(personTags);
final Condition modelCondition = checkCondition();
final BloodType modelBloodType = checkBloodType();
final List<Appointment> personAppointments = new ArrayList<>();
for (JsonAdaptedAppointment appointment : this.getAppointments()) {
personAppointments.add(appointment.toModelType());
}
final List<Appointment> personAppointments = checkAppointments();
final Set<Appointment> modelAppointments = new HashSet<>(personAppointments);
return new Patient(modelName, modelPhone, modelEmergencyContact, modelEmail, modelAddress, modelRemark,
modelGender, modelIc, modelCondition, modelBloodType, modelAppointments, modelTags);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/address/storage/JsonAdaptedPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
public abstract class JsonAdaptedPerson {

public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!";
public static final String MESSAGE_DUPLICATE_APPOINTMENT_TIME =
"Person has more than 1 appointment at the same timing!";
public static final String MESSAGE_INVALID_APPOINTMENT =
"Person contains an appointment that does not belong to him!";

private final String name;
private final String phone;
Expand Down Expand Up @@ -92,6 +96,7 @@ public List<JsonAdaptedTag> getTags() {
public List<JsonAdaptedAppointment> getAppointments() {
return this.appointments;
}

/**
* Checks the name given by storage.
*
Expand Down Expand Up @@ -203,6 +208,8 @@ public Ic checkIc() throws IllegalValueException {

/**
* Gives the list of appointments of the Person.
* Please ensure that this method is called only after the Ic has been added to the person.
* This checks for any appointments happening at the same time and any appointments not belonging to this person.
*
* @return a List of JsonAdaptedAppointments
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,6 @@ public void addAppointment(Appointment appointment) {
throw new AssertionError("This method should not be called.");
}

@Override
public void setAppointment(Appointment target, Appointment editedAppointment) {
throw new AssertionError("This method should not be called.");
}

/**
* Returns an unmodifiable view of the filtered person list
*/
@Override
public ObservableList<Person> getFilteredPersonList() {
return null; // not sure abt this method
}

@Override
public ObservableList<Patient> getFilteredPatientList() {
throw new AssertionError("This method should not be called.");
Expand Down
Loading

0 comments on commit 1189e53

Please sign in to comment.