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