Merge remote-tracking branch 'refs/remotes/origin/main'

This commit is contained in:
Joseph J Helfenbein
2025-01-26 07:11:08 -05:00
6 changed files with 86 additions and 13 deletions

View File

@@ -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",

View File

@@ -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 (
<Card>
<CardHeader>
<CardTitle>Age Distribution</CardTitle>
</CardHeader>
<CardContent>
<ResponsiveContainer width="100%" height={300}>
<BarChart data={chartData}>
<XAxis dataKey="range" />
<YAxis />
<Bar dataKey="count" fill="#8884d8" />
</BarChart>
</ResponsiveContainer>
</CardContent>
</Card>
)
}

View File

@@ -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() {
<div className="h-20 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<PatientTable data={patients} />
<AppointmentList appointments={appointments} />
<AgeChart />
</div>
</div>
)

View File

@@ -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();
@@ -27,12 +28,15 @@ export default function Dashboard() {
if (user) {
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() {
<div className="h-20 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<Card>
<CardContent>
{userData.role === 'caregiver' && (
{userData && userData.role === 'caregiver' && (
<div>
<ul className="mb-4">
{patients.map(patient => (

View File

@@ -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"]
}