← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14517: ProgramInstanceService, added enrollment method using uids in signature. Can be called outside a ...

 

------------------------------------------------------------
revno: 14517
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-03-28 12:28:37 +0100
message:
  ProgramInstanceService, added enrollment method using uids in signature. Can be called outside a transaction.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml


--
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	2014-03-26 14:01:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2014-03-28 11:28:37 +0000
@@ -346,6 +346,20 @@
     /**
      * Enroll a TrackedEntityInstance into a program
      * 
+     * @param entityInstance TrackedEntityInstance uid.
+     * @param program Program uid.
+     * @param enrollmentDate The date of enrollment
+     * @param dateOfIncident The date of incident
+     * @param orgunit Organisation Unit uid.
+     * 
+     * @return ProgramInsance
+     */
+    ProgramInstance enrollTrackedEntityInstance( String entityInstance, String program, 
+        Date enrollmentDate, Date dateOfIncident, String organisationUnit );
+    
+    /**
+     * Enroll a TrackedEntityInstance into a program. Must be run inside a transaction.
+     * 
      * @param entityInstance TrackedEntityInstance
      * @param program Program
      * @param enrollmentDate The date of enrollment

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2014-03-26 15:49:35 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2014-03-28 11:28:37 +0000
@@ -46,6 +46,7 @@
 import org.hisp.dhis.message.MessageConversation;
 import org.hisp.dhis.message.MessageService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.sms.SmsSender;
 import org.hisp.dhis.sms.SmsServiceException;
@@ -63,7 +64,6 @@
 import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValue;
 import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService;
 import org.hisp.dhis.user.CurrentUserService;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -140,6 +140,20 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
+    private TrackedEntityInstanceService trackedEntityInstanceService;
+    
+    public void setTrackedEntityInstanceService( TrackedEntityInstanceService trackedEntityInstanceService )
+    {
+        this.trackedEntityInstanceService = trackedEntityInstanceService;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
     private I18nManager i18nManager;
     
     public void setI18nManager( I18nManager i18nManager )
@@ -147,9 +161,6 @@
         this.i18nManager = i18nManager;
     }
 
-    @Autowired
-    private TrackedEntityInstanceService entityInstanceService;
-
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -514,6 +525,17 @@
     }
     
     @Override
+    public ProgramInstance enrollTrackedEntityInstance( String entityInstance, String program, 
+        Date enrollmentDate, Date dateOfIncident, String organisationUnit )
+    {
+        TrackedEntityInstance tei = trackedEntityInstanceService.getTrackedEntityInstance( entityInstance );
+        Program pr = programService.getProgram( program );
+        OrganisationUnit ou = organisationUnitService.getOrganisationUnit( organisationUnit );
+        
+        return enrollTrackedEntityInstance( tei, pr, enrollmentDate, dateOfIncident, ou );        
+    }
+    
+    @Override
     public ProgramInstance enrollTrackedEntityInstance( TrackedEntityInstance entityInstance, Program program,
         Date enrollmentDate, Date dateOfIncident, OrganisationUnit organisationUnit )
     {
@@ -591,7 +613,7 @@
         messages.addAll( sendMessageConversations( programInstance, TrackedEntityInstanceReminder.SEND_WHEN_TO_EMROLLEMENT ) );
 
         updateProgramInstance( programInstance );
-        entityInstanceService.updateTrackedEntityInstance( entityInstance );
+        trackedEntityInstanceService.updateTrackedEntityInstance( entityInstance );
 
         return programInstance;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml	2014-03-26 21:55:22 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml	2014-03-28 11:28:37 +0000
@@ -208,6 +208,8 @@
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="i18nManager" ref="org.hisp.dhis.i18n.I18nManager" />
+		<property name="trackedEntityInstanceService" ref="org.hisp.dhis.trackedentity.TrackedEntityInstanceService" />
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramStageService" class="org.hisp.dhis.program.DefaultProgramStageService">