-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassRecord.cpp
More file actions
126 lines (101 loc) · 2.61 KB
/
ClassRecord.cpp
File metadata and controls
126 lines (101 loc) · 2.61 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
#include <iostream>
#include "ClassRecord.h"
#include <string>
#include <bits/stdc++.h>
using namespace std;
Date::Date(string Date)
{
string strday, strmonth, temp;
size_t index1, index2;
index1 = Date.find("-");
strday = Date.substr(0, index1);
this->day = stoi(strday);
temp = Date.substr(index1 + 1);
index2 = temp.find("-");
strmonth = temp.substr(0, index2);
this->month = stoi(strmonth);
temp = temp.substr(index2 + 1);
this->year = stoi(temp);
// cout << this->day << endl;
// cout << this->month << endl;
// cout << this->year << endl;
}
int Date::getDay(){
return this->day;
}
int Date::getMonth(){
return this->month;
}
int Date::getYear(){
return this->year;
}
bool operator==(Date& date1, Date& date2){
return (date1.getDay() == date2.getDay() && date1.getMonth() == date2.getMonth()
&& date1.getYear() == date2.getYear());
}
bool operator<(Date& date1, Date& date2){
if(date1.getYear() < date2.getYear()){
return true;
}else if(date1.getYear() == date2.getYear() && date1.getMonth() < date2.getMonth()){
return true;
} else if(date1.getYear() == date2.getYear() && date1.getMonth() == date2.getMonth() && date1.getDay() < date2.getDay()){
return true;
}else{
return false;
}
}
bool operator>(Date& date1, Date& date2){
return !(date1 < date2 || date1 == date2);
}
Date::~Date(){
}
Record::Record(string BigString, bool query)
{
string entryDate;
string exitDate;
istringstream ss(BigString);
ss >> this->recordId;
ss >> this->patientFirstName;
ss >> this->patientLastName;
ss >> this->diseaseID;
if(!query){
ss >> this->country;
}
ss >> entryDate;
ss >> exitDate;
if(exitDate == "-"){
//cout << "Patient Not Out Yet" << endl;
this->exitDate = NULL;
this->entryDate = new Date(entryDate);
}else{
this->entryDate = new Date(entryDate);
this->exitDate = new Date(exitDate);
}
if(this->exitDate != NULL){
if(*this->entryDate > *this->exitDate) {
cout << "Error: entryDate is after exitDate" << endl;
}
}
}
Record::~Record(){
delete entryDate;
delete exitDate;
}
string Record::getRecordId() {
return this->recordId;
}
Date* Record::getEntryDate(){
return this->entryDate;
}
string Record::getCountry(){
return this->country;
}
string Record::getDisease(){
return this->diseaseID;
}
Date* Record::getExitDate(){
return this->exitDate;
}
void Record::setExitDate(string newExitDate){
this->exitDate = new Date(newExitDate);
}