Triage is a process for sorting injured patients into groups based on their need for or likely benefit from immediate medical treatment. At most veterinary clinics, veterinarians will interrupt treatment of a patient if another patient with higher medical priority arrives. Only after higher medical priority patients have been tended to will resources be once again diverted to lower medical priority patients.   Write a program for a veterinary clinic that will give an estimated time for when all patients will have been successfully treated. Input from a data file is as follows: • The first line of input will contain a single integer, n, indicating the number of data sets to process. The remainder of the input consists of those n data sets. Each data set will consist of two parts: 1. A line containing a single integer, m, indicating the number of patients. 2. Each of the next m lines will correspond with a single patient and be in the format "x y z", where: • x is the time the patient arrives at the clinic, specified by the number of minutes (0- 480) that have elapsed since the clinic opened. Patients are listed in order of arrival, so the x value for each patient is at least as high as for the previous patient. • y is the medical priority (1- 5) of the patient, with 1 being the highest medical priority. • z is the number of uninterrupted minutes (1- 480) of treatment necessary to tend to the patient. For each data set in the input display the following to the screen: • A single line in the form "Set n: a minutes", where n is the data set and a is the number of minutes that have elapsed since the clinic opened when all patients have been successfully treated. Only one patient can be treated at a time (it is a small clinic) and treatment for a patient can only begin after it has arrived at the clinic. Treatments are started as soon as possible. If two or more patients are at the clinic awaiting treatment, the one with highest medical priority is treated first. If two or more have the same highest medical priority, then the one (of those with the highest medical priority) with the shortest treatment time is treated first. The only time treatment may be interrupted is when a higher medical priority patient arrives. In this case, the treatment for the lower medical priority patient is stopped and treatment for the highest medical priority patient begins. For a patient to be successfully treated, its treatment must be uninterrupted and last the number of minutes specified in the input. Let the user input the file name from the keyboard. Use a Queue/PQ data structure. Refer to the sample output below. Sample File 3 3 0 5 20 19 4 30 48 3 60 7 60 1 30 75 1 60 80 2 10 80 3 5 80 2 5 155 1 10 166 2 5 3 0 3 10 1 3 5 2 4 1 Sample Run: Enter the file name: triage.txt Set 1: 158 minutes Set 2: 185 minutes Set 3: 16 minutes

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Triage is a process for sorting injured patients into groups based on their need for or likely benefit
from immediate medical treatment. At most veterinary clinics, veterinarians will interrupt treatment of
a patient if another patient with higher medical priority arrives. Only after higher medical priority
patients have been tended to will resources be once again diverted to lower medical priority patients.

 

Write a program for a veterinary clinic that will give an estimated time for when all patients will have
been successfully treated. Input from a data file is as follows:
• The first line of input will contain a single integer, n, indicating the number of data sets to process.
The remainder of the input consists of those n data sets. Each data set will consist of two parts:
1. A line containing a single integer, m, indicating the number of patients.
2. Each of the next m lines will correspond with a single patient and be in the format "x y z",
where:
• x is the time the patient arrives at the clinic, specified by the number of minutes (0- 480)
that have elapsed since the clinic opened. Patients are listed in order of arrival, so the x
value for each patient is at least as high as for the previous patient.
• y is the medical priority (1- 5) of the patient, with 1 being the highest medical priority.
• z is the number of uninterrupted minutes (1- 480) of treatment necessary to tend to the
patient.
For each data set in the input display the following to the screen:
• A single line in the form "Set n: a minutes", where n is the data set and a is the number of
minutes that have elapsed since the clinic opened when all patients have been successfully
treated.
Only one patient can be treated at a time (it is a small clinic) and treatment for a patient can only begin
after it has arrived at the clinic. Treatments are started as soon as possible. If two or more patients are
at the clinic awaiting treatment, the one with highest medical priority is treated first. If two or more
have the same highest medical priority, then the one (of those with the highest medical priority) with
the shortest treatment time is treated first. The only time treatment may be interrupted is when a
higher medical priority patient arrives. In this case, the treatment for the lower medical priority patient
is stopped and treatment for the highest medical priority patient begins. For a patient to be successfully
treated, its treatment must be uninterrupted and last the number of minutes specified in the input.
Let the user input the file name from the keyboard. Use a Queue/PQ data structure. Refer to the sample
output below.

Sample File
3
3
0 5 20
19 4 30
48 3 60
7
60 1 30
75 1 60
80 2 10
80 3 5
80 2 5
155 1 10
166 2 5
3
0 3 10
1 3 5
2 4 1
Sample Run:
Enter the file name: triage.txt

Set 1: 158 minutes
Set 2: 185 minutes
Set 3: 16 minutes
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education