pub struct MedicalComputingLibrary { /* private fields */ }Expand description
Medical Computing Library Manager
Implementations§
Source§impl MedicalComputingLibrary
impl MedicalComputingLibrary
Sourcepub fn bmi(&self, weight_kg: f64, height_m: f64) -> Result<f64, MedicalError>
pub fn bmi(&self, weight_kg: f64, height_m: f64) -> Result<f64, MedicalError>
Body Mass Index (Quetelet index): BMI = weight_kg / height_m² (kg/m²).
Sourcepub fn bsa_mosteller(
&self,
weight_kg: f64,
height_cm: f64,
) -> Result<f64, MedicalError>
pub fn bsa_mosteller( &self, weight_kg: f64, height_cm: f64, ) -> Result<f64, MedicalError>
Body Surface Area, Mosteller formula (1987):
BSA (m²) = sqrt(height_cm × weight_kg / 3600).
Sourcepub fn bsa_du_bois(
&self,
weight_kg: f64,
height_cm: f64,
) -> Result<f64, MedicalError>
pub fn bsa_du_bois( &self, weight_kg: f64, height_cm: f64, ) -> Result<f64, MedicalError>
Body Surface Area, Du Bois & Du Bois formula (1916):
BSA (m²) = 0.007184 × weight_kg^0.425 × height_cm^0.725.
Sourcepub fn ideal_body_weight_devine(
&self,
height_cm: f64,
sex: Gender,
) -> Result<f64, MedicalError>
pub fn ideal_body_weight_devine( &self, height_cm: f64, sex: Gender, ) -> Result<f64, MedicalError>
Ideal Body Weight, Devine formula (1974). In kg: male = 50.0 + 2.3 × (height_inches − 60); female = 45.5 + 2.3 × (height_inches − 60); height_inches = height_cm / 2.54. Only defined for male/female (rejects Other/Unknown).
Sourcepub fn egfr_ckd_epi_2021(
&self,
scr_mg_dl: f64,
age_years: f64,
sex: Gender,
) -> Result<f64, MedicalError>
pub fn egfr_ckd_epi_2021( &self, scr_mg_dl: f64, age_years: f64, sex: Gender, ) -> Result<f64, MedicalError>
Estimated GFR, CKD-EPI 2021 creatinine equation (race-free), mL/min/1.73 m²:
eGFR = 142 × min(Scr/κ,1)^α × max(Scr/κ,1)^−1.200 × 0.9938^age × (1.012 if female)
with κ = 0.7 (female)/0.9 (male), α = −0.241 (female)/−0.302 (male).
scr_mg_dl = serum creatinine in mg/dL. Only defined for male/female.
Sourcepub fn egfr_mdrd(
&self,
scr_mg_dl: f64,
age_years: f64,
sex: Gender,
is_black: bool,
) -> Result<f64, MedicalError>
pub fn egfr_mdrd( &self, scr_mg_dl: f64, age_years: f64, sex: Gender, is_black: bool, ) -> Result<f64, MedicalError>
Estimated GFR, MDRD 4-variable equation (IDMS-traceable, 2006 coefficient
175), mL/min/1.73 m²:
eGFR = 175 × Scr^−1.154 × age^−0.203 × (0.742 if female) × (1.212 if Black).
scr_mg_dl = serum creatinine in mg/dL. Only defined for male/female.
Sourcepub fn creatinine_clearance_cockcroft_gault(
&self,
age_years: f64,
weight_kg: f64,
scr_mg_dl: f64,
sex: Gender,
) -> Result<f64, MedicalError>
pub fn creatinine_clearance_cockcroft_gault( &self, age_years: f64, weight_kg: f64, scr_mg_dl: f64, sex: Gender, ) -> Result<f64, MedicalError>
Creatinine clearance, Cockcroft-Gault equation (1976), mL/min:
CrCl = ((140 − age) × weight_kg × (0.85 if female)) / (72 × Scr_mg/dL).
Only defined for male/female.
Sourcepub fn mean_arterial_pressure(
&self,
systolic: f64,
diastolic: f64,
) -> Result<f64, MedicalError>
pub fn mean_arterial_pressure( &self, systolic: f64, diastolic: f64, ) -> Result<f64, MedicalError>
Mean Arterial Pressure (standard estimate): MAP = (SBP + 2·DBP) / 3 (mmHg).
Sourcepub fn anion_gap(&self, na: f64, cl: f64, hco3: f64) -> f64
pub fn anion_gap(&self, na: f64, cl: f64, hco3: f64) -> f64
Serum anion gap: AG = Na − (Cl + HCO3) (mEq/L). (Potassium excluded, the
common convention.)
Sourcepub fn corrected_calcium(
&self,
measured_ca_mg_dl: f64,
albumin_g_dl: f64,
) -> Result<f64, MedicalError>
pub fn corrected_calcium( &self, measured_ca_mg_dl: f64, albumin_g_dl: f64, ) -> Result<f64, MedicalError>
Albumin-corrected calcium (Payne 1973):
corrected = measured_ca_mg_dl + 0.8 × (4.0 − albumin_g_dl) (mg/dL).
Sourcepub fn winters_expected_pco2(&self, hco3: f64) -> Result<f64, MedicalError>
pub fn winters_expected_pco2(&self, hco3: f64) -> Result<f64, MedicalError>
Winter’s formula — expected PaCO₂ compensation for metabolic acidosis:
expected pCO2 = 1.5 × HCO3 + 8 (mmHg, ±2). Returns the point estimate.
Sourcepub fn cha2ds2_vasc_score(
&self,
congestive_heart_failure: bool,
hypertension: bool,
age_years: u32,
diabetes: bool,
prior_stroke_tia_or_thromboembolism: bool,
vascular_disease: bool,
sex: Gender,
) -> u8
pub fn cha2ds2_vasc_score( &self, congestive_heart_failure: bool, hypertension: bool, age_years: u32, diabetes: bool, prior_stroke_tia_or_thromboembolism: bool, vascular_disease: bool, sex: Gender, ) -> u8
CHA₂DS₂-VASc stroke-risk score (Lip 2010) as its deterministic point sum (0–9). This is the arithmetic score itself, NOT a risk/probability estimate (mapping the score to an annual stroke rate needs the validated cohort table, which is not shipped): CHF/LV dysfunction (1), hypertension (1), age ≥75 (2) or 65–74 (1), diabetes (1), prior stroke/TIA/thromboembolism (2), vascular disease (1), female sex (1).
Sourcepub fn weight_based_dose(
&self,
dose_per_kg: f64,
weight_kg: f64,
) -> Result<f64, MedicalError>
pub fn weight_based_dose( &self, dose_per_kg: f64, weight_kg: f64, ) -> Result<f64, MedicalError>
Weight-based dose: dose = dose_per_kg × weight_kg (units follow dose_per_kg).
Sourcepub fn giusti_hayton_adjusted_dose(
&self,
normal_dose: f64,
fraction_renally_excreted: f64,
crcl_patient: f64,
crcl_normal: f64,
) -> Result<f64, MedicalError>
pub fn giusti_hayton_adjusted_dose( &self, normal_dose: f64, fraction_renally_excreted: f64, crcl_patient: f64, crcl_normal: f64, ) -> Result<f64, MedicalError>
Renal dose adjustment, Giusti-Hayton method (1973):
Q = 1 − Fe × (1 − CrCl_patient / CrCl_normal);
adjusted_dose = normal_dose × Q. fraction_renally_excreted (Fe) ∈ [0,1]
is the fraction of drug eliminated unchanged by the kidney.
Sourcepub fn mg_to_mmol(
&self,
mg: f64,
molar_mass_g_per_mol: f64,
) -> Result<f64, MedicalError>
pub fn mg_to_mmol( &self, mg: f64, molar_mass_g_per_mol: f64, ) -> Result<f64, MedicalError>
Convert mass to amount of substance: mmol = mg / molar_mass_g_per_mol.
Sourcepub fn mmol_to_mg(
&self,
mmol: f64,
molar_mass_g_per_mol: f64,
) -> Result<f64, MedicalError>
pub fn mmol_to_mg( &self, mmol: f64, molar_mass_g_per_mol: f64, ) -> Result<f64, MedicalError>
Convert amount of substance to mass: mg = mmol × molar_mass_g_per_mol.
Sourcepub fn infusion_rate_ml_per_hr(
&self,
dose_per_kg_per_min: f64,
weight_kg: f64,
concentration_per_ml: f64,
) -> Result<f64, MedicalError>
pub fn infusion_rate_ml_per_hr( &self, dose_per_kg_per_min: f64, weight_kg: f64, concentration_per_ml: f64, ) -> Result<f64, MedicalError>
Continuous infusion rate (mL/hr) for a weight-based dose:
rate = (dose_per_kg_per_min × weight_kg × 60) / concentration_per_ml.
Units of dose_per_kg_per_min and concentration_per_ml must match
(e.g. µg/kg/min with µg/mL).
Sourcepub fn elimination_rate_constant(
&self,
half_life: f64,
) -> Result<f64, MedicalError>
pub fn elimination_rate_constant( &self, half_life: f64, ) -> Result<f64, MedicalError>
First-order elimination rate constant from half-life: k = ln(2) / t½.
Sourcepub fn half_life_from_rate_constant(
&self,
rate_constant: f64,
) -> Result<f64, MedicalError>
pub fn half_life_from_rate_constant( &self, rate_constant: f64, ) -> Result<f64, MedicalError>
Half-life from first-order rate constant: t½ = ln(2) / k.
Sourcepub fn clearance(
&self,
rate_constant: f64,
volume_of_distribution: f64,
) -> Result<f64, MedicalError>
pub fn clearance( &self, rate_constant: f64, volume_of_distribution: f64, ) -> Result<f64, MedicalError>
Drug clearance from first-order PK: CL = k × Vd.
Sourcepub fn volume_of_distribution(
&self,
dose: f64,
initial_concentration: f64,
) -> Result<f64, MedicalError>
pub fn volume_of_distribution( &self, dose: f64, initial_concentration: f64, ) -> Result<f64, MedicalError>
Apparent volume of distribution: Vd = dose / C0.
Sourcepub fn steady_state_concentration(
&self,
infusion_rate: f64,
clearance: f64,
) -> Result<f64, MedicalError>
pub fn steady_state_concentration( &self, infusion_rate: f64, clearance: f64, ) -> Result<f64, MedicalError>
Steady-state concentration under continuous infusion:
Css = infusion_rate / clearance.
Sourcepub fn summarize_cohort(
&self,
values: &[f64],
) -> Result<CohortSummary, MedicalError>
pub fn summarize_cohort( &self, values: &[f64], ) -> Result<CohortSummary, MedicalError>
Summarise a numeric cohort (e.g. a series of lab values). This is the only
statistical work here and it DELEGATES to crate::solvers::statistics
(descriptive::mean, descriptive::std_dev, descriptive::median_sorted).
Source§impl MedicalComputingLibrary
impl MedicalComputingLibrary
Sourcepub fn initialize(&mut self) -> Result<(), MedicalError>
pub fn initialize(&mut self) -> Result<(), MedicalError>
Initialize the library
Sourcepub fn create_patient_record(
&mut self,
patient: Patient,
) -> Result<MedicalOperationResult<Patient>, MedicalError>
pub fn create_patient_record( &mut self, patient: Patient, ) -> Result<MedicalOperationResult<Patient>, MedicalError>
Create a new patient record
Sourcepub fn analyze_clinical_data(
&mut self,
patient_id: &str,
data_type: ClinicalDataType,
) -> Result<MedicalOperationResult<ClinicalAnalysis>, MedicalError>
pub fn analyze_clinical_data( &mut self, patient_id: &str, data_type: ClinicalDataType, ) -> Result<MedicalOperationResult<ClinicalAnalysis>, MedicalError>
Analyze clinical data
Sourcepub fn analyze_differential(
&mut self,
observed_findings: &[String],
knowledge_base: &DiagnosticKnowledgeBase,
) -> Result<MedicalOperationResult<DifferentialProposal>, MedicalError>
pub fn analyze_differential( &mut self, observed_findings: &[String], knowledge_base: &DiagnosticKnowledgeBase, ) -> Result<MedicalOperationResult<DifferentialProposal>, MedicalError>
Real transparent Bayesian differential over a caller-supplied, non-authoritative
knowledge base. Returns a ranked epistemic proposal (never a diagnosis); the honest
label lives in DifferentialProposal::epistemic_status.
Sourcepub fn analyze_medical_image_grid(
&mut self,
data: &[f64],
width: usize,
height: usize,
bins: usize,
threshold: SegmentationThreshold,
window: Option<(f64, f64)>,
) -> Result<MedicalOperationResult<ImageAnalysisResult>, MedicalError>
pub fn analyze_medical_image_grid( &mut self, data: &[f64], width: usize, height: usize, bins: usize, threshold: SegmentationThreshold, window: Option<(f64, f64)>, ) -> Result<MedicalOperationResult<ImageAnalysisResult>, MedicalError>
Real 2-D DSP over a caller-provided intensity grid (statistics, histogram, window/level, threshold segmentation, Sobel edge magnitude). The result is honestly labeled signal processing, never a diagnosis.
Sourcepub fn process_medical_image(
&mut self,
image: MedicalImage,
processing_type: ImageProcessingType,
) -> Result<MedicalOperationResult<ProcessedImage>, MedicalError>
pub fn process_medical_image( &mut self, image: MedicalImage, processing_type: ImageProcessingType, ) -> Result<MedicalOperationResult<ProcessedImage>, MedicalError>
Process medical image
Sourcepub fn screen_compounds(
&mut self,
compounds: Vec<Compound>,
target: DrugTarget,
query_smiles: Option<&str>,
) -> Result<MedicalOperationResult<ScreeningProposal>, MedicalError>
pub fn screen_compounds( &mut self, compounds: Vec<Compound>, target: DrugTarget, query_smiles: Option<&str>, ) -> Result<MedicalOperationResult<ScreeningProposal>, MedicalError>
Screen compounds by rule-based filtering + Tanimoto similarity ranking.
query_smiles is an optional reference structure for similarity ranking. The
result is honestly labeled (see ScreeningProposal::epistemic_status) — it is
NOT a binding-affinity or efficacy prediction.
Sourcepub fn check_compliance(
&mut self,
compliance_type: ComplianceType,
) -> Result<MedicalOperationResult<ComplianceReport>, MedicalError>
pub fn check_compliance( &mut self, compliance_type: ComplianceType, ) -> Result<MedicalOperationResult<ComplianceReport>, MedicalError>
Check compliance
Sourcepub fn get_performance_stats(&self) -> MedicalPerformanceMetrics
pub fn get_performance_stats(&self) -> MedicalPerformanceMetrics
Get performance statistics
Sourcepub fn list_patients(&self) -> Vec<String>
pub fn list_patients(&self) -> Vec<String>
List all patients
Sourcepub fn get_patient_info(&self, patient_id: &str) -> Option<Patient>
pub fn get_patient_info(&self, patient_id: &str) -> Option<Patient>
Get patient information
Auto Trait Implementations§
impl Freeze for MedicalComputingLibrary
impl RefUnwindSafe for MedicalComputingLibrary
impl Send for MedicalComputingLibrary
impl Sync for MedicalComputingLibrary
impl Unpin for MedicalComputingLibrary
impl UnsafeUnpin for MedicalComputingLibrary
impl UnwindSafe for MedicalComputingLibrary
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more