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
|
#include<iostream>
#include<string>
#include<cstring>
//#include<conio.h>
//#include<windows.h>
//#include<time.h>
//#pragma comment(lib, "user32")
using namespace std;
struct patient_info {
int id;
char name[22];
char adress[200];
char contact[12];
char cnic[13];
int age;
char sex[8];
char blood_gp[5];
char disease_past[50];
};
////////////////////////////Function Declaration//////////////////////////////
// Deleted distraction fluff
//int login(void);
//int header(void);
//int footer(void);
//int lpd(void);
//int load(void);
// This gets a lot easier if you start using actual C++ and
// have vector<patient_info> data;
int menu(patient_info data[], int &num_patients);
//void gotoxy(short x, short y);
int main()
{
patient_info data[10];
int num_patients = 0;
do {
;
} while ( menu(data, num_patients) != 5 );
}
void doAddPatient(patient_info data[], int &num_patients)
{
cout << "Enter Patient Details" << endl;
cout << "ID :: ";
cin.ignore();
cin >> data[num_patients].id;
cout << "Name :: ";
cin.ignore();
cin.getline(data[num_patients].name,sizeof(data[num_patients].name));
cout << "Address ::";
cin.getline(data[num_patients].adress,sizeof(data[num_patients].adress));
cout << "Contact ::";
cin >> data[num_patients].contact;
cout << "CNIC/NTN :: ";
cin.ignore();
cin >> data[num_patients].cnic;
cout << "Age :: ";
cin >> data[num_patients].age;
cout << "Sex :: ";
cin.ignore();
cin >> data[num_patients].sex;
cout << "Blood Group:: ";
cin >> data[num_patients].blood_gp;
cout << "Past Disease(if any) :: ";
cin >> data[num_patients].disease_past;
num_patients++;
}
void printPatient(const patient_info &patient)
{
cout << "Patient info\n";
cout << " ID ::" << patient.id << endl;
cout << " Name ::" << patient.name << endl;
cout << " Address ::" << patient.adress << endl;
cout << " Contact ::" << patient.contact << endl;
cout << " CNIC/NTN ::" << patient.cnic << endl;
cout << " Age ::" << patient.age << endl;
cout << " Sex ::" << patient.sex << endl;
cout << "Blood Group ::" << patient.blood_gp << endl;
cout << "Past Disease::" << patient.disease_past << endl;
}
void doSearchID(patient_info data[], int &num_patients)
{
cout << "Enter Patieint id::";
int num;
cin >> num;
for (int i = 0; i < num_patients; i++) {
if (data[i].id == num) {
printPatient(data[i]);
}
}
}
void doSearchCNIC_NTN(patient_info data[], int &num_patients)
{
char sr[13];
cout << "Search By Patient CNIC/NTN\n";
cout << "Enter Patient CNIC/NTN-->";
cin >> sr;
for (int i = 0; i < num_patients; i++) {
if ( strcmp(data[i].cnic,sr) == 0 ) {
printPatient(data[i]);
}
}
}
void doSearch(patient_info data[], int &num_patients)
{
int option;
cout << "Search For A Patint" << endl;
cout << "1 >> Search by ID" << endl;
cout << "2 >> Search by CNIC/NTN" << endl;
cout << "Enter Your Choice-->";
cin >> option;
if ( option == 1 )
doSearchID(data, num_patients);
else if ( option == 2 )
doSearchCNIC_NTN(data, num_patients);
}
int menu(patient_info data[], int &num_patients)
{
int option;
cout << "Please, Choose from the following Options: \n\n";
cout << "1 >> Add New Patient Record\n";
cout << "2 >> Search For A Patint\n";
cout << "3 >> Delete Patient Record\n";
cout << "4 >> Display All Admitted Patients\n";
cout << "5 >> Exit the Program\n";
do {
cout << "Enter your choice--> ";
cin >> option;
} while ( option < 1 || option > 5 );
if ( option == 1 ) doAddPatient(data, num_patients);
else if ( option == 2 ) doSearch(data, num_patients);
// add two more lines here to call two more functions
return option;
}
|