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
| //Source.cpp
#include "Header.h"
#include <string>
#pragma warning(disable: 6386)
void Str_To_Date(string s, unsigned int& day, unsigned int& month, unsigned int& year) {
string help_str = "";
help_str = s.substr(0, s.find("."));
day = stoi(help_str);
help_str = "";
s = s.substr(s.find(".") + 1, s.size());
help_str = s.substr(0, s.find("."));
month = stoi(help_str);
help_str = "";
s = s.substr(s.find(".") + 1, s.size());
help_str = s.substr(0, s.find("."));
year = stoi(help_str);
}
void Add_Date(Patient& human, unsigned int pos, string date) {
unsigned int cur_day, cur_month, cur_year;
Str_To_Date(date, cur_day, cur_month, cur_year);
human.List_Of_Illness[pos].day = cur_day;
human.List_Of_Illness[pos].month = cur_month;
human.List_Of_Illness[pos].year = cur_year;
}
void Print_Patient(Patient& human) {
cout << "Фамилия: " << human.surname << endl;
cout << "Имя: " << human.name << endl;
cout << "Отчество: " << human.otchestvo << endl;
cout << "Номер полиса: " << human.number_polis << endl;
cout << "Заболевания: " << endl;
for (unsigned int j = 0; j < human.cur_length_of_illness; j++) {
cout << j + 1 << ": " << endl;
cout << "Код заболевания: " << human.List_Of_Illness[j].code << endl;
cout << "Дата заболевания: " << human.List_Of_Illness[j].day << '.'
<< human.List_Of_Illness[j].month << '.' << human.List_Of_Illness[j].year << endl;
}
}
void Print_Patients_Archive(Patients_Archive& Arch) {
cout << "_____________________________________" << endl;
for (unsigned int i = 0; i < Arch.cur_length_of_arch; i++) {
cout << "Номер пациента: " << i + 1 << endl;
Print_Patient(Arch.Body[i]);
cout << "_____________________________________" << endl;
}
}
void Print_Patients_Special_Spisok(Patients_Special_Spisok spisok) {
cout << "Список: " << endl;
cout << "_____________________________________" << endl;
for (unsigned int i = 0; i < spisok.length; i++) {
cout << "Номер пациента: " << i + 1 << endl;
Print_Patient(spisok.Body[i]);
cout << "_____________________________________" << endl;
}
}
void Increase_List(Patient& human, unsigned int old_size, unsigned int new_size) {
if (old_size == 0) {
human.List_Of_Illness = new Zabolevanie[new_size];
return;
}
Zabolevanie* new_spisok;
new_spisok = new Zabolevanie[new_size];
memcpy(new_spisok, human.List_Of_Illness, old_size * sizeof(Patient));
delete[] human.List_Of_Illness;
human.List_Of_Illness = new_spisok;
}
void Add_Illness(Patient& human) {
Increase_List(human, human.cur_length_of_illness, human.cur_length_of_illness + 1);
human.cur_length_of_illness++;
for (unsigned int i = human.cur_length_of_illness; i > 0; i--) {
human.List_Of_Illness[i] = human.List_Of_Illness[i - 1];
}
cout << "Введите код заболевания: ";
cin >> human.List_Of_Illness[0].code;
string date;
cout << "Введите дату заболевания: ";
cin >> date;
Add_Date(human, 0, date);
}
void Delete_Zabolevanie(Patient& human, unsigned int code) {
for (unsigned int i = 0; i < human.cur_length_of_illness; i++) {
if (human.List_Of_Illness[i].code == code) {
for (unsigned int j = i; j < human.cur_length_of_illness - 1; j++) {
human.List_Of_Illness[j] = human.List_Of_Illness[j + 1];
}
if (human.cur_length_of_illness == 1) {
delete[] human.List_Of_Illness;
human.cur_length_of_illness--;
}
else {
human.cur_length_of_illness--;
Increase_List(human, human.cur_length_of_illness, human.cur_length_of_illness);
}
return;
}
}
}
void Increase_Spisok(Patients_Special_Spisok& spisok, unsigned int new_size) {
Patient* new_spisok;
new_spisok = new Patient[new_size];
memcpy(new_spisok, spisok.Body, spisok.length * sizeof(Patient));
delete[] spisok.Body;
spisok.Body = new_spisok;
}
void Increase_Arch(Patients_Archive& Arch, unsigned int new_size) {
Patient* new_arch;
new_arch = new Patient[new_size];
memcpy(new_arch, Arch.Body, Arch.cur_length_of_arch * sizeof(Patient));
delete[] Arch.Body;
Arch.Body = new_arch;
}
void Add_Patient(Patients_Archive& Arch) {
Patient cur_patient;
cout << "Введите номер полиса: ";
cin >> cur_patient.number_polis;
cout << "Введите фамилию: ";
cin >> cur_patient.surname;
cout << "Введите имя: ";
cin >> cur_patient.name;
cout << "Введите отчество: ";
cin >> cur_patient.otchestvo;
unsigned int number_of_ill = 0;
cout << "Введите кол-во заболеваний: ";
cin >> number_of_ill;
if (number_of_ill != 0) {
cur_patient.List_Of_Illness = new Zabolevanie[number_of_ill];
cur_patient.cur_length_of_illness = number_of_ill;
unsigned int cur_code;
string cur_date;
for (unsigned int i = number_of_ill; i > 0; i--) {
cout << "Заболевание #" << number_of_ill - i + 1 << endl;
cout << "Введите код заболевания: ";
cin >> cur_code;
cout << "Введите дату заболевания: ";
cin >> cur_date;
cur_patient.List_Of_Illness[i - 1].code = cur_code;
Add_Date(cur_patient, i - 1, cur_date);
}
}
Increase_Arch(Arch, Arch.cur_length_of_arch + 1);
Arch.Body[Arch.cur_length_of_arch] = cur_patient;
Arch.cur_length_of_arch++;
}
Patients_Special_Spisok Form_Special_Spisok(Patients_Archive& Arch, unsigned int code) {
Patients_Special_Spisok spisok;
unsigned int cnt = 0;
for (unsigned int i = 0; i < Arch.cur_length_of_arch; i++) {
for (unsigned int j = 0; j <= Arch.Body[i].cur_length_of_illness; j++) {
if (Arch.Body[i].List_Of_Illness[j].code == code) {
cnt++;
}
}
if (cnt >= 2) {
Increase_Spisok(spisok, spisok.length + 1);
spisok.Body[spisok.length] = Arch.Body[i];
spisok.length++;
}
cnt = 0;
}
return spisok;
}
void Create_Archive(Patients_Archive& Arch) {
unsigned int new_length;
cout << "Введите кол-во пациентов: ";
cin >> new_length;
for (unsigned int i = 0; i < new_length; i++) {
cout << endl;
cout << "Введите пациента #" << i + 1 << ':' << endl;
Add_Patient(Arch);
}
} |