Skip to content

Commit

Permalink
Merge pull request #252 from laney0808/dg-addvisit
Browse files Browse the repository at this point in the history
Dg addvisit
  • Loading branch information
NatLeong authored Apr 15, 2024
2 parents 00500cb + 57c62fa commit d3e88c5
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 9 deletions.
34 changes: 34 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,40 @@ How an `update` operation goes through the `Model` component is shown below:

### Add patient visit
#### Implementation
The `addvisit` feature allows users to add a patient visit by providing input through a command with specific arguments. This visit is then stored within the system for future reference.
The `addvisit` command is facilitated by `AddVisitCommand` and `AddVisitCommandParser`. They extend the `Command` and `Parser` classes respectively, storing a new instance of `Visit` in the `UniqueVisitList`.
* `AddVisitCommandParser#parse` is responsible for parsing the user input and creating a new `AddVisitCommand` instance.
* `AddVisitCommand#execute` is responsible for executing the command and adding the new visit to the system.
* `ImmuniMate#addVisit(Visit)` is called to add the visit to the internal list of visits.
* `UniquePersonList#add(Visit)` is used to add the new visit to the system.
`ModelManager#addVisit(Visit)` is called to add the visit to the system. It calls `ImmuniMate.addVisit(Visit)` which calls `UniqueVisitList#add(Visit)` to add the visit to the internal list of visits.
The command checks if the patient exists in the system before adding the new visit of a patient.
* `Person#equals(Object)` is overridden to check if two patients are the same person.
* `UniquePersonList#contains(Person)` is used to check if the patient exists in the system's list of patients.
* `ImmuniMate#hasPerson(Person)` is used to check if the patient exists in the system.
`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 exists in the internal list of patients.
The command checks for duplicates in the system before adding the new visit.
* `Visit#equals(Object)` is overridden to check if two visits are duplicates.
* `UniquePersonList#contains(Visit)` is used to check if the visit already exists in the system's list of visits.
* `ImmuniMate#hasVisit(Visit)` is used to check if the visit already exists in the system.
`ModelManager#hasVisit(Visit)` is called to check if the visit already exists in the system. It calls `ImmuniMate.hasVisit(Visit)` which calls `UniqueVisitList#contains(Visit)` to check if the visit already exists in the internal list of visits.

The creation of `Visit` instance also rely on field classes`NRIC`, `Symptoms`,`Diagnosis`, `Status` and `DateOfVisit`.

Step 1. `AddVisitCommandParser` interprets the user's input, creates instances of fields which matches the input, and creates a new `AddVisitCommand` instance.

Step 2. The `AddVisitCommand#execute` is called by the `LogicManager`. The `AddVisitCommand` checks if the patient already exists in the system by calling `model.hasPerson(person)`.

Step 3. If the patient exists, the `AddVisitCommand` checks if the visit already exists in the system by calling `model.hasVisit(visit)`.

Step 4. If the visit does not exist, the visit is added to the system by calling `model.addVisit(visit)`.

Step 4: After the visit is added, the `AddVisitCommand` returns the appropriate `CommandResult` to indicate the success of the operation.

The following sequence diagram shows how a addvisit operation goes through the `Logic` component:
![AddVisitState1](images/AddVisitCommandLogic.png)
Similarly, the following sequence diagram shows how a addvisit operation goes through the `Model` component:
![addVisitCommandState1](images/AddVisitCommandModel.png)

#### Overview
The `addvisit` feature allows healthcare workers to record a new visit for a patient by providing necessary details such as NRIC, date of visit, symptoms, diagnosis, and status. This command enhances the ImmuniMate Address Book System (IABS) by maintaining up-to-date health records for patients.
Expand Down
80 changes: 80 additions & 0 deletions docs/diagrams/AddVisitCommandLogic.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":ImmuniMateParser" as ImmuniMateParser LOGIC_COLOR
participant ":AddVisitCommandParser" as AddVisitCommandParser LOGIC_COLOR
participant "c:AddVisitCommand" as AddVisitCommand LOGIC_COLOR
participant "r:CommandResult" as CommandResult LOGIC_COLOR
end box

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

[-> LogicManager : execute("addvisit ...")
activate LogicManager
LogicManager -> ImmuniMateParser : parseCommand("addvisit ...")
activate ImmuniMateParser

create AddVisitCommandParser
ImmuniMateParser -> AddVisitCommandParser
activate AddVisitCommandParser
AddVisitCommandParser --> ImmuniMateParser
deactivate AddVisitCommandParser
ImmuniMateParser -> AddVisitCommandParser : parse("...")
activate AddVisitCommandParser

create Visit
AddVisitCommandParser -> Visit
activate Visit
Visit --> AddVisitCommandParser
deactivate Visit

create AddVisitCommand
AddVisitCommandParser -> AddVisitCommand
activate AddVisitCommand
AddVisitCommand --> AddVisitCommandParser
deactivate AddVisitCommand

AddVisitCommandParser --> ImmuniMateParser : c
deactivate AddVisitCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
AddVisitCommandParser -[hidden]-> ImmuniMateParser
destroy AddVisitCommandParser
ImmuniMateParser --> LogicManager : c
deactivate ImmuniMateParser

LogicManager -> AddVisitCommand : execute()
activate AddVisitCommand
AddVisitCommand -> Visit : getNric()
activate Visit
Visit --> AddVisitCommand : nric
deactivate Visit
AddVisitCommand -> Model : hasPerson(...)
activate Model
Model --> AddVisitCommand : false
deactivate Model
AddVisitCommand -> Model : hasVisit(...)
activate Model
Model --> AddVisitCommand : false
deactivate Model
AddVisitCommand -> Model : addVisit(v)
activate Model
Model --> AddVisitCommand : add visit in the model
deactivate Model

create CommandResult
AddVisitCommand -> CommandResult
activate CommandResult
CommandResult --> AddVisitCommand
deactivate
AddVisitCommand --> LogicManager : r
deactivate AddVisitCommand

[<--LogicManager : r
deactivate LogicManager
@enduml
119 changes: 119 additions & 0 deletions docs/diagrams/AddVisitCommandModel.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain
box Logic LOGIC_COLOR_T1
participant "l:Logic" as Logic LOGIC_COLOR
end box

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

[-> Logic : execute()
activate Logic

create p
Logic -> p
activate p
p --> Logic
deactivate p

create Visit
Logic -> Visit
activate Visit
Visit --> Logic
deactivate Visit

Logic -> ModelManager : hasPerson(p)
activate ModelManager

ModelManager -> ImmuniMate: hasPerson(p)
activate ImmuniMate

ImmuniMate -> UniqueVisitList : contains(p)
activate UniqueVisitList

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

internalList -> p : isSamePerson()
activate p

p --> internalList
deactivate p

internalList --> UniqueVisitList
deactivate internalList

UniqueVisitList --> ImmuniMate
deactivate UniqueVisitList

ImmuniMate --> ModelManager
deactivate ImmuniMate

ModelManager --> Logic
deactivate ModelManager

Logic -> ModelManager : hasVisit(v)
activate ModelManager

ModelManager -> ImmuniMate: hasVisit(v)
activate ImmuniMate

ImmuniMate -> UniqueVisitList : contains(v)
activate UniqueVisitList

UniqueVisitList -> internalList : stream().anyMatch(v::isSameVisit)
activate internalList

internalList -> Visit : isSameVisit()
activate Visit

Visit --> internalList
deactivate Visit

internalList --> UniqueVisitList
deactivate internalList

UniqueVisitList --> ImmuniMate
deactivate UniqueVisitList

ImmuniMate --> ModelManager
deactivate ImmuniMate

ModelManager --> Logic
deactivate ModelManager

Logic -> ModelManager : addVisit(v)
activate ModelManager

ModelManager -> ImmuniMate: addVisit(v)
activate ImmuniMate

ImmuniMate -> UniqueVisitList : add(v)
activate UniqueVisitList

UniqueVisitList -> internalList : add(v)
activate internalList

internalList --> UniqueVisitList
deactivate internalList

UniqueVisitList --> ImmuniMate
deactivate UniqueVisitList

ImmuniMate --> ModelManager
deactivate ImmuniMate

ModelManager --> Logic
deactivate ModelManager

[<--Logic
deactivate Logic

@enduml
28 changes: 20 additions & 8 deletions docs/diagrams/ModelClassDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Class ImmuniMate
Class ModelManager
Class UserPrefs
Class UniquePersonList
Class UniqueVisitList
Class Person
Class Address
Class Name
Expand All @@ -28,6 +29,8 @@ Class Condition
Class DateOfAdmission
Class Diagnosis
Class Symptom
Class Visit
Class DateOfVisit


Class I #FFFFFF
Expand All @@ -46,7 +49,9 @@ ModelManager -right-> "1" UserPrefs
UserPrefs .up.|> ReadOnlyUserPrefs

ImmuniMate *--> "1" UniquePersonList
ImmuniMate *--> "1" UniqueVisitList
UniquePersonList --> "~* all" Person
UniqueVisitList --> "~* all" Visit
Person *--> "1" Nric
Person *--> "1" Name
Person *--> "1" Phone
Expand All @@ -55,14 +60,20 @@ Person *--> "1" DateOfBirth
Person *--> "1" Sex
Person *--> "1" Status

Person *--> "1" Email
Person *--> "1" Country
Person *--> "1" Allergies
Person *--> "1" BloodType
Person *--> "1" Condition
Person *--> "1" DateOfAdmission
Person *--> "1" Diagnosis
Person *--> "1" Symptom
Person *--> "0..1" Email
Person *--> "0..1" Country
Person *--> "0..1" Allergies
Person *--> "0..1" BloodType
Person *--> "0..1" Condition
Person *--> "0..1" DateOfAdmission
Person *--> "0..1" Diagnosis
Person *--> "0..1" Symptom

Visit *--> "1" DateOfVisit
Visit *--> "1" Nric
Visit *--> "1" Diagnosis
Visit *--> "1" Symptom
Visit *--> "1" Status


Person -[hidden]up--> I
Expand All @@ -76,5 +87,6 @@ DateOfBirth -[hidden]right-> Sex
Sex -[hidden]right-> Status

ModelManager --> "~* filtered" Person
ModelManager --> "~* filtered" Visit
@enduml

Binary file added docs/images/AddVisitCommandLogic.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/AddVisitCommandModel.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 modified docs/images/ModelClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class AddVisitCommandParser implements Parser<AddVisitCommand> {
* and returns an AddCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
//TODO test cases
public AddVisitCommand parse(String args) throws ParseException {
ArgumentMultimap argMultimap =
ArgumentTokenizer.tokenize(args, PREFIX_NRIC, PREFIX_DATEOFVISIT,
Expand Down

0 comments on commit d3e88c5

Please sign in to comment.