change if condition for retestmarking
This commit is contained in:
@@ -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()
|
||||
});
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user