Patient Blood Pressure Report This Windows application determines which patients
ID: 3588695 • Letter: P
Question
Patient Blood Pressure Report This Windows application determines which patients have a systolic blood pressure reading that is considered too high. 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. 1. 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. 2. An opening graphic and title are displayed on the Windows Form object. 3. 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. 4. The patient names and systolic blood pressure levels are assigned to an array that holds 16 elements each. 5. Blood pressure systolic levels are tested to check whether the systolic number is above the value 120. 6. 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. 7. The program displays the number of patients who had a systolic level above 120 and the average systolic value of today’s patients. The programming language is VB.net. Any amount of time needed is more than okay. I appreciate the help. The assignment isnt due unitl this saturday at midnight.
Explanation / Answer
PatientInfo.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmPatientInfo
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.lstDocument = New System.Windows.Forms.ListBox()
Me.btnReturn = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'lstDocument
'
Me.lstDocument.FormattingEnabled = True
Me.lstDocument.ItemHeight = 21
Me.lstDocument.Location = New System.Drawing.Point(13, 15)
Me.lstDocument.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.lstDocument.Name = "lstDocument"
Me.lstDocument.Size = New System.Drawing.Size(351, 445)
Me.lstDocument.TabIndex = 0
'
'btnReturn
'
Me.btnReturn.BackColor = System.Drawing.Color.White
Me.btnReturn.Font = New System.Drawing.Font("Gill Sans MT", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnReturn.Location = New System.Drawing.Point(132, 470)
Me.btnReturn.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.btnReturn.Name = "btnReturn"
Me.btnReturn.Size = New System.Drawing.Size(112, 48)
Me.btnReturn.TabIndex = 1
Me.btnReturn.Text = "Done"
Me.btnReturn.UseVisualStyleBackColor = False
'
'frmPatientInfo
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 21.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(376, 539)
Me.Controls.Add(Me.btnReturn)
Me.Controls.Add(Me.lstDocument)
Me.Font = New System.Drawing.Font("Gill Sans MT", 11.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ForeColor = System.Drawing.Color.LightCoral
Me.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.Name = "frmPatientInfo"
Me.Text = "Patient Infomation"
Me.ResumeLayout(False)
End Sub
Friend WithEvents lstDocument As ListBox
Friend WithEvents btnReturn As Button
End Class
PatientInfo.vb
Public Class frmPatientInfo
Private Sub btnReturn_Click(sender As Object, e As EventArgs) Handles btnReturn.Click
'closes the form window
Me.Close()
frmBloodPressureReport.Show()
End Sub
Private Sub frmPatientInfo_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'write the patient.txt info into lstDocument
Dim intI As Integer = 0
For Each strItem In frmBloodPressureReport._StrPatientName
lstDocument.Items.Add(strItem) 'Name
lstDocument.Items.Add(frmBloodPressureReport._intLevels(intI)) 'Levels
intI += 1
Next
End Sub
End Class
frmBloodPressureReport.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmBloodPressureReport
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.lblTitle = New System.Windows.Forms.Label()
Me.mnuMenu = New System.Windows.Forms.MenuStrip()
Me.FileToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.DisplayPatientInformationToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ClearToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.ExitToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem()
Me.lblPatientAmount = New System.Windows.Forms.Label()
Me.lblAverageLevels = New System.Windows.Forms.Label()
Me.picGraphic = New System.Windows.Forms.PictureBox()
Me.btnDisplay = New System.Windows.Forms.Button()
Me.mnuMenu.SuspendLayout()
CType(Me.picGraphic, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'lblTitle
'
Me.lblTitle.AutoSize = True
Me.lblTitle.Font = New System.Drawing.Font("Gill Sans MT", 20.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTitle.ForeColor = System.Drawing.Color.LightCoral
Me.lblTitle.Location = New System.Drawing.Point(315, 29)
Me.lblTitle.Margin = New System.Windows.Forms.Padding(6, 0, 6, 0)
Me.lblTitle.Name = "lblTitle"
Me.lblTitle.Size = New System.Drawing.Size(407, 38)
Me.lblTitle.TabIndex = 0
Me.lblTitle.Text = "Patient Blood Pressure Report"
'
'mnuMenu
'
Me.mnuMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.FileToolStripMenuItem})
Me.mnuMenu.Location = New System.Drawing.Point(0, 0)
Me.mnuMenu.Name = "mnuMenu"
Me.mnuMenu.Size = New System.Drawing.Size(740, 24)
Me.mnuMenu.TabIndex = 2
Me.mnuMenu.Text = "MenuStrip1"
'
'FileToolStripMenuItem
'
Me.FileToolStripMenuItem.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.DisplayPatientInformationToolStripMenuItem, Me.ClearToolStripMenuItem, Me.ExitToolStripMenuItem})
Me.FileToolStripMenuItem.Name = "FileToolStripMenuItem"
Me.FileToolStripMenuItem.Size = New System.Drawing.Size(37, 20)
Me.FileToolStripMenuItem.Text = "File"
'
'DisplayPatientInformationToolStripMenuItem
'
Me.DisplayPatientInformationToolStripMenuItem.Name = "DisplayPatientInformationToolStripMenuItem"
Me.DisplayPatientInformationToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
Me.DisplayPatientInformationToolStripMenuItem.Text = "Display Patient Information"
'
'ClearToolStripMenuItem
'
Me.ClearToolStripMenuItem.Name = "ClearToolStripMenuItem"
Me.ClearToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
Me.ClearToolStripMenuItem.Text = "Clear"
'
'ExitToolStripMenuItem
'
Me.ExitToolStripMenuItem.Name = "ExitToolStripMenuItem"
Me.ExitToolStripMenuItem.Size = New System.Drawing.Size(218, 22)
Me.ExitToolStripMenuItem.Text = "Exit"
'
'lblPatientAmount
'
Me.lblPatientAmount.AutoSize = True
Me.lblPatientAmount.Location = New System.Drawing.Point(379, 106)
Me.lblPatientAmount.Name = "lblPatientAmount"
Me.lblPatientAmount.Size = New System.Drawing.Size(279, 27)
Me.lblPatientAmount.TabIndex = 3
Me.lblPatientAmount.Text = " Patients with >120 Levels: XX"
'
'lblAverageLevels
'
Me.lblAverageLevels.AutoSize = True
Me.lblAverageLevels.Location = New System.Drawing.Point(417, 168)
Me.lblAverageLevels.Name = "lblAverageLevels"
Me.lblAverageLevels.Size = New System.Drawing.Size(201, 27)
Me.lblAverageLevels.TabIndex = 4
Me.lblAverageLevels.Text = "Average Levels: XXX"
'
'picGraphic
'
Me.picGraphic.Image = Global.BloodPressureReport.My.Resources.Resources.shutterstock_369988844_double_brain_opener
Me.picGraphic.Location = New System.Drawing.Point(12, 29)
Me.picGraphic.Name = "picGraphic"
Me.picGraphic.Size = New System.Drawing.Size(271, 280)
Me.picGraphic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picGraphic.TabIndex = 1
Me.picGraphic.TabStop = False
'
'btnDisplay
'
Me.btnDisplay.ForeColor = System.Drawing.Color.IndianRed
Me.btnDisplay.Location = New System.Drawing.Point(422, 231)
Me.btnDisplay.Name = "btnDisplay"
Me.btnDisplay.Size = New System.Drawing.Size(196, 43)
Me.btnDisplay.TabIndex = 5
Me.btnDisplay.Text = "Display Results"
Me.btnDisplay.UseVisualStyleBackColor = True
'
'frmBloodPressureReport
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(12.0!, 27.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(740, 321)
Me.Controls.Add(Me.btnDisplay)
Me.Controls.Add(Me.lblAverageLevels)
Me.Controls.Add(Me.lblPatientAmount)
Me.Controls.Add(Me.picGraphic)
Me.Controls.Add(Me.lblTitle)
Me.Controls.Add(Me.mnuMenu)
Me.Font = New System.Drawing.Font("Gill Sans MT", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.MainMenuStrip = Me.mnuMenu
Me.Margin = New System.Windows.Forms.Padding(6)
Me.Name = "frmBloodPressureReport"
Me.Text = "Blood Pressure Report"
Me.mnuMenu.ResumeLayout(False)
Me.mnuMenu.PerformLayout()
CType(Me.picGraphic, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents lblTitle As Label
Friend WithEvents picGraphic As PictureBox
Friend WithEvents mnuMenu As MenuStrip
Friend WithEvents FileToolStripMenuItem As ToolStripMenuItem
Friend WithEvents DisplayPatientInformationToolStripMenuItem As ToolStripMenuItem
Friend WithEvents ClearToolStripMenuItem As ToolStripMenuItem
Friend WithEvents ExitToolStripMenuItem As ToolStripMenuItem
Friend WithEvents lblPatientAmount As Label
Friend WithEvents lblAverageLevels As Label
Friend WithEvents btnDisplay As Button
End Class
frmBloodPressureReport.vb
Public Class frmBloodPressureReport
Public Shared _intArraySize As Integer = 15
Public Shared _StrPatientName(_intArraySize) As String
Public Shared _intLevels(_intArraySize) As Integer
Private _intAmountofPatients As Integer
Private _intAverageLevels As Integer
Private _strHighLevels(1, _intArraySize) As String
Private Sub ExitToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExitToolStripMenuItem.Click
'Closes the windows and exits the program
Application.Exit()
End Sub
Private Sub ClearToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ClearToolStripMenuItem.Click
'Clears the average and number of people with high levels labels
lblAverageLevels.Text = ""
lblPatientAmount.Text = ""
End Sub
Private Sub DisplayPatientInformationToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DisplayPatientInformationToolStripMenuItem.Click
'Opens a seperate window with the contents of the patients.txt file
Dim frmInfo As New frmPatientInfo
Me.Hide()
frmInfo.ShowDialog()
End Sub
Private Sub frmBloodPressureReport_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'Clears the labels for amount of people and average levels
'Opens patients.txt and scans its contents for patients with >120 systolic levels
'Writes consult.txt with patient name and systolic levels for patients with >120 levels
Dim objPatients As IO.StreamReader
Dim objConsults As New IO.StreamWriter("consult.txt")
Dim strFileName As String = "patient.txt"
Dim intI As Integer
'Verify File existance and read from it, closing it when done
If IO.File.Exists(strFileName) Then
objPatients = IO.File.OpenText(strFileName)
'read and store contents of the file
Do While objPatients.Peek <> -1
Try
_StrPatientName(intI) = objPatients.ReadLine
_intLevels(intI) = Convert.ToInt32(objPatients.ReadLine)
Catch ex As Exception
MsgBox("Something went wrong reading the file: check file format.",, "Error")
End Try
intI += 1
Loop
objPatients.Close()
Else
MsgBox("Could not locate patient information file. Restart when file is available",, "Error")
Close()
End If
'Store high >120 patient names and levels
Calculate()
'write to consult.txt
For intI = 0 To (_intAmountofPatients - 1)
If IO.File.Exists("consult.txt") Then
objConsults.WriteLine(_strHighLevels(0, intI)) 'Name
objConsults.WriteLine(_strHighLevels(1, intI)) 'Levels
Else
MsgBox("Could not locate consultation file. Restart when file is available",, "Error")
Close()
End If
Next
objConsults.Close()
'clear labels
lblAverageLevels.Text = ""
lblPatientAmount.Text = ""
End Sub
Private Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click
'Displays the average and amount of people
lblAverageLevels.Text = "Average Levels: " & _intAverageLevels
lblPatientAmount.Text = " Patients with >120 Levels: " & _intAmountofPatients
End Sub
Private Sub Calculate()
'calculates the average Systolic levels from file and counts number of patients
Dim intI, intJ As Integer
intI = 0
intJ = 0
For Each intValue In _intLevels
'Store >120 values (name and level) into _strHighLevels(intI,IntJ)
If (intValue > 120) Then
_strHighLevels(0, intI) = _StrPatientName(intJ)
_strHighLevels(1, intI) = _intLevels(intJ).ToString
'Add to _intAmountofPatients and _average
_intAmountofPatients += 1
_intAverageLevels += intValue
intI += 1
End If
intJ += 1
Next
_intAverageLevels = _intAmountofPatients
'resize the Highlevels based on number of people with highlevels
ReDim Preserve _strHighLevels(1, _intAmountofPatients)
End Sub
End Class