From 0df863a5d39c6d46efd435815968f1decc368a7f Mon Sep 17 00:00:00 2001
From: Sir Blob <76974209+GamerBoss101@users.noreply.github.com>
Date: Sun, 26 Jan 2025 07:02:04 -0500
Subject: [PATCH] jknsekjvn
---
package.json | 1 +
.../suite/doctor/dashboard/AgeChart.jsx | 66 +++++++++++++++++++
.../(panels)/suite/doctor/dashboard/page.jsx | 12 ++--
.../{patient => patients}/PatientForm.tsx | 0
.../doctor/{patient => patients}/page.jsx | 18 +++--
tsconfig.json | 2 +-
6 files changed, 86 insertions(+), 13 deletions(-)
create mode 100644 src/app/(panels)/suite/doctor/dashboard/AgeChart.jsx
rename src/app/(panels)/suite/doctor/{patient => patients}/PatientForm.tsx (100%)
rename src/app/(panels)/suite/doctor/{patient => patients}/page.jsx (86%)
diff --git a/package.json b/package.json
index 004a242..dd33787 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
},
"dependencies": {
"@clerk/nextjs": "^6.10.2",
+ "@faker-js/faker": "^9.4.0",
"@huggingface/inference": "^3.1.2",
"@langchain/community": "^0.3.27",
"@langchain/core": "^0.3.36",
diff --git a/src/app/(panels)/suite/doctor/dashboard/AgeChart.jsx b/src/app/(panels)/suite/doctor/dashboard/AgeChart.jsx
new file mode 100644
index 0000000..82bcfa7
--- /dev/null
+++ b/src/app/(panels)/suite/doctor/dashboard/AgeChart.jsx
@@ -0,0 +1,66 @@
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from "recharts"
+
+import { faker } from "@faker-js/faker"
+
+
+export function AgeChart() {
+
+ const patients = generateFakePatients(100)
+
+ const ageGroups = {
+ "18-30": 0,
+ "31-50": 0,
+ "51-70": 0,
+ "71+": 0,
+ }
+
+ patients.forEach((patient) => {
+ if (patient.age <= 30) ageGroups["18-30"]++
+ else if (patient.age <= 50) ageGroups["31-50"]++
+ else if (patient.age <= 70) ageGroups["51-70"]++
+ else ageGroups["71+"]++
+ })
+
+ const chartData = Object.entries(ageGroups).map(([range, count]) => ({ range, count }))
+
+ function generateFakePatients(count) {
+ return Array.from({ length: count }, () => ({
+ id: faker.string.uuid(),
+ name: faker.person.fullName(),
+ age: faker.number.int({ min: 18, max: 100 }),
+ gender: faker.helpers.arrayElement(["male", "female", "other"]),
+ bloodType: faker.helpers.arrayElement(["A+", "A-", "B+", "B-", "AB+", "AB-", "O+", "O-"]),
+ lastCheckup: faker.date.recent({ days: 90 }),
+ symptoms: faker.helpers.arrayElements(
+ ["Fever", "Cough", "Fatigue", "Shortness of breath", "Headache", "Nausea", "Dizziness", "Chest pain"],
+ { min: 0, max: 3 },
+ ),
+ vitalSigns: {
+ temperature: faker.number.float({ min: 36.1, max: 37.5, precision: 0.1 }),
+ heartRate: faker.number.int({ min: 60, max: 100 }),
+ bloodPressure: `${faker.number.int({ min: 90, max: 140 })}/${faker.number.int({ min: 60, max: 90 })}`,
+ respiratoryRate: faker.number.int({ min: 12, max: 20 }),
+ },
+ }))
+ }
+
+ return (
+
+
+ Age Distribution
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+
diff --git a/src/app/(panels)/suite/doctor/dashboard/page.jsx b/src/app/(panels)/suite/doctor/dashboard/page.jsx
index 445de82..d34f146 100644
--- a/src/app/(panels)/suite/doctor/dashboard/page.jsx
+++ b/src/app/(panels)/suite/doctor/dashboard/page.jsx
@@ -2,6 +2,7 @@
import { PatientTable } from "./PatientTable"
import { AppointmentList } from "./AppList"
+import { AgeChart } from "./AgeChart"
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
@@ -25,11 +26,11 @@ export default function Dashboard() {
}
}, [user]);
- if (userData) {
- if (userData.role != "caregiver") {
- router.push("/suite/patient/dashboard");
- }
- }
+ // if (userData) {
+ // if (userData.role != "caregiver") {
+ // router.push("/suite/patient/dashboard");
+ // }
+ // }
const patients = [
{ id: 1, name: "John Doe", age: 30, lastVisit: "2024-10-01" },
@@ -52,6 +53,7 @@ export default function Dashboard() {
)
diff --git a/src/app/(panels)/suite/doctor/patient/PatientForm.tsx b/src/app/(panels)/suite/doctor/patients/PatientForm.tsx
similarity index 100%
rename from src/app/(panels)/suite/doctor/patient/PatientForm.tsx
rename to src/app/(panels)/suite/doctor/patients/PatientForm.tsx
diff --git a/src/app/(panels)/suite/doctor/patient/page.jsx b/src/app/(panels)/suite/doctor/patients/page.jsx
similarity index 86%
rename from src/app/(panels)/suite/doctor/patient/page.jsx
rename to src/app/(panels)/suite/doctor/patients/page.jsx
index f3f2144..a577d6e 100644
--- a/src/app/(panels)/suite/doctor/patient/page.jsx
+++ b/src/app/(panels)/suite/doctor/patients/page.jsx
@@ -12,11 +12,12 @@ import { CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { ChevronDown } from "lucide-react";
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
-import PersonForm from "@/components/PersonForm";
+import {PersonForm} from "./PatientForm";
import { Card } from "@/components/ui/card";
-export default function Dashboard() {
+
+export default function PatientsDOC() {
const router = useRouter();
const { user } = useUser();
@@ -25,14 +26,17 @@ export default function Dashboard() {
useEffect(() => {
if (user) {
- axios.get(`/api/user?userId=${user.id}`).then(response => {
- setUserData(response.data);
- });
+ axios.get(`/api/user?userId=${user.id}`).then(response => {
+ setUserData(response.data);
+ if (response.data.role === 'caregiver') {
+ axios.get('/api/patients').then(res => setPatients(res.data));
+ }
+ });
}
}, [user]);
if (userData) {
- if (userData.role != "caregiver") {
+ if (userData.role && userData.role != "caregiver") {
router.push("/suite/patient/dashboard");
}
}
@@ -43,7 +47,7 @@ export default function Dashboard() {
- {userData.role === 'caregiver' && (
+ {userData && userData.role === 'caregiver' && (
{patients.map(patient => (
diff --git a/tsconfig.json b/tsconfig.json
index 161b9f9..64f11d2 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -22,6 +22,6 @@
"@/*": ["./src/*"]
}
},
- "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app/api/connectDB.js", "src/lib/utils.js", "src/app/(web)/account/page.jsx", "src/app/(panels)/suite/patient/account/page.jsx", "src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx", "src/app/(panels)/suite/patient/dashboard/page.jsx", "src/app/api/transcribe/route.js", "src/components/ui/calendar.jsx", "src/app/(web)/page.jsx", "src/app/(web)/transcribe/page.jsx", "src/app/(web)/login/page.jsx", "src/app/(panels)/suite/layout.jsx", "src/app/(panels)/suite/doctor/dashboard/page.jsx", "src/app/(panels)/suite/patient/chat/page.jsx", "src/app/(panels)/suite/doctor/dashboard/AppList.jsx", "src/app/(panels)/suite/doctor/patient/page.jsx"],
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "src/app/api/connectDB.js", "src/lib/utils.js", "src/app/(web)/account/page.jsx", "src/app/(panels)/suite/patient/account/page.jsx", "src/app/(panels)/suite/patient/dashboard/MedicationTable.jsx", "src/app/(panels)/suite/patient/dashboard/page.jsx", "src/app/api/transcribe/route.js", "src/components/ui/calendar.jsx", "src/app/(web)/page.jsx", "src/app/(web)/transcribe/page.jsx", "src/app/(web)/login/page.jsx", "src/app/(panels)/suite/layout.jsx", "src/app/(panels)/suite/doctor/dashboard/page.jsx", "src/app/(panels)/suite/patient/chat/page.jsx", "src/app/(panels)/suite/doctor/dashboard/AppList.jsx", "src/app/(panels)/suite/doctor/patients/page.jsx", "src/app/(panels)/suite/doctor/dashboard/AgeChart.jsx"],
"exclude": ["node_modules"]
}