

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A guide to developing a backend API for an appointment system. It details entity relationships (one-to-many, many-to-one, one-to-one), data transfer object (DTO) implementation, REST API structure, and exception handling. The guide emphasizes data privacy using DTOs and provides an overview of entities like practitioners, departments, patients, appointments, and medical records. It includes DTO designs, REST endpoints for managing practitioners, patients, and appointments, and viewing appointments. A sample JSON for creating appointments is provided, offering a practical approach to building a robust and efficient appointment system API. Useful for understanding API design, data handling, and backend development best practices. It also covers mapping entities to DTOs and handling exceptions to ensure a robust application.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


➢ Hospital Appointment System
1. Real-world Scenario: You’re building a backend API for a hospital system where:
3. Entities & Relationships ➢ Doctor - id, name, email, mobile, specialization - @ManyToOne with Department - @OneToMany with Appointment ➢ Department - id, name (e.g., "Cardiology", "Orthopedics") - @OneToMany with Doctor ➢ Patient - id, fullName, age, email, mobile - @OneToOne with MedicalHistory - @OneToMany with Appointment ➢ Appointment - id, appointmentDate, appointmentTime - @ManyToOne with Doctor - @ManyToOne with Patient ➢ MedicalHistory - id, bloodGroup, diseases, allergies - @OneToOne with Patient 4. DTO Design Entity Field Hidden in DTO Reason DoctorDTO No mobile/email exposed Privacy PatientDTO Hide medical history Use separate MedicalHistoryDTO AppointmentDTO Show doctor name, patient name, date & time
19 June 2025 13: New Section 1 Page 1
AppointmentDTO Show doctor name, patient name, date & time MedicalHistoryDTO Separate call only if required
5. Handle the Exception if some id not fount then through a customer exception : Use RestControllerAdvise + Exception handler (for hadling the exception) and create one more class to show error response ( like date and time , error name , error message , and error status);
6. REST Endpoints POST /doctors Add a doctor (with department ID) POST /patients Add a patient with medical history POST /appointments Create appointment (pass doctorId, patientId, date, time) GET /appointments/patient/{id} View all appointments for a patient GET /appointments/doctor/{id} View all appointments for a doctor ➢ Use ModelMapper Map:
➢ Sample JSON: Create Appointment json { "doctorId": 3, "patientId": 10, "appointmentDate": "2025- 06 - 25", "appointmentTime": "15:30" } New Section 1 Page 2