diff --git a/src/app/(calculators)/calculate/[section]/[id]/renderCalc.tsx b/src/app/(calculators)/calculate/[section]/[id]/renderCalc.tsx
index fd203b0..0e6a42e 100644
--- a/src/app/(calculators)/calculate/[section]/[id]/renderCalc.tsx
+++ b/src/app/(calculators)/calculate/[section]/[id]/renderCalc.tsx
@@ -4,8 +4,7 @@ import InputComponent from "@/app/utils/Input";
import Input from "@/app/utils/Input";
import Result from "@/app/utils/Result";
import { CalculatorRegistry } from "@/app/utils/calculators/registry";
-import { Interpretation } from "@/app/utils/calculators/types";
-import { Metadata } from "next";
+import { Interpretation, pastUsed } from "@/app/utils/calculators/types";
import { useState } from "react";
export default function RenderCalculator({section, id} : {section:string, id:string}){
@@ -53,8 +52,25 @@ export default function RenderCalculator({section, id} : {section:string, id:str
e.preventDefault();
setResultStatus(true);
const calculatedValue = calculator.calc_func(form);
+ const interpretation = calculator.interpret_func(calculatedValue)
setValue(calculatedValue);
- setResult(calculator.interpret_func(calculatedValue));
+ setResult(interpretation);
+ const values : string = localStorage.getItem("pastUsed") || "[]";
+ const valuesobj : pastUsed[] = JSON.parse(values);
+ valuesobj.push(
+ {
+ calcInfo:{
+ section:section,
+ id:id,
+ name:calculator.name
+ },
+ value: calculatedValue,
+ interpretation: interpretation,
+ formData: form,
+ unit:calculator.unit
+ }
+ );
+ localStorage.setItem("pastUsed", JSON.stringify(valuesobj));
}}>
@@ -74,6 +90,8 @@ export default function RenderCalculator({section, id} : {section:string, id:str
interpretation={result}
calculated_value={value}
unit={calculator.unit ?? ""}
+ section={undefined}
+ id={undefined}
/>
: null}
diff --git a/src/app/(calculators)/calculators/page.tsx b/src/app/(calculators)/calculators/page.tsx
index b100241..dcca6e2 100644
--- a/src/app/(calculators)/calculators/page.tsx
+++ b/src/app/(calculators)/calculators/page.tsx
@@ -1,7 +1,44 @@
"use client"
+import { pastUsed } from "@/app/utils/calculators/types";
+import Result from "@/app/utils/Result";
+import { useEffect, useState } from "react";
+
export default function Calculators(){
+ const [pastUsedObj, setPastUsedObj] = useState
([]);
+ const [index, setIndex] = useState(0)
+ useEffect(() => {
+ const pastUsed : string = localStorage.getItem("pastUsed") || "[]";
+ setPastUsedObj(JSON.parse(pastUsed));
+ }, [])
+
return(
- <>hi
>
- )
+ <>
+
+ {
+ pastUsedObj.length !== 0 ?
+
+ : Empty
+ }
+
+
+
+
+
+
+
+ >
+ );
}
\ No newline at end of file
diff --git a/src/app/utils/Navbar.tsx b/src/app/utils/Navbar.tsx
index 767b6a6..ad0558a 100644
--- a/src/app/utils/Navbar.tsx
+++ b/src/app/utils/Navbar.tsx
@@ -22,7 +22,7 @@ export default function Navbar({navbarToggle}: Props){
-
+
CalcForCardiac
diff --git a/src/app/utils/Result.tsx b/src/app/utils/Result.tsx
index 972861a..80a0cb9 100644
--- a/src/app/utils/Result.tsx
+++ b/src/app/utils/Result.tsx
@@ -1,9 +1,15 @@
-import { Interpretation } from "./calculators/types";
-
-export default function Result({interpretation, calculated_value, unit} : {interpretation:Interpretation, calculated_value:string | number, unit:string
+import { Calculator, Interpretation } from "./calculators/types";
+import { CalculatorRegistry } from "./calculators/registry";
+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"){
@@ -16,6 +22,7 @@ export default function Result({interpretation, calculated_value, unit} : {inter
return(
+ {calc ?
{calc.name}
: null}
Calculated Score/Value: {calculated_value} {unit}
{message}
{diagnosis ?
Diagnosis: {diagnosis}
: null}
diff --git a/src/app/utils/Section.tsx b/src/app/utils/Section.tsx
index 2f63bea..85118cd 100644
--- a/src/app/utils/Section.tsx
+++ b/src/app/utils/Section.tsx
@@ -1,6 +1,15 @@
+"use client"
+
+import { useEffect, useState } from "react";
import { Calculator } from "./calculators/types";
export default function Section({sectionName, Calculators, id} : {sectionName:string, Calculators:Calculator[], id:string}){
+ const [bookmarks, setBookmarks] = useState
([]);
+ useEffect(() => {
+ const bookmarkedStr:string = localStorage.getItem("bookmarks") || "[]";
+ const bookmarkedObj : string[] = JSON.parse(bookmarkedStr);
+ setBookmarks(bookmarkedObj);
+ }, [])
return(
@@ -8,10 +17,87 @@ export default function Section({sectionName, Calculators, id} : {sectionName:st
{Calculators.map((e) => {
return(
- -
-
- {e.name}
-
+
-
+
+
+
+ {e.name}
+
+
+
)
})}
diff --git a/src/app/utils/calculators/Emergency/TIMI_score.ts b/src/app/utils/calculators/Emergency/TIMI_score.ts
index 8656075..eda9919 100644
--- a/src/app/utils/calculators/Emergency/TIMI_score.ts
+++ b/src/app/utils/calculators/Emergency/TIMI_score.ts
@@ -48,7 +48,7 @@ const parameters:Input[] = [
export const TIMI:Calculator = {
id:"timi-score",
- name:"Thrombolysis in Myocardial Infarction (TIMI) Score for UA and NSTEMI",
+ name:"Thrombolysis in Myocardial Infarction (TIMI) Score",
desc:"TIMI (Thrombolysis in Myocardial Infarction) Score is a validated, 7-point clinical tool used to predict the 14-day mortality and ischemic events in patients with unstable angina or NSTEMI",
inputs:parameters,
calc_func:(values : Values):number => {
diff --git a/src/app/utils/calculators/types.ts b/src/app/utils/calculators/types.ts
index 1b9114b..8dcb417 100644
--- a/src/app/utils/calculators/types.ts
+++ b/src/app/utils/calculators/types.ts
@@ -39,5 +39,15 @@ export interface Section {
svg:string,
calculators:Calculator[]
}
-
+export interface pastUsed {
+ calcInfo : {
+ section: string,
+ id: string,
+ name: string
+ },
+ value: string | number,
+ interpretation: Interpretation,
+ formData: object,
+ unit: string | undefined
+}
export type Values = Record;