dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17859
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7277: Cosmetic code, remove un-used methods (patient module).
------------------------------------------------------------
revno: 7277
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-06-12 14:46:25 +0700
message:
Cosmetic code, remove un-used methods (patient module).
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java
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/PatientDeletionHandler.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java
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/ValidatePatientAction.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-api/src/main/java/org/hisp/dhis/patient/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2012-05-15 07:40:06 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java 2012-06-12 07:46:25 +0000
@@ -55,14 +55,6 @@
Collection<Patient> getAllPatients();
/**
- * Get Patients base on isDead property
- *
- * @param isDead
- * @return Patient List
- */
- Collection<Patient> getAllPatients( Boolean isDead );
-
- /**
* Search Patient base on firstname/middlename/lastname/birthDate/gender
*
* @param firstName
@@ -72,7 +64,7 @@
* @param gender
* @return Patient List
*/
- Collection<Patient> getPatient( String firstName, String middleName, String lastName, Date birthdate, String gender );
+ Collection<Patient> getPatients( String firstName, String middleName, String lastName, Date birthdate, String gender );
/**
* Search Patient base on gender
@@ -96,17 +88,15 @@
* @param name fullName
* @return Patient List
*/
- Collection<Patient> getPatientsByNames( String name );
+ Collection<Patient> getPatientsByNames( String name, Integer min, Integer max );
/**
- * Search Patient base on identifier value with result limited
+ * Search Patient base on full-name or identifier value
*
* @param searchText value
- * @param min
- * @param max
* @return Patient List
*/
- Collection<Patient> getPatients( String searchText, int min, int max );
+ Collection<Patient> getPatients( String searchText, Integer min, Integer max );
/**
* Search Patient for mobile base on identifier value
@@ -123,28 +113,18 @@
* @param organisationUnit organisationUnit
* @return Patient List
*/
- Collection<Patient> getPatients( OrganisationUnit organisationUnit );
+ Collection<Patient> getPatients( OrganisationUnit organisationUnit, Integer min, Integer max );
/**
- * Search Patient base on organization unit with result limited
- *
- * @param organisationUnit organisationUnit
- * @param min
- * @param max
- * @return Patient List
- */
- Collection<Patient> getPatients( OrganisationUnit organisationUnit, int min, int max );
-
- /**
* Search Patient base on organization unit and sort the result by PatientAttribute
*
* @param organisationUnit organisationUnit
+ * @param patientAttribute
* @param min
* @param max
- * @param patientAttribute
* @return Patient List
*/
- Collection<Patient> getPatients( OrganisationUnit organisationUnit, int min, int max, PatientAttribute patientAttribute );
+ Collection<Patient> getPatients( OrganisationUnit organisationUnit, PatientAttribute patientAttribute, Integer min, Integer max );
/**
* Search Patient base on organisationUnit and identifier value
@@ -156,7 +136,7 @@
* @param max
* @return
*/
- Collection<Patient> getPatients( OrganisationUnit organisationUnit, String searchText, int min, int max );
+ Collection<Patient> getPatients( OrganisationUnit organisationUnit, String searchText, Integer min, Integer max );
/**
* Search Patient base on PatientIdentifierType or Attribute or Patient's
@@ -179,7 +159,7 @@
* @param max
* @return
*/
- Collection<Patient> getPatients( OrganisationUnit organisationUnit, Program program, int min, int max );
+ Collection<Patient> getPatients( OrganisationUnit organisationUnit, Program program, Integer min, Integer max );
/**
* Sort the result by PatientAttribute
@@ -190,16 +170,7 @@
*/
Collection<Patient> sortPatientsByAttribute( Collection<Patient> patients, PatientAttribute patientAttribute );
- /**
- * Search Patient base on firstname/middlename/lastname with result limited
- *
- * @param name firstName/middleName/lastName
- * @param min
- * @param max
- * @return Patient List
- */
- Collection<Patient> getPatientsByNames( String name, int min, int max );
-
+
Collection<Patient> getRepresentatives( Patient patient );
/**
* Search Patient base on identifier value and get number of result
=== 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 2011-12-21 04:23:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java 2012-06-12 07:46:25 +0000
@@ -43,23 +43,17 @@
{
String ID = PatientStore.class.getName();
- Collection<Patient> get( Boolean isDead );
-
Collection<Patient> getByGender( String gender );
Collection<Patient> getByBirthDate( Date birthDate );
- Collection<Patient> getByNames( String name );
-
- Collection<Patient> getByNames( String name, int min, int max );
-
- Collection<Patient> getPatient( String firstName, String middleName, String lastName, Date birthdate, String gender );
-
- Collection<Patient> getByOrgUnit( OrganisationUnit organisationUnit );
-
- Collection<Patient> getByOrgUnit( OrganisationUnit organisationUnit, int min, int max );
-
- Collection<Patient> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, int min, int max );
+ Collection<Patient> getByNames( String name, Integer min, Integer max );
+
+ Collection<Patient> get( String firstName, String middleName, String lastName, Date birthdate, String gender );
+
+ Collection<Patient> getByOrgUnit( OrganisationUnit organisationUnit, Integer min, Integer max );
+
+ Collection<Patient> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, Integer min, Integer max );
Collection<Patient> getRepresentatives( Patient patient );
=== 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 2012-06-06 04:31:43 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java 2012-06-12 07:46:25 +0000
@@ -187,16 +187,10 @@
}
@Override
- public Collection<Patient> getAllPatients( Boolean isDead )
- {
- return patientStore.get( isDead );
- }
-
- @Override
- public Collection<Patient> getPatient( String firstName, String middleName, String lastName, Date birthdate,
+ public Collection<Patient> getPatients( String firstName, String middleName, String lastName, Date birthdate,
String gender )
{
- return patientStore.getPatient( firstName, middleName, lastName, birthdate, gender );
+ return patientStore.get( firstName, middleName, lastName, birthdate, gender );
}
@Override
@@ -212,7 +206,7 @@
}
@Override
- public Collection<Patient> getPatients( String searchText, int min, int max )
+ public Collection<Patient> getPatients( String searchText, Integer min, Integer max )
{
int countPatientName = patientStore.countGetPatientsByName( searchText );
@@ -282,22 +276,16 @@
}
@Override
- public Collection<Patient> getPatients( OrganisationUnit organisationUnit )
- {
- return patientStore.getByOrgUnit( organisationUnit );
- }
-
- @Override
- public Collection<Patient> getPatients( OrganisationUnit organisationUnit, int min, int max )
+ public Collection<Patient> getPatients( OrganisationUnit organisationUnit, Integer min, Integer max )
{
return patientStore.getByOrgUnit( organisationUnit, min, max );
}
@Override
- public Collection<Patient> getPatients( OrganisationUnit organisationUnit, int min, int max,
- PatientAttribute patientAttribute )
+ public Collection<Patient> getPatients( OrganisationUnit organisationUnit, PatientAttribute patientAttribute,
+ Integer min, Integer max )
{
- List<Patient> patientList = new ArrayList<Patient>( patientStore.getByOrgUnit( organisationUnit ) );
+ List<Patient> patientList = new ArrayList<Patient>( patientStore.getByOrgUnit( organisationUnit, min, max ) );
if ( patientAttribute != null )
{
@@ -310,11 +298,12 @@
}
@Override
- public Collection<Patient> getPatients( OrganisationUnit organisationUnit, String searchText, int min, int max )
+ public Collection<Patient> getPatients( OrganisationUnit organisationUnit, String searchText, Integer min,
+ Integer max )
{
Collection<Patient> patients = new ArrayList<Patient>();
- Collection<Patient> allPatients = getPatientsByNames( searchText );
+ Collection<Patient> allPatients = getPatientsByNames( searchText, min, max );
if ( allPatients.retainAll( getPatients( organisationUnit, min, max ) ) )
{
@@ -351,7 +340,7 @@
}
else
{
- return patientStore.getByNames( value );
+ return patientStore.getByNames( value, null, null );
}
return null;
}
@@ -395,13 +384,7 @@
}
@Override
- public Collection<Patient> getPatientsByNames( String name )
- {
- return patientStore.getByNames( name.toLowerCase() );
- }
-
- @Override
- public Collection<Patient> getPatientsByNames( String name, int min, int max )
+ public Collection<Patient> getPatientsByNames( String name, Integer min, Integer max )
{
return patientStore.getByNames( name.toLowerCase(), min, max );
}
@@ -484,11 +467,13 @@
return patient.getRepresentative() == null || !patient.getRepresentative().getId().equals( representativeId );
}
- public Collection<Patient> getPatients( OrganisationUnit organisationUnit, Program program, int min, int max )
+ @Override
+ public Collection<Patient> getPatients( OrganisationUnit organisationUnit, Program program, Integer min, Integer max )
{
return patientStore.getByOrgUnitProgram( organisationUnit, program, min, max );
}
+ @Override
public int countGetPatientsByOrgUnitProgram( OrganisationUnit organisationUnit, Program program )
{
return patientStore.countGetPatientsByOrgUnitProgram( organisationUnit, program );
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java 2012-01-11 05:31:53 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/PatientDeletionHandler.java 2012-06-12 07:46:25 +0000
@@ -73,7 +73,7 @@
@Override
public void deleteOrganisationUnit( OrganisationUnit unit )
{
- for ( Patient patient : patientService.getPatients( unit ) )
+ for ( Patient patient : patientService.getPatients( unit, null, null ) )
{
patientService.deletePatient( patient );
}
=== 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 2011-12-21 04:23:59 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java 2012-06-12 07:46:25 +0000
@@ -89,58 +89,23 @@
// -------------------------------------------------------------------------
// Implementation methods
// -------------------------------------------------------------------------
-
- @SuppressWarnings( "unchecked" )
- public Collection<Patient> get( Boolean isDead )
- {
- return getCriteria( Restrictions.eq( "isDead", isDead ) ).list();
- }
-
- @SuppressWarnings( "unchecked" )
+
+ @SuppressWarnings( "unchecked" )
+ @Override
public Collection<Patient> getByGender( String gender )
{
return getCriteria( Restrictions.eq( "gender", gender ) ).list();
}
@SuppressWarnings( "unchecked" )
+ @Override
public Collection<Patient> getByBirthDate( Date birthDate )
{
return getCriteria( Restrictions.eq( "birthDate", birthDate ) ).list();
}
- public Collection<Patient> getByNames( String name )
- {
- String sql = statementBuilder.getPatientsByFullName( name );
-
- StatementHolder holder = statementManager.getHolder();
-
- Set<Patient> patients = new HashSet<Patient>();
-
- try
- {
- Statement statement = holder.getStatement();
-
- ResultSet resultSet = statement.executeQuery( sql );
-
- while ( resultSet.next() )
- {
- Patient p = get( resultSet.getInt( 1 ) );
- patients.add( p );
- }
- }
- catch ( Exception ex )
- {
- ex.printStackTrace();
- }
- finally
- {
- holder.close();
- }
-
- return patients;
- }
-
- public Collection<Patient> getByNames( String name, int min, int max )
+ @Override
+ public Collection<Patient> getByNames( String name, Integer min, Integer max )
{
String sql = statementBuilder.getPatientsByFullName( name, min, max );
@@ -173,7 +138,8 @@
}
@SuppressWarnings( "unchecked" )
- public Collection<Patient> getPatient( String firstName, String middleName, String lastName, Date birthdate,
+ @Override
+ public Collection<Patient> get( String firstName, String middleName, String lastName, Date birthdate,
String gender )
{
Criteria crit = getCriteria();
@@ -199,30 +165,38 @@
}
@SuppressWarnings( "unchecked" )
- public Collection<Patient> getByOrgUnit( OrganisationUnit organisationUnit )
- {
- String hql = "select distinct p from Patient p where p.organisationUnit = :organisationUnit order by p.id DESC";
-
- return getQuery( hql ).setEntity( "organisationUnit", organisationUnit ).list();
- }
-
- @SuppressWarnings( "unchecked" )
- public Collection<Patient> getByOrgUnit( OrganisationUnit organisationUnit, int min, int max )
+ @Override
+ public Collection<Patient> getByOrgUnit( OrganisationUnit organisationUnit, Integer min, Integer max )
{
String hql = "select p from Patient p where p.organisationUnit = :organisationUnit order by p.id DESC";
- return getQuery( hql ).setEntity( "organisationUnit", organisationUnit ).setFirstResult( min ).setMaxResults(
- max ).list();
+ Query query = getQuery( hql );
+ query.setEntity( "organisationUnit", organisationUnit );
+
+ if ( min != null && max != null )
+ {
+ query.setFirstResult( min ).setMaxResults( max );
+ }
+ return query.list();
}
@SuppressWarnings( "unchecked" )
- public Collection<Patient> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, int min, int max )
+ @Override
+ public Collection<Patient> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program, Integer min, Integer max )
{
- return getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) ).createAlias( "programs",
- "program" ).add( Restrictions.eq( "program.id", program.getId() ) ).addOrder( Order.desc( "id" ) )
- .setFirstResult( min ).setMaxResults( max ).list();
+ Criteria criteria = getCriteria( Restrictions.eq( "organisationUnit", organisationUnit ) ).createAlias( "programs",
+ "program" ).add( Restrictions.eq( "program.id", program.getId() ) );
+
+ criteria.addOrder( Order.desc( "id" ) );
+
+ if( min != null && max != null )
+ {
+ criteria.setFirstResult( min ).setMaxResults( max );
+ }
+ return criteria.list();
}
+ @Override
public int countGetPatientsByName( String name )
{
String sql = statementBuilder.countPatientsByFullName( name );
@@ -274,6 +248,7 @@
}
@SuppressWarnings( "unchecked" )
+ @Override
public Collection<Patient> getRepresentatives( Patient patient )
{
String hql = "select distinct p from Patient p where p.representative = :representative order by p.id DESC";
@@ -281,10 +256,11 @@
return getQuery( hql ).setEntity( "representative", patient ).list();
}
+ @Override
public void removeErollmentPrograms( Program program )
{
String sql = "delete from patient_programs where programid='" + program.getId() + "'";
-
+
jdbcTemplate.execute( sql );
}
}
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java 2012-06-08 10:35:59 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java 2012-06-12 07:46:25 +0000
@@ -77,7 +77,6 @@
{
if ( attributeValue.getValue() == null || attributeValue.getValue().length() == 0 )
{
-
attributeService.deleteAttributeValue( attributeValueItem );
}
else
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java 2011-08-03 07:44:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SearchPatientAction.java 2012-06-12 07:46:25 +0000
@@ -144,6 +144,7 @@
{
OrganisationUnit organisationUnit = selectionManager.getSelectedOrganisationUnit();
+ // List all patients
if ( listAll )
{
searchText = "list_all_patients";
@@ -168,6 +169,7 @@
}
}
+ // Search patients by attribute
if ( searchingAttributeId != null && searchText != null )
{
PatientAttribute searchingPatientAttribute = patientAttributeService
@@ -180,6 +182,8 @@
patients = patientAttributeValueService.searchPatients( searchingPatientAttribute, searchText, paging
.getStartPos(), paging.getPageSize() );
}
+
+ // Search patients by full-name / identifier
else
{
total = patientService.countGetPatients( searchText );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java 2011-12-27 07:35:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/SearchRelationshipPatientAction.java 2012-06-12 07:46:25 +0000
@@ -160,7 +160,7 @@
}
else
{
- patients = patientService.getPatientsByNames( searchText );
+ patients = patientService.getPatientsByNames( searchText, null, null );
}
}
if ( patients != null && !patients.isEmpty() )
=== 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 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidateAddRelationshipPatientAction.java 2012-06-12 07:46:25 +0000
@@ -181,7 +181,7 @@
{
// Check duplication name, birthdate, gender
- patients = patientService.getPatient( firstName, middleName, lastName, format.parseDate( birthDate ),
+ patients = patientService.getPatients( firstName, middleName, lastName, format.parseDate( birthDate ),
gender );
if ( patients != null && patients.size() > 0 )
=== 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 2012-03-12 10:20:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ValidatePatientAction.java 2012-06-12 07:46:25 +0000
@@ -188,7 +188,7 @@
if ( !checkedDuplicate )
{
- patients = patientService.getPatient( firstName, middleName, lastName, format.parseDate( birthDate ),
+ patients = patientService.getPatients( firstName, middleName, lastName, format.parseDate( birthDate ),
gender );
if ( patients != null && patients.size() > 0 )