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<fstream> //input/output
//!! #include<conio.h> //para sa getch()
#include<string.h> //arrays
#include<iomanip>
#include<iostream> //std
#include<time.h> //time
#include<cstdlib> // system()
using namespace std;
void getch(){}
struct check_up {
char weight[30],
height[30],
bmi[30],
temp[30],
bloodP[30],
heart[30],
complications[30],
findings[30],
treatment[30];
};
int s;
char patient[30];
class personal {
int number;
char name[40],
ad[100],
bd[30],
con[100],
age[30],
sex[30];
public:
void add() //input personal info
{
cout << "\nPATIENT NUMBER: ";
cin >> number;
cout << "\nNAME: ";
cin.ignore();
cin.get(name, 40);
cout << "\nADDRESS: ";
cin.ignore();
cin.get(ad, 100);
cout << "\nBIRTHDATE: ";
cin.ignore();
cin.get(bd, 30);
cout << "\nAGE: ";
cin.ignore();
cin.get(age, 30);
cout << "\nSEX: ";
cin.ignore();
cin.get(sex, 30);
cout << "\nCONTACT NUMBER: ";
cin.ignore();
cin.get(con, 100);
cout << "\t\t\t\n\Information saved!\n" << endl;
system("pause");
}
void show() //print info
{
cout << "\nPATIENT: " << number;
cout << "\nNAME: " << name;
cout << "\nADDRESS: " << ad;
cout << "\nBIRTHDATE: " << bd;
cout << "\nAGE: " << age;
cout << "\nSEX: " << sex;
cout << "\nCONTACT NUMBER: " << con;
}
int getNumber() {
return number;
}
char *getName() {
return name;
}
char *getAddress() {
return ad;
}
char *getPhone() {
return con;
}
char *getbirthdate() {
return bd;
}
char *getage() {
return age;
}
char *getsex() {
return sex;
}
void report() {
cout << "\t\t" << number << setw(40) << name << endl;
}
};
fstream medical;
personal info;
void save()
{
system("cls");
int option;
medical.open("patient.dat", ios::out | ios::app);
info.add();
medical.write((char *) &info, sizeof(personal));
medical.close();
}
void locate(int number)
{
system("cls");
cout << "\n[ P E R S O N A L I N F O R M A T I O N ]\n";
int check = 0;
medical.open("patient.dat", ios::in);
while (medical.read((char *) &info, sizeof(personal))) {
if (info.getNumber() == number) {
info.show();
check = 1;
}
}
medical.close();
if (check == 0)
cout << "\n\n[PATIENT'S RECORD DOES NOT EXIST]";
getch();
}
void update()
{
system("cls");
int number;
int found = 0;
cout << "\n\n\tPATIENT NUMBER: ";
cin >> number;
medical.open("patient.dat", ios::in | ios::out);
while (medical.read((char *) &info, sizeof(personal)) && found == 0) {
if (info.getNumber() == number) {
info.show();
cout << "\n\nUPDATE PERSONAL INFORMATION" << endl;
info.add();
int pos = -1 * sizeof(info); //-1 delete first file to overwrite updates
medical.seekp(pos, ios::cur);
medical.write((char *) &info, sizeof(personal));
cout << "\n\n\t[SUCCESSFULLY UPDATED]";
found = 1;
}
}
medical.close();
if (found == 0)
cout << "\n\n [PATIENTS'S RECORD DOES NOT EXIST]";
getch();
}
void list()
{
system("cls");
medical.open("patient.dat", ios::in);
cout << "===================================================================\n";
cout << "\tPATIENT NUMBER" << setw(20) << "NAME" << endl;
cout << "\n==================================================================\n";
while (medical.read((char *) &info, sizeof(personal))) {
info.report();
}
medical.close();
getch();
}
void main_menu()
{
time_t rawtime; //codes for current time+date//
struct tm *timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
int s;
select:
cout << "\n\nHELLO!\n";
cout << "\nWHAT DO YOU WANT TO DO?\n\n";
cout << "1 RECORD NEW PATIENT\n";
cout << "2 LOCATE EXISTING MEDICAL RECORD\n";
cout << "3 UPDATE PATIENT'S PERSONAL INFROMATION\n";
cout << "4 VIEW LIST OF PATIENTS\n";
cout << "5 EXIT";
cout << "\nSelect: ";
cin >> s;
if (s == 1) {
save();
system("cls");
goto select;
}
if (s == 2) {
int number;
system("cls");
cout << "\n\n\tPATIENT NUMBER: ";
cin >> number;
locate(number);
system("cls");
goto select;
}
if (s == 3) {
update();
system("cls");
goto select;
}
if (s == 4) {
list();
system("cls");
goto select;
}
if (s == 5) {
exit(0);
}
}
enter() //codes para sa password//
{
string pass;
cout << "\n\nENTER PASSWORD:\n";
cin >> pass;
if (pass == "jerjer") {
system("cls");
} else {
cout << "\n\n[ACCESS DENIED]\n\n";
system("pause");
system("cls");
enter();
}
}
int main(int argc, char *argv[])
{
enter();
main_menu();
return 0;
}
|