-
Notifications
You must be signed in to change notification settings - Fork 0
/
PATIENT.CPP
181 lines (150 loc) · 3.25 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
#include "patient.hpp"
#include <fstream.h>
///////FUNCTION DEFINITIONS FOR CLASS PATIENT/////////
patient::patient(str inp1, int inp2 , Date inp3, address inp4, phone inp5, disease inp6, str inp7, str inp8, phone inp9, insurance inp10, Date inp11) : person(inp1, inp2, inp3, inp4, inp5) //if date_of_admission is the current system date, last argument is not needed
{
fstream pat ("patient/max_id.dat", ios::in | ios::binary | ios::out);
long max_id;
pat.read( (char*) &max_id, sizeof(long) );
max_id++;
id = max_id;
pat.seekp(0);
pat.write( (char*) &max_id, sizeof(long) );
pat.close();
dis = inp6;
strcpy(guardian_name, inp7);
strcpy(emergency_contact, inp8);
strcpy(emer_contact_no, inp9);
insur_info = inp10;
admission_date = inp11;
Date dnow = system::get_date();
if( admission_date.day != dnow.day ||
admission_date.month != dnow.month ||
admission_date.year != dnow.year )
{
set_dob(inp3, inp11);
}
for(int i = 0; i < 50; i++){
med[i][0] = med[i][1] = 0;
}
bill_amt = 0; //bill_amt will be set by doctor after treatment
discharged = 0;
}
patient::patient()
{
id = 0;
}
long patient::get_id()
{
return id;
}
disease patient::get_dis()
{
return dis;
}
char* patient::get_guardian_name()
{
return guardian_name;
}
char* patient::get_emergency_contact()
{
return emergency_contact;
}
char* patient::get_emer_contact_no()
{
return emer_contact_no;
}
insurance patient::get_insur_info()
{
return insur_info;
}
int patient::get_admission_date(int inp)
{
switch(inp)
{
case DAY:
return admission_date.day;
case MONTH:
return admission_date.month;
case YEAR:
return admission_date.year;
default:
return 0;
}
}
int patient::get_discharge_date(int inp)
{
switch(inp)
{
case DAY:
return discharge_date.day;
case MONTH:
return discharge_date.month;
case YEAR:
return discharge_date.year;
default:
return 0;
}
}
unsigned long patient::get_bill_amt()
{
return bill_amt;
}
int patient::get_med(int a, int b){
return med[a][b];
}
transaction patient::get_transaction(int trans_num){
str temp;
transaction trans;
sprintf(temp, "patient/%d/trans.dat", this->id);
ifstream patient_file ( temp , ios::out | ios::binary | ios::app );
int i = 0;
while ( i<=trans_num && patient_file ){
patient_file.read( (char*) &trans , sizeof(transaction) );
i++;
}
if( i!= trans_num ){
trans = transaction(0);
}
patient_file.close();
return trans;
}
void patient::set_dis(disease a)
{
dis = a;
}
void patient::set_guardian_name(char *a)
{
strcpy(guardian_name, a);
}
void patient::set_emergency_contact(char *a)
{
strcpy(emergency_contact, a);
}
void patient::set_emer_contact_no(char *a)
{
strcpy(emer_contact_no, a);
}
void patient::set_insur_info(insurance a)
{
insur_info = a;
}
void patient::set_admission_date(Date a)
{
admission_date = a;
set_dob(dob, admission_date);
}
void patient::set_bill_amt(unsigned long a)
{
bill_amt = a;
}
void patient::set_med(int a, int b, int c){
med[a][0] = b;
med[a][1] = c;
}
void patient::set_discharge_date(Date inp){
discharge_date = inp;
}
void patient::discharge(){
discharged = 1;
}