Simple a Clinic Management System using C++

Simple Clinic Management System using C++ (With Source Code)

Simple a Clinic Management System using C++ (With Source Code)

Hello, coders. Welcome to the codewithrandom blog. In this article, we will learn how to create a Simple Clinic Management System using C++ (With Source Code). It is a simple to use console application which is easy to create and understand by the users.

A  Simple Clinic management has been created based on the idea of documenting the patient’s information. It is primarily intended to assist clinics, hospitals, and private practices in managing patient data, appointments, prescriptions, billing, and other administrative activities.

Simple a Clinic Management System using C++

Simple Clinic management systems can assist healthcare practitioners enhance patient care by streamlining their process, reducing paperwork, and streamlining their workflow. They can also assist with billing and invoicing, managing insurance claims, and financial reporting.

Base Convertor project using C++ (With source code)

What does a Simple Clinic Management system do?

This project allows users to collect patient information. The user may add patient records, medicines, see patient history, remove or amend patient data.  This project does not have a login mechanism. This project will retain the patient’s record. The entire project is written in the C++ programming language. The project just maintains track of the patient’s personal information and medicines.

Overview of the UI:

  • 1 Add New Patient Record
  • 2 Add Patient prescription
  • 3 Full History of the Patient
  • 4 delete Patient Record
  • 5 update Patient Record

The user will choose option 1 to add a new patient record into the clinic management system and then can further go on to choose the other options to perform the given operations in the system. Each of the given options will display their functionalities upon choosing them.

Simple a Clinic Management System Source code:

The entire system is written in C++. You can directly use this code by copying it in your IDE to understand the working and then can create it by understanding the project.

#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
struct node
{
    char fname[20];
    char sname[20];
    char address[200];
    char contact[10];
    char cnic[100];
    int age;
    char gender[8];
    char blood_gp[5];
    char disease_past[50];
    int id;
    char symptom[500];
    char diagnosis[500];
    char medicine[500];
    char addmission[30];
    struct node *next;
    bool diagnose;
};
struct node *head,*lastptr;
bool check=true;
int arr[20]={0},i=0;
bool check_id(int ch)
{
  	    for(int a=0;a<i;a++)
  	    {
  	    	if(ch==arr[a])
  	    	{
  	    		return true;
            }
        }
        return false;
};
class doctor
{
    public:
      void add()
      {
      	
      	node *p;
      	p=new node;
      	p->diagnose=false;	
      	cout<<"enter Patient ID"<<endl;
      	cin>>p->id;
      	cout<<"enter Patient First name"<<endl;
      	cin>>p->fname;
      	cout<<"enter Patient Last name"<<endl;
      	cin>>p->sname;
      	cout<<"enter Patient Age"<<endl;
      	cin>>p->age;
      	cout<<"enter Patient Gender"<<endl;
      	cin>>p->gender;
      	cout<<"enter Patient Blood Group"<<endl;
      	cin>>p->blood_gp;
      	cout<<"enter Patient Contact "<<endl;
      	cin>>p->contact;
      	fflush(stdin);
      	cout<<"enter Patient CNIC"<<endl;
      	cin.getline(p->cnic,100);
      	fflush(stdin);
      	cout<<"enter Patient Address"<<endl;
      	cin.getline(p->address,1000);
       
      	p->next=NULL;
      	arr[i]=p->id;
      	
      	i++;
      	if(check)
    {
        head=p;
        lastptr=p;
        check=false;
    }
    else
    {
        lastptr->next=p;
        lastptr=p;
    }
    
  }
  void show()
  {
  	    int n;
  	    node *current=NULL,*prev=NULL;
  	    prev=head;
  	    current=head;
  	    int ch;
 	    cout<<"enter Patient ID"<<endl;
  	    cin>>ch;
        if(check_id(ch))
        {
  	    while(current->id!=ch)
  	    {
  	    	prev=current;
  	    	current=current->next;
  	   	  }
  	   	
  	 	cout<<"enter Patient First name"<<endl;
      	cout<<current->fname<<endl;
      	cout<<"enter Patient Last name"<<endl;
      	cout<<current->sname<<endl;
      	cout<<"enter Patient ID"<<endl;
      	cout<<current->id<<endl;
      	cout<<"enter Patient Age"<<endl;
      	cout<<current->age<<endl;
      	cout<<"enter Patient Gender"<<endl;
      	cout<<current->gender<<endl;
      	cout<<"enter Patient Blood Group"<<endl;
      	cout<<current->blood_gp<<endl;
      	cout<<"enter Patient Contact "<<endl;
      	cout<<current->contact<<endl;
      	cout<<"CNIC number"<<endl;
      	cout<<current->cnic<<endl;
      	cout<<"enter Patient Address"<<endl;
        cout<<current->address<<endl;
        cout<<"*********************************"<<endl;
        if(current->diagnose){
        cout<<"Enter Symptoms"<<endl;
        cout<<current->symptom<<endl;
        cout<<"Enter Diagnosis"<<endl;
        cout<<current->diagnosis<<endl;
        cout<<"Enter Medicines"<<endl;
        cout<<current->medicine<<endl;
        cout<<"Admit Required to Hospital?"<<endl;
        cout<<current->addmission<<endl;
       }}
       else
       {
       	cout<<"ID not present"<<endl;
       }
}
  void diagnosis()
  {
  	int n;
    node *p=NULL,*prev=NULL;
    p=new node;
  	prev=head;
    p=head;
  	int ch;
  	cout<<"enter Patient ID"<<endl;
  	cin>>ch;
    if(check_id(ch)){
        while(p->id!=ch )
      	{
      		prev=p;
      		p=p->next;
        }
        p->diagnose=true;
        cout<<"Enter Symptoms"<<endl;
        cin>>p->symptom;
        cout<<"Enter Diagnosis"<<endl;
        cin>>p->diagnosis;
        cout<<"Enter Medicines"<<endl;
        cin>>p->medicine;
        cout<<"Admit Required to Hospital?"<<endl;
        cin>>p->addmission;
        
    }
  	
    else
        cout<<"ID is not Registered\n";
  	
    }
void deleteList()
{
    int counter=0;
    node *current=NULL,*prev=NULL;
  	    //current =new node;
  	prev=head;
  	current=head;
  	int ch;
    cout<<"Enter the ID: ";
    cin>>ch;
    if(check_id(ch)){
//	temp=head;
        while(current->id!=ch)
  	    {
  	    	prev=current;
  	    	current=current->next;
  		}
  		prev->next=current->next;
  		free(current);
  		
//  	while(head != NULL)
//    {
//        temp = head;
//        head = head->next;
//
//        free(temp);
//    }
      for(int a=0;a<i;a++)
      {
      	if(arr[a]==ch){
      		for (int j=a;j<i;j++){
      			arr[j]=arr[j+1];
              }
              i--;
          }
      }
    cout<<"SUCCESSFULLY DELETED ALL NODES OF LINKED LIST\n";
    }
    else
       cout<<"ID not present"<<endl;
}
void update_menu()
{
        cout<<"enter 1 Patient First name"<<endl;
      	cout<<"enter 2 Patient Last name"<<endl;
      	cout<<"enter 3 Patient ID"<<endl;
      	cout<<"enter 4 Patient Age"<<endl;
      	cout<<"enter 5 Patient Gender"<<endl;
      	cout<<"enter 6 Patient Blood Group"<<endl;
      	cout<<"enter 7 Patient Contact "<<endl;
      	cout<<"enter 8 patient CNIC"<<endl;
      	cout<<"enter 9 Patient Address"<<endl;
        cout<<"*********************************"<<endl;
        cout<<"Enter 10 Symptoms"<<endl;
        cout<<"Enter 11 Diagnosis"<<endl;
        cout<<"Enter 12 Medicines"<<endl;
        cout<<"Admit 13 Required to Hospital?"<<endl;
}
void update_data(){
    node *current=NULL,*prev=NULL;
    current=head;
    prev=head;
    int id,ch;
    cout<<"enter ID"<<endl;
    cin>>id;
    if(check_id(id)){
        while(current->id!=id)
  	    {
  	    	prev=current;
  	    	current=current->next;
  		}
  		update_menu();
  		cout<<"chose number"<<endl;
  		cin>>ch;
  		if(ch==1){
  			cout<<"enter first name"<<endl;
  			cin>>current->fname;
          }
        else if(ch==2){
            cout<<"enter second name"<<endl;
            cin>>current->sname;
        }
        else if(ch==3){
            cout<<"enter ID"<<endl;
            cin>>current->id;
        }
  		else if(ch==4){
  			cout<<"enter age"<<endl;
  			cin>>current->age;
          }
        else if(ch==5){
            cout<<"enter gender"<<endl;
            cin>>current->gender;
        }
        else if(ch==6){
            cout<<"enter blood group"<<endl;
            cin>>current->blood_gp;
        }
        else if(ch==7){
            cout<<"enter contact"<<endl;
            cin>>current->contact;
        }
        else if(ch==8){
            cout<<"enter CNIC"<<endl;
            cin>>current->cnic;
        }
        else if(ch==9){
            cout<<"enter address"<<endl;
            cin>>current->address;
        }
        else if(ch==10){
            cout<<"Enter 10 Symptoms"<<endl;
            cin>>current->symptom;
        }
        else if(ch==11){
        cout<<"Enter 11 Diagnosis"<<endl;
        cin>>current->diagnosis;
        }
        else if(ch==12){
        cout<<"Enter 12 Medicines"<<endl;
        cin>>current->medicine;
        }
        else if(ch==13){
        cout<<"Admit 13 Required to Hospital?"<<endl;
        cin>>current->addmission;
    }
   }
   else
     cout<<"ID not present"<<endl;
}
};

void dis()
{
    cout<<"1 Add New Patient Record "<<endl;
    cout<<"2 Add Patient prescription "<<endl;
    cout<<"3 Full History of the Patient"<<endl;
    cout<<"4 delete Patient Record"<<endl;
    cout<<"5 update Patient Record"<<endl;
}
void menu()
{
    cout<<"press 1 to doctor menu"<<endl;
    cout<<"press 2 to patients menu"<<endl;
    cout<<"press 3 to pharmacist menu"<<endl;
}
int main()
{
    struct node* head=NULL;
    doctor u;
    int i=0;
    do{
    dis();
    cin>>i;
    if(i==1)
    u.add();
    else if(i==2)
    u.diagnosis();
    else if(i==3)
    u.show();
    else if(i==4)
    u.deleteList();
    else if(i==5)
    u.update_data();
    }while(1);
    return 0;
}

Now let us understand the code:-

  • We will start by writing the header of the code with the required libraries – iostream for input/output operations, ctime for accessing the system clock, and cstdlib for generating random numbers.
  • Now we will declare a struct node which will define the attributes for the patient record : fname (first name), sname (last name), address, contact, cnic (CNIC number of the patient), age, gender,
    blood_gp, disease_past, id(unique for patients), symptom, diagnosis, medicine, addmission, next (pointer for the next node in the linked list), diagnose (boolean variable to tell whether the patient has been diagnosed yet).
  • After the variable declaration we will define a function called check_id(int ch), it will check whether the ID number already exists in the linked list and returns a boolean value.
  • We will create a class called doctor which with member functions to perform operations on the linked list. It will have the following functions – add(), show(), diagnosis(), deleteList(), update_menu(), update_data().
  • The add() function will allow doctor to add a new patient to the list by reading/inputting their information in.
  • The show() function will display the information of a particular patient based on their unique ID.
  • The diagnosis() function will allow the doctor to diagnose a patient by filling in their symptoms, diagnosis, and prescribed medicine, admission status.
  • The deleteList() function will delete a patient record from the list based on their ID by deleting the node with that ID number from the linked list. If the ID number is not found, it will return an error message.
  • The update_menu() function will display a menu of data which the doctor can update.
  • The update_data() function will allow the doctor to update the specified fields of a particular patient and store, update that data in the list.
  • Now we will define the functions outside the doctor class.
  • The dis() function displays the list of operations a user can perform in the system. Before proceeding on to any other option, user will choose 1st option to add new patient record.
  • The menu() function will display options to go to different menus – doctor menu, patients menu, pharmacist menu.
  • The main() function will have the function calls within a do-while loop. The respective function will be called when a user chooses an option from the given operations to perform in the system.
  • This sums up our project of Clinic Management System using C++.

Bakery Management System using C++ (With Source Code)

Final Output:-

Here is an example to show how this project works 

Simple a Clinic Management System using C++

Choosing option 1

Simple a Clinic Management System using C++

Choosing option 2:Add patient prescription 

Simple a Clinic Management System using C++

Choosing option 3 : Full History of the patient

Simple a Clinic Management System using C++

Conclusion

We have reached the end of this article and have a lot more projects in C++ coming so stay tuned. We have started with awesome and fun projects for you all to understand C++. Learning C++ by creating fun projects makes learning easy and interesting.

If you enjoyed the article and learned something new today, let us know in the comments.

Thank you.

Happy Reading! 🙂

Follow : CodewithRandom



Leave a Reply