-
Notifications
You must be signed in to change notification settings - Fork 0
/
Patient.cpp
210 lines (183 loc) · 3.9 KB
/
Patient.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
#include"Patient.h"
using namespace std;
//Constructors...
Patient::Patient()
{
setName("");
setAddress("");
next =NULL;
firstMedicalHistory=NULL;
MedicalHistoryNum=0;
}
void Patient::SetPMN(int i)
{
if (i < 0)cout << "Error!Please enter a valid Number of Medical History." << endl;
else
MedicalHistoryNum = i;
}
int Patient::GetPMN()
{
return MedicalHistoryNum;
}
Patient::Patient(string name, string address)
{
setName(name);
setAddress(address);
next=NULL;
firstMedicalHistory=NULL;
MedicalHistoryNum=0;
}
Patient::Patient(string name,string address,string mobil, string tele, string email,unsigned int d,unsigned int m,unsigned int y)
{
setName(name);
setAddress(address);
setContact(mobil,tele,email);
setDate(d,m,y);
next=NULL;
firstMedicalHistory=NULL;
MedicalHistoryNum=0;
}
//Set Functions...
void Patient::setName(string name)
{
this-> name = name;
}
void Patient::setAddress(string address)
{
this-> address = address;
}
void Patient::setDate(unsigned int Day,unsigned int Month,unsigned int Year)
{
cout << "Date of Birth:" << endl;
this-> DofB.setDay(Day);
this-> DofB.setMonth(Month);
this->DofB.setYear(Year);
}
void Patient::setContact(string mobile ,string tel, string Email)
{
this-> C.setMobile(mobile);
this-> C.setTel(tel);
this->C.setEmail(Email);
}
void Patient::setDate(Date Date)
{
//cout << "Date of Birth:" << endl;
this-> DofB.setDay(Date.getDay());
this-> DofB.setMonth(Date.getMonth());
this-> DofB.setYear(Date.getYear());
}
//Get Functions...
string Patient::getName()
{
return name;
}
string Patient::getAddress()
{
return address;
}
Date Patient::getDate()
{
return DofB;
}
Contact Patient::getContact()
{
return C;
}
MedicalHistory* Patient::getMH()
{
return firstMedicalHistory;
}
//ostream & istream...
istream& operator >> (istream& is, Patient& P1)
{
char n[255] ;
cout << "Name: ";
cin.getline(n, 255);
P1.name = n;
cout << "Address: ";
cin.getline(n, 255);
P1.address = n;
is >> P1.DofB;
is >> P1.C;
return is;
}
ostream& operator << (ostream& os, Patient& P1)
{
os << "Name: " << P1.name << endl;
os << "Address: " << P1.address << endl;
cout << "Date of Birth:" << endl;
os << P1.DofB << endl;
os << P1.C << endl;
os << P1.firstMedicalHistory << endl;
return os;
}
istream& operator>>(istream& is,Patient *P1)
{
char n[255] ;
cout << "Name: ";
cin.getline(n, 255);
P1->setName(n);
cout << "Address: ";
cin.getline(n, 255);
P1->setAddress(n);
cout << "Date of Birth:" << endl;
is >> P1->DofB;
is >> P1->C;
cout << "___________________________________________________________" << endl;
cin.ignore();
return is;
}
void Patient::addMedicalHistory()
{
MedicalHistoryNum++;
MedicalHistory *currMedical = firstMedicalHistory;
MedicalHistory *MedH = new MedicalHistory;
if (firstMedicalHistory == NULL)
{
firstMedicalHistory = MedH;
cin >> firstMedicalHistory;
}
else
{
char c = 'y';
while (currMedical->getNextMedical() != NULL)
{
currMedical = currMedical->getNextMedical();
}
currMedical->setNextMedical(MedH);
cin >> MedH;
}
}
void Patient::printMed()
{
if(MedicalHistoryNum==0)
{
cout << "No medical History for this Patient..." << endl;
return;
}
MedicalHistory *currMed = firstMedicalHistory;
int i=0;
while (MedicalHistoryNum - i != 0)
{
cout << currMed << endl;
currMed=currMed->getNextMedical();
cout << "****************************************" << endl;
i++;
}
}
void Patient::SetFirstMH(MedicalHistory* MH)
{
firstMedicalHistory = MH;
}
////Destructors...
Patient::~Patient()
{
MedicalHistory* M = firstMedicalHistory;
while (firstMedicalHistory != NULL)
{
M = M->getNextMedical();
delete firstMedicalHistory;
firstMedicalHistory = M;
}
MedicalHistoryNum = 0;
}