12  Health Clinic

12.1 Data

Table 12.1: List of Global Variables
Name Description Initial Value
NextWalkUpIdNum The Id number that will be assigned to the next walk-up patient 1
NextApptIdNum The Id number that will be assigned to the next appointment patient 1
NextDoctorIdNum The Id number that will be assigned to the next doctor 1
\(W\) The set of all walk-up patients \(\emptyset\)
\(A\) The set of all appointment patients \(\emptyset\)
\(D\) The set of all doctors \(\emptyset\)
Table 12.2: List of Data Modules
Name Source Model Type Input Output
InterarrivalTime Experiment Poisson Process Stochastic Mean Sample from distribution
AppointmentTimes Experiment Lookup Deterministic Appointment Number Appointment Time
ConsultationDuration Clinic Data Triangular Distribution Stochastic Min, Mode, Max Sample from Distribution

12.2 Components

Table 12.3: List of Entities
Entity Attributes
Walk-up Patient ID
CurrentActivity
CurrentStart
ArrivalTime
WaitTime
Appointment Patient ID
CurrentActivity
CurrentStart
AppointmentNumber
AppointmentTime
WaitTime
Doctor ID
CurrentActivity
CurrentStart
Role
ConsultTime
Table 12.4: List of Transitions
Participant Name From Event To Event
Walk-up Patient W.1 Walk-up Arrives Walk-up Wait for Consultation.Start
W.2 Walk-up Wait for Consultation.End Consultation.Start
W.3 Consultation.End Walk-up Patient Leaves
Appointment Patient A.1 Appt. Arrives Appt. Wait for Consultation.Start
A.2 Appt. Wait for Consultation.End Consultation.Start
A.3 Consultation.End Appt. Patient Leaves
Doctor D.1 Doctor Created Wait for Patient.Start
D.2 Wait for Patient.End Consultation.Start
D.3 Consultation.End Wait for Patient.Start
Table 12.5: Activities
Activity Participants Event Type State Change
Walk-up Wait for Consultation Walk-up Patient (w) Start Scheduled
TRIGGER OnStartWalkupWaitForConsultation WITH w
End Controlled
w.WaitTime = TIME - w.CurrentStart
Consultation Walk-up/Appointment Patient (p), Doctor (d) Start Controlled
SCHEDULE Consultation.End at TIME + ConsultationDuration()
End Scheduled
d.ConsultTime += TIME - d.CurrentStart
START Walk-up/Appt. Patient Leaves WITH p # TRANSITION P.3
START Wait for Patient WITH d # TRANSITION D.3
Appt. Wait for Consultation Appt. Patient (a) Start Scheduled
TRIGGER OnStartApptWaitForConsultation WITH a
End Controlled
a.WaitTime = TIME - a.CurrentStart
Wait for Patient Doctor (d) Start Scheduled
TRIGGER OnStartWaitForPatient WITH d
End Controlled
Table 12.6: Events
Event Participants Type State Change
Simulation Start - Scheduled
SCHEDULE Create Doctor at TIME
SCHEDULE Walk-up Patient Arrives at TIME + InterarrivalTime()
SCHEDULE Appt. Patient Arrives at AppointmentTimes(1)
Walk-up Patient Arrives - Scheduled
CREATE Walk-up Patient w
w.ID = NextWalkUpIDNum
NextWalkUpIDNum = NextWalkUpIDNum + 1
w.ArrivalTime = TIME
w.WaitTime = 0
SCHEDULE Walk-up Patient Arrives at TIME + InterarrivalTime()
START Walk-up Wait for Consultation WITH w # TRANSITION W.1
Appt. Patient Arrives - Scheduled
CREATE Appointment Patient a
a.ID = NextApptIDNum
NextWalkUpIDNum = NextWalkUpIDNum + 1
a.ArrivalTime = a.ID
a.AppointmentTime = TIME
SCHEDULE Appt. Patient Arrives at AppointmentTimes(a.ID + 1)
START Appt. Wait for Consultation WITH a # TRANSITION A.1
Create Doctor - Scheduled
CREATE Doctor d
d.ID = NextDoctorIDNum
NextDoctorIDNum = NextDoctorIDNum + 1
d.ConsultTime = 0
IF d.ID = 1 THEN
    d.Role = "Walk-up"
ELSE
    d.Role = "Appointment"
END IF
IF d.ID < 2 THEN
    SCHEDULE Create Doctor at TIME
END IF
START Wait for Patient WITH d # TRANSITION D.1
Walk-up Patient Leaves Walk-up Patient (w) Scheduled
Calculate any required statistics for w
Appt. Patient Leaves Appointment Patient (a) Scheduled
Calculate any required statistics for a
Simulation Finish - Scheduled
Calculate any required statistics

12.3 Activity Diagrams

Figure 12.1: Walk-up Patient Activity Diagram
Figure 12.2: Appointment Patient Activity Diagram
Figure 12.3: Doctor Activity Diagram

12.4 Logic

Table 12.7: OnStartWalkupWaitForConsultation
Triggered by: Walk-up Patient w
waiting_walkup_docs = {d FOR d IN D IF d.Role = "Walk-up" AND d.CurrentActivity = "Wait for Patient"}
waiting_appt_docs = {d FOR d IN D IF d.Role = "Appointment" AND d.CurrentActivity = "Wait for Patient"}
IF waiting_walkup_docs IS NOT empty THEN
    d_hat = argmin{d.CurrentStart FOR d IN waiting_walkup_docs}
    START Consultation WITH w, d_hat # TRANSITIONS W.2, D.2
ELSE IF waiting_appt_docs IS NOT empty THEN
    d_hat = argmin{d.CurrentStart FOR d IN waiting_appt_docs}
    START Consultation WITH w, d_hat # TRANSITIONS W.2, D.2
END IF
Table 12.8: OnStartApptWaitForConsultation
Triggered by: Appointment Patient a
waiting_appt_docs = {d FOR d IN D IF d.Role = "Appointment" AND d.CurrentActivity = "Wait for Patient"}
IF waiting_appt_docs IS NOT empty THEN
    d_hat = argmin{d.CurrentStart FOR d IN waiting_appt_docs}
    START Consultation WITH a, d_hat # TRANSITIONS A.2, D.2
END IF
Table 12.9: OnStartWaitForPatient
Triggered by: Doctor d
waiting_walkup_pats = {w FOR w IN W IF w.CurrentActivity = "Walk-up Wait for Doctor"}
waiting_appt_pats = {a FOR a IN A IF a.CurrentActivity = "Appt. Wait for Doctor"}
IF d.Role = "Appointment" and waiting_appt_pats IS NOT empty THEN 
    p_hat = argmin{p.CurrentStart FOR p IN waiting_appt_pats}
    START Consultation WITH p_hat, d # TRANSITIONS A.2, D.2
ELSE IF waiting_walkup_pats IS NOT empty THEN
    p_hat = argmin{p.CurrentStart FOR p IN waiting_walkup_pats}
    START Consultation WITH p_hat, d # TRANSITIONS W.2, D.2
END IF