=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2013-09-06 05:27:42 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/Patient.java 2013-09-06 08:24:36 +0000 @@ -28,11 +28,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.program.Program; import org.hisp.dhis.user.User; -import java.io.Serializable; import java.util.Calendar; import java.util.Date; import java.util.HashSet; @@ -42,7 +42,7 @@ * @author Abyot Asalefew Gizaw */ public class Patient - implements Serializable + extends BaseIdentifiableObject { /** * Determines if a de-serialized file is compatible with this class. @@ -73,8 +73,6 @@ public static String FIXED_ATTR_INTERGER_AGE = "integerValueOfAge"; public static String FIXED_ATTR_REGISTRATION_DATE = "registrationDate"; - private Integer id; - private String firstName; private String middleName; @@ -127,7 +125,7 @@ final int prime = 31; int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((uid == null) ? 0 : uid.hashCode()); result = prime * result + ((birthDate == null) ? 0 : birthDate.hashCode()); result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); result = prime * result + ((gender == null) ? 0 : gender.hashCode()); @@ -222,11 +220,6 @@ // Getters and setters // ------------------------------------------------------------------------- - public Integer getId() - { - return id; - } - public Set getAttributes() { return attributes; @@ -247,11 +240,6 @@ this.attributes = attributes; } - public void setId( Integer id ) - { - this.id = id; - } - public String getFirstName() { return firstName; @@ -404,7 +392,7 @@ { return "< 1 yr"; } - + return age + " yr"; } @@ -568,12 +556,12 @@ { switch ( dobType ) { - case DOB_TYPE_VERIFIED: - return "Verified"; - case DOB_TYPE_DECLARED: - return "Declared"; - default: - return "Approxiated"; + case DOB_TYPE_VERIFIED: + return "Verified"; + case DOB_TYPE_DECLARED: + return "Declared"; + default: + return "Approxiated"; } } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-08-23 15:56:19 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2013-09-06 08:24:36 +0000 @@ -28,15 +28,15 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Collection; -import java.util.Date; -import java.util.List; - import org.hisp.dhis.common.GenericStore; import org.hisp.dhis.common.Grid; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.program.Program; +import java.util.Collection; +import java.util.Date; +import java.util.List; + /** * @author Abyot Asalefew Gizaw * @version $Id$ === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2013-09-06 07:54:55 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java 2013-09-06 08:24:36 +0000 @@ -28,20 +28,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import java.util.Set; - import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.patient.Patient; import org.hisp.dhis.patientcomment.PatientComment; import org.hisp.dhis.sms.outbound.OutboundSms; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Set; + /** * @author Abyot Asalefew - * @version $Id$ */ public class ProgramStageInstance extends BaseIdentifiableObject === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java 2013-08-29 11:59:39 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/common/IdentityPopulator.java 2013-09-06 08:24:36 +0000 @@ -28,9 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Map; -import java.util.UUID; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hisp.dhis.system.startup.AbstractStartupRoutine; @@ -40,6 +37,9 @@ import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.support.rowset.SqlRowSet; +import java.util.Map; +import java.util.UUID; + /** * @author bobj */ @@ -53,10 +53,11 @@ "organisationunit", "orgunitgroup", "orgunitgroupset", "dataelementcategoryoption", "dataelementgroup", "sqlview", "dataelement", "dataelementgroupset", "dataelementcategory", "categorycombo", "categoryoptioncombo", "map", "mapview", "reporttable", "report", "messageconversation", "message", "userinfo", "usergroup", "userrole", "maplegend", - "maplegendset", "maplayer", "section", "optionset", "program", "programinstance", "programstage", "programstageinstance" + "maplegendset", "maplayer", "section", "optionset", "program", "programinstance", "programstage", "programstageinstance", + "patient" }; - - private static final Map TABLE_ID_MAP = DimensionalObjectUtils.asMap( + + private static final Map TABLE_ID_MAP = DimensionalObjectUtils.asMap( "dataelementcategoryoption", "categoryoptionid", "dataelementcategory", "categoryid" ); @@ -79,11 +80,11 @@ try { log.debug( "Checking table: " + table ); - + int count = 0; - + SqlRowSet resultSet = jdbcTemplate.queryForRowSet( "SELECT * from " + table + " WHERE uid IS NULL" ); - + while ( resultSet.next() ) { ++count; @@ -92,7 +93,7 @@ String sql = "update " + table + " set uid = '" + CodeGenerator.generateCode() + "' where " + idColumn + " = " + id; jdbcTemplate.update( sql ); } - + if ( count > 0 ) { log.info( count + " uids set on " + table ); @@ -101,9 +102,9 @@ count = 0; resultSet = jdbcTemplate.queryForRowSet( "SELECT * from " + table + " WHERE lastUpdated IS NULL" ); - + String timestamp = DateUtils.getLongDateString(); - + while ( resultSet.next() ) { ++count; @@ -112,7 +113,7 @@ String sql = "update " + table + " set lastupdated = '" + timestamp + "' where " + idColumn + " = " + id; jdbcTemplate.update( sql ); } - + if ( count > 0 ) { log.info( count + " last updated set on " + table ); @@ -121,7 +122,7 @@ count = 0; resultSet = jdbcTemplate.queryForRowSet( "SELECT * from " + table + " WHERE created IS NULL" ); - + while ( resultSet.next() ) { ++count; @@ -130,7 +131,7 @@ String sql = "update " + table + " set created = '" + timestamp + "' where " + idColumn + " = " + id; jdbcTemplate.update( sql ); } - + if ( count > 0 ) { log.info( count + " timestamps set on " + table ); @@ -139,27 +140,27 @@ catch ( Exception ex ) { log.error( "Problem updating: " + table + ", id column: " + getIdColumn( table ), ex ); - + throw ex; } } log.debug( "Identifiable properties updated" ); - + createUidConstraints(); log.debug( "Identifiable constraints updated" ); - + createOrgUnitUuids(); - - log.debug( "Organisation unit uuids updated" ); + + log.debug( "Organisation unit uuids updated" ); } private String getIdColumn( String table ) { - return TABLE_ID_MAP.containsKey( table ) ? TABLE_ID_MAP.get( table ) : ( table + "id" ); + return TABLE_ID_MAP.containsKey( table ) ? TABLE_ID_MAP.get( table ) : (table + "id"); } - + private void createUidConstraints() { for ( String table : tables ) @@ -176,7 +177,7 @@ } } } - + private void createOrgUnitUuids() { try === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2013-04-19 10:20:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2013-09-06 08:24:36 +0000 @@ -4,7 +4,6 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" [] > - === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2013-09-06 08:24:36 +0000 @@ -28,14 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import org.apache.commons.lang.StringUtils; import org.hisp.dhis.common.Grid; import org.hisp.dhis.common.GridHeader; @@ -52,6 +44,14 @@ import org.hisp.dhis.system.grid.ListGrid; import org.springframework.transaction.annotation.Transactional; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + /** * @author Abyot Asalefew Gizaw * @version $Id$ @@ -465,7 +465,7 @@ if ( representativeId == null ) return false; - return patient.getRepresentative() == null || !patient.getRepresentative().getId().equals( representativeId ); + return patient.getRepresentative() == null || !(patient.getRepresentative().getId() == representativeId); } @Override === 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 2013-09-06 05:27:42 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2013-09-06 08:24:36 +0000 @@ -28,14 +28,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashSet; -import java.util.List; - import org.apache.commons.lang.StringUtils; import org.hibernate.Criteria; import org.hibernate.Query; @@ -44,6 +36,7 @@ import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.common.Grid; +import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.jdbc.StatementBuilder; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -62,13 +55,20 @@ import org.springframework.jdbc.support.rowset.SqlRowSet; import org.springframework.transaction.annotation.Transactional; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; + /** * @author Abyot Asalefew Gizaw - * @version $Id$ */ @Transactional public class HibernatePatientStore - extends HibernateGenericStore + extends HibernateIdentifiableObjectStore implements PatientStore { // ------------------------------------------------------------------------- @@ -107,8 +107,8 @@ return getCriteria( Restrictions.eq( "gender", gender ) ).list(); } + @Override @SuppressWarnings( "unchecked" ) - @Override public Collection getByBirthDate( Date birthDate ) { return getCriteria( Restrictions.eq( "birthDate", birthDate ) ).list(); @@ -147,8 +147,8 @@ return patients; } + @Override @SuppressWarnings( "unchecked" ) - @Override public Collection get( String firstName, String middleName, String lastName, Date birthdate, String gender ) { @@ -173,8 +173,8 @@ return crit.list(); } + @Override @SuppressWarnings( "unchecked" ) - @Override public Collection getByOrgUnit( OrganisationUnit organisationUnit, Integer min, Integer max ) { String hql = "select p from Patient p where p.organisationUnit = :organisationUnit order by p.id DESC"; @@ -189,8 +189,8 @@ return query.list(); } + @Override @SuppressWarnings( "unchecked" ) - @Override public Collection getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, Integer min, Integer max ) { @@ -238,8 +238,8 @@ return rs != null ? rs.intValue() : 0; } + @Override @SuppressWarnings( "unchecked" ) - @Override public Collection getRepresentatives( Patient patient ) { String hql = "select distinct p from Patient p where p.representative = :representative order by p.id DESC"; @@ -425,7 +425,7 @@ { patientWhere += " ((DATE(now()) - DATE(birthdate))/365) " + value; } - else if(id.equals( Patient.FIXED_ATTR_REGISTRATION_DATE )) + else if ( id.equals( Patient.FIXED_ATTR_REGISTRATION_DATE ) ) { patientWhere += "p." + id + value; } @@ -481,103 +481,103 @@ int statusEvent = Integer.parseInt( keys[index] ); switch ( statusEvent ) { - case ProgramStageInstance.COMPLETED_STATUS: - patientWhere += condition + operatorStatus - + "( psi.executiondate is not null and psi.executiondate>='" + keys[2] - + "' and psi.executiondate<='" + keys[3] + "' and psi.completed=true "; - // get events by orgunit children - if ( keys[4].equals( "-1" ) ) - { - patientWhere += " and psi.organisationunitid in( " - + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; - } - // get events by selected - else if ( !keys[4].equals( "0" ) ) - { - patientWhere += " and psi.organisationunitid=" + keys[4]; - } - patientWhere += ")"; - operatorStatus = " OR "; - condition = ""; - continue; - case ProgramStageInstance.VISITED_STATUS: - patientWhere += condition + operatorStatus - + "( psi.executiondate is not null and psi.executiondate>='" + keys[2] - + "' and psi.executiondate<='" + keys[3] + "' and psi.completed=false "; + case ProgramStageInstance.COMPLETED_STATUS: + patientWhere += condition + operatorStatus + + "( psi.executiondate is not null and psi.executiondate>='" + keys[2] + + "' and psi.executiondate<='" + keys[3] + "' and psi.completed=true "; + // get events by orgunit children + if ( keys[4].equals( "-1" ) ) + { + patientWhere += " and psi.organisationunitid in( " + + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; + } + // get events by selected + else if ( !keys[4].equals( "0" ) ) + { + patientWhere += " and psi.organisationunitid=" + keys[4]; + } + patientWhere += ")"; + operatorStatus = " OR "; + condition = ""; + continue; + case ProgramStageInstance.VISITED_STATUS: + patientWhere += condition + operatorStatus + + "( psi.executiondate is not null and psi.executiondate>='" + keys[2] + + "' and psi.executiondate<='" + keys[3] + "' and psi.completed=false "; - // get events by orgunit children - if ( keys[4].equals( "-1" ) ) - { - patientWhere += " and psi.organisationunitid in( " - + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; - } - // get events by selected - else if ( !keys[4].equals( "0" ) ) - { - patientWhere += " and psi.organisationunitid=" + keys[4]; - } - patientWhere += ")"; - operatorStatus = " OR "; - condition = ""; - continue; - case ProgramStageInstance.FUTURE_VISIT_STATUS: - patientWhere += condition + operatorStatus + "( psi.executiondate is null and psi.duedate>='" - + keys[2] + "' and psi.duedate<='" + keys[3] - + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) <= 0) "; - // get events by orgunit children - if ( keys[4].equals( "-1" ) ) - { - patientWhere += " and p.organisationunitid in( " - + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; - } - // get events by selected - else if ( !keys[4].equals( "0" ) ) - { - patientWhere += " and p.organisationunitid=" + keys[4]; - } - patientWhere += ")"; - operatorStatus = " OR "; - condition = ""; - continue; - case ProgramStageInstance.LATE_VISIT_STATUS: - patientWhere += condition + operatorStatus + "( psi.executiondate is null and psi.duedate>='" - + keys[2] + "' and psi.duedate<='" + keys[3] - + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) > 0) "; - // get events by orgunit children - if ( keys[4].equals( "-1" ) ) - { - patientWhere += " and p.organisationunitid in( " - + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; - } - // get events by selected - else if ( !keys[4].equals( "0" ) ) - { - patientWhere += " and p.organisationunitid=" + keys[4]; - } - patientWhere += ")"; - operatorStatus = " OR "; - condition = ""; - continue; - case ProgramStageInstance.SKIPPED_STATUS: - patientWhere += condition + operatorStatus + "( psi.status=5 and psi.duedate>='" + keys[2] - + "' and psi.duedate<='" + keys[3] + "' "; - // get events by orgunit children - if ( keys[4].equals( "-1" ) ) - { - patientWhere += " and psi.organisationunitid in( " - + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; - } - // get events by selected - else if ( !keys[4].equals( "0" ) ) - { - patientWhere += " and p.organisationunitid=" + keys[4]; - } - patientWhere += ")"; - operatorStatus = " OR "; - condition = ""; - continue; - default: - continue; + // get events by orgunit children + if ( keys[4].equals( "-1" ) ) + { + patientWhere += " and psi.organisationunitid in( " + + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; + } + // get events by selected + else if ( !keys[4].equals( "0" ) ) + { + patientWhere += " and psi.organisationunitid=" + keys[4]; + } + patientWhere += ")"; + operatorStatus = " OR "; + condition = ""; + continue; + case ProgramStageInstance.FUTURE_VISIT_STATUS: + patientWhere += condition + operatorStatus + "( psi.executiondate is null and psi.duedate>='" + + keys[2] + "' and psi.duedate<='" + keys[3] + + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) <= 0) "; + // get events by orgunit children + if ( keys[4].equals( "-1" ) ) + { + patientWhere += " and p.organisationunitid in( " + + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; + } + // get events by selected + else if ( !keys[4].equals( "0" ) ) + { + patientWhere += " and p.organisationunitid=" + keys[4]; + } + patientWhere += ")"; + operatorStatus = " OR "; + condition = ""; + continue; + case ProgramStageInstance.LATE_VISIT_STATUS: + patientWhere += condition + operatorStatus + "( psi.executiondate is null and psi.duedate>='" + + keys[2] + "' and psi.duedate<='" + keys[3] + + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) > 0) "; + // get events by orgunit children + if ( keys[4].equals( "-1" ) ) + { + patientWhere += " and p.organisationunitid in( " + + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; + } + // get events by selected + else if ( !keys[4].equals( "0" ) ) + { + patientWhere += " and p.organisationunitid=" + keys[4]; + } + patientWhere += ")"; + operatorStatus = " OR "; + condition = ""; + continue; + case ProgramStageInstance.SKIPPED_STATUS: + patientWhere += condition + operatorStatus + "( psi.status=5 and psi.duedate>='" + keys[2] + + "' and psi.duedate<='" + keys[3] + "' "; + // get events by orgunit children + if ( keys[4].equals( "-1" ) ) + { + patientWhere += " and psi.organisationunitid in( " + + TextUtils.getCommaDelimitedString( orgunitChilrenIds ) + " )"; + } + // get events by selected + else if ( !keys[4].equals( "0" ) ) + { + patientWhere += " and p.organisationunitid=" + keys[4]; + } + patientWhere += ")"; + operatorStatus = " OR "; + condition = ""; + continue; + default: + continue; } } if ( condition.isEmpty() ) @@ -598,20 +598,20 @@ int statusEvent = Integer.parseInt( keys[2] ); switch ( statusEvent ) { - case ProgramStageInstance.COMPLETED_STATUS: - patientWhere += "psi.completed=true"; - break; - case ProgramStageInstance.VISITED_STATUS: - patientWhere += "psi.executiondate is not null and psi.completed=false"; - break; - case ProgramStageInstance.FUTURE_VISIT_STATUS: - patientWhere += "psi.executiondate is null and psi.duedate >= now()"; - break; - case ProgramStageInstance.LATE_VISIT_STATUS: - patientWhere += "psi.executiondate is null and psi.duedate < now()"; - break; - default: - break; + case ProgramStageInstance.COMPLETED_STATUS: + patientWhere += "psi.completed=true"; + break; + case ProgramStageInstance.VISITED_STATUS: + patientWhere += "psi.executiondate is not null and psi.completed=false"; + break; + case ProgramStageInstance.FUTURE_VISIT_STATUS: + patientWhere += "psi.executiondate is null and psi.duedate >= now()"; + break; + case ProgramStageInstance.LATE_VISIT_STATUS: + patientWhere += "psi.executiondate is null and psi.duedate < now()"; + break; + default: + break; } patientWhere += " and pgi.status=" + ProgramInstance.STATUS_ACTIVE + " "; @@ -675,12 +675,12 @@ { sql += statementBuilder.limitRecord( min, max ); } - + return sql; } + @Override @SuppressWarnings( "unchecked" ) - @Override public Collection getByPhoneNumber( String phoneNumber, Integer min, Integer max ) { String hql = "select p from Patient p where p.phoneNumber like '%" + phoneNumber + "%'"; @@ -734,6 +734,7 @@ criteria.createAlias( "organisationUnit", "orgunit" ); criteria.setProjection( Projections.distinct( Projections.projectionList().add( Projections.property( "orgunit.id" ), "orgunitid" ) ) ); + return criteria.list(); } @@ -743,38 +744,40 @@ private Collection getOrgunitChildren( Collection orgunits ) { - Collection orgunitIds = new HashSet(); + Collection orgUnitIds = new HashSet(); + if ( orgunits != null ) { for ( OrganisationUnit orgunit : orgunits ) { - orgunitIds - .addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) ); - orgunitIds.remove( orgunit.getId() ); + orgUnitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) ); + orgUnitIds.remove( orgunit.getId() ); } } - if ( orgunitIds.size() == 0 ) + if ( orgUnitIds.size() == 0 ) { - orgunitIds.add( 0 ); + orgUnitIds.add( 0 ); } - return orgunitIds; + + return orgUnitIds; } private Collection getOrganisationUnitIds( Collection orgunits ) { - Collection orgunitIds = new HashSet(); - for ( OrganisationUnit orgunit : orgunits ) - { - orgunitIds.add( orgunit.getId() ); - } - - if ( orgunitIds.size() == 0 ) - { - orgunitIds.add( 0 ); - } - return orgunitIds; + Collection orgUnitIds = new HashSet(); + + for ( OrganisationUnit orgUnit : orgunits ) + { + orgUnitIds.add( orgUnit.getId() ); + } + + if ( orgUnitIds.size() == 0 ) + { + orgUnitIds.add( 0 ); + } + + return orgUnitIds; } - } === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-08-27 03:31:40 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-09-06 08:24:36 +0000 @@ -35,9 +35,9 @@ import org.hibernate.criterion.Restrictions; import org.hisp.dhis.common.Grid; import org.hisp.dhis.common.GridHeader; +import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.hibernate.HibernateGenericStore; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.jdbc.StatementBuilder; @@ -88,7 +88,7 @@ * @author Abyot Asalefew */ public class HibernateProgramStageInstanceStore - extends HibernateGenericStore + extends HibernateIdentifiableObjectStore implements ProgramStageInstanceStore { // ------------------------------------------------------------------------- @@ -155,7 +155,7 @@ // Implemented methods // ------------------------------------------------------------------------- - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public ProgramStageInstance get( ProgramInstance programInstance, ProgramStage programStage ) { List list = new ArrayList( getCriteria( @@ -165,44 +165,44 @@ return list.isEmpty() ? null : list.get( list.size() - 1 ); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection get( ProgramStage programStage ) { return getCriteria( Restrictions.eq( "programStage", programStage ) ).list(); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection get( Collection programInstances ) { return getCriteria( Restrictions.in( "programInstance", programInstances ) ).list(); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection get( Date dueDate ) { return getCriteria( Restrictions.eq( "dueDate", dueDate ) ).list(); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection get( Date dueDate, Boolean completed ) { return getCriteria( Restrictions.eq( "dueDate", dueDate ), Restrictions.eq( "completed", completed ) ).list(); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection get( Date startDate, Date endDate ) { return (getCriteria( Restrictions.ge( "dueDate", startDate ), Restrictions.le( "dueDate", endDate ) )).list(); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection get( Date startDate, Date endDate, Boolean completed ) { return (getCriteria( Restrictions.ge( "dueDate", startDate ), Restrictions.le( "dueDate", endDate ), Restrictions.eq( "completed", completed ) )).list(); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public List get( OrganisationUnit unit, Date after, Date before, Boolean completed ) { String hql = "from ProgramStageInstance psi where psi.organisationUnit = :unit"; @@ -242,7 +242,7 @@ return q.list(); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public List get( Patient patient, Boolean completed ) { String hql = "from ProgramStageInstance where programInstance.patient = :patient and completed = :completed"; @@ -251,13 +251,13 @@ } @Override - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public List get( ProgramStage programStage, OrganisationUnit organisationUnit ) { return getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.eq( "organisationUnit", organisationUnit ) ).list(); } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public List get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max ) { @@ -464,7 +464,7 @@ return rs != null ? rs.intValue() : 0; } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public List getStatisticalProgramStageDetailsReport( ProgramStage programStage, Collection orgunitIds, Date startDate, Date endDate, int status, Integer min, Integer max ) { @@ -719,7 +719,7 @@ return rs != null ? rs.intValue() : 0; } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection get( Program program, Collection orgunitIds, Date startDate, Date endDate, Boolean completed ) { @@ -787,7 +787,7 @@ return grid; } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection get( Patient patient ) { return getCriteria().createAlias( "patients", "patient" ) @@ -2155,7 +2155,7 @@ return rs != null ? rs.intValue() : 0; } - @SuppressWarnings( "unchecked" ) + @SuppressWarnings("unchecked") public Collection getOrgunitIds( Date startDate, Date endDate ) { Criteria criteria = getCriteria(); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml' --- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml 2013-04-19 03:31:52 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patient/hibernate/Patient.hbm.xml 2013-09-06 08:24:36 +0000 @@ -1,14 +1,16 @@ - + "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" + [] + > + &identifiableProperties; @@ -44,7 +46,8 @@ - + - - - + + + === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java 2013-08-23 16:05:01 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java 2013-09-06 08:24:36 +0000 @@ -28,13 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - +import com.opensymphony.xwork2.Action; import org.apache.commons.lang.StringUtils; import org.apache.struts2.ServletActionContext; import org.hisp.dhis.i18n.I18n; @@ -49,7 +43,11 @@ import org.hisp.dhis.patientattributevalue.PatientAttributeValue; import org.hisp.dhis.patientattributevalue.PatientAttributeValueService; -import com.opensymphony.xwork2.Action; +import javax.servlet.http.HttpServletRequest; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; public class ValidateAddRelationshipPatientAction implements Action @@ -164,8 +162,8 @@ int endIndex = fullName.lastIndexOf( ' ' ); String firstName = fullName.substring( 0, startIndex ); - String middleName = ""; - String lastName = ""; + String middleName; + String lastName; if ( startIndex == endIndex ) { @@ -192,7 +190,7 @@ boolean flagDuplicate = false; for ( Patient p : patients ) { - if ( id == null || (id != null && p.getId().intValue() != id.intValue()) ) + if ( id == null || (id != null && p.getId() != id) ) { flagDuplicate = true; Collection patientAttributeValues = patientAttributeValueService @@ -221,7 +219,7 @@ } else { - p.setBirthDateFromAge( age.intValue(), ageType ); + p.setBirthDateFromAge( age, ageType ); } HttpServletRequest request = ServletActionContext.getRequest(); @@ -230,8 +228,9 @@ if ( identifiers != null && identifiers.size() > 0 ) { - String value = null; + String value; String idDuplicate = ""; + for ( PatientIdentifierType idType : identifiers ) { // If underAge is TRUE : Only check duplicate on @@ -243,7 +242,7 @@ { PatientIdentifier identifier = patientIdentifierService.get( idType, value ); if ( identifier != null - && (id == null || identifier.getPatient().getId().intValue() != id.intValue()) ) + && (id == null || identifier.getPatient().getId() != id) ) { idDuplicate += idType.getName() + ", "; } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-09-02 18:49:20 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2013-09-06 08:24:36 +0000 @@ -28,12 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - +import com.opensymphony.xwork2.Action; import org.apache.commons.lang.StringUtils; import org.apache.struts2.ServletActionContext; import org.hisp.dhis.i18n.I18n; @@ -50,11 +45,13 @@ import org.hisp.dhis.program.ProgramService; import org.hisp.dhis.validation.ValidationCriteria; -import com.opensymphony.xwork2.Action; +import javax.servlet.http.HttpServletRequest; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; /** * @author Abyot Asalefew Gizaw - * @version $Id$ */ public class ValidatePatientAction implements Action @@ -159,7 +156,7 @@ boolean flagDuplicate = false; for ( Patient p : patients ) { - if ( id == null || (id != null && p.getId().intValue() != id.intValue()) ) + if ( id == null || (id != null && p.getId() != id) ) { flagDuplicate = true; Collection patientAttributeValues = patientAttributeValueService @@ -220,7 +217,7 @@ PatientIdentifier identifier = patientIdentifierService.get( idType, value ); if ( identifier != null - && (id == null || identifier.getPatient().getId().intValue() != id.intValue()) ) + && (id == null || identifier.getPatient().getId() != id) ) { idDuplicate += idType.getName() + ", "; } @@ -254,7 +251,7 @@ } else if ( age != null ) { - p.setBirthDateFromAge( age.intValue(), Patient.AGE_TYPE_YEAR ); + p.setBirthDateFromAge( age, Patient.AGE_TYPE_YEAR ); } if ( programId != null )