____________________START_______________________________
#include
#include
#include
#include
#include
#include
char ans=0;
int ok;
int b, valid=0;
void First_Screen(void);
void Title_Screen(void);
void Menu_option(void);
void Login_option(void);
void Add_patient(void);
void patient_list();
void Patient_Search(void);
void Patient_Edit(void);
void Patient_Delate(void);
void Closed(void);
// gotoxy is a function for write anywhere of screen
void gotoxy(short x, short y)
{
COORD position = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), position);
}
// struct patient for this variable need more time
struct patient
{
int age;
char Gender;
char FirstNam[20];
char LastNam[20];
char PhoneNumber[15];
char HomeAddress[30];
char Email[30];
char Doctor[20];
char Problem[20];
};
struct patient p,temp_c;
main(void)
{
First_Screen();
Title_Screen();
Login_option();
}
//First screen
void First_Screen(void)
{
printf("");
printf(" WELCOME TO");
printf("Basundhora HOSPITAL MANAGEMENT SYSTEM");
printf("");
printf("Press Enter any Key for Continue....");
getch();
system("cls");
}
//Title
void Title_Screen(void)
{
printf("");
printf("Basundhora HOSPITAL System");
printf("");
}
//Main menu
void Menu_option(void)
{
system("cls"); // For New screen
int choose;
Title_Screen(); //call fun
printf("1. Add Patients Record");
printf("2. List Of Patients Record");
printf("3. Finding Of Patients Record");
printf("4. Change Of Patients Record");
printf("5. Remove Of Patients Record");
printf("6. Exit");
printf(" Choose Number from 1 to 6 :");
scanf("%i", &choose);
switch(choose)
{
case 1:
Add_patient(); //call fun
break;
case 2:
patient_list(); //call fun
break;
case 3:
Patient_Search(); //call fun
break;
case 4:
Patient_Edit(); //call fun
break;
case 5:
Patient_Delate(); //call fun
break;
case 6:
Closed(); //call fun
break;
default:
printf("Please enter valid Key");
getch();
}
}
void Closed(void)
{
system("cls");
Title_Screen();
printf("THANKS FOR VISI Of Bashundhora System");
getch();
}
void Login_option(void)
{
int e=0 ;
char Username[15];
char Password[15];
char original_Username[25]="suvo";
char original_Password[15]="1234";
do
{
printf("Enter your User name and Password ");
printf("USERNAME:");
scanf("%s",&Username);
printf("PASSWORD:");
scanf("%s",&Password);
if (strcmp(Username,original_Username)==0 && strcmp(Password,original_Password)==0)
{
printf("Your Login is Successfull...");
getch();
Menu_option();
break;
}
else
{
printf("Sorry your Password Incorrect Please Try Again");
e++;
getch();
}
}while(e<=2);
if(e>2)
{
printf("You have Tried Many Time. So, You cannot login.");
getch();
Closed();
}
system("cls");
}
void Add_patient(void)
{
system("cls");
Title_Screen();
char ans;
FILE*ek;
ek=fopen("Record2.dat","a");
printf("Add Patients Record ");
A:
printf("First Name: ");
scanf("%s",p.FirstNam);
p.FirstNam[0]=toupper(p.FirstNam[0]);
if(strlen(p.FirstNam)>20||strlen(p.FirstNam)<2)
{
printf("Invalid. The Character is too much short or long");
goto A;
}
else
{
for (b=0;b
{
if (isalpha(p.FirstNam[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("First name contain Invalid character. Please Enter again ");
goto A;
}
}
B:
printf("Last Name: ");
scanf("%s",p.LastNam);
p.LastNam[0]=toupper(p.LastNam[0]);
if(strlen(p.LastNam)>20||strlen(p.LastNam)<2)
{
printf("Invalid. The character is too much short or long");
goto B;
}
else
{
for (b=0;b
{
if (isalpha(p.LastNam[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("Last name contain Invalid character. Please Enter again ");
goto B;
}
}
do
{
printf("Gender[F/M]: ");
scanf(" %c",&p.Gender);
if(toupper(p.Gender)==M|| toupper(p.Gender)==F)// M an F use single //quotation
{
ok =1;
}
else
{
ok =0;
}
if(!ok)
{
printf("Invalid character.Enter Female for F and Mail for M");
}
}while(!ok);
printf("Age:");
scanf(" %i",&p.age);
do
{
C:
printf("HomeAddress: ");
scanf("%s",p.HomeAddress);
p.HomeAddress[0]=toupper(p.HomeAddress[0]);
if(strlen(p.HomeAddress)>20||strlen(p.HomeAddress)<4)
{
printf(" Invalid. The character is too much short or long");
goto C;
}
}while(!valid);
do
{
D:
printf("Contact no: ");
scanf("%s",p.PhoneNumber);
if(strlen(p.PhoneNumber)>11||strlen(p.PhoneNumber)!=11)
{
printf(" Sorry Invalid Numbers. Please Enter 11 digit numbers without country code");
goto D;
}
else
{
for (b=0;b
{
if (!isalpha(p.PhoneNumber[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("Contact no. contain Invalid character.Enter again");
goto D;
}
}
}while(!valid);
do
{
printf("Email: ");
scanf("%s",p.Email);
if (strlen(p.Email)>30||strlen(p.Email)<8)
{
printf(" Invalid. The max range for email is 30 character and min range is 8 ");
}
}while(strlen(p.Email)>30||strlen(p.Email)<8);
E:
printf("Problem: ");
scanf("%s",p.Problem);
p.Problem[0]=toupper(p.Problem[0]);
if(strlen(p.Problem)>15||strlen(p.Problem)<3)
{
printf(" Invalid. The max range for first name is 15 and min range is 3 :)");
goto E;
}
else
{
for (b=0;b
{
if (isalpha(p.Problem[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf("Sorry, Problem contain Invalid character");
goto E;
}
}
F:
printf("Prescribed Doctor:");
scanf("%s",p.Doctor);
p.Doctor[0]=toupper(p.Doctor[0]);
if(strlen(p.Doctor)>30||strlen(p.Doctor)<3)
{
printf(" Invalid.The character is too much short or long");
goto F;
}
else
{
for (b=0;b
{
if (isalpha(p.Doctor[b]))
{
valid=1;
}
else
{
valid=0;
break;
}
}
if(!valid)
{
printf(" Doctor name contain Invalid character. Enter again");
goto F;
}
}
fprintf(ek," %s %s %c %i %s %s %s %s %s", p.FirstNam, p.LastNam, p.Gender, p.age, p.HomeAddress, p.PhoneNumber, p.Email, p.Problem, p.Doctor);
printf("Information Record Done Successful ...");
fclose(ek);
sd:
getch();
printf("Do you want to add more[Y/N]?? ");
scanf(" %c",&ans);
if (toupper(ans)==Y) // Y-> use single quotation
{
Add_patient();
}
else if(toupper(ans)==N) // N-> use single quotation
{
printf("Thank you");
getch();
Menu_option();
}
else
{
printf("Invalid Input");
goto sd;
}
}
void patient_list()
{
int row;
system("cls");
Title_Screen();
FILE *ek;
ek=fopen("Record2.dat","r");
printf("List Patients Record ");
gotoxy(1,15);
printf("Full Name");
gotoxy(20,15);
printf("Gender");
gotoxy(32,15);
printf("Age");
gotoxy(37,15);
printf("HomeAddress");
gotoxy(49,15);
printf("Contact No.");
gotoxy(64,15);
printf("Email");
gotoxy(88,15);
printf("Problem");
gotoxy(98,15);
printf("Prescribed Doctor");
printf("=================================================================================================================");
row=17;
while(fscanf(ek,"%s %s %c %i %s %s %s %s %s", p.FirstNam, p.LastNam, &p.Gender, &p.age, p.HomeAddress, p.PhoneNumber, p.Email, p.Problem, p.Doctor)!=EOF)
{
gotoxy(1,row);
printf("%s %s",p.FirstNam, p.LastNam);
gotoxy(20,row);
printf("%c",p.Gender);
gotoxy(32,row);
printf("%i",p.age);
gotoxy(37,row);
printf("%s",p.HomeAddress);
gotoxy(49,row);
printf("%s",p.PhoneNumber);
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();
Menu_option();
}
void Patient_Search(void)
{
char name[20];
system("cls");
Title_Screen();
FILE *ek;
ek=fopen("Record2.dat","r");
printf("Search Patients Record");
gotoxy(12,8);
printf(" Enter Patient Name for view: ");
scanf("%s",name);
fflush(stdin);
name[0]=toupper(name[0]);
while(fscanf(ek,"%s %s %c %i %s %s %s %s %s", p.FirstNam, p.LastNam, &p.Gender, &p.age, p.HomeAddress, p.PhoneNumber, p.Email, p.Problem, p.Doctor)!=EOF)
{
if(strcmp(p.FirstNam,name)==0)
{
gotoxy(1,15);
printf("Full Name");
gotoxy(25,15);
printf("Gender");
gotoxy(32,15);
printf("Age");
gotoxy(37,15);
printf("HomeAddress");
gotoxy(52,15);
printf("Contact No.");
gotoxy(64,15);
printf("Email");
gotoxy(80,15);
printf("Problem");
gotoxy(95,15);
printf("Prescribed Doctor");
printf("=================================================================================================================");
gotoxy(1,18);
printf("%s %s",p.FirstNam, p.LastNam);
gotoxy(25,18);
printf("%c",p.Gender);
gotoxy(32,18);
printf("%i",p.age);
gotoxy(37,18);
printf("%s",p.HomeAddress);
gotoxy(52,18);
printf("%s",p.PhoneNumber);
gotoxy(64,18);
printf("%s",p.Email);
gotoxy(80,18);
printf("%s",p.Problem);
gotoxy(95,18);
printf("%s",p.Doctor);
printf("");
break;
}
}
if(strcmp(p.FirstNam,name)!=0)
{
gotoxy(5,10);
printf("Record not found!");
getch();
}
fclose(ek);
L:
getch();
printf("Do you want to view more[Y/N]?");
scanf("%c",&ans);
if (toupper(ans)==Y) //Y-> use single quotation
{
Patient_Search();
}
else if(toupper(ans)==N) // N-> use single quotation
{
printf(" Thank you");
getch();
Menu_option();
}
else
{
printf("Invalid Input.");
goto L;
}
}
void Patient_Edit(void)
{
FILE *ek, *ft;
int i,b, valid=0;
char ch;
char name[20];
system("cls");
Title_Screen();
//TBIS TECH
ft=fopen("temp2.dat","w+");
ek=fopen("Record2.dat","r");
if(ek==NULL)
{
printf(" Can not open file!! ");
getch();
Menu_option();
}
printf(" Edit Patients Record");
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(" Can not open file");
getch();
Menu_option();
}
while(fscanf(ek,"%s %s %c %i %s %s %s %s %s", p.FirstNam, p.LastNam, &p.Gender, &p.age, p.HomeAddress, p.PhoneNumber, p.Email, p.Problem, p.Doctor)!=EOF)
{
if(strcmp(p.FirstNam, name)==0)
{
valid=1;
gotoxy(25,17);
printf("Existing Record");
gotoxy(10,19);
printf("%s %s %c %i %s %s %s %s %s",p.FirstNam,p.LastNam,p.Gender, p.age,p.HomeAddress,p.PhoneNumber,p.Email,p.Problem,p.Doctor);
gotoxy(12,22);
printf("Enter New First Name: ");
scanf("%s",p.FirstNam);
gotoxy(12,24);
printf("Enter Last Name: ");
scanf("%s",p.LastNam);
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 HomeAddress: ");
scanf("%s",p.HomeAddress);
p.HomeAddress[0]=toupper(p.HomeAddress[0]);
gotoxy(12,32);
printf("Enter Contact no: ");
scanf("%s",p.PhoneNumber);
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("Press U charecter for the Updating operation : ");
ch=getche();
if(ch==u || ch==U) // u and U-> use single quotation
{
fprintf(ft,"%s %s %c %i %s %s %s %s %s",p.FirstNam,p.LastNam,p.Gender, p.age,p.HomeAddress,p.PhoneNumber,p.Email,p.Problem,p.Doctor);
printf("Patient record updated successfully...");
}
}
else
{
fprintf(ft,"%s %s %c %i %s %s %s %s %s",p.FirstNam,p.LastNam,p.Gender, p.age,p.HomeAddress,p.PhoneNumber,p.Email,p.Problem,p.Doctor);
}
}
if(!valid)
{
printf("NO RECORD FOUND...");
}
fclose(ft);
fclose(ek);
remove("Record2.dat");
rename("temp2.dat","Record2.dat");
getch();
Menu_option();
}
void Patient_Delate()
{
char name[20];
int found=0;
system("cls");
Title_Screen();
FILE *ek, *ft;
ft=fopen("temp_file2.dat","w+");
ek=fopen("Record2.dat","r");
printf("Delete Patients Record ");
gotoxy(12,8);
printf(" Enter Patient Name to delete: ");
scanf("%s",name);
fflush(stdin);
name[0]=toupper(name[0]);
while (fscanf(ek,"%s %s %c %i %s %s %s %s %s", p.FirstNam, p.LastNam, &p.Gender,&p.age, p.HomeAddress, p.PhoneNumber, p.Email, p.Problem, p.Doctor)!=EOF)
{
if (strcmp(p.FirstNam,name)!=0)
fprintf(ft,"%s %s %c %i %s %s %s %s %s", p.FirstNam, p.LastNam, p.Gender, p.age, p.HomeAddress, p.PhoneNumber, p.Email, p.Problem, p.Doctor);
else
{
printf("%s %s %c %i %s %s %s %s %s", p.FirstNam, p.LastNam, p.Gender, p.age, p.HomeAddress, p.PhoneNumber, p.Email, p.Problem, p.Doctor);
found=1;
}
}
if(found==0)
{
printf("Record not found..");
getch();
Menu_option();
}
else
{
fclose(ek);
fclose(ft);
remove("Record2.dat");
rename("temp_file2.dat","Record2.dat");
printf("Record deleted successfully ");
getch();
Menu_option();
}
}
---------------------------------------x------------------------------------------------------
hospital management system, hospital management system in c, hospital management system project, mini project in c programming with source code, hospital management in c, c programming projects, hospital management system in c programming, management system, hospital management system project in c language, c programming,c programming language, programming, programming projects, c projects, c programming projects, projects in c programming, c programming mini project, c (programming language), programming in c, projects in c, c language projects, programming project ideas, c projects with source code, c programming code, coding projects, c programming mini projects, 2021 , new