Filter candidatos: only records where ALL exams are in configured TNS list (NOT EXISTS)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
b5e56f2238
commit
da99a446f1
@@ -82,7 +82,7 @@ async def get_candidatos(request: Request, user: dict = Depends(get_current_user
|
||||
return JSONResponse({"error": f"Error Firebird: {fb_msg}"})
|
||||
|
||||
# Artículos configurados con especialidad en TNS
|
||||
arts_default = "CH4,CREA,TGP,VSG,PCR,AU,FER,TPO,TSH,TGO,GLI,BUN,COL,TRI,HDL,LDL,HBA1,VB12,VITD,FER,K,NA,MG,URO,PRL,T4L,T3,T4,T3L,HIV,VDRL,PSA,AFP,CEA,CA125,CA199,FV,TP,TPT"
|
||||
arts_default = "CH4,CREA,TGP,VSG,PCR,AU,FER,TPO,TSH,TGO,GLI,BUN,COL,TRI,HDL,LDL,HBA1,VB12,VITD,PO,K,NA,MG,URO,PRL,T4L,T3,T4,T3L,HIV,VDRL,PSA,AFP,CEA,CA125,CA199,FV,TP,TPT"
|
||||
arts_str = articulos.strip() if articulos.strip() else arts_default
|
||||
arts_list = [a.strip().upper() for a in arts_str.split(",") if a.strip()]
|
||||
arts_in = ", ".join(f"'{a}'" for a in arts_list)
|
||||
@@ -91,7 +91,8 @@ async def get_candidatos(request: Request, user: dict = Depends(get_current_user
|
||||
"r.NUM_FACTURA > 0",
|
||||
"e.CODCONTRATO IS NOT NULL",
|
||||
"TRIM(e.CODCONTRATO) <> ''",
|
||||
f"rel.COD_EXAMEN IN ({arts_in})",
|
||||
# Solo registros donde TODOS los exámenes están en el listado permitido
|
||||
f"NOT EXISTS (SELECT 1 FROM RELACION rx WHERE rx.IDRECEPCION = r.IDRECEPCION AND rx.COD_EXAMEN NOT IN ({arts_in}))",
|
||||
]
|
||||
params = {}
|
||||
if contrato:
|
||||
|
||||
Reference in New Issue
Block a user