public PatientElectiveListForWardViewVoCollection listPatientElectiveListForWardViewVo(LocationRefVo ward, Date tcidate) { StringBuilder query = new StringBuilder(); ArrayList<String> paramNames = new ArrayList<String>(); ArrayList<Object> paramValues = new ArrayList<Object>(); query.append("SELECT pel FROM PatientElectiveList AS pel "); query.append("LEFT JOIN pel.electiveListStatus AS els LEFT JOIN els.electiveListStatus AS elStatus "); query.append("LEFT JOIN pel.tCIDetails AS tci LEFT JOIN tci.tCIWard AS ward "); query.append("LEFT JOIN pel.patient AS patient "); query.append("WHERE ward.id = :WARD AND elStatus.id = :TCI_GIVEN AND tci.isActive = 1 AND tci.currentOutcome is null "); paramNames.add("WARD"); paramValues.add(ward.getID_Location()); paramNames.add("TCI_GIVEN"); paramValues.add(WaitingListStatus.TCI_GIVEN.getId()); if( tcidate != null) //wdev-19115 { query.append(" AND tci.tCIDate = :CURRENT_DATE"); paramNames.add("CURRENT_DATE"); paramValues.add(tcidate.getDate()); } query.append(" ORDER BY patient.name.surname, patient.name.forename"); return PatientElectiveListForWardViewVoAssembler.createPatientElectiveListForWardViewVoCollectionFromPatientElectiveList(getDomainFactory().find(query.toString(), paramNames, paramValues)); }