allow retest
This commit is contained in:
38
scripts/allow_retest_backdated.py
Normal file
38
scripts/allow_retest_backdated.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import os
|
||||||
|
import firebase_admin
|
||||||
|
from firebase_admin import credentials
|
||||||
|
from firebase_admin import firestore
|
||||||
|
from google.cloud.firestore_v1.base_query import FieldFilter
|
||||||
|
import pandas as pd
|
||||||
|
#import datetime
|
||||||
|
import sys
|
||||||
|
from datetime import datetime
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
cred = credentials.Certificate(os.getcwd() + '/keys/hpos-prod-firebase-adminsdk.json')
|
||||||
|
firebase_admin.initialize_app(cred)
|
||||||
|
|
||||||
|
db = firestore.client()
|
||||||
|
|
||||||
|
patient_collection = db.collection("patientData")
|
||||||
|
test_collection = db.collection("testData")
|
||||||
|
|
||||||
|
query = patient_collection.where(filter=FieldFilter("createdAt", ">=", "2023-10-30")).where(filter=FieldFilter("createdAt", "<", "2023-10-31"))
|
||||||
|
#.where(filter=FieldFilter("registrationCenterName", "==", "SCS high school"))
|
||||||
|
patient_docs = query.stream()
|
||||||
|
|
||||||
|
batch = db.batch()
|
||||||
|
|
||||||
|
data = []
|
||||||
|
for patient_doc in patient_docs:
|
||||||
|
patient_data = patient_doc.to_dict()
|
||||||
|
data.append(patient_data)
|
||||||
|
if "MAT" in patient_data['_id']:
|
||||||
|
print(patient_data['_id'])
|
||||||
|
doc_ref = db.collection("patientData").document(patient_doc.id)
|
||||||
|
|
||||||
|
delete_field_name = 'incubationTime'
|
||||||
|
|
||||||
|
batch.update(doc_ref, {"_idSearch": '20231201' + patient_data['_id'], delete_field_name: firestore.DELETE_FIELD, "incubationModified": True})
|
||||||
|
|
||||||
|
batch.commit()
|
||||||
Reference in New Issue
Block a user