Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Alteqa committed Apr 4, 2024
2 parents 8377e10 + 68c71f2 commit 47500f0
Show file tree
Hide file tree
Showing 29 changed files with 245 additions and 89 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies {
}

shadowJar {
archiveFileName = 'addressbook.jar'
archiveFileName = 'MediCLI.jar'
}

run {
Expand Down
127 changes: 79 additions & 48 deletions docs/UserGuide.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: "mediCLI"
title: "MediCLI"
theme: minima

header_pages:
Expand Down
Binary file added docs/images/addAppointment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/addDoctor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/addPatient.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/editAppointment.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/editPerson.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/helpMessage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class EditAppointmentCommand extends Command {
+ "by the index number used in the displayed appointment list. "
+ "Existing values will be overwritten by the input values.\n"
+ "Parameters: INDEX (must be a positive integer) "
+ "[" + PREFIX_DATE + "DATE]\n"
+ PREFIX_DATE + "DATE\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_DATE + "2024-04-09";
+ PREFIX_DATE + "2024-04-09 10:00";

public static final String MESSAGE_EDIT_APPOINTMENT_SUCCESS = "Edited Appointment: %1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/seedu/address/logic/commands/EditCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NRIC;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_APPOINTMENTS;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;

Expand Down Expand Up @@ -48,8 +47,7 @@ public class EditCommand extends Command {
+ "[" + PREFIX_NAME + "NAME] "
+ "[" + PREFIX_PHONE + "PHONE] "
+ "[" + PREFIX_NRIC + "NRIC] "
+ "[" + PREFIX_DOB + "DOB] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "[" + PREFIX_DOB + "DOB]\n"
+ "Example: " + COMMAND_WORD + " 1 "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_NRIC + "T0123452K";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class QueryDoctorAppointmentCommand extends Command {
private static final Logger logger = Logger.getLogger(QueryDoctorAppointmentCommand.class.getName());

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all appointments of doctors whose "
+ "nrics/names contain any of the specified keywords (case-insensitive) and displays them as a "
+ "nrics contain any of the specified keywords (case-insensitive) and displays them as a "
+ "list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...(Keywords can either be NRICs or Names)\n"
+ "Example: " + COMMAND_WORD + " alice bob T1234567A S7654321A";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class QueryPatientAppointmentCommand extends Command {
public static final String COMMAND_WORD = "apptforpatient";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all appointments of patients whose "
+ "nrics/names contain any of the specified keywords (case-insensitive) and displays them as a "
+ "nrics contain any of the specified keywords (case-insensitive) and displays them as a "
+ "list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...(Keywords can either be NRICs or Names)\n"
+ "Example: " + COMMAND_WORD + " alice bob T1234567A S7654321A";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ public class QueryPatientCommand extends Command {

public static final String COMMAND_WORD = "patient";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all patients whose names contain any of "
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all patients whose name, "
+ "NRIC, DoB or phone number contains 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";
+ "Example: " + COMMAND_WORD + " alice bob ethan";

private final PatientContainsKeywordsPredicate predicate;

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ public static Set<Tag> parseTags(Collection<String> tags) throws ParseException
public static AppointmentDateTime parseAppointmentDateTime(String apptDateTime) throws ParseException {
requireNonNull(apptDateTime);
String trimmedDate = apptDateTime.trim();
if (!AppointmentDateTime.isValidDate(trimmedDate)) {
String datetime = trimmedDate.substring(0, 11) + trimmedDate.substring(11).strip();
if (!AppointmentDateTime.isValidDate(datetime)) {
throw new ParseException(AppointmentDateTime.MESSAGE_CONSTRAINTS);
}
return new AppointmentDateTime(trimmedDate);
return new AppointmentDateTime(datetime);
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/UserPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class UserPrefs implements ReadOnlyUserPrefs {

private GuiSettings guiSettings = new GuiSettings();
private Path addressBookFilePath = Paths.get("data" , "medicli.json");
private Path addressBookFilePath = Paths.get("data" , "addressbook.json");

/**
* Creates a {@code UserPrefs} with default values.
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/seedu/address/model/appointment/Appointment.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ public Appointment(Nric doctorNric, Nric patientNric, AppointmentDateTime appoin
this.appointmentId = appointmentId;
}

/**
* constructs a new appointment instance
* @param doctorNric doctor in charge
* @param patientNric patient of the appointment
* @param appointmentDateTime dateTime of the appointment
* @param isInitialised a boolean value indication whether this was initialised by the json file
* @throws ParseException
*/
public Appointment(
Nric doctorNric, Nric patientNric,
AppointmentDateTime appointmentDateTime,
AppointmentId appointmentId, Boolean isInitialised) throws ParseException {
requireAllNonNull(doctorNric, patientNric, appointmentDateTime);
this.doctorNric = doctorNric;
this.patientNric = patientNric;
this.appointmentDateTime = appointmentDateTime;
this.appointmentId = new AppointmentId();
}
/**
* Checks if appointment is valid by comparing appointment date against current date.
* A valid new appointment can only be in the future, not the past.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public JsonAdaptedAppointment(@JsonProperty("doctorNric") String doctorNric,
public JsonAdaptedAppointment(Appointment source) {
doctorNric = source.getDoctorNric().toString();
patientNric = source.getPatientNric().toString();
appointmentDateTime = source.getAppointmentDateTime().appointmentDateTime.toString();
appointmentDateTime = source.getAppointmentDateTime().toString();
appointmentId = source.getAppointmentId().toString();
}

Expand Down Expand Up @@ -72,13 +72,13 @@ public Appointment toModelType() throws IllegalValueException {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
AppointmentDateTime.class.getSimpleName()));
}

if (!AppointmentDateTime.isValidDate(appointmentDateTime)) {
throw new IllegalValueException(AppointmentDateTime.MESSAGE_CONSTRAINTS);
}

final AppointmentDateTime modelAppointmentDateTime = new AppointmentDateTime(appointmentDateTime);


if (appointmentId == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT,
AppointmentId.class.getSimpleName()));
Expand All @@ -89,7 +89,8 @@ public Appointment toModelType() throws IllegalValueException {

final AppointmentId modelAppointmentId = new AppointmentId(appointmentId);

return new Appointment(modelDoctorNric, modelPatientNric, modelAppointmentDateTime, modelAppointmentId);
return new Appointment(modelDoctorNric, modelPatientNric,
modelAppointmentDateTime, modelAppointmentId, true);
}


Expand Down
6 changes: 5 additions & 1 deletion src/main/java/seedu/address/storage/StorageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ public Optional<ReadOnlyAddressBook> readAddressBook() throws DataLoadingExcepti
@Override
public Optional<ReadOnlyAddressBook> readAddressBook(Path filePath) throws DataLoadingException {
logger.fine("Attempting to read data from file: " + filePath);
return addressBookStorage.readAddressBook(filePath);
try {
return addressBookStorage.readAddressBook(filePath);
} catch (DataLoadingException e) {
return Optional.empty();
}
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/HelpWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public class HelpWindow extends UiPart<Stage> {

public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html";
public static final String USERGUIDE_URL = "https://ay2324s2-cs2103t-t15-1.github.io/tp/UserGuide.html";
public static final String HELP_MESSAGE = "Refer to the user guide: " + USERGUIDE_URL;

private static final Logger logger = LogsCenter.getLogger(HelpWindow.class);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import seedu.address.model.person.Person;

/**
* An UI component that displays information of a {@code Person}.
* A UI component that displays information of a {@code Person}.
*/
public class PersonCard extends UiPart<Region> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"z" : 99
}
},
"addressBookFilePath" : "medicli.json"
"addressBookFilePath" : "addressbook.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
"y" : 100
}
},
"addressBookFilePath" : "medicli.json"
"addressBookFilePath" : "addressbook.json"
}
2 changes: 1 addition & 1 deletion src/test/java/seedu/address/logic/LogicManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class LogicManagerTest {
@BeforeEach
public void setUp() {
JsonAddressBookStorage addressBookStorage =
new JsonAddressBookStorage(temporaryFolder.resolve("mediCli.json"));
new JsonAddressBookStorage(temporaryFolder.resolve("addressbook.json"));
JsonUserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(temporaryFolder.resolve("userPrefs.json"));
StorageManager storage = new StorageManager(addressBookStorage, userPrefsStorage);
logic = new LogicManager(model, storage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class JsonAdaptedAppointmentTest {
private static final String VALID_NRIC_1 = APPOINTMENT_1.getPatientNric().toString();
private static final String VALID_NRIC_2 = APPOINTMENT_1.getDoctorNric().toString();
private static final String VALID_DATE_A = APPOINTMENT_1.getAppointmentDateTime().toString();
private static final String VALID_DATE_B = APPOINTMENT_1.getAppointmentDateTime().appointmentDateTime.toString();
private static final String VALID_DATE_B = APPOINTMENT_1.getAppointmentDateTime().toString();
private static final String VALID_APPOINTMENT_ID = APPOINTMENT_1.getAppointmentId().toString();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void readUserPrefs_extraValuesInFile_extraValuesIgnored() throws DataLoad
private UserPrefs getTypicalUserPrefs() {
UserPrefs userPrefs = new UserPrefs();
userPrefs.setGuiSettings(new GuiSettings(1000, 500, 300, 100));
userPrefs.setAddressBookFilePath(Paths.get("medicli.json"));
userPrefs.setAddressBookFilePath(Paths.get("addressbook.json"));
return userPrefs;
}

Expand Down
29 changes: 13 additions & 16 deletions src/test/java/seedu/address/storage/StorageManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
//import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;

import java.nio.file.Path;
import java.util.Optional;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import seedu.address.commons.core.GuiSettings;
//import seedu.address.model.AddressBook;
//import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.UserPrefs;

public class StorageManagerTest {
Expand Down Expand Up @@ -47,19 +46,17 @@ public void prefsReadSave() throws Exception {
assertEquals(original, retrieved);
}

// @Test
// public void addressBookReadSave() throws Exception {
// /*
// * Note: This is an integration test that verifies the StorageManager is properly wired to the
// * {@link JsonAddressBookStorage} class.
// * More extensive testing of UserPref saving/reading is done in {@link JsonAddressBookStorageTest} class.
// */
// AddressBook original = getTypicalAddressBook();
// storageManager.saveAddressBook(original);
// ReadOnlyAddressBook retrieved = storageManager.readAddressBook().get();
// System.out.println(retrieved.equals(new AddressBook(retrieved)));
// assertEquals(original, new AddressBook(retrieved));
// }
@Test
public void addressBookReadSave() throws Exception {
/*
* Note: This is an integration test that verifies the StorageManager is properly wired to the
* {@link JsonAddressBookStorage} class.
* More extensive testing of UserPref saving/reading is done in {@link JsonAddressBookStorageTest} class.
*/
Optional<ReadOnlyAddressBook> retrieved =
storageManager.readAddressBook(getTempFilePath("addressbookinvalid.json"));
assertEquals(Optional.empty(), retrieved);
}

@Test
public void getAddressBookFilePath() {
Expand Down
60 changes: 60 additions & 0 deletions src/test/java/seedu/address/testutil/addressbookinvalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"persons" : [ {
"type" : "PATIENT",
"nric" : "S1234567A",
"name" : "John Doe",
"dob" : "2002-01-30",
"phone" : "92624417",
"tags" : [ ]
}, {
"type" : "PATIENT",
"nric" : "S0123456A",
"name" : "David Li",
"dob" : "2003-04-28",
"phone" : "87438807",
"tags" : [ ]
}, {
"type" : "DOCTOR",
"nric" : "S1234567s",
"name" : "John Doe",
"dob" : "2003-01-30",
"phone" : "98765432",
"tags" : [ ]
} ],
"appointments" : [ {
"doctorNric" : "s1234567s",
"patientNric" : "s1234567a",
"appointmentDateTime" : "2024-06-06 15:00",
"appointmentId" : "a48433956"
}, {
"doctorNric" : "s1234567s",
"patientNric" : "s1234567a",
"appointmentDateTime" : "2024-06-07 13:00",
"appointmentId" : "a14526721"
}, {
"doctorNric" : "s1234567s",
"patientNric" : "s1234567a",
"appointmentDateTime" : "2025-05-05 19:00",
"appointmentId" : "a56366553"
}, {
"doctorNric" : "s1234567s",
"patientNric" : "s1234567a",
"appointmentDateTime" : "2020-07-07 10:00",
"appointmentId" : "a11259511"
}, {
"doctorNric" : "s1234567s",
"patientNric" : "s1234567a",
"appointmentDateTime" : "2024-05-04 02:00",
"appointmentId" : "a20170899"
}, {
"doctorNric" : "s1234567s",
"patientNric" : "s1234567a",
"appointmentDateTime" : "2024-05-03 02:03",
"appointmentId" : "a50992029"
}, {
"doctorNric" : "s1234567s",
"patientNric" : "s1234567a",
"appointmentDateTime" : "2024kadlka",
"appointmentId" : "a13027485"
} ]
}
45 changes: 45 additions & 0 deletions src/test/java/seedu/address/ui/AppointmentCardTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package seedu.address.ui;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.junit.jupiter.api.Test;

import seedu.address.model.person.Person;

public class AppointmentCardTest {

private static final int INDEX = 1;

private AppointmentCard appointmentCard;
private Person samplePerson;

@Test
public void constructor_validPerson_correctFields() {
assertTrue(true);
}

@Test
public void constructor_nullPerson_throwsNullPointerException() {
assertTrue(true);
}

@Test
public void display() {
assertTrue(true);
}

@Test
public void equals() {
assertTrue(true);
}

@Test
public void equals_nullObject_returnsFalse() {
assertTrue(true);
}

@Test
public void hashCode_validHashCode() {
assertTrue(true);
}
}

0 comments on commit 47500f0

Please sign in to comment.