Skip to content

Commit

Permalink
feat: Refactor search_patient function to improve query accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
TanookiVerde committed Jan 10, 2025
1 parent f8873bc commit e948e8b
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions app/routers/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ async def search_patient(
LIMIT 1
""",
from_file="/tmp/credentials.json",
)[0]
cpf = result['cpf']
)
cpf = result[0]['cpf']

# --------------------------------
# SEARCH BY NAME OR CPF
Expand All @@ -144,16 +144,6 @@ async def search_patient(
name_cleaned = ''.join(c for c in unicodedata.normalize('NFD', name) if unicodedata.category(c) != 'Mn')
clause = f"search(nome,'{name_cleaned}')"

results = await read_bq(
f"""
SELECT
cpf
FROM `{BIGQUERY_PROJECT}`.{BIGQUERY_PATIENT_SEARCH_TABLE_ID}
WHERE {clause}
""",
from_file="/tmp/credentials.json",
)

user_permition_filter = user.role.permition.filter_clause.format(
user_cpf=user.cpf,
user_ap=user.data_source.ap,
Expand Down

0 comments on commit e948e8b

Please sign in to comment.