change if condition for retestmarking

This commit is contained in:
Pritimay Sarkar
2023-09-30 14:01:44 +05:30
parent ba637f1600
commit e7a30fc7a1

View File

@@ -262,21 +262,30 @@ const admin = require("firebase-admin");
admin.initializeApp();
exports.retestMarking = async (event, context) => {
const resource = context.resource;
// log out the resource string that triggered the function
console.log('Function triggered by change to: ' + resource);
// now log the full event object
console.log(JSON.stringify(event));
const { _id, classificationResult } = event.value.fields;
console.log("classificationResult", classificationResult.stringValue);
if (classificationResult?.stringValue?.includes("Negative Borderline")) {
const docs = await admin.firestore().collection("patientData").where("_id", "==", _id.stringValue).get();
docs?.forEach(async (doc) => {
await admin.firestore().collection("patientData").doc(doc.id).update({
testStatus: false,
retested: true
// incubationTime: admin.firestore.FieldValue.delete()
});
})
}
};
const resource = context.resource;
// log out the resource string that triggered the function
console.log('Function triggered by change to: ' + resource);
// now log the full event object
console.log(JSON.stringify(event));
const { _id, classificationResult } = event.value.fields;
console.log("classificationResult", classificationResult.stringValue);
if (classificationResult?.stringValue?.includes("Negative Borderline")) {
const docs = await admin.firestore().collection("patientData").where("_id", "==", _id.stringValue).get();
docs?.forEach(async (doc) => {
await admin.firestore().collection("patientData").doc(doc.id).update({
testStatus: false,
retested: true
// incubationTime: admin.firestore.FieldValue.delete()
});
})
} else if (classificationResult?.stringValue?.includes("Inconclusive")) {
const docs = await admin.firestore().collection("patientData").where("_id", "==", _id.stringValue).get();
docs?.forEach(async (doc) => {
await admin.firestore().collection("patientData").doc(doc.id).update({
testStatus: false,
retested: true
// incubationTime: admin.firestore.FieldValue.delete()
});
})
}
};