Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction In this assessment, your goal is to implement a Python program to find out if a hospital has enough of the required blood type

Introduction
In this assessment, your goal is to implement a Python program to find out if a hospital
has enough of the required blood type in its blood bank for their patients.
Chapter 5(Branching) in the Runestone textbook will be helpful if you feel you are
missing something.
Problem
Blood Types in humans are determined by two antigens, A and B and an Rh factor which
is represented by + and -, resulting in a total of 8 different blood types:
O-, O+, A-, A+, B-, B+, AB-, AB+
If a person needs a transfusion, they have to get the blood from a selected group of blood
types, otherwise their antibodies will react and the patient will face a serious infection called
Acute Haemolytic Reaction which requires further intensive care for the patient.
To simplify the problem for this assignment, we will assume people can only receive
blood of their own type. If you are interested in learning more, please check The Red
Cross. (Note that we are interested in red cell transfusion)
Assume you work in a hospital and you are responsible for the IT infrastructure. You
noticed that the Emergency Room (ER) has some problems with their communication with
the blood bank. Occasionally, the ER needs specific blood types for patients and they have
to get the blood as soon as possible. However, when they call the blood bank, it takes a
long time to get a response from them.
Luckily you know how to implement and run a program in Python where you can use
lists, string inputs, and conditionals to create a program to address your needs!
We know that we have a main blood bank located inside the hospital. In shortages, we
have an agreement with a backup blood bank close to our hospital but we prefer to use the
main one due to speed and lower costs.
In our program, we need to know how much of each blood type is available in the pri-
mary and secondary blood banks, and to be able to conduct withdrawals of certain amounts.
After the withdrawal we need to report on the remain blood amounts, and warn if any are low.
The blood banks record their inventory information as integers in milliliters, with each
blood type preceding each blood amount.
Input
Your program must take four lines of inputs:
1. A string representing the current blood amounts (in milliliters) available in the primary
bank
2. A string representing the current blood amounts (in milliliters) available in the backup
bank
3. The required blood type from the ER
4. The required amount of blood (in ml) from the ER
Both of the first two inputs will contain the information in the following format, with
blood types and amounts separated by spaces:
O-10 O+5 A-80 A+90 B-60 B+70 AB-50 AB+20
Output
The number of lines your program must output will depend on the amount requested.
If the amount to withdraw exceeds the amount stored in the primary and backup banks,
your program should only report Error: Amount requested exceeds reserves.
If the amount can be withdrawn, subtract from the primary bank first. If the primary
bank is emptied, then subtract from the backup bank.
If the primary bank is left empty after the withdrawal, output Warning: Main reserve
depleted. Regardless, then output the amount of blood of the requested type left in the
main bank after the withdrawal with the format Main Level: .
If the backup bank is left empty after the withdrawal, output Warning: Backup reserve
depleted. Regardless, then output the amount of blood of the requested type left in the
backup bank after the withdrawal with the format Backup Level: .
Reflection
We are still learning some of the basics of programming, so the capabilities of programs
we can create are still fairly limited. Assuming we had the knowledge already, what are some
features we could add that would make this program far more useful in the field?
If multiple nurses and doctors in the same hospital are using our software simultaneously,
what problems might arise due to how weve structured this program?
Sample Executions
Example 1:
MAIN> O-10 O+5 A-80 A+90 B-60 B+70 AB-50 AB+20
BACKUP> O-0 O+20 A-70 A+60 B-30 B+50 AB-60 AB+10
TYPE> AB-
AMOUNT>70
OUTPUT Warning: Main reserve depleted
OUTPUT Main Level: 0
OUTPUT Backup Level: 40
Example 2:
MAIN> O-10 O+5 A-80 A+90 B-60 B+70 AB-50 AB+20
BACKUP> O-0 O+20 A-70 A+60 B-30 B+50 AB-60 AB+10
TYPE> O-
AMOUNT>10
OUTPUT Warning: Main reserve depleted
OUTPUT Main Level: 0
OUTPUT Warning: Backup reserve depleted
OUTPUT Backup Level: 0
Example 3:
MAIN> O-10 O+5 A-80 A+90 B-60 B+70 AB-50 AB+20
BACKUP> O-0 O+20 A-70 A+60 B-30 B+50 AB-60 AB+10
TYPE> O+
AMOUNT>30
OUTPUT Error: Amount requested exceeds reserves
Example 4:
MAIN> O-10 O+5 A-80 A+90 B-60 B+70 AB-50 AB+20
BACKUP> O-0 O+20 A-70 A+60 B-30 B+50 AB-60 AB+10
TYPE> A+
AMOUNT>20
OUTPUT Main Level: 70
OUTPUT Backup Level: 60

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

Personal role: This consists of service to family and friends.

Answered: 1 week ago