diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java index 2958ecc6612..dcbd68c2494 100644 --- a/src/main/java/seedu/address/logic/commands/EditCommand.java +++ b/src/main/java/seedu/address/logic/commands/EditCommand.java @@ -28,6 +28,7 @@ import seedu.address.logic.Messages; import seedu.address.logic.commands.exceptions.CommandException; import seedu.address.model.Model; +import seedu.address.model.appointment.Appointment; import seedu.address.model.person.Address; import seedu.address.model.person.BloodType; import seedu.address.model.person.Condition; @@ -212,7 +213,7 @@ public static class EditPersonDescriptor { private Set tags; private Condition condition; private BloodType bloodType; - private ArrayList patients; + private Set appointments; public EditPersonDescriptor() { } @@ -233,7 +234,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { setTags(toCopy.tags); setBloodType(toCopy.bloodType); setCondition(toCopy.condition); - setPatients(toCopy.patients); + setAppointments(toCopy.appointments); } /** @@ -241,7 +242,7 @@ public EditPersonDescriptor(EditPersonDescriptor toCopy) { */ public boolean isAnyFieldEdited() { return CollectionUtil.isAnyNonNull(name, phone, email, emergencyContact, address, - gender, ic, tags, bloodType, condition, remark, patients); + gender, ic, tags, bloodType, condition, remark, appointments); } public void setName(Name name) { @@ -275,12 +276,6 @@ public void setEmail(Email email) { public Optional getEmail() { return Optional.ofNullable(email); } - public void setPatients(ArrayList patients) { - this.patients = patients; - } - public Optional> getPatients() { - return Optional.ofNullable(patients); - } public void setAddress(Address address) { this.address = address; } @@ -347,6 +342,22 @@ public Optional> getTags() { return (tags != null) ? Optional.of(Collections.unmodifiableSet(tags)) : Optional.empty(); } + /** + * Sets {@code tags} to this object's {@code tags}. + * A defensive copy of {@code tags} is used internally. + */ + public void setAppointments(Set appointments) { + this.appointments = (appointments != null) ? new HashSet<>(appointments) : null; + } + /** + * Returns an unmodifiable tag set, which throws {@code UnsupportedOperationException} + * if modification is attempted. + * Returns {@code Optional#empty()} if {@code tags} is null. + */ + public Optional> getAppointments() { + return (appointments != null) ? Optional.of(Collections.unmodifiableSet(appointments)) : Optional.empty(); + } + @Override public boolean equals(Object other) { if (other == this) { @@ -368,7 +379,8 @@ public boolean equals(Object other) { && Objects.equals(tags, otherEditPersonDescriptor.tags) && Objects.equals(condition, otherEditPersonDescriptor.condition) && Objects.equals(bloodType, otherEditPersonDescriptor.bloodType) - && Objects.equals(remark, otherEditPersonDescriptor.remark); + && Objects.equals(remark, otherEditPersonDescriptor.remark) + && Objects.equals(appointments, otherEditPersonDescriptor.appointments); } @Override @@ -383,6 +395,7 @@ public String toString() { .add("tags", tags) .add("condition", condition) .add("blood type", bloodType) + .add("appointments", appointments) .toString(); } } diff --git a/src/main/java/seedu/address/logic/parser/AddDoctorCommandParser.java b/src/main/java/seedu/address/logic/parser/AddDoctorCommandParser.java index c175cceb586..94a2234fbb5 100644 --- a/src/main/java/seedu/address/logic/parser/AddDoctorCommandParser.java +++ b/src/main/java/seedu/address/logic/parser/AddDoctorCommandParser.java @@ -40,7 +40,7 @@ public class AddDoctorCommandParser implements Parser { public AddDoctorCommand parse(String userInput) throws ParseException { ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(userInput, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, - PREFIX_TAG, PREFIX_REMARK); + PREFIX_GENDER, PREFIX_NRIC, PREFIX_TAG, PREFIX_REMARK); if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_GENDER, PREFIX_NRIC) diff --git a/src/main/java/seedu/address/logic/parser/CliSyntax.java b/src/main/java/seedu/address/logic/parser/CliSyntax.java index 4fe02557436..610fd382684 100644 --- a/src/main/java/seedu/address/logic/parser/CliSyntax.java +++ b/src/main/java/seedu/address/logic/parser/CliSyntax.java @@ -27,4 +27,9 @@ public class CliSyntax { //specific to doctor public static final Prefix PREFIX_PATIENTS = new Prefix("pts/"); + + //specific to appointment + public static final Prefix PREFIX_PATIENT_IC = new Prefix("pic/"); + public static final Prefix PREFIX_DOCTOR_IC = new Prefix("dic/"); + public static final Prefix PREFIX_APPOINTMENT_TIME = new Prefix("time/"); } diff --git a/src/main/java/seedu/address/model/person/Appointment.java b/src/main/java/seedu/address/model/appointment/Appointment.java similarity index 96% rename from src/main/java/seedu/address/model/person/Appointment.java rename to src/main/java/seedu/address/model/appointment/Appointment.java index 9301fb98216..40265ecc475 100644 --- a/src/main/java/seedu/address/model/person/Appointment.java +++ b/src/main/java/seedu/address/model/appointment/Appointment.java @@ -1,9 +1,12 @@ -package seedu.address.model.person; +package seedu.address.model.appointment; import static java.util.Objects.requireNonNull; import java.time.LocalDateTime; +import seedu.address.model.person.Doctor; +import seedu.address.model.person.Patient; + /** * The {@code Appointment} class represents a scheduled appointment between a doctor and a patient. * It includes information about the doctor, patient, and the appointment time. diff --git a/src/main/java/seedu/address/model/person/Doctor.java b/src/main/java/seedu/address/model/person/Doctor.java index 91df0c83ea8..633989e4ac4 100644 --- a/src/main/java/seedu/address/model/person/Doctor.java +++ b/src/main/java/seedu/address/model/person/Doctor.java @@ -1,10 +1,11 @@ package seedu.address.model.person; -import java.util.ArrayList; +import java.util.HashSet; import java.util.Objects; import java.util.Set; import seedu.address.commons.util.ToStringBuilder; +import seedu.address.model.appointment.Appointment; import seedu.address.model.tag.Tag; /** @@ -12,7 +13,7 @@ * Guarantees: details are present and not null, field values are validated, immutable. */ public class Doctor extends Person { - private ArrayList patients = new ArrayList(); + private final Set appointments = new HashSet<>(); /** * Every field must be present and not null. @@ -27,17 +28,17 @@ public Doctor(Name name, Phone phone, Email email, Address address, Remark remar * * @return An ArrayList containing the patients currently registered in the facility. */ - public ArrayList getPatients() { - return patients; + public Set getAppointments() { + return appointments; } /** * Adds a new patient to the medical facility's list of patients. * - * @param patient The Patient object representing the individual to be added. + * @param appointment The Patient object representing the individual to be added. */ - public void addPatient(Patient patient) { - this.patients.add(patient); + public void addAppointment(Appointment appointment) { + this.appointments.add(appointment); } /** @@ -68,7 +69,7 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof Person)) { + if (!(other instanceof Doctor)) { return false; } @@ -80,13 +81,13 @@ public boolean equals(Object other) { && gender.equals(otherDoctor.gender) && ic.equals(otherDoctor.ic) && tags.equals(otherDoctor.tags) - && patients.equals(otherDoctor.patients); + && appointments.equals(otherDoctor.appointments); } @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, tags, patients); + return Objects.hash(name, phone, email, address, gender, ic, tags, appointments); } @Override @@ -99,7 +100,7 @@ public String toString() { .add("remark", remark) .add("gender", gender) .add("nric", ic) - .add("patients", patients) + .add("appointments", appointments) .add("tags", tags) .toString(); } diff --git a/src/main/java/seedu/address/model/person/Patient.java b/src/main/java/seedu/address/model/person/Patient.java index ba5c430a89c..3bc873bf50d 100644 --- a/src/main/java/seedu/address/model/person/Patient.java +++ b/src/main/java/seedu/address/model/person/Patient.java @@ -2,10 +2,12 @@ import static seedu.address.commons.util.CollectionUtil.requireAllNonNull; +import java.util.HashSet; import java.util.Objects; import java.util.Set; import seedu.address.commons.util.ToStringBuilder; +import seedu.address.model.appointment.Appointment; import seedu.address.model.tag.Tag; /** @@ -17,8 +19,8 @@ public class Patient extends Person { // Patient specific fields private final Condition condition; private final BloodType bloodType; - //private final Doctor doctor; to be implemented after Doctor class created - private Phone emergencyContact; + private final Set appointments = new HashSet<>(); + private final Phone emergencyContact; /** * Every field must be present and not null. @@ -44,6 +46,24 @@ public Phone getEmergencyContact() { return emergencyContact; } + /** + * Retrieves the list of patients stored in this medical facility. + * + * @return An ArrayList containing the patients currently registered in the facility. + */ + public Set getAppointments() { + return appointments; + } + + /** + * Adds a new patient to the medical facility's list of patients. + * + * @param appointment The Patient object representing the individual to be added. + */ + public void addAppointment(Appointment appointment) { + this.appointments.add(appointment); + } + /** * Returns true if person is a doctor. */ @@ -85,7 +105,8 @@ public boolean equals(Object other) { && ic.equals(otherPatient.ic) && tags.equals(otherPatient.tags) && condition.equals(otherPatient.condition) - && bloodType.equals(otherPatient.bloodType); + && bloodType.equals(otherPatient.bloodType) + && appointments.equals(otherPatient.appointments); } @Override @@ -107,9 +128,9 @@ public String toString() { .add("nric", ic) .add("condition", condition) .add("bloodType", bloodType) + .add("appointments", appointments) .add("tags", tags) .toString(); } - } diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index 874827e4d5d..5e593ac8637 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -6,6 +6,7 @@ import seedu.address.model.AddressBook; import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.appointment.Appointment; import seedu.address.model.person.Address; import seedu.address.model.person.BloodType; import seedu.address.model.person.Condition; @@ -108,4 +109,12 @@ public static Set getTagSet(String... strings) { .collect(Collectors.toSet()); } + /** + * Returns a tag set containing the list of strings given. + */ + public static Set getAppointmentSet(Appointment... appointments) { + return Arrays.stream(appointments) + .collect(Collectors.toSet()); + } + } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedAppointment.java b/src/main/java/seedu/address/storage/JsonAdaptedAppointment.java new file mode 100644 index 00000000000..9c2fd4121d3 --- /dev/null +++ b/src/main/java/seedu/address/storage/JsonAdaptedAppointment.java @@ -0,0 +1,77 @@ +package seedu.address.storage; + +import static seedu.address.storage.JsonAdaptedPatient.MISSING_FIELD_MESSAGE_FORMAT; + +import java.time.LocalDateTime; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.appointment.Appointment; +import seedu.address.model.person.Doctor; +import seedu.address.model.person.Name; +import seedu.address.model.person.Patient; +import seedu.address.model.tag.Tag; + +/** + * Jackson-friendly version of {@link Tag}. + */ +class JsonAdaptedAppointment { + + private final Doctor doctor; + private final Patient patient; + private final LocalDateTime appointmentTime; + private final String status; + + /** + * Constructs a {@code JsonAdaptedTag} with the given {@code tagName}. + */ + @JsonCreator + public JsonAdaptedAppointment(@JsonProperty("doctor") Doctor doctor, @JsonProperty("patient") Patient patient, + @JsonProperty("appointmentTime") LocalDateTime appointmentTime, + @JsonProperty("status") String status) { + this.doctor = doctor; + this.patient = patient; + this.appointmentTime = appointmentTime; + this.status = status; + } + + /** + * Converts a given {@code Tag} into this class for Jackson use. + */ + public JsonAdaptedAppointment(Appointment source) { + doctor = source.getDoctor(); + patient = source.getPatient(); + appointmentTime = source.getAppointmentTime(); + status = source.getStatus(); + } + + public String checkStatus() throws IllegalValueException { + if (status == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName())); + } + return status; + } + + public LocalDateTime checkAppointmentTime() throws IllegalValueException { + if (appointmentTime == null) { + throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName())); + } + return appointmentTime; + } + + /** + * Converts this Jackson-friendly adapted tag object into the model's {@code Tag} object. + * + * @throws IllegalValueException if there were any data constraints violated in the adapted tag. + */ + public Appointment toModelType() throws IllegalValueException { + final Doctor modelDoctor = new JsonAdaptedDoctor(doctor).toModelType(); + final Patient modelPatient = new JsonAdaptedPatient(patient).toModelType(); + final LocalDateTime modelAppointmentTime = checkAppointmentTime(); + final String modelStatus = checkStatus(); + return new Appointment(modelDoctor, modelPatient, modelAppointmentTime, modelStatus); + } +} + diff --git a/src/main/java/seedu/address/storage/JsonAdaptedDoctor.java b/src/main/java/seedu/address/storage/JsonAdaptedDoctor.java index 604e56b5008..1a5d14f3df7 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedDoctor.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedDoctor.java @@ -1,42 +1,25 @@ package seedu.address.storage; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import seedu.address.commons.exceptions.IllegalValueException; -import seedu.address.model.person.Address; +import seedu.address.model.appointment.Appointment; import seedu.address.model.person.Doctor; -import seedu.address.model.person.Email; -import seedu.address.model.person.Gender; -import seedu.address.model.person.Ic; -import seedu.address.model.person.Name; import seedu.address.model.person.Person; -import seedu.address.model.person.Phone; -import seedu.address.model.person.Remark; -import seedu.address.model.tag.Tag; /** * Jackson-friendly version of {@link Doctor}. */ -public class JsonAdaptedDoctor { +public class JsonAdaptedDoctor extends JsonAdaptedPerson { - public static final String MISSING_FIELD_MESSAGE_FORMAT = "Person's %s field is missing!"; - - private final String name; - private final String phone; - private final String email; - private final String address; - private final String remark; - private final String gender; - private final String ic; - private final List tags = new ArrayList<>(); + public static final String MISSING_FIELD_MESSAGE_FORMAT = "Doctor's %s field is missing!"; + private final List appointments = new ArrayList<>(); /** * Constructs a {@code JsonAdaptedPerson} with the given person details. @@ -45,32 +28,22 @@ public class JsonAdaptedDoctor { public JsonAdaptedDoctor(@JsonProperty("name") String name, @JsonProperty("phone") String phone, @JsonProperty("email") String email, @JsonProperty("address") String address, @JsonProperty("remark") String remark, @JsonProperty("gender") String gender, - @JsonProperty("nric") String ic, @JsonProperty("tags") List tags) { - this.name = name; - this.phone = phone; - this.email = email; - this.address = address; - this.remark = remark; - this.gender = gender; - this.ic = ic; - if (tags != null) { - this.tags.addAll(tags); + @JsonProperty("nric") String ic, + @JsonProperty("appointments") List appointments, + @JsonProperty("tags") List tags) { + super(name, phone, email, address, remark, gender, ic, tags); + if (appointments != null) { + this.appointments.addAll(appointments); } } /** * Converts a given {@code Person} into this class for Jackson use. */ - public JsonAdaptedDoctor(Person source) { - name = source.getName().fullName; - phone = source.getPhone().value; - email = source.getEmail().value; - address = source.getAddress().value; - remark = source.getRemark().value; - gender = source.getGender().value; - ic = source.getIc().value; - tags.addAll(source.getTags().stream() - .map(JsonAdaptedTag::new) + public JsonAdaptedDoctor(Doctor source) { + super(source); + appointments.addAll(source.getAppointments().stream() + .map(JsonAdaptedAppointment::new) .collect(Collectors.toList())); } @@ -80,66 +53,17 @@ public JsonAdaptedDoctor(Person source) { * @throws IllegalValueException if there were any data constraints violated in the adapted person. */ public Doctor toModelType() throws IllegalValueException { - final List doctorTags = new ArrayList<>(); - for (JsonAdaptedTag tag : tags) { - doctorTags.add(tag.toModelType()); - } - - if (name == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName())); - } - if (!Name.isValidName(name)) { - throw new IllegalValueException(Name.MESSAGE_CONSTRAINTS); - } - final Name modelName = new Name(name); - - if (phone == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName())); - } - if (!Phone.isValidPhone(phone)) { - throw new IllegalValueException(Phone.MESSAGE_CONSTRAINTS); - } - final Phone modelPhone = new Phone(phone); - - if (email == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName())); - } - if (!Email.isValidEmail(email)) { - throw new IllegalValueException(Email.MESSAGE_CONSTRAINTS); - } - final Email modelEmail = new Email(email); - - if (address == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName())); - } - if (!Address.isValidAddress(address)) { - throw new IllegalValueException(Address.MESSAGE_CONSTRAINTS); - } - final Address modelAddress = new Address(address); - - if (remark == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Remark.class.getSimpleName())); - } - final Remark modelRemark = new Remark(remark); + Person p = super.toModelType(); - if (gender == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Gender.class.getSimpleName())); - } - if (!Gender.isValidGender(gender)) { - throw new IllegalValueException(Gender.MESSAGE_CONSTRAINTS); + final List listOfAppointments = new ArrayList<>(); + for (JsonAdaptedAppointment appointment : appointments) { + listOfAppointments.add(appointment.toModelType()); } - final Gender modelGender = new Gender(gender); - - if (ic == null) { - throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Ic.class.getSimpleName())); + Doctor modelDoctor = new Doctor(p.getName(), p.getPhone(), p.getEmail(), p.getAddress(), p.getRemark(), + p.getGender(), p.getIc(), p.getTags()); + for (Appointment appointment : listOfAppointments) { + modelDoctor.addAppointment(appointment); } - if (!Ic.isValidIc(ic)) { - throw new IllegalValueException(Ic.MESSAGE_CONSTRAINTS); - } - final Ic modelIc = new Ic(ic); - - final Set modelTags = new HashSet<>(doctorTags); - return new Doctor(modelName, modelPhone, modelEmail, modelAddress, modelRemark, modelGender, modelIc, - modelTags); + return modelDoctor; } } diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPatient.java b/src/main/java/seedu/address/storage/JsonAdaptedPatient.java index 54ed5a4b70a..1f7163eddde 100644 --- a/src/main/java/seedu/address/storage/JsonAdaptedPatient.java +++ b/src/main/java/seedu/address/storage/JsonAdaptedPatient.java @@ -1,11 +1,14 @@ package seedu.address.storage; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import seedu.address.commons.exceptions.IllegalValueException; +import seedu.address.model.appointment.Appointment; import seedu.address.model.person.BloodType; import seedu.address.model.person.Condition; import seedu.address.model.person.Patient; @@ -22,6 +25,7 @@ class JsonAdaptedPatient extends JsonAdaptedPerson { private final String emergencyContact; private final String condition; private final String bloodType; + private final List appointments = new ArrayList<>(); /** * Constructs a {@code JsonAdaptedPatient} with the given person details. @@ -31,9 +35,13 @@ public JsonAdaptedPatient(@JsonProperty("name") String name, @JsonProperty("phon @JsonProperty("email") String email, @JsonProperty("address") String address, @JsonProperty("remark") String remark, @JsonProperty("gender") String gender, @JsonProperty("ic") String ic, @JsonProperty("tags") List tags, + @JsonProperty("appointments") List appointments, @JsonProperty("condition") String condition, @JsonProperty("bloodType") String bloodType, @JsonProperty("emergencyContact") String emergencyContact) { super(name, phone, email, address, remark, gender, ic, tags); + if (appointments != null) { + this.appointments.addAll(appointments); + } this.condition = condition; this.bloodType = bloodType; this.emergencyContact = emergencyContact; @@ -45,6 +53,9 @@ public JsonAdaptedPatient(@JsonProperty("name") String name, @JsonProperty("phon public JsonAdaptedPatient(Patient source) { super(source); + appointments.addAll(source.getAppointments().stream() + .map(JsonAdaptedAppointment::new) + .collect(Collectors.toList())); this.emergencyContact = source.getEmergencyContact().value; this.bloodType = source.getBloodType().value; this.condition = source.getCondition().value; @@ -57,12 +68,22 @@ public JsonAdaptedPatient(Patient source) { */ public Patient toModelType() throws IllegalValueException { Person p = super.toModelType(); + + final List listOfAppointments = new ArrayList<>(); + for (JsonAdaptedAppointment appointment : appointments) { + listOfAppointments.add(appointment.toModelType()); + } final Phone modelEmergencyContact = checkEmergencyContact(); final Condition modelCondition = checkCondition(); final BloodType modelBloodType = checkBloodType(); - return new Patient(p.getName(), p.getPhone(), modelEmergencyContact, p.getEmail(), p.getAddress(), - p.getRemark(), p.getGender(), p.getIc(), modelCondition, modelBloodType, p.getTags()); + Patient modelPatient = new Patient(p.getName(), p.getPhone(), modelEmergencyContact, p.getEmail(), + p.getAddress(), p.getRemark(), p.getGender(), p.getIc(), modelCondition, modelBloodType, p.getTags()); + + for (Appointment appointment : listOfAppointments) { + modelPatient.addAppointment(appointment); + } + return modelPatient; } /** diff --git a/src/main/java/seedu/address/ui/DoctorCard.java b/src/main/java/seedu/address/ui/DoctorCard.java index f876a7e479f..4239149c785 100644 --- a/src/main/java/seedu/address/ui/DoctorCard.java +++ b/src/main/java/seedu/address/ui/DoctorCard.java @@ -7,6 +7,7 @@ import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; +import seedu.address.model.appointment.Appointment; import seedu.address.model.person.Doctor; @@ -41,6 +42,8 @@ public class DoctorCard extends UiPart { @FXML private FlowPane tags; @FXML + private FlowPane appointments; + @FXML private Label remark; @FXML private Label gender; @@ -64,5 +67,9 @@ public DoctorCard(Doctor doctor, int displayedIndex) { doctor.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + doctor.getAppointments().stream() + .sorted(Comparator.comparing(Appointment::getAppointmentTime)) + .forEach(appointment -> appointments.getChildren() + .add(new Label(appointment.getAppointmentTime().toString()))); } } diff --git a/src/main/java/seedu/address/ui/PatientCard.java b/src/main/java/seedu/address/ui/PatientCard.java index d23ffc80afc..fdcfdc72afa 100644 --- a/src/main/java/seedu/address/ui/PatientCard.java +++ b/src/main/java/seedu/address/ui/PatientCard.java @@ -7,6 +7,7 @@ import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.Region; +import seedu.address.model.appointment.Appointment; import seedu.address.model.person.Patient; /** @@ -41,6 +42,8 @@ public class PatientCard extends UiPart { @FXML private FlowPane tags; @FXML + private FlowPane appointments; + @FXML private Label remark; @FXML private Label gender; @@ -70,6 +73,10 @@ public PatientCard(Patient person, int displayedIndex) { person.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + person.getAppointments().stream() + .sorted(Comparator.comparing(Appointment::getAppointmentTime)) + .forEach(appointment -> appointments.getChildren() + .add(new Label(appointment.getAppointmentTime().toString()))); condition.setText("Condition: " + person.getCondition().value); bloodType.setText("Blood Type: " + person.getBloodType().value); diff --git a/src/main/resources/view/DoctorListCard.fxml b/src/main/resources/view/DoctorListCard.fxml index 0f988d18a13..0c266fc059f 100644 --- a/src/main/resources/view/DoctorListCard.fxml +++ b/src/main/resources/view/DoctorListCard.fxml @@ -28,6 +28,7 @@