0% found this document useful (0 votes)
8 views6 pages

Hospital Patient Management System Code

The document outlines a Hospital Patient Management System consisting of various classes including HospitalStaff, Doctor, Nurse, Patient, Appointment, MedicalRecord, and Billing strategies. Each class has specific attributes and methods to manage hospital staff details, patient information, appointments, and billing calculations. The main class, HospitalSystem, simulates patient flow by creating instances of these classes and displaying relevant details.

Uploaded by

amrin haider
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views6 pages

Hospital Patient Management System Code

The document outlines a Hospital Patient Management System consisting of various classes including HospitalStaff, Doctor, Nurse, Patient, Appointment, MedicalRecord, and Billing strategies. Each class has specific attributes and methods to manage hospital staff details, patient information, appointments, and billing calculations. The main class, HospitalSystem, simulates patient flow by creating instances of these classes and displaying relevant details.

Uploaded by

amrin haider
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Hospital Patient Management System

1. [Link]
- Base abstract class
abstract class HospitalStaff {
private String name;
private int id;
private String department;

public HospitalStaff(String name, int id, String department)


{
[Link] = name;
[Link] = id;
[Link] = department;
}

//
public String getName()
{
return name;
}
public void setName(String name)
{
[Link] = name;
}

//
public int getId()
{
return id;
}
public void setId(int id)
{
[Link] = id;
}

//
public String getDepartment()
{
return department;
}
public void setDepartment(String department)
{
[Link] = department;
}

//
public abstract void displayDetails();
}
2. [Link]
- Cioncrete subclass of HospitalStaff
- class Doctor extends HospitalStaff {
private String specialization;

public Doctor(String name, int id, String departemnt, String


specialization)
{
super(name, id, departemnt);
[Link] = specialization;
}

public String getSpecialization()


{
return specialization;
}

@Override
public void displayDetails()
{
[Link]("Doctor: " + getName() + " - Department:
" + getDepartment() + " - Specialization: " + specialization);
}
}

3. [Link]
- Concrete subclass of HospitalStaff
- class Nurse extends HospitalStaff {
public String shift;

public Nurse(String name, int id, String department, String


shift)
{
super(name, id, department);
[Link] = shift;
}

@Override
public void displayDetails()
{
[Link]("Nurse: " + getName() + " - Department: "
+ getDepartment() + " - Shift: " + shift);
}
}

4. [Link]
- Represents a patient in the Hospital System.

- class Patient {
private String name;
private int patientId;
private String disease;

public Patient(String name, int patientId, String


disease)
{
[Link] = name;
[Link] = patientId;
[Link] = disease;
}

public String getName()


{
return name;
}
public int getPatientId()
{
return patientId;
}
public String getDisease()
{
return disease;
}

public void displayDetails()


{
[Link]("Patient: " + name + " -
Disease: " + disease);
}
}

5. [Link]
- Associates exactly one Doctor and one Patient at a scheduled
- class Appointment {
Doctor doctor;
Patient patient;

private String date;


String type;

public Appointment(Doctor doctor, Patient patient, String date,


String type)
{
[Link] = doctor;
[Link] = patient;
[Link] = date;
[Link] = type;
}
public void showAppointmentDetails()
{
[Link]("Appointment Type: " + type);
[Link]("Date: " + date);
[Link]("Doctor: " + [Link]());
[Link]("Patient: " + [Link]());
}

6. [Link]
- One medical record entry for a patient
- class MedicalRecord {
private String diagnosis;
private String prescription;

public MedicalRecord(String diagnosis, String prescription)


{
[Link] = diagnosis;
[Link] = prescription;
}

public void showRecord()


{
[Link](
"Diagnosis: " + diagnosis +
" - Prescription: " + prescription
);
}
}

7. [Link]
- Abstraction for billing calculations
- Interface-based Abstraction
- interface Billing {
double calculateServiceCharge();
}

8. [Link]
- Billing strategy (implements Billing)
- class GeneralCheckup implements Billing {

@Override
public double calculateServiceCharge() {
return 10000.0;
}
}

9. Emergency [Link]
- Billing strategy (implements Billing)
- class EmergencyConsultation implements Billing {

@Override
public double calculateServiceCharge(){
return 15000.0;
}
}

10. [Link]
- Simulation of a patient flow:
- public class HospitalSystem {
public static void main(String[] args)
{
//
Doctor doc1 = new Doctor("Dr. Amrin", 115, "Neurologist",
"Brain Specialist");
Nurse nurse1 = new Nurse("Nurse Soyaib", 111,
"Neurologist", "Day/Night");
Patient patient1 = new Patient("Hamza", 135, "Brain
Tumour");

[Link]();
[Link]();
[Link]();

//
Appointment app1 = new Appointment(doc1, patient1, "5-11-
2025", "GeneralCheckup");

[Link]();
[Link]();

//
MedicalRecord record1 = new MedicalRecord("Headaches",
"steroids");

[Link]("\nMedical Record: ");


[Link]();

Billing bill;
if ([Link]("GeneralCheckup"))
{
bill = new GeneralCheckup();
}
else
{
bill = new EmergencyConsultation();
}

[Link]("\nService Charge: $" +


[Link]());
[Link]("\nPatient dose completed
successfully.");

}
}

11. Output:

Common questions

Powered by AI

Using abstract classes, like HospitalStaff, and interfaces, such as Billing, offers several design advantages. Abstract classes provide a common base for subclasses while enforcing specific method implementations, enabling code reuse and reducing redundancy. Interfaces provide a means to define contract-based design, where implementations can vary independently of the consuming code, enhancing flexibility and adaptability. These principles allow new staff roles or billing strategies to be integrated with minimal system disruption, promoting scalability and maintainability .

The existing class design in the Hospital Patient Management System, which uses abstract classes and interfaces, sets a solid foundation for scalability and feature additions. Because the system is built on well-defined contracts and abstract methods, new specialized staff classes or billing strategies can be integrated with little impact on existing code. This modular design allows independent development of components, like adding new medical record types or more complex appointment handling features, ensuring the system can evolve without significant refactors .

The billing strategy's effectiveness in the hospital management system is evidenced by its ability to clearly define and implement service-specific billing calculations through the Billing interface. This approach ensures accurate and consistent billing by segregating charges according to the service type, such as GeneralCheckup or EmergencyConsultation, each having fixed charges of 10000.0 and 15000.0, respectively. By using polymorphism, the system selects the appropriate strategy based on the appointment type, ensuring that patients receive proper billing without manual errors or redundancies .

The interface Billing provides an abstraction for calculating service charges, allowing various services to implement their specific billing strategies. By having GeneralCheckup and EmergencyConsultation implement Billing, the system can dynamically decide the billing strategy based on the type of service required for an appointment. This design allows for scalable and maintainable code, where new service billing strategies can be easily added without modifying existing code .

The displayDetails() method enhances usability by providing a standardized way to output essential information related to hospital staff, patients, or appointments. In the context of a Doctor, Nurse, or Patient class, it centralizes the retrieval of critical attributes such as name, department, and role-specific characteristics (like specialization or shift), improving user perception and system navigation. This method supports the transparency and verification of information flow, vital for managing hospital operations effectively .

The HospitalStaff class serves as an abstract base class, providing common attributes and methods like getName(), getId(), and getDepartment(), while enforcing specialization through abstract methods such as displayDetails(). This requires subclasses like Doctor and Nurse to implement their own versions of these methods, thus ensuring that specific behavior related to their roles is defined. For example, Doctor has an additional attribute specialization and implements displayDetails() to provide details specific to doctors .

The HospitalStaff class benefits from encapsulation by restricting direct access to its attributes, such as name, id, and department. This practice ensures that object state modifications are controlled through setter methods, which can include validation logic, thereby maintaining system integrity. Encapsulation also hides implementation details from other components, promoting loose coupling and increasing the robustness of the system against unintended interactions or errors .

The Appointment class acts as a mediator by holding references to a Doctor and a Patient, thereby associating them for a scheduled service. It facilitates interaction by allowing the system to manage appointments effectively, ensuring that the details of both participants are accessible in one place. The method showAppointmentDetails() demonstrates this interaction by outputting the appointment type, date, and associated doctor and patient names, ensuring that all necessary information for the appointment is organized and easily retrievable .

The HospitalSystem class simulates patient flow by sequentially executing key processes involved in patient management, from staff and patient initialization to billing. It begins by creating instances of doctors, nurses, and patients and displays their details using displayDetails(). The system then creates an Appointment instance, linking a doctor and patient, and displays the appointment details. A MedicalRecord is also generated and shown. Finally, it calculates service charges using a dynamic billing strategy based on the appointment type, fulfilling the patient management cycle from entry to completed billing .

The Patient class serves as a fundamental component that encapsulates patient-related information, such as name, patientId, and disease. It integrates with other system components by providing essential functionalities through its methods, such as getName() and getDisease(), which are used in displaying patient details in appointments and medical records. This helps manage patient information efficiently and ensures data encapsulation and accessibility when interacting with doctors or during the billing process .

You might also like