dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40155
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20341: Switched to using enum for ProgramInstance.status
------------------------------------------------------------
revno: 20341
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-09-24 15:32:10 +0700
message:
Switched to using enum for ProgramInstance.status
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java
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-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStatus.java
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/DefaultProgramStageInstanceService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramInstanceStoreTest.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/EnrollmentStatus.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.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/ProgramInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java 2015-09-11 11:54:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstance.java 2015-09-24 08:32:10 +0000
@@ -64,13 +64,7 @@
*/
private static final long serialVersionUID = -1235315582356509653L;
- public static int STATUS_ACTIVE = 0;
-
- private Integer status = STATUS_ACTIVE;
-
- public static int STATUS_COMPLETED = 1;
-
- public static int STATUS_CANCELLED = 2;
+ private ProgramStatus status = ProgramStatus.ACTIVE;
private OrganisationUnit organisationUnit;
@@ -318,12 +312,12 @@
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
- public int getStatus()
+ public ProgramStatus getStatus()
{
return status;
}
- public void setStatus( Integer status )
+ public void setStatus( ProgramStatus status )
{
this.status = status;
}
=== 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-09-11 11:54:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java 2015-09-24 08:32:10 +0000
@@ -28,16 +28,16 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.common.IllegalQueryException;
+import org.hisp.dhis.common.OrganisationUnitSelectionMode;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.trackedentity.TrackedEntityInstance;
+
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
-import org.hisp.dhis.common.IllegalQueryException;
-import org.hisp.dhis.common.OrganisationUnitSelectionMode;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.trackedentity.TrackedEntityInstance;
-
/**
* @author Abyot Asalefew
* @version $Id$
@@ -181,8 +181,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> getProgramInstances( Collection<Program> programs, OrganisationUnit organisationUnit,
- int status );
+ List<ProgramInstance> getProgramInstances( Collection<Program> programs, OrganisationUnit organisationUnit, ProgramStatus status );
/**
* Retrieve program instances on a program by status
@@ -192,7 +191,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> getProgramInstances( Program program, Integer status );
+ List<ProgramInstance> getProgramInstances( Program program, ProgramStatus status );
/**
* Retrieve program instances on a program list by status
@@ -202,7 +201,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> getProgramInstances( Collection<Program> programs, Integer status );
+ List<ProgramInstance> getProgramInstances( Collection<Program> programs, ProgramStatus status );
/**
* Retrieve program instances on a TrackedEntityInstance by a status
@@ -212,7 +211,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> getProgramInstances( TrackedEntityInstance entityInstance, Integer status );
+ List<ProgramInstance> getProgramInstances( TrackedEntityInstance entityInstance, ProgramStatus status );
/**
* Retrieve program instances on a TrackedEntityInstance by a program
@@ -232,7 +231,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> getProgramInstances( TrackedEntityInstance entityInstance, Program program, Integer status );
+ List<ProgramInstance> getProgramInstances( TrackedEntityInstance entityInstance, Program program, ProgramStatus status );
/**
* Retrieve program instances with active status on an orgunit by a program
@@ -244,11 +243,10 @@
* @param max Maximum results
* @return ProgramInstance list
*/
- List<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, Integer min,
- Integer max );
+ List<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, Integer min, Integer max );
/**
- * Retrieve program instances with active status on an organisation unit by
+ * Retrieve program instances with active status on an organisation unit by
* a program for a certain period with result limited
*
* @param program Program
@@ -286,7 +284,7 @@
* @param endDate The end date for retrieving on enrollment-date
* @return ProgramInstance list
*/
- List<ProgramInstance> getProgramInstancesByStatus( Integer status, Program program,
+ List<ProgramInstance> getProgramInstancesByStatus( ProgramStatus status, Program program,
Collection<Integer> orgunitIds, Date startDate, Date endDate );
/**
@@ -301,7 +299,7 @@
* @param endDate The end date for retrieving on enrollment-date
* @return A number
*/
- int countProgramInstancesByStatus( Integer status, Program program, Collection<Integer> orgunitIds, Date startDate,
+ int countProgramInstancesByStatus( ProgramStatus status, Program program, Collection<Integer> orgunitIds, Date startDate,
Date endDate );
/**
@@ -317,12 +315,12 @@
* @param trackedEntityInstance TrackedEntityInstance
* @param program Program
* @param enrollmentDate The date of enrollment
- * @param incidentDate The date of incident
+ * @param incidentDate The date of incident
* @param orgunit Organisation Unit
* @param uid UID to use for new instance
* @return ProgramInstance
*/
- ProgramInstance enrollTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance, Program program,
+ ProgramInstance enrollTrackedEntityInstance( TrackedEntityInstance trackedEntityInstance, Program program,
Date enrollmentDate, Date incidentDate, OrganisationUnit orgunit, String uid );
/**
@@ -331,7 +329,7 @@
* @param trackedEntityInstance TrackedEntityInstance
* @param program Program
* @param enrollmentDate The date of enrollment
- * @param incidentDate The date of incident
+ * @param incidentDate The date of incident
* @param orgunit Organisation Unit
* @return ProgramInstance
*/
=== 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 2015-07-07 14:54:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java 2015-09-24 08:32:10 +0000
@@ -97,7 +97,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> get( Collection<Program> programs, OrganisationUnit organisationUnit, int status );
+ List<ProgramInstance> get( Collection<Program> programs, OrganisationUnit organisationUnit, ProgramStatus status );
/**
* Retrieve program instances on a program by status
@@ -107,7 +107,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> get( Program program, Integer status );
+ List<ProgramInstance> get( Program program, ProgramStatus status );
/**
* Retrieve program instances on a program list by status
@@ -117,7 +117,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> get( Collection<Program> programs, Integer status );
+ List<ProgramInstance> get( Collection<Program> programs, ProgramStatus status );
/**
* Retrieve program instances on a TrackedEntityInstance by a status
@@ -127,7 +127,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> get( TrackedEntityInstance entityInstance, Integer status );
+ List<ProgramInstance> get( TrackedEntityInstance entityInstance, ProgramStatus status );
/**
* Retrieve program instances on a TrackedEntityInstance by a program
@@ -147,7 +147,7 @@
* STATUS_COMPLETED and STATUS_CANCELLED
* @return ProgramInstance list
*/
- List<ProgramInstance> get( TrackedEntityInstance entityInstance, Program program, Integer status );
+ List<ProgramInstance> get( TrackedEntityInstance entityInstance, Program program, ProgramStatus status );
/**
* Retrieve program instances with active status on an orgunit by a program
@@ -209,7 +209,7 @@
* @param endDate The end date for retrieving on enrollment-date
* @return A number
*/
- int countByStatus( Integer status, Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate );
+ int countByStatus( ProgramStatus status, Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate );
/**
* Retrieve program instances with a certain status on a program and an
@@ -223,7 +223,7 @@
* @param endDate The end date for retrieving on enrollment-date
* @return ProgramInstance list
*/
- List<ProgramInstance> getByStatus( Integer status, Program program, Collection<Integer> orgunitIds,
+ List<ProgramInstance> getByStatus( ProgramStatus status, Program program, Collection<Integer> orgunitIds,
Date startDate, Date endDate );
/**
@@ -238,7 +238,7 @@
* @param endDate The end date for retrieving on enrollment-date
* @return ProgramInstance list
*/
- List<ProgramInstance> getByStatus( Integer status, Program program, Collection<Integer> orgunitIds,
+ List<ProgramInstance> getByStatus( ProgramStatus status, Program program, Collection<Integer> orgunitIds,
Date startDate, Date endDate, Integer min, Integer max );
/**
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2015-06-16 13:17:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2015-09-24 08:32:10 +0000
@@ -61,7 +61,7 @@
* Retrieve an event list on program instance list with a certain status
*
* @param programInstances ProgramInstance list
- * @param status EventStatus
+ * @param status EventStatus
* @return ProgramStageInstance list
*/
List<ProgramStageInstance> get( Collection<ProgramInstance> programInstances, EventStatus status );
@@ -70,7 +70,7 @@
* Get all events by TrackedEntityInstance, optionally filtering by completed.
*
* @param entityInstance TrackedEntityInstance
- * @param status EventStatus
+ * @param status EventStatus
* @return ProgramStageInstance list
*/
List<ProgramStageInstance> get( TrackedEntityInstance entityInstance, EventStatus status );
@@ -80,7 +80,7 @@
*
* @return A SchedulingProgramObject list
*/
- Collection<SchedulingProgramObject> getSendMesssageEvents();
+ Collection<SchedulingProgramObject> getSendMessageEvents();
/**
* Get the number of events by completed status
@@ -93,8 +93,7 @@
* or uncompleted (<code>false</code>) instances.
* @return A number
*/
- int count( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate,
- Boolean completed );
+ int count( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate, Boolean completed );
/**
* Get the number of over due events of a program stage in a certain period
@@ -119,7 +118,7 @@
* LATE_VISIT_STATUS
* @return A number
*/
- int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before, int status );
+ int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before, ProgramStatus status );
/**
* Get/Export a report about the number of events of a program completed on
@@ -135,6 +134,7 @@
/**
* Get the number of ProgramStageInstances updates since the given Date.
+ *
* @param time the time.
* @return the number of ProgramStageInstances.
*/
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStatus.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStatus.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStatus.java 2015-09-24 08:32:10 +0000
@@ -37,7 +37,7 @@
private int value;
- private ProgramStatus( int value )
+ ProgramStatus( int value )
{
this.value = value;
}
=== 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-09-18 20:42:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2015-09-24 08:32:10 +0000
@@ -28,18 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.common.OrganisationUnitSelectionMode.ACCESSIBLE;
-import static org.hisp.dhis.common.OrganisationUnitSelectionMode.ALL;
-import static org.hisp.dhis.common.OrganisationUnitSelectionMode.CHILDREN;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.common.CodeGenerator;
@@ -69,6 +57,16 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.hisp.dhis.common.OrganisationUnitSelectionMode.*;
+
/**
* @author Abyot Asalefew
*/
@@ -362,25 +360,25 @@
@Override
public List<ProgramInstance> getProgramInstances( Collection<Program> programs,
- OrganisationUnit organisationUnit, int status )
+ OrganisationUnit organisationUnit, ProgramStatus status )
{
return programInstanceStore.get( programs, organisationUnit, status );
}
@Override
- public List<ProgramInstance> getProgramInstances( Collection<Program> programs, Integer status )
+ public List<ProgramInstance> getProgramInstances( Collection<Program> programs, ProgramStatus status )
{
return programInstanceStore.get( programs, status );
}
@Override
- public List<ProgramInstance> getProgramInstances( Program program, Integer status )
+ public List<ProgramInstance> getProgramInstances( Program program, ProgramStatus status )
{
return programInstanceStore.get( program, status );
}
@Override
- public List<ProgramInstance> getProgramInstances( TrackedEntityInstance entityInstance, Integer status )
+ public List<ProgramInstance> getProgramInstances( TrackedEntityInstance entityInstance, ProgramStatus status )
{
return programInstanceStore.get( entityInstance, status );
}
@@ -392,15 +390,13 @@
}
@Override
- public List<ProgramInstance> getProgramInstances( TrackedEntityInstance entityInstance, Program program,
- Integer status )
+ public List<ProgramInstance> getProgramInstances( TrackedEntityInstance entityInstance, Program program, ProgramStatus status )
{
return programInstanceStore.get( entityInstance, program, status );
}
@Override
- public List<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit,
- Integer min, Integer max )
+ public List<ProgramInstance> getProgramInstances( Program program, OrganisationUnit organisationUnit, Integer min, Integer max )
{
return programInstanceStore.get( program, organisationUnit, min, max );
}
@@ -419,14 +415,14 @@
}
@Override
- public int countProgramInstancesByStatus( Integer status, Program program, Collection<Integer> orgunitIds,
+ public int countProgramInstancesByStatus( ProgramStatus status, Program program, Collection<Integer> orgunitIds,
Date startDate, Date endDate )
{
return programInstanceStore.countByStatus( status, program, orgunitIds, startDate, endDate );
}
@Override
- public List<ProgramInstance> getProgramInstancesByStatus( Integer status, Program program,
+ public List<ProgramInstance> getProgramInstancesByStatus( ProgramStatus status, Program program,
Collection<Integer> orgunitIds, Date startDate, Date endDate )
{
return programInstanceStore.getByStatus( status, program, orgunitIds, startDate, endDate );
@@ -483,7 +479,7 @@
programInstance.setIncidentDate( new Date() );
}
- programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
+ programInstance.setStatus( ProgramStatus.ACTIVE );
addProgramInstance( programInstance );
// -----------------------------------------------------------------
@@ -571,7 +567,7 @@
// Update program-instance
// -----------------------------------------------------------------
- programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance.setStatus( ProgramStatus.COMPLETED );
programInstance.setEndDate( new Date() );
updateProgramInstance( programInstance );
@@ -589,7 +585,7 @@
Date currentDate = today.getTime();
programInstance.setEndDate( currentDate );
- programInstance.setStatus( ProgramInstance.STATUS_CANCELLED );
+ programInstance.setStatus( ProgramStatus.CANCELLED );
updateProgramInstance( programInstance );
// ---------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2015-09-13 17:45:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2015-09-24 08:32:10 +0000
@@ -28,14 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.hisp.dhis.event.EventStatus;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.message.MessageConversation;
@@ -52,6 +44,14 @@
import org.hisp.dhis.user.CurrentUserService;
import org.springframework.transaction.annotation.Transactional;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
/**
* @author Abyot Asalefew
*/
@@ -164,7 +164,7 @@
public long getProgramStageInstanceCount( int days )
{
Calendar cal = PeriodType.createCalendarInstance();
- cal.add( Calendar.DAY_OF_YEAR, ( days * -1 ) );
+ cal.add( Calendar.DAY_OF_YEAR, (days * -1) );
return programStageInstanceStore.getProgramStageInstanceCountLastUpdatedAfter( cal.getTime() );
}
@@ -172,7 +172,7 @@
@Override
public Collection<SchedulingProgramObject> getSendMesssageEvents()
{
- return programStageInstanceStore.getSendMesssageEvents();
+ return programStageInstanceStore.getSendMessageEvents();
}
@Override
@@ -247,13 +247,13 @@
{
programStage = program.getProgramStages().iterator().next();
}
-
+
ProgramInstance programInstance = null;
-
- if ( program.isWithoutRegistration() )
+
+ if ( program.isWithoutRegistration() )
{
Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( program );
-
+
if ( programInstances == null || programInstances.size() == 0 )
{
// Add a new program instance if it doesn't exist
@@ -261,7 +261,7 @@
programInstance.setEnrollmentDate( executionDate );
programInstance.setIncidentDate( executionDate );
programInstance.setProgram( program );
- programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
+ programInstance.setStatus( ProgramStatus.ACTIVE );
programInstanceService.addProgramInstance( programInstance );
}
else
@@ -337,7 +337,7 @@
if ( phoneNumbers.size() > 0 )
{
String msg = reminderService.getMessageFromTemplate( reminder, programStageInstance, format );
-
+
try
{
outboundSms = new OutboundSms();
@@ -392,7 +392,7 @@
&& rm.getWhenToSend() != null
&& rm.getWhenToSend() == status
&& (rm.getMessageType() == TrackedEntityInstanceReminder.MESSAGE_TYPE_DHIS_MESSAGE || rm
- .getMessageType() == TrackedEntityInstanceReminder.MESSAGE_TYPE_BOTH) )
+ .getMessageType() == TrackedEntityInstanceReminder.MESSAGE_TYPE_BOTH) )
{
int id = messageService.sendMessage( programStageInstance.getProgramStage().getDisplayName(),
reminderService.getMessageFromTemplate( rm, programStageInstance, format ), null,
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2015-07-07 14:54:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2015-09-24 08:32:10 +0000
@@ -52,10 +52,8 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import static org.hisp.dhis.common.IdentifiableObjectUtils.getUids;
import static org.hisp.dhis.commons.util.TextUtils.getQuotedCommaDelimitedString;
@@ -71,15 +69,6 @@
@Autowired
private TrackedEntityInstanceReminderService reminderService;
- private static final Map<ProgramStatus, Integer> PROGRAM_STATUS_MAP = new HashMap<ProgramStatus, Integer>()
- {
- {
- put( ProgramStatus.ACTIVE, ProgramInstance.STATUS_ACTIVE );
- put( ProgramStatus.COMPLETED, ProgramInstance.STATUS_COMPLETED );
- put( ProgramStatus.CANCELLED, ProgramInstance.STATUS_CANCELLED );
- }
- };
-
// -------------------------------------------------------------------------
// Implemented methods
// -------------------------------------------------------------------------
@@ -158,7 +147,7 @@
if ( params.hasProgramStatus() )
{
- hql += hlp.whereAnd() + "pi.status = " + PROGRAM_STATUS_MAP.get( params.getProgramStatus() );
+ hql += hlp.whereAnd() + "pi.status = '" + params.getProgramStatus() + "'";
}
if ( params.hasFollowUp() )
@@ -215,7 +204,7 @@
@Override
@SuppressWarnings( "unchecked" )
- public List<ProgramInstance> get( Collection<Program> programs, OrganisationUnit organisationUnit, int status )
+ public List<ProgramInstance> get( Collection<Program> programs, OrganisationUnit organisationUnit, ProgramStatus status )
{
if ( programs == null || programs.isEmpty() )
{
@@ -231,14 +220,14 @@
@Override
@SuppressWarnings( "unchecked" )
- public List<ProgramInstance> get( Program program, Integer status )
+ public List<ProgramInstance> get( Program program, ProgramStatus status )
{
return getCriteria( Restrictions.eq( "program", program ), Restrictions.eq( "status", status ) ).list();
}
@Override
@SuppressWarnings( "unchecked" )
- public List<ProgramInstance> get( Collection<Program> programs, Integer status )
+ public List<ProgramInstance> get( Collection<Program> programs, ProgramStatus status )
{
if ( programs == null || programs.isEmpty() )
{
@@ -250,7 +239,7 @@
@Override
@SuppressWarnings( "unchecked" )
- public List<ProgramInstance> get( TrackedEntityInstance entityInstance, Integer status )
+ public List<ProgramInstance> get( TrackedEntityInstance entityInstance, ProgramStatus status )
{
return getCriteria( Restrictions.eq( "entityInstance", entityInstance ), Restrictions.eq( "status", status ) ).list();
}
@@ -264,7 +253,7 @@
@Override
@SuppressWarnings( "unchecked" )
- public List<ProgramInstance> get( TrackedEntityInstance entityInstance, Program program, Integer status )
+ public List<ProgramInstance> get( TrackedEntityInstance entityInstance, Program program, ProgramStatus status )
{
return getCriteria( Restrictions.eq( "entityInstance", entityInstance ), Restrictions.eq( "program", program ),
Restrictions.eq( "status", status ) ).list();
@@ -344,7 +333,7 @@
}
@Override
- public int countByStatus( Integer status, Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate )
+ public int countByStatus( ProgramStatus status, Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate )
{
Number rs = (Number) getCriteria(
Restrictions.eq( "program", program ),
@@ -360,7 +349,7 @@
@Override
@SuppressWarnings( "unchecked" )
- public List<ProgramInstance> getByStatus( Integer status, Program program, Collection<Integer> orgunitIds,
+ public List<ProgramInstance> getByStatus( ProgramStatus status, Program program, Collection<Integer> orgunitIds,
Date startDate, Date endDate )
{
return getCriteria(
@@ -374,7 +363,7 @@
@Override
@SuppressWarnings( "unchecked" )
- public List<ProgramInstance> getByStatus( Integer status, Program program, Collection<Integer> orgunitIds,
+ public List<ProgramInstance> getByStatus( ProgramStatus status, Program program, Collection<Integer> orgunitIds,
Date startDate, Date endDate, Integer min, Integer max )
{
Criteria criteria = getCriteria(
@@ -478,8 +467,8 @@
+ " ON org.organisationunitid = p.organisationunitid INNER JOIN trackedentityinstancereminder prm "
+ " ON prm.programid = pi.programid INNER JOIN trackedentityattributevalue pav "
+ " ON pav.trackedentityinstanceid=p.trackedentityinstanceid INNER JOIN trackedentityattribute pa "
- + " ON pa.trackedentityattributeid=pav.trackedentityattributeid " + " WHERE pi.status= "
- + ProgramInstance.STATUS_ACTIVE
+ + " ON pa.trackedentityattributeid=pav.trackedentityattributeid "
+ + " WHERE pi.status= '" + ProgramStatus.ACTIVE + "'"
+ " and prm.templatemessage is not NULL and prm.templatemessage != '' "
+ " and pg.type=1 and prm.daysallowedsendmessage is not null and pa.valuetype='phoneNumber' "
+ " and ( DATE(now()) - DATE(pi." + dateToCompare + ") ) = prm.daysallowedsendmessage "
@@ -496,7 +485,7 @@
+ " ON p.trackedentityinstanceid=pi.trackedentityinstanceid INNER JOIN program pg "
+ " ON pg.programid=pi.programid INNER JOIN organisationunit org "
+ " ON org.organisationunitid = p.organisationunitid INNER JOIN trackedentityinstancereminder prm "
- + " ON prm.programid = pi.programid " + " WHERE pi.status = " + ProgramInstance.STATUS_ACTIVE
+ + " ON prm.programid = pi.programid " + " WHERE pi.status = '" + ProgramStatus.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."
@@ -516,8 +505,7 @@
+ " 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= '" + ProgramStatus.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 "
@@ -540,8 +528,9 @@
+ " INNER JOIN organisationunit org " + " ON org.organisationunitid = p.organisationunitid "
+ " INNER JOIN trackedentityinstancereminder 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 != '' "
+ + " INNER JOIN userinfo uif " + " ON uif.userinfoid = ugm.userid "
+ + " WHERE pi.status= '" + ProgramStatus.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 "
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2015-06-23 15:59:19 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2015-09-24 08:32:10 +0000
@@ -28,12 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-
import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Projections;
@@ -41,6 +35,7 @@
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.GridHeader;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
+import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.event.EventStatus;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.period.PeriodType;
@@ -50,16 +45,22 @@
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramStageInstanceStore;
+import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.program.SchedulingProgramObject;
import org.hisp.dhis.system.grid.GridUtils;
import org.hisp.dhis.system.grid.ListGrid;
-import org.hisp.dhis.commons.util.TextUtils;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.support.rowset.SqlRowSet;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+
/**
* @author Abyot Asalefew
*/
@@ -80,7 +81,7 @@
@Autowired
private TrackedEntityInstanceReminderService reminderService;
-
+
// -------------------------------------------------------------------------
// Implemented methods
// -------------------------------------------------------------------------
@@ -90,7 +91,7 @@
public ProgramStageInstance get( ProgramInstance programInstance, ProgramStage programStage )
{
List<ProgramStageInstance> list = getCriteria(
- Restrictions.eq( "programInstance", programInstance ),
+ Restrictions.eq( "programInstance", programInstance ),
Restrictions.eq( "programStage", programStage ) ).
addOrder( Order.asc( "id" ) ).list();
@@ -101,8 +102,8 @@
@SuppressWarnings( "unchecked" )
public List<ProgramStageInstance> get( Collection<ProgramInstance> programInstances, EventStatus status )
{
- return getCriteria(
- Restrictions.in( "programInstance", programInstances ),
+ return getCriteria(
+ Restrictions.in( "programInstance", programInstances ),
Restrictions.eq( "status", status ) ).list();
}
@@ -112,13 +113,13 @@
{
Criteria criteria = getCriteria();
criteria.createAlias( "programInstance", "programInstance" );
- criteria.add( Restrictions.eq( "programInstance.entityInstance", entityInstance));
- criteria.add( Restrictions.eq( "status", status ));
+ criteria.add( Restrictions.eq( "programInstance.entityInstance", entityInstance ) );
+ criteria.add( Restrictions.eq( "status", status ) );
return criteria.list();
}
@Override
- public Collection<SchedulingProgramObject> getSendMesssageEvents()
+ public Collection<SchedulingProgramObject> getSendMessageEvents()
{
String sql = " ( " + sendMessageToTrackedEntityInstanceSql() + " ) ";
@@ -137,7 +138,7 @@
while ( rs.next() )
{
String message = rs.getString( "templatemessage" );
-
+
List<String> attributeUids = reminderService.getAttributeUids( message );
int programstageinstanceid = rs.getInt( "programstageinstanceid" );
SqlRowSet attributeValueRow = jdbcTemplate
@@ -154,8 +155,8 @@
String value = attributeValueRow.getString( "value" );
String key = "\\{(" + TrackedEntityInstanceReminder.ATTRIBUTE + ")=(" + uid + ")\\}";
message = message.replaceAll( key, value );
- }
-
+ }
+
String organisationunitName = rs.getString( "orgunitName" );
String programName = rs.getString( "programName" );
String programStageName = rs.getString( "programStageName" );
@@ -167,7 +168,7 @@
message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DUE_DATE, dueDate );
message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_ORGUNIT_NAME, organisationunitName );
message = message.replace( TrackedEntityInstanceReminder.TEMPLATE_MESSSAGE_DAYS_SINCE_DUE_DATE, daysSinceDueDate );
-
+
SchedulingProgramObject schedulingProgramObject = new SchedulingProgramObject();
schedulingProgramObject.setProgramStageInstanceId( programstageinstanceid );
schedulingProgramObject.setPhoneNumber( rs.getString( "phonenumber" ) );
@@ -231,7 +232,7 @@
+ "and pg.programid = " + program.getId() + " "
+ "group by ou.name, ps.name, psi.completeduser, psi.completeddate, psi.status "
+ "having psi.completeddate >= '" + startDate + "' AND psi.completeddate <= '" + endDate + "' "
- + "and psi.status='" + EventStatus.COMPLETED.name() + "' "
+ + "and psi.status='" + EventStatus.COMPLETED.name() + "' "
+ "order by ou.name, ps.name, psi.completeduser";
SqlRowSet rs = jdbcTemplate.queryForRowSet( sql );
@@ -265,12 +266,10 @@
}
@Override
- public int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before,
- int status )
+ public int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before, ProgramStatus status )
{
- Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstancesByStatus(
- ProgramInstance.STATUS_COMPLETED, program, orgunitIds, after, before );
-
+ Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstancesByStatus( status, program, orgunitIds, after, before );
+
Criteria criteria = getCriteria();
criteria.createAlias( "programInstance", "programInstance" );
criteria.createAlias( "programStage", "programStage" );
@@ -280,14 +279,14 @@
criteria.add( Restrictions.in( "organisationUnit.id", orgunitIds ) );
criteria.add( Restrictions.between( "programInstance.endDate", after, before ) );
criteria.add( Restrictions.eq( "status", EventStatus.COMPLETED ) );
-
+
if ( programInstances != null && programInstances.size() > 0 )
{
criteria.add( Restrictions.not( Restrictions.in( "programInstance", programInstances ) ) );
}
-
+
Number rs = (Number) criteria.setProjection( Projections.rowCount() ).uniqueResult();
-
+
return rs != null ? rs.intValue() : 0;
}
@@ -307,11 +306,11 @@
criteria.createAlias( "programInstance.entityInstance", "entityInstance" );
criteria.createAlias( "entityInstance.organisationUnit", "regOrgunit" );
criteria.add( Restrictions.or( Restrictions.and( Restrictions.eq( "status", EventStatus.COMPLETED ),
- Restrictions.between( "executionDate", startDate, endDate ),
- Restrictions.in( "organisationUnit.id", orgunitIds ) ), Restrictions.and(
- Restrictions.eq( "status", EventStatus.ACTIVE ), Restrictions.isNotNull( "executionDate" ),
- Restrictions.between( "executionDate", startDate, endDate ),
- Restrictions.in( "organisationUnit.id", orgunitIds ) ),
+ Restrictions.between( "executionDate", startDate, endDate ),
+ Restrictions.in( "organisationUnit.id", orgunitIds ) ), Restrictions.and(
+ Restrictions.eq( "status", EventStatus.ACTIVE ), Restrictions.isNotNull( "executionDate" ),
+ Restrictions.between( "executionDate", startDate, endDate ),
+ Restrictions.in( "organisationUnit.id", orgunitIds ) ),
Restrictions.and( Restrictions.eq( "status", EventStatus.ACTIVE ), Restrictions.isNull( "executionDate" ),
Restrictions.between( "dueDate", startDate, endDate ),
Restrictions.in( "regOrgunit.id", orgunitIds ) ), Restrictions.and(
@@ -342,7 +341,7 @@
}
//TODO this must be re-written
-
+
private String sendMessageToTrackedEntityInstanceSql()
{
return "select psi.programstageinstanceid, pav.value as phonenumber, prm.templatemessage, org.name as orgunitName "
@@ -364,7 +363,7 @@
+ " INNER JOIN trackedentityattribute pa "
+ " ON pa.trackedentityattributeid=pav.trackedentityattributeid "
+ "WHERE pi.status="
- + ProgramInstance.STATUS_ACTIVE
+ + ProgramStatus.ACTIVE
+ " and prm.templatemessage is not NULL and prm.templatemessage != '' "
+ " and pg.type=1 and prm.daysallowedsendmessage is not null "
+ " and psi.executiondate is null and pa.valuetype='phoneNumber' "
@@ -395,8 +394,7 @@
+ " ON pa.trackedentityattributeid=pav.trackedentityattributeid "
+ " INNER JOIN userinfo uif "
+ " ON pav.value=concat(uif.userinfoid ,'') "
- + " WHERE pi.status="
- + ProgramInstance.STATUS_ACTIVE
+ + " WHERE pi.status='" + ProgramStatus.ACTIVE + "'"
+ " and pa.valueType='users' 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 "
@@ -424,8 +422,7 @@
+ " ON prm.programstageid = ps.programstageid "
+ " INNER JOIN organisationunit ou "
+ " ON ou.organisationunitid=p.organisationunitid "
- + "WHERE pi.status= "
- + ProgramInstance.STATUS_ACTIVE
+ + "WHERE pi.status= '" + ProgramStatus.ACTIVE + "'"
+ " and ou.phonenumber is not NULL and ou.phonenumber != '' "
+ " and prm.templatemessage is not NULL and prm.templatemessage != '' "
+ " and pg.type=1 and prm.daysallowedsendmessage is not null "
@@ -456,8 +453,7 @@
+ " ON ums.organisationunitid = p.organisationunitid "
+ " INNER JOIN userinfo uif "
+ " ON uif.userinfoid = ums.userinfoid "
- + " WHERE pi.status= "
- + ProgramInstance.STATUS_ACTIVE
+ + " WHERE pi.status= '" + ProgramStatus.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 "
@@ -488,8 +484,7 @@
+ " ON ugm.usergroupid = prm.usergroupid "
+ " INNER JOIN userinfo uif "
+ " ON uif.userinfoid = ugm.userid "
- + " WHERE pi.status= "
- + ProgramInstance.STATUS_ACTIVE
+ + " WHERE pi.status= '"+ ProgramStatus.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 "
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-09-17 08:13:56 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java 2015-09-24 08:32:10 +0000
@@ -74,6 +74,7 @@
updateAggregationTypes();
updateFeatureTypes();
updateValidationRuleEnums();
+ updateProgramStatus();
executeSql( "ALTER TABLE program ALTER COLUMN \"type\" TYPE varchar(255);" );
executeSql( "update program set \"type\"='WITH_REGISTRATION' where type='1' or type='2'" );
@@ -84,6 +85,15 @@
// Supportive methods
// -------------------------------------------------------------------------
+ private void updateProgramStatus()
+ {
+ executeSql( "alter table programinstance alter column status type varchar(50)" );
+
+ executeSql( "update programinstance set status='ACTIVE' where status='0'" );
+ executeSql( "update programinstance set status='COMPLETED' where status='1'" );
+ executeSql( "update programinstance set status='CANCELLED' where status='2'" );
+ }
+
private void updateValidationRuleEnums()
{
executeSql( "alter table validationrule alter column ruletype type varchar(50)" );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2015-09-23 17:18:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2015-09-24 08:32:10 +0000
@@ -46,8 +46,6 @@
import org.hisp.dhis.jdbc.StatementBuilder;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.program.Program;
-import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams;
@@ -81,15 +79,6 @@
{
private static final Log log = LogFactory.getLog( HibernateTrackedEntityInstanceStore.class );
- private static final Map<ProgramStatus, Integer> PROGRAM_STATUS_MAP = new HashMap<ProgramStatus, Integer>()
- {
- {
- put( ProgramStatus.ACTIVE, ProgramInstance.STATUS_ACTIVE );
- put( ProgramStatus.COMPLETED, ProgramInstance.STATUS_COMPLETED );
- put( ProgramStatus.CANCELLED, ProgramInstance.STATUS_CANCELLED );
- }
- };
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -193,7 +182,7 @@
if ( params.hasProgramStatus() )
{
- hql += hlp.whereAnd() + "pi.status = " + PROGRAM_STATUS_MAP.get( params.getProgramStatus() );
+ hql += hlp.whereAnd() + "pi.status = " + params.getProgramStatus();
}
if ( params.hasFollowUp() )
@@ -412,7 +401,7 @@
if ( params.hasProgramStatus() )
{
- sql += "and pi.status = " + PROGRAM_STATUS_MAP.get( params.getProgramStatus() ) + " ";
+ sql += "and pi.status = " + params.getProgramStatus() + " ";
}
if ( params.hasFollowUp() )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml 2015-09-11 13:17:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/program/hibernate/ProgramInstance.hbm.xml 2015-09-24 08:32:10 +0000
@@ -24,7 +24,13 @@
<property name="followup" column="followup" />
- <property name="status" />
+ <property name="status" length="50">
+ <type name="org.hibernate.type.EnumType">
+ <param name="enumClass">org.hisp.dhis.program.ProgramStatus</param>
+ <param name="useNamed">true</param>
+ <param name="type">12</param>
+ </type>
+ </property>
<many-to-one name="entityInstance"
class="org.hisp.dhis.trackedentity.TrackedEntityInstance" column="trackedentityinstanceid"
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java 2015-09-13 21:12:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java 2015-09-24 08:32:10 +0000
@@ -28,31 +28,25 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-import org.hisp.dhis.sms.config.SmsConfigurationManager;
-import org.hisp.dhis.trackedentity.TrackedEntityAttributeService;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
-import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService;
import org.joda.time.DateTime;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.*;
+
/**
* @author Chau Thu Tran
*/
@@ -74,15 +68,6 @@
@Autowired
private ProgramStageService programStageService;
- @Autowired
- private SmsConfigurationManager smsConfigurationManager;
-
- @Autowired
- private TrackedEntityAttributeService attributeService;
-
- @Autowired
- private TrackedEntityAttributeValueService attributeValueService;
-
private Date incidenDate;
private Date enrollmentDate;
@@ -170,7 +155,7 @@
testDate1.withTimeAtStartOfDay();
testDate1 = testDate1.minusDays( 70 );
incidenDate = testDate1.toDate();
-
+
DateTime testDate2 = DateTime.now();
testDate2.withTimeAtStartOfDay();
enrollmentDate = testDate2.toDate();
@@ -180,11 +165,11 @@
programInstanceB = new ProgramInstance( enrollmentDate, incidenDate, entityInstanceA, programB );
programInstanceB.setUid( "UID-B" );
- programInstanceB.setStatus( ProgramInstance.STATUS_CANCELLED );
+ programInstanceB.setStatus( ProgramStatus.CANCELLED );
programInstanceC = new ProgramInstance( enrollmentDate, incidenDate, entityInstanceA, programC );
programInstanceC.setUid( "UID-C" );
- programInstanceC.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstanceC.setStatus( ProgramStatus.COMPLETED );
programInstanceD = new ProgramInstance( enrollmentDate, incidenDate, entityInstanceB, programA );
programInstanceD.setUid( "UID-D" );
@@ -298,7 +283,7 @@
ProgramInstance programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstanceA, programA, enrollmentDate,
incidenDate, organisationUnitA );
- programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance.setStatus( ProgramStatus.COMPLETED );
programInstanceService.updateProgramInstance( programInstance );
List<ProgramInstance> programInstances = programInstanceService.getProgramInstances( entityInstanceA, programA );
@@ -314,22 +299,20 @@
ProgramInstance programInstance1 = programInstanceService.enrollTrackedEntityInstance( entityInstanceA, programA, enrollmentDate,
incidenDate, organisationUnitA );
- programInstance1.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance1.setStatus( ProgramStatus.COMPLETED );
programInstanceService.updateProgramInstance( programInstance1 );
ProgramInstance programInstance2 = programInstanceService.enrollTrackedEntityInstance( entityInstanceA, programA, enrollmentDate,
incidenDate, organisationUnitA );
- programInstance2.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance2.setStatus( ProgramStatus.COMPLETED );
programInstanceService.updateProgramInstance( programInstance2 );
- List<ProgramInstance> programInstances = programInstanceService.getProgramInstances( entityInstanceA, programA,
- ProgramInstance.STATUS_COMPLETED );
+ List<ProgramInstance> programInstances = programInstanceService.getProgramInstances( entityInstanceA, programA, ProgramStatus.COMPLETED );
assertEquals( 2, programInstances.size() );
assertTrue( programInstances.contains( programInstance1 ) );
assertTrue( programInstances.contains( programInstance2 ) );
- programInstances = programInstanceService.getProgramInstances( entityInstanceA, programA,
- ProgramInstance.STATUS_ACTIVE );
+ programInstances = programInstanceService.getProgramInstances( entityInstanceA, programA, ProgramStatus.ACTIVE );
assertEquals( 1, programInstances.size() );
assertTrue( programInstances.contains( programInstanceA ) );
}
@@ -380,7 +363,7 @@
programInstanceService.addProgramInstance( programInstanceD );
List<ProgramInstance> programInstances = programInstanceService.getProgramInstancesByStatus(
- ProgramInstance.STATUS_ACTIVE, programA, orgunitIds, incidenDate, enrollmentDate );
+ ProgramStatus.ACTIVE, programA, orgunitIds, incidenDate, enrollmentDate );
assertEquals( 2, programInstances.size() );
assertTrue( programInstances.contains( programInstanceA ) );
assertTrue( programInstances.contains( programInstanceD ) );
@@ -393,7 +376,7 @@
programInstanceService.addProgramInstance( programInstanceB );
programInstanceService.addProgramInstance( programInstanceD );
- int count = programInstanceService.countProgramInstancesByStatus( ProgramInstance.STATUS_ACTIVE, programA,
+ int count = programInstanceService.countProgramInstancesByStatus( ProgramStatus.ACTIVE, programA,
orgunitIds, incidenDate, enrollmentDate );
assertEquals( 2, count );
}
@@ -426,8 +409,8 @@
programInstanceService.completeProgramInstanceStatus( programInstanceA );
programInstanceService.completeProgramInstanceStatus( programInstanceD );
- assertEquals( ProgramInstance.STATUS_COMPLETED, programInstanceService.getProgramInstance( idA ).getStatus() );
- assertEquals( ProgramInstance.STATUS_COMPLETED, programInstanceService.getProgramInstance( idD ).getStatus() );
+ assertEquals( ProgramStatus.COMPLETED, programInstanceService.getProgramInstance( idA ).getStatus() );
+ assertEquals( ProgramStatus.COMPLETED, programInstanceService.getProgramInstance( idD ).getStatus() );
}
@Test
@@ -439,8 +422,7 @@
programInstanceService.cancelProgramInstanceStatus( programInstanceA );
programInstanceService.cancelProgramInstanceStatus( programInstanceD );
- assertEquals( ProgramInstance.STATUS_CANCELLED, programInstanceService.getProgramInstance( idA ).getStatus() );
- assertEquals( ProgramInstance.STATUS_CANCELLED, programInstanceService.getProgramInstance( idD ).getStatus() );
+ assertEquals( ProgramStatus.CANCELLED, programInstanceService.getProgramInstance( idA ).getStatus() );
+ assertEquals( ProgramStatus.CANCELLED, programInstanceService.getProgramInstance( idD ).getStatus() );
}
-
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramInstanceStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramInstanceStoreTest.java 2015-09-13 21:12:28 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/program/ProgramInstanceStoreTest.java 2015-09-24 08:32:10 +0000
@@ -28,16 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
import org.hisp.dhis.DhisSpringTest;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -48,6 +38,16 @@
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
/**
* @author Chau Thu Tran
*/
@@ -69,7 +69,7 @@
@Autowired
private ProgramStageService programStageService;
- private Date incidenDate;
+ private Date incidentDate;
private Date enrollmentDate;
@@ -155,24 +155,24 @@
DateTime testDate1 = DateTime.now();
testDate1.withTimeAtStartOfDay();
testDate1 = testDate1.minusDays( 70 );
- incidenDate = testDate1.toDate();
-
+ incidentDate = testDate1.toDate();
+
DateTime testDate2 = DateTime.now();
testDate2.withTimeAtStartOfDay();
enrollmentDate = testDate2.toDate();
- programInstanceA = new ProgramInstance( enrollmentDate, incidenDate, entityInstanceA, programA );
+ programInstanceA = new ProgramInstance( enrollmentDate, incidentDate, entityInstanceA, programA );
programInstanceA.setUid( "UID-A" );
- programInstanceB = new ProgramInstance( enrollmentDate, incidenDate, entityInstanceA, programB );
+ programInstanceB = new ProgramInstance( enrollmentDate, incidentDate, entityInstanceA, programB );
programInstanceB.setUid( "UID-B" );
- programInstanceB.setStatus( ProgramInstance.STATUS_CANCELLED );
+ programInstanceB.setStatus( ProgramStatus.CANCELLED );
- programInstanceC = new ProgramInstance( enrollmentDate, incidenDate, entityInstanceA, programC );
+ programInstanceC = new ProgramInstance( enrollmentDate, incidentDate, entityInstanceA, programC );
programInstanceC.setUid( "UID-C" );
- programInstanceC.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstanceC.setStatus( ProgramStatus.COMPLETED );
- programInstanceD = new ProgramInstance( enrollmentDate, incidenDate, entityInstanceB, programA );
+ programInstanceD = new ProgramInstance( enrollmentDate, incidentDate, entityInstanceB, programA );
programInstanceD.setUid( "UID-D" );
}
@@ -220,12 +220,11 @@
programInstanceStore.save( programInstanceC );
programInstanceStore.save( programInstanceD );
- List<ProgramInstance> programInstances = programInstanceStore.get( entityInstanceA, programC,
- ProgramInstance.STATUS_COMPLETED );
+ List<ProgramInstance> programInstances = programInstanceStore.get( entityInstanceA, programC, ProgramStatus.COMPLETED );
assertEquals( 1, programInstances.size() );
assertTrue( programInstances.contains( programInstanceC ) );
- programInstances = programInstanceStore.get( entityInstanceA, programA, ProgramInstance.STATUS_ACTIVE );
+ programInstances = programInstanceStore.get( entityInstanceA, programA, ProgramStatus.ACTIVE );
assertEquals( 1, programInstances.size() );
assertTrue( programInstances.contains( programInstanceA ) );
}
@@ -249,7 +248,7 @@
programInstanceStore.save( programInstanceB );
programInstanceStore.save( programInstanceD );
- List<ProgramInstance> programInstances = programInstanceStore.get( programA, orgunitIds, incidenDate,
+ List<ProgramInstance> programInstances = programInstanceStore.get( programA, orgunitIds, incidentDate,
enrollmentDate, null, null );
assertEquals( 2, programInstances.size() );
assertTrue( programInstances.contains( programInstanceA ) );
@@ -263,7 +262,7 @@
programInstanceStore.save( programInstanceB );
programInstanceStore.save( programInstanceD );
- int count = programInstanceStore.count( programA, orgunitIds, incidenDate, enrollmentDate );
+ int count = programInstanceStore.count( programA, orgunitIds, incidentDate, enrollmentDate );
assertEquals( 2, count );
}
@@ -274,8 +273,9 @@
programInstanceStore.save( programInstanceB );
programInstanceStore.save( programInstanceD );
- List<ProgramInstance> programInstances = programInstanceStore.getByStatus( ProgramInstance.STATUS_ACTIVE,
- programA, orgunitIds, incidenDate, enrollmentDate );
+ List<ProgramInstance> programInstances = programInstanceStore.getByStatus( ProgramStatus.ACTIVE, programA,
+ orgunitIds, incidentDate, enrollmentDate );
+
assertEquals( 2, programInstances.size() );
assertTrue( programInstances.contains( programInstanceA ) );
assertTrue( programInstances.contains( programInstanceD ) );
@@ -288,9 +288,7 @@
programInstanceStore.save( programInstanceB );
programInstanceStore.save( programInstanceD );
- int count = programInstanceStore.countByStatus( ProgramInstance.STATUS_ACTIVE, programA, orgunitIds,
- incidenDate, enrollmentDate );
+ int count = programInstanceStore.countByStatus( ProgramStatus.ACTIVE, programA, orgunitIds, incidentDate, enrollmentDate );
assertEquals( 2, count );
}
-
}
=== 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 2015-09-11 15:53:13 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-09-24 08:32:10 +0000
@@ -170,7 +170,7 @@
enrollment.setCreated( programInstance.getCreated() );
enrollment.setLastUpdated( programInstance.getLastUpdated() );
enrollment.setProgram( programInstance.getProgram().getUid() );
- enrollment.setStatus( EnrollmentStatus.fromInt( programInstance.getStatus() ) );
+ enrollment.setStatus( EnrollmentStatus.fromProgramStatus( programInstance.getStatus() ) );
enrollment.setEnrollmentDate( programInstance.getEnrollmentDate() );
enrollment.setIncidentDate( programInstance.getIncidentDate() );
enrollment.setFollowup( programInstance.getFollowup() );
@@ -376,7 +376,7 @@
programInstance.setEnrollmentDate( enrollment.getEnrollmentDate() );
programInstance.setFollowup( enrollment.getFollowup() );
- if ( programInstance.getStatus() != enrollment.getStatus().getValue() )
+ if ( EnrollmentStatus.fromProgramStatus( programInstance.getStatus() ) != enrollment.getStatus() )
{
if ( EnrollmentStatus.CANCELLED == enrollment.getStatus() )
{
@@ -388,8 +388,7 @@
}
else
{
- importSummary = new ImportSummary( ImportStatus.ERROR,
- "Re-enrollment is not allowed, please create a new enrollment." );
+ importSummary = new ImportSummary( ImportStatus.ERROR, "Re-enrollment is not allowed, please create a new enrollment." );
importSummary.getImportCount().incrementIgnored();
return importSummary;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentStatus.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentStatus.java 2015-09-13 21:54:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/EnrollmentStatus.java 2015-09-24 08:32:10 +0000
@@ -28,7 +28,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.program.ProgramStatus;
+
/**
+ * FIXME we should probably remove this, and replace it with program status
+ *
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
public enum EnrollmentStatus
@@ -37,7 +41,7 @@
private final int value;
- private EnrollmentStatus( int value )
+ EnrollmentStatus( int value )
{
this.value = value;
}
@@ -47,16 +51,18 @@
return value;
}
- public static EnrollmentStatus fromInt( int status )
+ public static EnrollmentStatus fromProgramStatus( ProgramStatus programStatus )
{
- for ( EnrollmentStatus enrollmentStatus : EnrollmentStatus.values() )
+ switch ( programStatus )
{
- if ( enrollmentStatus.getValue() == status )
- {
- return enrollmentStatus;
- }
+ case ACTIVE:
+ return ACTIVE;
+ case CANCELLED:
+ return CANCELLED;
+ case COMPLETED:
+ return COMPLETED;
}
- throw new IllegalArgumentException( "Enum value not found: " + status );
+ throw new IllegalArgumentException( "Enum value not found: " + programStatus );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-09-13 21:54:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-09-24 08:32:10 +0000
@@ -40,11 +40,14 @@
import org.hisp.dhis.common.IllegalQueryException;
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.common.Pager;
+import org.hisp.dhis.commons.collection.CachingMap;
+import org.hisp.dhis.commons.util.DebugUtils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dbms.DbmsManager;
import org.hisp.dhis.dxf2.common.IdSchemes;
import org.hisp.dhis.dxf2.common.ImportOptions;
+import org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus;
import org.hisp.dhis.dxf2.events.report.EventRow;
import org.hisp.dhis.dxf2.events.report.EventRows;
import org.hisp.dhis.dxf2.importsummary.ImportConflict;
@@ -78,8 +81,6 @@
import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueService;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.User;
-import org.hisp.dhis.commons.collection.CachingMap;
-import org.hisp.dhis.commons.util.DebugUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
@@ -290,7 +291,7 @@
}
List<ProgramInstance> programInstances = new ArrayList<>( programInstanceService.getProgramInstances(
- entityInstance, program, ProgramInstance.STATUS_ACTIVE ) );
+ entityInstance, program, ProgramStatus.ACTIVE ) );
if ( programInstances.isEmpty() )
{
@@ -350,7 +351,7 @@
else
{
List<ProgramInstance> programInstances = new ArrayList<>( programInstanceService.getProgramInstances(
- program, ProgramInstance.STATUS_ACTIVE ) );
+ program, ProgramStatus.ACTIVE ) );
if ( programInstances.isEmpty() )
{
@@ -786,7 +787,7 @@
}
event.setFollowup( programStageInstance.getProgramInstance().getFollowup() );
- event.setEnrollmentStatus( EventStatus.fromInt( programStageInstance.getProgramInstance().getStatus() ) );
+ event.setEnrollmentStatus( EnrollmentStatus.fromProgramStatus( programStageInstance.getProgramInstance().getStatus() ) );
event.setStatus( programStageInstance.getStatus() );
event.setEventDate( DateUtils.getLongDateString( programStageInstance.getExecutionDate() ) );
event.setDueDate( DateUtils.getLongDateString( programStageInstance.getDueDate() ) );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java 2015-09-03 09:03:51 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/Event.java 2015-09-24 08:32:10 +0000
@@ -34,6 +34,7 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus;
import org.hisp.dhis.event.EventStatus;
import java.util.ArrayList;
@@ -56,7 +57,7 @@
private String enrollment;
- private EventStatus enrollmentStatus;
+ private EnrollmentStatus enrollmentStatus;
private String orgUnit;
@@ -102,12 +103,12 @@
@JsonProperty( required = true )
@JacksonXmlProperty( isAttribute = true )
- public EventStatus getEnrollmentStatus()
+ public EnrollmentStatus getEnrollmentStatus()
{
return enrollmentStatus;
}
- public void setEnrollmentStatus( EventStatus programStatus )
+ public void setEnrollmentStatus( EnrollmentStatus programStatus )
{
this.enrollmentStatus = programStatus;
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2015-09-13 21:54:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2015-09-24 08:32:10 +0000
@@ -35,10 +35,12 @@
import org.hisp.dhis.common.ValueType;
import org.hisp.dhis.commons.util.SqlHelper;
import org.hisp.dhis.dxf2.common.IdSchemes;
+import org.hisp.dhis.dxf2.events.enrollment.EnrollmentStatus;
import org.hisp.dhis.dxf2.events.report.EventRow;
import org.hisp.dhis.dxf2.events.trackedentity.Attribute;
import org.hisp.dhis.event.EventStatus;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.program.ProgramType;
import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.util.ObjectUtils;
@@ -111,7 +113,7 @@
if ( programTye != ProgramType.WITHOUT_REGISTRATION )
{
event.setEnrollment( rowSet.getString( "pi_uid" ) );
- event.setEnrollmentStatus( EventStatus.fromInt( rowSet.getInt( "pi_status" ) ) );
+ event.setEnrollmentStatus( EnrollmentStatus.fromProgramStatus( ProgramStatus.valueOf( rowSet.getString( "pi_status" ) ) ) );
event.setFollowup( rowSet.getBoolean( "pi_followup" ) );
}
@@ -242,7 +244,7 @@
if ( rowSet.getString( "pav_value" ) != null && rowSet.getString( "ta_uid" ) != null )
{
String valueType = rowSet.getString( "ta_valuetype" );
-
+
Attribute attribute = new Attribute();
attribute.setValue( rowSet.getString( "pav_value" ) );
attribute.setDisplayName( rowSet.getString( "ta_name" ) );
@@ -371,7 +373,7 @@
if ( params.getProgramStatus() != null )
{
- sql += hlp.whereAnd() + " pi.status = " + params.getProgramStatus().getValue() + " ";
+ sql += hlp.whereAnd() + " pi.status = '" + params.getProgramStatus() + "' ";
}
if ( params.getFollowUp() != null )
=== 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-09-21 09:24:27 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java 2015-09-24 08:32:10 +0000
@@ -37,12 +37,12 @@
import org.hisp.dhis.api.mobile.model.DataValue;
import org.hisp.dhis.api.mobile.model.Interpretation;
import org.hisp.dhis.api.mobile.model.InterpretationComment;
-import org.hisp.dhis.api.mobile.model.OptionSet;
-import org.hisp.dhis.api.mobile.model.PatientAttribute;
import org.hisp.dhis.api.mobile.model.LWUITmodel.LostEvent;
import org.hisp.dhis.api.mobile.model.LWUITmodel.Notification;
import org.hisp.dhis.api.mobile.model.LWUITmodel.Patient;
import org.hisp.dhis.api.mobile.model.LWUITmodel.PatientList;
+import org.hisp.dhis.api.mobile.model.OptionSet;
+import org.hisp.dhis.api.mobile.model.PatientAttribute;
import org.hisp.dhis.api.mobile.model.Task;
import org.hisp.dhis.api.mobile.model.comparator.ActivityComparator;
import org.hisp.dhis.api.mobile.model.comparator.TrackedEntityAttributeValueSortOrderComparator;
@@ -77,6 +77,7 @@
import org.hisp.dhis.program.ProgramStageSection;
import org.hisp.dhis.program.ProgramStageSectionService;
import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.program.ProgramType;
import org.hisp.dhis.program.comparator.ProgramStageInstanceVisitDateComparator;
import org.hisp.dhis.relationship.Relationship;
@@ -472,7 +473,7 @@
programInstance.setEnrollmentDate( new Date() );
programInstance.setIncidentDate( new Date() );
programInstance.setProgram( programStage.getProgram() );
- programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance.setStatus( ProgramStatus.COMPLETED );
programInstance.setEntityInstance( patient );
programInstanceService.addProgramInstance( programInstance );
@@ -600,7 +601,7 @@
{
ProgramInstance programInstance = programStageInstance.getProgramInstance();
- programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance.setStatus( ProgramStatus.COMPLETED );
programInstanceService.updateProgramInstance( programInstance );
}
@@ -660,7 +661,7 @@
programInstance.setIncidentDate( incidentDate );
programInstance.setProgram( program );
programInstance.setEntityInstance( patient );
- programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
+ programInstance.setStatus( ProgramStatus.ACTIVE );
programInstanceService.addProgramInstance( programInstance );
Iterator<ProgramStage> programStagesIterator = program.getProgramStages().iterator();
@@ -812,7 +813,7 @@
{
org.hisp.dhis.api.mobile.model.PatientAttribute patientAttribute = new org.hisp.dhis.api.mobile.model.PatientAttribute(
value.getAttribute().getName(), value.getValue(), null, false, value.getAttribute()
- .getDisplayInListNoProgram(), new OptionSet() );
+ .getDisplayInListNoProgram(), new OptionSet() );
patientAttribute.setType( value.getAttribute().getValueType() );
patientAtts.add( patientAttribute );
@@ -824,7 +825,7 @@
// Set current programs
List<ProgramInstance> listOfProgramInstance = new ArrayList<>( programInstanceService.getProgramInstances(
- patient, ProgramInstance.STATUS_ACTIVE ) );
+ patient, ProgramStatus.ACTIVE ) );
if ( listOfProgramInstance.size() > 0 )
{
@@ -837,7 +838,7 @@
// Set completed programs
List<ProgramInstance> listOfCompletedProgramInstance = new ArrayList<>(
- programInstanceService.getProgramInstances( patient, ProgramInstance.STATUS_COMPLETED ) );
+ programInstanceService.getProgramInstances( patient, ProgramStatus.COMPLETED ) );
if ( listOfCompletedProgramInstance.size() > 0 )
{
@@ -912,7 +913,7 @@
mobileProgramInstance.setId( programInstance.getId() );
mobileProgramInstance.setName( programInstance.getProgram().getName() );
- mobileProgramInstance.setStatus( programInstance.getStatus() );
+ mobileProgramInstance.setStatus( programInstance.getStatus().getValue() );
mobileProgramInstance.setDateOfEnrollment( PeriodUtil.dateToString( programInstance.getEnrollmentDate() ) );
mobileProgramInstance.setDateOfIncident( PeriodUtil.dateToString( programInstance.getIncidentDate() ) );
mobileProgramInstance.setPatientId( programInstance.getEntityInstance().getId() );
@@ -1300,7 +1301,7 @@
org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement mobileDataElement = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement();
mobileDataElement.setId( programStageDataElement.getDataElement().getId() );
mobileDataElement.setName( programStageDataElement.getDataElement().getName() );
- mobileDataElement.setType( programStageDataElement.getDataElement().getValueType() );
+ mobileDataElement.setType( programStageDataElement.getDataElement().getValueType() );
// problem
mobileDataElement.setCompulsory( programStageDataElement.isCompulsory() );
@@ -1523,7 +1524,7 @@
{
errorMsg = "Duplicate value of "
+ attributeService.getTrackedEntityAttribute( Integer.parseInt( errorCode[1] ) )
- .getDisplayName();
+ .getDisplayName();
}
else
{
@@ -2034,7 +2035,7 @@
programInstance.setProgram( program );
- programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance.setStatus( ProgramStatus.COMPLETED );
programInstanceService.addProgramInstance( programInstance );
@@ -2405,7 +2406,7 @@
throws NotAllowedException
{
ProgramInstance programInstance = programInstanceService.getProgramInstance( programId );
- programInstance.setStatus( ProgramInstance.STATUS_COMPLETED );
+ programInstance.setStatus( ProgramStatus.COMPLETED );
programInstanceService.updateProgramInstance( programInstance );
return PROGRAM_COMPLETED;
@@ -2573,7 +2574,7 @@
{
errorMsg = "Duplicate value of "
+ attributeService.getTrackedEntityAttribute( Integer.parseInt( errorCode[1] ) )
- .getDisplayName();
+ .getDisplayName();
}
else
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java 2015-09-11 11:54:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/ProgramController.java 2015-09-24 08:32:10 +0000
@@ -34,6 +34,7 @@
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStatus;
import org.hisp.dhis.query.Order;
import org.hisp.dhis.query.Query;
import org.hisp.dhis.schema.descriptors.ProgramSchemaDescriptor;
@@ -70,7 +71,7 @@
programInstance.setEnrollmentDate( new Date() );
programInstance.setIncidentDate( new Date() );
programInstance.setProgram( program );
- programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
+ programInstance.setStatus( ProgramStatus.ACTIVE );
programInstanceService.addProgramInstance( programInstance );
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java 2015-09-23 12:27:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/program/AddProgramAction.java 2015-09-24 08:32:10 +0000
@@ -29,7 +29,6 @@
*/
import com.opensymphony.xwork2.Action;
-
import org.apache.commons.lang3.StringUtils;
import org.hisp.dhis.attribute.AttributeService;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -39,8 +38,9 @@
import org.hisp.dhis.program.ProgramService;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageService;
+import org.hisp.dhis.program.ProgramStatus;
+import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
import org.hisp.dhis.program.ProgramType;
-import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
import org.hisp.dhis.relationship.RelationshipType;
import org.hisp.dhis.relationship.RelationshipTypeService;
import org.hisp.dhis.system.util.AttributeUtils;
@@ -88,7 +88,7 @@
@Autowired
private AttributeService attributeService;
-
+
@Autowired
private DataElementCategoryService categoryService;
@@ -249,7 +249,7 @@
{
this.categoryComboId = categoryComboId;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -264,7 +264,7 @@
selectEnrollmentDatesInFuture = (selectEnrollmentDatesInFuture == null) ? false : selectEnrollmentDatesInFuture;
selectIncidentDatesInFuture = (selectIncidentDatesInFuture == null) ? false : selectIncidentDatesInFuture;
dataEntryMethod = (dataEntryMethod == null) ? false : dataEntryMethod;
-
+
Program program = new Program();
program.setName( StringUtils.trimToNull( name ) );
@@ -293,8 +293,8 @@
RelationshipType relationshipType = relationshipTypeService.getRelationshipType( relationshipTypeId );
program.setRelationshipType( relationshipType );
program.setRelationshipFromA( relationshipFromA );
- program.setRelationshipText( relationshipText );
-
+ program.setRelationshipText( relationshipText );
+
Program relatedProgram = programService.getProgram( relatedProgramId );
program.setRelatedProgram( relatedProgram );
}
@@ -311,10 +311,10 @@
TrackedEntity trackedEntity = trackedEntityService.getTrackedEntity( trackedEntityId );
program.setTrackedEntity( trackedEntity );
}
-
+
if ( categoryComboId != null )
{
- program.setCategoryCombo( categoryService.getDataElementCategoryCombo( categoryComboId ) );
+ program.setCategoryCombo( categoryService.getDataElementCategoryCombo( categoryComboId ) );
}
programService.addProgram( program );
@@ -370,7 +370,7 @@
programInstance.setEnrollmentDate( new Date() );
programInstance.setIncidentDate( new Date() );
programInstance.setProgram( program );
- programInstance.setStatus( ProgramInstance.STATUS_ACTIVE );
+ programInstance.setStatus( ProgramStatus.ACTIVE );
programInstanceService.addProgramInstance( programInstance );
}