How saphulele/hospital_management_system works
1. Purpose and Runtime Entry Point
This is a Java Hospital Management System focused in its implemented source on patient, doctor, and appointment management. The executable entry point is src/src/Main.java. The repository also contains extensive requirements, domain-modeling, workflow, and persistence-layer design documentation, but no database implementation, UI, or external-service integration is present in the source tree.
2. Layered Application Structure
The implementation follows a controller → service → DTO/error-boundary organization:
• Controllers expose operation-facing endpoints or commands: src/src/Controller/PatientController.java, src/src/Controller/DoctorController.java, src/src/Controller/AppointmentController.java.
• Services hold domain/business operations: src/src/services/PatientService.java, src/src/services/DoctorService.java, src/src/services/AppointmentService.java.
• DTOs define data transferred between controllers and services: src/src/DTO/Patientdto.java, src/src/DTO/DoctorDto.java, src/src/DTO/AppointmentDto.java.
3. Patient Management
Patient operations are centered on the patient service contract and its concrete implementation. src/src/services/PatientService.java defines the patient-facing business API, while src/src/services/PatientServiceImplementation.java supplies its current implementation. src/src/Controller/PatientController.java is the boundary that accepts patient requests and maps results to Patientdto.
Patient admission safety is explicitly modeled through src/src/exceptions/PatientAlreadyAdmittedException.java; lookup failures use src/src/exceptions/PatientNotFoundException.java.
4. Doctor Availability and Coordination
Doctor lifecycle and availability behavior is separated into src/src/Controller/DoctorController.java and src/src/services/DoctorService.java, with src/src/DTO/DoctorDto.java carrying doctor data. This separation is architecturally important because appointment scheduling depends on doctor existence and availability. Failures are represented by src/src/exceptions/DoctorNotFoundException.java and src/src/exceptions/DoctorNotAvailableException.java.
5. Appointment Scheduling Flow
Appointment handling is the principal cross-domain workflow:
1. A request enters src/src/Controller/AppointmentController.java.
2. src/src/services/AppointmentService.java coordinates appointment operations and must enforce patient/doctor constraints.
3. Appointment data crosses the boundary via src/src/DTO/AppointmentDto.java.
4. Scheduling failures are surfaced as src/src/exceptions/AppointmentConflictException.java or src/src/exceptions/AppointmentNotFoundException.java.
This is the key control-flow boundary joining patient identity, doctor availability, and temporal conflict rules.
6. Error Handling Boundary
Domain exceptions are centralized under src/src/exceptions, allowing services to signal business failures without coupling to a presentation mechanism. src/src/exceptions/GlobalExceptionHandler.java is the top-level translation point intended to convert those failures into consistent application responses. This keeps controllers thin and makes exception behavior a shared contract across patient, doctor, and appointment flows.
7. Persistence and Broader Hospital Scope
Persistence is documented as an intended abstraction rather than implemented runtime infrastructure. The design materials identify repository interfaces, in-memory storage, and future-proofing: Implementing a Persistence Repository Layer/generic repository interface.md, Implementing a Persistence Repository Layer/In-Memory Implementation.md, and Implementing a Persistence Repository Layer/Storage-Abstraction Mechanism.md.
The wider target domain—billing, records, beds, pharmacy, labs, surgery, and admissions—is specified in documentation such as SPECIFICATION.md and Object State Modeling/Patient Admission Workflow.md. These capabilities should be treated as planned domain expansion, not current source-level modules. No concrete database, authentication/security provider, web framework, message broker, or third-party external service is evidenced by the supplied tree.
Main entry points: AppointmentService.java Appointment service · PatientService.java Patient service contract · Main.java Application entry point · PatientController.java Patient controller
Components 18
Runtime application
- Application entry point
src/src/Main.java
Patient management
- Patient controller
src/src/Controller/PatientController.java - Patient service contract
src/src/services/PatientService.java - Patient service implementation
src/src/services/PatientServiceImplementation.java - Patient DTO
src/src/DTO/Patientdto.java
Doctor management
- Doctor controller
src/src/Controller/DoctorController.java - Doctor service · Manages doctor lifecycle and availability.
src/src/services/DoctorService.java - Doctor DTO
src/src/DTO/DoctorDto.java
Appointment scheduling
- Appointment controller
src/src/Controller/AppointmentController.java - Appointment service · Coordinates patient, doctor, and scheduling constraints.
src/src/services/AppointmentService.java - Appointment DTO
src/src/DTO/AppointmentDto.java
Error boundary
- Patient exceptions · Admission and lookup failures.
src/src/exceptions/PatientAlreadyAdmittedException.java - Doctor exceptions · Missing or unavailable doctor failures.
src/src/exceptions/DoctorNotAvailableException.java - Appointment exceptions · Conflict and lookup failures.
src/src/exceptions/AppointmentConflictException.java - Global exception handler · Converts domain failures into consistent responses.
src/src/exceptions/GlobalExceptionHandler.java
Planned architecture
Documented only; not implemented at runtime.
- Persistence repository design · Defines repository, in-memory, and storage-abstraction plans.
Implementing a Persistence Repository Layer/generic repository interface.md - Hospital domain specification · Defines broader future hospital capabilities.
SPECIFICATION.md - Patient admission workflow · Documents planned admission state modeling.
Object State Modeling/Patient Admission Workflow.md
Connections 20
- Application entry point → Patient controller: starts operations
- Application entry point → Doctor controller: starts operations
- Application entry point → Appointment controller: starts operations
- Patient controller → Patient service contract: invokes
- Patient controller → Patient DTO: maps requests and results
- Patient service contract → Patient service implementation: implemented by
- Doctor controller → Doctor service: invokes
- Doctor controller → Doctor DTO: maps requests and results
- Appointment controller → Appointment service: invokes
- Appointment controller → Appointment DTO: maps requests and results
- Appointment service → Patient service contract: validates patient
- Appointment service → Doctor service: checks existence and availability
- Patient service contract → Patient exceptions: signals business failures
- Doctor service → Doctor exceptions: signals business failures
- Appointment service → Appointment exceptions: signals conflicts and lookup failures
- Patient exceptions → Global exception handler: translated by
- Doctor exceptions → Global exception handler: translated by
- Appointment exceptions → Global exception handler: translated by
- Hospital domain specification → Patient admission workflow: details future workflow
- Persistence repository design → Hospital domain specification: supports planned expansion