calculate tat for currentday
This commit is contained in:
@@ -1,22 +1,25 @@
|
||||
import firebase_admin
|
||||
from firebase_admin import firestore
|
||||
import os
|
||||
from datetime import datetime
|
||||
from datetime import datetime, date, timedelta
|
||||
from google.cloud.firestore_v1.base_query import FieldFilter
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
file_path = os.getcwd() + '/keys' + '/hpos-prod-firebase-adminsdk-bionp-7af43fc5d6.json'
|
||||
file_path = os.getcwd() + '/keys' + '/hpos-prod-firebase-adminsdk-bionp-3c041b2300.json'
|
||||
cred = firebase_admin.credentials.Certificate(fr'{file_path}')
|
||||
|
||||
firebase_admin.initialize_app(cred)
|
||||
|
||||
db = firestore.client()
|
||||
|
||||
registrations = db.collection("patientData").stream()
|
||||
registrations = db.collection("patientData").where(filter = FieldFilter("createdAt", ">", str(date.today()))).stream()
|
||||
hpos_tests = db.collection("testData").stream()
|
||||
|
||||
# print([doc.to_dict() for doc in patient_collection.stream()])
|
||||
|
||||
total_deta = timedelta(minutes=0)
|
||||
total_count = 0
|
||||
for registration in registrations:
|
||||
registration_dic = registration.to_dict()
|
||||
# print(registration_dic["_id"])
|
||||
@@ -34,6 +37,9 @@ if __name__ == "__main__":
|
||||
start_time = combined_data["createdAt"]
|
||||
end_time = combined_data["testTime"]
|
||||
delta = datetime.strptime(end_time, "%Y-%m-%d %H:%M:%S") - datetime.strptime(start_time, "%Y-%m-%d %H:%M:%S")
|
||||
print(combined_data["createdAt"], combined_data["testTime"], delta)
|
||||
total_deta = total_deta + delta
|
||||
total_count = total_count + 1
|
||||
print(combined_data['_id'], combined_data["createdAt"], combined_data["testTime"], delta)
|
||||
|
||||
print("TAT:", total_deta / total_count)
|
||||
firebase_admin.delete_app(firebase_admin.get_app())
|
||||
|
||||
Reference in New Issue
Block a user