By: Team W14-3      Since: Sept 2018      Licence: MIT

1. Setting up

1.1. Prerequisites

  1. JDK 9 or later

    JDK 10 on Windows will fail to run tests in headless mode due to a JavaFX bug. Windows developers are highly recommended to use JDK 9.
  2. IntelliJ IDE

    IntelliJ by default has Gradle and JavaFx plugins installed.
    Do not disable them. If you have disabled them, go to File > Settings > Plugins to re-enable them.

1.2. Setting up the project in your computer

  1. Fork this repo, and clone the fork to your computer

  2. Open IntelliJ (if you are not in the welcome screen, click File > Close Project to close the existing project dialog first)

  3. Set up the correct JDK version for Gradle

    1. Click Configure > Project Defaults > Project Structure

    2. Click New…​ and find the directory of the JDK

  4. Click Import Project

  5. Locate the build.gradle file and select it. Click OK

  6. Click Open as Project

  7. Click OK to accept the default settings

  8. Open a console and run the command gradlew processResources (Mac/Linux: ./gradlew processResources). It should finish with the BUILD SUCCESSFUL message.
    This will generate all resources required by the application and tests.

  9. Open XmlAdaptedPerson.java and MainWindow.java and check for any code errors

    1. Due to an ongoing issue with some of the newer versions of IntelliJ, code errors may be detected even if the project can be built and run successfully

    2. To resolve this, place your cursor over any of the code section highlighted in red. Press ALT+ENTER, and select Add '--add-modules=…​' to module compiler options for each error

  10. Repeat this for the test folder as well (e.g. check XmlUtilTest.java and HelpWindowTest.java for code errors, and if so, resolve it the same way)

1.3. Verifying the setup

  1. Run the seedu.address.MainApp and try a few commands

  2. Run the tests to ensure they all pass.

1.4. Configurations to do before writing code

1.4.1. Configuring the coding style

This project follows oss-generic coding standards. IntelliJ’s default style is mostly compliant with ours but it uses a different import order from ours. To rectify,

  1. Go to File > Settings…​ (Windows/Linux), or IntelliJ IDEA > Preferences…​ (macOS)

  2. Select Editor > Code Style > Java

  3. Click on the Imports tab to set the order

    • For Class count to use import with '*' and Names count to use static import with '*': Set to 999 to prevent IntelliJ from contracting the import statements

    • For Import Layout: The order is import static all other imports, import java.*, import javax.*, import org.*, import com.*, import all other imports. Add a <blank line> between each import

Optionally, you can follow the UsingCheckstyle.adoc document to configure Intellij to check style-compliance as you write code.

1.4.2. Updating documentation to match your fork

After forking the repo, the documentation will still have the SE-EDU branding and refer to the se-edu/AddressBook-level4 repo.

If you plan to develop this fork (separate product (i.e. instead of contributing to se-edu/AddressBook-level4)) | you should do the following:

  1. Configure the site-wide documentation settings in build.gradle, such as the site-name, to suit your own project.

  2. Replace the URL in the attribute repoURL in DeveloperGuide.adoc and UserGuide.adoc with the URL of your fork.

1.4.3. Setting up CI

Set up Travis to perform Continuous Integration (CI) for your fork. See UsingTravis.adoc to learn how to set it up.

After setting up Travis, you can optionally set up coverage reporting for your team fork (see UsingCoveralls.adoc).

Coverage reporting could be useful for a team repository that hosts the final version but it is not that useful for your patiental fork.

Optionally, you can set up AppVeyor (second CI (see UsingAppVeyor.html).

Having both Travis and AppVeyor ensures your App works on both Unix-based platforms and Windows-based platforms (Travis is Unix-based and AppVeyor is Windows-based)

1.4.4. Getting started with coding

When you are ready to start coding,

  1. Get some sense of the overall design by reading Section 2.1, “Architecture”.

2. Design

2.1. Architecture

Architecture
Figure 1. Architecture Diagram

The Architecture Diagram given above explains the high-level design of the App. Given below is a quick overview of each component.

The .pptx files used to create diagrams in this document can be found in the diagrams folder. To update a diagram, modify the diagram in the pptx file, select the objects of the diagram, and choose Save as picture.

Main has only one class called MainApp. It is responsible for,

  • At app launch: Initializes the components in the correct sequence, and connects them up with each other.

  • At shut down: Shuts down the components and invokes cleanup method(s) where necessary.

Commons represents a collection of classes used by multiple other components. Two of those classes play important roles at the architecture level.

  • EventsCenter : This class (written using Google’s Event Bus library) is used by components to communicate with other components using events (i.e. a form of Event Driven design)

  • LogsCenter : Used by many classes to write log messages to the App’s log file.

The rest of the App consists of four components.

  • UI: The UI of the App.

  • Logic: The command executor.

  • Model: Holds the data of the App in-memory.

  • Storage: Reads data from, and writes data to, the hard disk.

Each of the four components

  • Defines its API in an interface with the same name as the component.

  • Exposes its functionality using a {component Name}Manager class.

For example, the Logic component (see the class diagram given below) defines it’s API in the Logic.java interface and exposes its functionality using the LogicManager.java class.

LogicClassDiagram
Figure 2. Class Diagram of the Logic component

Events-driven nature of the design

The Sequence Diagram below shows how the components interact for the scenario where the user issues the command delete 1.

SDforDeletePerson
Figure 3. Component interactions for delete 1 command (part 1)
Note how the Model simply raises a HealthBaseChangedEvent when HealthBase data are changed, instead of asking the Storage to save the updates to the hard disk.

The diagram below shows how the EventsCenter reacts to that event, which eventually results in the updates being saved to the hard disk and the status bar of the UI being updated to reflect the 'Last Updated' time.

SDforDeletePersonEventHandling
Figure 4. Component interactions for delete 1 command (part 2)
Note how the event is propagated through the EventsCenter to the Storage and UI without Model having to be coupled to either of them. This is an example of how this Event Driven approach helps us reduce direct coupling between components.

The sections below give more details of each component.

2.2. UI component

UiClassDiagram
Figure 5. Structure of the UI component

API : Ui.java

The UI consists of a MainWindow that is made up of parts e.g.CommandBox, ResultDisplay, patientListPanel, StatusBarFooter, MedicationView, etc. All these, including the MainWindow, inherit from the abstract UiPart class.

The UI component uses the JavaFX UI framework. The layout of these UI parts are defined in matching .fxml files that are in the src/main/resources/view folder. For example, the layout of the MainWindow is specified in MainWindow.fxml

The UI component does the following:

  • Executes user commands using the Logic component

  • Binds itself to some data in the Model so that the UI can auto-update when data in the Model changes

  • Responds to events raised from various parts of the App and updates the UI accordingly

2.3. Logic component

LogicClassDiagram
Figure 6. Structure of the Logic component

API : Logic.java

  1. Logic uses the HealthBaseParser class to parse the user command.

  2. This results in a Command object which is executed by the LogicManager.

  3. The command execution can affect the Model (e.g. adding a patient) and/or raise events.

  4. The result of the command execution is encapsulated as a CommandResult object which is passed back to the UI.

Given below is the Sequence Diagram for interactions within the Logic component for the execute("delete 1") API call.

DeletePersonSdForLogic
Figure 7. Interactions Inside the Logic component for the delete 1 Command

2.4. Model component

ModelClassDiagram
Figure 8. Structure of the Model component

API : Model.java

The Model,

  • stores a UserPref object that represents the user’s preferences.

  • stores HealthBase data.

  • exposes an unmodifiable ObservableList<patient> that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.

  • does not depend on any of the other three components.

As a more OOP model, we can store a Tag list in HealthBase, which patient can reference. This would allow HealthBase to only require one Tag object per unique Tag, instead of each patient needing their own Tag object. An example of how such a model may look like is given below.

ModelClassBetterOopDiagram

2.5. Storage component

StorageClassDiagram
Figure 9. Structure of the Storage component

API : Storage.java

The Storage component,

  • can save UserPref objects in json format and read it back.

  • can save HealthBase data in xml format and read it back.

2.6. Common classes

Classes used by multiple components are in the seedu.addressbook.commons package.

3. Implementation

This section describes some noteworthy details on how certain features are implemented.

3.1. Addappt

3.1.1. Current implementation

The addappt command provides functionality for users to add an appointment for a given patient. This is done by adding appointment-related information to a given person, represented by a Person object. This allows for users to track the upcoming appointments for every patient.

The adding of appointment-related information is facilitated by the following classes:

  • AppointmentsList, a list of

    • Appointment, each of which have a

      • Type

A more detailed description of the classes follows below:

  • AppointmentsList

    • Every Person has an AppointmentsList, the purpose of which is to store all Appointment s belonging to a Person.

    • A wrapper class around the internal representation of a list of appointments that exposes only a few select methods in the List API.

      • The methods relevant to the addappt command from the API are: add.

  • Appointment

    • Class encapsulating all the information about a particular appointment.

      • These information include the type of appointment (enum Type), name of the procedure, date and time of the appointment and the name of the doctor-in-charge of the appointment

  • Type

    • An enumeration that covers all the different types of medical procedures. The four types are:

      • PROPAEDEUTIC, with PROP as abbreviation

      • DIAGNOSTIC, with DIAG as abbreviation

      • THERAPEUTIC, with THP as abbreviation

      • SURGICAL, with SRG as abbreviation

Given below is an example usage scenario and how the relevant classes behave at each step.

Activity and sequence diagrams are different ways to represent the execution of a command:
The activity diagram provides a general view of the execution and
The sequence diagram provides an intricate view of the execution
Both diagrams have been included to better aid you through the execution of the addappt command.

The user executes addappt ic/S1234567A type/SRG pn/Heart Bypass dt/27-04-2019 10:30 doc/Dr. Pepper. This command has the following intent: Record the following appointment to a patient with NRIC = S1234567A:

Appt. type Procedure name Date and time Doctor-in-charge

SRG

Heart Bypass

27-04-2019 10:30

Dr. Pepper

The following activity diagram shows the execution of the addappt command:

AddapptActivityDiagram
Figure 10. Execution activity of the addappt command

The following sequence diagram shows the execution of the addappt command:

AddapptSequenceDiagram
Figure 11. Execution sequence of the addappt command

With reference to the above figures, the following steps occur upon the execution of the addappt command (code snippets have been included for the first 4 steps to further aid understanding):

...
    @Override
    public CommandResult execute(String commandText) throws CommandException, ParseException { (1)
        logger.info("----------------[USER COMMAND][" + commandText + "]");
        try {
            Command command = healthBaseParser.parseCommand(commandText); (2)
            return command.execute(model, history);
        } finally {
            history.add(commandText);
        }
    }
...
...
    public Command parseCommand(String userInput) throws ParseException { (2)
        final Matcher matcher = BASIC_COMMAND_FORMAT.matcher(userInput.trim());
        if (!matcher.matches()) {
            throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, HelpCommand.MESSAGE_USAGE));
        }

        final String commandWord = matcher.group("commandWord");
        final String arguments = matcher.group("arguments");

        switch (commandWord) {

        case RegisterCommand.COMMAND_WORD:
            return new RegisterCommandParser().parse(arguments);
        ...
        case AddApptCommand.COMMAND_WORD:
            return new AddApptCommandParser().parse(arguments); (3)
        ...
    }
...
...
    @Override
    public AddApptCommand parse(String args) throws ParseException { (3)
        ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NRIC, PREFIX_TYPE, PREFIX_PROCEDURE,
                PREFIX_DATE_TIME, PREFIX_DOCTOR);

        if (!arePrefixesPresent(argMultimap, PREFIX_NRIC, PREFIX_TYPE, PREFIX_PROCEDURE,
                PREFIX_DATE_TIME, PREFIX_DOCTOR) || !argMultimap.getPreamble().isEmpty()) {
            throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddApptCommand.MESSAGE_USAGE));
        }
        ...
        nric = new Nric(patientNric);
        appt = new Appointment(type, procedure, dateTime, doctor);

        return new AddApptCommand(nric, appt); (4)
    }
...
1 The command is executed and passed to an instance of the LogicManager class,
2 which in turn executes HealthBaseParser::parseCommand.
3 The HealthBaseParser first parses the command word (addappt),
4 then executes AddApptCommandParser::parse.
5 The AddApptCommandParser::parse method returns an AddApptCommand object which encapsulates the necessary information to update the Person 's Appointment (s). Control is also passed back to the LogicManager.
6 Next, the instance of LogicManager calls AddApptCommand::execute. The AddApptCommand::execute method constructs a new Person object using all the details of the old Person with one exception: the AppointmentsList is a copy of the original Person 's AppointmentsList with an added Appointment.
7 This is done by obtaining a Person object from the static method CommandUtil::getPatient
8 then adding the Appointment to the obtained Person.
9 This updated Person object is used to update the existing Person by using Model::updatePerson of the backing model.
10 Finally, the AddApptCommand::execute method terminates, returning a CommandResult with a success message.
11 The LogicManager returns the same CommandResult as the value of the LogicManager::execute method.
12 The command execution ends.
If no/multiple patient(s) with that NRIC exist(s), then the AddApptCommand::execute method will throw a CommandException with the appropriate error message and the usage case will end.
For the sake of simplicity, some methods in AddApptCommand::execute are excluded from the diagram. These methods check for the validity of the command and are not crucial in the sequence of events.

3.1.2. Design considerations

Aspect: Representation of types of medical procedures
  • Alternative 1 (Current implementation): Use an Enum for Type

    • Pros: Makes for easier handling of incorrect values.

    • Cons: Requires more effort to filter and retrieve the different types.

  • Alternative 2: Have a switch case to handle the different types

    • Pros: Makes the process easier to handle.

    • Cons: Makes the code more difficult to read.

3.2. Adddiet

3.2.1. Current implementation

The adddiet command provides functionality for users to add dietary requirements for a given patient.
This command allows users to add three different types of dietary requirements: allergy, cultural requirement and physical difficulty.
This command adds these dietary requirements to a given Person , so that the dietary requirements can be viewed later on.
This command blocks non-alphabetical or empty input as the detail of a dietary requirement.

Classes involved

The adding of the dietary requirements involve the following classes:

  • DietCollection, which is a set of

    • Diet, which consists of the detail of the requirement and its type

      • DietType.

A more detailed description of the classes involved is as follows:

  • Diet Collection

    • Every Person object has a Diet Collection object.

    • This class encapsulates a collection of all the dietary requirements of the given patient.

    • This class is a wrapper class around the internal representation of a Set of Diet s.

  • Diet

    • This class encapsulates the information of a single dietary requirement.

    • Specifically, an instance of this class is composed of

      • a String representing the details of the requirement in text, and

      • a DietType representing the type of this dietary requirement (allergy, cultural requirement, or physical difficulty).

  • DietType

    • This class is an Enum class representing the three different types of dietary requirements.

    • This class is implemented as Enum class to avoid typo and invalid types being entered.

Execution of the command

Given below is a usage scenario and the details when executing adddiet command.
For example, when the user executes adddiet ic/S1234567A alg/Egg alg/Crab cr/Halal pd/Hands cannot move:

  • The command text is passed to an instance of the LogicManager class.

  • The LogicManager instance calls HealthBaseParser#parseCommand, which parses the adddiet command word.

  • Next, the AddDietCommandParser#parse method parses the different dietary requirements into one DietCollection object. An instance of AddDietCommand is returned after the parsing.

  • LogicManager then execute this AddDietCommand by calling AddDietCommand#execute.

  • In the AddDietCommand#execute method, the new DietCollection object is added to a new copy of the Person object.

  • The new Person object is updated to the model by Model#updatePerson method.

  • A new CommandResult is returned and the execution ends.

Here is the sequence diagram of the typical execution of an adddiet command:

AdddietSequenceDiagram
Figure 12. Execution sequence of the adddiet command

3.2.2. Design considerations

Aspect: How to represent different kinds of dietary requirements
  • Alternative 1 (current implementation): Use a Enum inside the Diet class and contain all Diet in one collection.

    • Pros: Results in less repetitive code and cleaner design.

    • Cons: Requires more effort to filter or retrieve different types of Diet from one DietCollection.

  • Alternative 2: Use polymorphism to extends Diet class and add three different collections to a Person.

    • Pros: Makes it easier to retrieve different types of dietary requirements.

    • Cons: Results in a lot of repetitive code since the three different types do not differ much.

Aspect: Data structure to hold the different Diet objects
  • Alternative 1 (current implementation): Use HashSet and override the hashCode for Diet.

    • Pros: Makes it easier to handle duplication in adding dietary requirement.

    • Cons: Causes the order in which dietary requirements are added to be lost. (However, the sequence is not important for the current set of features implemented.)

  • Alternative 2: Use ArrayList.

    • Pros: Preserves the order in which dietary requirements are added.

    • Cons: Makes it harder to handle duplicates.

3.3. Addmeds

3.3.1. Current implementation

The addmeds command provides functionality for users to add prescription-related information for a given patient. This is done by adding prescription-related information to a given person, represented by a Person object. This allows for a patient to build up a history of prescriptions for viewing at a later date.

The adding of prescription-related information is facilitated by the following classes:

  • PrescriptionList, a list of

    • Prescription s, each of which have a

      • Dose and a

      • Duration.

A more detailed description of the classes follows below:

  • PrescriptionList

    • Every Person has a PrescriptionList, the purpose of which is to store the Person 's Prescriptions.

    • A wrapper class around the internal representation of a list of prescriptions that exposes only a few select methods in its API.

      • The methods relevant for the addmeds command execution are: add

  • Prescription

    • Class encapsulating all the information about a given medication prescription.

      • More specifically, the Prescription class encapsulates the name of the drug prescribed, the dosage information (itself stored as a Dose object), and the duration of the prescription (as a Duration object).

  • Dose

    • Class encapsulating all the information about a given medication dosage.

      • More specifically, the Dose class encapsulates the dose, dosage unit, and doses per day to administer.

  • Duration

    • Class encapsulating all the information about a given time period.

      • More specifically, the Duration class encapsulates the duration of the time period in milliseconds, and the calendar dates for the start and end of that time period.

Given below is an example usage scenario and how the relevant classes behave at each step.
At the end of the explanation is a sequence diagram of a typical addmeds command execution.

The user executes addmeds ic/S1234567A d/Paracetamol q/2 u/tablets n/4 t/14 .
This command has the following intent: Prescribe the following medication to a patient with NRIC = S1234567A:

Drug Name

Dosage

Duration

Paracetamol

2 tablets, 4 times a day

14 days, from current date to 14 days from now.

The command text is passed to an instance of the LogicManager class, which in turn executes HealthBaseParser::parse.
The HealthBaseParser parses the command word (addmeds) and executes AddmedsCommandParser::parse.
This causes the AddmedsCommandParser to construct the following objects in the following order:

Index

Information used

Class instances used

Class instance constructed

1

Dosage, Dosage unit, Doses per day

nil

Dose object

2

Duration in days

nil

Duration object

3

NRIC

nil

Nric object

4

Drug name

Dose, Duration

Prescription object

5

nil

Nric, Prescription

AddmedsCommand object

The AddmedsCommandParser::parse method returns an AddmedsCommand object which encapsulates the necessary information to update the Person 's medication(s).
Control then passes back to the LogicManager, which calls AddmedsCommand::execute.

If no/multiple patient(s) with that NRIC exist, then the AddmedsCommand::execute method will throw a CommandException with the appropriate error message and the usage case will end.

The AddmedsCommand::execute method constructs a new Person object using all the details of the old Person, with the sole difference being the PrescriptionList used being a deep copy of the original Person 's PrescriptionList with the new Prescription added. This updated Person object is used to update the existing Person object using the Model::updatePerson method (or an overridden version) of the backing model. Finally, the AddmedsCommand::execute method terminates, returning a CommandResult with a success message. The LogicManager then returns the same CommandResult as the return value of the LogicManager::execute method. The command execution then ends.

The following sequence diagram shows the execution of the addmeds command:

AddmedsSequenceDiagram
Figure 13. Execution sequence of the addmeds command

3.3.2. Design considerations

Aspect: Data structure to support the medication data storage
  • Alternative 1 (Current implementation): Store the data inside multiple POJO classes, with new classes being introduced as necessary to maintain high cohesion of individual classes. For example, the Duration class holds temporal information, whereas the Dose class holds medication dosage-related information.

    • Pros: Maintains the Single Responsibility Principle (e.g. the Prescription class now changes only if there are changes to the structure of a physical prescription, and not due to (e.g.) changes in time representation, or the way that dosage-related information is stored.

    • Cons: Increases the number of classes we will have to maintain.

  • Alternative 2: Store all the data directly as members inside a single Prescription class.

    • Pros: Reduces the number of classes we will have to maintain.

    • Cons: Reduces the cohesion of the Prescription class as it now handles multiple different items e.g. dosage-related information and duration-related information.

3.4. Addmh

3.4.1. Current implementation

The function of the addmh command is to allow the user to add a diagnosis to a patient’s medical history. Each patient’s information is stored within the Person objects. The execution of the addmh command results in the retrieval of a particular Person object, and the consequent updating of the patient’s MedicalHistory.

Stated below is an example usage scenario and an explanation of the interactions that occurs as a result of the code execution.

The user executes the following input:

addmh ic/S1234567A mh/Hypertension, diagnosed “years ago”, well contracted with Metoponol doc/Dr. Amos

Intent

The purpose of the entered input is to record a diagnosis issued by Dr.Amos, "Hypertension, diagnosed “years ago”, well contracted with Metoponol", into the medical history of the patient with the NRIC S1234567A.

3.4.2. Command execution

The sequence diagram below shows the execution of the given scenario:

AddmhSequenceDiagram
Figure 14. Execution sequence of the addmh command

addmh ic/S1234567A mh/Hypertension, diagnosed “years ago”, well contracted with Metoponol doc/Dr. Amos

  1. Firstly, the String user input is passed into the LogicManager::execute method of the LogicManager instance as the only parameter.

  2. Then, the LogicManager::execute method calls HealthBaseParser::parseCommand which receives the user input as a parameter.

    • The user input is formatted: the first String token is taken as the command word, while the remaining String is grouped as arguments to be used later in AddmhCommandParser.

    • From the command word, the HealthBaseParser instance identifies the user input as an addmh command and constructs an AddmhCommandParser instance.

  3. Next, the HealthBaseParser calls the AddmhCommandParser::parse method. The AddmhCommandParser takes in the remaining string, ic/S1234567A mh/Hypertension, diagnosed “years ago”, well contracted with Metoponol doc/Dr. Amos.

    • The string is tokenised to arguments according to their prefixes.

      ArgumentMultimap argMultimap = ArgumentTokenizer.tokenize(args, PREFIX_NRIC, PREFIX_MED_HISTORY, PREFIX_DOCTOR);
    • A check on the presence of the relevant prefixes ic/, mh/ and doc/ is done.

    • If not all prefixes are present, a ParseException will be thrown with an error message on the proper usage of the addmh command.

      if (!arePrefixesPresent(argMultimap, PREFIX_NRIC, PREFIX_MED_HISTORY, PREFIX_DOCTOR)
              || !argMultimap.getPreamble().isEmpty()) {
              throw new ParseException((String.format(MESSAGE_INVALID_COMMAND_FORMAT,
                                                      AddmhCommand.MESSAGE_USAGE)));
      }
    • Otherwise, Diagnosis and Nric objects are constructed and used as fields in the creation of an AddmhCommand object.

  4. Subsequently, the newly created AddmhCommand is returned to back to the LogicManager instance through AddmhCommandParser and HealthBaseParser objects.

  5. When control is returned to the LogicManager object, it calls the AddmhCommand::execute method.

    • The method takes in a Model object to access the application’s data context, the stored data of all persons.

    • Its execution sequence may be broken down into the numbered steps in the code below.

    public CommandResult execute(Model model, CommandHistory history) throws CommandException {
        requireNonNull(model);
    
        Person patientToUpdate = CommandUtil.getPatient(patientNric, model); (6)
        Person updatedPatient = addMedicalHistoryForPatient(patientToUpdate, this.newRecord); (7)
    
        model.updatePerson(patientToUpdate, updatedPatient); (8)
    
        return new CommandResult(String.format(MESSAGE_SUCCESS, patientNric)); (9)
    }
  6. The stored persons data is accessed in the CommandUtil::getPatient class method.

    • Model::getFilteredPersonList is called to search for a person with a Nric that matches the Nric field in the AddmhCommand

    • If a match is found, the Person is returned to the AddmhCommand::execute method.

      public static Person getPatient(Nric nric, Model model) throws CommandException {
          ObservableList<Person> matchedCheckedOutPatients = model.getFilteredCheckedOutPersonList()
              .filtered(p -> nric.equals(p.getNric()));
      
          if (matchedCheckedOutPatients.size() > 0) {
              throw new CommandException(MESSAGE_PATIENT_CHECKED_OUT);
          }
      
          ObservableList<Person> matchedCheckedInPatients = model.getFilteredPersonList()
              .filtered(p -> nric.equals(p.getNric()));
      
          if (matchedCheckedInPatients.size() < 1) {
              throw new CommandException(MESSAGE_NO_SUCH_PATIENT);
          }
      
          if (matchedCheckedInPatients.size() > 1) {
              throw new CommandException(MESSAGE_MULTIPLE_PATIENTS);
          }
      
          return matchedCheckedInPatients.get(0);
      }
  7. Following that, the Person 's medical history is to be updated.

    • The person’s current medicalHistory is retrieved, and the Diagnosis field in the AddmhCommand is added it.

    • Then, a new Person is created with the updated fields, as part of the immutability of the Person class.

      private static Person addMedicalHistoryForPatient(Person patientToEdit, Diagnosis diagnosis) {
          requireAllNonNull(patientToEdit, diagnosis);
      
          MedicalHistory updatedMedicalHistory = patientToEdit.getMedicalHistory();
          updatedMedicalHistory.add(diagnosis);
      
          return patientToEdit.withMedicalHistory(updatedMedicalHistory);
      }
  8. Then, the old Person 's data will be replaced with the updated Person 's data.

    • Here the Model::updatePerson method is called, and it subsequently calls the HealthBase::updatePerson method.

    • Replaces the person’s existing data in the storage with the person’s updated data.

      // ModelManager.java
      public void updatePerson(Person target, Person editedPerson) {
          requireAllNonNull(target, editedPerson);
      
          internalHealthBase.updatePerson(target, editedPerson);
          indicateHealthBaseChanged();
      }
      
      // HealthBase.java
      public void updatePerson(Person target, Person editedPerson) {
          requireNonNull(editedPerson);
      
          persons.setPerson(target, editedPerson);
      }
  9. The AddmhCommand::execute execution completes by returning a new CommandResult that contains a success message to its calling method, LogicManager::execute.

  10. Finally the CommandResult is returned to the caller of LogicManager::execute, and the execution sequence ends.


The activity diagram below summarises what happens when a user executes the addmh command.

AddmhActivityDiagram
Figure 15. The activity diagram for the addmh command
If multiple patients with the entered NRIC exist, then the AddmhCommand::execute will throw a CommandException with an appropriate error message before the use case ends.

3.4.3. Design Considerations

Aspect: How to represent a timestamp in a diagnosis
  • Alternative 1 (current implementation): Use a POJO class to represent the timestamp data in the Diagnosis class.

    • Pros: Results in improved readability and modularity of code, due to a stronger adherence to the Object-Oriented Programming paradigm.

    • Cons: Increases in modularity can make it difficult to find information, if code becomes over-modularised.

  • Alternative 2 (alternative implementation): Use a String to represent the timestamp and contain date-time related functions in the Diagnosis class.

    • Pros: Results in more compact code.

    • Cons: Decreases code modularity, and this decreases code readability.

Aspect: How to store medical history
  • Alternative 1 (current implementation): Use an ArrayList to store diagnoses in a person.

    • Pros: Allows expandable storage of diagnoses with its dynamic size. As an ArrayList implements the list interface, its contracted functionality suitably represents a list of diagnoses and this makes its usage in developing intuitive.

    • Cons: Slows down performance if the ArrayList capacity is constantly filled due to resizing costs.

  • Alternative 2 (alternative implementation): Use an Array to store diagnoses in a person.

    • Pros: Reduces performance losses that may arise from constant resizing in ArrayLists.

    • Cons: Decreases flexibility in developing as Arrays do not support generics in Java.

3.5. Visitorin/Viewvisitors/Visitorout

3.5.1. Current implementation

There three commands related to manage patients' visitors.

  • The visitorin command allows user to add visitors into patient’s visitorList. Each patient has a VisitorList and the maximum size of the list is 5 so that patients can have a comfortable environment.

  • The viewvisitors command allows user to view a patient’s current visitors in his/her VisitorList. It displays all the visitors from the requested patient’s visitorList in order of entry.

  • The visitorout command allows user to remove a visitor from patient’s VisitorList.

Classes associated

The three commands are executed mainly depends on the classes of VisitorList and Visitor. Each Person object contains a VisitorList. The visitorin and visitorout commands are created to add/remove a Visitor in the required Person 's VisitorList. The viewvisitors command display the Person 's VisitorList.

  • VisitorList, a list of

    • Visitor s

A more detailed description of the classes involved is as follows:

  • Visitor

    • This class encapsulates the given name of the visitor.

    • String represent the visitor name.

  • VisitorList

    • Using List type of structure to store all the Visitor s stored for a particular patient

3.5.2. Commands Execution

To illustrate how the three commands work, examples are given below.

  • visitorin ic/S1234567A v/Jane

    • The command inputs are passed to an instance of the LogicManager class.

    • HealthBaseParser parses the command word (visitorin) and executes VisitorInCommandParser::parse.

    • VisitorInCommandParser::parse construct and a Visitor (Jane), Nric (S1234567A) of the patient provided by the user and then returns VisitorinCommand object. Below shows the part of code:

public CommandResult execute(Model model, CommandHistory history) throws CommandException {
        requireNonNull(model);

        Person patientToUpdate = CommandUtil.getPatient(patientNric, model);

        if (patientToUpdate.getVisitorList().getSize() >= 5) {
            throw new CommandException(MESSAGE_FULL);
        }

        if (patientToUpdate.getVisitorList().contains(visitorName)) {
            throw new CommandException(MESSAGE_DUPLICATE_VISITORS);
        }

        Person updatedPatient = addVisitorForPatient(patientToUpdate, this.visitorName);

        model.updatePerson(patientToUpdate, updatedPatient);

        return new CommandResult(String.format(MESSAGE_SUCCESS, patientNric));
    }
  • In VisitorinCommand, new Visitor object is created and added to a copy of the required Person object’s VisitorList

    • The new Person object is updated to the model by Model#updatePerson method.

    • A new CommandResult object is returned and the execution ends.

Below is visitorin sequence diagram (Figure 1):

VisitorinSequenceDiagram
Figure 16. visitorin sequence diagram
  • viewvisitor ic/S1234567A

    • Similar to the visitorin command, ViewvisitorsCommandParser::parse the required patient’s ic(S1234567A) and returns a ViewvisitorsCommand object

    • ViewvisitorsCommand retrieves the person with the required patient’s ic and construct a copy of selected patient’s VisitorList for display

      • A new CommandResult object is returned and the execution ends.

Below is viewvisitor sequence diagram (Figure 2):

ViewvisitorsSequenceDiagram
Figure 17. viewvisitor sequence diagram
  • visitorout ic/S1234567A v/Jane

    • Similar to the visitorin command, VisitoroutCommandParser::parse construct and a Visitor (Jane), Nric (S1234567A) of the patient provided by the user and then returns VisitoroutCommand object. Below shows the part of code:

public CommandResult execute(Model model, CommandHistory history) throws CommandException {
        requireNonNull(model);

        Person selectedPatient = CommandUtil.getPatient(patientNric, model);
        VisitorList patientVisitorList = selectedPatient.getVisitorList();

        if (patientVisitorList.getSize() == 0) {
            return new CommandResult(String.format(MESSAGE_NO_VISITORS, patientNric));
        }

        if (!patientVisitorList.contains(visitorName)) {
            return new CommandResult(String.format(MESSAGE_NO_REQUIRED_VISITOR, patientNric));
        }

        Person updatedPatient = removeVisitorForPatient(selectedPatient, this.visitorName);

        model.updatePerson(selectedPatient, updatedPatient);

        return new CommandResult(String.format(MESSAGE_SUCCESS, patientNric));
    }
  • In VisitoroutCommand, new Visitor object is created and removed from the copy of the required Person object’s VisitorList

    • The new Person object is updated to the model by Model#updatePerson method.

    • A new CommandResult object is returned and the execution ends.

Below is visitorout sequence diagram (Figure 3):

VisitoroutSequenceDiagram
Figure 18. visitorout sequence diagram

3.7. Logging

We are using the java.util.logging package for logging. The LogsCenter class is used to manage the logging levels and logging destinations.

  • The logging level can be controlled using the logLevel setting in the configuration file (See Section 3.8, “Configuration”)

  • The Logger for a class can be obtained using LogsCenter.getLogger(Class) which will log messages according to the specified logging level

  • Currently, log messages are output through: Console and to a .log file.

Logging levels

  • SEVERE : Critical problem detected which may possibly cause the termination of the application

  • WARNING : Can continue, but with caution

  • INFO : Information showing the noteworthy actions by the App

  • FINE : Details that is not usually noteworthy but may be useful in debugging e.g. print the actual list instead of just its size

3.8. Configuration

Certain properties of the application can be controlled (e.g app name, logging level) through the configuration file (default: config.json).

4. Documentation

We use AsciiDoc for writing documentation.

We chose AsciiDoc over Markdown because AsciiDoc, although a bit more complex than Markdown, provides more flexibility in formatting.

4.1. Editing documentation

See UsingGradle.adoc to learn how to render .adoc files locally to preview the end result of your edits. Alternatively, you can download the AsciiDoc plugin for IntelliJ, which allows you to preview the changes you have made to your .adoc files in real-time.

4.2. Publishing documentation

See UsingTravis.adoc to learn how to deploy GitHub Pages using Travis.

4.3. Converting documentation to PDF format

We use Google Chrome for converting documentation to PDF format, as Chrome’s PDF engine preserves hyperlinks used in webpages.

Here are the steps to convert the project documentation files to PDF format.

  1. Follow the instructions in UsingGradle.adoc to convert the AsciiDoc files in the docs/ directory to HTML format.

  2. Go to your generated HTML files in the build/docs folder, right click on them and select Open withGoogle Chrome.

  3. Within Chrome, click on the Print option in Chrome’s menu.

  4. Set the destination to Save as PDF, then click Save to save a copy of the file in PDF format. For best results, use the settings indicated in the screenshot below.

chrome save as pdf
Figure 19. Saving documentation as PDF files in Chrome

4.4. Site-wide documentation settings

The build.gradle file specifies some project-specific asciidoc attributes which affects how all documentation files within this project are rendered.

Attributes left unset in the build.gradle file will use their default value, if any.
Table 1. List of site-wide attributes
Attribute name Description Default value

site-name

The name of the website. If set, the name will be displayed near the top of the page.

not set

site-githuburl

URL to the site’s repository on GitHub. Setting this will add a "View on GitHub" link in the navigation bar.

not set

site-seedu

Define this attribute if the project is an official SE-EDU project. This will render the SE-EDU navigation bar at the top of the page, and add some SE-EDU-specific navigation items.

not set

4.5. Per-file documentation settings

Each .adoc file may also specify some file-specific asciidoc attributes which affects how the file is rendered.

Asciidoctor’s built-in attributes may be specified and used as well.

Attributes left unset in .adoc files will use their default value, if any.
Table 2. List of per-file attributes, excluding Asciidoctor’s built-in attributes
Attribute name Description Default value

site-section

Site section that the document belongs to. This will cause the associated item in the navigation bar to be highlighted. One of: UserGuide, DeveloperGuide, LearningOutcomes*, AboutUs, ContactUs

* Official SE-EDU projects only

not set

no-site-header

Set this attribute to remove the site navigation bar.

not set

4.6. Site template

The files in docs/stylesheets are the CSS stylesheets of the site. You can modify them to change some properties of the site’s design.

The files in docs/templates controls the rendering of .adoc files into HTML5. These template files are written in a mixture of Ruby and Slim.

Modifying the template files in docs/templates requires some knowledge and experience with Ruby and Asciidoctor’s API. You should only modify them if you need greater control over the site’s layout than what stylesheets can provide. The SE-EDU team does not provide support for modified template files.

5. Testing

5.1. Running tests

There are three ways to run tests.

The most reliable way to run tests is the third one. The first two methods might fail some GUI tests due to platform/resolution-specific idiosyncrasies.

Method 1: Using IntelliJ JUnit test runner

  • To run all tests, right-click on the src/test/java folder and choose Run 'All Tests'

  • To run a subset of tests, you can right-click on a test package, test class, or a test and choose Run 'ABC'

Method 2: Using Gradle

  • Open a console and run the command gradlew clean allTests (Mac/Linux: ./gradlew clean allTests)

See UsingGradle.adoc for more info on how to run tests using Gradle.

Method 3: Using Gradle (headless)

Thanks to the TestFX library we use, our GUI tests can be run in the headless mode. In the headless mode, GUI tests do not show up on the screen. That means the developer can do other things on the Computer while the tests are running.

To run tests in headless mode, open a console and run the command gradlew clean headless allTests (Mac/Linux: ./gradlew clean headless allTests)

5.2. Types of tests

We have two types of tests:

  1. GUI Tests - These are tests involving the GUI. They include,

    1. System Tests that test the entire App by simulating user actions on the GUI. These are in the systemtests package.

    2. Unit tests that test the individual components. These are in seedu.address.ui package.

  2. Non-GUI Tests - These are tests not involving the GUI. They include,

    1. Unit tests targeting the lowest level methods/classes.
      e.g. seedu.address.commons.StringUtilTest

    2. Integration tests that are checking the integration of multiple code units (those code units are assumed to be working).
      e.g. seedu.address.storage.StorageManagerTest

    3. Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together.
      e.g. seedu.address.logic.LogicManagerTest

5.3. Troubleshooting testing

Problem: HelpWindowTest fails with a NullPointerException.

  • Reason: One of its dependencies, HelpWindow.html in src/main/resources/docs is missing.

  • Solution: Execute Gradle task processResources.

6. Dev Ops

6.1. Build automation

See UsingGradle.adoc to learn how to use Gradle for build automation.

6.2. Continuous integration

We use Travis CI to perform Continuous Integration on our projects. See UsingTravis.adoc and UsingAppVeyor.adoc for more details.

6.3. Coverage reporting

We use Coveralls to track the code coverage of our projects. See UsingCoveralls.adoc for more details.

6.4. Documentation previews

When a pull request has changes to asciidoc files, you can use Netlify to see a preview of how the HTML version of those asciidoc files will look like when the pull request is merged. See UsingNetlify.adoc for more details.

6.5. Making a release

Here are the steps to create a new release.

  1. Update the version number in MainApp.java.

  2. Generate a JAR file using Gradle.

  3. Tag the repo with the version number. e.g. v0.1

  4. Create a new release using GitHub and upload the JAR file you created.

6.6. Managing dependencies

A project often depends on third-party libraries. For example, HealthBase depends on the Jackson library for XML parsing. Managing these dependencies can be automated using Gradle. For example, Gradle can download the dependencies automatically, which is better than these alternatives.
a. Include those libraries in the repo (this bloats the repo size)
b. Require developers to download those libraries manually (this creates extra work for developers)

Appendix A: Product Scope

Target user profile:

  • has a need to manage a significant amount of medical data

  • prefer desktop apps over other types

  • can type fast

  • prefers typing over mouse input

  • is reasonably comfortable using CLI apps

Value proposition: manage patient data faster than a typical mouse/GUI driven app or pen/paper management systems.

Appendix B: User Stories

Priorities: High (must have) - * * *, Medium (nice to have) - * *, Low (unlikely to have) - *

Priority As a …​ I want to …​ So that I can…​

* * *

doctor

view my patient’s medical history

be aware of any chronic illnesses he has.

* * *

doctor

view my patient’s current medication

avoid double-prescriptions.

* * *

doctor

search for a particular patient

view his information.

* * *

doctor

view my patient’s medical history

understand his medical situation better.

* * *

doctor

view my patient’s drug allergies

prescribe him the correct medicine.

* * *

doctor

view my patient’s drug prescription history on a timeline

have a better idea of the patient’s medication history.

* * *

pharmacist

view my patient’s current medication

can avoid double-prescriptions.

* * *

nurse

view my patient’s dietary information

know my patient’s dietary preference.

* * *

nurse

view a patient’s next-of-kin

contact them in the event that the patient dies.

* * *

nurse

view a patient’s medical history

can triage them effectively.

* * *

counter staff

view a patient’s registered visitors

verify if a visitor is a valid visitor.

* * *

counter staff

view a patient’s registered visitors

view the number of visitors for each patient at any one time

{More to be added in V2.0}

Appendix C: Use Cases

(For all use cases below, the System is the HealthBase and the Actor is the user, unless specified otherwise)

Use case: delete patients

MSS

  1. User requests to list patients

  2. HealthBase shows a list of patients

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

  4. HealthBase deletes the patient

    Use case ends.

Extensions

  • 2a. The list is empty.

    Use case ends.

  • 3a. The given index is invalid.

    • 3a1. HealthBase shows an error message.

      Use case resumes at step 2.

Use case: View patient’s medical details

MSS

  1. Doctor requests to list patient’s medical details

  2. HealthBase shows a list of the patient’s medical details

    Use case ends.

Extensions

  • 2a. The patient does not exist.

    • 2a1. HealthBase shows an error message.

      Use case ends.

Use case: View patient’s medication

MSS

  1. Doctor/Pharmacist requests to list patient’s current medication

  2. HealthBase shows a list of the patient’s current medication

    Use case ends.

Extensions

  • 2a. The patient does not exist.

    • 2a1. HealthBase shows an error message.

      Use case ends.

Use case: View patient’s dietary details

MSS

  1. User searches the name of a patient

  2. HealthBase shows a list of patients

  3. User requests to view a patient’s dietary details

  4. HealthBase shows requested details

    Use case ends.

Extensions

  • 2a. The list is empty.

    Use case ends.

  • 3a. The given index is invalid.

    • 3a1. HealthBase shows an error message.

      Use case ends.

Use case: Sign in patient’s visitors

MSS

  1. Counter staff inputs the visited patient’s NRIC

  2. Visitor is registered

    Use case ends.

Extensions

  • 2a. Number of visitors for that patient exceeds maximum number(5) allowed.

    • 2a1. HealthBase rejects visitor.

      Use case ends.

Use case: Sign out patient’s visitors

MSS

  1. Counter staff inputs the visited patient’s NRIC and visitor name

  2. Visitor is signed out

    Use case ends

Extensions

  • 1a. Counter staff inputs the visited patient’s number and visitor name.

  • 2a. Visitor is signed out.

    Use case ends.

Use case: Register patient

MSS

  1. Counter nurse request to register a new patient

  2. Counter nurse inputs the patient’s NRIC

  3. HealthBase adds the patient into the patient queue

    Use case ends

Extensions

  • 1a. The patient is already checked in.

    • 1a1. HealthBase shows an error message.

      Use case resumes at step 2.

  • 2a. The patient has no existing data.

    • 2a1. HealthBase prompts for additional data.

      User case resumes at step 2.

    • 3a1. HealthBase shows an error message.

      Use case resumes at step 2.

Use case: Checkout patient

MSS

  1. Counter nurse request to checkout patient

  2. Counter nurse inputs the details for the patient to be checked out.

  3. User requests to delete a specific person in the list

  4. HealthBase removes the patient from patient queue

    Use case ends.

Extensions

  • 2a. The list is empty.

    Use case ends.

  • 3a. The given index is invalid.

    • 3a1. HealthBase shows an error message.

      Use case resumes at step 2.

Appendix D: Non Functional Requirements

  1. Should work on any mainstream OS as long as it has Java 9 or higher installed.

  2. Should be able to hold up to 1000 patients without a noticeable sluggishness in performance for typical usage.

  3. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse.

  4. Should work on Windows 10 and above as long as it has Java 9 or higher installed.

  5. Should be able to hold up to 1000 patients without a noticeable sluggishness in performance for typical usage.

  6. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse.

  7. Patient data should be securely encrypted.

  8. Patients information will be safely backed up every week.

{More to be added in V2.0}

Appendix E: Glossary

Mainstream OS

Windows, Linux, Unix, OS-X

Private contact detail

A contact detail that is not meant to be shared with others

Patient’s medical details

Information about the patient’s medical history and drug allergies

Medical history

Past records of healthcare visits, pre-existing medical conditions

Authorised visitors

Upon check-in of patient, the information of permitted visitors entered

Register

Patient registers at the hospital

Checkout

Patient is discharged from the hospital

Appendix F: Instructions for Manual Testing

Given below are instructions to test the app manually.

These instructions only provide a starting point for testers to work on; testers are expected to do more exploratory testing.

F.1. Launch and shutdown

  1. Initial launch

    1. Download the jar file and copy into an empty folder

    2. Double-click the jar file
      Expected: Shows the GUI with a set of sample patients. The window size may not be optimum.

  2. Saving window preferences

    1. Resize the window to an optimum size. Move the window to a different location. Close the window.

    2. Re-launch the app by double-clicking the jar file.
      Expected: The most recent window size and location is retained.

F.2. Generating test data

  1. Generating patients with mock data

    1. Open the application.

    2. Run the following commands in the following sequence:

      1. dev-mode (Enables developer mode; the next command requires developer mode to run.)

      2. gendata NUMBER_OF_PATIENTS, where NUMBER_OF_PATIENTS is a positive integer value that indicates how many patients you wish to generate.

The application will then generate that number of patients with mock data for their:

  1. Personal particulars

    1. NRIC

    2. Name

    3. Phone number

    4. Email address

    5. Physical address

  2. Drug allergies

  3. Medications

  4. Appointments

  5. Dietary restrictions

  6. Medical history

Details on the exact range of values that the mock data can take on can be found in the related .java files.

F.3. Adding an appointment for a patient

  1. Adding an appointment for a checked in patient

    1. Prerequisites: Patient must not have an existing appointment at the same Date and Time

    2. Test case: addappt ic/S1234567A type/SRG pn/Heart Bypass dt/27-04-2019 10:30 doc/Dr. Pepper
      Expected: Appointment is added for patient. To verify, run view appt.

    3. Test case: addappt ic/S1234567 type/SRG pn/Heart Bypass dt/27-04-2019 10:30 doc/Dr. Pepper
      Expected: Appointment is not added due to the invalid NRIC input.

    4. Test case: addappt ic/S1234567A type/SRG pn/Heart Bypass dt/27-04-2019 10:30 doc/Dr. Pepper (after (b) has been run)
      Expected: Appointment is not added due to the duplicate Date and Time from an existing appointment.

    5. Test case: addappt ic/S1234567A type/apple pn/Heart Bypass dt/27-04-2019 10:30 doc/Dr. Pepper
      Expected: Appointment is not added due to the invalid Type input.

    6. Test case: addappt ic/S1234567A type/SRG pn/123 dt/27-04-2019 10:30 doc/Dr. Pepper
      Expected: Appointment is not added because Procedure Name must only consist of alphabets.

    7. Test case: addappt ic/S1234567A type/SRG pn/Heart Bypass dt/27-04-2019 10:30 doc/Pepper
      Expected: Appointment is not added because of the missing salutation for Doctor.

F.4. Adding dietary requirements for a patient

  1. Adding dietary requirements for a checked in patient

    1. Prerequisites: Select a patient in the app using the select command. If there are no patients to be selected, add a new patient using the register command. Let this selected patient’s NRIC be denoted by $nric. The test cases must be executed in the sequence listed.

    2. Test case: adddiet ic/$nric alg/Egg alg/Milk cr/Halal pd/Hands cannot move
      Expected: Dietary requirements are added for patient. To verify, run view diets.

    3. Test case: adddiet ic/$nric cr/Vegetarian
      Expected: Dietary requirement is added for patient. To verify, run view diets.

    4. Test case: adddiet ic/$nric alg/Egg
      Expected: No new dietary requirement is added, since the new allergy has been added before.

    5. Test case: adddiet ic/$nric pd/1 hand cannot move.
      Expected: Dietary requirement is not added due to the invalid input.

    6. Test case: adddiet ic/$nric alg/Fish cr/
      Expected: Dietary requirement is not added due to the invalid cr input.

F.5. Adding medication for a patient

  1. Adding medication for a given patient

  1. Prerequisites: Select a patient in the app using the select command. If there are no patients to be selected, add a new patient using the register command. Let this selected patient’s NRIC be denoted by $nric.

  2. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/4 t/14
    Expected: A prescription corresponding to "Paracetamol, 2 tablets 4 times a day for 14 days" is added to the patient’s medications.

  3. Test case: addmeds ic/$nric d/ q/2 u/tablets n/4 t/14
    Expected: No prescription is added. Error details shown in the status message.

  4. Test case: addmeds ic/$nric d/ q/2 u/tablets n/4 t/14 (Whitespace character as drug name)
    Expected: No prescription is added. Error details shown in the status message.

  5. Test case: addmeds ic/$nric d/Paracetamol q/0 u/tablets n/4 t/14
    Expected: No prescription is added. Error details shown in the status message.

  6. Test case: addmeds ic/$nric d/Paracetamol q/-1 u/tablets n/4 t/14
    Expected: No prescription is added. Error details shown in the status message.

  7. Test case: addmeds ic/$nric d/Paracetamol q/ u/tablets n/4 t/14
    Expected: No prescription is added. Error details shown in the status message.

  8. Test case: addmeds ic/$nric d/Paracetamol q/A u/tablets n/4 t/14
    Expected: No prescription is added. Error details shown in the status message.

  9. Test case: addmeds ic/$nric d/Paracetamol q/2 u/ n/4 t/14
    Expected: No prescription is added. Error details shown in the status message.

  10. Test case: addmeds ic/$nric d/Paracetamol q/2 u/ n/4 t/14 (Empty string as input for dosage unit)
    Expected: No prescription is added. Error details shown in the status message.

  11. Test case: addmeds ic/$nric d/Paracetamol q/2 u/ n/4 t/14 (Whitespace as input for dosage unit)
    Expected: No prescription is added. Error details shown in the status message.

  12. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/0 t/14
    Expected: No prescription is added. Error details shown in the status message.

  13. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/-1 t/14
    Expected: No prescription is added. Error details shown in the status message.

  14. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/-1 t/14
    Expected: No prescription is added. Error details shown in the status message.

  15. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/A t/14
    Expected: No prescription is added. Error details shown in the status message.

  16. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/4 t/0
    Expected: No prescription is added. Error details shown in the status message.

  17. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/4 t/-1
    Expected: No prescription is added. Error details shown in the status message.

  18. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/4 t/0.5
    Expected: No prescription is added. Error details shown in the status message.

  19. Test case: addmeds ic/$nric d/Paracetamol q/2 u/tablets n/4 t/AAA
    Expected: No prescription is added. Error details shown in the status message.

F.6. Adding a diagnosis to a patient’s medical record

  • Add diagnosis to a registered patient while all patients are listed.

    1. Prerequisites:

      • Patient must be listed in the list on the panel on the left-hand side. Use the list command to list them, if there are no listed patients.

      • Patient must be registered in HealthBase already.

      • Enter the following commands to set up a test scenario with only one registered patient:

        1. clear

        2. register ic/S1234567A n/John Doe p/98765432 e/johnd@example.com a/311, Clementi Ave 2, #02-25 da/aspirin da/insulin

    2. Test case: addmh ic/S1234567A mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/Dr.Ross
      Expected: Patient’s diagnosis is successfully added.

    3. Test case: addmh ic/ mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/Dr.Ross
      Expected: Failed addition, NRICs should consist of a starting letter (capital), followed by 7 numerical digits, followed by a letter (again capital). No such patient will exist.

    4. Test case: addmh ic/S9876543Z mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/Dr.Ross
      Expected: Failed addition, patient is not registered, cannot add diagnosis for an unregistered patient.

    5. Test case: addmh ic/A1234567Z mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/Dr.Ross
      Expected: NRICs should consist of a starting letter (capital), followed by 7 numerical digits, followed by a letter (again capital). No such patient will exist.

    6. Test case: addmh ic/S12234598675667A mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/Dr.Ross
      Expected: Failed addition, NRICs should consist of a starting letter (capital), followed by 7 numerical digits, followed by a letter (again capital). No such patient will exist.

    7. Test case: addmh ic/S1234567A mh/ doc/Dr.Ross
      Expected: Failed addition, diagnosis should not be blank.

    8. Test case: addmh ic/S1234567A mh/ doc/Dr.Ross
      Expected: Failed addition, diagnosis should not be a whitespace.

    9. Test case: addmh ic/S1234567A mh/!$!#! doc/Dr.Ross
      Expected: Patient’s diagnosis is successfully added, diagnosis does not need to be made up of word letters.

    10. Test case: addmh ic/S1234567A mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/dr.Ross
      Expected: Failed addition, doctor’s title should precede his full name. The starting letter of all words in the doctor’s title should be should be spelt out with capitalisation.

    11. Test case: addmh ic/S1234567A mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/Dr.Ross Geller Stuart Jack Ma Steve Bombamama Nojobs
      Expected: Patient’s diagnosis is successfully added as doctor’s name is valid.

    12. Test case: addmh ic/S1234567A mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/
      Expected: Failed addition, doctor’s name should not be blank.

    13. Test case: addmh ic/S1234567A mh/Patient has acute terminal stage brain cancer, refer to Dr.Zhang immediately. doc/
      Expected: Failed addition, doctor’s name cannot be a whitespace.

F.7. Changing the view

  1. Changing the view (right-side panel of the UI)

    1. Prerequisites: None

    2. Test case: view default
      Expected: The view changes to a blank panel (the default view).

    3. Test case: view appt
      Expected: The view changes to the Appointment View.

    4. Test case: view diets
      Expected: The view changes to the Diet View.

    5. Test case: view meds
      Expected: The view changes to the Medication View.

    6. Test case: view mh
      Expected: The view changes to the Medical History view.

    7. Test case: view AAA
      Expected: The view does not change. An error message is shown.

    8. Test case: view
      Expected: The view does not change. An error message is shown.

F.8. Sorting the view

  1. Sorting a given view

    1. Prerequisites: The current view is a sortable view. Change the view to the Medication View (guaranteed sortable) using view meds.

    2. Test case: sort a 1
      Expected: The first column is used to sort the entries in the Medication View in ascending order. The natural ordering is lexicographical (for alphabetical data) and numerical (for numerical data).

    3. Test case: sort
      Expected: The view remains unsorted. An error message is shown.

    4. Test case: sort x
      Expected: The view remains unsorted. An error message is shown.

    5. Test case: sort a
      Expected: The view remains unsorted. An error message is shown.

F.9. Checking out a patient

  1. Checking out a patient who is in the system

    1. Prerequisites: A patient is registered and checked in to the system, and is visible on the left panel. Let $nric denotes this patient’s NRIC. Let $nricOther denotes an NRIC of a patient who is not registered in the system. The test cases must be executed in the sequence listed.

    2. Test case: checkout ic/$nricOther
      Expected: The command fails. Error detail shown in the status message.

    3. Test case: checkout ic/$nric
      Expected: The patient with $nric is checked out.

    4. Test case: checkout ic/$nric
      Expected: The command fails. Error detail shown in the status message.

F.10. Checking in a patient

  1. Checking in a previously checked out patient

    1. Prerequisites: A patient is registered and previously checked out from the system. Let $nric denotes this patient’s NRIC. Let $nricOther denotes an NRIC of a patient who is not registered in the system. The test cases must be executed in the sequence listed.

    2. Test case: checkin ic/$nricOther
      Expected: The command fails. Error detail shown in the status message.

    3. Test case: checkin ic/$nric
      Expected: The patient with $nric is checked in.

    4. Test case: checkin ic/$nric
      Expected: The command fails. Error detail shown in the status message.

F.11. Generating data

  1. Generating data for testing

    1. Prerequisites: The application must be in developer mode. Toggle developer mode using the dev-mode command.

    2. Test case: gendata 10
      Expected: The application’s data is cleared. 10 patients’s worth of data is generated.

    3. Test case: gendata
      Expected: No data is generated. An error message is shown.

    4. Test case: gendata -1
      Expected: No data is generated. An error message is shown.

    5. Test case: gendata A
      Expected: No data is generated. An error message is shown.