PROJECT: Giatros by CS2103 AY1819S2 W13-4


Overview

Giatros is a desktop patient record application used to keep track of patient data in a hospital. Written in Java, the user interacts with it using a CLI, and it has a GUI created with JavaFX. One of the main features of Giatros is its ability to track various allergies for each patient, something that medical professionals often overlook. This may lead to tragedy, such as death due to drug allergy, as seen in this news article. This software is built upon an existing application: Address Book - Level 4 by MIT SE-EDU.

Summary of contributions

  • Major enhancement: Added the ability to add/remove allergies

    • What it does: Allows the user to add allergies to an existing patient or remove allergies from an existing patient.

    • Justification: This feature improves the product significantly because the current edit command will overwrite the existing allergies whenever new allergies are specified. The addall and remall commands allow user to add and remove allergies from the existing list associated to a patient.

    • Highlights: This enhancement extends the ability of the existing add and edit commands, which allows user to create a patient with allergies displayed as colourful tags.

  • Minor enhancement:

    • Updated the GUI colour scheme.

    • Changed the landing page of the application.

    • Changed the UI to show the search result of the first allergy when the patient is selected.

    • Added colours to the various allergies for easier identification.

  • Code contributed: [Code contribution]

  • Other contributions:

    • Project management:

      • Managed releases v1.0 - v1.4 (5 releases) on GitHub

    • Enhancements to existing features:

      • Updated the GUI colour scheme: Pull request #83

      • Changed the landing page of the application: Pull request #83

      • Changed the UI to show the search result of the first allergy when the patient is selected: Pull request #83

      • Added colours to the various allergies for easier identification: Pull request #50

    • Documentation:

      • Did cosmetic tweaks to existing contents of the User Guide: Pull request #49

      • Updated the existing diagrams in the Developer Guide: Pull request #93

    • Community:

      • PRs reviewed: #86, #96

      • Reported bugs and suggestions for other teams in the class (examples: 1, 2, 3)

Contributions to the User Guide

Given below are sections I contributed to the User Guide. They showcase my ability to write documentation targeting end-users.

Adding allergy to a patient: addall

Adds one or more allergies to an existing patient in Giatros.
Format: addall INDEX y/ALLERGY [y/ALLERGY]…​

Allergy names should be alphanumeric, i.e. ibuprofen, C6H6 are acceptable but anti-inflammatory is not acceptable.

  • Adds one or more allergies to the patient at the specified INDEX. The index refers to the index number shown in the displayed patient list. The index must be a positive integer 1, 2, 3, …​

  • Multiple allergies can be added at a time by separating the distinct allergies with distinct y/ tags, e.g. y/aspirin y/ibuprofen.

  • Allergies already associated with the patient will be ignored. For example, if the 1st patient is allergic to aspirin, addall 1 y/aspirin will not modify the allergy list while addall 1 y/aspirin y/ibuprofen will just add ibuprofen to the allergy list.

Examples:

  • addall 1 y/ibuprofen
    Adds the allergy ibuprofen to the 1st patient in the list.

  • addall 3 y/aspirin y/amoxicillin
    Adds two allergies, aspirin and amoxicillin to the 3rd patient in the list.

Removing allergy from a patient: remall

Allergy names should be alphanumeric, i.e. ibuprofen, C6H6 are acceptable but anti-inflammatory is not acceptable.

Removes one or more allergies to an existing patient in Giatros.
Format: remall INDEX y/ALLERGY [y/ALLERGY]…​

  • Removes one or more allergies to the patient at the specified INDEX. The index refers to the index number shown in the displayed patient list. The index must be a positive integer 1, 2, 3, …​

  • Multiple allergies can be removed at a time by separating the distinct allergies with distinct y/ tags, e.g. y/aspirin y/ibuprofen.

  • Allergies not already associated with the patient will be ignored. For example, if the 1st patient is allergic to aspirin, remall 1 y/ibuprofen will not modify the allergy list while remall 1 y/aspirin y/ibuprofen will just remove aspirin from the allergy list.

Examples:

  • remall 1 y/ibuprofen
    Removes the allergy ibuprofen from the 1st patient in the list.

  • remall 3 y/aspirin y/amoxicillin
    Removes two allergies, aspirin and amoxicillin from the 3rd patient in the list.

    == User Authentication Features When the application is first opened, it will be in Guest mode and no command can be executed except the login command.

Logging in to the application : login

Allows a guest to login and start using the application.
Format: login id/USERNAME pw/PASSWORD

A dummy staff account with sample data is available by default. Username: STAFF and Password: 1122qq

Logging out of the application : logout

Allows the user to logout when done with the session.
Format: logout

You can only logout when you have been logged in.

Registering a new staff to use the application : register

Allows the manager to create new staff account using which new staff can log into the application.
Format: register id/USERNAME pw/PASSWORD n/NAME

  • Only the manager can create new staff accounts. A normal staff will not be able to execute the register command

  • The username manager is restricted. There can only be one manager.

A dummy manager account is available by default. Username: MANAGER and Password: 1122qq

Contributions to the Developer Guide

Given below are sections I contributed to the Developer Guide. They showcase my ability to write technical documentation and the technical depth of my contributions to the project.

Add/Remove Allergy Feature

Current Implementation

The add and remove allergy feature is implemented to extend the functionality of Allergy tags. Currently, the edit command will overwrite the existing Allergy tags if user attempts to edit the existing Allergy. With the addall and remall command, it is now possible to add or remove a single or multiple allergies associated with a patient.

The functionality of the classes related to addall and remall are listed below:

  • AddallCommandParser and RemallCommandParser — Reads the user input and create AddallCommand and RemallCommand object respectively.

  • AddallCommand and RemallCommand — When executed, the command will result in the addition or removal of a single or multiple allergies.

  • Allergy — An object that models allergy. It contains a String describing the name of the allergy.

A patient’s Allergy is stored in a Java HashSet, which stores only unique Allergy object. This feature makes use of this behaviour of a HashSet to allow user to add or remove allergies from the patient.

  • addall command uses the .addAll() method, which takes in a set of Allergy objects and add them in if they are not inside the set already.

  • remall command uses the .remAll() method, which takes in a set of Allergy objects and remove them if they are actually inside in the set.

Given below is an example usage scenario and how the add allergy mechanism behaves at each step.

Step 1. The user launches the application and logs into the STAFF account.

Step 2. Assuming that the patient list is not empty, the user executes addall 1 y/newallergy to add newallergy to the first patient in the list.

Step 3. This command in string format will be passed to the AddallCommandParser, which will check if the command format is valid.

Step 4. Since this command has a valid format, the system will create a new AddallCommand object, which will be executed.

Step 5. The system will locate the first patient in the patient list, and adds the non-existing allergy to the unique list of patient allergy.

The following sequence diagram shows how the add allergy operation works:

AddAllergySequenceDiagram

The remove allergy mechanism behaves similarly to the add allergy mechanism. Below is the example usage scenario.

Step 1. The user launches the application and logs into the STAFF account.

Step 2. Assuming that the patient list is not empty, the user executes remall 1 y/existingallergy to remove existingallergy to the first patient in the list.

Step 3. This command in string format will be passed to the AddallCommandParser, which will check if the command format is valid.

Step 4. Since this command has a valid format, the system will create a new AddallCommand object, which will be executed.

Step 5. The system will locate the first patient in the patient list, and removes the existing allergy from the unique list of patient allergy.

The following sequence diagram shows how the remove allergy operation works:

RemoveAllergySequenceDiagram

Design Consideration

Aspect: Data structure to support the add/remove allergy commands
  • Alternative 1 (current choice): Use a HashSet to store the list of allergy.

    • Pros: Supports the addition and removal of allergy. Additionally, by storing unique list of allergy, we minimise the risk of inputting duplicate allergy by accident.

    • Cons: Slightly harder to implement as compared to a String representation.

  • Alternative 2: Use a String to store the list of allergy.

    • Pros: Easier to implement when compared to using a HashSet.

    • Cons: Every time we add or remove an allergy, we need to retype the whole lists of allergies because the previous String will simply be overwritten by the new String.

Use case: Add patient

MSS

  1. Receptionist inputs to add a new patient into the record.

  2. System adds patient details into the database.

    Use case ends.

Extensions

  • 1a. The receptionist did not input data in the specified format.

    • 1a1. System shows an error message, along with a hint on how to input the data in the right format.

      Use case resumes at step 1.

  • 1b. The receptionist input a patient that has already existed in the database.

    • 1b1. System shows an error message, alerting the receptionist that such patient already exists in the database.

      Use case ends.

Use case: Delete patient

MSS

  1. Receptionist requests to list all patients in the database.

  2. System shows a list of patients registered in the database.

  3. Receptionist requests to delete a specific patient in the list.

  4. System deletes the patient.

    Use case ends.

Extensions

  • 2a. The list is empty.

    Use case ends.

  • 3a. The given index is invalid.

    • 3a1. System shows an error message, prompting for a valid index.

      Use case resumes at step 2.

Use case: Edit patient

Precondition: Current list of patients is not empty.

MSS

  1. Receptionist requests to list all patients in the database.

  2. System shows a list of patients registered in the database.

  3. Receptionists edits the details of a specific patient in the list.

  4. System edits the details of the patient.

    Use case ends.

Extensions

  • 3a. The given index is invalid.

    • 3a1. System shows an error message, prompting for a valid index.

      Use case resumes at step 2.

  • 3b. The receptionist did not input any field to edit.

    • 3b1. System shows an error message, prompting for at least one field to be edited.

      Use case resumes at step 2.

Use case: Add allergy to patient

Precondition: Current list of patients is not empty.

MSS

  1. Receptionist requests to list all patients in the database.

  2. System shows a list of patients registered in the database.

  3. Receptionists adds some allergy to a specific patient in the list.

  4. System adds the allergy to the patient.

    Use case ends.

Extensions

  • 3a. The given index is invalid.

    • 3a1. System shows an error message, prompting for a valid index.

      Use case resumes at step 2.

  • 3b. The allergy already exists in the patient.

    • 3b1. System shows an error message, alerting the receptionist that such allergy already exists in the patient.

      Use case ends.

  • 3c. Receptionist inputs multiple allergy to be added, some of them already associated with the patient.

    • 3c1. System will ignore allergy that is already associated to the patient.

      Use case resumes at step 4.

Use case: Remove allergy from patient

Precondition: Current list of patients is not empty.

MSS

  1. Receptionist requests to list all patients in the database.

  2. System shows a list of patients registered in the database.

  3. Receptionists removes some allergy from a specific patient in the list.

  4. System removes the allergy from the patient.

    Use case ends.

Extensions

  • 3a. The given index is invalid.

    • 3a1. System shows an error message, prompting for a valid index.

      Use case resumes at step 2.

  • 3b. The receptionist attempts to remove an allergy that does not exist in the patient.

    • 3b1. System shows an error message, alerting the receptionist that such allergy does not exist in the patient.

      Use case ends.

  • 3c. Receptionist inputs multiple allergy to be removed, some of them not associated with the patient.

    • 3c1. System will ignore allergy that is not associated to the patient.

      Use case resumes at step 4.

Use case: Add appointment to patient

Precondition: Current list of patients is not empty, and user is logged in to a staff account.

MSS

  1. Receptionist requests to list all patients in the database.

  2. System shows a list of patients registered in the database.

  3. Receptionists adds some appointment to a specific patient in the list.

  4. System adds the appointment to the patient.

    Use case ends.

Extensions

  • 3a. The given index is invalid.

    • 3a1. System shows an error message, prompting for a valid index.

      Use case resumes at step 2.

  • 3b. The appointment already exists in the patient.

    • 3b1. System shows an error message, alerting the receptionist that such appointment already exists in the patient.

      Use case ends.

  • 3c. Receptionist inputs multiple appointment to be added, some of them already associated with the patient.

    • 3c1. System will ignore appointment that is already associated to the patient.

      Use case resumes at step 4.

Use case: Remove appointment from patient

Precondition: Current list of patients is not empty and user is logged in to a staff account.

MSS

  1. Receptionist requests to list all patients in the database.

  2. System shows a list of patients registered in the database.

  3. Receptionists removes some appointment from a specific patient in the list.

  4. System removes the appointment from the patient.

    Use case ends.

Extensions

  • 3a. The given index is invalid.

    • 3a1. System shows an error message, prompting for a valid index.

      Use case resumes at step 2.

  • 3b. The receptionist attempts to remove an appointment that does not exist in the patient.

    • 3b1. System shows an error message, alerting the receptionist that such appointment does not exist in the patient.

      Use case ends.

  • 3c. Receptionist inputs multiple appointment to be removed, some of them not associated with the patient.

    • 3c1. System will ignore appointment that is not associated to the patient.

      Use case resumes at step 4.

Use case: Undo an action

MSS

  1. Receptionist executes a command that changes the giatros book state.

  2. System commits the change made by receptionist into a new giatros book state.

  3. Receptionist decides to undo the action.

  4. System reverts the change by returning to the previous giatros book state.

    Use case ends.

Extensions

  • 1a. Command execution fails due to invalid format.

    • 1a1. System shows an error message, along with a hint on how to input the data in the right format.

    • 1a2. System does not commit into a new state as there is no change yet, so there is no command to undo if the user insists on undoing.

      Use case resumes at step 1.

Use case: Redo an action

MSS

  1. Receptionist executes a command that changes the giatros book state.

  2. System commits the change made by receptionist into a new giatros book state.

  3. Receptionist decides to undo the action.

  4. System reverts the change by returning to the previous giatros book state.

  5. Receptionist decides to redo the action.

  6. System reverts the undo by going to the next giatros book state.

    Use case ends.

Extensions

  • 1a. Command execution fails due to invalid format.

    • 1a1. System shows an error message, along with a hint on how to input the data in the right format.

    • 1a2. System does not commit into a new state as there is no change yet, so there is no command to undo if the user insists on undoing.

    • 1a3. Since there is no commands to undo, the system will show an error message if redo is executed.

      Use case resumes at step 1. === Logging into the application

      1. Using the guest account to use the application

        1. Test case: list, clear, edit 1 n/Try to Change Name, etc
          Expected: An error will occur. Need to be logged in to execute these commands.

        2. Test case: exit
          Expected: Exits the application. A guest should be able to exit.

        3. Test case: login id/staff pw/1122qq, login id/MYUSER pq/1122qq, login id/STAFF pq/1122ww, login id/STAFF pw/1122q, etc
          Expected: Login failed. Incorrect username and/or password.

        4. Test case: login id/STAFF pw/1122qq Expected: Login successful. Can now execute command as a staff.

      2. Using the staff account to use the application — should be able to execute all the commands below, except for register

      3. Using the manager account to use the application — should only be able to execute register

Adding a patient

  1. Test case: add n/Alex p/WRONG e/a@bc.com a/Anywhere
    Expected: An error will occur. Phone number format is invalid.

  2. Test case: add n/Alex p/1234 e/WRONG a/Anywhere
    Expected: An error will occur. Email format is invalid.

  3. Test case: add n/Alex Yeoh p/1234 e/alexyeoh@example.com a/Anywhere
    Expected: An error will occur. Such patient already exists.

  4. Test case: add n/Alex Yeoh p/1234 e/a@b.com a/Anywhere
    Expected: Add successful. Details of the added contact shown in the status message. Timestamp in the status bar is updated. === Editing a patient

Prerequisites: List some patients using the list or find command. At least one patient in the list.

  1. Test case: edit
    Expected: An error will occur. Invalid command format.

  2. Test case: edit 1
    Expected: An error will occur. At least one field to edit must be specified.

  3. Test case: edit 1 n/Alex Tan
    Expected: Edit successful. First patient’s name will be updated to Alex Tan.

  4. Test case: edit 1 y/
    Expected: Edit successful. Clears all the existing allergy of the first patient.

Adding allergy to a patient

Prerequisites: List all patients using the list command. Multiple patients in the list.

  1. Test case: addall, addall 1
    Expected: An error will occur. Invalid command format.

  2. Test case: addall 1 y/
    Expected: An error will occur. Allergy names should be alphanumeric. An empty string is not a valid input.

  3. Test case: addall 1 y/amoxicillin
    Expected: An error will occur. Amoxicillin is already associated to the first patient.

  4. Test case: addall 1 y/ibuprofen
    Expected: Add allergy successful. The first patient is now associated with ibuprofen allergy.

  5. Test case: addall 1 y/amoxicillin y/aspirin
    Expected: Add allergy successful. Amoxicillin is ignored, since it is already associated to the first patient. Aspirin allergy is added.

Removing allergy from a patient

Prerequisites: List all patients using the list command. Multiple patients in the list.

  1. Test case: remall, remall 1
    Expected: An error will occur. Invalid command format.

  2. Test case: remall 1 y/
    Expected: An error will occur. Allergy names should be alphanumeric. An empty string is not a valid input.

  3. Test case: remall 1 y/toxin
    Expected: An error will occur. Cannot find toxin in the list of allergies for the first patient.

  4. Test case: remall 1 y/amoxicillin
    Expected: Remove allergy successful. The first patient is now not associated with amoxicillin allergy anymore.

  5. Test case: remall 2 y/penicillin y/aspirin
    Expected: Remove allergy successful. Aspirin is ignored, since it is not associated to the second patient. Penicillin allergy is removed.

Adding appointment to a patient

Prerequisites: List all patients using the list command. Multiple patients in the list.

  1. Test case: addapt, addapt 1
    Expected: An error will occur. Invalid command format.

  2. Test case: addapt 1 apt/
    Expected: An error will occur. An error will occur. Appointment needs to follow the one of the valid formats: 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH' . An empty string is not a valid input.

  3. Test case: addapt 1 apt/2019-04-01 14:30
    Expected: An error will occur. The appointment is already associated to the first patient.

  4. Test case: addapt 1 apt/2019-02-29 14:30
    Expected: An error will occur. The 29th of Feb doesn’t exist for 2019.

  5. Test case: addapt 1 apt/2019-04-01 15:00
    Expected: Add appointment successful. The first patient is now associated with 2019-04-01 15:00 appointment.

  6. Test case: addapt 1 apt/2019-04-01 14:30 apt/2019-04-01 18:00
    Expected: Add appointment successful. The first appointment is ignored, since it is already associated to the first patient. Aspirin appointment is added.

    See AppointmentTests.java for other examples for other valid/invalid appointments.

Removing appointment from a patient

Prerequisites: List all patients using the list command. Multiple patients in the list.

  1. Test case: remapt, remapt 1
    Expected: An error will occur. Invalid command format.

  2. Test case: remapt 1 apt/
    Expected: An error will occur. Appointment needs to follow the one of the valid formats: 'yyyy-MM-dd HH:mm:ss', 'yyyy-MM-dd HH:mm', 'yyyy-MM-dd HH' . An empty string is not a valid input.

  3. Test case: remapt 1 apt/2019-12-01 13:30
    Expected: An error will occur. Cannot find the appointment in the list of appointments for the first patient.

  4. Test case: remapt 1 apt/2019-04-01 14:30
    Expected: Remove appointment successful. The first patient is now not associated with 2019-04-01 14:30 appointment anymore.

  5. Test case: remapt 2 apt/2019-04-01 14:30 apt/2019-04-01 18:00
    Expected: Remove appointment successful. The second appointment is ignored, since it is not associated to the second patient. The first appointment is removed.

    See AppointmentTests.java for other examples for other invalid appointments.

Selecting a patient

Prerequisites: List some patients using the list or find command. At least one patient in the list.

  1. Test case: select 1
    Expected: Selects the first patient in the list. The patient card is highlighted. The google search page of the first allergy in the list will be shown.

  2. Test case: edit 1 y/
    Expected: Edit successful. Removes all the allergies of the first patient.

  3. Test case: select 1
    Expected: Selects the first patient in the list. The patient card is highlighted. Since the patient has no allergy, the default page will be shown.

Undoing an action

Prerequisites: List all patients using the list command. Multiple patients in the list.

  1. Test case: undo
    Expected: An error will occur. No commands to undo.

  2. Test case: find Alex
    Expected: Find successful. Search result for Alex will be shown.

  3. Test case: undo
    Expected. An error will occur. No commands to undo as find does not change the state of giatros book.

  4. Test case: addall 1 y/benzene
    Expected: Add allergy successful. The first patient in the found list will now have a benzene allergy.

  5. Test case: undo
    Expected: Undo successful. The benzene allergy will be removed and the giatros book reverts to the previous state.

  6. Test case: addall 1 y/amoxicillin
    Expected: An error will occur. The first patient is already allergic to amoxicillin.

  7. Test case: undo
    Expected: An error will occur. No commands to undo as the previous step fails to modify the giatros book state due to the addall command failing its execution.

Redoing an action

Prerequisites: List all patients using the login and list command respectively. Multiple patients in the list. You may need to restart your application if you just finished testing the undo command.

  1. Test case: redo
    Expected: An error will occur. No commands to redo.

  2. Test case: addall 1 y/benzene
    Expected: Add allergy successful. The first patient in the found list will now have a benzene allergy.

  3. Test case: undo
    Expected: Undo successful. The benzene allergy will be removed and the giatros book reverts to the previous state.

  4. Test case: redo
    Expected: Redo successful. The benzene allergy will be added back, reverting the previous undo command.

  5. Test case: redo
    Expected: An error will occur. No commands to redo.

Exporting Giatros Book

Prerequisites: Have a non-empty list of patients. You may need to restart your application if you just finished testing the undo command.

  1. Test case: export
    Expected: Export sucessful. Giatros book csv file located at ~/Downloads.

  2. Test case: export d/~/Desktop/Giatros.csv
    Expected: Export sucessful. Giatros book csv file located at ~/Desktop.

  3. Test case: export d/~/Desktop
    Expected: An error will occur. Invalid destination specified. Destination must end in .csv