Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete the emergency room scheduler application as described, must be completed in python. Patient details are entered in by the user, they are NOT provided

Complete the emergency room scheduler application as described, must be completed in python. Patient details are entered in by the user, they are NOT provided for this program. The program does not need it to work, the user enters in the details as they run the program. All .py files have been provided, please let me know if the following instructions are not clear. Thank you.

image text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

"""

File: linkedqueue.py

Author: Ken Lambert

"""

from node import Node

from abstractcollection import AbstractCollection

class LinkedQueue(AbstractCollection):

"""A link-based queue implementation."""

# Constructor

def __init__(self, sourceCollection = None):

"""Sets the initial state of self, which includes the

contents of sourceCollection, if it's present."""

self.front = self.rear = None

AbstractCollection.__init__(self, sourceCollection)

# Accessor methods

def __iter__(self):

"""Supports iteration over a view of self.

Visits items from bottom to top of stack."""

def visitNodes(node):

"""Adds items to tempList from tail to head."""

if not node is None:

visitNodes(node.next)

tempList.append(node.data)

def peek(self):

"""

Returns the item at the front of the queue.

Precondition: the queue is not empty.

Raises: KeyError if the stack is empty."""

if self.isEmpty():

raise KeyError("The queue is empty.")

return self.front.data

# Mutator methods

def clear(self):

self.size = 0

self.items = None

def add(self, item):

"""Adds item to the rear of the queue."""

newNode = Node(item, None)

if self.isEmpty():

self.front = newNode

else:

self.rear.next = newNode

self.rear = newNode

self.size += 1

def pop(self):

"""

Removes and returns the item at the front of the queue.

Precondition: the queue is not empty.

Raises: KeyError if the queue is empty.

Postcondition: the front item is removed from the queue."""

if self.isEmpty():

raise KeyError("The queue is empty.")

oldItem = self.front.data

self.front = self.front.next

if self.front is None:

self.rear = None

self.size -= 1

return oldItem

"""

File: ermodel.py

Project 8.8

Defines the classes ERModel, Patient, and Condition for an

emergency room scheduler.

"""

from linkedpriorityqueue import LinkedPriorityQueue

class Condition(object):

"""Represents a condition."""

def __init__(self, rank):

self.rank = rank

def __eq__(self, other):

return self.rank == other.rank

def __lt__(self, other):

return self.rank

def __le__(self, other):

return self.rank

def __str__(self):

"""Returns the string rep of a condition."""

if self.rank == 1: return "critical"

elif self.rank == 2: return "serious"

else: return "fair"

class Patient(object):

"""Represents a patient with a name and a condition."""

def __init__(self, name, condition):

self.name = name

self.condition = condition

def __eq__(self, other):

return self.condition == other.condition

def __lt__(self, other):

return self.condition

def __le__(self, other):

return self.condition

def __str__(self):

"""Returns the string rep of a patient."""

return self.name + " / " + str(self.condition)

class ERModel(object):

"""Model of a scheduler."""

def __init__(self):

pass

def isEmpty(self):

"""Returns True if there are patients in the model

or False otherwise."""

return True

def schedule(self, p):

"""Adds a patient to the schedule."""

pass

def treatNext(self):

"""Returns the patient treated or None if there are none."""

return None

what additional info? Can't just slap needs additional info without asking for specifics.

Complete the emergency room scheduler application as described in the case study. In the ERModel class of the ermodel.py file complete the following: 1. Complete the implementation of the _init_ method. 2. Complete the implementation of the isEmpty() method. o Returns True if there are patients in the model or False otherwise. 3. Complete the implementation of the schedule() method. o Adds a patient to the schedule. 4. Complete the implementation of the treatNext() method. o Returns the patient treated or None if there are none. In the LinkedQueue class of the linkedqueue.py file complete the following: 1. Complete the implementation of the _iter_ method. o Supports iteration over a view of self. 2. Complete the implementation of the clear() method. o Makes self become empty. To test your program run the main() method in the erapp.py file. File: linkedpriorityqueue.py from node import Node from linkedqueue import LinkedQueue class LinkedPriorityQueue (LinkedQueue): ****"A link-based priority queue implementation. def __init__(self, sourceCollection None): ** Sets the initial state of self, which includes the contents of sourceCollection, if it's present." LinkedQueue. __init__(self, sourceCollection) def add(self, item): ***"Adds item to its proper place in the queue.' if self.isEmpty() or item >= self.rear.data: LinkedQueue.add(self, item) else: probe = self.front trailer = None while item >= probe. data: trailer = probe probe - probe.next newNode = Node(item, probe) if trailer is None: self.front = newNode else: trailer.next = newNode self.size += 1 File: erapp.py Author: Ken Lambert A terminal-based view for an emergency room scheduler. from ermodel import ERModel, Patient, Condition class ErView(object): **"The view class for the ER application.' def __init__(self, model): self.model = model menu = 2 def run(self): "Menu-driven command loop for the app. "Main menu " + 1 Schedule a patient " + Treat the next patient " + 1 3 Treat all patients " \ Exit the program ". while True: command self.getCommand(4, menu) if command == 1: self.schedule() elif command == 2: self. treatNext() elif command == 3: self. treatAll() else: break 4 def treatNext(self): ***"Treats one patient if there is one. if self.model.isEmpty(): print("No patients available to treat.") else: patient = self.model.treatNext() print(patient, "is being treated.") def treatAll(self): "*"Treats all the remaining patients. if self.model.isEmpty(): print("No patients available to treat.") else: while not self.model.isEmpty(): self. treatNext() name = def schedule(self): "Obtains patient info and schedules patient. input(" Enter the patient's name: ") condition = self.getCondition() self.model. schedule(Patient(name, condition)) print(name, "is added to the", condition, "list ") menu = def getCondition(self): "Obtains condition info.' "Patient's condition: " + 1 1 Critical " + 2 Serious " + 3 Fair " number self.getCommand (3, menu) return Condition (number) error = def getCommand(self, high, menu): *** Obtains and returns a command number. prompt = "Enter a number [1-" + str(high) + "]: commandRange list(map(str, range(1, high + 1))) "Error, number must be 1 to + str(high) while True: print(menu) command = input (prompt) if command in commandRange: return int(command) else: print(error) # Main function to start up the application def main(): model ERModel() view = ERView(model) view.run() _main__": if __name main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

use the equation: n = 2 C ( Dt / pi ) ^ 1 / 2

Answered: 1 week ago