Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Hospital Appointment System, Assignments of Programming Languages

One who wants to learn spring boot can try this assignment

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 Hospital Appointment System 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