C
C
PROJECT PREPARED BY: Ritvick Bargotra and Archit Garg XII-A Session: 2012-2013
TABLE OF CONTENTS
Acknowledgement Certificate Header files and their purpose Hardware and Software Requirements Files generated Working description of project Introduction Problem Definition Advantages Of The Proposed System Objectives Of The Proposed System Source code
ACKNOWLEDGEMENT
It would be my utmost pleasure to express my sincere thanks to My Computer Science Teacher Mrs. Annu Saini in providing a helping hand in this project. Her unflagging patience, creativity and immense knowledge that she shared with us have proved highly beneficial to us and have made our Project File both possible and successful.
CERTIFICATE
This is to certify that Archit Garg and Ritvick Bargotra of class XII has completed this project titled PATEINT MANAGEMENT SYSTEM under my guidance & this project may be considered as the part of the practical exam of AISSCE conducted by CBSE.
FILES GENERATED
WORKING DESCRIPTION OF
PROJECT
This program is designed to keep the records of patients This program consists of six options as follows
1. TO ADD 2. TO DISPLAY FILE 3. TO SEARCH 4. TO MODIFY 5. TO DELETE 6. TO EXIT 7. TO CREATE FILE 8. TO SORT 9. TO COUNT
INTRODUCTION
Theres a reason why we use technology, theres a reason why we need it. Computers are not just a proof of our high intellectual acumen or our ability to evolve at a rapid pace; but they are a helping hand that enables technology to make our lives easier Technology thus aids us in many ways: One of which has been to replace the strenuous and taxing tasks of collection of large set of data in manual handscripts, or through writing. C++ is very useful tool that enables us to store data and maintain it for as long as we wish to keep it without causing damage to the data. The project that is being presented is made to store the data of n number of patients using the concept of Classes and Objects and Data File Handling. Data File Handling has been chosen as the Data Files are capable of storing a given set of data permanently, and in this project extensive use of Binary Files would be easily visible. Through this project, we intend to simplify and introduce ease, to outdo the problems of searching, modifying, deleting, adding as well sorting the details and
information of the patients, thus making it easier and much less complicated for the user to store his/her data and keep track of it. In the development of the project, selection of an appropriate programming language and a platform is of primary importance. The major part of the credit goes to the software environment chosen by the developer. Selection of a language from the ocean of languages is very difficult, a developer has to consider various features and functionalities that a particular language can provide. In this project C++ language is used to maintain all the data. It provides many features like file handling ,data can be easily maintained and many features that are required while doing a project.
PROBLEM DEFINITION
The project is developed for Hospitals and Clinics, which aims to automate its various tasks. All the work of various tasks was earlier carried out manually. However in the due course of time it was realized that manual work is error prone and time consuming. Automation provides quick & easy step by step approach to handle tasks like adding items to the menu, deleting items, modifying the details of items and calculating bills. Thus automation is no longer an option, its a requirement.
SOURCE CODE
/*------------------------------------------------------------------------12TH CLASS PROJECT OF C++ PROGRAM TO STORE THE DATA OF THE PATIENTS ADMITTED IN A HOSPITAL USING CLASSES AND OBJECTS AND THE CONCEPT OF DATA FILE HANDLING IN THE PROJECT --------------------------------------------------------------------------*/
#include<fstream.h> #include<conio.h> #include<string.h> #include<stdio.h> #include<iomanip.h> int a,b,n,r,p,count=0; char x,d; class patient //global class created,which is accessible anywhere in the program { long int phoneno; unsigned long patientno; char date[20]; float age,temp,pulse; char bloodp[10]; //In majority of functions Patient Number
//represented by 'patientno' is used for //searching,modifying,deleting or sorting //the data of any patient, It is a unique value
char name[20], sex[10], address[100], email[30], bloodgr[10]; char addictions[100], complaints[100], duration[20]; char respiratoryrate[20], symptoms[200]; public : void getdata(){ cout<<"\n\n\nEnter the data of the Patient:\n\n"; cout<<"\tPatient Number: "; cin>>patientno; cout<<"\n\n\tName of the Patient: "; gets(name); cout<<"\n\n\tAge: "; cin>>age; cout<<"\n\n\tSex: "; cin>>sex; cout<<"\n\n\tPhone Number: "; cin>>phoneno; cout<<"\n\n\tDate of admission: "; gets(date); cout<<"\n\n\tAddress: "; gets(address); cout<<"\n\n\tE-mail ID: "; gets(email); cout<<"\n\n\tTemperature: "; cin>>temp;
cout<<"\n\n\tPulse Rate: "; cin>>pulse; cout<<"\n\n\tBlood Pressure: "; gets(bloodp); cout<<"\n\n\tBlood Group: "; gets(bloodgr); cout<<"\n\n\tRespiratory Rate: "; gets(respiratoryrate); cout<<"\n\n\tAddictions of the Patient: "; gets(addictions); cout<<"\n\n\tSymptoms of Disease/Uneasiness: "; gets(symptoms); cout<<"\n\n\tComplaints of the Patient: "; gets(complaints); cout<<"\n\n\tDuration of the stay: "; gets(duration); } void putdata() { cout<<"\n\nDetails of the Patient:\n";
cout<<"\t\nPatient Number: "; cout<<patientno; cout<<"\n\n\tName of the Patient: "; puts(name); cout<<"\n\n\tAge: ";
cout<<age; cout<<"\n\n\tSex: "; cout<<sex; cout<<"\n\n\tPhone Number: "; cout<<phoneno; cout<<"\n\n\tDate of admission: "; puts(date); cout<<"\n\n\tAddress: "; puts(address); cout<<"\n\n\tE-mail ID: "; puts(email); cout<<"\n\n\tTemperature: "; cout<<temp; cout<<"\n\n\tPulse Rate: "; cout<<pulse; cout<<"\n\n\tBlood Pressure: "; puts(bloodp); cout<<"\n\n\tBlood Group: "; puts(bloodgr); cout<<"\n\n\tRespiratory Rate: "; puts(respiratoryrate); cout<<"\n\n\tAddictions of the Patient: "; puts(addictions); cout<<"\n\n\tSymptoms of Disease/Uneasiness: ";
puts(symptoms); cout<<"\n\n\tComplaints of the Patient: "; puts(complaints); cout<<"\n\n\tDuration of the stay: "; puts(duration); } char * retename() { return(name);} int retpatientno() {return (patientno);} }pt,pt2,pt3; //a user defined variable "patient" is //assigned to pt,pt2 & pt3 objects void modify(void); void menu(void); void pat(void); void addfile(void); void search(void); void deletefile(void); void sort(void); void donothing(void); void displayfile(void); void createfile(void); int countrecord(void); void deleterecord(void);
cout<<"\n\n\n\t\t\tMODIFY\n\n"; int pno,pos; cout<<"\n Modify your data:\n Enter the Patient Number: "; cin>>pno; fstream f4("pat.dat", ios::binary|ios::in|ios::out); while(!f4.eof()) { pos=f4.tellg(); f4.read((char*)&pt,sizeof(pt)); if(pno==pt.retpatientno()) { pt.putdata(); pt2.getdata(); f4.seekg(pos); f4.write((char*)&pt2,sizeof(pt2)); break; }
} pos=sizeof(pt); f4.close(); }
cout<<"Patient Number\n"<<"Phone Number\n"<<"date\n"<<"age\n"<<"temperature\n"<<"pulse rate\n"<<"bloodp\n"<<"name\n"<<"sex\n"<<"address\n"<<"email\n"<<"blood group\n"<<"addictions\n"<<"complains\n"<<"duration\n"<<"respiratoryrate\n"<<"symptom s\n"; cout<<"How many entries do you want to make?"; cin>>r; fstream f2("pat.dat",ios::binary|ios::app); for(int i=0;i<r;i++) { pt.getdata(); f2.write((char*)&pt,sizeof(pt)); cout<<"Recorded!! Welcome Patient!"; } f2.close();
void search() {
clrscr(); char name[20],flag=0; int r,ptno; cout<<"\n\n\t\tSEARCH\n"; cout<<"\n1.Search by Patient Number\n\n2.Search by Patient Name\n\nPlease enter your choice: "; cin>>r; if(r==1) { cout<<"\n\nEnter the Patient Number: "; cin>>ptno; fstream f3("pat.dat",ios::binary|ios::in); while(f3.read((char*)&pt,sizeof(pt))) { if(pt.retpatientno()==ptno) { pt.putdata(); flag=1; } } if(!flag) f3.close(); } if(r==2) { cout<<"\n\nEnter the Patient Name: "; gets(name); fstream f3("pat.dat",ios::binary|ios::in);
//Menu Function created to provide user with options //for the actions to be performed //It is the first function encountered by the user
char ch; cout<<"\n\t\t PATIENT MANAGEMENT SYSTEM CENTRAL \n\n"; cout<<"\t\t\tMENU CENTRAL\n\n"; do { clrscr(); //do while loop is used and it will //continue as long as the user wants
cout<<"\n\tWhat do you want to do?\n\n"; cout<<"\tMenu Table\n\n"; cout<<"\t1.Enter Data To Initiate Interaction With Program\n\n"<<"\t2.Add External Data\n\n"<<"\t3.Modify Data\n\n"<<"\t4.Search Data\n\n"<<"\t5.Display Data\n\n"<<"\t6.Exit Program\n\n"<<"\t7.Sort\n\n"<<"\t8.Delete The Record";
cout<< "\n\n\tPlease Enter your choice: "; cin>>n; switch(n) { case 1:pat();break; case 2:addfile();break; case 3:modify();break; case 4:search();break; case 5:displayfile();break; case 6:donothing();break; case 7:sort();break; case 8:deleterecord();break; default:cout<<"\n\tInvalid entry!! Try again please\n";break; } cout<<"\n\n\tDo you want to continue?(y/n): "; cin>>ch; }while(ch=='y' || ch=='Y'); }
void sort() //function to Sort Data-Files entered by the User { clrscr(); int i,j,x,min; patient temp, patn[20]; p=countrecord();
cout<<"\t\t\tSORTING\n"; fstream f11("pat.dat",ios::binary|ios::in|ios::out); fstream f12("temp.dat",ios::binary|ios::in|ios::out); while(!f11.eof()) { for(i=0;i<p;i++) { } for(i=0;i<p;i++) { min=i; for(int j=(i+1);j<p;j++) { f11.read((char*)&patn[i],sizeof(patn[i]));
f12.close(); remove("pat.dat"); rename("temp.dat","pat.dat"); cout<<"Data sorted in increasing order.Use Display to confirm Sorting\n";
void pat() //Function "pat" is actually the main function to create a data-file first { //into the program.Data-Files can be created unlimited times as long as the //user wishes to continue, with the help of the do-while loop used in this function clrscr(); cout<<"\n\n\t\t\tPATIENT RECORD MANAGEMENT"; cout<<"\n\n\tWELCOME PATIENT! PLEASE FILL UP YOUR DETAILS\n\n"; cout<<"\tPlease enter the following:\n\n"; fstream f1("pat.dat",ios::binary|ios::app); do { pt.getdata(); f1.write((char*)&pt,sizeof(pt)); cout<<"\tRecorded!! Welcome Patient"; cout<<"\n\tDo you want to add more data?(y/n)\n"; cin>>x;
} while(x=='y'||x=='Y'); f1.close();
menu();
void displayfile() //Function created to display files for the user { clrscr(); fstream f7("pat.dat",ios::binary|ios::in); while(f7.read((char*)&pt,sizeof(pt))) { pt.putdata(); getch(); } f7.close(); }
void donothing() //Function created so that user can exit from the program {}
int countrecord() //Function to count and store the number of records entered in the program { fstream f14("pat.dat",ios::binary|ios::in); while(f14.read((char*)&pt,sizeof(pt))) {
void deleterecord() //Function to delete the data-files { clrscr(); int no,i,pos,found=0; char ch; cout<<"\n\n\t\t\tDELETE\n\n"; fstream f1("pat.dat",ios::binary|ios::in|ios::out); fstream f2("temp.dat",ios::binary |ios::out); cout<<"\nEnter the Patient Number of whose details you want to delete: "; cin>>no; i=0; while(f1.read((char*)&pt,sizeof(pt))) { if (pt.retpatientno()==no) { pos=i; found=1; pt.putdata();
break; } ++i; } if (!found) { cout<<"\n\nINVALID ENTRY!! NO RECORD FOUND!! "; return; } cout<<"\n\nAre you SURE you want to DELETE this record? "; cin>>ch; if ((ch=='y')||(ch=='Y')); else return; f1.seekg(ios::beg); i=0; while(f1.read((char*)&pt,sizeof(pt))) { if (i==pos); else f2.write((char*)&pt,sizeof(pt)); ++i; } f1.close();
f2.close(); remove("pat.dat"); rename("temp.dat","pat.dat"); cout<<"\n\nYour entered record has been deleted! Use Search to confirm deletion\n\n";
OUTPUT
What do you want to do?
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
Patient Number: 1
Age: 17
Sex: m
Address: c-23/45,Sector-9,Delhi
Temperature: 98
Pulse Rate: 72
Blood Group: b+
Respiratory Rate: 45
Welcome Patient!
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
Patient Number: 23
Age: 17
Sex: m
Temperature: 98
Pulse Rate: 77
Respiratory Rate: 45
Welcome Patient!
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
Patient Number: 2
Age: 17
Sex: m
Address: b-8/12,Sector-24,Delhi
Temperature: 102
Pulse Rate: 75
Blood Group: o+
Respiratory Rate: 45
Welcome Patient!
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
Patient Number: 15
Age: 17
Sex: m
Temperature: 100
Pulse Rate: 70
Blood Group: b+
Respiratory Rate: 50
Welcome Patient!
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
Patient Number Patient Name Age Sex Phone Number Date of Admission Address E-mail ID Temperature Pulse Rate Blood Pressure Blood Group Respiratory Rate Addictions of the patient Symptoms of disease/uneasiness Complaints of the patient Duration of the stay
Patient Number: 27
Age: 17
Sex: m
Temperature: 100
Pulse Rate: 72
Respiratory Rate: 46
Welcome Patient!
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
MODIFY
Patient Number: 1
Age: 17
Sex: m
Address: c-23/45,Sector-9,Delhi
Temperature: 98
Pulse Rate: 72
Blood Group: b+
Respiratory Rate: 45
Patient Number: 3
Age: 17
Sex: m
Address: c-23/45,Sector-9,Delhi
Temperature: 98
Pulse Rate: 72
Blood Group: b+
Respiratory Rate: 45
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
SEARCH
Patient Number: 3
Age: 17
Sex: m
Address: c-23/45,Sector-9,Delhi
Temperature: 98
Pulse Rate: 72
Blood Group: b+
Respiratory Rate: 45
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
SEARCH
Patient Number: 15
Age: 17
Sex: m
Temperature: 100
Pulse Rate: 70
Blood Group: b+
Respiratory Rate: 50
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
Patient Number: 3
Age: 17
Sex: m
Address: c-23/45,Sector-9,Delhi
Temperature: 98
Pulse Rate: 72
Blood Group: b+
Respiratory Rate: 45
Patient Number: 23
Age: 17
Sex: m
Temperature: 98
Pulse Rate: 77
Respiratory Rate: 45
Patient Number: 2
Age: 17
Sex: m
Address: b-8/12,Sector-24,Delhi
Temperature: 102
Pulse Rate: 75
Blood Group: o+
Respiratory Rate: 45
Patient Number: 15
Age: 17
Sex: m
Temperature: 100
Pulse Rate: 70
Blood Group: b+
Respiratory Rate: 50
Patient Number: 27
Age: 17
Sex: m
Temperature: 100
Pulse Rate: 72
Respiratory Rate: 46
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
Patient Number: 2
Age: 17
Sex: m
Address: b-8/12,Sector-24,Delhi
Temperature: 102
Pulse Rate: 75
Blood Group: o+
Respiratory Rate: 45
Patient Number: 3
Age: 17
Sex: m
Address: c-23/45,Sector-9,Delhi
Temperature: 98
Pulse Rate: 72
Blood Group: b+
Respiratory Rate: 45
Patient Number: 15
Age: 17
Sex: m
Temperature: 100
Pulse Rate: 70
Blood Group: b+
Respiratory Rate: 50
Patient Number: 23
Age: 17
Sex: m
Temperature: 98
Pulse Rate: 77
Respiratory Rate: 45
Patient Number: 27
Age: 17
Sex: m
Temperature: 100
Pulse Rate: 72
Respiratory Rate: 46
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
DELETE
Patient Number: 23
Age: 17
Sex: m
Temperature: 98
Pulse Rate: 77
Respiratory Rate: 45
Your entered record has been deleted! Use Search to confirm deletion.
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort
SEARCH
Menu
3.Modify Data
4.Search Data
5.Display Data
6.Exit
7.Sort