@startuml
!include style.puml

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":AppointmentBookParser" as AppointmentBookParser LOGIC_COLOR
participant ":AddAppointmentCommandParser" as AddAppointmentCommandParser LOGIC_COLOR
participant "c:AddAppointmentCommand" as AddAppointmentCommand LOGIC_COLOR
participant "a:Appointment" as Appointment MODEL_COLOR
participant "r:CommandResult" as CommandResult LOGIC_COLOR
end box

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

[-> LogicManager : execute("addappt 1 at/12:30 \ndur/60 desc/removal of \nbraces")
activate LogicManager

note left
notice that only the time
is supplied in the user
input
end note

LogicManager -> AppointmentBookParser : parseCommand("addappt 1 \nat/12:30 dur/60 \ndesc/removal of braces")
activate AppointmentBookParser

create AddAppointmentCommandParser
AppointmentBookParser -> AddAppointmentCommandParser
activate AddAppointmentCommandParser

AddAppointmentCommandParser --> AppointmentBookParser
deactivate AddAppointmentCommandParser

AppointmentBookParser -> AddAppointmentCommandParser : parse("1 at/12:30 dur/60 \ndesc/removal of braces")
activate AddAppointmentCommandParser

create AddAppointmentCommand
AddAppointmentCommandParser -> AddAppointmentCommand
activate AddAppointmentCommand

AddAppointmentCommand --> AddAppointmentCommandParser : c
deactivate AddAppointmentCommand

AddAppointmentCommandParser --> AppointmentBookParser : c
deactivate AddAppointmentCommandParser

AddAppointmentCommandParser -[hidden]-> AppointmentBookParser
destroy AddAppointmentCommandParser

AppointmentBookParser --> LogicManager : c
deactivate AppointmentBookParser

LogicManager -> AddAppointmentCommand : execute(m)
activate AddAppointmentCommand

AddAppointmentCommand -> ModelManager : getAppointmentCalendar()
activate ModelManager

ModelManager -> CalendarManager : getAppointmentCalendar()
activate CalendarManager

CalendarManager -> ModelManager : calendar
deactivate CalendarManager

ModelManager --> AddAppointmentCommand : calendar
deactivate ModelManager

create Appointment
AddAppointmentCommand -> Appointment : Appointment(patient, dt, dur, \ndesc, tags, status)
activate Appointment

note left
""dt"" is the datetime
constructed using the
date retrieved from
the calendar and
the time supplied by the
user.
end note

Appointment --> AddAppointmentCommand : a
deactivate Appointment

AddAppointmentCommand -> ModelManager : addAppointment(a)
activate ModelManager

ModelManager --> AddAppointmentCommand
deactivate ModelManager

create CommandResult
AddAppointmentCommand -> CommandResult
activate CommandResult

CommandResult --> AddAppointmentCommand : r
deactivate CommandResult

AddAppointmentCommand --> LogicManager : r
deactivate AddAppointmentCommand

AddAppointmentCommand -[hidden]-> LogicManager
destroy AddAppointmentCommand

[<--LogicManager : ""r""
deactivate LogicManager

@enduml
