Appointment System API Development Guide, Assignments of Programming Languages

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

2020/2021

Available from 06/20/2025

ishita-thakur-1
ishita-thakur-1 🇮🇳

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Hospital Appointment System
Real-world Scenario:
1.
You’re building a backend API for a hospital system where:
Patients can book appointments with doctors.
Doctors belong to departments (e.g., Cardiology, Orthopedics).
Patients have medical history records.
Appointments are stored in the system and can be retrieved by doctor or patient.
Learning Outcomes:
2.
Solidifies understanding of:
OneToMany, ManyToOne, OneToOne
DTO + ModelMapper
REST API structure
Exception Handling using @RestControllerAdvice
Avoiding @JsonIgnore using DTOs instead
Entities & Relationships
3.
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
DTO Design
4.
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
HOSPITAL APPOINTMENT SYSTEM :
19 June 2025
13:08
New Section 1 Page 1
pf2

Partial preview of the text

Download Appointment System API Development Guide and more Assignments Programming Languages in PDF only on Docsity!

Hospital Appointment System

1. Real-world Scenario: You’re building a backend API for a hospital system where:

  • Patients can book appointments with doctors.
  • Doctors belong to departments (e.g., Cardiology, Orthopedics).
  • Each appointment has a patient, a doctor, and a scheduled date & time.
  • Patients have medical history records.
  • Appointments are stored in the system and can be retrieved by doctor or patient. 2. Learning Outcomes: Solidifies understanding of: ○ OneToMany, ManyToOne, OneToOne ○ DTO + ModelMapper ○ REST API structure ○ Exception Handling using @RestControllerAdvice ○ Avoiding @JsonIgnore — using DTOs instead

3. Entities & RelationshipsDoctor - 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

HOSPITAL APPOINTMENT SYSTEM :

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:

  • Entity → DTO DTO → Entity for Doctor, Patient, Appointment

Sample JSON: Create Appointment json { "doctorId": 3, "patientId": 10, "appointmentDate": "2025- 06 - 25", "appointmentTime": "15:30" } New Section 1 Page 2