Skip to main content

MedicalComputingLibrary

Struct MedicalComputingLibrary 

Source
pub struct MedicalComputingLibrary { /* private fields */ }
Expand description

Medical Computing Library Manager

Implementations§

Source§

impl MedicalComputingLibrary

Source

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²).

Source

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).

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn mean_arterial_pressure( &self, systolic: f64, diastolic: f64, ) -> Result<f64, MedicalError>

Mean Arterial Pressure (standard estimate): MAP = (SBP + 2·DBP) / 3 (mmHg).

Source

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.)

Source

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).

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn elimination_rate_constant( &self, half_life: f64, ) -> Result<f64, MedicalError>

First-order elimination rate constant from half-life: k = ln(2) / t½.

Source

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.

Source

pub fn clearance( &self, rate_constant: f64, volume_of_distribution: f64, ) -> Result<f64, MedicalError>

Drug clearance from first-order PK: CL = k × Vd.

Source

pub fn volume_of_distribution( &self, dose: f64, initial_concentration: f64, ) -> Result<f64, MedicalError>

Apparent volume of distribution: Vd = dose / C0.

Source

pub fn steady_state_concentration( &self, infusion_rate: f64, clearance: f64, ) -> Result<f64, MedicalError>

Steady-state concentration under continuous infusion: Css = infusion_rate / clearance.

Source

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

Source

pub fn new() -> Self

Create new medical computing library

Source

pub fn initialize(&mut self) -> Result<(), MedicalError>

Initialize the library

Source

pub fn create_patient_record( &mut self, patient: Patient, ) -> Result<MedicalOperationResult<Patient>, MedicalError>

Create a new patient record

Source

pub fn analyze_clinical_data( &mut self, patient_id: &str, data_type: ClinicalDataType, ) -> Result<MedicalOperationResult<ClinicalAnalysis>, MedicalError>

Analyze clinical data

Source

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.

Source

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.

Source

pub fn process_medical_image( &mut self, image: MedicalImage, processing_type: ImageProcessingType, ) -> Result<MedicalOperationResult<ProcessedImage>, MedicalError>

Process medical image

Source

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.

Source

pub fn check_compliance( &mut self, compliance_type: ComplianceType, ) -> Result<MedicalOperationResult<ComplianceReport>, MedicalError>

Check compliance

Source

pub fn get_performance_stats(&self) -> MedicalPerformanceMetrics

Get performance statistics

Source

pub fn list_patients(&self) -> Vec<String>

List all patients

Source

pub fn get_patient_info(&self, patient_id: &str) -> Option<Patient>

Get patient information

Auto Trait Implementations§

Blanket Implementations§

§

impl<S, A> Aggregate<Result<S, Error>> for A
where A: Aggregate<S>,

§

fn from_shares<T>(iter: T) -> Result<A, Error>
where T: IntoIterator<Item = Result<S, Error>>,

Aggregate shares in an MPC protocol.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,