Question: Purpose: This Windows application determines which patients have a systolic blood pressure reading that is considered too high. Program Procedures: In a Windows application, a

Purpose:
This Windows application determines which patients have a systolic blood pressure reading that is considered too high.
Program Procedures:
In a Windows application, a text file of patient information named patient.txt is opened. The patients who have a systolic reading above 120 are written to a second text file named consult .txt for consultation. The systolic reading is the first number in blood pressure results.
Algorithms, Processing, and Conditions:
Each day, a text file named patient.txt is opened from the USB drive. The patient.txt file contains patient names, ID numbers, and systolic blood pressure results from a lab.
An opening graphic and title are displayed on the Windows Form object.
A File menu includes options to Display Patient Information, Clear, and Exit. Selecting the Display Patient Information option displays the contents of the patient.txt file on a second Windows Form object.
The patient names and systolic blood pressure levels are assigned to an array that holds 16 elements each.
Blood pressure systolic levels are tested to check whether the systolic number is above the value 120.
All patients who have a systolic level above 120 have their names and systolic results written to a text file named consult.txt on the USB drive. A nurse will contact these patients for further evaluation.
The program displays the number of patients who had a systolic level above 120 and the average systolic value of todays patients.
My code:
Imports System.IO
Public Class BloodPressure
Private Sub PatientDataToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PatientDataToolStripMenuItem.Click
Dim patientDataForm As New PatientData()
patientDataForm.Show()
End Sub
Private Sub ClearMenuItem_Click(sender As Object, e As EventArgs) Handles ClearToolStripMenuItem.Click
End Sub
Private Sub ExitMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
End Class
Imports System.IO
Public Class PatientData
Private patientFNames(15) As String
Private patientLName(15) As String
Private patientId(15) As Integer
Private systolicValues(15) As Integer
Private patientCount As Integer =0
Private Sub PatientData_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim lines As String()= File.ReadAllLines("D:\patient.txt")
For i As Integer =0 To Math.Min(lines.Length -1,16)
Dim parts As String()= lines(i).Split(","c)
If parts.Length >=4 Then
patientFNames(i)= parts(0).Trim()
patientLName(i)= parts(1).Trim()
patientId(i)= Integer.Parse(parts(2).Trim())
systolicValues(i)= Integer.Parse(parts(3).Split("/"c)(0).Trim())
patientCount +=1
End If
Next
DisplayPatientData()
Catch ex As Exception
MessageBox.Show("Error loading patient data: " & ex.Message)
End Try
End Sub
Private Sub DisplayPatientData()
Dim highSystolicCount As Integer =0
Dim totalSystolic As Integer =0
Dim consultList As New List(Of String)()
For i As Integer =0 To patientFNames.Length -1
If String.IsNullOrEmpty(patientFNames(i)) OrElse String.IsNullOrEmpty(patientLName(i)) Then Continue For
If systolicValues(i)>120 Then
consultList.Add($"{patientFNames(i)}{patientLName(i)}-{systolicValues(i)}")
highSystolicCount +=1
End If
totalSystolic += systolicValues(i)
Next
File.WriteAllLines("D:\consult.txt", consultList)
lstName.Items.AddRange(consultList.ToArray())
lblHighCount.Text = $"High Systolic Patients: {highSystolicCount}"
lblAVGSystolic.Text = $"Average Systolic: {totalSystolic / Math.Max(1, patientFNames.Length):F2}"
End Sub
End Class

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!