List of usage examples for org.hibernate.criterion Restrictions gt
public static SimpleExpression gt(String propertyName, Object value)
From source file:org.openmrs.module.hospitalcore.db.hibernate.HibernatePatientQueueDAO.java
License:Open Source License
public List<Obs> getAllExamination(Integer personId) throws DAOException { // TODO Auto-generated method stub Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Obs.class, "obs"); String toDdate = formatter1.format(new Date()); Date date1 = new Date(); Date oldDate = new Date(date1.getTime() - TimeUnit.HOURS.toMillis(24)); String fromDate = formatter1.format(oldDate); try {//from ww w.j a v a 2s . c o m criteria.add(Restrictions.lt("obs.obsDatetime", formatter1.parse(toDdate))); criteria.add(Restrictions.gt("obs.obsDatetime", formatter1.parse(fromDate))); } catch (Exception e) { // TODO: handle exception System.out.println("Error convert date: " + e.toString()); e.printStackTrace(); } criteria.add(Restrictions.eq("obs.personId", personId)); criteria.add(Restrictions.eq("obs.concept", Context.getConceptService().getConcept("EXAMINATION"))); return criteria.list(); }
From source file:org.openmrs.module.hospitalcore.db.hibernate.HibernatePatientQueueDAO.java
License:Open Source License
public List<Obs> getAllUnderlinedCondition(Integer personId) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Obs.class, "obs"); String toDdate = formatter1.format(new Date()); Date date1 = new Date(); Date oldDate = new Date(date1.getTime() - TimeUnit.HOURS.toMillis(24)); String fromDate = formatter1.format(oldDate); try {/* www. j a v a 2 s. co m*/ criteria.add(Restrictions.lt("obs.obsDatetime", formatter1.parse(toDdate))); criteria.add(Restrictions.gt("obs.obsDatetime", formatter1.parse(fromDate))); } catch (Exception e) { // TODO: handle exception System.out.println("Error convert date: " + e.toString()); e.printStackTrace(); } criteria.add(Restrictions.eq("obs.personId", personId)); criteria.add( Restrictions.eq("obs.concept", Context.getConceptService().getConcept("UNDERLINED CONDITION"))); return criteria.list(); }
From source file:org.openmrs.module.hospitalcore.db.hibernate.HibernatePatientQueueDAO.java
License:Open Source License
public List<Obs> getAllSigns(Integer personId) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Obs.class, "obs"); String toDdate = formatter1.format(new Date()); Date date1 = new Date(); Date oldDate = new Date(date1.getTime() - TimeUnit.HOURS.toMillis(24)); String fromDate = formatter1.format(oldDate); try {//from w w w .ja v a 2 s. c o m criteria.add(Restrictions.lt("obs.obsDatetime", formatter1.parse(toDdate))); criteria.add(Restrictions.gt("obs.obsDatetime", formatter1.parse(fromDate))); } catch (Exception e) { // TODO: handle exception System.out.println("Error convert date: " + e.toString()); e.printStackTrace(); } criteria.add(Restrictions.eq("obs.personId", personId)); criteria.add(Restrictions.eq("obs.concept", Context.getConceptService().getConcept("SIGNS"))); return criteria.list(); }
From source file:org.openmrs.module.hospitalcore.db.hibernate.HibernatePatientQueueDAO.java
License:Open Source License
public List<Obs> getAllDifferentialDiagnosis(Integer personId) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Obs.class, "obs"); String toDdate = formatter1.format(new Date()); Date date1 = new Date(); Date oldDate = new Date(date1.getTime() - TimeUnit.HOURS.toMillis(24)); String fromDate = formatter1.format(oldDate); try {/*from w ww .j av a 2 s . c o m*/ criteria.add(Restrictions.lt("obs.obsDatetime", formatter1.parse(toDdate))); criteria.add(Restrictions.gt("obs.obsDatetime", formatter1.parse(fromDate))); } catch (Exception e) { // TODO: handle exception System.out.println("Error convert date: " + e.toString()); e.printStackTrace(); } criteria.add(Restrictions.eq("obs.personId", personId)); criteria.add( Restrictions.eq("obs.concept", Context.getConceptService().getConcept("DIFFERENTIAL DIAGNOSIS"))); return criteria.list(); }
From source file:org.openmrs.module.hospitalcore.db.hibernate.HibernatePatientQueueDAO.java
License:Open Source License
public List<Obs> getAllWorkingDiagnosis(Integer personId) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Obs.class, "obs"); String toDdate = formatter1.format(new Date()); Date date1 = new Date(); Date oldDate = new Date(date1.getTime() - TimeUnit.HOURS.toMillis(24)); String fromDate = formatter1.format(oldDate); try {/*from w w w . j a v a 2 s . c om*/ criteria.add(Restrictions.lt("obs.obsDatetime", formatter1.parse(toDdate))); criteria.add(Restrictions.gt("obs.obsDatetime", formatter1.parse(fromDate))); } catch (Exception e) { // TODO: handle exception System.out.println("Error convert date: " + e.toString()); e.printStackTrace(); } criteria.add(Restrictions.eq("obs.personId", personId)); criteria.add(Restrictions.eq("obs.concept", Context.getConceptService().getConcept("WORKING DIAGNOSIS"))); return criteria.list(); }
From source file:org.openmrs.module.inventory.db.hibernate.HibernateInventoryDAO.java
License:Open Source License
public List<InventoryStoreItemTransactionDetail> listStoreItemTransactionDetail(Integer storeId, Integer itemId, Integer specificationId, boolean haveQuantity) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession() .createCriteria(InventoryStoreItemTransactionDetail.class, "transactionDetail") .createAlias("transactionDetail.transaction", "transaction") .add(Restrictions.eq("transaction.store.id", storeId)) .add(Restrictions.eq("transactionDetail.item.id", itemId)) .add(Restrictions.eq("transaction.typeTransaction", ActionValue.TRANSACTION[0])); if (specificationId != null && specificationId > 0) { criteria.add(Restrictions.eq("transactionDetail.specification.id", specificationId)); } else {//from www . jav a 2 s . co m criteria.add(Restrictions.isNull("transactionDetail.specification")); } if (haveQuantity) { criteria.add(Restrictions.gt("transactionDetail.currentQuantity", 0)); } criteria.addOrder(Order.asc("transactionDetail.currentQuantity")); List<InventoryStoreItemTransactionDetail> l = criteria.list(); return l; }
From source file:org.openmrs.module.inventory.db.hibernate.HibernateInventoryDAO.java
License:Open Source License
@Override public Integer sumStoreItemCurrentQuantity(Integer storeId, Integer itemId, Integer specificationId) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession() .createCriteria(InventoryStoreItemTransactionDetail.class, "transactionDetail") .createAlias("transactionDetail.transaction", "transaction") .add(Restrictions.eq("transaction.store.id", storeId)) .add(Restrictions.eq("transaction.typeTransaction", ActionValue.TRANSACTION[0])) .add(Restrictions.eq("transactionDetail.item.id", itemId)); if (specificationId != null && specificationId > 0) { criteria.add(Restrictions.eq("transactionDetail.specification.id", specificationId)); } else {// w w w . j a v a 2 s . c om criteria.add(Restrictions.isNull("transactionDetail.specification")); } criteria.add(Restrictions.gt("transactionDetail.currentQuantity", 0)); ProjectionList proList = Projections.projectionList(); proList.add(Projections.sum("currentQuantity")); criteria.setProjection(proList); Object l = criteria.uniqueResult(); return l != null ? (Integer) l : 0; }
From source file:org.openmrs.module.obgyn.api.db.hibernate.HibernateOBGynDAO.java
License:Open Source License
public List<Patient> getNewPatients(Date startDate) { List<Patient> list = sessionFactory.getCurrentSession().createCriteria(Patient.class) .add(Restrictions.gt("dateCreated", startDate)).list(); if (list.isEmpty()) return null; return list;/* w w w.j a v a2 s. c om*/ }
From source file:org.openmrs.module.openhmis.commons.api.entity.search.BaseObjectTemplateSearch.java
License:Open Source License
protected Criterion createCriterion(String field, Date value, DateComparisonType comparisonType) { DateComparisonType comparison = comparisonType == null ? DateComparisonType.EQUAL : comparisonType; Criterion result;/*w ww. ja v a 2s . c o m*/ switch (comparison) { case EQUAL: result = Restrictions.eq(field, value); break; case NOT_EQUAL: result = Restrictions.ne(field, value); break; case IS_NULL: result = Restrictions.isNull(field); break; case IS_NOT_NULL: result = Restrictions.isNotNull(field); break; case GREATER_THAN: result = Restrictions.gt(field, value); break; case GREATER_THAN_EQUAL: result = Restrictions.ge(field, value); break; case LESS_THAN: result = Restrictions.lt(field, value); break; case LESS_THAN_EQUAL: result = Restrictions.le(field, value); break; default: throw new IllegalArgumentException(); } return result; }
From source file:org.openmrs.module.operationtheater.api.db.hibernate.HibernateSurgeryDAO.java
License:Open Source License
@Override @Transactional(readOnly = true)/*from w w w . j av a2 s . c o m*/ public List<Surgery> getAllOngoingSurgeries(LocalDateTime dateTime) { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Surgery.class); criteria.add(Restrictions.eq("voided", false)); criteria.add(Restrictions.le("dateStarted", dateTime)); criteria.add( Restrictions.or(Restrictions.isNull("dateFinished"), Restrictions.gt("dateFinished", dateTime))); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }