Spaces:
Sleeping
Sleeping
Update utils/db.py
Browse files- utils/db.py +17 -0
utils/db.py
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from db.mongo import patients_collection
|
| 2 |
+
import logging
|
| 3 |
+
|
| 4 |
+
logging.basicConfig(level=logging.INFO)
|
| 5 |
+
logger = logging.getLogger(__name__)
|
| 6 |
+
|
| 7 |
+
async def create_indexes():
|
| 8 |
+
try:
|
| 9 |
+
# Create indexes for patients_collection
|
| 10 |
+
await patients_collection.create_index("fhir_id", unique=True)
|
| 11 |
+
await patients_collection.create_index("full_name", background=True)
|
| 12 |
+
await patients_collection.create_index("date_of_birth", background=True)
|
| 13 |
+
await patients_collection.create_index("source", background=True)
|
| 14 |
+
logger.info("Indexes created successfully for patients_collection")
|
| 15 |
+
except Exception as e:
|
| 16 |
+
logger.error(f"Failed to create indexes: {str(e)}")
|
| 17 |
+
raise
|