-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
534 lines (490 loc) · 20.4 KB
/
Copy pathmain.cpp
File metadata and controls
534 lines (490 loc) · 20.4 KB
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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
#include "ChocAn.h"
//function stubs for terminal interface simulation functions in main menu
void operator_terminal();
void provider_terminal();
void manager_terminal();
int main() {
//for selecting menu options
int selection = 0;
//Inital terminal bootup
while (true) {
//display menu options and prompt for selection
cout << "ChocAn Data Processing Software" << endl;
cout << "------------------------------------------------------" << endl;
cout << "1. Operator Terminal - Manage Members and Providers" << endl;
cout << "2. Provider Terminal - Manage Services" << endl;
cout << "3. Manager Terminal - Manage Service Reports" << endl;
cout << "4. Exit" << endl;
cout << "Enter selection: ";
cin >> selection;
//each selection calls respective functions
if (selection == 1) {
operator_terminal();
}
else if (selection == 2) {
provider_terminal();
}
else if (selection == 3) {
manager_terminal();
}
else if (selection == 4) {
cout << endl << "Exiting Terminal..." << endl;
return 0;
}
else {
cout << endl << "Invalid input, try again..." << endl;
}
}
return 0;
}
//interface for the operator terminal simulation - used to manage members and providers
void operator_terminal() {
// database instance for this terminal session
ChocAnDB db;
if (!db.initialize()) {
cerr << "Failed to open ChocAn database for operator terminal." << endl;
return;
}
//for selection
int selection = 0;
//display operator terminal options
while (true) {
cout << "Operator Terminal - Manage Members and Providers" << endl;
cout << "------------------------------------------------------" << endl;
cout << "1. Manage Members" << endl;
cout << "2. Manage Providers" << endl;
cout << "3. Return to Main Menu" << endl;
cout << "Enter selection: ";
cin >> selection;
//go to member management
if (selection == 1) {
//for selecting in if block
int subselect = 0;
//display options to select
while (true) {
cout << "Member Management" << endl;
cout << "-------------------------------------" << endl;
cout << "1. Add Member" << endl;
cout << "2. Remove Member" << endl;
cout << "3. Update Member" << endl;
cout << "4. View Member" << endl;
cout << "5. Return to Main Menu" << endl;
cout << "Enter selection: ";
cin >> subselect;
//THIS IS WHERE FUNCTION CALLS GO WHEN IMPLEMENTED
if (subselect == 1) {
Member m;
cout << "Enter Member ID (int): ";
cin >> m.mem_id;
cout << "Enter Member Name (no spaces for now): ";
cin >> m.mem_name;
cout << "Enter Street Address (no spaces for now): ";
cin >> m.address;
cout << "Enter City: ";
cin >> m.city;
cout << "Enter State (2 letters): ";
cin >> m.state;
cout << "Enter Zip: ";
cin >> m.zip;
cout << "Enter Status (active/suspended): ";
cin >> m.status;
if (db.addMember(m)) {
cout << "Member added successfully." << endl;
} else {
cout << "Failed to add member." << endl;
}
}
else if (subselect == 2) {
int id;
cout << "Enter Member ID to remove: ";
cin >> id;
if (db.deleteMember(id)) {
cout << "Member removed successfully." << endl;
} else {
cout << "Failed to remove member (ID may not exist)." << endl;
}
}
else if (subselect == 3) {
Member m;
cout << "Enter Member ID to update: ";
cin >> m.mem_id;
Member *existing = db.getMember(m.mem_id);
if (!existing) {
cout << "Member not found." << endl;
} else {
cout << "Enter new Member Name (no spaces for now): ";
cin >> m.mem_name;
cout << "Enter new Street Address (no spaces for now): ";
cin >> m.address;
cout << "Enter new City: ";
cin >> m.city;
cout << "Enter new State (2 letters): ";
cin >> m.state;
cout << "Enter new Zip: ";
cin >> m.zip;
cout << "Enter new Status (active/suspended): ";
cin >> m.status;
if (db.updateMember(m)) {
cout << "Member updated successfully." << endl;
} else {
cout << "Failed to update member." << endl;
}
delete existing;
}
}
else if (subselect == 4) {
int id;
cout << "Enter Member ID to view: ";
cin >> id;
Member *m = db.getMember(id);
if (!m) {
cout << "Member not found." << endl;
} else {
cout << "Member ID: " << m->mem_id << endl;
cout << "Name: " << m->mem_name << endl;
cout << "Address: " << m->address << endl;
cout << "City: " << m->city << endl;
cout << "State: " << m->state << endl;
cout << "Zip: " << m->zip << endl;
cout << "Status: " << m->status << endl;
delete m;
}
}
else if (subselect == 5) {
return;
}
else {
cout << "Invalid input, try again..." << endl;
}
}
}
//go to provider management
else if (selection == 2) {
//for selecting in else-if block
int subselect = 0;
//display options to select
while (true) {
cout << "Provider Management" << endl;
cout << "-------------------------------------" << endl;
cout << "1. Add Provider" << endl;
cout << "2. Remove Provider" << endl;
cout << "3. Update Provider" << endl;
cout << "4. View Provider" << endl;
cout << "5. Return to Main Menu" << endl;
cout << "Enter selection: ";
cin >> subselect;
//THIS IS WHERE FUNCTION CALLS GO WHEN IMPLEMENTED
if (subselect == 1) {
Provider p;
cout << "Enter Provider ID (int): ";
cin >> p.prov_id;
cout << "Enter Provider Name (no spaces for now): ";
cin >> p.prov_name;
cout << "Enter Street Address (no spaces for now): ";
cin >> p.address;
cout << "Enter City: ";
cin >> p.city;
cout << "Enter State (2 letters): ";
cin >> p.state;
cout << "Enter Zip: ";
cin >> p.zip;
if (db.addProvider(p)) {
cout << "Provider added successfully." << endl;
} else {
cout << "Failed to add provider." << endl;
}
}
else if (subselect == 2) {
int id;
cout << "Enter Provider ID to remove: ";
cin >> id;
if (db.deleteProvider(id)) {
cout << "Provider removed successfully." << endl;
} else {
cout << "Failed to remove provider (ID may not exist)." << endl;
}
}
else if (subselect == 3) {
Provider p;
cout << "Enter Provider ID to update: ";
cin >> p.prov_id;
Provider *existing = db.getProvider(p.prov_id);
if (!existing) {
cout << "Provider not found." << endl;
} else {
cout << "Enter new Provider Name (no spaces for now): ";
cin >> p.prov_name;
cout << "Enter new Street Address (no spaces for now): ";
cin >> p.address;
cout << "Enter new City: ";
cin >> p.city;
cout << "Enter new State (2 letters): ";
cin >> p.state;
cout << "Enter new Zip: ";
cin >> p.zip;
if (db.updateProvider(p)) {
cout << "Provider updated successfully." << endl;
} else {
cout << "Failed to update provider." << endl;
}
delete existing;
}
}
else if (subselect == 4) {
int id;
cout << "Enter Provider ID to view: ";
cin >> id;
Provider *p = db.getProvider(id);
if (!p) {
cout << "Provider not found." << endl;
} else {
cout << "Provider ID: " << p->prov_id << endl;
cout << "Name: " << p->prov_name << endl;
cout << "Address: " << p->address << endl;
cout << "City: " << p->city << endl;
cout << "State: " << p->state << endl;
cout << "Zip: " << p->zip << endl;
delete p;
}
}
else if (subselect == 5) {
return;
}
else {
cout << "Invalid input, try again..." << endl;
}
}
}
//return to main menu
else if (selection == 3) return;
else cout << "Invalid input, try again..." << endl;
}
}
//interface for the provider terminal simulation - used to manage services
void provider_terminal() {
// database instance for this terminal session
ChocAnDB db;
if (!db.initialize()) {
cerr << "Failed to open ChocAn database for provider terminal." << endl;
return;
}
//for selecting options
int selection = 0;
//display provider terminal options
while (true) {
cout << "Provider Terminal - Manage Services" << endl;
cout << "------------------------------------------------------" << endl;
cout << "1. Add Service" << endl;
cout << "2. Remove Service" << endl;
cout << "3. Update Service" << endl;
cout << "4. View Service" << endl;
cout << "5. Return to Main Menu" << endl;
cout << "Enter selection: ";
cin >> selection;
//THIS IS WHERE FUNCTION CALLS GO WHEN IMPLEMENTED
if (selection == 1) {
Service s;
cout << "Enter Service Code (int): ";
cin >> s.code;
cout << "Enter Service Name (no spaces for now): ";
cin >> s.name;
cout << "Enter Service Fee: ";
cin >> s.fee;
if (db.addService(s)) {
cout << "Service added successfully." << endl;
} else {
cout << "Failed to add service." << endl;
}
}
else if (selection == 2) {
int code;
cout << "Enter Service Code to remove: ";
cin >> code;
if (db.deleteService(code)) {
cout << "Service removed successfully." << endl;
} else {
cout << "Failed to remove service (code may not exist)." << endl;
}
}
else if (selection == 3) {
Service s;
cout << "Enter Service Code to update: ";
cin >> s.code;
Service *existing = db.getService(s.code);
if (!existing) {
cout << "Service not found." << endl;
} else {
cout << "Enter new Service Name (no spaces for now): ";
cin >> s.name;
cout << "Enter new Service Fee: ";
cin >> s.fee;
if (db.updateService(s)) {
cout << "Service updated successfully." << endl;
} else {
cout << "Failed to update service." << endl;
}
delete existing;
}
}
else if (selection == 4) {
int code;
cout << "Enter Service Code to view: ";
cin >> code;
Service *s = db.getService(code);
if (!s) {
cout << "Service not found." << endl;
} else {
cout << "Service Code: " << s->code << endl;
cout << "Name: " << s->name << endl;
cout << "Fee: " << s->fee << endl;
delete s;
}
}
else if (selection == 5) return;
else cout << "Invalid input, try again..." << endl;
}
}
//interface for manager terminal simulation - used to manage records and reports of services
void manager_terminal() {
// database instance for this terminal session
ChocAnDB db;
if (!db.initialize()) {
cerr << "Failed to open ChocAn database for manager terminal." << endl;
return;
}
//for selecting options
int selection = 0;
//display manager terminal options
while (true) {
cout << "Manager Terminal - Manage Service Reports" << endl;
cout << "------------------------------------------------------" << endl;
cout << "1. Add Service Record" << endl;
cout << "2. Show Service Records by Member" << endl;
cout << "3. Show Service Records by Provider" << endl;
cout << "4. Show All Service Records - Summary" << endl;
cout << "5. Return to Main Menu" << endl;
cout << "Enter selection: ";
cin >> selection;
//THIS IS WHERE FUNCTION CALLS GO WHEN IMPLEMENTED
if (selection == 1) {
ServiceRecord r;
cout << "Enter Current Date (MM-DD-YYYY): ";
cin >> r.current_date;
cout << "Enter Service Date (MM-DD-YYYY): ";
cin >> r.service_date;
cout << "Enter Provider ID: ";
cin >> r.prov_id;
cout << "Enter Member ID: ";
cin >> r.mem_id;
cout << "Enter Service Code: ";
cin >> r.service_code;
cout << "Enter Comments (no spaces for now): ";
cin >> r.comments;
cout << "Enter Fee: ";
cin >> r.fee;
if (db.addServiceRecord(r)) {
cout << "Service record added successfully. Record ID: " << r.rec_id << endl;
} else {
cout << "Failed to add service record." << endl;
}
}
else if (selection == 2) {
int mem_id;
string startDate, endDate;
cout << "Enter Member ID: ";
cin >> mem_id;
cout << "Enter Start Date (MM-DD-YYYY, or 0 for all): ";
cin >> startDate;
cout << "Enter End Date (MM-DD-YYYY, or 0 for all): ";
cin >> endDate;
if (startDate == "0" || endDate == "0") {
startDate.clear();
endDate.clear();
}
vector<ServiceRecord> records =
db.getServiceRecordsByMember(mem_id, startDate, endDate);
if (records.empty()) {
cout << "No service records found for that member / date range." << endl;
} else {
for (const auto &r : records) {
cout << "Record ID: " << r.rec_id << endl;
cout << "Current Date: " << r.current_date << endl;
cout << "Service Date: " << r.service_date << endl;
cout << "Provider ID: " << r.prov_id << endl;
cout << "Member ID: " << r.mem_id << endl;
cout << "Service Code: " << r.service_code << endl;
cout << "Comments: " << r.comments << endl;
cout << "Fee: " << r.fee << endl;
cout << "------------------------" << endl;
}
}
}
else if (selection == 3) {
int prov_id;
string startDate, endDate;
cout << "Enter Provider ID: ";
cin >> prov_id;
cout << "Enter Start Date (MM-DD-YYYY, or 0 for all): ";
cin >> startDate;
cout << "Enter End Date (MM-DD-YYYY, or 0 for all): ";
cin >> endDate;
if (startDate == "0" || endDate == "0") {
startDate.clear();
endDate.clear();
}
vector<ServiceRecord> records =
db.getServiceRecordsByProvider(prov_id, startDate, endDate);
if (records.empty()) {
cout << "No service records found for that provider / date range." << endl;
} else {
for (const auto &r : records) {
cout << "Record ID: " << r.rec_id << endl;
cout << "Current Date: " << r.current_date << endl;
cout << "Service Date: " << r.service_date << endl;
cout << "Provider ID: " << r.prov_id << endl;
cout << "Member ID: " << r.mem_id << endl;
cout << "Service Code: " << r.service_code << endl;
cout << "Comments: " << r.comments << endl;
cout << "Fee: " << r.fee << endl;
cout << "------------------------" << endl;
}
}
}
else if (selection == 4) {
string startDate, endDate;
cout << "Enter Start Date (MM-DD-YYYY, or 0 for all): ";
cin >> startDate;
cout << "Enter End Date (MM-DD-YYYY, or 0 for all): ";
cin >> endDate;
if (startDate == "0" || endDate == "0") {
startDate.clear();
endDate.clear();
}
vector<ServiceRecord> records =
db.getAllServiceRecords(startDate, endDate);
if (records.empty()) {
cout << "No service records found for that date range." << endl;
} else {
double totalFees = 0.0;
int count = 0;
for (const auto &r : records) {
cout << "Record ID: " << r.rec_id << endl;
cout << "Current Date: " << r.current_date << endl;
cout << "Service Date: " << r.service_date << endl;
cout << "Provider ID: " << r.prov_id << endl;
cout << "Member ID: " << r.mem_id << endl;
cout << "Service Code: " << r.service_code << endl;
cout << "Comments: " << r.comments << endl;
cout << "Fee: " << r.fee << endl;
cout << "------------------------" << endl;
totalFees += r.fee;
++count;
}
cout << "Total records: " << count << endl;
cout << "Total fees: " << totalFees << endl;
}
}
else if (selection == 5) return;
else cout << "Invalid input, try again..." << endl;
}
}