Adding info on hover over svg feature and CHA2_DS2-VASc calculator

This commit is contained in:
2026-04-03 14:53:31 +05:30
parent 66d178472a
commit 0b913dcf67
12 changed files with 295 additions and 16 deletions

View File

@@ -0,0 +1,158 @@
import { Calculator, Input, Interpretation, Values } from "../types";
const parameters:Input[] = [
{
id:"chf",
name:"CHF/LV dysfunction",
type:"checkbox",
placeholder:"Whether the patient has CHF or LV dysfunction",
required:true
},
{
id:"hypertension",
name:"Hypertension",
type:"checkbox",
placeholder:"Whether the patient has hypertension",
required:true
},
{
id:"age",
name:"age",
type:"number",
placeholder:"Enter the age",
required:true,
min: 18,
max: 95
},
{
id:"dm",
name:"Diabetes Mellitus",
placeholder:"Whether the patient has diabetes",
type:"checkbox",
required:true
},
{
id:"ischemia",
name:"Prior ischemia",
placeholder:"Whether the patient had prior ischemic event",
type:"checkbox",
required:true
},
{
id:"vd",
name:"Vascular Disease",
placeholder:"Whether the patient has any vascular disease",
info:"Myocardial Infarction, Peripheral Vascular Disease etc.",
type:"checkbox",
required:true
},
{
id:"gender",
name:"Gender",
placeholder:"Select the gender",
type:"select",
required:true,
inputOptions:[
{
label:"Male",
value:"male"
},
{
label:"Female",
value:"female"
}
]
}
];
export const cha2ds2 : Calculator = {
id:"cha2ds2",
name:"CHA₂DS₂-VASc Score",
desc:"CHA₂DS₂-VASc Score is a clinical prediction tool used to estimate the risk of stroke in patients with non-valvular atrial fibrillation (AF).",
inputs:parameters,
calc_func:(values : Values):number => {
const chf = values.chf as boolean;
const hypertension = values.hypertension as boolean;
const age = values.age as number;
const dm = values.dm as boolean;
const ischemia = values.ischemia as boolean;
const vd = values.vd as boolean;
const gender = values.gender as "male" | "female";
var score = 0;
if(chf) score++;
if(hypertension) score++
if(age >= 75) score = score + 2;
if(dm) score++;
if(ischemia) score = score + 2;
if(vd) score ++;
if(age >= 65 && age < 75) score++;
if(gender === "female") score++;
return score;
},
interpret_func:(score : number):Interpretation => {
if(score === 0){
return {
level:"low",
message:"The stroke risk % for the patient is 0.2%"
}
}
if(score === 1){
return {
level:"low",
message:"The stroke risk % for the patient is 0.6%"
}
}
if(score === 2){
return {
level:"low",
message:"The stroke risk % for the patient is 2.2%"
}
}
if(score === 3){
return {
level:"low",
message:"The stroke risk % for the patient is 3.2%"
}
}
if(score === 4){
return {
level:"moderate",
message:"The stroke risk % for the patient is 4.8%"
}
}
if(score === 5){
return {
level:"moderate",
message:"The stroke risk % for the patient is 7.2%"
}
}
if(score === 6){
return {
level:"moderate",
message:"The stroke risk % for the patient is 9.7%"
}
}
if(score === 7){
return {
level:"high",
message:"The stroke risk % for the patient is 11.2%"
}
}
if(score === 8){
return {
level:"high",
message:"The stroke risk % for the patient is 10.8%"
}
}
if(score === 9){
return {
level:"severe",
message:"The stroke risk % for the patient is 12.2"
}
}
return {
level:"none",
message:"invalid values"
}
}
}

View File

@@ -10,14 +10,15 @@ const parameters:Input[] = [
},
{
id:"isCAD",
name:"Known Coronary Artery Disease (stenosis >= 50%)",
placeholder:"Whether the patient has a known CAD with more than 50% stenosis",
name:"Known Coronary Artery Disease",
placeholder:"Whether the patient has a known CAD with more than or equal to 50% stenosis",
type:"checkbox"
},
{
id:"cadRiskFactors",
name:"CAD Risk Factors",
placeholder:"Whether the patient has 3 or more than 3 CAD Risk Factors (Family history of CAD, Hypertension, Hypercholesterolemia, Diabetes, Smoker)",
placeholder:"Whether the patient has 3 or more than 3 CAD Risk Factors",
info:"Hypertension, hypercholesterolemia, diabetes, family history of CAD, or current smoker",
type:"checkbox"
},
{
@@ -41,8 +42,9 @@ const parameters:Input[] = [
{
id:"biomarkers",
name:"Elevated Serum cardiac biomarkers",
placeholder:"Whether the patient has Elevated Serum cardiac biomarkers (Troponin levels, creatine kinase etc)",
type:"checkbox"
placeholder:"Whether the patient has Elevated Serum cardiac biomarkers",
type:"checkbox",
info:"Troponin levels, creatine kinase"
}
];

View File

@@ -4,18 +4,20 @@ const parameters : Input[] = [
{
id:"sbp",
name:"Systolic Blood Pressure",
placeholder:"Enter the Systolic Blood Pressure in mmHg",
placeholder:"Enter the Systolic Blood Pressure",
type:"number",
required:true,
min:0
min:0,
defaultUnit:"mmHg",
},
{
id:"dbp",
name:"Diastolic Blood Pressure",
placeholder:"Enter the Disatolic Blood Pressure in mmHg",
placeholder:"Enter the Disatolic Blood Pressure",
type:"number",
required:true,
min:0
min:0,
defaultUnit:"mmHg"
}
]

View File

@@ -4,6 +4,7 @@ import { Section } from "./types";
import { MELD } from "./Utilities/MELD";
import { MAP } from "./General Cardiology/MAP";
import { TIMI } from "./Emergency/TIMI_score";
import { cha2ds2 } from "./Arrhythmias and Anti-Coagulation/CHA2DS2-VASc-score";
export const CalculatorRegistry : Record<string, Section> = {
generalCardiology:{
@@ -15,6 +16,15 @@ export const CalculatorRegistry : Record<string, Section> = {
MAP
]
},
arrhythmias:{
id:"arrhythmias",
displayName:"Arrhythmias & Anti-Coagulation",
textColor:"#ccc",
svg:"",
calculators:[
cha2ds2
]
},
emergency:{
id:"emergency",
displayName:"Emergency",

View File

@@ -23,6 +23,7 @@ export interface Input{
required?:boolean,
defaultUnit?:string,
unitOptions?:string[],
info?: string,
handleDataChange?:Function
}