Created
September 4, 2023 07:06
-
-
Save halcwb/e1eb3141e01900f2a646cf7d6463380f to your computer and use it in GitHub Desktop.
Calculate the SOFA score
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub Main | |
Dim SOFAScore As Integer | |
SOFAScore = CalculateSOFAScore(350, 120, 14, 1.5, 75, 0, 0, 0.1, 0.1, 2.5, 600, True) | |
Console.WriteLine("SOFA Score: " & SOFAScore) | |
End Sub | |
' A function that calculates a SOFA score (Sequential Organ Failure Assessment) | |
' This function calculates the SOFA (Sequential Organ Failure Assessment) score based on various parameters. | |
' The SOFA score is used to assess the extent of a person's organ function or rate of failure in the ICU (Intensive Care Unit). | |
' Parameters include PaO2/FiO2, Platelets count, Glasgow Coma Scale, Bilirubin, Mean Arterial Pressure (MAP), | |
' doses of vasoactive agents (Dopamine, Dobutamine, Epinephrine, Norepinephrine), Creatinine, and Urine Output | |
Function CalculateSOFAScore(intPAF As Integer, intPlatelets As Integer, intGCS As Integer, dblBili As Double, intMAP As Integer, dblDopa As Double, dblDobu As Double, dblEpi As Double, dblNor As Double, dblCreat As Double, intUrine As Integer, blnVent As Boolean) As Integer | |
Dim intScore As Integer = 0 | |
Const dblCreatToMicroMolePerLiter As Double = 88.42 | |
If dblCreat <> -1 Then dblCreat = dblCreat / dblCreatToMicroMolePerLiter | |
Const dblBiliToMicroMolePerLiter As Double = 17.104 | |
If dblBili <> -1 Then dblBili = dblBili / dblBiliToMicroMolePerLiter | |
'PaO2/FiO2 | |
Select Case intPAF | |
Case Is >= 400 | |
intScore += 0 | |
Case 300 To 399 | |
intScore += 1 | |
Case 200 To 299 | |
intScore += 2 | |
Case 100 To 199 | |
If blnVent Then intScore += 3 Else intScore += 2 | |
Case Is < 100 | |
If blnVent Then intScore += 4 Else intScore += 2 | |
End Select | |
'Platelets | |
Select Case intPlatelets | |
Case Is >= 150 | |
intScore += 0 | |
Case 100 To 149 | |
intScore += 1 | |
Case 50 To 99 | |
intScore += 2 | |
Case 20 To 49 | |
intScore += 3 | |
Case Is < 20 | |
intScore += 4 | |
End Select | |
'Glasgow Coma Scale | |
Select Case intGCS | |
Case 15 | |
intScore += 0 | |
Case 13 To 14 | |
intScore += 1 | |
Case 10 To 12 | |
intScore += 2 | |
Case 6 To 9 | |
intScore += 3 | |
Case Is < 6 | |
intScore += 4 | |
End Select | |
'Bilirubin | |
Select Case dblBili | |
Case Is < 1.2 | |
intScore += 0 | |
Case 1.2 To 1.9 | |
intScore += 1 | |
Case 2.0 To 5.9 | |
intScore += 2 | |
Case 6.0 To 11.9 | |
intScore += 3 | |
Case Is >= 12.0 | |
intScore += 4 | |
End Select | |
'MAP or Vasoactive Agents | |
If intMAP < 70 Then | |
intScore += 1 | |
ElseIf dblDopa > 0 Or dblDobu > 0 Then | |
If dblDopa <= 5 Or dblDobu > 0 Then | |
intScore += 2 | |
ElseIf dblDopa > 5 And dblDopa <= 15 Or dblEpi <= 0.1 Or dblNor <= 0.1 Then | |
intScore += 3 | |
ElseIf dblDopa > 15 Or dblEpi > 0.1 Or dblNor > 0.1 Then | |
intScore += 4 | |
End If | |
End If | |
'Creatinine or UOP | |
Select Case dblCreat | |
Case Is < 1.2 | |
intScore += 0 | |
Case 1.2 To 1.9 | |
intScore += 1 | |
Case 2.0 To 3.4 | |
intScore += 2 | |
Case 3.5 To 4.9 | |
intScore += 3 | |
Case Is >= 5.0 | |
intScore += 4 | |
End Select | |
If intUrine < 500 Then | |
If intUrine < 200 Then | |
intScore += 4 | |
Else | |
intScore += 3 | |
End If | |
End If | |
Return intScore | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment