add retest with ids script
This commit is contained in:
44
scripts/allow_retest_backdated_ids.py
Normal file
44
scripts/allow_retest_backdated_ids.py
Normal file
@@ -0,0 +1,44 @@
|
||||
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("_id", "in",
|
||||
[
|
||||
'xyx','xyz'
|
||||
]))
|
||||
#.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)
|
||||
print(patient_data['_id'])
|
||||
doc_ref = db.collection("patientData").document(patient_doc.id)
|
||||
|
||||
delete_field_name = 'incubationTime'
|
||||
|
||||
# batch.update(doc_ref, {
|
||||
# "_idSearch": '20231209' + patient_data['_id'],
|
||||
# # delete_field_name: firestore.DELETE_FIELD,
|
||||
# "allowFreshTest": True,
|
||||
# "testStatus": False})
|
||||
|
||||
batch.commit()
|
||||
Reference in New Issue
Block a user