Download as pdf or txt
Download as pdf or txt
You are on page 1of 53

A

MINI PROJECT

ON
HOSPITAL MANAGEMENT
Submitted
By
Pulkit Pujara
Roll Number-180879106041

(Bachelor of Computer Application)


6th SEM
Under the Guidance of

Dr.Himanshu Verma
ASST.PROF.

Hierank Business School


A-42,Institutonal Area,Sector-62,Noida
CANDIDATE’S DECLARATION

I hereby declare that the mini project work being presented in this
report entitled“HOSPITAL MANAGEMENT”submitted in the
department of computer science,It is the authentic work carried out
by me under the guidance of Dr.Himanshu Verma.

Date__/__/____ Pulkit Pujara


Roll Number-180879106041
Bachelor of Computer Application 6th sem

Hierank Business School


A-42,Institutonal Area,Sector-62,Noida
ACKNOWLEDGEMENT

I would like to express my special thanks of gratitude to my teacher


Dr.Himanshu Verma. who Gave me the golden opportunity to do this
wonderful project on the topic HOSPITAL MANAGEMENT,which also
helped me in doing a lot of Research and I came to know about so
many new things I am really thankful to them.

Secondly I would also like to thank my friends who helped me a lot in


finalizing this project within the limited time frame.
CONTENTS
1. Introduction
1.1 Purpose
1.2 Scope
1.3 Module Description
2. Overall Description
2.1 Goals of Proposed System
2.2 Background
2.3 Project Requirements
2.4 User Characteristics
2.5 Constraints
2.6 Definition of Problems
2.7 Alternative Solutions
3. Feasibility Study
3.1 Technical Feasibility
3.2 Economical Feasibility
3.3 Operational Feasibility
3.4 Schedule Feasibility
4. Use Case Diagram
5. Entity Relationship Diagram
6. Output
7. Source Code
8. Conclusion
1.Introduction

1.1) Purpose
 The Software is for the automation of Hospital Management.
 It maintains two levels of users:-
➢ Administrator Level
➢ User Level
 The Software includes:-
➢ Maintaining Patient details.
➢ Providing Prescription, Precautions and Diet advice.
➢ Providing and maintaining all kinds of tests for a patient.
➢ Billing and Report generation.

1.2) Scope

It can be used in any Hospital, Clinic, Dispensary or Pathology labs for maintaining
patient details and their test result.

1.3) Module Description


 Administration Module:-
 This is the main module in the proposed project.The administrator can read
and write information about any member such as patient,doctors and staff
of the hospital.They can also update,create and delete the record of
members as requirement and implementation plan.

 Patient Module :-

 This module contains the patient records.The sub modules are


➢ Inpatient :-

 It contains details of patients who are admitted.

➢ Outpatient:-

 The outpatient module contains details of the patient who came for
checkups.

➢ Lab Module:-
 Lab module is used to generate laboratory reports.

➢ Billing Module:-
 The bill payment report of the patient.
2. Overall Description

2.1) Goals of proposed system

1. Planned approach towards working: - The working in the organization will


be well planned and organized. The data will be stored properly in data stores,
which will help in retrieval of information as well as its storage.

2. Accuracy: - The level of accuracy in the proposed system will be higher. All
operation would be done correctly and it ensures that whatever information is
coming from the center is accurate.

3. Reliability: - The reliability of the proposed system will be high due to the
above stated reasons. The reason for the increased reliability of the system is that
now there would be proper storage of information.

4. No Redundancy: - In the proposed system utmost care would be that no


information is repeated anywhere, in storage or otherwise. This would assure
economic use of storage space and consistency in the data stored.

5. Immediate retrieval of information: - The main objective of proposed


system is to provide for a quick and efficient retrieval of information. Any type
of information would be available whenever the user requires.

6. Immediate storage of information: - In manual system there are many


problems to store the largest amount of information.

7. Easy to Operate: - The system should be easy to operate and should be such
that it can be developed within a short period of time and fit in the limited budget
of the user.
2.2) Background
A Hospital is a place where Patients come up for general diseases. Hospitals provide
facilities like:-
➢ Consultation by Doctors on Diseases.
➢ Diagnosis for diseases.
➢ Providing treatment facility.
➢ Facility for admitting Patients (providing beds, nursing, medicines etc.)
➢ Immunization for Patients/Children.

Various operational works that are done in a Hospital are:-


➢ Recording information about the Patients that come.
➢ Generating bills.
➢ Recording information related to diagnosis given to Patients.
➢ Keeping record of the Immunization provided to children/patients.
➢ Keeping information about various diseases and medicines available to cure
them.

These are the various jobs that need to be done in a Hospital by the operational staff and
Doctors. All these works are done on papers.

The work is done as follows:-

➢ Information about Patients is done by just writing the Patients name, age and
gender. Whenever the Patient comes up his information is stored freshly.
➢ Bills are generated by recording price for each facility provided to Patient on a
separate sheet and at last they all are summed up.
➢ Diagnosis information to patients is generally recorded on the document, which
contains Patient information. It is destroyed after some time period to decrease
the paper load in the office.
➢ Immunization records of children are maintained in pre-formatted sheets, which
are kept in a file.
➢ Information about various diseases is not kept as any document. Doctors
themselves do this job by remembering various medicines.

All this work is done manually by the receptionist and other operational staff and lot of
papers are needed to be handled and taken care of. Doctors have to remember various
medicines available for diagnosis and sometimes miss better alternatives as they can’t
remember them at that time.

2.3) Project Requirements

Hardware Requirements

Processor RAM Disk Space

Pentium II, Pentium III,


64 Mb or Higher 130 Mb
Pentium IV or higher

Software Requirements

Operating System Database

Win-98, Win-XP, Linux or any other


Ms Access
higher version

2.4) User Characteristics

Every user should be:

 Comfortable of working with computer.


 He must have knowledge in medical field.
 He must also have basic knowledge of English too.

2.5) Constraints

 Login and password is used for identification of user and there is no facility for
guest.
2.6) Definitions of problems

Problems with conventional system

1. Lack of immediate retrievals: -The information is very difficult to retrieve


and to find particular information like- E.g. - To find out about the patient’s
history, the user has to go through various registers. This results in inconvenience
and wastage of time.

2. Lack of immediate information storage: - The information generated by


various transactions takes time and efforts to be stored at right place.

3. Lack of prompt updating: - Various changes to information like patient


details or immunization details of child are difficult to make as paper work is
involved.

4. Error prone manual calculation: - Manual calculations are error prone and
take a lot of time this may result in incorrect information. For example
calculation of patient’s bill based on various treatments.

5. Preparation of accurate and prompt reports: - This becomes a difficult


task as information is difficult to collect from various registers.
2.7) Alternative Solutions

1. Improved Manual System:-

One of the alternative solutions is the improvement of the manual system.


Anything, which can be done by using automated methods, can be done
manually. But the question arises how to perform thing manually in a sound
manner. Following are some suggestions, which can be useful in the manual
system.

A more sophisticate register maintenance for various Patient Information, Doctor


diary, Immunization Details and a good system for writing bill amount
employees and stock availed for the customers can be maintained at central place.

Adequate staff may be maintained so that updations are made at the very moment
at the same time. Proper person for proper work should be made responsible so
that a better efficiency could be achieved. This needs a lot of work force.

2. Batch System:-

Another alternative solution can be used of computer based batch system for
maintaining the information regarding purchase details, customers and
employees. A batch system refers to a system in which data is processed in a
periodical basis.

The batch system is able to achieve most of the goals and sub goals. But a batch
system data is processed in sequential basis. Therefore batch system is not
suggested.

3. Online System:-

This system (HMS) provides online storage/ updations and retrieval facility. This
system promises very less or no paper work and also provides help to Doctor and
operational staff.

In this system everything is stored electronically so very less amount of paper


work is required and information can be retrieved very easily without searching
here and there into registers. This system is been discussed here.
3. Feasibility Study

Depending on the results of the initial investigation the survey is now expanded to a
more detailed feasibility study. “FEASIBILITY STUDY” is a test of system proposal
according to its workability, impact of the organization, ability to meet needs and
effective use of the resources. It focuses on these major questions:
1. What are the user’s demonstrable needs and how does a candidate system
meet them?
2. What resources are available for given candidate system?
3. What are the likely impacts of the candidate system on the organization?
4. Whether it is worth to solve the problem?

During feasibility analysis for this project, following primary areas of interest are to be
considered. Investigation and generating ideas about a new system does this.

Steps in feasibility analysis

Eight steps involved in the feasibility analysis are:

✓ Form a project team and appoint a project leader.


✓ Prepare system flowcharts.
✓ Enumerate potential proposed system.
✓ Define and identify characteristics of proposed system.
✓ Determine and evaluate performance and cost effective of each proposed system.
✓ Weight system performance and cost data.
✓ Select the best-proposed system.
✓ Prepare and report final project directive to management.
3.1) Technical feasibility

A study of resource availability that may affect the ability to achieve an acceptable
system. This evaluation determines whether the technology needed for the proposed
system is available or not.

3.2) Economical feasibility

Economic justification is generally the “Bottom Line” consideration for most systems.
Economic justification includes a broad range of concerns that includes cost benefit
analysis. In this we weight the cost and the benefits associated with the candidate
system and if it suits the basic purpose of the organization i.e. profit making, the project
is making to the analysis and design phase.

3.3) Operational Feasibility

 It is mainly related to human organizations and political aspects.

The system is operationally feasible as it very easy for the End users to operate it. It
only needs basic information about Windows platform.

3.4) Schedule feasibility

Time evaluation is the most important consideration in the development of project. The
time schedule required for the developed of this project is very important since more
development time effect machine time, cost and cause delay in the development of
other systems.

A reliable Hospital Management System can be developed in the considerable


amount of time.
4. Use Case Diagram
5. Entity Relationship Diagram
5.OUTPUT

 LOGIN:

 MAIN MENU:
 ADD PATIENTS RECORD:
 EDIT PATIENTS RECORD:
 SEARCH PATIENTS RECORD:
 DELETE PATIENTS RECORD:
 EXIT:
8. Conclusion

The project Hospital Management System (HMS) is for


computerizing the working in a hospital. The software takes
care of all the requirements of an average hospital and is
capable to provide easy and effective storage of information
related to patients that come up to the hospital.

The system also provides the facility of backup as per the


requirement.
8.SOURCE CODE

#include<stdio.h>
#include<windows.h>//gotoxy()
#include<conio.h>//Use for delay(),getch()etc.
#include<ctype.h>//use for toupper(), tolower(),etc.
#include<string.h>//Use for
strcmp(),strcpy(),strlen(),etc.
#include<stdlib.h>
char ans=0;
int ok;
int b, valid=0;
//FUNCTION DECLERATION
void WelcomeScreen(void);//WelcomeScreen function
decleration
void Title(void);//Title function decleration
void MainMenu(void);//MainMenu function
decleration
void LoginScreen(void);//LoginScreen function
decleration
void Add_rec(void);//Add_rec function declaration
void func_list();//function to list the patient details
void Search_rec(void);//Search_rec function
declaration
void Edit_rec(void);//Edit_rec function declaration
void Dlt_rec(void);//Dlt_rec function declaration
void ex_it(void);//exit function declaration
void gotoxy(short x, short y)
{
COORD pos = {x, y};//sets co-ordinates in (x,y).
SetConsoleCursorPosition(GetStdHandle(STD_OUT
PUT_HANDLE), pos);
}
//list of global variable

struct patient
{
int age;
char Gender;
char First_Name[20];
char Last_Name[20];
char Contact_no[15];
char Address[30];
char Email[30];
char Doctor[20];
char Problem[20];
};
struct patient p,temp_c;
main(void)
{
WelcomeScreen();//Use to call WelcomeScreen
function
Title();//Use to call Title function
LoginScreen();//Use to call Menu function
}
/* *************************************************
Welcome Screen
********************************************* */
void WelcomeScreen(void)//function for welcome
screen
{
printf("\n\n\n\n\n\n\n\t\t\t\t###############
##########################");
printf("\n\t\t\t\t#\t\t WELCOME TO\t\t#");
printf("\n\t\t\t\t# FORTIS HOSPITAL
MANAGEMENT SYSTEM #");
printf("\n\t\t\t\t###########################
##############");
printf("\n\n\n\n\n Press any key to
continue......\n");
getch();
system("cls");//Use to clear screen
}
/* ************************************************* Title
Screen ********************************************* */
void Title(void)//function for title screen
{
printf("\n\n\t\t-------------------------------------------
---------------------------------------");
printf("\n\t\t\t\t FORTIS HOSPITAL NOIDA
");
printf("\n\t\t----------------------------------------------
------------------------------------");
}
/* ************************************************* Main
Menu ********************************************* */
void MainMenu(void)//function decleration
{
system("cls");
int choose;
Title();// call Title function
printf("\n\n\n\n\n\t\t\t\t1. Add Patients
Record\n");
printf("\n\t\t\t\t2. List Patients Record\n");
printf("\n\t\t\t\t3. Search Patients Record\n");
printf("\n\t\t\t\t4. Edit Patients Record\n");
printf("\n\t\t\t\t5. Delete Patients Record\n");
printf("\n\t\t\t\t6. Exit\n");
printf("\n\n\n \n\t\t\t\tChoose from 1 to 6:");
scanf("%i", &choose);
switch(choose)//Add_rec function is called
{
case 1:
Add_rec();
break;
case 2:
func_list();
break;
case 3:
Search_rec();//View_rec function is call
break;
case 4:
Edit_rec();//Edit_rec function is call
break;
case 5:
Dlt_rec();//Dlt_rec function is call
break;
case 6:
ex_it();//ex_it function is call
break;
default:
printf("\t\t\tInvalid entry. Please enter right
option :)");
getch();
}
}
/* ************************************************* Exit
Screen ********************************************* */
void ex_it(void)//function to exit
{
system("cls");
Title();
printf("\n\n\n\n\n\t\t\tTHANK YOU FOR
VISITING :)");
getch();
}
/* ************************************************* Login
Screen ********************************************* */
void LoginScreen(void)//function for login screen
{
//list of variables
int e=0 ;
char Username[15];
char Password[15];
char original_Username[25]="pulkit";
char original_Password[15]="289";
do
{
printf("\n\n\n\n\t\t\t\tEnter your Username
and Password :)");
printf("\n\n\n\t\t\t\t\tUSERNAME:");
scanf("%s",&Username);
printf("\n\n\t\t\t\t\tPASSWORD:");
scanf("%s",&Password);
if (strcmp(Username,original_Username)==0 &&
strcmp(Password,original_Password)==0)
{
printf("\n\n\n\t\t\t\t\t...Login
Successfull...");
getch();
MainMenu();//call MainMenu function
break;
}
else
{
printf("\n\t\t\tPassword in incorrect:( Try
Again :)");
e++;
getch();
}
}while(e<=2);
if(e>2)
{
printf("You have cross the limit. You cannot
login. :( :(");
getch();
ex_it();
}
system("cls");
}
/* **************************************ADD
RECORD*******************************************/
void Add_rec(void)
{
system("cls");
Title();// call Title function
//list of variables
char ans;
FILE*ek;//file pointer
ek=fopen("Record2.dat","a");//open file in write
mode
printf("\n\n\t\t\t!!!!!!!!!!!!!! Add Patients
Record !!!!!!!!!!!!!\n");
/* **************************First
Name*********************************** */
A:
printf("\n\t\t\tFirst Name: ");
scanf("%s",p.First_Name);
p.First_Name[0]=toupper(p.First_Name[0]);
if(strlen(p.First_Name)>20||strlen(p.First_Name)<2)
{
printf("\n\t Invalid :( \t The max range for first
name is 20 and min range is 2 :)");
goto A;
}
else
{
for (b=0;b<strlen(p.First_Name);b++)
{
if (isalpha(p.First_Name[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("\n\t\t First name contain Invalid
character :( Enter again :)");
goto A;
}
}
/* ********************************************** Last
name ************************************************ */
B:
printf("\n\t\t\tLast Name: ");
scanf("%s",p.Last_Name);
p.Last_Name[0]=toupper(p.Last_Name[0]);
if(strlen(p.Last_Name)>20||strlen(p.Last_Name)<2)
{
printf("\n\t Invalid :( \t The max range for last
name is 20 and min range is 2 :)");
goto B;
}
else
{
for (b=0;b<strlen(p.Last_Name);b++)
{
if (isalpha(p.Last_Name[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("\n\t\t Last name contain Invalid
character :( Enter again :)");
goto B;
}
}
/* ******************************************* Gender
************************************************************
** */
do
{
printf("\n\t\t\tGender[F/M]: ");
scanf(" %c",&p.Gender);
if(toupper(p.Gender)=='M'||
toupper(p.Gender)=='F')
{
ok =1;
}
else
{
ok =0;
}
if(!ok)
{
printf("\n\t\t Gender contain Invalid
character :( Enter either F or M :)");
}
}while(!ok);
/* ***************************************** Age
************************************************************
********** */
printf("\n\t\t\tAge:");
scanf(" %i",&p.age);
/* **************************************** Address
************************************************************
******* */
do
{
C:
printf("\n\t\t\tAddress: ");
scanf("%s",p.Address);
p.Address[0]=toupper(p.Address[0]);
if(strlen(p.Address)>20||strlen(p.Address)<4)
{
printf("\n\t Invalid :( \t The max range for
address is 20 and min range is 4 :)");
goto C;
}
}while(!valid);
/* ******************************************* Contact
no. ***************************************** */
do
{
D:
printf("\n\t\t\tContact no: ");
scanf("%s",p.Contact_no);

if(strlen(p.Contact_no)>10||strlen(p.Contact_no)!=10)
{
printf("\n\t Sorry :( Invalid. Contact no.
must contain 10 numbers. Enter again :)");
goto D;
}
else
{
for (b=0;b<strlen(p.Contact_no);b++)
{
if (!isalpha(p.Contact_no[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("\n\t\t Contact no. contain
Invalid character :( Enter again :)");
goto D;
}
}
}while(!valid);
/* **************************************************
Email ******************************************** */
do
{
printf("\n\t\t\tEmail: ");
scanf("%s",p.Email);
if (strlen(p.Email)>30||strlen(p.Email)<8)
{
printf("\n\t Invalid :( \t The max range for
email is 30 and min range is 8 :)");
}
}while(strlen(p.Email)>30||strlen(p.Email)<8);
/*
*********************************************************
Problem *********************************************** */
E:
printf("\n\t\t\tProblem: ");
scanf("%s",p.Problem);
p.Problem[0]=toupper(p.Problem[0]);
if(strlen(p.Problem)>15||strlen(p.Problem)<3)
{
printf("\n\t Invalid :( \t The max range for first
name is 15 and min range is 3 :)");
goto E;
}
else
{
for (b=0;b<strlen(p.Problem);b++)
{
if (isalpha(p.Problem[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("\n\t\t Problem contain Invalid
character :( Enter again :)");
goto E;
}
}
/* **********************************************
Prescribed Doctor
**************************************** */
F:
printf("\n\t\t\tPrescribed Doctor:");
scanf("%s",p.Doctor);
p.Doctor[0]=toupper(p.Doctor[0]);
if(strlen(p.Doctor)>30||strlen(p.Doctor)<3)
{
printf("\n\t Invalid :( \t The max range for first
name is 30 and min range is 3 :)");
goto F;
}
else
{
for (b=0;b<strlen(p.Doctor);b++)
{
if (isalpha(p.Doctor[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("\n\t\t Doctor name contain Invalid
character :( Enter again :)");
goto F;
}
}
fprintf(ek," %s %s %c %i %s %s %s %s %s\n",
p.First_Name, p.Last_Name, p.Gender, p.age,
p.Address, p.Contact_no, p.Email, p.Problem,
p.Doctor);
printf("\n\n\t\t\t.... Information Record
Successful ...");
fclose(ek);//ek file is closed
sd:
getch();
printf("\n\n\t\t\tDo you want to add more[Y/N]??
");
scanf(" %c",&ans);
if (toupper(ans)=='Y')
{
Add_rec();
}
else if(toupper(ans)=='N')
{
printf("\n\t\t Thank you :) :)");
getch();
MainMenu();
}
else
{
printf("\n\t\tInvalid Input\n");
goto sd;
}
}
/* **************************************VIEW
RECORD*******************************************/
void func_list()
{
int row;
system("cls");
Title();
FILE *ek;
ek=fopen("Record2.dat","r");
printf("\n\n\t\t\t!!!!!!!!!!!!!! List Patients
Record !!!!!!!!!!!!!\n");
gotoxy(1,15);
printf("Full Name");
gotoxy(20,15);
printf("Gender");
gotoxy(32,15);
printf("Age");
gotoxy(37,15);
printf("Address");
gotoxy(49,15);
printf("Contact No.");
gotoxy(64,15);
printf("Email");
gotoxy(88,15);
printf("Problem");
gotoxy(98,15);
printf("Prescribed Doctor\n");

printf("====================================
============================================
=================================");
row=17;

while(fscanf(ek,"%s %s %c %i %s %s %s %s %s\n",
p.First_Name, p.Last_Name, &p.Gender, &p.age,
p.Address, p.Contact_no, p.Email, p.Problem,
p.Doctor)!=EOF)
{
gotoxy(1,row);
printf("%s %s",p.First_Name, p.Last_Name);
gotoxy(20,row);
printf("%c",p.Gender);
gotoxy(32,row);
printf("%i",p.age);
gotoxy(37,row);
printf("%s",p.Address);
gotoxy(49,row);
printf("%s",p.Contact_no);
gotoxy(64,row);
printf("%s",p.Email);
gotoxy(88,row);
printf("%s",p.Problem);
gotoxy(98,row);
printf("%s",p.Doctor);
row++;
}
fclose(ek);
getch();
MainMenu();
}
void Search_rec(void)
{
char name[20];
system("cls");
Title();// call Title function
FILE *ek;
ek=fopen("Record2.dat","r");
printf("\n\n\t\t\t!!!!!!!!!!!!!! Search Patients
Record !!!!!!!!!!!!!\n");
//gotoxy(12,8);
printf("\n Enter Patient Name to be viewed:");
scanf("%s",name);
fflush(stdin);
name[0]=toupper(name[0]);
while(fscanf(ek,"%s %s %c %i %s %s %s %s %s\n",
p.First_Name, p.Last_Name, &p.Gender, &p.age,
p.Address, p.Contact_no, p.Email, p.Problem,
p.Doctor)!=EOF)
{
if(strcmp(p.First_Name,name)==0)
{
gotoxy(1,15);
printf("Full Name");
gotoxy(25,15);
printf("Gender");
gotoxy(32,15);
printf("Age");
gotoxy(37,15);
printf("Address");
gotoxy(52,15);
printf("Contact No.");
gotoxy(64,15);
printf("Email");
gotoxy(80,15);
printf("Problem");
gotoxy(95,15);
printf("Prescribed Doctor\n");

printf("====================================
============================================
=================================");
gotoxy(1,18);
printf("%s %s",p.First_Name, p.Last_Name);
gotoxy(25,18);
printf("%c",p.Gender);
gotoxy(32,18);
printf("%i",p.age);
gotoxy(37,18);
printf("%s",p.Address);
gotoxy(52,18);
printf("%s",p.Contact_no);
gotoxy(64,18);
printf("%s",p.Email);
gotoxy(80,18);
printf("%s",p.Problem);
gotoxy(95,18);
printf("%s",p.Doctor);
printf("\n");
break;
}
}
if(strcmp(p.First_Name,name)!=0)
{
gotoxy(5,10);
printf("Record not found!");
getch();
}
fclose(ek);
L:
getch();
printf("\n\n\t\t\tDo you want to view
more[Y/N]??");
scanf("%c",&ans);
if (toupper(ans)=='Y')
{
Search_rec();
}
else if(toupper(ans)=='N')
{
printf("\n\t\t Thank you :) :)");
getch();
MainMenu();
}
else
{
printf("\n\tInvalid Input.\n");
goto L;
}
}
void Edit_rec(void)
{
FILE *ek, *ft;
int i,b, valid=0;
char ch;
char name[20];
system("cls");
Title();
ft=fopen("temp2.dat","w+");
ek=fopen("Record2.dat","r");
if(ek==NULL)
{
printf("\n\t Can not open file!! ");
getch();
MainMenu();
}
printf("\n\n\t\t\t!!!!!!!!!!!!!! Edit Patients
Record !!!!!!!!!!!!!\n");
gotoxy(12,13);
printf("Enter the First Name of the Patient : ");
scanf(" %s",name);
fflush(stdin);
name[0]=toupper(name[0]);
gotoxy(12,15);
if(ft==NULL)
{
printf("\n Can not open file");
getch();
MainMenu();
}
while(fscanf(ek,"%s %s %c %i %s %s %s %s %s\n",
p.First_Name, p.Last_Name, &p.Gender, &p.age,
p.Address, p.Contact_no, p.Email, p.Problem,
p.Doctor)!=EOF)
{
if(strcmp(p.First_Name, name)==0)
{
valid=1;
gotoxy(25,17);
printf("*** Existing Record ***");
gotoxy(10,19);
printf("%s \t%s \t%c \t%i \t%s \t%s \t%s
\t%s \t%s\n",p.First_Name,p.Last_Name,p.Gender,
p.age,p.Address,p.Contact_no,p.Email,p.Problem,p.Do
ctor);
gotoxy(12,22);
printf("Enter New First Name: ");
scanf("%s",p.First_Name);
gotoxy(12,24);
printf("Enter Last Name: ");
scanf("%s",p.Last_Name);
gotoxy(12,26);
printf("Enter Gender: ");
scanf(" %c",&p.Gender);
p.Gender=toupper(p.Gender);
gotoxy(12,28);
printf("Enter age: ");
scanf(" %i",&p.age);
gotoxy(12,30);
printf("Enter Address: ");
scanf("%s",p.Address);
p.Address[0]=toupper(p.Address[0]);
gotoxy(12,32);
printf("Enter Contact no: ");
scanf("%s",p.Contact_no);
gotoxy(12,34);
printf("Enter New email: ");
scanf("%s",p.Email);
gotoxy(12,36);
printf("Enter Problem: ");
scanf("%s",p.Problem);
p.Problem[0]=toupper(p.Problem[0]);
gotoxy(12,38);
printf("Enter Doctor: ");
scanf("%s",p.Doctor);
p.Doctor[0]=toupper(p.Doctor[0]);
printf("\nPress U charecter for the Updating
operation : ");
ch=getche();
if(ch=='u' || ch=='U')
{

fprintf(ft,"%s %s %c %i %s %s %s %s %s\n",p.First
_Name,p.Last_Name,p.Gender,
p.age,p.Address,p.Contact_no,p.Email,p.Problem,p.Do
ctor);
printf("\n\n\t\t\tPatient record updated
successfully...");
}
}
else
{
fprintf(ft,"%s %s %c %i %s %s %s %s %s\n",p.First
_Name,p.Last_Name,p.Gender,
p.age,p.Address,p.Contact_no,p.Email,p.Problem,p.Do
ctor);
}
}
if(!valid)
{
printf("\n\t\tNO RECORD FOUND...");
}
fclose(ft);
fclose(ek);
remove("Record2.dat");
rename("temp2.dat","Record2.dat");
getch();
MainMenu();
}
void Dlt_rec()
{
char name[20];
int found=0;
system("cls");
Title();// call Title function
FILE *ek, *ft;
ft=fopen("temp_file2.dat","w+");
ek=fopen("Record2.dat","r");
printf("\n\n\t\t\t!!!!!!!!!!!!!! Delete Patients
Record !!!!!!!!!!!!!\n");
gotoxy(12,8);
printf("\n Enter Patient Name to delete: ");
fflush(stdin);
gets(name);
name[0]=toupper(name[0]);
while (fscanf(ek,"%s %s %c %i %s %s %s %s %s",
p.First_Name, p.Last_Name, &p.Gender,&p.age,
p.Address, p.Contact_no, p.Email, p.Problem,
p.Doctor)!=EOF)
{
if (strcmp(p.First_Name,name)!=0)
fprintf(ft,"%s %s %c %i %s %s %s %s %s\n",
p.First_Name, p.Last_Name, p.Gender, p.age,
p.Address, p.Contact_no, p.Email, p.Problem,
p.Doctor);
else
{
printf("%s %s %c %i %s %s %s %s %s\n",
p.First_Name, p.Last_Name, p.Gender, p.age,
p.Address, p.Contact_no, p.Email, p.Problem,
p.Doctor);
found=1;
}
}//while loop ends
if(found==0)
{
printf("\n\n\t\t\t Record not found....");
getch();
MainMenu();
}
else
{
fclose(ek);
fclose(ft);
remove("Record2.dat");
rename("temp_file2.dat","Record2.dat");
printf("\n\n\t\t\t Record deleted successfully :)
");
getch();
MainMenu();
}

You might also like