Complet exercici 3d
This commit is contained in:
parent
7fb7c113fd
commit
f272d52f10
1 changed files with 47 additions and 3 deletions
|
@ -20,6 +20,8 @@
|
||||||
#define MAX_PERSON_EMAIL_LEN 30
|
#define MAX_PERSON_EMAIL_LEN 30
|
||||||
#define MAX_PERSON_ADDRESS_LEN 30
|
#define MAX_PERSON_ADDRESS_LEN 30
|
||||||
#define VACCINE_TYPE_NAME "VACCINE"
|
#define VACCINE_TYPE_NAME "VACCINE"
|
||||||
|
#define DATE_LEN 10
|
||||||
|
#define TIME_LEN 5
|
||||||
|
|
||||||
// Get the API version information
|
// Get the API version information
|
||||||
const char* api_version() {
|
const char* api_version() {
|
||||||
|
@ -280,13 +282,15 @@ tApiError api_getVaccineLot(tApiData data, const char* cp, const char* vaccine,
|
||||||
|
|
||||||
vaccineLot_cpy(&found,data.vaccineLots.elems[index]);
|
vaccineLot_cpy(&found,data.vaccineLots.elems[index]);
|
||||||
|
|
||||||
// Fill buffer with data from the vaccine on that pointer
|
// Fill buffer with data from the vaccineLot
|
||||||
sprintf(buffer, "%02d/%02d/%04d;%02d:%02d;%s;%s;%d;%d;%d",
|
sprintf(buffer, "%02d/%02d/%04d;%02d:%02d;%s;%s;%d;%d;%d",
|
||||||
found.timestamp.date.day,found.timestamp.date.month,found.timestamp.date.year,
|
found.timestamp.date.day,found.timestamp.date.month,found.timestamp.date.year,
|
||||||
found.timestamp.time.hour,found.timestamp.time.minutes,
|
found.timestamp.time.hour,found.timestamp.time.minutes,
|
||||||
found.cp,
|
found.cp,
|
||||||
found.vaccine->name,found.vaccine->required,found.vaccine->days,
|
found.vaccine->name,found.vaccine->required,found.vaccine->days,
|
||||||
found.doses);
|
found.doses);
|
||||||
|
|
||||||
|
vaccineLot_free(&found);
|
||||||
|
|
||||||
// Init CSV entry and set values accordingly
|
// Init CSV entry and set values accordingly
|
||||||
csv_initEntry(entry);
|
csv_initEntry(entry);
|
||||||
|
@ -325,7 +329,7 @@ tApiError api_getVaccines(tApiData data, tCSVData *vaccines) {
|
||||||
// Reuse previous function to get a vaccine by name and have it stored in a CSVEntry
|
// Reuse previous function to get a vaccine by name and have it stored in a CSVEntry
|
||||||
if (api_getVaccine(data,currentVaccine->vaccine.name,&foundVaccine) == E_SUCCESS) {
|
if (api_getVaccine(data,currentVaccine->vaccine.name,&foundVaccine) == E_SUCCESS) {
|
||||||
|
|
||||||
// Read vaccine info from getVaccine() method
|
// Read vaccine info
|
||||||
csv_getAsString(foundVaccine,0,name,MAX_VACCINE_NAME_LEN+1);
|
csv_getAsString(foundVaccine,0,name,MAX_VACCINE_NAME_LEN+1);
|
||||||
required = csv_getAsInteger(foundVaccine,1);
|
required = csv_getAsInteger(foundVaccine,1);
|
||||||
days = csv_getAsInteger(foundVaccine,2);
|
days = csv_getAsInteger(foundVaccine,2);
|
||||||
|
@ -352,5 +356,45 @@ tApiError api_getVaccineLots(tApiData data, tCSVData *lots) {
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
// Ex PR1 3d
|
// Ex PR1 3d
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
return E_NOT_IMPLEMENTED;
|
|
||||||
|
tApiError ret = E_NOT_IMPLEMENTED;
|
||||||
|
tCSVEntry foundLot;
|
||||||
|
tVaccineLot currentVaccineLot;
|
||||||
|
char buffer[FILE_READ_BUFFER_SIZE];
|
||||||
|
tDateTime timestamp;
|
||||||
|
char date[DATE_LEN];
|
||||||
|
char time[TIME_LEN];
|
||||||
|
char cp [MAX_CP_LEN];
|
||||||
|
char vaccine [MAX_VACCINE_NAME_LEN];
|
||||||
|
int required;
|
||||||
|
int days;
|
||||||
|
int doses;
|
||||||
|
|
||||||
|
csv_init(lots);
|
||||||
|
|
||||||
|
for (int i = 0; i < data.vaccineLots.count; i++) {
|
||||||
|
|
||||||
|
vaccineLot_cpy(¤tVaccineLot,data.vaccineLots.elems[i]);
|
||||||
|
csv_initEntry(&foundLot);
|
||||||
|
|
||||||
|
if (api_getVaccineLot(data, currentVaccineLot.cp, currentVaccineLot.vaccine->name, currentVaccineLot.timestamp, &foundLot) == E_SUCCESS) {
|
||||||
|
|
||||||
|
// Fill buffer with data from the vaccinelot
|
||||||
|
sprintf(buffer, "%02d/%02d/%04d;%02d:%02d;%s;%s;%d;%d;%d",
|
||||||
|
currentVaccineLot.timestamp.date.day,currentVaccineLot.timestamp.date.month,currentVaccineLot.timestamp.date.year,
|
||||||
|
currentVaccineLot.timestamp.time.hour,currentVaccineLot.timestamp.time.minutes,
|
||||||
|
currentVaccineLot.cp,
|
||||||
|
currentVaccineLot.vaccine->name,currentVaccineLot.vaccine->required,currentVaccineLot.vaccine->days,
|
||||||
|
currentVaccineLot.doses);
|
||||||
|
|
||||||
|
csv_addStrEntry(lots,buffer,VACCINE_LOT_TYPE_NAME);
|
||||||
|
|
||||||
|
vaccineLot_free(¤tVaccineLot);
|
||||||
|
|
||||||
|
ret = E_SUCCESS;
|
||||||
|
|
||||||
|
}
|
||||||
|
csv_freeEntry(&foundLot);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue