Index: backend/src/main/java/medora/controller/AppointmentController.java
===================================================================
--- backend/src/main/java/medora/controller/AppointmentController.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/controller/AppointmentController.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -3,8 +3,11 @@
 import medora.dto.AppointmentDTO;
 import medora.dto.CreateAppointmentRequest;
+import medora.dto.PatientDTO;
 import medora.dto.DoctorDTO;
-import medora.dto.PatientDTO;
 import medora.models.domain.Appointment;
+import medora.models.domain.Patient;
+import medora.models.domain.Doctors;
 import medora.service.AppointmentService;
+import medora.util.SecurityUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -13,4 +16,5 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import jakarta.servlet.http.HttpServletRequest;
 
 import java.time.LocalDate;
@@ -26,12 +30,20 @@
 
     private final AppointmentService appointmentService;
-
-    public AppointmentController(AppointmentService appointmentService) {
+    private final SecurityUtil securityUtil;
+
+    public AppointmentController(AppointmentService appointmentService, SecurityUtil securityUtil) {
         this.appointmentService = appointmentService;
+        this.securityUtil = securityUtil;
     }
 
     @PostMapping
-    public ResponseEntity<?> createAppointment(@RequestBody CreateAppointmentRequest request) {
-        try {
+    public ResponseEntity<?> createAppointment(@RequestBody CreateAppointmentRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
             if (request.getPatientId() == null || request.getPatientId() <= 0) {
                 return ResponseEntity.badRequest()
@@ -49,4 +61,13 @@
                 return ResponseEntity.badRequest()
                         .body(Map.of("error", "Appointment time is required"));
+            }
+
+            // Patients can only create appointments for themselves
+            if (role.equals("PATIENT")) {
+                Long patientIdFromToken = securityUtil.getPatientIdFromRequest(httpRequest);
+                if (patientIdFromToken == null || !patientIdFromToken.equals(request.getPatientId())) {
+                    return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                            .body(Map.of("error", "You can only create appointments for yourself"));
+                }
             }
 
@@ -90,8 +111,35 @@
 
     @GetMapping
-    public ResponseEntity<?> getAllAppointments() {
-        try {
-            logger.info("Fetching all appointments");
-            List<Appointment> appointments = appointmentService.getAllAppointments();
+    public ResponseEntity<?> getAllAppointments(HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Patients cannot view all appointments
+            if (role.equals("PATIENT")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Patients cannot view all appointments"));
+            }
+
+            List<Appointment> appointments;
+
+            // Doctors can only view their own appointments
+            if (role.equals("DOCTOR")) {
+                Long doctorIdFromToken = securityUtil.getDoctorIdFromRequest(httpRequest);
+                if (doctorIdFromToken == null || doctorIdFromToken <= 0) {
+                    return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                            .body(Map.of("error", "Doctor ID not found in token"));
+                }
+                logger.info("Fetching appointments for doctor ID: {}", doctorIdFromToken);
+                appointments = appointmentService.getAppointmentsForDoctor(doctorIdFromToken);
+            } else {
+                // ADMIN and other roles can view all appointments
+                logger.info("Fetching all appointments");
+                appointments = appointmentService.getAllAppointments();
+            }
+
             List<AppointmentDTO> dtos = appointments.stream()
                     .map(this::convertToDTO)
@@ -110,6 +158,21 @@
 
     @GetMapping("/patient/{patientId}")
-    public ResponseEntity<?> getAppointmentsForPatient(@PathVariable Long patientId) {
-        try {
+    public ResponseEntity<?> getAppointmentsForPatient(@PathVariable Long patientId, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Patients can only view their own appointments
+            if (role.equals("PATIENT")) {
+                Long patientIdFromToken = securityUtil.getPatientIdFromRequest(httpRequest);
+                if (patientIdFromToken == null || !patientIdFromToken.equals(patientId)) {
+                    return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                            .body(Map.of("error", "You can only view your own appointments"));
+                }
+            }
+
             logger.info("Fetching appointments for patient ID: {}", patientId);
             List<Appointment> appointments = appointmentService.getAppointmentsForPatient(patientId);
@@ -172,8 +235,27 @@
 
     @PatchMapping("/{appointmentId}/cancel")
-    public ResponseEntity<?> cancelAppointment(@PathVariable Long appointmentId) {
-        try {
+    public ResponseEntity<?> cancelAppointment(@PathVariable Long appointmentId, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Verify appointment exists and check permissions for patients
+            Appointment appointment = appointmentService.getAppointmentById(appointmentId)
+                    .orElseThrow(() -> new RuntimeException("Appointment not found"));
+
+            if (role.equals("PATIENT")) {
+                Long patientIdFromToken = securityUtil.getPatientIdFromRequest(httpRequest);
+                Long appointmentPatientId = appointment.getPatient() != null ? appointment.getPatient().getPatientId() : null;
+                if (patientIdFromToken == null || !patientIdFromToken.equals(appointmentPatientId)) {
+                    return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                            .body(Map.of("error", "You can only cancel your own appointments"));
+                }
+            }
+
             logger.info("Cancelling appointment with ID: {}", appointmentId);
-            Appointment appointment = appointmentService.cancelAppointment(appointmentId);
+            appointment = appointmentService.cancelAppointment(appointmentId);
             AppointmentDTO dto = convertToDTO(appointment);
             return ResponseEntity.ok(dto);
@@ -190,6 +272,18 @@
 
     @PatchMapping("/{appointmentId}/complete")
-    public ResponseEntity<?> completeAppointment(@PathVariable Long appointmentId) {
-        try {
+    public ResponseEntity<?> completeAppointment(@PathVariable Long appointmentId, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN and DOCTOR can complete appointments
+            if (role.equals("PATIENT")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Patients cannot complete appointments"));
+            }
+
             logger.info("Completing appointment with ID: {}", appointmentId);
             Appointment appointment = appointmentService.completeAppointment(appointmentId);
Index: backend/src/main/java/medora/controller/BillingController.java
===================================================================
--- backend/src/main/java/medora/controller/BillingController.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/controller/BillingController.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -9,4 +9,5 @@
 import medora.service.BillingService;
 import medora.util.BillingPDFGenerator;
+import medora.util.SecurityUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -16,4 +17,5 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import jakarta.servlet.http.HttpServletRequest;
 
 import java.time.LocalDate;
@@ -29,12 +31,26 @@
 
     private final BillingService billingService;
-
-    public BillingController(BillingService billingService) {
+    private final SecurityUtil securityUtil;
+
+    public BillingController(BillingService billingService, SecurityUtil securityUtil) {
         this.billingService = billingService;
+        this.securityUtil = securityUtil;
     }
 
     @PostMapping
-    public ResponseEntity<?> generateBillingRecord(@RequestBody CreateBillingRequest request) {
-        try {
+    public ResponseEntity<?> generateBillingRecord(@RequestBody CreateBillingRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can generate billing records (doctors cannot access billing)
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can generate billing records"));
+            }
+
             if (request.getMedicalRecordId() == null || request.getMedicalRecordId() <= 0) {
                 return ResponseEntity.badRequest()
@@ -70,10 +86,37 @@
 
     @GetMapping("/{billId}")
-    public ResponseEntity<?> getBillingById(@PathVariable Long billId) {
-        try {
+    public ResponseEntity<?> getBillingById(@PathVariable Long billId, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Doctors cannot access billing
+            if (role.equals("DOCTOR")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Doctors cannot access billing records"));
+            }
+
             logger.info("Fetching billing record with ID: {}", billId);
-            return billingService.getBillingById(billId)
-                    .map(b -> ResponseEntity.ok(convertToDTO(b)))
-                    .orElse(ResponseEntity.notFound().build());
+            var billing = billingService.getBillingById(billId);
+            if (billing.isEmpty()) {
+                return ResponseEntity.notFound().build();
+            }
+
+            // Patients can only view their own billing records
+            if (role.equals("PATIENT")) {
+                Long patientIdFromToken = securityUtil.getPatientIdFromRequest(httpRequest);
+                Long billPatientId = billing.get().getMedicalRecord() != null && billing.get().getMedicalRecord().getPatient() != null
+                        ? billing.get().getMedicalRecord().getPatient().getPatientId()
+                        : null;
+                if (patientIdFromToken == null || !patientIdFromToken.equals(billPatientId)) {
+                    return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                            .body(Map.of("error", "You can only view your own billing records"));
+                }
+            }
+
+            return ResponseEntity.ok(convertToDTO(billing.get()));
         } catch (RuntimeException e) {
             logger.error("Error fetching billing record: {}", e.getMessage());
@@ -88,8 +131,30 @@
 
     @GetMapping("/{billId}/detail")
-    public ResponseEntity<?> getBillingDetail(@PathVariable Long billId) {
-        try {
+    public ResponseEntity<?> getBillingDetail(@PathVariable Long billId, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Doctors cannot access billing
+            if (role.equals("DOCTOR")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Doctors cannot access billing records"));
+            }
+
             logger.info("Fetching detailed billing information for bill ID: {}", billId);
             BillingDetailDTO detail = billingService.getBillingDetail(billId);
+
+            // Patients can only view their own billing details
+            if (role.equals("PATIENT")) {
+                Long patientIdFromToken = securityUtil.getPatientIdFromRequest(httpRequest);
+                if (patientIdFromToken == null || detail == null || !patientIdFromToken.equals(detail.getPatientId())) {
+                    return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                            .body(Map.of("error", "You can only view your own billing records"));
+                }
+            }
+
             return ResponseEntity.ok(detail);
         } catch (RuntimeException e) {
@@ -105,6 +170,18 @@
 
     @GetMapping
-    public ResponseEntity<?> getAllBillings() {
-        try {
+    public ResponseEntity<?> getAllBillings(HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Doctors and Patients cannot view all billing records
+            if (role.equals("PATIENT") || role.equals("DOCTOR")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "You cannot view all billing records"));
+            }
+
             logger.info("Fetching all billing records");
             List<Billing> billings = billingService.getAllBillingRecords();
@@ -125,6 +202,27 @@
 
     @GetMapping("/patient/{patientId}")
-    public ResponseEntity<?> getBillingHistoryForPatient(@PathVariable Long patientId) {
-        try {
+    public ResponseEntity<?> getBillingHistoryForPatient(@PathVariable Long patientId, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Doctors cannot access billing
+            if (role.equals("DOCTOR")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Doctors cannot access billing records"));
+            }
+
+            // Patients can only view their own billing history
+            if (role.equals("PATIENT")) {
+                Long patientIdFromToken = securityUtil.getPatientIdFromRequest(httpRequest);
+                if (patientIdFromToken == null || !patientIdFromToken.equals(patientId)) {
+                    return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                            .body(Map.of("error", "You can only view your own billing records"));
+                }
+            }
+
             logger.info("Fetching billing history for patient ID: {}", patientId);
             List<Billing> billings = billingService.getBillingHistoryForPatient(patientId);
@@ -146,6 +244,19 @@
     @PatchMapping("/{billId}/payment-status")
     public ResponseEntity<?> updatePaymentStatus(@PathVariable Long billId,
-                                                 @RequestBody UpdateBillingRequest request) {
-        try {
+                                                 @RequestBody UpdateBillingRequest request,
+                                                 HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can update payment status
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can update payment status"));
+            }
+
             if (request.getPaymentStatus() == null) {
                 return ResponseEntity.badRequest()
@@ -170,8 +281,30 @@
 
     @GetMapping("/{billId}/invoice-pdf")
-    public ResponseEntity<?> downloadInvoicePDF(@PathVariable Long billId) {
-        try {
+    public ResponseEntity<?> downloadInvoicePDF(@PathVariable Long billId, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Doctors cannot access billing
+            if (role.equals("DOCTOR")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Doctors cannot access billing records"));
+            }
+
             logger.info("Generating PDF invoice for bill ID: {}", billId);
             BillingDetailDTO billingDetail = billingService.getBillingDetail(billId);
+
+            // Patients can only download their own invoices
+            if (role.equals("PATIENT")) {
+                Long patientIdFromToken = securityUtil.getPatientIdFromRequest(httpRequest);
+                if (patientIdFromToken == null || !patientIdFromToken.equals(billingDetail.getPatientId())) {
+                    return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                            .body(Map.of("error", "You can only download your own invoices"));
+                }
+            }
+
             byte[] pdfContent = BillingPDFGenerator.generateInvoicePDF(billingDetail);
 
Index: backend/src/main/java/medora/controller/DepartmentController.java
===================================================================
--- backend/src/main/java/medora/controller/DepartmentController.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/controller/DepartmentController.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -4,4 +4,5 @@
 import medora.models.domain.Doctors;
 import medora.service.DepartmentService;
+import medora.util.SecurityUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -9,4 +10,5 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import jakarta.servlet.http.HttpServletRequest;
 
 import java.util.List;
@@ -21,7 +23,9 @@
 
     private final DepartmentService departmentService;
-
-    public DepartmentController(DepartmentService departmentService) {
+    private final SecurityUtil securityUtil;
+
+    public DepartmentController(DepartmentService departmentService, SecurityUtil securityUtil) {
         this.departmentService = departmentService;
+        this.securityUtil = securityUtil;
     }
 
@@ -67,5 +71,7 @@
     }
 
-
+    /**
+     * Get department by name
+     */
     @GetMapping("/name/{departmentName}")
     public ResponseEntity<?> getDepartmentByName(@PathVariable String departmentName) {
@@ -110,8 +116,22 @@
     }
 
-
+    /**
+     * Create a new department
+     */
     @PostMapping
-    public ResponseEntity<?> createDepartment(@RequestBody Map<String, String> request) {
-        try {
+    public ResponseEntity<?> createDepartment(@RequestBody Map<String, String> request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can create departments
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can create departments"));
+            }
+
             String departmentName = request.get("departmentName");
             if (departmentName == null || departmentName.isBlank()) {
@@ -137,9 +157,24 @@
     }
 
-
+    /**
+     * Update a department
+     */
     @PutMapping("/{departmentId}")
     public ResponseEntity<?> updateDepartment(@PathVariable Long departmentId,
-                                              @RequestBody Map<String, String> request) {
-        try {
+                                              @RequestBody Map<String, String> request,
+                                              HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can update departments
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can update departments"));
+            }
+
             String departmentName = request.get("departmentName");
             if (departmentName == null || departmentName.isBlank()) {
Index: backend/src/main/java/medora/controller/DoctorController.java
===================================================================
--- backend/src/main/java/medora/controller/DoctorController.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/controller/DoctorController.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -1,10 +1,15 @@
 package medora.controller;
 
-import medora.dto.*;
-import medora.models.domain.Departments;
+import medora.dto.DoctorDTO;
+import medora.dto.CreateDoctorRequest;
+import medora.dto.DoctorLevelDTO;
+import medora.dto.DoctorSpecializationDTO;
+import medora.dto.DepartmentDTO;
+import medora.models.domain.Doctors;
 import medora.models.domain.DoctorLevel;
 import medora.models.domain.DoctorSpecialization;
-import medora.models.domain.Doctors;
+import medora.models.domain.Departments;
 import medora.service.DoctorService;
+import medora.util.SecurityUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -12,4 +17,5 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import jakarta.servlet.http.HttpServletRequest;
 
 import java.util.List;
@@ -24,12 +30,25 @@
 
     private final DoctorService doctorService;
-
-    public DoctorController(DoctorService doctorService) {
+    private final SecurityUtil securityUtil;
+
+    public DoctorController(DoctorService doctorService, SecurityUtil securityUtil) {
         this.doctorService = doctorService;
+        this.securityUtil = securityUtil;
     }
 
     @PostMapping
-    public ResponseEntity<?> createDoctor(@RequestBody CreateDoctorRequest request) {
-        try {
+    public ResponseEntity<?> createDoctor(@RequestBody CreateDoctorRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can create doctors
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can create doctors"));
+            }
             if (request.getFirstName() == null || request.getFirstName().isBlank()) {
                 return ResponseEntity.badRequest()
@@ -193,6 +212,19 @@
     @PutMapping("/{doctorId}")
     public ResponseEntity<?> updateDoctor(@PathVariable Long doctorId,
-                                         @RequestBody CreateDoctorRequest request) {
-        try {
+                                          @RequestBody CreateDoctorRequest request,
+                                          HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can update doctors
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can update doctors"));
+            }
+
             logger.info("Updating doctor with ID: {}", doctorId);
 
Index: backend/src/main/java/medora/controller/LabController.java
===================================================================
--- backend/src/main/java/medora/controller/LabController.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/controller/LabController.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -2,9 +2,7 @@
 
 import medora.dto.*;
-import medora.models.domain.LabResults;
-import medora.models.domain.LabTests;
-import medora.models.domain.MedicalRecordLabResults;
-import medora.models.domain.PerformedLabTests;
+import medora.models.domain.*;
 import medora.service.LabService;
+import medora.util.SecurityUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -12,4 +10,5 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import jakarta.servlet.http.HttpServletRequest;
 
 import java.util.List;
@@ -24,12 +23,26 @@
 
     private final LabService labService;
-
-    public LabController(LabService labService) {
+    private final SecurityUtil securityUtil;
+
+    public LabController(LabService labService, SecurityUtil securityUtil) {
         this.labService = labService;
+        this.securityUtil = securityUtil;
     }
 
     @PostMapping
-    public ResponseEntity<?> createLabTest(@RequestBody CreateLabTestRequest request) {
-        try {
+    public ResponseEntity<?> createLabTest(@RequestBody CreateLabTestRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can create lab tests
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can create lab tests"));
+            }
+
             if (request.getTestName() == null || request.getTestName().isBlank()) {
                 return ResponseEntity.badRequest()
@@ -100,5 +113,5 @@
     @PutMapping("/{testId}")
     public ResponseEntity<?> updateLabTest(@PathVariable Long testId,
-                                          @RequestBody CreateLabTestRequest request) {
+                                           @RequestBody CreateLabTestRequest request) {
         try {
             logger.info("Updating lab test with ID: {}", testId);
@@ -123,6 +136,18 @@
 
     @PostMapping("/request")
-    public ResponseEntity<?> requestLabTest(@RequestBody RequestLabTestRequest request) {
-        try {
+    public ResponseEntity<?> requestLabTest(@RequestBody RequestLabTestRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Patients cannot request lab tests
+            if (role.equals("PATIENT")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Patients cannot request lab tests"));
+            }
+
             logger.info("Requesting lab test {} for patient {}", request.getTestId(), request.getPatientId());
 
@@ -193,6 +218,18 @@
 
     @PostMapping("/results")
-    public ResponseEntity<?> submitLabResult(@RequestBody SubmitLabResultRequest request) {
-        try {
+    public ResponseEntity<?> submitLabResult(@RequestBody SubmitLabResultRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only LAB_TECHNICIAN can submit lab results (not DOCTOR)
+            if (!role.equals("LAB_TECHNICIAN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only lab technicians can submit lab results"));
+            }
+
             logger.info("Submitting lab result for medical record {}", request.getMedicalRecordId());
 
Index: backend/src/main/java/medora/controller/PatientController.java
===================================================================
--- backend/src/main/java/medora/controller/PatientController.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/controller/PatientController.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -1,8 +1,9 @@
 package medora.controller;
 
+import medora.dto.PatientDTO;
 import medora.dto.CreatePatientRequest;
-import medora.dto.PatientDTO;
 import medora.models.domain.Patient;
 import medora.service.PatientService;
+import medora.util.SecurityUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -10,4 +11,5 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import jakarta.servlet.http.HttpServletRequest;
 
 import java.util.List;
@@ -22,12 +24,25 @@
 
     private final PatientService patientService;
-
-    public PatientController(PatientService patientService) {
+    private final SecurityUtil securityUtil;
+
+    public PatientController(PatientService patientService, SecurityUtil securityUtil) {
         this.patientService = patientService;
+        this.securityUtil = securityUtil;
     }
 
     @PostMapping
-    public ResponseEntity<?> createPatient(@RequestBody CreatePatientRequest request) {
-        try {
+    public ResponseEntity<?> createPatient(@RequestBody CreatePatientRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can create patients
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can create patients"));
+            }
             if (request.getFirstName() == null || request.getFirstName().isBlank()) {
                 return ResponseEntity.badRequest()
@@ -144,6 +159,19 @@
     @PutMapping("/{patientId}")
     public ResponseEntity<?> updatePatient(@PathVariable Long patientId,
-                                          @RequestBody CreatePatientRequest request) {
-        try {
+                                           @RequestBody CreatePatientRequest request,
+                                           HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only ADMIN can update patients
+            if (!role.equals("ADMIN")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only administrators can update patients"));
+            }
+
             logger.info("Updating patient with ID: {}", patientId);
 
Index: backend/src/main/java/medora/controller/ProcedureController.java
===================================================================
--- backend/src/main/java/medora/controller/ProcedureController.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/controller/ProcedureController.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -5,6 +5,8 @@
 import medora.dto.SubmitProcedureResultRequest;
 import medora.models.domain.PerformedProcedures;
+import medora.models.domain.Procedure;
 import medora.models.domain.ProcedureResults;
 import medora.service.ProcedureService;
+import medora.util.SecurityUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -13,4 +15,5 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import jakarta.servlet.http.HttpServletRequest;
 
 import java.time.LocalDate;
@@ -26,7 +29,9 @@
 
     private final ProcedureService procedureService;
-
-    public ProcedureController(ProcedureService procedureService) {
+    private final SecurityUtil securityUtil;
+
+    public ProcedureController(ProcedureService procedureService, SecurityUtil securityUtil) {
         this.procedureService = procedureService;
+        this.securityUtil = securityUtil;
     }
 
@@ -48,6 +53,18 @@
 
     @PostMapping("/request")
-    public ResponseEntity<?> requestProcedure(@RequestBody RequestProcedureRequest request) {
-        try {
+    public ResponseEntity<?> requestProcedure(@RequestBody RequestProcedureRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Patients cannot request procedures
+            if (role.equals("PATIENT")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Patients cannot request procedures"));
+            }
+
             logger.info("Requesting procedure {} for patient {}", request.getProcedureId(), request.getPatientId());
 
@@ -207,6 +224,19 @@
     public ResponseEntity<?> recordProcedureOutcome(
             @PathVariable Long procedureId,
-            @RequestParam String notes) {
-        try {
+            @RequestParam String notes,
+            HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only DOCTOR and ADMIN can record procedure outcomes
+            if (role.equals("PATIENT")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Patients cannot record procedure outcomes"));
+            }
+
             logger.info("Recording procedure outcome for ID: {}", procedureId);
             PerformedProcedures procedure = procedureService.recordProcedureOutcome(procedureId, notes);
@@ -232,6 +262,18 @@
 
     @PostMapping("/results")
-    public ResponseEntity<?> submitProcedureResult(@RequestBody SubmitProcedureResultRequest request) {
-        try {
+    public ResponseEntity<?> submitProcedureResult(@RequestBody SubmitProcedureResultRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Only DOCTOR can submit procedure results
+            if (!role.equals("DOCTOR")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Only doctors can submit procedure results"));
+            }
+
             logger.info("Submitting procedure result for medical record {}", request.getMedicalRecordId());
 
@@ -292,10 +334,11 @@
     private Map<String, Object> convertResultToDTO(ProcedureResults result) {
         return Map.of(
-            "resultId", result.getResultId(),
-            "procedureId", result.getProcedure().getProcedureId(),
-            "procedureType", result.getProcedure().getProcedureType(),
-            "resultDescription", result.getResultDescription() != null ? result.getResultDescription() : "",
-            "resultDate", result.getResultDate()
+                "resultId", result.getResultId(),
+                "procedureId", result.getProcedure().getProcedureId(),
+                "procedureType", result.getProcedure().getProcedureType(),
+                "resultDescription", result.getResultDescription() != null ? result.getResultDescription() : "",
+                "resultDate", result.getResultDate()
         );
     }
 }
+
Index: backend/src/main/java/medora/controller/ReferralController.java
===================================================================
--- backend/src/main/java/medora/controller/ReferralController.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/controller/ReferralController.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -5,4 +5,5 @@
 import medora.models.domain.Referrals;
 import medora.service.ReferralService;
+import medora.util.SecurityUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -10,4 +11,5 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import jakarta.servlet.http.HttpServletRequest;
 
 import java.util.List;
@@ -22,12 +24,26 @@
 
     private final ReferralService referralService;
-
-    public ReferralController(ReferralService referralService) {
+    private final SecurityUtil securityUtil;
+
+    public ReferralController(ReferralService referralService, SecurityUtil securityUtil) {
         this.referralService = referralService;
+        this.securityUtil = securityUtil;
     }
 
     @PostMapping
-    public ResponseEntity<?> createReferral(@RequestBody CreateReferralRequest request) {
-        try {
+    public ResponseEntity<?> createReferral(@RequestBody CreateReferralRequest request, HttpServletRequest httpRequest) {
+        try {
+            String role = securityUtil.getRoleFromRequest(httpRequest);
+            if (role == null) {
+                return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
+                        .body(Map.of("error", "Unauthorized"));
+            }
+
+            // Patients cannot create referrals
+            if (role.equals("PATIENT")) {
+                return ResponseEntity.status(HttpStatus.FORBIDDEN)
+                        .body(Map.of("error", "Patients cannot create referrals"));
+            }
+
             if (request.getMedicalRecordId() == null || request.getMedicalRecordId() <= 0) {
                 return ResponseEntity.badRequest()
Index: backend/src/main/java/medora/dto/BillingDetailDTO.java
===================================================================
--- backend/src/main/java/medora/dto/BillingDetailDTO.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/dto/BillingDetailDTO.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -7,4 +7,5 @@
 public class BillingDetailDTO {
     private Long billId;
+    private Long patientId;
     private String patientName;
     private String patientEmbg;
@@ -19,8 +20,9 @@
     public BillingDetailDTO() {}
 
-    public BillingDetailDTO(Long billId, String patientName, String patientEmbg, String patientPhone,
+    public BillingDetailDTO(Long billId, Long patientId, String patientName, String patientEmbg, String patientPhone,
                             BigDecimal totalCost, String paymentStatus, LocalDate paymentDate,
                             LocalDate billDate, List<BillingItemDTO> procedures, List<BillingItemDTO> labTests) {
         this.billId = billId;
+        this.patientId = patientId;
         this.patientName = patientName;
         this.patientEmbg = patientEmbg;
@@ -37,4 +39,7 @@
     public Long getBillId() { return billId; }
     public void setBillId(Long billId) { this.billId = billId; }
+
+    public Long getPatientId() { return patientId; }
+    public void setPatientId(Long patientId) { this.patientId = patientId; }
 
     public String getPatientName() { return patientName; }
Index: backend/src/main/java/medora/util/JwtUtil.java
===================================================================
--- backend/src/main/java/medora/util/JwtUtil.java	(revision 43e476aafc15990f73b0a6b6411d3aa22acc770a)
+++ backend/src/main/java/medora/util/JwtUtil.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -1,4 +1,5 @@
 package medora.util;
 
+import io.jsonwebtoken.Claims;
 import io.jsonwebtoken.Jwts;
 import io.jsonwebtoken.SignatureAlgorithm;
@@ -9,26 +10,100 @@
 import javax.crypto.SecretKey;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 @Component
 public class JwtUtil {
 
-    @Value("${jwt.secret:your-secret-key-change-this-in-production}")
+    @Value("${jwt.secret:MyVerySecretKeyForJWTTokenGenerationAndValidationPurposesOnly12345}")
     private String jwtSecret;
 
-    @Value("${jwt.expiration:86400000}")
+    @Value("${jwt.expiration:86400000}") // 24 hours in milliseconds
     private long jwtExpirationMs;
 
+    private SecretKey getSigningKey() {
+        return Keys.hmacShaKeyFor(jwtSecret.getBytes());
+    }
+
     public String generateToken(String username, String role, Long userId, Long patientId) {
-        SecretKey key = Keys.hmacShaKeyFor(jwtSecret.getBytes());
+        return generateTokenWithDoctorId(username, role, userId, patientId, null);
+    }
 
+    public String generateTokenWithDoctorId(String username, String role, Long userId, Long patientId, Long doctorId) {
+        Map<String, Object> claims = new HashMap<>();
+        claims.put("role", role);
+        claims.put("userId", userId);
+        if (patientId != null) {
+            claims.put("patientId", patientId);
+        }
+        if (doctorId != null) {
+            claims.put("doctorId", doctorId);
+        }
+        return createToken(claims, username);
+    }
+
+    private String createToken(Map<String, Object> claims, String subject) {
         return Jwts.builder()
-                .subject(username)
-                .claim("role", role)
-                .claim("userId", userId)
-                .claim("patientId", patientId)
-                .issuedAt(new Date())
-                .expiration(new Date(System.currentTimeMillis() + jwtExpirationMs))
-                .signWith(key, SignatureAlgorithm.HS256)
+                .setClaims(claims)
+                .setSubject(subject)
+                .setIssuedAt(new Date())
+                .setExpiration(new Date(System.currentTimeMillis() + jwtExpirationMs))
+                .signWith(getSigningKey(), SignatureAlgorithm.HS256)
                 .compact();
     }
+
+    public String extractUsername(String token) {
+        return extractClaim(token, Claims::getSubject);
+    }
+
+    public String extractRole(String token) {
+        return extractClaim(token, claims -> (String) claims.get("role"));
+    }
+
+    public Long extractUserId(String token) {
+        return extractClaim(token, claims -> ((Number) claims.get("userId")).longValue());
+    }
+
+    public Long extractPatientId(String token) {
+        return extractClaim(token, claims -> {
+            Object patientId = claims.get("patientId");
+            return patientId != null ? ((Number) patientId).longValue() : null;
+        });
+    }
+
+    public Long extractDoctorId(String token) {
+        return extractClaim(token, claims -> {
+            Object doctorId = claims.get("doctorId");
+            return doctorId != null ? ((Number) doctorId).longValue() : null;
+        });
+    }
+
+    public <T> T extractClaim(String token, java.util.function.Function<Claims, T> claimsResolver) {
+        final Claims claims = extractAllClaims(token);
+        return claimsResolver.apply(claims);
+    }
+
+    private Claims extractAllClaims(String token) {
+        return Jwts.parser()
+                .verifyWith(getSigningKey())
+                .build()
+                .parseSignedClaims(token)
+                .getPayload();
+    }
+
+    public boolean isTokenValid(String token) {
+        try {
+            Jwts.parser()
+                    .verifyWith(getSigningKey())
+                    .build()
+                    .parseSignedClaims(token);
+            return true;
+        } catch (Exception e) {
+            return false;
+        }
+    }
+
+    public boolean isTokenExpired(String token) {
+        return extractClaim(token, Claims::getExpiration).before(new Date());
+    }
 }
Index: backend/src/main/java/medora/util/SecurityUtil.java
===================================================================
--- backend/src/main/java/medora/util/SecurityUtil.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
+++ backend/src/main/java/medora/util/SecurityUtil.java	(revision 946877f508647dc88cbaa9c515c5a587126d0206)
@@ -0,0 +1,85 @@
+package medora.util;
+
+import jakarta.servlet.http.HttpServletRequest;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SecurityUtil {
+
+    private final JwtUtil jwtUtil;
+
+    public SecurityUtil(JwtUtil jwtUtil) {
+        this.jwtUtil = jwtUtil;
+    }
+
+    public String extractTokenFromRequest(HttpServletRequest request) {
+        String authHeader = request.getHeader("Authorization");
+        if (authHeader != null && authHeader.startsWith("Bearer ")) {
+            return authHeader.substring(7);
+        }
+        return null;
+    }
+
+    public String getUsernameFromRequest(HttpServletRequest request) {
+        String token = extractTokenFromRequest(request);
+        if (token != null && jwtUtil.isTokenValid(token)) {
+            return jwtUtil.extractUsername(token);
+        }
+        return null;
+    }
+
+    public String getRoleFromRequest(HttpServletRequest request) {
+        String token = extractTokenFromRequest(request);
+        if (token != null && jwtUtil.isTokenValid(token)) {
+            return jwtUtil.extractRole(token);
+        }
+        return null;
+    }
+
+    public Long getUserIdFromRequest(HttpServletRequest request) {
+        String token = extractTokenFromRequest(request);
+        if (token != null && jwtUtil.isTokenValid(token)) {
+            return jwtUtil.extractUserId(token);
+        }
+        return null;
+    }
+
+    public Long getPatientIdFromRequest(HttpServletRequest request) {
+        String token = extractTokenFromRequest(request);
+        if (token != null && jwtUtil.isTokenValid(token)) {
+            return jwtUtil.extractPatientId(token);
+        }
+        return null;
+    }
+
+    public Long getDoctorIdFromRequest(HttpServletRequest request) {
+        String token = extractTokenFromRequest(request);
+        if (token != null && jwtUtil.isTokenValid(token)) {
+            return jwtUtil.extractDoctorId(token);
+        }
+        return null;
+    }
+
+    public boolean isValidToken(HttpServletRequest request) {
+        String token = extractTokenFromRequest(request);
+        return token != null && jwtUtil.isTokenValid(token);
+    }
+
+    public boolean hasRole(String role, HttpServletRequest request) {
+        String userRole = getRoleFromRequest(request);
+        return userRole != null && userRole.equals(role);
+    }
+
+    public boolean hasAnyRole(String[] roles, HttpServletRequest request) {
+        String userRole = getRoleFromRequest(request);
+        if (userRole == null) {
+            return false;
+        }
+        for (String role : roles) {
+            if (userRole.equals(role)) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
