Spaces:
Runtime error
Runtime error
Download debug_data.py from Darshankumarr03/Swift-Query: direct link, hf CLI and curl.
- Browser
- Download file 1.41 kB
-
https://huggingface.co/spaces/Darshankumarr03/Swift-Query/resolve/main/debug_data.py
- Command line
-
hf download hf://spaces/Darshankumarr03/Swift-Query/debug_data.py
-
curl -L -o debug_data.py https://huggingface.co/spaces/Darshankumarr03/Swift-Query/resolve/main/debug_data.py
1.41 kB
| from flask import Flask | |
| from utils.db.db import init_db, mongo | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| app = Flask(__name__) | |
| app.config["MONGO_URI"] = os.environ.get("MONGO_URI").replace("mongodb.net/?", "mongodb.net/swiftquery?") | |
| init_db(app) | |
| with app.app_context(): | |
| # 1. Find the patient | |
| patient = mongo.db.patient.find_one({"id": 1001}) | |
| if not patient: | |
| patient = mongo.db.patient.find_one({"id": "1001"}) | |
| if not patient: | |
| print("Patient 1001 NOT FOUND") | |
| else: | |
| print(f"Found Patient: {patient.get('name')} (ID: {patient.get('id')}, Type: {type(patient.get('id'))})") | |
| pid = patient.get('id') | |
| # 2. Check collections | |
| colls = ['consultation', 'medicalhistory', 'treatment', 'testreport', 'chatsession'] | |
| for c in colls: | |
| count_int = mongo.db[c].count_documents({"patient_id": int(pid) if str(pid).isdigit() else pid}) | |
| count_str = mongo.db[c].count_documents({"patient_id": str(pid)}) | |
| print(f"Collection '{c}': Int-ID matches: {count_int}, Str-ID matches: {count_str}") | |
| # Print one sample if exists | |
| if count_int > 0: | |
| print(f" Sample (Int): {mongo.db[c].find_one({'patient_id': int(pid)})}") | |
| elif count_str > 0: | |
| print(f" Sample (Str): {mongo.db[c].find_one({'patient_id': str(pid)})}") | |