-
Notifications
You must be signed in to change notification settings - Fork 1
/
Doctor's Appointment System.c
236 lines (233 loc) · 6.54 KB
/
Doctor's Appointment System.c
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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
struct node
{
int serial;
char name[100];
char phone[12];
struct node *next;
};
typedef struct node node;
int appointment=20;
node *head;
void Appoint(node*pointer)
{
printf(" *********Appointment Portal*********\n");
int serial;
char key;
if(appointment==0)
{
printf("Sorry! Today's Appointment Full. Try after 8 p.m. for tomorrows appointment\n\n\n");
printf("Press any key to continue...");
scanf("%c",&key);
if(key>=0)
return;
}
else
{
if(pointer==NULL)
{
head=(node*)malloc(sizeof(node));
pointer=head;
pointer->next=NULL;
printf("Enter your name: ");
getchar();
gets(pointer->name);
phone_tag1:
printf("Enter Mobile Number: ");
gets(pointer->phone);
int len=strlen(pointer->phone);
if(len!=11)
{
printf("Invalid Mobile Number. Try again\n");
goto phone_tag1;
}
int i;
for(i=0;pointer->phone[i]!=NULL;i++)
{
if(pointer->phone[i]<'0' || pointer->phone[i]>'9')
{
printf("Invalid Mobile Number. Try again\n");
goto phone_tag1;
}
}
appointment--;
serial=20-appointment;
pointer->serial=serial;
printf("\n\nAppointment accepted.\n");
printf("Your serial number is %d.\n\n\n",pointer->serial);
printf("Press any key to continue...");
scanf("%c",&key);
if(key>=0)
return;
}
while(pointer->next!=NULL)
{
pointer=pointer->next;
}
pointer->next=(node*)malloc(sizeof(node));
pointer=pointer->next;
pointer->next=NULL;
printf("Enter your name: ");
getchar();
gets(pointer->name);
phone_tag:
printf("Enter your Mobile Number: ");
gets(pointer->phone);
int len=strlen(pointer->phone);
if(len!=11)
{
printf("Invalid Mobile Number. Try again\n");
goto phone_tag;
}
appointment--;
serial=20-appointment;
pointer->serial=serial;
printf("\n\nAppointment accepted.\n");
printf("Your serial number is %d.\n\n\n",pointer->serial);
printf("Press any key to continue...");
scanf("%c",&key);
if(key>=0)
return;
}
}
void Showlist(node *pointer)
{
printf(" *********Today's appointment list*********\n");
if(pointer==NULL)
{
printf("No Appointment today!!!\n\n\n");
}
while(pointer!=NULL)
{
printf("%d: ",pointer->serial);
printf("%s (Ph: %s )\n",pointer->name,pointer->phone);
pointer=pointer->next;
}
printf("\n\n\n\nPress enter to go back to Doctor's menu: ");
char key;
getchar();
scanf("%c",&key);
if(key>=0)
{
system("cls");
return;
}
}
void Call(node *head)
{
node *temp;
temp=head;
char key;
if(temp==NULL)
{
printf("No Appointment today!!!\n\n\n");
printf("Press enter to go back to main menu");
scanf("%c",&key);
if(key>=0)
{
printf("Bolod");
system("cls");
return;
}
}
printf("Calling:\n");
printf("Serial %d: %s\nPhone:%s\n\n",temp->serial,temp->name,temp->phone);
if(temp->next!=NULL)
{
temp=temp->next;
printf("Next is:\n");
printf("Serial %d: %s\nPhone:%s\n\n",temp->serial,temp->name,temp->phone);
}
printf("\nPress enter to go back to Doctor's Menu...");
getchar();
scanf("%c",&key);
if(key>=0)
{
head=head->next;
free(temp);
system("cls");
return;
}
}
int main()
{
head=NULL;
char query,query2;
while(1)
{
printf(" *********Main Menu*********\n");
main_again:
printf("1.I'm a Patient\n2.I'm the Doctor\n\n\n");
scanf(" %c",&query);
if(query=='1')
{
while(1)
{
system("cls");
printf(" *********Patient's Menu*********\n");
printf("1.Place Appointment\n2.Back to main menu.\n\n");
char appoint1;
patient_again:
scanf(" %c",&appoint1);
if(appoint1=='1')
{
system("cls");
Appoint(head);
}
else if(appoint1=='2')
{
system("cls");
break;
}
else
{
printf("Wrong Command!!!\n\n");
goto patient_again;
}
}
}
else if(query=='2')
{
while(1)
{
system("cls");
printf(" *********Doctor's Menu*********\n");
printf("1.Show list\n2.Call next\n3.Back to main menu.\n\n\n");
scanf(" %c",&query2);
if(query2=='1')
{
system("cls");
Showlist(head);
}
else if(query2=='2')
{
system("cls");
Call(head);
}
else if(query2=='3')
{
system("cls");
break;
}
else
{
printf("Wrong Command!!!\n\n");
continue;
}
}
}
else if(query2=='3')
{
exit(0);
}
else
{
printf("Wrong Command!!!\n\n");
goto main_again;
}
}
return 0;
}