diff --git a/src/app/(calculators)/calculate/[section]/[id]/renderCalc.tsx b/src/app/(calculators)/calculate/[section]/[id]/renderCalc.tsx index 9cfd27e..4c4500c 100644 --- a/src/app/(calculators)/calculate/[section]/[id]/renderCalc.tsx +++ b/src/app/(calculators)/calculate/[section]/[id]/renderCalc.tsx @@ -35,9 +35,9 @@ export default function RenderCalculator({section, id} : {section:string, id:str

{calculator?.desc}

-

+ {calculator?.unit ?

Unit of the value:- {calculator?.unit} -

+ : null}
{ diff --git a/src/app/(calculators)/layout.tsx b/src/app/(calculators)/layout.tsx index ee519e3..cdb4466 100644 --- a/src/app/(calculators)/layout.tsx +++ b/src/app/(calculators)/layout.tsx @@ -1,5 +1,5 @@ import LayoutClient from "./layoutClient"; -import { Roboto } from "next/font/google"; + export default function CalculatorsLayout({children} : {children:React.ReactNode}){ return( <> diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f1d8007..e3b529a 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,8 +3,8 @@ import "./globals.css"; import 'animate.css'; export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", + title: "CalcForCardiac", + description: "A zero friction and zero login medical calculator made by Saksham Vitwekar (SomeTroller77)", }; export default function RootLayout({ diff --git a/src/app/utils/Input.tsx b/src/app/utils/Input.tsx index e63cf21..f4c3385 100644 --- a/src/app/utils/Input.tsx +++ b/src/app/utils/Input.tsx @@ -56,12 +56,28 @@ export default function InputComponent({id, type, inputOptions, min, max, requir {inputOptions?.map(e => { return( - + ) })} {/* Optional */} ) + }else if(type === "checkbox"){ + return( +
+ {name} + +
+ ) } } \ No newline at end of file diff --git a/src/app/utils/calculators/registry.ts b/src/app/utils/calculators/registry.ts index 5accbc0..7d9e7b4 100644 --- a/src/app/utils/calculators/registry.ts +++ b/src/app/utils/calculators/registry.ts @@ -1,7 +1,17 @@ import { cockcroftGault } from "./miscellaneous/cockcroft-gault-eq"; +import { IMPACT } from "./transplantation/IMPACT"; import { Section } from "./types"; export const CalculatorRegistry : Record = { + transplantation:{ + id:"transplantation", + displayName:"Transplantation", + textColor:"#ccc", + svg:"", + calculators:[ + IMPACT + ] + }, miscellaneous:{ id:"miscellaneous", displayName:"Miscellaneous", diff --git a/src/app/utils/calculators/transplantation/IMPACT.ts b/src/app/utils/calculators/transplantation/IMPACT.ts new file mode 100644 index 0000000..5b9d6ce --- /dev/null +++ b/src/app/utils/calculators/transplantation/IMPACT.ts @@ -0,0 +1,262 @@ +import { Calculator, Input, Interpretation, Values } from "../types"; + +const parameters : Input[] = [ + { + id:"age", + name:"Age", + placeholder:"Enter age", + type:"number", + min:0, + required:true, + }, + { + id:"sbilirubin", + name:"Serum Bilirubin", + placeholder:"Enter the serum bilirubin value in mg/dL", + type:"number", + defaultUnit:"mg/dL", + required:true + }, + { + id:"crcl", + name:"Creatinine Clearance (CrCl)", + placeholder:"Enter the CrCl value in mL/min", + type:"number", + defaultUnit:"mL/min", + required:true + }, + { + id:"dialysisStatus", + name:"Dialysis Requirement", + placeholder:"Whether Dialysis was done between listing and transplantation", + type:"checkbox", + required:true + }, + { + id:"gender", + name:"Gender", + placeholder:"Select Gender", + type:"select", + required:true, + inputOptions:[ + { + label:"Male", + value:"male" + }, + { + label:"Female", + value:"female" + } + ] + }, + { + id:"causeOfHF", + name:"Heart Failure Etiology", + placeholder:"Cause of Heart Failure", + type:"select", + required:true, + inputOptions:[ + { + label:"Idiopathic", + value:"idiopathic" + }, + { + label:"Ischemic", + value:"ischemic" + }, + { + label:"Congenital", + value:"congenital" + }, + { + label:"Other", + value:"other" + } + ] + }, + { + id:"recentInfection", + name:"Recent Infection Status", + placeholder:"Whether the patient had a recent infection", + type:"checkbox" + }, + { + id:"aorticBalloonPump", + name:"Intra-Aortic Balloon Pump", + placeholder:"Whether Intra-Aortic Balloon Pump was implanted", + type:"checkbox" + }, + { + id:"preTransplantMechVent", + name:"Mechanical Ventilation", + placeholder:"whether Mechanical Ventilation was done pre-transplant", + type:"checkbox" + }, + { + id:"race", + name:"Race", + placeholder:"Select the Race of the patient", + type:"select", + required:true, + inputOptions:[ + { + label:"Caucasian", + value:"caucasian" + }, + { + label:"African American", + value:"african-american" + }, + { + label:"Hispanic", + value:"hispanic" + }, + { + label:"Other", + value:"other" + } + ] + }, + { + id:"tempCircSupp", + name:"Temporary Circulation Support", + placeholder:"Whether temporary circulation support was needed (includes ECMO and e-VADs)", + type:"checkbox" + }, + { + id:"VAD", + name:"Ventricular Assist Device", + placeholder:"Select the Ventricular Assist Device used", + type:"select", + required:true, + inputOptions:[ + { + label:"None used", + value:"none" + }, + { + label:"Older-Generation Pulsatile", + value:"older-generation" + }, + { + label:"Newer-Generation continuous", + value:"newer-generation" + }, + { + label:"HeartMate II", + value:"heartmateii" + } + ] + } +] + +export const IMPACT:Calculator = { + id:"impact-score", + name:"IMPACT (Index for Mortality Prediction After Cardiac Transplantation", + desc:"IMPACT score is a risk assessment tool used to predict 1-year mortality following a Heart Transplantation based on 12 parameters (including renal function, liver function, age)", + inputs:parameters, + calc_func:(values : Values):number => { + const age = values.age as number; + const sbilirubin = values.sbilirubin as number; + const crcl = values.crcl as number; + const dialysisStatus = values.dialysisStatus as boolean; + const gender = values.gender as "male" | "female"; + const causeOfHF = values.causeOfHF as "idiopathic" | "ischemic" | "congenital" | "others"; + const recentInfection = values.recentInfection as boolean; + const aorticBalloonPump = values.aorticBalloonPump as boolean; + const preTransplantMechVent = values.preTransplantMechVent as boolean; + const race = values.race as "caucasian" | "african-american" | "hispanic" | "other"; + const tempCircSupp = values.tempCircSupp as boolean; + const VAD = values.VAD as "none" | "older-generation" | "newer-generation" | "heartmateii"; + var score = 0; + console.log(preTransplantMechVent); + if(age > 60){ + score += 3; + } + if(sbilirubin > 0 && sbilirubin < 1){ + score += 0; + }else if(sbilirubin >= 1 && sbilirubin < 2){ + score += 1; + }else if(sbilirubin >= 2 && sbilirubin < 4){ + score += 3; + }else{ + score += 4; + } + if(crcl >= 50){ + score += 0; + }else if(crcl < 50 && crcl > 30){ + score += 2; + }else{ + score += 5; + } + if(dialysisStatus){ + score += 4; + } + if(gender === "female"){ + score += 3; + } + if(causeOfHF === "idiopathic"){ + score += 0; + }else if(causeOfHF === "ischemic"){ + score += 2; + }else if(causeOfHF === "congenital"){ + score += 5; + }else{ + score += 1; + } + if(recentInfection){ + score += 3; + } + if(aorticBalloonPump){ + score += 3; + } + if(preTransplantMechVent){ + score += 5; + } + if(race === "caucasian" || race === "other" || race === "hispanic"){ + score += 0; + }else{ + score += 3; + } + if(tempCircSupp){ + console.log("ran temp") + score += 7; + } + if(VAD === "none" || VAD === "heartmateii"){ + score += 0; + }else if(VAD === "older-generation"){ + score += 3; + }else{ + score += 5; + } + return score; + }, + interpret_func:(score : number):Interpretation => { + if(score >= 0 && score < 5){ + return { + level:"none", + message:"The rate of mortality for the patient is really low" + } + }else if(score >= 5 && score < 10){ + return { + level:"low", + message:"The rate of mortality for the patient is low" + } + }else if(score >= 10 && score < 15){ + return { + level:"moderate", + message:"The rate of mortality for the patient is moderate" + } + }else if(score >= 15 && score < 20){ + return { + level:"high", + message:"The rate of mortality for the patient is high" + } + }else{ + return { + level:"severe", + message:"The rate of mortality for the patient is severe" + } + } + } +} \ No newline at end of file diff --git a/src/app/utils/calculators/types.ts b/src/app/utils/calculators/types.ts index 83cf535..1b9114b 100644 --- a/src/app/utils/calculators/types.ts +++ b/src/app/utils/calculators/types.ts @@ -15,8 +15,8 @@ interface inputOptions { export interface Input{ id:string, name:string, - placeholder:string, - type: "number" | "text" | "select", + placeholder?:string, + type: "number" | "text" | "select" | "checkbox", inputOptions?:inputOptions[], min?:number, max?:number, @@ -40,4 +40,4 @@ export interface Section { calculators:Calculator[] } -export type Values = Record; +export type Values = Record;