dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29464
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14891: TEI query, supporting follow up status
------------------------------------------------------------
revno: 14891
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-04-17 22:10:10 +0200
message:
TEI query, supporting follow up status
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.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/trackedentity/TrackedEntityInstanceQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2014-04-08 15:19:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2014-04-17 20:10:10 +0000
@@ -90,6 +90,12 @@
private ProgramStatus programStatus;
/**
+ * Indicates whether tracked entity instance is marked for follow up for the
+ * specified program.
+ */
+ private Boolean followUp;
+
+ /**
* Enrollment dates for the given program.
*/
private List<QueryFilter> programDates = new ArrayList<QueryFilter>();
@@ -328,6 +334,15 @@
}
/**
+ * Indicates whether this params specifies follow up for the given program.
+ * Follow up can be specified as true or false.
+ */
+ public boolean hasFollowUp()
+ {
+ return followUp != null;
+ }
+
+ /**
* Indicates whether this params specifies any program dates.
* @return
*/
@@ -448,6 +463,16 @@
this.programStatus = programStatus;
}
+ public Boolean getFollowUp()
+ {
+ return followUp;
+ }
+
+ public void setFollowUp( Boolean followUp )
+ {
+ this.followUp = followUp;
+ }
+
public List<QueryFilter> getProgramDates()
{
return programDates;
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java 2014-04-12 04:55:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java 2014-04-17 20:10:10 +0000
@@ -70,11 +70,12 @@
* @param query the query string.
* @param attribute the set of attributes.
* @param filter the set of filters.
- * @param ou the organisation unit string.
+ * @param ou the set of organisatio unit identifiers.
* @param ouMode the OrganisationUnitSelectionMode.
- * @param program the Program uid.
- * @param programStatus the ProgramStatus of the given Program.
- * @param programDate the set of filters for program enrollment dates.
+ * @param program the Program identifier.
+ * @param programStatus the ProgramStatus in the given orogram.
+ * @param followUp indicates follow up status in the given Program.
+ * @param programDate the set of filters for Program enrollment dates.
* @param trackedEntity the TrackedEntity uid.
* @param skipMeta indicates whether to include meta data in the response.
* @param page the page number.
@@ -82,7 +83,7 @@
* @return a TrackedEntityInstanceQueryParams.
*/
TrackedEntityInstanceQueryParams getFromUrl( String query, Set<String> attribute, Set<String> filter,
- Set<String> ou, OrganisationUnitSelectionMode ouMode, String program, ProgramStatus programStatus, Set<String> programDate,
+ Set<String> ou, OrganisationUnitSelectionMode ouMode, String program, ProgramStatus programStatus, Boolean followUp, Set<String> programDate,
String trackedEntity, boolean skipMeta, Integer page, Integer pageSize );
/**
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2014-04-12 04:55:36 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2014-04-17 20:10:10 +0000
@@ -291,6 +291,11 @@
violation = "Program must be defined when program status is defined";
}
+ if ( params.hasFollowUp() && !params.hasProgram() )
+ {
+ violation = "Program must be defined when follow up status is defined";
+ }
+
if ( params.hasProgramDates() && !params.hasProgram() )
{
violation = "Program must be defined when program dates are specified";
@@ -321,7 +326,8 @@
@Override
public TrackedEntityInstanceQueryParams getFromUrl( String query, Set<String> attribute, Set<String> filter, Set<String> ou,
- OrganisationUnitSelectionMode ouMode, String program, ProgramStatus programStatus, Set<String> programDate, String trackedEntity, boolean skipMeta, Integer page, Integer pageSize )
+ OrganisationUnitSelectionMode ouMode, String program, ProgramStatus programStatus, Boolean followUp, Set<String> programDate,
+ String trackedEntity, boolean skipMeta, Integer page, Integer pageSize )
{
TrackedEntityInstanceQueryParams params = new TrackedEntityInstanceQueryParams();
@@ -387,6 +393,7 @@
params.setQuery( query );
params.setProgram( pr );
params.setProgramStatus( programStatus );
+ params.setFollowUp( followUp );
params.setTrackedEntity( te );
params.setOrganisationUnitMode( ouMode );
params.setSkipMeta( skipMeta );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-04-17 12:09:39 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-04-17 20:10:10 +0000
@@ -281,8 +281,7 @@
else if ( params.isOrganisationUnitMode( OrganisationUnitSelectionMode.ALL ) )
{
}
- else
- // SELECTED (default)
+ else // SELECTED (default)
{
sql += hlp.whereAnd() + " tei.organisationunitid in ("
+ getCommaDelimitedString( getIdentifiers( params.getOrganisationUnits() ) ) + ") ";
@@ -290,14 +289,20 @@
if ( params.hasProgram() )
{
- sql += hlp.whereAnd() + " exists (" + "select trackedentityinstanceid from programinstance pi "
- + "where pi.trackedentityinstanceid=tei.trackedentityinstanceid " + "and pi.programid = "
- + params.getProgram().getId() + " ";
+ sql += hlp.whereAnd() + " exists (" +
+ "select trackedentityinstanceid from programinstance pi " +
+ "where pi.trackedentityinstanceid=tei.trackedentityinstanceid " +
+ "and pi.programid = " + params.getProgram().getId() + " ";
if ( params.hasProgramStatus() )
{
sql += "and pi.status = " + PROGRAM_STATUS_MAP.get( params.getProgramStatus() + " " );
}
+
+ if ( params.hasFollowUp() )
+ {
+ sql += "and pi.followup = " + params.getFollowUp() + " ";
+ }
if ( params.hasProgramDates() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2014-04-15 09:59:01 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/EventController.java 2014-04-17 20:10:10 +0000
@@ -243,6 +243,7 @@
return metaData;
}
+
// -------------------------------------------------------------------------
// CREATE
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java 2014-04-08 11:37:59 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/event/TrackedEntityInstanceController.java 2014-04-17 20:10:10 +0000
@@ -105,6 +105,7 @@
@RequestParam(required=false) OrganisationUnitSelectionMode ouMode,
@RequestParam(required=false) String program,
@RequestParam(required=false) ProgramStatus programStatus,
+ @RequestParam(required=false) Boolean followUp,
@RequestParam(required=false) Set<String> programDate,
@RequestParam(required=false) String trackedEntity,
@RequestParam(required=false) boolean skipMeta,
@@ -115,7 +116,7 @@
{
Set<String> orgUnits = new HashSet<String>( ContextUtils.getQueryParamValues( ou ) );
TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
- program, programStatus, programDate, trackedEntity, skipMeta, page, pageSize );
+ program, programStatus, followUp, programDate, trackedEntity, skipMeta, page, pageSize );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.NO_CACHE );
Grid grid = instanceService.getTrackedEntityInstances( params );
@@ -134,6 +135,7 @@
@RequestParam(required=false) OrganisationUnitSelectionMode ouMode,
@RequestParam(required=false) String program,
@RequestParam(required=false) ProgramStatus programStatus,
+ @RequestParam(required=false) Boolean followUp,
@RequestParam(required=false) Set<String> programDate,
@RequestParam(required=false) String trackedEntity,
@RequestParam(required=false) boolean skipMeta,
@@ -144,7 +146,7 @@
{
Set<String> orgUnits = new HashSet<String>( ContextUtils.getQueryParamValues( ou ) );
TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
- program, programStatus, programDate, trackedEntity, skipMeta, page, pageSize );
+ program, programStatus, followUp, programDate, trackedEntity, skipMeta, page, pageSize );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.NO_CACHE );
Grid grid = instanceService.getTrackedEntityInstances( params );
@@ -160,6 +162,7 @@
@RequestParam(required=false) OrganisationUnitSelectionMode ouMode,
@RequestParam(required=false) String program,
@RequestParam(required=false) ProgramStatus programStatus,
+ @RequestParam(required=false) Boolean followUp,
@RequestParam(required=false) Set<String> programDate,
@RequestParam(required=false) String trackedEntity,
@RequestParam(required=false) boolean skipMeta,
@@ -170,7 +173,7 @@
{
Set<String> orgUnits = new HashSet<String>( ContextUtils.getQueryParamValues( ou ) );
TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
- program, programStatus, programDate, trackedEntity, skipMeta, page, pageSize );
+ program, programStatus, followUp, programDate, trackedEntity, skipMeta, page, pageSize );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.NO_CACHE );
Grid grid = instanceService.getTrackedEntityInstances( params );
@@ -186,6 +189,7 @@
@RequestParam(required=false) OrganisationUnitSelectionMode ouMode,
@RequestParam(required=false) String program,
@RequestParam(required=false) ProgramStatus programStatus,
+ @RequestParam(required=false) Boolean followUp,
@RequestParam(required=false) Set<String> programDate,
@RequestParam(required=false) String trackedEntity,
@RequestParam(required=false) boolean skipMeta,
@@ -196,7 +200,7 @@
{
Set<String> orgUnits = new HashSet<String>( ContextUtils.getQueryParamValues( ou ) );
TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
- program, programStatus, programDate, trackedEntity, skipMeta, page, pageSize );
+ program, programStatus, followUp, programDate, trackedEntity, skipMeta, page, pageSize );
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.NO_CACHE );
Grid grid = instanceService.getTrackedEntityInstances( params );