1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
/////////////////////////////////////////////////////////////////////
// DESP-C++ (Discrete-Event Simulation Package)
// Version 1.1, February 1998
// Jerome Darmont
// LIMOS, Blaise Pascal University (Clermont-Ferrand II), France
/////////////////////////////////////////////////////////////////////
// eventc.h: Event Manager classes definition
// Variable with simulated systems
/////////////////////////////////////////////////////////////////////
#include <vector>

using namespace std;
// Active resources declaration
class PatientInfo;
class Secretary;
class HoldingNurse;
class Pass;
class PatientCareSupport;
class PreopRoom;
class CirclingNurse;
class CirclingNurseHeart;
class ScrubTech;
class ScrubTechHeart;
class PA;
class PAHeart;
class Anesthesiologist;
class ORs;
class Doctor;
class RecoveryRoomLevel1;
class RecoveryRoomLevel2;

/////////////////////////////////////////////////////////////////////
// CLASS EventManager
/////////////////////////////////////////////////////////////////////
// Simulation events management
/////////////////////////////////////////////////////////////////////

// The Event Manager must "know" all (active and passive) resources.

class EventManager 
{

  public:

    // Methods

    EventManager(Simulation *sim, int *, int, int);      // Constructor
    ~EventManager();                    // Destructor
    void ExecuteEvent(int code, Client *client); // Event execution
    void Init();                        // Initialization
    void InitRep();                     // Replication initialization 
    void Stats();                       // Stats computation (end of replication)
    void DisplayStats();                // Statistics display

	void SaveResult();						// save result to txt file
	int GetNumCustomerOut();				// Return number of customers out of system
	double GetReplicSumLOS();
	
  private:
	  int *SaveResCap, NumCustomerOut, GetNumOfDoctor, GetNumOfOR;
	  double ReplicSumLOS;

    // Attributes

    Simulation *simul;                  // Pointer toward simulation object

    // Passive resources
    // E.g. Resource *pr;

    // Active resources
	PatientInfo *PatientInfo_obj;
	Secretary *Secretary_obj;
	HoldingNurse *HoldingNurse_obj;
	Pass *Pass_obj;
	PatientCareSupport *PatientCareSupport_obj;
	PreopRoom *PreopRoom_obj;
	CirclingNurse *CirclingNurse_obj;
	CirclingNurseHeart *CirclingNurseHeart_obj;
	ScrubTech *ScrubTech_obj;
	ScrubTechHeart *ScrubTechHeart_obj;
	PA *PA_obj;
	PAHeart *PAHeart_obj;
	Anesthesiologist *Anesthesiologist_obj;

	vector<ORs> ORList;
	ORs *ORs_obj;
	vector<Doctor> DoctorList;
	Doctor *Doctor_obj;

	RecoveryRoomLevel1 *RecoveryRoomLevel1_obj;
	RecoveryRoomLevel2 *RecoveryRoomLevel2_obj;
};

/////////////////////////////////////////////////////////////////////
// CLASS Client
/////////////////////////////////////////////////////////////////////
// Custom simulation entity
/////////////////////////////////////////////////////////////////////

class Client 
{
  public:
           // Add here (in public) additional attributes

           Client *next;
           Client *previous;

		   double PatArrivalTime, PatSurgeryTime;
		   int PatORNum, PatDocNum;
		   bool Heart;

		   int LevelControl;
};
//==================================
// class PatientInfo	// dummy resource
//==================================
class PatientInfo: public Resource
{
	public:
		PatientInfo(char n[STRS], int cap, Simulation *sim);	// read patient data
		~PatientInfo();

		void Event0(Client *client);	// initial new a client
		void Event1(Client *client);	// new clients
	
	private:	
		double *ArrivalSchedule, *SurgerySchedule;
		int *ORNum, *DoctorNum;
		bool *ForHeart;
};
//==================================
// class Secretary
//==================================
class Secretary: public Resource
{
	public:
		Secretary(char n[STRS], int cap, Simulation *sim);
		~Secretary();

		void Event100(Client *client);	// seize a secretary
		void Event101(Client *client);	// registration process
		void Event102(Client *client);	// release a secretary
		
	private:
};
//==================================
// class Pass
//==================================
class Pass: public Resource
{
	public:
		Pass(char n[STRS], int cap, Simulation *sim);
		~Pass();

		void Event103(Client *client);	// seize pass
		void Event104(Client *client);	// pre-admission process
		void Event105(Client *client);	// release pass
		
	private:
};
//==================================
// class PatientCareSupport
//==================================
class PatientCareSupport: public Resource
{
	public:
		PatientCareSupport(char n[STRS], int cap, Simulation *sim);
		~PatientCareSupport();

		void Event106(Client *client);	// seize a patient care support
		void Event107(Client *client);	// route from bathroom to pre-operating
		void Event108(Client *client);	// release a patient care support
		
	private:
		
};
//==================================
// class PreopRoom
//==================================
class PreopRoom: public Resource
{
	public:
		PreopRoom(char n[STRS], int cap, Simulation *sim);
		~PreopRoom();
		void Event200(Client *client);	// seize a pre-operating room
		void Event204(Client *client);	// release a pre-operating room
		
	private:
		
};
//==================================
// class HoldingNurse
//==================================
class HoldingNurse: public Resource
{
	public:
		HoldingNurse(char n[STRS], int cap, Simulation *sim);
		~HoldingNurse();

		void Event201(Client *client);	// seize a holding nurse
		void Event202(Client *client);	// pre-operating process
		void Event203(Client *client);	// release a holding nurse
		
		void Event402(Client *client);	// seize a holding nurse
		void Event406(Client *client);	// release a holding nurse
		
	private:
		
};
//==================================
// class Anesthesiologist
//==================================
class Anesthesiologist: public Resource
{
	public:
		Anesthesiologist(char n[STRS], int cap, Simulation *sim);
		~Anesthesiologist();
		void Event205(Client *client);	// seize an anesthesiologist
		void Event207(Client *client);	// Delay Surgery Wait
		void Event208(Client *client);	// route from pre-operating to OR
		void Event404(Client *client);	// release an anesthesiologist
		
	private:
		
};
//==================================
// class CirclingNurse
//==================================
class CirclingNurse: public Resource
{
	public:
		CirclingNurse(char n[STRS], int cap, Simulation *sim);
		~CirclingNurse();
		void Event206(Client *client);	// seize a circling nurse
		void Event310(Client *client);	// route from OR to recorvery
		void Event400(Client *client);	// release a circling nurse
		
	private:
		
};
//==================================
// class CirclingNurseHeart
//==================================
class CirclingNurseHeart: public Resource
{
	public:
		CirclingNurseHeart(char n[STRS], int cap, Simulation *sim);
		~CirclingNurseHeart();
		void Event206(Client *client);	// seize a circling nurse
		void Event310(Client *client);	// route from OR to recorvery
		void Event400(Client *client);	// release a circling nurse
		
	private:
		
};
//==================================
// class ORs
//==================================
class ORs: public Resource
{
	public:
		ORs(char n[STRS], int cap, Simulation *sim);
		~ORs();
		void Event300(Client *client);	// seize an operating room
		void Event309(Client *client);	// release an operating room

	private:

};
//==================================
// class ScrubTech
//==================================
class ScrubTech: public Resource
{
	public:
		ScrubTech(char n[STRS], int cap, Simulation *sim);
		~ScrubTech();
		void Event301(Client *client);	// seize a scrub tech
		void Event302(Client *client);	// sedate patient process
		void Event308(Client *client);	// release a scrub tech
		
	private:
		
};
//==================================
// class ScrubTechHeart
//==================================
class ScrubTechHeart: public Resource
{
	public:
		ScrubTechHeart(char n[STRS], int cap, Simulation *sim);
		~ScrubTechHeart();
		void Event301(Client *client);	// seize a scrub tech
		void Event302(Client *client);	// sedate patient process
		void Event308(Client *client);	// release a scrub tech
		
	private:
		
};
//==================================
// class PA
//==================================
class PA: public Resource
{
	public:
		PA(char n[STRS], int cap, Simulation *sim);
		~PA();
		void Event303(Client *client);	// seize a PA
		void Event307(Client *client);	// release a PA
		
	private:
		
};
//==================================
// class PAHeart
//==================================
class PAHeart: public Resource
{
	public:
		PAHeart(char n[STRS], int cap, Simulation *sim);
		~PAHeart();
		void Event303(Client *client);	// seize a PA
		void Event307(Client *client);	// release a PA
		
	private:
		
};
//==================================
// class Doctor
//==================================
class Doctor: public Resource
{
	public:
		Doctor(char n[STRS], int cap, Simulation *sim);
		~Doctor();
		void Event304(Client *client);	// seize a doctor
		void Event305(Client *client);	// operation process
		void Event306(Client *client);	// release a doctor

	private:
		RNG RandomDistribution;

};
//==================================
// class RecoveryRoomLevel1
//==================================
class RecoveryRoomLevel1: public Resource
{
	public:
		RecoveryRoomLevel1(char n[STRS], int cap, Simulation *sim);
		~RecoveryRoomLevel1();
		void Event401(Client *client);	// seize a recovery room
		void Event403(Client *client);	// patient stablized process
		void Event405(Client *client);	// recovery process
		void Event407(Client *client);	// release a recovery room
		void Event408(Client *client);	// dispatch process
		void Event409(Client *client);	// dispatch patient
		
	private:
		
};
//==================================
// class RecoveryRoomLevel2
//==================================
class RecoveryRoomLevel2: public Resource
{
	public:
		RecoveryRoomLevel2(char n[STRS], int cap, Simulation *sim);
		~RecoveryRoomLevel2();
		void Event401(Client *client);	// seize a recovery room
		void Event403(Client *client);	// patient stablized process
		void Event405(Client *client);	// recovery process
		void Event407(Client *client);	// release a recovery room
		void Event408(Client *client);	// dispatch patient
		
	private:
		
};