diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index bb61a909de1..b2dd21847ad 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -237,7 +237,73 @@ The following activity diagram summarizes what happens when a user executes a ne * Pros: Will use less memory (e.g. for `delete`, just save the person being deleted). * Cons: We must ensure that the implementation of each individual command are correct. -_{more aspects and alternatives to be added}_ +_{more aspects and alternatives to be added} + +### Add a patient + +#### Implementation + +The add patient feature is facilitated by `AddCommand`, `AddCommandParser` and `Person`. + +Given below is an example usage scenario and how the add patient feature behaves at each step. + +Step 1. The user launches the application for the first time. + +Step 2. The user executes an Add Command (e.g. 'add n\Alice ic\A0055679T ad\01/01/2022 dob\01/01/2002 w\WA') to add a new patient to the address book. + +n\: Indicates the name of the patient +ic\: Indicates the NRIC of the patient +ad\: Indicates the admission date of the patient +dob\: Indicates the date of birth of the patient +w\: Indicates the ward of the patient is currently in + +The `AddCommandParser` parses the user input, creating a new `AddCommand` object. +The `AddCommand` object then creates a new `Person` object with the parsed details. + + +### List by tags and/or ward feature + +#### Implementation + +The filter by tags and/or ward mechanism is facilitated by `ListCommand`, `ListCommandParser` and `ListKeywordsPredicate`. Additionally, it implements the following operations: + +* `ListCommandParser#parse()` — Parses user input and creates a `ListCommand` object. + +Given below is an example usage scenario and how the filter by tags and/or ward mechanism behaves at each step. + +Step 1. The user launches the application for the first time. + +Step 2. The user executes `list t\diabetes` command to list patients with the diabetes tag in the address book. The `ListCommandParser` parses the user input, creating a new `ListCommand` and `ListKeywordPredicate` object as `predicate` (since there are keywords provided). `predicate` will filter the list of patients in the address book to only show patients with the diabetes tag. + +![ListObjectDiagram](images/ListObjectDiagram.png) + +Step 3. For each patient in the address book, the `predicate` object will be passed to `Model#updateFilteredPersonList` check if the patient has the diabetes tag. If the patient has the diabetes tag, the patient will be shown in the list of patients. + +The following activity diagram summarizes what happens when a user executes a new command: + + + +#### Design considerations: + +**Aspect: Command to filter:** + +* **Alternative 1 (current choice):** Add the parameters to list command instead of find. + * Pros: More appropriate as `list` will produce a useful list of relevant contacts, whereas `find` implies that only one useful result is expected. + * Cons: May not have such a clear distinction between `list` and `find`, as user just wants to search for results. + +* **Alternative 2:** Add parameters to find command instead of list. + * Pros: Easy to use, one command will perform all search. + * Cons: Unable to differentiate usefulness. + +**Aspect: Filter by a ward or many wards:** + +* **Alternative 1 (current choice):** Allow filtering only by at most 1 ward input. + * Pros: More targeted; Nurses will only refer to the ward that they are in or are visiting. Otherwise, will filter across all wards. + * Cons: Does not allow looking at specific, multiple wards. + +* **Alternative 2:** Allow multiple ward tags. + * Pros: Easy to be more specific. + * Cons: Not relevant for the nurses use case. Allowing more wards also make it harder to filter fast. ### \[Proposed\] Data archiving diff --git a/docs/diagrams/ListCommandActivityDiagram.puml b/docs/diagrams/ListCommandActivityDiagram.puml new file mode 100644 index 00000000000..2352d6e3744 --- /dev/null +++ b/docs/diagrams/ListCommandActivityDiagram.puml @@ -0,0 +1,21 @@ +@startuml +skin rose +skinparam ActivityFontSize 15 +skinparam ArrowFontSize 12 + +start +:User executes command; + +'Since the beta syntax does not support placing the condition outside the +'diamond we place it as the true branch instead. + +if () then ([command has parameters]) + :Create a new predicate; + :Filter the addressbook + using the predicate; + :Show the filtered contacts; +else ([else]) + : Show all contacts; +endif +stop +@enduml diff --git a/docs/diagrams/ListObjectDiagram.puml b/docs/diagrams/ListObjectDiagram.puml new file mode 100644 index 00000000000..ca3c159c5e7 --- /dev/null +++ b/docs/diagrams/ListObjectDiagram.puml @@ -0,0 +1,16 @@ +@startuml +!include style.puml +skinparam arrowThickness 1.1 +skinparam arrowColor MODEL_COLOR +skinparam classBackgroundColor MODEL_COLOR + +class State1 as ":ListCommand" +class State2 as ":ListKeywordPredicate" +class State3 as "wardKeyword:String" +class State4 as "tagKeywords:List" + +State1 -down-> "0..1" State2 +State2 -right-> "1" State3 +State2 -down-> "1" State4 + +@enduml diff --git a/docs/images/ListCommandActivityDiagram.png b/docs/images/ListCommandActivityDiagram.png new file mode 100644 index 00000000000..36dfc181e55 Binary files /dev/null and b/docs/images/ListCommandActivityDiagram.png differ diff --git a/docs/images/ListObjectDiagram.png b/docs/images/ListObjectDiagram.png new file mode 100644 index 00000000000..42f07e178ac Binary files /dev/null and b/docs/images/ListObjectDiagram.png differ