Skip to content

Commit

Permalink
Merge pull request AY2223S1-CS2103T-T14-3#176 from marclzh/branch-1.4…
Browse files Browse the repository at this point in the history
…Final

Final 1.4 Fix
  • Loading branch information
LJXSean authored Nov 7, 2022
2 parents 0c05138 + 47aa369 commit 7908fa0
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/_sass/minima/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
* Posts
*/
.post-header {
margin-bottom: $spacing-unit;
margin-bottom: $spacing-unit / 2;
}

.post-title,
Expand Down
19 changes: 8 additions & 11 deletions docs/team/marclzh.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
layout: page
title: Marcus Lee's Project Portfolio Page
layout: page title: Marcus Lee's Project Portfolio Page
---
### Project: OmniHealth

OmniHealth is a **Patient Management System** tailored to private clinicians to manage patients' details, records and
upcoming appointments. As a private clinician, you can manage and monitor your patient database all in one location.
OmniHealth allows you to manage and search for your patient's details and records with ease with its management system,
Expand All @@ -30,13 +27,12 @@ Given below are my contributions to the project.
* Justification: Since the target users are doctors, this is a key feature that allows users to plan out their
schedule of when next to see a patient. Due to the nature of different illnesses and medication requirements, the
ability to forward plan appointments for the user's patients would greatly benefit their workflow.
* Highlights: This feature entailed adding code to most of the areas of OmniHealth, including its model, UI and test
cases, as well as requiring changes to existing commands.

* **Code contributed**: [RepoSense link](https://nus-cs2103-ay2223s1.github.io/tp-dashboard/?search=marclzh&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=docs~functional-code~test-code~other&since=2022-09-16&tabOpen=true&tabType=authorship&zFR=false&tabAuthor=marclzh&tabRepo=AY2223S1-CS2103T-T14-3%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=docs~functional-code~test-code~other&authorshipIsBinaryFileTypeChecked=false&authorshipIsIgnoredFilesChecked=false)

<div style="page-break-after: always;"></div>

* **Code
contributed**: [RepoSense link](https://nus-cs2103-ay2223s1.github.io/tp-dashboard/?search=marclzh&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=docs~functional-code~test-code~other&since=2022-09-16&tabOpen=true&tabType=authorship&zFR=false&tabAuthor=marclzh&tabRepo=AY2223S1-CS2103T-T14-3%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=docs~functional-code~test-code~other&authorshipIsBinaryFileTypeChecked=false&authorshipIsIgnoredFilesChecked=false)

* **Project management**:
* Created team's organisation and repository.
* Set up project's Continuous Integration and website.
Expand All @@ -51,6 +47,8 @@ Given below are my contributions to the project.
* Wrote test cases for `Record` and `Appointment` classes. (Pull
Requests [\#58](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/58)
, [\#91](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/91)
* Added Logging for `Appointment`, `AddAppointmentCommand`, `ClearAppointmentCommand`, `ClearRecordCommand`
, `Record` and `RecordList` classes. [\#176](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/176)

* **Documentation**:
* User Guide:
Expand All @@ -61,9 +59,8 @@ Given below are my contributions to the project.
, [\#98](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/98))
* Added details on date validation for features that include
dates. [\#149](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/149)
* Improved continuity of UG, allowing for better
flow. [\#149](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/149)
* Amended various issues found by other students. [\#149](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/149)
* Improved continuity of UG, allowing for better flow and amended various issues raised by other
students. [\#149](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/149)
* Developer Guide:
* Added implementation details of the `Clear Record`
feature. [\#89](https://github.com/AY2223S1-CS2103T-T14-3/tp/pull/89)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE;

import java.util.List;
import java.util.logging.Logger;

import seedu.address.MainApp;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
Expand All @@ -30,6 +33,8 @@ public class AddAppointmentCommand extends Command {
public static final String DATE_MISSING = "No date & time given! "
+ "Appointments must have date & time, formatted in d/dd-MM-yyyy HHmm.";

private static final Logger logger = LogsCenter.getLogger(MainApp.class);

private final Index index;
private final String appointmentDate;

Expand All @@ -42,18 +47,27 @@ public class AddAppointmentCommand extends Command {
public AddAppointmentCommand(Index index, String appointmentDate) {
requireAllNonNull(index, appointmentDate);

assert index != null;
assert appointmentDate != null;

this.index = index;
this.appointmentDate = appointmentDate;

logger.info("Appointment created for index: " + this.index.getOneBased()
+ " & Appointment Date: " + this.appointmentDate);
}

@Override
public CommandResult execute(Model model) throws CommandException {
List<Person> lastShownList = CommandUtil.prepareFilteredList(model, index);

if (!Appointment.isFutureDate(appointmentDate)) {
logger.warning("Appointment Date is in the future.");
throw new CommandException(Appointment.MESSAGE_DATE_PAST);
}

assert Appointment.isFutureDate(appointmentDate);

Person personToEdit = lastShownList.get(index.getZeroBased());
Person editedPerson = new Person(personToEdit.getName(), personToEdit.getBirthdate(),
personToEdit.getPhone(), personToEdit.getEmail(),
Expand All @@ -62,6 +76,9 @@ public CommandResult execute(Model model) throws CommandException {

model.setPerson(personToEdit, editedPerson);
model.updateFilteredPersonList(Model.PREDICATE_SHOW_ALL_PERSONS);

logger.info("Appointment has been added successfully.");

return new CommandResult(String.format(MESSAGE_SUCCESS,
personToEdit.getName().toString()) + ": " + appointmentDate);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package seedu.address.logic.commands;

import java.util.List;
import java.util.logging.Logger;

import seedu.address.MainApp;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
Expand All @@ -21,10 +24,19 @@ public class ClearAppointmentCommand extends Command {

public static final String MESSAGE_SUCCESS = "Appointment cleared!";

private static final Logger logger = LogsCenter.getLogger(MainApp.class);

private final Index index;

/**
* Constructs a ClearAppointmentCommand to clear an appointment for a patient.
*
* @param index Index of the patient.
*/
public ClearAppointmentCommand(Index index) {
this.index = index;

logger.info("ClearAppointmentCommand created with index: " + this.index.getOneBased());
}

@Override
Expand All @@ -39,6 +51,9 @@ public CommandResult execute(Model model) throws CommandException {

model.setPerson(personToEdit, editedPerson);
model.updateFilteredPersonList(Model.PREDICATE_SHOW_ALL_PERSONS);

logger.info("Appointment has been cleared successfully.");

return new CommandResult(MESSAGE_SUCCESS);
}

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/seedu/address/logic/commands/ClearCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import static java.util.Objects.requireNonNull;

import java.util.logging.Logger;

import seedu.address.MainApp;
import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.AddressBook;
import seedu.address.model.Model;
Expand All @@ -14,16 +18,21 @@ public class ClearCommand extends Command {
public static final String COMMAND_WORD = "clear";
public static final String MESSAGE_SUCCESS = "Patient list has been cleared!";

private static final Logger logger = LogsCenter.getLogger(MainApp.class);

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

if (model.isRecordListDisplayed()) {
logger.warning("Patient List View not currently displayed.");
throw new CommandException(MESSAGE_ADDRESS_BOOK_COMMAND_PREREQUISITE);
}

model.setAddressBook(new AddressBook());

logger.info("Patient List has been cleared successfully.");

return new CommandResult(MESSAGE_SUCCESS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import static java.util.Objects.requireNonNull;

import java.util.logging.Logger;

import seedu.address.MainApp;
import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;

Expand All @@ -17,16 +21,21 @@ public class ClearRecordCommand extends Command {

public static final String MESSAGE_SUCCESS = "Patient's record list has been cleared!";

private static final Logger logger = LogsCenter.getLogger(MainApp.class);

@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

if (!model.isRecordListDisplayed()) {
logger.warning("Patient List View is not currently being displayed.");
throw new CommandException(MESSAGE_RECORD_COMMAND_PREREQUISITE);
}

model.clearRecords();

logger.info("Records have been cleared.");

return new CommandResult(MESSAGE_SUCCESS,
false, false, true);
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/seedu/address/logic/commands/CommandUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
import static seedu.address.logic.commands.Command.MESSAGE_ADDRESS_BOOK_COMMAND_PREREQUISITE;

import java.util.List;
import java.util.logging.Logger;

import seedu.address.MainApp;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.core.Messages;
import seedu.address.commons.core.index.Index;
import seedu.address.logic.commands.exceptions.CommandException;
Expand All @@ -15,6 +18,9 @@
* Contains utility methods for the Command classes.
*/
public class CommandUtil {

private static final Logger logger = LogsCenter.getLogger(MainApp.class);

/**
* Prepares the model for index based commands.
*
Expand All @@ -26,13 +32,15 @@ public static List<Person> prepareFilteredList(Model model, Index index) throws
requireNonNull(model);

if (model.isRecordListDisplayed()) {
logger.warning("Patient List View is not currently being displayed.");
throw new CommandException(MESSAGE_ADDRESS_BOOK_COMMAND_PREREQUISITE);
}

List<Person> lastShownList = model.getFilteredPersonList();

// Check if index given is out of bounds
if (index.getZeroBased() >= lastShownList.size()) {
logger.warning("Patient index specified is invalid.");
throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/seedu/address/model/person/Appointment.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static boolean isValidDateFormat(String testDate) {
try {
LocalDateTime.parse(testDate, DATE_FORMAT);
} catch (DateTimeParseException e) {

return false;
}
return true;
Expand All @@ -59,8 +60,8 @@ public static boolean isValidDateFormat(String testDate) {
/**
* Returns true if the date is in the past.
*
* @param testDate Date to be tested
* @return
* @param testDate Date to be tested.
* @return True if date is passed.
*/
public static boolean isFutureDate(String testDate) {
LocalDateTime currDate = LocalDateTime.now();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/seedu/address/model/record/Record.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Logger;

import seedu.address.MainApp;
import seedu.address.commons.core.LogsCenter;

/**
* Represents a single record in the record list of a Person object.
Expand All @@ -22,6 +26,9 @@ public class Record implements Comparable<Record> {
public static final String MESSAGE_INVALID_DATE_FORMAT = "Record dates have to be of format dd-MM-yyyy HHmm!"
+ "Please also ensure this is a valid date!";
public static final String MESSAGE_FUTURE_DATE = "Record dates must not be later than the current date!";

private static final Logger logger = LogsCenter.getLogger(MainApp.class);

/* Data Fields */
public final String record;
private final LocalDateTime recordDate;
Expand All @@ -39,6 +46,7 @@ public Record(LocalDateTime recordDate, String record, Set<Medication> meds) {
this.recordDate = recordDate;
this.record = record;
this.medications = meds;
logger.info("Record created with record date: " + this.recordDate + " with record " + this.record);
}

/**
Expand Down Expand Up @@ -66,6 +74,7 @@ public static boolean isValidDateFormat(String testDate) {
try {
LocalDateTime.parse(testDate, DATE_FORMAT);
} catch (DateTimeParseException e) {
logger.warning("Record date is invalid");
return false;
}
return true;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/model/record/RecordList.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;

import java.util.logging.Logger;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.address.MainApp;
import seedu.address.commons.core.LogsCenter;
import seedu.address.model.person.exceptions.DuplicateRecordException;
import seedu.address.model.person.exceptions.RecordNotFoundException;

/**
* Represents a record list in the address book.
*/
public class RecordList {
private static final Logger logger = LogsCenter.getLogger(MainApp.class);
/* Record List variables */
// count of the record list should be accessed through the ArrayList#size() method.
private final ObservableList<Record> recordList = FXCollections.observableArrayList();
Expand All @@ -21,11 +26,13 @@ public class RecordList {
/**
* Adds a record to the RecordList.
* The person must not already exist in the list.
*
* @param toAdd Record to add.
*/
public void add(Record toAdd) {
requireNonNull(toAdd);
if (contains(toAdd)) {
logger.warning("Duplicate record detected.");
throw new DuplicateRecordException();
}
recordList.add(toAdd);
Expand Down Expand Up @@ -74,10 +81,12 @@ public void set(Record target, Record editedRecord) {

int index = recordList.indexOf(target);
if (index == -1) {
logger.warning("Index input is negative and invalid.");
throw new RecordNotFoundException();
}

if (!target.isSameRecord(editedRecord) && this.contains(editedRecord)) {
logger.warning("Record is duplicate.");
throw new DuplicateRecordException();
}

Expand All @@ -103,6 +112,7 @@ public boolean equals(Object other) {
public void delete(Record record) {
requireNonNull(record);
if (!recordList.remove(record)) {
logger.warning("Record not found");
throw new RecordNotFoundException();
}
recordList.remove(record);
Expand Down

0 comments on commit 7908fa0

Please sign in to comment.