← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12862: Remove unused methods in ProgramInstanceService

 

------------------------------------------------------------
revno: 12862
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-11-04 10:49:17 +0700
message:
  Remove unused methods in ProgramInstanceService
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramInstanceDeletionHandler.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.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/program/ProgramInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2013-11-04 03:13:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2013-11-04 03:49:17 +0000
@@ -170,16 +170,7 @@
      * @return ProgramInstance list
      */
     Collection<ProgramInstance> getProgramInstances( Collection<Program> programs, Integer status );
-
-    /**
-     * Retrieve program instances on a patient
-     * 
-     * @param patient Patient
-     * 
-     * @return ProgramInstance list
-     */
-    Collection<ProgramInstance> getProgramInstances( Patient patient );
-
+    
     /**
      * Retrieve program instances on a patient by a status
      * 
@@ -234,8 +225,8 @@
      * 
      * @return ProgramInstance list
      */
-    Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, int min,
-        int max );
+    Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, Integer min,
+        Integer max );
 
     /**
      * Retrieve program instances with active status on an orgunit by a program

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java	2013-11-04 03:13:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java	2013-11-04 03:49:17 +0000
@@ -119,15 +119,6 @@
     Collection<ProgramInstance> get( Collection<Program> programs, Integer status );
 
     /**
-     * Retrieve program instances on a patient
-     * 
-     * @param patient Patient
-     * 
-     * @return ProgramInstance list
-     */
-    Collection<ProgramInstance> get( Patient patient );
-
-    /**
      * Retrieve program instances on a patient by a status
      * 
      * @param patient Patient
@@ -181,7 +172,7 @@
      * 
      * @return ProgramInstance list
      */
-    Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, int min, int max );
+    Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, Integer min, Integer max );
 
     /**
      * Retrieve program instances with active status on an orgunit by a program

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2013-11-04 03:13:27 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2013-11-04 03:49:17 +0000
@@ -211,11 +211,6 @@
         return programInstanceStore.get( program, status );
     }
 
-    public Collection<ProgramInstance> getProgramInstances( Patient patient )
-    {
-        return programInstanceStore.get( patient );
-    }
-
     public Collection<ProgramInstance> getProgramInstances( Patient patient, Integer status )
     {
         return programInstanceStore.get( patient, status );
@@ -237,7 +232,7 @@
     }
 
     public Collection<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit,
-        int min, int max )
+        Integer min, Integer max )
     {
         return programInstanceStore.get( program, organisationUnit, min, max );
     }
@@ -574,14 +569,16 @@
         Collection<OutboundSms> outboundSmsList = new HashSet<OutboundSms>();
 
         Collection<PatientReminder> reminders = programInstance.getProgram().getPatientReminders();
-        
+
         for ( PatientReminder rm : reminders )
         {
-            if ( rm != null && rm.getWhenToSend() != null && rm.getWhenToSend() == status
+            if ( rm != null
+                && rm.getWhenToSend() != null
+                && rm.getWhenToSend() == status
                 && (rm.getMessageType() == PatientReminder.MESSAGE_TYPE_DIRECT_SMS || rm.getMessageType() == PatientReminder.MESSAGE_TYPE_BOTH) )
             {
                 OutboundSms outboundSms = sendProgramMessage( rm, programInstance, patient, format );
-                
+
                 if ( outboundSms != null )
                 {
                     outboundSmsList.add( outboundSms );
@@ -635,7 +632,7 @@
         // ---------------------------------------------------------------------
 
         ProgramInstance programInstance = new ProgramInstance();
-        
+
         programInstance.enrollPatient( patient, program );
         programInstance.setEnrollmentDate( enrollmentDate );
         programInstance.setDateOfIncident( dateOfIncident );
@@ -666,7 +663,7 @@
         // -----------------------------------------------------------------
 
         List<OutboundSms> outboundSms = programInstance.getOutboundSms();
-        
+
         if ( outboundSms == null )
         {
             outboundSms = new ArrayList<OutboundSms>();
@@ -679,7 +676,7 @@
         // -----------------------------------------------------------------
 
         List<MessageConversation> messages = programInstance.getMessageConversations();
-        
+
         if ( messages == null )
         {
             messages = new ArrayList<MessageConversation>();

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramInstanceDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramInstanceDeletionHandler.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/ProgramInstanceDeletionHandler.java	2013-11-04 03:49:17 +0000
@@ -89,7 +89,7 @@
     @Override
     public void deletePatient( Patient patient )
     {
-        Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient );
+        Collection<ProgramInstance> programInstances = patient.getProgramInstances();
 
         if ( programInstances != null )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2013-10-14 11:20:58 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2013-11-04 03:49:17 +0000
@@ -32,6 +32,7 @@
 import java.util.Date;
 import java.util.HashSet;
 
+import org.hibernate.Criteria;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
@@ -86,8 +87,9 @@
     @SuppressWarnings( "unchecked" )
     public Collection<ProgramInstance> get( Collection<Program> programs, OrganisationUnit organisationUnit, int status )
     {
-        return getCriteria( Restrictions.eq( "status", status ), Restrictions.in( "program", programs ) ).createAlias( "patient", "patient" )
-            .add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) ).list();
+        return getCriteria( Restrictions.eq( "status", status ), Restrictions.in( "program", programs ) )
+            .createAlias( "patient", "patient" ).add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) )
+            .list();
     }
 
     @SuppressWarnings( "unchecked" )
@@ -103,12 +105,6 @@
     }
 
     @SuppressWarnings( "unchecked" )
-    public Collection<ProgramInstance> get( Patient patient )
-    {
-        return getCriteria( Restrictions.eq( "patient", patient ) ).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
     public Collection<ProgramInstance> get( Patient patient, Integer status )
     {
         return getCriteria( Restrictions.eq( "patient", patient ), Restrictions.eq( "status", status ) ).list();
@@ -136,11 +132,17 @@
     }
 
     @SuppressWarnings( "unchecked" )
-    public Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, int min, int max )
+    public Collection<ProgramInstance> get( Program program, OrganisationUnit organisationUnit, Integer min, Integer max )
     {
-        return getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) )
+        Criteria criteria = getCriteria( Restrictions.eq( "program", program ), Restrictions.isNull( "endDate" ) )
             .add( Restrictions.eq( "patient.organisationUnit", organisationUnit ) ).createAlias( "patient", "patient" )
-            .addOrder( Order.asc( "patient.id" ) ).setFirstResult( min ).setMaxResults( max ).list();
+            .addOrder( Order.asc( "patient.id" ) );
+
+        if ( min != null && max != null )
+        {
+            criteria.setFirstResult( min ).setMaxResults( max );
+        }
+        return criteria.list();
     }
 
     @SuppressWarnings( "unchecked" )
@@ -276,12 +278,10 @@
         return schedulingProgramObjects;
     }
 
-
     private String sendToPatientSql( String dateToCompare )
     {
         return "SELECT pi.programinstanceid, p.phonenumber, prm.templatemessage, "
-            + "         p.name, org.name as orgunitName, "
-            + "         pg.name as programName, pi.dateofincident , "
+            + "         p.name, org.name as orgunitName, " + "         pg.name as programName, pi.dateofincident , "
             + "         pi.enrollmentdate,(DATE(now()) - DATE(pi.enrollmentdate) ) as days_since_erollment_date, "
             + "         (DATE(now()) - DATE(pi.dateofincident) ) as days_since_incident_date "
             + "       FROM patient p INNER JOIN programinstance pi "
@@ -308,17 +308,11 @@
             + "           ON org.organisationunitid = p.organisationunitid INNER JOIN patientreminder prm "
             + "           ON prm.programid = pi.programid INNER JOIN users us "
             + "           ON us.userid=p.healthworkerid INNER JOIN userinfo uif "
-            + "           ON us.userid=uif.userinfoid "
-            + "    WHERE pi.status = "
-            + ProgramInstance.STATUS_ACTIVE
+            + "           ON us.userid=uif.userinfoid " + "    WHERE pi.status = " + ProgramInstance.STATUS_ACTIVE
             + "      and uif.phonenumber is not NULL and uif.phonenumber != '' "
             + "      and prm.templatemessage is not NULL and prm.templatemessage != '' "
-            + "      and pg.type=1 and prm.daysallowedsendmessage is not null "
-            + "      and ( DATE(now()) - DATE( pi."
-            + dateToCompare
-            + " ) ) = prm.daysallowedsendmessage "
-            + "      and prm.dateToCompare='"
-            + dateToCompare
+            + "      and pg.type=1 and prm.daysallowedsendmessage is not null " + "      and ( DATE(now()) - DATE( pi."
+            + dateToCompare + " ) ) = prm.daysallowedsendmessage " + " and prm.dateToCompare='" + dateToCompare
             + "'     and prm.whenToSend is null and prm.sendto =  " + PatientReminder.SEND_TO_HEALTH_WORKER;
     }
 
@@ -331,17 +325,11 @@
             + "           ON p.patientid=pi.patientid INNER JOIN program pg "
             + "           ON pg.programid=pi.programid INNER JOIN organisationunit org "
             + "           ON org.organisationunitid = p.organisationunitid INNER JOIN patientreminder prm "
-            + "           ON prm.programid = pi.programid "
-            + "    WHERE pi.status = "
-            + ProgramInstance.STATUS_ACTIVE
+            + "           ON prm.programid = pi.programid " + "    WHERE pi.status = " + ProgramInstance.STATUS_ACTIVE
             + "      and org.phonenumber is not NULL and org.phonenumber != '' "
             + "      and prm.templatemessage is not NULL and prm.templatemessage != '' "
-            + "      and pg.type=1 and prm.daysallowedsendmessage is not null "
-            + "      and ( DATE(now()) - DATE( pi."
-            + dateToCompare
-            + " ) ) = prm.daysallowedsendmessage "
-            + "      and prm.dateToCompare='"
-            + dateToCompare
+            + "      and pg.type=1 and prm.daysallowedsendmessage is not null " + "      and ( DATE(now()) - DATE( pi."
+            + dateToCompare + " ) ) = prm.daysallowedsendmessage " + " and prm.dateToCompare='" + dateToCompare
             + "'     and prm.whenToSend is null and prm.sendto =  " + PatientReminder.SEND_TO_ORGUGNIT_REGISTERED;
     }
 
@@ -357,7 +345,8 @@
             + "    ON prm.programid = pi.programid INNER JOIN usermembership ums "
             + "    ON ums.organisationunitid = p.organisationunitid INNER JOIN userinfo uif "
             + "    ON uif.userinfoid = ums.userinfoid "
-            + "WHERE pi.status= " + ProgramInstance.STATUS_ACTIVE
+            + "WHERE pi.status= "
+            + ProgramInstance.STATUS_ACTIVE
             + "         and uif.phonenumber is not NULL and uif.phonenumber != '' "
             + "         and prm.templatemessage is not NULL and prm.templatemessage != '' "
             + "         and pg.type=1 and prm.daysallowedsendmessage is not null "
@@ -375,25 +364,16 @@
         return "select pi.programinstanceid, uif.phonenumber,prm.templatemessage, p.name, org.name as orgunitName ,"
             + " pg.name as programName, pi.dateofincident, pi.enrollmentdate, (DATE(now()) - DATE(pi.enrollmentdate) ) as days_since_erollment_date, "
             + "(DATE(now()) - DATE(pi.dateofincident) ) as days_since_incident_date "
-            + "  from patient p INNER JOIN programinstance pi "
-            + "       ON p.patientid=pi.patientid "
-            + "   INNER JOIN program pg "
-            + "       ON pg.programid=pi.programid "
-            + "   INNER JOIN organisationunit org "
-            + "       ON org.organisationunitid = p.organisationunitid "
-            + "   INNER JOIN patientreminder prm "
-            + "       ON prm.programid = pg.programid "
-            + "   INNER JOIN usergroupmembers ugm "
-            + "       ON ugm.usergroupid = prm.usergroupid "
-            + "   INNER JOIN userinfo uif "
-            + "       ON uif.userinfoid = ugm.userid "
-            + "  WHERE pi.status= "
-            + ProgramInstance.STATUS_ACTIVE
-            + "       and uif.phonenumber is not NULL and uif.phonenumber != '' "
+            + "  from patient p INNER JOIN programinstance pi " + "       ON p.patientid=pi.patientid "
+            + "   INNER JOIN program pg " + "       ON pg.programid=pi.programid "
+            + "   INNER JOIN organisationunit org " + "       ON org.organisationunitid = p.organisationunitid "
+            + "   INNER JOIN patientreminder prm " + "       ON prm.programid = pg.programid "
+            + "   INNER JOIN usergroupmembers ugm " + "       ON ugm.usergroupid = prm.usergroupid "
+            + "   INNER JOIN userinfo uif " + "       ON uif.userinfoid = ugm.userid " + "  WHERE pi.status= "
+            + ProgramInstance.STATUS_ACTIVE + "       and uif.phonenumber is not NULL and uif.phonenumber != '' "
             + "       and prm.templatemessage is not NULL and prm.templatemessage != '' "
-            + "       and pg.type=1 and prm.daysallowedsendmessage is not null "
-            + "       and (  DATE(now()) - DATE("+ dateToCompare +") ) = prm.daysallowedsendmessage "
-            + "       and prm.whentosend is null "
-            + "       and prm.sendto = " +  PatientReminder.SEND_TO_USER_GROUP;
+            + "       and pg.type=1 and prm.daysallowedsendmessage is not null " + "       and (  DATE(now()) - DATE("
+            + dateToCompare + ") ) = prm.daysallowedsendmessage " + "       and prm.whentosend is null "
+            + "       and prm.sendto = " + PatientReminder.SEND_TO_USER_GROUP;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2013-09-27 11:13:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/PatientDashboardAction.java	2013-11-04 03:49:17 +0000
@@ -49,7 +49,6 @@
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramIndicatorService;
 import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.relationship.Relationship;
 import org.hisp.dhis.relationship.RelationshipService;
@@ -73,8 +72,6 @@
 
     private RelationshipService relationshipService;
 
-    private ProgramInstanceService programInstanceService;
-
     private PatientAuditService patientAuditService;
 
     private CurrentUserService currentUserService;
@@ -84,7 +81,7 @@
     private ProgramIndicatorService programIndicatorService;
 
     private PatientAttributeValueService patientAttributeValueService;
-    
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -173,11 +170,6 @@
         return relationships;
     }
 
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
     public Patient getPatient()
     {
         return patient;
@@ -223,8 +215,8 @@
 
         relationships = relationshipService.getRelationshipsForPatient( patient );
 
-        Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient );
-        
+        Collection<ProgramInstance> programInstances = patient.getProgramInstances();
+
         // ---------------------------------------------------------------------
         // Get patient-attribute-values
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-11-03 23:45:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-11-04 03:49:17 +0000
@@ -773,7 +773,7 @@
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.patient.ValidateSearchRelationshipAction"
 		class="org.hisp.dhis.caseentry.action.patient.ValidateSearchRelationshipAction"
@@ -1002,7 +1002,6 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="relationshipService"
 			ref="org.hisp.dhis.relationship.RelationshipService" />
-		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="patientAuditService" ref="org.hisp.dhis.patient.PatientAuditService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/namebaseddataentry/action/GetPatientProgramListAction.java	2013-11-04 03:49:17 +0000
@@ -35,6 +35,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import org.hisp.dhis.light.utils.NamebasedUtils;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientIdentifier;
@@ -285,9 +286,10 @@
 
         patient = patientService.getPatient( patientId );
         Collection<Program> programByCurrentUser = programService.getProgramsByCurrentUser();
-        for ( ProgramInstance programInstance : programInstanceService.getProgramInstances( patient ) )
+        for ( ProgramInstance programInstance : patient.getProgramInstances() )
         {
-            if ( programInstance.getStatus() == ProgramInstance.STATUS_ACTIVE && programByCurrentUser.contains( programInstance.getProgram() ) )
+            if ( programInstance.getStatus() == ProgramInstance.STATUS_ACTIVE
+                && programByCurrentUser.contains( programInstance.getProgram() ) )
             {
                 programInstances.add( programInstance );
             }
@@ -313,7 +315,7 @@
 
         patientIdentifiers = patientIdentifierService.getPatientIdentifiers( patient );
 
-        Collection<ProgramInstance> listOfProgramInstance = programInstanceService.getProgramInstances( patient );
+        Collection<ProgramInstance> listOfProgramInstance = patient.getProgramInstances();
 
         this.listOfCompletedProgram = new ArrayList<ProgramInstance>();
 
@@ -343,13 +345,15 @@
             }
             else if ( !program.isSingleEvent() )
             {
-                if ( programInstanceService.getProgramInstances( patient, program, ProgramInstance.STATUS_ACTIVE ).size() == 0 )
+                if ( programInstanceService.getProgramInstances( patient, program, ProgramInstance.STATUS_ACTIVE )
+                    .size() == 0 )
                 {
                     programs.add( program );
                 }
                 else if ( programInstanceService.getProgramInstances( patient, program ).size() > 0
                     && !program.getOnlyEnrollOnce()
-                    && programInstanceService.getProgramInstances( patient, program, ProgramInstance.STATUS_ACTIVE ).size() == 0 )
+                    && programInstanceService.getProgramInstances( patient, program, ProgramInstance.STATUS_ACTIVE )
+                        .size() == 0 )
                 {
                     programs.add( program );
                 }