Example usage for org.hibernate.criterion Restrictions isNotNull

List of usage examples for org.hibernate.criterion Restrictions isNotNull

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions isNotNull.

Prototype

public static Criterion isNotNull(String propertyName) 

Source Link

Document

Apply an "is not null" constraint to the named property

Usage

From source file:org.openmrs.module.patientportal.api.db.hibernate.HibernatePatientPortalReminderDAO.java

License:Open Source License

@Override
public List<PatientPortalReminder> getPatientPortalRemindersByProvider(Patient pat) {
    Criteria crit = sessionFactory.getCurrentSession().createCriteria(PatientPortalReminder.class);
    crit.add(Restrictions.eq("patient", pat));
    crit.add(Restrictions.isNull("completeDate"));
    crit.add(Restrictions.isNotNull("targetDate"));
    crit.add(Restrictions.eq("responseType", "PHR_PROVIDER"));
    crit.addOrder(Order.asc("targetDate"));
    @SuppressWarnings("unchecked")
    List<PatientPortalReminder> list = (List<PatientPortalReminder>) crit.list();
    if (list.size() >= 1)
        return list;
    else//from w  w  w. j av  a2 s . c o  m
        return null;
}

From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java

License:Open Source License

/**
 * @see org.openmrs.module.vcttrac.db.VCTModuleDAO#getAllClientCodeForReceptionOfResult()
 *//*from  w w  w  . j a  v  a2s .  c  om*/
@Override
@SuppressWarnings("unchecked")
public List<String> getAllClientCodeForReceptionOfResult() {
    List<String> clientsCode = new ArrayList<String>();

    List<VCTClient> clientList = getSession().createCriteria(VCTClient.class)
            .add(Restrictions.isNotNull("codeTest")).add(Restrictions.isNotNull("resultObs"))
            .add(Restrictions.eq("archived", false)).add(Restrictions.eq("voided", false)).list();

    for (VCTClient c : clientList)
        if (VCTModuleTag.convsetObsValueByConcept(c.getResultObs(),
                VCTConfigurationUtil.getDateResultOfHivTestReceivedConceptId()).compareTo("-") == 0)
            clientsCode.add(c.getCodeTest());

    return clientsCode;
}

From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java

License:Open Source License

@SuppressWarnings({ "unchecked" })
@Override/* w  w w .ja  v  a 2 s.c  o  m*/
public Integer getNumberOfNewClientsCounseledAndTestedForHIV(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.size();
}

From source file:org.openmrs.module.vcttrac.db.hibernate.VCTModuleDAOImpl.java

License:Open Source License

@SuppressWarnings({ "unchecked" })
@Override/*from  ww  w . j av a  2 s  .c o  m*/
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/*w  ww .j a  va 2  s.  com*/
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)
 *//*from  w  w  w  . j  a 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/*from  w ww  .j  ava2  s. co  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  w w w  .j  a va2s. 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  ava 2s  . c o m
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.dashboard.server.DefaultSurveillanceService.java

License:Open Source License

/** {@inheritDoc} */
@Override//from ww  w. j a v a2  s.c  o m
public Notification[] getNotificationsForSet(SurveillanceSet set) {
    List<Notification> notifications = new ArrayList<Notification>();

    Date fifteenMinutesAgo = new Date(System.currentTimeMillis() - (15 * 60 * 1000));
    Date oneWeekAgo = new Date(System.currentTimeMillis() - (7 * 24 * 60 * 60 * 1000));

    notifications.addAll(
            getNotificationsWithCriterion(set, "Critical", Restrictions.isNull("notification.respondTime"),
                    Restrictions.le("notification.pageTime", fifteenMinutesAgo)));
    notifications
            .addAll(getNotificationsWithCriterion(set, "Minor", Restrictions.isNull("notification.respondTime"),
                    Restrictions.gt("notification.pageTime", fifteenMinutesAgo)));
    notifications.addAll(
            getNotificationsWithCriterion(set, "Normal", Restrictions.isNotNull("notification.respondTime"),
                    Restrictions.gt("notification.pageTime", oneWeekAgo)));

    return notifications.toArray(new Notification[notifications.size()]);
}