Sei sulla pagina 1di 12

#include<iostream>

#include<conio.h>

#include<string.h>

#include<stdlib.h>

#include <ctime> //Header file for RANDOM number

#include <cstdlib> //Header file for RANDOM number

using namespace std;

struct patient

int rand();

long long ID;

string firstname;

string lastname;

string problem;

int IDN;

int age;

char blood[5];

char gender;

patient*next;

int r;

};

class linkedqueue

{
patient *head,*last;

public:

linkedqueue() //Constructor (c) Sarang

head=NULL;

last=NULL;

patient input();

void insertatend();

void insertatbeg();

void getpatientout();

void listofpatients();

int search(int);

char departmentname[50];

};

int linkedqueue :: search(int item)

if(head==NULL)

return false;

else

int flag=0;

patient*p=new patient();

p=head;
while( p->next!=NULL && p->ID!=item )

p=p->next;

if(p->ID==item)

flag=1;

return true;

if(flag==0)

return false;

int readnumber()

char b[20];

cin.getline(b, sizeof(b));

return atoi(b);

patient linkedqueue :: input() //Patient Info Input (C) Sarang

int flag=0;

patient *p=new patient();

int r,IDN;

srand(time(0));
r = rand();

IDN=r;

cout<< "\n\tPlease enter data for patient\n"<<endl;

cout<< "\n\tLIVE ID NUMBER : "<<r<<endl;

cout<< "\n\tFirst name : ";

getline(cin,p->firstname);

cout<< "\tLast name : ";

getline(cin,p->lastname);

again :

cout << "\tBlood Group : ";

cin>>p->blood;

if((strcmp(p->blood,"A+")==0)||(strcmp(p->blood,"a+")==0)||(strcmp(p->blood,"A-
")==0)||(strcmp(p->blood,"a-")==0)||

(strcmp(p->blood,"B+")==0)||(strcmp(p->blood,"b+")==0)||(strcmp(p->blood,"B-
")==0)||(strcmp(p->blood,"b-")==0)||

(strcmp(p->blood,"O+")==0)||(strcmp(p->blood,"o+")==0)||(strcmp(p->blood,"O-
")==0)||(strcmp(p->blood,"o-")==0)||

(strcmp(p->blood,"AB+")==0)||(strcmp(p->blood,"ab+")==0)||(strcmp(p->blood,"AB-
")==0)||(strcmp(p->blood,"ab-")==0))

flag=1;

if(flag==0)

cout<<"\nWrong Entry...Enter a valid Blood Group..Try Again..";

goto again;

cout<< "\tGender :(M/F)";

cin>>p->gender;
cout<< "\tAge : ";

cin>>p->age;

cout<< "\tProblem (Spc->_) : ";

cin>>p->problem;

cout<< "\tID Number Input : ";

cin>>p->IDN;

cout<< "\tMobile number : ";

cin>>p->ID;

if(search(p->ID))

p->ID=0;

cout << "\n\tData not valid. Operation cancelled.";

return *p;

void output(patient *p)

cout<<"\n\t**********************************";

cout<<"\n\n\tPatient data :";

cout<<"\n\tID Number : "<<p->IDN;

cout<<"\n\tFirst Name : "<<p->firstname;

cout<<"\n\tLast Name : "<<p->lastname;

cout<<"\n\tGender : "<<p->gender;

cout<<"\n\tAge : "<<p->age;
cout<<"\n\tBlood Group : "<<p->blood;

cout<<"\n\tProblem : "<<p->problem;

cout<<"\n\tMobile Number : "<<p->ID;

cout<<"\n\n\t**********************************";

void linkedqueue :: insertatbeg()

patient*p=new patient();

*p=input();

if(p->ID==0)

return;

if(head==NULL)

head=p;

last=p;

p->next=NULL;

else

p->next=head;

head=p;

system("cls");
cout << "\n\tPatient added:";

output(p);

void linkedqueue:: insertatend()

patient*p=new patient();

*p=input();

if(p->ID==0)

return;

if(head==NULL)

head=p;

last=p;

p->next=NULL;

else

p->next=NULL;

last->next=p;

last=p;

system("cls");

cout << "\n\tPatient added:";

output(p);
}

void linkedqueue :: getpatientout()

system("cls");

if(head==NULL)

cout<<"\n\tNo Patient to operate";

else

patient*p=new patient();

p=head;

head=head->next;

cout << "\n\tPatient to operate:";

output(p);

void linkedqueue :: listofpatients()

if(head==NULL)

cout<<"\n\tNo patient";

patient*p=new patient;

p=head;
while(p!=NULL)

cout<<"\nPatient data:";

cout<<"\n*************************************\n";

cout<<"\n\tID Number : "<<p->IDN;

cout<<"\n\tFirst Name : "<<p->firstname;

cout<<"\n\tLast Name : "<<p->lastname;

cout<<"\n\tGender : "<<p->gender;

cout<<"\n\tAge : "<<p->age;

cout<<"\n\tBlood Group : "<<p->blood;

cout<<"\n\tproblem : "<<p->problem;

cout<<"\n\tMobile Number : "<<p->ID<<"\n";

cout<<"\n*************************************\n";

p=p->next;

cout<<"\n";

void departmentmenu (linkedqueue * q)

int choice = 0, success;

patient p;

while (choice != 5)

system("cls");
cout<<"\n\n\tWelcome To Department : " << q->departmentname;

cout<<"\n\t\t[1] Add normal patient\n";

cout<<"\t\t[2] Add critically ill patient\n";

cout<<"\t\t[3] Take patient to Doctor\n";

cout<<"\t\t[4] Display list\n\a";

cout<<"\t\t[5] Back to Menu or exit\n";

cout<<"\n\tPlease enter your choice : ";

choice=readnumber();

switch (choice)

case 1: q->insertatend();

cout << "\n\tPress any key";

getch();

break;

case 2: q->insertatbeg();

cout << "\n\tPress any key";

getch();

break;

case 3: q->getpatientout();

cout<<"\n\tPress any key";

getch();

break;

case 4: system("cls");
q->listofpatients();

cout<<"\n\tPress any key";

getch();

break;

int main ()

int i, choice = 0;

linkedqueue departments[5];

system("COLOR FC");

while(choice!=2)

strcpy(departments[0].departmentname,"Patient Portal\n");

system("cls");

cout<<"\n\t============================\a";

cout<<"\n\t .:+ VAR-SAR HOSPITAL +:.\t\a";

cout<<"\n\t----------------------------\n\a";

cout<<"\n\t-------.: SERVER 1 :.-------\n"<<endl;

for (i = 0; i < 1; i++)

cout<<"\t["<<(i+1)<<"]: "<<departments[i].departmentname;

}
cout<<"\t[2]: Exit";

cout<<"\n\n\tPlease enter your choice : ";

choice=readnumber();

if(choice>=1 && choice<=1)

departmentmenu(&departments[choice-1]);

if(choice==2)

cout<<"Brought to you by Sarang"<<endl;

exit(0); //system end cp

Potrebbero piacerti anche