@SuppressWarnings("unchecked") public OcsOrderWebServiceListVoCollection getPatientOrders(Integer patientId, Integer lastNumberOfDays) { if(patientId == null) throw new CodingRuntimeException("Invalid patient Id."); if(lastNumberOfDays == null || (lastNumberOfDays != null && lastNumberOfDays < 0)) return null; DomainFactory factory = getDomainFactory(); String query = "from OcsOrder ocsOrd where ocsOrd.patient.id = :patient and ocsOrd.systemInformation.creationDateTime >= :lastDate order by ocsOrd.systemInformation.creationDateTime desc"; List listOrder = factory.find(query, new String[] {"patient", "lastDate"}, new Object[] {patientId, (new DateTime()).addDays(-lastNumberOfDays).getJavaDate()}); return OcsOrderWebServiceListVoAssembler.createOcsOrderWebServiceListVoCollectionFromOcsOrderSession(listOrder); }