Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
chonguschonguschongus committed Nov 3, 2023
2 parents ab4e12c + 94de0a5 commit 710d318
Show file tree
Hide file tree
Showing 26 changed files with 699 additions and 105 deletions.
29 changes: 15 additions & 14 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ title: User Guide

MediLink Contacts(MLC) is a **desktop app for managing patients and doctors details, optimized for use via a Command
Line Interface** (CLI) while still having the benefits of a Graphical User Interface (GUI). If you can type fast, MLC
cang get your patients management tasks done faster than traditional GUI apps.
can get your patients management tasks done faster than traditional GUI apps.

### Table of Contents

* Table of Contents
{:toc}
{:toc}

--------------------------------------------------------------------------------------------------------------------

## Quick start

1. Ensure you have Java `11` or above installed in your Computer.

1. Download the latest `mediLink.jar` from [here](https://github.com/AY2324S1-CS2103T-T09-3/tp/releases).
1. Download the latest `MediLink.jar` from [here](https://github.com/AY2324S1-CS2103T-T09-3/tp/releases).

1. Copy the file to the folder you want to use as the _home folder_ for your MLC.

1. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar medilink.jar` command
1. Open a command terminal, `cd` into the folder you put the jar file in, and use the `java -jar Medilink.jar` command
to run the application.<br>
A GUI similar to the below should appear in a few seconds. Note how the app contains some sample data.<br>
![Ui](images/Ui.png)
Expand Down Expand Up @@ -139,14 +139,14 @@ Format: `add-patient n/NAME ic/IC g/GENDER p/PHONE_NUMBER ec/EMERGENCY_CONTACT e

Examples:

* `add-patient n/John Doe ic/S9851386G g/M p/98765432 ec/90123456 e/johnd@example.com a/John street, block 123, #01-01 d/T0123456H c/pneumothorax b/O+`
* `add-patient n/Betsy Crowe ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/High Priority pt/T0123556H`
* `add-patient n/John Doe ic/S9851386G g/M p/98765432 ec/90123456 e/johnd@example.com a/John street, block 123, #01-01 c/pneumothorax b/O+`
* `add-patient n/Betsy Crowe ic/S9851586G g/F p/98765433 ec/98765432 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/High Priority c/Flu b/O-`

### Creating an Appointment : `new-appt`

Creates a new appointment for patients.

Format: `new-appt pic/IC dic/IC time/yyyy-MM-dd HH:mm:ss`
Format: `new-appt pic/IC dic/IC time/yyyy-MM-dd HH:mm`

<div markdown="block" class="alert alert-info">
**:information_source: Take Note:**<br>
Expand All @@ -160,7 +160,7 @@ Format: `new-appt pic/IC dic/IC time/yyyy-MM-dd HH:mm:ss`

Examples:

* `new-appt pic/T0123456H dic/S9851586G time/2023-10-30T13:00:00`
* `new-appt pic/T0123456H dic/S9851586G time/2023-10-30 13:00`

### Deleting an Appointment : `delete-appt`

Expand Down Expand Up @@ -239,16 +239,17 @@ Format: `find KEYWORD [MORE_KEYWORDS]`
* When searching names, only full words will be matched e.g. `Han` will not match `Hans`
* When searching names, Persons matching at least one keyword will be returned (i.e. `OR` search).
e.g. `Hans Bo` will return `Hans Gruber`, `Bo Yang`
* Other supported attributes like NRIC, Gender and Blood Type will only handle one query `KEYWORD`, anything afterward is discarded.
* Other supported attributes like NRIC, Gender and Blood Type will only handle one query `KEYWORD`, anything afterward
is discarded.
* Below we have supported attributes and their example `KEYWORD`.
* It is recommended to use `list` to restore the view of all data after a `find` command

| Attribute | Example keywords |
|-----------|-----------------|
|-----------|-----------------|
| NRIC | T1125957G |
| Gender | M |
| Blood Type | Blood Type A+ |
| Name | Travis Kelce
| Blood Type | Blood Type A+ |
| Name | Travis Kelce

Examples:

Expand Down Expand Up @@ -284,15 +285,15 @@ Undoes the effect of the last command.

Format: `undo`

* Can only do upto 5 undos at any one time.
* Can only do up to 5 undos at any one time.

### Redo last action : `redo`

Repeats the previous command; an `undo` for an `undo` command.

Format: `redo`

* Can only do upto 5 redos at any one time.
* Can only do up to 5 redos at any one time.

### Adding / Deleting remarks : `remark`

Expand Down
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ header_pages:

markdown: kramdown

repository: "https://github.com/AY2324S1-CS2103T-T09-3/tp"
repository: "AY2324S1-CS2103T-T09-3/tp"
github_icon: "images/github-icon.png"

plugins:
Expand Down
Binary file modified docs/images/Ui.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 @@ -16,7 +16,7 @@
import seedu.address.model.person.Patient;

/**
* Adds a person to the address book.
* Adds an Appointment to the address book.
*/
public class AddAppointmentCommand extends Command {

Expand Down Expand Up @@ -55,6 +55,11 @@ public AddAppointmentCommand(Appointment appointment) {
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

if (toAdd.getDoctor().equals(toAdd.getPatient())) {
throw new CommandException(MESSAGE_SAME_DOCTOR_AND_PATIENT);
}

Patient chosenPatient = findPatient(model);
Doctor chosenDoctor = findDoctor(model);
checkPatientAndDoctor(chosenPatient, chosenDoctor);
Expand All @@ -74,6 +79,7 @@ private void checkValidAppointment(Patient chosenPatient, Doctor chosenDoctor, A
throw new CommandException(MESSAGE_DUPLICATE_APPOINTMENT_DOCTOR);
}
}

private void checkPatientAndDoctor(Patient chosenPatient, Doctor chosenDoctor) throws CommandException {
if (chosenPatient == null) {
throw new CommandException(MESSAGE_INVALID_PATIENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_APPOINTMENT_TIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_DOCTOR_IC;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PATIENT_IC;
import static seedu.address.model.appointment.Appointment.FORMATTER;

import java.time.LocalDateTime;
import java.time.format.DateTimeParseException;
import java.util.stream.Stream;

import seedu.address.logic.commands.AddAppointmentCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.appointment.Appointment;
import seedu.address.model.appointment.AppointmentTime;
import seedu.address.model.person.Ic;

/**
Expand Down Expand Up @@ -40,12 +38,8 @@ public AddAppointmentCommand parse(String args) throws ParseException {

Ic patientIc = ParserUtil.parseIc(argMultimap.getValue(PREFIX_PATIENT_IC).get());
Ic doctorIc = ParserUtil.parseIc(argMultimap.getValue(PREFIX_DOCTOR_IC).get());
LocalDateTime dateTime;
try {
dateTime = LocalDateTime.parse(argMultimap.getValue(PREFIX_APPOINTMENT_TIME).get(), FORMATTER);
} catch (DateTimeParseException e) {
throw new ParseException(e.getMessage());
}
AppointmentTime dateTime = ParserUtil.parseAppointmentTime(argMultimap.getValue(PREFIX_APPOINTMENT_TIME).get());

Appointment appointment = new Appointment(doctorIc, patientIc, dateTime);
return new AddAppointmentCommand(appointment);
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import seedu.address.commons.core.index.Index;
import seedu.address.commons.util.StringUtil;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.appointment.AppointmentTime;
import seedu.address.model.person.Address;
import seedu.address.model.person.BloodType;
import seedu.address.model.person.Condition;
Expand Down Expand Up @@ -298,4 +299,17 @@ public static Remark parseRemark(String remark) {
String trimmedRemark = remark.trim();
return new Remark(trimmedRemark);
}

/**
* Parses {@code String appointmentTime} into a {@code Appointment}.
* Leading and trailing whitespaces will be trimmed.
*/
public static AppointmentTime parseAppointmentTime(String appointmentTime) throws ParseException {
requireNonNull(appointmentTime);
String trimmedAppointmentTime = appointmentTime.trim();
if (!AppointmentTime.isValidAppointmentTime(trimmedAppointmentTime)) {
throw new ParseException(AppointmentTime.MESSAGE_CONSTRAINTS);
}
return new AppointmentTime(trimmedAppointmentTime);
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ public void deletePerson(Person target) {

@Override
public void addPerson(Person person) {
if (person instanceof Patient) {
if (person.isPatient()) {
updateBackup();
addressBook.addPatient((Patient) person);
} else if (person instanceof Doctor) {
} else if (person.isDoctor()) {
updateBackup();
addressBook.addDoctor((Doctor) person);
}
Expand Down
17 changes: 7 additions & 10 deletions src/main/java/seedu/address/model/appointment/Appointment.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import static java.util.Objects.requireNonNull;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Objects;

import seedu.address.model.person.Ic;
Expand All @@ -14,11 +12,10 @@
* Doctor and patient ic should not be the same.
*/
public class Appointment {
public static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private Ic doctorIc;
private Ic patientIc;
private LocalDateTime appointmentTime;
private String status = "scheduled";
private AppointmentTime appointmentTime;
private String status = "Scheduled";

/**
* Constructs a new appointment with the specified doctor, patient, and appointment time.
Expand All @@ -27,7 +24,7 @@ public class Appointment {
* @param patientIc The patient involved in the appointment.
* @param appointmentTime The date and time of the appointment.
*/
public Appointment(Ic doctorIc, Ic patientIc, LocalDateTime appointmentTime) {
public Appointment(Ic doctorIc, Ic patientIc, AppointmentTime appointmentTime) {
requireNonNull(doctorIc);
requireNonNull(patientIc);
requireNonNull(appointmentTime);
Expand All @@ -44,7 +41,7 @@ public Appointment(Ic doctorIc, Ic patientIc, LocalDateTime appointmentTime) {
* @param appointmentTime The date and time of the appointment.
* @param status The status of the appointment.
*/
public Appointment(Ic doctorIc, Ic patientIc, LocalDateTime appointmentTime, String status) {
public Appointment(Ic doctorIc, Ic patientIc, AppointmentTime appointmentTime, String status) {
requireNonNull(doctorIc);
requireNonNull(patientIc);
requireNonNull(appointmentTime);
Expand All @@ -55,7 +52,7 @@ public Appointment(Ic doctorIc, Ic patientIc, LocalDateTime appointmentTime, Str
this.status = status;
}

public LocalDateTime getAppointmentTime() {
public AppointmentTime getAppointmentTime() {
return appointmentTime;
}

Expand All @@ -71,7 +68,7 @@ public String getStatus() {
return status;
}

public void setAppointmentTime(LocalDateTime appointmentTime) {
public void setAppointmentTime(AppointmentTime appointmentTime) {
this.appointmentTime = appointmentTime;
}

Expand Down Expand Up @@ -113,6 +110,6 @@ public int hashCode() {
@Override
public String toString() {
return "Patient with IC " + patientIc + ", Doctor with IC " + doctorIc + " at "
+ appointmentTime.format(FORMATTER);
+ appointmentTime.toString();
}
}
73 changes: 73 additions & 0 deletions src/main/java/seedu/address/model/appointment/AppointmentTime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package seedu.address.model.appointment;

import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.AppUtil.checkArgument;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;


/**
* Represents the time of an appointment.
* Guarantees: immutable; is valid as declared in {@link #isValidAppointmentTime(String)}
*/
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 final LocalDateTime value;

/**
* Constructs a {@code AppointmentTime}.
*
* @param appointmentTime A valid ic.
*/
public AppointmentTime(String appointmentTime) {
requireNonNull(appointmentTime);
checkArgument(isValidAppointmentTime(appointmentTime), MESSAGE_CONSTRAINTS);
value = LocalDateTime.parse(appointmentTime, FORMATTER);
}

/**
* Returns true if a given string is a valid appointmentTime.
*/
public static boolean isValidAppointmentTime(String test) {
try {
LocalDateTime.parse(test, FORMATTER);
} catch (DateTimeParseException e) {
return false;
}
return true;
}

@Override
public String toString() {
return value.format(FORMATTER);
}

@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}

// instanceof handles nulls
if (!(other instanceof AppointmentTime)) {
return false;
}

AppointmentTime otherAppointmentTime = (AppointmentTime) other;
return value.equals(otherAppointmentTime.value);
}

@Override
public int hashCode() {
return value.hashCode();
}

@Override
public int compareTo(AppointmentTime o) {
return this.value.compareTo(o.value);
}
}
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/person/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;

import java.time.LocalDateTime;
import java.util.Collections;
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.appointment.AppointmentTime;
import seedu.address.model.tag.Tag;

/**
Expand Down Expand Up @@ -111,7 +111,7 @@ public boolean hasIc(Ic ic) {
* @param dateTime the time of appointment to be checked.
* @return true is this person has an appointment at the specified time.
*/
public boolean hasAppointmentAt(LocalDateTime dateTime) {
public boolean hasAppointmentAt(AppointmentTime dateTime) {
requireNonNull(dateTime);
// check from set of appointments
for (Appointment a : appointments) {
Expand Down
Loading

0 comments on commit 710d318

Please sign in to comment.