Skip to content

Commit

Permalink
Merge pull request AY2324S2-CS2103T-F10-3#106 from xuelinglow/v1.3-up…
Browse files Browse the repository at this point in the history
…date-docs

Update developer guide with mark app implementation
  • Loading branch information
xuelinglow authored Apr 4, 2024
2 parents 205538b + 027b08b commit 6ec2926
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 25 deletions.
61 changes: 45 additions & 16 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ The sequence diagram below illustrates the interactions within the `Logic` compo

How the `Logic` component works:

1. When `Logic` is called upon to execute a command, it is passed to an `AddressBookParser` object which in turn creates a parser that matches the command (e.g., `DeletePatientCommandParser`) and uses it to parse the command.
1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeletePatientCommandParser`) which is executed by the `LogicManager`.
1. The command can communicate with the `Model` when it is executed (e.g. to delete a patient).<br>
1. When `Logic` is called upon to execute a command, it is passed to an `AddressBookParser` object which in turn creates a parser that matches the command (e.g.,`DeletePatientCommandParser`) and uses it to parse the command.
2. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DeletePatientCommandParser`) which is executed by the `LogicManager`.
3. The command can communicate with the `Model` when it is executed (e.g. to delete a patient).<br>
Note that although this is shown as a single step in the diagram above (for simplicity), in the code it can take several interactions (between the command object and the `Model`) to achieve.
1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.
4. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.

Here are the other classes in `Logic` (omitted from the class diagram above) that are used for parsing a user command:

Expand Down Expand Up @@ -200,23 +200,23 @@ The following activity diagram summarizes what happens when a user executes an `
#### Implementation

The implementation of `AddApptCommand` is supported by creation of the `Appointment` class and its related classes.
Details captured in an `Appointment` class include:
Details captured in an `Appointment` class include:
* NRIC
* Date
* TimePeriod (composed of start and end time)
* Appointment Type
* [Optional] Note

The management of all appointments is achieved through the `AppointmentList` class stored in the `AddressBook`,
similar to the `UniquePatientList`. `AppointmentList` supports adding, editing and deleting of appointments to the list.
The operation `AppointmentList#add(Appointment)` checks if the incoming appointment already exists in the list, preventing
The management of all appointments is achieved through the `AppointmentList` class stored in the `AddressBook`,
similar to the `UniquePatientList`. `AppointmentList` supports adding, editing and deleting of appointments to the list.
The operation `AppointmentList#add(Appointment)` checks if the incoming appointment already exists in the list, preventing
duplicates from occurring. Since an `Appointment` can only exist in the `AppointmentList` if a `Patient` with the
corresponding NRIC exists in the `AddressBook`, this will be checked in the execution of the `AddApptCommand`.

Given below is an example usage scenario and how the add appointment mechanism works.

1. The user executes `addAppt i/ S9922758A d/ 2024-03-27 from/ 00:00 to/ 00:30 t/ Medical Check-up note/`,
attempting to create an appointment for a patient with NRIC: S9922758A on 27 Mar 2024 from 12am to 1230am.
1. The user executes `addAppt i/ S9922758A d/ 2024-03-27 from/ 00:00 to/ 00:30 t/ Medical Check-up note/`,
attempting to create an appointment for a patient with NRIC: S9922758A on 27 Mar 2024 from 12am to 1230am.
2. `AddApptCommand` calls `Model#hasPatientWithNric(Nric)` to check if the given NRIC belongs to an individual
in the system. If yes, continue. Else throw a `CommandException`.
3. `AddApptCommand` calls `Model#hasAppointment(Appointment)` to check if an equivalent appointment exists
Expand Down Expand Up @@ -255,19 +255,19 @@ An appointment's DATE, START_TIME, END_TIME, APPOINTMENT_TYPE and NOTE can be ed

The implementation will include the following key components:

1. **Parsing User Input**: The application will parse user input to extract values for the target appointment (NRIC, DATE, START_TIME, END_TIME) and optional prefixes for new values such as newnote/, newd/.
1. **Parsing User Input**: The application will parse user input to extract values for the target appointment (NRIC, DATE, START_TIME) and optional prefixes for new values such as newnote/, newd/.
2. **Executing Edit Queries**: The application will search through the list of appointments stored in the database and identify the target appointment. It will then set the appointment with the new values inputted.
3. **Presenting Updated Results**: The matched appointments will be presented to the user in a clear and organized manner, displaying relevant details such as the updated appointment time, date, and associated appointment information.

#### Example Usage Scenario

1. **Context**: User wants to edit the date of an appointment with a specific NRIC, date, start time and end time.
2. **User Input**: The user enters the command `editAppt i/ T0123456A d/ 2024-02-20 from/ 11:00 to/ 11:30 newd/ 2024-02-21`.
1. **Context**: User wants to edit the date of an appointment with a specific NRIC, date, start time.
2. **User Input**: The user enters the command `editAppt i/ T0123456A d/ 2024-02-20 from/ 11:00 newd/ 2024-02-21`.

<puml src="diagrams/EditApptSequenceDiagram.puml" alt="EditApptSeqDiag" />

3. **Parsing**: The application parses the user input and extracts the NRIC (`T0123456A`), date (`2024-02-20`), start time (`11:00`) and end time (`11:30`) criteria for the target appointment. The new date is parsed as (`2024-02-21`).
4. **Search Execution**: The application searches through the list of appointments and identifies a target appointment that matches the specified NRIC, date, start time and end time criteria.
3. **Parsing**: The application parses the user input and extracts the NRIC (`T0123456A`), date (`2024-02-20`) and start time (`11:00`) criteria for the target appointment. The new date is parsed as (`2024-02-21`).
4. **Search Execution**: The application searches through the list of appointments and identifies a target appointment that matches the specified NRIC, date and start time criteria.
5. **Update Execution**: The application sets the target appointment with a new appointment created that has the new values inputted, in this case date (`2024-02-21`).
6. **Presentation**: The updated appointment is presented to the user as a message, and the upcoming appointments list is updated as well.

Expand All @@ -287,6 +287,35 @@ The following activity diagram summarizes what happens when a user executes a ne
* Pros: Time efficient as we can make use of the shorter prefixes because there's no need to differentiate between target appointment and new appointment details, Easier to correct mistakes in updating wrong appointment
* Cons: Prone to errors as just a wrong number could cause the user to update the wrong appointment, Huge list could make it difficult to find a specific index


### Mark/Unmark Appointment for a Patient

#### Implementation

The Mark Appointment feature will involve parsing user input and marking the appointment as completed/ not completed.

The implementation will include the following key components:

1. **Parsing User Input**: The application will parse user input to extract values to find the target appointment (NRIC, DATE, START_TIME).
2. **Executing Mark Queries** The application will search through the list of appointments and identify the target appointment to be marked/unmarked. It will then set the mark boolean condition based on the mark/unmark command.
3. **Appointment Status Updated Results** The appointment will be updated accordingly to show whether it has been marked/unmarked successfully based on color code.

#### Example Usage Scenario
1. Context: User wants to mark a specfic appointment as completed.
2. User Input: The user enters the command 'mark i/T0123456A d/2024-02-20 from/11:00'

<puml src="diagrams/MarkApptSequenceDiagram.puml" alt="MarkApptSeqDiag" />

3. **Parsing**: The application parses the user input and extracts the NRIC (`T0123456A`), date (`2024-02-20`) and start time (`11:00`) criteria for the target appointment.
4. **Search Execution**: The application searches through the list of appointments and identifies a target appointment that matches the specified NRIC, date and start time criteria.
5. **Update Execution**: The application sets the target appointment with a new appointment created that has the new values inputted, in this case mark (true).
6. **Presentation**: The updated appointment is presented to the user as a message, and the upcoming appointments list is updated as well.

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

<puml src="diagrams/MarkApptActivityDiagram.puml" alt="MarkApptActivityDiagram" width="250" />


### \[Proposed\] Undo/redo feature

#### Proposed Implementation
Expand Down Expand Up @@ -401,7 +430,7 @@ The implementation will include the following key components:
4. **Search Execution**: The application searches through the list of appointments and identifies appointments that match the specified NRIC, date, and start time criteria.
5. **Presentation**: The matched appointments are presented to the user, displaying relevant details such as appointment time, date, and associated patient information.
6. **User Interaction**: The user can view the search results and perform additional actions such as viewing detailed information about specific appointments or modifying appointments as needed.

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

<puml src="diagrams/FindApptActivityDiagram.puml" alt="FindApptActivityDiagram" width="250" />
Expand Down
13 changes: 6 additions & 7 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Shorthand: `da i/NRIC d/DATE from/START_TIME`

* Deletes an appointment for the patient with specified `NRIC`, on `DATE` from `START_TIME`.
* Appointment with the stated details **must exist within database**.
* `END_TIME` not needed as same patient can never have overlapping appointments, hence `START_TIME` is unique
* `END_TIME` not needed as same patient can never have overlapping appointments, hence `START_TIME` is unique

Examples:
* `deleteAppt i/S8743880A d/2024-02-20 from/11:00`
Expand All @@ -270,9 +270,9 @@ Shorthand: `ea i/NRIC d/DATE from/START_TIME [newd/NEW_DATE] [newfrom/NEW_START_
</box>

Examples:
* `editAppt i/T0123456A d/2024-02-20 from/11:00 newd/2024-02-21`
* `editAppt i/T0123456A d/2024-02-20 from/11:00 newd/2024-02-21`
* Edits the date of the appointment with NRIC:`T0123456A`, DATE: `2024-02-20`, START_TIME: `11:00`, to be `2024-02-21` instead.
* `editAppt i/S8743880A d/2024-10-20 from/14:00 newnote/ `
* `editAppt i/S8743880A d/2024-10-20 from/14:00 newnote/ `
* Clears note for appointment with NRIC:`S8743880A`, DATE: `2024-10-20`, START_TIME: `14:00`.
* `ea i/S8743880A d/2024-10-20 from/14:00 newnote/ `

Expand All @@ -295,9 +295,9 @@ Shorthand: `fa [i/NRIC] [d/DATE] [from/START_TIME]`
</box>

Examples:
* `findAppt d/2024-02-20 from/11:00`
* `fa d/2024-02-20 from/11:00`
* returns you all appointments on `2024-02-20` starting from `11:00` and later.
* `findAppt d/ 2024-02-20 from/ 11:00`
* `fa d/ 2024-02-20 from/ 11:00`
* returns you all appointments on `2024-02-20` starting from `11:00` and later.

### Marking an Appointment: `mark`

Expand Down Expand Up @@ -448,4 +448,3 @@ Furthermore, certain edits can cause the CLInic to behave in unexpected ways (e.
| **Clear** | `clear` |
| **Exit** | `exit` |
| **Help** | `help` |

2 changes: 1 addition & 1 deletion docs/diagrams/EditApptActivityDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ skinparam ArrowFontSize 12
start
:User executes EditApptCommand;

if () then ([Appt with NRIC, Date, StartTime, EndTime found])
if () then ([Appt with NRIC, Date, StartTime found])
if () then ([Valid new values for appt])
:Update Appointment in
AppointmentList in AddressBook;
Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/EditApptSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ deactivate AddressBookParser
LogicManager -> EditApptCommand : execute(m)
activate EditApptCommand

EditApptCommand -> Model : getMatchingAppointment(targetNric, targetDate, targetTimePeriod)
EditApptCommand -> Model : getMatchingAppointment(targetNric, targetDate, targetStartTime)
Model --> EditApptCommand
EditApptCommand -> Model : setAppointment(Appointment, editedAppointment)
activate Model
Expand Down
15 changes: 15 additions & 0 deletions docs/diagrams/MarkApptActivityDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@startuml
skin rose
skinparam ActivityFontSize 15
skinparam ArrowFontSize 12
start
:User executes MarkApptCommand;

if () then ([Appt with NRIC, Date, StartTime found])
:Mark Appointment in
AppointmentList in AddressBook;
else ([Appt not found]))
: CommandException;
endif
stop
@enduml
71 changes: 71 additions & 0 deletions docs/diagrams/MarkApptSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AddressBookParser" as AddressBookParser LOGIC_COLOR
participant ":MarkCommandParser" as MarkCommandParser LOGIC_COLOR
participant "a:MarkCommand" as MarkCommand 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("mark i/ T0123456A...")
activate LogicManager

LogicManager -> AddressBookParser : parseCommand("mark i/ T0123456A...")
activate AddressBookParser

create MarkCommandParser
AddressBookParser -> MarkCommandParser
activate MarkCommandParser

MarkCommandParser --> AddressBookParser
deactivate MarkCommandParser

AddressBookParser -> MarkCommandParser : parse("i/ T0123456A...")
activate MarkCommandParser

create MarkCommand
MarkCommandParser -> MarkCommand
activate MarkCommand

MarkCommand --> MarkCommandParser :
deactivate MarkCommand

MarkCommandParser --> AddressBookParser : a
deactivate MarkCommandParser
'Hidden arrow to position the destroy marker below the end of the activation bar.
MarkCommandParser -[hidden]-> AddressBookParser
destroy MarkCommandParser

AddressBookParser --> LogicManager : a
deactivate AddressBookParser

LogicManager -> MarkCommand : execute(m)
activate MarkCommand

MarkCommand -> Model : getMatchingAppointment(targetNric, targetDate, targetStartTime)
Model --> MarkCommand
MarkCommand -> Model : setAppointment(Appointment, markedAppointment)
activate Model
Model --> MarkCommand
deactivate Model

create CommandResult
MarkCommand -> CommandResult
activate CommandResult

CommandResult --> MarkCommand
deactivate CommandResult

MarkCommand --> LogicManager : r
deactivate MarkCommand

[<--LogicManager
deactivate LogicManager
@enduml

0 comments on commit 6ec2926

Please sign in to comment.