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
|
/* Functions are written in the in order as I implement them.
* "Diseño desendente" */
#include <iostream>
#include <iomanip>
#include <cstring> // strcmp
#include "fun.h"
using namespace std;
void readRecordsWriteReport()
{
char esp1[MAXLEN], esp2[MAXLEN], strfecha[MAXLEN];
// Header
cin >> esp1 >> esp2 >> strfecha;
writeHeader(esp1, esp2, strfecha);
// Medicos
readWriteMedicos();
}
void writeHeader(char *esp1, char *esp2, char *strfecha)
{
cout <<
" EMPRESA PRESTADORA DE SALUD\n"
"================================================================================\n"
"ESPECIALIDADES A VERIFICAR: " << esp1 << " Y " << esp2 << '\n' <<
"FECHA DEL PROCESO: " << strfecha << '\n' <<
"================================================================================\n"
;
// Note: formatting strfecha to (dd/mm/yyyy) is a lot of work for little
// benefit. Do later.
}
void readWriteMedicos()
{
char id[MAXLEN], name[MAXLEN];
while (cin >> id >> name) {
//cout << "Medico: " << id << name << '\n';
writeformattedMedico(id, name);
// Pacientes
readWritePacientes();
}
}
void readWritePacientes()
{
/* The trick here is that every Paciente begins with a number. So input
* will fail when there is no more Pacientes. Then clear the fail flag to
* resume with next Medico */
char name[MAXLEN];
int dni, qty;
while (cin >> dni >> name >> qty) {
//cout << " Paciente: " << dni << name << qty << '\n';
writeformattedPaciente(10, dni, name);
// Medicina
readWriteMedicinas(qty);
}
cin.clear();
}
void readWriteMedicinas(int n)
{
char name[MAXLEN], strfecha[MAXLEN];
int id;
while (n--) {
cin >> id >> name >> strfecha;
//cout << " Medicina: " << id << name << strfecha << '\n';
writeformattedMedicina(2, id, name, strfecha, n);
}
}
// Una vez con los datos leidos. Verificando que el ultimo medico y medicina se
// leen bien. Se procede a tratar de formatear bien la salida.
void writeformattedMedico(char *id, char *name)
{
char esp[MAXLEN] = "Ginecologia";
cout <<
"Medico: " << name << "[" << id << "] Especialidad: " << esp << '\n' <<
"--------------------------------------------------------------------------------\n"
" Pacientes atendidos Mediciinas recibidas\n"
"--------------------------------------------------------------------------------\n"
" DNI Nombre Cantidad Codigo Descripcion FV Obs. \n"
"--------------------------------------------------------------------------------\n"
;
}
void writeformattedPaciente(int i, int id, char *name)
{
cout << i << ") " << id << " " << name << " ";
}
void writeformattedMedicina(int i, int id, char *name, char *strfecha, int qty)
{
char obs[MAXLEN] = "VENCIDO";
if (i != 0) {
cout <<
" ";
} else {
cout << qty << " ";
}
cout << id << " " << name << " " << strfecha << " " << obs << '\n';
}
// TODO: formatting + resumen
|