(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: 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.

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:
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: Here is the list of things you have to turn in: 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.