×

Hospital Management Project in C++

The following capabilities are required to build a hospital management project: These are as follows: hospitals' names, contact information, and lists of doctors and patients.

Activities Supported

  • Hospital Data Print
  • Patients' data to print
  • Beds Price Sort
  • Order By Available Beds
  • Order By Name
  • Rating and reviewing the order
  • Print the Hospital for any city.

The program's primary features are:

  • All hospital data will be printed using the PrintHospitalData() method.
  • All hospital data will be printed using the PrintPatientData() method.
  • SortHospitalByName(): List all hospitals in alphabetical order by name
  • SortHospitalByRating(): Arrange hospitals by rating
  • Sort hospitals by beds available using the SortByBedsAvailable() method.
  • Hospitals can be sorted by bed price using the SortByBedsPrice() method.

Approach

  • Create classes for the Patient dataset as well as the Hospital dataset.
  • Set up the variables that store patient and Hospital data.
  • Create objects for patient classes and hospitals with the patient and hospital data access.
  • Employ two arrays to hold the patient data and the hospital dataset.
  • Apply the provided functionality as indicated below.

The application of the strategy is shown below:

Example 1:

#include <bits/stdc++.h>
usingnamespace std;
class Hospital {
Public:
    string H_name;
    string location;
    intavailable_beds;
    float rating;
    string contact;
    string doctor_name;
    int price;
};
classPatient:public Hospital {
public:
    string P_name;
    intP_id;
};
voidPrintHospitalData(
    vector<Hospital>& hospitals)
{
    cout<< "PRINT hospitals DATA:"
         <<endl;
  
    cout<< "HospitalName     "
<< "Location."
         << "Beds_Available     "
<< "Rating."
         << "Hospital_Contact     "
         << "Doctor_Name     "
         << "Price_Per_Bed     \n";
    for (inti = 0; i< 4; i++) {
        cout<< hospitals[i].H_nam
<< "                 "
             << "        "
             << hospitals[i].location
             << "           "
             << hospitals[i].available_beds
             << "                    "
             << hospitals[i].rating
             << "            "
             << hospitals[i].contact
             << "             "
             << hospitals[i].doctor_name
             << "                  "
             << "        "
             << hospitals[i].price
             << "            "
             <<endl;
    }
    cout<<endl
         <<endl;
}
voidPrintPatientData(
    vector<Patient>& patients,
    vector<Hospital>& hospitals)
{
    cout<< "PRINT patients DATA:"
         <<endl;
    cout<< "Patient_Name     "
         << "Patient_Id     "
         << "Patient_Contact     "
         << "Alloted_Hospital     "
         << "Patient_Expenditure     \n";
    for (inti = 0; i< 4; i++) {
        cout<< patients[i].P_name
             << "                "
             << "          "
             << patients[i].P_id
             << "              "
             << "          "
             << patients[i].contact
             << "                   "
             << hospitals[i].H_name
             << "                   "
             << patients[i].price
             << "            "
             <<endl;
    }
    cout<<endl
         <<endl;
}
boolname(Hospital& A, Hospital& B)
{
    returnA.H_name>B.H_name;
}
  
voidSortHospitalByName(
    vector<Hospital> hospitals)
{
    sort(hospitals.begin(),
         hospitals.end(),
         name);
    cout<< "SORT BY NAME:"
         <<endl
         <<endl;
    PrintHospitalData(hospitals);
}
boolrating(Hospital& A, Hospital& B)
{
    returnA.rating>B.rating;
}
voidSortHospitalByRating(vector<Hospital> hospitals)
{
    sort(hospitals.begin(),
         hospitals.end(),
         rating);  
    cout<< "SORT BY Rating:"
         <<endl
         <<endl;
    PrintHospitalData(hospitals);
}
boolbeds(Hospital& A, Hospital& B)
{
    returnA.available_beds>B.available_beds;
}
voidSortByBedsAvailable(
    vector<Hospital> hospitals)
{
    sort(hospitals.begin(),
         hospitals.end(),
         beds);  
    cout<< "SORT BY Available Beds:"
         <<endl
         <<endl;
    PrintHospitalData(hospitals);
}
boolbeds_price(Hospital& A, Hospital& B)
{
    returnA.price<B.price;
}
voidSortByBedsPrice(
    vector<Hospital> hospitals)
{
    sort(hospitals.begin(),
         hospitals.end(),
         beds_price);  
    cout<< "SORT BY Available Beds Price:"
         <<endl
         <<endl;
  
    PrintHospitalData(hospitals);
}
voidPrintHospitalBycity(
    string city, vector<Hospital> hospitals)
{
    cout<< "PRINT hospitals by Name:"
         << city <<endl;  
    cout<< "HospitalName     "
<< "Location."
         << "Beds_Available     "
<< "Rating."
         << "Hospital_Contact     "
         << "Doctor_Name     "
         << "Price_Per_Bed     \n";
    for (inti = 0; i< 4; i++) {
        if (hospitals[i].location != city)
            continue;
        cout<< hospitals[i].H_name
             << "                  "
             << "       "
             << hospitals[i].location
             << "           "
             << hospitals[i].available_beds
             << "                    "
             << hospitals[i].rating
             << "            "
             << hospitals[i].contact
             << "             "
             << hospitals[i].doctor_name
             << "                "
             << "          "
             << hospitals[i].price
             << "            "
             <<endl;
    }
    cout<<endl
         <<endl;
}
voidHospitalManagement(
    string patient_Name[], intpatient_Id[],
    string patient_Contact[], intbookingCost[],
    string hospital_Name[], string locations[], int beds[],
    floatratings[], string hospital_Contact[],
    string doctor_Name[], int prices[])
{
    vector<Hospital> hospitals;
    Hospital h;
    for (inti = 0; i< 4; i++) {
        h.H_name = hospital_Name[i];
        h.location = locations[i];
        h.available_beds = beds[i];
        h.rating = ratings[i];
        h.contact = hospital_Contact[i];
        h.doctor_name = doctor_Name[i];
        h.price = prices[i];
        hospitals.push_back(h);
    }
    vector<Patient> patients;
    Patient p;
    for (inti = 0; i< 4; i++) {
        p.P_name = patient_Name[i];
        p.P_id = patient_Id[i];
        p.contact = patient_Contact[i];
        p.price = bookingCost[i];
        patients.push_back(p);
    }
    cout<<endl;
    PrintHospitalData(hospitals);
    PrintPatientData(patients, hospitals);
    SortHospitalByName(hospitals);
    SortHospitalByRating(hospitals);
    PrintHospitalBycity("Bangalore", hospitals);
    SortByBedsAvailable(hospitals);
    SortByBedsPrice(hospitals);
}
intmain()
{
    string patient_Name[] = { "P1", "P2", "P3", "P4" };
    intpatient_Id[] = { 2, 3, 4, 1 };
    string patient_Contact[]
        = { "234534XXX7", "234576XXX2", "857465XXX9",
            "567657XXX0" };
    intbookingCost[] = { 1000, 1200, 1100, 600 }  
    string hospital_Name[] = { "H1", "H2", "H4", "H3" };
    string locations[] = { "Bangalore", "Bangalore",
                           "Mumbai   ", "Prayagraj" };
    intbeds[] = { 4, 5, 6, 9 };
    floatratings[] = { 5.2, 4.1, 3.4, 5.9 };
    string hospital_Contact[]
        = { "657534XXX7", "298766XXX2", "324565XXX9",
            "343456XXX4" };
    string doctor_Name[] = { "D1", "D4", "D3", "D2" };
    intprices[] = { 100, 200, 100, 290 };
    hospital management(
        patient_Name, patient_Id, patient_Contact,
        booking cost, hospital_Name, locations, beds,
        ratings, hospital_Contact, doctor_Name, prices);
  
    return 0;
}

Output:

Hospital Management Project in C++
Hospital Management Project in C++
Hospital Management Project in C++

Related Topics

C++ Expressions

C ++ equations are made up of operators, constants and variables arranged according to language rules. It may also include function calls that give results. To calculate the value, the...

4 minutes read.

C++ History

C++ is a middle-level programming language developed in 1980s by Bjarne Stroustrup at Bel Labs. C ++ development initially started in 1979, four years before its launch. It is started with...

1 minute read.

Virtual Function Vs Pure Virtual Function

Virtual activity is a member function defined in the foundation phase that can be redefined by acquired classes. Let's have a look at an example: #include <iostream>   #include <bits/stdc++.h> #include <stdlib> using namespace std;   class Base   {    ...

5 minutes read.

For Loop Examples in C++

For Loop A for loop is a repetitive control structure that allows you to create a loop to execute a specific number of times efficiently. The syntax of for loop In C++, a...

6 minutes read.

Input Iterators in C++

What are input iterators? Input iterators are used in sequence for carrying out input operations where each value is read-only. It is pointed by the iterator and further incremented. All the iterators...

4 minutes read.

Hierarchical Inheritance

C++ Hierarchical Inheritance Hierarchical inheritance inherits the property of one base class in more than one derived class.   C++ Hierarchical Inheritance Example #include <iostream>   using namespace std;   class Person {       char gender[10];       int age;   public:       void getPerson()       {           cout << "Age: "; cin >> age;           cout << "Gender: "; cin >> gender;       }       void dispPerson()       {           cout << "Age: " << age << endl;           cout << "Gender: " << gender << endl;       }   };   class Employee : public Person {       float salary;   public:       void getEmployee()       {           Person::getPerson();           cout << "Salary: Rs."; cin >> salary;       }       void dispEmployee()       {           Person::dispPerson();           cout << "Salary: Rs." << salary << endl;       }   };   class Student : public Person {       char level[20];   public:       void getStudent()       {           Person::getPerson();           cout << "Class: "; cin >> level;       }       void dispStudent()       {           Person::dispPerson();           cout << "Level: " << level << endl;       }   };   int main()   {       Person per;       Employee emp;       Student stu;       cout << "Student data" << endl;       cout << "Enter data" << endl;       stu.getStudent();       cout << endl << "Displaying data" << endl;       stu.dispPerson();       cout << endl << "Staff Data" << endl;       cout << "Enter data" << endl;       emp.getEmployee();       cout << endl << "Displaying data" << endl;       emp.dispPerson();   } Output: Student data Enter data Age: 10 Gender: f Class: 5 Displaying data Age: 10 Gender: f Employee data Enter data Age:...

1 minute read.

How to concatenate two strings in C++

In the C++ programming language, the concatenation of two or even more strings is covered in this section. The term "string concatenation" refers to a collection of characters that join two...

4 minutes read.

Binary Search in C++

The binary search in the C++ programming language will be discussed. By continually halves the array and then seeking specified items from a half array; binary search is a technique...

8 minutes read.

Difference between OOP and POP in C++

Object-Oriented Programming (OOP) Prioritizes data over methods (functions) and treats data as an essential component of program development.  OOP prohibits the free flow of data throughout the system. Tighter ties to data manipulation...

4 minutes read.

Destructor

Let’s discover the C++ destructor, virtual and pure virtual destructors, and when destructors are invoked and their rules in this lesson. Destructors : A member function that destroys an object is known as...

5 minutes read.

C++ program to read string using cin.getline()

C++ program to read string using cin.getline() C++ getline() is a standard library feature for reading a string or a line from an input source. A getline() function gets characters from...

3 minutes read.

Random Number Generator in C++

In programming, we need to frequently create the randomly. For example, a dice game, handing out cards to players, apps for rearranging tunes, etc. T There are two tools available in...

4 minutes read.

C++ Goto

In this article, we will discuss the C++ goto statement with its syntax, use, key features, key points, pseudo code, and examples. What is the goto statement in C++? In C++, the...

4 minutes read.

Pointer to Object in C++

What is a pointer? A pointer in C++ is used to point the variable by storing the address of the variable. In C++, to print the address of the variable, we...

4 minutes read.

Add two numbers represented by two arrays in C++

The array stores a number in such a way that each digit of the number is represented by an array element. As an example, The array number 147 is 1,4,7. To add...

3 minutes read.

C++ storage classes

Storage Classes are used to characterize a variable's or function's characteristics. These characteristics include scope, visibility, and life-time, which allow us to track the presence of a variable over the...

5 minutes read.

Reverse String Word-Wise in C++

What is a reversed String? Reversing the words of a sentence is called reversed string by words. The difference between the reverse a string and the reverse a string word-wise is...

4 minutes read.

Fast Input and Output in C++

In competitive programming, it's critical to read input as quickly as possible in order to save time. "Warning: Big I / O data, be aware of certain languages (but most...

3 minutes read.

Skyline Problem in C++

We have given n rectangular buildings in a 2-dimensional city. Here, to compute the Skyline of the given n rectangle structures in a two-dimensional metropolis while removing hidden lines, the...

3 minutes read.

Nullptr in C++

What is Nullptr in C++? A null pointer value is represented by the term nullptr. Use a null pointer value to indicate that a native pointer type, inner pointer, or object...

3 minutes read.