+ {/* Active indicator - Dynamic positioning with precise centering */}
+
item.id === activeItem) * 64 + 10}px`,
+ }}
+ />
+
+ {/* Logo */}
+
+ {/* Menu Items */}
+
+ {menuItems.map((item) => {
+ const Icon = item.icon
+ const isActive = activeItem === item.id
+
+ return (
+ onItemClick(item.id)}
+ >
+
+
+ {item.label}
+
+
+ )
+ })}
+
+
+ )
+}
diff --git a/ipdmodule/components/appointment-page.tsx b/ipdmodule/components/appointment-page.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..7687be20b954a3f6706a3fca774331a2f8c1764d
--- /dev/null
+++ b/ipdmodule/components/appointment-page.tsx
@@ -0,0 +1,277 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Clock, CheckCircle, XCircle, MoreHorizontal, Filter, ArrowUpDown } from "lucide-react"
+import { YellowBackgroundPattern } from "./yellow-background-pattern"
+import { AppointmentSearchControls } from "./appointment-search-controls"
+
+const appointmentTabs = [
+ { id: "queue", label: "Queue (2)", icon: Clock, count: 2, active: true },
+ { id: "finished", label: "Finished (0)", icon: CheckCircle, count: 0, active: false },
+ { id: "cancelled", label: "Cancelled (0)", icon: XCircle, count: 0, active: false },
+]
+
+// Generate dynamic dummy data
+const generatePatients = (count: number) => {
+ const firstNames = [
+ "Ram",
+ "Sri",
+ "Priya",
+ "Arjun",
+ "Kavya",
+ "Ravi",
+ "Meera",
+ "Suresh",
+ "Anita",
+ "Vikram",
+ "Deepa",
+ "Rajesh",
+ "Lakshmi",
+ "Kiran",
+ "Pooja",
+ "Amit",
+ "Sneha",
+ "Rohit",
+ "Divya",
+ "Sanjay",
+ ]
+
+ const lastNames = [
+ "Sharma",
+ "Patel",
+ "Kumar",
+ "Singh",
+ "Reddy",
+ "Nair",
+ "Gupta",
+ "Joshi",
+ "Rao",
+ "Iyer",
+ "Agarwal",
+ "Verma",
+ "Mishra",
+ "Chopra",
+ "Malhotra",
+ ]
+
+ const genders = ["Male", "Female"]
+ const visitTypes = ["New", "Follow-up", "Emergency", "Consultation", "Check-up"]
+ const timeSlots = [
+ "09:00 am",
+ "09:30 am",
+ "10:00 am",
+ "10:30 am",
+ "11:00 am",
+ "11:30 am",
+ "12:00 pm",
+ "02:00 pm",
+ "02:30 pm",
+ "03:00 pm",
+ "03:30 pm",
+ "04:00 pm",
+ "04:30 pm",
+ "05:00 pm",
+ ]
+
+ const generatePhoneNumber = () => {
+ const prefix = "+91-"
+ const number = Math.floor(Math.random() * 9000000000) + 1000000000
+ return prefix + number.toString()
+ }
+
+ // Generate dates starting from today and going forward
+ const generateDate = (index: number) => {
+ const today = new Date()
+ const appointmentDate = new Date(today)
+ appointmentDate.setDate(today.getDate() + index)
+
+ const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+
+ const day = appointmentDate.getDate()
+ const month = months[appointmentDate.getMonth()]
+ const year = appointmentDate.getFullYear()
+
+ const suffix =
+ day === 1 || day === 21 || day === 31
+ ? "st"
+ : day === 2 || day === 22
+ ? "nd"
+ : day === 3 || day === 23
+ ? "rd"
+ : "th"
+
+ return `${day}${suffix} ${month} ${year}`
+ }
+
+ const generateAge = () => Math.floor(Math.random() * 60) + 18
+
+ // Generate patients with sequential dates (latest first)
+ const patients = Array.from({ length: count }, (_, index) => {
+ const firstName = firstNames[Math.floor(Math.random() * firstNames.length)]
+ const lastName = lastNames[Math.floor(Math.random() * lastNames.length)]
+ const gender = genders[Math.floor(Math.random() * genders.length)]
+ const age = generateAge()
+
+ return {
+ id: index + 1,
+ name: `${firstName} ${lastName}`,
+ gender,
+ age: `${age}y`,
+ contact: generatePhoneNumber(),
+ visitType: visitTypes[Math.floor(Math.random() * visitTypes.length)],
+ slot: timeSlots[Math.floor(Math.random() * timeSlots.length)],
+ date: generateDate(index),
+ dateIndex: index, // For sorting purposes
+ }
+ })
+
+ // Sort by date (latest appointments first - smallest dateIndex first)
+ return patients.sort((a, b) => a.dateIndex - b.dateIndex)
+}
+
+const patients = generatePatients(12)
+
+export function AppointmentPage() {
+ const [activeTab, setActiveTab] = useState("queue")
+
+ return (
+
+ {/* Yellow Background Pattern */}
+
+
+ {/* Main Content */}
+
+ {/* Welcome Section */}
+
+
+
+ Welcome Dr. Mihir!
+
+
Your Appointments
+
+
+ Start Walk-In Consultation
+
+
+
+ {/* Appointment Card */}
+
+
+ {/* Tabs */}
+
+
+ {appointmentTabs.map((tab) => {
+ const Icon = tab.icon
+ return (
+
setActiveTab(tab.id)}
+ >
+
+
+ {tab.label}
+
+ {tab.active &&
}
+
+ )
+ })}
+
+
+
+ {/* Search and Controls */}
+
+
+ {/* Patient Table */}
+
+
+ {/* Table Header */}
+
+
+ #
+
+
+ NAME
+
+
+ CONTACT
+
+
+ VISIT TYPE
+
+
+
+
+ ACTION
+
+
+
+
+ {/* Table Rows */}
+
+ {patients.map((patient, index) => (
+
+
+ {index + 1}
+
+
+
+ {patient.name}
+
+
+ {patient.gender}, {patient.age}
+
+
+
+
+ {patient.contact}
+
+
+
+
+ {patient.visitType}
+
+
+
+
+ {patient.slot}
+
+
+ {patient.date}
+
+
+
+
+ Consult
+
+
+
+
+
+
+
+
+ ))}
+
+
+
+
+
+
+
+ )
+}
diff --git a/ipdmodule/components/appointment-search-controls.tsx b/ipdmodule/components/appointment-search-controls.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..335ff4ddf043cbd01c196dd562bd13881d21dd17
--- /dev/null
+++ b/ipdmodule/components/appointment-search-controls.tsx
@@ -0,0 +1,58 @@
+"use client"
+
+import { Search, Calendar, ChevronRightIcon, ChevronRight } from "lucide-react"
+import { Input } from "@/components/ui/input"
+import { Button } from "@/components/ui/button"
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
+
+export function AppointmentSearchControls() {
+ return (
+
+ {/* Search Input */}
+
+
+
+
+
+ {/* Date Navigation and Filter */}
+
+ {/* Date Navigation */}
+
+
+
+
+
+
+ 9-10-2023
+
+
+
+
+
+
+ {/* Today Filter */}
+
+
+
+
+
+ Today
+ Tomorrow
+ This Week
+
+
+
+
+ )
+}
diff --git a/ipdmodule/components/consultant-notes-form.tsx b/ipdmodule/components/consultant-notes-form.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..77b8b148241a1d2880c056cf482d56989652b014
--- /dev/null
+++ b/ipdmodule/components/consultant-notes-form.tsx
@@ -0,0 +1,242 @@
+"use client"
+
+import { useState, useEffect } from "react"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
+import { Button } from "@/components/ui/button"
+import { RichTextEditor } from "./rich-text-editor"
+import { FormNavigation } from "./form-navigation"
+import { User, Stethoscope, ClipboardList, Calendar } from "lucide-react"
+
+export function ConsultantNotesForm() {
+ const [activeSection, setActiveSection] = useState("consultation-info")
+ const [formData, setFormData] = useState({
+ consultationInfo: "",
+ clinicalFindings: "",
+ recommendations: "",
+ followUp: "",
+ })
+
+ const sections = [
+ { id: "consultation-info", label: "Consultation Info", icon:
},
+ { id: "clinical-findings", label: "Clinical Findings", icon:
},
+ { id: "recommendations", label: "Recommendations", icon:
},
+ { id: "follow-up", label: "Follow-up", icon:
},
+ ]
+
+ useEffect(() => {
+ const handleScroll = () => {
+ const sectionElements = sections.map((section) => ({
+ id: section.id,
+ element: document.getElementById(section.id),
+ }))
+
+ const currentSection = sectionElements.find(({ element }) => {
+ if (!element) return false
+ const rect = element.getBoundingClientRect()
+ return rect.top <= 100 && rect.bottom >= 100
+ })
+
+ if (currentSection) {
+ setActiveSection(currentSection.id)
+ }
+ }
+
+ window.addEventListener("scroll", handleScroll)
+ return () => window.removeEventListener("scroll", handleScroll)
+ }, [])
+
+ const updateFormData = (field: string, value: string) => {
+ setFormData((prev) => ({ ...prev, [field]: value }))
+ }
+
+ return (
+
+
+
+
+ {/* Consultation Info Section */}
+
+
+
+
+ Consultation Information
+
+
+
+
+
+ Consultant Name
+
+
+
+ Specialty
+
+
+
+
+
+ Cardiology
+ Neurology
+ Orthopedics
+ Surgery
+ Internal Medicine
+
+
+
+
+ Consultation Date
+
+
+
+ Time
+
+
+
+
+ Reason for Consultation
+ updateFormData("consultationInfo", value)}
+ placeholder="Reason for requesting consultation..."
+ fieldType="chief-complaints"
+ showAutofill={true}
+ autofillSource="Referring Doctor"
+ autofillTimestamp="2024-01-15, 9:00 AM"
+ />
+
+
+
+
+ {/* Clinical Findings Section */}
+
+
+
+
+ Clinical Findings
+
+
+
+
+ Examination Findings
+ updateFormData("clinicalFindings", value)}
+ placeholder="Detailed examination findings and clinical observations..."
+ fieldType="assessment"
+ rows={6}
+ />
+
+
+ Diagnostic Impression
+ {}}
+ placeholder="Clinical diagnosis and differential diagnoses..."
+ fieldType="assessment"
+ rows={4}
+ />
+
+
+
+
+ {/* Recommendations Section */}
+
+
+
+
+ Recommendations
+
+
+
+
+ Treatment Recommendations
+ updateFormData("recommendations", value)}
+ placeholder="Specific treatment recommendations and management plan..."
+ fieldType="plan"
+ rows={6}
+ />
+
+
+ Investigations Recommended
+ {}}
+ placeholder="Additional investigations or tests recommended..."
+ fieldType="plan"
+ rows={4}
+ />
+
+
+
+
+ {/* Follow-up Section */}
+
+
+
+
+ Follow-up Plan
+
+
+
+
+ Follow-up Instructions
+ updateFormData("followUp", value)}
+ placeholder="Follow-up schedule and instructions..."
+ fieldType="plan"
+ rows={4}
+ />
+
+
+
+ Next Appointment
+
+
+
+ Urgency Level
+
+
+
+
+
+ Routine
+ Urgent
+ Emergency
+
+
+
+
+ Department
+
+
+
+
+
+ Cardiology
+ Neurology
+ Orthopedics
+ Surgery
+ Internal Medicine
+
+
+
+
+
+
+
+ {/* Form Actions */}
+
+ Save Draft
+ Print
+ Submit Consultation
+
+
+
+ )
+}
diff --git a/ipdmodule/components/cross-referral-form.tsx b/ipdmodule/components/cross-referral-form.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..58a69fc5d443715cd17449b51ce8aad206fbbe3c
--- /dev/null
+++ b/ipdmodule/components/cross-referral-form.tsx
@@ -0,0 +1,252 @@
+"use client"
+
+import { useState, useEffect } from "react"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
+import { Button } from "@/components/ui/button"
+import { RichTextEditor } from "./rich-text-editor"
+import { FormNavigation } from "./form-navigation"
+import { User, FileText, AlertCircle, Calendar } from "lucide-react"
+
+export function CrossReferralForm() {
+ const [activeSection, setActiveSection] = useState("referral-info")
+ const [formData, setFormData] = useState({
+ referralInfo: "",
+ clinicalDetails: "",
+ urgency: "",
+ followUp: "",
+ })
+
+ const sections = [
+ { id: "referral-info", label: "Referral Info", icon:
},
+ { id: "clinical-details", label: "Clinical Details", icon:
},
+ { id: "urgency", label: "Urgency", icon:
},
+ { id: "follow-up", label: "Follow-up", icon:
},
+ ]
+
+ useEffect(() => {
+ const handleScroll = () => {
+ const sectionElements = sections.map((section) => ({
+ id: section.id,
+ element: document.getElementById(section.id),
+ }))
+
+ const currentSection = sectionElements.find(({ element }) => {
+ if (!element) return false
+ const rect = element.getBoundingClientRect()
+ return rect.top <= 100 && rect.bottom >= 100
+ })
+
+ if (currentSection) {
+ setActiveSection(currentSection.id)
+ }
+ }
+
+ window.addEventListener("scroll", handleScroll)
+ return () => window.removeEventListener("scroll", handleScroll)
+ }, [])
+
+ const updateFormData = (field: string, value: string) => {
+ setFormData((prev) => ({ ...prev, [field]: value }))
+ }
+
+ return (
+
+
+
+
+ {/* Referral Info Section */}
+
+
+
+
+ Referral Information
+
+
+
+
+
+ Referring Doctor
+
+
+
+ Referring Department
+
+
+
+
+
+ Internal Medicine
+ Surgery
+ Cardiology
+ Neurology
+ Orthopedics
+
+
+
+
+ Referred To
+
+
+
+ Referral Date
+
+
+
+
+ Reason for Referral
+ updateFormData("referralInfo", value)}
+ placeholder="Reason for cross-referral and specific consultation request..."
+ fieldType="chief-complaints"
+ showAutofill={true}
+ autofillSource="Referring Doctor"
+ autofillTimestamp="2024-01-15, 2:30 PM"
+ />
+
+
+
+
+ {/* Clinical Details Section */}
+
+
+
+
+ Clinical Details
+
+
+
+
+ Clinical Summary
+ updateFormData("clinicalDetails", value)}
+ placeholder="Current clinical status, relevant history, and findings..."
+ fieldType="assessment"
+ rows={6}
+ />
+
+
+
+ Current Medications
+ {}}
+ placeholder="List of current medications and dosages..."
+ fieldType="plan"
+ rows={4}
+ />
+
+
+ Relevant Investigations
+ {}}
+ placeholder="Recent lab results, imaging, and other investigations..."
+ fieldType="general"
+ rows={4}
+ showAutofill={true}
+ autofillSource="Lab System"
+ autofillTimestamp="2024-01-15, 1:00 PM"
+ />
+
+
+
+
+
+ {/* Urgency Section */}
+
+
+
+
+ Urgency & Priority
+
+
+
+
+
+ Urgency Level
+
+
+
+
+
+ Routine
+ Urgent (within 24 hours)
+ Emergency (immediate)
+
+
+
+
+ Expected Timeframe
+
+
+
+
+ Urgency Justification
+ updateFormData("urgency", value)}
+ placeholder="Justification for the urgency level and any time-sensitive concerns..."
+ fieldType="assessment"
+ rows={4}
+ />
+
+
+
+
+ {/* Follow-up Section */}
+
+
+
+
+ Follow-up Instructions
+
+
+
+
+ Follow-up Instructions
+ updateFormData("followUp", value)}
+ placeholder="Specific follow-up instructions and communication requirements..."
+ fieldType="plan"
+ rows={4}
+ />
+
+
+
+ Contact Information
+
+
+
+ Preferred Communication
+
+
+
+
+
+ Phone Call
+ Email
+ In-Person
+ Hospital System
+
+
+
+
+
+
+
+ {/* Form Actions */}
+
+ Save Draft
+ Print
+ Submit Referral
+
+
+
+ )
+}
diff --git a/ipdmodule/components/discharge-summary-form.tsx b/ipdmodule/components/discharge-summary-form.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..b5f834ef797c962f729a20b3a35c91594b54bcc4
--- /dev/null
+++ b/ipdmodule/components/discharge-summary-form.tsx
@@ -0,0 +1,1463 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
+import { Badge } from "@/components/ui/badge"
+import { Checkbox } from "@/components/ui/checkbox"
+import { Textarea } from "@/components/ui/textarea"
+import {
+ FileText,
+ Download,
+ Edit,
+ Eye,
+ Printer,
+ CheckCircle,
+ Save,
+ RefreshCw,
+ AlertCircle,
+ User,
+ Stethoscope,
+ TestTube,
+ Pill,
+ MapPin,
+ Activity,
+ Upload,
+ Calendar,
+} from "lucide-react"
+
+interface DischargeSummaryFormProps {
+ patient: any
+}
+
+interface AutofillSource {
+ source: string
+ timestamp?: string
+ available: boolean
+ data?: any
+}
+
+interface FormField {
+ value: string
+ source?: AutofillSource
+ isEdited: boolean
+ isRequired: boolean
+}
+
+export function DischargeSummaryForm({ patient }: DischargeSummaryFormProps) {
+ const [isEditing, setIsEditing] = useState(true)
+ const [isFinalized, setIsFinalized] = useState(false)
+ const [showProcedures, setShowProcedures] = useState(true)
+ const [currentUser] = useState({
+ name: "Dr. Sarah Johnson",
+ role: "Medical Officer",
+ id: "MO001",
+ })
+
+ // Form data with autofill source tracking
+ const [formData, setFormData] = useState({
+ // Patient Identification
+ patientName: {
+ value: "John Smith",
+ source: { source: "Admission Form/HIS", available: true, timestamp: "2024-01-15 09:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ age: {
+ value: "45",
+ source: { source: "Admission Form/HIS", available: true, timestamp: "2024-01-15 09:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ gender: {
+ value: "Male",
+ source: { source: "Admission Form/HIS", available: true, timestamp: "2024-01-15 09:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ uhid: {
+ value: "MRN001234",
+ source: { source: "Admission Notes", available: true, timestamp: "2024-01-15 09:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ ipdNo: {
+ value: "IPD-2024-001234",
+ source: { source: "Admission Notes", available: true, timestamp: "2024-01-15 09:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ bedNo: {
+ value: "A-101",
+ source: { source: "Admission Notes", available: true, timestamp: "2024-01-15 09:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ ward: {
+ value: "General Ward",
+ source: { source: "Admission Form/HIS", available: true, timestamp: "2024-01-15 09:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ admissionDateTime: {
+ value: "2024-01-15 14:30",
+ source: { source: "System Generated", available: true, timestamp: "2024-01-15 14:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ dischargeDateTime: {
+ value: "",
+ source: { source: "System Generated", available: false },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ referringDoctor: {
+ value: "",
+ source: { source: "Manual Entry", available: false },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ treatingConsultant: {
+ value: "Dr. Sarah Johnson",
+ source: { source: "Assignment Sheet", available: true, timestamp: "2024-01-15 09:45" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+
+ // Admission Details
+ reasonForAdmission: {
+ value: "Chest pain and shortness of breath for 2 days",
+ source: { source: "Admission Note", available: true, timestamp: "2024-01-15 15:00" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ presentingComplaints: {
+ value: "Substernal chest pain radiating to left arm, associated with dyspnea on exertion",
+ source: { source: "Initial Assessment", available: true, timestamp: "2024-01-15 15:15" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ conditionOnAdmission: {
+ value: "BP: 150/90 mmHg, HR: 95 bpm, RR: 22/min, Temp: 98.6°F, SpO2: 94% on room air",
+ source: { source: "HIS/Nursing Vitals Form", available: true, timestamp: "2024-01-15 15:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ mlcStatus: {
+ value: "No",
+ source: { source: "Admission Note", available: true, timestamp: "2024-01-15 15:00" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+
+ // Diagnosis
+ provisionalDiagnosis: {
+ value: "Acute coronary syndrome",
+ source: { source: "Admission Note", available: true, timestamp: "2024-01-15 09:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ finalDiagnosis: {
+ value: "NSTEMI (Non-ST elevation myocardial infarction)",
+ source: { source: "Final Consultant Notes", available: true, timestamp: "2024-01-18 10:30" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ icdCode: {
+ value: "I21.4",
+ source: { source: "Coding System", available: true, timestamp: "2024-01-18 10:35" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+
+ // Course in Hospital
+ chronologicalSummary: {
+ value: `Day 1: Patient admitted with chest pain, started on dual antiplatelet therapy and anticoagulation. Day 2: Cardiac enzymes elevated, ECG changes noted. Day 3: Cardiac catheterization performed showing 70% LAD stenosis. Day 4: PCI with drug-eluting stent placement. Day 5: Patient stable, ambulating, ready for discharge.`,
+ source: {
+ source: "Summarized from last 5 days of Progress Notes",
+ available: true,
+ timestamp: "2024-01-18 11:00",
+ },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ complications: {
+ value: "None",
+ source: { source: "Incident Logs/Notes", available: true, timestamp: "2024-01-18 11:00" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+
+ // Investigations
+ labSummary: {
+ value: "Troponin I: 2.5 ng/mL (elevated), CK-MB: 45 U/L (elevated), CBC: WNL, BMP: Creatinine 1.2 mg/dL",
+ source: { source: "Lab Attachments/HIS", available: true, timestamp: "2024-01-17 08:00" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ imagingFindings: {
+ value: "ECG: ST depression in leads V4-V6. Echo: EF 45%, regional wall motion abnormality in anterior wall",
+ source: { source: "Radiology Reports", available: true, timestamp: "2024-01-16 16:30" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ abnormalResults: {
+ value: "Elevated cardiac enzymes consistent with myocardial infarction. Reduced ejection fraction.",
+ source: { source: "AI-summarized, editable", available: true, timestamp: "2024-01-18 11:15" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+
+ // Treatment Given
+ ivFluidsInjections: {
+ value: "Normal Saline 1000ml over 8 hours x 2 days, Heparin 5000 units SC q12h",
+ source: { source: "Orders + Nursing Chart", available: true, timestamp: "2024-01-18 11:20" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ medicationsDuringStay: {
+ value: "Aspirin 325mg daily, Atorvastatin 80mg daily, Metoprolol 25mg BID, Lisinopril 5mg daily",
+ source: { source: "Medicine Chart / Drug Orders", available: true, timestamp: "2024-01-18 11:20" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ supportiveTherapies: {
+ value: "Cardiac rehabilitation consultation",
+ source: { source: "Physio Logs", available: true, timestamp: "2024-01-17 14:00" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+
+ // Procedures/Surgeries
+ procedureName: {
+ value: "Percutaneous Coronary Intervention (PCI)",
+ source: { source: "OT Notes", available: true, timestamp: "2024-01-17 10:00" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ procedureIndication: {
+ value: "70% stenosis of LAD artery",
+ source: { source: "OT Notes", available: true, timestamp: "2024-01-17 10:00" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ operativeFindings: {
+ value: "70% stenosis in proximal LAD, good distal flow after stent placement",
+ source: { source: "OT Report", available: true, timestamp: "2024-01-17 12:30" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ procedureSteps: {
+ value: "Right radial access, 6F sheath, coronary angiography, PCI to LAD with drug-eluting stent 3.0x18mm",
+ source: { source: "OT Report", available: true, timestamp: "2024-01-17 12:30" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ procedureOutcome: {
+ value: "Successful PCI with TIMI 3 flow, no complications",
+ source: { source: "OT Report", available: true, timestamp: "2024-01-17 12:30" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ surgeon: {
+ value: "Dr. Sarah Johnson",
+ source: { source: "OT Scheduling/Logs", available: true, timestamp: "2024-01-17 09:00" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ anesthetist: {
+ value: "Local anesthesia",
+ source: { source: "OT Scheduling/Logs", available: true, timestamp: "2024-01-17 09:00" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+
+ // Discharge Condition
+ dischargeVitals: {
+ value: "BP: 130/80 mmHg, HR: 72 bpm, RR: 16/min, Temp: 98.4°F, SpO2: 98% on room air",
+ source: { source: "Final Day Progress Note", available: true, timestamp: "2024-01-18 08:00" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ clinicalStatus: {
+ value: "Stable, ambulating, chest pain resolved, tolerating oral medications",
+ source: { source: "Final Day Progress Note", available: true, timestamp: "2024-01-18 08:00" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ comparedToAdmission: {
+ value: "Significant improvement - chest pain resolved, vitals stable, cardiac enzymes trending down",
+ source: { source: "Auto-comparison with admission vitals", available: true, timestamp: "2024-01-18 11:30" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+
+ // Discharge Medications
+ dischargeMedications: {
+ value: `1. Aspirin 75mg daily
+2. Atorvastatin 40mg at bedtime
+3. Metoprolol 25mg twice daily
+4. Lisinopril 5mg daily
+5. Clopidogrel 75mg daily x 12 months`,
+ source: { source: "Final Orders", available: true, timestamp: "2024-01-18 10:45" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+
+ // Discharge Advice
+ diet: {
+ value: "Low sodium, heart-healthy diet. Limit saturated fats.",
+ source: { source: "Consultant Notes / Templates", available: true, timestamp: "2024-01-18 10:50" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ activity: {
+ value:
+ "Gradual increase in activity. Avoid heavy lifting >10 lbs for 1 week. Cardiac rehabilitation recommended.",
+ source: { source: "Standard Template - editable", available: true, timestamp: "2024-01-18 10:50" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ warningSigns: {
+ value: "Return immediately if chest pain, shortness of breath, dizziness, or palpitations occur.",
+ source: { source: "Standard Template - editable", available: true, timestamp: "2024-01-18 10:50" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+
+ // Follow-up
+ followUpDate: {
+ value: "25/01/2024",
+ source: { source: "Follow-up Order", available: true, timestamp: "2024-01-18 10:55" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ followUpDept: {
+ value: "Cardiology",
+ source: { source: "Consultant Note", available: true, timestamp: "2024-01-18 10:55" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+ followUpDoctor: {
+ value: "Dr. Sarah Johnson",
+ source: { source: "Consultant Note", available: true, timestamp: "2024-01-18 10:55" },
+ isEdited: false,
+ isRequired: true,
+ } as FormField,
+
+ // Patient/Relative Acknowledgement
+ acknowledgement: {
+ value: "Patient/Relative has been informed about discharge instructions and medications",
+ source: { source: "Manual Entry", available: true, timestamp: "2024-01-18 11:15" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ additionalNotes: {
+ value:
+ "Patient and spouse counseled about discharge medications, dietary restrictions, and warning signs. All questions answered.",
+ source: { source: "Manual Entry", available: true, timestamp: "2024-01-18 11:15" },
+ isEdited: false,
+ isRequired: false,
+ } as FormField,
+ })
+
+ const [validationErrors, setValidationErrors] = useState
([])
+
+ // Auto-fill source indicator component
+ const AutofillIndicator = ({ field }: { field: FormField }) => {
+ if (!field.source) return null
+
+ const getIndicatorStyle = (available: boolean, isEdited: boolean) => {
+ if (isEdited) {
+ return {
+ bg: "bg-blue-50",
+ text: "text-blue-700",
+ border: "border-blue-200",
+ icon: ,
+ }
+ }
+ if (available) {
+ return {
+ bg: "bg-green-50",
+ text: "text-green-700",
+ border: "border-green-200",
+ icon: ,
+ }
+ }
+ return {
+ bg: "bg-gray-50",
+ text: "text-gray-600",
+ border: "border-gray-200",
+ icon: ,
+ }
+ }
+
+ const style = getIndicatorStyle(field.source.available, field.isEdited)
+
+ return (
+
+
+ {style.icon}
+
+ {field.isEdited
+ ? "Manually edited"
+ : field.source.available
+ ? `Auto-filled from: ${field.source.source}`
+ : `No data available from: ${field.source.source}`}
+
+ {field.source.timestamp && field.source.available && (
+ • {field.source.timestamp}
+ )}
+
+ {field.source.available && !field.isEdited && (
+
+ refreshField(Object.keys(formData).find((key) => formData[key as keyof typeof formData] === field) || "")
+ }
+ >
+
+
+ )}
+
+ )
+ }
+
+ const handleFieldChange = (fieldName: string, value: string) => {
+ setFormData((prev) => ({
+ ...prev,
+ [fieldName]: {
+ ...prev[fieldName as keyof typeof prev],
+ value,
+ isEdited: true,
+ },
+ }))
+ }
+
+ const refreshField = (fieldName: string) => {
+ alert(`Refreshing ${fieldName} from source...`)
+ }
+
+ const validateForm = () => {
+ const errors: string[] = []
+ Object.entries(formData).forEach(([key, field]) => {
+ if (field.isRequired && !field.value.trim()) {
+ errors.push(`${key.replace(/([A-Z])/g, " $1").toLowerCase()} is required`)
+ }
+ })
+ setValidationErrors(errors)
+ return errors.length === 0
+ }
+
+ const handleSave = () => {
+ if (validateForm()) {
+ console.log("Saving discharge summary:", formData)
+ alert("Discharge summary saved successfully!")
+ }
+ }
+
+ const handleFinalize = () => {
+ if (validateForm()) {
+ setIsFinalized(true)
+ setIsEditing(false)
+ alert("Discharge summary finalized and saved to patient record!")
+ }
+ }
+
+ const handleDownloadPDF = () => {
+ alert("Generating structured PDF with autofill source annotations...")
+ }
+
+ return (
+
+ {/* Header */}
+
+
+
Discharge Summary
+
+ Comprehensive discharge summary with autofill source tracking for {formData.patientName.value}
+
+
+
+ {!isFinalized && (
+
setIsEditing(!isEditing)}>
+ {isEditing ? : }
+ {isEditing ? "View Mode" : "Edit Mode"}
+
+ )}
+
+
+ Download PDF
+
+
+
+ Print
+
+
+
+
+ {/* Validation Errors */}
+ {validationErrors.length > 0 && (
+
+
+
+
+
Please complete the following required fields:
+
+
+ {validationErrors.map((error, index) => (
+ {error}
+ ))}
+
+
+
+ )}
+
+ {/* Finalization Status */}
+ {isFinalized && (
+
+
+
+
+ Discharge Summary Finalized
+
+ Final
+
+
+ by {currentUser.name} on {new Date().toLocaleString()}
+
+
+
+
+ )}
+
+
+ {/* Patient Identification */}
+
+
+
+
+ Patient Identification
+
+
+
+
+
Patient Name *
+
+ {isEditing ? (
+
handleFieldChange("patientName", e.target.value)}
+ />
+ ) : (
+
{formData.patientName.value}
+ )}
+
+
+
+
Age *
+
+ {isEditing ? (
+
handleFieldChange("age", e.target.value)} />
+ ) : (
+
{formData.age.value}
+ )}
+
+
+
+
Gender *
+
+ {isEditing ? (
+
handleFieldChange("gender", value)}>
+
+
+
+
+ Male
+ Female
+ Other
+
+
+ ) : (
+
{formData.gender.value}
+ )}
+
+
+
+
UHID *
+
+ {isEditing ? (
+
handleFieldChange("uhid", e.target.value)}
+ />
+ ) : (
+
{formData.uhid.value}
+ )}
+
+
+
+
IPD No. *
+
+ {isEditing ? (
+
handleFieldChange("ipdNo", e.target.value)}
+ />
+ ) : (
+
{formData.ipdNo.value}
+ )}
+
+
+
+
Bed No. *
+
+ {isEditing ? (
+
handleFieldChange("bedNo", e.target.value)}
+ />
+ ) : (
+
{formData.bedNo.value}
+ )}
+
+
+
+
Ward *
+
+ {isEditing ? (
+
handleFieldChange("ward", e.target.value)}
+ />
+ ) : (
+
{formData.ward.value}
+ )}
+
+
+
+
Admission Date/Time *
+
+ {isEditing ? (
+
handleFieldChange("admissionDateTime", e.target.value)}
+ />
+ ) : (
+
{formData.admissionDateTime.value}
+ )}
+
+
+
+
Discharge Date/Time *
+
+ {isEditing ? (
+
handleFieldChange("dischargeDateTime", e.target.value)}
+ placeholder="dd/mm/yyyy, --:--"
+ />
+ ) : (
+
{formData.dischargeDateTime.value || "Not set"}
+ )}
+
+
+
+
Referring Doctor/Hospital
+
+ {isEditing ? (
+
handleFieldChange("referringDoctor", e.target.value)}
+ placeholder="Optional"
+ />
+ ) : (
+
{formData.referringDoctor.value || "Not specified"}
+ )}
+
+
+
+
Treating Consultant *
+
+ {isEditing ? (
+
handleFieldChange("treatingConsultant", e.target.value)}
+ />
+ ) : (
+
{formData.treatingConsultant.value}
+ )}
+
+
+
+
+
+ {/* Admission Details */}
+
+
+
+
+ Admission Details
+
+
+
+
+
Reason for Admission *
+
+ {isEditing ? (
+
+
+
+
Presenting Complaints *
+
+ {isEditing ? (
+
+
+
+
Condition on Admission *
+
+ {isEditing ? (
+
+
+
+
MLC Status
+
+ {isEditing ? (
+
handleFieldChange("mlcStatus", value)}
+ >
+
+
+
+
+ Yes
+ No
+
+
+ ) : (
+
{formData.mlcStatus.value}
+ )}
+
+
+
+
+ {/* Diagnosis */}
+
+
+
+
+ Diagnosis
+
+
+
+
+
Provisional Diagnosis *
+
+ {isEditing ? (
+
handleFieldChange("provisionalDiagnosis", e.target.value)}
+ />
+ ) : (
+
{formData.provisionalDiagnosis.value}
+ )}
+
+
+
+
Final Diagnosis *
+
+ {isEditing ? (
+
handleFieldChange("finalDiagnosis", e.target.value)}
+ />
+ ) : (
+
{formData.finalDiagnosis.value}
+ )}
+
+
+
+
ICD Code
+
+ {isEditing ? (
+
handleFieldChange("icdCode", e.target.value)}
+ placeholder="ICD-10 Code"
+ />
+ ) : (
+
{formData.icdCode.value}
+ )}
+
+
+
+
+
+ {/* Course in Hospital */}
+
+
+
+
+ Course in Hospital
+
+
+
+
+
Chronological Summary *
+
+ {isEditing ? (
+
+
+
+
Complications
+
+ {isEditing ? (
+
+
+
+
+ {/* Investigations */}
+
+
+
+
+ Investigations
+
+
+
+
+
Lab Summary
+
+ {isEditing ? (
+
+
+
+
Imaging Findings
+
+ {isEditing ? (
+
+
+
+
Abnormal Results
+
+ {isEditing ? (
+
+
+
+
+ {/* Treatment Given */}
+
+
+
+
+ Treatment Given
+
+
+
+
+
IV Fluids, Injections, Transfusions
+
+ {isEditing ? (
+
+
+
+
Medications during Stay *
+
+ {isEditing ? (
+
+
+
+
Supportive Therapies
+
+ {isEditing ? (
+
+
+
+
+ {/* Procedures/Surgeries */}
+
+
+
+
+
+ Procedures / Surgeries
+
+
+
+
+ Patient had procedures/surgeries
+
+
+
+
+ {showProcedures && (
+
+
+
+
Procedure Name
+
+ {isEditing ? (
+
handleFieldChange("procedureName", e.target.value)}
+ placeholder="Name of procedure"
+ />
+ ) : (
+
{formData.procedureName.value}
+ )}
+
+
+
+
Indication
+
+ {isEditing ? (
+
handleFieldChange("procedureIndication", e.target.value)}
+ placeholder="Indication for procedure"
+ />
+ ) : (
+
{formData.procedureIndication.value}
+ )}
+
+
+
+
+
Operative Findings
+
+ {isEditing ? (
+
+
+
+
Procedure Steps
+
+ {isEditing ? (
+
+
+
+
Outcome
+
+ {isEditing ? (
+
+
+
+
+
Surgeon
+
+ {isEditing ? (
+
handleFieldChange("surgeon", e.target.value)}
+ placeholder="Surgeon name"
+ />
+ ) : (
+
{formData.surgeon.value}
+ )}
+
+
+
+
Anesthetist
+
+ {isEditing ? (
+
handleFieldChange("anesthetist", e.target.value)}
+ placeholder="Anesthetist name or type"
+ />
+ ) : (
+
{formData.anesthetist.value}
+ )}
+
+
+
+ )}
+
+
+ {/* Discharge Condition */}
+
+
+
+
+ Discharge Condition
+
+
+
+
+
Patient Vitals *
+
+ {isEditing ? (
+
+
+
+
Clinical Status *
+
+ {isEditing ? (
+
+
+
+
Compared to Admission
+
+ {isEditing ? (
+
+
+
+
+ {/* Discharge Medications */}
+
+
+
+
+ Discharge Medications
+
+
+
+
+
Medications *
+
+ {isEditing ? (
+
+
+
+
+ {/* Discharge Advice */}
+
+
+
+
+ Discharge Advice
+
+
+
+
+
Diet
+
+ {isEditing ? (
+
+
+
+
Activity
+
+ {isEditing ? (
+
+
+
+
Warning Signs *
+
+ {isEditing ? (
+
+
+
+
+ {/* Follow-up */}
+
+
+
+
+ Follow-up
+
+
+
+
+
Date *
+
+ {isEditing ? (
+
handleFieldChange("followUpDate", e.target.value)}
+ placeholder="DD/MM/YYYY"
+ />
+ ) : (
+
{formData.followUpDate.value}
+ )}
+
+
+
+
Department *
+
+ {isEditing ? (
+
handleFieldChange("followUpDept", e.target.value)}
+ />
+ ) : (
+
{formData.followUpDept.value}
+ )}
+
+
+
+
Doctor *
+
+ {isEditing ? (
+
handleFieldChange("followUpDoctor", e.target.value)}
+ />
+ ) : (
+
{formData.followUpDoctor.value}
+ )}
+
+
+
+
+ {/* Patient/Relative Acknowledgement */}
+
+
+
+
+ Patient/Relative Acknowledgement
+
+
+
+
+
Acknowledgement
+
+ {isEditing ? (
+
+
+
+
Additional Notes
+
+ {isEditing ? (
+
+
+
+
+ {/* Attachments */}
+
+
+
+
+ Attachments (Optional)
+
+
+
+
+
+
Upload slots for Lab Reports, Imaging, OT Notes, etc.
+
Inline reference text to note which reports are attached
+
+ Choose Files
+
+
+
+
+
+ {/* Consultant and Author Info */}
+
+
+
+
+ Consultant and Author Info
+
+
+
+
+
Consultant Name
+
{currentUser.name}
+
+
+
M.O./M.T. name
+
M.O. - Dr. Smith
+
+
+ Status
+
+ {isFinalized ? "Final" : "Draft"}
+
+
+
+
Created on
+
{new Date().toLocaleDateString()}
+
+
+
Last modified
+
{new Date().toLocaleDateString()}
+
+
+
Auto-timestamp signature
+
{new Date().toLocaleTimeString()}
+
+
+
+
+
+ {/* Action Buttons */}
+
+
* Required fields must be completed before finalizing
+
+ {isEditing && !isFinalized && (
+ <>
+
+
+ Save Draft
+
+
+
+ Finalize Summary
+
+ >
+ )}
+
+
+
+ )
+}
diff --git a/ipdmodule/components/discharge-summary.tsx b/ipdmodule/components/discharge-summary.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..a8a5018e5d5d95d57978323b826e13431216e2d3
--- /dev/null
+++ b/ipdmodule/components/discharge-summary.tsx
@@ -0,0 +1,276 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { RichTextEditor } from "./rich-text-editor"
+import { User, Home, Save, Printer } from "lucide-react"
+
+interface DischargeSummaryProps {
+ patient: any
+}
+
+export function DischargeSummary({ patient }: DischargeSummaryProps) {
+ const [summaryData, setSummaryData] = useState({
+ admissionDate: "",
+ dischargeDate: new Date().toISOString().split("T")[0],
+ lengthOfStay: "",
+ admissionDiagnosis: "",
+ finalDiagnosis: "",
+ clinicalSummary: "",
+ hospitalCourse: "",
+ proceduresPerformed: "",
+ investigations: "",
+ treatmentGiven: "",
+ conditionAtDischarge: "",
+ dischargeMedications: "",
+ followUpInstructions: "",
+ dietaryAdvice: "",
+ activityRestrictions: "",
+ warningSignsToReturn: "",
+ followUpAppointments: "",
+ })
+
+ const handleInputChange = (field: string, value: string) => {
+ setSummaryData((prev) => ({ ...prev, [field]: value }))
+ }
+
+ return (
+
+ {/* Header */}
+
+
+
Discharge Summary
+
Comprehensive discharge documentation for {patient.name}
+
+
+
+
+ Print
+
+
+
+ Save Summary
+
+
+
+
+ {/* Patient Information */}
+
+
+
+
+ Patient Information
+
+
+
+
+
+
+
+ {/* Clinical Information */}
+
+
+ Clinical Information
+
+
+
+ Admission Diagnosis
+ handleInputChange("admissionDiagnosis", value)}
+ placeholder="Enter admission diagnosis..."
+ rows={2}
+ fieldType="assessment"
+ showAutofill={true}
+ autofillSource="Admission Notes"
+ autofillTimestamp="2024-01-10, 09:15 AM"
+ />
+
+
+
+ Final Diagnosis
+ handleInputChange("finalDiagnosis", value)}
+ placeholder="Enter final diagnosis at discharge..."
+ rows={2}
+ fieldType="assessment"
+ />
+
+
+
+ Clinical Summary
+ handleInputChange("clinicalSummary", value)}
+ placeholder="Brief summary of patient's clinical presentation and course..."
+ rows={4}
+ fieldType="general"
+ />
+
+
+
+ Hospital Course
+ handleInputChange("hospitalCourse", value)}
+ placeholder="Detailed description of patient's hospital stay, treatments, and progress..."
+ rows={5}
+ fieldType="general"
+ />
+
+
+
+ Procedures Performed
+ handleInputChange("proceduresPerformed", value)}
+ placeholder="List all procedures, surgeries, or interventions performed..."
+ rows={3}
+ fieldType="ot-procedure"
+ />
+
+
+
+ Investigations
+ handleInputChange("investigations", value)}
+ placeholder="Significant laboratory results, imaging findings, and other investigations..."
+ rows={4}
+ fieldType="general"
+ />
+
+
+
+ Treatment Given
+ handleInputChange("treatmentGiven", value)}
+ placeholder="Medications, therapies, and treatments provided during admission..."
+ rows={4}
+ fieldType="plan"
+ />
+
+
+
+
+ {/* Discharge Information */}
+
+
+
+
+ Discharge Information
+
+
+
+
+ Condition at Discharge
+ handleInputChange("conditionAtDischarge", value)}
+ placeholder="Patient's condition at the time of discharge (stable, improved, etc.)..."
+ rows={2}
+ fieldType="assessment"
+ />
+
+
+
+ Discharge Medications
+ handleInputChange("dischargeMedications", value)}
+ placeholder="Complete list of medications prescribed at discharge with dosages and instructions..."
+ rows={5}
+ fieldType="plan"
+ />
+
+
+
+ Follow-up Instructions
+ handleInputChange("followUpInstructions", value)}
+ placeholder="Specific instructions for follow-up care, wound care, activity modifications..."
+ rows={4}
+ fieldType="plan"
+ />
+
+
+
+ Dietary Advice
+ handleInputChange("dietaryAdvice", value)}
+ placeholder="Dietary restrictions, recommendations, and nutritional guidance..."
+ rows={3}
+ fieldType="general"
+ />
+
+
+
+ Activity Restrictions
+ handleInputChange("activityRestrictions", value)}
+ placeholder="Physical activity limitations, work restrictions, driving restrictions..."
+ rows={3}
+ fieldType="general"
+ />
+
+
+
+ Warning Signs to Return
+ handleInputChange("warningSignsToReturn", value)}
+ placeholder="Symptoms or signs that should prompt immediate medical attention..."
+ rows={3}
+ fieldType="general"
+ />
+
+
+
+ Follow-up Appointments
+ handleInputChange("followUpAppointments", value)}
+ placeholder="Scheduled appointments with specialists, primary care, or other healthcare providers..."
+ rows={3}
+ fieldType="plan"
+ />
+
+
+
+
+ )
+}
diff --git a/ipdmodule/components/form-navigation.tsx b/ipdmodule/components/form-navigation.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..2a0adc79a8bf163c906f6080edf17b8cc79eaeb2
--- /dev/null
+++ b/ipdmodule/components/form-navigation.tsx
@@ -0,0 +1,114 @@
+"use client"
+
+import type React from "react"
+
+import { useState, useEffect } from "react"
+import { Button } from "@/components/ui/button"
+import { ChevronLeft, ChevronRight } from "lucide-react"
+import { cn } from "@/lib/utils"
+
+interface NavigationSection {
+ id: string
+ label: string
+ icon: React.ReactNode
+}
+
+interface FormNavigationProps {
+ sections: NavigationSection[]
+ activeSection: string
+ onSectionChange: (sectionId: string) => void
+ className?: string
+}
+
+export function FormNavigation({ sections, activeSection, onSectionChange, className }: FormNavigationProps) {
+ const [isCollapsed, setIsCollapsed] = useState(false)
+ const [isMobile, setIsMobile] = useState(false)
+
+ useEffect(() => {
+ const checkMobile = () => {
+ setIsMobile(window.innerWidth < 768)
+ }
+
+ checkMobile()
+ window.addEventListener("resize", checkMobile)
+ return () => window.removeEventListener("resize", checkMobile)
+ }, [])
+
+ const scrollToSection = (sectionId: string) => {
+ const element = document.getElementById(sectionId)
+ if (element) {
+ const headerOffset = 80
+ const elementPosition = element.getBoundingClientRect().top
+ const offsetPosition = elementPosition + window.pageYOffset - headerOffset
+
+ window.scrollTo({
+ top: offsetPosition,
+ behavior: "smooth",
+ })
+ }
+ onSectionChange(sectionId)
+ }
+
+ if (isMobile) {
+ return (
+
+
+ {sections.map((section) => (
+ scrollToSection(section.id)}
+ className="flex-shrink-0 text-xs px-2 py-1 h-8"
+ >
+ {section.icon}
+ {section.label}
+
+ ))}
+
+
+ )
+ }
+
+ return (
+
+
+
+
setIsCollapsed(!isCollapsed)}
+ className="w-full justify-center mb-2 h-8"
+ >
+ {isCollapsed ? : }
+
+
+
+ {sections.map((section) => (
+ scrollToSection(section.id)}
+ className={cn(
+ "w-full justify-start h-8 transition-all",
+ isCollapsed ? "px-2" : "px-3",
+ activeSection === section.id && "bg-blue-100 text-blue-700 border-l-2 border-blue-500",
+ )}
+ title={isCollapsed ? section.label : undefined}
+ >
+ {section.icon}
+ {!isCollapsed && {section.label} }
+
+ ))}
+
+
+
+
+ )
+}
diff --git a/ipdmodule/components/ipd-page.tsx b/ipdmodule/components/ipd-page.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..df9e9567136b76a39a27a7642f7619185bcd36ac
--- /dev/null
+++ b/ipdmodule/components/ipd-page.tsx
@@ -0,0 +1,416 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Input } from "@/components/ui/input"
+import {
+ ChevronLeft,
+ Search,
+ Calendar,
+ Filter,
+ MoreHorizontal,
+ Users,
+ Bed,
+ FileText,
+ Activity,
+ TestTube,
+ ReceiptTextIcon,
+ ChevronDown,
+} from "lucide-react"
+
+interface Patient {
+ id: string
+ name: string
+ patientId: string
+ age: number
+ gender: string
+ ward: string
+ room: string
+ contact: string
+ admittingDoctor: string
+ admittedOn: string
+ mrn: string
+ bed: string
+}
+
+interface IPDPageProps {
+ onPatientSelect: (patient: Patient) => void
+ onBackClick: () => void
+}
+
+export function IPDPage({ onPatientSelect, onBackClick }: IPDPageProps) {
+ const [searchTerm, setSearchTerm] = useState("")
+
+ const patients: Patient[] = [
+ {
+ id: "1",
+ name: "Tara Patil",
+ patientId: "PAT00012",
+ age: 28,
+ gender: "Male",
+ ward: "General",
+ room: "011",
+ contact: "6405065678",
+ admittingDoctor: "Dr Prudhvi Raj",
+ admittedOn: "02-01-2025",
+ mrn: "MRN001",
+ bed: "B01",
+ },
+ {
+ id: "2",
+ name: "Laila Grewal",
+ patientId: "PAT00011",
+ age: 28,
+ gender: "Female",
+ ward: "Gyn",
+ room: "002",
+ contact: "8357786893",
+ admittingDoctor: "Dr Thanuja Korlepa",
+ admittedOn: "02-01-2025",
+ mrn: "MRN002",
+ bed: "B02",
+ },
+ {
+ id: "3",
+ name: "Yagya Gahalot",
+ patientId: "PAT00010",
+ age: 28,
+ gender: "Male",
+ ward: "Opt",
+ room: "004",
+ contact: "7799729743",
+ admittingDoctor: "Dr Ramilla",
+ admittedOn: "02-01-2025",
+ mrn: "MRN003",
+ bed: "B03",
+ },
+ {
+ id: "4",
+ name: "Alaina Mahajan",
+ patientId: "PAT00009",
+ age: 28,
+ gender: "Male",
+ ward: "Neu",
+ room: "040",
+ contact: "9581468185",
+ admittingDoctor: "02-01-2025",
+ admittedOn: "02-01-2025",
+ mrn: "MRN004",
+ bed: "B04",
+ },
+ {
+ id: "5",
+ name: "Devasena",
+ patientId: "PAT00008",
+ age: 28,
+ gender: "Female",
+ ward: "Gyn",
+ room: "002",
+ contact: "8670940984",
+ admittingDoctor: "02-01-2025",
+ admittedOn: "02-01-2025",
+ mrn: "MRN005",
+ bed: "B05",
+ },
+ {
+ id: "6",
+ name: "Puravi Arakeri",
+ patientId: "PAT00007",
+ age: 28,
+ gender: "Male",
+ ward: "General",
+ room: "009",
+ contact: "7464002468",
+ admittingDoctor: "01-01-2025",
+ admittedOn: "01-01-2025",
+ mrn: "MRN006",
+ bed: "B06",
+ },
+ {
+ id: "7",
+ name: "Sragvibhushan",
+ patientId: "PAT00006",
+ age: 28,
+ gender: "Male",
+ ward: "General",
+ room: "008",
+ contact: "8542560341",
+ admittingDoctor: "01-01-2025",
+ admittedOn: "01-01-2025",
+ mrn: "MRN007",
+ bed: "B07",
+ },
+ {
+ id: "8",
+ name: "Aryan Hanagandi",
+ patientId: "PAT00005",
+ age: 28,
+ gender: "Female",
+ ward: "General",
+ room: "010",
+ contact: "9763087109",
+ admittingDoctor: "01-01-2025",
+ admittedOn: "01-01-2025",
+ mrn: "MRN008",
+ bed: "B08",
+ },
+ ]
+
+ const filteredPatients = patients.filter(
+ (patient) =>
+ patient.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
+ patient.patientId.toLowerCase().includes(searchTerm.toLowerCase()) ||
+ patient.contact.includes(searchTerm) ||
+ patient.room.includes(searchTerm),
+ )
+
+ return (
+
+ {/* Header */}
+
+
+
+
+
+
IPD
+
+
+
+ Tutorial
+
+
+
+ Hospital Name
+
+
+
+
+
+
+
+ {/* Left Sidebar */}
+
+ {/* Active indicator positioned for InPatients */}
+
+
+
+
+
+
+
+
+
+
+
+
+ Ward Manager
+
+
+
+
+
+
+
+
+
+
+
+
+ IPD Billing
+
+
+
+
+
+ {/* Main Content */}
+
+ {/* Yellow Background Section - 200px height */}
+
+ {/* InPatients Heading - Outside the white frame */}
+
+
InPatients
+
+
+
+ {/* White Content Frame - Overlapping yellow background */}
+
+ {/* Summary Cards Section */}
+
+
+
+
Total No of wards
+
04
+
+
+
Total Beds Occupied
+
+ 14/24
+
+
+
+
+
+ {/* Patient List Section */}
+
+ {/* Search and Filters */}
+
+
+
+ setSearchTerm(e.target.value)}
+ className="pl-10 border-[#e2e2ea] h-10 text-sm placeholder:text-[#92929d]"
+ />
+
+
+
+
+ Filter by Ward
+
+
+
+ Filter by Doctor
+
+
+
+ Today
+
+
+
+
+
+ {/* Patient Count */}
+
+
+ {/* Patient Table */}
+
+
+
+
+
+ #
+
+
+ PATIENT DETAILS
+
+
+ PATIENT ID
+
+
+ Ward/Room
+
+
+ CONTACT
+
+
+ Admitting Doctor
+
+
+ Admitted on
+
+
+ ACTION
+
+
+
+
+ {filteredPatients.map((patient, index) => (
+
+ {index + 1}
+
+
+
onPatientSelect?.(patient)}
+ >
+ {patient.name}
+
+
+ {patient.gender}, {patient.age}y
+
+
+
+ {patient.patientId}
+
+ {patient.ward}/ {patient.room}
+
+ {patient.contact}
+ {patient.admittingDoctor}
+ {patient.admittedOn}
+
+
+ onPatientSelect?.(patient)}
+ >
+ View Details
+
+
+
+
+
+
+
+ ))}
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/ipdmodule/components/ipd-patient-details.tsx b/ipdmodule/components/ipd-patient-details.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..0a6bc5f2abd01d5173c100745ec1ce3595317c08
--- /dev/null
+++ b/ipdmodule/components/ipd-patient-details.tsx
@@ -0,0 +1,414 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
+import { Badge } from "@/components/ui/badge"
+import {
+ ChevronLeft,
+ User,
+ Calendar,
+ MapPin,
+ Phone,
+ FileText,
+ Activity,
+ TestTube,
+ Stethoscope,
+ ClipboardList,
+ Heart,
+} from "lucide-react"
+
+interface Patient {
+ id: string
+ name: string
+ patientId: string
+ age: number
+ gender: string
+ ward: string
+ room: string
+ contact: string
+ admittingDoctor: string
+ admittedOn: string
+}
+
+interface IPDPatientDetailsProps {
+ patient: Patient
+ onBackClick: () => void
+}
+
+export function IPDPatientDetails({ patient, onBackClick }: IPDPatientDetailsProps) {
+ const [activeTab, setActiveTab] = useState("progress-notes")
+
+ return (
+
+ {/* Header */}
+
+
+
+
+
+
Patient Details
+
+
+
+ {/* Patient Header Card */}
+
+
+
+
+
+
+
+
{patient.name}
+
+ {patient.gender}, {patient.age} years old
+
+
+ {patient.patientId}
+
+
+
+
+
+
+
+
+
Ward/Room
+
+ {patient.ward}/{patient.room}
+
+
+
+
+
+
+
Contact
+
{patient.contact}
+
+
+
+
+
+
Admitting Doctor
+
{patient.admittingDoctor}
+
+
+
+
+
+
Admitted On
+
{patient.admittedOn}
+
+
+
+
+
+
+ {/* Tabs Section */}
+
+
+
+
+
+ Progress Notes
+
+
+
+ Existing IPD
+
+
+
+ OPD History
+
+
+
+ Assessments
+
+
+
+ Lab & Radiology
+
+
+
+ Activity Logs
+
+
+
+
+
+
+
+ Progress Notes
+
+
+
+
+
+
Daily Progress Note
+ 02-01-2025 10:30 AM
+
+
+ Patient is stable and responding well to treatment. Vital signs are within normal limits.
+
+
Dr. Prudhvi Raj
+
+
+
+
Nursing Note
+ 01-01-2025 08:00 PM
+
+
+ Patient comfortable, no complaints. Medications administered as prescribed.
+
+
Nurse Sarah Johnson
+
+
+
+
+
+
+
+
+
+ Current IPD Details
+
+
+
+
+
Admission Information
+
+
+ Admission Date:
+ {patient.admittedOn}
+
+
+ Length of Stay:
+ 2 days
+
+
+ Admission Type:
+ Emergency
+
+
+
+
+
Current Status
+
+
+ Status:
+ Stable
+
+
+ Diet:
+ Regular
+
+
+ Activity Level:
+ Bed Rest
+
+
+
+
+
+
+
+
+
+
+
+ OPD Consultation History
+
+
+
+
+
+
General Medicine Consultation
+ 28-12-2024
+
+
Chief Complaint: Fever and body ache for 3 days
+
Dr. Prudhvi Raj
+
+
+
+
Follow-up Consultation
+ 25-12-2024
+
+
Routine check-up, all parameters normal
+
Dr. Prudhvi Raj
+
+
+
+
+
+
+
+
+
+ Clinical Assessments
+
+
+
+
+
Vital Signs
+
+
+ Blood Pressure:
+ 120/80 mmHg
+
+
+ Heart Rate:
+ 72 bpm
+
+
+ Temperature:
+ 98.6°F
+
+
+ Respiratory Rate:
+ 16/min
+
+
+
+
+
Physical Examination
+
+
+ General Appearance:
+ Alert & Oriented
+
+
+ Cardiovascular:
+ Normal
+
+
+ Respiratory:
+ Clear
+
+
+ Neurological:
+ Intact
+
+
+
+
+
+
+
+
+
+
+
+ Lab Results & Radiology
+
+
+
+
+
Recent Lab Results
+
+
+
+
+ Test
+ Result
+ Reference Range
+ Date
+
+
+
+
+ Hemoglobin
+ 12.5 g/dL
+ 12.0-15.5 g/dL
+ 02-01-2025
+
+
+ White Blood Cells
+ 7,200/μL
+ 4,000-11,000/μL
+ 02-01-2025
+
+
+
+
+
+
+
Radiology Reports
+
+
+
Chest X-Ray
+ 01-01-2025
+
+
Normal chest X-ray. No acute cardiopulmonary abnormalities.
+
+
+
+
+
+
+
+
+
+
+ Activity Logs
+
+
+
+
+
+
+
+ Medication administered
+ 02-01-2025 10:30 AM
+
+
Paracetamol 500mg administered by Nurse Sarah
+
+
+
+
+
+
+ Vital signs recorded
+ 02-01-2025 08:00 AM
+
+
BP: 120/80, HR: 72, Temp: 98.6°F
+
+
+
+
+
+
+ Doctor's round
+ 01-01-2025 06:00 PM
+
+
Dr. Prudhvi Raj completed evening rounds
+
+
+
+
+
+
+
+
+
+
+ )
+}
diff --git a/ipdmodule/components/ipd-patient-flow.tsx b/ipdmodule/components/ipd-patient-flow.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..f32e5812e532a4e33f88ea347c0c36344d1eda9f
--- /dev/null
+++ b/ipdmodule/components/ipd-patient-flow.tsx
@@ -0,0 +1,171 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent } from "@/components/ui/card"
+import { Badge } from "@/components/ui/badge"
+import { Input } from "@/components/ui/input"
+import { Search, Plus, Filter, MoreHorizontal, ArrowLeft } from "lucide-react"
+import { AdmissionAssessment } from "./admission-assessment"
+
+const mockPatients = [
+ {
+ id: 1,
+ name: "John Doe",
+ age: 45,
+ gender: "Male",
+ admissionDate: "2024-01-15",
+ condition: "Stable",
+ room: "A-101",
+ doctor: "Dr. Smith",
+ },
+ {
+ id: 2,
+ name: "Jane Smith",
+ age: 32,
+ gender: "Female",
+ admissionDate: "2024-01-14",
+ condition: "Critical",
+ room: "B-205",
+ doctor: "Dr. Johnson",
+ },
+ {
+ id: 3,
+ name: "Robert Wilson",
+ age: 67,
+ gender: "Male",
+ admissionDate: "2024-01-13",
+ condition: "Stable",
+ room: "C-301",
+ doctor: "Dr. Brown",
+ },
+]
+
+export function IPDPatientFlow() {
+ const [selectedPatient, setSelectedPatient] = useState(null)
+ const [searchTerm, setSearchTerm] = useState("")
+
+ const filteredPatients = mockPatients.filter((patient) =>
+ patient.name.toLowerCase().includes(searchTerm.toLowerCase()),
+ )
+
+ const getConditionColor = (condition: string) => {
+ switch (condition.toLowerCase()) {
+ case "critical":
+ return "bg-red-100 text-red-800"
+ case "stable":
+ return "bg-green-100 text-green-800"
+ case "moderate":
+ return "bg-yellow-100 text-yellow-800"
+ default:
+ return "bg-gray-100 text-gray-800"
+ }
+ }
+
+ if (selectedPatient) {
+ const patient = mockPatients.find((p) => p.id === selectedPatient)
+ return (
+
+
+
setSelectedPatient(null)} className="mb-4">
+
+ Back to Patient List
+
+
IPD Patient Details - {patient?.name}
+
+
+
+ )
+ }
+
+ return (
+
+
+
IPD Patient Management
+
Manage in-patient department patients and their care
+
+
+ {/* Search and Actions */}
+
+
+
+
+ setSearchTerm(e.target.value)}
+ className="pl-10 w-80"
+ />
+
+
+
+
+
+
+
+ New Admission
+
+
+
+ {/* Patient List */}
+
+ {filteredPatients.map((patient) => (
+
+
+
+
+
+ {patient.name
+ .split(" ")
+ .map((n) => n[0])
+ .join("")}
+
+
+
{patient.name}
+
+ {patient.age} years • {patient.gender}
+
+
+
+
+
+
+
Room
+
{patient.room}
+
+
+
Doctor
+
{patient.doctor}
+
+
+
Admitted
+
{new Date(patient.admissionDate).toLocaleDateString()}
+
+
{patient.condition}
+
+ setSelectedPatient(patient.id)}
+ className="bg-[#4b4ad5] hover:bg-[#4b4ad5]/90"
+ >
+ View Details
+
+
+
+
+
+
+
+
+
+ ))}
+
+
+ {filteredPatients.length === 0 && (
+
+
No patients found
+
Try adjusting your search criteria
+
+ )}
+
+ )
+}
diff --git a/ipdmodule/components/ipd-patient-list.tsx b/ipdmodule/components/ipd-patient-list.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..d77a342021903beba64351bf111ef4fe0bebac8a
--- /dev/null
+++ b/ipdmodule/components/ipd-patient-list.tsx
@@ -0,0 +1,215 @@
+"use client"
+
+import { useState } from "react"
+import { Card, CardContent } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Button } from "@/components/ui/button"
+import { Badge } from "@/components/ui/badge"
+import { Search, Filter, User, MapPin, Calendar, Stethoscope } from "lucide-react"
+
+interface Patient {
+ id: string
+ name: string
+ mrn: string
+ age: number
+ gender: string
+ ward: string
+ bed: string
+ admissionDate: string
+ diagnosis: string
+ consultant: string
+}
+
+interface IPDPatientListProps {
+ onPatientSelect: (patient: Patient) => void
+}
+
+export function IPDPatientList({ onPatientSelect }: IPDPatientListProps) {
+ const [searchTerm, setSearchTerm] = useState("")
+ const [selectedWard, setSelectedWard] = useState("all")
+
+ const patients: Patient[] = [
+ {
+ id: "1",
+ name: "John Smith",
+ mrn: "MRN001234",
+ age: 45,
+ gender: "Male",
+ ward: "General Ward",
+ bed: "A-101",
+ admissionDate: "2024-01-15",
+ diagnosis: "Acute Myocardial Infarction",
+ consultant: "Dr. Sarah Johnson",
+ },
+ {
+ id: "2",
+ name: "Mary Johnson",
+ mrn: "MRN001235",
+ age: 62,
+ gender: "Female",
+ ward: "ICU",
+ bed: "ICU-05",
+ admissionDate: "2024-01-16",
+ diagnosis: "Pneumonia with Respiratory Failure",
+ consultant: "Dr. Michael Chen",
+ },
+ {
+ id: "3",
+ name: "Robert Davis",
+ mrn: "MRN001236",
+ age: 38,
+ gender: "Male",
+ ward: "Surgical Ward",
+ bed: "S-203",
+ admissionDate: "2024-01-17",
+ diagnosis: "Acute Appendicitis",
+ consultant: "Dr. Lisa Wang",
+ },
+ {
+ id: "4",
+ name: "Emily Wilson",
+ mrn: "MRN001237",
+ age: 29,
+ gender: "Female",
+ ward: "Maternity Ward",
+ bed: "M-108",
+ admissionDate: "2024-01-18",
+ diagnosis: "Normal Delivery",
+ consultant: "Dr. James Brown",
+ },
+ {
+ id: "5",
+ name: "David Miller",
+ mrn: "MRN001238",
+ age: 71,
+ gender: "Male",
+ ward: "General Ward",
+ bed: "A-205",
+ admissionDate: "2024-01-19",
+ diagnosis: "Diabetes Mellitus with Complications",
+ consultant: "Dr. Sarah Johnson",
+ },
+ ]
+
+ const wards = ["all", "General Ward", "ICU", "Surgical Ward", "Maternity Ward"]
+
+ const filteredPatients = patients.filter((patient) => {
+ const matchesSearch =
+ patient.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
+ patient.mrn.toLowerCase().includes(searchTerm.toLowerCase()) ||
+ patient.diagnosis.toLowerCase().includes(searchTerm.toLowerCase())
+
+ const matchesWard = selectedWard === "all" || patient.ward === selectedWard
+
+ return matchesSearch && matchesWard
+ })
+
+ return (
+
+ {/* Header */}
+
+
+
IPD Patient List
+
Select a patient to view their medical records
+
+
+ {filteredPatients.length} Patients
+
+
+
+ {/* Search and Filter */}
+
+
+
+ setSearchTerm(e.target.value)}
+ className="pl-10"
+ />
+
+
+
+ setSelectedWard(e.target.value)}
+ className="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
+ >
+ {wards.map((ward) => (
+
+ {ward === "all" ? "All Wards" : ward}
+
+ ))}
+
+
+
+
+ {/* Patient Cards */}
+
+ {filteredPatients.map((patient) => (
+
onPatientSelect(patient)}
+ >
+
+
+
+
+
+
{patient.name}
+
+ {patient.age}Y {patient.gender}
+
+
+
+
+
+ MRN:
+ {patient.mrn}
+
+
+
+
+ {patient.ward} - {patient.bed}
+
+
+
+
+ Admitted: {patient.admissionDate}
+
+
+
+
+
+ {patient.diagnosis}
+
+
+
+
+
+ {patient.consultant}
+
+
+ View Records
+
+
+
+
+
+ ))}
+
+
+ {/* Empty State */}
+ {filteredPatients.length === 0 && (
+
+
+
+ No patients found
+ Try adjusting your search criteria or filters
+
+
+ )}
+
+ )
+}
diff --git a/ipdmodule/components/ipd-patient-module.tsx b/ipdmodule/components/ipd-patient-module.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..990799e1cad67b439237d70662e636c6ae84576e
--- /dev/null
+++ b/ipdmodule/components/ipd-patient-module.tsx
@@ -0,0 +1,445 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import {
+ ChevronLeft,
+ User,
+ Calendar,
+ MapPin,
+ Stethoscope,
+ FileText,
+ TestTube,
+ ClipboardList,
+ Plus,
+ History,
+ Scissors,
+ ArrowLeftRight,
+ FolderOpen,
+ Home,
+ BarChart3,
+} from "lucide-react"
+
+// Import form components
+import { AdmissionAssessmentForm } from "./admission-assessment-form"
+import { ProgressNotesForm } from "./progress-notes-form"
+import { ConsultantNotesForm } from "./consultant-notes-form"
+import { OTNotesForm } from "./ot-notes-form"
+import { CrossReferralForm } from "./cross-referral-form"
+import { DischargeSummaryForm } from "./discharge-summary-form"
+import { LabRadiologyTab } from "./lab-radiology-tab"
+import { ActivityLogsTab } from "./activity-logs-tab"
+
+interface Patient {
+ id: string
+ name: string
+ patientId: string
+ age: number
+ gender: string
+ ward: string
+ room: string
+ contact: string
+ admittingDoctor: string
+ admittedOn: string
+ mrn: string
+ bed: string
+}
+
+interface IPDPatientModuleProps {
+ patient: Patient
+ onBackClick: () => void
+}
+
+interface SavedData {
+ assessments: any[]
+ progressNotes: any[]
+ consultantNotes: any[]
+ otNotes: any[]
+ crossReferrals: any[]
+ dischargeSummaries: any[]
+}
+
+export function IPDPatientModule({ patient, onBackClick }: IPDPatientModuleProps) {
+ const [activeSection, setActiveSection] = useState("assessment")
+ const [currentView, setCurrentView] = useState("list") // 'list', 'form', 'preview'
+ const [savedData, setSavedData] = useState({
+ assessments: [],
+ progressNotes: [],
+ consultantNotes: [],
+ otNotes: [],
+ crossReferrals: [],
+ dischargeSummaries: [],
+ })
+
+ const sidebarItems = [
+ { id: "opd-history", label: "OPD Visit History", icon: History },
+ { id: "assessment", label: "Assessment", icon: ClipboardList },
+ { id: "progress-notes", label: "Progress Notes", icon: FileText },
+ { id: "consultant-notes", label: "Consultant Notes", icon: Stethoscope },
+ { id: "ot-details", label: "OT Details", icon: Scissors },
+ { id: "lab-reports", label: "Lab Reports", icon: TestTube },
+ { id: "cross-referral", label: "Cross Referral", icon: ArrowLeftRight },
+ { id: "medical-records", label: "Medical Records", icon: FolderOpen },
+ { id: "discharge-summary", label: "Discharge Summary", icon: Home },
+ { id: "activity-logs", label: "Activity Logs", icon: BarChart3 },
+ ]
+
+ const handleSectionChange = (sectionId: string) => {
+ setActiveSection(sectionId)
+ setCurrentView("list")
+ }
+
+ const handleAddNew = () => {
+ setCurrentView("form")
+ }
+
+ const handleSave = (data: any) => {
+ const newData = { ...savedData }
+ const timestamp = new Date().toISOString()
+ const dataWithTimestamp = { ...data, id: Date.now().toString(), timestamp }
+
+ switch (activeSection) {
+ case "assessment":
+ newData.assessments.push(dataWithTimestamp)
+ break
+ case "progress-notes":
+ newData.progressNotes.push(dataWithTimestamp)
+ break
+ case "consultant-notes":
+ newData.consultantNotes.push(dataWithTimestamp)
+ break
+ case "ot-details":
+ newData.otNotes.push(dataWithTimestamp)
+ break
+ case "cross-referral":
+ newData.crossReferrals.push(dataWithTimestamp)
+ break
+ case "discharge-summary":
+ newData.dischargeSummaries.push(dataWithTimestamp)
+ break
+ }
+
+ setSavedData(newData)
+ setCurrentView("list")
+ }
+
+ const handleCancel = () => {
+ setCurrentView("list")
+ }
+
+ const renderEmptyState = (title: string, description: string, buttonText: string) => (
+
+
+
+
+
+
{title}
+
{description}
+
+
+ {buttonText}
+
+
+
+ )
+
+ const renderSavedItems = (items: any[], title: string, buttonText: string) => (
+
+
+
{title}
+
+
+ {buttonText}
+
+
+
+ {items.map((item) => (
+
+
+
+
+ {activeSection === "assessment" && "Admission Assessment"}
+ {activeSection === "progress-notes" && "Progress Note"}
+ {activeSection === "consultant-notes" && "Consultant Note"}
+ {activeSection === "ot-details" && "OT Note"}
+ {activeSection === "cross-referral" && "Cross Referral"}
+ {activeSection === "discharge-summary" && "Discharge Summary"}
+
+
+ {new Date(item.timestamp).toLocaleDateString()} {new Date(item.timestamp).toLocaleTimeString()}
+
+
+
+
+
+ {item.chiefComplaint ||
+ item.clinicalSummary ||
+ item.procedureName ||
+ item.reasonForReferral ||
+ "Saved entry"}
+
+
+
+ View Details
+
+
+ Edit
+
+
+
+
+ ))}
+
+
+ )
+
+ const renderMainContent = () => {
+ if (currentView === "form") {
+ switch (activeSection) {
+ case "assessment":
+ return
+ case "progress-notes":
+ return
+ case "consultant-notes":
+ return
+ case "ot-details":
+ return
+ case "cross-referral":
+ return
+ case "discharge-summary":
+ return
+ default:
+ return Form not implemented
+ }
+ }
+
+ // List view
+ switch (activeSection) {
+ case "opd-history":
+ return (
+
+
OPD Visit History
+
+
+
+
+ General Medicine Consultation
+ 28-12-2024
+
+
+
+ Chief Complaint: Fever and body ache for 3 days
+ Dr. {patient.admittingDoctor}
+
+
+
+
+
+ Follow-up Consultation
+ 25-12-2024
+
+
+
+ Routine check-up, all parameters normal
+ Dr. {patient.admittingDoctor}
+
+
+
+
+ )
+
+ case "assessment":
+ return savedData.assessments.length > 0
+ ? renderSavedItems(savedData.assessments, "Assessment", "Add Assessment")
+ : renderEmptyState(
+ "No Assessment Available",
+ "Start documenting patient assessments to track clinical progress and treatment plans.",
+ "Add Assessment",
+ )
+
+ case "progress-notes":
+ return savedData.progressNotes.length > 0
+ ? renderSavedItems(savedData.progressNotes, "Progress Notes", "Add Progress Note")
+ : renderEmptyState(
+ "No Progress Notes Available",
+ "Document daily progress notes to track patient recovery and treatment response.",
+ "Add Progress Note",
+ )
+
+ case "consultant-notes":
+ return savedData.consultantNotes.length > 0
+ ? renderSavedItems(savedData.consultantNotes, "Consultant Notes", "Add Consultant Note")
+ : renderEmptyState(
+ "No Consultant Notes Available",
+ "Record specialist consultations and expert recommendations for comprehensive care.",
+ "Add Consultant Note",
+ )
+
+ case "ot-details":
+ return savedData.otNotes.length > 0
+ ? renderSavedItems(savedData.otNotes, "OT Details", "Add OT Note")
+ : renderEmptyState(
+ "No OT Details Available",
+ "Document surgical procedures and operative details for complete medical records.",
+ "Add OT Note",
+ )
+
+ case "lab-reports":
+ return
+
+ case "cross-referral":
+ return savedData.crossReferrals.length > 0
+ ? renderSavedItems(savedData.crossReferrals, "Cross Referrals", "Add Cross Referral")
+ : renderEmptyState(
+ "No Cross Referrals Available",
+ "Create referrals to other departments or specialists for comprehensive patient care.",
+ "Add Cross Referral",
+ )
+
+ case "medical-records":
+ return (
+
+
Medical Records
+
+
+
+ Lab Reports
+
+
+ Latest blood work and diagnostic tests
+
+ View Reports
+
+
+
+
+
+ Imaging Studies
+
+
+ X-rays, CT scans, and MRI reports
+
+ View Images
+
+
+
+
+
+ Prescriptions
+
+
+ Current and past medications
+
+ View Prescriptions
+
+
+
+
+
+ )
+
+ case "discharge-summary":
+ return savedData.dischargeSummaries.length > 0
+ ? renderSavedItems(savedData.dischargeSummaries, "Discharge Summaries", "Add Discharge Summary")
+ : renderEmptyState(
+ "No Discharge Summary Available",
+ "Create comprehensive discharge summaries for patient care continuity.",
+ "Add Discharge Summary",
+ )
+
+ case "activity-logs":
+ return
+
+ default:
+ return renderEmptyState("Coming Soon", "This feature is under development.", "Add New")
+ }
+ }
+
+ return (
+
+ {/* Header */}
+
+
+
+
+
+
Patient Module
+
+
+
+ Tutorial
+
+
+ Hospital Name
+
+
+
+
+
+ {/* Left Sidebar */}
+
+ {/* Patient Info */}
+
+
+
+
+
+
+
{patient.name}
+
+ {patient.gender}, {patient.age}Y | {patient.patientId}
+
+
+
+
+
+
+
+ {patient.ward} - {patient.room}
+
+
+
+
+ Admitted: {patient.admittedOn}
+
+
+
+
+ {/* Navigation */}
+
+ {sidebarItems.map((item) => {
+ const Icon = item.icon
+ const isActive = activeSection === item.id
+ return (
+ handleSectionChange(item.id)}
+ className={`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#f1f1f5] transition-colors ${
+ isActive ? "bg-[#4b4ad5] text-white" : "text-[#44444f]"
+ }`}
+ >
+
+ {item.label}
+
+ )
+ })}
+
+
+
+ {/* Main Content */}
+
+ {/* Section Header */}
+
+
+ {sidebarItems.find((item) => item.id === activeSection)?.label}
+
+
+
+ {/* Content Area */}
+ {renderMainContent()}
+
+
+
+ )
+}
diff --git a/ipdmodule/components/lab-radiology-tab.tsx b/ipdmodule/components/lab-radiology-tab.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..079e8b83c5d85f21c5661307afabe472200132fb
--- /dev/null
+++ b/ipdmodule/components/lab-radiology-tab.tsx
@@ -0,0 +1,646 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
+import { Badge } from "@/components/ui/badge"
+import { Checkbox } from "@/components/ui/checkbox"
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
+import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
+import {
+ Download,
+ Eye,
+ TrendingUp,
+ TrendingDown,
+ Minus,
+ AlertTriangle,
+ CheckCircle,
+ Plus,
+ Search,
+ X,
+ ImageIcon,
+ Activity,
+} from "lucide-react"
+
+interface LabRadiologyTabProps {
+ patient: any
+}
+
+interface LabResult {
+ id: string
+ testName: string
+ parameter: string
+ value: string
+ unit: string
+ normalRange: string
+ status: "normal" | "high" | "low" | "critical"
+ date: string
+ time: string
+ reportedBy: string
+ selectedForDischarge: boolean
+}
+
+interface RadiologyReport {
+ id: string
+ examType: string
+ bodyPart: string
+ findings: string
+ impression: string
+ date: string
+ time: string
+ radiologist: string
+ status: "pending" | "reported" | "reviewed"
+ selectedForDischarge: boolean
+ imageUrl?: string
+}
+
+export function LabRadiologyTab({ patient }: LabRadiologyTabProps) {
+ const [activeTab, setActiveTab] = useState("lab-results")
+ const [searchTerm, setSearchTerm] = useState("")
+ const [dateFilter, setDateFilter] = useState("all")
+ const [statusFilter, setStatusFilter] = useState("all")
+
+ // Sample lab results data with date-wise comparison
+ const [labResults, setLabResults] = useState([
+ {
+ id: "lab-001",
+ testName: "Complete Blood Count (CBC)",
+ parameter: "Hemoglobin (Hb)",
+ value: "7.2",
+ unit: "g/dL",
+ normalRange: "12.0-15.5",
+ status: "low",
+ date: "2024-01-18",
+ time: "08:30",
+ reportedBy: "Dr. Pathology",
+ selectedForDischarge: true,
+ },
+ {
+ id: "lab-002",
+ testName: "Complete Blood Count (CBC)",
+ parameter: "White Blood Cells (WBC)",
+ value: "12,500",
+ unit: "/μL",
+ normalRange: "4,000-11,000",
+ status: "high",
+ date: "2024-01-18",
+ time: "08:30",
+ reportedBy: "Dr. Pathology",
+ selectedForDischarge: true,
+ },
+ {
+ id: "lab-003",
+ testName: "Complete Blood Count (CBC)",
+ parameter: "Platelets",
+ value: "180,000",
+ unit: "/μL",
+ normalRange: "150,000-450,000",
+ status: "normal",
+ date: "2024-01-18",
+ time: "08:30",
+ reportedBy: "Dr. Pathology",
+ selectedForDischarge: false,
+ },
+ {
+ id: "lab-004",
+ testName: "Liver Function Test (LFT)",
+ parameter: "ALT",
+ value: "45",
+ unit: "U/L",
+ normalRange: "7-35",
+ status: "high",
+ date: "2024-01-17",
+ time: "14:15",
+ reportedBy: "Dr. Pathology",
+ selectedForDischarge: true,
+ },
+ {
+ id: "lab-005",
+ testName: "Kidney Function Test",
+ parameter: "Creatinine",
+ value: "1.8",
+ unit: "mg/dL",
+ normalRange: "0.6-1.2",
+ status: "high",
+ date: "2024-01-17",
+ time: "14:15",
+ reportedBy: "Dr. Pathology",
+ selectedForDischarge: true,
+ },
+ // Previous day results for comparison
+ {
+ id: "lab-006",
+ testName: "Complete Blood Count (CBC)",
+ parameter: "Hemoglobin (Hb)",
+ value: "6.8",
+ unit: "g/dL",
+ normalRange: "12.0-15.5",
+ status: "critical",
+ date: "2024-01-16",
+ time: "09:00",
+ reportedBy: "Dr. Pathology",
+ selectedForDischarge: false,
+ },
+ {
+ id: "lab-007",
+ testName: "Complete Blood Count (CBC)",
+ parameter: "White Blood Cells (WBC)",
+ value: "15,200",
+ unit: "/μL",
+ normalRange: "4,000-11,000",
+ status: "high",
+ date: "2024-01-16",
+ time: "09:00",
+ reportedBy: "Dr. Pathology",
+ selectedForDischarge: false,
+ },
+ ])
+
+ // Sample radiology reports data
+ const [radiologyReports, setRadiologyReports] = useState([
+ {
+ id: "rad-001",
+ examType: "Chest X-Ray",
+ bodyPart: "Chest",
+ findings: "Bilateral lower lobe consolidation with air bronchograms. No pleural effusion. Heart size normal.",
+ impression: "Bilateral pneumonia",
+ date: "2024-01-18",
+ time: "10:30",
+ radiologist: "Dr. Radiology Smith",
+ status: "reported",
+ selectedForDischarge: true,
+ imageUrl: "/placeholder.svg?height=300&width=400&text=Chest+X-Ray",
+ },
+ {
+ id: "rad-002",
+ examType: "CT Chest",
+ bodyPart: "Chest",
+ findings:
+ "Multiple ground glass opacities in bilateral lungs. No mediastinal lymphadenopathy. No pleural effusion.",
+ impression: "Viral pneumonia, COVID-19 suspected",
+ date: "2024-01-17",
+ time: "16:45",
+ radiologist: "Dr. Radiology Johnson",
+ status: "reported",
+ selectedForDischarge: true,
+ imageUrl: "/placeholder.svg?height=300&width=400&text=CT+Chest",
+ },
+ {
+ id: "rad-003",
+ examType: "Ultrasound Abdomen",
+ bodyPart: "Abdomen",
+ findings: "Liver shows normal echogenicity. Gallbladder normal. Kidneys show normal size and echogenicity.",
+ impression: "Normal abdominal ultrasound",
+ date: "2024-01-16",
+ time: "11:20",
+ radiologist: "Dr. Radiology Brown",
+ status: "reported",
+ selectedForDischarge: false,
+ },
+ ])
+
+ const getStatusColor = (status: string) => {
+ switch (status) {
+ case "critical":
+ return "bg-red-100 text-red-800 border-red-200"
+ case "high":
+ return "bg-orange-100 text-orange-800 border-orange-200"
+ case "low":
+ return "bg-yellow-100 text-yellow-800 border-yellow-200"
+ case "normal":
+ return "bg-green-100 text-green-800 border-green-200"
+ case "pending":
+ return "bg-gray-100 text-gray-800 border-gray-200"
+ case "reported":
+ return "bg-blue-100 text-blue-800 border-blue-200"
+ case "reviewed":
+ return "bg-green-100 text-green-800 border-green-200"
+ default:
+ return "bg-gray-100 text-gray-800 border-gray-200"
+ }
+ }
+
+ const getStatusIcon = (status: string) => {
+ switch (status) {
+ case "critical":
+ return
+ case "high":
+ return
+ case "low":
+ return
+ case "normal":
+ return
+ default:
+ return
+ }
+ }
+
+ const toggleLabSelection = (labId: string) => {
+ setLabResults((prev) =>
+ prev.map((lab) => (lab.id === labId ? { ...lab, selectedForDischarge: !lab.selectedForDischarge } : lab)),
+ )
+ }
+
+ const toggleRadiologySelection = (reportId: string) => {
+ setRadiologyReports((prev) =>
+ prev.map((report) =>
+ report.id === reportId ? { ...report, selectedForDischarge: !report.selectedForDischarge } : report,
+ ),
+ )
+ }
+
+ const getSelectedLabResults = () => {
+ return labResults.filter((lab) => lab.selectedForDischarge)
+ }
+
+ const getSelectedRadiologyReports = () => {
+ return radiologyReports.filter((report) => report.selectedForDischarge)
+ }
+
+ // Group lab results by parameter for trend analysis
+ const getParameterTrends = () => {
+ const trends: { [key: string]: LabResult[] } = {}
+ labResults.forEach((lab) => {
+ if (!trends[lab.parameter]) {
+ trends[lab.parameter] = []
+ }
+ trends[lab.parameter].push(lab)
+ })
+
+ // Sort by date for each parameter
+ Object.keys(trends).forEach((param) => {
+ trends[param].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
+ })
+
+ return trends
+ }
+
+ const filteredLabResults = labResults.filter((lab) => {
+ const matchesSearch =
+ lab.testName.toLowerCase().includes(searchTerm.toLowerCase()) ||
+ lab.parameter.toLowerCase().includes(searchTerm.toLowerCase())
+ const matchesDate = dateFilter === "all" || lab.date === dateFilter
+ const matchesStatus = statusFilter === "all" || lab.status === statusFilter
+ return matchesSearch && matchesDate && matchesStatus
+ })
+
+ const filteredRadiologyReports = radiologyReports.filter((report) => {
+ const matchesSearch =
+ report.examType.toLowerCase().includes(searchTerm.toLowerCase()) ||
+ report.bodyPart.toLowerCase().includes(searchTerm.toLowerCase()) ||
+ report.findings.toLowerCase().includes(searchTerm.toLowerCase())
+ const matchesDate = dateFilter === "all" || report.date === dateFilter
+ const matchesStatus = statusFilter === "all" || report.status === statusFilter
+ return matchesSearch && matchesDate && matchesStatus
+ })
+
+ return (
+
+ {/* Header */}
+
+
+
Lab Results & Radiology Reports
+
View and select investigations for discharge summary - {patient.name}
+
+
+
+
+ {getSelectedLabResults().length} Lab Results Selected
+
+
+
+ {getSelectedRadiologyReports().length} Reports Selected
+
+
+
+
+ {/* Filters */}
+
+
+
+
+
+
+ setSearchTerm(e.target.value)}
+ className="pl-10"
+ />
+
+
+
+
+
+
+
+
+ All Dates
+ Today (18 Jan)
+ Yesterday (17 Jan)
+ 16 Jan 2024
+
+
+
+
+
+
+
+ All Status
+ Critical
+ High
+ Low
+ Normal
+ Pending
+ Reported
+
+
+ {(searchTerm || dateFilter !== "all" || statusFilter !== "all") && (
+ {
+ setSearchTerm("")
+ setDateFilter("all")
+ setStatusFilter("all")
+ }}
+ >
+
+ Clear
+
+ )}
+
+
+
+
+
+ {/* Main Content Tabs */}
+
+
+ Lab Results
+ Radiology Reports
+ Trend Analysis
+
+
+ {/* Lab Results Tab */}
+
+
+
+
+ Laboratory Results
+
+
+
+ Export Selected
+
+
+
+ Add to Discharge Summary
+
+
+
+
+
+
+
+
+ Select
+ Test Name
+ Parameter
+ Value
+ Normal Range
+ Status
+ Date/Time
+ Reported By
+
+
+
+ {filteredLabResults.map((lab) => (
+
+
+ toggleLabSelection(lab.id)}
+ />
+
+ {lab.testName}
+ {lab.parameter}
+
+ {lab.value} {lab.unit}
+
+ {lab.normalRange}
+
+
+ {getStatusIcon(lab.status)}
+ {lab.status}
+
+
+
+ {lab.date}
+ {lab.time}
+
+ {lab.reportedBy}
+
+ ))}
+
+
+
+
+
+
+ {/* Radiology Reports Tab */}
+
+
+ {filteredRadiologyReports.map((report) => (
+
+
+
+
+
toggleRadiologySelection(report.id)}
+ />
+
+
{report.examType}
+
{report.bodyPart}
+
+
+
+
{report.status}
+
+
{report.date}
+
{report.time}
+
+
+
+
+
+
+
+
+
Findings:
+
{report.findings}
+
+
+
Impression:
+
{report.impression}
+
+
+
Radiologist:
+
{report.radiologist}
+
+
+ {report.imageUrl && (
+
+
Image:
+
+
+
+
+
+
+ View Full
+
+
+
+ Download
+
+
+
+ )}
+
+
+
+ ))}
+
+
+
+ {/* Trend Analysis Tab */}
+
+
+
+ Parameter Trends & Comparison
+ Date-wise comparison of lab parameters to track patient progress
+
+
+
+ {Object.entries(getParameterTrends()).map(([parameter, results]) => (
+
+
{parameter}
+
+
+
+ Date
+ Value
+ Status
+ Trend
+ Normal Range
+
+
+
+ {results.map((result, index) => {
+ const prevResult = results[index + 1]
+ let trend = "stable"
+ if (prevResult) {
+ const currentVal = Number.parseFloat(result.value.replace(/,/g, ""))
+ const prevVal = Number.parseFloat(prevResult.value.replace(/,/g, ""))
+ if (currentVal > prevVal) trend = "up"
+ else if (currentVal < prevVal) trend = "down"
+ }
+
+ return (
+
+ {result.date}
+
+ {result.value} {result.unit}
+
+
+
+ {getStatusIcon(result.status)}
+ {result.status}
+
+
+
+ {index === results.length - 1 ? (
+ -
+ ) : (
+
+ {trend === "up" && }
+ {trend === "down" && }
+ {trend === "stable" && }
+ {trend}
+
+ )}
+
+ {result.normalRange}
+
+ )
+ })}
+
+
+
+ ))}
+
+
+
+
+
+
+ {/* Selected Items Summary */}
+ {(getSelectedLabResults().length > 0 || getSelectedRadiologyReports().length > 0) && (
+
+
+ Selected for Discharge Summary
+
+
+
+ {getSelectedLabResults().length > 0 && (
+
+
Lab Results ({getSelectedLabResults().length})
+
+ {getSelectedLabResults().map((lab) => (
+
+ • {lab.parameter}: {lab.value} {lab.unit} ({lab.date})
+
+ ))}
+
+
+ )}
+ {getSelectedRadiologyReports().length > 0 && (
+
+
+ Radiology Reports ({getSelectedRadiologyReports().length})
+
+
+ {getSelectedRadiologyReports().map((report) => (
+
+ • {report.examType}: {report.impression} ({report.date})
+
+ ))}
+
+
+ )}
+
+
+
+
+ Add Selected to Discharge Summary
+
+
+
+ Export Selected Results
+
+
+
+
+ )}
+
+ )
+}
diff --git a/ipdmodule/components/opd-consultation-history.tsx b/ipdmodule/components/opd-consultation-history.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..1788a96589e67496ae3de20f1968887ddf0fb9bb
--- /dev/null
+++ b/ipdmodule/components/opd-consultation-history.tsx
@@ -0,0 +1,519 @@
+"use client"
+
+import { useState, useEffect } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader } from "@/components/ui/card"
+import { Badge } from "@/components/ui/badge"
+import {
+ Users,
+ Calendar,
+ User,
+ Copy,
+ ChevronDown,
+ ChevronUp,
+ FileText,
+ Stethoscope,
+ Pill,
+ TestTube,
+ AlertCircle,
+ CheckCircle,
+} from "lucide-react"
+
+interface OPDConsultationHistoryProps {
+ patient: any
+}
+
+interface OPDConsultation {
+ id: string
+ date: string
+ time: string
+ doctor: string
+ department: string
+ symptoms: string
+ examination: string
+ advice: string
+ investigation: string
+ diagnosis: string
+ medicine: string
+ followUp: string
+ status: "completed" | "pending" | "cancelled"
+}
+
+export function OPDConsultationHistory({ patient }: OPDConsultationHistoryProps) {
+ const [consultations, setConsultations] = useState([])
+ const [visibleCount, setVisibleCount] = useState(3)
+ const [expandedConsultations, setExpandedConsultations] = useState>(new Set())
+ const [copySuccess, setCopySuccess] = useState(null)
+
+ // Mock data - in real implementation, this would come from API
+ const allConsultations: OPDConsultation[] = [
+ {
+ id: "opd-001",
+ date: "2024-01-10",
+ time: "10:30 AM",
+ doctor: "Dr. Smith",
+ department: "Internal Medicine",
+ symptoms:
+ "Chest pain and shortness of breath for 2 days. Patient reports acute onset chest pain, substernal, radiating to left arm. Associated with shortness of breath, diaphoresis, and nausea. Pain is 7/10 in intensity, worsens with exertion.",
+ examination:
+ "General: Alert, oriented, mild distress. Vitals: BP 140/90, HR 88, Temp 98.6°F. CVS: S1S2 heard, no murmurs, no gallops. Chest: Clear to auscultation bilaterally. Abdomen: Soft, non-tender, no organomegaly. Extremities: No pedal edema.",
+ advice:
+ "Avoid strenuous activity, low salt diet, medication compliance. Return immediately if chest pain worsens or new symptoms develop. Regular follow-up as scheduled.",
+ investigation:
+ "ECG - shows ST depression in leads V4-V6. Troponin I - elevated at 2.5 ng/mL. Chest X-ray - normal heart size, clear lung fields. Lipid profile - Total cholesterol 280 mg/dL, LDL 180 mg/dL.",
+ diagnosis:
+ "Acute coronary syndrome - NSTEMI (Non-ST elevation myocardial infarction). Secondary diagnosis: Hyperlipidemia",
+ medicine:
+ "Tab. Aspirin 75mg once daily after food. Tab. Atorvastatin 20mg once daily at bedtime. Tab. Metoprolol 25mg twice daily. Tab. Clopidogrel 75mg once daily for 1 year.",
+ followUp: "Follow up in cardiology clinic in 1 week. Emergency visit if symptoms worsen.",
+ status: "completed",
+ },
+ {
+ id: "opd-002",
+ date: "2024-01-05",
+ time: "02:15 PM",
+ doctor: "Dr. Johnson",
+ department: "Cardiology",
+ symptoms:
+ "Follow-up for hypertension and diabetes. Patient reports good medication compliance. Occasional morning headaches. Blood sugar levels well controlled with current regimen. No chest pain or shortness of breath.",
+ examination:
+ "General: Well-appearing, no acute distress. Vitals: BP 130/80, HR 72, Weight 68kg. CVS: Regular rate and rhythm, no murmurs. No pedal edema. Fundoscopy: No diabetic retinopathy. Peripheral pulses palpable.",
+ advice:
+ "Continue current medications as prescribed. Regular exercise 30 minutes daily. Diabetic diet with carbohydrate counting. Home blood pressure monitoring twice weekly. Weight management.",
+ investigation:
+ "HbA1c - 6.8% (target <7%). Fasting glucose - 110 mg/dL. Lipid profile - within normal limits. Microalbumin - negative. ECG - normal sinus rhythm.",
+ diagnosis:
+ "Essential hypertension - well controlled. Diabetes mellitus type 2 - well controlled. No evidence of diabetic complications.",
+ medicine:
+ "Tab. Amlodipine 5mg once daily in morning. Tab. Metformin 500mg twice daily with meals. Tab. Glimepiride 2mg once daily before breakfast. Tab. Aspirin 75mg once daily.",
+ followUp: "Follow up in 3 months with HbA1c and lipid profile. Ophthalmology screening annually.",
+ status: "completed",
+ },
+ {
+ id: "opd-003",
+ date: "2023-12-20",
+ time: "11:00 AM",
+ doctor: "Dr. Brown",
+ department: "General Medicine",
+ symptoms:
+ "Fever and productive cough for 5 days. Maximum temperature 101°F, mainly in evenings. Cough with yellowish sputum, mild shortness of breath on exertion. Decreased appetite and mild fatigue. No chest pain.",
+ examination:
+ "General: Febrile (100.8°F), mild respiratory distress. Vitals: BP 120/80, HR 96. Chest: Bilateral crepitations in lower zones, dullness on percussion. CVS: Normal heart sounds. Abdomen: Soft, non-tender.",
+ advice:
+ "Complete full course of antibiotics even if feeling better. Adequate rest and avoid strenuous activities. Plenty of warm fluids. Steam inhalation twice daily. Return if fever persists beyond 3 days of treatment.",
+ investigation:
+ "Chest X-ray - bilateral lower lobe consolidation. CBC - WBC 12,000 with neutrophilia. CRP - elevated at 45 mg/L. Sputum culture - Streptococcus pneumoniae sensitive to Amoxicillin.",
+ diagnosis: "Community-acquired pneumonia (bilateral lower lobe). Secondary diagnosis: Mild dehydration",
+ medicine:
+ "Tab. Amoxicillin 500mg three times daily for 7 days. Tab. Paracetamol 500mg as needed for fever (max 4 times daily). Salbutamol inhaler 2 puffs twice daily for 5 days.",
+ followUp: "Follow up in 5 days or earlier if symptoms worsen. Chest X-ray repeat after 2 weeks.",
+ status: "completed",
+ },
+ {
+ id: "opd-004",
+ date: "2023-12-10",
+ time: "09:45 AM",
+ doctor: "Dr. Wilson",
+ department: "Endocrinology",
+ symptoms:
+ "Diabetes follow-up visit. Patient reports frequent urination, especially at night (3-4 times). Increased thirst and occasional blurred vision. Fatigue in afternoons. No weight loss or diabetic foot symptoms.",
+ examination:
+ "General: Overweight (BMI 28), no acute distress. Vitals: BP 135/85, Weight 72kg. Diabetic foot examination - no ulcers, good peripheral pulses. Fundoscopy: Mild background diabetic retinopathy with few microaneurysms.",
+ advice:
+ "Strict adherence to diabetic diet with carbohydrate restriction. Regular exercise program - walking 45 minutes daily. Home blood glucose monitoring twice daily. Weight reduction target 5kg in 6 months. Diabetic foot care education.",
+ investigation:
+ "HbA1c - 9.2% (poor control). Fasting glucose - 180 mg/dL. Post-meal glucose - 280 mg/dL. Lipid profile - elevated triglycerides. Kidney function tests - normal. Urine microalbumin - trace positive.",
+ diagnosis:
+ "Diabetes mellitus type 2 - poorly controlled (HbA1c 9.2%). Diabetic retinopathy - mild background changes. Pre-diabetic nephropathy (microalbuminuria).",
+ medicine:
+ "Tab. Metformin 1000mg twice daily with meals. Insulin Glargine 20 units at bedtime (to be increased gradually). Tab. Aspirin 75mg once daily. Multivitamin once daily.",
+ followUp:
+ "Follow up in 6 weeks with glucose logs. Ophthalmology referral for detailed retinal examination. Dietitian consultation scheduled.",
+ status: "completed",
+ },
+ {
+ id: "opd-005",
+ date: "2023-11-25",
+ time: "03:30 PM",
+ doctor: "Dr. Martinez",
+ department: "Internal Medicine",
+ symptoms:
+ "Routine health check-up. No specific complaints. Patient feels generally well and energetic. Occasional mild headaches during stress. Good sleep pattern and appetite. No urinary or bowel complaints.",
+ examination:
+ "General: Well-appearing, healthy-looking individual. Vitals: BP 125/75, HR 70, Weight 68kg. All systems examination normal. Heart sounds normal, lungs clear. Abdomen soft with no organomegaly. No lymphadenopathy.",
+ advice:
+ "Maintain current healthy lifestyle. Continue regular exercise routine. Balanced diet with adequate fruits and vegetables. Stress management techniques. Annual health screening as recommended for age group.",
+ investigation:
+ "CBC - all parameters normal. Comprehensive metabolic panel - normal kidney and liver function. Lipid profile - optimal levels. PSA - normal for age. Vitamin D - sufficient levels.",
+ diagnosis: "Routine health maintenance - all parameters normal. Overall excellent health status for age group.",
+ medicine:
+ "Multivitamin tablet once daily. Calcium with Vitamin D supplement once daily. No other medications required at present.",
+ followUp: "Annual comprehensive health check-up in 1 year. Earlier visit if any health concerns arise.",
+ status: "completed",
+ },
+ ]
+
+ useEffect(() => {
+ // Simulate loading consultations
+ setConsultations(allConsultations)
+ }, [])
+
+ const loadMoreConsultations = () => {
+ setVisibleCount((prev) => Math.min(prev + 3, allConsultations.length))
+ }
+
+ const toggleExpanded = (consultationId: string) => {
+ setExpandedConsultations((prev) => {
+ const newSet = new Set(prev)
+ if (newSet.has(consultationId)) {
+ newSet.delete(consultationId)
+ } else {
+ newSet.add(consultationId)
+ }
+ return newSet
+ })
+ }
+
+ const copyToClipboard = async (text: string, label: string) => {
+ try {
+ await navigator.clipboard.writeText(text)
+ setCopySuccess(label)
+ setTimeout(() => setCopySuccess(null), 2000)
+ } catch (err) {
+ console.error("Failed to copy text: ", err)
+ }
+ }
+
+ const getStatusColor = (status: string) => {
+ switch (status) {
+ case "completed":
+ return "bg-green-100 text-green-800"
+ case "pending":
+ return "bg-yellow-100 text-yellow-800"
+ case "cancelled":
+ return "bg-red-100 text-red-800"
+ default:
+ return "bg-gray-100 text-gray-800"
+ }
+ }
+
+ const getStatusIcon = (status: string) => {
+ switch (status) {
+ case "completed":
+ return
+ case "pending":
+ return
+ case "cancelled":
+ return
+ default:
+ return
+ }
+ }
+
+ const visibleConsultations = consultations.slice(0, visibleCount)
+
+ return (
+
+ {/* Header */}
+
+
+
OPD Consultation History
+
+ Historical OPD consultations for {patient.name} - Showing {visibleCount} of {consultations.length}{" "}
+ consultations
+
+
+
+
+ {consultations.length} Total Consultations
+
+
+
+ {/* Copy Success Message */}
+ {copySuccess && (
+
+
+
+ {copySuccess} copied to clipboard!
+
+
+ )}
+
+ {/* Consultations List */}
+
+ {visibleConsultations.map((consultation) => {
+ const isExpanded = expandedConsultations.has(consultation.id)
+
+ return (
+
+
+
+
+
+
+
{consultation.department}
+
+
+
+ {consultation.date} at {consultation.time}
+
+
+
+ {consultation.doctor}
+
+
+
+
+
+
+ {getStatusIcon(consultation.status)}
+ {consultation.status}
+
+ toggleExpanded(consultation.id)}>
+ {isExpanded ? : }
+
+
+
+
+
+
+ {/* Always visible summary */}
+
+
+
+
Symptoms:
+ copyToClipboard(consultation.symptoms, "Symptoms")}
+ className="h-6 px-2"
+ >
+
+
+
+
{consultation.symptoms}
+
+
+
+
+
Diagnosis:
+ copyToClipboard(consultation.diagnosis, "Diagnosis")}
+ className="h-6 px-2"
+ >
+
+
+
+
+ {consultation.diagnosis}
+
+
+
+
+ {/* Expanded content */}
+ {isExpanded && (
+
+ {/* Symptoms */}
+
+
+
Symptoms:
+ copyToClipboard(consultation.symptoms, "Symptoms")}
+ className="h-6 px-2"
+ >
+
+
+
+
+ {consultation.symptoms}
+
+
+
+ {/* Examination */}
+
+
+
Examination:
+ copyToClipboard(consultation.examination, "Examination")}
+ className="h-6 px-2"
+ >
+
+
+
+
+ {consultation.examination}
+
+
+
+ {/* Investigation */}
+
+
+
+
+ Investigation:
+
+ copyToClipboard(consultation.investigation, "Investigation")}
+ className="h-6 px-2"
+ >
+
+
+
+
+ {consultation.investigation}
+
+
+
+ {/* Diagnosis */}
+
+
+
Diagnosis:
+ copyToClipboard(consultation.diagnosis, "Diagnosis")}
+ className="h-6 px-2"
+ >
+
+
+
+
+ {consultation.diagnosis}
+
+
+
+ {/* Medicine */}
+
+
+
+
+ Medicine:
+
+
copyToClipboard(consultation.medicine, "Medicine")}
+ className="h-6 px-2"
+ >
+
+
+
+
+ {consultation.medicine}
+
+
+
+ {/* Advice */}
+
+
+
Advice:
+ copyToClipboard(consultation.advice, "Advice")}
+ className="h-6 px-2"
+ >
+
+
+
+
+ {consultation.advice}
+
+
+
+ {/* Follow-up */}
+
+
+
Follow-up:
+ copyToClipboard(consultation.followUp, "Follow-up")}
+ className="h-6 px-2"
+ >
+
+
+
+
+ {consultation.followUp}
+
+
+
+ {/* Copy All Button */}
+
+ {
+ const fullConsultation = `
+OPD Consultation - ${consultation.date}
+Doctor: ${consultation.doctor}
+Department: ${consultation.department}
+
+SYMPTOMS:
+${consultation.symptoms}
+
+EXAMINATION:
+${consultation.examination}
+
+INVESTIGATION:
+${consultation.investigation}
+
+DIAGNOSIS:
+${consultation.diagnosis}
+
+MEDICINE:
+${consultation.medicine}
+
+ADVICE:
+${consultation.advice}
+
+FOLLOW-UP:
+${consultation.followUp}
+ `.trim()
+ copyToClipboard(fullConsultation, "Complete Consultation")
+ }}
+ className="w-full"
+ >
+
+ Copy Complete Consultation
+
+
+
+ )}
+
+
+ )
+ })}
+
+
+ {/* Load More Button */}
+ {visibleCount < consultations.length && (
+
+
+
+ Load More Consultations ({consultations.length - visibleCount} remaining)
+
+
+ )}
+
+ {/* Empty State */}
+ {consultations.length === 0 && (
+
+
+
+ No OPD Consultations
+ No previous OPD consultations found for this patient.
+
+
+ )}
+
+ )
+}
diff --git a/ipdmodule/components/ot-details-form.tsx b/ipdmodule/components/ot-details-form.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..6cc5aa6d0261b925885ccac4636a44c275ce5c44
--- /dev/null
+++ b/ipdmodule/components/ot-details-form.tsx
@@ -0,0 +1,464 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { Textarea } from "@/components/ui/textarea"
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
+import { Badge } from "@/components/ui/badge"
+import { Scissors, Save, Plus, Edit, Trash2, AlertTriangle, CheckCircle } from "lucide-react"
+
+interface OTDetailsFormProps {
+ patient: any
+}
+
+export function OTDetailsForm({ patient }: OTDetailsFormProps) {
+ const [showAddOT, setShowAddOT] = useState(false)
+ const [formData, setFormData] = useState({
+ dateOfSurgery: "",
+ surgeryName: "",
+ indication: "",
+ surgeon: "",
+ assistants: "",
+ anesthesiaType: "",
+ anesthesiologist: "",
+ intraoperativeFindings: "",
+ procedureDescription: "",
+ complications: "No",
+ complicationDetails: "",
+ postOpPlan: "",
+ estimatedBloodLoss: "",
+ fluidBalance: "",
+ duration: "",
+ implants: "",
+ specimens: "",
+ })
+
+ const [otRecords, setOtRecords] = useState([
+ {
+ id: "1",
+ date: "2024-01-16",
+ surgeryName: "Laparoscopic Cholecystectomy",
+ surgeon: "Dr. Brown",
+ anesthesia: "General",
+ duration: "2 hours 30 minutes",
+ status: "Completed",
+ complications: "None",
+ postOpPlan: "Recovery Room → Ward",
+ },
+ ])
+
+ const handleInputChange = (field: string, value: string) => {
+ setFormData((prev) => ({ ...prev, [field]: value }))
+ }
+
+ const handleSaveOT = () => {
+ const newRecord = {
+ id: Date.now().toString(),
+ date: formData.dateOfSurgery,
+ surgeryName: formData.surgeryName,
+ surgeon: formData.surgeon,
+ anesthesia: formData.anesthesiaType,
+ duration: formData.duration,
+ status: "Completed",
+ complications: formData.complications === "Yes" ? formData.complicationDetails : "None",
+ postOpPlan: formData.postOpPlan,
+ }
+
+ setOtRecords((prev) => [newRecord, ...prev])
+ setFormData({
+ dateOfSurgery: "",
+ surgeryName: "",
+ indication: "",
+ surgeon: "",
+ assistants: "",
+ anesthesiaType: "",
+ anesthesiologist: "",
+ intraoperativeFindings: "",
+ procedureDescription: "",
+ complications: "No",
+ complicationDetails: "",
+ postOpPlan: "",
+ estimatedBloodLoss: "",
+ fluidBalance: "",
+ duration: "",
+ implants: "",
+ specimens: "",
+ })
+ setShowAddOT(false)
+ alert("OT record saved successfully!")
+ }
+
+ return (
+
+ {/* Header */}
+
+
+
OT Details
+
Surgery and operation theater details for {patient.name}
+
+
setShowAddOT(!showAddOT)}>
+
+ Add OT Record
+
+
+
+ {/* Add New OT Record Form */}
+ {showAddOT && (
+
+
+
+
+ Add New OT Record
+
+
+
+ {/* Basic Surgery Information */}
+
+
+ Date of Surgery
+ handleInputChange("dateOfSurgery", e.target.value)}
+ className="bg-white"
+ />
+
+
+
+ Duration
+ handleInputChange("duration", e.target.value)}
+ className="bg-white"
+ />
+
+
+
+ Surgery/Procedure Name
+ handleInputChange("surgeryName", e.target.value)}
+ className="bg-white"
+ />
+
+
+
+ Indication for Surgery
+
+
+
+ {/* Surgical Team */}
+
+
+ Surgical Team
+
+
+
+
+ Primary Surgeon
+ handleInputChange("surgeon", e.target.value)}
+ className="bg-white"
+ />
+
+
+
+ Assistant Surgeons
+ handleInputChange("assistants", e.target.value)}
+ className="bg-white"
+ />
+
+
+
+ Anesthesia Type
+ handleInputChange("anesthesiaType", value)}>
+
+
+
+
+ General
+ Spinal
+ Epidural
+ Local
+ Sedation
+ Regional Block
+
+
+
+
+
+ Anesthesiologist
+ handleInputChange("anesthesiologist", e.target.value)}
+ className="bg-white"
+ />
+
+
+
+
+
+ {/* Operative Details */}
+
+
+ Operative Details
+
+
+
+ Intraoperative Findings
+
+
+
+ Procedure Description
+
+
+
+
+
+ Implants/Prosthetics Used
+
+
+
+ Specimens Sent
+
+
+
+
+ {/* Complications */}
+
+
+ Complications
+
+
+
+
+
+
+ {/* Post-operative Plan */}
+
+
+ Post-operative Plan
+
+
+
+ Post-op Destination & Plan
+ handleInputChange("postOpPlan", value)}>
+
+
+
+
+ ICU
+ Recovery Room
+ General Ward
+ PACU (Post Anesthesia Care Unit)
+ Day Surgery Discharge
+
+
+
+
+
+
+
+
+
+ Save OT Record
+
+ setShowAddOT(false)}>
+ Cancel
+
+
+
+
+ )}
+
+ {/* Existing OT Records */}
+
+ {otRecords.map((record) => (
+
+
+
+
+
+ {record.surgeryName}
+
+
+
+
+ {record.status}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Date:
+
{record.date}
+
+
+
Surgeon:
+
{record.surgeon}
+
+
+
Duration:
+
{record.duration}
+
+
+
Anesthesia:
+
{record.anesthesia}
+
+
+
Post-op Plan:
+
{record.postOpPlan}
+
+
+
+ {record.complications !== "None" && (
+
+
+
+
Complications:
+
{record.complications}
+
+
+ )}
+
+
+ ))}
+
+
+ {/* Empty State */}
+ {otRecords.length === 0 && !showAddOT && (
+
+
+
+ No OT Records
+ No surgery records found for this patient.
+ setShowAddOT(true)}>
+
+ Add First OT Record
+
+
+
+ )}
+
+ )
+}
diff --git a/ipdmodule/components/ot-details.tsx b/ipdmodule/components/ot-details.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..7b6b9d175b835d412c1cac5b317301fc461280ed
--- /dev/null
+++ b/ipdmodule/components/ot-details.tsx
@@ -0,0 +1,204 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { RichTextEditor } from "./rich-text-editor"
+import { Scissors, Save } from "lucide-react"
+
+interface OTDetailsProps {
+ patient: any
+}
+
+export function OTDetails({ patient }: OTDetailsProps) {
+ const [otData, setOTData] = useState({
+ operationDate: new Date().toISOString().split("T")[0],
+ operationTime: "",
+ duration: "",
+ surgeon: "",
+ assistant: "",
+ anesthesia: "",
+ preOpNotes: "",
+ procedure: "",
+ findings: "",
+ complications: "",
+ postOpInstructions: "",
+ })
+
+ const handleInputChange = (field: string, value: string) => {
+ setOTData((prev) => ({ ...prev, [field]: value }))
+ }
+
+ return (
+
+ {/* Header */}
+
+
+
Operation Theatre Notes
+
Comprehensive surgical documentation for {patient.name}
+
+
+
+ Save OT Notes
+
+
+
+ {/* Operation Details */}
+
+
+
+
+ Operation Details
+
+
+
+
+
+
+
+
+
+ {/* Pre-operative Notes */}
+
+
+ Pre-operative Notes
+
+
+ Pre-operative Assessment and Preparation
+ handleInputChange("preOpNotes", value)}
+ placeholder="Enter pre-operative assessment, patient preparation, consent details..."
+ rows={4}
+ fieldType="assessment"
+ showAutofill={true}
+ autofillSource="Pre-op Assessment"
+ autofillTimestamp="2024-01-15, 08:30 AM"
+ />
+
+
+
+ {/* Operative Procedure */}
+
+
+ Operative Procedure
+
+
+ Detailed Procedure Description
+ handleInputChange("procedure", value)}
+ placeholder="Enter detailed step-by-step description of the surgical procedure..."
+ rows={6}
+ fieldType="ot-procedure"
+ />
+
+
+
+ {/* Operative Findings */}
+
+
+ Operative Findings
+
+
+ Intraoperative Findings and Observations
+ handleInputChange("findings", value)}
+ placeholder="Describe anatomical findings, pathological observations..."
+ rows={5}
+ fieldType="ot-findings"
+ />
+
+
+
+ {/* Complications */}
+
+
+ Complications
+
+
+ Intraoperative Complications (if any)
+ handleInputChange("complications", value)}
+ placeholder="Document any complications. Enter 'None' if no complications occurred..."
+ rows={3}
+ fieldType="general"
+ />
+
+
+
+ {/* Post-operative Instructions */}
+
+
+ Post-operative Instructions
+
+
+ Post-operative Care and Instructions
+ handleInputChange("postOpInstructions", value)}
+ placeholder="Enter post-operative care instructions, monitoring requirements..."
+ rows={5}
+ fieldType="plan"
+ />
+
+
+
+ )
+}
diff --git a/ipdmodule/components/ot-notes-form.tsx b/ipdmodule/components/ot-notes-form.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..0efc1c896ec5e6fb2fb1517b714a65d1d9ac29c4
--- /dev/null
+++ b/ipdmodule/components/ot-notes-form.tsx
@@ -0,0 +1,266 @@
+"use client"
+
+import { useState, useEffect } from "react"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
+import { Button } from "@/components/ui/button"
+import { RichTextEditor } from "./rich-text-editor"
+import { FormNavigation } from "./form-navigation"
+import { Clock, Scissors, Heart, AlertTriangle } from "lucide-react"
+
+export function OTNotesForm() {
+ const [activeSection, setActiveSection] = useState("pre-operative")
+ const [formData, setFormData] = useState({
+ preOperative: "",
+ operativeDetails: "",
+ postOperative: "",
+ complications: "",
+ })
+
+ const sections = [
+ { id: "pre-operative", label: "Pre-Operative", icon: },
+ { id: "operative-details", label: "Operative Details", icon: },
+ { id: "post-operative", label: "Post-Operative", icon: },
+ { id: "complications", label: "Complications", icon: },
+ ]
+
+ useEffect(() => {
+ const handleScroll = () => {
+ const sectionElements = sections.map((section) => ({
+ id: section.id,
+ element: document.getElementById(section.id),
+ }))
+
+ const currentSection = sectionElements.find(({ element }) => {
+ if (!element) return false
+ const rect = element.getBoundingClientRect()
+ return rect.top <= 100 && rect.bottom >= 100
+ })
+
+ if (currentSection) {
+ setActiveSection(currentSection.id)
+ }
+ }
+
+ window.addEventListener("scroll", handleScroll)
+ return () => window.removeEventListener("scroll", handleScroll)
+ }, [])
+
+ const updateFormData = (field: string, value: string) => {
+ setFormData((prev) => ({ ...prev, [field]: value }))
+ }
+
+ return (
+
+
+
+
+ {/* Pre-Operative Section */}
+
+
+
+
+ Pre-Operative Assessment
+
+
+
+
+
+ Procedure Name
+
+
+
+ Primary Surgeon
+
+
+
+ Anesthesia Type
+
+
+
+
+
+ General
+ Spinal
+ Epidural
+ Local
+
+
+
+
+ ASA Grade
+
+
+
+
+
+ ASA I
+ ASA II
+ ASA III
+ ASA IV
+
+
+
+
+
+ Pre-Operative Assessment
+ updateFormData("preOperative", value)}
+ placeholder="Pre-operative patient condition, vital signs, investigations..."
+ fieldType="assessment"
+ rows={5}
+ showAutofill={true}
+ autofillSource="Pre-Op Checklist"
+ autofillTimestamp="2024-01-15, 8:00 AM"
+ />
+
+
+
+
+ {/* Operative Details Section */}
+
+
+
+
+ Operative Details
+
+
+
+
+
+ Operative Procedure
+ updateFormData("operativeDetails", value)}
+ placeholder="Detailed description of the surgical procedure performed..."
+ fieldType="ot-procedure"
+ rows={8}
+ />
+
+
+
+ Operative Findings
+ {}}
+ placeholder="Intraoperative findings and observations..."
+ fieldType="assessment"
+ rows={4}
+ />
+
+
+ Specimens Sent
+ {}}
+ placeholder="Specimens sent for histopathology..."
+ fieldType="general"
+ rows={4}
+ />
+
+
+
+
+
+ {/* Post-Operative Section */}
+
+
+
+
+ Post-Operative Care
+
+
+
+
+ Post-Operative Condition
+ updateFormData("postOperative", value)}
+ placeholder="Patient's condition immediately post-surgery..."
+ fieldType="assessment"
+ rows={4}
+ />
+
+
+
+ Post-Operative Orders
+ {}}
+ placeholder="Post-operative care instructions and orders..."
+ fieldType="plan"
+ rows={5}
+ />
+
+
+ Recovery Plan
+ {}}
+ placeholder="Expected recovery timeline and milestones..."
+ fieldType="plan"
+ rows={5}
+ />
+
+
+
+
+
+ {/* Complications Section */}
+
+
+
+
+ Complications & Notes
+
+
+
+
+ Complications (if any)
+ updateFormData("complications", value)}
+ placeholder="Any intraoperative or immediate post-operative complications..."
+ fieldType="general"
+ rows={4}
+ />
+
+
+ Additional Notes
+ {}}
+ placeholder="Any additional observations or special instructions..."
+ fieldType="general"
+ rows={4}
+ />
+
+
+
+
+ {/* Form Actions */}
+
+ Save Draft
+ Print
+ Submit OT Notes
+
+
+
+ )
+}
diff --git a/ipdmodule/components/progress-notes-form.tsx b/ipdmodule/components/progress-notes-form.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..dfdcad0dc75d993018ab83d45594a8f557e4390d
--- /dev/null
+++ b/ipdmodule/components/progress-notes-form.tsx
@@ -0,0 +1,217 @@
+"use client"
+
+import { useState, useEffect } from "react"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { Button } from "@/components/ui/button"
+import { RichTextEditor } from "./rich-text-editor"
+import { FormNavigation } from "./form-navigation"
+import { User, Activity, ClipboardList, Heart, FileText } from "lucide-react"
+
+export function ProgressNotesForm() {
+ const [activeSection, setActiveSection] = useState("basic-info")
+ const [formData, setFormData] = useState({
+ basicInfo: "",
+ vitals: "",
+ assessment: "",
+ plan: "",
+ notes: "",
+ })
+
+ const sections = [
+ { id: "basic-info", label: "Basic Info", icon: },
+ { id: "vitals", label: "Vitals", icon: },
+ { id: "assessment", label: "Assessment", icon: },
+ { id: "plan", label: "Plan", icon: },
+ { id: "notes", label: "Notes", icon: },
+ ]
+
+ useEffect(() => {
+ const handleScroll = () => {
+ const sectionElements = sections.map((section) => ({
+ id: section.id,
+ element: document.getElementById(section.id),
+ }))
+
+ const currentSection = sectionElements.find(({ element }) => {
+ if (!element) return false
+ const rect = element.getBoundingClientRect()
+ return rect.top <= 100 && rect.bottom >= 100
+ })
+
+ if (currentSection) {
+ setActiveSection(currentSection.id)
+ }
+ }
+
+ window.addEventListener("scroll", handleScroll)
+ return () => window.removeEventListener("scroll", handleScroll)
+ }, [])
+
+ const updateFormData = (field: string, value: string) => {
+ setFormData((prev) => ({ ...prev, [field]: value }))
+ }
+
+ return (
+
+
+
+
+ {/* Basic Info Section */}
+
+
+
+
+ Basic Information
+
+
+
+
+
+ Subjective (Patient's Complaints)
+ updateFormData("basicInfo", value)}
+ placeholder="Patient's subjective complaints and symptoms..."
+ fieldType="chief-complaints"
+ showAutofill={true}
+ autofillSource="Patient Interview"
+ autofillTimestamp="2024-01-15, 10:30 AM"
+ />
+
+
+
+
+ {/* Vitals Section */}
+
+
+
+
+ Vital Signs & Objective Findings
+
+
+
+
+
+ Objective Findings
+ updateFormData("vitals", value)}
+ placeholder="Physical examination findings, lab results, imaging..."
+ fieldType="assessment"
+ rows={5}
+ showAutofill={true}
+ autofillSource="Nursing Station"
+ autofillTimestamp="2024-01-15, 11:00 AM"
+ />
+
+
+
+
+ {/* Assessment Section */}
+
+
+
+
+ Assessment
+
+
+
+
+ Clinical Assessment
+ updateFormData("assessment", value)}
+ placeholder="Current clinical status, progress, complications..."
+ fieldType="assessment"
+ rows={6}
+ />
+
+
+
+
+ {/* Plan Section */}
+
+
+
+
+ Plan
+
+
+
+
+ Treatment Plan
+ updateFormData("plan", value)}
+ placeholder="Treatment modifications, new orders, discharge planning..."
+ fieldType="plan"
+ rows={6}
+ />
+
+
+
+
+ {/* Additional Notes Section */}
+
+
+
+
+ Additional Notes
+
+
+
+
+ Additional Notes
+ updateFormData("notes", value)}
+ placeholder="Any additional observations, communications, or instructions..."
+ fieldType="general"
+ rows={4}
+ />
+
+
+
+
+ {/* Form Actions */}
+
+ Save Draft
+ Print
+ Submit Progress Note
+
+
+
+ )
+}
diff --git a/ipdmodule/components/progress-notes.tsx b/ipdmodule/components/progress-notes.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..edcb75b5f35f2e9c5249dad459698174557fd2dd
--- /dev/null
+++ b/ipdmodule/components/progress-notes.tsx
@@ -0,0 +1,230 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { RichTextEditor } from "./rich-text-editor"
+import { Plus, Calendar, Sun, Sunset, Moon, Clock } from "lucide-react"
+
+interface ProgressNotesProps {
+ patient: any
+}
+
+export function ProgressNotes({ patient }: ProgressNotesProps) {
+ const [showAddNote, setShowAddNote] = useState(false)
+ const [currentDate, setCurrentDate] = useState(new Date().toISOString().split("T")[0])
+
+ const [morningShift, setMorningShift] = useState({
+ complaints: "",
+ findings: "",
+ vitals: "",
+ events: "",
+ doctor: "",
+ })
+
+ const [eveningShift, setEveningShift] = useState({
+ complaints: "",
+ findings: "",
+ vitals: "",
+ events: "",
+ doctor: "",
+ })
+
+ const [nightShift, setNightShift] = useState({
+ complaints: "",
+ findings: "",
+ vitals: "",
+ events: "",
+ doctor: "",
+ })
+
+ const handleShiftChange = (shift: string, field: string, value: string) => {
+ if (shift === "morning") {
+ setMorningShift((prev) => ({ ...prev, [field]: value }))
+ } else if (shift === "evening") {
+ setEveningShift((prev) => ({ ...prev, [field]: value }))
+ } else if (shift === "night") {
+ setNightShift((prev) => ({ ...prev, [field]: value }))
+ }
+ }
+
+ const ShiftCard = ({
+ title,
+ icon: Icon,
+ bgColor,
+ shift,
+ shiftData,
+ }: {
+ title: string
+ icon: any
+ bgColor: string
+ shift: string
+ shiftData: any
+ }) => (
+
+
+
+
+ {title}
+
+
+
+
+ Chief Complaints
+ handleShiftChange(shift, "complaints", value)}
+ placeholder="Enter chief complaints for this shift..."
+ rows={2}
+ fieldType="chief-complaints"
+ />
+
+
+
+ Findings (Systemic examination)
+ handleShiftChange(shift, "findings", value)}
+ placeholder="Enter examination findings..."
+ rows={3}
+ fieldType="assessment"
+ />
+
+
+
+ Vital Parameters
+ handleShiftChange(shift, "vitals", value)}
+ placeholder="BP: 120/80, Pulse: 72, Temp: 98.6°F, RR: 16"
+ rows={2}
+ fieldType="general"
+ />
+
+
+
+ Specific Event
+ handleShiftChange(shift, "events", value)}
+ placeholder="Any specific events or observations..."
+ rows={2}
+ fieldType="general"
+ />
+
+
+
+ Doctor Name
+ handleShiftChange(shift, "doctor", e.target.value)}
+ placeholder="Enter doctor name"
+ className="bg-white"
+ />
+
+
+
+ )
+
+ return (
+
+ {/* Header */}
+
+
+
Daily Progress Notes
+
Three-shift monitoring for {patient.name}
+
+
setShowAddNote(!showAddNote)} className="gap-2">
+
+ Add Progress Note
+
+
+
+ {/* Add New Note Form */}
+ {showAddNote && (
+
+
+
+
+
+ New Daily Progress Note
+
+
+ Date:
+ setCurrentDate(e.target.value)}
+ className="bg-white"
+ />
+
+
+
+
+ {/* Patient Info */}
+
+
Patient Label:
+
+ {patient.name} | MRN: {patient.mrn} | {patient.age}Y {patient.gender} | Ward:{" "}
+ {patient.ward} | Bed: {patient.bed}
+
+
+
+ {/* Three Shifts */}
+
+
+
+
+
+
+
+
+
+
+
+ Save Progress Note
+
+ setShowAddNote(false)}>
+ Cancel
+
+
+
+
+ )}
+
+ {/* Existing Notes */}
+
+
+ Progress Notes History
+
+
+
+
+
No Progress Notes
+
Start documenting daily progress with three-shift monitoring.
+
+
+
+
+ )
+}
diff --git a/ipdmodule/components/radiology-findings-form.tsx b/ipdmodule/components/radiology-findings-form.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..dbbda8731c18f9de585bf0b92fcac10e5c96f9ea
--- /dev/null
+++ b/ipdmodule/components/radiology-findings-form.tsx
@@ -0,0 +1,331 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
+import { Input } from "@/components/ui/input"
+import { Label } from "@/components/ui/label"
+import { Textarea } from "@/components/ui/textarea"
+import { Badge } from "@/components/ui/badge"
+import { Zap, Plus, Save, Eye, Calendar, User, FileText } from "lucide-react"
+
+interface RadiologyFindingsFormProps {
+ patient: any
+}
+
+export function RadiologyFindingsForm({ patient }: RadiologyFindingsFormProps) {
+ const [radiologyRecords, setRadiologyRecords] = useState([
+ {
+ id: "1",
+ date: "2024-01-17",
+ time: "14:30",
+ studyType: "Chest X-Ray",
+ indication: "Chest pain, rule out pneumonia",
+ technique: "PA and Lateral views",
+ findings:
+ "Lungs are clear bilaterally. No consolidation, pleural effusion, or pneumothorax. Heart size normal. Mediastinum unremarkable.",
+ impression: "Normal chest radiograph",
+ radiologist: "Dr. Wilson",
+ status: "Final Report",
+ },
+ {
+ id: "2",
+ date: "2024-01-18",
+ time: "09:15",
+ studyType: "CT Chest with Contrast",
+ indication: "Follow-up chest pain, detailed evaluation",
+ technique: "Axial CT images of chest with IV contrast",
+ findings:
+ "No pulmonary embolism. Lungs show no focal consolidation. Small bilateral pleural effusions noted. Heart and great vessels appear normal.",
+ impression: "Small bilateral pleural effusions, otherwise normal study",
+ radiologist: "Dr. Martinez",
+ status: "Final Report",
+ },
+ ])
+
+ const [newRecord, setNewRecord] = useState({
+ date: new Date().toISOString().split("T")[0],
+ time: new Date().toTimeString().slice(0, 5),
+ studyType: "",
+ indication: "",
+ technique: "",
+ findings: "",
+ impression: "",
+ radiologist: "",
+ status: "Pending",
+ })
+
+ const [showAddRecord, setShowAddRecord] = useState(false)
+
+ const handleInputChange = (field: string, value: string) => {
+ setNewRecord((prev) => ({ ...prev, [field]: value }))
+ }
+
+ const handleSaveRecord = () => {
+ const recordToSave = {
+ id: Date.now().toString(),
+ ...newRecord,
+ status: "Final Report",
+ }
+ setRadiologyRecords((prev) => [recordToSave, ...prev])
+ setNewRecord({
+ date: new Date().toISOString().split("T")[0],
+ time: new Date().toTimeString().slice(0, 5),
+ studyType: "",
+ indication: "",
+ technique: "",
+ findings: "",
+ impression: "",
+ radiologist: "",
+ status: "Pending",
+ })
+ setShowAddRecord(false)
+ alert("Radiology findings saved successfully!")
+ }
+
+ const getStatusColor = (status: string) => {
+ switch (status) {
+ case "Final Report":
+ return "bg-green-100 text-green-800"
+ case "Preliminary":
+ return "bg-yellow-100 text-yellow-800"
+ case "Pending":
+ return "bg-gray-100 text-gray-800"
+ default:
+ return "bg-gray-100 text-gray-800"
+ }
+ }
+
+ const commonStudyTypes = [
+ "Chest X-Ray",
+ "CT Chest",
+ "CT Abdomen",
+ "CT Head",
+ "MRI Brain",
+ "MRI Spine",
+ "Ultrasound Abdomen",
+ "Ultrasound Pelvis",
+ "Mammography",
+ "Bone Scan",
+ "PET Scan",
+ "Angiography",
+ ]
+
+ return (
+
+ {/* Header */}
+
+
+
Radiology Findings
+
Imaging studies and radiology reports for {patient.name}
+
+
setShowAddRecord(!showAddRecord)}>
+
+ Add Radiology Report
+
+
+
+ {/* Add New Record Form */}
+ {showAddRecord && (
+
+
+
+
+ Add New Radiology Report
+
+
+
+
+
+
+
+ Study Type
+ handleInputChange("studyType", e.target.value)}
+ className="w-full px-3 py-2 border border-gray-300 rounded-md bg-white"
+ >
+ Select study type...
+ {commonStudyTypes.map((type) => (
+
+ {type}
+
+ ))}
+ Other
+
+
+
+ Radiologist
+ handleInputChange("radiologist", e.target.value)}
+ className="bg-white"
+ />
+
+
+
+
+ Clinical Indication
+
+
+
+ Technique
+
+
+
+ Findings
+
+
+
+ Impression
+
+
+
+
+
+ Save Report
+
+ setShowAddRecord(false)}>
+ Cancel
+
+
+
+
+ )}
+
+ {/* Radiology Records */}
+
+ {radiologyRecords.map((record) => (
+
+
+
+
+
+
+
{record.studyType}
+
+
+
+ {record.date} at {record.time}
+
+
+
+ {record.radiologist}
+
+
+
+
+
{record.status}
+
+
+
+
+
Clinical Indication:
+
{record.indication}
+
+
+
+
Technique:
+
{record.technique}
+
+
+
+
Findings:
+
{record.findings}
+
+
+
+
+
+
+
+ View Images
+
+
+
+ Print Report
+
+
+
+
+ ))}
+
+
+ {/* Empty State */}
+ {radiologyRecords.length === 0 && !showAddRecord && (
+
+
+
+ No Radiology Reports
+ No imaging studies have been recorded for this patient.
+ setShowAddRecord(true)}>
+
+ Add First Report
+
+
+
+ )}
+
+ )
+}
diff --git a/ipdmodule/components/rich-text-editor.tsx b/ipdmodule/components/rich-text-editor.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..4c0a8549b37ff6ebb7f32826562116cbc1dab236
--- /dev/null
+++ b/ipdmodule/components/rich-text-editor.tsx
@@ -0,0 +1,334 @@
+"use client"
+
+import { useState, useRef, useEffect } from "react"
+import { Button } from "@/components/ui/button"
+import { Textarea } from "@/components/ui/textarea"
+import { Badge } from "@/components/ui/badge"
+import { Bold, List, Mic, Save, Sparkles, Volume2, VolumeX, Copy } from "lucide-react"
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
+
+interface RichTextEditorProps {
+ value: string
+ onChange: (value: string) => void
+ placeholder: string
+ disabled?: boolean
+ rows?: number
+ fieldType: string
+ label?: string
+ showAutofill?: boolean
+ autofillSource?: string
+ autofillTimestamp?: string
+ className?: string
+}
+
+export function RichTextEditor({
+ value,
+ onChange,
+ placeholder,
+ disabled = false,
+ rows = 4,
+ fieldType,
+ label = "",
+ showAutofill = false,
+ autofillSource = "",
+ autofillTimestamp = "",
+ className = "",
+}: RichTextEditorProps) {
+ const [isListening, setIsListening] = useState(false)
+ const [speechSupported, setSpeechSupported] = useState(false)
+ const [selectedTemplate, setSelectedTemplate] = useState("")
+ const textareaRef = useRef(null)
+ const recognitionRef = useRef(null)
+
+ useEffect(() => {
+ // Check if speech recognition is supported
+ if (typeof window !== "undefined") {
+ const SpeechRecognition = (window as any).SpeechRecognition || (window as any).webkitSpeechRecognition
+ setSpeechSupported(!!SpeechRecognition)
+
+ if (SpeechRecognition) {
+ recognitionRef.current = new SpeechRecognition()
+ recognitionRef.current.continuous = true
+ recognitionRef.current.interimResults = true
+ recognitionRef.current.lang = "en-US"
+
+ recognitionRef.current.onresult = (event: any) => {
+ let finalTranscript = ""
+ for (let i = event.resultIndex; i < event.results.length; i++) {
+ const transcript = event.results[i][0].transcript
+ if (event.results[i].isFinal) {
+ finalTranscript += transcript
+ }
+ }
+
+ if (finalTranscript) {
+ const newValue = value + (value ? " " : "") + finalTranscript
+ onChange(newValue)
+ }
+ }
+
+ recognitionRef.current.onerror = () => setIsListening(false)
+ recognitionRef.current.onend = () => setIsListening(false)
+ }
+ }
+ }, [value, onChange])
+
+ const handleFormat = (format: string) => {
+ const textarea = textareaRef.current
+ if (!textarea) return
+
+ const start = textarea.selectionStart
+ const end = textarea.selectionEnd
+ const selectedText = value.substring(start, end)
+
+ if (!selectedText) {
+ let markers = ""
+ switch (format) {
+ case "bold":
+ markers = "****"
+ break
+ case "list":
+ markers = "• "
+ break
+ }
+ const newValue = value.substring(0, start) + markers + value.substring(end)
+ onChange(newValue)
+ setTimeout(() => {
+ textarea.focus()
+ const cursorPos = format === "list" ? start + markers.length : start + markers.length / 2
+ textarea.setSelectionRange(cursorPos, cursorPos)
+ }, 0)
+ return
+ }
+
+ let formattedText = selectedText
+ switch (format) {
+ case "bold":
+ formattedText = `**${selectedText}**`
+ break
+ case "list":
+ formattedText = `• ${selectedText}`
+ break
+ }
+
+ const newValue = value.substring(0, start) + formattedText + value.substring(end)
+ onChange(newValue)
+
+ setTimeout(() => {
+ textarea.focus()
+ textarea.setSelectionRange(start, start + formattedText.length)
+ }, 0)
+ }
+
+ const getTemplatesByFieldType = (fieldType: string) => {
+ const templates = {
+ "chief-complaints": [
+ "Patient presents with chest pain radiating to left arm, onset 2 hours ago, associated with shortness of breath and diaphoresis.",
+ "Abdominal pain in right lower quadrant, sharp in nature, started 6 hours ago, associated with nausea and vomiting.",
+ "Shortness of breath on exertion for past 3 days, associated with bilateral lower extremity swelling.",
+ "Fever with chills for 2 days, temperature up to 102°F, associated with body aches and headache.",
+ ],
+ assessment: [
+ "Patient is hemodynamically stable with improving clinical condition. Vital signs within normal limits.",
+ "Clinical improvement noted with current treatment regimen. Patient tolerating oral intake well.",
+ "Stable patient with good response to therapy. No acute distress observed.",
+ "Patient showing signs of clinical deterioration. Requires close monitoring and possible intervention.",
+ ],
+ plan: [
+ "Continue current medical management with close monitoring of clinical response.",
+ "Initiate new treatment protocol with frequent reassessment and adjustment as needed.",
+ "Prepare for discharge with appropriate follow-up arrangements and patient education.",
+ "Consider escalation of care if no improvement noted within specified timeframe.",
+ ],
+ "ot-procedure": [
+ "Standard laparoscopic technique employed with CO2 insufflation. Four-port access obtained safely.",
+ "Midline incision made and extended through all layers. Adequate exposure achieved.",
+ "Careful dissection performed with identification and preservation of vital structures.",
+ "Hemostasis achieved with electrocautery. Irrigation and inspection of surgical site completed.",
+ ],
+ general: [
+ "Patient tolerated procedure well without complications.",
+ "No acute distress noted at this time.",
+ "Stable clinical condition with appropriate response to treatment.",
+ "Requires continued monitoring and supportive care.",
+ ],
+ }
+
+ return templates[fieldType as keyof typeof templates] || templates.general
+ }
+
+ const loadTemplate = (templateText: string) => {
+ onChange(templateText)
+ setSelectedTemplate("")
+ }
+
+ const startVoiceInput = () => {
+ if (!speechSupported || !recognitionRef.current) {
+ alert("Speech recognition is not supported in your browser. Please use Chrome or Edge for voice input.")
+ return
+ }
+
+ if (isListening) {
+ recognitionRef.current.stop()
+ setIsListening(false)
+ } else {
+ try {
+ recognitionRef.current.start()
+ setIsListening(true)
+ } catch (error) {
+ console.error("Error starting speech recognition:", error)
+ alert("Unable to start voice recognition. Please check your microphone permissions.")
+ }
+ }
+ }
+
+ const handleSave = () => {
+ console.log("Saving content:", value)
+ alert("Content saved successfully!")
+ }
+
+ const handleMagicEnhance = () => {
+ alert("Magic AI enhancement feature would be implemented here to improve and expand the content using AI.")
+ }
+
+ const handleAutofillClick = () => {
+ if (showAutofill && autofillSource) {
+ alert(`Loading data from ${autofillSource} (${autofillTimestamp})`)
+ }
+ }
+
+ const templates = getTemplatesByFieldType(fieldType)
+
+ return (
+
+ {/* Header with Templates and Save buttons */}
+
+
+ {label || fieldType.replace("-", " ").replace(/\b\w/g, (l) => l.toUpperCase())}
+
+
+
+
+
+
+
+ {templates.map((template, index) => (
+
+ Template {index + 1}
+
+ ))}
+
+
+
+
+ Save
+
+
+
+
+ {/* Main textarea container */}
+
+
+ {!speechSupported && (
+
+
+ Voice input requires Chrome or Edge browser
+
+ )}
+
+ )
+}
diff --git a/ipdmodule/components/sidebar.tsx b/ipdmodule/components/sidebar.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..bd3884c5d48cad7c49f47b0fa21dab918a4ff23f
--- /dev/null
+++ b/ipdmodule/components/sidebar.tsx
@@ -0,0 +1,90 @@
+"use client"
+
+import { useState } from "react"
+import { Button } from "@/components/ui/button"
+import { ScrollArea } from "@/components/ui/scroll-area"
+import { Hospital, FileText, Menu, X, Stethoscope, Bed } from "lucide-react"
+
+interface SidebarProps {
+ activeModule: string
+ onModuleSelect: (module: string) => void
+}
+
+export function Sidebar({ activeModule, onModuleSelect }: SidebarProps) {
+ const [isCollapsed, setIsCollapsed] = useState(false)
+
+ const modules = [
+ { id: "ipd", label: "IPD", icon: Bed },
+ { id: "opd", label: "OPD", icon: Stethoscope },
+ { id: "emergency", label: "Emergency", icon: Hospital },
+ { id: "pharmacy", label: "Pharmacy", icon: FileText },
+ { id: "lab", label: "Laboratory", icon: FileText },
+ { id: "radiology", label: "Radiology", icon: FileText },
+ ]
+
+ return (
+ <>
+ {/* Mobile overlay */}
+ {!isCollapsed && (
+ setIsCollapsed(true)} />
+ )}
+
+ {/* Sidebar */}
+
+ {/* Header */}
+
+ {!isCollapsed && (
+
+
+ TatvaCare
+
+ )}
+
setIsCollapsed(!isCollapsed)} className="md:hidden">
+ {isCollapsed ? : }
+
+
+
+ {/* Navigation */}
+
+
+ {modules.map((module) => {
+ const Icon = module.icon
+ return (
+ {
+ onModuleSelect(module.id)
+ if (window.innerWidth < 768) setIsCollapsed(true)
+ }}
+ >
+
+ {!isCollapsed && {module.label} }
+
+ )
+ })}
+
+
+
+
+ {/* Mobile menu button */}
+
setIsCollapsed(false)}
+ >
+
+
+ >
+ )
+}
diff --git a/ipdmodule/components/theme-provider.tsx b/ipdmodule/components/theme-provider.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..55c2f6eb60b22a313a4c27bd0b2d728063cb8ab9
--- /dev/null
+++ b/ipdmodule/components/theme-provider.tsx
@@ -0,0 +1,11 @@
+'use client'
+
+import * as React from 'react'
+import {
+ ThemeProvider as NextThemesProvider,
+ type ThemeProviderProps,
+} from 'next-themes'
+
+export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
+ return
{children}
+}
diff --git a/ipdmodule/components/ui/accordion.tsx b/ipdmodule/components/ui/accordion.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..24c788c2c44cb058812cdbb97d071439a87af5f0
--- /dev/null
+++ b/ipdmodule/components/ui/accordion.tsx
@@ -0,0 +1,58 @@
+"use client"
+
+import * as React from "react"
+import * as AccordionPrimitive from "@radix-ui/react-accordion"
+import { ChevronDown } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Accordion = AccordionPrimitive.Root
+
+const AccordionItem = React.forwardRef<
+ React.ElementRef
,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+AccordionItem.displayName = "AccordionItem"
+
+const AccordionTrigger = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+
+ svg]:rotate-180",
+ className
+ )}
+ {...props}
+ >
+ {children}
+
+
+
+))
+AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
+
+const AccordionContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, children, ...props }, ref) => (
+
+ {children}
+
+))
+
+AccordionContent.displayName = AccordionPrimitive.Content.displayName
+
+export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }
diff --git a/ipdmodule/components/ui/alert-dialog.tsx b/ipdmodule/components/ui/alert-dialog.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..25e7b474464c9849cef836f5c863be0f38bdaac3
--- /dev/null
+++ b/ipdmodule/components/ui/alert-dialog.tsx
@@ -0,0 +1,141 @@
+"use client"
+
+import * as React from "react"
+import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog"
+
+import { cn } from "@/lib/utils"
+import { buttonVariants } from "@/components/ui/button"
+
+const AlertDialog = AlertDialogPrimitive.Root
+
+const AlertDialogTrigger = AlertDialogPrimitive.Trigger
+
+const AlertDialogPortal = AlertDialogPrimitive.Portal
+
+const AlertDialogOverlay = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
+
+const AlertDialogContent = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+
+
+
+))
+AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName
+
+const AlertDialogHeader = ({
+ className,
+ ...props
+}: React.HTMLAttributes) => (
+
+)
+AlertDialogHeader.displayName = "AlertDialogHeader"
+
+const AlertDialogFooter = ({
+ className,
+ ...props
+}: React.HTMLAttributes) => (
+
+)
+AlertDialogFooter.displayName = "AlertDialogFooter"
+
+const AlertDialogTitle = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName
+
+const AlertDialogDescription = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+AlertDialogDescription.displayName =
+ AlertDialogPrimitive.Description.displayName
+
+const AlertDialogAction = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName
+
+const AlertDialogCancel = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName
+
+export {
+ AlertDialog,
+ AlertDialogPortal,
+ AlertDialogOverlay,
+ AlertDialogTrigger,
+ AlertDialogContent,
+ AlertDialogHeader,
+ AlertDialogFooter,
+ AlertDialogTitle,
+ AlertDialogDescription,
+ AlertDialogAction,
+ AlertDialogCancel,
+}
diff --git a/ipdmodule/components/ui/alert.tsx b/ipdmodule/components/ui/alert.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..41fa7e0561a3fdb5f986c1213a35e563de740e96
--- /dev/null
+++ b/ipdmodule/components/ui/alert.tsx
@@ -0,0 +1,59 @@
+import * as React from "react"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const alertVariants = cva(
+ "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
+ {
+ variants: {
+ variant: {
+ default: "bg-background text-foreground",
+ destructive:
+ "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ }
+)
+
+const Alert = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes & VariantProps
+>(({ className, variant, ...props }, ref) => (
+
+))
+Alert.displayName = "Alert"
+
+const AlertTitle = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+AlertTitle.displayName = "AlertTitle"
+
+const AlertDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+AlertDescription.displayName = "AlertDescription"
+
+export { Alert, AlertTitle, AlertDescription }
diff --git a/ipdmodule/components/ui/aspect-ratio.tsx b/ipdmodule/components/ui/aspect-ratio.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..d6a5226f5e9cc09a2bd1ccbce465524e41f04345
--- /dev/null
+++ b/ipdmodule/components/ui/aspect-ratio.tsx
@@ -0,0 +1,7 @@
+"use client"
+
+import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio"
+
+const AspectRatio = AspectRatioPrimitive.Root
+
+export { AspectRatio }
diff --git a/ipdmodule/components/ui/avatar.tsx b/ipdmodule/components/ui/avatar.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..51e507ba9d08bcdbb1fb630498f1cbdf2bf50093
--- /dev/null
+++ b/ipdmodule/components/ui/avatar.tsx
@@ -0,0 +1,50 @@
+"use client"
+
+import * as React from "react"
+import * as AvatarPrimitive from "@radix-ui/react-avatar"
+
+import { cn } from "@/lib/utils"
+
+const Avatar = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+Avatar.displayName = AvatarPrimitive.Root.displayName
+
+const AvatarImage = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+AvatarImage.displayName = AvatarPrimitive.Image.displayName
+
+const AvatarFallback = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+))
+AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName
+
+export { Avatar, AvatarImage, AvatarFallback }
diff --git a/ipdmodule/components/ui/badge.tsx b/ipdmodule/components/ui/badge.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..f000e3ef5176395b067dfc3f3e1256a80c450015
--- /dev/null
+++ b/ipdmodule/components/ui/badge.tsx
@@ -0,0 +1,36 @@
+import * as React from "react"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const badgeVariants = cva(
+ "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
+ {
+ variants: {
+ variant: {
+ default:
+ "border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
+ secondary:
+ "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
+ destructive:
+ "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
+ outline: "text-foreground",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ }
+)
+
+export interface BadgeProps
+ extends React.HTMLAttributes,
+ VariantProps {}
+
+function Badge({ className, variant, ...props }: BadgeProps) {
+ return (
+
+ )
+}
+
+export { Badge, badgeVariants }
diff --git a/ipdmodule/components/ui/breadcrumb.tsx b/ipdmodule/components/ui/breadcrumb.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..60e6c96f72f0350d08b47e4730cab8f3975dc853
--- /dev/null
+++ b/ipdmodule/components/ui/breadcrumb.tsx
@@ -0,0 +1,115 @@
+import * as React from "react"
+import { Slot } from "@radix-ui/react-slot"
+import { ChevronRight, MoreHorizontal } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Breadcrumb = React.forwardRef<
+ HTMLElement,
+ React.ComponentPropsWithoutRef<"nav"> & {
+ separator?: React.ReactNode
+ }
+>(({ ...props }, ref) => )
+Breadcrumb.displayName = "Breadcrumb"
+
+const BreadcrumbList = React.forwardRef<
+ HTMLOListElement,
+ React.ComponentPropsWithoutRef<"ol">
+>(({ className, ...props }, ref) => (
+
+))
+BreadcrumbList.displayName = "BreadcrumbList"
+
+const BreadcrumbItem = React.forwardRef<
+ HTMLLIElement,
+ React.ComponentPropsWithoutRef<"li">
+>(({ className, ...props }, ref) => (
+
+))
+BreadcrumbItem.displayName = "BreadcrumbItem"
+
+const BreadcrumbLink = React.forwardRef<
+ HTMLAnchorElement,
+ React.ComponentPropsWithoutRef<"a"> & {
+ asChild?: boolean
+ }
+>(({ asChild, className, ...props }, ref) => {
+ const Comp = asChild ? Slot : "a"
+
+ return (
+
+ )
+})
+BreadcrumbLink.displayName = "BreadcrumbLink"
+
+const BreadcrumbPage = React.forwardRef<
+ HTMLSpanElement,
+ React.ComponentPropsWithoutRef<"span">
+>(({ className, ...props }, ref) => (
+
+))
+BreadcrumbPage.displayName = "BreadcrumbPage"
+
+const BreadcrumbSeparator = ({
+ children,
+ className,
+ ...props
+}: React.ComponentProps<"li">) => (
+ svg]:w-3.5 [&>svg]:h-3.5", className)}
+ {...props}
+ >
+ {children ?? }
+
+)
+BreadcrumbSeparator.displayName = "BreadcrumbSeparator"
+
+const BreadcrumbEllipsis = ({
+ className,
+ ...props
+}: React.ComponentProps<"span">) => (
+
+
+ More
+
+)
+BreadcrumbEllipsis.displayName = "BreadcrumbElipssis"
+
+export {
+ Breadcrumb,
+ BreadcrumbList,
+ BreadcrumbItem,
+ BreadcrumbLink,
+ BreadcrumbPage,
+ BreadcrumbSeparator,
+ BreadcrumbEllipsis,
+}
diff --git a/ipdmodule/components/ui/button.tsx b/ipdmodule/components/ui/button.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..36496a28727a3643b4212a14225d4f6cbd50bda5
--- /dev/null
+++ b/ipdmodule/components/ui/button.tsx
@@ -0,0 +1,56 @@
+import * as React from "react"
+import { Slot } from "@radix-ui/react-slot"
+import { cva, type VariantProps } from "class-variance-authority"
+
+import { cn } from "@/lib/utils"
+
+const buttonVariants = cva(
+ "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
+ {
+ variants: {
+ variant: {
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
+ destructive:
+ "bg-destructive text-destructive-foreground hover:bg-destructive/90",
+ outline:
+ "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
+ secondary:
+ "bg-secondary text-secondary-foreground hover:bg-secondary/80",
+ ghost: "hover:bg-accent hover:text-accent-foreground",
+ link: "text-primary underline-offset-4 hover:underline",
+ },
+ size: {
+ default: "h-10 px-4 py-2",
+ sm: "h-9 rounded-md px-3",
+ lg: "h-11 rounded-md px-8",
+ icon: "h-10 w-10",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ size: "default",
+ },
+ }
+)
+
+export interface ButtonProps
+ extends React.ButtonHTMLAttributes,
+ VariantProps {
+ asChild?: boolean
+}
+
+const Button = React.forwardRef(
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
+ const Comp = asChild ? Slot : "button"
+ return (
+
+ )
+ }
+)
+Button.displayName = "Button"
+
+export { Button, buttonVariants }
diff --git a/ipdmodule/components/ui/calendar.tsx b/ipdmodule/components/ui/calendar.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..61d2b451ef5fd1d9faa1162371628a8132dd51df
--- /dev/null
+++ b/ipdmodule/components/ui/calendar.tsx
@@ -0,0 +1,66 @@
+"use client"
+
+import * as React from "react"
+import { ChevronLeft, ChevronRight } from "lucide-react"
+import { DayPicker } from "react-day-picker"
+
+import { cn } from "@/lib/utils"
+import { buttonVariants } from "@/components/ui/button"
+
+export type CalendarProps = React.ComponentProps
+
+function Calendar({
+ className,
+ classNames,
+ showOutsideDays = true,
+ ...props
+}: CalendarProps) {
+ return (
+ ,
+ IconRight: ({ ...props }) => ,
+ }}
+ {...props}
+ />
+ )
+}
+Calendar.displayName = "Calendar"
+
+export { Calendar }
diff --git a/ipdmodule/components/ui/card.tsx b/ipdmodule/components/ui/card.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..f62edea578d50058bef5e6bcc178b88d145564e9
--- /dev/null
+++ b/ipdmodule/components/ui/card.tsx
@@ -0,0 +1,79 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+const Card = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+Card.displayName = "Card"
+
+const CardHeader = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardHeader.displayName = "CardHeader"
+
+const CardTitle = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardTitle.displayName = "CardTitle"
+
+const CardDescription = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardDescription.displayName = "CardDescription"
+
+const CardContent = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardContent.displayName = "CardContent"
+
+const CardFooter = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => (
+
+))
+CardFooter.displayName = "CardFooter"
+
+export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
diff --git a/ipdmodule/components/ui/carousel.tsx b/ipdmodule/components/ui/carousel.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..ec505d00d95ecdbbc1501d1bfa7020e51d6010a7
--- /dev/null
+++ b/ipdmodule/components/ui/carousel.tsx
@@ -0,0 +1,262 @@
+"use client"
+
+import * as React from "react"
+import useEmblaCarousel, {
+ type UseEmblaCarouselType,
+} from "embla-carousel-react"
+import { ArrowLeft, ArrowRight } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+import { Button } from "@/components/ui/button"
+
+type CarouselApi = UseEmblaCarouselType[1]
+type UseCarouselParameters = Parameters
+type CarouselOptions = UseCarouselParameters[0]
+type CarouselPlugin = UseCarouselParameters[1]
+
+type CarouselProps = {
+ opts?: CarouselOptions
+ plugins?: CarouselPlugin
+ orientation?: "horizontal" | "vertical"
+ setApi?: (api: CarouselApi) => void
+}
+
+type CarouselContextProps = {
+ carouselRef: ReturnType[0]
+ api: ReturnType[1]
+ scrollPrev: () => void
+ scrollNext: () => void
+ canScrollPrev: boolean
+ canScrollNext: boolean
+} & CarouselProps
+
+const CarouselContext = React.createContext(null)
+
+function useCarousel() {
+ const context = React.useContext(CarouselContext)
+
+ if (!context) {
+ throw new Error("useCarousel must be used within a ")
+ }
+
+ return context
+}
+
+const Carousel = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes & CarouselProps
+>(
+ (
+ {
+ orientation = "horizontal",
+ opts,
+ setApi,
+ plugins,
+ className,
+ children,
+ ...props
+ },
+ ref
+ ) => {
+ const [carouselRef, api] = useEmblaCarousel(
+ {
+ ...opts,
+ axis: orientation === "horizontal" ? "x" : "y",
+ },
+ plugins
+ )
+ const [canScrollPrev, setCanScrollPrev] = React.useState(false)
+ const [canScrollNext, setCanScrollNext] = React.useState(false)
+
+ const onSelect = React.useCallback((api: CarouselApi) => {
+ if (!api) {
+ return
+ }
+
+ setCanScrollPrev(api.canScrollPrev())
+ setCanScrollNext(api.canScrollNext())
+ }, [])
+
+ const scrollPrev = React.useCallback(() => {
+ api?.scrollPrev()
+ }, [api])
+
+ const scrollNext = React.useCallback(() => {
+ api?.scrollNext()
+ }, [api])
+
+ const handleKeyDown = React.useCallback(
+ (event: React.KeyboardEvent) => {
+ if (event.key === "ArrowLeft") {
+ event.preventDefault()
+ scrollPrev()
+ } else if (event.key === "ArrowRight") {
+ event.preventDefault()
+ scrollNext()
+ }
+ },
+ [scrollPrev, scrollNext]
+ )
+
+ React.useEffect(() => {
+ if (!api || !setApi) {
+ return
+ }
+
+ setApi(api)
+ }, [api, setApi])
+
+ React.useEffect(() => {
+ if (!api) {
+ return
+ }
+
+ onSelect(api)
+ api.on("reInit", onSelect)
+ api.on("select", onSelect)
+
+ return () => {
+ api?.off("select", onSelect)
+ }
+ }, [api, onSelect])
+
+ return (
+
+
+ {children}
+
+
+ )
+ }
+)
+Carousel.displayName = "Carousel"
+
+const CarouselContent = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => {
+ const { carouselRef, orientation } = useCarousel()
+
+ return (
+
+ )
+})
+CarouselContent.displayName = "CarouselContent"
+
+const CarouselItem = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes
+>(({ className, ...props }, ref) => {
+ const { orientation } = useCarousel()
+
+ return (
+
+ )
+})
+CarouselItem.displayName = "CarouselItem"
+
+const CarouselPrevious = React.forwardRef<
+ HTMLButtonElement,
+ React.ComponentProps
+>(({ className, variant = "outline", size = "icon", ...props }, ref) => {
+ const { orientation, scrollPrev, canScrollPrev } = useCarousel()
+
+ return (
+
+
+ Previous slide
+
+ )
+})
+CarouselPrevious.displayName = "CarouselPrevious"
+
+const CarouselNext = React.forwardRef<
+ HTMLButtonElement,
+ React.ComponentProps
+>(({ className, variant = "outline", size = "icon", ...props }, ref) => {
+ const { orientation, scrollNext, canScrollNext } = useCarousel()
+
+ return (
+
+
+ Next slide
+
+ )
+})
+CarouselNext.displayName = "CarouselNext"
+
+export {
+ type CarouselApi,
+ Carousel,
+ CarouselContent,
+ CarouselItem,
+ CarouselPrevious,
+ CarouselNext,
+}
diff --git a/ipdmodule/components/ui/chart.tsx b/ipdmodule/components/ui/chart.tsx
new file mode 100644
index 0000000000000000000000000000000000000000..8620baa3b32301ef0e071b13049f2a00caa6f0bc
--- /dev/null
+++ b/ipdmodule/components/ui/chart.tsx
@@ -0,0 +1,365 @@
+"use client"
+
+import * as React from "react"
+import * as RechartsPrimitive from "recharts"
+
+import { cn } from "@/lib/utils"
+
+// Format: { THEME_NAME: CSS_SELECTOR }
+const THEMES = { light: "", dark: ".dark" } as const
+
+export type ChartConfig = {
+ [k in string]: {
+ label?: React.ReactNode
+ icon?: React.ComponentType
+ } & (
+ | { color?: string; theme?: never }
+ | { color?: never; theme: Record }
+ )
+}
+
+type ChartContextProps = {
+ config: ChartConfig
+}
+
+const ChartContext = React.createContext(null)
+
+function useChart() {
+ const context = React.useContext(ChartContext)
+
+ if (!context) {
+ throw new Error("useChart must be used within a ")
+ }
+
+ return context
+}
+
+const ChartContainer = React.forwardRef<
+ HTMLDivElement,
+ React.ComponentProps<"div"> & {
+ config: ChartConfig
+ children: React.ComponentProps<
+ typeof RechartsPrimitive.ResponsiveContainer
+ >["children"]
+ }
+>(({ id, className, children, config, ...props }, ref) => {
+ const uniqueId = React.useId()
+ const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`
+
+ return (
+
+
+
+
+ {children}
+
+
+
+ )
+})
+ChartContainer.displayName = "Chart"
+
+const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
+ const colorConfig = Object.entries(config).filter(
+ ([_, config]) => config.theme || config.color
+ )
+
+ if (!colorConfig.length) {
+ return null
+ }
+
+ return (
+