Added General Cardiology and Emergency section, implemented more calculators (TIMI score, MAP)

This commit is contained in:
2026-03-31 20:04:51 +05:30
parent 537dd03362
commit 7a0ba9e459
10 changed files with 225 additions and 13 deletions

View File

@@ -0,0 +1,83 @@
import { Calculator, Input, Interpretation, Values } from "../types";
const parameters : Input[] = [
{
id:"sbilirubin",
type:"number",
name:"Serum (Total) Bilirubin",
defaultUnit:"mg/dL",
placeholder:"Enter serum bilirubin levels in mg/dL",
required:true,
min:0,
},
{
id:"screatinine",
type:"number",
name:"Serum Creatinine",
defaultUnit:"mg/dL",
placeholder:"Enter Serum Creatinine levels in mg/dL",
required:true,
min:0.2
},
{
id:'inr',
name:"International Normalized Ratio",
type:'number',
placeholder:"Enter INR values",
required:true,
min:0
}
];
export const MELD:Calculator = {
id:"meld-score",
name:"Model For End-stage Liver Disease (MELD) score",
desc:"MELD (Model for End-stage Liver Disease) score is a numerical scale ranging from 6 to 40 that estimates the 3-month mortality risk for patients with CLD (Chronic Liver Disease)",
inputs:parameters,
calc_func:(values : Values):number => {
const sbilirubin = values.sbilirubin as number;
const screatinine = values.screatinine as number;
const inr = values.inr as number;
const score = (9.57 * Math.log(screatinine))
+ (3.78 * Math.log(sbilirubin))
+ (11.2 * Math.log(inr))
+ 6.43;
return Math.floor(score);
},
interpret_func:(score : number):Interpretation => {
if(score <= 9){
return {
level:"none",
message:"The mortality prediction percent for the patient is 1.9%",
advice:"Patient is a great candidate for TIPS procedure"
}
}else if(score >= 10 && score < 20){
if(score < 14){
return{
level:"low",
message:"The mortality risk percent for the patient is less than 6.0%",
advice:"Patient is a great candidate for TIPS procedure"
};
}
return{
level:"low",
message:"The mortality risk percent for the patient is from 6.0% to 19.6%",
};
}else if (score >=20 && score < 30){
return {
level:"moderate",
message:"The mortality risk percent for the patient is from 19.6% to 52.6%"
};
}else if(score >= 30 && score < 40){
return {
level:"high",
message:"The mortality risk percent for the patient is from 52.6% to 71.3%"
}
}else{
return {
level:"severe",
message:"The mortality risk percent for the patient is more than 71.3%"
}
}
}
}

View File

@@ -0,0 +1,109 @@
import { Calculator, Input, Interpretation, Values } from "../types";
const parameters:Input[] = [
{
id:"gender",
name:"Gender",
placeholder:"Select gender",
type:"select",
inputOptions:[
{
label:"Male",
value:"male"
},
{
label:"Female",
value:"female"
}
],
required:true
},
{
id:"age",
type:"number",
name:"Age",
placeholder:"Enter age",
min:18,
max:95,
required:true
},
{
id:"creatinine",
type:"number",
name:"Creatinine",
placeholder:"Enter serum creatinine values in mg/dL",
min:0.2,
max:20,
required:true
},
{
id:"weight",
type:"number",
name:"Weight",
placeholder:"Enter weight in kilograms",
min:10,
max:100 ,
required:true
}
];
function calc_func(values : Values):number{
const gender = values.gender as "male" | "female";
const age = values.age as number;
const weight = values.weight as number;
const creatinine = values.creatinine as number;
return gender === "male"
? Math.floor(((140 - age) * weight)/(72 * creatinine))
: Math.floor((((140 - age) * weight)/(72 * creatinine)) * 0.85);
}
function interpret_func(crcl:number):Interpretation{
if(crcl >= 90){
return {
level:"none",
message:"Creatinine Clearance (CrCl) is normal or on the higher side, To be correlated with other clinical clues",
diagnosis:"CKD Stage 1"
}
}else if(crcl < 90 && crcl >= 60){
return {
level:"low",
message:"Creatinine Clearance (CrCl) is slightly reduced, To be correlated with other clinical clues",
diagnosis:"CKD Stage 2"
}
}else if(crcl < 60 && crcl >= 45){
return{
level:"moderate",
message:"Creatinine Clearance (CrCl) is moderately reduced",
advice:"Consult a Nephrologist",
diagnosis:"CKD Stage 3A"
}
}else if(crcl < 45 && crcl >= 30){
return{
level:"high",
message:"Creatinine Clearance (CrCl) is significantly reduced",
advice:"Consult a Nephrologist urgently",
diagnosis:"CKD Stage 3B"
}
}else if(crcl < 30 && crcl >= 15){
return{
level:"high",
message:"Creatinine Clearance (CrCl) is largely reduced",
advice:"Consult a Nephrologist urgently",
diagnosis:"CKD Stage 4"
}
}else{
return{
level:"severe",
message:"Creatinine Clearance (CrCl) is severely reduced",
advice:"Consult a Nephrologist urgently to consider dialysis",
diagnosis:"CKD Stage 5 / ESRD (End Stage Renal Disease)"
}
}
}
export const cockcroftGault: Calculator = {
id:"cockcroft-gault",
name:"Cockcroft Gault Equation",
desc:"The CockCroft Gault equation is a formula which is used to find the CrCl (Creatinine Clearance) of an individual on the basis of Age, Weight, Gender and Creatinine",
unit:"mL/min",
inputs:parameters,
calc_func:calc_func,
interpret_func:interpret_func
}

View File

@@ -0,0 +1,10 @@
import { CalculatorRegistry } from "../registry";
const calculator = CalculatorRegistry.miscellaneous.calculators[0].calc_func;
console.log(calculator(
{
gender:"male",
age:43,
creatinine:5,
weight:60
}
));