add retestMarking function
This commit is contained in:
@@ -248,3 +248,31 @@ exports.migrateUsers = async (event, context) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered by a change to a Firestore document.
|
||||||
|
*
|
||||||
|
* @param {!Object} event Event payload.
|
||||||
|
* @param {!Object} context Metadata for the event.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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")) {
|
||||||
|
await admin.firestore().collection("patientData").where("_id", "==", _id.stringValue).update({
|
||||||
|
testStatus: false,
|
||||||
|
incubationTime: admin.firestore.FieldValue.delete()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user