Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMSEDT-186: Data Validation #53

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/src/aqi_api/aqi_api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ export class AqiApiService {
},
},
);
this.logger.log("AQI SPECIMEN DELETION: " + aqiDeletion.data);
this.logger.log("AQI SPECIMEN DELETION: " + aqiDeletion.status);

try {
const dbDeletion = await this.prisma.aqi_specimens.delete({
Expand Down Expand Up @@ -659,7 +659,7 @@ export class AqiApiService {
},
},
);
this.logger.log("AQI ACTIVITY DELETION: " + aqiDeletion.data);
this.logger.log("AQI ACTIVITY DELETION: " + aqiDeletion.status);

try {
const dbDeletion = await this.prisma.aqi_field_activities.delete({
Expand Down Expand Up @@ -698,7 +698,7 @@ export class AqiApiService {
},
},
);
this.logger.log("AQI VISIT DELETION: " + deletion.data);
this.logger.log("AQI VISIT DELETION: " + deletion.status);

try {
const dbDeletion = await this.prisma.aqi_field_visits.delete({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,15 @@ export class FileParseValidateService {
const methodId = lookupResult.method_id;
const methodContext = lookupResult.method_context;
const methodName = lookupResult.method_name;

const concatAnalysisMethod = String(methodId) + ';' + String(methodName) + ';' + String(methodContext);

const concatAnalysisMethod =
String(methodId) +
";" +
String(methodName) +
";" +
String(methodContext);
// Add quotes around the newAnalysisMethod only if it isn't already enclosed in quotes
newObs["Lab: Analysis Method"] = concatAnalysisMethod
newObs["Lab: Analysis Method"] = concatAnalysisMethod;
}
}

Expand Down Expand Up @@ -1292,12 +1297,13 @@ export class FileParseValidateService {

ministryContacts.add(fieldVisit.MinistryContact); // getting the ministry contacts (this will result in a unique list at the end of all rows)

if (
rowData.DataClassification == "VERTICAL_PROFILE" ||
rowData.DataClassification == "FIELD_RESULT"
) {
if (rowData.DataClassification == "VERTICAL_PROFILE") {
rowData.SpecimenName = "";
rowData.ActivityName = "";
}

if (rowData.DataClassification == "FIELD_RESULT") { // TODO: add VERTICAL_PROFILE to this if when AQI fixed their bug and remove the if block above this
rowData.SpecimenName = "";
rowData.ActivityName == "";
}

const observation = this.filterFile<Observations>(
Expand All @@ -1312,13 +1318,12 @@ export class FileParseValidateService {
rowNumber,
);

const csvRow = Object.values(obsRecord)
const csvRow = Object.values(obsRecord);

csvStream.write(csvRow)
csvStream.write(csvRow);

this.logger.log(`Created observation object for row ${rowNumber}`);


this.logger.log(
`Wrote observation object to file for row ${rowNumber}`,
);
Expand Down Expand Up @@ -1445,8 +1450,14 @@ export class FileParseValidateService {
const rowData: Record<string, string> = rowHeaders
.map((header, colNumber) => {
const cellValue = row.getCell(colNumber + 1).value; // using getCell to access value with a 1-based index pattern
const value =
typeof cellValue === "object" &&
cellValue != null &&
"result" in cellValue
? cellValue.result
: cellValue ?? "";
return {
[header]: String(cellValue ?? ""),
[header]: String(value),
};
})
.reduce((acc, curr) => ({ ...acc, ...curr }), {});
Expand Down Expand Up @@ -1480,10 +1491,11 @@ export class FileParseValidateService {
null,
);

if (
rowData.DataClassification == "VERTICAL_PROFILE" ||
rowData.DataClassification == "FIELD_RESULT"
) {
if (rowData.DataClassification == "VERTICAL_PROFILE") {
specimen.SpecimenName = "";
}

if (rowData.DataClassification == "FIELD_RESULT") { // TODO: add VERTICAL_PROFILE to this if when AQI fixed their bug and remove the if block above this
specimen.SpecimenName = "";
fieldActivity.ActivityName == "";
}
Expand Down Expand Up @@ -2055,10 +2067,11 @@ export class FileParseValidateService {
null,
);

if (
rowData.DataClassification == "VERTICAL_PROFILE" ||
rowData.DataClassification == "FIELD_RESULT"
) {
if (rowData.DataClassification == "VERTICAL_PROFILE") {
specimen.SpecimenName = "";
}

if (rowData.DataClassification == "FIELD_RESULT") { // TODO: add VERTICAL_PROFILE to this if when AQI fixed their bug and remove the if block above this
specimen.SpecimenName = "";
fieldActivity.ActivityName == "";
}
Expand Down
Loading