Question: Develop a system in MIPS assembly to efficiently store, manage, and retrieve medical test data for individual patients. This system acts as a basic patient

Develop a system in MIPS assembly to efficiently store, manage, and retrieve medical test data for
individual patients. This system acts as a basic patient record management system focusing on test
results.
File Format:
The medical test will be stored in text file. Each line in the text file represents a single medical test. The
representation will include fields for:
Patient ID (integer: 7 digits)
Test name (string - consider a fixed length)
Test date (string - fixed format like YYYY-MM)
Result (floating-point value)
For example, the following file has two medical tests:
1300500: RBC,2024-03,13.5
1300511: LDL,2024-03,110
Medical Tests:
Below is the list of medical tests with their normal range:
1. Hemoglobin (Hgb): 13.8 to 17.2 grams per deciliter
2. Blood Glucose Test (BGT): Normal Range Between 70 to 99 milligrams per deciliter (mg/dL)
3. LDL Cholesterol Low-Density Lipoprotein (LDL): Normal Range Less than 100 mg/dL
4. Blood Pressure Test (BPT): Normal Range: Systolic Blood Pressure: Less than 120 millimeters of
mercury (mm Hg). Diastolic Blood Pressure: Less than 80 mm Hg
System Functionality:
Develop a text-based menu that allows users to:
Add a new medical test: the system will allow the user to store a new medical test with the
required data. The system will check the validity of the input data.
Search for a test by patient ID: the system will have the following functionality based on user
selection:
Retrieve all patient tests
Retrieve all up normal patient tests
Retrieve all patient tests in a given specific period
Searching for unnormal tests: the system will retrieve all up normal patients tests based on the
input medical test.
Average test value: the system will retrieve the average value of each medical test
Update an existing test result
Delete a test
In addition to the above functionality, the system has capability for:
Error Handling: Implement error handling for invalid file name, searching for non-existent tests,
searching for non-existent patient, ....
Data Validation: Validate user input to ensure proper data types (e.g., integers for ID, valid
dates) and handle potential errors. and this is my code .data
# Define data structures
test_struct: .space 32 # Assuming each test takes 32 bytes (7 for ID,10 for name, 7 for date, 8 for result)
test_count: .word 0
patient_ids: .space 4000 # Array to store patient IDs (1000*4 bytes per ID)
test_names: .space 10000 # Array to store test names (1000*10 bytes per name)
test_dates: .space 7000 # Array to store test dates (1000*7 bytes per date, assuming YYYY-MM format)
test_results: .space 8000 # Array to store test results (1000*8 bytes per result, assuming float)
buffer: .space 512
# Define constants for normal ranges
Hgb_min: .float 13.8
Hgb_max: .float 17.2
BGT_min: .float 70
BGT_max: .float 99
LDL_max: .float 100
BPT_systolic_max: .float 120
BPT_diastolic_max: .float 80
# Define constants for menu options
add_option: .asciiz "1. Add a new medical test
"
search_option: .asciiz "2. Search for a test by patient ID
"
average_option: .asciiz "3. Average test value
"
update_option: .asciiz "4. Update an existing test result
"
delete_option: .asciiz "5. Delete a test
"
exit_option: .asciiz "6. Exit
"
menu_prompt: .asciiz "Enter your choice: "
filename: .asciiz "test.txt"
# Prompts for user input
prompt_patient_id: .asciiz "
Enter Patient ID (7 digits):
"
prompt_test_name: .asciiz "
Enter Test Name:
"
prompt_test_date: .asciiz "
Enter Test Date (YYYY-MM):
"
prompt_result: .asciiz "
Enter Test Result:
"
invalid_patient_id_message: .asciiz "Invalid patient ID. Please enter exactly 7 digits.
"
invalid_test_name_message: .asciiz "Invalid test name. Please enter a name of 4 characters or less.
"
invalid_test_date_message: .asciiz "Invalid test date format. Please enter date in YYYY-MM format.
"
invalid_test_result_message: .asciiz "Invalid test result. Please enter a valid numerical value.
"
# Variables to store user input
user_patient_id: .space 8 # Buffer to store patient ID
user_test_name: .space 4 # Buffer to store test name
user_test_date: .space 8 # Buffer to store test date
user_result: .space 5 # Buffer to store test result
.text
main:
# Display menu
li $v0,4
la $a0, add_option
syscall
li $v0,4
la $a0, search_option
syscall
li $v0,4
la $a0, average_option
syscall
li $v0,4
la $a0, update_option
syscall
li $v0,4
la $a0, delete_option
syscall
li $v0,4
la $a0, exit_option
syscall
li $v0,4
la $a0, menu_prompt
syscall
# Get user input for menu option
li $v0,5
syscall
move $t0, $v0 # Store user choice in $t0
# Branch to corresponding function based on user choice
beq $t0,1, add_test
beq $t0,2, search_test
beq $t0,3, ave i need the completeion for all functions like search and delete and updtate and avg

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!