← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19735: ProgramInstanceService, minor

 

------------------------------------------------------------
revno: 19735
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-08-06 19:12:37 +0200
message:
  ProgramInstanceService, minor
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminder.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.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/Program.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2015-07-15 17:25:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/Program.java	2015-08-06 17:12:37 +0000
@@ -249,6 +249,11 @@
 
         return null;
     }
+    
+    public boolean isSingleProgramStage()
+    {
+        return programStages != null && programStages.size() == 1;
+    }
 
     @Override
     public int increaseVersion()

=== 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	2015-07-08 03:26:22 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2015-08-06 17:12:37 +0000
@@ -250,8 +250,8 @@
         Integer max );
 
     /**
-     * Retrieve program instances with active status on an orgunit by a program
-     * for a certain period with result limited
+     * Retrieve program instances with active status on an organisation unit by 
+     * a program for a certain period with result limited
      *
      * @param program    Program
      * @param orgunitIds Organisation Units
@@ -266,7 +266,7 @@
 
     /**
      * Get the number of program instances which are active status and
-     * registered in a certain orgunit by a program for a certain period
+     * registered in a certain organisation unit by a program for a certain period
      *
      * @param program    Program
      * @param orgunitIds Organisation Units
@@ -335,16 +335,16 @@
     /**
      * Enroll a TrackedEntityInstance into a program. Must be run inside a transaction.
      *
-     * @param uid            UID to use for new instance
-     * @param entityInstance TrackedEntityInstance
-     * @param program        Program
-     * @param enrollmentDate The date of enrollment
-     * @param dateOfIncident The date of incident
-     * @param orgunit        Organisation Unit
-     * @return ProgramInsance
+     * @param uid                   UID to use for new instance
+     * @param trackedEntityInstance TrackedEntityInstance
+     * @param program               Program
+     * @param enrollmentDate        The date of enrollment
+     * @param dateOfIncident        The date of incident
+     * @param orgunit               Organisation Unit
+     * @return ProgramInstance
      */
-    ProgramInstance enrollTrackedEntityInstance( String uid, TrackedEntityInstance entityInstance, Program program, Date enrollmentDate, Date dateOfIncident,
-        OrganisationUnit orgunit );
+    ProgramInstance enrollTrackedEntityInstance( String uid, TrackedEntityInstance trackedEntityInstance, Program program, 
+        Date enrollmentDate, Date dateOfIncident, OrganisationUnit orgunit );
 
     /**
      * Enroll a TrackedEntityInstance into a program. Must be run inside a transaction.
@@ -354,7 +354,7 @@
      * @param enrollmentDate The date of enrollment
      * @param dateOfIncident The date of incident
      * @param orgunit        Organisation Unit
-     * @return ProgramInsance
+     * @return ProgramInstance
      */
     ProgramInstance enrollTrackedEntityInstance( TrackedEntityInstance entityInstance, Program program, Date enrollmentDate, Date dateOfIncident,
         OrganisationUnit orgunit );

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminder.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminder.java	2015-07-13 12:34:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminder.java	2015-08-06 17:12:37 +0000
@@ -90,7 +90,7 @@
 
     public static final int SEND_TO_USER_GROUP = 5;
 
-    public static final int SEND_WHEN_TO_EMROLLEMENT = 1;
+    public static final int SEND_WHEN_TO_ENROLLMENT = 1;
 
     public static final int SEND_WHEN_TO_C0MPLETED_EVENT = 2;
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2015-07-08 03:38:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2015-08-06 17:12:37 +0000
@@ -642,7 +642,7 @@
     }
 
     @Override
-    public ProgramInstance enrollTrackedEntityInstance( String uid, TrackedEntityInstance entityInstance,
+    public ProgramInstance enrollTrackedEntityInstance( String uid, TrackedEntityInstance trackedEntityInstance,
         Program program, Date enrollmentDate, Date dateOfIncident, OrganisationUnit organisationUnit )
     {
         // ---------------------------------------------------------------------
@@ -652,8 +652,7 @@
         ProgramInstance programInstance = new ProgramInstance();
         programInstance.setUid( CodeGenerator.isValidCode( uid ) ? uid : CodeGenerator.generateCode() );
         programInstance.setOrganisationUnit( organisationUnit );
-
-        programInstance.enrollTrackedEntityInstance( entityInstance, program );
+        programInstance.enrollTrackedEntityInstance( trackedEntityInstance, program );
 
         if ( enrollmentDate != null )
         {
@@ -677,11 +676,10 @@
         addProgramInstance( programInstance );
 
         // ---------------------------------------------------------------------
-        // Generate event if program is single event and has program stage.
-        // At some point, programs of type single event should be removed.
+        // Generate event if program is single event
         // ---------------------------------------------------------------------
 
-        if ( program.isRegistration() && program.getProgramStages().size() == 1 )
+        if ( program.isRegistration() && program.isSingleProgramStage() )
         {
             ProgramStage programStage = program.getProgramStages().iterator().next();
             programStageInstanceService.createProgramStageInstance( programInstance, programStage, enrollmentDate,
@@ -694,12 +692,12 @@
 
         List<OutboundSms> outboundSms = programInstance.getOutboundSms();
 
-        if ( outboundSms == null )
+        if ( outboundSms == null ) // TODO remove
         {
             outboundSms = new ArrayList<>();
         }
 
-        outboundSms.addAll( sendMessages( programInstance, TrackedEntityInstanceReminder.SEND_WHEN_TO_EMROLLEMENT ) );
+        outboundSms.addAll( sendMessages( programInstance, TrackedEntityInstanceReminder.SEND_WHEN_TO_ENROLLMENT ) );
 
         // -----------------------------------------------------------------
         // Send message when to completed the program
@@ -707,16 +705,16 @@
 
         List<MessageConversation> messages = programInstance.getMessageConversations();
 
-        if ( messages == null )
+        if ( messages == null ) // TODO remove
         {
             messages = new ArrayList<>();
         }
 
         messages.addAll( sendMessageConversations( programInstance,
-            TrackedEntityInstanceReminder.SEND_WHEN_TO_EMROLLEMENT ) );
+            TrackedEntityInstanceReminder.SEND_WHEN_TO_ENROLLMENT ) );
 
         updateProgramInstance( programInstance );
-        trackedEntityInstanceService.updateTrackedEntityInstance( entityInstance );
+        trackedEntityInstanceService.updateTrackedEntityInstance( trackedEntityInstance );
 
         return programInstance;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2015-08-02 14:29:38 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2015-08-06 17:12:37 +0000
@@ -718,7 +718,7 @@
         patient.getProgramInstances().add( programInstance );
         entityInstanceService.updateTrackedEntityInstance( patient );
         patient = entityInstanceService.getTrackedEntityInstance( patientId );
-        this.sendMessages( programInstance, TrackedEntityInstanceReminder.SEND_WHEN_TO_EMROLLEMENT );
+        this.sendMessages( programInstance, TrackedEntityInstanceReminder.SEND_WHEN_TO_ENROLLMENT );
         return getPatientModel( patient );
     }