Categories: SQL Training
Tags:

In a multiple doctor prescription system, you would likely need the following tables to manage doctors, patients, prescriptions, and medications. Here’s a suggested structure for the database:

1. Users Table (For managing system users, including doctors, patients, and other roles)

  • user_id (Primary Key)
  • name
  • email
  • password
  • role (e.g., doctor, patient, admin)
  • contact_number
  • address
  • date_of_birth
  • created_at
  • updated_at

2. Doctors Table (For storing information about doctors)

  • doctor_id (Primary Key)
  • user_id (Foreign Key, references Users.user_id)
  • specialization
  • license_number
  • clinic_address
  • contact_number
  • experience_years
  • created_at
  • updated_at
CREATE TABLE doctorstbl (
    doctor_id INT PRIMARY KEY IDENTITY(1,1),
    user_id INT FOREIGN KEY REFERENCES Users(user_id),
    specialization NVARCHAR(100) NOT NULL,
    license_number NVARCHAR(50) NOT NULL UNIQUE,
    clinic_address NVARCHAR(255),
    contact_number NVARCHAR(20),
    experience_years INT CHECK (experience_years >= 0),
    created_at DATETIME DEFAULT GETDATE(),
    updated_at DATETIME DEFAULT GETDATE()
);
 

3. Patients Table (For storing information about patients)

  • patient_id (Primary Key)
  • user_id (Foreign Key, references Users.user_id)
  • medical_history
  • allergies
  • contact_number
  • emergency_contact
  • created_at
  • updated_at

4. Prescriptions Table (For storing prescription details)

  • prescription_id (Primary Key)
  • doctor_id (Foreign Key, references Doctors.doctor_id)
  • patient_id (Foreign Key, references Patients.patient_id)
  • prescription_date
  • diagnosis
  • notes
  • created_at
  • updated_at

5. Prescription_Medicines Table (For storing medicines prescribed in each prescription)

  • prescription_medicine_id (Primary Key)
  • prescription_id (Foreign Key, references Prescriptions.prescription_id)
  • medicine_id (Foreign Key, references Medicines.medicine_id)
  • dosage
  • frequency
  • duration
  • created_at
  • updated_at

6. Medicines Table (For storing a list of medicines)

  • medicine_id (Primary Key)
  • name
  • brand
  • category_id (Foreign Key, references Categories.category_id)
  • description
  • side_effects
  • created_at
  • updated_at

7. Categories Table (For organizing medicines into categories)

  • category_id (Primary Key)
  • name
  • description
  • created_at
  • updated_at

8. Appointments Table (For managing doctor appointments)

  • appointment_id (Primary Key)
  • doctor_id (Foreign Key, references Doctors.doctor_id)
  • patient_id (Foreign Key, references Patients.patient_id)
  • appointment_date
  • appointment_time
  • status (e.g., scheduled, completed, canceled)
  • created_at
  • updated_at

9. Pharmacies Table (For storing information about pharmacies where prescriptions can be filled)

  • pharmacy_id (Primary Key)
  • name
  • address
  • contact_number
  • email
  • created_at
  • updated_at

10. Pharmacy_Orders Table (For tracking when patients fill prescriptions at a pharmacy)

  • order_id (Primary Key)
  • pharmacy_id (Foreign Key, references Pharmacies.pharmacy_id)
  • patient_id (Foreign Key, references Patients.patient_id)
  • prescription_id (Foreign Key, references Prescriptions.prescription_id)
  • order_date
  • order_status
  • created_at
  • updated_at

11. Labs Table (For storing information about diagnostic labs, if required)

  • lab_id (Primary Key)
  • name
  • address
  • contact_number
  • created_at
  • updated_at

12. Lab_Tests Table (For storing lab tests ordered for patients)

  • lab_test_id (Primary Key)
  • lab_id (Foreign Key, references Labs.lab_id)
  • patient_id (Foreign Key, references Patients.patient_id)
  • test_name
  • result
  • test_date
  • created_at
  • updated_at

13. Billing Table (For managing bills for prescriptions, appointments, lab tests, etc.)

  • bill_id (Primary Key)
  • patient_id (Foreign Key, references Patients.patient_id)
  • bill_date
  • amount
  • status (e.g., paid, unpaid)
  • created_at
  • updated_at

14. Medical_Records Table (For maintaining medical records and history for patients)

  • record_id (Primary Key)
  • patient_id (Foreign Key, references Patients.patient_id)
  • document (e.g., files for scans, reports)
  • record_type (e.g., X-ray, blood report)
  • date_added
  • created_at
  • updated_at

This structure should cover the key elements of a multiple doctor prescription system, including user management, prescriptions, appointments, medicines, pharmacies, and lab tests. You can modify or add fields as needed based on the system’s specific requirements.