pharmsol 0.26.1

Rust library for solving analytic and ode-defined pharmacometric models.
Documentation
//! Non-Compartmental Analysis (NCA) for pharmacokinetic data
//!
//! This module provides an API for calculating standard NCA parameters
//! from the basic Pharmsol's data structures
//! ([`crate::Subject`], [`crate::Occasion`] and [`crate::Data`]).
//!
//! # Usage
//!
//! NCA is performed by calling `.nca()` on a `Subject`. Dose and route
//! information are automatically detected from the dose events in the data.
//!
//! ```rust,ignore
//! use pharmsol::prelude::*;
//! use pharmsol::nca::NCAOptions;
//!
//! // Build subject with dose and observation events
//! let subject = Subject::builder("patient_001")
//!     .bolus(0.0, 100.0, 0)  // 100 mg oral dose
//!     .observation(1.0, 10.0, 0)
//!     .observation(2.0, 8.0, 0)
//!     .observation(4.0, 4.0, 0)
//!     .build();
//!
//! // Perform NCA with default options
//! let result = subject.nca(&NCAOptions::default()).expect("NCA failed");
//!
//! println!("Cmax: {:.2}", result.exposure.cmax);
//! println!("AUClast: {:.2}", result.exposure.auc_last);
//! ```
//!
//! # Steady-State Analysis
//!
//! ```rust,ignore
//! use pharmsol::nca::NCAOptions;
//!
//! // Configure for steady-state with 12h dosing interval
//! let options = NCAOptions::default().with_tau(12.0);
//! let result = subject.nca(&options).unwrap();
//!
//! if let Some(ref ss) = result.steady_state {
//!     println!("Cavg: {:.2}", ss.cavg);
//!     println!("Fluctuation: {:.1}%", ss.fluctuation);
//! }
//! ```
//!
//! # Population Analysis
//!
//! ```rust,ignore
//! use pharmsol::nca::{NCAOptions, NCA, NCAPopulation};
//!
//! // All occasions flat
//! let all_results = data.nca_all(&options);
//!
//! // Grouped by subject (includes error isolation)
//! let grouped = data.nca_grouped(&options);
//! for subj in &grouped {
//!     println!("{}: {} ok, {} errors",
//!         subj.subject_id,
//!         subj.successes().len(),
//!         subj.errors().len());
//! }
//! ```

// Internal modules
mod analyze;
mod calc;
mod error;
pub(crate) mod observation;
pub mod summary;
mod traits;
mod types;

// Feature modules
pub mod bioavailability;
pub mod sparse;
pub mod superposition;

#[cfg(test)]
mod tests;

// Crate-internal re-exports
// (traits.rs accesses analyze::analyze and calc::tlag_from_raw directly)

// Public API
pub use bioavailability::{
    bioavailability, bioequivalence, compare, metabolite_parent_ratio, BioavailabilityResult,
    BioequivalenceResult,
};

pub use error::NCAError;
pub use sparse::{sparse_auc, sparse_auc_from_data, SparsePKResult};
pub use summary::{nca_to_csv, summarize, ParameterSummary, PopulationSummary};
pub use superposition::{Superposition, SuperpositionResult};
pub use traits::{MetricsError, NCAPopulation, ObservationMetrics, SubjectNCAResult, NCA};
pub use types::{
    C0Method, ClearanceParams, ExposureParams, IVBolusParams, IVInfusionParams, LambdaZMethod,
    LambdaZOptions, MultiDoseParams, NCAOptions, NCAResult, Quality, RegressionStats, RouteParams,
    Severity, SteadyStateParams, TerminalParams, Warning,
};

// Re-export shared types (backwards compatible)
pub use crate::data::event::{AUCMethod, BLQRule, Route};