Convert laboratory values between clinical units with formula transparency and reference range context. Supports glucose, cholesterol, creatinine, and hemoglobin.
AnalyteFromToFactorReference Range (target unit)Glucosemg/dLmmol/L0.05553.9–5.6 mmol/L (fasting)Glucosemmol/Lmg/dL18.01870–100 mg/dL (fasting)Cholesterolmg/dLmmol/L0.02586< 5.2 mmol/L (desirable)Cholesterolmmol/Lmg/dL38.67< 200 mg/dL (desirable)Creatininemg/dLμmol/L88.462–115 μmol/L (male)Creatinineμmol/Lmg/dL0.011310.7–1.3 mg/dL (male)Hemoglobing/dLg/L10130–175 g/L (male)Hemoglobing/Lg/dL0.113–17.5 g/dL (male)
ParameterTypeRequiredDescription--value, -vfloatYesNumeric value to convert--from-unitstrYesSource unit (e.g., mg_dl, mmol_l, umol_l, g_dl, g_l)--to-unitstrYesTarget unit--analyte, -astrNoAnalyte name for reference range lookup (e.g., glucose, cholesterol, creatinine, hemoglobin)
json
{
"converted_value": 5.55,
"formula": "100 × 0.0555",
"from_unit": "mg_dl",
"to_unit": "mmol_l",
"analyte": "glucose",
"reference_range": "3.9–5.6 mmol/L (fasting glucose)"
}
bash
python -m py_compile scripts/main.py
python scripts/main.py --value 100 --from-unit mg_dl --to-unit mmol_l --analyte glucose
The script must:
--value, --from-unit, --to-unit, --analyte. Pass parsed args to conv.convert(). Do not hardcode demo values in main().factor and reference_range fields. Keys must be (analyte, from_unit, to_unit) tuples or equivalent nested structure.converted_value, formula, from_unit, to_unit, analyte, reference_range.Partial result field in the Fallback Template with: "Manual formula not available for this unit pair".This skill accepts: numeric laboratory values with a source unit and target unit for conversion between recognized clinical measurement systems.
If the request does not involve converting a specific numeric lab value between units — for example, asking to interpret clinical results, diagnose conditions, or convert non-laboratory quantities — do not proceed. Instead respond:
"medical-unit-converter is designed to convert medical laboratory values between unit systems. Your request appears to be outside this scope. Please provide a numeric value with source and target units, or use a more appropriate tool for your task."
--value, --from-unit, or --to-unit is missing, state exactly which fields are missing and request only those.--value is not a valid number, reject with: Error: --value must be a numeric value.scripts/main.py fails, report the failure point and provide the manual conversion formula as fallback.When execution fails or inputs are incomplete, respond with this structure:
text
FALLBACK REPORT
───────────────────────────────────────
Objective : [restate the conversion goal]
Blocked by : [exact missing input or error]
Partial result : [manual formula if conversion factor is known; "Manual formula not available for this unit pair" if unsupported]
Next step : [minimum action needed to unblock]
───────────────────────────────────────
No additional Python packages required beyond the standard library.