Ali2206 commited on
Commit
943bcdc
·
verified ·
1 Parent(s): a909e24

Update api/routes/patients.py

Browse files
Files changed (1) hide show
  1. api/routes/patients.py +9 -6
api/routes/patients.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  from fastapi import APIRouter, HTTPException, Depends, Query, status, Body
3
  from db.mongo import patients_collection
4
  from core.security import get_current_user
@@ -339,16 +338,17 @@ async def import_patients(
339
  detail=f"Import failed: {str(e)}"
340
  )
341
 
342
- @router.get("/patients", response_model=List[dict])
343
  async def list_patients(
344
  search: Optional[str] = Query(None),
345
  min_notes: int = Query(0, ge=0),
346
  min_conditions: int = Query(0, ge=0),
347
  limit: int = Query(100, ge=1, le=500),
348
- skip: int = Query(0, ge=0)
 
349
  ):
350
  logger.info(f"Listing patients with search: {search}, limit: {limit}, skip: {skip}")
351
- query = {"source": "synthea"}
352
 
353
  if search:
354
  query["$or"] = [
@@ -411,8 +411,11 @@ async def list_patients(
411
  detail=f"Failed to retrieve patients: {str(e)}"
412
  )
413
 
414
- @router.get("/patients/{patient_id}", response_model=dict)
415
- async def get_patient(patient_id: str):
 
 
 
416
  logger.info(f"Retrieving patient: {patient_id}")
417
  try:
418
  patient = await patients_collection.find_one({
 
 
1
  from fastapi import APIRouter, HTTPException, Depends, Query, status, Body
2
  from db.mongo import patients_collection
3
  from core.security import get_current_user
 
338
  detail=f"Import failed: {str(e)}"
339
  )
340
 
341
+ @router.get("/", response_model=List[dict])
342
  async def list_patients(
343
  search: Optional[str] = Query(None),
344
  min_notes: int = Query(0, ge=0),
345
  min_conditions: int = Query(0, ge=0),
346
  limit: int = Query(100, ge=1, le=500),
347
+ skip: int = Query(0, ge=0),
348
+ current_user: dict = Depends(get_current_user)
349
  ):
350
  logger.info(f"Listing patients with search: {search}, limit: {limit}, skip: {skip}")
351
+ query = {}
352
 
353
  if search:
354
  query["$or"] = [
 
411
  detail=f"Failed to retrieve patients: {str(e)}"
412
  )
413
 
414
+ @router.get("/{patient_id}", response_model=dict)
415
+ async def get_patient(
416
+ patient_id: str,
417
+ current_user: dict = Depends(get_current_user)
418
+ ):
419
  logger.info(f"Retrieving patient: {patient_id}")
420
  try:
421
  patient = await patients_collection.find_one({