Skip to content

Instantly share code, notes, and snippets.

@halcwb
halcwb / Ollama.fsx
Last active March 7, 2024 09:29
Experimenting with Ollama
#r "nuget: Newtonsoft.Json"
/// Utility methods to use ollama
/// https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion
module Ollama =
open System
@halcwb
halcwb / CalcPELOD2Score.vb
Created September 4, 2023 07:09
Calculate the PELOD-2 score
Sub Main
End Sub
' Define other methods and classes here
Public Function CalcPELOD2Score(intGCS As Integer, strPupil As String, dblLactate As Double, intMAP As Integer,
intMos As Integer, dblCreat As Double, intPaO2 As Integer, intFiO2 As Integer,
intPaCO2 As Integer, blnVent As Boolean, intWBC As Integer, intPlatelets As Integer) As Integer
Dim intScore As Integer = 0
@halcwb
halcwb / CalcPedSOFAScore.vb
Created September 4, 2023 07:07
Calculate the Pediatric SOFA score
Sub Main
End Sub
' This function, CalculatePedSOFAScore, calculates the Pediatric Sequential Organ Failure Assessment (pSOFA) score for a child based on various physiological parameters.
' The pSOFA score is used to assess the extent of organ dysfunction in critically ill patients.
'
' The function takes several parameters including the age of the child in months, partial pressure of oxygen to fraction of inspired oxygen (PaO2/FiO2),
' saturation of peripheral oxygen to fraction of inspired oxygen (SpO2/FiO2), platelet count, bilirubin, mean arterial pressure (MAP),
' rates of infusion of various vasoactive drugs (Dopamine, Dobutamine, Epinephrine, Norepinephrine), Glasgow Coma Scale (GCS), and Creatinine.
@halcwb
halcwb / CalculateSOFAScore.vb
Created September 4, 2023 07:06
Calculate the SOFA score
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).
@halcwb
halcwb / CalculateSOFAScore.vb
Created September 4, 2023 07:06
Calculate the SOFA score
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).
@halcwb
halcwb / FixPrecision.fsx
Created August 27, 2023 07:14
Makes a floating point number "readable"
/// <summary>
/// Fixes the precision of a double number.
/// </summary>
/// <param name="dblNum">The double number to fix the precision of.</param>
/// <param name="intPrec">The desired precision.</param>
/// <returns>The double number with the fixed precision.</returns>
let fixPrecision (dblNum: double) (intPrec: int) : double =
let strNum = dblNum.ToString("F99", CultureInfo.InvariantCulture)
let colNum = List.ofArray (strNum.Split('.'))
let strN, strD =
@halcwb
halcwb / CalcAaDO2.vb
Created July 27, 2023 22:07
Calculate the Alveolar Arterial Oxygen Difference
Sub Main
Console.WriteLine(CalcAaDO2(50, 60, 80))
End Sub
' Calculate the Alveolar Arterial Oxygen Difference. Returns -1 if calculation not possible
' AaDO2 = (713 * FiO2) - (PaCO2 / 0.8) - PaO2
Function CalcAaDO2(dblPaCO2 As Double, dblPaO2 As Double, dblFiO2 As Double) As Double
Dim dblRatio As Double = -1
If dblFiO2 > 1 Then dblFiO2 = dblFiO2 / 100
@halcwb
halcwb / CalcArterialAlveolarRatio.vb
Last active July 27, 2023 22:06
Calculate the a/A ratio
Sub Main
Console.WriteLine(CalcArterialAlveolarRatio(50, 60, 80))
End Sub
' Calculate the a/A ratio. Returns -1 if calculation not possible
' aARatio = 100 * PaO2 / (713 * FiO2 - PaCO2)
Function CalcArterialAlveolarRatio(dblPaCO2 As Double, dblPaO2 As Double, dblFiO2 As Double) As Double
Dim dblRatio As Double = -1
If dblFiO2 > 1 Then dblFiO2 = dblFiO2 / 100
@halcwb
halcwb / CalcVentilationIndex.vb
Created July 27, 2023 21:56
Calculate the ventilation index
Sub Main
Console.WriteLine(CalcVentilationIndex(50, 25, 10, 15))
End Sub
' Calculate the ventilation index. Returns -1 if calculation not possible
' VI = (PaCO2 * (PIP - PEEP) * rate) / 1000
Function CalcVentilationIndex(dblPaCO2 As Double, dblPIP As Double, dblPEEP As Double, intRate As Integer) As Double
Dim dblVI As Double = -1
If dblPaCO2 > 0 And dblPIP > 0 And dblPEEP > 0 And intRate > 0 Then
@halcwb
halcwb / CalcOI.vb
Created July 27, 2023 21:51
Calculate the oxygenation index
Sub Main
Console.WriteLine(CalcOI(12, 80, 60))
Console.WriteLine(CalcOI(12, 0.8, 60))
End Sub
' Calculate the oxygenation index. Returns -1 if calculation not possible
' OI = (MAP * FiO2 * 100) / PaO2
Function CalcOI(dblMAP As Double, dblFiO2 As Double, dblPaO2 As Double) As Double
Dim dblOI As Double = -1