# Product Requirements Document (PRD)
## Healthcare Management System

**Version:** 1.0  
**Domain:** https://anil.dev.dalfin.ai  
**Last Updated:** 2024

---

## 1. Overview

The Healthcare Management System is a comprehensive web-based application designed to streamline healthcare operations across five core functional areas. The system enables healthcare providers to manage patient records, schedule appointments, track medical histories, process billing, and generate reports efficiently. This platform serves as a centralized solution for clinics, hospitals, and healthcare facilities to digitize and optimize their administrative and clinical workflows.

---

## 2. User Roles

### 2.1 Administrator
- Full system access and configuration rights
- Manage user accounts (create, edit, deactivate healthcare providers and staff)
- Configure system settings, departments, and services
- Access all reports and analytics
- Manage billing rates and insurance providers
- Audit system logs and activity

### 2.2 Doctor
- View and manage assigned patient records
- Create and update medical diagnoses and treatment plans
- Prescribe medications and order lab tests
- View appointment schedule and patient history
- Generate medical reports and prescriptions
- Update consultation notes

### 2.3 Nurse/Medical Staff
- Register new patients and update patient demographics
- Schedule and manage appointments
- Record vital signs and basic patient information
- View doctor's orders and treatment plans
- Assist in patient check-in and check-out processes
- Cannot modify diagnoses or prescriptions

### 2.4 Receptionist/Front Desk
- Register new patients
- Schedule, reschedule, and cancel appointments
- Manage appointment calendar
- Check-in patients for appointments
- Print appointment confirmations and receipts
- Limited access to medical records (demographics only)

### 2.5 Billing Officer
- Generate and manage patient invoices
- Process payments and refunds
- Track outstanding balances
- Manage insurance claims
- Generate billing reports
- View appointment and service records for billing purposes
- Cannot access detailed medical records

---

## 3. Core Entities

### 3.1 User
Represents all system users including administrators, doctors, nurses, receptionists, and billing officers. Contains authentication credentials, role assignments, and profile information.

### 3.2 Patient
Represents individuals receiving healthcare services. Stores demographic information, contact details, emergency contacts, insurance information, and patient identification numbers.

### 3.3 Appointment
Represents scheduled visits between patients and healthcare providers. Contains date, time, duration, appointment type, status, and associated notes.

### 3.4 Medical Record
Comprehensive health record for each patient containing medical history, allergies, chronic conditions, blood type, and other clinical information.

### 3.5 Consultation
Represents a specific medical consultation session. Contains chief complaints, examination findings, diagnosis, treatment plans, and doctor's notes.

### 3.6 Prescription
Medication orders created by doctors. Contains medicine names, dosages, frequency, duration, and special instructions.

### 3.7 Vital Signs
Records of patient vital measurements including blood pressure, temperature, pulse rate, respiratory rate, weight, and height, captured during visits.

### 3.8 Department
Organizational units within the healthcare facility (e.g., Cardiology, Pediatrics, Radiology). Contains department name, description, and assigned staff.

### 3.9 Service
Medical services offered by the facility (e.g., consultation, lab test, imaging). Contains service name, description, duration, and default pricing.

### 3.10 Invoice
Billing document for services rendered. Contains line items, subtotals, taxes, discounts, total amount, and payment status.

### 3.11 Payment
Records of financial transactions. Contains payment amount, method (cash, card, insurance), date, and reference numbers.

### 3.12 Insurance Provider
Details of insurance companies accepted by the facility. Contains provider name, contact information, and coverage policies.

### 3.13 Lab Test
Laboratory test orders and results. Contains test name, ordered date, sample collection date, results, and reference ranges.

### 3.14 Report
System-generated analytical reports including patient statistics, revenue reports, appointment summaries, and operational metrics.

---

## 4. Entity Relationships

### 4.1 User Relationships
- **User → Department**: Many-to-One (a user belongs to one department)
- **User → Appointment**: One-to-Many (a doctor has many appointments)
- **User → Consultation**: One-to-Many (a doctor conducts many consultations)

### 4.2 Patient Relationships
- **Patient → Medical Record**: One-to-One (each patient has one comprehensive medical record)
- **Patient → Appointment**: One-to-Many (a patient can have multiple appointments)
- **Patient → Consultation**: One-to-Many (a patient has multiple consultations)
- **Patient → Invoice**: One-to-Many (a patient receives multiple invoices)
- **Patient → Insurance Provider**: Many-to-One (a patient has one primary insurance provider)
- **Patient → Vital Signs**: One-to-Many (a patient has multiple vital sign recordings)

### 4.3 Appointment Relationships
- **Appointment → Patient**: Many-to-One (many appointments belong to one patient)
- **Appointment → User (Doctor)**: Many-to-One (many appointments assigned to one doctor)
- **Appointment → Department**: Many-to-One (appointment scheduled in one department)
- **Appointment → Consultation**: One-to-One (an appointment may result in one consultation)

### 4.4 Consultation Relationships
- **Consultation → Patient**: Many-to-One (many consultations for one patient)
- **Consultation → User (Doctor)**: Many-to-One (many consultations by one doctor)
- **Consultation → Prescription**: One-to-Many (one consultation may have multiple prescriptions)
- **Consultation → Lab Test**: One-to-Many (one consultation may order multiple lab tests)
- **Consultation → Appointment**: One-to-One (consultation linked to one appointment)

### 4.5 Billing Relationships
- **Invoice → Patient**: Many-to-One (many invoices for one patient)
- **Invoice → Payment**: One-to-Many (an invoice may have multiple partial payments)
- **Invoice → Service**: Many-to-Many (an invoice contains multiple services, a service appears on multiple invoices)
- **Invoice → Consultation**: Many-to-One (multiple charges may stem from one consultation)

### 4.6 Medical Record Relationships
- **Medical Record → Patient**: One-to-One (one medical record per patient)
- **Medical Record → Consultation**: One-to-Many (medical record updated by multiple consultations)
- **Medical Record → Lab Test**: One-to-Many (medical record contains multiple lab test results)

### 4.7 Other Relationships
- **Department → Service**: One-to-Many (a department offers multiple services)
- **Lab Test → Consultation**: Many-to-One (multiple tests can be ordered in one consultation)
- **Vital Signs → Patient**: Many-to-One (multiple vital sign records for one patient)

---

## 5. Key Workflows

### 5.1 Patient Registration Workflow
1. Receptionist navigates to patient registration page
2. Receptionist enters patient demographic information (name, DOB, gender, contact)
3. Receptionist captures emergency contact details
4. Receptionist enters insurance provider information (if applicable)
5. System validates required fields and unique identifiers
6. System generates unique patient ID
7. System creates initial medical record for patient
8. Receptionist prints patient registration card
9. Patient profile is now active in the system

### 5.2 Appointment Scheduling Workflow
1. Receptionist/Patient accesses appointment scheduling interface
2. User searches for patient by name, ID, or phone number
3. User selects desired department and doctor
4. System displays doctor's availability calendar
5. User selects available date and time slot
6. User specifies appointment type (new consultation, follow-up, emergency)
7. User adds appointment notes/reason for visit
8. System validates appointment slot availability
9. System creates appointment record with "Scheduled" status
10. System sends confirmation notification (email/SMS)
11. Appointment appears on doctor's calendar

### 5.3 Patient Check-in and Consultation Workflow
1. Patient arrives at facility for scheduled appointment
2. Receptionist searches for appointment
3. Receptionist updates appointment status to "Checked-In"
4. Nurse calls patient and records vital signs (BP, temperature, pulse, weight)
5. System saves vital signs linked to patient record
6. Patient moves to waiting area
7. Doctor views queue of checked-in patients
8. Doctor calls patient for consultation
9. Doctor updates appointment status to "In Progress"
10. Doctor reviews patient's medical history and current vitals
11. Doctor records chief complaint and examination findings
12. Doctor enters diagnosis and treatment plan
13. Doctor creates prescription (if needed)
14. Doctor orders lab tests (if needed)
15. Doctor saves consultation notes
16. Doctor marks appointment as "Completed"
17. System updates medical record with consultation summary
18. Patient proceeds to billing/pharmacy

### 5.4 Prescription and Medication Workflow
1. Doctor creates prescription during consultation
2. Doctor searches medication database or enters medication name
3. Doctor specifies dosage, frequency (e.g., twice daily), and duration (e.g., 7 days)
4. Doctor adds special instructions (e.g., "take after meals")
5. Doctor adds multiple medications to prescription if needed
6. System validates drug interactions and allergies (warning displayed if conflicts)
7. Doctor finalizes and saves prescription
8. System generates printable prescription document
9. Prescription is linked to patient's medical record
10. Patient receives printed prescription
11. (Optional) Prescription sent to pharmacy system for fulfillment

### 5.5 Billing and Payment Workflow
1. After consultation completion, patient proceeds to billing desk
2. Billing officer retrieves patient and consultation details
3. System automatically populates invoice with consultation charges
4. Billing officer adds additional services (lab tests, procedures, medications)
5. System calculates subtotal for all services
6. System applies insurance coverage (if applicable)
7. System calculates patient responsibility (copay, deductible)
8. System applies any discounts or adjustments
9. System calculates final total amount due
10. Billing officer reviews invoice with patient
11. Patient makes payment (cash, card, or insurance claim)
12. Billing officer records payment details
13. System updates invoice status to "Paid" or "Partially Paid"
14. System generates and prints receipt
15. If balance remains, system tracks as outstanding
16. System updates patient's billing history

### 5.6 Lab Test Request and Results Workflow
1. Doctor orders lab test during consultation
2. Doctor selects test type from predefined list
3. Doctor adds special instructions for lab
4. System creates lab test order with "Ordered" status
5. Patient receives lab test requisition form
6. Patient goes to lab for sample collection
7. Lab technician updates test status to "Sample Collected"
8. Lab processes sample and enters results
9. Lab technician uploads result document and enters values
10. Lab technician marks test as "Completed"
11. System notifies doctor of available results
12. Doctor reviews results and updates patient record
13. Doctor may schedule follow-up appointment based on results
14. Results are permanently attached to patient's medical record

### 5.7 Report Generation Workflow
1. Administrator/Manager navigates to reports module
2. User selects report type (patient statistics, revenue, appointments, etc.)
3. User specifies date range and filter criteria (department, doctor, service type)
4. User clicks "Generate Report"
5. System queries database and aggregates data
6. System calculates metrics and statistics
7. System renders report in selected format (table, chart, graph)
8. User reviews report on screen
9. User exports report (PDF, Excel, CSV)
10. System logs report generation activity
11. Report can be saved for future reference

---

## 6. Features & Requirements

### 6.1 Page 1: Dashboard
**Purpose:** Central hub displaying key metrics and quick access to common functions

#### 6.1.1 Dashboard Widgets (Role-based)
- **FR-DASH-001**: Display today's appointment count and status summary
- **FR-DASH-002**: Show pending patient check-ins list
- **FR-DASH-003**: Display real-time statistics (total patients, today's consultations, revenue)
- **FR-DASH-004**: Show doctor's daily schedule (for doctor role)
- **FR-DASH-005**: Display outstanding invoices summary (for billing officer)
- **FR-DASH-006**: Show recent patient registrations
- **FR-DASH-007**: Display department-wise appointment distribution chart
- **FR-DASH-008**: Show alerts and notifications (pending lab results, upcoming appointments)
- **FR-DASH-009**: Quick action buttons (New Appointment, Register Patient, New Consultation)
- **FR-DASH-010**: Display system announcements and messages

#### 6.1.2 Navigation
- **FR-DASH-011**: Sidebar navigation menu with role-based access control
- **FR-DASH-012**: Global search bar (search patients, appointments by ID, name, phone)
- **FR-DASH-013**: User profile dropdown with logout option
- **FR-DASH-014**: Notification bell icon with unread count
- **FR-DASH-015**: Breadcrumb navigation for current page location

### 6.2 Page 2: Patient Management
**Purpose:** Comprehensive patient registration, search, and profile management

#### 6.2.1 Patient Registration
- **FR-PAT-001**: Form to capture patient first name, last name, middle name
- **FR-PAT-002**: Date of birth input with age auto-calculation
- **FR-PAT-003**: Gender selection (Male, Female, Other)
- **FR-PAT-004**: Contact information (mobile number, email, alternate phone)
- **FR-PAT-005**: Address fields (street, city, state, postal code, country)
- **FR-PAT-006**: Emergency contact (name, relationship, phone number)
- **FR-PAT-007**: Insurance provider selection and policy number entry
- **FR-PAT-008**: Blood group selection
- **FR-PAT-009**: Known allergies text area
- **FR-PAT-010**: Upload patient photo capability
- **FR-PAT-011**: Auto-generate unique patient ID upon registration
- **FR-PAT-012**: Mark patient as active/inactive status

#### 6.2.2 Patient Search and List
- **FR-PAT-013**: Search patients by name, patient ID, phone number, email
- **FR-PAT-014**: Filter patients by registration date range
- **FR-PAT-015**: Filter by insurance provider
- **FR-PAT-016**: Paginated patient list table showing ID, name, age, gender, contact, last visit
- **FR-PAT-017**: Sort by name, registration date, last visit date
- **FR-PAT-018**: Export patient list to Excel/CSV
- **FR-PAT-019**: Quick action buttons (View, Edit, View History) for each patient

#### 6.2.3 Patient Profile View
- **FR-PAT-020**: Display complete patient demographics
- **FR-PAT-021**: Show medical record summary (blood group, allergies, chronic conditions)
- **FR-PAT-022**: Display appointment history with dates and doctors
- **FR-PAT-023**: Show consultation history with diagnoses
- **FR-PAT-024**: List all prescriptions issued
- **FR-PAT-025**: Display vital signs trend charts
- **FR-PAT-026**: Show lab test results history
- **FR-PAT-027**: Display billing history and outstanding balance
- **FR-PAT-028**: Edit patient information button (with permission check)
- **FR-PAT-029**: Schedule new appointment button from patient profile
- **FR-PAT-030**: Print patient summary report

#### 6.2.4 Medical Record Management
- **FR-PAT-031**: Update medical history section
- **FR-PAT-032**: Add/edit chronic conditions list
- **FR-PAT-033**: Add/edit current medications
- **FR-PAT-034**: Update family medical history
- **FR-PAT-035**: Record surgical history
- **FR-PAT-036**: Document immunization records
- **FR-PAT-037**: Attach medical documents (scans, reports, images)
- **FR-PAT-038**: Timestamp all medical record updates with user who made the change

### 6.3 Page 3: Appointment & Scheduling
**Purpose:** Complete appointment lifecycle management from scheduling to completion

#### 6.3.1 Appointment Calendar View
- **FR-APPT-001**: Month view calendar showing all appointments
- **FR-APPT-002**: Week view showing daily time slots
- **FR-APPT-003**: Day view with hourly breakdown
- **FR-APPT-004**: Color-coded appointment status (Scheduled, Checked-in, In Progress, Completed, Cancelled)
- **FR-APPT-005**: Filter calendar by department
- **FR-APPT-006**: Filter by doctor
- **FR-APPT-007**: Filter by appointment type
- **FR-APPT-008**: Click appointment to view details popup

#### 6.3.2 Appointment Creation
- **FR-APPT-009**: Select patient from searchable dropdown
- **FR-APPT-010**: Quick register new patient option if not found
- **FR-APPT-011**: Select department from dropdown
- **FR-APPT-012**: Select doctor (filtered by selected department)
- **FR-APPT-013**: Select appointment date from calendar
- **FR-APPT-014**: Select available time slot (system shows only available slots)
- **FR-APPT-015**: Specify appointment duration (default based on appointment type)
- **FR-APPT-016**: Select appointment type (New Consultation, Follow-up, Emergency, Check-up)
- **FR-APPT-017**: Enter reason for visit / chief complaint
- **FR-APPT-018**: Add internal notes (visible to staff only)
- **FR-APPT-019**: Select priority (Normal, Urgent)
- **FR-APPT-020**: Send confirmation SMS/email checkbox
- **FR-APPT-021**: Validate no double-booking before saving

#### 6.3.3 Appointment Management
- **FR-APPT-022**: Reschedule appointment with date/time change
- **FR-APPT-023**: Cancel appointment with reason
- **FR-APPT-024**: Check-in patient (update status)
- **FR-APPT-025**: Mark as "No Show" for missed appointments
- **FR-APPT-026**: View appointment details (patient info, doctor, time, status)
- **FR-APPT-027**: Print appointment confirmation slip
- **FR-APPT-028**: Send reminder notification before appointment
- **FR-APPT-029**: Display appointment queue for each doctor
- **FR-APPT-030**: Estimated wait time calculation

#### 6.3.4 Appointment List & Search
- **FR-APPT-031**: List view of all appointments with filters
- **FR-APPT-032**: Search by patient name or ID
- **FR-APPT-033**: Filter by date range
- **FR-APPT-034**: Filter by status
- **FR-APPT-035**: Filter by doctor or department
- **FR-APPT-036**: Export appointments list to Excel
- **FR-APPT-037**: Today's appointments quick filter
- **FR-APPT-038**: Upcoming appointments quick filter (next 7 days)

### 6.4 Page 4: Clinical & Consultation
**Purpose:** Medical consultation documentation, prescriptions, and clinical workflows

#### 6.4.1 Consultation Management
- **FR-CLIN-001**: Start consultation from checked-in appointment
- **FR-CLIN-002**: Display patient summary (age, gender, allergies, chronic conditions)
- **FR-CLIN-003**: Show previous consultations quick reference
- **FR-CLIN-004**: Display current vital signs
- **FR-CLIN-005**: Record chief complaint / reason for visit
- **FR-CLIN-006**: Document history of present illness
- **FR-CLIN-007**: Record physical examination findings
- **FR-CLIN-008**: Enter diagnosis (ICD-10 code support)
- **FR-CLIN-009**: Add multiple diagnoses (primary and secondary)
- **FR-CLIN-010**: Document treatment plan and recommendations
- **FR-CLIN-011**: Add clinical notes text area
- **FR-CLIN-012**: Mark consultation as completed
- **FR-CLIN-013**: Save as draft for incomplete consultations
- **FR-CLIN-014**: Timestamp and doctor signature capture

#### 6.4.2 Vital Signs Recording
- **FR-CLIN-015**: Record blood pressure (systolic/diastolic)
- **FR-CLIN-016**: Record temperature (Celsius/Fahrenheit toggle)
- **FR-CLIN-017**: Record pulse rate (bpm)
- **FR-CLIN-018**: Record respiratory rate
- **FR-CLIN-019**: Record oxygen saturation (SpO2)
- **FR-CLIN-020**: Record weight (kg/lbs toggle)
- **FR-CLIN-021**: Record height (cm/inches toggle)
- **FR-CLIN-022**: Auto-calculate BMI from height and weight
- **FR-CLIN-023**: Timestamp vital signs capture
- **FR-CLIN-024**: Record who captured vitals (nurse/staff ID)
- **FR-CLIN-025**: Display vital signs history graph

#### 6.4.3 Prescription Management
- **FR-CLIN-026**: Add prescription within consultation
- **FR-CLIN-027**: Search medication from drug database
- **FR-CLIN-028**: Enter medication name (free text if not in database)
- **FR-CLIN-029**: Specify dosage strength (e.g., 500mg)
- **FR-CLIN-030**: Select dosage form (tablet, capsule, syrup, injection, etc.)
- **FR-CLIN-031**: Specify frequency (once daily, twice daily, thrice daily, every 6 hours, etc.)
- **FR-CLIN-032**: Specify duration (number of days)
- **FR-CLIN-033**: Select timing (before food, after food, empty stomach)
- **FR-CLIN-034**: Add special instructions per medication
- **FR-CLIN-035**: Add multiple medications to prescription
- **FR-CLIN-036**: Remove medication from prescription
- **FR-CLIN-037**: Check for drug-allergy interactions (warning displayed)
- **FR-CLIN-038**: Save prescription linked to consultation
- **FR-CLIN-039**: Print prescription document on letterhead
- **FR-CLIN-040**: View prescription history for patient

#### 6.4.4 Lab Test Orders
- **FR-CLIN-041**: Order lab test from predefined test catalog
- **FR-CLIN-042**: Search lab tests (blood tests, urine tests, imaging, etc.)
- **FR-CLIN-043**: Add multiple tests to single order
- **FR-CLIN-044**: Mark test as urgent/priority
- **FR-CLIN-045**: Add special instructions for lab
- **FR-CLIN-046**: Print lab requisition form
- **FR-CLIN-047**: Track test status (Ordered, Sample Collected, Processing, Completed)
- **FR-CLIN-048**: View pending lab test results
- **FR-CLIN-049**: Upload and attach lab result documents
- **FR-CLIN-050**: Enter lab result values and reference ranges
- **FR-CLIN-051**: Mark abnormal results with flag
- **FR-CLIN-052**: Notify doctor when results are available

#### 6.4.5 Consultation History
- **FR-CLIN-053**: List all consultations for selected patient
- **FR-CLIN-054**: Filter consultations by date range
- **FR-CLIN-055**: Filter by doctor
- **FR-CLIN-056**: Display consultation summary cards (date, doctor, diagnosis)
- **FR-CLIN-057**: View detailed consultation notes
- **FR-CLIN-058**: View prescriptions issued in past consultations
- **FR-CLIN-059**: View lab tests ordered in past consultations
- **FR-CLIN-060**: Export consultation history to PDF

### 6.5 Page 5: Billing & Reports
**Purpose:** Financial management, invoicing, payment processing, and analytics

#### 6.5.1 Invoice Generation
- **FR-BILL-001**: Create invoice from completed consultation
- **FR-BILL-002**: Auto-populate patient information
- **FR-BILL-003**: Add service line items with descriptions
- **FR-BILL-004**: Select services from master service catalog
- **FR-BILL-005**: Specify quantity for each service
- **FR-BILL-006**: Display unit price for each service
- **FR-BILL-007**: Auto-calculate line item total (quantity × unit price)
- **FR-BILL-008**: Add custom line items (free text description and price)
- **FR-BILL-009**: Calculate subtotal of all line items
- **FR-BILL-010**: Apply discount (percentage or fixed amount)
- **FR-BILL-011**: Calculate and display tax (if applicable)
- **FR-BILL-012**: Display total amount due prominently
- **FR-BILL-013**: Support multiple currency (default system currency)
- **FR-BILL-014**: Add invoice notes/terms
- **FR-BILL-015**: Generate unique invoice number automatically

#### 6.5.2 Payment Processing
- **FR-BILL-016**: Record payment against invoice
- **FR-BILL-017**: Select payment method (Cash, Credit Card, Debit Card, Bank Transfer, Insurance, UPI, Other)
- **FR-BILL-018**: Enter payment amount
- **FR-BILL-019**: Allow partial payment with remaining balance tracking
- **FR-BILL-020**: Enter payment reference number (transaction ID, check number)
- **FR-BILL-021**: Record payment date and time
- **FR-BILL-022**: Record who processed the payment
- **FR-BILL-023**: Calculate and display remaining balance
- **FR-BILL-024**: Support multiple payments for one invoice
- **FR-BILL-025**: Process refunds with reason
- **FR-BILL-026**: Print payment receipt
- **FR-BILL-027**: Send payment receipt via email
- **FR-BILL-028**: Update invoice status (Unpaid, Partially Paid, Paid, Refunded)

#### 6.5.3 Billing History & Search
- **FR-BILL-029**: List all invoices with search and filter
- **FR-BILL-030**: Search by patient name or ID
- **FR-BILL-031**: Search by invoice number
- **FR-BILL-032**: Filter by invoice status
- **FR-BILL-033**: Filter by date range
- **FR-BILL-034**: Filter by payment method
- **FR-BILL-035**: Display invoice list (invoice #, date, patient, amount, status)
- **FR-BILL-036**: Show outstanding invoices only view
- **FR-BILL-037**: Show paid invoices only view
- **FR-BILL-038**: View invoice details popup
- **FR-BILL-039**: Print invoice from list
- **FR-BILL-040**: Export invoice list to Excel

#### 6.5.4 Insurance Management
- **FR-BILL-041**: Manage insurance provider directory
- **FR-BILL-042**: Add insurance provider (name, contact, policy details)
- **FR-BILL-043**: Link patient to insurance provider
- **FR-BILL-044**: Enter patient policy number and coverage details
- **FR-BILL-045**: Apply insurance coverage to invoice
- **FR-BILL-046**: Calculate patient copay amount
- **FR-BILL-047**: Generate insurance claim form
- **FR-BILL-048**: Track insurance claim status (Submitted, Approved, Denied, Paid)
- **FR-BILL-049**: Record insurance payment received
- **FR-BILL-050**: Handle insurance denials and adjustments

#### 6.5.5 Reports & Analytics
- **FR-REP-001**: Patient statistics report (total patients, new registrations by period)
- **FR-REP-002**: Appointment report (total appointments, by status, by department, by doctor)
- **FR-REP-003**: Revenue report (total revenue, by service type, by payment method)
- **FR-REP-004**: Daily collection report
- **FR-REP-005**: Outstanding balance report (aging analysis)
- **FR-REP-006**: Doctor performance report (consultations count, revenue generated)
- **FR-REP-007**: Department utilization report
- **FR-REP-008**: Service-wise revenue analysis
- **FR-REP-009**: Payment method breakdown report
- **FR-REP-010**: Patient visit frequency report
- **FR-REP-011**: Select date range for all reports
- **FR-REP-012**: Export reports to PDF
- **FR-REP-013**: Export reports to Excel
- **FR-REP-014**: Visualize data with charts (bar, line, pie charts)
- **FR-REP-015**: Schedule automated report generation (email delivery)
- **FR-REP-016**: Dashboard widgets showing key metrics (total revenue, appointments today, pending payments)
- **FR-REP-017**: Real-time report data refresh
- **FR-REP-018**: Report access control based on user role

#### 6.5.6 Service & Pricing Management
- **FR-BILL-051**: Manage master service catalog
- **FR-BILL-052**: Add new service (name, description, category, price)
- **FR-BILL-053**: Edit service details and pricing
- **FR-BILL-054**: Deactivate services
- **FR-BILL-055**: Assign services to departments
- **FR-BILL-056**: Set service duration (for scheduling purposes)
- **FR-BILL-057**: Support tiered pricing (e.g., different prices for different patient categories)
- **FR-BILL-058**: Search and filter services
- **FR-BILL-059**: Import services from Excel template

---

## 7. Business Rules

### 7.1 Patient Management Rules
- **BR-PAT-001**: Patient ID must be unique across the system
- **BR-PAT-002**: Mobile number is mandatory for patient registration
- **BR-PAT-003**: Email address must be in valid email format if provided
- **BR-PAT-004**: Date of birth cannot be in the future
- **BR-PAT-005**: Age must be calculated from date of birth automatically
- **BR-PAT-006**: Patient status must be either Active or Inactive
- **BR-PAT-007**: Inactive patients cannot be scheduled for new appointments
- **BR-PAT-008**: Emergency contact phone number is mandatory
- **BR-PAT-009**: Each patient can have only one primary insurance provider
- **BR-PAT-010**: Patient records can be edited only by authorized roles (not by billing officer)

### 7.2 Appointment Rules
- **BR-APPT-001**: Appointment date cannot be in the past
- **BR-APPT-002**: Appointment duration must be at least 15 minutes
- **BR-APPT-003**: No double-booking allowed for the same doctor at the same time
- **BR-APPT-004**: A patient cannot have more than one active appointment with the same doctor on the same day
- **BR-APPT-005**: Appointments can only be cancelled or rescheduled at least 1 hour before scheduled time (configurable)
- **BR-APPT-006**: Emergency appointments can be scheduled outside normal working hours
- **BR-APPT-007**: Only checked-in appointments can transition to "In Progress"
- **BR-APPT-008**: Only appointments with status "In Progress" can be marked as "Completed"
- **BR-APPT-009**: Completed appointments cannot be edited or deleted
- **BR-APPT-010**: Cancelled appointments retain historical data but cannot be checked-in
- **BR-APPT-011**: Follow-up appointments must be linked to a previous consultation
- **BR-APPT-012**: Appointment reminders sent 24 hours before scheduled time (configurable)

### 7.3 Consultation Rules
- **BR-CLIN-001**: Consultation can only be created from a checked-in appointment
- **BR-CLIN-002**: Only doctors can create and complete consultations
- **BR-CLIN-003**: At least one diagnosis is required to complete a consultation
- **BR-CLIN-004**: Consultation must be completed before invoice can be generated
- **BR-CLIN-005**: Vital signs must be recorded before consultation begins
- **BR-CLIN-006**: Consultation notes cannot be edited after 24 hours of completion (configurable)
- **BR-CLIN-007**: All consultations must be digitally signed by the doctor
- **BR-CLIN-008**: Chief complaint is mandatory for all consultations
- **BR-CLIN-009**: Completed consultations automatically update patient medical record

### 7.4 Prescription Rules
- **BR-PRES-001**: Only doctors can create prescriptions
- **BR-PRES-002**: Prescriptions must be linked to a consultation
- **BR-PRES-003**: Each medication must have dosage and frequency specified
- **BR-PRES-004**: System must warn if prescribed medication matches patient's listed allergies
- **BR-PRES-005**: System should warn about potential drug interactions (if multiple medications)
- **BR-PRES-006**: Prescription duration must be specified (number of days)
- **BR-PRES-007**: Completed prescriptions cannot be edited, only new prescription can be created
- **BR-PRES-008**: Prescription validity period is 30 days from issue date (configurable)
- **BR-PRES-009**: Controlled substances require additional authorization fields

### 7.5 Vital Signs Rules
- **BR-VITAL-001**: Vital signs must be recorded before consultation
- **BR-VITAL-002**: Systolic blood pressure must be greater than diastolic
- **BR-VITAL-003**: Temperature must be within valid range (95°F - 110°F or equivalent Celsius)
- **BR-VITAL-004**: Pulse rate must be between 40 and 200 bpm
- **BR-VITAL-005**: Oxygen saturation must be between 70% and 100%
- **BR-VITAL-006**: Weight must be greater than zero
- **BR-VITAL-007**: Height must be greater than zero
- **BR-VITAL-008**: BMI is auto-calculated and cannot be manually entered
- **BR-VITAL-009**: Vital signs record must include timestamp and recording staff member

### 7.6 Billing Rules
- **BR-BILL-001**: Invoice can only be generated after consultation is completed
- **BR-BILL-002**: Invoice number must be unique and sequential
- **BR-BILL-003**: At least one service line item is required in an invoice
- **BR-BILL-004**: Line item quantity must be greater than zero
- **BR-BILL-005**: Unit price cannot be negative
- **BR-BILL-006**: Discount cannot exceed subtotal amount
- **BR-BILL-007**: Total amount cannot be negative
- **BR-BILL-008**: Payment amount cannot exceed invoice total
- **BR-BILL-009**: Refund amount cannot exceed total payments received
- **BR-BILL-010**: Invoice status automatically updates based on payment received
- **BR-BILL-011**: Paid invoices cannot be edited or deleted
- **BR-BILL-012**: Outstanding balance = Invoice Total - Sum of Payments
- **BR-BILL-013**: Insurance coverage cannot exceed invoice total
- **BR-BILL-014**: Patient copay = Invoice Total - Insurance Coverage
- **BR-BILL-015**: Services must exist in service catalog with valid pricing

### 7.7 Lab Test Rules
- **BR-LAB-001**: Only doctors can order lab tests
- **BR-LAB-002**: Lab tests must be linked to a consultation
- **BR-LAB-003**: Sample collection date cannot be before order date
- **BR-LAB-004**: Results can only be entered after sample is collected
- **BR-LAB-005**: Abnormal results must be flagged automatically based on reference ranges
- **BR-LAB-006**: Doctor must be notified when results are available
- **BR-LAB-007**: Lab test results become part of patient's permanent medical record
- **BR-LAB-008**: Lab tests cannot be deleted once sample is collected

### 7.8 User & Access Rules
- **BR-USER-001**: Each user must have a unique username
- **BR-USER-002**: User must be assigned to exactly one role
- **BR-USER-003**: Password must meet complexity requirements (min 8 characters, alphanumeric)
- **BR-USER-004**: Users must be assigned to a department (except administrators)
- **BR-USER-005**: Inactive users cannot log into the system
- **BR-USER-006**: Receptionists cannot view detailed medical records (diagnosis, treatment)
- **BR-USER-007**: Billing officers cannot modify medical records
- **BR-USER-008**: Only administrators can create, edit, or deactivate user accounts
- **BR-USER-009**: Doctors can only view patients assigned to their department or appointments
- **BR-USER-010**: All user actions must be logged with timestamp

### 7.9 Report Rules
- **BR-REP-001**: Reports can only show data within user's authorized scope
- **BR-REP-002**: Financial reports are only accessible to billing officers and administrators
- **BR-REP-003**: Patient-identifiable information in reports must comply with privacy regulations
- **BR-REP-004**: Date range for reports cannot exceed 1 year in a single report
- **BR-REP-005**: Exported reports must include generation date and time
- **BR-REP-006**: Scheduled reports require administrator approval

---

## 8. Non-Functional Requirements

### 8.1 Performance Requirements
- **NFR-PERF-001**: System must load dashboard within 3 seconds
- **NFR-PERF-002**: Search results must return within 2 seconds for up to 10,000 records
- **NFR-PERF-003**: Patient profile page must load within 2 seconds
- **NFR-PERF-004**: Invoice generation must complete within 5 seconds
- **NFR-PERF-005**: Report generation must complete within 10 seconds for standard reports
- **NFR-PERF-006**: System must support at least 100 concurrent users
- **NFR-PERF-007**: Database queries must be optimized with proper indexing
- **NFR-PERF-008**: API response time should not exceed 1 second for 95% of requests
- **NFR-PERF-009**: System must handle up to 1000 appointments per day
- **NFR-PERF-010**: File uploads (images, documents) up to 10MB must complete within 30 seconds

### 8.2 Security Requirements
- **NFR-SEC-001**: All user passwords must be encrypted using industry-standard hashing (bcrypt/Argon2)
- **NFR-SEC-002**: User sessions must expire after 30 minutes of inactivity
- **NFR-SEC-003**: System must enforce role-based access control (RBAC) for all features
- **NFR-SEC-004**: All sensitive data (patient records, medical history) must be encrypted at rest
- **NFR-SEC-005**: All data transmission must use HTTPS/TLS encryption
- **NFR-SEC-006**: System must log all user authentication attempts (success and failure)
- **NFR-SEC-007**: Failed login attempts must be limited (max 5 attempts, then lockout for 15 minutes)
- **NFR-SEC-008**: System must maintain audit trail for all data modifications (who, what, when)
- **NFR-SEC-009**: Patient data access must be logged for compliance and audit purposes
- **NFR-SEC-010**: System must comply with HIPAA/GDPR regulations for healthcare data protection
- **NFR-SEC-011**: Backup data must be encrypted
- **NFR-SEC-012**: API endpoints must require authentication tokens
- **NFR-SEC-013**: SQL injection and XSS attacks must be prevented through input validation
- **NFR-SEC-014**: User permissions must be checked server-side for every action

### 8.3 Usability Requirements
- **NFR-USE-001**: Interface must be responsive and work on desktop, tablet, and mobile devices
- **NFR-USE-002**: System must support modern browsers (Chrome, Firefox, Safari, Edge - latest 2 versions)
- **NFR-USE-003**: Forms must provide real-time validation feedback
- **NFR-USE-004**: Error messages must be clear and actionable
- **NFR-USE-005**: Success/failure notifications must be displayed for all user actions
- **NFR-USE-006**: Navigation must be intuitive with no more than 3 clicks to reach any feature
- **NFR-USE-007**: System must provide tooltips and help text for complex fields
- **NFR-USE-008**: Loading indicators must be shown for all asynchronous operations
- **NFR-USE-009**: Forms must support keyboard navigation and shortcuts
- **NFR-USE-010**: System must be accessible (WCAG 2.1 Level AA compliance)

### 8.4 Reliability & Availability Requirements
- **NFR-REL-001**: System uptime must be 99.5% (excluding planned maintenance)
- **NFR-REL-002**: Planned maintenance windows must be scheduled during off-peak hours
- **NFR-REL-003**: System must perform automatic daily backups
- **NFR-REL-004**: Database backup retention: daily for 7 days, weekly for 4 weeks, monthly for 12 months
- **NFR-REL-005**: System must support disaster recovery with RPO (Recovery Point Objective) of 24 hours
- **NFR-REL-006**: System must support RTO (Recovery Time Objective) of 4 hours
- **NFR-REL-007**: Critical operations (appointment check-in, payment) must have transaction rollback capability
- **NFR-REL-008**: System errors must be logged with sufficient detail for debugging
- **NFR-REL-009**: System must gracefully handle database connection failures
- **NFR-REL-010**: Lost sessions should allow users to resume work when reconnected

### 8.5 Scalability Requirements
- **NFR-SCALE-001**: Database must support horizontal scaling
- **NFR-SCALE-002**: Application must support load balancing across multiple servers
- **NFR-SCALE-003**: System must handle growth to 50,000 patient records without performance degradation
- **NFR-SCALE-004**: System must support addition of new departments and services without code changes
- **NFR-SCALE-005**: File storage must be expandable to accommodate document uploads

### 8.6 Maintainability Requirements
- **NFR-MAINT-001**: Code must follow consistent coding standards and style guides
- **NFR-MAINT-002**: System must have comprehensive API documentation
- **NFR-MAINT-003**: Database schema must be version-controlled with migration scripts
- **NFR-MAINT-004**: System must provide admin interface for configuration (working hours, appointment slots, etc.)
- **NFR-MAINT-005**: Error logs must be centralized and searchable
- **NFR-MAINT-006**: System must support feature flags for gradual rollout of new features
- **NFR-MAINT-007**: Third-party dependencies must be documented and kept up-to-date

### 8.7 Compliance & Regulatory Requirements
- **NFR-COMP-001**: System must comply with HIPAA regulations for patient data privacy (if US-based)
- **NFR-COMP-002**: System must comply with GDPR for data protection (if serving EU patients)
- **NFR-COMP-003**: System must support data export for patient data portability
- **NFR-COMP-004**: System must support patient data deletion (right to be forgotten) while maintaining required legal records
- **NFR-COMP-005**: Audit logs must be retained for minimum 7 years
- **NFR-COMP-006**: System must support e-signature compliance for medical documents
- **NFR-COMP-007**: Patient consent must be recorded for data sharing

### 8.8 Integration Requirements
- **NFR-INT-001**: System must provide RESTful API for external integrations
- **NFR-INT-002**: System must support integration with SMS gateway for notifications
- **NFR-INT-003**: System must support integration with email service for notifications
- **NFR-INT-004**: System must support payment gateway integration (for card payments)
- **NFR-INT-005**: System must support export to standard formats (HL7, FHIR) for interoperability
- **NFR-INT-006**: System must provide webhooks for real-time event notifications

### 8.9 Data Requirements
- **NFR-DATA-001**: All timestamps must be stored in UTC and displayed in user's local timezone
- **NFR-DATA-002**: Soft delete must be implemented for critical records (patients, consultations)
- **NFR-DATA-003**: Data retention policy: patient records retained for 10 years after last visit
- **NFR-DATA-004**: Personal identifiable information (PII) must be anonymized in reports
- **NFR-DATA-005**: System must support data import from Excel templates for bulk uploads
- **NFR-DATA-006**: System must validate data integrity with referential constraints

### 8.10 Localization Requirements
- **NFR-LOC-001**: System must support multiple time zones
- **NFR-LOC-002**: System must support date format configuration (DD/MM/YYYY, MM/DD/YYYY)
- **NFR-LOC-003**: System must support currency configuration
- **NFR-LOC-004**: System must support metric and imperial units for vital signs
- **NFR-LOC-005**: System should be architected to support future multi-language capability

---

## Appendix

### Change Log
| Version | Date | Author | Changes |
|---------|------|--------|---------|
| 1.0 | 2024 | Product Manager | Initial PRD creation |

### Glossary
- **BMI**: Body Mass Index - calculated metric from height and weight
- **ICD-10**: International Classification of Diseases, 10th Revision - standard diagnostic codes
- **HIPAA**: Health Insurance Portability and Accountability Act - US healthcare data regulation
- **GDPR**: General Data Protection Regulation - EU data privacy regulation
- **RPO**: Recovery Point Objective - maximum acceptable data loss timeframe
- **RTO**: Recovery Time Objective - maximum acceptable downtime
- **RBAC**: Role-Based Access Control - permission system based on user roles
- **HL7/FHIR**: Healthcare data exchange standards

### Future Considerations (Out of Scope for v1.0)
- Mobile application for patients (appointment booking, view records)
- Telemedicine / video consultation capability
- Integration with pharmacy systems for e-prescriptions
- Integration with lab equipment for automatic result import
- Advanced analytics and predictive modeling
- Patient portal for self-service
- Inventory management for medications and supplies
- Staff attendance and payroll management
- Multi-facility support with centralized data
- AI-assisted diagnosis suggestions
- Automated insurance eligibility verification

---

**Document Status:** Approved for Development  
**Next Review Date:** Quarterly or upon major feature requests