add retestMarking function

This commit is contained in:
Pritimay Sarkar
2023-09-27 09:37:56 +05:30
parent cd72470b51
commit ee8e11ff9b

View File

@@ -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()
});
}
};