×

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

Palindrome using Do-while loop in C++

What is Palindrome? A palindrome is a word, number, phrase, or other sequence of letters that reads the same backward as forward, such as 101 or MOM. Like other programming languages, C++...

5 minutes read.

C++ Enumeration

C++ Enumeration In C++, Enum is a special data type that contains some fixed sets of components that have various applications in the programming. Enum works fine with fixed constant sets...

3 minutes read.

User-defined literals in C++

Introduction to User-Defined Literals: User-defined literals, introduced in C++11, are a way to extend the C++ language to allow users to define their literal suffixes and the corresponding behavior. These suffixes...

7 minutes read.

Sum of all elements between k1’th and k2’th Smallest Elements

In this tutorial, we will look at how to determine sum of all given elements between two given indexes’ smallest elements. Assuming an array of integers and two numbers, k1...

2 minutes read.

Initialize Vector in C++

Initialize Vector in C++  The following comparison operators are defined for vector and those are given below. ==, <, <=, !=, >,>=  This allows you to access the element of a vector using...

3 minutes read.

C++ Program to find the largest number formed from an array

Given an array, write a program to find the largest number that will be formed from the elements of the array. Arrangement should be done in such a way that...

4 minutes read.

Difference between C and C++

What do you mean by C? C is a machine-independent structure or procedural oriented computer language that is widely utilized in a variety of applications. C is a fundamental programming language...

4 minutes read.

How to create a library in C++

Before going on to the creation of a library, let’s understand its meaning. What is a library? In simple words, a library is a collection of numerous functions, methods, classes, header files...

7 minutes read.

C++ Socket Programming

In this world, computer networking has become very important for sharing of data. Every good programmer has some knowledge about computer networking. Socket programming is one of the critical topics...

6 minutes read.

Principles of Object-Oriented Programming in C++

What is Object-Oriented Programming? Object-oriented programming is about creating obejcts that represent the real-world entity . In object-oriented programming, objects are created for the class. One of the main objectives of...

5 minutes read.

How to improve programming skills in C++

Before getting started, one should know why to improve their programming skills. To become a good software developer or programmer, one must be skilled in at least one programming language. Many...

4 minutes read.

Scope Resolution Operator vs this Pointer in C++

In this tutorial, we will compare the Scope Resolution operation to this Pointer in C++ language. Scope Resolution Operator The Scope Resolution Operator in C++ programming language is usually denoted by (::)....

3 minutes read.

Passing a Vector to a function in C++

A pointer is sent to the function when we feed it an array. However, there are two ways to pass a vector: Pass by Value Pass by Reference A copy of a vector...

3 minutes read.

Reverse function in C++

The function std::reverse() is included in the standard template library of C++. It takes in a beginning and ending iterator, reversing the order. To use the reverse statement, we need...

2 minutes read.

Object Slicing in C++

In this article, we will learn about Object slicing. When an object from a derived class is assigned to an object from a base class in C++, these extra attributes...

3 minutes read.

Array program in C++

What is an Array? An array is a set of identically typed elements that are organized into contiguous memory locations and each element can be independently accessed using an index. We can...

16 minutes read.

C++ Virtual Destructor

In C++, a destructor is a class member function that is used to free up space or remove an object of the class that has gone out of scope. The...

4 minutes read.

Unary Operators in C++

Unary operators in C++ Unary operator: is operations that function to produce a new value on a single operand. a) unary minus: A minus operator modifies the argument's symbol. A positive number...

3 minutes read.

Binary to Decimal in C++

We must create a software to convert a binary number into an equivalent decimal value given a binary number as input. Example: // C++ program to convert binary to decimal #include < iostream...

3 minutes read.

Processing strings using std string stream in C++

A string class object called std: string stream is used to streamline into various variables, just as files can pour into strings. This class's things make use of a string...

3 minutes read.