(Latest Revision: 10/03/2003)
(10/03/2003: added some new directions on what to turn in)
Medical Clinic Program
(Much of this assignment is reproduced from Pascal Plus Data
Structures by Nell Dale and Susan C. Lilly.)
PRELIMINARIES:
Before working on this problem you should understand lists, stacks, and
queues. Also you should understand some fundamentals of object-oriented
computing: you should be comfortable with the possibility of using C++ classes
to represent such things as doctors, patients, a clinic, and rooms in a
clinic. You may want to read parts of chapter 8 of Carrano before beginning,
and you may want to review parts of chapters 4, 6, and 7.
You also need to be familiar with the directions and
examples here:
http://www.cs.csustan.edu/~john/Classes/General_Info/progAsgRules/
ASSIGNMENT SYNOPSIS:
Write a 'toy' program that simulates operations done in a medical clinic.
INPUT:
The program reads a series of one or more commands from standard input.
I will test your program this way:
a.out < fileOfInputs > fileOfOutputs
Series
sampInput1.html
and
sampInput2.html
illustrate the kind of input command series I will place in 'fileOfInputs'
when I test your program. The program must not prompt for input. It must
simply read and execute a series of commands of a pre-specified form from the
standard input.
There will be five different kinds of commands:
- Doctor Check-In <lastName> <room number> <specialty code>
- Doctor Check-Out <room number>
- Patient Check-In <lastName> <age> <specialty code> <priority code>
- Patient Check-Out <lastName> <room number>
- Stop
In the commands above, the objects placed between the "angle-brackets" <
> stand for variables and the other names there are literal
command names.
OUTPUT:
The program must write all its output to standard output. It must produce a
'message' for each command in the input and the messages must appear on the
output in order: the order corresponding to the order of the input.
Series
sampOutput1.html
and
sampOutput2.html
illustrate the outputs the program would be expected to produce for
sampInput1.html
and
sampInput2.html
What is in each message? In response to every check-in or check-out
command, the program must print the state of the clinic -- the ordered
list (deque) of patients associated with each examination room of the
clinic, the current assignments of doctors to examination rooms, and the
respective speciality codes of each doctor.
When showing the contents of the deques, for each patient the program must
include the name, age, specialty code requested, and priority code given. The
program must list patient information in front-to-rear order.
The program must show the state information in a clear, compact
format that is easy to read.
When I say the display must be compact I mean I want you to economize
on the amount of space you take to write the information.
There is a trade-off involved in designing the display the program makes. If
you use too much space or cause information to disappear too soon then very
little information (and 'history') can be seen on the screen at any given
time. If you use too little space, the eye has difficulty picking out the
information. Unless a proper balance is achieved, the display will lack
intelligibility.
Incidentally please don't make the program perform "clear screen"
operations. (I don't want the program to erase history.)
Here is a table showing what sorts of messages must be printed for each type
of job:
JOB TYPE OF MESSAGE REQUIRED
Doctor check-in ........ confirmation that room is available or error
message if room is in use. Lastly, show the
current state of the clinic.
Doctor check-out ....... goodbye message to doctor, and messages
indicating what was done with any patients left
in the doctor's deque when the doctor checked
out. (It is possible that some waiting
patients may have to be told to find another
hospital if the last physician in the clinic
decides to leave while patients are still
there.) Lastly, show the current state of the
clinic.
Patient check-in ....... If any doctors are available, a message telling
the patient which room to go to, which doctor
has been assigned, and what the doctor's
specialty is. If the patient has had to be
assigned, or reassigned, to a type of
specialist that he did not request, or if no
doctors are in the clinic at all, an
appropriate message of apology. Lastly, show
the current state of the clinic.
Patient check-out ..... goodbye message, or error message if an attempt
is made to check-out a patient that has not
reached the front of a deque. Lastly, show
the current state of the clinic.
DISCUSSION OF PROCESSING:
To motivate things, pretend that the local medical clinic has decided to
automate scheduling services, and you have been assigned to design the
prototype version of the scheduler. The functions we want to implement are
doctor check-in and check-out and patient check-in and check-out.
A doctor checking-in tells the scheduler his name, an examination room number,
and a specialist code that tells what kind of doctor he is. The doctor is
likely to have a favorite examination room. The scheduler checks to see if
the room specified by the physician is free. If so, it assigns the doctor to
that room. If not, it rejects the request with a message, and if the doctor
still wants to check-in, he has to go through the check-in procedure from the
beginning.
When a doctor checks-out, the examination room is freed. In the (unusual, but
not impossible) event that a doctor checks-out when there are still patients
waiting to see him (or her), the program must reassign the patients, if
possible, to other doctors in the clinic. If there are no doctors left in the
clinic, the remaining patients have to be told to go find another hospital.
A patient that is checking-in provides his/her name, age, desired specialist
code, and a priority code. The scheduler decides where to put the patient
based on the set of assignment rules given below. The program uses
the very same set of assignment rules when it reassigns patients as
described in the previous paragraph.
If there are any doctors at all in the clinic, a patient requesting to be
checked-in, or being reassigned, is placed in a deque -- a structure much like
a queue, except that it is possible for the patient to be inserted either at
the front, or the rear of the deque, according to the priority code.
Usually the patient is put at the rear of a deque. If, however, the patient's
problem has high priority, s/he is put at the front of the deque, ahead of any
other patients. The patient at the front of a deque is the one currently
being seen by the doctor. (In this version of the program we assume that we
will never have more than one high priority patient at any time.)
The Assignment Rules for assigning patients to doctors are as follows.
Note that the scheduler has to obey every one of these rules every time that
it handles a request from a patient to check-in, and every time it reassigns a
patient whose doctor checked-out before the patient checked-out.
- Rule 1. If the patient is 9 years of age or younger, and if a
pediatrician is available, then the patient must be assigned to see a
pediatrician
- Rule 2. If the patient is of age greater than 9, but not over 17, and if
a general practitioner is available, then the patient must be assigned to
a general practitioner.
- Rule 3. If the patient is of age greater than 17, and if a specialist of
the type requested by the patient is available, then the patient must be
assigned to such a specialist.
- Rule 4. If following rules 1 - 3 does not result in finding a doctor to
whom to assign the patient, and if a specialist in general practice,
internal medicine, pediatrics, or obstetrics is available, then the
patient must be assigned to one of those specialists.
- Rule 5. If following rules 1 - 4 does not result in finding a doctor to
whom to assign the patient, then the patient can be assigned to a doctor
with any speciality.
- Rule 6. When processing a patient check-in, suppose there is more than
one eligible doctor. (An eligible doctor is one to whom the
rules allow the program to assign the patient.) In that case the program
must assign the patient to an eligible doctor whose deque is of minimal
length.
- Rule 7. In the event that there are no doctors at all in the clinic, the
program must not assign the patient any examination room. The
program must tell the patient to find another hospital.
The program should loop, processing one request for check-in or check-out per
cycle, and the program must halt in response to the Stop command.
The program should have internal data structures that keep track of the state
of the clinic. It should update those data structures appropriately in
response to every check-in or check-out command.
DETAILS AND ASSUMPTIONS:
- There are 6 examination rooms at the clinic, each with a deque attached.
The room numbers are 1, 2, 3, 4, 5, and 6. (No, not 0 through 5.)
- The Specialty codes are:
PED Pediatrics
GP General Practice
INT Internal Medicine
CARD Cardiology
SUR Surgeon
OBS Obstetrics
PSY Psychiatry
NEUR Neurology
ORTH Orthopedics
DERM Dermatology
OPH Ophthalmology
ENT Ear, Nose, and Throat
The user is allowed to type these codes in any combination of upper and
lower case characters -- e.g. Neur, EnT, oph, and DERM are all OK.
- The priority codes are 'red' and 'green'. Red means high priority
patient. Any combination of upper and lower case is allowed in an input
priority code -- e.g. it is OK for the input to give the priority code as
RED, Red, GReen, or greEN.
DATA STRUCTURES:
The basic 'structure' underlying this assignment is a group of examination
rooms with a deque attached to each. Since the number of rooms is fixed and
it will be convenient to have random access to the rooms, it seems that an
array of structs or classes -- or something similar -- is a logical way to
represent the group of rooms.
You, the programmer, must design the data structures for this program. You
are answerable for the wisdom and efficacy of your choice. You must use
principles of good program design: modular code, top down design, data
encapsulation, information hiding, ...
Maintain a balanced approach. For example if you create some classes
to represent doctors, patients, the clinic, and rooms it will probably make
your work easier. However if you create too many classes and methods, the
complexity may become unmanageable.
Keep track of the critical data your program will be required to maintain.
One example is that the number of patients in each deque becomes important
when there are two or more doctors available with a specialty requested by an
adult patient. This is a small detail, but there are many such details that
you must try to consider in a timely manner while designing the program.
Before deciding on the final form of a data structure or class write a
description of each operation or method your data structure or class will need
and what information each such operation or method will need to use or produce.
TESTING:
You need to create tests for your program that give you good data and code
coverage, and you need to turn in a script showing that you executed those
tests successfully. (If you just run your program on the tiny samples I have
provided here, expect it to lower your score by a full letter grade or more.)
I'll be happy to discuss testing strategies in class. Please ask if you want
more information.
WHAT TO TURN IN:
You will turn in a level-two version of this assignment, and a final level.
You will turn in three printer outputs (hardcopies) and you will send me three
e-mail messages. Please follow these rules:
- Always send me e-mail as plain text in the main message body. Never
send me attachments.
- Always use the exact subject line I specify for each message.
(I often get hundreds of e-mail messages in a week. The subject line
allows me to find, filter and sort messages.) You will lose a
significant number of points on the assignment if you use the wrong
subject line.
- Be very careful when typing the command to send e-mail. You may use
the instructions in your
Hello World! lab excercise
for guidance. Of course, you will need to make the obvious changes to
those directions -- you have to use the correct subject line and
filename.
- Always send yourself a copy of each e-mail message you send to me, and
check immediately to see if you receive the message intact.
You are responsible for sending e-mail correctly.
Here is the list of things you have to turn in:
-
On the first due
date, place the following item
in my mailbox:
- a hardcopy of your test script showing adequate testing of
the level-two version of your
program.
Make sure that all of the script content shows on the paper. Make sure
all content is plainly readable and properly formatted.
- Using the subject line: CS3100,prog3.2 send the following item to
me by e-mail before midnight on the first due
date:
One
shell archive file
(only one) containing items 1-4.
- All source files for your level-two
program (*.cpp files and *.h files)
- Your test script showing adequate testing of your level-two program.
- A file named 'README' containing the compilation command one should
use to compile your program.
- A copy of your 'makefile' if you used one.
-
- At the start of class on
the second due
date, place the following item
on the "counter" in front of me:
- a hardcopy of your test script showing adequate testing of
the level-three version of your
program.
Make sure that all of the script content shows on the paper. Make sure
all content is plainly readable and properly formatted.
- Using the subject line: CS3100,prog3.3 send the following item to
me by e-mail before midnight on the second due
date:
One
shell archive file
(only one) containing items 1-4.
- All source files for your level-three
program (*.cpp files and *.h files)
- Your test script showing adequate testing of your level-three program.
- A file named 'README' containing the compilation command one should
use to compile your program.
- A copy of your 'makefile' if you used one.
-
- At the start of class on the third due
date, place the following item on the "counter" in front
of me:
- a hardcopy of your test script showing adequate testing of
the final version of your
program.
Make sure that all of the script content shows on the paper. Make sure
all content is plainly readable and properly formatted.
- Using the subject line: CS3100,prog3.f send the following item to
me by e-mail before midnight on the third due
date:
One
shell archive file
(only one) containing items 1-4.
- All source files for the final version of
your program (*.cpp files and *.h files)
- Your test script showing adequate testing of the final version of your program.
- A file named 'README' containing the compilation command one should
use to compile your program.
- A copy of your 'makefile' if you used one.
Notice that I'm telling you to send me all the files I need to compile
the program (plus some other things). Send all the source files. If I
have to write back to you to request more files or instructions you may lose
significant credit.
Make sure the scripts you send are cleaned up using the sort of "col -b"
filtering trick
illustrated here.
(Don't forget to change the commands so you are using the correct name of your
script.)
Make sure all your source files are clean too. Sometimes files transferred
from a PC to a Sun Ultra need to be
cleaned up.
Don't send me any compiled code.
Note that there are no spaces in the subject lines given. It is important
that you do not insert any spaces. My e-mail address is:
john@ishi.csustan.edu.
QUESTIONS:
Please bring up in class any questions you still have about this assignment.
DUE DATES:
For the due dates, see
the class schedule.