Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DG features sequence diagrams #260

Merged
90 changes: 58 additions & 32 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,24 @@ This section describes some noteworthy details on how certain features are imple

#### Implementation:

The add mechanism is facilitated by `AddressBook`. It implements `AddressBook#addPerson(Person p)`which allow users to add patients’ contacts and relevant patient information into the addressbook.
The `add` feature is implemented using the `AddCommand` class. The `AddCommand` object takes in a `Person` object.
`Person` object is created if the following conditions are satisfied:
- all the inputs for the parameters are valid
- all compulsory parameters are present
- no duplicate `Person` in ClinicMate

These operations are exposed in the `Model` interface as `Model#addPerson(Person p)`.
The add mechanism is facilitated by `AddressBook`. It implements `ModelManager#addPerson(Person p)`which allows users to add patients’ contacts
and relevant patient information into ClinicMate. These operations are exposed in the `Model` interface as `Model#addPerson(Person p)`.

Given below is an example usage scenario and how the add mechanism behaves at each step.
Apart from that, the feature also includes the following operation in `ModelManager`, which implements the `Model` interface:
- `Model#hasPerson(Person person)`: Checks if the `Person` to be added is already an existing `Person` profile in ClinicMate

Step 1. The user launches the application for the first time. The `AddressBook` will be initialized with the initial address book state.
Given below is an example usage scenario and how the `add` mechanism behaves at each step.

Step 2. The user executes `add n\John Doe …` to add the person in the address book with the unique identification number `T0123456A`. The add command calls `Model#addPerson(Person p)`, causing the modified state of the address book after the `add n\John Doe …` command executes to be saved.
Step 1. The user launches the application for the first time. `ClinicMate` will be initialized with the initial address book state.

Step 2. The user executes `add n\John Doe p\12345678 e\[email protected] i\T0123456A ag\12 s\M a\John street, block 123, #01-01` to add the person in the address book with the unique identification number `T0123456A`.
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved
The add command calls `Model#addPerson(Person p)`, causing the modified state of the address book after the `add n/John Doe …` command executes to be saved.
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved

<box type="info" seamless>

Expand All @@ -178,17 +186,17 @@ Step 2. The user executes `add n\John Doe …` to add the person in the address

</box>

The following sequence diagram shows how an add operation goes through the `Logic` component:
The following sequence diagram illustrates how the `add` command works and goes through the `Logic` and `Model` components.

<puml src="diagrams/AddCommandDiagram.puml" alt="AddCommandDiagram" />

<box type="info" seamless>

**Note:** The lifeline for `AddCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.
**Note:** The lifeline for `AddCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

</box>

The following activity diagram summarizes what happens when a user executes a new command:
The following activity diagram summarizes what happens when a user executes a new `add` command:

<div style="text-align: center;">
<puml src="diagrams/AddCommandActivityDiagram.puml" width="600"/>
Expand All @@ -209,48 +217,54 @@ The following activity diagram summarizes what happens when a user executes a ne
* **Alternative 2:** Allow users to add patients by adding fields as and when is needed (i.e. not make all the fields compulsory).
* Pros: Shorter command to type to add a patient.
* Cons:
* We must ensure that the implementation of each individual command are correct.
* Might not have all the relevant information of all patients. Messy to keep track.
* We must ensure that the implementation of each individual commands is correct.
* Might not have all the relevant information of the patients. Messy to keep track.
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved

**Aspect: Display of new contact when command is successful:**
* Current choice: Displays the new contact with relevant patient information in the addressbook.
* Current choice: Displays the new contact with relevant patient information in ClinicMate.
* Rationale: Users will be able to view the patient and the information added easily.

**Aspect: Display of error message when command is unsuccessful:**
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, duplicate person, invalid ic format).
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, duplicate person, invalid IC number format).
* Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful.

### Add/replace note feature

#### Implementation

The add/replace notes mechanism is facilitated by `AddressBook`. It implements `AddressBook#setPerson(Person target, Person editedPerson)` which allow users to add/replace patients’ notes in the addressbook.
The add/replace note mechanism is facilitated by `AddressBook`. It implements `AddressBook#setPerson(Person target, Person editedPerson)` which allow users to add/replace patients’ notes in the addressbook.

These operations are exposed in the `Model` interface as `Model#setPerson(Person target, Person editedPerson)`

The `addnote` feature has the following operations in `ModelManager` which implements the `Model` interface:
- `Model#setPerson`: Changes the note parameter of the target Person
- `Model#isPersonDisplayed`: Checks if the `Person` has their notes displayed in the person notes panel
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved
- `Model#setDisplayedNote`: If `Model#isPersonDisplayed` returns true, the notes displayed will be updated

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

Step 1. The user launches the application. The `AddressBook` will be initialized with the initial address book state.

Step 2. The user executes `addnote T0123456A …` to add a note to the person in the address book with the unique identification number `T0123456A`. The addnote command calls `Model#setPerson(Person target, Person editedPerson)`, causing the modified state of the address book after the `addnote T0123456A …` command executes to be saved.
Step 2. The user executes `addnote T0123456A n\Covid` to add a note to the person in ClinicMate with the unique identification number `T0123456A`.
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved
The `addnote` command calls `Model#setPerson(Person target, Person editedPerson)`, causing the modified state of ClinicMate after the `addnote T0123456A n\Covid` command executes to be saved.

<box type="info" seamless>

**Note:** If a command fails its execution, it will not call `Model#setPerson(Person target, Person editedPerson)`, so the address book state will not be saved.

</box>

The following sequence diagram shows how an addnote operation goes through the `Logic` component:
The following sequence diagram shows how an `addnote` operation goes through the `Logic` component:

<puml src="diagrams/AddNoteSequenceDiagram.puml" alt="AddNoteSequenceDiagram" />

<box type="info" seamless>

**Note:** The lifeline for `AddNoteCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.
**Note:** The lifeline for `AddNoteCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

</box>

The following activity diagram summarizes what happens when a user executes a new command:
The following activity diagram summarizes what happens when a user executes a new `addnote` command:

<div style="text-align: center;">
<puml src="diagrams/AddNoteCommandActivityDiagram.puml" width="250"/>
Expand All @@ -260,38 +274,42 @@ The following activity diagram summarizes what happens when a user executes a ne

**Aspect: How to add or replace:**

* **Alternative 1 (current choice):** Have a flag (-replace) to allow users to replace the whole note section of specified patient. This is on top of the normal add note command where new notes are appended to the existing note itself.
* **Alternative 1 (Current Choice):** Have a flag (-replace) to allow users to replace the whole note section of specified patient.
* This is an extension of the normal `addnote` command where new notes are appended to the existing note itself.
* Pros:
* Able to edit/clean up notes section.
* Gives users the freedom to decide how they want to keep notes.
* Cons:
* Users might not want to replace all the notes they have (just want to edit a section).
* Users might not want to replace all the notes they have, and might just want to edit a section.

* **Alternative 2:** Allow users to only add notes to patients.
* Pros: More structured command to add notes to patient.
* Cons: Not able to give users the freedom to ‘edit’ the notes they have.

**Aspect: Display of new note when command is successful:**
* Current choice: Displays the new note in the correct patient’s section in the addressbook.
* Current choice: Displays the new note in the correct patient’s section in ClinicMate.
* Rationale: Users will be able to view the new note added easily.

**Aspect: Display of error message when command is unsuccessful:**
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid ic format).
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid IC number format).
* Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful.

### Find feature

#### Implementation

The find mechanism is facilitated by `ModelManager`. It implements `ModelManager#updateFilteredPersonList(Predicate predicate)` which allow users to find patients in the addressbook.
The find mechanism is facilitated by `ModelManager`. It implements `ModelManager#updateFilteredPersonList(Predicate predicate)`
which allow users to find patients in ClinicMate.

These operations are exposed in the `Model` interface as `Model#updateFilteredPersonList(Predicate predicate)`.
`predicate` takes in a `IdentityCardNumberMatchesPredicate` to filter the list of patients.

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

Step 1. The user launches the application. The `AddressBook` will be initialized with the initial address book state.

Step 2. The user executes `find T0123456A …` to find the person in the address book with the unique identification number `T0123456A`. The find command calls `Model#updateFilteredPersonList(Predicate predicate)`, causing the modified state of the address book after the `find T0123456A …` command executes to be displayed.
Step 2. The user executes `find S0123456A` to find the person in the address book with the unique identification number `S0123456A`. The find command calls `Model#updateFilteredPersonList(Predicate predicate)`,
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved
causing the modified state of the address book after the `find S0123456A` command executes to be displayed.

<box type="info" seamless>

Expand All @@ -317,28 +335,36 @@ The following activity diagram summarizes what happens when a user executes a ne

#### Design Considerations & Alternatives Considered

**Aspect: Display of filtered list/contact when command is successful:**
* Current choice: Displays the correct patient’s contact in the addressbook.
**Aspect: Filtering patients**
* **Alternative 1 (Current Choice):** Requires user to input a full and valid IC number
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved
* Pros: Precise results, allows user to directly single out the patient details
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved
* Cons: Might omit relevant results if the user types the IC number incorrectly
* Alternative 2: Match all relevant patients' profiles even if the user enters a partial IC number
* Pros: Flexible search, more time-efficient, returns results even without typing the whole IC number
* Cons: Might produce more results than expected. Might incorrectly refer to the wrong patient details.

**Aspect: Display of filtered list when command is successful:**
* Current choice: Displays the correct patient’s contact in the patient list panel.
* Rationale: Users will be able to view the contact added easily.

**Aspect: Display of error message when command is unsuccessful:**
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid ic format).
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid IC number format).
* Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful.

### Delete feature

#### Implementation

The find mechanism is facilitated by `Addressbook`. It implements `Addressbook#removePerson(Person key)` which allow users to delete patients in the addressbook.
The delete mechanism is facilitated by `Addressbook`. It implements `Addressbook#removePerson(Person key)` which allow users to delete patients in the addressbook.

These operations are exposed in the `Model` interface as `Model#deletePerson(Person target)`.

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

Step 1. The user launches the application. The `AddressBook` will be initialized with the initial address book state.

Step 2. The user executes `delete T0123456A` to delete the person in the address book with the unique identification number `T0123456A`.
The delete command calls `Model#deletePerson(Person target)`, causing the modified state of the address book after the `delete T0123456A` command executes to be saved.
Step 2. The user executes `delete S0123456A` to delete the person in the address book with the unique identification number `S0123456A`.
tengcharmaine marked this conversation as resolved.
Show resolved Hide resolved
The delete command calls `Model#deletePerson(Person target)`, causing the modified state of the address book after the `delete S0123456A` command executes to be saved.

<box type="info" seamless>

Expand All @@ -352,7 +378,7 @@ The following sequence diagram shows how a delete operation goes through the `Lo

<box type="info" seamless>

**Note:** The lifeline for `DeleteCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.
**Note:** The lifeline for `DeleteCommandParser` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

</box>

Expand All @@ -369,8 +395,8 @@ The following activity diagram summarizes what happens when a user executes a ne
* Rationale: Users will be able to view the updated contact list easily.

**Aspect: Display of error message when command is unsuccessful:**
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid ic format).
* Rationale: Users will be able to learn of their error quickly annd have an idea of what to edit to make the command successful.
* Current choice: Displays the correct error message based on the type of error made (e.g. missing fields, invalid IC number format).
* Rationale: Users will be able to learn of their error quickly and have an idea of what to edit to make the command successful.

### Edit feature

Expand Down
39 changes: 32 additions & 7 deletions docs/diagrams/AddCommandDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@ box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":AddCommandParser" as AddCommandParser LOGIC_COLOR
participant "d:AddCommand" as AddCommand LOGIC_COLOR
participant "p:Person" as Person LOGIC_COLOR
participant "a:AddCommand" as AddCommand LOGIC_COLOR
participant "r:CommandResult" as CommandResult LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant "m:Model" as Model MODEL_COLOR
end box

[-> LogicManager : execute("add n/John Doe p/12345678 \n e/[email protected] i/T0123456A ag/12 s/Male \n a/John street, block 123, #01-01")
note left of LogicManager
In the diagram, params refers to the following:
"n\John Doe p\12345678
e\[email protected] i\T0123456A ag\12 s\M
a\John street, block 123, #01-01"
end note

[-> LogicManager : execute("add params")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("add n/John Doe p/12345678 \n e/[email protected] i/T0123456A ag/12 s/Male \n a/John street, block 123, #01-01")
LogicManager -> AddressBookParser : parseCommand("add params")
activate AddressBookParser

create AddCommandParser
Expand All @@ -27,14 +35,21 @@ activate AddCommandParser
AddCommandParser --> AddressBookParser
deactivate AddCommandParser

AddressBookParser -> AddCommandParser : parse("add n/John Doe p/12345678 \n e/[email protected] i/T0123456A ag/12 s/Male \n a/John street, block 123, #01-01")
AddressBookParser -> AddCommandParser : parse("params")
activate AddCommandParser

create Person
AddCommandParser -> Person:
activate Person

Person --> AddCommandParser
deactivate Person

create AddCommand
AddCommandParser -> AddCommand
AddCommandParser -> AddCommand : new AddCommand(p)
activate AddCommand

AddCommand --> AddCommandParser :
AddCommand --> AddCommandParser : a
deactivate AddCommand

AddCommandParser --> AddressBookParser : a
Expand All @@ -49,7 +64,13 @@ deactivate AddressBookParser
LogicManager -> AddCommand : execute(m)
activate AddCommand

AddCommand -> Model : setPerson(T0123456A, \n new Person(John Doe, 12345678, ...))
AddCommand -> Model : hasPerson(p)
activate Model

Model --> AddCommand
deactivate Model

AddCommand -> Model : addPerson(p)
activate Model

Model --> AddCommand
Expand All @@ -65,6 +86,10 @@ deactivate CommandResult
AddCommand --> LogicManager : r
deactivate AddCommand

'Hidden arrow to position the destroy marker below the end of the activation bar.
AddCommand -[hidden]-> LogicManager
destroy AddCommand

[<--LogicManager
deactivate LogicManager
@enduml
Loading
Loading