module JosieHealth::LUT

Defined in:

alcohol_lut.cr
caffeine_lut.cr
cannabis_lut.cr
data_analysis.cr
data_files.cr
drug_lut.cr
fuzzy.cr
josie-health-lut.cr
meds_lut.cr
vitals_tracker.cr

Constant Summary

VERSION = "0.1.0"
VITAL_RANGES = {"pulse" => {"normal_min" => 60, "normal_max" => 100, "concerning_low" => 50, "concerning_high" => 120, "critical_low" => 40, "critical_high" => 150}, "systolic_bp" => {"normal_min" => 90, "normal_max" => 120, "concerning_low" => 80, "concerning_high" => 140, "critical_low" => 70, "critical_high" => 180}, "diastolic_bp" => {"normal_min" => 60, "normal_max" => 80, "concerning_low" => 50, "concerning_high" => 90, "critical_low" => 40, "critical_high" => 120}, "blood_oxygen" => {"normal_min" => 95, "normal_max" => 100, "concerning_low" => 90, "concerning_high" => 100, "critical_low" => 85, "critical_high" => 100}}

Vital signs ranges based on medical standards

Class Method Summary

Class Method Detail

def self.all_substances : Array(String) #

Get all canonical substance names


def self.calculate_alcohol_dose(dosage : String, substance : String, abv_override : Float64 | Nil = nil) #

Calculate alcohol dose from dosage string and substance


def self.calculate_alcohol_grams(volume_ml : Float64, abv_percent : Float64) : Float64 #

Calculate alcohol grams from volume and ABV


def self.calculate_caffeine_dose(dosage : String, substance : String) #

Calculate caffeine dose from dosage string and substance


def self.calculate_cannabis_dose(dosage : String, source : String) #

Calculate cannabis dose from dosage string and source


def self.calculate_meds_dose(substance : String, dosage : String, unit : String) #

Calculate medication dose from ml to mg Supports @concentration syntax (e.g., "een@20" for 20mg/ml)


def self.export_mappings : String #

Export all mappings as JSON for diffing/migration purposes Returns a hash with alias -> canonical for both substances and routes


def self.fuzzy_normalize_route(input : String) : FuzzyResult | Nil #

Fuzzy route normalization (exact match first, then Damerau-Levenshtein)


def self.fuzzy_normalize_substance(input : String) : FuzzyResult | Nil #

Fuzzy substance normalization (exact match first, then Damerau-Levenshtein)


def self.get_aliases(canonical_name : String) : Array(String) #

Get all known aliases for a substance


def self.is_alcohol?(name : String) : Bool #

Check if a substance is an alcoholic beverage


def self.is_caffeine_source?(name : String) : Bool #

Check if a substance is a caffeinated beverage/product


def self.is_cannabis_source?(name : String) : Bool #

Check if a substance is a cannabis source


def self.is_injectable_med?(name : String) : Bool #

Check if a substance is an injectable medication


def self.known_substance?(input : String) : Bool #

Check if a substance is known


def self.lookup_alcohol(name : String) #

Look up an alcoholic beverage by brand name


def self.lookup_caffeine(name : String) #

Look up a caffeinated product by brand name


def self.lookup_caffeine_powder_mg_per_g(name : String) : Int32 | Nil #

Lookup caffeine mg per gram for powder sources (e.g., matcha)


def self.lookup_cannabis(name : String) #

Look up a cannabis source by name (joint, cart, bowl, etc.)


def self.lookup_medication(name : String) #

Look up an injectable medication by name


def self.normalize_route(input : String) : String | Nil #

Normalize route of administration


def self.normalize_substance(input : String) : String | Nil #

Main entry point for drug normalization


def self.parse_alcohol_dosage(dosage : String) #

Parse dosage string for alcohol (e.g., "2pints", "500ml")


def self.parse_caffeine_dosage(dosage : String) #

Parse dosage string for caffeine (e.g., "2cans", "500ml", "2g")


def self.parse_cannabis_dosage(dosage : String) #

Parse dosage string for cannabis (e.g., "5puff", "1/3", "2hit")


def self.parse_meds_concentration(name : String) #

Parse substance name with optional concentration override


def self.substance_info(input : String) : NamedTuple(canonical_name: String | Nil, aliases: Array(String)) #

Get substance info with metadata