(Latest Revision: 10/18/99)

10/18/99 -- Moved Final due date back from 10/18 to 10/22
10/18/99 -- Changed spelling of "dequeue" to "deque"

The Medical Clinic

CS 3100 PROGRAMMING ASSIGNMENT TWO


DUE DATES:

Please read pages A7, A11-A15, and A30-A50 in Appendix A of your textbook (Carrano) before you read this document.

Also, you are expected to read the class documents entitled:
before beginning to do this or any programming assignment. You will find the documents under "CourseDocuments" in the class web space.

This problem is a version of one of the programming assignments found in an early edition of Pascal Plus Data Structures, by Nell Dale and Susan C. Lilly.

We will 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 basic functions that the clinic has in mind 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 the 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, the patients have to be reassigned, 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 checking-in gives a name, age, specialist code, and priority code. The scheduler decides what to do with the patient by following a set of rules which will be described below. Patients who are being reassigned as described in the previous paragraph are handled using the same set of rules.

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, 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 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 seeing him.

INPUT
This program must run in "batch mode."

I will run the program this way:

a.out < fileOfInputs > fileOfOutputs

The program should 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

Above, the objects between "angle-brackets" < and > stand for variables and the other names are literal command names.

OUTPUT
The output for each request is in the form of messages to the user in accordance with the request. The program will loop, processing one request for check-in or check-out per cycle, and the program will halt in response to the Stop command.

After updating it's data structures in response to every check-in or check-out command, the program must print the STATE of the clinic -- the contents of the deques, the current assignments of doctors to examination rooms, and the respective speciality codes of each doctor.

When showing the contents of the deques, the program must include the name, age, specialty code requested, and priority code given, for each patient, and must list patient information in front-to-rear order.

The program must show the state information in a CLEAR, COMPACT format which is easy to read.

COMPACT means don't be "greedy" about the amount of space you take to print things. (Please don't do "clear screen" operations of any kind.) There is a trade-off involved here. If you use too much space then very little information 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.

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.
DETAILS AND ASSUMPTIONS

  1. 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.)

  2. 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.

  3. 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.
DATA STRUCTURES
The basic data structure 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 is a logical way to represent the group of rooms.

You must design the data structures used for this program. You are answerable for the wisdom and efficacy of your choice. You must implement each data structure in a way consistent with the DEFINITION we have chosen for the term "Data Type" -- a set of data values together with operations on those data values. We will have class discussion regarding the design decisions.

Keep in mind that you have to maintain some sort of access to critical data. 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 each data structure, write a description of each operation your program will need to perform on the data, and what information each such operation will need to use.

Look in your textbook for examples of properly specified and implemented data types and data structures. You need to create a package of code that implements the values and operations of each data structure. This should be done in a way that separates the different packages, or modules, from each other as completely as possible, in order to achieve the goals of modular code, top down design, data encapsulation, and information hiding.


DUE DATES: