diff --git a/build.gradle b/build.gradle
index 5cd2de53441..b12618d46a5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -66,7 +66,7 @@ dependencies {
}
shadowJar {
- archiveFileName = 'addressbook.jar'
+ archiveFileName = 'MediLink.jar'
}
defaultTasks 'clean', 'test'
diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md
index 3c4d14fab90..204a91bde68 100644
--- a/docs/DeveloperGuide.md
+++ b/docs/DeveloperGuide.md
@@ -129,7 +129,7 @@ Here's a (partial) class diagram of the `Logic` component:
-The sequence diagram below illustrates the interactions within the `Logic` component, taking `execute("delete 1")` API
+The sequence diagram below illustrates the interactions within the `Logic` component, taking `execute("delete NRIC")` API
call as an example.
![Interactions Inside the Logic Component for the `delete 1` Command](images/DeleteSequenceDiagram.png)
@@ -618,6 +618,39 @@ otherwise)
Use case resumes at step 2.
+* 4b. The edited fields include invalid inputs.
+
+ * 4b1. Medilink Contacts shows an error message.
+
+ Use case resumes at step 2.
+
+**Use case: UC5 - Undo a command**
+
+**MSS**
+
+1. User requests to delete a specific person in the list.
+2. Medilink Contacts deletes the person.
+3. User realises mistake, requests to undo previous action.
+4. Medilink Contacts reverts to state before patient was deleted.
+
+ Use case ends.
+
+**Extensions**
+
+* 4a. User wants to redo the command.
+
+ * 4a1. User requests to redo last command.
+ * 4a2. MediLink Contacts reverts to state where patient was deleted.
+
+ Use case ends.
+
+* 4b. User wants to perform another undo when there are no further actions to be undone.
+
+ * 4b1. User requests to undo again.
+ * 4b2. Medilink Contacts shows an error message.
+
+ Use case ends.
+
### Non-Functional Requirements
1. Should work on any _mainstream OS_ as long as it has Java `11` or above installed.
diff --git a/docs/UserGuide.md b/docs/UserGuide.md
index 05a56e0c57c..26b53b567fd 100644
--- a/docs/UserGuide.md
+++ b/docs/UserGuide.md
@@ -3,31 +3,32 @@ layout: page
title: User Guide
---
-MediLink Contacts(MLC) is a **desktop app for managing patients and doctors details, optimized for use via a Command
+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
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. Ensure you have Java `11` or above installed in your Computer. If you don't, install it for your relevant operating
+ system at this link https://www.oracle.com/sg/java/technologies/javase/jdk11-archive-downloads.html
-1. Download the latest `mediLink.jar` from [here](https://github.com/AY2324S1-CS2103T-T09-3/tp/releases).
+2. 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.
+3. 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
+4. 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.
A GUI similar to the below should appear in a few seconds. Note how the app contains some sample data.
![Ui](images/Ui.png)
-1. Type the command in the command box and press Enter to execute it. e.g. typing **`help`** and pressing Enter will
+5. Type the command in the command box and press Enter to execute it. e.g. typing **`help`** and pressing Enter will
open the help window.
Some example commands you can try:
@@ -42,9 +43,26 @@ can get your patients management tasks done faster than traditional GUI apps.
* `exit` : Exits the app.
-1. Refer to the [Features](#features) below for details of each command.
+6. Refer to the [Features](#features) below for details of each command.
--------------------------------------------------------------------------------------------------------------------
+## Parameters
+
+The list below contains the parameters that are used in various commands as well as their various constraints.
+
+| Parameter | Constraints | Valid Examples | Invalid Examples |
+|:--------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------|:-------------------------|
+| NRIC | Starting with S or T, followed by 7 numbers, and ends with a letter. Not case-sensitive. | T0123456G, s33344476i | T01234567G, “”, t12367K |
+| Doctor/Patient name | Empty strings are not allowed. Name must contain only alphanumeric characters. | Cristiano Ronaldo, Tanveer Singh | “”, 高橋紳助, s/o someone |
+| Contact number | 3 digit or more integer as phone number. Empty strings are not allowed. | 91234569 | “”, 99 |
+| Email | Must be of the format `local-name`@`domain`. `local-name` should only contain alphanumeric characters and these special characters, excluding the parentheses, (+_.-), and may not start or end with any special characters. `domain` is made up of domain labels separated by periods, and must end with a domain label at least 2 characters long. Domain labels start and end with alphanumeric characters, consist of alphanumeric characters, separated only by hyphens, if any. | j@Email.com, isaac@a-b.com | isaac@a+b.com, james.com |
+| Blood type | Accepts only strings containing valid blood types, that is a combination of A/B/AB/O and +/-. | B+, O, B-, AB | J, K |
+| Address | Any non-empty string. | Clementi, OneCare@Hougang Avenue | "" |
+| Gender | Either the character “M” or “F”. | M, F | G, girl, male |
+| Emergency Contact | Valid Contact number. Same constraints as the Contact Number parameter. | 91234569 | “”, 99 |
+| Condition | Any non-empty string. | Knee Injury, appendicitis | "" |
+| Patient Tag | Accepts only strings containing valid priority levels, either low, medium or high. Not case-sensitive | low, MEDIUM, hiGh | extreme, med |
+| Doctor Tag | Accepts only strings containing valid specialisations. Not case-sensitive. The current allowed specialisations are listed in the examples box. | CARDIOLOGIST, ORTHOPEDIC, PEDIATRICIAN, DERMATOLOGIST, NEUROLOGIST, GENERAL_PRACTITIONER, PSYCHIATRIST, SURGEON | Nurse, Head-Doctor |
## Features
@@ -75,7 +93,7 @@ can get your patients management tasks done faster than traditional GUI apps.
### Viewing help : `help`
-Shows a message explaning how to access the help page.
+Shows a message explaining how to access the help page.
![help message](images/helpMessage.png)
@@ -83,13 +101,13 @@ Format: `help`
### Adding a Doctor: `add-doctor`
-Adds a Doctor to the hospital database.
+Adds a Doctor to the clinic database.
Format: `add-doctor n/NAME ic/IC g/GENDER p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…`
:bulb:
**Tip:**
-A person can have any number of tags (including 0)
+A doctor can have any number of tags (including 0). Duplicate tags, however, are NOT allowed.
@@ -97,23 +115,29 @@ A person can have any number of tags (including 0)
- A doctor **MUST** have a non-empty NAME and a valid IC at the very least.
Failure to include these details may result in an error.
+- A person can either be a doctor or a patient, but not both. Hence if the doctor's IC is already in the app
+as a patient, it may result in an error.
- Phone Numbers and Emails have to be in a valid format.
- PHONE_NUMBER must have exactly 8 digits.
- EMAIL must contain email domain (eg. `@gmail.com`).
- PATIENT must contain the valid IC of a Patient in the Database.
+- Tags for doctors represent the specialisation(s) of the doctor. Only tags from the list below are supported
+in our current version:
+ `CARDIOLOGIST, ORTHOPEDIC, PEDIATRICIAN, DERMATOLOGIST, NEUROLOGIST, GENERAL_PRACTITIONER, PSYCHIATRIST, SURGEON`
+- Tags are not case-sensitive (e.g. `t/SURGEON` and `t/surgeon` are both valid inputs).
Examples:
-* `add-doctor n/John Doe ic/S9851386G g/M p/98765432 e/johnd@example.com a/John street, block 123, #01-01 pt/T0123456H`
+* `add-doctor n/John Doe ic/S9851386G g/M p/98765432 e/johnd@example.com a/John street, block 123, #01-01 t/Pediatrician`
* `add-doctor n/Betsy Crowe ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 t/Surgeon`
### Adding a Patient: `add-patient`
-Adds a Patient to the hospital database.
+Adds a Patient to the clinic database.
-Format: `add-patient n/NAME ic/IC g/GENDER p/PHONE_NUMBER ec/EMERGENCY_CONTACT e/EMAIL a/ADDRESS [t/TAG] [d/DOCTOR] [c/CONDITION] [b/BLOODTYPE] …`
+Format: `add-patient n/NAME ic/IC g/GENDER p/PHONE_NUMBER ec/EMERGENCY_CONTACT e/EMAIL a/ADDRESS c/CONDITION b/BLOODTYPE [t/TAG] `
@@ -121,43 +145,90 @@ Format: `add-patient n/NAME ic/IC g/GENDER p/PHONE_NUMBER ec/EMERGENCY_CONTACT e
- A patient **MUST** have a non-empty NAME and a valid IC at the very least. Failure to include these details may result
in an error.
+- A person can either be a doctor or a patient, but not both. Hence, if the patient's IC is already in the app
+ as a doctor, it may result in an error.
- Phone Numbers and Emails have to be in a valid format.
- - PHONE_NUMBER must have exactly 8 digits.
+ - PHONE_NUMBER must have at least 3 digits.
- EMAIL must contain email domain (eg. `@gmail.com`).
-- DOCTOR must contain the valid IC of a doctor in the Database.
-- EMERGENCY_CONTACT must contain valid emergency contact number, which needs to be a valid phone number.
-- Blood type must be a combination of A/B/AB/O and +/-
+- TAG must indicate Priority Level of the Patient and be one of the following:
+ - Low
+ - Medium
+ - High
+- EMERGENCY_CONTACT must contain valid emergency contact number, which needs to be a valid phone number. This number can be the same the person's contact number.
+- Blood type must be a combination of A/B/AB/O and +/-.
+- A patient can only have up to one tag at any time.
+- Tags for patients represent the priority level of the patient. Only the following tags are allowed: Low, Medium, High.
+- Tags are not case-sensitive (e.g. `t/LOW` and `t/low` are both valid inputs).
**:information_source: Take Note:**
- All fields are Required.
-- EMAIL must follow the specified format (ie. `yyyy-MM-dd HH:mm:ss`).
+- TIME must follow the specified format (ie. `yyyy-MM-dd HH:mm`), where `HH:mm` follows the 24hr format.
- PATIENT must contain the valid IC of a Patient in the Database.
- DOCTOR must contain the valid IC of a Doctor in the Database.
+- There must not be conflicting Appointments. (eg the doctor already has an appointment with another patient at the same time) However, the duration of each appointment is flexible and up to the users. As long as appointments are not at the exact same time, users can add it in.
+**:information_source: Take Note:**
+
+- Index is according to the list view in the application.
+- Use `list` command to find index of desired appointment.
+
+
+
+Examples:
+
+* `delete-appt 1`
+
+### Finding a Appointment : `find-appt`
+
+Finds all appointments that involve a specific patient/doctor.
+
+Format: `find-appt NRIC`
+
+
+**:information_source: Take Note:**
+
+- All fields are Required.
+- NRIC must contain the valid NRIC of a Patient or Doctor in the Database.
+- Either Doctor NRIC or Patient NRIC can be used in the search
+- It is recommended to use `list` to restore the view of all data after a `find` command.
+
+
+
+Examples:
+
+* `find-appt T0001222Q`
### Listing all persons : `list`
-Shows a list of all persons in the MediLink Contacts.
+Shows a list of all persons and appointments in the MediLink Contacts.
Format: `list`
@@ -169,44 +240,83 @@ Format: `edit NRIC [n/NAME] [p/PHONE] [e/EMAIL] [a/ADDRESS] [t/TAG]…`
* Edits the person at the specified `NRIC`. The NRIC **must be a valid IC number**
* At least one of the optional fields must be provided.
+* If the provided fields are the same as the original, the command will still work.
* Must edit appropriate fields based on whether the person is a patient or doctor (e.g. can't update condition of a
doctor)
* Existing values will be updated to the input values.
* When editing tags, the existing tags of the person will be removed i.e adding of tags is not cumulative.
* You can remove all the person’s tags by typing `t/` without
specifying any tags after it.
+* Note: In our app, the Remark Section will be left blank by default. Edit Command can be used to add any misc info not captured by other fields such as possible allergies, medical history, etc.
Examples:
* `edit T0123456A p/91234567 e/johndoe@example.com g/F` Edits the phone number and email address of the 1st person to
be `91234567` and `johndoe@example.com` respectively.
-* `edit S9876543B pt/T0123456A n/Betsy Crower t/` Edits the name of the 2nd person to be `Betsy Crower` and clears all
+* `edit S9876543B n/Betsy Crower t/` Edits the name of the 2nd person to be `Betsy Crower` and clears all
existing tags.
### Locating persons by name: `find`
-Finds persons that match the query. Supports gender, NRIC and name.
+Finds persons that match the query.
Format: `find KEYWORD [MORE_KEYWORDS]`
-* The search is case-insensitive. e.g `hans` will match `Hans`
-* The order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans`
-* Only the name is searched.
-* Only full words will be matched e.g. `Han` will not match `Hans`
-* Persons matching at least one keyword will be returned (i.e. `OR` search).
+* When searching names, the search is case-insensitive. e.g `hans` will match `Hans`
+* When searching names, the order of the keywords does not matter. e.g. `Hans Bo` will match `Bo Hans`
+* 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`
-* When searching by NRIC, input the NRIC as the keyword.
-* When searching by gender, input either `M` or `F` as the keyword.
-* When searching by name, input the names as per above.
+* Note that if the name coincides with other find commands, it will be interpreted as the other find command first and extraneous paremeters will be ignored. e.g. `find F Kennedy John` will search for all female persons.
+* It is recommended to use `list` to restore the view of all data after a `find` command
Examples:
* `find John` returns `john` and `John Doe`
-* `find alex david` returns `Alex Yeoh`, `David Li`
- ![result for 'find alex david'](images/findAlexDavidResult.png)
-* `find T1125726G` returns the person with the matching NRIC.
+* `find kenny pickens` returns `Kenny Pickett`, `George Pickens`
+ ![result for 'find alex david'](images/findpickettpickensresult.png)
+
+
+### Locating a person by NRIC : `find` ###
+
+Finds person that matches the NRIC query
+
+Format: `find NRIC`
+
+* NRIC input must be capitalised!
+* It is recommended to use `list` to restore the view of all data after a `find` command
+
+Examples:
+
+* `find T1125726G` returns the person with the matching NRIC
+
+### Locating people by gender : `find M`, `find F` ###
+
+Finds all persons with matching gender
+
+Format: `find M` or `find F`
+
+* M and F must be capitalised
+* It is recommended to use `list` to restore the view of all data after a `find` command
+
+Examples:
+
* `find M` returns all male persons.
+### Locating people by blood types : `find Blood Type` ###
+
+Finds all Patients with query blood type
+
+Format: `find Blood Type QUERY`
+
+* All blood type inputs must be capitalised
+* Acceptable blood types are A, A+, B, B+, O, O+, AB and AB+
+* It is recommended to use `list` to restore the view of all data after a `find` command
+
+Examples:
+
+* `find Blood Type A+` returns all Patients with blood type A+
+
### Deleting a person : `delete`
Deletes the specified person from the address book.
@@ -233,7 +343,7 @@ 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`
@@ -241,7 +351,7 @@ 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.
### Exiting the program : `exit`
@@ -256,12 +366,11 @@ need to save manually.
### Editing the data file
-MediLink Contacts data are saved automatically as a JSON file `[JAR file location]/data/addressbook.json`. Advanced
-users are welcome to update data directly by editing that data file.
+MediLink Contacts data are saved automatically as a JSON file `[JAR file location]/data/addressbook.json`. Advanced users are welcome to update data directly by editing that data file. However, please ensure that the edits are valid, else it may cause unexpected behaviours when the invalid data is not detected by the system.
:exclamation: **Caution:**
-If your changes to the data file makes its format invalid, MediLink Contacts will discard all data and start with an empty data file at the next run. Hence, it is recommended to take a backup of the file before editing it.
+If your changes to the data file makes its format invalid, MediLink Contacts may discard all data and start with an empty data file at the next run. Hence, it is recommended to take a backup of the file before editing it. Some changes may also be invalid, but not detected by the system. In that case, there may be many unexpected behaviours due to those undetected errors.
### Archiving data files `[coming in v2.0]`
@@ -288,17 +397,20 @@ the data of your previous MediLink Contacts home folder.
## Command summary
-| Action | Format, Examples |
-|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| **New Doctor** | `add-doctor n/NAME ic/IC g/GENDER p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…` e.g., `add-doctor n/John Doe ic/S9851386G g/M p/98765432 e/johnd@example.com a/John street, block 123, #01-01 pt/T0123456H` |
-| **New Patient** | `add-patient n/NAME ic/IC g/GENDER p/PHONE_NUMBER ec/EMERGENCY_CONTACT e/EMAIL a/ADDRESS [t/TAG] [d/DOCTOR] [c/CONDITION] [b/BLOODTYPE] …` e.g., `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+` |
-| **New Appointment** | `new-appt pic/IC dic/IC time/yyyy-MM-dd HH:mm:ss` e.g., `new-appt pic/T0123456H dic/S9851586G time/yyyy-MM-dd 13:00:00` |
-| **Clear** | `clear` |
-| **Undo** | `undo` |
-| **Redo** | `redo` |
-| **Delete** | `delete INDEX` e.g., `delete 3` |
-| **Edit** | `edit INDEX [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…` e.g.,`edit 2 n/James Lee e/jameslee@example.com` |
-| **Find** | `find KEYWORD [MORE_KEYWORDS]` e.g., `find James Jake` |
-| **List** | `list` |
-| **Help** | `help` |
+| Action | Format, Examples |
+|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| **New Doctor** | `add-doctor n/NAME ic/IC g/GENDER p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…` e.g., `add-doctor n/John Doe ic/S9851386G g/M p/98765432 e/johnd@example.com a/John street, block 123, #01-01 t/Pediatrician` |
+| **New Patient** | `add-patient n/NAME ic/IC g/GENDER p/PHONE_NUMBER ec/EMERGENCY_CONTACT e/EMAIL a/ADDRESS [t/TAG] [d/DOCTOR] [c/CONDITION] [b/BLOODTYPE] …` e.g., `add-patient n/Betsy Crowe ic/S9851586G g/F p/98765433 e/betsycrowe@example.com a/#104-C, Wakanda St 42 c/AIDS b/O+ t/High` |
+| **New Appointment** | `new-appt pic/IC dic/IC time/yyyy-MM-dd HH:mm` e.g., `new-appt pic/T0123456H dic/S9851586G time/2023-10-30 13:00` |
+| **Delete Appointment** | `delete-appt INDEX` e.g., delete-appt 1 |
+| **Find Appointment** | `find-appt NRIC` e.g., find-appt T00012220 |
+| **Clear** | `clear` |
+| **Undo** | `undo` |
+| **Redo** | `redo` |
+| **Delete** | `delete NRIC` e.g., `delete T0666485G` |
+| **Edit** | `edit NRIC [n/NAME] [p/PHONE_NUMBER] [e/EMAIL] [a/ADDRESS] [t/TAG]…` e.g.,`edit S9760431H n/James Lee e/jameslee@example.com` |
+| **Find** | `find KEYWORD [MORE_KEYWORDS]` e.g., `find James Jake` |
+| **List** | `list` |
+| **Help** | `help` |
+| **Exit** | `exit` |
diff --git a/docs/_config.yml b/docs/_config.yml
index 2d7e33d4083..2b453166440 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -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:
diff --git a/docs/diagrams/DeleteSequenceDiagram.puml b/docs/diagrams/DeleteSequenceDiagram.puml
index 40ea6c9dc4c..6e80f62c935 100644
--- a/docs/diagrams/DeleteSequenceDiagram.puml
+++ b/docs/diagrams/DeleteSequenceDiagram.puml
@@ -14,10 +14,10 @@ box Model MODEL_COLOR_T1
participant ":Model" as Model MODEL_COLOR
end box
-[-> LogicManager : execute("delete 1")
+[-> LogicManager : execute("delete NRIC")
activate LogicManager
-LogicManager -> AddressBookParser : parseCommand("delete 1")
+LogicManager -> AddressBookParser : parseCommand("delete NRIC")
activate AddressBookParser
create DeleteCommandParser
@@ -27,7 +27,7 @@ activate DeleteCommandParser
DeleteCommandParser --> AddressBookParser
deactivate DeleteCommandParser
-AddressBookParser -> DeleteCommandParser : parse("1")
+AddressBookParser -> DeleteCommandParser : parse("NRIC")
activate DeleteCommandParser
create DeleteCommand
@@ -49,7 +49,7 @@ deactivate AddressBookParser
LogicManager -> DeleteCommand : execute()
activate DeleteCommand
-DeleteCommand -> Model : deletePerson(1)
+DeleteCommand -> Model : deletePerson(NRIC)
activate Model
Model --> DeleteCommand
diff --git a/docs/diagrams/tracing/DeleteSequenceDiagram.png b/docs/diagrams/tracing/DeleteSequenceDiagram.png
new file mode 100644
index 00000000000..580f7e1c222
Binary files /dev/null and b/docs/diagrams/tracing/DeleteSequenceDiagram.png differ
diff --git a/docs/images/DeleteSequenceDiagram.png b/docs/images/DeleteSequenceDiagram.png
index e186f7ba096..580f7e1c222 100644
Binary files a/docs/images/DeleteSequenceDiagram.png and b/docs/images/DeleteSequenceDiagram.png differ
diff --git a/docs/images/Ui.png b/docs/images/Ui.png
index 5bd77847aa2..c60e490a992 100644
Binary files a/docs/images/Ui.png and b/docs/images/Ui.png differ
diff --git a/docs/images/findpickettpickensresult.png b/docs/images/findpickettpickensresult.png
new file mode 100644
index 00000000000..2684da25f54
Binary files /dev/null and b/docs/images/findpickettpickensresult.png differ
diff --git a/docs/images/helpMessage.png b/docs/images/helpMessage.png
index b1f70470137..0be846d7728 100644
Binary files a/docs/images/helpMessage.png and b/docs/images/helpMessage.png differ
diff --git a/docs/team/chonguschonguschongus.md b/docs/team/chonguschonguschongus.md
index 9bd998f41b3..1e8a10ab3ed 100644
--- a/docs/team/chonguschonguschongus.md
+++ b/docs/team/chonguschonguschongus.md
@@ -3,19 +3,22 @@ layout: page
title: Isaac's Project Portfolio Page
---
-### Project: AddressBook Level 3
+### Project: MediLink Contacts
-AddressBook - Level 3 is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC.
+MediLink Contacts aims to help medical staff including nurses/doctors/pharmacists navigate through patient details in
+their high workload and time-pressured working environment. When medical emergencies arise, it becomes crucial to
+provide rapid access to emergency contacts for patients and access other details of the patients to make decisions more
+quickly. It is optimised for CLI so that users can quickly access the information. There is also a GUI created with
+JavaFX.
Given below are my contributions to the project.
-* **New Feature**: Added the ability to undo/redo previous commands.
- * What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command.
- * Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them.
- * Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands.
- * Credits: *{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}*
-
-* **New Feature**: Added a history command that allows the user to navigate to previous commands using up/down keys.
+* **New Feature**: Enhanced the Find feature to function with NRIC, blood type, gender as well as name.
+ * What it does: Allows users to search for Patients/Doctors by their NRIC, blood type, gender or simply name
+ * Justification: Users can search by a specific attribute, increasing convenience
+
+* **New Feature**: Added a Find Appointment function to locate a specific appointment by NRIC of people involved
+* **New Feature** Added a Delete Appointment function to delete a specific appointment by NRIC of people involved
* **Code contributed**: [RepoSense link]()
@@ -23,13 +26,13 @@ Given below are my contributions to the project.
* Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub
* **Enhancements to existing features**:
+ * Wrote an abstract UniqueObjectList that can be inherited to form UniqueLists of Patients, Doctors and Appointments
* Updated the GUI color scheme (Pull requests [\#33](), [\#34]())
- * Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests [\#36](), [\#38]())
+ * Wrote additional tests for existing features (Pull requests [\#36](), [\#38]())
* **Documentation**:
* User Guide:
- * Added documentation for the features `delete` and `find` [\#72]()
- * Did cosmetic tweaks to existing documentation of features `clear`, `exit`: [\#74]()
+ * Added documentation for the features `find`, `delete-appt`, `find-appt` [\#72]()
* Developer Guide:
* Added implementation details of the `delete` feature.
diff --git a/docs/team/cmhuang777.md b/docs/team/cmhuang777.md
index d578b766749..3967e75248c 100644
--- a/docs/team/cmhuang777.md
+++ b/docs/team/cmhuang777.md
@@ -5,7 +5,7 @@ title: Chao Ming's Project Portfolio Page
### Project: MediLink Contacts
-MediLink Contacts aims to help medical staff including nurses/doctors/pharmacists navigate through patient details in
+MediLink Contacts aims to help medical staff including nurses/doctors navigate through patient details in
their high workload and time-pressured working environment. When medical emergencies arise, it becomes crucial to
provide rapid access to emergency contacts for patients and access other details of the patients to make decisions more
quickly. It is optimised for CLI so that users can quickly access the information. There is also a GUI created with
@@ -17,19 +17,29 @@ Given below are my contributions to the project.
[Link to TP code dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=cmhuang777&breakdown=false&sort=groupTitle%20dsc&sortWithin=title&since=2023-09-22&timeframe=commit&mergegroup=&groupSelect=groupByRepos&tabOpen=true&tabType=authorship&tabAuthor=cmHuang777&tabRepo=AY2324S1-CS2103T-T09-3%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=&authorshipIsBinaryFileTypeChecked=false&authorshipIsIgnoredFilesChecked=false)
* **New Feature**: Created new Patient class
+ * Adapted UI and Storage to store Patients instead of Person
+ * Changed Person card to patient card so that it can get displayed on the UI
-* **New Feature**: Modified current add person command to add new Patient class.
+* **New Feature**: Modified current add person command to add new Patient class
+* **New Feature**: Added new command and parser to add new appointment for patients and doctors
+ * Also updated the storage for the appointments
+* **New Feature**: Created a new Class AppointmentTime to represent the time object used in Appointment
+* **New Feature**: Updated part of the sample data to include the new features
* **Project management**:
- * Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub
+ * Managed releases `v1.3 trial` and `v1.3` on GitHub
* Managed milestones and issues
* **Enhancements to existing features**:
* (to be added soon)
* **Documentation**:
- * User Guide: (to be added soon)
- * Developer Guide: (to be added soon)
+ * User Guide:
+ * Updated existing content to our project
+ * Added the section on adding new patients
+ * Developer Guide:
+ * Included the section for add patient/doctor feature and added a new sequence diagram for that feature
+ * Added use case for adding new patient
* **Team-based tasks**:
* Forked the team repo from the source code
diff --git a/docs/team/kohkaijie.md b/docs/team/kohkaijie.md
index 4c242ce1785..c0b327899b4 100644
--- a/docs/team/kohkaijie.md
+++ b/docs/team/kohkaijie.md
@@ -3,44 +3,45 @@ layout: page
title: Kai Jie's Project Portfolio Page
---
-### Project: AddressBook Level 3
+### Project: MediLink Contacts
-AddressBook - Level 3 is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC.
+MediLink Contacts aims to help medical staff including nurses/doctors/pharmacists navigate through patient details in
+their high workload and time-pressured working environment. When medical emergencies arise, it becomes crucial to
+provide rapid access to emergency contacts for patients and access other details of the patients to make decisions more
+quickly. It is optimised for CLI so that users can quickly access the information. There is also a GUI created with
+JavaFX.
Given below are my contributions to the project.
-* **New Feature**: Added the ability to undo/redo previous commands.
+* **New Feature**: Added the ability to undo/redo previous commands (done with Tanveer).
* What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command.
* Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them.
* Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands.
- * Credits: *{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}*
-* **New Feature**: Added a history command that allows the user to navigate to previous commands using up/down keys.
+* **New Feature**: Allowed only specific tags to be added for patients and doctors respectively.
+ * What it does: restricts the user to only enter specific tags for patients and doctors. Patients can only have up to one tag specifying their priority level. Doctors can have up to multiple tags specifying their specialisations.
+ * Justification: This feature ensures that tags have a clear purpose and users cannot enter tags that do not add value to the patient or doctor (e.g adding Engineer tag for a doctor).
+ * Highlights: While this enhancement itself did not affect much other commands, the implementation itself was challenging as it required choosing between different implementation methods, and choosing the most future-proof and OOP-friendly one.
-* **Code contributed**: [RepoSense link]()
+* **Code contributed**: [Link to TP code dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=kohkaijie&breakdown=false&sort=groupTitle%20dsc&sortWithin=title&since=2023-09-22&timeframe=commit&mergegroup=&groupSelect=groupByRepos)
* **Project management**:
- * Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub
+ * Managed releases `v1.1` - `v1.3` (3 releases) on GitHub
+ * Added issues on GitHub for various tasks.
* **Enhancements to existing features**:
- * Updated the GUI color scheme (Pull requests [\#33](), [\#34]())
- * Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests [\#36](), [\#38]())
+ * Created classes for new fields for Patient and Doctor classes.
+ * Wrote additional tests for existing features such as Patient fields, UndoCommand and Tags.
* **Documentation**:
* User Guide:
- * Added documentation for the features `delete` and `find` [\#72]()
- * Did cosmetic tweaks to existing documentation of features `clear`, `exit`: [\#74]()
+ * Added documentation for the features `delete` and usage of special tags.
* Developer Guide:
* Added implementation details of the `delete` feature.
+ * Modified UML diagram for DeleteSequenceDiagram.
+ * Added Use Case for UndoCommand and extensions for EditCommand.
-* **Community**:
- * PRs reviewed (with non-trivial review comments): [\#12](), [\#32](), [\#19](), [\#42]()
- * Contributed to forum discussions (examples: [1](), [2](), [3](), [4]())
- * Reported bugs and suggestions for other teams in the class (examples: [1](), [2](), [3]())
- * Some parts of the history feature I added was adopted by several other class mates ([1](), [2]())
+* **Team-based tasks**:
+ * Reviewed PRs and approved when needed for merging.
-* **Tools**:
- * Integrated a third party library (Natty) to the project ([\#42]())
- * Integrated a new Github plugin (CircleCI) to the team repo
-* _{you can add/remove categories in the list above}_
diff --git a/docs/team/mohammed-faizzzz.md b/docs/team/mohammed-faizzzz.md
index ca486714437..3f45243817d 100644
--- a/docs/team/mohammed-faizzzz.md
+++ b/docs/team/mohammed-faizzzz.md
@@ -3,44 +3,41 @@ layout: page
title: Faiz's Project Portfolio Page
---
-### Project: AddressBook Level 3
+### Project: MediLink Contacts
-AddressBook - Level 3 is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC.
+MediLink Contacts aims to help medical staff including nurses/doctors navigate through patient details in
+their high workload and time-pressured working environment. When medical emergencies arise, it becomes crucial to
+provide rapid access to emergency contacts for patients and access other details of the patients to make decisions more
+quickly. It is optimised for CLI so that users can quickly access the information. There is also a GUI created with
+JavaFX.
Given below are my contributions to the project.
-* **New Feature**: Added the ability to undo/redo previous commands.
- * What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command.
- * Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them.
- * Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands.
- * Credits: *{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}*
+* **Code contributed**:
+ [Link to TP code dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=Faiz&sort=groupTitle&sortWithin=title&timeframe=commit&mergegroup=&groupSelect=groupByRepos&breakdown=true&checkedFileTypes=docs~functional-code~test-code&since=2023-09-22)
-* **New Feature**: Added a history command that allows the user to navigate to previous commands using up/down keys.
-
-* **Code contributed**: [RepoSense link]()
+* **New Feature**: Created new Doctor class
+ * Adapted UI and Storage to store Doctors instead of Person
+ * Changed Person card to Doctor card so that it can get displayed on the UI
+ * Modified UI to also display Doctors as a List alongside the Patients
+* **New Feature**: Modified current add person command to add new Doctor class
+* **New Feature**: Created a new Class Appointment to represent an Appointment between a pre-existing Doctor and Patient
+ * Added `new-appt` command to add new Appointment
+* **New Feature**: Updated part of the sample data to include the new features
* **Project management**:
- * Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub
+ * Managed milestones and issues
+ * Did Peer Reviews on other teammates' Pull Requests
+ * Resolved Merge Conflicts where applicable
* **Enhancements to existing features**:
- * Updated the GUI color scheme (Pull requests [\#33](), [\#34]())
- * Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests [\#36](), [\#38]())
+ * (to be added soon)
* **Documentation**:
- * User Guide:
- * Added documentation for the features `delete` and `find` [\#72]()
- * Did cosmetic tweaks to existing documentation of features `clear`, `exit`: [\#74]()
- * Developer Guide:
- * Added implementation details of the `delete` feature.
-
-* **Community**:
- * PRs reviewed (with non-trivial review comments): [\#12](), [\#32](), [\#19](), [\#42]()
- * Contributed to forum discussions (examples: [1](), [2](), [3](), [4]())
- * Reported bugs and suggestions for other teams in the class (examples: [1](), [2](), [3]())
- * Some parts of the history feature I added was adopted by several other class mates ([1](), [2]())
-
-* **Tools**:
- * Integrated a third party library (Natty) to the project ([\#42]())
- * Integrated a new Github plugin (CircleCI) to the team repo
-
-* _{you can add/remove categories in the list above}_
+ * User Guide:
+ * Updated existing content to our project
+ * Added the section on adding new doctors
+ * Added the section on adding new appointments
+ * Proofread other sections and added the commands/sample commands to a summary table.
+
+
diff --git a/docs/team/tanveersingh10.md b/docs/team/tanveersingh10.md
index 43605ed4335..28a8651f1ae 100644
--- a/docs/team/tanveersingh10.md
+++ b/docs/team/tanveersingh10.md
@@ -3,44 +3,40 @@ layout: page
title: Tanveer's Project Portfolio Page
---
-### Project: AddressBook Level 3
+### Project: MediLink Contacts
-AddressBook - Level 3 is a desktop address book application used for teaching Software Engineering principles. The user interacts with it using a CLI, and it has a GUI created with JavaFX. It is written in Java, and has about 10 kLoC.
+MediLink Contacts aims to help medical staff including nurses/doctors navigate through patient details in
+their high workload and time-pressured working environment. When medical emergencies arise, it becomes crucial to
+provide rapid access to emergency contacts for patients and access other details of the patients to make decisions more
+quickly. It is optimised for CLI so that users can quickly access the information. There is also a GUI created with
+JavaFX.
Given below are my contributions to the project.
+* **Code contributed**:
+ [Link to TP code dashboard](https://nus-cs2103-ay2324s1.github.io/tp-dashboard/?search=tanveersingh10&breakdown=false&sort=groupTitle%20dsc&sortWithin=title&since=2023-09-22&timeframe=commit&mergegroup=&groupSelect=groupByRepos&tabOpen=true&tabType=authorship&tabAuthor=tanveersingh10&tabRepo=AY2324S1-CS2103T-T09-3%2Ftp%5Bmaster%5D&authorshipIsMergeGroup=false&authorshipFileTypes=&authorshipIsBinaryFileTypeChecked=false&authorshipIsIgnoredFilesChecked=false)
+
+
* **New Feature**: Added the ability to undo/redo previous commands.
* What it does: allows the user to undo all previous commands one at a time. Preceding undo commands can be reversed by using the redo command.
* Justification: This feature improves the product significantly because a user can make mistakes in commands and the app should provide a convenient way to rectify them.
- * Highlights: This enhancement affects existing commands and commands to be added in future. It required an in-depth analysis of design alternatives. The implementation too was challenging as it required changes to existing commands.
- * Credits: *{mention here if you reused any code/ideas from elsewhere or if a third-party library is heavily used in the feature so that a reader can make a more accurate judgement of how much effort went into the feature}*
-
-* **New Feature**: Added a history command that allows the user to navigate to previous commands using up/down keys.
-* **Code contributed**: [RepoSense link]()
+* **New Feature**: Implemented the Edit Command
+ * What it does: allows to update fields of a doctor or patient.
+ * Justification: This feature improves the product significantly because a user can make mistakes and may need to change details of a person. Alternatively, it's possible a
+ person's details change over time, such as their condition or remarks, and there needs to be a quick way to update the information.
* **Project management**:
- * Managed releases `v1.3` - `v1.5rc` (3 releases) on GitHub
+ * Led the ideation process. Had to find a balance between new features and ensuring current features are bug free.
+ * Helped delegate issues and tickets
+ * Did Peer Reviews on other teammates' Pull Requests
+ * Resolved Merge Conflicts where applicable
* **Enhancements to existing features**:
- * Updated the GUI color scheme (Pull requests [\#33](), [\#34]())
- * Wrote additional tests for existing features to increase coverage from 88% to 92% (Pull requests [\#36](), [\#38]())
+ * Wrote additional tests for existing features to increase test coverage.
* **Documentation**:
* User Guide:
- * Added documentation for the features `delete` and `find` [\#72]()
- * Did cosmetic tweaks to existing documentation of features `clear`, `exit`: [\#74]()
+ * Added documentation for the features `edit`, `undo` and `redo`
* Developer Guide:
- * Added implementation details of the `delete` feature.
-
-* **Community**:
- * PRs reviewed (with non-trivial review comments): [\#12](), [\#32](), [\#19](), [\#42]()
- * Contributed to forum discussions (examples: [1](), [2](), [3](), [4]())
- * Reported bugs and suggestions for other teams in the class (examples: [1](), [2](), [3]())
- * Some parts of the history feature I added was adopted by several other class mates ([1](), [2]())
-
-* **Tools**:
- * Integrated a third party library (Natty) to the project ([\#42]())
- * Integrated a new Github plugin (CircleCI) to the team repo
-
-* _{you can add/remove categories in the list above}_
+ * Added implementation details of the `edit` feature.
diff --git a/src/main/java/seedu/address/logic/Logic.java b/src/main/java/seedu/address/logic/Logic.java
index e68fcc90428..e461661e614 100644
--- a/src/main/java/seedu/address/logic/Logic.java
+++ b/src/main/java/seedu/address/logic/Logic.java
@@ -8,6 +8,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.ReadOnlyAddressBook;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
import seedu.address.model.person.Patient;
@@ -40,6 +41,7 @@ public interface Logic {
/** Returns an unmodifiable view of the filtered list of doctors */
ObservableList getFilteredDoctorList();
+ ObservableList getFilteredAppointmentList();
/**
* Returns the user prefs' address book file path.
*/
diff --git a/src/main/java/seedu/address/logic/LogicManager.java b/src/main/java/seedu/address/logic/LogicManager.java
index fe0f2e69e08..8c98ffd3a5e 100644
--- a/src/main/java/seedu/address/logic/LogicManager.java
+++ b/src/main/java/seedu/address/logic/LogicManager.java
@@ -1,5 +1,7 @@
package seedu.address.logic;
+import static java.util.Objects.requireNonNull;
+
import java.io.IOException;
import java.nio.file.AccessDeniedException;
import java.nio.file.Path;
@@ -15,6 +17,7 @@
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
import seedu.address.model.person.Patient;
import seedu.address.storage.Storage;
@@ -38,6 +41,8 @@ public class LogicManager implements Logic {
* Constructs a {@code LogicManager} with the given {@code Model} and {@code Storage}.
*/
public LogicManager(Model model, Storage storage) {
+ requireNonNull(model);
+ requireNonNull(storage);
this.model = model;
this.storage = storage;
addressBookParser = new AddressBookParser();
@@ -45,6 +50,7 @@ public LogicManager(Model model, Storage storage) {
@Override
public CommandResult execute(String commandText) throws CommandException, ParseException {
+ requireNonNull(commandText);
logger.info("----------------[USER COMMAND][" + commandText + "]");
CommandResult commandResult;
@@ -76,6 +82,11 @@ public ObservableList getFilteredDoctorList() {
return model.getFilteredDoctorList();
}
+ @Override
+ public ObservableList getFilteredAppointmentList() {
+ return model.getFilteredAppointmentList();
+ }
+
@Override
public Path getAddressBookFilePath() {
return model.getAddressBookFilePath();
diff --git a/src/main/java/seedu/address/logic/Messages.java b/src/main/java/seedu/address/logic/Messages.java
index 271c7caed66..2a2c08675c7 100644
--- a/src/main/java/seedu/address/logic/Messages.java
+++ b/src/main/java/seedu/address/logic/Messages.java
@@ -5,6 +5,7 @@
import java.util.stream.Stream;
import seedu.address.logic.parser.Prefix;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Person;
/**
@@ -19,6 +20,8 @@ public class Messages {
public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!";
public static final String MESSAGE_DUPLICATE_FIELDS =
"Multiple values specified for the following single-valued field(s): ";
+ public static final String MESSAGE_APPOINTMENT_NOT_FOUND = "Specified appointment does not exist!";
+ public static final String MESSAGE_APPOINTMENTS_FOUND_OVERVIEW = "%1d appointments found!";
/**
* Returns an error message indicating the duplicate prefixes.
@@ -51,4 +54,18 @@ public static String format(Person person) {
return builder.toString();
}
+ /**
+ * Formats the {@code appointment} for display to the user.
+ */
+ public static String format(Appointment appointment) {
+ final StringBuilder builder = new StringBuilder();
+ builder.append("Patient involved: ")
+ .append(appointment.getPatient())
+ .append("; Doctor involved: ")
+ .append(appointment.getDoctor())
+ .append("; Time of appointment: ")
+ .append(appointment.getAppointmentTime());
+ return builder.toString();
+ }
+
}
diff --git a/src/main/java/seedu/address/logic/commands/AddAppointmentCommand.java b/src/main/java/seedu/address/logic/commands/AddAppointmentCommand.java
index 0d536e27b07..a45f8febe58 100644
--- a/src/main/java/seedu/address/logic/commands/AddAppointmentCommand.java
+++ b/src/main/java/seedu/address/logic/commands/AddAppointmentCommand.java
@@ -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 {
@@ -56,34 +56,37 @@ public AddAppointmentCommand(Appointment appointment) {
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
- Patient chosenPatient = findPatient(model);
- Doctor chosenDoctor = findDoctor(model);
- if (chosenPatient == null) {
- throw new CommandException(MESSAGE_INVALID_PATIENT);
- }
- if (chosenDoctor == null) {
- throw new CommandException(MESSAGE_INVALID_DOCTOR);
- }
-
- // check that patient and doctor are not the same person
- if (chosenPatient.isSamePerson(chosenDoctor)) {
+ 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);
+ checkValidAppointment(chosenPatient, chosenDoctor, toAdd);
+ chosenPatient.addAppointment(toAdd);
+ chosenDoctor.addAppointment(toAdd);
+ model.addAppointment(toAdd);
+ return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
+ }
- // check that the patient and doctor do not have appointment scheduled at the same time
+ private void checkValidAppointment(Patient chosenPatient, Doctor chosenDoctor, Appointment toAdd)
+ throws CommandException {
if (chosenPatient.hasAppointmentAt(toAdd.getAppointmentTime())) {
throw new CommandException(MESSAGE_DUPLICATE_APPOINTMENT_PATIENT);
}
if (chosenDoctor.hasAppointmentAt(toAdd.getAppointmentTime())) {
throw new CommandException(MESSAGE_DUPLICATE_APPOINTMENT_DOCTOR);
}
- // add appointment to the specified doctor's appointment set
- // add appointment to the specified patient's appointment set
- chosenPatient.addAppointment(toAdd);
- chosenDoctor.addAppointment(toAdd);
+ }
- return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd));
+ private void checkPatientAndDoctor(Patient chosenPatient, Doctor chosenDoctor) throws CommandException {
+ if (chosenPatient == null) {
+ throw new CommandException(MESSAGE_INVALID_PATIENT);
+ }
+ if (chosenDoctor == null) {
+ throw new CommandException(MESSAGE_INVALID_DOCTOR);
+ }
}
private Patient findPatient(Model model) {
diff --git a/src/main/java/seedu/address/logic/commands/AddDoctorCommand.java b/src/main/java/seedu/address/logic/commands/AddDoctorCommand.java
index 2a7c951d7eb..75207d50ce5 100644
--- a/src/main/java/seedu/address/logic/commands/AddDoctorCommand.java
+++ b/src/main/java/seedu/address/logic/commands/AddDoctorCommand.java
@@ -9,6 +9,9 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
+import java.util.logging.Logger;
+
+import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
@@ -37,12 +40,12 @@ public class AddDoctorCommand extends Command {
+ PREFIX_EMAIL + "johnd@example.com "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_GENDER + "M "
- + PREFIX_NRIC + "S1234567Z"
- + PREFIX_TAG + "friends "
- + PREFIX_TAG + "owesMoney";
+ + PREFIX_NRIC + "S1234567Z "
+ + PREFIX_TAG + "SURGEON";
public static final String MESSAGE_SUCCESS = "New doctor added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
+ private static final Logger logger = LogsCenter.getLogger(AddDoctorCommand.class);
private final Doctor toAdd;
/**
@@ -57,14 +60,15 @@ public AddDoctorCommand(Doctor doctor) {
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
- if (model.hasPerson(toAdd)) {
+ if (model.hasIc(toAdd.getIc()) || model.hasPerson(toAdd)) {
+ logger.warning("Can't add doctor as doctor already exists");
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
}
model.addPerson(toAdd);
+ logger.info("Successfully added doctor");
return new CommandResult(String.format(MESSAGE_SUCCESS, Messages.format(toAdd)));
}
-
@Override
public boolean equals(Object other) {
if (other == this) {
diff --git a/src/main/java/seedu/address/logic/commands/AddPatientCommand.java b/src/main/java/seedu/address/logic/commands/AddPatientCommand.java
index 7aadb79c381..9ff8d5838ce 100644
--- a/src/main/java/seedu/address/logic/commands/AddPatientCommand.java
+++ b/src/main/java/seedu/address/logic/commands/AddPatientCommand.java
@@ -2,6 +2,8 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_BLOODTYPE;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_CONDITION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMERGENCY_CONTACT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER;
@@ -32,16 +34,20 @@ public class AddPatientCommand extends Command {
+ PREFIX_ADDRESS + "ADDRESS "
+ PREFIX_GENDER + "GENDER "
+ PREFIX_NRIC + "NRIC "
+ + PREFIX_CONDITION + "CONDITION"
+ + PREFIX_BLOODTYPE + "BLOOD TYPE"
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " "
- + PREFIX_NAME + "John Doe "
+ + PREFIX_NAME + "Kenny Pickett "
+ PREFIX_PHONE + "98765432 "
+ + PREFIX_EMERGENCY_CONTACT + "88884444 "
+ PREFIX_EMAIL + "johnd@example.com "
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
+ PREFIX_GENDER + "M "
+ PREFIX_NRIC + "S1234567Z "
- + PREFIX_TAG + "friends "
- + PREFIX_TAG + "owesMoney";
+ + PREFIX_CONDITION + "COVID "
+ + PREFIX_BLOODTYPE + "A+ "
+ + PREFIX_TAG + "MEDIUM";
public static final String MESSAGE_SUCCESS = "New patient added: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
@@ -60,7 +66,7 @@ public AddPatientCommand(Patient patient) {
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
- if (model.hasPerson(toAdd)) {
+ if (model.hasIc(toAdd.getIc()) || model.hasPerson(toAdd)) {
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
}
diff --git a/src/main/java/seedu/address/logic/commands/DeleteAppointmentCommand.java b/src/main/java/seedu/address/logic/commands/DeleteAppointmentCommand.java
new file mode 100644
index 00000000000..cda2331924a
--- /dev/null
+++ b/src/main/java/seedu/address/logic/commands/DeleteAppointmentCommand.java
@@ -0,0 +1,108 @@
+package seedu.address.logic.commands;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import seedu.address.commons.core.LogsCenter;
+import seedu.address.commons.util.ToStringBuilder;
+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.Doctor;
+import seedu.address.model.person.Ic;
+import seedu.address.model.person.Patient;
+
+/**
+ * Deletes a person identified using it's displayed index from the address book.
+ */
+public class DeleteAppointmentCommand extends Command {
+
+ public static final String COMMAND_WORD = "delete-appt";
+
+ public static final String MESSAGE_USAGE = COMMAND_WORD
+ + ": Deletes the person identified by specified index in the Appointments list.\n"
+ + "Parameters: valid integer as shown in Appointments list \n"
+ + "Example: " + COMMAND_WORD + " 1";
+
+ public static final String MESSAGE_DELETE_APPOINTMENT_SUCCESS = "Deleted Appointment: %1$s";
+ private static final Logger logger = LogsCenter.getLogger(DeleteAppointmentCommand.class);
+
+ private final int targetIndex;
+ private Appointment toDelete;
+
+ public DeleteAppointmentCommand(int targetIndex) {
+ this.targetIndex = targetIndex;
+ }
+
+ @Override
+ public CommandResult execute(Model model) throws CommandException {
+ requireNonNull(model);
+ List lastShownList = new ArrayList<>();
+ lastShownList.addAll(model.getFilteredAppointmentList());
+ try {
+ this.toDelete = lastShownList.get(targetIndex - 1);
+ Patient targetPatient = findPatient(model, toDelete);
+ Doctor targetDoctor = findDoctor(model, toDelete);
+ targetPatient.deleteAppointment(toDelete);
+ targetDoctor.deleteAppointment(toDelete);
+ model.deleteAppointment(toDelete);
+ List updatedList = new ArrayList<>();
+ updatedList.addAll(model.getFilteredAppointmentList());
+ assert updatedList.size() < lastShownList.size();
+ logger.info("Successfully deleted appointment");
+ return new CommandResult(String.format(MESSAGE_DELETE_APPOINTMENT_SUCCESS, Messages.format(toDelete)));
+ } catch (IndexOutOfBoundsException e) {
+ logger.warning("Appointment does not exist");
+ throw new CommandException(Messages.MESSAGE_APPOINTMENT_NOT_FOUND);
+ }
+ }
+
+ private Patient findPatient(Model model, Appointment toDelete) {
+ Ic patientIc = toDelete.getPatient();
+ List patients = model.getFilteredPatientList();
+ for (Patient p : patients) {
+ if (p.hasIc(patientIc)) {
+ return p;
+ }
+ }
+ return null;
+ }
+
+ private Doctor findDoctor(Model model, Appointment toDelete) {
+ Ic doctorIc = toDelete.getDoctor();
+ List doctors = model.getFilteredDoctorList();
+ for (Doctor d : doctors) {
+ if (d.hasIc(doctorIc)) {
+ return d;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ // instanceof handles nulls
+ if (!(other instanceof DeleteAppointmentCommand)) {
+ return false;
+ }
+
+ DeleteAppointmentCommand otherDeleteAppointmentCommand = (DeleteAppointmentCommand) other;
+ return targetIndex == otherDeleteAppointmentCommand.targetIndex;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .add("targetIc", targetIndex)
+ .toString();
+ }
+}
+
diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java
index aa0e1583921..8272ea87b03 100644
--- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java
+++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java
@@ -4,7 +4,9 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.logging.Logger;
+import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
@@ -25,6 +27,7 @@ public class DeleteCommand extends Command {
+ "Example: " + COMMAND_WORD + " T0333789H";
public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";
+ private static final Logger logger = LogsCenter.getLogger(DeleteCommand.class);
private final Ic targetIc;
@@ -43,9 +46,15 @@ public CommandResult execute(Model model) throws CommandException {
for (Person target : lastShownList) {
if (targetIc.equals(target.getIc())) {
model.deletePerson(target);
+ List updatedList = new ArrayList<>();
+ updatedList.addAll(model.getFilteredDoctorList());
+ updatedList.addAll(model.getFilteredPatientList());
+ assert updatedList.size() < lastShownList.size();
+ logger.info("Successfully deleted person");
return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(target)));
}
}
+ logger.warning("Could not find person to delete");
throw new CommandException(Messages.MESSAGE_PERSON_NOT_FOUND);
}
diff --git a/src/main/java/seedu/address/logic/commands/EditCommand.java b/src/main/java/seedu/address/logic/commands/EditCommand.java
index ad5a2cbe4fb..e686c196983 100644
--- a/src/main/java/seedu/address/logic/commands/EditCommand.java
+++ b/src/main/java/seedu/address/logic/commands/EditCommand.java
@@ -8,7 +8,6 @@
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMERGENCY_CONTACT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER;
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_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
@@ -21,8 +20,10 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
+import java.util.logging.Logger;
import java.util.stream.Collectors;
+import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.util.CollectionUtil;
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
@@ -47,7 +48,6 @@
* Edits the details of an existing person in the address book.
*/
public class EditCommand extends Command {
-
public static final String COMMAND_WORD = "edit";
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits the details of the person identified "
@@ -61,22 +61,20 @@ public class EditCommand extends Command {
+ "[" + PREFIX_GENDER + "GENDER] "
+ "[" + PREFIX_CONDITION + "CONDITION] "
+ "[" + PREFIX_BLOODTYPE + "BLOOD TYPE] "
- + "[" + PREFIX_NRIC + "NRIC] "
+ "[" + PREFIX_EMERGENCY_CONTACT + "EMAIL] "
+ "[" + PREFIX_TAG + "TAG]...\n"
+ "Example: " + COMMAND_WORD + " T0123456H "
+ PREFIX_PHONE + "91234567 "
+ PREFIX_EMAIL + "johndoe@example.com"
+ PREFIX_REMARK + "remarks";
-
public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edited Person: %1$s";
public static final String MESSAGE_NOT_EDITED = "At least one field to edit must be provided.";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book.";
public static final String MESSAGE_DOESNT_EXIST = "This person hasn't been saved";
-
+ public static final String MESSAGE_IC_CHANGED = "You can't change a person's IC";
+ private static final Logger logger = LogsCenter.getLogger(EditCommand.class.getName());
private final Ic nric;
private final EditPersonDescriptor editPersonDescriptor;
- private String personRole;
/**
* @param nric of the person in the filtered person list to edit
@@ -93,52 +91,73 @@ public EditCommand(Ic nric, EditPersonDescriptor editPersonDescriptor) {
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
+ if (editPersonDescriptor.getIc().isPresent() && !(editPersonDescriptor.getIc().get().equals(nric))) {
+ throw new CommandException(MESSAGE_IC_CHANGED);
+ }
+
// combine doctor list and patient list
+ Person personToEdit = getPersonToEdit(model);
+ Person editedPerson = getEditedPerson(model, personToEdit);
+
+ model.setPerson(personToEdit, editedPerson);
+ model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
+ logger.info("Successfully edited person");
+ return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)));
+ }
+
+ private Person getPersonToEdit(Model model) throws CommandException {
List lastShownList = new ArrayList<>();
lastShownList.addAll(model.getFilteredDoctorList());
lastShownList.addAll(model.getFilteredPatientList());
-
List personToEditList = lastShownList.stream()
.filter(x -> x.getIc().equals(nric))
.collect(Collectors.toList());
-
if (personToEditList.size() == 0) {
+ logger.warning("Could not edit - person isn't in adressbook");
throw new CommandException(MESSAGE_DOESNT_EXIST);
}
-
//developer assumption - can't have 2 people with same IC
assert personToEditList.size() < 2;
-
Person personToEdit = personToEditList.get(0);
- Person editedPerson;
+ return personToEdit;
+ }
+ private Person getEditedPerson(Model model, Person personToEdit) throws CommandException {
+ Person editedPerson;
if (personToEdit instanceof Patient) {
- personRole = "patient";
+ if (editPersonDescriptor.getTags().isPresent()
+ && !editPersonDescriptor.isValidPatientTagList(editPersonDescriptor.getTags().get())) {
+ logger.warning("Invalid tag for patient");
+ throw new CommandException("Please enter a valid patient tag.");
+ }
editedPerson = createEditedPatient((Patient) personToEdit, editPersonDescriptor);
} else {
- assert personToEdit instanceof Doctor;
+ assert personToEdit.isDoctor();
if (editPersonDescriptor.getCondition().isPresent() || editPersonDescriptor.getBloodType().isPresent()) {
+ logger.warning("Error thrown - tried to edit condition / bloodtype of doctor");
throw new CommandException("Doctors cannot have Condition or BloodType fields.");
}
- personRole = "doctor";
- editedPerson = createEditedDoctor(personToEdit, editPersonDescriptor);
+ if (editPersonDescriptor.getTags().isPresent()
+ && !editPersonDescriptor.isValidDoctorTagList(editPersonDescriptor.getTags().get())) {
+ logger.warning(editPersonDescriptor.getTags().toString());
+ throw new CommandException("Please enter valid Doctor tags.");
+ }
+ editedPerson = createEditedDoctor((Doctor) personToEdit, editPersonDescriptor);
}
-
if (!personToEdit.isSamePerson(editedPerson) && model.hasPerson(editedPerson)) {
+ logger.warning("Edited Person and orignal person are the same");
throw new CommandException(MESSAGE_DUPLICATE_PERSON);
}
- model.setPerson(personToEdit, editedPerson);
- model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
- return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPerson)));
+ return editedPerson;
}
/**
* Creates and returns a {@code Person} with the details of {@code personToEdit}
* edited with {@code editPersonDescriptor}.
*/
-
- private static Doctor createEditedDoctor(Person personToEdit, EditPersonDescriptor editPersonDescriptor) {
- assert personToEdit != null;
+ private static Doctor createEditedDoctor(Doctor personToEdit, EditPersonDescriptor editPersonDescriptor) {
+ requireNonNull(personToEdit);
+ requireNonNull(personToEdit);
Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName());
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone());
@@ -146,18 +165,21 @@ private static Doctor createEditedDoctor(Person personToEdit, EditPersonDescript
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
Remark updatedRemarks = editPersonDescriptor.getRemark().orElse(personToEdit.getRemark());
Gender updatedGender = editPersonDescriptor.getGender().orElse(personToEdit.getGender());
- Ic updatedIc = editPersonDescriptor.getIc().orElse(personToEdit.getIc());
+ Ic updatedIc = personToEdit.getIc(); // since you can't modify ic
Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());
Set updatedAppointments =
editPersonDescriptor.getAppointments().orElse(personToEdit.getAppointments());
+ logger.fine("Successfully created Edited Doctor");
return new Doctor(updatedName, updatedPhone, updatedEmail, updatedAddress, updatedRemarks,
updatedGender, updatedIc, updatedAppointments, updatedTags);
}
private static Patient createEditedPatient(Patient personToEdit, EditPersonDescriptor editPersonDescriptor) {
- assert personToEdit != null;
+ requireNonNull(personToEdit);
+ requireNonNull(personToEdit);
+
Name updatedName = editPersonDescriptor.getName().orElse(personToEdit.getName());
Phone updatedPhone = editPersonDescriptor.getPhone().orElse(personToEdit.getPhone());
Phone updatedEmergencyContact =
@@ -166,12 +188,13 @@ private static Patient createEditedPatient(Patient personToEdit, EditPersonDescr
Address updatedAddress = editPersonDescriptor.getAddress().orElse(personToEdit.getAddress());
Remark updatedRemarks = editPersonDescriptor.getRemark().orElse(personToEdit.getRemark());
Gender updatedGender = editPersonDescriptor.getGender().orElse(personToEdit.getGender());
- Ic updatedIc = editPersonDescriptor.getIc().orElse(personToEdit.getIc());
+ Ic updatedIc = personToEdit.getIc(); // since you can't modify ic
Set updatedTags = editPersonDescriptor.getTags().orElse(personToEdit.getTags());
Set updatedAppointments =
editPersonDescriptor.getAppointments().orElse(personToEdit.getAppointments());
BloodType updatedBloodType = editPersonDescriptor.getBloodType().orElse(personToEdit.getBloodType());
Condition updatedCondition = editPersonDescriptor.getCondition().orElse(personToEdit.getCondition());
+ logger.fine("Successfully created Edited Patient");
return new Patient(updatedName, updatedPhone, updatedEmergencyContact, updatedEmail, updatedAddress,
updatedRemarks, updatedGender, updatedIc, updatedCondition, updatedBloodType, updatedAppointments,
updatedTags);
@@ -330,6 +353,38 @@ public Optional getBloodType() {
return Optional.ofNullable(bloodType);
}
+ /**
+ * Ensures the set of tags contains only valid patient tags.
+ *
+ * @param tagSet The set of tags to be validated.
+ * @return true if the tag set is valid (contains zero or one valid patient tag), false otherwise.
+ */
+ public boolean isValidPatientTagList(Set tagSet) {
+ if (tagSet.size() > 1) {
+ return false;
+ }
+ for (Tag tag : tagSet) {
+ if (!tag.isValidPatientTag()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Ensures the set of tags contains only valid doctor tags.
+ *
+ * @param tagSet The set of tags to be validated.
+ * @return true if the tag set is valid (contains no duplicate doctor tags), false otherwise.
+ */
+ public boolean isValidDoctorTagList(Set tagSet) {
+ for (Tag tag : tagSet) {
+ if (!tag.isValidDoctorTag()) {
+ return false;
+ }
+ }
+ return true;
+ }
/**
* Sets {@code tags} to this object's {@code tags}.
diff --git a/src/main/java/seedu/address/logic/commands/FindAppointmentCommand.java b/src/main/java/seedu/address/logic/commands/FindAppointmentCommand.java
new file mode 100644
index 00000000000..c48ccddb21b
--- /dev/null
+++ b/src/main/java/seedu/address/logic/commands/FindAppointmentCommand.java
@@ -0,0 +1,68 @@
+package seedu.address.logic.commands;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Predicate;
+
+import seedu.address.commons.util.ToStringBuilder;
+import seedu.address.logic.Messages;
+import seedu.address.model.Model;
+import seedu.address.model.appointment.Appointment;
+
+/**
+ * Finds and lists all persons in in address book whose attributes match the predicate.
+ * Keyword matching is case insensitive.
+ */
+public class FindAppointmentCommand extends Command {
+
+ public static final String COMMAND_WORD = "find-appt";
+
+ public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all appointments who involve the "
+ + "the specified case-sensitive NRIC and displays them as a list with index numbers.\n"
+ + "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ + "Example: " + COMMAND_WORD + " T1234567Z";
+
+ private final Predicate predicate;
+ /**
+ * Finds and lists all persons in address book whose attributes match the predicate.
+ * Keyword matching is case-insensitive.
+ */
+ public FindAppointmentCommand(Predicate predicate) {
+ requireNonNull(predicate);
+ this.predicate = predicate;
+ }
+
+ @Override
+ public CommandResult execute(Model model) {
+ requireNonNull(model);
+ model.updateFilteredAppointmentList(predicate);
+ List searchList = new ArrayList<>();
+ searchList.addAll(model.getFilteredAppointmentList());
+ return new CommandResult(
+ String.format(Messages.MESSAGE_APPOINTMENTS_FOUND_OVERVIEW, searchList.size()));
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ // instanceof handles nulls
+ if (!(other instanceof FindAppointmentCommand)) {
+ return false;
+ }
+
+ FindAppointmentCommand otherFindAppointmentCommand = (FindAppointmentCommand) other;
+ return predicate.equals(otherFindAppointmentCommand.predicate);
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this)
+ .add("predicate", predicate)
+ .toString();
+ }
+}
diff --git a/src/main/java/seedu/address/logic/commands/FindCommand.java b/src/main/java/seedu/address/logic/commands/FindCommand.java
index 63a13709c64..63653f30cc7 100644
--- a/src/main/java/seedu/address/logic/commands/FindCommand.java
+++ b/src/main/java/seedu/address/logic/commands/FindCommand.java
@@ -12,7 +12,7 @@
import seedu.address.model.person.Person;
/**
- * Finds and lists all persons in address book whose name contains any of the argument keywords.
+ * Finds and lists all persons in in address book whose attributes match the predicate.
* Keyword matching is case insensitive.
*/
public class FindCommand extends Command {
@@ -25,8 +25,12 @@ public class FindCommand extends Command {
+ "Example: " + COMMAND_WORD + " alice bob charlie";
private final Predicate predicate;
-
+ /**
+ * Finds and lists all persons in address book whose attributes match the predicate.
+ * Keyword matching is case insensitive.
+ */
public FindCommand(Predicate predicate) {
+ requireNonNull(predicate);
this.predicate = predicate;
}
diff --git a/src/main/java/seedu/address/logic/commands/ListCommand.java b/src/main/java/seedu/address/logic/commands/ListCommand.java
index 84be6ad2596..ea1d36fec2b 100644
--- a/src/main/java/seedu/address/logic/commands/ListCommand.java
+++ b/src/main/java/seedu/address/logic/commands/ListCommand.java
@@ -1,6 +1,7 @@
package seedu.address.logic.commands;
import static java.util.Objects.requireNonNull;
+import static seedu.address.model.Model.PREDICATE_SHOW_ALL_APPOINTMENTS;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;
import seedu.address.model.Model;
@@ -19,6 +20,7 @@ public class ListCommand extends Command {
public CommandResult execute(Model model) {
requireNonNull(model);
model.updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
+ model.updateFilteredAppointmentList(PREDICATE_SHOW_ALL_APPOINTMENTS);
return new CommandResult(MESSAGE_SUCCESS);
}
}
diff --git a/src/main/java/seedu/address/logic/commands/RedoCommand.java b/src/main/java/seedu/address/logic/commands/RedoCommand.java
index 7faadf7430b..e29847db644 100644
--- a/src/main/java/seedu/address/logic/commands/RedoCommand.java
+++ b/src/main/java/seedu/address/logic/commands/RedoCommand.java
@@ -1,5 +1,10 @@
package seedu.address.logic.commands;
+import static java.util.Objects.requireNonNull;
+
+import java.util.logging.Logger;
+
+import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
@@ -12,10 +17,13 @@ public class RedoCommand extends Command {
public static final String MESSAGE_SUCCESS = "Previous command redid successfully!";
public static final String MESSAGE_EMPTY = "There's nothing to redo";
+ private static final Logger logger = LogsCenter.getLogger(RedoCommand.class);
@Override
public CommandResult execute(Model model) throws CommandException {
+ requireNonNull(model);
model.redo();
+ logger.info("Successfully redid previously undone task");
return new CommandResult(MESSAGE_SUCCESS);
}
}
diff --git a/src/main/java/seedu/address/logic/commands/RemarkCommand.java b/src/main/java/seedu/address/logic/commands/RemarkCommand.java
deleted file mode 100644
index 89c5b2e1808..00000000000
--- a/src/main/java/seedu/address/logic/commands/RemarkCommand.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package seedu.address.logic.commands;
-
-import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import seedu.address.commons.core.index.Index;
-import seedu.address.logic.Messages;
-import seedu.address.logic.commands.exceptions.CommandException;
-import seedu.address.model.Model;
-import seedu.address.model.person.Person;
-import seedu.address.model.person.Remark;
-
-/**
- * The RemarkCommand class represents a command in a software application for editing remarks associated with persons.
- * This command allows the user to add or update a remark for a person identified by their index number in the last
- * person listing. If a remark already exists for the person, it will be overwritten by the new input remark.
- * If the remark input is empty, the existing remark for the person can be removed.
- */
-public class RemarkCommand extends Command {
- public static final String COMMAND_WORD = "remark";
-
- public static final String MESSAGE_USAGE = COMMAND_WORD
- + ": Edits the remark of the person identified "
- + "by the index number used in the last person listing. "
- + "Existing remark will be overwritten by the input.\n"
- + "Parameters: INDEX (must be a positive integer) "
- + "r/ [REMARK]\n"
- + "Example: " + COMMAND_WORD + " 1 "
- + "r/ Likes to swim.";
-
- public static final String MESSAGE_ADD_REMARK_SUCCESS = "Added remark to Person: %1$s";
- public static final String MESSAGE_DELETE_REMARK_SUCCESS = "Removed remark from Person: %1$s";
-
- private final Index index;
- private final Remark remark;
-
- /**
- * @param index of the person in the filtered person list to edit the remark
- * @param remark of the person to be updated to
- */
- public RemarkCommand(Index index, Remark remark) {
- requireAllNonNull(index, remark);
-
- this.index = index;
- this.remark = remark;
- }
-
- @Override
- public CommandResult execute(Model model) throws CommandException {
- // combine doctor list and patient list
- List lastShownList = new ArrayList<>();
- lastShownList.addAll(model.getFilteredDoctorList());
- lastShownList.addAll(model.getFilteredPatientList());
-
- if (index.getZeroBased() >= lastShownList.size()) {
- throw new CommandException(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX);
- }
-
- Person personToEdit = lastShownList.get(index.getZeroBased());
- Person editedPerson = new Person(
- personToEdit.getName(), personToEdit.getPhone(), personToEdit.getEmail(),
- personToEdit.getAddress(), remark, personToEdit.getGender(),
- personToEdit.getIc(), personToEdit.getAppointments(), personToEdit.getTags());
-
- model.setPerson(personToEdit, editedPerson);
- model.updateFilteredPersonList(Model.PREDICATE_SHOW_ALL_PERSONS);
-
- return new CommandResult(generateSuccessMessage(editedPerson));
- }
-
- /**
- * Generates a command execution success message based on whether
- * the remark is added to or removed from
- * {@code personToEdit}.
- */
- private String generateSuccessMessage(Person personToEdit) {
- String message = !remark.value.isEmpty() ? MESSAGE_ADD_REMARK_SUCCESS : MESSAGE_DELETE_REMARK_SUCCESS;
- return String.format(message, personToEdit);
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
-
- // instanceof handles nulls
- if (!(other instanceof RemarkCommand)) {
- return false;
- }
-
- RemarkCommand e = (RemarkCommand) other;
- return index.equals(e.index)
- && remark.equals(e.remark);
- }
-}
diff --git a/src/main/java/seedu/address/logic/commands/UndoCommand.java b/src/main/java/seedu/address/logic/commands/UndoCommand.java
index 9b96471bd04..f67ddb067c9 100644
--- a/src/main/java/seedu/address/logic/commands/UndoCommand.java
+++ b/src/main/java/seedu/address/logic/commands/UndoCommand.java
@@ -1,5 +1,10 @@
package seedu.address.logic.commands;
+import static java.util.Objects.requireNonNull;
+
+import java.util.logging.Logger;
+
+import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
@@ -9,13 +14,15 @@
*/
public class UndoCommand extends Command {
public static final String COMMAND_WORD = "undo";
-
public static final String MESSAGE_SUCCESS = "Previous command undid successfully!";
public static final String MESSAGE_EMPTY = "There's nothing to undo";
+ private static final Logger logger = LogsCenter.getLogger(UndoCommand.class);
@Override
public CommandResult execute(Model model) throws CommandException {
+ requireNonNull(model);
model.undo();
+ logger.info("Successfully undid previous command");
return new CommandResult(MESSAGE_SUCCESS);
}
}
diff --git a/src/main/java/seedu/address/logic/parser/AddAppointmentCommandParser.java b/src/main/java/seedu/address/logic/parser/AddAppointmentCommandParser.java
index 16ce0987ebb..35a3279e3e6 100644
--- a/src/main/java/seedu/address/logic/parser/AddAppointmentCommandParser.java
+++ b/src/main/java/seedu/address/logic/parser/AddAppointmentCommandParser.java
@@ -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;
/**
@@ -26,6 +24,7 @@ public class AddAppointmentCommandParser implements Parser {
-
+ private static final Logger logger = LogsCenter.getLogger(AddDoctorCommandParser.class);
/**
* Parses {@code userInput} into a command and returns it.
*
@@ -47,6 +49,7 @@ public AddDoctorCommand parse(String userInput) throws ParseException {
if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_GENDER,
PREFIX_NRIC)
|| !argMultimap.getPreamble().isEmpty()) {
+ logger.warning("Invalid command format for AddPatientCommand: " + userInput);
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddDoctorCommand.MESSAGE_USAGE));
}
@@ -59,11 +62,13 @@ public AddDoctorCommand parse(String userInput) throws ParseException {
Remark remark = new Remark(""); // add command does not allow adding remarks straight away
Gender gender = ParserUtil.parseGender(argMultimap.getValue(PREFIX_GENDER).get());
Ic ic = ParserUtil.parseIc(argMultimap.getValue(PREFIX_NRIC).get());
- Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
+ Set tagList = ParserUtil.parseDoctorTags(argMultimap.getAllValues(PREFIX_TAG));
// appointments need to be added separately, so we initialise doctors with empty appointments
Set appointmentList = new HashSet<>();
+
Doctor doctor = new Doctor(name, phone, email, address, remark, gender, ic, appointmentList, tagList);
+ logger.info("Successfully parsed AddDoctorCommand with doctor: " + doctor);
return new AddDoctorCommand(doctor);
}
diff --git a/src/main/java/seedu/address/logic/parser/AddPatientCommandParser.java b/src/main/java/seedu/address/logic/parser/AddPatientCommandParser.java
index d37b40a5b19..1aa397f29c2 100644
--- a/src/main/java/seedu/address/logic/parser/AddPatientCommandParser.java
+++ b/src/main/java/seedu/address/logic/parser/AddPatientCommandParser.java
@@ -15,8 +15,10 @@
import java.util.HashSet;
import java.util.Set;
+import java.util.logging.Logger;
import java.util.stream.Stream;
+import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.AddPatientCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.appointment.Appointment;
@@ -36,7 +38,7 @@
* Parses input arguments and creates a new AddPatientCommand object
*/
public class AddPatientCommandParser implements Parser {
-
+ private static final Logger logger = LogsCenter.getLogger(AddPatientCommandParser.class);
/**
* Parses the given {@code String} of arguments in the context of the AddPatientCommand
* and returns an AddPatientCommand object for execution.
@@ -44,6 +46,7 @@ public class AddPatientCommandParser implements Parser {
* @throws ParseException if the user input does not conform the expected format
*/
public AddPatientCommand parse(String args) throws ParseException {
+ logger.fine("Attempting to parse AddPatientCommand from arguments: " + args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG,
PREFIX_REMARK, PREFIX_GENDER, PREFIX_NRIC, PREFIX_CONDITION, PREFIX_BLOODTYPE,
@@ -51,10 +54,11 @@ public AddPatientCommand parse(String args) throws ParseException {
if (!arePrefixesPresent(argMultimap, PREFIX_NAME, PREFIX_ADDRESS, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_GENDER,
PREFIX_NRIC, PREFIX_CONDITION, PREFIX_BLOODTYPE, PREFIX_EMERGENCY_CONTACT)
|| !argMultimap.getPreamble().isEmpty()) {
+ logger.warning("Invalid command format for AddPatientCommand: " + args);
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddPatientCommand.MESSAGE_USAGE));
}
- argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS,
+ argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_TAG,
PREFIX_GENDER, PREFIX_NRIC, PREFIX_CONDITION, PREFIX_BLOODTYPE, PREFIX_EMERGENCY_CONTACT);
Name name = ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get());
Phone phone = ParserUtil.parsePhone(argMultimap.getValue(PREFIX_PHONE).get());
@@ -67,13 +71,14 @@ public AddPatientCommand parse(String args) throws ParseException {
Ic ic = ParserUtil.parseIc(argMultimap.getValue(PREFIX_NRIC).get());
BloodType bloodType = ParserUtil.parseBloodType(argMultimap.getValue(PREFIX_BLOODTYPE).get());
Condition condition = ParserUtil.parseCondition(argMultimap.getValue(PREFIX_CONDITION).get());
- Set tagList = ParserUtil.parseTags(argMultimap.getAllValues(PREFIX_TAG));
+ Set tagList = ParserUtil.parsePatientTags(argMultimap.getAllValues(PREFIX_TAG));
// appointments need to be added separately, so we initialise patients with empty appointments
Set appointmentList = new HashSet<>();
Patient patient =
new Patient(name, phone, emergencyContact, email, address, remark, gender, ic, condition, bloodType,
appointmentList, tagList);
+ logger.info("Successfully parsed AddPatientCommand with patient: " + patient);
return new AddPatientCommand(patient);
}
diff --git a/src/main/java/seedu/address/logic/parser/AddressBookParser.java b/src/main/java/seedu/address/logic/parser/AddressBookParser.java
index e248d12bfdd..dbaf82349ef 100644
--- a/src/main/java/seedu/address/logic/parser/AddressBookParser.java
+++ b/src/main/java/seedu/address/logic/parser/AddressBookParser.java
@@ -1,5 +1,6 @@
package seedu.address.logic.parser;
+import static java.util.Objects.requireNonNull;
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.Messages.MESSAGE_UNKNOWN_COMMAND;
@@ -13,14 +14,15 @@
import seedu.address.logic.commands.AddPatientCommand;
import seedu.address.logic.commands.ClearCommand;
import seedu.address.logic.commands.Command;
+import seedu.address.logic.commands.DeleteAppointmentCommand;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.ExitCommand;
+import seedu.address.logic.commands.FindAppointmentCommand;
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.RedoCommand;
-import seedu.address.logic.commands.RemarkCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.parser.exceptions.ParseException;
@@ -43,6 +45,7 @@ public class AddressBookParser {
* @throws ParseException if the user input does not conform the expected format
*/
public Command parseCommand(String userInput) throws ParseException {
+ requireNonNull(userInput);
final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim());
if (!matcher.matches()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
@@ -69,12 +72,18 @@ public Command parseCommand(String userInput) throws ParseException {
case DeleteCommand.COMMAND_WORD:
return new DeleteCommandParser().parse(arguments);
+ case DeleteAppointmentCommand.COMMAND_WORD:
+ return new DeleteAppointmentCommandParser().parse(arguments);
+
case ClearCommand.COMMAND_WORD:
return new ClearCommand();
case FindCommand.COMMAND_WORD:
return new FindCommandParser().parse(arguments);
+ case FindAppointmentCommand.COMMAND_WORD:
+ return new FindAppointmentCommandParser().parse(arguments);
+
case ListCommand.COMMAND_WORD:
return new ListCommand();
@@ -84,9 +93,6 @@ public Command parseCommand(String userInput) throws ParseException {
case HelpCommand.COMMAND_WORD:
return new HelpCommand();
- case RemarkCommand.COMMAND_WORD:
- return new RemarkCommandParser().parse(arguments);
-
case UndoCommand.COMMAND_WORD:
return new UndoCommand();
diff --git a/src/main/java/seedu/address/logic/parser/DeleteAppointmentCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteAppointmentCommandParser.java
new file mode 100644
index 00000000000..d3f1af50645
--- /dev/null
+++ b/src/main/java/seedu/address/logic/parser/DeleteAppointmentCommandParser.java
@@ -0,0 +1,35 @@
+package seedu.address.logic.parser;
+
+import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
+
+import java.util.logging.Logger;
+
+import seedu.address.commons.core.LogsCenter;
+import seedu.address.logic.commands.DeleteAppointmentCommand;
+import seedu.address.logic.parser.exceptions.ParseException;
+
+/**
+ * Parses input arguments and creates a new DeleteCommand object
+ */
+public class DeleteAppointmentCommandParser implements Parser {
+ private static final Logger logger = LogsCenter.getLogger(DeleteCommandParser.class);
+ /**
+ * Parses the given {@code String} of arguments in the context of the DeleteCommand
+ * and returns a DeleteCommand object for execution.
+ *
+ * @throws ParseException if the user input does not conform the expected format
+ */
+ public DeleteAppointmentCommand parse(String args) throws ParseException {
+ String trimmedArgs = args.trim();
+ try {
+ int index = Integer.parseInt(trimmedArgs);
+ logger.info("Successfully parsed integer from DeleteAppointmentCommand: " + index);
+ return new DeleteAppointmentCommand(index);
+ } catch (NumberFormatException e) {
+ logger.warning("Invalid user input for delete appointment command");
+ throw new ParseException(
+ String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteAppointmentCommand.MESSAGE_USAGE), e);
+ }
+ }
+
+}
diff --git a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java b/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java
index ffda571a9f8..4b91e992c54 100644
--- a/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java
+++ b/src/main/java/seedu/address/logic/parser/DeleteCommandParser.java
@@ -2,6 +2,9 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
+import java.util.logging.Logger;
+
+import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Ic;
@@ -10,17 +13,20 @@
* Parses input arguments and creates a new DeleteCommand object
*/
public class DeleteCommandParser implements Parser {
-
+ private static final Logger logger = LogsCenter.getLogger(DeleteCommandParser.class);
/**
* Parses the given {@code String} of arguments in the context of the DeleteCommand
* and returns a DeleteCommand object for execution.
+ *
* @throws ParseException if the user input does not conform the expected format
*/
public DeleteCommand parse(String args) throws ParseException {
try {
Ic ic = ParserUtil.parseIc(args);
+ logger.info("Successfully parsed IC from DeleteCommand: " + ic);
return new DeleteCommand(ic);
} catch (ParseException pe) {
+ logger.warning("Invalid user input for delete command");
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, DeleteCommand.MESSAGE_USAGE), pe);
}
diff --git a/src/main/java/seedu/address/logic/parser/EditCommandParser.java b/src/main/java/seedu/address/logic/parser/EditCommandParser.java
index 976abc5b979..2c9c51fd093 100644
--- a/src/main/java/seedu/address/logic/parser/EditCommandParser.java
+++ b/src/main/java/seedu/address/logic/parser/EditCommandParser.java
@@ -1,6 +1,5 @@
package seedu.address.logic.parser;
-import static java.util.Objects.requireNonNull;
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_BLOODTYPE;
@@ -19,7 +18,9 @@
import java.util.Collections;
import java.util.Optional;
import java.util.Set;
+import java.util.logging.Logger;
+import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.EditCommand.EditPersonDescriptor;
import seedu.address.logic.parser.exceptions.ParseException;
@@ -30,14 +31,15 @@
* Parses input arguments and creates a new EditCommand object
*/
public class EditCommandParser implements Parser {
-
+ public static final String CANNOT_CHANGE_IC_MESSAGE = "You cannot modify a person's IC";
+ private static final Logger logger = LogsCenter.getLogger(EditCommand.class);
/**
* Parses the given {@code String} of arguments in the context of the EditCommand
* and returns an EditCommand object for execution.
+ *
* @throws ParseException if the user input does not conform the expected format
*/
public EditCommand parse(String args) throws ParseException {
- requireNonNull(args);
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL,
PREFIX_ADDRESS, PREFIX_REMARK, PREFIX_GENDER, PREFIX_NRIC, PREFIX_TAG,
@@ -48,16 +50,18 @@ public EditCommand parse(String args) throws ParseException {
try {
nric = ParserUtil.parseIc(argMultimap.getPreamble());
} catch (ParseException pe) {
+ logger.severe("Error parsing NRIC: " + pe.getMessage());
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, EditCommand.MESSAGE_USAGE), pe);
}
-
-
argMultimap.verifyNoDuplicatePrefixesFor(PREFIX_NAME, PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS, PREFIX_NRIC,
PREFIX_GENDER, PREFIX_BLOODTYPE, PREFIX_CONDITION, PREFIX_DOCTOR, PREFIX_EMERGENCY_CONTACT);
EditPersonDescriptor editPersonDescriptor = new EditPersonDescriptor();
+ if (argMultimap.getValue(PREFIX_NRIC).isPresent()) {
+ editPersonDescriptor.setIc(ParserUtil.parseIc(argMultimap.getValue(PREFIX_NRIC).get()));
+ }
if (argMultimap.getValue(PREFIX_NAME).isPresent()) {
editPersonDescriptor.setName(ParserUtil.parseName(argMultimap.getValue(PREFIX_NAME).get()));
}
@@ -73,9 +77,6 @@ public EditCommand parse(String args) throws ParseException {
if (argMultimap.getValue(PREFIX_GENDER).isPresent()) {
editPersonDescriptor.setGender(ParserUtil.parseGender(argMultimap.getValue(PREFIX_GENDER).get()));
}
- if (argMultimap.getValue(PREFIX_NRIC).isPresent()) {
- editPersonDescriptor.setIc(ParserUtil.parseIc(argMultimap.getValue(PREFIX_NRIC).get()));
- }
if (argMultimap.getValue(PREFIX_CONDITION).isPresent()) {
editPersonDescriptor.setCondition(ParserUtil.parseCondition(argMultimap.getValue(PREFIX_CONDITION).get()));
}
@@ -93,10 +94,11 @@ public EditCommand parse(String args) throws ParseException {
parseTagsForEdit(argMultimap.getAllValues(PREFIX_TAG)).ifPresent(editPersonDescriptor::setTags);
if (!editPersonDescriptor.isAnyFieldEdited()) {
+ logger.warning("No fields were edited for the EditCommand.");
throw new ParseException(EditCommand.MESSAGE_NOT_EDITED);
}
- // make it pass a 3rd argument on whether doctor or patient
+ logger.info("Successfully parsed EditCommand.");
return new EditCommand(nric, editPersonDescriptor);
}
diff --git a/src/main/java/seedu/address/logic/parser/FindAppointmentCommandParser.java b/src/main/java/seedu/address/logic/parser/FindAppointmentCommandParser.java
new file mode 100644
index 00000000000..bd67fcdad0f
--- /dev/null
+++ b/src/main/java/seedu/address/logic/parser/FindAppointmentCommandParser.java
@@ -0,0 +1,40 @@
+package seedu.address.logic.parser;
+
+import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
+
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import seedu.address.commons.core.LogsCenter;
+import seedu.address.logic.commands.FindAppointmentCommand;
+import seedu.address.logic.parser.exceptions.ParseException;
+import seedu.address.model.appointment.AppointmentIcPredicate;
+
+/**
+ * Parses input arguments and creates a new FindCommand object
+ */
+public class FindAppointmentCommandParser implements Parser {
+ private static final Logger logger = LogsCenter.getLogger(FindAppointmentCommandParser.class);
+
+ /**
+ * Parses the given {@code String} of arguments in the context of the FindCommand
+ * and returns a FindCommand object for execution.
+ *
+ * @throws ParseException if the user input does not conform the expected format
+ */
+ public FindAppointmentCommand parse(String args) throws ParseException {
+ String trimmedArgs = args.trim();
+ Pattern nricPattern = Pattern.compile("^[ST]\\d{7}[A-Z]$");
+ Matcher nricMatcher = nricPattern.matcher(trimmedArgs);
+ if (trimmedArgs.isEmpty() || !nricMatcher.matches()) {
+ logger.warning("Can't parse find command - invalid input");
+ throw new ParseException(
+ String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindAppointmentCommand.MESSAGE_USAGE));
+ }
+ logger.info("Successfully parsed Find Command");
+ AppointmentIcPredicate icPredicate = new AppointmentIcPredicate(trimmedArgs);
+ return new FindAppointmentCommand(icPredicate);
+ }
+
+}
diff --git a/src/main/java/seedu/address/logic/parser/FindCommandParser.java b/src/main/java/seedu/address/logic/parser/FindCommandParser.java
index d9f3320e1f1..8a7b10e2c85 100644
--- a/src/main/java/seedu/address/logic/parser/FindCommandParser.java
+++ b/src/main/java/seedu/address/logic/parser/FindCommandParser.java
@@ -2,6 +2,9 @@
import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
+import java.util.logging.Logger;
+
+import seedu.address.commons.core.LogsCenter;
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.parser.exceptions.ParseException;
@@ -9,21 +12,25 @@
* Parses input arguments and creates a new FindCommand object
*/
public class FindCommandParser implements Parser {
+ private static final Logger logger = LogsCenter.getLogger(FindCommandParser.class);
/**
* Parses the given {@code String} of arguments in the context of the FindCommand
* and returns a FindCommand object for execution.
+ *
* @throws ParseException if the user input does not conform the expected format
*/
public FindCommand parse(String args) throws ParseException {
String trimmedArgs = args.trim();
if (trimmedArgs.isEmpty()) {
+ logger.warning("Can't parse find command - invalid input");
throw new ParseException(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindCommand.MESSAGE_USAGE));
}
String[] keywords = trimmedArgs.split("\\s+");
+ logger.info("Successfully parsed Find Command");
return new FindCommand(KeywordParser.parseInput(keywords));
}
diff --git a/src/main/java/seedu/address/logic/parser/KeywordParser.java b/src/main/java/seedu/address/logic/parser/KeywordParser.java
index f16c02ccf8c..719572f1e2b 100644
--- a/src/main/java/seedu/address/logic/parser/KeywordParser.java
+++ b/src/main/java/seedu/address/logic/parser/KeywordParser.java
@@ -23,21 +23,27 @@ public class KeywordParser {
public static Predicate parseInput(String[] input) {
Pattern nricPattern = Pattern.compile("^[ST]\\d{7}[A-Z]$");
Pattern genderPattern = Pattern.compile("^([MF])$");
- Pattern bloodtypePattern = Pattern.compile("^Blood Type (A\\+|A-|B\\+|B-|AB\\+|AB-|O\\+|O-)$");
+ Pattern bloodtypePattern = Pattern.compile("^(A\\+|A-|B\\+|B-|AB\\+|AB-|O\\+|O-)$");
Matcher genderMatcher = genderPattern.matcher(input[0]);
Matcher nricMatcher = nricPattern.matcher(input[0]);
- Matcher bloodtypeMatcher = bloodtypePattern.matcher(input[0]);
+
+ if (input.length >= 3) {
+ Matcher bloodtypeMatcher = bloodtypePattern.matcher(input[2]);
+ if (bloodtypeMatcher.matches()) {
+ return new BloodTypePredicate(input[2]);
+ } else {
+ return new NameContainsKeywordsPredicate(Arrays.asList(input));
+ }
+ }
if (nricMatcher.matches()) {
return new IcContainsKeywordsPredicate(input[0]);
} else if (genderMatcher.matches()) {
return new GenderPredicate(input[0]);
- } else if (bloodtypeMatcher.matches()) {
- return new BloodTypePredicate(input[0]);
+ } else {
+ return new NameContainsKeywordsPredicate(Arrays.asList(input));
}
-
- return new NameContainsKeywordsPredicate(Arrays.asList(input));
}
}
diff --git a/src/main/java/seedu/address/logic/parser/Parser.java b/src/main/java/seedu/address/logic/parser/Parser.java
index d6551ad8e3f..ce644a9c6fd 100644
--- a/src/main/java/seedu/address/logic/parser/Parser.java
+++ b/src/main/java/seedu/address/logic/parser/Parser.java
@@ -10,6 +10,7 @@ public interface Parser {
/**
* Parses {@code userInput} into a command and returns it.
+ *
* @throws ParseException if {@code userInput} does not conform the expected format
*/
T parse(String userInput) throws ParseException;
diff --git a/src/main/java/seedu/address/logic/parser/ParserUtil.java b/src/main/java/seedu/address/logic/parser/ParserUtil.java
index d853c427851..518178cebf6 100644
--- a/src/main/java/seedu/address/logic/parser/ParserUtil.java
+++ b/src/main/java/seedu/address/logic/parser/ParserUtil.java
@@ -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;
@@ -135,28 +136,125 @@ public static Gender parseGender(String gender) throws ParseException {
}
/**
- * Parses a {@code String tag} into a {@code Tag}.
- * Leading and trailing whitespaces will be trimmed.
+ * Parses a string to create a {@code Tag} object after processing the input string.
+ * The input string is trimmed and converted to uppercase. If the tag name is a valid
+ * patient tag name, it is prefixed with "priority: " before being used to create the tag.
*
- * @throws ParseException if the given {@code tag} is invalid.
+ * @param tag The string to be parsed into a Tag object.
+ * @return A Tag object representing the input string.
+ * @throws NullPointerException if the tag parameter is null.
*/
- public static Tag parseTag(String tag) throws ParseException {
+ public static Tag parseTag(String tag) {
requireNonNull(tag);
- String trimmedTag = tag.trim();
- if (!Tag.isValidTagName(trimmedTag)) {
- throw new ParseException(Tag.MESSAGE_CONSTRAINTS);
+ String trimmedTag = tag.trim().toUpperCase();
+ if (Tag.isValidPatientTagName(trimmedTag)) {
+ trimmedTag = "priority: " + trimmedTag;
}
return new Tag(trimmedTag);
}
/**
- * Parses {@code Collection tags} into a {@code Set}.
+ * Parses a collection of strings to create a set of {@code Tag} objects.
+ * Each string in the collection is processed to create a Tag. If a duplicate tag is found,
+ * a ParseException is thrown.
+ *
+ * @param tags The collection of strings to be parsed into Tag objects.
+ * @return A set of Tag objects.
+ * @throws ParseException if a duplicate tag is detected.
+ * @throws NullPointerException if the tags parameter is null.
*/
public static Set parseTags(Collection tags) throws ParseException {
requireNonNull(tags);
final Set tagSet = new HashSet<>();
for (String tagName : tags) {
- tagSet.add(parseTag(tagName));
+ Tag toAdd = parseTag(tagName);
+ if (tagSet.contains(toAdd)) {
+ throw new ParseException(Tag.DUPLICATE_TAG);
+ }
+ tagSet.add(toAdd);
+ }
+ return tagSet;
+ }
+
+ /**
+ * Parses a string to create a {@code Tag} object representing a patient tag.
+ * The tag name is validated to be a valid patient tag name, prefixed with "priority: ".
+ * If the tag name is not valid, a ParseException is thrown.
+ *
+ * @param tag The string to be parsed into a patient Tag object.
+ * @return A Tag object representing the patient tag.
+ * @throws ParseException if the tag name is not a valid patient tag name.
+ * @throws NullPointerException if the tag parameter is null.
+ */
+ public static Tag parsePatientTag(String tag) throws ParseException {
+ requireNonNull(tag);
+ String trimmedTag = tag.trim().toUpperCase();
+ if (!Tag.isValidPatientTagName(trimmedTag)) {
+ throw new ParseException(Tag.INVALID_PATIENT_TAG);
+ }
+ return new Tag("priority: " + trimmedTag);
+ }
+
+ /**
+ * Parses a collection of strings to create a set of {@code Tag} objects representing patient tags.
+ * If more than one tag is provided, a ParseException is thrown since patients should only have one tag.
+ * Each tag is validated to be a proper patient tag.
+ *
+ * @param tags The collection of strings to be parsed into patient Tag objects.
+ * @return A set of Tag objects representing the patient tags.
+ * @throws ParseException if the collection contains more than one tag or if the tag is not valid.
+ * @throws NullPointerException if the tags parameter is null.
+ */
+ public static Set parsePatientTags(Collection tags) throws ParseException {
+ requireNonNull(tags);
+ final Set tagSet = new HashSet<>();
+ if (tags.size() > 1) {
+ throw new ParseException(Tag.EXTRA_PATIENT_TAG);
+ }
+ for (String tagName : tags) {
+ tagSet.add(parsePatientTag(tagName));
+ }
+ return tagSet;
+ }
+
+ /**
+ * Parses a string to create a {@code Tag} object representing a doctor tag.
+ * The tag name is validated to be a valid doctor tag name. If the tag name is not valid,
+ * a ParseException is thrown.
+ *
+ * @param tag The string to be parsed into a doctor Tag object.
+ * @return A Tag object representing the doctor tag.
+ * @throws ParseException if the tag name is not a valid doctor tag name.
+ * @throws NullPointerException if the tag parameter is null.
+ */
+ public static Tag parseDoctorTag(String tag) throws ParseException {
+ requireNonNull(tag);
+ String trimmedTag = tag.trim().toUpperCase();
+ if (!Tag.isValidDoctorTagName(trimmedTag)) {
+ throw new ParseException(Tag.INVALID_DOCTOR_TAG);
+ }
+ return new Tag(trimmedTag);
+ }
+
+ /**
+ * Parses a collection of strings to create a set of {@code Tag} objects representing doctor tags.
+ * Duplicate tags are not allowed, and if found, a ParseException is thrown.
+ * Each tag is validated to be a proper doctor tag.
+ *
+ * @param tags The collection of strings to be parsed into doctor Tag objects.
+ * @return A set of Tag objects representing the doctor tags.
+ * @throws ParseException if a duplicate tag is detected or if the tag is not valid.
+ * @throws NullPointerException if the tags parameter is null.
+ */
+ public static Set parseDoctorTags(Collection tags) throws ParseException {
+ requireNonNull(tags);
+ final Set tagSet = new HashSet<>();
+ for (String tagName : tags) {
+ Tag toAdd = parseDoctorTag(tagName);
+ if (tagSet.contains(toAdd)) {
+ throw new ParseException(Tag.DUPLICATE_TAG);
+ }
+ tagSet.add(toAdd);
}
return tagSet;
}
@@ -201,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);
+ }
}
diff --git a/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java b/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java
deleted file mode 100644
index ab4093c5b78..00000000000
--- a/src/main/java/seedu/address/logic/parser/RemarkCommandParser.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package seedu.address.logic.parser;
-
-import static java.util.Objects.requireNonNull;
-import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
-import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK;
-
-import seedu.address.commons.core.index.Index;
-import seedu.address.commons.exceptions.IllegalValueException;
-import seedu.address.logic.commands.RemarkCommand;
-import seedu.address.logic.parser.exceptions.ParseException;
-import seedu.address.model.person.Remark;
-
-/**
- * The DeleteCommandParser class is responsible for parsing user input and creating a DeleteCommand object
- * to represent the user's request to delete a record. It interprets the provided input arguments and converts them
- * into a valid DeleteCommand.
- */
-public class RemarkCommandParser implements Parser {
- /**
- * Parses the given {@code String} of arguments in the context of the DeleteCommand
- * and returns a DeleteCommand object for execution.
- *
- * @param args The user input string containing the details for deleting a record.
- * @return A DeleteCommand object representing the user's request to delete a record.
- * @throws ParseException If the user input does not conform to the expected format.
- */
- public RemarkCommand parse(String args) throws ParseException {
- requireNonNull(args);
- ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args,
- PREFIX_REMARK);
-
- Index index;
- try {
- index = ParserUtil.parseIndex(argMultimap.getPreamble());
- } catch (IllegalValueException ive) {
- throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
- RemarkCommand.MESSAGE_USAGE), ive);
- }
-
- String remarkString = argMultimap.getValue(PREFIX_REMARK).orElse("");
- Remark remark = new Remark(remarkString);
-
- return new RemarkCommand(index, remark);
- }
-}
diff --git a/src/main/java/seedu/address/model/AddressBook.java b/src/main/java/seedu/address/model/AddressBook.java
index 710ec25792d..9cca0d3e9e9 100644
--- a/src/main/java/seedu/address/model/AddressBook.java
+++ b/src/main/java/seedu/address/model/AddressBook.java
@@ -7,8 +7,11 @@
import javafx.collections.ObservableList;
import seedu.address.commons.util.ToStringBuilder;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
+import seedu.address.model.person.Ic;
import seedu.address.model.person.Patient;
+import seedu.address.model.person.UniqueAppointmentList;
import seedu.address.model.person.UniqueDoctorList;
import seedu.address.model.person.UniquePatientList;
@@ -19,6 +22,7 @@
public class AddressBook implements ReadOnlyAddressBook {
private final UniqueDoctorList doctors;
private final UniquePatientList patients;
+ private final UniqueAppointmentList appointments;
/*
* The 'unusual' code block below is a non-static initialization block, sometimes used to avoid duplication
@@ -30,6 +34,7 @@ public class AddressBook implements ReadOnlyAddressBook {
{
doctors = new UniqueDoctorList();
patients = new UniquePatientList();
+ appointments = new UniqueAppointmentList();
}
public AddressBook() {
@@ -50,7 +55,7 @@ public AddressBook(ReadOnlyAddressBook toBeCopied) {
* {@code patients} must not contain duplicate patients.
*/
public void setPatients(List patients) {
- this.patients.setPatients(patients);
+ this.patients.setObjects(patients);
}
/**
@@ -58,7 +63,15 @@ public void setPatients(List patients) {
* {@code doctors} must not contain duplicate persons.
*/
public void setDoctors(List doctors) {
- this.doctors.setDoctors(doctors);
+ this.doctors.setObjects(doctors);
+ }
+
+ /**
+ * Replaces the contents of the appointments list with {@code appointments}.
+ * {@code appointments} must not contain duplicate appointments.
+ */
+ public void setAppointments(List appointments) {
+ this.appointments.setObjects(appointments);
}
/**
@@ -68,6 +81,7 @@ public void resetData(ReadOnlyAddressBook newData) {
requireNonNull(newData);
setDoctors(newData.getDoctorList());
setPatients(newData.getPatientList());
+ setAppointments(newData.getAppointmentList());
}
//// person-level operations
@@ -79,6 +93,7 @@ public boolean hasPatient(Patient patient) {
requireNonNull(patient);
// return in patients list or in doctor list
return patients.contains(patient);
+
}
/**
@@ -89,6 +104,14 @@ public boolean hasDoctor(Doctor doctor) {
return doctors.contains(doctor);
}
+ /**
+ * Returns true if an appointment with the same details as {@code appointment} exists in the address book.
+ */
+ public boolean hasAppointment(Appointment appointment) {
+ requireNonNull(appointment);
+ return appointments.contains(appointment);
+ }
+
/**
* Adds a person to the address book.
* The person must not already exist in the address book.
@@ -107,6 +130,10 @@ public void addDoctor(Doctor d) {
doctors.add(d);
}
+ public void addAppointment(Appointment a) {
+ appointments.add(a);
+ }
+
/**
* Replaces the given person {@code target} in the list with {@code editedPerson}.
* Replaces the given patients {@code target} in the list with {@code editedPerson}.
@@ -116,7 +143,7 @@ public void addDoctor(Doctor d) {
public void setPatient(Patient target, Patient editedPerson) {
requireNonNull(editedPerson);
- patients.setPatient(target, editedPerson);
+ patients.setObject(target, editedPerson);
}
/**
@@ -127,7 +154,7 @@ public void setPatient(Patient target, Patient editedPerson) {
public void setDoctor(Doctor target, Doctor editedDoctor) {
requireNonNull(editedDoctor);
- doctors.setDoctor(target, editedDoctor);
+ doctors.setObject(target, editedDoctor);
}
/**
@@ -150,6 +177,16 @@ public void removeDoctor(Doctor key) {
}
}
+ /**
+ * Removes {@code key} from this {@code AddressBook}.
+ * {@code key} must exist in the address book.
+ */
+ public void removeAppointment(Appointment key) {
+ if (appointments.contains(key)) {
+ appointments.remove(key);
+ }
+ }
+
//// util methods
@Override
@@ -157,6 +194,7 @@ public String toString() { //not sure how to modify this
return new ToStringBuilder(this)
.add("patients", patients)
.add("doctors", doctors)
+ .add("appointments", appointments)
.toString();
}
@@ -164,11 +202,14 @@ public ObservableList getPatientList() {
return patients.asUnmodifiableObservableList();
}
- @Override
public ObservableList getDoctorList() {
return doctors.asUnmodifiableObservableList();
}
+ public ObservableList getAppointmentList() {
+ return appointments.asUnmodifiableObservableList();
+ }
+
@Override
public boolean equals(Object other) {
if (other == this) {
@@ -182,11 +223,19 @@ public boolean equals(Object other) {
AddressBook otherAddressBook = (AddressBook) other;
return patients.equals(otherAddressBook.patients)
- && doctors.equals((otherAddressBook.doctors));
+ && doctors.equals((otherAddressBook.doctors))
+ && appointments.equals((otherAddressBook.appointments));
}
@Override
public int hashCode() {
- return Objects.hash(patients, doctors);
+ return Objects.hash(patients, doctors, appointments);
+ }
+
+ /**
+ * Checks if an IC exists in the addressbook.
+ */
+ public boolean hasIc(Ic nric) {
+ return patients.containsIc(nric) || doctors.containsIc(nric);
}
}
diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java
index e41f750f289..4b74023ca77 100644
--- a/src/main/java/seedu/address/model/Model.java
+++ b/src/main/java/seedu/address/model/Model.java
@@ -6,7 +6,9 @@
import javafx.collections.ObservableList;
import seedu.address.commons.core.GuiSettings;
import seedu.address.logic.commands.exceptions.CommandException;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
+import seedu.address.model.person.Ic;
import seedu.address.model.person.Patient;
import seedu.address.model.person.Person;
@@ -20,6 +22,8 @@ public interface Model {
Predicate PREDICATE_SHOW_ALL_PERSONS = unused -> true;
Predicate PREDICATE_SHOW_ALL_DOCTORS = unused -> true;
+ Predicate PREDICATE_SHOW_ALL_APPOINTMENTS = unused -> true;
+
/**
* Replaces user prefs data with the data in {@code userPrefs}.
*/
@@ -77,6 +81,8 @@ public interface Model {
*/
void addPerson(Person person);
+ void deleteAppointment(Appointment appointment);
+
/**
* Replaces the given person {@code target} with {@code editedPerson}.
* {@code target} must exist in the address book.
@@ -84,10 +90,7 @@ public interface Model {
*/
void setPerson(Person target, Person editedPerson);
- /**
- * Returns an unmodifiable view of the filtered person list
- */
- ObservableList getFilteredPersonList();
+ void addAppointment(Appointment appointment);
/**
* Returns an unmodifiable view of the filtered patient list
@@ -99,6 +102,8 @@ public interface Model {
*/
ObservableList getFilteredDoctorList();
+ ObservableList getFilteredAppointmentList();
+
/**
* Updates the filter of the filtered person list to filter by the given {@code predicate}.
*
@@ -109,4 +114,7 @@ public interface Model {
void undo() throws CommandException;
void redo() throws CommandException;
+
+ void updateFilteredAppointmentList(Predicate predicate);
+ boolean hasIc(Ic nric);
}
diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java
index c2205937d27..39eec66c5d3 100644
--- a/src/main/java/seedu/address/model/ModelManager.java
+++ b/src/main/java/seedu/address/model/ModelManager.java
@@ -15,7 +15,9 @@
import seedu.address.logic.commands.RedoCommand;
import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.commands.exceptions.CommandException;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
+import seedu.address.model.person.Ic;
import seedu.address.model.person.Patient;
import seedu.address.model.person.Person;
@@ -31,6 +33,7 @@ public class ModelManager implements Model {
private final UserPrefs userPrefs;
private final FilteredList filteredDoctors;
private final FilteredList filteredPatients;
+ private final FilteredList filteredAppointments;
/**
* Initializes a ModelManager with the given addressBook and userPrefs.
@@ -45,6 +48,7 @@ public ModelManager(ReadOnlyAddressBook addressBook, ReadOnlyUserPrefs userPrefs
this.redoList = new ArrayList<>();
filteredDoctors = new FilteredList<>(this.addressBook.getDoctorList());
filteredPatients = new FilteredList<>(this.addressBook.getPatientList());
+ filteredAppointments = new FilteredList<>(this.addressBook.getAppointmentList());
}
public ModelManager() {
@@ -129,14 +133,16 @@ 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
+ public boolean hasIc(Ic nric) {
+ return addressBook.hasIc(nric);
+ }
@Override
public void deletePerson(Person target) {
@@ -152,16 +158,30 @@ 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);
}
updateFilteredPersonList(PREDICATE_SHOW_ALL_PERSONS);
}
+ @Override
+ public void addAppointment(Appointment appointment) {
+ updateBackup();
+ addressBook.addAppointment(appointment);
+ updateFilteredAppointmentList(PREDICATE_SHOW_ALL_APPOINTMENTS);
+ }
+
+ @Override
+ public void deleteAppointment(Appointment appointment) {
+ updateBackup();
+ addressBook.removeAppointment(appointment);
+ updateFilteredAppointmentList(PREDICATE_SHOW_ALL_APPOINTMENTS);
+ }
+
@Override
public void setPerson(Person target, Person editedPerson) {
requireAllNonNull(target, editedPerson);
@@ -174,13 +194,6 @@ public void setPerson(Person target, Person editedPerson) {
}
}
- /**
- * Returns an unmodifiable view of the filtered person list
- */
- @Override
- public ObservableList getFilteredPersonList() {
- return null;
- }
//=========== Filtered Person List Accessors =============================================================
@@ -201,6 +214,11 @@ public ObservableList getFilteredDoctorList() {
return filteredDoctors;
}
+ @Override
+ public ObservableList getFilteredAppointmentList() {
+ return filteredAppointments;
+ }
+
@Override
public void updateFilteredPersonList(Predicate predicate) {
requireNonNull(predicate);
@@ -208,6 +226,12 @@ public void updateFilteredPersonList(Predicate predicate) {
filteredDoctors.setPredicate(predicate);
}
+ @Override
+ public void updateFilteredAppointmentList(Predicate predicate) {
+ requireNonNull(predicate);
+ filteredAppointments.setPredicate(predicate);
+ }
+
@Override
public boolean equals(Object other) {
if (other == this) {
@@ -223,6 +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);
}
+
}
diff --git a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java
index 57e49cad716..bacc136c5e6 100644
--- a/src/main/java/seedu/address/model/ReadOnlyAddressBook.java
+++ b/src/main/java/seedu/address/model/ReadOnlyAddressBook.java
@@ -1,6 +1,7 @@
package seedu.address.model;
import javafx.collections.ObservableList;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
import seedu.address.model.person.Patient;
@@ -14,4 +15,5 @@ public interface ReadOnlyAddressBook {
*/
ObservableList getDoctorList();
ObservableList getPatientList();
+ ObservableList getAppointmentList();
}
diff --git a/src/main/java/seedu/address/model/appointment/Appointment.java b/src/main/java/seedu/address/model/appointment/Appointment.java
index 036f80be1d6..b702ab733af 100644
--- a/src/main/java/seedu/address/model/appointment/Appointment.java
+++ b/src/main/java/seedu/address/model/appointment/Appointment.java
@@ -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;
@@ -14,11 +12,9 @@
* 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;
/**
* Constructs a new appointment with the specified doctor, patient, and appointment time.
@@ -27,7 +23,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);
@@ -44,7 +40,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);
@@ -52,10 +48,9 @@ public Appointment(Ic doctorIc, Ic patientIc, LocalDateTime appointmentTime, Str
this.doctorIc = doctorIc;
this.patientIc = patientIc;
this.appointmentTime = appointmentTime;
- this.status = status;
}
- public LocalDateTime getAppointmentTime() {
+ public AppointmentTime getAppointmentTime() {
return appointmentTime;
}
@@ -67,11 +62,7 @@ public Ic getPatient() {
return patientIc;
}
- public String getStatus() {
- return status;
- }
-
- public void setAppointmentTime(LocalDateTime appointmentTime) {
+ public void setAppointmentTime(AppointmentTime appointmentTime) {
this.appointmentTime = appointmentTime;
}
@@ -83,10 +74,6 @@ public void changePatient(Ic newPatientIc) {
this.patientIc = newPatientIc;
}
- public void changeStatus(String newStatus) {
- this.status = newStatus;
- }
-
@Override
public boolean equals(Object other) {
if (other == this) {
@@ -101,18 +88,17 @@ public boolean equals(Object other) {
Appointment otherAppointment = (Appointment) other;
return this.doctorIc.equals(otherAppointment.doctorIc)
&& this.patientIc.equals(otherAppointment.patientIc)
- && this.appointmentTime.equals(otherAppointment.appointmentTime)
- && this.status.equals(otherAppointment.status);
+ && this.appointmentTime.equals(otherAppointment.appointmentTime);
}
@Override
public int hashCode() {
- return Objects.hash(doctorIc, patientIc, appointmentTime, status);
+ return Objects.hash(doctorIc, patientIc, appointmentTime);
}
@Override
public String toString() {
return "Patient with IC " + patientIc + ", Doctor with IC " + doctorIc + " at "
- + appointmentTime.format(FORMATTER);
+ + appointmentTime.toString();
}
}
diff --git a/src/main/java/seedu/address/model/appointment/AppointmentIcPredicate.java b/src/main/java/seedu/address/model/appointment/AppointmentIcPredicate.java
new file mode 100644
index 00000000000..0c7bda2655f
--- /dev/null
+++ b/src/main/java/seedu/address/model/appointment/AppointmentIcPredicate.java
@@ -0,0 +1,46 @@
+package seedu.address.model.appointment;
+
+import java.util.function.Predicate;
+
+import seedu.address.commons.util.ToStringBuilder;
+
+/**
+ * Checks if an {@code appointment} has a patient or doctor, matching
+ * the query Ic {@code keywords}.
+ */
+public class AppointmentIcPredicate implements Predicate {
+ private final String keywords;
+
+ public AppointmentIcPredicate(String keywords) {
+ this.keywords = keywords;
+ }
+
+ @Override
+ public boolean test(Appointment appointment) {
+ if (keywords.equalsIgnoreCase(appointment.getPatient().toString())) {
+ return true;
+ }
+ return keywords.equalsIgnoreCase(appointment.getDoctor().toString());
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ // instanceof handles nulls
+ if (!(other instanceof AppointmentIcPredicate)) {
+ return false;
+ }
+
+ AppointmentIcPredicate otherAppointmentIcPredicate = (AppointmentIcPredicate) other;
+ return keywords.equals(otherAppointmentIcPredicate.keywords);
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).add("keywords", keywords).toString();
+ }
+}
+
diff --git a/src/main/java/seedu/address/model/appointment/AppointmentTime.java b/src/main/java/seedu/address/model/appointment/AppointmentTime.java
new file mode 100644
index 00000000000..c997fec687c
--- /dev/null
+++ b/src/main/java/seedu/address/model/appointment/AppointmentTime.java
@@ -0,0 +1,76 @@
+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;
+import java.time.format.ResolverStyle;
+
+
+/**
+ * Represents the time of an appointment.
+ * Guarantees: immutable; is valid as declared in {@link #isValidAppointmentTime(String)}
+ */
+public class AppointmentTime implements Comparable {
+
+ 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;
+
+ /**
+ * 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);
+ }
+}
diff --git a/src/main/java/seedu/address/model/person/BloodTypePredicate.java b/src/main/java/seedu/address/model/person/BloodTypePredicate.java
index bc900dfab3c..c119fb8e6e7 100644
--- a/src/main/java/seedu/address/model/person/BloodTypePredicate.java
+++ b/src/main/java/seedu/address/model/person/BloodTypePredicate.java
@@ -14,8 +14,7 @@ public class BloodTypePredicate implements Predicate {
* Constructs a predicate that tests that a {@code Person}'s {@code Gender} matches either male or female.
*/
public BloodTypePredicate(String keywords) {
- String[] trimmed = keywords.split(" ");
- this.keywords = trimmed[2];
+ this.keywords = keywords;
}
@Override
diff --git a/src/main/java/seedu/address/model/person/GenderPredicate.java b/src/main/java/seedu/address/model/person/GenderPredicate.java
index 854709ab9ac..98203a13e5d 100644
--- a/src/main/java/seedu/address/model/person/GenderPredicate.java
+++ b/src/main/java/seedu/address/model/person/GenderPredicate.java
@@ -38,4 +38,6 @@ public boolean equals(Object other) {
public String toString() {
return new ToStringBuilder(this).add("keywords", keywords).toString();
}
+
+
}
diff --git a/src/main/java/seedu/address/model/person/Ic.java b/src/main/java/seedu/address/model/person/Ic.java
index 2217fd9b168..1ae41880bf2 100644
--- a/src/main/java/seedu/address/model/person/Ic.java
+++ b/src/main/java/seedu/address/model/person/Ic.java
@@ -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;
@@ -58,6 +58,4 @@ public boolean equals(Object other) {
public int hashCode() {
return value.hashCode();
}
-
-
}
diff --git a/src/main/java/seedu/address/model/person/Patient.java b/src/main/java/seedu/address/model/person/Patient.java
index ca4a11a46c2..e2dcef75cbc 100644
--- a/src/main/java/seedu/address/model/person/Patient.java
+++ b/src/main/java/seedu/address/model/person/Patient.java
@@ -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
diff --git a/src/main/java/seedu/address/model/person/Person.java b/src/main/java/seedu/address/model/person/Person.java
index a879e48f07f..69d2a42eb9c 100644
--- a/src/main/java/seedu/address/model/person/Person.java
+++ b/src/main/java/seedu/address/model/person/Person.java
@@ -3,7 +3,6 @@
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;
@@ -11,13 +10,14 @@
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.model.appointment.Appointment;
+import seedu.address.model.appointment.AppointmentTime;
import seedu.address.model.tag.Tag;
/**
* Represents a Person in the address book.
* Guarantees: details are present and not null, field values are validated, immutable.
*/
-public class Person {
+public abstract class Person {
// Identity fields
protected final Name name;
@@ -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) {
@@ -131,6 +131,15 @@ public void addAppointment(Appointment appointment) {
this.appointments.add(appointment);
}
+ /**
+ * Removes the given {@Code appointment} to this person's set of appointments.
+ *
+ * @param appointment the appointment to be added.
+ */
+ public void deleteAppointment(Appointment appointment) {
+ this.appointments.remove(appointment);
+ }
+
/**
* Retrieves the list of patients stored in this medical facility.
*
@@ -200,5 +209,4 @@ public String toString() {
.add("tags", tags)
.toString();
}
-
}
diff --git a/src/main/java/seedu/address/model/person/UniquePersonList.java b/src/main/java/seedu/address/model/person/UniqueAppointmentList.java
similarity index 53%
rename from src/main/java/seedu/address/model/person/UniquePersonList.java
rename to src/main/java/seedu/address/model/person/UniqueAppointmentList.java
index 22dc48af2b6..d3e68ac7843 100644
--- a/src/main/java/seedu/address/model/person/UniquePersonList.java
+++ b/src/main/java/seedu/address/model/person/UniqueAppointmentList.java
@@ -3,13 +3,14 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
-import java.util.Iterator;
import java.util.List;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import seedu.address.model.appointment.Appointment;
+import seedu.address.model.person.exceptions.DuplicateObjectException;
import seedu.address.model.person.exceptions.DuplicatePersonException;
-import seedu.address.model.person.exceptions.PersonNotFoundException;
+import seedu.address.model.person.exceptions.ObjectNotFoundException;
/**
* A list of persons that enforces uniqueness between its elements and does not allow nulls.
@@ -22,28 +23,35 @@
*
* @see Person#isSamePerson(Person)
*/
-public class UniquePersonList implements Iterable {
+public class UniqueAppointmentList extends UniqueObjectList {
- protected final ObservableList internalList = FXCollections.observableArrayList();
- protected final ObservableList internalUnmodifiableList =
+ protected final ObservableList internalList = FXCollections.observableArrayList();
+ protected final ObservableList internalUnmodifiableList =
FXCollections.unmodifiableObservableList(internalList);
+ public void setAppointments(UniqueAppointmentList replacement) {
+ requireNonNull(replacement);
+ internalList.setAll(replacement.internalList);
+ }
+
/**
* Returns true if the list contains an equivalent person as the given argument.
*/
- public boolean contains(Person toCheck) {
+ @Override
+ public boolean contains(Appointment toCheck) {
requireNonNull(toCheck);
- return internalList.stream().anyMatch(toCheck::isSamePerson);
+ return internalList.stream().anyMatch(toCheck::equals);
}
/**
* Adds a person to the list.
* The person must not already exist in the list.
*/
- public void add(Person toAdd) {
+ @Override
+ public void add(Appointment toAdd) {
requireNonNull(toAdd);
if (contains(toAdd)) {
- throw new DuplicatePersonException();
+ throw new DuplicateObjectException();
}
internalList.add(toAdd);
}
@@ -53,94 +61,61 @@ public void add(Person toAdd) {
* {@code target} must exist in the list.
* The person identity of {@code editedPerson} must not be the same as another existing person in the list.
*/
- public void setPerson(Person target, Person editedPerson) {
- requireAllNonNull(target, editedPerson);
+ @Override
+ public void setObject(Appointment target, Appointment editedAppointment) {
+ requireAllNonNull(target, editedAppointment);
int index = internalList.indexOf(target);
if (index == -1) {
- throw new PersonNotFoundException();
+ throw new ObjectNotFoundException();
}
- if (!target.isSamePerson(editedPerson) && contains(editedPerson)) {
+ if (!target.equals(editedAppointment) && contains(editedAppointment)) {
throw new DuplicatePersonException();
}
- internalList.set(index, editedPerson);
+ internalList.set(index, editedAppointment);
}
/**
* Removes the equivalent person from the list.
* The person must exist in the list.
*/
- public void remove(Person toRemove) {
+ @Override
+ public void remove(Appointment toRemove) {
requireNonNull(toRemove);
if (!internalList.remove(toRemove)) {
- throw new PersonNotFoundException();
+ throw new ObjectNotFoundException();
}
}
- public void setPersons(UniquePersonList replacement) {
- requireNonNull(replacement);
- internalList.setAll(replacement.internalList);
- }
-
/**
* Replaces the contents of this list with {@code persons}.
* {@code persons} must not contain duplicate persons.
*/
- public void setPersons(List persons) {
- requireAllNonNull(persons);
- if (!personsAreUnique(persons)) {
- throw new DuplicatePersonException();
- }
-
- internalList.setAll(persons);
- }
-
- /**
- * Returns the backing list as an unmodifiable {@code ObservableList}.
- */
- public ObservableList asUnmodifiableObservableList() {
- return internalUnmodifiableList;
- }
-
- @Override
- public Iterator iterator() {
- return internalList.iterator();
- }
-
@Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
-
- // instanceof handles nulls
- if (!(other instanceof UniquePersonList)) {
- return false;
+ public void setObjects(List appointments) {
+ requireAllNonNull(appointments);
+ if (!objectsAreUnique(appointments)) {
+ throw new DuplicateObjectException();
}
- UniquePersonList otherUniquePersonList = (UniquePersonList) other;
- return internalList.equals(otherUniquePersonList.internalList);
- }
-
- @Override
- public int hashCode() {
- return internalList.hashCode();
+ internalList.setAll(appointments);
}
@Override
- public String toString() {
- return internalList.toString();
+ public ObservableList asUnmodifiableObservableList() {
+ return internalUnmodifiableList;
}
/**
* Returns true if {@code persons} contains only unique persons.
*/
- protected boolean personsAreUnique(List persons) {
- for (int i = 0; i < persons.size() - 1; i++) {
- for (int j = i + 1; j < persons.size(); j++) {
- if (persons.get(i).isSamePerson(persons.get(j))) {
+ @Override
+ protected boolean objectsAreUnique(List appointments) {
+ for (int i = 0; i < appointments.size() - 1; i++) {
+ for (int j = i + 1; j < appointments.size(); j++) {
+ if (appointments.get(i).equals(appointments.get(j))) {
return false;
}
}
diff --git a/src/main/java/seedu/address/model/person/UniqueDoctorList.java b/src/main/java/seedu/address/model/person/UniqueDoctorList.java
index 287225e3d1f..d59f6384018 100644
--- a/src/main/java/seedu/address/model/person/UniqueDoctorList.java
+++ b/src/main/java/seedu/address/model/person/UniqueDoctorList.java
@@ -3,7 +3,6 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
-import java.util.Iterator;
import java.util.List;
import javafx.collections.FXCollections;
@@ -22,24 +21,38 @@
*
* @see Person#isSamePerson(Person)
*/
-public class UniqueDoctorList implements Iterable {
+public class UniqueDoctorList extends UniqueObjectList {
- private final ObservableList internalList = FXCollections.observableArrayList();
- private final ObservableList internalUnmodifiableList =
+ protected final ObservableList internalList = FXCollections.observableArrayList();
+ protected final ObservableList internalUnmodifiableList =
FXCollections.unmodifiableObservableList(internalList);
+ public void setDoctors(UniqueDoctorList replacement) {
+ requireNonNull(replacement);
+ internalList.setAll(replacement.internalList);
+ }
+
/**
* Returns true if the list contains an equivalent person as the given argument.
*/
+ @Override
public boolean contains(Doctor toCheck) {
requireNonNull(toCheck);
return internalList.stream().anyMatch(toCheck::isSamePerson);
}
+ /**
+ * Returns true if the list contains the same ic as the given argument.
+ */
+ public boolean containsIc(Ic nric) {
+ requireNonNull(nric);
+ return internalList.stream().anyMatch(x -> x.getIc().equals(nric));
+ }
/**
* Adds a person to the list.
* The person must not already exist in the list.
*/
+ @Override
public void add(Doctor toAdd) {
requireNonNull(toAdd);
if (contains(toAdd)) {
@@ -49,29 +62,31 @@ public void add(Doctor toAdd) {
}
/**
- * Replaces the doctor {@code target} in the list with {@code editedPerson}.
+ * Replaces the person {@code target} in the list with {@code editedPerson}.
* {@code target} must exist in the list.
* The person identity of {@code editedPerson} must not be the same as another existing person in the list.
*/
- public void setDoctor(Doctor target, Doctor editedPerson) {
- requireAllNonNull(target, editedPerson);
+ @Override
+ public void setObject(Doctor target, Doctor editedDoctor) {
+ requireAllNonNull(target, editedDoctor);
int index = internalList.indexOf(target);
if (index == -1) {
throw new PersonNotFoundException();
}
- if (!target.isSamePerson(editedPerson) && contains(editedPerson)) {
+ if (!target.isSamePerson(editedDoctor) && contains(editedDoctor)) {
throw new DuplicatePersonException();
}
- internalList.set(index, editedPerson);
+ internalList.set(index, editedDoctor);
}
/**
* Removes the equivalent person from the list.
* The person must exist in the list.
*/
+ @Override
public void remove(Doctor toRemove) {
requireNonNull(toRemove);
if (!internalList.remove(toRemove)) {
@@ -79,81 +94,33 @@ public void remove(Doctor toRemove) {
}
}
- public void setDoctors(UniqueDoctorList replacement) {
- requireNonNull(replacement);
- internalList.setAll(replacement.internalList);
- }
-
/**
* Replaces the contents of this list with {@code persons}.
* {@code persons} must not contain duplicate persons.
*/
- public void setDoctors(List persons) {
- requireAllNonNull(persons);
- if (!personsAreUnique(persons)) {
+ @Override
+ public void setObjects(List doctors) {
+ requireAllNonNull(doctors);
+ if (!objectsAreUnique(doctors)) {
throw new DuplicatePersonException();
}
- internalList.setAll(persons);
+ internalList.setAll(doctors);
}
- /**
- * Returns the backing list as an unmodifiable {@code ObservableList}.
- */
+ @Override
public ObservableList asUnmodifiableObservableList() {
return internalUnmodifiableList;
}
- @Override
- public Iterator iterator() {
- return internalList.iterator();
- }
-
- @Override
- public boolean equals(Object other) {
- if (this == other) {
- return true;
- }
-
- // instanceof handles nulls
- if (!(other instanceof UniqueDoctorList)) {
- return false;
- }
-
- UniqueDoctorList otherUniqueDoctorList = (UniqueDoctorList) other;
-
- // Check if both lists are of the same size
- if (this.internalList.size() != otherUniqueDoctorList.internalList.size()) {
- return false;
- }
-
- // Compare individual doctors in the lists
- for (int i = 0; i < this.internalList.size(); i++) {
- if (!this.internalList.get(i).equals(otherUniqueDoctorList.internalList.get(i))) {
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return internalList.hashCode();
- }
-
- @Override
- public String toString() {
- return internalList.toString();
- }
-
/**
* Returns true if {@code persons} contains only unique persons.
*/
- private boolean personsAreUnique(List persons) {
- for (int i = 0; i < persons.size() - 1; i++) {
- for (int j = i + 1; j < persons.size(); j++) {
- if (persons.get(i).isSamePerson(persons.get(j))) {
+ @Override
+ protected boolean objectsAreUnique(List doctors) {
+ for (int i = 0; i < doctors.size() - 1; i++) {
+ for (int j = i + 1; j < doctors.size(); j++) {
+ if (doctors.get(i).isSamePerson(doctors.get(j))) {
return false;
}
}
@@ -161,3 +128,4 @@ private boolean personsAreUnique(List persons) {
return true;
}
}
+
diff --git a/src/main/java/seedu/address/model/person/UniqueObjectList.java b/src/main/java/seedu/address/model/person/UniqueObjectList.java
new file mode 100644
index 00000000000..433595f2b19
--- /dev/null
+++ b/src/main/java/seedu/address/model/person/UniqueObjectList.java
@@ -0,0 +1,96 @@
+package seedu.address.model.person;
+
+import java.util.Iterator;
+import java.util.List;
+
+import javafx.collections.FXCollections;
+import javafx.collections.ObservableList;
+
+/**
+ * A list of persons that enforces uniqueness between its elements and does not allow nulls.
+ * A person is considered unique by comparing using {@code Person#isSamePerson(Person)}. As such, adding and updating of
+ * persons uses Person#isSamePerson(Person) for equality so as to ensure that the person being added or updated is
+ * unique in terms of identity in the UniquePersonList. However, the removal of a person uses Person#equals(Object) so
+ * as to ensure that the person with exactly the same fields will be removed.
+ *
+ * Supports a minimal set of list operations.
+ *
+ * @see Person#isSamePerson(Person)
+ */
+public abstract class UniqueObjectList implements Iterable {
+
+ protected final ObservableList internalList = FXCollections.observableArrayList();
+ protected final ObservableList internalUnmodifiableList =
+ FXCollections.unmodifiableObservableList(internalList);
+
+ /**
+ * Returns true if the list contains an equivalent person as the given argument.
+ */
+ public abstract boolean contains(T toCheck);
+
+ /**
+ * Adds a person to the list.
+ * The person must not already exist in the list.
+ */
+ public abstract void add(T toAdd);
+
+ /**
+ * Replaces the person {@code target} in the list with {@code editedPerson}.
+ * {@code target} must exist in the list.
+ * The person identity of {@code editedPerson} must not be the same as another existing person in the list.
+ */
+ public abstract void setObject(T target, T editedObject);
+
+ /**
+ * Removes the equivalent person from the list.
+ * The person must exist in the list.
+ */
+ public abstract void remove(T toRemove);
+
+ /**
+ * Replaces the contents of this list with {@code persons}.
+ * {@code persons} must not contain duplicate persons.
+ */
+ public abstract void setObjects(List objects);
+
+ /**
+ * Returns the backing list as an unmodifiable {@code ObservableList}.
+ */
+ public abstract ObservableList asUnmodifiableObservableList();
+
+ @Override
+ public Iterator iterator() {
+ return (Iterator) internalList.iterator();
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (other == this) {
+ return true;
+ }
+
+ // instanceof handles nulls
+ if (!(other instanceof UniqueObjectList)) {
+ return false;
+ }
+
+ UniqueObjectList> otherUniqueObjectList = (UniqueObjectList>) other;
+ return internalList.equals(otherUniqueObjectList.internalList);
+ }
+
+ @Override
+ public int hashCode() {
+ return internalList.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return internalList.toString();
+ }
+
+ /**
+ * Returns true if {@code persons} contains only unique persons.
+ */
+ protected abstract boolean objectsAreUnique(List objects);
+}
+
diff --git a/src/main/java/seedu/address/model/person/UniquePatientList.java b/src/main/java/seedu/address/model/person/UniquePatientList.java
index 0094b9c25c8..35c61e38d55 100644
--- a/src/main/java/seedu/address/model/person/UniquePatientList.java
+++ b/src/main/java/seedu/address/model/person/UniquePatientList.java
@@ -3,7 +3,6 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
-import java.util.Iterator;
import java.util.List;
import javafx.collections.FXCollections;
@@ -22,24 +21,38 @@
*
* @see Person#isSamePerson(Person)
*/
-public class UniquePatientList implements Iterable {
+public class UniquePatientList extends UniqueObjectList {
protected final ObservableList internalList = FXCollections.observableArrayList();
protected final ObservableList internalUnmodifiableList =
FXCollections.unmodifiableObservableList(internalList);
+ public void setPersons(UniquePatientList replacement) {
+ requireNonNull(replacement);
+ internalList.setAll(replacement.internalList);
+ }
+
/**
* Returns true if the list contains an equivalent person as the given argument.
*/
+ @Override
public boolean contains(Patient toCheck) {
requireNonNull(toCheck);
return internalList.stream().anyMatch(toCheck::isSamePerson);
}
+ /**
+ * Returns true if the list contains an equivalent ic as the given argument.
+ */
+ public boolean containsIc(Ic nric) {
+ requireNonNull(nric);
+ return internalList.stream().anyMatch(patient -> patient.getIc().equals(nric));
+ }
/**
* Adds a person to the list.
* The person must not already exist in the list.
*/
+ @Override
public void add(Patient toAdd) {
requireNonNull(toAdd);
if (contains(toAdd)) {
@@ -49,29 +62,31 @@ public void add(Patient toAdd) {
}
/**
- * Replaces the patient {@code target} in the list with {@code editedPerson}.
+ * Replaces the person {@code target} in the list with {@code editedPerson}.
* {@code target} must exist in the list.
* The person identity of {@code editedPerson} must not be the same as another existing person in the list.
*/
- public void setPatient(Patient target, Patient editedPerson) {
- requireAllNonNull(target, editedPerson);
+ @Override
+ public void setObject(Patient target, Patient editedPatient) {
+ requireAllNonNull(target, editedPatient);
int index = internalList.indexOf(target);
if (index == -1) {
throw new PersonNotFoundException();
}
- if (!target.isSamePerson(editedPerson) && contains(editedPerson)) {
+ if (!target.isSamePerson(editedPatient) && contains(editedPatient)) {
throw new DuplicatePersonException();
}
- internalList.set(index, editedPerson);
+ internalList.set(index, editedPatient);
}
/**
* Removes the equivalent person from the list.
* The person must exist in the list.
*/
+ @Override
public void remove(Patient toRemove) {
requireNonNull(toRemove);
if (!internalList.remove(toRemove)) {
@@ -79,79 +94,33 @@ public void remove(Patient toRemove) {
}
}
- public void setPatients(UniquePatientList replacement) {
- requireNonNull(replacement);
- internalList.setAll(replacement.internalList);
- }
-
/**
* Replaces the contents of this list with {@code persons}.
* {@code persons} must not contain duplicate persons.
*/
- public void setPatients(List persons) {
- requireAllNonNull(persons);
- if (!personsAreUnique(persons)) {
+ @Override
+ public void setObjects(List patients) {
+ requireAllNonNull(patients);
+ if (!objectsAreUnique(patients)) {
throw new DuplicatePersonException();
}
- internalList.setAll(persons);
+ internalList.setAll(patients);
}
- /**
- * Returns the backing list as an unmodifiable {@code ObservableList}.
- */
+ @Override
public ObservableList asUnmodifiableObservableList() {
return internalUnmodifiableList;
}
- @Override
- public Iterator iterator() {
- return internalList.iterator();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other == this) {
- return true;
- }
-
- // instanceof handles nulls
- if (!(other instanceof UniquePatientList)) {
- return false;
- }
-
- UniquePatientList otherUniquePatientList = (UniquePatientList) other;
-
- if (this.internalList.size() != otherUniquePatientList.internalList.size()) {
- return false;
- }
-
- // Compare individual patients in the lists
- for (int i = 0; i < this.internalList.size(); i++) {
- if (!this.internalList.get(i).equals(otherUniquePatientList.internalList.get(i))) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- return internalList.hashCode();
- }
-
- @Override
- public String toString() {
- return internalList.toString();
- }
-
/**
* Returns true if {@code persons} contains only unique persons.
*/
- protected boolean personsAreUnique(List persons) {
- for (int i = 0; i < persons.size() - 1; i++) {
- for (int j = i + 1; j < persons.size(); j++) {
- if (persons.get(i).isSamePerson(persons.get(j))) {
+ @Override
+ protected boolean objectsAreUnique(List patients) {
+ for (int i = 0; i < patients.size() - 1; i++) {
+ for (int j = i + 1; j < patients.size(); j++) {
+ if (patients.get(i).isSamePerson(patients.get(j))) {
return false;
}
}
diff --git a/src/main/java/seedu/address/model/person/exceptions/DuplicateObjectException.java b/src/main/java/seedu/address/model/person/exceptions/DuplicateObjectException.java
new file mode 100644
index 00000000000..6a88bc60702
--- /dev/null
+++ b/src/main/java/seedu/address/model/person/exceptions/DuplicateObjectException.java
@@ -0,0 +1,10 @@
+package seedu.address.model.person.exceptions;
+
+/**
+ * Signals that the operation will result in duplicate objects.
+ */
+public class DuplicateObjectException extends RuntimeException {
+ public DuplicateObjectException() {
+ super("Operation would result in duplicate objects");
+ }
+}
diff --git a/src/main/java/seedu/address/model/person/exceptions/ObjectNotFoundException.java b/src/main/java/seedu/address/model/person/exceptions/ObjectNotFoundException.java
new file mode 100644
index 00000000000..c176f7a1b95
--- /dev/null
+++ b/src/main/java/seedu/address/model/person/exceptions/ObjectNotFoundException.java
@@ -0,0 +1,6 @@
+package seedu.address.model.person.exceptions;
+
+/**
+ * Signals that the operation is unable to find the specified object.
+ */
+public class ObjectNotFoundException extends RuntimeException {}
diff --git a/src/main/java/seedu/address/model/tag/Tag.java b/src/main/java/seedu/address/model/tag/Tag.java
index f1a0d4e233b..aa809e36aaa 100644
--- a/src/main/java/seedu/address/model/tag/Tag.java
+++ b/src/main/java/seedu/address/model/tag/Tag.java
@@ -1,16 +1,18 @@
package seedu.address.model.tag;
import static java.util.Objects.requireNonNull;
-import static seedu.address.commons.util.AppUtil.checkArgument;
/**
* Represents a Tag in the address book.
- * Guarantees: immutable; name is valid as declared in {@link #isValidTagName(String)}
+ * Guarantees: immutable; name is valid as declared in {@link #isValidPatientTagName(String)}
*/
public class Tag {
- public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric";
- public static final String VALIDATION_REGEX = "\\p{Alnum}+";
+ public static final String DUPLICATE_TAG = "Doctors should not have duplicate tags!";
+ public static final String EXTRA_PATIENT_TAG = "Each Patient should only have one priority tag!";
+ public static final String INVALID_PATIENT_TAG = "Patient tag should be a valid priority level: Low, Medium or"
+ + " High.";
+ public static final String INVALID_DOCTOR_TAG = "Doctor tag should be a valid specialisation.";
public final String tagName;
@@ -21,15 +23,52 @@ public class Tag {
*/
public Tag(String tagName) {
requireNonNull(tagName);
- checkArgument(isValidTagName(tagName), MESSAGE_CONSTRAINTS);
this.tagName = tagName;
}
/**
- * Returns true if a given string is a valid tag name.
+ * Returns true if a given string is a valid patient tag name.
*/
- public static boolean isValidTagName(String test) {
- return test.matches(VALIDATION_REGEX);
+ public static boolean isValidPatientTagName(String test) {
+ for (ValidPatientTags tag : ValidPatientTags.values()) {
+ if (tag.name().equals(test)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if a given string is a valid patient tag name.
+ */
+ public static boolean isValidFullPatientTagName(String test) {
+ for (ValidPatientTags tag : ValidPatientTags.values()) {
+ String fullTagName = "priority: " + tag;
+ if (fullTagName.equals(test)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if a given string is a valid doctor tag name.
+ */
+ public static boolean isValidDoctorTagName(String test) {
+ for (ValidDoctorTags tag : ValidDoctorTags.values()) {
+ if (tag.name().equals(test)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isValidPatientTag() {
+ return isValidFullPatientTagName(tagName);
+ }
+
+ public boolean isValidDoctorTag() {
+ return isValidDoctorTagName(tagName);
}
@Override
diff --git a/src/main/java/seedu/address/model/tag/ValidDoctorTags.java b/src/main/java/seedu/address/model/tag/ValidDoctorTags.java
new file mode 100644
index 00000000000..9edea624241
--- /dev/null
+++ b/src/main/java/seedu/address/model/tag/ValidDoctorTags.java
@@ -0,0 +1,9 @@
+package seedu.address.model.tag;
+
+/**
+ * Enumeration of valid doctor specializations for doctor tags.
+ * These specializations are used to categorize doctors by their field of expertise.
+ */
+public enum ValidDoctorTags {
+ CARDIOLOGIST, ORTHOPEDIC, PEDIATRICIAN, DERMATOLOGIST, NEUROLOGIST, GENERAL_PRACTITIONER, PSYCHIATRIST, SURGEON
+}
diff --git a/src/main/java/seedu/address/model/tag/ValidPatientTags.java b/src/main/java/seedu/address/model/tag/ValidPatientTags.java
new file mode 100644
index 00000000000..f41e4417842
--- /dev/null
+++ b/src/main/java/seedu/address/model/tag/ValidPatientTags.java
@@ -0,0 +1,8 @@
+package seedu.address.model.tag;
+
+/**
+ * Enumeration of valid priority levels for patient tags.
+ */
+public enum ValidPatientTags {
+ LOW, MEDIUM, HIGH
+}
diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java
index 110b04ce12e..2ab58e94d91 100644
--- a/src/main/java/seedu/address/model/util/SampleDataUtil.java
+++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java
@@ -1,6 +1,5 @@
package seedu.address.model.util;
-import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@@ -9,6 +8,7 @@
import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.appointment.Appointment;
+import seedu.address.model.appointment.AppointmentTime;
import seedu.address.model.person.Address;
import seedu.address.model.person.BloodType;
import seedu.address.model.person.Condition;
@@ -30,11 +30,11 @@ public class SampleDataUtil {
public static final Remark EMPTY_REMARK = new Remark("");
public static final Set EMPTY_APPOINTMENTS = new HashSet<>();
public static final Appointment APPOINTMENT_1 = new Appointment(new Ic("S8811111Z"),
- new Ic("S1111111Z"), LocalDateTime.parse("2023-10-31T14:00"));
+ new Ic("S1111111Z"), new AppointmentTime("2023-10-31 14:00"));
public static final Appointment APPOINTMENT_2 = new Appointment(new Ic("S8811112Z"),
- new Ic("S1111111Z"), LocalDateTime.parse("2023-10-31T15:00"));
+ new Ic("S1111111Z"), new AppointmentTime("2023-10-31 15:00"));
public static final Appointment APPOINTMENT_3 = new Appointment(new Ic("S8811112Z"),
- new Ic("S1111112Z"), LocalDateTime.parse("2023-10-31T16:00"));
+ new Ic("S1111112Z"), new AppointmentTime("2023-10-31 16:00"));
// persons should not be used anymore
public static Patient[] getSamplePatients() {
@@ -43,30 +43,30 @@ public static Patient[] getSamplePatients() {
new Email("alexyeoh@example.com"), new Address("Blk 30 Geylang Street 29, #06-40"),
EMPTY_REMARK, new Gender("M"), new Ic("S1111111Z"), new Condition("Unknown"),
new BloodType("O+"), getAppointmentSet(APPOINTMENT_1, APPOINTMENT_2),
- getTagSet("friends")),
+ getTagSet("priority: LOW")),
new Patient(new Name("Bernice Yu"), new Phone("99272758"), new Phone("87438807"),
new Email("berniceyu@example.com"), new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"),
EMPTY_REMARK, new Gender("F"), new Ic("S1111112Z"), new Condition("Unknown"),
new BloodType("O+"), getAppointmentSet(APPOINTMENT_3),
- getTagSet("colleagues", "friends")),
+ getTagSet("priority: LOW")),
new Patient(new Name("Charlotte Oliveiro"), new Phone("93210283"), new Phone("87438807"),
new Email("charlotte@example.com"), new Address("Blk 11 Ang Mo Kio Street 74, #11-04"),
EMPTY_REMARK, new Gender("F"), new Ic("S1111113Z"), new Condition("Unknown"),
new BloodType("O+"), EMPTY_APPOINTMENTS,
- getTagSet("neighbours")),
+ getTagSet("priority: MEDIUM")),
new Patient(new Name("David Li"), new Phone("91031282"), new Phone("87438807"),
new Email("lidavid@example.com"), new Address("Blk 436 Serangoon Gardens Street 26, #16-43"),
EMPTY_REMARK, new Gender("M"), new Ic("S1111114Z"), new Condition("Unknown"),
new BloodType("O+"), EMPTY_APPOINTMENTS,
- getTagSet("family")),
+ getTagSet("priority: MEDIUM")),
new Patient(new Name("Irfan Ibrahim"), new Phone("92492021"), new Phone("87438807"),
new Email("irfan@example.com"), new Address("Blk 47 Tampines Street 20, #17-35"), EMPTY_REMARK,
new Gender("M"), new Ic("S1111115Z"), new Condition("Unknown"), new BloodType("O+"),
- EMPTY_APPOINTMENTS, getTagSet("classmates")),
+ EMPTY_APPOINTMENTS, getTagSet("priority: LOW")),
new Patient(new Name("Roy Balakrishnan"), new Phone("92624417"), new Phone("87438807"),
new Email("royb@example.com"), new Address("Blk 45 Aljunied Street 85, #11-31"), EMPTY_REMARK,
new Gender("M"), new Ic("S1111116Z"), new Condition("Unknown"), new BloodType("O+"),
- EMPTY_APPOINTMENTS, getTagSet("colleagues"))
+ EMPTY_APPOINTMENTS, getTagSet("priority: HIGH"))
};
}
@@ -74,22 +74,30 @@ public static Doctor[] getSampleDoctors() {
return new Doctor[] {
new Doctor(new Name("Adam Lim"), new Phone("87438000"), new Email("adamlim@example.com"),
new Address("Blk 30 Geylang Street 29, #06-40"), EMPTY_REMARK, new Gender("M"),
- new Ic("S8811111Z"), getAppointmentSet(APPOINTMENT_1), getTagSet("GP")),
+ new Ic("S8811111Z"), getAppointmentSet(APPOINTMENT_1), getTagSet("SURGEON")),
new Doctor(new Name("Bernard Tan"), new Phone("99272000"), new Email("bernardtan@example.com"),
new Address("Blk 30 Lorong 3 Serangoon Gardens, #07-18"), EMPTY_REMARK, new Gender("M"),
new Ic("S8811112Z"), getAppointmentSet(APPOINTMENT_2, APPOINTMENT_3),
- getTagSet("ENTspecialist"))
+ getTagSet("CARDIOLOGIST"))
};
}
+ public static Appointment[] getSampleAppointments() {
+ return new Appointment[] {APPOINTMENT_1, APPOINTMENT_2, APPOINTMENT_3};
+ }
+
public static ReadOnlyAddressBook getSampleAddressBook() {
AddressBook sampleAb = new AddressBook();
for (Patient samplePatient : getSamplePatients()) {
sampleAb.addPatient(samplePatient);
}
+
for (Doctor sampleDoctor : getSampleDoctors()) {
sampleAb.addDoctor(sampleDoctor);
}
+ for (Appointment sampleAppointment : getSampleAppointments()) {
+ sampleAb.addAppointment(sampleAppointment);
+ }
return sampleAb;
}
diff --git a/src/main/java/seedu/address/storage/JsonAdaptedAppointment.java b/src/main/java/seedu/address/storage/JsonAdaptedAppointment.java
index dbe0e03deb3..816c2936201 100644
--- a/src/main/java/seedu/address/storage/JsonAdaptedAppointment.java
+++ b/src/main/java/seedu/address/storage/JsonAdaptedAppointment.java
@@ -1,14 +1,11 @@
package seedu.address.storage;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
-
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.appointment.AppointmentTime;
import seedu.address.model.person.Ic;
/**
@@ -17,14 +14,11 @@
class JsonAdaptedAppointment {
public static final String MISSING_FIELD_MESSAGE_FORMAT = "Appointment's %s field is missing!";
- public static final String INVALID_FIELD_MESSAGE_FORMAT = "Appointment's %s field is invalid!";
public static final String DUPLICATE_PATIENT_AND_DOCTOR_IC =
"Appointment's doctor IC and patients IC are the same!";
- private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
private final String doctorIc;
private final String patientIc;
private final String appointmentTime;
- private final String status;
/**
* Constructs a {@code JsonAdaptedTag} with the given {@code tagName}.
@@ -32,12 +26,10 @@ class JsonAdaptedAppointment {
@JsonCreator
public JsonAdaptedAppointment(@JsonProperty("doctorIc") String doctorIc,
@JsonProperty("patientIc") String patientIc,
- @JsonProperty("appointmentTime") String appointmentTime,
- @JsonProperty("status") String status) {
+ @JsonProperty("appointmentTime") String appointmentTime) {
this.doctorIc = doctorIc;
this.patientIc = patientIc;
this.appointmentTime = appointmentTime;
- this.status = status;
}
/**
@@ -46,30 +38,18 @@ public JsonAdaptedAppointment(@JsonProperty("doctorIc") String doctorIc,
public JsonAdaptedAppointment(Appointment source) {
doctorIc = source.getDoctor().value;
patientIc = source.getPatient().value;
- appointmentTime = source.getAppointmentTime().format(formatter);
- status = source.getStatus();
- }
-
- public String checkStatus() throws IllegalValueException {
- if (status == null) {
- throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, "Status"));
- }
- return status;
+ appointmentTime = source.getAppointmentTime().toString();
}
- public LocalDateTime checkAppointmentTime() throws IllegalValueException {
+ public AppointmentTime checkAppointmentTime() throws IllegalValueException {
if (appointmentTime == null) {
throw new IllegalValueException(
- String.format(MISSING_FIELD_MESSAGE_FORMAT, LocalDateTime.class.getSimpleName()));
+ String.format(MISSING_FIELD_MESSAGE_FORMAT, AppointmentTime.class.getSimpleName()));
}
- LocalDateTime result;
- try {
- result = LocalDateTime.parse(appointmentTime, formatter);
- } catch (DateTimeParseException e) {
- throw new IllegalValueException(String.format(INVALID_FIELD_MESSAGE_FORMAT,
- LocalDateTime.class.getSimpleName()));
+ if (!AppointmentTime.isValidAppointmentTime(appointmentTime)) {
+ throw new IllegalValueException(AppointmentTime.MESSAGE_CONSTRAINTS);
}
- return result;
+ return new AppointmentTime(appointmentTime);
}
/**
@@ -100,9 +80,8 @@ public Appointment toModelType() throws IllegalValueException {
}
final Ic modelDoctor = checkIc(doctorIc);
final Ic modelPatient = checkIc(patientIc);
- final LocalDateTime modelAppointmentTime = checkAppointmentTime();
- final String modelStatus = checkStatus();
- return new Appointment(modelDoctor, modelPatient, modelAppointmentTime, modelStatus);
+ final AppointmentTime modelAppointmentTime = checkAppointmentTime();
+ return new Appointment(modelDoctor, modelPatient, modelAppointmentTime);
}
}
diff --git a/src/main/java/seedu/address/storage/JsonAdaptedDoctor.java b/src/main/java/seedu/address/storage/JsonAdaptedDoctor.java
index 0ff9dd2a57d..4b9ad0b9db3 100644
--- a/src/main/java/seedu/address/storage/JsonAdaptedDoctor.java
+++ b/src/main/java/seedu/address/storage/JsonAdaptedDoctor.java
@@ -1,13 +1,24 @@
package seedu.address.storage;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
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.Address;
import seedu.address.model.person.Doctor;
-import seedu.address.model.person.Person;
+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.Phone;
+import seedu.address.model.person.Remark;
+import seedu.address.model.tag.Tag;
/**
@@ -30,7 +41,7 @@ public JsonAdaptedDoctor(@JsonProperty("name") String name, @JsonProperty("phone
}
/**
- * Converts a given {@code Person} into this class for Jackson use.
+ * Converts a given {@code Doctor} into this class for Jackson use.
*/
public JsonAdaptedDoctor(Doctor source) {
super(source);
@@ -42,10 +53,21 @@ public JsonAdaptedDoctor(Doctor source) {
* @throws IllegalValueException if there were any data constraints violated in the adapted person.
*/
public Doctor toModelType() throws IllegalValueException {
- Person p = super.toModelType();
-
- Doctor modelDoctor = new Doctor(p.getName(), p.getPhone(), p.getEmail(), p.getAddress(), p.getRemark(),
- p.getGender(), p.getIc(), p.getAppointments(), p.getTags());
- return modelDoctor;
+ final Name modelName = checkName();
+ final Phone modelPhone = checkPhone();
+ final Email modelEmail = checkEmail();
+ final Address modelAddress = checkAddress();
+ final Remark modelRemark = checkRemark();
+ final Gender modelGender = checkGender();
+ final Ic modelIc = checkIc();
+ final List personTags = new ArrayList<>();
+ for (JsonAdaptedTag tag : this.getTags()) {
+ personTags.add(tag.toModelDoctorType());
+ }
+ final Set modelTags = new HashSet<>(personTags);
+ final List personAppointments = checkAppointments();
+ final Set modelAppointments = new HashSet<>(personAppointments);
+ return new Doctor(modelName, modelPhone, modelEmail, modelAddress, modelRemark, modelGender, modelIc,
+ modelAppointments, modelTags);
}
}
diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPatient.java b/src/main/java/seedu/address/storage/JsonAdaptedPatient.java
index 27cbd3fa325..b8d3739ff45 100644
--- a/src/main/java/seedu/address/storage/JsonAdaptedPatient.java
+++ b/src/main/java/seedu/address/storage/JsonAdaptedPatient.java
@@ -1,21 +1,31 @@
package seedu.address.storage;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
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.Address;
import seedu.address.model.person.BloodType;
import seedu.address.model.person.Condition;
+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.Patient;
-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 Patient}.
*/
-class JsonAdaptedPatient extends JsonAdaptedPerson {
+public class JsonAdaptedPatient extends JsonAdaptedPerson {
public static final String MISSING_FIELD_MESSAGE_FORMAT = "Patient's %s field is missing!";
@@ -56,17 +66,25 @@ public JsonAdaptedPatient(Patient source) {
* @throws IllegalValueException if there were any data constraints violated in the adapted person.
*/
public Patient toModelType() throws IllegalValueException {
- Person p = super.toModelType();
-
+ final Name modelName = checkName();
+ final Phone modelPhone = checkPhone();
final Phone modelEmergencyContact = checkEmergencyContact();
+ final Email modelEmail = checkEmail();
+ final Address modelAddress = checkAddress();
+ final Remark modelRemark = checkRemark();
+ final Gender modelGender = checkGender();
+ final Ic modelIc = checkIc();
+ final List personTags = new ArrayList<>();
+ for (JsonAdaptedTag tag : this.getTags()) {
+ personTags.add(tag.toModelPatientType());
+ }
+ final Set modelTags = new HashSet<>(personTags);
final Condition modelCondition = checkCondition();
final BloodType modelBloodType = checkBloodType();
-
- Patient modelPatient = new Patient(p.getName(), p.getPhone(), modelEmergencyContact, p.getEmail(),
- p.getAddress(), p.getRemark(), p.getGender(), p.getIc(), modelCondition, modelBloodType,
- p.getAppointments(), p.getTags());
-
- return modelPatient;
+ final List personAppointments = checkAppointments();
+ final Set modelAppointments = new HashSet<>(personAppointments);
+ return new Patient(modelName, modelPhone, modelEmergencyContact, modelEmail, modelAddress, modelRemark,
+ modelGender, modelIc, modelCondition, modelBloodType, modelAppointments, modelTags);
}
/**
diff --git a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java
index 3b148004f3c..2756b3d1969 100644
--- a/src/main/java/seedu/address/storage/JsonAdaptedPerson.java
+++ b/src/main/java/seedu/address/storage/JsonAdaptedPerson.java
@@ -1,9 +1,7 @@
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;
@@ -19,14 +17,18 @@
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 Person}.
*/
-class JsonAdaptedPerson {
+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;
@@ -83,27 +85,16 @@ public JsonAdaptedPerson(Person source) {
}
/**
- * Converts this Jackson-friendly adapted person object into the model's {@code Person} object.
+ * Gives the list of tags of the Person.
*
- * @throws IllegalValueException if there were any data constraints violated in the adapted person.
+ * @return a List of JsonAdaptedTags
*/
- public Person toModelType() throws IllegalValueException {
- final List personTags = new ArrayList<>();
- for (JsonAdaptedTag tag : tags) {
- personTags.add(tag.toModelType());
- }
-
- final Set modelTags = new HashSet<>(personTags);
- final Set modelAppointments = new HashSet<>(checkAppointments());
- final Name modelName = checkName();
- final Phone modelPhone = checkPhone();
- final Email modelEmail = checkEmail();
- final Address modelAddress = checkAddress();
- final Remark modelRemark = checkRemark();
- final Gender modelGender = checkGender();
- final Ic modelIc = checkIc();
- return new Person(modelName, modelPhone, modelEmail, modelAddress, modelRemark, modelGender, modelIc,
- modelAppointments, modelTags);
+ public List getTags() {
+ return this.tags;
+ }
+
+ public List getAppointments() {
+ return this.appointments;
}
/**
@@ -112,7 +103,7 @@ public Person toModelType() throws IllegalValueException {
* @return a valid name object.
* @throws IllegalValueException if name is not valid.
*/
- private Name checkName() throws IllegalValueException {
+ public Name checkName() throws IllegalValueException {
if (name == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName()));
}
@@ -128,7 +119,7 @@ private Name checkName() throws IllegalValueException {
* @return a valid phone object.
* @throws IllegalValueException if phone is not valid.
*/
- private Phone checkPhone() throws IllegalValueException {
+ public Phone checkPhone() throws IllegalValueException {
if (phone == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName()));
}
@@ -144,7 +135,7 @@ private Phone checkPhone() throws IllegalValueException {
* @return a valid email object.
* @throws IllegalValueException if email is not valid.
*/
- private Email checkEmail() throws IllegalValueException {
+ public Email checkEmail() throws IllegalValueException {
if (email == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName()));
}
@@ -160,7 +151,7 @@ private Email checkEmail() throws IllegalValueException {
* @return a valid address
* @throws IllegalValueException if address is not valid.
*/
- private Address checkAddress() throws IllegalValueException {
+ public Address checkAddress() throws IllegalValueException {
if (address == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName()));
}
@@ -176,7 +167,7 @@ private Address checkAddress() throws IllegalValueException {
* @return a valid remark
* @throws IllegalValueException if remark is not valid.
*/
- private Remark checkRemark() throws IllegalValueException {
+ public Remark checkRemark() throws IllegalValueException {
if (remark == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Remark.class.getSimpleName()));
}
@@ -189,7 +180,7 @@ private Remark checkRemark() throws IllegalValueException {
* @return a valid gender
* @throws IllegalValueException if gender is not valid.
*/
- private Gender checkGender() throws IllegalValueException {
+ public Gender checkGender() throws IllegalValueException {
if (gender == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Gender.class.getSimpleName()));
}
@@ -205,7 +196,7 @@ private Gender checkGender() throws IllegalValueException {
* @return a valid ic
* @throws IllegalValueException if ic is not valid.
*/
- private Ic checkIc() throws IllegalValueException {
+ public Ic checkIc() throws IllegalValueException {
if (ic == null) {
throw new IllegalValueException(String.format(MISSING_FIELD_MESSAGE_FORMAT, Ic.class.getSimpleName()));
}
@@ -215,7 +206,14 @@ private Ic checkIc() throws IllegalValueException {
return new Ic(ic);
}
- private List checkAppointments() 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
+ */
+ public List checkAppointments() throws IllegalValueException {
final List listOfAppointments = new ArrayList<>();
for (JsonAdaptedAppointment appointment : appointments) {
listOfAppointments.add(appointment.toModelType());
diff --git a/src/main/java/seedu/address/storage/JsonAdaptedTag.java b/src/main/java/seedu/address/storage/JsonAdaptedTag.java
index 0df22bdb754..da63271c38d 100644
--- a/src/main/java/seedu/address/storage/JsonAdaptedTag.java
+++ b/src/main/java/seedu/address/storage/JsonAdaptedTag.java
@@ -38,9 +38,16 @@ public String getTagName() {
*
* @throws IllegalValueException if there were any data constraints violated in the adapted tag.
*/
- public Tag toModelType() throws IllegalValueException {
- if (!Tag.isValidTagName(tagName)) {
- throw new IllegalValueException(Tag.MESSAGE_CONSTRAINTS);
+ public Tag toModelPatientType() throws IllegalValueException {
+ if (!Tag.isValidFullPatientTagName(tagName)) {
+ throw new IllegalValueException(Tag.INVALID_PATIENT_TAG);
+ }
+ return new Tag(tagName);
+ }
+
+ public Tag toModelDoctorType() throws IllegalValueException {
+ if (!Tag.isValidDoctorTagName(tagName)) {
+ throw new IllegalValueException(Tag.INVALID_DOCTOR_TAG);
}
return new Tag(tagName);
}
diff --git a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java
index df089a0a0db..ba333e8bab1 100644
--- a/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java
+++ b/src/main/java/seedu/address/storage/JsonSerializableAddressBook.java
@@ -11,6 +11,7 @@
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.AddressBook;
import seedu.address.model.ReadOnlyAddressBook;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
import seedu.address.model.person.Patient;
@@ -21,18 +22,22 @@
class JsonSerializableAddressBook {
public static final String MESSAGE_DUPLICATE_DOCTOR = "Doctors list contains duplicate doctor(s).";
public static final String MESSAGE_DUPLICATE_PATIENT = "Patients list contains duplicate patient(s).";
+ public static final String MESSAGE_DUPLICATE_APPOINTMENT = "Appointments list contains duplicate appointments";
private final List doctors = new ArrayList<>();
private final List patients = new ArrayList<>();
+ private final List appointments = new ArrayList<>();
/**
* Constructs a {@code JsonSerializableAddressBook} with the given persons.
*/
@JsonCreator
public JsonSerializableAddressBook(@JsonProperty("patients") List patients,
- @JsonProperty("doctors") List doctors) {
+ @JsonProperty("doctors") List doctors,
+ @JsonProperty("appointments") List appointments) {
this.doctors.addAll(doctors);
this.patients.addAll(patients);
+ this.appointments.addAll(appointments);
}
/**
@@ -43,6 +48,8 @@ public JsonSerializableAddressBook(@JsonProperty("patients") List {
+
+ private static final String FXML = "AppointmentListCard.fxml";
+ private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
+
+ /**
+ * Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX.
+ * As a consequence, UI elements' variable names cannot be set to such keywords
+ * or an exception will be thrown by JavaFX during runtime.
+ *
+ * @see The issue on AddressBook level 4
+ */
+ public final Appointment appointment;
+
+ @FXML
+ private HBox cardPane;
+ @FXML
+ private Label id;
+ @FXML
+ private Label patientIc;
+ @FXML
+ private Label doctorIc;
+ @FXML
+ private Label appointmentTime;
+
+ /**
+ * Creates a {@code PersonCode} with the given {@code Person} and index to display.
+ */
+ public AppointmentCard(Appointment appointment, int displayedIndex) {
+ super(FXML);
+ this.appointment = appointment;
+ id.setText("APPOINTMENT " + displayedIndex);
+ patientIc.setText("Patient IC: " + this.appointment.getPatient().toString());
+ doctorIc.setText("Doctor IC: " + this.appointment.getDoctor().toString());
+ appointmentTime.setText("Time of appointment: " + this.appointment.getAppointmentTime().toString());
+ }
+}
diff --git a/src/main/java/seedu/address/ui/AppointmentListPanel.java b/src/main/java/seedu/address/ui/AppointmentListPanel.java
new file mode 100644
index 00000000000..0399c8d346f
--- /dev/null
+++ b/src/main/java/seedu/address/ui/AppointmentListPanel.java
@@ -0,0 +1,49 @@
+package seedu.address.ui;
+
+import java.util.logging.Logger;
+
+import javafx.collections.ObservableList;
+import javafx.fxml.FXML;
+import javafx.scene.control.ListCell;
+import javafx.scene.control.ListView;
+import javafx.scene.layout.Region;
+import seedu.address.commons.core.LogsCenter;
+import seedu.address.model.appointment.Appointment;
+
+/**
+ * Panel containing the list of persons.
+ */
+public class AppointmentListPanel extends UiPart {
+ private static final String FXML = "AppointmentListPanel.fxml";
+ private final Logger logger = LogsCenter.getLogger(AppointmentListPanel.class);
+
+ @FXML
+ private ListView appointmentListView;
+
+ /**
+ * Creates a {@code AppointmentListPanel} with the given {@code ObservableList}.
+ */
+ public AppointmentListPanel(ObservableList appointmentList) {
+ super(FXML);
+ appointmentListView.setItems(appointmentList);
+ appointmentListView.setCellFactory(listView -> new AppointmentListViewCell());
+ }
+
+ /**
+ * Custom {@code ListCell} that displays the graphics of a {@code Patient} using a {@code PatientCard}.
+ */
+ class AppointmentListViewCell extends ListCell {
+ @Override
+ protected void updateItem(Appointment appointment, boolean empty) {
+ super.updateItem(appointment, empty);
+
+ if (empty || appointment == null) {
+ setGraphic(null);
+ setText(null);
+ } else {
+ setGraphic(new AppointmentCard(appointment, getIndex() + 1).getRoot());
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/seedu/address/ui/DoctorCard.java b/src/main/java/seedu/address/ui/DoctorCard.java
index a1adde8421a..f876a7e479f 100644
--- a/src/main/java/seedu/address/ui/DoctorCard.java
+++ b/src/main/java/seedu/address/ui/DoctorCard.java
@@ -7,7 +7,6 @@
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;
@@ -42,8 +41,6 @@ public class DoctorCard extends UiPart {
@FXML
private FlowPane tags;
@FXML
- private FlowPane appointments;
- @FXML
private Label remark;
@FXML
private Label gender;
@@ -67,10 +64,5 @@ 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 with Patient: " + appointment.getPatient() + " at "
- + appointment.getAppointmentTime().format(Appointment.FORMATTER))));
}
}
diff --git a/src/main/java/seedu/address/ui/HelpWindow.java b/src/main/java/seedu/address/ui/HelpWindow.java
index 3f16b2fcf26..fc100dc5c9d 100644
--- a/src/main/java/seedu/address/ui/HelpWindow.java
+++ b/src/main/java/seedu/address/ui/HelpWindow.java
@@ -15,7 +15,7 @@
*/
public class HelpWindow extends UiPart {
- public static final String USERGUIDE_URL = "https://se-education.org/addressbook-level3/UserGuide.html";
+ public static final String USERGUIDE_URL = "https://ay2324s1-cs2103t-t09-3.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);
@@ -46,6 +46,7 @@ public HelpWindow() {
/**
* Shows the help window.
+ *
* @throws IllegalStateException
*
*
diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java
index 2aa4dd264a3..ce53afcc6e9 100644
--- a/src/main/java/seedu/address/ui/MainWindow.java
+++ b/src/main/java/seedu/address/ui/MainWindow.java
@@ -33,6 +33,7 @@ public class MainWindow extends UiPart {
// Independent Ui parts residing in this Ui container
private DoctorListPanel doctorListPanel;
private PatientListPanel patientListPanel;
+ private AppointmentListPanel appointmentListPanel;
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;
@@ -46,6 +47,8 @@ public class MainWindow extends UiPart {
private StackPane doctorListPanelPlaceholder;
@FXML
private StackPane patientListPanelPlaceholder;
+ @FXML
+ private StackPane appointmentListPanelPlaceholder;
@FXML
private StackPane resultDisplayPlaceholder;
@@ -118,7 +121,8 @@ void fillInnerParts() {
patientListPanelPlaceholder.getChildren().add(patientListPanel.getRoot());
doctorListPanel = new DoctorListPanel(logic.getFilteredDoctorList());
doctorListPanelPlaceholder.getChildren().add(doctorListPanel.getRoot());
-
+ appointmentListPanel = new AppointmentListPanel(logic.getFilteredAppointmentList());
+ appointmentListPanelPlaceholder.getChildren().add(appointmentListPanel.getRoot());
resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());
diff --git a/src/main/java/seedu/address/ui/PatientCard.java b/src/main/java/seedu/address/ui/PatientCard.java
index 9bf55822534..7309c387bcc 100644
--- a/src/main/java/seedu/address/ui/PatientCard.java
+++ b/src/main/java/seedu/address/ui/PatientCard.java
@@ -7,7 +7,6 @@
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;
/**
@@ -42,8 +41,6 @@ public class PatientCard extends UiPart {
@FXML
private FlowPane tags;
@FXML
- private FlowPane appointments;
- @FXML
private Label remark;
@FXML
private Label gender;
@@ -73,12 +70,6 @@ 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 with Doctor: " + appointment.getDoctor() + " at "
- + appointment.getAppointmentTime().format(Appointment.FORMATTER))));
-
condition.setText("Condition: " + person.getCondition().value);
bloodType.setText("Blood Type: " + person.getBloodType().value);
emergencyContact.setText("Emergency Contact: " + person.getEmergencyContact().value);
diff --git a/src/main/resources/view/AppointmentListCard.fxml b/src/main/resources/view/AppointmentListCard.fxml
new file mode 100644
index 00000000000..78dca91284c
--- /dev/null
+++ b/src/main/resources/view/AppointmentListCard.fxml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/view/AppointmentListPanel.fxml b/src/main/resources/view/AppointmentListPanel.fxml
new file mode 100644
index 00000000000..35b3d93ce99
--- /dev/null
+++ b/src/main/resources/view/AppointmentListPanel.fxml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css
index dab8ae35182..4e06ce35733 100644
--- a/src/main/resources/view/DarkTheme.css
+++ b/src/main/resources/view/DarkTheme.css
@@ -1,39 +1,39 @@
.background {
- -fx-background-color: derive(#1d1d1d, 20%);
- background-color: #383838; /* Used in the default.html file */
+ -fx-background-color: #f0f0f0; /* Light gray background */
+ background-color: #e6e6e6; /* Slightly darker gray */
}
.label {
-fx-font-size: 11pt;
- -fx-font-family: "Segoe UI Semibold";
- -fx-text-fill: #555555;
+ -fx-font-family: "Arial", Helvetica, sans-serif;
+ -fx-text-fill: #333333; /* Dark gray text */
-fx-opacity: 0.9;
}
.label-bright {
-fx-font-size: 11pt;
- -fx-font-family: "Segoe UI Semibold";
- -fx-text-fill: white;
+ -fx-font-family: "Arial", Helvetica, sans-serif;
+ -fx-text-fill: #0088cc; /* Blue text */
-fx-opacity: 1;
}
.label-header {
-fx-font-size: 32pt;
- -fx-font-family: "Segoe UI Light";
- -fx-text-fill: white;
+ -fx-font-family: "Arial", Helvetica, sans-serif;
+ -fx-text-fill: #0088cc; /* Blue text */
-fx-opacity: 1;
}
.label-list-header {
-fx-font-size: 24pt;
- -fx-font-family: "Segoe UI Light";
- -fx-text-fill: white;
+ -fx-font-family: "Arial", Helvetica, sans-serif;
+ -fx-text-fill: #0088cc; /* Blue text */
-fx-opacity: 1;
}
.text-field {
-fx-font-size: 12pt;
- -fx-font-family: "Segoe UI Semibold";
+ -fx-font-family: "Arial", Helvetica, sans-serif;
}
.tab-pane {
@@ -47,9 +47,9 @@
}
.table-view {
- -fx-base: #1d1d1d;
- -fx-control-inner-background: #1d1d1d;
- -fx-background-color: #1d1d1d;
+ -fx-base: #f0f0f0; /* Light gray background */
+ -fx-control-inner-background: #f0f0f0; /* Light gray background */
+ -fx-background-color: #f0f0f0; /* Light gray background */
-fx-table-cell-border-color: transparent;
-fx-table-header-border-color: transparent;
-fx-padding: 5;
@@ -66,38 +66,38 @@
-fx-border-color:
transparent
transparent
- derive(-fx-base, 80%)
+ #0088cc
transparent;
-fx-border-insets: 0 10 1 0;
}
.table-view .column-header .label {
-fx-font-size: 20pt;
- -fx-font-family: "Segoe UI Light";
- -fx-text-fill: white;
+ -fx-font-family: "Arial", Helvetica, sans-serif;
+ -fx-text-fill: #0088cc; /* Blue text */
-fx-alignment: center-left;
-fx-opacity: 1;
}
.table-view:focused .table-row-cell:filled:focused:selected {
- -fx-background-color: -fx-focus-color;
+ -fx-background-color: #0088cc; /* Blue background */
}
.split-pane:horizontal .split-pane-divider {
- -fx-background-color: derive(#1d1d1d, 20%);
- -fx-border-color: transparent transparent transparent #4d4d4d;
+ -fx-background-color: #f0f0f0; /* Light gray background */
+ -fx-border-color: transparent transparent transparent #0088cc; /* Blue border */
}
.split-pane {
-fx-border-radius: 1;
-fx-border-width: 1;
- -fx-background-color: derive(#1d1d1d, 20%);
+ -fx-background-color: #f0f0f0; /* Light gray background */
}
.list-view {
-fx-background-insets: 0;
-fx-padding: 0;
- -fx-background-color: derive(#1d1d1d, 20%);
+ -fx-background-color: #f0f0f0; /* Light gray background */
}
.list-cell {
@@ -107,63 +107,63 @@
}
.list-cell:filled:even {
- -fx-background-color: #3c3e3f;
+ -fx-background-color: #e6e6e6; /* Slightly darker gray background */
}
.list-cell:filled:odd {
- -fx-background-color: #515658;
+ -fx-background-color: #f0f0f0; /* Light gray background */
}
.list-cell:filled:selected {
- -fx-background-color: #424d5f;
+ -fx-background-color: #ADD8E6; /* Blue background */
}
.list-cell:filled:selected #cardPane {
- -fx-border-color: #3e7b91;
+ -fx-border-color: #0088cc; /* Blue border */
-fx-border-width: 1;
}
.list-cell .label {
- -fx-text-fill: white;
+ -fx-text-fill: #333333; /* Dark gray text */
}
.cell_big_label {
- -fx-font-family: "Segoe UI Semibold";
+ -fx-font-family: "Arial", Helvetica, sans-serif;
-fx-font-size: 16px;
- -fx-text-fill: #010504;
+ -fx-text-fill: #333333; /* Dark gray text */
}
.cell_small_label {
- -fx-font-family: "Segoe UI";
+ -fx-font-family: "Arial", Helvetica, sans-serif;
-fx-font-size: 13px;
- -fx-text-fill: #010504;
+ -fx-text-fill: #333333; /* Dark gray text */
}
.stack-pane {
- -fx-background-color: derive(#1d1d1d, 20%);
+ -fx-background-color: #f0f0f0; /* Light gray background */
}
.pane-with-border {
- -fx-background-color: derive(#1d1d1d, 20%);
- -fx-border-color: derive(#1d1d1d, 10%);
+ -fx-background-color: #f0f0f0; /* Light gray background */
+ -fx-border-color: #0088cc; /* Blue border */
-fx-border-top-width: 1px;
}
.pane-with-white-border {
- -fx-background-color: derive(#1d1d1d, 20%);
- -fx-border-color: white;
+ -fx-background-color: #f0f0f0; /* Light gray background */
+ -fx-border-color: white; /* White border */
-fx-border-top-width: 1px;
}
.status-bar {
- -fx-background-color: derive(#1d1d1d, 30%);
+ -fx-background-color: #e6e6e6; /* Slightly darker gray background */
}
.result-display {
-fx-background-color: transparent;
- -fx-font-family: "Segoe UI Light";
+ -fx-font-family: "Arial", Helvetica, sans-serif;
-fx-font-size: 13pt;
- -fx-text-fill: white;
+ -fx-text-fill: #0088cc; /* Blue text */
}
.result-display .label {
@@ -171,79 +171,74 @@
}
.status-bar .label {
- -fx-font-family: "Segoe UI Light";
- -fx-text-fill: white;
+ -fx-font-family: "Arial", Helvetica, sans-serif;
+ -fx-text-fill: #333333; /* Dark gray text */
-fx-padding: 4px;
-fx-pref-height: 30px;
}
.status-bar-with-border {
- -fx-background-color: derive(#1d1d1d, 30%);
- -fx-border-color: derive(#1d1d1d, 25%);
+ -fx-background-color: #e6e6e6; /* Slightly darker gray background */
+ -fx-border-color: #d8d8d8; /* Light gray border */
-fx-border-width: 1px;
}
.status-bar-with-border .label {
- -fx-text-fill: white;
+ -fx-text-fill: #333333; /* Dark gray text */
}
.grid-pane {
- -fx-background-color: derive(#1d1d1d, 30%);
- -fx-border-color: derive(#1d1d1d, 30%);
+ -fx-background-color: #e6e6e6; /* Slightly darker gray background */
+ -fx-border-color: #d8d8d8; /* Light gray border */
-fx-border-width: 1px;
}
.grid-pane .stack-pane {
- -fx-background-color: derive(#1d1d1d, 30%);
+ -fx-background-color: #e6e6e6; /* Slightly darker gray background */
}
.context-menu {
- -fx-background-color: derive(#1d1d1d, 50%);
+ -fx-background-color: #f0f0f0; /* Light gray background */
}
.context-menu .label {
- -fx-text-fill: white;
+ -fx-text-fill: #333333; /* Dark gray text */
}
.menu-bar {
- -fx-background-color: derive(#1d1d1d, 20%);
+ -fx-background-color: #f0f0f0; /* Light gray background */
}
.menu-bar .label {
-fx-font-size: 14pt;
- -fx-font-family: "Segoe UI Light";
- -fx-text-fill: white;
+ -fx-font-family: "Arial", Helvetica, sans-serif;
+ -fx-text-fill: #0088cc; /* Blue text */
-fx-opacity: 0.9;
}
.menu .left-container {
- -fx-background-color: black;
+ -fx-background-color: white; /* White background */
}
-/*
- * Metro style Push Button
- * Author: Pedro Duque Vieira
- * http://pixelduke.wordpress.com/2012/10/23/jmetro-windows-8-controls-on-java/
- */
.button {
-fx-padding: 5 22 5 22;
- -fx-border-color: #e2e2e2;
+ -fx-border-color: #0088cc; /* Blue border */
-fx-border-width: 2;
-fx-background-radius: 0;
- -fx-background-color: #1d1d1d;
- -fx-font-family: "Segoe UI", Helvetica, Arial, sans-serif;
+ -fx-background-color: #f0f0f0; /* Light gray background */
+ -fx-font-family: "Arial", Helvetica, sans-serif;
-fx-font-size: 11pt;
- -fx-text-fill: #d8d8d8;
+ -fx-text-fill: #0088cc; /* Blue text */
-fx-background-insets: 0 0 0 0, 0, 1, 2;
}
.button:hover {
- -fx-background-color: #3a3a3a;
+ -fx-background-color: #e6e6e6; /* Slightly darker gray background */
}
.button:pressed, .button:default:hover:pressed {
-fx-background-color: white;
- -fx-text-fill: #1d1d1d;
+ -fx-text-fill: #f0f0f0; /* Light gray text */
}
.button:focused {
@@ -256,35 +251,35 @@
.button:disabled, .button:default:disabled {
-fx-opacity: 0.4;
- -fx-background-color: #1d1d1d;
- -fx-text-fill: white;
+ -fx-background-color: #f0f0f0; /* Light gray background */
+ -fx-text-fill: #333333; /* Dark gray text */
}
.button:default {
- -fx-background-color: -fx-focus-color;
+ -fx-background-color: #0088cc; /* Blue background */
-fx-text-fill: #ffffff;
}
.button:default:hover {
- -fx-background-color: derive(-fx-focus-color, 30%);
+ -fx-background-color: #0066aa; /* Darker blue background */
}
.dialog-pane {
- -fx-background-color: #1d1d1d;
+ -fx-background-color: #f0f0f0; /* Light gray background */
}
.dialog-pane > *.button-bar > *.container {
- -fx-background-color: #1d1d1d;
+ -fx-background-color: #f0f0f0; /* Light gray background */
}
.dialog-pane > *.label.content {
-fx-font-size: 14px;
-fx-font-weight: bold;
- -fx-text-fill: white;
+ -fx-text-fill: #333333; /* Dark gray text */
}
.dialog-pane:header *.header-panel {
- -fx-background-color: derive(#1d1d1d, 25%);
+ -fx-background-color: #e6e6e6; /* Slightly darker gray background */
}
.dialog-pane:header *.header-panel *.label {
@@ -295,11 +290,11 @@
}
.scroll-bar {
- -fx-background-color: derive(#1d1d1d, 20%);
+ -fx-background-color: #e6e6e6; /* Slightly darker gray background */
}
.scroll-bar .thumb {
- -fx-background-color: derive(#1d1d1d, 50%);
+ -fx-background-color: #0088cc; /* Blue thumb */
-fx-background-insets: 3;
}
@@ -327,18 +322,18 @@
#commandTypeLabel {
-fx-font-size: 11px;
- -fx-text-fill: #F70D1A;
+ -fx-text-fill: #0088cc; /* Blue text */
}
#commandTextField {
- -fx-background-color: transparent #383838 transparent #383838;
+ -fx-background-color: transparent #e6e6e6 transparent #e6e6e6;
-fx-background-insets: 0;
- -fx-border-color: #383838 #383838 #ffffff #383838;
+ -fx-border-color: #e6e6e6 #e6e6e6 #0088cc #e6e6e6;
-fx-border-insets: 0;
-fx-border-width: 1;
- -fx-font-family: "Segoe UI Light";
+ -fx-font-family: "Arial", Helvetica, sans-serif;
-fx-font-size: 13pt;
- -fx-text-fill: white;
+ -fx-text-fill: #333333; /* Dark gray text */
}
#filterField, #personListPanel, #personWebpage {
@@ -346,7 +341,7 @@
}
#resultDisplay .content {
- -fx-background-color: transparent, #383838, transparent, #383838;
+ -fx-background-color: transparent, #e6e6e6, transparent, #e6e6e6;
-fx-background-radius: 0;
}
@@ -357,7 +352,7 @@
#tags .label {
-fx-text-fill: white;
- -fx-background-color: #3e7b91;
+ -fx-background-color: #009D94; /* Blue background */
-fx-padding: 1 3 1 3;
-fx-border-radius: 2;
-fx-background-radius: 2;
diff --git a/src/main/resources/view/DoctorListCard.fxml b/src/main/resources/view/DoctorListCard.fxml
index 30e1ecbac7a..8c6484818e0 100644
--- a/src/main/resources/view/DoctorListCard.fxml
+++ b/src/main/resources/view/DoctorListCard.fxml
@@ -24,7 +24,7 @@
-
+
@@ -33,7 +33,6 @@
-
diff --git a/src/main/resources/view/DoctorListPanel.fxml b/src/main/resources/view/DoctorListPanel.fxml
index 9348ec709fa..223e71006a9 100644
--- a/src/main/resources/view/DoctorListPanel.fxml
+++ b/src/main/resources/view/DoctorListPanel.fxml
@@ -7,7 +7,7 @@
-
+
-
+
diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml
index 4e186297c83..0c834d8905d 100644
--- a/src/main/resources/view/MainWindow.fxml
+++ b/src/main/resources/view/MainWindow.fxml
@@ -12,6 +12,7 @@
+
@@ -48,18 +49,24 @@
-
+
-
+
+
+
+
+
+
+
diff --git a/src/main/resources/view/PatientListCard.fxml b/src/main/resources/view/PatientListCard.fxml
index 75b59e4bf23..e3ac97acdfd 100644
--- a/src/main/resources/view/PatientListCard.fxml
+++ b/src/main/resources/view/PatientListCard.fxml
@@ -24,7 +24,7 @@
-
+
@@ -36,7 +36,6 @@
-
diff --git a/src/main/resources/view/PatientListPanel.fxml b/src/main/resources/view/PatientListPanel.fxml
index 01a748ac8b5..5264e0d3531 100644
--- a/src/main/resources/view/PatientListPanel.fxml
+++ b/src/main/resources/view/PatientListPanel.fxml
@@ -7,7 +7,7 @@
-
+
diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicateDoctorAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicateDoctorAddressBook.json
index 11732dfca71..d21fceae417 100644
--- a/src/test/data/JsonSerializableAddressBookTest/duplicateDoctorAddressBook.json
+++ b/src/test/data/JsonSerializableAddressBookTest/duplicateDoctorAddressBook.json
@@ -10,7 +10,7 @@
"gender": "F",
"ic": "S9831263J",
"tags": [
- "friends"
+ "SURGEON"
]
},
{
@@ -22,5 +22,6 @@
"gender": "F",
"ic": "S9831263J"
}
- ]
+ ],
+ "appointments": []
}
diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePatientAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicatePatientAddressBook.json
index e40a32d9a41..bf6f6cfb675 100644
--- a/src/test/data/JsonSerializableAddressBookTest/duplicatePatientAddressBook.json
+++ b/src/test/data/JsonSerializableAddressBookTest/duplicatePatientAddressBook.json
@@ -9,7 +9,7 @@
"gender": "F",
"ic": "S1234567Z",
"tags": [
- "friends"
+ "priority: LOW"
],
"condition": "Unknown",
"bloodType": "O+",
@@ -28,5 +28,6 @@
"emergencyContact": "99272759"
}
],
- "doctors": []
+ "doctors": [],
+ "appointments": []
}
diff --git a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json
index 702160ab3de..948744b48c3 100644
--- a/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json
+++ b/src/test/data/JsonSerializableAddressBookTest/duplicatePersonAddressBook.json
@@ -50,5 +50,6 @@
"gender": "F",
"ic": "S9831263J"
}
- ]
+ ],
+ "appointments": []
}
diff --git a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json
index 22071d817c2..69614033936 100644
--- a/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json
+++ b/src/test/data/JsonSerializableAddressBookTest/invalidPersonAddressBook.json
@@ -15,5 +15,6 @@
"email": "invalid@email!3e",
"address": "4th street"
}
- ]
+ ],
+ "appointments": []
}
diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalDoctorsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalDoctorsAddressBook.json
index c0c0a9ceee3..feadc1983cc 100644
--- a/src/test/data/JsonSerializableAddressBookTest/typicalDoctorsAddressBook.json
+++ b/src/test/data/JsonSerializableAddressBookTest/typicalDoctorsAddressBook.json
@@ -14,18 +14,18 @@
{
"doctorIc": "S9712346B",
"patientIc": "S8192320E",
- "appointmentTime": "2022-02-14 13:30:00",
+ "appointmentTime": "2022-02-14 13:30",
"status": "Scheduled"
},
{
"doctorIc": "S9812345A",
"patientIc": "S8192320E",
- "appointmentTime": "2022-02-28 13:30:00",
+ "appointmentTime": "2022-02-28 13:30",
"status": "Scheduled"
}
],
"tags": [
- "friends"
+ "NEUROLOGIST"
]
},
{
@@ -40,13 +40,13 @@
{
"doctorIc": "S9712346B",
"patientIc": "S8192320E",
- "appointmentTime": "2022-02-14 13:30:00",
+ "appointmentTime": "2022-02-14 13:30",
"status": "Scheduled"
}
],
"tags": [
- "owesMoney",
- "friends"
+ "CARDIOLOGIST",
+ "SURGEON"
]
},
{
@@ -115,5 +115,6 @@
"appointments": [],
"tags": []
}
- ]
+ ],
+ "appointments": []
}
diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPatientsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPatientsAddressBook.json
index 2cd907eb151..26f7be691b6 100644
--- a/src/test/data/JsonSerializableAddressBookTest/typicalPatientsAddressBook.json
+++ b/src/test/data/JsonSerializableAddressBookTest/typicalPatientsAddressBook.json
@@ -10,7 +10,7 @@
"gender": "F",
"ic": "T0131267K",
"tags": [
- "friends"
+ "priority: HIGH"
],
"condition": "NA",
"bloodType": "O+",
@@ -25,8 +25,7 @@
"gender": "M",
"ic": "T0131268K",
"tags": [
- "owesMoney",
- "friends"
+ "priority: LOW"
],
"condition": "Type 1 Diabetes",
"bloodType": "O-",
@@ -54,7 +53,7 @@
"gender": "M",
"ic": "T0131260K",
"tags": [
- "friends"
+ "priority: MEDIUM"
],
"condition": "Kidney Failure",
"bloodType": "A+",
@@ -100,5 +99,6 @@
"emergencyContact": "91634567"
}
],
- "doctors": []
+ "doctors": [],
+ "appointments": []
}
diff --git a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json
index cb03e0de1fb..4cf58971f01 100644
--- a/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json
+++ b/src/test/data/JsonSerializableAddressBookTest/typicalPersonsAddressBook.json
@@ -176,5 +176,6 @@
"ic": "S9531263K",
"tags": []
}
- ]
+ ],
+ "appointments": []
}
diff --git a/src/test/java/seedu/address/logic/commands/AddAppointmentCommandTest.java b/src/test/java/seedu/address/logic/commands/AddAppointmentCommandTest.java
new file mode 100644
index 00000000000..e1a0ddd9e77
--- /dev/null
+++ b/src/test/java/seedu/address/logic/commands/AddAppointmentCommandTest.java
@@ -0,0 +1,205 @@
+package seedu.address.logic.commands;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_AMY;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_DEREK;
+import static seedu.address.testutil.Assert.assertThrows;
+import static seedu.address.testutil.TypicalAppointment.APPOINTMENT_1;
+
+import java.nio.file.Path;
+import java.util.function.Predicate;
+
+import org.junit.jupiter.api.Test;
+
+import javafx.collections.ObservableList;
+import seedu.address.commons.core.GuiSettings;
+import seedu.address.logic.commands.exceptions.CommandException;
+import seedu.address.model.Model;
+import seedu.address.model.ReadOnlyAddressBook;
+import seedu.address.model.ReadOnlyUserPrefs;
+import seedu.address.model.appointment.Appointment;
+import seedu.address.model.appointment.AppointmentTime;
+import seedu.address.model.person.Doctor;
+import seedu.address.model.person.Ic;
+import seedu.address.model.person.Patient;
+import seedu.address.model.person.Person;
+import seedu.address.testutil.AppointmentBuilder;
+
+public class AddAppointmentCommandTest {
+
+ @Test
+ public void constructor_nullPatient_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> new AddAppointmentCommand(null));
+ }
+
+ @Test
+ public void execute_sameDoctorAndPatient_throwsCommandException() {
+ Appointment invalidAppointment = new AppointmentBuilder().withPatientIc(new Ic(VALID_NRIC_DEREK))
+ .withDoctorIc(new Ic(VALID_NRIC_DEREK)).build();
+ AddAppointmentCommand addAppointmentCommand = new AddAppointmentCommand(invalidAppointment);
+ ModelStub modelStub = new ModelStub();
+
+ assertThrows(CommandException.class, AddAppointmentCommand.MESSAGE_SAME_DOCTOR_AND_PATIENT, (
+ ) -> addAppointmentCommand.execute(modelStub));
+ }
+
+ @Test
+ public void equals() {
+ // default appointmentBuilder uses dic: Derek, pic: Bob, time: "2022-02-14 13:30"
+ Appointment appointmentA = new AppointmentBuilder().build();
+ Appointment appointmentB = new AppointmentBuilder().withPatientIc(new Ic(VALID_NRIC_AMY)).build();
+ Appointment appointmentC = new AppointmentBuilder().withDoctorIc(new Ic(VALID_NRIC_AMY)).build();
+ Appointment appointmentD =
+ new AppointmentBuilder().withAppointmentTime(new AppointmentTime("2024-12-31 10:00")).build();
+ AddAppointmentCommand addACommand = new AddAppointmentCommand(appointmentA);
+ AddAppointmentCommand addBCommand = new AddAppointmentCommand(appointmentB);
+ AddAppointmentCommand addCCommand = new AddAppointmentCommand(appointmentC);
+ AddAppointmentCommand addDCommand = new AddAppointmentCommand(appointmentD);
+
+ // same object -> returns true
+ assertTrue(addACommand.equals(addACommand));
+
+ // same values -> returns true
+ AddAppointmentCommand addACommandCopy = new AddAppointmentCommand(appointmentA);
+ assertTrue(addACommand.equals(addACommandCopy));
+
+ // different types -> returns false
+ assertFalse(addACommand.equals(1));
+
+ // null -> returns false
+ assertFalse(addACommand.equals(null));
+
+ // different value for any field -> returns false
+ assertFalse(addACommand.equals(addBCommand));
+ assertFalse(addACommand.equals(addCCommand));
+ assertFalse(addACommand.equals(addDCommand));
+ }
+
+ @Test
+ public void toStringMethod() {
+ AddAppointmentCommand addAppointmentCommand = new AddAppointmentCommand(APPOINTMENT_1);
+ String expected = AddAppointmentCommand.class.getCanonicalName() + "{toAdd=" + APPOINTMENT_1 + "}";
+ assertEquals(expected, addAppointmentCommand.toString());
+ }
+
+ /**
+ * A default model stub that have all of the methods failing.
+ */
+ private class ModelStub implements Model {
+ @Override
+ public void setUserPrefs(ReadOnlyUserPrefs userPrefs) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public ReadOnlyUserPrefs getUserPrefs() {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public GuiSettings getGuiSettings() {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void setGuiSettings(GuiSettings guiSettings) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public Path getAddressBookFilePath() {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void setAddressBookFilePath(Path addressBookFilePath) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void addPerson(Person person) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void deleteAppointment(Appointment appointment) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void setAddressBook(ReadOnlyAddressBook newData) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public ReadOnlyAddressBook getAddressBook() {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public boolean hasPerson(Person person) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void deletePerson(Person target) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void setPerson(Person target, Person editedPerson) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void addAppointment(Appointment appointment) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public ObservableList getFilteredPatientList() {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ /**
+ * Returns an unmodifiable view of the filtered doctor list
+ */
+ @Override
+ public ObservableList getFilteredDoctorList() {
+ return null;
+ }
+
+ @Override
+ public ObservableList getFilteredAppointmentList() {
+ return null;
+ }
+
+ @Override
+ public void updateFilteredPersonList(Predicate predicate) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void undo() {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void redo() throws CommandException {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public void updateFilteredAppointmentList(Predicate predicate) {
+ throw new AssertionError("This method should not be called.");
+ }
+
+ @Override
+ public boolean hasIc(Ic nric) {
+ throw new AssertionError("This method should not be called.");
+ }
+ }
+
+}
diff --git a/src/test/java/seedu/address/logic/commands/AddAppointmentIntegrationTest.java b/src/test/java/seedu/address/logic/commands/AddAppointmentIntegrationTest.java
new file mode 100644
index 00000000000..fde2e2cac58
--- /dev/null
+++ b/src/test/java/seedu/address/logic/commands/AddAppointmentIntegrationTest.java
@@ -0,0 +1,162 @@
+package seedu.address.logic.commands;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
+import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
+import static seedu.address.testutil.TypicalAddressBook.getTypicalAddressBook;
+import static seedu.address.testutil.TypicalDoctor.CHERYL;
+import static seedu.address.testutil.TypicalDoctor.DEREK;
+import static seedu.address.testutil.TypicalPatient.AMY;
+import static seedu.address.testutil.TypicalPatient.BOB;
+
+import java.util.Set;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import seedu.address.model.Model;
+import seedu.address.model.ModelManager;
+import seedu.address.model.UserPrefs;
+import seedu.address.model.appointment.Appointment;
+import seedu.address.model.person.Doctor;
+import seedu.address.model.person.Patient;
+import seedu.address.testutil.AppointmentBuilder;
+import seedu.address.testutil.DoctorBuilder;
+import seedu.address.testutil.PatientBuilder;
+
+/**
+ * Contains integration tests (interaction with the Model) for {@code AddCommand}.
+ */
+public class AddAppointmentIntegrationTest {
+
+ private Model model;
+
+ @BeforeEach
+ public void setUp() {
+ model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
+ }
+
+ @Test
+ public void execute_newAppointment_success() {
+ Doctor derek = new DoctorBuilder(DEREK).build();
+ Patient bob = new PatientBuilder(BOB).build();
+ model.addPerson(derek);
+ model.addPerson(bob);
+ Appointment validAppointment =
+ new AppointmentBuilder().withDoctorIc(derek.getIc()).withPatientIc(bob.getIc()).build();
+
+ Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
+ expectedModel.addAppointment(validAppointment);
+
+ assertCommandSuccess(new AddAppointmentCommand(validAppointment), model,
+ String.format(AddAppointmentCommand.MESSAGE_SUCCESS, validAppointment),
+ expectedModel);
+
+ // check that the appointments have been added to all patients, doctors and appointment list
+ Set patientAppointments = bob.getAppointments();
+ Set doctorAppointments = derek.getAppointments();
+ assertTrue(patientAppointments.contains(validAppointment));
+ assertTrue(doctorAppointments.contains(validAppointment));
+ assertTrue(model.getFilteredAppointmentList().contains(validAppointment));
+ }
+
+ @Test
+ public void execute_appointmentWithPatientNotInModel_throwsCommandException() {
+ Doctor derek = new DoctorBuilder(DEREK).build();
+ Patient bob = new PatientBuilder(BOB).build();
+ // only add doctor
+ model.addPerson(derek);
+ Appointment invalidAppointment =
+ new AppointmentBuilder().withDoctorIc(derek.getIc()).withPatientIc(bob.getIc()).build();
+
+ assertCommandFailure(new AddAppointmentCommand(invalidAppointment), model,
+ AddAppointmentCommand.MESSAGE_INVALID_PATIENT);
+ }
+
+ @Test
+ public void execute_appointmentWithDoctorNotInModel_throwsCommandException() {
+ Doctor derek = new DoctorBuilder(DEREK).build();
+ Patient bob = new PatientBuilder(BOB).build();
+ // only add patient
+ model.addPerson(bob);
+ Appointment invalidAppointment =
+ new AppointmentBuilder().withDoctorIc(derek.getIc()).withPatientIc(bob.getIc()).build();
+
+ assertCommandFailure(new AddAppointmentCommand(invalidAppointment), model,
+ AddAppointmentCommand.MESSAGE_INVALID_DOCTOR);
+ }
+
+ @Test
+ public void execute_appointmentWithDoctorHasAppointmentAtTheSameTime_throwsCommandException() {
+ Doctor derek = new DoctorBuilder(DEREK).build();
+ Patient bob = new PatientBuilder(BOB).build();
+ model.addPerson(derek);
+ model.addPerson(bob);
+ Appointment validAppointment =
+ new AppointmentBuilder().withDoctorIc(derek.getIc()).withPatientIc(bob.getIc()).build();
+
+ Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
+ expectedModel.addAppointment(validAppointment);
+
+ assertCommandSuccess(new AddAppointmentCommand(validAppointment), model,
+ String.format(AddAppointmentCommand.MESSAGE_SUCCESS, validAppointment),
+ expectedModel);
+
+ Patient amy = new PatientBuilder(AMY).build();
+ model.addPerson(amy);
+ // create another appointment between Amy and Doctor Derek at the same time
+ Appointment invalidAppointment =
+ new AppointmentBuilder().withDoctorIc(derek.getIc()).withPatientIc(amy.getIc()).build();
+
+ assertCommandFailure(new AddAppointmentCommand(invalidAppointment), model,
+ AddAppointmentCommand.MESSAGE_DUPLICATE_APPOINTMENT_DOCTOR);
+ }
+
+ @Test
+ public void execute_appointmentWithPatientHasAppointmentAtTheSameTime_throwsCommandException() {
+ Doctor derek = new DoctorBuilder(DEREK).build();
+ Patient bob = new PatientBuilder(BOB).build();
+ model.addPerson(derek);
+ model.addPerson(bob);
+ Appointment validAppointment =
+ new AppointmentBuilder().withDoctorIc(derek.getIc()).withPatientIc(bob.getIc()).build();
+
+ Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
+ expectedModel.addAppointment(validAppointment);
+
+ assertCommandSuccess(new AddAppointmentCommand(validAppointment), model,
+ String.format(AddAppointmentCommand.MESSAGE_SUCCESS, validAppointment),
+ expectedModel);
+
+ Doctor cheryl = new DoctorBuilder(CHERYL).build();
+ model.addPerson(cheryl);
+ // create another appointment between patient Bob and Doctor cheryl at the same time
+ Appointment invalidAppointment =
+ new AppointmentBuilder().withDoctorIc(cheryl.getIc()).withPatientIc(bob.getIc()).build();
+
+ assertCommandFailure(new AddAppointmentCommand(invalidAppointment), model,
+ AddAppointmentCommand.MESSAGE_DUPLICATE_APPOINTMENT_PATIENT);
+ }
+
+ @Test
+ public void execute_duplicateAppointment_throwsCommandException() {
+ Doctor derek = new DoctorBuilder(DEREK).build();
+ Patient bob = new PatientBuilder(BOB).build();
+ model.addPerson(derek);
+ model.addPerson(bob);
+ Appointment validAppointment =
+ new AppointmentBuilder().withDoctorIc(derek.getIc()).withPatientIc(bob.getIc()).build();
+
+ Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
+ expectedModel.addAppointment(validAppointment);
+
+ assertCommandSuccess(new AddAppointmentCommand(validAppointment), model,
+ String.format(AddAppointmentCommand.MESSAGE_SUCCESS, validAppointment),
+ expectedModel);
+
+ // try to add the same appointment again will give an error
+ assertCommandFailure(new AddAppointmentCommand(validAppointment), model,
+ AddAppointmentCommand.MESSAGE_DUPLICATE_APPOINTMENT_PATIENT);
+ }
+
+}
diff --git a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java
index 8efdf72b7eb..d114e5c4750 100644
--- a/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java
+++ b/src/test/java/seedu/address/logic/commands/AddCommandIntegrationTest.java
@@ -12,7 +12,7 @@
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
import seedu.address.model.person.Person;
-import seedu.address.testutil.PersonBuilder;
+import seedu.address.testutil.PatientBuilder;
/**
* Contains integration tests (interaction with the Model) for {@code AddCommand}.
@@ -28,7 +28,7 @@ public void setUp() {
@Test
public void execute_newPerson_success() {
- Person validPerson = new PersonBuilder().withName("Barry Allen").build();
+ Person validPerson = new PatientBuilder().withName("Barry Allen").build();
Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs());
expectedModel.addPerson(validPerson);
diff --git a/src/test/java/seedu/address/logic/commands/AddDoctorCommandTest.java b/src/test/java/seedu/address/logic/commands/AddDoctorCommandTest.java
index 317261a9ed7..4973d767cbd 100644
--- a/src/test/java/seedu/address/logic/commands/AddDoctorCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/AddDoctorCommandTest.java
@@ -22,18 +22,21 @@
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlyUserPrefs;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
+import seedu.address.model.person.Ic;
import seedu.address.model.person.Patient;
import seedu.address.model.person.Person;
import seedu.address.testutil.DoctorBuilder;
+//import seedu.address.testutil.PatientBuilder;
public class AddDoctorCommandTest {
-
@Test
public void constructor_nullDoctor_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new AddCommand(null));
}
+
@Test
public void execute_doctorAcceptedByModel_addSuccessful() throws Exception {
ModelStubAcceptingPersonAdded modelStub = new ModelStubAcceptingPersonAdded();
@@ -126,6 +129,11 @@ public void addPerson(Person person) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public void deleteAppointment(Appointment appointment) {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void setAddressBook(ReadOnlyAddressBook newData) {
throw new AssertionError("This method should not be called.");
@@ -151,12 +159,9 @@ public void setPerson(Person target, Person editedPerson) {
throw new AssertionError("This method should not be called.");
}
- /**
- * Returns an unmodifiable view of the filtered person list
- */
@Override
- public ObservableList getFilteredPersonList() {
- return null; // not sure abt this method
+ public void addAppointment(Appointment appointment) {
+ throw new AssertionError("This method should not be called.");
}
@Override
@@ -172,6 +177,11 @@ public ObservableList getFilteredDoctorList() {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public ObservableList getFilteredAppointmentList() {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void updateFilteredPersonList(Predicate predicate) {
throw new AssertionError("This method should not be called.");
@@ -186,6 +196,15 @@ public void undo() {
public void redo() throws CommandException {
throw new AssertionError("This method should not be called.");
}
+
+ @Override
+ public void updateFilteredAppointmentList(Predicate predicate) {
+ throw new AssertionError("This method should not be called.");
+ }
+ @Override
+ public boolean hasIc(Ic nric) {
+ throw new AssertionError("This method should not be called.");
+ }
}
/**
@@ -204,6 +223,11 @@ public boolean hasPerson(Person doctor) {
requireNonNull(doctor);
return this.doctor.isSamePerson(doctor);
}
+ @Override
+ public boolean hasIc(Ic nric) {
+ requireNonNull(nric);
+ return this.doctor.getIc().equals(nric);
+ }
}
/**
diff --git a/src/test/java/seedu/address/logic/commands/AddPatientCommandTest.java b/src/test/java/seedu/address/logic/commands/AddPatientCommandTest.java
index 5e5a2f0f447..2c8ec690dd3 100644
--- a/src/test/java/seedu/address/logic/commands/AddPatientCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/AddPatientCommandTest.java
@@ -22,7 +22,9 @@
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlyUserPrefs;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
+import seedu.address.model.person.Ic;
import seedu.address.model.person.Patient;
import seedu.address.model.person.Person;
import seedu.address.testutil.PatientBuilder;
@@ -126,6 +128,11 @@ public void addPerson(Person person) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public void deleteAppointment(Appointment appointment) {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void setAddressBook(ReadOnlyAddressBook newData) {
throw new AssertionError("This method should not be called.");
@@ -140,6 +147,10 @@ public ReadOnlyAddressBook getAddressBook() {
public boolean hasPerson(Person person) {
throw new AssertionError("This method should not be called.");
}
+ @Override
+ public boolean hasIc(Ic nric) {
+ throw new AssertionError("This method should not be called.");
+ }
@Override
public void deletePerson(Person target) {
@@ -151,12 +162,9 @@ public void setPerson(Person target, Person editedPerson) {
throw new AssertionError("This method should not be called.");
}
- /**
- * Returns an unmodifiable view of the filtered person list
- */
@Override
- public ObservableList getFilteredPersonList() {
- return null; // not sure abt this method
+ public void addAppointment(Appointment appointment) {
+ throw new AssertionError("This method should not be called.");
}
@Override
@@ -172,6 +180,11 @@ public ObservableList getFilteredDoctorList() {
return null;
}
+ @Override
+ public ObservableList getFilteredAppointmentList() {
+ throw new AssertionError("This method should not be called.");
+ }
+
@Override
public void updateFilteredPersonList(Predicate predicate) {
throw new AssertionError("This method should not be called.");
@@ -186,6 +199,11 @@ public void undo() {
public void redo() throws CommandException {
throw new AssertionError("This method should not be called.");
}
+
+ @Override
+ public void updateFilteredAppointmentList(Predicate predicate) {
+ throw new AssertionError("This method should not be called.");
+ }
}
/**
@@ -204,6 +222,11 @@ public boolean hasPerson(Person patient) {
requireNonNull(patient);
return this.patient.isSamePerson(patient);
}
+ @Override
+ public boolean hasIc(Ic nric) {
+ return this.patient.getIc().equals(nric);
+ }
+
}
/**
@@ -228,6 +251,10 @@ public void addPerson(Person person) {
public ReadOnlyAddressBook getAddressBook() {
return new AddressBook();
}
+ @Override
+ public boolean hasIc(Ic nric) {
+ return personsAdded.stream().anyMatch(person -> person.getIc().equals(nric));
+ }
}
}
diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java
index dd6cd45793d..7ed1b0b056c 100644
--- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java
+++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java
@@ -3,20 +3,21 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_APPOINTMENT_TIME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_BLOODTYPE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CONDITION;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_DOCTOR_IC;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMERGENCY_CONTACT;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER;
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_PATIENT_IC;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
import static seedu.address.testutil.Assert.assertThrows;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -55,8 +56,11 @@ public class CommandTestUtil {
public static final String VALID_ADDRESS_CHERYL = "123 Main Street, Anytown, USA";
public static final String VALID_ADDRESS_DEREK = "456 Elm Avenue, Somewhereville, Canada";
- public static final String VALID_TAG_HUSBAND = "husband";
- public static final String VALID_TAG_FRIEND = "friend";
+ public static final String VALID_TAG_LOW = "priority: LOW";
+ public static final String VALID_TAG_MEDIUM = "priority: MEDIUM";
+ public static final String VALID_TAG_HIGH = "priority: HIGH";
+ public static final String VALID_TAG_CARDIOLOGIST = "CARDIOLOGIST";
+ public static final String VALID_TAG_SURGEON = "SURGEON";
public static final String VALID_GENDER_MALE = "M";
public static final String VALID_GENDER_FEMALE = "F";
public static final String VALID_NRIC_AMY = "S8643226I";
@@ -71,6 +75,10 @@ public class CommandTestUtil {
public static final String VALID_BLOODTYPE_BOB = "A+";
public static final String VALID_BLOODTYPE_AMY = "A+";
public static final String VALID_CONDITION_AMY = "Diabetes";
+ public static final String VALID_DATE_1 = "2022-02-14 13:30";
+ public static final String VALID_DATE_2 = "2022-02-28 13:30";
+ public static final String VALID_DATE_1_DESC = " " + PREFIX_APPOINTMENT_TIME + VALID_DATE_1;
+ public static final String VALID_DATE_2_DESC = " " + PREFIX_APPOINTMENT_TIME + VALID_DATE_2;
public static final String NAME_DESC_AMY = " " + PREFIX_NAME + VALID_NAME_AMY;
public static final String NAME_DESC_BOB = " " + PREFIX_NAME + VALID_NAME_BOB;
public static final String NAME_DESC_CHERYL = " " + PREFIX_NAME + VALID_NAME_CHERYL;
@@ -104,50 +112,57 @@ public class CommandTestUtil {
public static final String CONDITION_DESC_BOB = " " + PREFIX_CONDITION + VALID_CONDITION_BOB;
public static final String BLOODTYPE_DESC_AMY = " " + PREFIX_BLOODTYPE + VALID_BLOODTYPE_AMY;
public static final String BLOODTYPE_DESC_BOB = " " + PREFIX_BLOODTYPE + VALID_BLOODTYPE_BOB;
- public static final String TAG_DESC_FRIEND = " " + PREFIX_TAG + VALID_TAG_FRIEND;
- public static final String TAG_DESC_HUSBAND = " " + PREFIX_TAG + VALID_TAG_HUSBAND;
+ public static final String APPOINTMENT_DOCTOR_NRIC_DESC_DEREK = " " + PREFIX_DOCTOR_IC + VALID_NRIC_DEREK;
+
+ public static final String APPOINTMENT_DOCTOR_NRIC_DESC_CHERYL = " " + PREFIX_DOCTOR_IC + VALID_NRIC_CHERYL;
+
+ public static final String APPOINTMENT_PATIENT_NRIC_DESC_BOB = " " + PREFIX_PATIENT_IC + VALID_NRIC_BOB;
+ public static final String APPOINTMENT_PATIENT_NRIC_DESC_AMY = " " + PREFIX_PATIENT_IC + VALID_NRIC_AMY;
+ public static final String TAG_DESC_LOW = " " + PREFIX_TAG + "Low";
+ public static final String TAG_DESC_MEDIUM = " " + PREFIX_TAG + "Medium";
+ public static final String TAG_DESC_HIGH = " " + PREFIX_TAG + "High";
public static final String INVALID_NAME_DESC = " " + PREFIX_NAME + "James&"; // '&' not allowed in names
public static final String INVALID_PHONE_DESC = " " + PREFIX_PHONE + "911a"; // 'a' not allowed in phones
public static final String INVALID_EMAIL_DESC = " " + PREFIX_EMAIL + "bob!yahoo"; // missing '@' symbol
public static final String INVALID_ADDRESS_DESC = " " + PREFIX_ADDRESS; // empty string not allowed for addresses
- public static final String INVALID_TAG_DESC = " " + PREFIX_TAG + "hubby*"; // '*' not allowed in tags
+ public static final String INVALID_PATIENT_TAG_DESC = " " + PREFIX_TAG + "highest"; // not a priority level
+ public static final String INVALID_DOCTOR_TAG_DESC = " " + PREFIX_TAG + "nurse"; // not a valid specialisation
public static final String INVALID_BLOODTYPE_DESC = " " + PREFIX_BLOODTYPE + "Z+";
public static final String INVALID_CONDITION_DESC = " " + PREFIX_CONDITION + " ";
public static final String INVALID_EMERGENCY_CONTACT_DESC = " " + PREFIX_EMERGENCY_CONTACT + "+6A";
public static final String INVALID_NRIC = "A1234567G";
public static final String INVALID_GENDER_DESC = " " + PREFIX_GENDER + "Alien";
+
+ public static final String INVALID_APPOINTMENT_DOCTOR_NRIC_DESC = " " + PREFIX_DOCTOR_IC + INVALID_NRIC;
+
+ public static final String INVALID_APPOINTMENT_PATIENT_NRIC_DESC = " " + PREFIX_PATIENT_IC + INVALID_NRIC;
+ public static final String INVALID_DATE_DESC = " " + PREFIX_APPOINTMENT_TIME + "100-100-12";
public static final String PREAMBLE_WHITESPACE = "\t \r \n";
public static final String PREAMBLE_NON_EMPTY = "NonEmptyPreamble";
public static final EditCommand.EditPersonDescriptor DESC_AMY;
public static final EditCommand.EditPersonDescriptor DESC_BOB;
public static final EditCommand.EditPersonDescriptor DESC_CHERYL;
- private static final EditCommand.EditPersonDescriptor DESC_DEREK;
- private static final String VALID_DATE_1_DESC = "2022-02-14 13:30:00";
- private static final String VALID_DATE_2_DESC = "2022-02-28 13:30:00";
- private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
- public static final LocalDateTime VALID_DATE_1 = LocalDateTime.parse(VALID_DATE_1_DESC, formatter);
- public static final LocalDateTime VALID_DATE_2 = LocalDateTime.parse(VALID_DATE_2_DESC, formatter);
+ public static final EditCommand.EditPersonDescriptor DESC_DEREK;
+
static {
DESC_AMY = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY)
.withPhone(VALID_PHONE_AMY).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY)
.withBloodType(VALID_BLOODTYPE_AMY).withCondition(VALID_CONDITION_AMY)
- .withGender(VALID_GENDER_FEMALE).withIc(VALID_NRIC_AMY)
- .withTags(VALID_TAG_FRIEND).withBloodType(VALID_BLOODTYPE_AMY)
- .build();
+ .withGender(VALID_GENDER_FEMALE)
+ .withTags(VALID_TAG_LOW).withBloodType(VALID_BLOODTYPE_AMY).build();
DESC_BOB = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB)
.withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB).withAddress(VALID_ADDRESS_BOB)
- .withGender(VALID_GENDER_MALE).withIc(VALID_NRIC_BOB)
- .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build();
+ .withGender(VALID_GENDER_MALE).withTags(VALID_TAG_MEDIUM).build();
DESC_CHERYL = new EditPersonDescriptorBuilder().withName(VALID_NAME_CHERYL)
.withPhone(VALID_PHONE_CHERYL).withEmail(VALID_EMAIL_CHERYL).withAddress(VALID_ADDRESS_CHERYL)
- .withGender(VALID_GENDER_FEMALE).withIc(VALID_NRIC_CHERYL).build();
+ .withGender(VALID_GENDER_FEMALE).build();
DESC_DEREK = new EditPersonDescriptorBuilder().withName(VALID_NAME_DEREK)
.withPhone(VALID_PHONE_DEREK).withEmail(VALID_EMAIL_DEREK).withAddress(VALID_ADDRESS_DEREK)
- .withGender(VALID_GENDER_MALE).withIc(VALID_NRIC_DEREK).build();
+ .withGender(VALID_GENDER_MALE).build();
}
/**
diff --git a/src/test/java/seedu/address/logic/commands/EditCommandTest.java b/src/test/java/seedu/address/logic/commands/EditCommandTest.java
index 7610658cf12..a5f6d587e5b 100644
--- a/src/test/java/seedu/address/logic/commands/EditCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/EditCommandTest.java
@@ -7,7 +7,7 @@
import static seedu.address.logic.commands.CommandTestUtil.DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_LOW;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
import static seedu.address.logic.commands.CommandTestUtil.showPersonAtIndex;
@@ -41,9 +41,9 @@ public class EditCommandTest {
@Test
public void execute_patientAllFieldsSpecifiedUnfilteredList_success() {
- Person editedPatient = new PatientBuilder().build();
- EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedPatient).build();
Ic nricOfFirstPatient = model.getFilteredPatientList().get(0).getIc();
+ Person editedPatient = new PatientBuilder(nricOfFirstPatient).build();
+ EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(nricOfFirstPatient, editedPatient).build();
EditCommand editCommand = new EditCommand(nricOfFirstPatient, descriptor);
String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedPatient));
@@ -56,9 +56,9 @@ public void execute_patientAllFieldsSpecifiedUnfilteredList_success() {
@Test
public void execute_doctorAllFieldsSpecifiedUnfilteredList_success() {
- Doctor editedDoctor = new DoctorBuilder().build();
- EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(editedDoctor).build();
Ic nricOfFirstDoctor = model.getFilteredDoctorList().get(0).getIc();
+ Doctor editedDoctor = new DoctorBuilder(nricOfFirstDoctor).build();
+ EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(nricOfFirstDoctor, editedDoctor).build();
EditCommand editCommand = new EditCommand(nricOfFirstDoctor, descriptor);
String expectedMessage = String.format(EditCommand.MESSAGE_EDIT_PERSON_SUCCESS, Messages.format(editedDoctor));
@@ -75,10 +75,10 @@ public void execute_someFieldsSpecifiedUnfilteredList_success() {
PatientBuilder patientInList = new PatientBuilder(lastPatient);
Patient editedPatient = patientInList.withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB)
- .withTags(VALID_TAG_HUSBAND).build();
+ .withTags(VALID_TAG_LOW).build();
EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_BOB)
- .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_HUSBAND).build();
+ .withPhone(VALID_PHONE_BOB).withTags(VALID_TAG_LOW).build();
Ic nricLastPerson = lastPatient.getIc();
EditCommand editCommand = new EditCommand(nricLastPerson, descriptor);
@@ -127,11 +127,10 @@ public void execute_duplicatePersonUnfilteredList_failure() {
Ic nricOfFirstPerson = model.getFilteredPatientList().get(0).getIc();
Person firstPerson = model.getFilteredPatientList().stream().filter(p ->
p.getIc().equals(nricOfFirstPerson)).findFirst().orElse(null);
- EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(firstPerson).build();
+ EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(nricOfFirstPerson, firstPerson).build();
Ic nricOfSecondPerson = model.getFilteredPatientList().get(1).getIc();
EditCommand editCommand = new EditCommand(nricOfSecondPerson, descriptor);
-
- assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON);
+ assertCommandFailure(editCommand, model, EditCommand.MESSAGE_IC_CHANGED);
}
@Test
@@ -142,9 +141,9 @@ public void execute_duplicatePersonFilteredList_failure() {
Patient patientInList = model.getAddressBook().getPatientList().get(INDEX_SECOND_PERSON.getZeroBased());
Ic nricOfFirstPerson = model.getFilteredPatientList().get(INDEX_FIRST_PERSON.getZeroBased()).getIc();
EditCommand editCommand = new EditCommand(nricOfFirstPerson,
- new EditPersonDescriptorBuilder(patientInList).build());
+ new EditPersonDescriptorBuilder(patientInList.getIc(), patientInList).build());
- assertCommandFailure(editCommand, model, EditCommand.MESSAGE_DUPLICATE_PERSON);
+ assertCommandFailure(editCommand, model, EditCommand.MESSAGE_IC_CHANGED);
}
@Test
diff --git a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java
index e582f69f881..8e2abb6c0cd 100644
--- a/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java
+++ b/src/test/java/seedu/address/logic/commands/EditPersonDescriptorTest.java
@@ -9,7 +9,7 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_MEDIUM;
import org.junit.jupiter.api.Test;
@@ -53,7 +53,7 @@ public void equals() {
assertFalse(DESC_AMY.equals(editedAmy));
// different tags -> returns false
- editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_HUSBAND).build();
+ editedAmy = new EditPersonDescriptorBuilder(DESC_AMY).withTags(VALID_TAG_MEDIUM).build();
assertFalse(DESC_AMY.equals(editedAmy));
}
diff --git a/src/test/java/seedu/address/logic/commands/FindCommandTest.java b/src/test/java/seedu/address/logic/commands/FindCommandTest.java
index bdceca4cb73..9a8da09e160 100644
--- a/src/test/java/seedu/address/logic/commands/FindCommandTest.java
+++ b/src/test/java/seedu/address/logic/commands/FindCommandTest.java
@@ -5,10 +5,20 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.Messages.MESSAGE_PERSONS_LISTED_OVERVIEW;
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess;
+import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalAddressBook.getTypicalAddressBook;
+import static seedu.address.testutil.TypicalDoctor.ALLEN;
+import static seedu.address.testutil.TypicalDoctor.BOYD;
+import static seedu.address.testutil.TypicalDoctor.CARLOS;
+import static seedu.address.testutil.TypicalDoctor.DAVID;
+import static seedu.address.testutil.TypicalDoctor.GREG;
+import static seedu.address.testutil.TypicalPatient.ALICE;
+import static seedu.address.testutil.TypicalPatient.BENSON;
import static seedu.address.testutil.TypicalPatient.CARL;
+import static seedu.address.testutil.TypicalPatient.DANIEL;
import static seedu.address.testutil.TypicalPatient.ELLE;
import static seedu.address.testutil.TypicalPatient.FIONA;
+import static seedu.address.testutil.TypicalPatient.GEORGE;
import java.util.Arrays;
import java.util.function.Predicate;
@@ -16,6 +26,7 @@
import org.junit.jupiter.api.Test;
import seedu.address.logic.parser.KeywordParser;
+import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.UserPrefs;
@@ -30,6 +41,11 @@ public class FindCommandTest {
private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs());
private Model expectedModel = new ModelManager(getTypicalAddressBook(), new UserPrefs());
+ @Test
+ public void constructor_nullField_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> new FindCommand(null));
+ }
+
@Test
public void equals() {
GenderPredicate firstPredicate =
@@ -58,7 +74,7 @@ public void equals() {
}
@Test
- public void execute_multipleKeywords_multiplePersonsFound() {
+ public void execute_multipleKeywords_multiplePersonsFound() throws ParseException {
String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 3);
Predicate predicate = preparePredicate("Kurz Elle Kunz");
FindCommand command = new FindCommand(predicate);
@@ -67,6 +83,38 @@ public void execute_multipleKeywords_multiplePersonsFound() {
assertEquals(Arrays.asList(CARL, ELLE, FIONA), model.getFilteredPatientList());
}
+ @Test
+ public void execute_findNric_personFound() throws ParseException {
+ String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 1);
+ Predicate predicate = preparePredicate("T0131267K");
+ FindCommand command = new FindCommand(predicate);
+ expectedModel.updateFilteredPersonList(predicate);
+ assertCommandSuccess(command, model, expectedMessage, expectedModel);
+ assertEquals(Arrays.asList(ALICE), model.getFilteredPatientList());
+ }
+
+ @Test
+ public void execute_findGender_personFound() throws ParseException {
+ String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 9);
+ Predicate predicate = preparePredicate("M");
+ FindCommand command = new FindCommand(predicate);
+ expectedModel.updateFilteredPersonList(predicate);
+ assertCommandSuccess(command, model, expectedMessage, expectedModel);
+ assertEquals(Arrays.asList(BENSON, CARL, DANIEL, GEORGE),
+ model.getFilteredPatientList());
+ assertEquals(Arrays.asList(BOYD, CARLOS, DAVID, GREG, ALLEN), model.getFilteredDoctorList());
+ }
+
+ @Test
+ public void execute_findBloodType_personFound() throws ParseException {
+ String expectedMessage = String.format(MESSAGE_PERSONS_LISTED_OVERVIEW, 1);
+ Predicate predicate = preparePredicate("Blood Type AB+");
+ FindCommand command = new FindCommand(predicate);
+ expectedModel.updateFilteredPersonList(predicate);
+ assertCommandSuccess(command, model, expectedMessage, expectedModel);
+ assertEquals(Arrays.asList(CARL), model.getFilteredPatientList());
+ }
+
@Test
public void toStringMethod() {
IcContainsKeywordsPredicate predicate = new IcContainsKeywordsPredicate("keyword");
@@ -78,7 +126,7 @@ public void toStringMethod() {
/**
* Parses {@code userInput} into a {@code Predicate}.
*/
- private Predicate preparePredicate(String userInput) {
+ private Predicate preparePredicate(String userInput) throws ParseException {
return KeywordParser.parseInput(userInput.split("\\s"));
}
}
diff --git a/src/test/java/seedu/address/logic/parser/AddAppointmentCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddAppointmentCommandParserTest.java
new file mode 100644
index 00000000000..f8602d21c3c
--- /dev/null
+++ b/src/test/java/seedu/address/logic/parser/AddAppointmentCommandParserTest.java
@@ -0,0 +1,131 @@
+package seedu.address.logic.parser;
+
+import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
+import static seedu.address.logic.commands.CommandTestUtil.ADDRESS_DESC_BOB;
+import static seedu.address.logic.commands.CommandTestUtil.APPOINTMENT_DOCTOR_NRIC_DESC_CHERYL;
+import static seedu.address.logic.commands.CommandTestUtil.APPOINTMENT_DOCTOR_NRIC_DESC_DEREK;
+import static seedu.address.logic.commands.CommandTestUtil.APPOINTMENT_PATIENT_NRIC_DESC_AMY;
+import static seedu.address.logic.commands.CommandTestUtil.APPOINTMENT_PATIENT_NRIC_DESC_BOB;
+import static seedu.address.logic.commands.CommandTestUtil.EMAIL_DESC_BOB;
+import static seedu.address.logic.commands.CommandTestUtil.GENDER_DESC_MALE;
+import static seedu.address.logic.commands.CommandTestUtil.INVALID_APPOINTMENT_DOCTOR_NRIC_DESC;
+import static seedu.address.logic.commands.CommandTestUtil.INVALID_APPOINTMENT_PATIENT_NRIC_DESC;
+import static seedu.address.logic.commands.CommandTestUtil.INVALID_DATE_DESC;
+import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB;
+import static seedu.address.logic.commands.CommandTestUtil.NRIC_DESC_BOB;
+import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB;
+import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_NON_EMPTY;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE_1;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE_1_DESC;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_DATE_2_DESC;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_BOB;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_DEREK;
+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.logic.parser.CommandParserTestUtil.assertParseFailure;
+import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
+import static seedu.address.testutil.TypicalAppointment.APPOINTMENT_1;
+
+import org.junit.jupiter.api.Test;
+
+import seedu.address.logic.Messages;
+import seedu.address.logic.commands.AddAppointmentCommand;
+import seedu.address.model.appointment.Appointment;
+import seedu.address.model.appointment.AppointmentTime;
+import seedu.address.model.person.Ic;
+import seedu.address.testutil.AppointmentBuilder;
+
+public class AddAppointmentCommandParserTest {
+ private AddAppointmentCommandParser parser = new AddAppointmentCommandParser();
+
+ @Test
+ public void parse_allFieldsPresent_success() {
+ Appointment expectedAppointment = new AppointmentBuilder(APPOINTMENT_1).build();
+
+ assertParseSuccess(parser,
+ APPOINTMENT_DOCTOR_NRIC_DESC_DEREK + APPOINTMENT_PATIENT_NRIC_DESC_BOB + VALID_DATE_1_DESC,
+ new AddAppointmentCommand(expectedAppointment));
+ }
+
+ @Test
+ public void parse_repeatedValue_failure() {
+ String validExpectedAppointmentString =
+ APPOINTMENT_DOCTOR_NRIC_DESC_DEREK + APPOINTMENT_PATIENT_NRIC_DESC_BOB + VALID_DATE_1_DESC;
+
+ // multiple doctor ic
+ assertParseFailure(parser, APPOINTMENT_DOCTOR_NRIC_DESC_CHERYL + validExpectedAppointmentString,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_DOCTOR_IC));
+
+ // multiple patient ic
+ assertParseFailure(parser, APPOINTMENT_PATIENT_NRIC_DESC_AMY + validExpectedAppointmentString,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PATIENT_IC));
+
+ // multiple appointment time
+ assertParseFailure(parser, VALID_DATE_2_DESC + validExpectedAppointmentString,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_APPOINTMENT_TIME));
+
+
+ // invalid value followed by valid value
+
+ // invalid doctor ic
+ assertParseFailure(parser, INVALID_APPOINTMENT_DOCTOR_NRIC_DESC + validExpectedAppointmentString,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_DOCTOR_IC));
+
+ // invalid patient ic
+ assertParseFailure(parser, INVALID_APPOINTMENT_PATIENT_NRIC_DESC + validExpectedAppointmentString,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PATIENT_IC));
+
+ // invalid appointment time
+ assertParseFailure(parser, INVALID_DATE_DESC + validExpectedAppointmentString,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_APPOINTMENT_TIME));
+ }
+
+ @Test
+ public void parse_compulsoryFieldMissing_failure() {
+ String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddAppointmentCommand.MESSAGE_USAGE);
+
+ // missing doctor ic prefix
+ assertParseFailure(parser, VALID_NRIC_DEREK + APPOINTMENT_PATIENT_NRIC_DESC_BOB + VALID_DATE_1_DESC,
+ expectedMessage);
+
+ // missing patient ic prefix
+ assertParseFailure(parser, APPOINTMENT_DOCTOR_NRIC_DESC_DEREK + VALID_NRIC_BOB + VALID_DATE_1_DESC,
+ expectedMessage);
+
+ // missing appointment time prefix
+ assertParseFailure(parser,
+ APPOINTMENT_DOCTOR_NRIC_DESC_DEREK + APPOINTMENT_PATIENT_NRIC_DESC_BOB + VALID_DATE_1, expectedMessage);
+
+ // all prefixes missing
+ assertParseFailure(parser, VALID_NRIC_DEREK + VALID_NRIC_BOB + VALID_DATE_1, expectedMessage);
+ }
+
+ @Test
+ public void parse_invalidValue_failure() {
+ // invalid doctor ic
+ assertParseFailure(parser,
+ INVALID_APPOINTMENT_DOCTOR_NRIC_DESC + APPOINTMENT_PATIENT_NRIC_DESC_BOB + VALID_DATE_1_DESC,
+ Ic.MESSAGE_CONSTRAINTS);
+
+ // invalid patient ic
+ assertParseFailure(parser,
+ APPOINTMENT_DOCTOR_NRIC_DESC_DEREK + INVALID_APPOINTMENT_PATIENT_NRIC_DESC + VALID_DATE_1_DESC,
+ Ic.MESSAGE_CONSTRAINTS);
+
+ // invalid appointment time
+ assertParseFailure(parser,
+ APPOINTMENT_DOCTOR_NRIC_DESC_DEREK + APPOINTMENT_PATIENT_NRIC_DESC_BOB + INVALID_DATE_DESC,
+ AppointmentTime.MESSAGE_CONSTRAINTS);
+
+ // two invalid values, only first invalid value reported
+ assertParseFailure(parser,
+ INVALID_APPOINTMENT_DOCTOR_NRIC_DESC + APPOINTMENT_PATIENT_NRIC_DESC_BOB + INVALID_DATE_DESC,
+ Ic.MESSAGE_CONSTRAINTS);
+
+ // non-empty preamble
+ assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB
+ + ADDRESS_DESC_BOB + NRIC_DESC_BOB + GENDER_DESC_MALE,
+ String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddAppointmentCommand.MESSAGE_USAGE));
+ }
+}
diff --git a/src/test/java/seedu/address/logic/parser/AddDoctorCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddDoctorCommandParserTest.java
index df078a61524..798a6d42abd 100644
--- a/src/test/java/seedu/address/logic/parser/AddDoctorCommandParserTest.java
+++ b/src/test/java/seedu/address/logic/parser/AddDoctorCommandParserTest.java
@@ -17,6 +17,7 @@
public class AddDoctorCommandParserTest {
private AddDoctorCommandParser parser = new AddDoctorCommandParser();
+
@Test
public void parse_compulsoryFieldMissing_failure() {
String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddDoctorCommand.MESSAGE_USAGE);
diff --git a/src/test/java/seedu/address/logic/parser/AddPatientCommandParserTest.java b/src/test/java/seedu/address/logic/parser/AddPatientCommandParserTest.java
index d4bfc05eb8c..f286401d116 100644
--- a/src/test/java/seedu/address/logic/parser/AddPatientCommandParserTest.java
+++ b/src/test/java/seedu/address/logic/parser/AddPatientCommandParserTest.java
@@ -19,8 +19,8 @@
import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMAIL_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_EMERGENCY_CONTACT_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC;
+import static seedu.address.logic.commands.CommandTestUtil.INVALID_PATIENT_TAG_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC;
-import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.NRIC_DESC_AMY;
@@ -29,8 +29,8 @@
import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_NON_EMPTY;
import static seedu.address.logic.commands.CommandTestUtil.PREAMBLE_WHITESPACE;
-import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_FRIEND;
-import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_LOW;
+import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_MEDIUM;
import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_BLOODTYPE_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_CONDITION_BOB;
@@ -40,8 +40,6 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_BLOODTYPE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_CONDITION;
@@ -51,6 +49,7 @@
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.logic.parser.CommandParserTestUtil.assertParseFailure;
import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
import static seedu.address.testutil.TypicalPatient.AMY;
@@ -67,7 +66,6 @@
import seedu.address.model.person.Name;
import seedu.address.model.person.Patient;
import seedu.address.model.person.Phone;
-import seedu.address.model.tag.Tag;
import seedu.address.testutil.PatientBuilder;
public class AddPatientCommandParserTest {
@@ -75,30 +73,20 @@ public class AddPatientCommandParserTest {
@Test
public void parse_allFieldsPresent_success() {
- Patient expectedPatient = new PatientBuilder(BOB).withTags(VALID_TAG_FRIEND).build();
+ Patient expectedPatient = new PatientBuilder(BOB).build();
// whitespace only preamble
assertParseSuccess(parser, PREAMBLE_WHITESPACE + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB
+ ADDRESS_DESC_BOB + GENDER_DESC_MALE + NRIC_DESC_BOB + CONDITION_DESC_BOB
- + BLOODTYPE_DESC_BOB + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_FRIEND,
+ + BLOODTYPE_DESC_BOB + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_MEDIUM,
new AddPatientCommand(expectedPatient));
-
-
- // multiple tags - all accepted
- Patient expectedPatientMultipleTags = new PatientBuilder(BOB).withTags(VALID_TAG_FRIEND, VALID_TAG_HUSBAND)
- .build();
- assertParseSuccess(parser,
- NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
- + GENDER_DESC_MALE + NRIC_DESC_BOB + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB
- + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
- new AddPatientCommand(expectedPatientMultipleTags));
}
@Test
public void parse_repeatedNonTagValue_failure() {
String validExpectedPatientString = NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ GENDER_DESC_MALE + NRIC_DESC_BOB + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB
- + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_FRIEND;
+ + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_LOW;
// multiple names
assertParseFailure(parser, NAME_DESC_AMY + validExpectedPatientString,
@@ -128,13 +116,17 @@ public void parse_repeatedNonTagValue_failure() {
assertParseFailure(parser, EMERGENCY_CONTACT_DESC_AMY + validExpectedPatientString,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMERGENCY_CONTACT));
+ //multiple tags
+ assertParseFailure(parser, TAG_DESC_MEDIUM + validExpectedPatientString,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_TAG));
+
// multiple fields repeated
assertParseFailure(parser,
validExpectedPatientString + PHONE_DESC_AMY + EMAIL_DESC_AMY + NAME_DESC_AMY + ADDRESS_DESC_AMY
- + CONDITION_DESC_AMY + BLOODTYPE_DESC_AMY + EMERGENCY_CONTACT_DESC_AMY
+ + TAG_DESC_LOW + CONDITION_DESC_AMY + BLOODTYPE_DESC_AMY + EMERGENCY_CONTACT_DESC_AMY
+ validExpectedPatientString,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_NAME, PREFIX_NRIC, PREFIX_GENDER,
- PREFIX_ADDRESS, PREFIX_EMAIL, PREFIX_PHONE, PREFIX_CONDITION, PREFIX_BLOODTYPE,
+ PREFIX_ADDRESS, PREFIX_TAG, PREFIX_EMAIL, PREFIX_PHONE, PREFIX_CONDITION, PREFIX_BLOODTYPE,
PREFIX_CONDITION, PREFIX_EMERGENCY_CONTACT));
// invalid value followed by valid value
@@ -167,6 +159,10 @@ public void parse_repeatedNonTagValue_failure() {
assertParseFailure(parser, INVALID_EMERGENCY_CONTACT_DESC + validExpectedPatientString,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMERGENCY_CONTACT));
+ //invalid tag
+ assertParseFailure(parser, INVALID_PATIENT_TAG_DESC + validExpectedPatientString,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_TAG));
+
// valid value followed by invalid value
// invalid name
@@ -196,6 +192,10 @@ public void parse_repeatedNonTagValue_failure() {
// invalid emergencyContact
assertParseFailure(parser, validExpectedPatientString + INVALID_EMERGENCY_CONTACT_DESC,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_EMERGENCY_CONTACT));
+
+ // invalid tag
+ assertParseFailure(parser, validExpectedPatientString + INVALID_PATIENT_TAG_DESC,
+ Messages.getErrorMessageForDuplicatePrefixes(PREFIX_TAG));
}
@Test
@@ -236,12 +236,6 @@ public void parse_compulsoryFieldMissing_failure() {
+ NRIC_DESC_BOB + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB + EMERGENCY_CONTACT_DESC_BOB,
expectedMessage);
- // missing address prefix
- assertParseFailure(parser,
- NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + VALID_ADDRESS_BOB + GENDER_DESC_MALE
- + NRIC_DESC_BOB + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB + EMERGENCY_CONTACT_DESC_BOB,
- expectedMessage);
-
// missing condition prefix
assertParseFailure(parser,
NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB + GENDER_DESC_MALE
@@ -272,43 +266,38 @@ public void parse_invalidValue_failure() {
// invalid name
assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ NRIC_DESC_BOB + GENDER_DESC_MALE + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB
- + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Name.MESSAGE_CONSTRAINTS);
+ + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_LOW, Name.MESSAGE_CONSTRAINTS);
// invalid phone
assertParseFailure(parser, NAME_DESC_BOB + INVALID_PHONE_DESC + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ NRIC_DESC_BOB + GENDER_DESC_MALE + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB
- + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_CONSTRAINTS);
+ + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_LOW, Phone.MESSAGE_CONSTRAINTS);
// invalid email
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + INVALID_EMAIL_DESC + ADDRESS_DESC_BOB
+ NRIC_DESC_BOB + GENDER_DESC_MALE + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB
- + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Email.MESSAGE_CONSTRAINTS);
+ + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_LOW, Email.MESSAGE_CONSTRAINTS);
// invalid address
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + INVALID_ADDRESS_DESC
+ NRIC_DESC_BOB + GENDER_DESC_MALE + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB
- + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Address.MESSAGE_CONSTRAINTS);
-
- // invalid tag
- assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
- + NRIC_DESC_BOB + GENDER_DESC_MALE + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB
- + EMERGENCY_CONTACT_DESC_BOB + INVALID_TAG_DESC + VALID_TAG_FRIEND, Tag.MESSAGE_CONSTRAINTS);
+ + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_LOW, Address.MESSAGE_CONSTRAINTS);
// invalid condition
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ NRIC_DESC_BOB + GENDER_DESC_MALE + INVALID_CONDITION_DESC + BLOODTYPE_DESC_BOB
- + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Condition.MESSAGE_CONSTRAINTS);
+ + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_LOW, Condition.MESSAGE_CONSTRAINTS);
// invalid bloodType
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ NRIC_DESC_BOB + GENDER_DESC_MALE + CONDITION_DESC_BOB + INVALID_BLOODTYPE_DESC
- + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, BloodType.MESSAGE_CONSTRAINTS);
+ + EMERGENCY_CONTACT_DESC_BOB + TAG_DESC_LOW, BloodType.MESSAGE_CONSTRAINTS);
// invalid emergencyContact
assertParseFailure(parser, NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB + ADDRESS_DESC_BOB
+ NRIC_DESC_BOB + GENDER_DESC_MALE + CONDITION_DESC_BOB + BLOODTYPE_DESC_BOB
- + INVALID_EMERGENCY_CONTACT_DESC + TAG_DESC_HUSBAND + TAG_DESC_FRIEND, Phone.MESSAGE_CONSTRAINTS);
+ + INVALID_EMERGENCY_CONTACT_DESC + TAG_DESC_LOW, Phone.MESSAGE_CONSTRAINTS);
// two invalid values, only first invalid value reported
assertParseFailure(parser, INVALID_NAME_DESC + PHONE_DESC_BOB + EMAIL_DESC_BOB
@@ -318,7 +307,7 @@ public void parse_invalidValue_failure() {
// non-empty preamble
assertParseFailure(parser, PREAMBLE_NON_EMPTY + NAME_DESC_BOB + PHONE_DESC_BOB + EMAIL_DESC_BOB
- + ADDRESS_DESC_BOB + NRIC_DESC_BOB + GENDER_DESC_MALE + TAG_DESC_HUSBAND + TAG_DESC_FRIEND,
+ + ADDRESS_DESC_BOB + NRIC_DESC_BOB + GENDER_DESC_MALE + TAG_DESC_LOW,
String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddPatientCommand.MESSAGE_USAGE));
}
}
diff --git a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java
index cc7fbe52ba3..fc37303c9ec 100644
--- a/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java
+++ b/src/test/java/seedu/address/logic/parser/AddressBookParserTest.java
@@ -9,8 +9,11 @@
import org.junit.jupiter.api.Test;
+import seedu.address.logic.commands.AddAppointmentCommand;
+import seedu.address.logic.commands.AddDoctorCommand;
import seedu.address.logic.commands.AddPatientCommand;
import seedu.address.logic.commands.ClearCommand;
+import seedu.address.logic.commands.DeleteAppointmentCommand;
import seedu.address.logic.commands.DeleteCommand;
import seedu.address.logic.commands.EditCommand;
import seedu.address.logic.commands.EditCommand.EditPersonDescriptor;
@@ -18,13 +21,19 @@
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.HelpCommand;
import seedu.address.logic.commands.ListCommand;
+import seedu.address.logic.commands.RedoCommand;
+import seedu.address.logic.commands.UndoCommand;
import seedu.address.logic.parser.exceptions.ParseException;
+import seedu.address.model.appointment.Appointment;
+import seedu.address.model.person.Doctor;
import seedu.address.model.person.Patient;
-import seedu.address.model.person.Person;
+import seedu.address.testutil.AppointmentBuilder;
+import seedu.address.testutil.AppointmentUtil;
+import seedu.address.testutil.DoctorBuilder;
+import seedu.address.testutil.DoctorUtil;
import seedu.address.testutil.EditPersonDescriptorBuilder;
import seedu.address.testutil.PatientBuilder;
import seedu.address.testutil.PatientUtil;
-import seedu.address.testutil.PersonBuilder;
import seedu.address.testutil.PersonUtil;
public class AddressBookParserTest {
@@ -38,6 +47,13 @@ public void parseCommand_add_patient() throws Exception {
assertEquals(new AddPatientCommand(patient), command);
}
+ @Test
+ public void parseCommand_add_doctor() throws Exception {
+ Doctor doctor = new DoctorBuilder().build();
+ AddDoctorCommand command = (AddDoctorCommand) parser.parseCommand(DoctorUtil.getAddDoctorCommand(doctor));
+ assertEquals(new AddDoctorCommand(doctor), command);
+ }
+
@Test
public void parseCommand_clear() throws Exception {
assertTrue(parser.parseCommand(ClearCommand.COMMAND_WORD) instanceof ClearCommand);
@@ -51,15 +67,42 @@ public void parseCommand_delete() throws Exception {
assertEquals(new DeleteCommand(FIRST_NRIC), command);
}
+ @Test
+ public void parseCommand_addAppointment() throws Exception {
+ Appointment appointment = new AppointmentBuilder().build();
+ AddAppointmentCommand command =
+ (AddAppointmentCommand) parser.parseCommand(AppointmentUtil.getAddAppointmentCommand(appointment));
+ assertEquals(new AddAppointmentCommand(appointment), command);
+ }
+
+ @Test
+ public void parseCommand_deleteAppointment() throws Exception {
+ DeleteAppointmentCommand command = (DeleteAppointmentCommand) parser.parseCommand(
+ DeleteAppointmentCommand.COMMAND_WORD + " 1");
+ assertEquals(new DeleteAppointmentCommand(1), command);
+ }
+
@Test
public void parseCommand_edit() throws Exception {
- Person person = new PersonBuilder().build();
- EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person).build();
+ Patient person = new PatientBuilder().build();
+ EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder(person.getIc(), person).build();
EditCommand command = (EditCommand) parser.parseCommand(EditCommand.COMMAND_WORD + " "
+ person.getIc() + " " + PersonUtil.getEditPersonDescriptorDetails(descriptor));
assertEquals(new EditCommand(person.getIc(), descriptor), command);
}
+ @Test
+ public void parseCommand_undo() throws Exception {
+ assertTrue(parser.parseCommand(UndoCommand.COMMAND_WORD) instanceof UndoCommand);
+ assertTrue(parser.parseCommand(UndoCommand.COMMAND_WORD + " 3") instanceof UndoCommand);
+ }
+
+ @Test
+ public void parseCommand_redo() throws Exception {
+ assertTrue(parser.parseCommand(RedoCommand.COMMAND_WORD) instanceof RedoCommand);
+ assertTrue(parser.parseCommand(RedoCommand.COMMAND_WORD + " 3") instanceof RedoCommand);
+ }
+
@Test
public void parseCommand_exit() throws Exception {
assertTrue(parser.parseCommand(ExitCommand.COMMAND_WORD) instanceof ExitCommand);
@@ -90,6 +133,14 @@ public void parseCommand_findGender() throws Exception {
assertEquals(new FindCommand(KeywordParser.parseInput(keywords)), command);
}
+ @Test
+ public void parseCommand_findBloodType() throws Exception {
+ String[] keywords = {"Blood", "Type", "A+"};
+ FindCommand command = (FindCommand) parser.parseCommand(
+ FindCommand.COMMAND_WORD + " Blood Type A+");
+ assertEquals(new FindCommand(KeywordParser.parseInput(keywords)), command);
+ }
+
@Test
public void parseCommand_help() throws Exception {
assertTrue(parser.parseCommand(HelpCommand.COMMAND_WORD) instanceof HelpCommand);
diff --git a/src/test/java/seedu/address/logic/parser/DeleteAppointmentCommandParserTest.java b/src/test/java/seedu/address/logic/parser/DeleteAppointmentCommandParserTest.java
new file mode 100644
index 00000000000..448baab0690
--- /dev/null
+++ b/src/test/java/seedu/address/logic/parser/DeleteAppointmentCommandParserTest.java
@@ -0,0 +1,24 @@
+package seedu.address.logic.parser;
+
+import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
+import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
+import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
+
+import org.junit.jupiter.api.Test;
+
+import seedu.address.logic.commands.DeleteAppointmentCommand;
+
+public class DeleteAppointmentCommandParserTest {
+ private DeleteAppointmentCommandParser parser = new DeleteAppointmentCommandParser();
+
+ @Test
+ public void parseValidArgs_returnsDeleteAppointmentCommand() {
+ assertParseSuccess(parser, "1", new DeleteAppointmentCommand(1));
+ }
+
+ @Test
+ public void parseInvalidArgs_throwsParseException() {
+ assertParseFailure(parser, "a", String.format(MESSAGE_INVALID_COMMAND_FORMAT,
+ DeleteAppointmentCommand.MESSAGE_USAGE));
+ }
+}
diff --git a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java
index 33cb721ae13..59c28ca69e3 100644
--- a/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java
+++ b/src/test/java/seedu/address/logic/parser/EditCommandParserTest.java
@@ -16,13 +16,12 @@
import static seedu.address.logic.commands.CommandTestUtil.INVALID_NAME_DESC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_NRIC;
import static seedu.address.logic.commands.CommandTestUtil.INVALID_PHONE_DESC;
-import static seedu.address.logic.commands.CommandTestUtil.INVALID_TAG_DESC;
import static seedu.address.logic.commands.CommandTestUtil.NAME_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_AMY;
import static seedu.address.logic.commands.CommandTestUtil.PHONE_DESC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.REMARK_DESC_AMY;
-import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_FRIEND;
-import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_LOW;
+import static seedu.address.logic.commands.CommandTestUtil.TAG_DESC_MEDIUM;
import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_AMY;
import static seedu.address.logic.commands.CommandTestUtil.VALID_BLOODTYPE_AMY;
import static seedu.address.logic.commands.CommandTestUtil.VALID_CONDITION_AMY;
@@ -33,8 +32,8 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_AMY;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_REMARK_AMY;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_LOW;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_MEDIUM;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
@@ -55,7 +54,6 @@
import seedu.address.model.person.Ic;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
-import seedu.address.model.tag.Tag;
import seedu.address.testutil.EditPersonDescriptorBuilder;
public class EditCommandParserTest {
@@ -97,7 +95,6 @@ public void parse_invalidValue_failure() {
assertParseFailure(parser, VALID_NRIC_AMY + INVALID_PHONE_DESC, Phone.MESSAGE_CONSTRAINTS);
assertParseFailure(parser, VALID_NRIC_AMY + INVALID_EMAIL_DESC, Email.MESSAGE_CONSTRAINTS);
assertParseFailure(parser, VALID_NRIC_AMY + INVALID_ADDRESS_DESC, Address.MESSAGE_CONSTRAINTS);
- assertParseFailure(parser, VALID_NRIC_AMY + INVALID_TAG_DESC, Tag.MESSAGE_CONSTRAINTS);
assertParseFailure(parser, VALID_NRIC_AMY + INVALID_BLOODTYPE_DESC, BloodType.MESSAGE_CONSTRAINTS);
assertParseFailure(parser, VALID_NRIC_AMY + INVALID_CONDITION_DESC, Condition.MESSAGE_CONSTRAINTS);
assertParseFailure(parser, VALID_NRIC_AMY + INVALID_GENDER_DESC, Gender.MESSAGE_CONSTRAINTS);
@@ -105,15 +102,6 @@ public void parse_invalidValue_failure() {
// invalid phone followed by valid email
assertParseFailure(parser, VALID_NRIC_AMY + INVALID_PHONE_DESC + EMAIL_DESC_AMY, Phone.MESSAGE_CONSTRAINTS);
- // while parsing {@code PREFIX_TAG} alone will reset the tags of the {@code Person} being edited,
- // parsing it together with a valid tag results in error
- assertParseFailure(parser, VALID_NRIC_AMY + TAG_DESC_FRIEND + TAG_DESC_HUSBAND + TAG_EMPTY,
- Tag.MESSAGE_CONSTRAINTS);
- assertParseFailure(parser, VALID_NRIC_AMY + TAG_DESC_FRIEND + TAG_EMPTY + TAG_DESC_HUSBAND,
- Tag.MESSAGE_CONSTRAINTS);
- assertParseFailure(parser, VALID_NRIC_AMY + TAG_EMPTY + TAG_DESC_FRIEND + TAG_DESC_HUSBAND,
- Tag.MESSAGE_CONSTRAINTS);
-
// multiple invalid values, but only the first invalid value is captured
assertParseFailure(parser, VALID_NRIC_AMY + INVALID_NAME_DESC + INVALID_EMAIL_DESC + VALID_ADDRESS_AMY
+ VALID_PHONE_AMY,
@@ -122,13 +110,13 @@ public void parse_invalidValue_failure() {
@Test
public void parse_allFieldsSpecified_success() {
- String userInput = VALID_NRIC_AMY + PHONE_DESC_BOB + TAG_DESC_HUSBAND
- + EMAIL_DESC_AMY + ADDRESS_DESC_AMY + NAME_DESC_AMY + TAG_DESC_FRIEND + BLOODTYPE_DESC_AMY
+ String userInput = VALID_NRIC_AMY + PHONE_DESC_BOB + EMAIL_DESC_AMY
+ + ADDRESS_DESC_AMY + NAME_DESC_AMY + TAG_DESC_LOW + BLOODTYPE_DESC_AMY
+ CONDITION_DESC_AMY + GENDER_DESC_FEMALE + REMARK_DESC_AMY;
EditPersonDescriptor descriptor = new EditPersonDescriptorBuilder().withName(VALID_NAME_AMY)
.withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_AMY).withAddress(VALID_ADDRESS_AMY)
- .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).withCondition(VALID_CONDITION_AMY)
+ .withTags(VALID_TAG_LOW).withCondition(VALID_CONDITION_AMY)
.withBloodType(VALID_BLOODTYPE_AMY).withGender(VALID_GENDER_FEMALE).withRemark(VALID_REMARK_AMY)
.build();
EditCommand expectedCommand = new EditCommand(new Ic(VALID_NRIC_AMY), descriptor);
@@ -175,8 +163,8 @@ public void parse_oneFieldSpecified_success() {
assertParseSuccess(parser, userInput, expectedCommand);
// tags
- userInput = VALID_NRIC_AMY + TAG_DESC_FRIEND;
- descriptor = new EditPersonDescriptorBuilder().withTags(VALID_TAG_FRIEND).build();
+ userInput = VALID_NRIC_AMY + TAG_DESC_MEDIUM;
+ descriptor = new EditPersonDescriptorBuilder().withTags(VALID_TAG_MEDIUM).build();
expectedCommand = new EditCommand(new Ic(VALID_NRIC_AMY), descriptor);
assertParseSuccess(parser, userInput, expectedCommand);
@@ -222,8 +210,8 @@ public void parse_multipleRepeatedFields_failure() {
// mulltiple valid fields repeated
userInput = VALID_NRIC_AMY + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY
- + TAG_DESC_FRIEND + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY + TAG_DESC_FRIEND
- + PHONE_DESC_BOB + ADDRESS_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_HUSBAND;
+ + TAG_DESC_MEDIUM + PHONE_DESC_AMY + ADDRESS_DESC_AMY + EMAIL_DESC_AMY + TAG_DESC_MEDIUM
+ + PHONE_DESC_BOB + ADDRESS_DESC_BOB + EMAIL_DESC_BOB + TAG_DESC_LOW;
assertParseFailure(parser, userInput,
Messages.getErrorMessageForDuplicatePrefixes(PREFIX_PHONE, PREFIX_EMAIL, PREFIX_ADDRESS));
diff --git a/src/test/java/seedu/address/logic/parser/FindAppointmentCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindAppointmentCommandParserTest.java
new file mode 100644
index 00000000000..e1ecb8b9993
--- /dev/null
+++ b/src/test/java/seedu/address/logic/parser/FindAppointmentCommandParserTest.java
@@ -0,0 +1,31 @@
+package seedu.address.logic.parser;
+
+import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
+import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure;
+import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess;
+
+import org.junit.jupiter.api.Test;
+
+import seedu.address.logic.commands.FindAppointmentCommand;
+import seedu.address.logic.parser.exceptions.ParseException;
+import seedu.address.model.appointment.AppointmentIcPredicate;
+
+public class FindAppointmentCommandParserTest {
+ private FindAppointmentCommandParser parser = new FindAppointmentCommandParser();
+
+ private String testInput = "T1111111G";
+
+ @Test
+ public void parse_emptyArg_throwsParseException() {
+ assertParseFailure(parser, " ", String.format(MESSAGE_INVALID_COMMAND_FORMAT,
+ FindAppointmentCommand.MESSAGE_USAGE));
+ }
+
+ @Test
+ public void parse_validArgs_returnsFindCommand() throws ParseException {
+ // no leading and trailing whitespaces
+ FindAppointmentCommand expectedFindAppointmentCommand =
+ new FindAppointmentCommand(new AppointmentIcPredicate(testInput));
+ assertParseSuccess(parser, "T1111111G", expectedFindAppointmentCommand);
+ }
+}
diff --git a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java
index 9814e15cfb9..ded453ab8aa 100644
--- a/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java
+++ b/src/test/java/seedu/address/logic/parser/FindCommandParserTest.java
@@ -7,11 +7,12 @@
import org.junit.jupiter.api.Test;
import seedu.address.logic.commands.FindCommand;
+import seedu.address.logic.parser.exceptions.ParseException;
public class FindCommandParserTest {
private FindCommandParser parser = new FindCommandParser();
- private String[] testInput = {"Alice", "Bob"};
+ private String[] testInput1 = {"Alice", "Bob"};
@Test
public void parse_emptyArg_throwsParseException() {
@@ -19,10 +20,10 @@ public void parse_emptyArg_throwsParseException() {
}
@Test
- public void parse_validArgs_returnsFindCommand() {
+ public void parse_validArgs_returnsFindCommand() throws ParseException {
// no leading and trailing whitespaces
FindCommand expectedFindCommand =
- new FindCommand(KeywordParser.parseInput(testInput));
+ new FindCommand(KeywordParser.parseInput(testInput1));
assertParseSuccess(parser, "Alice Bob", expectedFindCommand);
// multiple whitespaces between keywords
diff --git a/src/test/java/seedu/address/logic/parser/KeywordParserTest.java b/src/test/java/seedu/address/logic/parser/KeywordParserTest.java
index 146307f0cf9..394b9057a00 100644
--- a/src/test/java/seedu/address/logic/parser/KeywordParserTest.java
+++ b/src/test/java/seedu/address/logic/parser/KeywordParserTest.java
@@ -2,7 +2,6 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.util.Arrays;
import java.util.function.Predicate;
import org.junit.jupiter.api.Test;
@@ -15,24 +14,73 @@
public class KeywordParserTest {
+ @Test
+ public void parseInputWithName_returnsNamePredicate() {
+ String[] input = {"John", "Doe"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof NameContainsKeywordsPredicate);
+ }
+
+ @Test
+ public void parseInputWithIC_returnsIcPredicate() {
+ String[] input = {"S1234567A"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof IcContainsKeywordsPredicate);
+ }
+
+ @Test
+ public void parseInputWithGender_returnsGenderPredicate() {
+ String[] input = {"M"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof GenderPredicate);
+ }
+
+ @Test
+ public void parseInputWithBloodType_returnsBloodTypePredicate() {
+ String[] input = {"Blood", "Type", "A+"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof BloodTypePredicate);
+ }
@Test
- public void test_userInput_returnsCorrectFindCommand() {
- String[] testIcInput = {"T1234567G"};
- String[] testGenderInput = {"M"};
- String[] testBloodTypeInput = {"Blood Type A+"};
- String[] testNameInput = {"Alice", "Bob"};
+ public void parseInputWithInvalidGender_returnsNamePredicate() {
+ String[] input = {"X"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof NameContainsKeywordsPredicate);
+ }
- Predicate testPredicate1 = new IcContainsKeywordsPredicate("T1234567G");
- assertTrue(KeywordParser.parseInput(testIcInput).equals(testPredicate1));
+ @Test
+ public void parseInputWithInvalidBloodType_returnsNamePredicate() {
+ String[] input = {"Blood", "Type", "C"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof NameContainsKeywordsPredicate);
+ }
- Predicate testPredicate2 = new GenderPredicate("M");
- assertTrue(KeywordParser.parseInput(testGenderInput).equals(testPredicate2));
+ @Test
+ public void parseInputWithMultipleKeywords_returnsNamePredicate() {
+ String[] input = {"John", "Doe", "Carl"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof NameContainsKeywordsPredicate);
+ }
- Predicate testPredicate3 = new BloodTypePredicate("Blood Type A+");
- assertTrue(KeywordParser.parseInput(testBloodTypeInput).equals(testPredicate3));
+ @Test
+ public void parseInputWithIcAndGender_returnsIcPredicate() {
+ String[] input = {"S1234567A", "M"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof IcContainsKeywordsPredicate);
+ }
- Predicate testPredicate4 = new NameContainsKeywordsPredicate(Arrays.asList("Alice", "Bob"));
- assertTrue(KeywordParser.parseInput(testNameInput).equals(testPredicate4));
+ @Test
+ public void parseInputWithIcAndBloodType_returnsIcPredicate() {
+ String[] input = {"S1234567A", "A+"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof IcContainsKeywordsPredicate);
+ }
+
+ @Test
+ public void parseInputWithGenderAndBloodType_returnsGenderPredicate() {
+ String[] input = {"M", "A+"};
+ Predicate predicate = KeywordParser.parseInput(input);
+ assertTrue(predicate instanceof GenderPredicate);
}
}
diff --git a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java
index 4256788b1a7..5e6e6be3fef 100644
--- a/src/test/java/seedu/address/logic/parser/ParserUtilTest.java
+++ b/src/test/java/seedu/address/logic/parser/ParserUtilTest.java
@@ -16,6 +16,7 @@
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Address;
import seedu.address.model.person.Email;
+import seedu.address.model.person.Ic;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
import seedu.address.model.tag.Tag;
@@ -25,14 +26,23 @@ public class ParserUtilTest {
private static final String INVALID_PHONE = "+651234";
private static final String INVALID_ADDRESS = " ";
private static final String INVALID_EMAIL = "example.com";
- private static final String INVALID_TAG = "#friend";
+ private static final String INVALID_IC1 = "Y9834876G";
+ private static final String INVALID_IC2 = "T934865H";
+ private static final String INVALID_PATIENT_TAG = "priority: HIGHEST";
+ private static final String INVALID_DOCTOR_TAG1 = "NURSE";
private static final String VALID_NAME = "Rachel Walker";
private static final String VALID_PHONE = "123456";
private static final String VALID_ADDRESS = "123 Main Street #0505";
private static final String VALID_EMAIL = "rachel@example.com";
- private static final String VALID_TAG_1 = "friend";
- private static final String VALID_TAG_2 = "neighbour";
+ private static final String VALID_IC1 = "T1234567H";
+ private static final String VALID_IC2 = "t1234567h";
+ private static final String VALID_TAG1 = "FRIENDS";
+ private static final String VALID_TAG2 = "STUDENT";
+ private static final String VALID_PATIENT_TAG1 = "priority: LOW";
+ private static final String VALID_PATIENT_TAG2 = "priority: HIGH";
+ private static final String VALID_DOCTOR_TAG1 = "SURGEON";
+ private static final String VALID_DOCTOR_TAG2 = "CARDIOLOGIST";
private static final String WHITESPACE = " \t\r\n";
@@ -148,26 +158,59 @@ public void parseEmail_validValueWithWhitespace_returnsTrimmedEmail() throws Exc
assertEquals(expectedEmail, ParserUtil.parseEmail(emailWithWhitespace));
}
+ @Test
+ public void parseIc_null_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> ParserUtil.parseIc((String) null));
+ }
+
+ @Test
+ public void parseIc_invalidStartingCharacter_throwsParseException() {
+ assertThrows(ParseException.class, () -> ParserUtil.parseIc(INVALID_IC1));
+ }
+
+ @Test
+ public void parseIc_invalidNumbers_throwsParseException() {
+ assertThrows(ParseException.class, () -> ParserUtil.parseIc(INVALID_IC2));
+ }
+
+ @Test
+ public void parseIc_validIcWithCaps_returnsIc() throws Exception {
+ Ic expectedIc = new Ic(VALID_IC1);
+ assertEquals(expectedIc, ParserUtil.parseIc(VALID_IC1));
+ }
+
+ @Test
+ public void parseIc_validIcWithoutCaps_returnsIc() throws Exception {
+ String inputIc = VALID_IC2.toUpperCase();
+ Ic expectedIc = new Ic(inputIc);
+ assertEquals(expectedIc, ParserUtil.parseIc(VALID_IC2));
+ }
+
@Test
public void parseTag_null_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> ParserUtil.parseTag(null));
}
@Test
- public void parseTag_invalidValue_throwsParseException() {
- assertThrows(ParseException.class, () -> ParserUtil.parseTag(INVALID_TAG));
+ public void parsePatientTag_invalidValue_throwsParseException() {
+ assertThrows(ParseException.class, () -> ParserUtil.parsePatientTag(INVALID_PATIENT_TAG));
}
@Test
- public void parseTag_validValueWithoutWhitespace_returnsTag() throws Exception {
- Tag expectedTag = new Tag(VALID_TAG_1);
- assertEquals(expectedTag, ParserUtil.parseTag(VALID_TAG_1));
+ public void parseDoctorTag_invalidValue_throwsParseException() {
+ assertThrows(ParseException.class, () -> ParserUtil.parseDoctorTag(INVALID_DOCTOR_TAG1));
}
@Test
- public void parseTag_validValueWithWhitespace_returnsTrimmedTag() throws Exception {
- String tagWithWhitespace = WHITESPACE + VALID_TAG_1 + WHITESPACE;
- Tag expectedTag = new Tag(VALID_TAG_1);
+ public void parseTag_validValueWithoutWhitespace_returnsTag() {
+ Tag expectedTag = new Tag(VALID_TAG1);
+ assertEquals(expectedTag, ParserUtil.parseTag(VALID_TAG1));
+ }
+
+ @Test
+ public void parseTag_validValueWithWhitespace_returnsTrimmedTag() {
+ String tagWithWhitespace = WHITESPACE + VALID_TAG1 + WHITESPACE;
+ Tag expectedTag = new Tag(VALID_TAG1);
assertEquals(expectedTag, ParserUtil.parseTag(tagWithWhitespace));
}
@@ -177,8 +220,15 @@ public void parseTags_null_throwsNullPointerException() {
}
@Test
- public void parseTags_collectionWithInvalidTags_throwsParseException() {
- assertThrows(ParseException.class, () -> ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, INVALID_TAG)));
+ public void parsePatientTags_collectionWithMultipleTags_throwsParseException() {
+ assertThrows(ParseException.class, () -> ParserUtil.parsePatientTags(Arrays.asList(VALID_PATIENT_TAG1,
+ VALID_PATIENT_TAG2)));
+ }
+
+ @Test
+ public void parseDoctorTags_collectionWithInvalidTags_throwsParseException() {
+ assertThrows(ParseException.class, () -> ParserUtil.parseDoctorTags(Arrays.asList(VALID_DOCTOR_TAG1,
+ INVALID_DOCTOR_TAG1)));
}
@Test
@@ -188,8 +238,18 @@ public void parseTags_emptyCollection_returnsEmptySet() throws Exception {
@Test
public void parseTags_collectionWithValidTags_returnsTagSet() throws Exception {
- Set actualTagSet = ParserUtil.parseTags(Arrays.asList(VALID_TAG_1, VALID_TAG_2));
- Set expectedTagSet = new HashSet(Arrays.asList(new Tag(VALID_TAG_1), new Tag(VALID_TAG_2)));
+ Set actualTagSet = ParserUtil.parseTags(Arrays.asList(VALID_TAG1, VALID_TAG2));
+ Set expectedTagSet = new HashSet(Arrays.asList(new Tag(VALID_TAG1),
+ new Tag(VALID_TAG2)));
+
+ assertEquals(expectedTagSet, actualTagSet);
+ }
+
+ @Test
+ public void parseTags_collectionWithValidDoctorTags_returnsTagSet() throws Exception {
+ Set actualTagSet = ParserUtil.parseDoctorTags(Arrays.asList(VALID_DOCTOR_TAG1, VALID_DOCTOR_TAG2));
+ Set expectedTagSet = new HashSet(Arrays.asList(new Tag(VALID_DOCTOR_TAG1),
+ new Tag(VALID_DOCTOR_TAG2)));
assertEquals(expectedTagSet, actualTagSet);
}
diff --git a/src/test/java/seedu/address/model/AddressBookTest.java b/src/test/java/seedu/address/model/AddressBookTest.java
index 5d209f5b67f..d5ea397d03a 100644
--- a/src/test/java/seedu/address/model/AddressBookTest.java
+++ b/src/test/java/seedu/address/model/AddressBookTest.java
@@ -4,9 +4,10 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_LOW;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalAddressBook.getTypicalAddressBook;
+import static seedu.address.testutil.TypicalAppointment.APPOINTMENT_1;
import static seedu.address.testutil.TypicalPatient.ALICE;
import java.util.Arrays;
@@ -18,10 +19,12 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Doctor;
import seedu.address.model.person.Patient;
import seedu.address.model.person.Person;
import seedu.address.model.person.exceptions.DuplicatePersonException;
+import seedu.address.testutil.AppointmentBuilder;
import seedu.address.testutil.PatientBuilder;
public class AddressBookTest {
@@ -48,7 +51,7 @@ public void resetData_withValidReadOnlyAddressBook_replacesData() {
@Test
public void resetData_withDuplicatePatient_throwsDuplicatePersonException() {
// Two persons with the same identity fields
- Patient editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND)
+ Patient editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_LOW)
.build();
List newPatients = Arrays.asList(ALICE, editedAlice);
AddressBookStub newData = new AddressBookStub(newPatients);
@@ -75,11 +78,34 @@ public void hasPatient_patientInAddressBook_returnsTrue() {
@Test
public void hasPatient_patientWithSameIdentityFieldsInAddressBook_returnsTrue() {
addressBook.addPatient(ALICE);
- Patient editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND)
+ Patient editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_LOW)
.build();
assertTrue(addressBook.hasPatient(editedAlice));
}
+ @Test
+ public void hasAppointment_nullAppointment_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> addressBook.hasAppointment(null));
+ }
+
+ @Test
+ public void hasAppointment_appointmentNotInAddressBook_returnsFalse() {
+ assertFalse(addressBook.hasAppointment(APPOINTMENT_1));
+ }
+
+ @Test
+ public void hasAppointment_appointmentInAddressBook_returnsTrue() {
+ addressBook.addAppointment(APPOINTMENT_1);
+ assertTrue(addressBook.hasAppointment(APPOINTMENT_1));
+ }
+
+ @Test
+ public void hasAppointment_appointmentWithSameFieldsInAddressBook_returnsTrue() {
+ addressBook.addAppointment(APPOINTMENT_1);
+ Appointment appointment = new AppointmentBuilder().build();
+ assertTrue(addressBook.hasAppointment(appointment));
+ }
+
@Test
public void getPatientList_modifyList_throwsUnsupportedOperationException() {
assertThrows(UnsupportedOperationException.class, () -> addressBook.getPatientList().remove(0));
@@ -88,7 +114,8 @@ public void getPatientList_modifyList_throwsUnsupportedOperationException() {
@Test
public void toStringMethod() {
String expected = AddressBook.class.getCanonicalName() + "{patients=" + addressBook.getPatientList()
- + ", doctors=" + addressBook.getDoctorList() + "}";
+ + ", doctors=" + addressBook.getDoctorList() + ", appointments="
+ + addressBook.getAppointmentList() + "}";
assertEquals(expected, addressBook.toString());
}
@@ -98,6 +125,7 @@ public void toStringMethod() {
private static class AddressBookStub implements ReadOnlyAddressBook {
private final ObservableList patients = FXCollections.observableArrayList(); // I think this is wrong
private final ObservableList doctors = FXCollections.observableArrayList();
+ private final ObservableList appointments = FXCollections.observableArrayList();
AddressBookStub(Collection persons) {
for (Person p : persons) {
@@ -122,6 +150,11 @@ public ObservableList getDoctorList() {
public ObservableList getPatientList() {
return patients;
}
+
+ @Override
+ public ObservableList getAppointmentList() {
+ return appointments;
+ }
}
}
diff --git a/src/test/java/seedu/address/model/ModelManagerTest.java b/src/test/java/seedu/address/model/ModelManagerTest.java
index 030b71070aa..a23a63013b2 100644
--- a/src/test/java/seedu/address/model/ModelManagerTest.java
+++ b/src/test/java/seedu/address/model/ModelManagerTest.java
@@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.model.Model.PREDICATE_SHOW_ALL_PERSONS;
import static seedu.address.testutil.Assert.assertThrows;
+import static seedu.address.testutil.TypicalDoctor.BOYD;
import static seedu.address.testutil.TypicalPatient.ALICE;
import static seedu.address.testutil.TypicalPatient.BENSON;
@@ -79,12 +80,15 @@ public void hasPerson_nullPerson_throwsNullPointerException() {
@Test
public void hasPerson_personNotInAddressBook_returnsFalse() {
assertFalse(modelManager.hasPerson(ALICE));
+ assertFalse(modelManager.hasPerson(BOYD));
}
@Test
public void hasPerson_personInAddressBook_returnsTrue() {
modelManager.addPerson(ALICE);
assertTrue(modelManager.hasPerson(ALICE));
+ modelManager.addPerson(BOYD);
+ assertTrue(modelManager.hasPerson(BOYD));
}
@Test
diff --git a/src/test/java/seedu/address/model/person/AppointmentTest.java b/src/test/java/seedu/address/model/person/AppointmentTest.java
index 2d12f966d00..7b4a67dbfc0 100644
--- a/src/test/java/seedu/address/model/person/AppointmentTest.java
+++ b/src/test/java/seedu/address/model/person/AppointmentTest.java
@@ -14,6 +14,7 @@
import org.junit.jupiter.api.Test;
import seedu.address.model.appointment.Appointment;
+import seedu.address.model.appointment.AppointmentTime;
public class AppointmentTest {
@Test
@@ -24,13 +25,13 @@ public void constructor_null_throwsNullPointerException() {
@Test
public void constructor_nullDoctor_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new Appointment(null, new Ic(VALID_NRIC_AMY),
- VALID_DATE_1));
+ new AppointmentTime(VALID_DATE_1)));
}
@Test
public void constructor_nullPatient_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new Appointment(new Ic(VALID_NRIC_DEREK), null,
- VALID_DATE_1));
+ new AppointmentTime(VALID_DATE_1)));
}
@Test
@@ -42,13 +43,13 @@ public void constructor_nullAppointmentTime_throwsNullPointerException() {
@Test
public void secondConstructor_nullDoctor_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new Appointment(null, new Ic(VALID_NRIC_AMY),
- VALID_DATE_1, "Follow-Up"));
+ new AppointmentTime(VALID_DATE_1), "Follow-Up"));
}
@Test
public void secondConstructorr_nullPatient_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> new Appointment(new Ic(VALID_NRIC_DEREK), null,
- VALID_DATE_1, "Follow-Up"));
+ new AppointmentTime(VALID_DATE_1), "Follow-Up"));
}
@Test
@@ -60,63 +61,62 @@ public void secondConstructor_nullAppointmentTime_throwsNullPointerException() {
@Test
public void constructor_nullStatus() { // should this throw a nullPointerException?
assertThrows(NullPointerException.class, (
- ) -> new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1, null));
+ ) -> new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), new AppointmentTime(VALID_DATE_1),
+ null));
}
@Test
public void testGetDoctor() {
- Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1);
+ Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
+ new AppointmentTime(VALID_DATE_1));
assertEquals(newAppointment.getDoctor(), new Ic(VALID_NRIC_DEREK));
}
@Test
public void testGetPatient() {
- Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1);
+ Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
+ new AppointmentTime(VALID_DATE_1));
assertEquals(newAppointment.getPatient(), new Ic(VALID_NRIC_AMY));
}
@Test
public void testGetAppointmentTime() {
- Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1);
- assertEquals(newAppointment.getAppointmentTime(), VALID_DATE_1);
+ Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
+ new AppointmentTime(VALID_DATE_1));
+ assertEquals(newAppointment.getAppointmentTime(), new AppointmentTime(VALID_DATE_1));
}
@Test
public void testChangeDoctor() {
- Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1);
+ Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
+ new AppointmentTime(VALID_DATE_1));
newAppointment.changeDoctor(new Ic(VALID_NRIC_CHERYL));
assertEquals(newAppointment.getDoctor(), new Ic(VALID_NRIC_CHERYL));
}
@Test
public void testChangePatient() {
- Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1);
+ Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
+ new AppointmentTime(VALID_DATE_1));
newAppointment.changePatient(new Ic(VALID_NRIC_BOB));
assertEquals(newAppointment.getPatient(), new Ic(VALID_NRIC_BOB));
}
@Test
public void testSetAppointmentTime() {
- Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1);
- newAppointment.setAppointmentTime(VALID_DATE_2);
- assertEquals(newAppointment.getAppointmentTime(), VALID_DATE_2);
+ Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
+ new AppointmentTime(VALID_DATE_1));
+ newAppointment.setAppointmentTime(new AppointmentTime(VALID_DATE_2));
+ assertEquals(newAppointment.getAppointmentTime(), new AppointmentTime(VALID_DATE_2));
}
-
- @Test
- public void testChangeStatus() {
- String newStatus = "Completed";
- Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1);
- newAppointment.changeStatus(newStatus);
- assertEquals(newAppointment.getStatus(), newStatus);
- }
-
- @Test
public void equals() {
- Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1);
+ Appointment newAppointment = new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
+ new AppointmentTime(VALID_DATE_1));
// same values -> returns true
assertTrue(
- newAppointment.equals(new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY), VALID_DATE_1)));
+ newAppointment.equals(new Appointment(new Ic(VALID_NRIC_DEREK), new Ic(VALID_NRIC_AMY),
+ new AppointmentTime(VALID_DATE_1))));
// same object -> returns true
assertTrue(newAppointment.equals(newAppointment));
@@ -129,6 +129,6 @@ public void equals() {
// different values -> returns false
assertFalse(newAppointment.equals(
- new Appointment(new Ic(VALID_NRIC_CHERYL), new Ic(VALID_NRIC_AMY), VALID_DATE_1)));
+ new Appointment(new Ic(VALID_NRIC_CHERYL), new Ic(VALID_NRIC_AMY), new AppointmentTime(VALID_DATE_1))));
}
}
diff --git a/src/test/java/seedu/address/model/person/AppointmentTimeTest.java b/src/test/java/seedu/address/model/person/AppointmentTimeTest.java
new file mode 100644
index 00000000000..80af506af76
--- /dev/null
+++ b/src/test/java/seedu/address/model/person/AppointmentTimeTest.java
@@ -0,0 +1,81 @@
+package seedu.address.model.person;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static seedu.address.testutil.Assert.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+import seedu.address.model.appointment.AppointmentTime;
+
+public class AppointmentTimeTest {
+ @Test
+ public void constructor_null_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> new AppointmentTime(null));
+ }
+
+ @Test
+ public void constructor_invalidAppointmentTime1_throwsIllegalArgumentException() {
+ String invalidAppointment1 = "S458Z";
+ assertThrows(IllegalArgumentException.class, () -> new Ic(invalidAppointment1));
+ }
+
+ @Test
+ public void constructor_invalidIc2_throwsIllegalArgumentException() {
+ String invalidAppointment2 = "2023/10/15 12:00";
+ assertThrows(IllegalArgumentException.class, () -> new Ic(invalidAppointment2));
+ }
+
+ @Test
+ public void isValidAppointmentTime() {
+ // null appointment time
+ assertThrows(NullPointerException.class, () -> AppointmentTime.isValidAppointmentTime(null));
+
+ // invalid appointment time
+ assertFalse(AppointmentTime.isValidAppointmentTime("")); // empty string
+ assertFalse(AppointmentTime.isValidAppointmentTime(" ")); // spaces only
+ assertFalse(AppointmentTime.isValidAppointmentTime("2023-10-20")); // only date no time
+ assertFalse(AppointmentTime.isValidAppointmentTime("2023/12/12 10:00")); // does not follow the correct format
+
+ // valid appointment time
+ assertTrue(AppointmentTime.isValidAppointmentTime("2023-10-20 12:00")); // follows yyyy-mm-dd hh:mm format
+ }
+
+ @Test
+ public void equals() {
+ AppointmentTime appointmentTime = new AppointmentTime("2023-10-20 12:00");
+
+ // same values -> returns true
+ assertTrue(appointmentTime.equals(new AppointmentTime("2023-10-20 12:00")));
+
+ // same object -> returns true
+ assertTrue(appointmentTime.equals(appointmentTime));
+
+ // null -> returns false
+ assertFalse(appointmentTime.equals(null));
+
+ // different types -> returns false
+ assertFalse(appointmentTime.equals(5.0f));
+
+ // different values -> returns false
+ assertFalse(appointmentTime.equals(new AppointmentTime("2023-10-20 13:00")));
+ }
+
+ @Test
+ public void compareTo() {
+ AppointmentTime appointmentTime1 = new AppointmentTime("2023-10-20 12:00");
+ AppointmentTime appointmentTime2 = new AppointmentTime("2023-10-20 13:00");
+ AppointmentTime appointmentTime3 = new AppointmentTime("2023-10-20 11:00");
+
+ // compare to itself -> return 0
+ assertEquals(0, appointmentTime1.compareTo(appointmentTime1));
+
+ // same value -> return 0
+ assertEquals(0, appointmentTime1.compareTo(new AppointmentTime("2023-10-20 12:00")));
+
+ // different values -> compare correctly
+ assertTrue(appointmentTime1.compareTo(appointmentTime2) < 0);
+ assertTrue(appointmentTime1.compareTo(appointmentTime3) > 0);
+ }
+}
diff --git a/src/test/java/seedu/address/model/person/BloodTypePredicateTest.java b/src/test/java/seedu/address/model/person/BloodTypePredicateTest.java
index b8f7816b248..d43ac0b0f8a 100644
--- a/src/test/java/seedu/address/model/person/BloodTypePredicateTest.java
+++ b/src/test/java/seedu/address/model/person/BloodTypePredicateTest.java
@@ -11,8 +11,8 @@
public class BloodTypePredicateTest {
@Test
public void equals() {
- String firstPredicateKeyword = "Blood Type A+";
- String secondPredicateKeyword = "Blood Type B-";
+ String firstPredicateKeyword = "A+";
+ String secondPredicateKeyword = "B-";
BloodTypePredicate firstPredicate = new BloodTypePredicate(firstPredicateKeyword);
BloodTypePredicate secondPredicate = new BloodTypePredicate(secondPredicateKeyword);
@@ -36,47 +36,47 @@ public void equals() {
@Test
public void testCorrectBloodTypePredicate() {
- BloodTypePredicate aPlusPredicate = new BloodTypePredicate("Blood Type A+");
- BloodTypePredicate aMinusPredicate = new BloodTypePredicate("Blood Type A-");
- BloodTypePredicate bPlusPredicate = new BloodTypePredicate("Blood Type B+");
- BloodTypePredicate bMinusPredicate = new BloodTypePredicate("Blood Type B-");
- BloodTypePredicate abPlusPredicate = new BloodTypePredicate("Blood Type AB+");
- BloodTypePredicate abMinusPredicate = new BloodTypePredicate("Blood Type AB-");
- BloodTypePredicate oPlusPredicate = new BloodTypePredicate("Blood Type O+");
- BloodTypePredicate oMinusPredicate = new BloodTypePredicate("Blood Type O-");
- // Test with a person having A+ blood type.
+ BloodTypePredicate aPlusPredicate = new BloodTypePredicate("A+");
+ BloodTypePredicate aMinusPredicate = new BloodTypePredicate("A-");
+ BloodTypePredicate bPlusPredicate = new BloodTypePredicate("B+");
+ BloodTypePredicate bMinusPredicate = new BloodTypePredicate("B-");
+ BloodTypePredicate abPlusPredicate = new BloodTypePredicate("AB+");
+ BloodTypePredicate abMinusPredicate = new BloodTypePredicate("AB-");
+ BloodTypePredicate oPlusPredicate = new BloodTypePredicate("O+");
+ BloodTypePredicate oMinusPredicate = new BloodTypePredicate("O-");
+ // Test with a person having A+ .
assertTrue(aPlusPredicate.test(new PatientBuilder().withBloodType("A+").build()));
- // Test with a person having A- blood type.
+ // Test with a person having A- .
assertTrue(aMinusPredicate.test(new PatientBuilder().withBloodType("A-").build()));
- // Test with a person having B+ blood type.
+ // Test with a person having B+ .
assertTrue(bPlusPredicate.test(new PatientBuilder().withBloodType("B+").build()));
- // Test with a person having B- blood type.
+ // Test with a person having B- .
assertTrue(bMinusPredicate.test(new PatientBuilder().withBloodType("B-").build()));
- // Test with a person having AB+ blood type.
+ // Test with a person having AB+ .
assertTrue(abPlusPredicate.test(new PatientBuilder().withBloodType("AB+").build()));
- // Test with a person having AB- blood type.
+ // Test with a person having AB- .
assertTrue(abMinusPredicate.test(new PatientBuilder().withBloodType("AB-").build()));
- // Test with a person having O+ blood type.
+ // Test with a person having O+ .
assertTrue(oPlusPredicate.test(new PatientBuilder().withBloodType("O+").build()));
- // Test with a person having O- blood type.
+ // Test with a person having O- .
assertTrue(oMinusPredicate.test(new PatientBuilder().withBloodType("O-").build()));
}
@Test
public void testWrongBloodTypePredicate() {
- BloodTypePredicate aPlusPredicate = new BloodTypePredicate("Blood Type A+");
- BloodTypePredicate aMinusPredicate = new BloodTypePredicate("Blood Type A-");
- BloodTypePredicate bPlusPredicate = new BloodTypePredicate("Blood Type B+");
- BloodTypePredicate bMinusPredicate = new BloodTypePredicate("Blood Type B-");
- BloodTypePredicate abPlusPredicate = new BloodTypePredicate("Blood Type AB+");
- BloodTypePredicate abMinusPredicate = new BloodTypePredicate("Blood Type AB-");
+ BloodTypePredicate aPlusPredicate = new BloodTypePredicate(" A+");
+ BloodTypePredicate aMinusPredicate = new BloodTypePredicate(" A-");
+ BloodTypePredicate bPlusPredicate = new BloodTypePredicate(" B+");
+ BloodTypePredicate bMinusPredicate = new BloodTypePredicate(" B-");
+ BloodTypePredicate abPlusPredicate = new BloodTypePredicate(" AB+");
+ BloodTypePredicate abMinusPredicate = new BloodTypePredicate(" AB-");
assertFalse(aPlusPredicate.test(new PatientBuilder().withBloodType("A-").build()));
assertFalse(aMinusPredicate.test(new PatientBuilder().withBloodType("AB+").build()));
@@ -89,7 +89,7 @@ public void testWrongBloodTypePredicate() {
@Test
public void toStringMethod() {
String keyword = "keyword1";
- BloodTypePredicate predicate = new BloodTypePredicate("Blood type keyword1");
+ BloodTypePredicate predicate = new BloodTypePredicate("keyword1");
String expected = BloodTypePredicate.class.getCanonicalName() + "{keywords=" + keyword + "}";
assertEquals(expected, predicate.toString());
diff --git a/src/test/java/seedu/address/model/person/DoctorTest.java b/src/test/java/seedu/address/model/person/DoctorTest.java
index 432df2553d8..d1c0bf08b89 100644
--- a/src/test/java/seedu/address/model/person/DoctorTest.java
+++ b/src/test/java/seedu/address/model/person/DoctorTest.java
@@ -13,7 +13,7 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_CHERYL;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_CHERYL;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_SURGEON;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalDoctor.ALICE;
import static seedu.address.testutil.TypicalDoctor.CHERYL;
@@ -86,7 +86,7 @@ public void equals() {
assertFalse(ALICE.equals(editedAlice));
// different tags -> returns false
- editedAlice = new DoctorBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build();
+ editedAlice = new DoctorBuilder(ALICE).withTags(VALID_TAG_SURGEON).build();
assertFalse(ALICE.equals(editedAlice));
}
diff --git a/src/test/java/seedu/address/model/person/GenderPredicateTest.java b/src/test/java/seedu/address/model/person/GenderPredicateTest.java
index ff48262ea89..ac4687d999f 100644
--- a/src/test/java/seedu/address/model/person/GenderPredicateTest.java
+++ b/src/test/java/seedu/address/model/person/GenderPredicateTest.java
@@ -1,27 +1,65 @@
package seedu.address.model.person;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
-import seedu.address.testutil.PersonBuilder;
+import seedu.address.testutil.PatientBuilder;
public class GenderPredicateTest {
-
@Test
- public void testGenderPredicate() {
+ public void correctGenderPredicate_returnsTrue() {
GenderPredicate malePredicate = new GenderPredicate("M");
GenderPredicate femalePredicate = new GenderPredicate("F");
-
// Test with a person having MALE gender
- assertTrue(malePredicate.test(new PersonBuilder().withGender("M").build()));
-
+ assertTrue(malePredicate.test(new PatientBuilder().withGender("M").build()));
// Test with a person having FEMALE gender
- assertTrue(femalePredicate.test(new PersonBuilder().withGender("F").build()));
+ assertTrue(femalePredicate.test(new PatientBuilder().withGender("F").build()));
+ }
+ @Test
+ public void wrongGenderPredicate_returnsFalse() {
+ GenderPredicate malePredicate = new GenderPredicate("M");
+ GenderPredicate femalePredicate = new GenderPredicate("F");
// Test with a person having a different gender
- assertFalse(malePredicate.test(new PersonBuilder().withGender("F").build()));
+ assertFalse(malePredicate.test(new PatientBuilder().withGender("F").build()));
+ assertFalse(femalePredicate.test(new PatientBuilder().withGender("M").build()));
+ }
+
+ @Test
+ public void equals() {
+ String firstPredicateKeyword = "M";
+ String secondPredicateKeyword = "F";
+
+ GenderPredicate firstPredicate = new GenderPredicate(firstPredicateKeyword);
+ GenderPredicate secondPredicate = new GenderPredicate(secondPredicateKeyword);
+
+ // same object -> returns true
+ assertTrue(firstPredicate.equals(firstPredicate));
+
+ // same values -> returns true
+ GenderPredicate firstPredicateCopy = new GenderPredicate(firstPredicateKeyword);
+ assertTrue(firstPredicate.equals(firstPredicateCopy));
+
+ // different types -> returns false
+ assertFalse(firstPredicate.equals(1));
+
+ // null -> returns false
+ assertFalse(firstPredicate.equals(null));
+
+ // different person -> returns false
+ assertFalse(firstPredicate.equals(secondPredicate));
+ }
+
+ @Test
+ public void toStringMethod() {
+ String keyword = "keyword1";
+ GenderPredicate predicate = new GenderPredicate(keyword);
+
+ String expected = GenderPredicate.class.getCanonicalName() + "{keywords=" + keyword + "}";
+ assertEquals(expected, predicate.toString());
}
}
diff --git a/src/test/java/seedu/address/model/person/IcContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/person/IcContainsKeywordsPredicateTest.java
index 906c0a98e29..1d31b3976ee 100644
--- a/src/test/java/seedu/address/model/person/IcContainsKeywordsPredicateTest.java
+++ b/src/test/java/seedu/address/model/person/IcContainsKeywordsPredicateTest.java
@@ -6,7 +6,7 @@
import org.junit.jupiter.api.Test;
-import seedu.address.testutil.PersonBuilder;
+import seedu.address.testutil.PatientBuilder;
public class IcContainsKeywordsPredicateTest {
@@ -39,18 +39,18 @@ public void equals() {
public void test_icContainsKeywords_returnsTrue() {
// Test with a person having matching IC
IcContainsKeywordsPredicate icPredicate = new IcContainsKeywordsPredicate("T1234567G");
- assertTrue(icPredicate.test(new PersonBuilder().withIc("T1234567G").build()));
+ assertTrue(icPredicate.test(new PatientBuilder().withIc("T1234567G").build()));
}
@Test
public void test_icDoesNotContainKeywords_returnsFalse() {
// Zero keywords
IcContainsKeywordsPredicate predicate = new IcContainsKeywordsPredicate(" ");
- assertFalse(predicate.test(new PersonBuilder().withIc("T1234567Q").build()));
+ assertFalse(predicate.test(new PatientBuilder().withIc("T1234567Q").build()));
// Non-matching keyword
predicate = new IcContainsKeywordsPredicate("S0001004Q");
- assertFalse(predicate.test(new PersonBuilder().withIc("T1123876Q").build()));
+ assertFalse(predicate.test(new PatientBuilder().withIc("T1123876Q").build()));
}
@Test
diff --git a/src/test/java/seedu/address/model/person/IcTest.java b/src/test/java/seedu/address/model/person/IcTest.java
index eb3c4ec5de4..bb24fcdea6f 100644
--- a/src/test/java/seedu/address/model/person/IcTest.java
+++ b/src/test/java/seedu/address/model/person/IcTest.java
@@ -34,6 +34,7 @@ public void isValidIc() {
assertFalse(Ic.isValidIc(" ")); // spaces only
assertFalse(Ic.isValidIc("S333444Z")); // only 6 numbers included
assertFalse(Ic.isValidIc("G2223331H")); // starting alphabet not S or T
+ assertFalse(Ic.isValidIc("s2223331H")); // alphabets not in caps
// valid nric
assertTrue(Ic.isValidIc("S0345999H")); // starting alphabet S
diff --git a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java b/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java
index 6b3fd90ade7..6df14450723 100644
--- a/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java
+++ b/src/test/java/seedu/address/model/person/NameContainsKeywordsPredicateTest.java
@@ -10,7 +10,7 @@
import org.junit.jupiter.api.Test;
-import seedu.address.testutil.PersonBuilder;
+import seedu.address.testutil.PatientBuilder;
public class NameContainsKeywordsPredicateTest {
@@ -43,34 +43,34 @@ public void equals() {
public void test_nameContainsKeywords_returnsTrue() {
// One keyword
NameContainsKeywordsPredicate predicate = new NameContainsKeywordsPredicate(Collections.singletonList("Alice"));
- assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build()));
+ assertTrue(predicate.test(new PatientBuilder().withName("Alice Bob").build()));
// Multiple keywords
predicate = new NameContainsKeywordsPredicate(Arrays.asList("Alice", "Bob"));
- assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build()));
+ assertTrue(predicate.test(new PatientBuilder().withName("Alice Bob").build()));
// Only one matching keyword
predicate = new NameContainsKeywordsPredicate(Arrays.asList("Bob", "Carol"));
- assertTrue(predicate.test(new PersonBuilder().withName("Alice Carol").build()));
+ assertTrue(predicate.test(new PatientBuilder().withName("Alice Carol").build()));
// Mixed-case keywords
predicate = new NameContainsKeywordsPredicate(Arrays.asList("aLIce", "bOB"));
- assertTrue(predicate.test(new PersonBuilder().withName("Alice Bob").build()));
+ assertTrue(predicate.test(new PatientBuilder().withName("Alice Bob").build()));
}
@Test
public void test_nameDoesNotContainKeywords_returnsFalse() {
// Zero keywords
NameContainsKeywordsPredicate predicate = new NameContainsKeywordsPredicate(Collections.emptyList());
- assertFalse(predicate.test(new PersonBuilder().withName("Alice").build()));
+ assertFalse(predicate.test(new PatientBuilder().withName("Alice").build()));
// Non-matching keyword
predicate = new NameContainsKeywordsPredicate(Arrays.asList("Carol"));
- assertFalse(predicate.test(new PersonBuilder().withName("Alice Bob").build()));
+ assertFalse(predicate.test(new PatientBuilder().withName("Alice Bob").build()));
// Keywords match phone, email and address, but does not match name
predicate = new NameContainsKeywordsPredicate(Arrays.asList("12345", "alice@email.com", "Main", "Street"));
- assertFalse(predicate.test(new PersonBuilder().withName("Alice").withPhone("12345")
+ assertFalse(predicate.test(new PatientBuilder().withName("Alice").withPhone("12345")
.withEmail("alice@email.com").withAddress("Main Street").build()));
}
diff --git a/src/test/java/seedu/address/model/person/PatientTest.java b/src/test/java/seedu/address/model/person/PatientTest.java
index 101765ff709..415fba681d9 100644
--- a/src/test/java/seedu/address/model/person/PatientTest.java
+++ b/src/test/java/seedu/address/model/person/PatientTest.java
@@ -12,7 +12,7 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_MEDIUM;
import static seedu.address.testutil.Assert.assertThrows;
import static seedu.address.testutil.TypicalPatient.ALICE;
import static seedu.address.testutil.TypicalPatient.BOB;
@@ -39,7 +39,7 @@ public void isSamePerson() {
// same ic, all other attributes different -> returns true
Patient editedAlice = new PatientBuilder(ALICE).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB)
- .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND).withName(VALID_NAME_BOB)
+ .withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_MEDIUM).withName(VALID_NAME_BOB)
.withGender(VALID_GENDER_MALE).withCondition(VALID_CONDITION_BOB).withBloodType(VALID_BLOODTYPE_BOB)
.withEmergencyContact(VALID_EMERGENCY_CONTACT_BOB).build();
assertTrue(ALICE.isSamePerson(editedAlice));
@@ -49,6 +49,11 @@ public void isSamePerson() {
assertFalse(ALICE.isSamePerson(editedAlice));
}
+ @Test
+ public void isDoctor() {
+ assertFalse(ALICE.isDoctor());
+ }
+
@Test
public void equals() {
// same values -> returns true
@@ -84,7 +89,7 @@ public void equals() {
assertFalse(ALICE.equals(editedAlice));
// different tags -> returns false
- editedAlice = new PatientBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build();
+ editedAlice = new PatientBuilder(ALICE).withTags(VALID_TAG_MEDIUM).build();
assertFalse(ALICE.equals(editedAlice));
// different emergency contact -> return false
@@ -100,6 +105,51 @@ public void equals() {
assertFalse(ALICE.equals(editedAlice));
}
+ @Test
+ public void hashCodeTest() {
+ // same values -> returns true
+ Patient aliceCopy = new PatientBuilder(ALICE).build();
+ assertTrue(ALICE.hashCode() == aliceCopy.hashCode());
+
+ // same object -> returns true
+ assertTrue(ALICE.hashCode() == ALICE.hashCode());
+
+ // different person shuold have different hashCode -> returns false
+ assertFalse(ALICE.hashCode() == BOB.hashCode());
+
+ // different name -> returns false
+ Patient editedAlice = new PatientBuilder(ALICE).withName(VALID_NAME_BOB).build();
+ assertFalse(ALICE.hashCode() == editedAlice.hashCode());
+
+ // different phone -> returns false
+ editedAlice = new PatientBuilder(ALICE).withPhone(VALID_PHONE_BOB).build();
+ assertFalse(ALICE.hashCode() == editedAlice.hashCode());
+
+ // different email -> returns false
+ editedAlice = new PatientBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build();
+ assertFalse(ALICE.hashCode() == editedAlice.hashCode());
+
+ // different address -> returns false
+ editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build();
+ assertFalse(ALICE.hashCode() == editedAlice.hashCode());
+
+ // different tags -> returns false
+ editedAlice = new PatientBuilder(ALICE).withTags(VALID_TAG_MEDIUM).build();
+ assertFalse(ALICE.hashCode() == editedAlice.hashCode());
+
+ // different emergency contact -> return false
+ editedAlice = new PatientBuilder(ALICE).withEmergencyContact(VALID_EMERGENCY_CONTACT_BOB).build();
+ assertFalse(ALICE.hashCode() == editedAlice.hashCode());
+
+ // different condition -> return false
+ editedAlice = new PatientBuilder(ALICE).withCondition(VALID_CONDITION_BOB).build();
+ assertFalse(ALICE.hashCode() == editedAlice.hashCode());
+
+ // different blood type -> return false
+ editedAlice = new PatientBuilder(ALICE).withBloodType(VALID_BLOODTYPE_BOB).build();
+ assertFalse(ALICE.hashCode() == editedAlice.hashCode());
+ }
+
@Test
public void toStringMethod() {
String expected = Patient.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone()
diff --git a/src/test/java/seedu/address/model/person/PersonTest.java b/src/test/java/seedu/address/model/person/PersonTest.java
deleted file mode 100644
index 5b19ed650c1..00000000000
--- a/src/test/java/seedu/address/model/person/PersonTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package seedu.address.model.person;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_EMAIL_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_GENDER_MALE;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_NAME_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_ALICE;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
-import static seedu.address.testutil.Assert.assertThrows;
-import static seedu.address.testutil.TypicalPatient.ALICE;
-import static seedu.address.testutil.TypicalPatient.BOB;
-
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-
-import seedu.address.testutil.PersonBuilder;
-
-@Disabled("Disabled since we will be moving Person class to abstract in the future")
-public class PersonTest {
-
- @Test
- public void asObservableList_modifyList_throwsUnsupportedOperationException() {
- Person person = new PersonBuilder().build();
- assertThrows(UnsupportedOperationException.class, () -> person.getTags().remove(0));
- }
-
- @Test
- public void isSamePerson() {
- // same object -> returns true
- assertTrue(ALICE.isSamePerson(ALICE));
-
- // null -> returns false
- assertFalse(ALICE.isSamePerson(null));
-
- // same nric, all other attributes different -> returns true
- Person editedAlice = new PersonBuilder(BOB).withPhone(VALID_PHONE_BOB).withEmail(VALID_EMAIL_BOB)
- .withAddress(VALID_ADDRESS_BOB).withGender(VALID_GENDER_MALE).withIc(VALID_NRIC_ALICE)
- .withTags(VALID_TAG_HUSBAND).build();
- assertTrue(ALICE.isSamePerson(editedAlice));
-
- // different nric, all other attributes same -> returns false
- editedAlice = new PersonBuilder(ALICE).withIc(VALID_NRIC_BOB).build();
- assertFalse(ALICE.isSamePerson(editedAlice));
- }
-
- @Test
- public void equals() {
- // same values -> returns true
- Person aliceCopy = new PersonBuilder(ALICE).build();
- assertTrue(ALICE.equals(aliceCopy));
-
- // same object -> returns true
- assertTrue(ALICE.equals(ALICE));
-
- // null -> returns false
- assertFalse(ALICE.equals(null));
-
- // different type -> returns false
- assertFalse(ALICE.equals(5));
-
- // different person -> returns false
- assertFalse(ALICE.equals(BOB));
-
- // different name -> returns false
- Person editedAlice = new PersonBuilder(ALICE).withName(VALID_NAME_BOB).build();
- assertFalse(ALICE.equals(editedAlice));
-
- // different phone -> returns false
- editedAlice = new PersonBuilder(ALICE).withPhone(VALID_PHONE_BOB).build();
- assertFalse(ALICE.equals(editedAlice));
-
- // different email -> returns false
- editedAlice = new PersonBuilder(ALICE).withEmail(VALID_EMAIL_BOB).build();
- assertFalse(ALICE.equals(editedAlice));
-
- // different address -> returns false
- editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).build();
- assertFalse(ALICE.equals(editedAlice));
-
- // different tags -> returns false
- editedAlice = new PersonBuilder(ALICE).withTags(VALID_TAG_HUSBAND).build();
- assertFalse(ALICE.equals(editedAlice));
- }
-
- @Test
- public void toStringMethod() {
- String expected = Person.class.getCanonicalName() + "{name=" + ALICE.getName() + ", phone=" + ALICE.getPhone()
- + ", email=" + ALICE.getEmail() + ", address=" + ALICE.getAddress() + ", remark=" + ALICE.getRemark()
- + ", gender=" + ALICE.getGender() + ", nric=" + ALICE.getIc() + ", tags=" + ALICE.getTags() + "}";
- assertEquals(expected, ALICE.toString());
- }
-}
diff --git a/src/test/java/seedu/address/model/person/UniqueAppointmentListTest.java b/src/test/java/seedu/address/model/person/UniqueAppointmentListTest.java
new file mode 100644
index 00000000000..aa8aeb225b7
--- /dev/null
+++ b/src/test/java/seedu/address/model/person/UniqueAppointmentListTest.java
@@ -0,0 +1,143 @@
+package seedu.address.model.person;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static seedu.address.testutil.Assert.assertThrows;
+import static seedu.address.testutil.TypicalAppointment.APPOINTMENT_1;
+import static seedu.address.testutil.TypicalAppointment.APPOINTMENT_2;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
+
+import seedu.address.model.appointment.Appointment;
+import seedu.address.model.person.exceptions.DuplicateObjectException;
+import seedu.address.model.person.exceptions.ObjectNotFoundException;
+
+public class UniqueAppointmentListTest {
+
+ private final UniqueAppointmentList uniqueAppointmentList = new UniqueAppointmentList();
+
+ @Test
+ public void contains_nullAppointment_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniqueAppointmentList.contains(null));
+ }
+
+ @Test
+ public void contains_appointmentNotInList_returnsFalse() {
+ assertFalse(uniqueAppointmentList.contains(APPOINTMENT_1));
+ }
+
+ @Test
+ public void contains_appointmentInList_returnsTrue() {
+ uniqueAppointmentList.add(APPOINTMENT_1);
+ assertTrue(uniqueAppointmentList.contains(APPOINTMENT_1));
+ }
+
+ @Test
+ public void add_nullAppointment_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniqueAppointmentList.add(null));
+ }
+
+ @Test
+ public void add_duplicateAppointment_throwsDuplicateAppointmentException() {
+ uniqueAppointmentList.add(APPOINTMENT_1);
+ assertThrows(DuplicateObjectException.class, () -> uniqueAppointmentList.add(APPOINTMENT_1));
+ }
+
+ @Test
+ public void setObject_nullTargetAppointment_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniqueAppointmentList.setObject(null, APPOINTMENT_2));
+ }
+
+ @Test
+ public void setObject_nullEditedAppointment_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniqueAppointmentList.setObject(APPOINTMENT_1,
+ null));
+ }
+
+ @Test
+ public void setObject_targetAppointmentNotInList_throwsObjectNotFoundException() {
+ assertThrows(ObjectNotFoundException.class, () -> uniqueAppointmentList.setObject(APPOINTMENT_1,
+ APPOINTMENT_1));
+ }
+
+ @Test
+ public void setObject_editedAppointmentIsSameAppointment_success() {
+ uniqueAppointmentList.add(APPOINTMENT_1);
+ uniqueAppointmentList.setObject(APPOINTMENT_1, APPOINTMENT_1);
+ UniqueAppointmentList expectedUniqueAppointmentList = new UniqueAppointmentList();
+ expectedUniqueAppointmentList.add(APPOINTMENT_1);
+ assertEquals(expectedUniqueAppointmentList, uniqueAppointmentList);
+ }
+
+ @Test
+ public void remove_nullAppointment_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniqueAppointmentList.remove(null));
+ }
+
+ @Test
+ public void remove_appointmentDoesNotExist_throwsObjectNotFoundException() {
+ assertThrows(ObjectNotFoundException.class, () -> uniqueAppointmentList.remove(APPOINTMENT_1));
+ }
+
+ @Test
+ public void remove_existingAppointment_removesAppointment() {
+ uniqueAppointmentList.add(APPOINTMENT_1);
+ uniqueAppointmentList.remove(APPOINTMENT_1);
+ UniqueAppointmentList expectedUniqueAppointmentList = new UniqueAppointmentList();
+ assertEquals(expectedUniqueAppointmentList, uniqueAppointmentList);
+ }
+
+ @Test
+ public void setAppointments_nullUniqueAppointmentList_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () ->
+ uniqueAppointmentList.setAppointments((UniqueAppointmentList) null));
+ }
+
+ @Test
+ public void setAppointments_uniqueAppointmentList_replacesOwnListWithProvidedUniqueAppointmentList() {
+ uniqueAppointmentList.add(APPOINTMENT_1);
+ UniqueAppointmentList expectedUniqueAppointmentList = new UniqueAppointmentList();
+ expectedUniqueAppointmentList.add(APPOINTMENT_2);
+ uniqueAppointmentList.setAppointments(expectedUniqueAppointmentList);
+ assertEquals(expectedUniqueAppointmentList, uniqueAppointmentList);
+ }
+
+ @Test
+ public void setObjects_nullList_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniqueAppointmentList.setObjects((List) null));
+ }
+
+ @Test
+ public void setObjects_list_replacesOwnListWithProvidedList() {
+ uniqueAppointmentList.add(APPOINTMENT_1);
+ List appointmentList = Collections.singletonList(APPOINTMENT_1);
+ uniqueAppointmentList.setObjects(appointmentList);
+ UniqueAppointmentList expectedUniqueAppointmentList = new UniqueAppointmentList();
+ expectedUniqueAppointmentList.add(APPOINTMENT_1);
+ assertEquals(expectedUniqueAppointmentList, uniqueAppointmentList);
+ }
+
+ @Test
+ public void setObjects_listWithDuplicatePersons_throwsDuplicateObjectException() {
+ List listWithDuplicateAppointments = Arrays.asList(APPOINTMENT_1, APPOINTMENT_1);
+ assertThrows(DuplicateObjectException.class, () ->
+ uniqueAppointmentList.setObjects(listWithDuplicateAppointments));
+ }
+
+ @Test
+ public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() {
+ assertThrows(UnsupportedOperationException.class, ()
+ -> uniqueAppointmentList.asUnmodifiableObservableList().remove(0));
+ }
+
+ @Test
+ public void toStringMethod() {
+ assertEquals(uniqueAppointmentList.asUnmodifiableObservableList().toString(), uniqueAppointmentList.toString());
+ }
+}
+
diff --git a/src/test/java/seedu/address/model/person/UniqueDoctorListTest.java b/src/test/java/seedu/address/model/person/UniqueDoctorListTest.java
index 61b6e32ef61..ef24f5a0257 100644
--- a/src/test/java/seedu/address/model/person/UniqueDoctorListTest.java
+++ b/src/test/java/seedu/address/model/person/UniqueDoctorListTest.java
@@ -3,11 +3,12 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_DEREK;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_CARDIOLOGIST;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_MEDIUM;
import static seedu.address.testutil.Assert.assertThrows;
-import static seedu.address.testutil.TypicalDoctor.ALLEN;
-import static seedu.address.testutil.TypicalDoctor.WAYNE;
+import static seedu.address.testutil.TypicalDoctor.ALICE;
+import static seedu.address.testutil.TypicalDoctor.BOYD;
import java.util.Arrays;
import java.util.Collections;
@@ -24,27 +25,27 @@ public class UniqueDoctorListTest {
private final UniqueDoctorList uniqueDoctorList = new UniqueDoctorList();
@Test
- public void contains_nullDoctor_throwsNullPointerException() {
+ public void contains_nullPerson_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> uniqueDoctorList.contains(null));
}
@Test
public void contains_personNotInList_returnsFalse() {
- assertFalse(uniqueDoctorList.contains(WAYNE));
+ assertFalse(uniqueDoctorList.contains(ALICE));
}
@Test
public void contains_personInList_returnsTrue() {
- uniqueDoctorList.add(WAYNE);
- assertTrue(uniqueDoctorList.contains(WAYNE));
+ uniqueDoctorList.add(ALICE);
+ assertTrue(uniqueDoctorList.contains(ALICE));
}
@Test
public void contains_personWithSameIdentityFieldsInList_returnsTrue() {
- uniqueDoctorList.add(WAYNE);
- Doctor editedWayne = new DoctorBuilder(WAYNE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND)
+ uniqueDoctorList.add(ALICE);
+ Doctor editedAlice = new DoctorBuilder(ALICE).withAddress(VALID_ADDRESS_DEREK).withTags(VALID_TAG_CARDIOLOGIST)
.build();
- assertTrue(uniqueDoctorList.contains(editedWayne));
+ assertTrue(uniqueDoctorList.contains(editedAlice));
}
@Test
@@ -54,59 +55,59 @@ public void add_nullPerson_throwsNullPointerException() {
@Test
public void add_duplicatePerson_throwsDuplicatePersonException() {
- uniqueDoctorList.add(WAYNE);
- assertThrows(DuplicatePersonException.class, () -> uniqueDoctorList.add(WAYNE));
+ uniqueDoctorList.add(ALICE);
+ assertThrows(DuplicatePersonException.class, () -> uniqueDoctorList.add(ALICE));
}
@Test
- public void setPerson_nullTargetPerson_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniqueDoctorList.setDoctor(null, WAYNE));
+ public void setObject_nullTargetPerson_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniqueDoctorList.setObject(null, ALICE));
}
@Test
- public void setPerson_nullEditedPerson_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniqueDoctorList.setDoctor(WAYNE, null));
+ public void setObject_nullEditedPerson_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniqueDoctorList.setObject(ALICE, null));
}
@Test
- public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() {
- assertThrows(PersonNotFoundException.class, () -> uniqueDoctorList.setDoctor(WAYNE, WAYNE));
+ public void setObject_targetPersonNotInList_throwsPersonNotFoundException() {
+ assertThrows(PersonNotFoundException.class, () -> uniqueDoctorList.setObject(ALICE, ALICE));
}
@Test
- public void setPerson_editedPersonIsSamePerson_success() {
- uniqueDoctorList.add(WAYNE);
- uniqueDoctorList.setDoctor(WAYNE, WAYNE);
+ public void setObject_editedPersonIsSamePerson_success() {
+ uniqueDoctorList.add(ALICE);
+ uniqueDoctorList.setObject(ALICE, ALICE);
UniqueDoctorList expectedUniqueDoctorList = new UniqueDoctorList();
- expectedUniqueDoctorList.add(WAYNE);
+ expectedUniqueDoctorList.add(ALICE);
assertEquals(expectedUniqueDoctorList, uniqueDoctorList);
}
@Test
- public void setPerson_editedPersonHasSameIdentity_success() {
- uniqueDoctorList.add(WAYNE);
- Doctor editedWayne = new DoctorBuilder(WAYNE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND)
+ public void setObject_editedPersonHasSameIdentity_success() {
+ uniqueDoctorList.add(ALICE);
+ Doctor editedAlice = new DoctorBuilder(ALICE).withAddress(VALID_ADDRESS_DEREK).withTags(VALID_TAG_MEDIUM)
.build();
- uniqueDoctorList.setDoctor(WAYNE, editedWayne);
+ uniqueDoctorList.setObject(ALICE, editedAlice);
UniqueDoctorList expectedUniqueDoctorList = new UniqueDoctorList();
- expectedUniqueDoctorList.add(editedWayne);
+ expectedUniqueDoctorList.add(editedAlice);
assertEquals(expectedUniqueDoctorList, uniqueDoctorList);
}
@Test
- public void setPerson_editedPersonHasDifferentIdentity_success() {
- uniqueDoctorList.add(WAYNE);
- uniqueDoctorList.setDoctor(WAYNE, ALLEN);
- UniqueDoctorList expectedUniqueDpctorList = new UniqueDoctorList();
- expectedUniqueDpctorList.add(ALLEN);
- assertEquals(expectedUniqueDpctorList, uniqueDoctorList);
+ public void setObject_editedPersonHasDifferentIdentity_success() {
+ uniqueDoctorList.add(ALICE);
+ uniqueDoctorList.setObject(ALICE, BOYD);
+ UniqueDoctorList expectedUniqueDoctorList = new UniqueDoctorList();
+ expectedUniqueDoctorList.add(BOYD);
+ assertEquals(expectedUniqueDoctorList, uniqueDoctorList);
}
@Test
- public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() {
- uniqueDoctorList.add(WAYNE);
- uniqueDoctorList.add(ALLEN);
- assertThrows(DuplicatePersonException.class, () -> uniqueDoctorList.setDoctor(WAYNE, ALLEN));
+ public void setObject_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() {
+ uniqueDoctorList.add(ALICE);
+ uniqueDoctorList.add(BOYD);
+ assertThrows(DuplicatePersonException.class, () -> uniqueDoctorList.setObject(ALICE, BOYD));
}
@Test
@@ -116,50 +117,50 @@ public void remove_nullPerson_throwsNullPointerException() {
@Test
public void remove_personDoesNotExist_throwsPersonNotFoundException() {
- assertThrows(PersonNotFoundException.class, () -> uniqueDoctorList.remove(WAYNE));
+ assertThrows(PersonNotFoundException.class, () -> uniqueDoctorList.remove(ALICE));
}
@Test
public void remove_existingPerson_removesPerson() {
- uniqueDoctorList.add(WAYNE);
- uniqueDoctorList.remove(WAYNE);
+ uniqueDoctorList.add(ALICE);
+ uniqueDoctorList.remove(ALICE);
UniqueDoctorList expectedUniqueDoctorList = new UniqueDoctorList();
assertEquals(expectedUniqueDoctorList, uniqueDoctorList);
}
@Test
- public void setPersons_nullUniquePersonList_throwsNullPointerException() {
+ public void setPersons_nullUniqueDoctorList_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> uniqueDoctorList.setDoctors((UniqueDoctorList) null));
}
@Test
- public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonList() {
- uniqueDoctorList.add(WAYNE);
+ public void setPersons_uniqueDoctorList_replacesOwnListWithProvidedUniqueDoctorList() {
+ uniqueDoctorList.add(ALICE);
UniqueDoctorList expectedUniqueDoctorList = new UniqueDoctorList();
- expectedUniqueDoctorList.add(ALLEN);
+ expectedUniqueDoctorList.add(BOYD);
uniqueDoctorList.setDoctors(expectedUniqueDoctorList);
assertEquals(expectedUniqueDoctorList, uniqueDoctorList);
}
@Test
public void setPersons_nullList_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniqueDoctorList.setDoctors((List) null));
+ assertThrows(NullPointerException.class, () -> uniqueDoctorList.setObjects((List) null));
}
@Test
- public void setPersons_list_replacesOwnListWithProvidedList() {
- uniqueDoctorList.add(WAYNE);
- List doctorList = Collections.singletonList(ALLEN);
- uniqueDoctorList.setDoctors(doctorList);
+ public void setObjects_list_replacesOwnListWithProvidedList() {
+ uniqueDoctorList.add(ALICE);
+ List doctorList = Collections.singletonList(BOYD);
+ uniqueDoctorList.setObjects(doctorList);
UniqueDoctorList expectedUniqueDoctorList = new UniqueDoctorList();
- expectedUniqueDoctorList.add(ALLEN);
+ expectedUniqueDoctorList.add(BOYD);
assertEquals(expectedUniqueDoctorList, uniqueDoctorList);
}
@Test
- public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() {
- List listWithDuplicateDoctors = Arrays.asList(WAYNE, WAYNE);
- assertThrows(DuplicatePersonException.class, () -> uniqueDoctorList.setDoctors(listWithDuplicateDoctors));
+ public void setObjects_listWithDuplicatePersons_throwsDuplicatePersonException() {
+ List listWithDuplicateDoctors = Arrays.asList(ALICE, ALICE);
+ assertThrows(DuplicatePersonException.class, () -> uniqueDoctorList.setObjects(listWithDuplicateDoctors));
}
@Test
diff --git a/src/test/java/seedu/address/model/person/UniquePatientListTest.java b/src/test/java/seedu/address/model/person/UniquePatientListTest.java
index 68706ecdaa8..046e93e8927 100644
--- a/src/test/java/seedu/address/model/person/UniquePatientListTest.java
+++ b/src/test/java/seedu/address/model/person/UniquePatientListTest.java
@@ -4,9 +4,9 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_MEDIUM;
import static seedu.address.testutil.Assert.assertThrows;
-import static seedu.address.testutil.TypicalPatient.ALICE;
+import static seedu.address.testutil.TypicalPatient.AMY;
import static seedu.address.testutil.TypicalPatient.BOB;
import java.util.Arrays;
@@ -24,142 +24,141 @@ public class UniquePatientListTest {
private final UniquePatientList uniquePatientList = new UniquePatientList();
@Test
- public void contains_nullPatient_throwsNullPointerException() {
+ public void contains_nullPerson_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> uniquePatientList.contains(null));
}
@Test
- public void contains_patientNotInList_returnsFalse() {
- assertFalse(uniquePatientList.contains(ALICE));
+ public void contains_personNotInList_returnsFalse() {
+ assertFalse(uniquePatientList.contains(AMY));
}
@Test
- public void contains_patientInList_returnsTrue() {
- uniquePatientList.add(ALICE);
- assertTrue(uniquePatientList.contains(ALICE));
+ public void contains_personInList_returnsTrue() {
+ uniquePatientList.add(AMY);
+ assertTrue(uniquePatientList.contains(AMY));
}
@Test
- public void contains_patientWithSameIdentityFieldsInList_returnsTrue() {
- uniquePatientList.add(ALICE);
- Patient editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND)
- .build();
- assertTrue(uniquePatientList.contains(editedAlice));
+ public void add_nullPerson_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniquePatientList.add(null));
}
@Test
- public void add_nullPatient_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePatientList.add(null));
+ public void contains_personWithSameIdentityFieldsInList_returnsTrue() {
+ uniquePatientList.add(AMY);
+ Patient editedAmy = new PatientBuilder(AMY).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_MEDIUM).build();
+ assertTrue(uniquePatientList.contains(editedAmy));
}
@Test
- public void add_duplicatePatient_throwsDuplicatePersonException() {
- uniquePatientList.add(ALICE);
- assertThrows(DuplicatePersonException.class, () -> uniquePatientList.add(ALICE));
+ public void add_duplicatePerson_throwsDuplicatePersonException() {
+ uniquePatientList.add(AMY);
+ assertThrows(DuplicatePersonException.class, () -> uniquePatientList.add(AMY));
}
@Test
- public void setPatient_nullTargetPatient_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePatientList.setPatient(null, ALICE));
+ public void setObject_nullTargetPerson_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniquePatientList.setObject(null, AMY));
}
@Test
- public void setPatient_nullEditedPatient_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePatientList.setPatient(ALICE, null));
+ public void setObject_nullEditedPerson_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniquePatientList.setObject(AMY, null));
}
@Test
- public void setPatient_targetPatientNotInList_throwsPersonNotFoundException() {
- assertThrows(PersonNotFoundException.class, () -> uniquePatientList.setPatient(ALICE, ALICE));
+ public void setObject_targetPersonNotInList_throwsPersonNotFoundException() {
+ assertThrows(PersonNotFoundException.class, () -> uniquePatientList.setObject(AMY, AMY));
}
@Test
- public void setPatient_editedPersonIsSamePerson_success() {
- uniquePatientList.add(ALICE);
- uniquePatientList.setPatient(ALICE, ALICE);
+ public void setObject_editedPersonIsSamePerson_success() {
+ uniquePatientList.add(AMY);
+ uniquePatientList.setObject(AMY, AMY);
UniquePatientList expectedUniquePatientList = new UniquePatientList();
- expectedUniquePatientList.add(ALICE);
+ expectedUniquePatientList.add(AMY);
assertEquals(expectedUniquePatientList, uniquePatientList);
}
@Test
- public void setPatient_editedPersonHasSameIdentity_success() {
- uniquePatientList.add(ALICE);
- Patient editedAlice = new PatientBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND)
+ public void setObject_editedPersonHasSameIdentity_success() {
+ uniquePatientList.add(AMY);
+ Patient editedAmy = new PatientBuilder(AMY).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_MEDIUM)
.build();
- uniquePatientList.setPatient(ALICE, editedAlice);
+ uniquePatientList.setObject(AMY, editedAmy);
UniquePatientList expectedUniquePatientList = new UniquePatientList();
- expectedUniquePatientList.add(editedAlice);
+ expectedUniquePatientList.add(editedAmy);
assertEquals(expectedUniquePatientList, uniquePatientList);
}
@Test
- public void setPatient_editedPersonHasDifferentIdentity_success() {
- uniquePatientList.add(ALICE);
- uniquePatientList.setPatient(ALICE, BOB);
+ public void setObject_editedPersonHasDifferentIdentity_success() {
+ uniquePatientList.add(AMY);
+ uniquePatientList.setObject(AMY, BOB);
UniquePatientList expectedUniquePatientList = new UniquePatientList();
expectedUniquePatientList.add(BOB);
assertEquals(expectedUniquePatientList, uniquePatientList);
}
@Test
- public void setPatient_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() {
- uniquePatientList.add(ALICE);
+ public void setObject_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() {
+ uniquePatientList.add(AMY);
uniquePatientList.add(BOB);
- assertThrows(DuplicatePersonException.class, () -> uniquePatientList.setPatient(ALICE, BOB));
+ assertThrows(DuplicatePersonException.class, () -> uniquePatientList.setObject(AMY, BOB));
}
@Test
- public void remove_nullPatient_throwsNullPointerException() {
+ public void remove_nullPerson_throwsNullPointerException() {
assertThrows(NullPointerException.class, () -> uniquePatientList.remove(null));
}
@Test
- public void remove_patientDoesNotExist_throwsPersonNotFoundException() {
- assertThrows(PersonNotFoundException.class, () -> uniquePatientList.remove(ALICE));
+ public void remove_personDoesNotExist_throwsPersonNotFoundException() {
+ assertThrows(PersonNotFoundException.class, () -> uniquePatientList.remove(AMY));
}
@Test
- public void remove_existingPatient_removesPatient() {
- uniquePatientList.add(ALICE);
- uniquePatientList.remove(ALICE);
+ public void remove_existingPerson_removesPerson() {
+ uniquePatientList.add(AMY);
+ uniquePatientList.remove(AMY);
UniquePatientList expectedUniquePatientList = new UniquePatientList();
assertEquals(expectedUniquePatientList, uniquePatientList);
}
@Test
- public void setPatients_nullUniquePatientList_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePatientList.setPatients((UniquePatientList) null));
+ public void setPersons_nullUniquePatientList_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniquePatientList.setPersons((UniquePatientList) null));
}
@Test
- public void setPatients_uniquePatientList_replacesOwnListWithProvidedUniquePatientList() {
- uniquePatientList.add(ALICE);
+ public void setPersons_uniquePatientList_replacesOwnListWithProvidedUniquePatientList() {
+ uniquePatientList.add(AMY);
UniquePatientList expectedUniquePatientList = new UniquePatientList();
expectedUniquePatientList.add(BOB);
- uniquePatientList.setPatients(expectedUniquePatientList);
+ uniquePatientList.setPersons(expectedUniquePatientList);
assertEquals(expectedUniquePatientList, uniquePatientList);
}
@Test
- public void setPatients_nullList_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePatientList.setPatients((List) null));
+ public void setPersons_nullList_throwsNullPointerException() {
+ assertThrows(NullPointerException.class, () -> uniquePatientList.setObjects((List) null));
}
@Test
- public void setPatients_list_replacesOwnListWithProvidedList() {
- uniquePatientList.add(ALICE);
+ public void setObjects_list_replacesOwnListWithProvidedList() {
+ uniquePatientList.add(AMY);
List patientList = Collections.singletonList(BOB);
- uniquePatientList.setPatients(patientList);
+ uniquePatientList.setObjects(patientList);
UniquePatientList expectedUniquePatientList = new UniquePatientList();
expectedUniquePatientList.add(BOB);
assertEquals(expectedUniquePatientList, uniquePatientList);
}
@Test
- public void setPatients_listWithDuplicatePatients_throwsDuplicatePersonException() {
- List listWithDuplicatePatients = Arrays.asList(ALICE, ALICE);
- assertThrows(DuplicatePersonException.class, () -> uniquePatientList.setPatients(listWithDuplicatePatients));
+ public void setObjects_listWithDuplicatePersons_throwsDuplicatePersonException() {
+ List listWithDuplicatePatients = Arrays.asList(AMY, AMY);
+ assertThrows(DuplicatePersonException.class, () -> uniquePatientList.setObjects(listWithDuplicatePatients));
}
@Test
diff --git a/src/test/java/seedu/address/model/person/UniquePersonListTest.java b/src/test/java/seedu/address/model/person/UniquePersonListTest.java
deleted file mode 100644
index 84a99a0bb77..00000000000
--- a/src/test/java/seedu/address/model/person/UniquePersonListTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-package seedu.address.model.person;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
-import static seedu.address.testutil.Assert.assertThrows;
-import static seedu.address.testutil.TypicalPatient.ALICE;
-import static seedu.address.testutil.TypicalPatient.BOB;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.junit.jupiter.api.Test;
-
-import seedu.address.model.person.exceptions.DuplicatePersonException;
-import seedu.address.model.person.exceptions.PersonNotFoundException;
-import seedu.address.testutil.PersonBuilder;
-
-public class UniquePersonListTest {
-
- private final UniquePersonList uniquePersonList = new UniquePersonList();
-
- @Test
- public void contains_nullPerson_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePersonList.contains(null));
- }
-
- @Test
- public void contains_personNotInList_returnsFalse() {
- assertFalse(uniquePersonList.contains(ALICE));
- }
-
- @Test
- public void contains_personInList_returnsTrue() {
- uniquePersonList.add(ALICE);
- assertTrue(uniquePersonList.contains(ALICE));
- }
-
- @Test
- public void contains_personWithSameIdentityFieldsInList_returnsTrue() {
- uniquePersonList.add(ALICE);
- Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND)
- .build();
- assertTrue(uniquePersonList.contains(editedAlice));
- }
-
- @Test
- public void add_nullPerson_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePersonList.add(null));
- }
-
- @Test
- public void add_duplicatePerson_throwsDuplicatePersonException() {
- uniquePersonList.add(ALICE);
- assertThrows(DuplicatePersonException.class, () -> uniquePersonList.add(ALICE));
- }
-
- @Test
- public void setPerson_nullTargetPerson_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePersonList.setPerson(null, ALICE));
- }
-
- @Test
- public void setPerson_nullEditedPerson_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePersonList.setPerson(ALICE, null));
- }
-
- @Test
- public void setPerson_targetPersonNotInList_throwsPersonNotFoundException() {
- assertThrows(PersonNotFoundException.class, () -> uniquePersonList.setPerson(ALICE, ALICE));
- }
-
- @Test
- public void setPerson_editedPersonIsSamePerson_success() {
- uniquePersonList.add(ALICE);
- uniquePersonList.setPerson(ALICE, ALICE);
- UniquePersonList expectedUniquePersonList = new UniquePersonList();
- expectedUniquePersonList.add(ALICE);
- assertEquals(expectedUniquePersonList, uniquePersonList);
- }
-
- @Test
- public void setPerson_editedPersonHasSameIdentity_success() {
- uniquePersonList.add(ALICE);
- Person editedAlice = new PersonBuilder(ALICE).withAddress(VALID_ADDRESS_BOB).withTags(VALID_TAG_HUSBAND)
- .build();
- uniquePersonList.setPerson(ALICE, editedAlice);
- UniquePersonList expectedUniquePersonList = new UniquePersonList();
- expectedUniquePersonList.add(editedAlice);
- assertEquals(expectedUniquePersonList, uniquePersonList);
- }
-
- @Test
- public void setPerson_editedPersonHasDifferentIdentity_success() {
- uniquePersonList.add(ALICE);
- uniquePersonList.setPerson(ALICE, BOB);
- UniquePersonList expectedUniquePersonList = new UniquePersonList();
- expectedUniquePersonList.add(BOB);
- assertEquals(expectedUniquePersonList, uniquePersonList);
- }
-
- @Test
- public void setPerson_editedPersonHasNonUniqueIdentity_throwsDuplicatePersonException() {
- uniquePersonList.add(ALICE);
- uniquePersonList.add(BOB);
- assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPerson(ALICE, BOB));
- }
-
- @Test
- public void remove_nullPerson_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePersonList.remove(null));
- }
-
- @Test
- public void remove_personDoesNotExist_throwsPersonNotFoundException() {
- assertThrows(PersonNotFoundException.class, () -> uniquePersonList.remove(ALICE));
- }
-
- @Test
- public void remove_existingPerson_removesPerson() {
- uniquePersonList.add(ALICE);
- uniquePersonList.remove(ALICE);
- UniquePersonList expectedUniquePersonList = new UniquePersonList();
- assertEquals(expectedUniquePersonList, uniquePersonList);
- }
-
- @Test
- public void setPersons_nullUniquePersonList_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((UniquePersonList) null));
- }
-
- @Test
- public void setPersons_uniquePersonList_replacesOwnListWithProvidedUniquePersonList() {
- uniquePersonList.add(ALICE);
- UniquePersonList expectedUniquePersonList = new UniquePersonList();
- expectedUniquePersonList.add(BOB);
- uniquePersonList.setPersons(expectedUniquePersonList);
- assertEquals(expectedUniquePersonList, uniquePersonList);
- }
-
- @Test
- public void setPersons_nullList_throwsNullPointerException() {
- assertThrows(NullPointerException.class, () -> uniquePersonList.setPersons((List) null));
- }
-
- @Test
- public void setPersons_list_replacesOwnListWithProvidedList() {
- uniquePersonList.add(ALICE);
- List personList = Collections.singletonList(BOB);
- uniquePersonList.setPersons(personList);
- UniquePersonList expectedUniquePersonList = new UniquePersonList();
- expectedUniquePersonList.add(BOB);
- assertEquals(expectedUniquePersonList, uniquePersonList);
- }
-
- @Test
- public void setPersons_listWithDuplicatePersons_throwsDuplicatePersonException() {
- List listWithDuplicatePersons = Arrays.asList(ALICE, ALICE);
- assertThrows(DuplicatePersonException.class, () -> uniquePersonList.setPersons(listWithDuplicatePersons));
- }
-
- @Test
- public void asUnmodifiableObservableList_modifyList_throwsUnsupportedOperationException() {
- assertThrows(UnsupportedOperationException.class, ()
- -> uniquePersonList.asUnmodifiableObservableList().remove(0));
- }
-
- @Test
- public void toStringMethod() {
- assertEquals(uniquePersonList.asUnmodifiableObservableList().toString(), uniquePersonList.toString());
- }
-}
diff --git a/src/test/java/seedu/address/model/tag/TagTest.java b/src/test/java/seedu/address/model/tag/TagTest.java
index 64d07d79ee2..343efc32274 100644
--- a/src/test/java/seedu/address/model/tag/TagTest.java
+++ b/src/test/java/seedu/address/model/tag/TagTest.java
@@ -1,5 +1,9 @@
package seedu.address.model.tag;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static seedu.address.testutil.Assert.assertThrows;
import org.junit.jupiter.api.Test;
@@ -12,15 +16,63 @@ public void constructor_null_throwsNullPointerException() {
}
@Test
- public void constructor_invalidTagName_throwsIllegalArgumentException() {
- String invalidTagName = "";
- assertThrows(IllegalArgumentException.class, () -> new Tag(invalidTagName));
+ void testIsValidPatientTagName() {
+ assertTrue(Tag.isValidPatientTagName("LOW"));
+ assertTrue(Tag.isValidPatientTagName("MEDIUM"));
+ assertTrue(Tag.isValidPatientTagName("HIGH"));
+ assertFalse(Tag.isValidPatientTagName("URGENT"));
}
@Test
- public void isValidTagName() {
- // null tag name
- assertThrows(NullPointerException.class, () -> Tag.isValidTagName(null));
+ void testIsValidFullPatientTagName() {
+ assertTrue(Tag.isValidFullPatientTagName("priority: LOW"));
+ assertFalse(Tag.isValidFullPatientTagName("LOW"));
+ assertFalse(Tag.isValidFullPatientTagName("priority: URGENT"));
+ }
+
+ @Test
+ void testIsValidDoctorTagName() {
+ assertTrue(Tag.isValidDoctorTagName("CARDIOLOGIST"));
+ assertTrue(Tag.isValidDoctorTagName("SURGEON"));
+ assertFalse(Tag.isValidDoctorTagName("NURSE"));
+ }
+
+ @Test
+ void testIsValidPatientTag() {
+ Tag validTag = new Tag("priority: HIGH");
+ Tag invalidTag = new Tag("HIGH");
+ assertTrue(validTag.isValidPatientTag());
+ assertFalse(invalidTag.isValidPatientTag());
+ }
+
+ @Test
+ void testIsValidDoctorTag() {
+ Tag validTag = new Tag("CARDIOLOGIST");
+ Tag invalidTag = new Tag("NURSE");
+ assertTrue(validTag.isValidDoctorTag());
+ assertFalse(invalidTag.isValidDoctorTag());
+ }
+
+ @Test
+ void testEquals() {
+ Tag tag1 = new Tag("CARDIOLOGIST");
+ Tag tag2 = new Tag("CARDIOLOGIST");
+ Tag tag3 = new Tag("SURGEON");
+ assertEquals(tag1, tag2);
+ assertNotEquals(tag1, tag3);
+ }
+
+ @Test
+ void testHashCode() {
+ Tag tag1 = new Tag("CARDIOLOGIST");
+ Tag tag2 = new Tag("CARDIOLOGIST");
+ assertEquals(tag1.hashCode(), tag2.hashCode());
+ }
+
+ @Test
+ void testToString() {
+ Tag tag = new Tag("CARDIOLOGIST");
+ assertEquals("[CARDIOLOGIST]", tag.toString());
}
}
diff --git a/src/test/java/seedu/address/storage/JsonAdaptedAppointmentTest.java b/src/test/java/seedu/address/storage/JsonAdaptedAppointmentTest.java
new file mode 100644
index 00000000000..249a33e4da1
--- /dev/null
+++ b/src/test/java/seedu/address/storage/JsonAdaptedAppointmentTest.java
@@ -0,0 +1,94 @@
+package seedu.address.storage;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static seedu.address.testutil.Assert.assertThrows;
+import static seedu.address.testutil.TypicalAppointment.APPOINTMENT_1;
+import static seedu.address.testutil.TypicalPatient.BENSON;
+
+import org.junit.jupiter.api.Test;
+
+import seedu.address.commons.exceptions.IllegalValueException;
+import seedu.address.model.appointment.AppointmentTime;
+import seedu.address.model.person.Ic;
+
+public class JsonAdaptedAppointmentTest {
+
+ private static final String INVALID_IC = "A1234567G";
+ private static final String INVALID_PATIENT_IC = "S123Z";
+ private static final String INVALID_APPOINTMENT_TIME = "123456";
+
+ private static final String VALID_DOCTOR_IC = APPOINTMENT_1.getDoctor().toString();
+ private static final String VALID_PATIENT_IC = APPOINTMENT_1.getPatient().toString();
+ private static final String VALID_APPOINTMENT_TIME = APPOINTMENT_1.getAppointmentTime().toString();
+
+ @Test
+ public void toModelType_validPatientDetails_returnsPatient() throws Exception {
+ JsonAdaptedPatient patient = new JsonAdaptedPatient(BENSON);
+ assertEquals(BENSON, patient.toModelType());
+ }
+
+ @Test
+ public void toModelType_invalidPatientIc_throwsIllegalValueException() {
+ JsonAdaptedAppointment appointment =
+ new JsonAdaptedAppointment(VALID_DOCTOR_IC, INVALID_IC, VALID_APPOINTMENT_TIME);
+ String expectedMessage = Ic.MESSAGE_CONSTRAINTS;
+ assertThrows(IllegalValueException.class, expectedMessage, appointment::toModelType);
+ }
+
+ @Test
+ public void toModelType_nullPatientIc_throwsIllegalValueException() {
+ JsonAdaptedAppointment appointment =
+ new JsonAdaptedAppointment(VALID_DOCTOR_IC, null, VALID_APPOINTMENT_TIME);
+ String expectedMessage =
+ String.format(JsonAdaptedAppointment.MISSING_FIELD_MESSAGE_FORMAT, Ic.class.getSimpleName());
+ assertThrows(IllegalValueException.class, expectedMessage, appointment::toModelType);
+ }
+
+ @Test
+ public void toModelType_invalidDoctorIc_throwsIllegalValueException() {
+ JsonAdaptedAppointment appointment =
+ new JsonAdaptedAppointment(INVALID_IC, VALID_PATIENT_IC, VALID_APPOINTMENT_TIME);
+ String expectedMessage = Ic.MESSAGE_CONSTRAINTS;
+ assertThrows(IllegalValueException.class, expectedMessage, appointment::toModelType);
+ }
+
+ @Test
+ public void toModelType_nullDoctorIc_throwsIllegalValueException() {
+ JsonAdaptedAppointment appointment =
+ new JsonAdaptedAppointment(null, VALID_PATIENT_IC, VALID_APPOINTMENT_TIME);
+ String expectedMessage =
+ String.format(JsonAdaptedAppointment.MISSING_FIELD_MESSAGE_FORMAT, Ic.class.getSimpleName());
+ assertThrows(IllegalValueException.class, expectedMessage, appointment::toModelType);
+ }
+
+ @Test
+ public void toModelType_invalidAppointment_throwsIllegalValueException() {
+ JsonAdaptedAppointment appointment =
+ new JsonAdaptedAppointment(VALID_DOCTOR_IC, VALID_PATIENT_IC, INVALID_APPOINTMENT_TIME);
+ String expectedMessage = AppointmentTime.MESSAGE_CONSTRAINTS;
+ assertThrows(IllegalValueException.class, expectedMessage, appointment::toModelType);
+ }
+
+ @Test
+ public void toModelType_nullAppointment_throwsIllegalValueException() {
+ JsonAdaptedAppointment appointment =
+ new JsonAdaptedAppointment(VALID_DOCTOR_IC, VALID_PATIENT_IC, null);
+ String expectedMessage = String.format(JsonAdaptedAppointment.MISSING_FIELD_MESSAGE_FORMAT,
+ AppointmentTime.class.getSimpleName());
+ assertThrows(IllegalValueException.class, expectedMessage, appointment::toModelType);
+ }
+
+ @Test
+ public void toModelType_duplicateIc_throwsIllegalValueException() {
+ // same patient ic
+ JsonAdaptedAppointment appointment =
+ new JsonAdaptedAppointment(VALID_PATIENT_IC, VALID_PATIENT_IC, VALID_APPOINTMENT_TIME);
+ String expectedMessage = JsonAdaptedAppointment.DUPLICATE_PATIENT_AND_DOCTOR_IC;
+ assertThrows(IllegalValueException.class, expectedMessage, appointment::toModelType);
+ // same doctor ic
+ appointment =
+ new JsonAdaptedAppointment(VALID_DOCTOR_IC, VALID_DOCTOR_IC, VALID_APPOINTMENT_TIME);
+ assertThrows(IllegalValueException.class, expectedMessage, appointment::toModelType);
+ }
+
+}
diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java b/src/test/java/seedu/address/storage/JsonAdaptedDoctorTest.java
similarity index 55%
rename from src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java
rename to src/test/java/seedu/address/storage/JsonAdaptedDoctorTest.java
index 530ad73f3b3..d73ffe3573a 100644
--- a/src/test/java/seedu/address/storage/JsonAdaptedPersonTest.java
+++ b/src/test/java/seedu/address/storage/JsonAdaptedDoctorTest.java
@@ -3,167 +3,172 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static seedu.address.storage.JsonAdaptedPerson.MISSING_FIELD_MESSAGE_FORMAT;
import static seedu.address.testutil.Assert.assertThrows;
-import static seedu.address.testutil.TypicalPatient.BENSON;
+import static seedu.address.testutil.TypicalDoctor.BOYD;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import seedu.address.commons.exceptions.IllegalValueException;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Address;
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.Phone;
+import seedu.address.testutil.AppointmentBuilder;
-public class JsonAdaptedPersonTest {
+public class JsonAdaptedDoctorTest {
private static final String INVALID_NAME = "R@chel";
private static final String INVALID_PHONE = "+651234";
private static final String INVALID_ADDRESS = " ";
private static final String INVALID_EMAIL = "example.com";
private static final String INVALID_GENDER = "G";
private static final String INVALID_NRIC = "T33340K";
- private static final String INVALID_TAG = "#friend";
-
- private static final String VALID_NAME = BENSON.getName().toString();
- private static final String VALID_PHONE = BENSON.getPhone().toString();
- private static final String VALID_EMAIL = BENSON.getEmail().toString();
- private static final String VALID_ADDRESS = BENSON.getAddress().toString();
- private static final String VALID_REMARK = BENSON.getRemark().toString();
- private static final String VALID_GENDER = BENSON.getGender().toString();
- private static final String VALID_NRIC = BENSON.getIc().toString();
- private static final List VALID_TAGS = BENSON.getTags().stream()
+ private static final String INVALID_TAG = "nurse";
+
+
+ private static final String VALID_NAME = BOYD.getName().toString();
+ private static final String VALID_PHONE = BOYD.getPhone().toString();
+ private static final String VALID_EMAIL = BOYD.getEmail().toString();
+ private static final String VALID_ADDRESS = BOYD.getAddress().toString();
+ private static final String VALID_REMARK = BOYD.getRemark().toString();
+ private static final String VALID_GENDER = BOYD.getGender().toString();
+ private static final String VALID_NRIC = BOYD.getIc().toString();
+ private static final Appointment BOYD_APPOINTMENT =
+ new AppointmentBuilder().withPatientIc(BOYD.getIc()).build();
+ private static final List VALID_TAGS = BOYD.getTags().stream()
.map(JsonAdaptedTag::new)
.collect(Collectors.toList());
- private static final List VALID_APPOINTMENTS = BENSON.getAppointments().stream()
+ private static final List VALID_APPOINTMENTS = Arrays.asList(BOYD_APPOINTMENT).stream()
.map(JsonAdaptedAppointment::new)
.collect(Collectors.toList());
@Test
- public void toModelType_validPersonDetails_returnsPerson() throws Exception {
- JsonAdaptedPatient person = new JsonAdaptedPatient(BENSON);
- assertEquals(BENSON, person.toModelType());
+ public void toModelType_validDoctorDetails_returnsDoctor() throws Exception {
+ JsonAdaptedDoctor doctor = new JsonAdaptedDoctor(BOYD);
+ assertEquals(BOYD, doctor.toModelType());
}
@Test
public void toModelType_invalidName_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(INVALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = Name.MESSAGE_CONSTRAINTS;
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_nullName_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(null, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Name.class.getSimpleName());
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_invalidPhone_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, INVALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = Phone.MESSAGE_CONSTRAINTS;
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_nullPhone_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, null, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Phone.class.getSimpleName());
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_invalidEmail_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, INVALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = Email.MESSAGE_CONSTRAINTS;
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_nullEmail_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, null, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Email.class.getSimpleName());
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_invalidAddress_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, VALID_EMAIL, INVALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = Address.MESSAGE_CONSTRAINTS;
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_nullAddress_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, VALID_EMAIL, null, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Address.class.getSimpleName());
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_invalidGender_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- INVALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ INVALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = Gender.MESSAGE_CONSTRAINTS;
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_nullGender_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- null, VALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ null, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Gender.class.getSimpleName());
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_invalidIc_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, INVALID_NRIC, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, INVALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = Ic.MESSAGE_CONSTRAINTS;
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_nullIc_throwsIllegalValueException() {
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, null, VALID_APPOINTMENTS, VALID_TAGS);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, null, VALID_TAGS, VALID_APPOINTMENTS);
String expectedMessage = String.format(MISSING_FIELD_MESSAGE_FORMAT, Ic.class.getSimpleName());
- assertThrows(IllegalValueException.class, expectedMessage, person::toModelType);
+ assertThrows(IllegalValueException.class, expectedMessage, doctor::toModelType);
}
@Test
public void toModelType_invalidTags_throwsIllegalValueException() {
List invalidTags = new ArrayList<>(VALID_TAGS);
invalidTags.add(new JsonAdaptedTag(INVALID_TAG));
- JsonAdaptedPerson person =
- new JsonAdaptedPerson(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
- VALID_GENDER, VALID_NRIC, VALID_APPOINTMENTS, invalidTags);
- assertThrows(IllegalValueException.class, person::toModelType);
+ JsonAdaptedDoctor doctor =
+ new JsonAdaptedDoctor(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, invalidTags, VALID_APPOINTMENTS);
+ assertThrows(IllegalValueException.class, doctor::toModelType);
}
-
}
diff --git a/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java b/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java
index b901a03c03d..bf53b658f57 100644
--- a/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java
+++ b/src/test/java/seedu/address/storage/JsonAdaptedPatientTest.java
@@ -6,12 +6,14 @@
import static seedu.address.testutil.TypicalPatient.BENSON;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import seedu.address.commons.exceptions.IllegalValueException;
+import seedu.address.model.appointment.Appointment;
import seedu.address.model.person.Address;
import seedu.address.model.person.BloodType;
import seedu.address.model.person.Condition;
@@ -20,6 +22,8 @@
import seedu.address.model.person.Ic;
import seedu.address.model.person.Name;
import seedu.address.model.person.Phone;
+import seedu.address.model.person.Remark;
+import seedu.address.testutil.AppointmentBuilder;
public class JsonAdaptedPatientTest {
private static final String INVALID_NAME = "R@chel";
@@ -44,10 +48,12 @@ public class JsonAdaptedPatientTest {
private static final String VALID_EMERGENCY_CONTACT = BENSON.getEmergencyContact().toString();
private static final String VALID_CONDITION = BENSON.getCondition().toString();
private static final String VALID_BLOODTYPE = BENSON.getBloodType().toString();
+ private static final Appointment BENSON_APPOINTMENT =
+ new AppointmentBuilder().withPatientIc(BENSON.getIc()).build();
private static final List VALID_TAGS = BENSON.getTags().stream()
.map(JsonAdaptedTag::new)
.collect(Collectors.toList());
- private static final List VALID_APPOINTMENTS = BENSON.getAppointments().stream()
+ private static final List VALID_APPOINTMENTS = Arrays.asList(BENSON_APPOINTMENT).stream()
.map(JsonAdaptedAppointment::new)
.collect(Collectors.toList());
@@ -194,6 +200,17 @@ public void toModelType_invalidTags_throwsIllegalValueException() {
assertThrows(IllegalValueException.class, patient::toModelType);
}
+ @Test
+ public void toModelType_nullRemark_throwsIllegalValueException() {
+ JsonAdaptedPatient patient =
+ new JsonAdaptedPatient(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, null,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS, VALID_CONDITION, VALID_BLOODTYPE,
+ VALID_EMERGENCY_CONTACT);
+ String expectedMessage =
+ String.format(JsonAdaptedPerson.MISSING_FIELD_MESSAGE_FORMAT, Remark.class.getSimpleName());
+ assertThrows(IllegalValueException.class, expectedMessage, patient::toModelType);
+ }
+
@Test
public void toModelType_invalidCondition_throwsIllegalValueException() {
JsonAdaptedPatient patient =
@@ -254,4 +271,12 @@ public void toModelType_nullEmergencyContact_throwsIllegalValueException() {
assertThrows(IllegalValueException.class, expectedMessage, patient::toModelType);
}
+ @Test
+ public void test_getAppointment() {
+ JsonAdaptedPatient patient =
+ new JsonAdaptedPatient(VALID_NAME, VALID_PHONE, VALID_EMAIL, VALID_ADDRESS, VALID_REMARK,
+ VALID_GENDER, VALID_NRIC, VALID_TAGS, VALID_APPOINTMENTS, VALID_CONDITION, VALID_BLOODTYPE,
+ VALID_EMERGENCY_CONTACT);
+ assertEquals(VALID_APPOINTMENTS, patient.getAppointments());
+ }
}
diff --git a/src/test/java/seedu/address/testutil/AppointmentBuilder.java b/src/test/java/seedu/address/testutil/AppointmentBuilder.java
index e6e8e649e47..00a69f70b58 100644
--- a/src/test/java/seedu/address/testutil/AppointmentBuilder.java
+++ b/src/test/java/seedu/address/testutil/AppointmentBuilder.java
@@ -4,9 +4,8 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_NRIC_DEREK;
-import java.time.LocalDateTime;
-
import seedu.address.model.appointment.Appointment;
+import seedu.address.model.appointment.AppointmentTime;
import seedu.address.model.person.Ic;
@@ -16,11 +15,10 @@
public class AppointmentBuilder {
public static final Ic DEFAULT_DOCTOR_IC = new Ic(VALID_NRIC_DEREK);
public static final Ic DEFAULT_PATIENT_IC = new Ic(VALID_NRIC_BOB);
- public static final LocalDateTime DEFAULT_APPT_TIME = VALID_DATE_1;
+ public static final AppointmentTime DEFAULT_APPT_TIME = new AppointmentTime(VALID_DATE_1);
private Ic doctorIc;
private Ic patientIc;
- private LocalDateTime appointmentTime;
- private String status;
+ private AppointmentTime appointmentTime;
/**
* Constructor for the PersonBuilder class that initialises
@@ -30,7 +28,6 @@ public AppointmentBuilder() {
doctorIc = DEFAULT_DOCTOR_IC;
patientIc = DEFAULT_PATIENT_IC;
appointmentTime = DEFAULT_APPT_TIME;
- status = "Scheduled";
}
/**
@@ -40,7 +37,6 @@ public AppointmentBuilder(Appointment appointmentToCopy) {
this.doctorIc = appointmentToCopy.getDoctor();
this.patientIc = appointmentToCopy.getPatient();
this.appointmentTime = appointmentToCopy.getAppointmentTime();
- this.status = appointmentToCopy.getStatus();
}
/**
@@ -62,13 +58,13 @@ public AppointmentBuilder withPatientIc(Ic patientIc) {
/**
* Sets the {@code Name} of the {@code Person} that we are building.
*/
- public AppointmentBuilder withAppointmentTime(LocalDateTime appointmentTime) {
+ public AppointmentBuilder withAppointmentTime(AppointmentTime appointmentTime) {
this.appointmentTime = appointmentTime;
return this;
}
public Appointment build() {
- return new Appointment(doctorIc, patientIc, appointmentTime, status);
+ return new Appointment(doctorIc, patientIc, appointmentTime);
}
}
diff --git a/src/test/java/seedu/address/testutil/AppointmentUtil.java b/src/test/java/seedu/address/testutil/AppointmentUtil.java
new file mode 100644
index 00000000000..181020bc81e
--- /dev/null
+++ b/src/test/java/seedu/address/testutil/AppointmentUtil.java
@@ -0,0 +1,33 @@
+package seedu.address.testutil;
+
+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 seedu.address.logic.commands.AddAppointmentCommand;
+import seedu.address.model.appointment.Appointment;
+
+/**
+ * A utility class for Appointment.
+ */
+public class AppointmentUtil {
+
+ /**
+ * Returns an new-appt command string for adding the {@code appointment}.
+ */
+ public static String getAddAppointmentCommand(Appointment appointment) {
+ return AddAppointmentCommand.COMMAND_WORD + " " + getAppointmentDetails(appointment);
+ }
+
+ /**
+ * Returns the part of command string for the given {@code patient}'s details.
+ */
+ public static String getAppointmentDetails(Appointment appointment) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(PREFIX_DOCTOR_IC + appointment.getDoctor().value + " ");
+ sb.append(PREFIX_PATIENT_IC + appointment.getPatient().value + " ");
+ sb.append(PREFIX_APPOINTMENT_TIME + appointment.getAppointmentTime().toString() + " ");
+ return sb.toString();
+ }
+}
+
diff --git a/src/test/java/seedu/address/testutil/DoctorBuilder.java b/src/test/java/seedu/address/testutil/DoctorBuilder.java
index fda34f60f9c..a9a231abdae 100644
--- a/src/test/java/seedu/address/testutil/DoctorBuilder.java
+++ b/src/test/java/seedu/address/testutil/DoctorBuilder.java
@@ -68,7 +68,20 @@ public DoctorBuilder(Doctor doctorToCopy) {
tags = new HashSet<>(doctorToCopy.getTags());
appointments = new HashSet<>(doctorToCopy.getAppointments());
}
-
+ /**
+ * Initializes the PersonBuilder with an nric.
+ */
+ public DoctorBuilder(Ic nric) {
+ name = new Name(DEFAULT_NAME);
+ phone = new Phone(DEFAULT_PHONE);
+ email = new Email(DEFAULT_EMAIL);
+ address = new Address(DEFAULT_ADDRESS);
+ remark = new Remark(DEFAULT_REMARK);
+ gender = new Gender(DEFAULT_GENDER);
+ ic = nric;
+ tags = new HashSet<>();
+ appointments = new HashSet<>();
+ }
/**
* Sets the {@code Name} of the {@code Person} that we are building.
*/
diff --git a/src/test/java/seedu/address/testutil/DoctorUtil.java b/src/test/java/seedu/address/testutil/DoctorUtil.java
new file mode 100644
index 00000000000..92f87f85fdb
--- /dev/null
+++ b/src/test/java/seedu/address/testutil/DoctorUtil.java
@@ -0,0 +1,70 @@
+package seedu.address.testutil;
+
+import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER;
+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_REMARK;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
+
+import java.util.Set;
+
+import seedu.address.logic.commands.AddDoctorCommand;
+import seedu.address.logic.commands.EditCommand.EditPersonDescriptor;
+import seedu.address.model.person.Doctor;
+import seedu.address.model.tag.Tag;
+
+/**
+ * A utility class for Doctor.
+ */
+public class DoctorUtil {
+
+ /**
+ * Returns an add command string for adding the {@code Doctor}.
+ */
+ public static String getAddDoctorCommand(Doctor doctor) {
+ return AddDoctorCommand.COMMAND_WORD + " " + getDoctorDetails(doctor);
+ }
+
+ /**
+ * Returns the part of command string for the given {@code person}'s details.
+ */
+ public static String getDoctorDetails(Doctor doctor) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(PREFIX_NAME + doctor.getName().fullName + " ");
+ sb.append(PREFIX_PHONE + doctor.getPhone().value + " ");
+ sb.append(PREFIX_EMAIL + doctor.getEmail().value + " ");
+ sb.append(PREFIX_ADDRESS + doctor.getAddress().value + " ");
+ sb.append(PREFIX_GENDER + doctor.getGender().value + " ");
+ sb.append(PREFIX_NRIC + doctor.getIc().value + " ");
+ doctor.getTags().stream().forEach(
+ s -> sb.append(PREFIX_TAG + s.tagName + " ")
+ );
+ return sb.toString();
+ }
+
+ /**
+ * Returns the part of command string for the given {@code EditPersonDescriptor}'s details.
+ */
+ public static String getEditDoctorDescriptorDetails(EditPersonDescriptor descriptor) {
+ StringBuilder sb = new StringBuilder();
+ descriptor.getName().ifPresent(name -> sb.append(PREFIX_NAME).append(name.fullName).append(" "));
+ descriptor.getPhone().ifPresent(phone -> sb.append(PREFIX_PHONE).append(phone.value).append(" "));
+ descriptor.getEmail().ifPresent(email -> sb.append(PREFIX_EMAIL).append(email.value).append(" "));
+ descriptor.getAddress().ifPresent(address -> sb.append(PREFIX_ADDRESS).append(address.value).append(" "));
+ descriptor.getRemark().ifPresent(remark -> sb.append(PREFIX_REMARK).append(remark.value).append(" "));
+ descriptor.getGender().ifPresent(gender -> sb.append(PREFIX_GENDER).append(gender.value).append(" "));
+ descriptor.getIc().ifPresent(ic -> sb.append(PREFIX_NRIC).append(ic.value).append(" "));
+ if (descriptor.getTags().isPresent()) {
+ Set tags = descriptor.getTags().get();
+ if (tags.isEmpty()) {
+ sb.append(PREFIX_TAG);
+ } else {
+ tags.forEach(s -> sb.append(PREFIX_TAG).append(s.tagName).append(" "));
+ }
+ }
+ return sb.toString();
+ }
+}
diff --git a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java
index 82d947ab933..8737aeb11fd 100644
--- a/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java
+++ b/src/test/java/seedu/address/testutil/EditPersonDescriptorBuilder.java
@@ -37,22 +37,22 @@ public EditPersonDescriptorBuilder(EditPersonDescriptor descriptor) {
/**
* Returns an {@code EditPersonDescriptor} with fields containing {@code person}'s details
*/
- public EditPersonDescriptorBuilder(Person person) {
+ public EditPersonDescriptorBuilder(Ic nric, Person person) {
descriptor = new EditPersonDescriptor();
+ descriptor.setIc(nric);
descriptor.setName(person.getName());
descriptor.setPhone(person.getPhone());
descriptor.setEmail(person.getEmail());
descriptor.setAddress(person.getAddress());
descriptor.setGender(person.getGender());
- descriptor.setIc(person.getIc());
descriptor.setTags(person.getTags());
descriptor.setRemark(person.getRemark());
- if (person instanceof Patient) {
+ if (person.isPatient()) {
Patient patient = (Patient) person;
descriptor.setBloodType(patient.getBloodType());
descriptor.setCondition(patient.getCondition());
descriptor.setEmergencyContact(patient.getEmergencyContact());
- } else if (person instanceof Doctor) {
+ } else if (person.isDoctor()) {
Doctor doctor = (Doctor) person;
descriptor.setAppointments(doctor.getAppointments());
}
@@ -104,13 +104,6 @@ public EditPersonDescriptorBuilder withRemark(String remark) {
return this;
}
- /**
- * Sets the {@code Ic} of the {@code EditPersonDescriptor} that we are building.
- */
- public EditPersonDescriptorBuilder withIc(String ic) {
- descriptor.setIc(new Ic(ic));
- return this;
- }
/**
* Sets the {@code BloodType} of the {@code EditPersonDescriptor} that we are building.
diff --git a/src/test/java/seedu/address/testutil/PatientBuilder.java b/src/test/java/seedu/address/testutil/PatientBuilder.java
index cb5de5dd0b3..fd764b25cfa 100644
--- a/src/test/java/seedu/address/testutil/PatientBuilder.java
+++ b/src/test/java/seedu/address/testutil/PatientBuilder.java
@@ -63,6 +63,23 @@ public PatientBuilder() {
tags = new HashSet<>();
appointments = new HashSet<>();
}
+ /**
+ * Initializes the PatientBuilder with an nric,
+ */
+ public PatientBuilder(Ic nric) {
+ name = new Name(DEFAULT_NAME);
+ phone = new Phone(DEFAULT_PHONE);
+ emergencyContact = new Phone(DEFAULT_EMERGENCY_CONTACT);
+ email = new Email(DEFAULT_EMAIL);
+ address = new Address(DEFAULT_ADDRESS);
+ remark = new Remark(DEFAULT_REMARK);
+ gender = new Gender(DEFAULT_GENDER);
+ ic = nric;
+ condition = new Condition(DEFAULT_CONDITION);
+ bloodType = new BloodType(DEFAULT_BLOODTYPE);
+ tags = new HashSet<>();
+ appointments = new HashSet<>();
+ }
/**
* Initializes the PatientBuilder with the data of {@code patientToCopy}.
diff --git a/src/test/java/seedu/address/testutil/PersonBuilder.java b/src/test/java/seedu/address/testutil/PersonBuilder.java
index 3e0b117241a..db19af1fe88 100644
--- a/src/test/java/seedu/address/testutil/PersonBuilder.java
+++ b/src/test/java/seedu/address/testutil/PersonBuilder.java
@@ -140,10 +140,4 @@ public PersonBuilder withIc(String ic) {
this.ic = new Ic(ic);
return this;
}
-
-
- public Person build() {
- return new Person(name, phone, email, address, remark, gender, ic, appointments, tags);
- }
-
}
diff --git a/src/test/java/seedu/address/testutil/PersonUtil.java b/src/test/java/seedu/address/testutil/PersonUtil.java
index c3312d97681..bdb35f1be41 100644
--- a/src/test/java/seedu/address/testutil/PersonUtil.java
+++ b/src/test/java/seedu/address/testutil/PersonUtil.java
@@ -1,6 +1,8 @@
package seedu.address.testutil;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_BLOODTYPE;
+import static seedu.address.logic.parser.CliSyntax.PREFIX_CONDITION;
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
import static seedu.address.logic.parser.CliSyntax.PREFIX_GENDER;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
@@ -58,6 +60,10 @@ public static String getEditPersonDescriptorDetails(EditPersonDescriptor descrip
descriptor.getEmail().ifPresent(email -> sb.append(PREFIX_EMAIL).append(email.value).append(" "));
descriptor.getAddress().ifPresent(address -> sb.append(PREFIX_ADDRESS).append(address.value).append(" "));
descriptor.getRemark().ifPresent(remark -> sb.append(PREFIX_REMARK).append(remark.value).append(" "));
+ descriptor.getCondition().ifPresent(condition -> sb.append(PREFIX_CONDITION)
+ .append(condition.value).append(" "));
+ descriptor.getBloodType().ifPresent(bloodType -> sb.append(PREFIX_BLOODTYPE)
+ .append(bloodType.value).append(" "));
if (descriptor.getTags().isPresent()) {
Set tags = descriptor.getTags().get();
if (tags.isEmpty()) {
diff --git a/src/test/java/seedu/address/testutil/TypicalAppointment.java b/src/test/java/seedu/address/testutil/TypicalAppointment.java
index 5133ded2cb4..de6609881f7 100644
--- a/src/test/java/seedu/address/testutil/TypicalAppointment.java
+++ b/src/test/java/seedu/address/testutil/TypicalAppointment.java
@@ -8,6 +8,7 @@
import java.util.List;
import seedu.address.model.appointment.Appointment;
+import seedu.address.model.appointment.AppointmentTime;
import seedu.address.model.person.Ic;
/**
@@ -18,7 +19,7 @@ public class TypicalAppointment {
public static final Appointment APPOINTMENT_1 = new AppointmentBuilder().build();
public static final Appointment APPOINTMENT_2 = new AppointmentBuilder().withDoctorIc(new Ic(VALID_NRIC_CHERYL))
- .withAppointmentTime(VALID_DATE_2).build();
+ .withAppointmentTime(new AppointmentTime(VALID_DATE_2)).build();
private TypicalAppointment() {
} // prevents instantiation
diff --git a/src/test/java/seedu/address/testutil/TypicalDoctor.java b/src/test/java/seedu/address/testutil/TypicalDoctor.java
index 77d9a19e879..6c031fc928f 100644
--- a/src/test/java/seedu/address/testutil/TypicalDoctor.java
+++ b/src/test/java/seedu/address/testutil/TypicalDoctor.java
@@ -30,11 +30,11 @@ public class TypicalDoctor {
public static final Doctor ALICE = new DoctorBuilder().withName("Alice Pauline")
.withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com")
.withPhone("94351253").withRemark("She wants to become a Surgeon.").withGender("F").withIc("S9631267K")
- .withTags("friends").withAppointments(APPOINTMENT_1, APPOINTMENT_2).build();
+ .withTags("NEUROLOGIST").withAppointments(APPOINTMENT_1, APPOINTMENT_2).build();
public static final Doctor BOYD = new DoctorBuilder().withName("Boyd Anders")
.withAddress("311, Clementi Ave 2, #02-25").withRemark("His weakness is being a Perfectionist")
.withEmail("boyda@example.com").withPhone("98765432").withGender("M").withIc("S9331268K")
- .withTags("owesMoney", "friends").withAppointments(APPOINTMENT_1).build();
+ .withTags("CARDIOLOGIST", "SURGEON").withAppointments(APPOINTMENT_1).build();
public static final Doctor CARLOS = new DoctorBuilder().withName("Carlos Sainz").withPhone("95352563")
.withEmail("smoothoperator@example.com").withAddress("wall street").withGender("M")
.withIc("S9831269K").build();
diff --git a/src/test/java/seedu/address/testutil/TypicalPatient.java b/src/test/java/seedu/address/testutil/TypicalPatient.java
index 877f2434831..bb4bf4360ff 100644
--- a/src/test/java/seedu/address/testutil/TypicalPatient.java
+++ b/src/test/java/seedu/address/testutil/TypicalPatient.java
@@ -20,8 +20,7 @@
import static seedu.address.logic.commands.CommandTestUtil.VALID_PHONE_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_REMARK_AMY;
import static seedu.address.logic.commands.CommandTestUtil.VALID_REMARK_BOB;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_FRIEND;
-import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
+import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_MEDIUM;
import java.util.ArrayList;
import java.util.Arrays;
@@ -38,17 +37,18 @@ public class TypicalPatient {
public static final Patient ALICE = new PatientBuilder().withName("Alice Pauline")
.withAddress("123, Jurong West Ave 6, #08-111").withEmail("alice@example.com")
.withPhone("94351253").withRemark("She likes aardvarks.").withGender("F").withIc("T0131267K")
- .withTags("friends").withCondition("NA").withBloodType("O+").withEmergencyContact("90234567").build();
+ .withTags("priority: HIGH").withCondition("NA").withBloodType("O+")
+ .withEmergencyContact("90234567").build();
public static final Patient BENSON = new PatientBuilder().withName("Benson Meier")
.withAddress("311, Clementi Ave 2, #02-25").withRemark("He can't take beer!")
.withEmail("johnd@example.com").withPhone("98765432").withGender("M").withIc("T0131268K")
- .withTags("owesMoney", "friends").withCondition("Type 1 Diabetes").withBloodType("O-")
+ .withTags("priority: LOW").withCondition("Type 1 Diabetes").withBloodType("O-")
.withEmergencyContact("92234567").build();
public static final Patient CARL = new PatientBuilder().withName("Carl Kurz").withPhone("95352563")
.withEmail("heinz@example.com").withAddress("wall street").withGender("M").withIc("T0131269K")
.withCondition("Type 2 Diabetes").withBloodType("AB+").withEmergencyContact("91334567").build();
public static final Patient DANIEL = new PatientBuilder().withName("Daniel Meier").withPhone("87652533")
- .withEmail("cornelia@example.com").withAddress("10th street").withTags("friends")
+ .withEmail("cornelia@example.com").withAddress("10th street").withTags("priority: MEDIUM")
.withGender("M").withIc("T0131260K").withCondition("Kidney Failure").withBloodType("A+")
.withEmergencyContact("91234567").build();
public static final Patient ELLE = new PatientBuilder().withName("Elle Meyer").withPhone("9482224")
@@ -74,12 +74,12 @@ public class TypicalPatient {
.withEmergencyContact(VALID_EMERGENCY_CONTACT_AMY).withEmail(VALID_EMAIL_AMY)
.withAddress(VALID_ADDRESS_AMY).withIc(VALID_NRIC_AMY).withGender(VALID_GENDER_FEMALE)
.withRemark(VALID_REMARK_AMY).withCondition(VALID_CONDITION_AMY).withBloodType(VALID_BLOODTYPE_AMY)
- .withTags(VALID_TAG_FRIEND).build();
+ .withTags(VALID_TAG_MEDIUM).build();
public static final Patient BOB = new PatientBuilder().withName(VALID_NAME_BOB).withPhone(VALID_PHONE_BOB)
.withEmergencyContact(VALID_EMERGENCY_CONTACT_BOB).withEmail(VALID_EMAIL_BOB)
.withAddress(VALID_ADDRESS_BOB).withIc(VALID_NRIC_BOB).withGender(VALID_GENDER_MALE)
.withRemark(VALID_REMARK_BOB).withCondition(VALID_CONDITION_BOB).withBloodType(VALID_BLOODTYPE_BOB)
- .withTags(VALID_TAG_HUSBAND, VALID_TAG_FRIEND).build();
+ .withTags(VALID_TAG_MEDIUM).build();
public static final String KEYWORD_MATCHING_MEIER = "Meier"; // A keyword that matches MEIER