Skip to content

Commit

Permalink
Update DG for read and check command
Browse files Browse the repository at this point in the history
  • Loading branch information
NatLeong committed Apr 13, 2024
1 parent 5dce7fa commit 061866e
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 7 deletions.
41 changes: 40 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ This `deleteinfo` command is facilitated by `DeleteInfoCommand` and `DeleteInfoC
* `DeleteInfoCommandParser#parse` is responsible for parsing the user input and creating a new `DeleteInfoCommand` instance.
* `DeleteInfoCommand#execute` is responsible for executing the command and removing the field of information from the patient.
* `Model#getFilteredPersonList()` is called to get the list of patients in the system.
`DeleteInfoCommand` checks if the patient exists in the system before removing the field of information.
`DeleteInfoCommand` checks if the patient exists in the system before removing the field of information.
* `ModelManager#hasPerson(Person)` is called to check if the patient already exists in the system. It calls `ImmuniMate.hasPerson(Person)` which calls `UniquePersonList#contains(Person)` to check if the patient already exists in the internal list of patients.

Step 1. `DeleteInfoCommandParser` interprets the user's input for NRIC and the fields to be deleted, and creates a new `DeleteInfoCommand` instance.
Expand All @@ -245,6 +245,26 @@ Step 5: After the field of information is removed, the `DeleteInfoCommand` retur

### Read a patient's information
#### Proposed Implementation
The `read` feature allows users to read a patient profile by providing NRIC through a command. This patient data is then displayed.
The `read` command is facilitated by `ReadCommand` and `ReadCommandParser`. They extend the `Command` and `Parser` classes respectively, displaying patient profile from an instance of `Person` from the `UniquePersonList`.

* `ReadCommandParser#parse` is responsible for parsing the user input and creating a new `ReadCommand` instance.
* `ReadCommand#execute` is responsible for executing the command and displaying the patient profile from the system.
`ReadCommand` checks if the patient exists in the system before displaying patient profile.
* `ModelManager#hasPerson(Person)` is called to check if the patient exists in the system. It calls `ImmuniMate.hasPerson(Person)` which calls `UniquePersonList#contains(Person)` to check if the patient already exists in the internal list of patients.
* `Model#updateFilteredPersonList(Predicate)` and is called to update the list to be of patient with specified NRIC in the system.
* `Model#getFilteredPersonList()` is called to get the list of patient with specified NRIC in the system.
* `Observablelist<Persons>#get(int)` is called to obtain `Person` object of patient with speicified NRIC.
Step 1. `ReadCommandParser` interprets the user's input for NRIC, and creates a new `ReadCommand` instance.
Step 2. The `ReadCommand#execute` is called by the `LogicManager`. The `ReadCommand` checks if the patient exists in the system by calling `model.hasPerson(person)`.
Step 3. If the patient exists, the patient is obtained from the system by calling `model.updateFilteredPersonList(person)`, followed by calling `model.getFilteredPersonList()` and `Observablelist<Persons>#get(int)`.
Step 4: After the patient is obtained, the `ReadCommand` formats the patient profile by calling `Messages.format(person)` and returns the appropriate `CommandResult` to indicate the success of the operation.

The following sequence diagram shows how a delete operation goes through the Logic component:
![ReadState1](images/ReadCommandSequenceDiagram.png)
How a read operation goes through the Model component is shown below:
![ReadState2](images/ReadCommandModelDiagram.png)


### Find patient
#### Proposed Implementation
Expand Down Expand Up @@ -281,6 +301,25 @@ Step 7. `model.setPerson()` then replaces the retrieved `Person` object with the

### Check a patient's visit history
#### Proposed Implementation
The `check` feature allows users to check the visit history of a patient by providing NRIC through a command. This patient visit history is then displayed.
The `check` command is facilitated by `CheckCommand` and `CheckCommandParser`. They extend the `Command` and `Parser` classes respectively, displaying patient visit history from list of `Visit` from the `UniqueVisitList`.

* `CheckCommandParser#parse` is responsible for parsing the user input and creating a new `CheckCommand` instance.
* `CheckCommand#execute` is responsible for executing the command and displaying the patient visit history from the system.
`CheckCommand` checks if the patient exists in the system before displaying patient visit history.
* `ModelManager#hasPerson(Person)` is called to check if the patient exists in the system. It calls `ImmuniMate.hasPerson(Person)` which calls `UniquePersonList#contains(Person)` to check if the patient already exists in the internal list of patients.
* `Model#updateFilteredPersonList(Predicate)` is called to get the list of patient with specified NRIC in the system.
* `Model#updateFilteredVisitList(Predicate)` is called to get the list of visits with specified NRIC in the system.
Step 1. `CheckCommandParser` interprets the user's input for NRIC, and creates a new `CheckCommand` instance.
Step 2. The `CheckCommand#execute` is called by the `LogicManager`. The `CheckCommand` checks if the patient exists in the system by calling `model.hasPerson(person)`.
Step 3. If the patient exists, the patient is obtained from the system by calling `model.updateFilteredPersonList(pred)`, followed by calling `model.getFilteredPersonList()` and `Observablelist<Persons>#get(int)`.
Step 4: Patient visit history is obtained from the system by calling `model.updateFilteredVisitList(pred)`, followed by `model.getFilteredVisitList()`.
Step 5: After the patient visit history is obtained, the `CheckCommand` formats the patient visit history by calling `Messages.formatCheck(visit)` and returns the appropriate `CommandResult` to indicate the success of the operation.

The following sequence diagram shows how a delete operation goes through the Logic component:
![ReadState1](images/CheckCommandSequenceDiagram.png)
How a check operation goes through the Model component is shown below:
![ReadState2](images/CheckCommandModelDiagram.png)

### Check for clusters
#### Proposed Implementation
Expand Down
65 changes: 65 additions & 0 deletions docs/diagrams/CheckCommandModelDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant "l:Logic" as CheckCommand LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":ModelManager" as ModelManager MODEL_COLOR
participant ":ImmuniMate" as ImmuniMate MODEL_COLOR
participant ":UniquePersonList" as UniquePersonList MODEL_COLOR
participant "internalList: ObservableList<Person>" as internalList MODEL_COLOR
participant "p:Person" as p MODEL_COLOR
end box

[-> CheckCommand : execute()
activate CheckCommand

CheckCommand -> ModelManager : hasPerson(p)
activate ModelManager

ModelManager -> ImmuniMate: hasPerson(p)
activate ImmuniMate

ImmuniMate --> UniquePersonList : contains(p)
activate UniquePersonList

UniquePersonList -> internalList : stream().anyMatch(p::isSamePerson)
activate internalList

internalList -> p : isSamePerson(p)
activate p

p --> internalList
deactivate p

internalList --> UniquePersonList
deactivate internalList

UniquePersonList --> ImmuniMate
deactivate UniquePersonList

ImmuniMate --> ModelManager
deactivate ImmuniMate

ModelManager --> CheckCommand
deactivate ModelManager

CheckCommand -> ModelManager : updateFilteredPersonList(predicate)
activate ModelManager

ModelManager --> CheckCommand
deactivate ModelManager

CheckCommand -> ModelManager : updateFilteredVisitList(predicate)
activate ModelManager

ModelManager --> CheckCommand
deactivate ModelManager

[<--CheckCommand
deactivate CheckCommand

@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,34 @@ deactivate AddressBookParser
LogicManager -> CheckCommand : execute(m)
activate CheckCommand

CheckCommand -> Model : updateFilteredPersonList(new NricContainsKeywordsPredicate("T0123456A"));
CheckCommand -> Model : hasPerson(...)
activate Model

Model --> CheckCommand : getFilteredPersonList()
Model --> CheckCommand : false
deactivate Model

CheckCommand -> Model : updateFilteredVisitList(new VisitContainsNricPredicate("T0123456A"));
CheckCommand -> Model : updateFilteredPersonList(...)
activate Model

Model --> CheckCommand : getFilteredVisitList()
Model --> CheckCommand : updateFilteredPersonList() successful
deactivate Model

CheckCommand -> Model : getFilteredPersonList()
activate Model

Model --> CheckCommand : Filtered person list
deactivate Model

CheckCommand -> Model : updateFilteredVisitList(...)
activate Model

Model --> CheckCommand : updateFilteredVisitList() successful
deactivate Model

CheckCommand -> Model : getFilteredVisitList()
activate Model

Model --> CheckCommand : Filtered visit list
deactivate Model

create CommandResult
Expand Down
59 changes: 59 additions & 0 deletions docs/diagrams/ReadCommandModelDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant "l:Logic" as ReadCommand LOGIC_COLOR
end box

box Model MODEL_COLOR_T1
participant ":ModelManager" as ModelManager MODEL_COLOR
participant ":ImmuniMate" as ImmuniMate MODEL_COLOR
participant ":UniquePersonList" as UniquePersonList MODEL_COLOR
participant "internalList: ObservableList<Person>" as internalList MODEL_COLOR
participant "p:Person" as p MODEL_COLOR
end box

[-> ReadCommand : execute()
activate ReadCommand

ReadCommand -> ModelManager : hasPerson(p)
activate ModelManager

ModelManager -> ImmuniMate: hasPerson(p)
activate ImmuniMate

ImmuniMate --> UniquePersonList : contains(p)
activate UniquePersonList

UniquePersonList -> internalList : stream().anyMatch(p::isSamePerson)
activate internalList

internalList -> p : isSamePerson(p)
activate p

p --> internalList
deactivate p

internalList --> UniquePersonList
deactivate internalList

UniquePersonList --> ImmuniMate
deactivate UniquePersonList

ImmuniMate --> ModelManager
deactivate ImmuniMate

ModelManager --> ReadCommand
deactivate ModelManager

ReadCommand -> ModelManager : updateFilteredPersonList(predicate)
activate ModelManager

ModelManager --> ReadCommand
deactivate ModelManager

[<--ReadCommand
deactivate ReadCommand

@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,22 @@ deactivate AddressBookParser
LogicManager -> ReadCommand : execute(m)
activate ReadCommand

ReadCommand -> Model : updateFilteredPersonList(new NricContainsKeywordsPredicate("T0123456A"));
ReadCommand -> Model : hasPerson(...)
activate Model

Model --> ReadCommand : getFilteredPersonList()
Model --> ReadCommand : false
deactivate Model

ReadCommand -> Model : updateFilteredPersonList(...)
activate Model

Model --> ReadCommand : updateFilteredPersonList() successful
deactivate Model

ReadCommand -> Model : getFilteredPersonList()
activate Model

Model --> ReadCommand : Filtered person list
deactivate Model

create CommandResult
Expand Down
Binary file removed docs/images/CheckCommand.png
Binary file not shown.
Binary file added docs/images/CheckCommandModelDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/CheckCommandSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/ReadCommand.png
Binary file not shown.
Binary file added docs/images/ReadCommandModelDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ReadCommandSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 061866e

Please sign in to comment.