You could just say `ti = queryResult.contains(patientId);` ...