Expand description
§clincalc
Open, auditable clinical calculators: the pure scoring engine and the clincalc
command-line surface in one crate.
§Feature flags
default = ["cli"]builds the standaloneclincalcbinary and exposes the reusableclimodule.mcpadds the optional local stdio MCP server used byclincalc mcp. It pulls in the MCP SDK and async runtime behind the feature gate.default-features = falsebuilds only the leaf engine: calculators, registry, schemas, tags, licences, andCalculationResponse. This mode depends only onserdeandserde_json.
clincalc = { version = "0.2", default-features = false }§One registry, many surfaces
With default-features = false this crate is a strict leaf: it never
depends on a host application and never on an async runtime. That is what lets
the same logic drive every surface without divergence:
- the standalone
clincalcbinary (the defaultclifeature) - host CLIs that embed the
climodule (for example GitEHR’sgitehr calc) - the optional MCP server (each calculator exposed as a tool)
- a native desktop GUI (called natively over a Tauri command)
- the single-file web calculators
Adding a calculator to all() surfaces it everywhere.
let calc = clincalc::get("feverpain").expect("calculator exists");
let input = serde_json::json!({
"fever": true,
"purulence": true,
"attend_rapidly": true,
"inflamed_tonsils": false,
"absence_of_cough": false
});
let response = calc.calculate(&input).expect("valid input");
assert_eq!(response.calculator, "feverpain");Every calculator implements the Calculator trait and returns a
CalculationResponse - the Rust counterpart of the JSON schema the web
calculators dispatch via gitehr-bridge.js.
Scoring functions are pure: no clock, no I/O, no global state. A host that needs a timestamp stamps it when recording the result, so the core stays deterministic and trivially testable.
Re-exports§
pub use calculator::CalcError;pub use calculator::Calculator;pub use license::CalculatorLicense;pub use proprietary::ProprietaryCalculator;pub use response::CalculationResponse;pub use template::template_from_schema;
Modules§
- api
- The HTTP REST API surface, behind the optional
rest-apifeature. HTTP REST API surface for clincalc, behind therest-apifeature. - calculator
- The
Calculatortrait and its error type. - calculators
- The calculator implementations.
- cli
- The command-line surface (
CalcCommand,run), behind theclifeature. Embeddable by host CLIs such as GitEHR’sgitehr calc. - license
- Distribution licence / provenance for a calculator’s clinical algorithm.
- mcp
- The Model Context Protocol server surface, behind the optional
mcpfeature. Feature-gated Model Context Protocol server surface. - proprietary
- Proprietary / licence-locked calculators.
- response
- The result schema returned by every calculator.
- tags
- Calculator tags - lightweight taxonomy for discovery and filtering.
- template
- Fillable input templates derived from a calculator’s JSON Schema.