dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24644
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12117: added /api/enrollments controller, made it possible to get all enrollments (no filtering yet)
------------------------------------------------------------
revno: 12117
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-09-17 17:26:14 +0200
message:
added /api/enrollments controller, made it possible to get all enrollments (no filtering yet)
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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.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-09-10 04:51:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2013-09-17 15:26:14 +0000
@@ -56,6 +56,8 @@
ProgramInstance getProgramInstance( int id );
+ ProgramInstance getProgramInstance( String id );
+
Collection<ProgramInstance> getAllProgramInstances();
Collection<ProgramInstance> getProgramInstances( Integer status );
=== 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-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java 2013-09-17 15:26:14 +0000
@@ -28,19 +28,19 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Date;
-import java.util.Collection;
-
-import org.hisp.dhis.common.GenericStore;
+import org.hisp.dhis.common.GenericIdentifiableObjectStore;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.patient.Patient;
+import java.util.Collection;
+import java.util.Date;
+
/**
* @author Abyot Asalefew
* @version $Id$
*/
public interface ProgramInstanceStore
- extends GenericStore<ProgramInstance>
+ extends GenericIdentifiableObjectStore<ProgramInstance>
{
String ID = ProgramInstanceStore.class.getName();
@@ -72,15 +72,15 @@
int min, int max );
int count( Program program, OrganisationUnit organisationUnit );
-
+
int count( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate );
-
+
void removeProgramEnrollment( ProgramInstance programInstance );
-
+
int countByStatus( Integer status, Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate );
-
+
Collection<ProgramInstance> getByStatus( Integer status, Program program, Collection<Integer> orgunitIds,
Date startDate, Date endDate );
-
+
Collection<SchedulingProgramObject> getSendMesssageEvents( String dateToCompare );
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2013-09-17 14:42:57 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2013-09-17 15:26:14 +0000
@@ -28,13 +28,89 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
public abstract class AbstractEnrollmentService implements EnrollmentService
{
- @Override public Enrollment getEnrollment( String id )
- {
- return null;
+ @Autowired
+ private ProgramInstanceService programInstanceService;
+
+ // -------------------------------------------------------------------------
+ // READ
+ // -------------------------------------------------------------------------
+
+ @Override
+ public Enrollments getEnrollments()
+ {
+ List<ProgramInstance> programInstances = new ArrayList<ProgramInstance>( programInstanceService.getAllProgramInstances() );
+ return getEnrollments( programInstances );
+ }
+
+ @Override
+ public Enrollments getEnrollments( Patient patient )
+ {
+ List<ProgramInstance> programInstances = new ArrayList<ProgramInstance>( programInstanceService.getProgramInstances( patient ) );
+ return getEnrollments( programInstances );
+ }
+
+ @Override
+ public Enrollments getEnrollments( Program program )
+ {
+ return null;
+ }
+
+ @Override
+ public Enrollments getEnrollments( OrganisationUnit organisationUnit )
+ {
+ return null;
+ }
+
+ @Override
+ public Enrollments getEnrollments( Program program, OrganisationUnit organisationUnit )
+ {
+ return null;
+ }
+
+ @Override
+ public Enrollments getEnrollments( Collection<ProgramInstance> programInstances )
+ {
+ Enrollments enrollments = new Enrollments();
+
+ for ( ProgramInstance programInstance : programInstances )
+ {
+ enrollments.getEnrollments().add( getEnrollment( programInstance ) );
+ }
+
+ return enrollments;
+ }
+
+ @Override
+ public Enrollment getEnrollment( String id )
+ {
+ return getEnrollment( programInstanceService.getProgramInstance( id ) );
+ }
+
+ @Override
+ public Enrollment getEnrollment( ProgramInstance programInstance )
+ {
+ Enrollment enrollment = new Enrollment();
+
+ enrollment.setEnrollment( programInstance.getUid() );
+ enrollment.setPerson( programInstance.getPatient().getUid() );
+ enrollment.setProgram( programInstance.getProgram().getUid() );
+
+ return enrollment;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java 2013-09-17 14:42:57 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentService.java 2013-09-17 15:26:14 +0000
@@ -28,6 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+
+import java.util.Collection;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -37,5 +44,33 @@
// READ
// -------------------------------------------------------------------------
- Enrollment getEnrollment(String id);
+ Enrollments getEnrollments();
+
+ Enrollments getEnrollments( Patient patient );
+
+ Enrollments getEnrollments( Program program );
+
+ Enrollments getEnrollments( OrganisationUnit organisationUnit );
+
+ Enrollments getEnrollments( Program program, OrganisationUnit organisationUnit );
+
+ Enrollments getEnrollments( Collection<ProgramInstance> programInstances );
+
+ Enrollment getEnrollment( String id );
+
+ Enrollment getEnrollment( ProgramInstance programInstance );
+
+ // -------------------------------------------------------------------------
+ // CREATE
+ // -------------------------------------------------------------------------
+
+
+ // -------------------------------------------------------------------------
+ // UPDATE
+ // -------------------------------------------------------------------------
+
+
+ // -------------------------------------------------------------------------
+ // DELETE
+ // -------------------------------------------------------------------------
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2013-09-17 12:15:39 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2013-09-17 15:26:14 +0000
@@ -47,6 +47,32 @@
*/
public interface EventService
{
+ // -------------------------------------------------------------------------
+ // READ
+ // -------------------------------------------------------------------------
+
+ Events getEvents( Program program, OrganisationUnit organisationUnit );
+
+ Events getEvents( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+
+ Events getEvents( ProgramStage programStage, OrganisationUnit organisationUnit );
+
+ Events getEvents( ProgramStage programStage, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+
+ Events getEvents( Program program, ProgramStage programStage, OrganisationUnit organisationUnit );
+
+ Events getEvents( Program program, ProgramStage programStage, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+
+ Events getEvents( List<Program> programs, List<ProgramStage> programStages, List<OrganisationUnit> organisationUnits, Date startDate, Date endDate );
+
+ Event getEvent( String uid );
+
+ Event getEvent( ProgramStageInstance programStageInstance );
+
+ // -------------------------------------------------------------------------
+ // CREATE
+ // -------------------------------------------------------------------------
+
ImportSummary saveEventXml( InputStream inputStream ) throws IOException;
ImportSummary saveEventXml( InputStream inputStream, ImportOptions importOptions ) throws IOException;
@@ -67,25 +93,15 @@
ImportSummaries saveEventsJson( InputStream inputStream, TaskId taskId, ImportOptions importOptions ) throws IOException;
- Events getEvents( Program program, OrganisationUnit organisationUnit );
-
- Events getEvents( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
-
- Events getEvents( ProgramStage programStage, OrganisationUnit organisationUnit );
-
- Events getEvents( ProgramStage programStage, OrganisationUnit organisationUnit, Date startDate, Date endDate );
-
- Events getEvents( Program program, ProgramStage programStage, OrganisationUnit organisationUnit );
-
- Events getEvents( Program program, ProgramStage programStage, OrganisationUnit organisationUnit, Date startDate, Date endDate );
-
- Events getEvents( List<Program> programs, List<ProgramStage> programStages, List<OrganisationUnit> organisationUnits, Date startDate, Date endDate );
-
- Event getEvent( String uid );
-
- Event getEvent( ProgramStageInstance programStageInstance );
+ // -------------------------------------------------------------------------
+ // UPDATE
+ // -------------------------------------------------------------------------
void updateEvent( Event event );
+ // -------------------------------------------------------------------------
+ // DELETE
+ // -------------------------------------------------------------------------
+
void deleteEvent( Event event );
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2013-09-17 12:15:39 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2013-09-17 15:26:14 +0000
@@ -14,11 +14,13 @@
<bean id="org.hisp.dhis.dxf2.datavalueset.DataValueSetStore"
class="org.hisp.dhis.dxf2.datavalueset.SpringDataValueSetStore" />
- <bean id="org.hisp.dhis.dxf2.event.EventStore" class="org.hisp.dhis.dxf2.events.event.DefaultEventStore" />
-
- <bean id="org.hisp.dhis.dxf2.event.EventService" class="org.hisp.dhis.dxf2.events.event.JacksonEventService" />
-
- <bean id="org.hisp.dhis.dxf2.event.PersonService" class="org.hisp.dhis.dxf2.events.person.JacksonPersonService" />
+ <bean id="org.hisp.dhis.dxf2.events.event.EventStore" class="org.hisp.dhis.dxf2.events.event.DefaultEventStore" />
+
+ <bean id="org.hisp.dhis.dxf2.events.event.EventService" class="org.hisp.dhis.dxf2.events.event.JacksonEventService" />
+
+ <bean id="org.hisp.dhis.dxf2.events.person.PersonService" class="org.hisp.dhis.dxf2.events.person.JacksonPersonService" />
+
+ <bean id="org.hisp.dhis.dxf2.events.enrollment.EnrollmentService" class="org.hisp.dhis.dxf2.events.enrollment.JacksonEnrollmentService" />
<bean id="org.hisp.dhis.dxf2.InputValidationService" class="org.hisp.dhis.dxf2.DefaultInputValidationService" />
=== 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-09-12 07:19:15 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2013-09-17 15:26:14 +0000
@@ -154,6 +154,12 @@
return programInstanceStore.get( id );
}
+ @Override
+ public ProgramInstance getProgramInstance( String id )
+ {
+ return programInstanceStore.getByUid( id );
+ }
+
public Collection<ProgramInstance> getProgramInstances( Integer status )
{
return programInstanceStore.get( status );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java 2013-09-17 14:42:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EnrollmentController.java 2013-09-17 15:26:14 +0000
@@ -28,8 +28,18 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.controller.WebOptions;
+import org.hisp.dhis.dxf2.events.enrollment.EnrollmentService;
+import org.hisp.dhis.dxf2.events.enrollment.Enrollments;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -39,4 +49,29 @@
public class EnrollmentController
{
public static final String RESOURCE_PATH = "/enrollments";
+
+ @Autowired
+ private EnrollmentService enrollmentService;
+
+ // -------------------------------------------------------------------------
+ // READ
+ // -------------------------------------------------------------------------
+
+ @RequestMapping( value = "", method = RequestMethod.GET )
+ public String getEnrollments(
+ @RequestParam( value = "orgUnit", required = false ) String orgUnitUid,
+ @RequestParam( value = "program", required = false ) String programUid,
+ @RequestParam( value = "person", required = false ) String personUid,
+ @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request )
+ {
+ WebOptions options = new WebOptions( parameters );
+ Enrollments enrollments;
+
+ enrollments = enrollmentService.getEnrollments();
+
+ model.addAttribute( "model", enrollments );
+ model.addAttribute( "viewClass", options.getViewClass( "basic" ) );
+
+ return "enrollments";
+ }
}