2023-10-23 11:58:54 +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
|
|
|
|
|
|
2023-11-22 22:37:22 +05:30
|
|
|
cred = credentials.Certificate(os.getcwd() + '/keys/hpos-prod-firebase-adminsdk.json')
|
2023-10-23 11:58:54 +05:30
|
|
|
firebase_admin.initialize_app(cred)
|
|
|
|
|
|
|
|
|
|
db = firestore.client()
|
|
|
|
|
|
|
|
|
|
patient_collection = db.collection("patientData")
|
|
|
|
|
test_collection = db.collection("testData")
|
|
|
|
|
|
2023-11-08 14:01:53 +05:30
|
|
|
query = patient_collection.where(filter=FieldFilter("createdAt", ">=", "2023-11-07")).where(filter=FieldFilter("createdAt", "<", "2023-11-08"))
|
2023-11-02 11:52:33 +05:30
|
|
|
#.where(filter=FieldFilter("registrationCenterName", "==", "SCS high school"))
|
2023-10-23 11:58:54 +05:30
|
|
|
patient_docs = query.stream()
|
|
|
|
|
|
2023-11-22 22:37:22 +05:30
|
|
|
batch = db.batch()
|
|
|
|
|
|
2023-10-23 11:58:54 +05:30
|
|
|
data = []
|
|
|
|
|
for patient_doc in patient_docs:
|
|
|
|
|
patient_data = patient_doc.to_dict()
|
|
|
|
|
data.append(patient_data)
|
|
|
|
|
# print(patient_data['_idSearch'])
|
|
|
|
|
# if patient_data['_idSearch'] is None:
|
|
|
|
|
# # print(patient_doc.id)
|
|
|
|
|
# print(patient_data['_id'])
|
2023-11-03 15:29:23 +05:30
|
|
|
# print(patient_data['_id'])
|
2023-11-08 14:01:53 +05:30
|
|
|
if "LAL" in patient_data['_id']:
|
2023-11-03 15:29:23 +05:30
|
|
|
# print("ADA")
|
|
|
|
|
print(patient_data['_id'])
|
2023-11-22 22:37:22 +05:30
|
|
|
doc_ref = db.collection("patientData").document(patient_doc.id)
|
|
|
|
|
batch.update(doc_ref, {"_idSearch": '20231108' + patient_data['_id']})
|
|
|
|
|
|
|
|
|
|
batch.commit()
|
2023-10-23 11:58:54 +05:30
|
|
|
|