-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhospman2.cpp
267 lines (267 loc) · 6.63 KB
/
hospman2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
#include<iostream>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
struct patient
{
long ID;
string firstname;
string lastname;
int age;
char blood[5];
char gender;
patient*next;
};
class linkedqueue
{
patient *head,*last;
public:
linkedqueue()
{
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()
{
int flag=0;
patient *p=new patient();
cout << "\n Please enter data for patient\n";
cout<<"\n First name : ";
getline(cin,p->firstname);
cout << " Last name : ";
getline(cin,p->lastname);
again :
cout << " Blood 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<<"\n Invalid Blood Group Try Again\n\n";
goto again;
}
cout<<" Gender(m/f) : ";
cin>>p->gender;
cout<<" Age : ";
cin>>p->age;
cout<<" Mobile number : ";
cin>>p->ID;
if(search(p->ID))
{
p->ID=0;
cout << "\n Data not valid. Operation cancelled.";
}
return *p;
}
void output(patient *p)
{
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
cout<<"\n Patient data:\n";
cout<<"\n First Name : "<<p->firstname;
cout<<"\n Last Name : "<<p->lastname;
cout<<"\n Gender : "<<p->gender;
cout<<"\n Age : "<<p->age;
cout<<"\n Blood Group : "<<p->blood;
cout<<"\n Mobile Number : "<<p->ID;
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
}
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 ----------------------------------------------------------------------------------------------------------------------------------------";
cout<<"\n |-- HOSPITAL MANAGEMENT SYSTEM --|";
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
cout <<"\n ----------PATIENT ADDED-----------";
output(p);
}
void linkedqueue :: getpatientout()
{
system("cls");
if(head==NULL)
{
cout<<"\n No Patient to operate";
}
else
{
patient*p=new patient();
p=head;
head=head->next;
cout << "\n Patient to operate:";
output(p);
}
}
void linkedqueue :: listofpatients()
{
if(head==NULL)
{
cout<<"\n No patient";
}
system("cls");
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
cout<<"\n |-- HOSPITAL MANAGEMENT SYSTEM --|";
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
patient*p=new patient;
p=head;
while(p!=NULL)
{
cout<<"\n Patient data:\n";
cout<<"\n First Name : "<<p->firstname;
cout<<"\n Last Name : "<<p->lastname;
cout<<"\n Gender : "<<p->gender;
cout<<"\n Age : "<<p->age;
cout<<"\n Blood Group : "<<p->blood;
cout<<"\n Mobile Number : "<<p->ID;
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
p=p->next;
}
cout<<"\n";
}
void departmentmenu (linkedqueue * q)
{
int choice = 0, success;
patient p;
while (choice != 5)
{
system("cls");
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
cout<<"\n |-- HOSPITAL MANAGEMENT SYSTEM --|";
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
cout<<"\n\n "<<q->departmentname;
cout<<"\n [1] Add normal patient\n";
cout<<" [2] Add critically ill patient\n";
cout<<" [3] Take patient to Doctor\n";
cout<<" [4] Display list\n";
cout<<" [5] Change department or exit\n";
cout<<"\n Please enter your choice : ";
choice=readnumber();
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
switch (choice)
{
case 1: q->insertatend();
cout << "\n Press any key";
getch();
break;
case 2: q->insertatbeg();
cout << "\n Press any key";
getch();
break;
case 3: q->getpatientout();
cout<<"\n Press any key";
getch();
break;
case 4: system("cls");
q->listofpatients();
cout<<"\n Press any key";
getch();
break;
}
}
}
int main ()
{
int i, choice = 0;
linkedqueue departments[4];
while(choice!=5)
{
strcpy(departments[0].departmentname,"GENERAL CLINIC\n");
strcpy(departments[1].departmentname,"HEART CLINIC\n");
strcpy(departments[2].departmentname,"LUNG CLINIC\n");
strcpy(departments[3].departmentname,"PLASTIC SURGERY\n");
system("cls");
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------";
cout<<"\n |-- HOSPITAL MANAGEMENT SYSTEM --|";
cout<<"\n ----------------------------------------------------------------------------------------------------------------------------------------\n";
cout<<" |-- Main Menu -------------------|\n";
for (i = 0; i < 4; i++)
{
cout<<" "<<(i+1)<<": "<<departments[i].departmentname;
}
cout<<" 5: Exit";
cout<<"\n\n Please enter your choice : ";
choice=readnumber();
if(choice>=1 && choice<=4)
{
departmentmenu(&departments[choice-1]);
}
}
if(choice==5)
cout<<"\n\t\tThank you! \n";
exit(0);
}