List of usage examples for org.hibernate.criterion Restrictions between
public static Criterion between(String propertyName, Object low, Object high)
From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) @Override/*from w ww . j a v a 2s . c om*/ public Integer getNumberOfNewClientsTestedAndReceivedResults(String from, String to, Integer locationId, String admissionMode, Integer minAge, Integer maxAge, String gender) { List<VCTClient> result = new ArrayList<VCTClient>(); try { List<VCTClient> clientList = getSession().createCriteria(VCTClient.class) .add(Restrictions.eq("registrationEntryPoint", admissionMode)) .add(Restrictions.eq("location", Context.getLocationService().getLocation(locationId))) .add(Restrictions.isNotNull("codeTest")).add(Restrictions.isNotNull("resultObs")) .add(Restrictions.between("dateOfRegistration", Context.getDateFormat().parse(from), Context.getDateFormat().parse(to))) .list(); for (VCTClient c : clientList) { Person p = c.getClient(); if (p.getGender().compareToIgnoreCase(gender) == 0 && (p.getAge() >= minAge)) if (maxAge > 0) { if (p.getAge() < maxAge) { if (VCTModuleTag .convsetObsValueByConcept(c.getResultObs(), VCTConfigurationUtil.getDateResultOfHivTestReceivedConceptId()) .compareTo("-") != 0) result.add(c); } } else { if (VCTModuleTag .convsetObsValueByConcept(c.getResultObs(), VCTConfigurationUtil.getDateResultOfHivTestReceivedConceptId()) .compareTo("-") != 0) result.add(c); } } } catch (Exception e) { log.error(">>>VCT>>Number>>of>>new>>clients>>counseled>>and>>tested>>for>>hiv>> from: " + from + ", to: " + to + ", location: " + locationId + ", admissionMode: " + admissionMode + ", minAge: " + minAge + ", maxAge: " + maxAge + ", gender: " + gender); e.printStackTrace(); } return result.size(); }
From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java
License:Open Source License
@SuppressWarnings({ "unchecked" }) @Override//from w w w . j a v a 2 s . co m public Integer getNumberOfHIVPositiveClients(String from, String to, Integer locationId, String admissionMode, Integer minAge, Integer maxAge, String gender) { List<VCTClient> result = new ArrayList<VCTClient>(); try { List<VCTClient> clientList = getSession().createCriteria(VCTClient.class) .add(Restrictions.eq("registrationEntryPoint", admissionMode)) .add(Restrictions.eq("location", Context.getLocationService().getLocation(locationId))) .add(Restrictions.isNotNull("resultObs")).add(Restrictions.between("dateOfRegistration", Context.getDateFormat().parse(from), Context.getDateFormat().parse(to))) .list(); for (VCTClient c : clientList) { Person p = c.getClient(); if (p.getGender().compareToIgnoreCase(gender) == 0 && (p.getAge() >= minAge)) if (maxAge > 0) { if (p.getAge() < maxAge) { if (VCTModuleTag .convsetObsValueByConcept(c.getResultObs(), VCTTracConstant.RESULT_OF_HIV_TEST) .compareTo(Context.getConceptService().getConcept(VCTTracConstant.POSITIVE_CID) .getDisplayString()) == 0) result.add(c); } } else { if (VCTModuleTag .convsetObsValueByConcept(c.getResultObs(), VCTTracConstant.RESULT_OF_HIV_TEST) .compareTo(Context.getConceptService().getConcept(VCTTracConstant.POSITIVE_CID) .getDisplayString()) == 0) result.add(c); } } } catch (Exception e) { log.error(">>>VCT>>Number>>of>>new>>clients>>counseled>>and>>tested>>for>>hiv>> from: " + from + ", to: " + to + ", location: " + locationId + ", admissionMode: " + admissionMode + ", minAge: " + minAge + ", maxAge: " + maxAge + ", gender: " + gender); e.printStackTrace(); } return result.size(); }
From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java
License:Open Source License
/** * @see org.openmrs.module.vcttrac.db.VCTModuleDAO#getCouplesCounseled(java.lang.String, * java.lang.String, java.lang.Integer) */// ww w .ja v a 2s . c o m @SuppressWarnings("unchecked") @Override public List<VCTClient> getCouplesCounseled(String from, String to, Integer locationId) { List<VCTClient> couplesCounseled = new ArrayList<VCTClient>(); try { couplesCounseled = getSession().createCriteria(VCTClient.class) .add(Restrictions.eq("typeOfCounseling", 2)).add(Restrictions.isNotNull("counselingObs")) .add(Restrictions.eq("location", Context.getLocationService().getLocation(locationId))) .add(Restrictions.between("dateOfRegistration", Context.getDateFormat().parse(from), Context.getDateFormat().parse(to))) .list(); } catch (Exception e) { log.error(">>>VCT>>Number>>of>>Couples>>Counseled>>And>>Tested>>for>>hiv>> from: " + from + ", to: " + to + ", location: " + locationId); e.printStackTrace(); } return couplesCounseled; }
From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override// w w w. j a v a 2s. c o m public List<VCTClient> getHIVPositiveClients(String from, String to, Integer locationId, String admissionMode, Integer minAge, Integer maxAge, String gender) { List<VCTClient> result = new ArrayList<VCTClient>(); try { List<VCTClient> clientList = getSession().createCriteria(VCTClient.class) .add(Restrictions.eq("registrationEntryPoint", admissionMode)) .add(Restrictions.eq("location", Context.getLocationService().getLocation(locationId))) .add(Restrictions.isNotNull("resultObs")).add(Restrictions.between("dateOfRegistration", Context.getDateFormat().parse(from), Context.getDateFormat().parse(to))) .list(); for (VCTClient c : clientList) { Person p = c.getClient(); if (p.getGender().compareToIgnoreCase(gender) == 0 && (p.getAge() >= minAge)) if (maxAge > 0) { if (p.getAge() < maxAge) { if (VCTModuleTag .convsetObsValueByConcept(c.getResultObs(), VCTTracConstant.RESULT_OF_HIV_TEST) .compareTo(Context.getConceptService().getConcept(VCTTracConstant.POSITIVE_CID) .getDisplayString()) == 0) result.add(c); } } else { if (VCTModuleTag .convsetObsValueByConcept(c.getResultObs(), VCTTracConstant.RESULT_OF_HIV_TEST) .compareTo(Context.getConceptService().getConcept(VCTTracConstant.POSITIVE_CID) .getDisplayString()) == 0) result.add(c); } } } catch (Exception e) { log.error(">>>VCT>>Number>>of>>new>>clients>>counseled>>and>>tested>>for>>hiv>> from: " + from + ", to: " + to + ", location: " + locationId + ", admissionMode: " + admissionMode + ", minAge: " + minAge + ", maxAge: " + maxAge + ", gender: " + gender); e.printStackTrace(); } return result; }
From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//from ww w . j a va 2s. c o m public List<VCTClient> getNewClientsCounseledAndTestedForHIV(String from, String to, Integer locationId, String admissionMode, Integer minAge, Integer maxAge, String gender) { List<VCTClient> result = new ArrayList<VCTClient>(); try { List<VCTClient> clientList = getSession().createCriteria(VCTClient.class) .add(Restrictions.eq("registrationEntryPoint", admissionMode)) .add(Restrictions.eq("location", Context.getLocationService().getLocation(locationId))) .add(Restrictions.isNotNull("counselingObs")).add(Restrictions.isNotNull("codeTest")) .add(Restrictions.between("dateOfRegistration", Context.getDateFormat().parse(from), Context.getDateFormat().parse(to))) .list(); for (VCTClient c : clientList) { Person p = c.getClient(); if (p.getGender().compareToIgnoreCase(gender) == 0 && (p.getAge() >= minAge)) if (maxAge > 0) { if (p.getAge() < maxAge) result.add(c); } else result.add(c); } } catch (Exception e) { log.error(">>>VCT>>Number>>of>>new>>clients>>counseled>>and>>tested>>for>>hiv>> from: " + from + ", to: " + to + ", location: " + locationId + ", admissionMode: " + admissionMode + ", minAge: " + minAge + ", maxAge: " + maxAge + ", gender: " + gender); e.printStackTrace(); } return result; }
From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java
License:Open Source License
@SuppressWarnings("unchecked") @Override//w w w .j a va 2 s .c om public List<VCTClient> getNewClientsTestedAndReceivedResults(String from, String to, Integer locationId, String admissionMode, Integer minAge, Integer maxAge, String gender) { List<VCTClient> result = new ArrayList<VCTClient>(); try { List<VCTClient> clientList = getSession().createCriteria(VCTClient.class) .add(Restrictions.eq("registrationEntryPoint", admissionMode)) .add(Restrictions.eq("location", Context.getLocationService().getLocation(locationId))) .add(Restrictions.isNotNull("codeTest")).add(Restrictions.isNotNull("resultObs")) .add(Restrictions.between("dateOfRegistration", Context.getDateFormat().parse(from), Context.getDateFormat().parse(to))) .list(); for (VCTClient c : clientList) { Person p = c.getClient(); if (p.getGender().compareToIgnoreCase(gender) == 0 && (p.getAge() >= minAge)) if (maxAge > 0) { if (p.getAge() < maxAge) { if (VCTModuleTag .convsetObsValueByConcept(c.getResultObs(), VCTConfigurationUtil.getDateResultOfHivTestReceivedConceptId()) .compareTo("-") != 0) result.add(c); } } else { if (VCTModuleTag .convsetObsValueByConcept(c.getResultObs(), VCTConfigurationUtil.getDateResultOfHivTestReceivedConceptId()) .compareTo("-") != 0) result.add(c); } } } catch (Exception e) { log.error(">>>VCT>>Number>>of>>new>>clients>>counseled>>and>>tested>>for>>hiv>> from: " + from + ", to: " + to + ", location: " + locationId + ", admissionMode: " + admissionMode + ", minAge: " + minAge + ", maxAge: " + maxAge + ", gender: " + gender); e.printStackTrace(); } return result; }
From source file:org.opennms.features.poller.remote.gwt.server.LocationBroadcastProcessor.java
License:Open Source License
/** * <p>afterPropertiesSet</p> * * @throws java.lang.Exception if any.//from w w w . j a va 2 s. co m */ @Override public void afterPropertiesSet() throws Exception { BeanUtils.assertAutowiring(this); m_task = new TimerTask() { private Date m_lastRun = new Date(); @Override public void run() { final Date now = new Date(); final OnmsCriteria criteria = new OnmsCriteria(OnmsEvent.class) .add(Restrictions.between("eventTime", m_lastRun, now)) .add(Restrictions.in("eventUei", m_events)); for (final OnmsEvent e : m_eventDao.findMatching(criteria)) { handleLocationEvent(e); } m_lastRun = now; } }; //m_timer.schedule(m_task, UPDATE_PERIOD, UPDATE_PERIOD); }
From source file:org.opennms.web.filter.BetweenFilter.java
License:Open Source License
/** {@inheritDoc} */ @Override public Criterion getCriterion() { return Restrictions.between(getPropertyName(), getFirst(), getLast()); }
From source file:org.oscarehr.casemgmt.dao.CaseManagementNoteDAO.java
License:Open Source License
public List search(CaseManagementSearchBean searchBean) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Criteria criteria = getSession().createCriteria(CaseManagementNote.class); criteria.add(Expression.eq("demographic_no", searchBean.getDemographicNo())); if (searchBean.getSearchRoleId() > 0) { criteria.add(Expression.eq("reporter_caisi_role", String.valueOf(searchBean.getSearchRoleId()))); }//from w w w . j ava2s . co m if (searchBean.getSearchProgramId() > 0) { criteria.add(Expression.eq("program_no", String.valueOf(searchBean.getSearchProgramId()))); } try { Date startDate; Date endDate; if (searchBean.getSearchStartDate().length() > 0) { startDate = formatter.parse(searchBean.getSearchStartDate()); } else { startDate = formatter.parse("1970-01-01"); } if (searchBean.getSearchEndDate().length() > 0) { endDate = formatter.parse(searchBean.getSearchEndDate()); } else { endDate = new Date(); } criteria.add(Restrictions.between("update_date", startDate, endDate)); } catch (ParseException e) { log.warn("Warning", e); } criteria.addOrder(Order.desc("update_date")); return criteria.list(); }
From source file:org.oscarehr.PMmodule.dao.AdmissionDao.java
License:Open Source License
@SuppressWarnings("unchecked") public List search(AdmissionSearchBean searchBean) { if (searchBean == null) { throw new IllegalArgumentException(); }//from w ww. j a v a 2s . co m Criteria criteria = getSession().createCriteria(Admission.class); if (searchBean.getProviderNo() != null && searchBean.getProviderNo().length() > 0) { criteria.add(Restrictions.eq("ProviderNo", searchBean.getProviderNo())); } if (searchBean.getAdmissionStatus() != null && searchBean.getAdmissionStatus().length() > 0) { criteria.add(Restrictions.eq("AdmissionStatus", searchBean.getAdmissionStatus())); } if (searchBean.getClientId() != null && searchBean.getClientId() > 0) { criteria.add(Restrictions.eq("ClientId", searchBean.getClientId())); } if (searchBean.getProgramId() != null && searchBean.getProgramId() > 0) { criteria.add(Restrictions.eq("ProgramId", searchBean.getProgramId())); } if (searchBean.getStartDate() != null && searchBean.getEndDate() != null) { criteria.add(Restrictions.between("AdmissionDate", searchBean.getStartDate(), searchBean.getEndDate())); } List results = criteria.list(); if (log.isDebugEnabled()) { log.debug("search: # of results: " + results.size()); } return results; }