Purpose:
This assignment introduces you to computer programming using the Turing programming language. In programming the problem described below, you will learn something about data structures, algorithm design, and programming methodology.
The Problem:
You are to write an Turing program that manages a hospital emergency ward (ER).
In a typical ER, when a patient arrives, the triage physician assigns
the incoming patient one of the following four priority levels:
0: airway blocked and/or breathing impaired
1: circulation impaired, ie. internal bleeding
2: central nervous system trauma, eg. head injury
3: all else
Your Turing program is the computer interface that the triage physician uses to enter the names, status and priorities of incoming patients. The program will keep a list of the patients and when prompted by the physician, produce the information on the current patient with the highest priority. Your interface implements an interaction with the physician described as follows.
When the triage physician starts your program, your first output is the following text:
This program keeps track of emergency patients in priority order
based on their need for care.
The physician can then make one of the following commands to your program and your program will reply appropriately:
e: enter new patient
g: retrieve most urgent patient
h: list instructions
q: quit
A sample dialog between your program (listed below in teletype) and the triage physician (listed below in italics) might proceed as follows:
command: e
give care level (breathing(0), circulation(1), CNS(2), other(3)):
0
give patient status: Patient A is not breathing.
command: e
give care level (breathing(0), circulation(1), CNS(2), other(3)):
5
Sorry, 5 is an incorrect priority.
give care level (breathing(0), circulation(1), CNS(2), other(3)):
1
give patient status: Patient X has internal bleeding.
command: g
**Top Priority (0) ** Patient A is not breathing.
etc.
To keep track of arriving patients, your Turing interface will use a Priority Queue data structure. The background for this data structure is given below.
Priority Queue Data Structure
If you've ever stood in a bank line or at a grocery checkout stand or at an airport check-in counter, then you know that a queue is a collection of customers/items where the customer at the head of the queue receives service first (and then leaves), and new customers join the end of the queue. In computer terms, this type of queue is called a First In First Out (FIFO) queue. A FIFO queue is one type of data structure, a way of organizing data. A Priority Queue is another data structure that behaves like a FIFO queue, except the customer with the highest priority receives service (and departs the queue) first. Hence, each customer in a Priority Queue carries a priority value. In this way, your Turing interface will record each patient arriving at the hospital ER in a Priority Queue, along with the priority assigned by the triage physician. Since the triage physician assigns an integer value between 0 and 3, a patient with the lowest number, eg. 0, has the highest priority ie. receives service first. If there are several patients with the same priority number, the group is served on a FIFO basis within the priority. For example, if there are 3 patients with priority value 0, these 3 patients will be served first, but one at a time in the order they arrived.
You need to understand the data structures described above to test your program, but we will provide the Turing code for them. A number of operations are associated with the Priority Queue, which are coded with the data structure. Your Turing interface will use some of these operations. In particular, when a new patient is entered, your program will call the Arrive procedure, with the patient information AND priority assigned by the triage physician. Similarly, when a patient is chosen for service (ie. with the g command), your program will remove the patient from the queue using the Leave procedure. Your program will also use the IsEmpty? procedure to check if there are patients in the queue awaiting service. These procedures are described and coded in the file listed below.
{When Coding Your Assignment
Obtain the Turing file priority.t from the CDFPC system either by using
Pickup Standard File or by downloading it from the course Web pages.
You do not need to understand the details of this code but you must understand
the comments well enough to use the Arrive, Leave and IsEmpty?
routines. Do not change the code in the priority.t file,
but add it to complete your program.
Submission
You will submit hardcopies only for this assignment. Once your program
works correctly with the triage doctor's commands typed at the keyboard, you
need to create test files that demonstrate your program
to the marker. Use the WinOOT editor to create an input file containing the
same input that you previously typed on the keyboard. Run your program on this
batch input file using the Run with Args option in WinOOT. Notice that
the inputs, i.e. the doctor's commands, are no longer visible on the screen. To
display the batch inputs, add a put statement directly after every get
statement in your program; this will echo the input to the screen.
The output will then look a little funny if you run the edited program with
input from the keyboard, but that is ok. When you are finished testing your
program, use Print Turing Assignment to create your submission printout,
which will include your program, your input/test file and the resulting
output. In addition, create a readme.A2 file which describes any
unusual properties of your program and/or your test file.
Other things to Note:
The sample interaction above suggests a design for your interface. Some decisions
about the interface have been left to you. You are not expected to handle
the situation where the physician enters a non-integer for the priority.
Programming can be very frustrating. The more time you spend designing the interface BEFORE you start to code, the less frustrating the process will be. You are ready to code when ALL the design issues have been worked out.
The marking scheme for this programming problem is as follows:
Correctness and Completeness....40%
Testing and Documentation.......40%
Style...........................20%
Debugging a new language can take many many hours. Do NOT leave it until
the last few days.