dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05855
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1838: Minor fixes in patient module.
------------------------------------------------------------
revno: 1838
committer: Viet <Viet@Viet-Laptop>
branch nick: trunk
timestamp: Tue 2010-05-11 23:29:50 +0700
message:
Minor fixes in patient module.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2010-04-05 12:41:21 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientIdentifierStore.java 2010-05-11 16:29:50 +0000
@@ -29,6 +29,7 @@
import java.util.Collection;
+import org.hibernate.Query;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.hibernate.HibernateGenericStore;
@@ -103,7 +104,7 @@
@SuppressWarnings( "unchecked" )
public Collection<Patient> listPatientByOrganisationUnit( OrganisationUnit organisationUnit, int min, int max )
{
- return (Collection<Patient>) getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) )
+ return (Collection<Patient>) getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) )
.setProjection( Projections.distinct( Projections.property( "patient" ) ) ).setFirstResult( min ).setMaxResults( max ).list();
}
@@ -111,25 +112,28 @@
{
return (Patient) getCriteria( Restrictions.and( Restrictions.eq( "identifierType", idenType ),
Restrictions.eq( "identifier", value ) ) )
- .setProjection( Projections.property( "patient" ) ).uniqueResult();
+ .setProjection( Projections.property( "patient.id" ) ).uniqueResult();
}
public int countListPatientByOrganisationUnit( OrganisationUnit orgUnit )
{
- return (Integer) getCriteria( Restrictions.eq( "organisationUnit", orgUnit ) )
- .setProjection( Projections.countDistinct( "patient" ) ).uniqueResult();
+ Query query = getQuery("select count(distinct pdi.patient.id) from PatientIdentifier pdi where pdi.organisationUnit.id=:orgUnitId ");
+ query.setParameter("orgUnitId", orgUnit.getId());
+ Number rs = (Number) query.uniqueResult();
+ return rs != null ? rs.intValue() : 0;
}
@SuppressWarnings( "unchecked" )
public Collection<Patient> listPatientByOrganisationUnit( OrganisationUnit organisationUnit )
{
- return (Collection<Patient>) getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) )
+ return (Collection<Patient>) getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) )
.setProjection( Projections.distinct( Projections.property( "patient" ) ) ).list();
}
public int countGetPatientsByIdentifier( String identifier )
{
- return (Integer)getCriteria( Restrictions.ilike( "identifier", "%" + identifier + "%" ) ).setProjection( Projections.rowCount() ).uniqueResult();
+ Number rs = (Number)getCriteria( Restrictions.ilike( "identifier", "%" + identifier + "%" ) ).setProjection( Projections.rowCount() ).uniqueResult();
+ return rs != null ? rs.intValue() : 0;
}
@SuppressWarnings( "unchecked" )
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2010-04-21 12:14:08 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2010-05-11 16:29:50 +0000
@@ -103,10 +103,11 @@
public int countGetPatientsByNames( String name )
{
- return (Integer)getCriteria(
+ Number rs = (Number)getCriteria(
Restrictions.disjunction().add( Restrictions.ilike( "firstName", "%" + name + "%" ) ).add(
Restrictions.ilike( "middleName", "%" + name + "%" ) ).add(
Restrictions.ilike( "lastName", "%" + name + "%" ) ) ).addOrder( Order.asc( "firstName" ) ).setProjection( Projections.rowCount() ).uniqueResult();
+ return rs != null ? rs.intValue() : 0;
}
@SuppressWarnings( "unchecked" )
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java 2010-04-05 12:41:21 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patientattributevalue/hibernate/HibernatePatientAttributeValueStore.java 2010-05-11 16:29:50 +0000
@@ -107,8 +107,9 @@
public int countByPatientAttributeoption( PatientAttributeOption attributeOption )
{
- return (Integer) getCriteria( Restrictions.eq( "patientAttributeOption", attributeOption ) )
+ Number rs = (Number) getCriteria( Restrictions.eq( "patientAttributeOption", attributeOption ) )
.setProjection(Projections.rowCount() ).uniqueResult();
+ return rs != null ? rs.intValue() : 0;
}
@SuppressWarnings( "unchecked" )