2023-12-10 13:45:39 +05:30
|
|
|
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",
|
|
|
|
|
[
|
2024-01-16 15:29:30 +05:30
|
|
|
'957539044830HEMSAN','336694457928TRUSAN','952345130951PRIKES','867067867252SAMKES','833204928565KHUKES','621177486591TANKES','644852777735SAKKES','962439786909TANKES','735707478715MANKES','200338449939SIMKES','687100580009VAIKES','285966149202RUSKES','967578334682RAKKES','921021476789PIYKES'
|
2023-12-10 13:45:39 +05:30
|
|
|
]))
|
|
|
|
|
#.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'
|
|
|
|
|
|
2024-01-16 15:29:30 +05:30
|
|
|
batch.update(doc_ref, {
|
|
|
|
|
"_idSearch": '20231221' + patient_data['_id'],
|
|
|
|
|
delete_field_name: firestore.DELETE_FIELD,
|
|
|
|
|
"allowFreshTest": True,
|
|
|
|
|
"testStatus": False})
|
2023-12-10 13:45:39 +05:30
|
|
|
|
|
|
|
|
batch.commit()
|