add turn around time script
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,4 +2,5 @@
|
||||
env/
|
||||
.DS_Store
|
||||
*.xlsx
|
||||
*.csv
|
||||
*.csv
|
||||
*.json
|
||||
39
scripts/tat.py
Normal file
39
scripts/tat.py
Normal file
@@ -0,0 +1,39 @@
|
||||
import firebase_admin
|
||||
from firebase_admin import firestore
|
||||
import os
|
||||
from datetime import datetime
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
file_path = os.getcwd() + '/keys' + '/hpos-prod-firebase-adminsdk-bionp-7af43fc5d6.json'
|
||||
cred = firebase_admin.credentials.Certificate(fr'{file_path}')
|
||||
|
||||
firebase_admin.initialize_app(cred)
|
||||
|
||||
db = firestore.client()
|
||||
|
||||
registrations = db.collection("patientData").stream()
|
||||
hpos_tests = db.collection("testData").stream()
|
||||
|
||||
# print([doc.to_dict() for doc in patient_collection.stream()])
|
||||
|
||||
for registration in registrations:
|
||||
registration_dic = registration.to_dict()
|
||||
# print(registration_dic["_id"])
|
||||
# hpos_test = filter(lambda x: x.to_dict()["_id"] != registration_dic["_id"], hpos_tests)
|
||||
# print(list(hpos_test))
|
||||
|
||||
test_docs = db.collection("testData").where("_id", "==", registration_dic["_id"]).stream()
|
||||
|
||||
for test_doc in test_docs:
|
||||
test_data = test_doc.to_dict()
|
||||
|
||||
# Combine the data from both collections into a single dictionary
|
||||
combined_data = {**registration_dic, **test_data}
|
||||
|
||||
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)
|
||||
|
||||
firebase_admin.delete_app(firebase_admin.get_app())
|
||||
Reference in New Issue
Block a user