0% found this document useful (0 votes)
12 views5 pages

Healthcare

The document defines a Healthcare class that manages patient information, including assigning doctors based on diseases and displaying patient status. It includes methods for handling patient discharge, treatment status, and doctor assignment. The main method demonstrates the functionality with three patient instances and their respective statuses.

Uploaded by

Sana Shyzu
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)
12 views5 pages

Healthcare

The document defines a Healthcare class that manages patient information, including assigning doctors based on diseases and displaying patient status. It includes methods for handling patient discharge, treatment status, and doctor assignment. The main method demonstrates the functionality with three patient instances and their respective statuses.

Uploaded by

Sana Shyzu
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
You are on page 1/ 5

class Healthcare {

int pid; // Patient ID

String pname; // Patient Name

String pdisease; // Patient Disease

int did; // Doctor ID

String dname; // Doctor Name

String dspec; // Doctor Specialization

String hospitalname; // Hospital Name

String status; // Patient status

// Constructor

public Healthcare(int pid1, String pname1, String pdisease1, String hospitalname1, String status1) {

pid = pid1;

pname = pname1;

pdisease = pdisease1;

hospitalname = hospitalname1;

status = status1;

// Method to assign doctors based on disease

void assignDoctors() {

switch (pdisease) {

case "Heart Issue":

dname = "Dr. Smith";

dspec = "Cardiologist";

break;

case "Cancer":

dname = "Dr. Johnson";

dspec = "Oncologist";

break;

case "Liver Issue":


dname = "Dr. Carter";

dspec = "Hepatologist";

break;

case "Nerves Issues":

dname = "Dr. Brown";

dspec = "Neurologist";

break;

default:

System.out.println("No doctor available for the disease: " + pdisease);

dname = "Not Assigned";

dspec = "N/A";

break;

// Method

void outPatients() {

if (status.equals("cured")) {

System.out.println(pname + " has been discharged as the patient is cured.");

} else if (status.equals("non-curable")) {

System.out.println(pname + " has been shifted to another hospital as the condition is non-
curable.");

// Method

void inPatients() {

if (status.equals("under treatment")) {

System.out.println(pname + " is still under treatment.");

} else if (status.equals("under observation")) {

System.out.println(pname + " is being observed for further diagnosis.");


}

// Method

void display() {

System.out.println("ID: " + pid + " | Name: " + pname + " | Disease: " + pdisease + " | Status: " +
status);

System.out.println("Doctor: " + dname + " (" + dspec + ")");

System.out.println("Hospital: " + hospitalname);

public static void main(String[] args) {

//patients with updated status

Healthcare patient1 = new Healthcare(1, "John Doe", "Heart Issue", "City Hospital", "under
treatment");

Healthcare patient2 = new Healthcare(2, "Jane Doe", "Cancer", "General Hospital", "cured");

Healthcare patient3 = new Healthcare(3, "Jim Beam", "Liver Issue", "Specialist Hospital", "under
observation");

// Process and display details for each patient

patient1.assignDoctors();

patient1.outPatients();

patient1.inPatients();

patient1.display();

System.out.println();

patient2.assignDoctors();

patient2.outPatients();

patient2.inPatients();

patient2.display();

System.out.println();
patient3.assignDoctors();

patient3.outPatients();

patient3.inPatients();

patient3.display();

System.out.println();

}
Output
John Doe is still under treatment.
ID: 1 | Name: John Doe | Disease: Heart Issue | Status: under treatment
Doctor: Dr. Smith (Cardiologist)
Hospital: City Hospital

Jane Doe has been discharged as the patient is cured.


ID: 2 | Name: Jane Doe | Disease: Cancer | Status: cured
Doctor: Dr. Johnson (Oncologist)
Hospital: General Hospital

Jim Beam is being observed for further diagnosis.


ID: 3 | Name: Jim Beam | Disease: Liver Issue | Status: under observation
Doctor: Dr. Carter (Hepatologist)
Hospital: Specialist Hospital

You might also like