import { Calculator, Interpretation } from "./calculators/types"; import { CalculatorRegistry } from "./calculators/registry"; import Link from "next/link"; export default function Result({interpretation, calculated_value, unit, id, section} : { interpretation:Interpretation, calculated_value:string | number, unit:string | undefined, id: string | undefined, section:string | undefined }){ var {level, message, diagnosis, advice} = interpretation; var levelClass = ""; const calc : Calculator | undefined = id && section ? CalculatorRegistry[section].calculators.find(e => e.id === id) : undefined; if(level === "none" || level === "low"){ levelClass = "bg-success"; }else if(level === "moderate"){ levelClass = "bg-orange-600 text-white"; }else if(level === "high" || level === "severe"){ levelClass = "bg-red-500 text-white"; }else{ levelClass = "bg-white"; } return(
{message}
{diagnosis ?Diagnosis: {diagnosis}
: null} {advice ?Advice: {advice}
: null}