dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37473
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19163: events now have orgunit - services and tests are changed accordingly; when necessary attributes a...
------------------------------------------------------------
revno: 19163
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-05-18 19:05:23 +0200
message:
events now have orgunit - services and tests are changed accordingly; when necessary attributes are now fetched as part of the event query
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.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/EventService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/EventRow.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java
dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java
dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java
dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java
dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramExpressionServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramValidationServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueServiceTest.java
dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueStoreTest.java
dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveProgramEnrollmentAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js
--
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/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2015-04-23 17:00:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2015-05-18 17:05:23 +0000
@@ -52,7 +52,8 @@
* Adds an {@link TrackedEntityAttribute}
*
* @param programStageInstance The to TrackedEntityAttribute add.
- * @return A generated unique id of the added {@link TrackedEntityAttribute}.
+ * @return A generated unique id of the added {@link TrackedEntityAttribute}
+ * .
*/
int addProgramStageInstance( ProgramStageInstance programStageInstance );
@@ -82,7 +83,8 @@
* Returns the {@link TrackedEntityAttribute} with the given UID.
*
* @param uid the UID.
- * @return the TrackedEntityAttribute with the given UID, or null if no match.
+ * @return the TrackedEntityAttribute with the given UID, or null if no
+ * match.
*/
ProgramStageInstance getProgramStageInstance( String uid );
@@ -91,7 +93,7 @@
* repeatable stage, the system returns the last event
*
* @param programInstance ProgramInstance
- * @param programStage ProgramStage
+ * @param programStage ProgramStage
* @return ProgramStageInstance
*/
ProgramStageInstance getProgramStageInstance( ProgramInstance programInstance, ProgramStage programStage );
@@ -100,17 +102,18 @@
* 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
*/
Collection<ProgramStageInstance> getProgramStageInstances( Collection<ProgramInstance> programInstances,
EventStatus status );
/**
- * Get all events by TrackedEntityInstance, optionally filtering by completed.
+ * Get all events by TrackedEntityInstance, optionally filtering by
+ * completed.
*
* @param entityInstance TrackedEntityInstance
- * @param status EventStatus
+ * @param status EventStatus
* @return ProgramStageInstance list
*/
List<ProgramStageInstance> getProgramStageInstances( TrackedEntityInstance entityInstance, EventStatus status );
@@ -133,12 +136,12 @@
/**
* Get/export statistical report of a program
*
- * @param program Program needs to report
+ * @param program Program needs to report
* @param orgunitIds The ids of orgunits where the events happened
- * @param startDate Optional date the instance should be on or after.
- * @param endDate Optional date the instance should be on or before.
- * @param i18n I18n object
- * @param format I18nFormat
+ * @param startDate Optional date the instance should be on or after.
+ * @param endDate Optional date the instance should be on or before.
+ * @param i18n I18n object
+ * @param format I18nFormat
* @return Program report
*/
Grid getStatisticalReport( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate,
@@ -148,10 +151,10 @@
* Get/Export a report about the number of events of a program completed on
* a orgunit
*
- * @param orgunits The ids of orgunits where the events happened
- * @param program The program needs for reporting
+ * @param orgunits The ids of orgunits where the events happened
+ * @param program The program needs for reporting
* @param startDate Optional date the instance should be on or after.
- * @param endDate Optional date the instance should be on or before.
+ * @param endDate Optional date the instance should be on or before.
* @return Grid
*/
Grid getCompletenessProgramStageInstance( Collection<Integer> orgunits, Program program, String startDate,
@@ -162,7 +165,7 @@
* was defined to send when to complete this program
*
* @param programStageInstance ProgramStageInstance
- * @param format I18nFormat
+ * @param format I18nFormat
*/
void completeProgramStageInstance( ProgramStageInstance programStageInstance, I18nFormat format );
@@ -170,8 +173,8 @@
* Set report date and orgunit where an event happened for the event
*
* @param programStageInstance ProgramStageInstance
- * @param executionDate Report date
- * @param organisationUnit Orgunit where the event happens
+ * @param executionDate Report date
+ * @param organisationUnit Orgunit where the event happens
*/
void setExecutionDate( ProgramStageInstance programStageInstance, Date executionDate,
OrganisationUnit organisationUnit );
@@ -182,12 +185,15 @@
* program-stage-instance. The similar thing happens for single event with
* registration.
*
- * @param entityInstance TrackedEntityInstance
- * @param program Single event without registration
- * @param executionDate Report date of the event
+ * @param entityInstance TrackedEntityInstance
+ * @param program Single event without registration
+ * @param executionDate Report date of the event
* @param organisationUnit Orgunit where the event happens
* @return ProgramStageInstance ProgramStageInstance object
*/
- ProgramStageInstance createProgramStageInstance( TrackedEntityInstance entityInstance, Program program, Date executionDate,
- OrganisationUnit organisationUnit );
+ ProgramStageInstance createProgramStageInstance( TrackedEntityInstance entityInstance, Program program,
+ Date executionDate, OrganisationUnit organisationUnit );
+
+ ProgramStageInstance createProgramStageInstance( ProgramInstance programInstance, ProgramStage programStage,
+ Date enrollmentDate, Date dateOfIncident, OrganisationUnit organisationUnit );
}
=== 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-05-01 15:17:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java 2015-05-18 17:05:23 +0000
@@ -54,6 +54,8 @@
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dxf2.common.IdSchemes;
import org.hisp.dhis.dxf2.common.ImportOptions;
+import org.hisp.dhis.dxf2.events.report.EventRow;
+import org.hisp.dhis.dxf2.events.report.EventRows;
import org.hisp.dhis.dxf2.importsummary.ImportConflict;
import org.hisp.dhis.dxf2.importsummary.ImportStatus;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
@@ -448,6 +450,41 @@
}
@Override
+ public EventRows getEventRows( EventSearchParams params )
+ {
+ List<OrganisationUnit> organisationUnits = new ArrayList<>();
+
+ OrganisationUnit orgUnit = params.getOrgUnit();
+ OrganisationUnitSelectionMode orgUnitSelectionMode = params.getOrgUnitSelectionMode();
+
+ if ( params.getOrgUnit() != null )
+ {
+ if ( OrganisationUnitSelectionMode.DESCENDANTS.equals( orgUnitSelectionMode ) )
+ {
+ organisationUnits.addAll( organisationUnitService.getOrganisationUnitWithChildren( orgUnit.getUid() ) );
+ }
+ else if ( OrganisationUnitSelectionMode.CHILDREN.equals( orgUnitSelectionMode ) )
+ {
+ organisationUnits.add( orgUnit );
+ organisationUnits.addAll( orgUnit.getChildren() );
+ }
+ else // SELECTED
+ {
+ organisationUnits.add( orgUnit );
+ }
+ }
+
+ EventRows eventRows = new EventRows();
+
+
+ List<EventRow> eventRowList = eventStore.getEventRows( params, organisationUnits );
+
+ eventRows.setEventRows( eventRowList );
+
+ return eventRows;
+ }
+
+ @Override
public EventSearchParams getFromUrl( String program, String programStage, ProgramStatus programStatus, Boolean followUp, String orgUnit,
OrganisationUnitSelectionMode orgUnitSelectionMode, String trackedEntityInstance, Date startDate, Date endDate,
EventStatus status, Date lastUpdated, IdSchemes idSchemes, Integer page, Integer pageSize, boolean totalPages, boolean skipPaging )
=== 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 2015-05-01 15:17:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventService.java 2015-05-18 17:05:23 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.common.OrganisationUnitSelectionMode;
import org.hisp.dhis.dxf2.common.IdSchemes;
import org.hisp.dhis.dxf2.common.ImportOptions;
+import org.hisp.dhis.dxf2.events.report.EventRows;
import org.hisp.dhis.dxf2.importsummary.ImportSummaries;
import org.hisp.dhis.dxf2.importsummary.ImportSummary;
import org.hisp.dhis.event.EventStatus;
@@ -53,6 +54,8 @@
// -------------------------------------------------------------------------
Events getEvents( EventSearchParams params );
+
+ EventRows getEventRows( EventSearchParams params );
EventSearchParams getFromUrl( String program, String programStage, ProgramStatus programStatus, Boolean followUp, String orgUnit,
OrganisationUnitSelectionMode orgUnitSelectionMode, String trackedEntityInstance, Date startDate, Date endDate,
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java 2015-04-21 20:08:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/EventStore.java 2015-05-18 17:05:23 +0000
@@ -30,6 +30,7 @@
import java.util.List;
+import org.hisp.dhis.dxf2.events.report.EventRow;
import org.hisp.dhis.organisationunit.OrganisationUnit;
/**
@@ -39,5 +40,7 @@
{
List<Event> getEvents( EventSearchParams params, List<OrganisationUnit> organisationUnits );
+ List<EventRow> getEventRows( EventSearchParams params, List<OrganisationUnit> organisationUnits );
+
int getEventCount( EventSearchParams params, List<OrganisationUnit> organisationUnits );
}
=== 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-05-05 08:34:06 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/JdbcEventStore.java 2015-05-18 17:05:23 +0000
@@ -41,6 +41,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dxf2.common.IdSchemes;
+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.Program;
@@ -184,6 +186,98 @@
return events;
}
+
+ public List<EventRow> getEventRows( EventSearchParams params, List<OrganisationUnit> organisationUnits )
+ {
+ List<EventRow> eventRows = new ArrayList<>();
+
+ String sql = buildSql( params, organisationUnits );
+
+ SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
+
+ log.debug( "Event query SQL: " + sql );
+
+ EventRow eventRow = new EventRow();
+
+ eventRow.setEvent( "not_valid" );
+
+ Set<String> notes = new HashSet<>();
+
+ IdSchemes idSchemes = ObjectUtils.firstNonNull( params.getIdSchemes(), new IdSchemes() );
+
+ while ( rowSet.next() )
+ {
+ if ( rowSet.getString( "psi_uid" ) == null )
+ {
+ continue;
+ }
+
+ if ( !eventRow.getEvent().equals( rowSet.getString( "psi_uid" ) ) )
+ {
+ eventRow = new EventRow();
+
+ eventRow.setEvent( rowSet.getString( "psi_uid" ) );
+ eventRow.setTrackedEntityInstance( rowSet.getString( "tei_uid" ) );
+
+ eventRow.setProgram( IdSchemes.getValue( rowSet.getString( "p_uid" ), rowSet.getString( "p_code" ),
+ idSchemes.getProgramIdScheme() ) );
+ eventRow.setProgramStage( IdSchemes.getValue( rowSet.getString( "ps_uid" ),
+ rowSet.getString( "ps_code" ), idSchemes.getProgramStageIdScheme() ) );
+ eventRow.setOrgUnit( IdSchemes.getValue( rowSet.getString( "ou_uid" ), rowSet.getString( "ou_code" ),
+ idSchemes.getOrgUnitIdScheme() ) );
+
+ if ( rowSet.getInt( "p_type" ) != Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
+ {
+ eventRow.setEnrollment( rowSet.getString( "pi_uid" ) );
+ eventRow.setFollowup( rowSet.getBoolean( "pi_followup" ) );
+ }
+
+ eventRow.setTrackedEntityInstance( rowSet.getString( "tei_uid" ) );
+ eventRow.setOrgUnitName( rowSet.getString( "ou_name" ) );
+ eventRow.setDueDate( DateUtils.getLongDateString( rowSet.getDate( "psi_duedate" ) ) );
+ eventRow.setEventDate( DateUtils.getLongDateString( rowSet.getDate( "psi_executiondate" ) ) );
+
+ eventRows.add( eventRow );
+ }
+
+ if ( rowSet.getString( "pav_value" ) != null && rowSet.getString( "ta_uid" ) != null )
+ {
+ Attribute attribute = new Attribute();
+ attribute.setValue( rowSet.getString( "pav_value" ) );
+ attribute.setDisplayName( rowSet.getString( "ta_name" ) );
+ attribute.setType( rowSet.getString( "ta_valuetype" ) );
+ attribute.setAttribute( rowSet.getString( "ta_uid" ) );
+
+ eventRow.getAttributes().add( attribute );
+ }
+
+ if ( rowSet.getString( "pdv_value" ) != null && rowSet.getString( "de_uid" ) != null )
+ {
+ DataValue dataValue = new DataValue();
+ dataValue.setValue( rowSet.getString( "pdv_value" ) );
+ dataValue.setProvidedElsewhere( rowSet.getBoolean( "pdv_providedelsewhere" ) );
+ dataValue.setDataElement( IdSchemes.getValue( rowSet.getString( "de_uid" ),
+ rowSet.getString( "de_code" ), idSchemes.getDataElementIdScheme() ) );
+
+ dataValue.setStoredBy( rowSet.getString( "pdv_storedby" ) );
+
+ eventRow.getDataValues().add( dataValue );
+ }
+
+ if ( rowSet.getString( "psinote_value" ) != null && !notes.contains( rowSet.getString( "psinote_id" ) ) )
+ {
+ Note note = new Note();
+ note.setValue( rowSet.getString( "psinote_value" ) );
+ note.setStoredDate( rowSet.getString( "psinote_storeddate" ) );
+ note.setStoredBy( rowSet.getString( "psinote_storedby" ) );
+
+ eventRow.getNotes().add( note );
+ notes.add( rowSet.getString( "psinote_id" ) );
+ }
+ }
+
+ return eventRows;
+ }
public int getEventCount( EventSearchParams params, List<OrganisationUnit> organisationUnits )
{
@@ -211,6 +305,10 @@
sql += ") as event left join (";
+ sql += getAttributeValueQuery();
+
+ sql += ") as att on event.tei_id=att.pav_id left join (";
+
sql += getDataValueQuery();
sql += ") as dv on event.psi_id=dv.pdv_id left join (";
@@ -235,7 +333,7 @@
"psi.longitude as psi_longitude, psi.latitude as psi_latitude, psi.created as psi_created, psi.lastupdated as psi_lastupdated, " +
"pi.uid as pi_uid, pi.status as pi_status, pi.followup as pi_followup, p.uid as p_uid, p.code as p_code, " +
"p.type as p_type, ps.uid as ps_uid, ps.code as ps_code, ps.capturecoordinates as ps_capturecoordinates, " +
- "ou.uid as ou_uid, ou.code as ou_code, ou.name as ou_name, tei.uid as tei_uid " +
+ "ou.uid as ou_uid, ou.code as ou_code, ou.name as ou_name, tei.trackedentityinstanceid as tei_id, tei.uid as tei_uid " +
"from programstageinstance psi " +
"inner join programinstance pi on pi.programinstanceid=psi.programinstanceid " +
"inner join program p on p.programid=pi.programid " +
@@ -375,4 +473,13 @@
return sql;
}
+
+ private String getAttributeValueQuery()
+ {
+ String sql = "select pav.trackedentityinstanceid as pav_id, pav.value as pav_value, ta.uid as ta_uid, ta.name as ta_name, ta.valuetype as ta_valuetype "
+ + "from trackedentityattributevalue pav "
+ + "inner join trackedentityattribute ta on pav.trackedentityattributeid=ta.trackedentityattributeid ";
+
+ return sql;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java 2015-03-12 11:03:32 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/AbstractEventRowService.java 2015-05-18 17:05:23 +0000
@@ -28,15 +28,10 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.ArrayList;
-import java.util.List;
import org.hisp.dhis.common.IdentifiableObjectManager;
-import org.hisp.dhis.dxf2.events.event.Event;
import org.hisp.dhis.dxf2.events.event.EventSearchParams;
import org.hisp.dhis.dxf2.events.event.EventService;
-import org.hisp.dhis.dxf2.events.event.Events;
-import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -62,7 +57,7 @@
@Override
public EventRows getEventRows( EventSearchParams params )
{
- List<EventRow> eventRowList = new ArrayList<EventRow>();
+ /*List<EventRow> eventRowList = new ArrayList<EventRow>();
EventRows eventRows = new EventRows();
Events events = eventService.getEvents( params );
@@ -88,8 +83,10 @@
}
}
- eventRows.setEventRows( eventRowList );
-
+ eventRows.setEventRows( eventRowList );*/
+
+ EventRows eventRows = eventService.getEventRows( params );
+
return eventRows;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/EventRow.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/EventRow.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/report/EventRow.java 2015-05-18 17:05:23 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.DxfNamespaces;
+import org.hisp.dhis.dxf2.events.event.DataValue;
import org.hisp.dhis.dxf2.events.event.Note;
import org.hisp.dhis.dxf2.events.trackedentity.Attribute;
@@ -52,8 +53,6 @@
{
private String trackedEntityInstance;
- private List<Attribute> attributes = new ArrayList<>();
-
private String event;
private String program;
@@ -62,11 +61,9 @@
private String enrollment;
- private String eventOrgUnitName;
-
- private String registrationOrgUnit;
-
- private String registrationDate;
+ private String orgUnit;
+
+ private String orgUnitName;
private String eventDate;
@@ -74,6 +71,10 @@
private Boolean followup;
+ private List<Attribute> attributes = new ArrayList<>();
+
+ private List<DataValue> dataValues = new ArrayList<>();
+
private List<Note> notes = new ArrayList<>();
public EventRow()
@@ -103,6 +104,18 @@
{
this.attributes = attributes;
}
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public List<DataValue> getDataValues()
+ {
+ return dataValues;
+ }
+
+ public void setDataValues( List<DataValue> dataValues )
+ {
+ this.dataValues = dataValues;
+ }
@JsonProperty
@JacksonXmlProperty( isAttribute = true )
@@ -154,38 +167,26 @@
@JsonProperty
@JacksonXmlProperty( isAttribute = true )
- public String getRegistrationOrgUnit()
- {
- return registrationOrgUnit;
- }
-
- public void setRegistrationOrgUnit( String registrationOrgUnit )
- {
- this.registrationOrgUnit = registrationOrgUnit;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getRegistrationDate()
- {
- return registrationDate;
- }
-
- public void setRegistrationDate( String registrationDate )
- {
- this.registrationDate = registrationDate;
- }
-
- @JsonProperty
- @JacksonXmlProperty( isAttribute = true )
- public String getEventOrgUnitName()
- {
- return eventOrgUnitName;
- }
-
- public void setEventOrgUnitName( String eventOrgUnitName )
- {
- this.eventOrgUnitName = eventOrgUnitName;
+ public String getOrgUnit()
+ {
+ return orgUnit;
+ }
+
+ public void setOrgUnit( String orgUnit )
+ {
+ this.orgUnit = orgUnit;
+ }
+
+ @JsonProperty
+ @JacksonXmlProperty( isAttribute = true )
+ public String getOrgUnitName()
+ {
+ return orgUnitName;
+ }
+
+ public void setOrgUnitName( String orgUnitName )
+ {
+ this.orgUnitName = orgUnitName;
}
@JsonProperty( required = true )
@@ -252,16 +253,15 @@
return false;
if ( attributes != null ? !attributes.equals( eventRow1.attributes ) : eventRow1.attributes != null )
return false;
-
+ if ( dataValues != null ? !dataValues.equals( eventRow1.dataValues ) : eventRow1.dataValues != null )
+ return false;
if ( eventDate != null ? !eventDate.equals( eventRow1.eventDate ) : eventRow1.eventDate != null )
return false;
if ( dueDate != null ? !dueDate.equals( eventRow1.dueDate ) : eventRow1.dueDate != null )
return false;
- if ( eventOrgUnitName != null ? !eventOrgUnitName.equals( eventRow1.eventOrgUnitName ) : eventRow1.eventOrgUnitName != null )
+ if ( orgUnitName != null ? !orgUnitName.equals( eventRow1.orgUnitName ) : eventRow1.orgUnitName != null )
return false;
- if ( registrationOrgUnit != null ? !registrationOrgUnit.equals( eventRow1.registrationOrgUnit ) : eventRow1.registrationOrgUnit != null )
- return false;
- if ( registrationDate != null ? !registrationDate.equals( eventRow1.registrationDate ) : eventRow1.registrationDate != null )
+ if ( orgUnit != null ? !orgUnit.equals( eventRow1.orgUnit ) : eventRow1.orgUnit != null )
return false;
if ( trackedEntityInstance != null ? !trackedEntityInstance.equals( eventRow1.trackedEntityInstance )
: eventRow1.trackedEntityInstance != null )
@@ -279,11 +279,11 @@
{
int result = event != null ? event.hashCode() : 0;
result = 31 * result + (attributes != null ? attributes.hashCode() : 0);
+ result = 31 * result + (dataValues != null ? dataValues.hashCode() : 0);
result = 31 * result + (program != null ? program.hashCode() : 0);
result = 31 * result + (programStage != null ? programStage.hashCode() : 0);
- result = 31 * result + (eventOrgUnitName != null ? eventOrgUnitName.hashCode() : 0);
- result = 31 * result + (registrationOrgUnit != null ? registrationOrgUnit.hashCode() : 0);
- result = 31 * result + (registrationDate != null ? registrationDate.hashCode() : 0);
+ result = 31 * result + (orgUnitName != null ? orgUnitName.hashCode() : 0);
+ result = 31 * result + (orgUnit != null ? orgUnit.hashCode() : 0);
result = 31 * result + (trackedEntityInstance != null ? trackedEntityInstance.hashCode() : 0);
result = 31 * result + (eventDate != null ? eventDate.hashCode() : 0);
result = 31 * result + (dueDate != null ? dueDate.hashCode() : 0);
@@ -296,11 +296,11 @@
return "Event{" +
"event='" + event + '\'' +
", attributes=" + attributes +
+ ", dataValues=" + dataValues +
", program='" + program + '\'' +
", programStage='" + programStage + '\'' +
- ", eventOrgUnitName='" + eventOrgUnitName + '\'' +
- ", registrationOrgUnit='" + registrationOrgUnit + '\'' +
- ", registrationDate='" + registrationDate + '\'' +
+ ", eventOrgUnitName='" + orgUnitName + '\'' +
+ ", registrationOrgUnit='" + orgUnit + '\'' +
", trackedEntityInstance='" + trackedEntityInstance + '\'' +
", eventDate='" + eventDate + '\'' +
", dueDate='" + dueDate + '\'' +
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java 2015-04-09 11:01:31 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/EnrollmentServiceTest.java 2015-05-18 17:05:23 +0000
@@ -135,8 +135,8 @@
@Test
public void testGetEnrollments()
{
- programInstanceService.enrollTrackedEntityInstance( maleA, programA, null, null, organisationUnitA );
- programInstanceService.enrollTrackedEntityInstance( femaleA, programA, null, null, organisationUnitA );
+ programInstanceService.enrollTrackedEntityInstance( maleA, programA, new Date(), new Date(), organisationUnitA );
+ programInstanceService.enrollTrackedEntityInstance( femaleA, programA, new Date(), new Date(), organisationUnitA );
assertEquals( 2, enrollmentService.getEnrollments().getEnrollments().size() );
}
@@ -144,8 +144,8 @@
@Test
public void testGetEnrollmentsByPatient()
{
- programInstanceService.enrollTrackedEntityInstance( maleA, programA, null, null, organisationUnitA );
- programInstanceService.enrollTrackedEntityInstance( femaleA, programA, null, null, organisationUnitA );
+ programInstanceService.enrollTrackedEntityInstance( maleA, programA, new Date(), new Date(), organisationUnitA );
+ programInstanceService.enrollTrackedEntityInstance( femaleA, programA, new Date(), new Date(), organisationUnitA );
assertEquals( 1, enrollmentService.getEnrollments( maleA ).getEnrollments().size() );
assertEquals( 1, enrollmentService.getEnrollments( femaleA ).getEnrollments().size() );
@@ -155,8 +155,8 @@
public void testGetEnrollmentsByPerson()
{
- programInstanceService.enrollTrackedEntityInstance( maleA, programA, null, null, organisationUnitA );
- programInstanceService.enrollTrackedEntityInstance( femaleA, programA, null, null, organisationUnitA );
+ programInstanceService.enrollTrackedEntityInstance( maleA, programA, new Date(), new Date(), organisationUnitA );
+ programInstanceService.enrollTrackedEntityInstance( femaleA, programA, new Date(), new Date(), organisationUnitA );
TrackedEntityInstance male = trackedEntityInstanceService.getTrackedEntityInstance( maleA );
TrackedEntityInstance female = trackedEntityInstanceService.getTrackedEntityInstance( femaleA );
@@ -168,8 +168,8 @@
@Test
public void testGetEnrollmentsByStatus()
{
- ProgramInstance piMale = programInstanceService.enrollTrackedEntityInstance( maleA, programA, null, null, organisationUnitA );
- ProgramInstance piFemale = programInstanceService.enrollTrackedEntityInstance( femaleA, programA, null, null, organisationUnitA );
+ ProgramInstance piMale = programInstanceService.enrollTrackedEntityInstance( maleA, programA, new Date(), new Date(), organisationUnitA );
+ ProgramInstance piFemale = programInstanceService.enrollTrackedEntityInstance( femaleA, programA, new Date(), new Date(), organisationUnitA );
assertEquals( 2, enrollmentService.getEnrollments( EnrollmentStatus.ACTIVE ).getEnrollments().size() );
assertEquals( 0, enrollmentService.getEnrollments( EnrollmentStatus.CANCELLED ).getEnrollments().size() );
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java 2015-04-15 20:26:30 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationMultiEventsServiceTest.java 2015-05-18 17:05:23 +0000
@@ -31,6 +31,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import java.util.Date;
import java.util.HashSet;
import org.hamcrest.CoreMatchers;
@@ -326,6 +327,8 @@
enrollment.setOrgUnit( organisationUnitA.getUid() );
enrollment.setProgram( program );
enrollment.setTrackedEntityInstance( person );
+ enrollment.setDateOfEnrollment( new Date() );
+ enrollment.setDateOfIncident( new Date() );
return enrollment;
}
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java 2015-04-15 20:26:30 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/test/java/org/hisp/dhis/dxf2/events/RegistrationSingleEventServiceTest.java 2015-05-18 17:05:23 +0000
@@ -32,6 +32,7 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertThat;
+import java.util.Date;
import java.util.HashSet;
import org.hamcrest.CoreMatchers;
@@ -241,6 +242,8 @@
enrollment.setOrgUnit( organisationUnitA.getUid() );
enrollment.setProgram( program );
enrollment.setTrackedEntityInstance( person );
+ enrollment.setDateOfEnrollment( new Date() );
+ enrollment.setDateOfIncident( new Date() );
return enrollment;
}
=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java 2015-02-09 22:18:20 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionServiceTest.java 2015-05-18 17:05:23 +0000
@@ -236,10 +236,10 @@
ProgramInstance programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program,
today.toDate(), today.toDate(), organisationUnit );
- ProgramStageInstance stageInstanceA = programStageInstanceService.getProgramStageInstance( programInstance,
- stageA );
- ProgramStageInstance stageInstanceB = programStageInstanceService.getProgramStageInstance( programInstance,
- stageB );
+ ProgramStageInstance stageInstanceA = programStageInstanceService.createProgramStageInstance( programInstance,
+ stageA, today.toDate(), today.toDate(), organisationUnit );
+ ProgramStageInstance stageInstanceB = programStageInstanceService.createProgramStageInstance( programInstance,
+ stageB, today.toDate(), today.toDate(), organisationUnit );
TrackedEntityDataValue dataValueA = new TrackedEntityDataValue( stageInstanceA, dataElementA, "A" );
TrackedEntityDataValue dataValueB = new TrackedEntityDataValue( stageInstanceA, dataElementB, "B" );
@@ -395,8 +395,8 @@
dataElements.add( dataElementC );
dataElements.add( dataElementD );
- assertTrue( equals( aggConditionServiceService.getCaseAggregationConditions( dataElements , null, null, null ), conditionA,
- conditionB ) );
+ assertTrue( equals( aggConditionServiceService.getCaseAggregationConditions( dataElements, null, null, null ),
+ conditionA, conditionB ) );
}
@Test
=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/test/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionStoreTest.java 2015-05-18 17:05:23 +0000
@@ -248,13 +248,13 @@
DateTime today = DateTime.now();
today.withTimeAtStartOfDay();
- ProgramInstance programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, today.toDate(),
- today.toDate(), organisationUnit );
+ ProgramInstance programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program,
+ today.toDate(), today.toDate(), organisationUnit );
- ProgramStageInstance stageInstanceA = programStageInstanceService.getProgramStageInstance( programInstance,
- stageA );
- ProgramStageInstance stageInstanceB = programStageInstanceService.getProgramStageInstance( programInstance,
- stageB );
+ ProgramStageInstance stageInstanceA = programStageInstanceService.createProgramStageInstance( programInstance,
+ stageA, today.toDate(), today.toDate(), organisationUnit );
+ ProgramStageInstance stageInstanceB = programStageInstanceService.createProgramStageInstance( programInstance,
+ stageB, today.toDate(), today.toDate(), organisationUnit );
TrackedEntityDataValue dataValueA = new TrackedEntityDataValue( stageInstanceA, dataElementA, "A" );
TrackedEntityDataValue dataValueB = new TrackedEntityDataValue( stageInstanceA, dataElementB, "B" );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2015-04-23 17:30:50 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java 2015-05-18 17:05:23 +0000
@@ -44,7 +44,6 @@
import org.hisp.dhis.sms.SmsServiceException;
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.system.grid.ListGrid;
-import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
@@ -511,21 +510,15 @@
addProgramInstance( programInstance );
// ---------------------------------------------------------------------
- // Generate events for program instance
+ // Generate event if program is single event and has program stage.
+ // At some point, programs of type single event should be removed.
// ---------------------------------------------------------------------
- for ( ProgramStage programStage : program.getProgramStages() )
+ if ( program.isSingleEvent() && program.getProgramStages().size() == 1 )
{
- if ( programStage.getAutoGenerateEvent() )
- {
- ProgramStageInstance programStageInstance = generateEvent( programInstance, programStage,
- programInstance.getEnrollmentDate(), programInstance.getDateOfIncident(), organisationUnit );
-
- if ( programStageInstance != null )
- {
- programStageInstanceService.addProgramStageInstance( programStageInstance );
- }
- }
+ ProgramStage programStage = program.getProgramStages().iterator().next();
+ programStageInstanceService.createProgramStageInstance( programInstance, programStage, enrollmentDate,
+ dateOfIncident, organisationUnit );
}
// -----------------------------------------------------------------
@@ -666,45 +659,6 @@
// Supportive methods
// -------------------------------------------------------------------------
- private ProgramStageInstance generateEvent( ProgramInstance programInstance, ProgramStage programStage,
- Date enrollmentDate, Date dateOfIncident, OrganisationUnit orgunit )
- {
- ProgramStageInstance programStageInstance = null;
-
- Date currentDate = new Date();
- Date dateCreatedEvent;
-
- if ( programStage.getGeneratedByEnrollmentDate() )
- {
- dateCreatedEvent = enrollmentDate;
- }
- else
- {
- dateCreatedEvent = dateOfIncident;
- }
-
- Date dueDate = DateUtils.getDateAfterAddition( dateCreatedEvent, programStage.getMinDaysFromStart() );
-
- if ( !programInstance.getProgram().getIgnoreOverdueEvents() || dueDate.before( currentDate ) )
- {
- programStageInstance = new ProgramStageInstance();
- programStageInstance.setProgramInstance( programInstance );
- programStageInstance.setProgramStage( programStage );
- programStageInstance.setDueDate( dueDate );
- programStageInstance.setStatus( EventStatus.SCHEDULE );
-
- if ( programStage.getOpenAfterEnrollment() || programInstance.getProgram().isSingleEvent()
- || programStage.getPeriodType() != null )
- {
- programStageInstance.setOrganisationUnit( orgunit );
- programStageInstance.setExecutionDate( dueDate );
- programStageInstance.setStatus( EventStatus.ACTIVE );
- }
- }
-
- return programStageInstance;
- }
-
private void getProgramStageInstancesReport( Grid grid, ProgramInstance programInstance, I18n i18n )
{
I18nFormat format = i18nManager.getI18nFormat();
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2015-04-23 17:00:11 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2015-05-18 17:05:23 +0000
@@ -49,6 +49,7 @@
import org.hisp.dhis.sms.SmsServiceException;
import org.hisp.dhis.sms.outbound.OutboundSms;
import org.hisp.dhis.system.grid.ListGrid;
+import org.hisp.dhis.system.util.DateUtils;
import org.hisp.dhis.system.util.MathUtils;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceReminder;
@@ -143,7 +144,7 @@
{
return programStageInstanceStore.get( programInstance, programStage );
}
-
+
@Override
public void updateProgramStageInstance( ProgramStageInstance programStageInstance )
{
@@ -227,8 +228,8 @@
double percent = 0.0;
if ( totalCompleted != 0 )
{
- int stageCompleted = programStageInstanceStore.averageNumberCompleted( program, orgunitIds, startDate, endDate,
- ProgramInstance.STATUS_ACTIVE );
+ int stageCompleted = programStageInstanceStore.averageNumberCompleted( program, orgunitIds, startDate,
+ endDate, ProgramInstance.STATUS_ACTIVE );
percent = (stageCompleted + 0.0) / totalCompleted;
}
grid.addValue( MathUtils.getRounded( percent ) ).addEmptyValues( 6 );
@@ -361,7 +362,7 @@
// ---------------------------------------------------------------------
updateProgramStageInstance( programStageInstance );
-
+
// ---------------------------------------------------------------------
// Check Completed status for all of ProgramStageInstance of
// ProgramInstance
@@ -459,6 +460,46 @@
return programStageInstance;
}
+ public ProgramStageInstance createProgramStageInstance( ProgramInstance programInstance, ProgramStage programStage,
+ Date enrollmentDate, Date dateOfIncident, OrganisationUnit organisationUnit )
+ {
+ ProgramStageInstance programStageInstance = null;
+ Date currentDate = new Date();
+ Date dateCreatedEvent;
+
+ if ( programStage.getGeneratedByEnrollmentDate() )
+ {
+ dateCreatedEvent = enrollmentDate;
+ }
+ else
+ {
+ dateCreatedEvent = dateOfIncident;
+ }
+
+ Date dueDate = DateUtils.getDateAfterAddition( dateCreatedEvent, programStage.getMinDaysFromStart() );
+
+ if ( !programInstance.getProgram().getIgnoreOverdueEvents() || dueDate.before( currentDate ) )
+ {
+ programStageInstance = new ProgramStageInstance();
+ programStageInstance.setProgramInstance( programInstance );
+ programStageInstance.setProgramStage( programStage );
+ programStageInstance.setOrganisationUnit( organisationUnit );
+ programStageInstance.setDueDate( dueDate );
+ programStageInstance.setStatus( EventStatus.SCHEDULE );
+
+ if ( programStage.getOpenAfterEnrollment() || programInstance.getProgram().isSingleEvent()
+ || programStage.getPeriodType() != null )
+ {
+ programStageInstance.setExecutionDate( dueDate );
+ programStageInstance.setStatus( EventStatus.ACTIVE );
+ }
+
+ addProgramStageInstance( programStageInstance );
+ }
+
+ return programStageInstance;
+ }
+
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
@@ -488,15 +529,14 @@
return outboundSms;
}
-
+
private Collection<OutboundSms> sendMessages( ProgramStageInstance programStageInstance, int status,
I18nFormat format )
{
TrackedEntityInstance entityInstance = programStageInstance.getProgramInstance().getEntityInstance();
Collection<OutboundSms> outboundSmsList = new HashSet<>();
- Collection<TrackedEntityInstanceReminder> reminders = programStageInstance.getProgramStage()
- .getReminders();
+ Collection<TrackedEntityInstanceReminder> reminders = programStageInstance.getProgramStage().getReminders();
for ( TrackedEntityInstanceReminder rm : reminders )
{
if ( rm != null
@@ -516,28 +556,27 @@
}
private Collection<MessageConversation> sendMessageConversations( ProgramStageInstance programStageInstance,
- int status, I18nFormat format )
- {
- Collection<MessageConversation> messageConversations = new HashSet<>();
-
- Collection<TrackedEntityInstanceReminder> reminders = programStageInstance.getProgramStage()
- .getReminders();
- for ( TrackedEntityInstanceReminder rm : reminders )
- {
- if ( rm != null
- && rm.getWhenToSend() != null
- && rm.getWhenToSend() == status
- && (rm.getMessageType() == TrackedEntityInstanceReminder.MESSAGE_TYPE_DHIS_MESSAGE || rm
- .getMessageType() == TrackedEntityInstanceReminder.MESSAGE_TYPE_BOTH) )
- {
- int id = messageService.sendMessage( programStageInstance.getProgramStage().getDisplayName(),
- reminderService.getMessageFromTemplate( rm, programStageInstance, format ), null,
- reminderService.getUsers( rm, programStageInstance.getProgramInstance().getEntityInstance() ),
- null, false, true );
- messageConversations.add( messageService.getMessageConversation( id ) );
- }
- }
-
- return messageConversations;
- }
+ int status, I18nFormat format )
+ {
+ Collection<MessageConversation> messageConversations = new HashSet<>();
+
+ Collection<TrackedEntityInstanceReminder> reminders = programStageInstance.getProgramStage().getReminders();
+ for ( TrackedEntityInstanceReminder rm : reminders )
+ {
+ if ( rm != null
+ && rm.getWhenToSend() != null
+ && rm.getWhenToSend() == status
+ && (rm.getMessageType() == TrackedEntityInstanceReminder.MESSAGE_TYPE_DHIS_MESSAGE || rm
+ .getMessageType() == TrackedEntityInstanceReminder.MESSAGE_TYPE_BOTH) )
+ {
+ int id = messageService.sendMessage( programStageInstance.getProgramStage().getDisplayName(),
+ reminderService.getMessageFromTemplate( rm, programStageInstance, format ), null,
+ reminderService.getUsers( rm, programStageInstance.getProgramInstance().getEntityInstance() ),
+ null, false, true );
+ messageConversations.add( messageService.getMessageConversation( id ) );
+ }
+ }
+
+ return messageConversations;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramExpressionServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramExpressionServiceTest.java 2015-01-27 13:45:40 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramExpressionServiceTest.java 2015-05-18 17:05:23 +0000
@@ -98,14 +98,13 @@
private ProgramStageInstance stageInstance;
private DataElement dataElementA;
-
+
private DataElement dataElementB;
-
+
private ProgramStage stageA;
-
+
private ProgramStage stageB;
-
@Override
public void setUpTest()
{
@@ -138,9 +137,10 @@
TrackedEntityInstance entityInstance = createTrackedEntityInstance( 'A', organisationUnit );
entityInstanceService.addTrackedEntityInstance( entityInstance );
- ProgramInstance programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, new Date(),
- new Date(), organisationUnit );
- stageInstance = programStageInstanceService.getProgramStageInstance( programInstance, stageA );
+ ProgramInstance programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program,
+ new Date(), new Date(), organisationUnit );
+ ProgramStageInstance stageInstance = programStageInstanceService.createProgramStageInstance( programInstance,
+ stageA, new Date(), new Date(), organisationUnit );
TrackedEntityDataValue dataValueA = new TrackedEntityDataValue( stageInstance, dataElementA, "1" );
TrackedEntityDataValue dataValueB = new TrackedEntityDataValue( stageInstance, dataElementB, "2" );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-04-24 13:39:16 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramIndicatorServiceTest.java 2015-05-18 17:05:23 +0000
@@ -75,7 +75,7 @@
@Autowired
private TrackedEntityAttributeService attributeService;
-
+
@Autowired
private TrackedEntityInstanceService entityInstanceService;
@@ -93,19 +93,18 @@
@Autowired
private TrackedEntityDataValueService dataValueService;
-
+
@Autowired
private DataElementService dataElementService;
@Autowired
private ProgramStageDataElementService programStageDataElementService;
-
+
@Autowired
private TrackedEntityAttributeValueService attributeValueService;
@Autowired
private ProgramStageInstanceService programStageInstanceService;
-
@Autowired
private ConstantService constantService;
@@ -113,34 +112,49 @@
private Date incidenDate;
private Date enrollmentDate;
-
+
private ProgramStage psA;
+
private ProgramStage psB;
private Program programA;
+
private Program programB;
private ProgramInstance programInstance;
-
- private DataElement deA;
+
+ private DataElement deA;
+
private DataElement deB;
-
+
private TrackedEntityAttribute atA;
+
private TrackedEntityAttribute atB;
+
private TrackedEntityAttribute atC;
+
private TrackedEntityAttribute atD;
private ProgramIndicator indicatorA;
+
private ProgramIndicator indicatorB;
+
private ProgramIndicator indicatorC;
+
private ProgramIndicator indicatorD;
+
private ProgramIndicator indicatorE;
+
private ProgramIndicator indicatorF;
+
private ProgramIndicator indicatorG;
+
private ProgramIndicator indicatorH;
+
private ProgramIndicator indicatorI;
+
private ProgramIndicator indicatorJ;
-
+
@Override
public void setUpTest()
{
@@ -148,9 +162,9 @@
organisationUnitService.addOrganisationUnit( organisationUnit );
// ---------------------------------------------------------------------
- // Program
+ // Program
// ---------------------------------------------------------------------
-
+
programA = createProgram( 'A', new HashSet<ProgramStage>(), organisationUnit );
programService.addProgram( programA );
@@ -172,17 +186,17 @@
programService.addProgram( programB );
// ---------------------------------------------------------------------
- // Program Stage DE
+ // Program Stage DE
// ---------------------------------------------------------------------
-
+
deA = createDataElement( 'A' );
deA.setDomainType( DataElementDomain.TRACKER );
- deA.setType( DataElement.VALUE_TYPE_NUMBER );
-
+ deA.setType( DataElement.VALUE_TYPE_NUMBER );
+
deB = createDataElement( 'B' );
- deB.setDomainType( DataElementDomain.TRACKER );
- deB.setType( DataElement.VALUE_TYPE_DATE );
-
+ deB.setDomainType( DataElementDomain.TRACKER );
+ deB.setType( DataElement.VALUE_TYPE_DATE );
+
dataElementService.addDataElement( deA );
dataElementService.addDataElement( deB );
@@ -198,67 +212,70 @@
// ---------------------------------------------------------------------
// TrackedEntityInstance & Enrollment
- // ---------------------------------------------------------------------
-
+ // ---------------------------------------------------------------------
+
TrackedEntityInstance entityInstance = createTrackedEntityInstance( 'A', organisationUnit );
entityInstanceService.addTrackedEntityInstance( entityInstance );
incidenDate = DateUtils.getMediumDate( "2014-10-22" );
enrollmentDate = DateUtils.getMediumDate( "2014-12-31" );
- programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, programA, enrollmentDate, incidenDate,
- organisationUnit );
+ programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, programA, enrollmentDate,
+ incidenDate, organisationUnit );
incidenDate = DateUtils.getMediumDate( "2014-10-22" );
enrollmentDate = DateUtils.getMediumDate( "2014-12-31" );
- programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, programA, enrollmentDate, incidenDate,
- organisationUnit );
-
- //TODO enroll twice?
-
+ programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, programA, enrollmentDate,
+ incidenDate, organisationUnit );
+
+ // TODO enroll twice?
+
// ---------------------------------------------------------------------
// TrackedEntityAttribute
- // ---------------------------------------------------------------------
-
+ // ---------------------------------------------------------------------
+
atA = createTrackedEntityAttribute( 'A', TrackedEntityAttribute.TYPE_NUMBER );
atB = createTrackedEntityAttribute( 'B', TrackedEntityAttribute.TYPE_NUMBER );
atC = createTrackedEntityAttribute( 'C', TrackedEntityAttribute.TYPE_DATE );
atD = createTrackedEntityAttribute( 'D', TrackedEntityAttribute.TYPE_DATE );
-
+
attributeService.addTrackedEntityAttribute( atA );
attributeService.addTrackedEntityAttribute( atB );
attributeService.addTrackedEntityAttribute( atC );
attributeService.addTrackedEntityAttribute( atD );
-
-
+
TrackedEntityAttributeValue attributeValueA = new TrackedEntityAttributeValue( atA, entityInstance, "1" );
TrackedEntityAttributeValue attributeValueB = new TrackedEntityAttributeValue( atB, entityInstance, "2" );
- TrackedEntityAttributeValue attributeValueC = new TrackedEntityAttributeValue( atC, entityInstance, "2015-01-01" );
- TrackedEntityAttributeValue attributeValueD = new TrackedEntityAttributeValue( atD, entityInstance, "2015-01-03" );
+ TrackedEntityAttributeValue attributeValueC = new TrackedEntityAttributeValue( atC, entityInstance,
+ "2015-01-01" );
+ TrackedEntityAttributeValue attributeValueD = new TrackedEntityAttributeValue( atD, entityInstance,
+ "2015-01-03" );
attributeValueService.addTrackedEntityAttributeValue( attributeValueA );
attributeValueService.addTrackedEntityAttributeValue( attributeValueB );
attributeValueService.addTrackedEntityAttributeValue( attributeValueC );
attributeValueService.addTrackedEntityAttributeValue( attributeValueD );
-
+
// ---------------------------------------------------------------------
// TrackedEntityDataValue
- // ---------------------------------------------------------------------
-
- ProgramStageInstance stageInstanceA = programStageInstanceService.getProgramStageInstance( programInstance, psA );
- ProgramStageInstance stageInstanceB = programStageInstanceService.getProgramStageInstance( programInstance, psB );
+ // ---------------------------------------------------------------------
+
+ ProgramStageInstance stageInstanceA = programStageInstanceService.createProgramStageInstance( programInstance,
+ psA, enrollmentDate, incidenDate, organisationUnit );
+ ProgramStageInstance stageInstanceB = programStageInstanceService.createProgramStageInstance( programInstance,
+ psB, enrollmentDate, incidenDate, organisationUnit );
Set<ProgramStageInstance> programStageInstances = new HashSet<>();
programStageInstances.add( stageInstanceA );
programStageInstances.add( stageInstanceB );
- programInstance.setProgramStageInstances( programStageInstances );
-
+ programInstance.setProgramStageInstances( programStageInstances );
+
TrackedEntityDataValue dataValueA = new TrackedEntityDataValue( stageInstanceA, deA, "3" );
TrackedEntityDataValue dataValueB = new TrackedEntityDataValue( stageInstanceA, deB, "2015-03-01" );
TrackedEntityDataValue dataValueC = new TrackedEntityDataValue( stageInstanceB, deA, "5" );
- TrackedEntityDataValue dataValueD = new TrackedEntityDataValue( stageInstanceB, deB, "2015-03-15" );
-
+ TrackedEntityDataValue dataValueD = new TrackedEntityDataValue( stageInstanceB, deB, "2015-03-15" );
+
dataValueService.saveTrackedEntityDataValue( dataValueA );
dataValueService.saveTrackedEntityDataValue( dataValueB );
dataValueService.saveTrackedEntityDataValue( dataValueC );
@@ -266,74 +283,74 @@
// ---------------------------------------------------------------------
// Constant
- // ---------------------------------------------------------------------
-
+ // ---------------------------------------------------------------------
+
Constant constantA = createConstant( 'A', 7.0 );
constantService.saveConstant( constantA );
-
+
// ---------------------------------------------------------------------
// ProgramIndicator
- // ---------------------------------------------------------------------
-
- indicatorA = new ProgramIndicator( "IndicatorA", "IndicatorDesA", programA, VALUE_TYPE_INT, "( " + KEY_PROGRAM_VARIABLE + "{"
- + ProgramIndicator.ENROLLMENT_DATE + "} - " + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.INCIDENT_DATE + "} ) / "
- + ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}" );
+ // ---------------------------------------------------------------------
+
+ indicatorA = new ProgramIndicator( "IndicatorA", "IndicatorDesA", programA, VALUE_TYPE_INT, "( "
+ + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.ENROLLMENT_DATE + "} - " + KEY_PROGRAM_VARIABLE + "{"
+ + ProgramIndicator.INCIDENT_DATE + "} ) / " + ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid()
+ + "}" );
indicatorA.setUid( "UID-DATE" );
indicatorA.setShortName( "DATE" );
- indicatorB = new ProgramIndicator( "IndicatorB", "IndicatorDesB", programA, ProgramIndicator.VALUE_TYPE_DATE, "70" );
+ indicatorB = new ProgramIndicator( "IndicatorB", "IndicatorDesB", programA, ProgramIndicator.VALUE_TYPE_DATE,
+ "70" );
indicatorB.setRootDate( ProgramIndicator.INCIDENT_DATE );
indicatorB.setUid( "UID-INT" );
indicatorB.setShortName( "INT" );
- indicatorC = new ProgramIndicator( "IndicatorC", "IndicatorDesB", programB, ProgramIndicator.VALUE_TYPE_INT, "0" );
+ indicatorC = new ProgramIndicator( "IndicatorC", "IndicatorDesB", programB, ProgramIndicator.VALUE_TYPE_INT,
+ "0" );
indicatorC.setUid( "UID-C" );
indicatorC.setShortName( "C" );
-
- indicatorD = new ProgramIndicator( "IndicatorD", "IndicatorDesD", programB, ProgramIndicator.VALUE_TYPE_INT, "0 + A + 4 + " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{"
- + ProgramIndicator.INCIDENT_DATE + "}" );
+
+ indicatorD = new ProgramIndicator( "IndicatorD", "IndicatorDesD", programB, ProgramIndicator.VALUE_TYPE_INT,
+ "0 + A + 4 + " + ProgramIndicator.KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.INCIDENT_DATE + "}" );
indicatorD.setUid( "UID-D" );
indicatorD.setShortName( "D" );
-
- String expressionE = KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "} + " +
- KEY_DATAELEMENT + "{" + psB.getUid() + "." + deA.getUid() + "} - " +
- KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " + KEY_ATTRIBUTE + "{" + atB.getUid() + "}";
-
+
+ String expressionE = KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "} + " + KEY_DATAELEMENT + "{"
+ + psB.getUid() + "." + deA.getUid() + "} - " + KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " + KEY_ATTRIBUTE
+ + "{" + atB.getUid() + "}";
+
indicatorE = new ProgramIndicator( "IndicatorE", "IndicatorDesE", programB, VALUE_TYPE_INT, expressionE );
-
- String expressionF = "(" + KEY_DATAELEMENT + "{" + psB.getUid() + "." + deB.getUid() + "} - " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
- KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " + KEY_ATTRIBUTE + "{" + atB.getUid() + "}";
-
+
+ String expressionF = "(" + KEY_DATAELEMENT + "{" + psB.getUid() + "." + deB.getUid() + "} - " + KEY_DATAELEMENT
+ + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " + KEY_ATTRIBUTE + "{" + atA.getUid() + "} + "
+ + KEY_ATTRIBUTE + "{" + atB.getUid() + "}";
+
indicatorF = new ProgramIndicator( "IndicatorF", "IndicatorDesF", programB, VALUE_TYPE_INT, expressionF );
-
- String expressionG = "(" + KEY_DATAELEMENT + "{" + psB.getUid() + "." + deB.getUid() + "} - " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
- KEY_ATTRIBUTE + "{" + atA.getUid() + "} + " +
- KEY_ATTRIBUTE + "{" + atB.getUid() + "} * " +
- KEY_CONSTANT + "{" + constantA.getUid() + "}";
-
+
+ String expressionG = "(" + KEY_DATAELEMENT + "{" + psB.getUid() + "." + deB.getUid() + "} - " + KEY_DATAELEMENT
+ + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " + KEY_ATTRIBUTE + "{" + atA.getUid() + "} + "
+ + KEY_ATTRIBUTE + "{" + atB.getUid() + "} * " + KEY_CONSTANT + "{" + constantA.getUid() + "}";
+
indicatorG = new ProgramIndicator( "IndicatorG", "IndicatorDesG", programB, VALUE_TYPE_INT, expressionG );
-
- String expressionH = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "}";
-
- indicatorH = new ProgramIndicator( "IndicatorH", "IndicatorDesH", programB, VALUE_TYPE_INT, expressionH );
-
- String expressionI = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "}";
-
- indicatorI = new ProgramIndicator( "IndicatorI", "IndicatorDesI", programB, VALUE_TYPE_DATE, expressionI );
- indicatorI.setRootDate( ProgramIndicator.INCIDENT_DATE );
-
- String expressionJ = "(" + KEY_ATTRIBUTE + "{" + atC.getUid() + "} - " +
- KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.ENROLLMENT_DATE + "} ) + " +
- KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid() + "} * " +
- ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}";
-
- indicatorJ = new ProgramIndicator( "IndicatorJ", "IndicatorDesJ", programB, VALUE_TYPE_DATE, expressionJ );
+
+ String expressionH = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - "
+ + KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " + KEY_DATAELEMENT + "{"
+ + psA.getUid() + "." + deA.getUid() + "}";
+
+ indicatorH = new ProgramIndicator( "IndicatorH", "IndicatorDesH", programB, VALUE_TYPE_INT, expressionH );
+
+ String expressionI = "(" + KEY_PROGRAM_VARIABLE + "{" + ProgramIndicator.CURRENT_DATE + "} - "
+ + KEY_DATAELEMENT + "{" + psA.getUid() + "." + deB.getUid() + "} ) + " + KEY_DATAELEMENT + "{"
+ + psA.getUid() + "." + deA.getUid() + "}";
+
+ indicatorI = new ProgramIndicator( "IndicatorI", "IndicatorDesI", programB, VALUE_TYPE_DATE, expressionI );
+ indicatorI.setRootDate( ProgramIndicator.INCIDENT_DATE );
+
+ String expressionJ = "(" + KEY_ATTRIBUTE + "{" + atC.getUid() + "} - " + KEY_PROGRAM_VARIABLE + "{"
+ + ProgramIndicator.ENROLLMENT_DATE + "} ) + " + KEY_DATAELEMENT + "{" + psA.getUid() + "." + deA.getUid()
+ + "} * " + ProgramIndicator.KEY_CONSTANT + "{" + constantA.getUid() + "}";
+
+ indicatorJ = new ProgramIndicator( "IndicatorJ", "IndicatorDesJ", programB, VALUE_TYPE_DATE, expressionJ );
indicatorJ.setRootDate( ProgramIndicator.INCIDENT_DATE );
}
@@ -440,24 +457,25 @@
@Test
public void testGetProgramStageDataElementsInExpression()
{
- Set<ProgramStageDataElement> elements = programIndicatorService.getProgramStageDataElementsInExpression( indicatorE );
-
+ Set<ProgramStageDataElement> elements = programIndicatorService
+ .getProgramStageDataElementsInExpression( indicatorE );
+
assertEquals( 2, elements.size() );
-
+
assertTrue( elements.contains( new ProgramStageDataElement( psA, deA ) ) );
assertTrue( elements.contains( new ProgramStageDataElement( psB, deA ) ) );
}
-
+
@Test
public void testGetAttributesInExpression()
{
Set<TrackedEntityAttribute> attributes = programIndicatorService.getAttributesInExpression( indicatorE );
-
+
assertEquals( 2, attributes.size() );
assertTrue( attributes.contains( atA ) );
assertTrue( attributes.contains( atB ) );
}
-
+
@Test
public void testGetProgramIndicatorValue()
{
@@ -473,12 +491,12 @@
String valueINT = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorA );
assertEquals( "10.0", valueINT );
- String valueDATE = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorB );
+ String valueDATE = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorB );
assertEquals( DateUtils.getMediumDateString( enrollmentDate ), valueDATE );
-
+
String valueE = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorE );
- assertEquals( "9.0", valueE );
-
+ assertEquals( "9.0", valueE );
+
String valueF = programIndicatorService.getProgramIndicatorValue( programInstance, indicatorF );
assertEquals( "17.0", valueF );
@@ -497,7 +515,7 @@
assertEquals( "10.0", indicatorMap.get( "IndicatorA" ) );
assertEquals( DateUtils.getMediumDateString( enrollmentDate ), indicatorMap.get( "IndicatorB" ) );
}
-
+
@Test
public void testGetExpressionDescription()
{
@@ -505,13 +523,13 @@
programIndicatorService.addProgramIndicator( indicatorA );
String description = programIndicatorService.getExpressionDescription( indicatorB.getExpression() );
- assertEquals( "70", description);
-
+ assertEquals( "70", description );
+
description = programIndicatorService.getExpressionDescription( indicatorA.getExpression() );
- assertEquals( "( Enrollment date - Incident date ) / ConstantA", description);
-
+ assertEquals( "( Enrollment date - Incident date ) / ConstantA", description );
+
}
-
+
@Test
public void testExpressionIsValid()
{
@@ -521,6 +539,7 @@
assertEquals( ProgramIndicator.VALID, programIndicatorService.expressionIsValid( indicatorB.getExpression() ) );
assertEquals( ProgramIndicator.VALID, programIndicatorService.expressionIsValid( indicatorA.getExpression() ) );
- assertEquals( ProgramIndicator.EXPRESSION_NOT_WELL_FORMED, programIndicatorService.expressionIsValid( indicatorD.getExpression() ) );
- }
+ assertEquals( ProgramIndicator.EXPRESSION_NOT_WELL_FORMED,
+ programIndicatorService.expressionIsValid( indicatorD.getExpression() ) );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramValidationServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramValidationServiceTest.java 2015-02-03 13:14:56 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/program/ProgramValidationServiceTest.java 2015-05-18 17:05:23 +0000
@@ -147,11 +147,13 @@
TrackedEntityInstance entityInstance = createTrackedEntityInstance( 'A', organisationUnit );
entityInstanceService.addTrackedEntityInstance( entityInstance );
- ProgramInstance programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, new Date(),
- new Date(), organisationUnit );
+ ProgramInstance programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program,
+ new Date(), new Date(), organisationUnit );
- stageInstanceA = programStageInstanceService.getProgramStageInstance( programInstance, stageA );
- stageInstanceB = programStageInstanceService.getProgramStageInstance( programInstance, stageB );
+ stageInstanceA = programStageInstanceService.createProgramStageInstance( programInstance, stageA, new Date(),
+ new Date(), organisationUnit );
+ stageInstanceB = programStageInstanceService.createProgramStageInstance( programInstance, stageB, new Date(),
+ new Date(), organisationUnit );
Set<ProgramStageInstance> programStageInstances = new HashSet<>();
programStageInstances.add( stageInstanceA );
@@ -169,18 +171,18 @@
dataValueService.saveTrackedEntityDataValue( dataValueD );
ProgramExpression programExpressionA = new ProgramExpression( "["
- + ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramExpression.SEPARATOR_OBJECT + stageA.getUid() + "."
- + dataElementA.getUid() + "]", "A" );
+ + ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramExpression.SEPARATOR_OBJECT + stageA.getUid()
+ + "." + dataElementA.getUid() + "]", "A" );
ProgramExpression programExpressionB = new ProgramExpression( "["
- + ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramExpression.SEPARATOR_OBJECT + stageA.getUid() + "."
- + dataElementB.getUid() + "]", "B" );
+ + ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramExpression.SEPARATOR_OBJECT + stageA.getUid()
+ + "." + dataElementB.getUid() + "]", "B" );
ProgramExpression programExpressionC = new ProgramExpression( "["
- + ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramExpression.SEPARATOR_OBJECT + stageB.getUid() + "."
- + dataElementA.getUid() + "]", "C" );
+ + ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramExpression.SEPARATOR_OBJECT + stageB.getUid()
+ + "." + dataElementA.getUid() + "]", "C" );
ProgramExpression programExpressionD = new ProgramExpression( "["
- + ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramExpression.SEPARATOR_OBJECT + stageB.getUid() + "."
- + dataElementB.getUid() + "]", "D" );
+ + ProgramExpression.OBJECT_PROGRAM_STAGE_DATAELEMENT + ProgramExpression.SEPARATOR_OBJECT + stageB.getUid()
+ + "." + dataElementB.getUid() + "]", "D" );
validationA = new ProgramValidation( "A", programExpressionA, programExpressionB, program );
validationA.setOperator( Operator.valueOf( "equal_to" ) );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceReminderServiceTest.java 2015-05-18 17:05:23 +0000
@@ -97,6 +97,8 @@
private ProgramInstance programInstance;
+ private ProgramStageInstance programStageInstance;
+
private TrackedEntityInstanceReminder reminderA;
private TrackedEntityInstanceReminder reminderB;
@@ -173,6 +175,9 @@
programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, new Date(),
new Date(), organisationUnit );
+
+ programStageInstance = programStageInstanceService.createProgramStageInstance( programInstance, stageA,
+ new Date(), new Date(), organisationUnit );
}
@Test
@@ -185,8 +190,6 @@
@Test
public void testGetMessageFromTemplateByProgramStage()
{
- ProgramStageInstance programStageInstance = programStageInstanceService.getProgramStageInstance(
- programInstance, stageA );
String message = reminderService.getMessageFromTemplate( reminderA, programStageInstance, mockFormat );
assertEquals( "Test program message template", message );
}
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueServiceTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueServiceTest.java 2015-05-18 17:05:23 +0000
@@ -143,7 +143,7 @@
programStages.add( stageB );
program.setProgramStages( programStages );
programService.updateProgram( program );
-
+
DateTime yesterDate = DateTime.now();
yesterDate.withTimeAtStartOfDay();
yesterDate.minusDays( 1 );
@@ -153,12 +153,14 @@
tomorrowDate.withTimeAtStartOfDay();
tomorrowDate.plusDays( 1 );
tomorrow = tomorrowDate.toDate();
-
- programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, yesterday, yesterday,
- organisationUnit );
-
- stageInstanceA = programStageInstanceService.getProgramStageInstance( programInstance, stageA );
- stageInstanceB = programStageInstanceService.getProgramStageInstance( programInstance, stageB );
+
+ programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, yesterday,
+ yesterday, organisationUnit );
+
+ stageInstanceA = programStageInstanceService.createProgramStageInstance( programInstance, stageA, yesterday,
+ yesterday, organisationUnit );
+ stageInstanceB = programStageInstanceService.createProgramStageInstance( programInstance, stageB, yesterday,
+ yesterday, organisationUnit );
dataValueA = new TrackedEntityDataValue( stageInstanceA, dataElementA, "A" );
dataValueB = new TrackedEntityDataValue( stageInstanceA, dataElementB, "B" );
@@ -259,7 +261,8 @@
programStageInstances.add( stageInstanceA );
programStageInstances.add( stageInstanceB );
- Collection<TrackedEntityDataValue> dataValues = dataValueService.getTrackedEntityDataValues( programStageInstances );
+ Collection<TrackedEntityDataValue> dataValues = dataValueService
+ .getTrackedEntityDataValues( programStageInstances );
assertEquals( 4, dataValues.size() );
assertTrue( dataValues.contains( dataValueA ) );
assertTrue( dataValues.contains( dataValueB ) );
@@ -298,8 +301,8 @@
dataElements.add( dataElementA );
dataElements.add( dataElementB );
- Collection<TrackedEntityDataValue> dataValues = dataValueService.getTrackedEntityDataValues( entityInstance, dataElements,
- yesterday, tomorrow );
+ Collection<TrackedEntityDataValue> dataValues = dataValueService.getTrackedEntityDataValues( entityInstance,
+ dataElements, yesterday, tomorrow );
dataValues = dataValueService.getTrackedEntityDataValues( dataElementB );
assertEquals( 2, dataValues.size() );
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueStoreTest.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueStoreTest.java 2015-05-18 17:05:23 +0000
@@ -144,7 +144,7 @@
program.setProgramStages( programStages );
programService.updateProgram( program );
- DateTime yesterDate = DateTime.now();
+ DateTime yesterDate = DateTime.now();
yesterDate.withTimeAtStartOfDay();
yesterDate.minusDays( 1 );
yesterday = yesterDate.toDate();
@@ -153,13 +153,14 @@
tomorrowDate.withTimeAtStartOfDay();
tomorrowDate.plusDays( 1 );
tomorrow = tomorrowDate.toDate();
-
-
- programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, yesterday, yesterday,
- organisationUnit );
-
- stageInstanceA = programStageInstanceService.getProgramStageInstance( programInstance, stageA );
- stageInstanceB = programStageInstanceService.getProgramStageInstance( programInstance, stageB );
+
+ programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, yesterday,
+ yesterday, organisationUnit );
+
+ stageInstanceA = programStageInstanceService.createProgramStageInstance( programInstance, stageA, yesterday,
+ yesterday, organisationUnit );
+ stageInstanceB = programStageInstanceService.createProgramStageInstance( programInstance, stageB, yesterday,
+ yesterday, organisationUnit );
dataValueA = new TrackedEntityDataValue( stageInstanceA, dataElementA, "A" );
dataValueB = new TrackedEntityDataValue( stageInstanceA, dataElementB, "B" );
=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-04-28 20:52:00 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java 2015-05-18 17:05:23 +0000
@@ -86,6 +86,7 @@
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.program.ProgramTrackedEntityAttribute;
import org.hisp.dhis.programrule.ProgramRule;
import org.hisp.dhis.programrule.ProgramRuleAction;
@@ -1263,6 +1264,12 @@
return entityInstance;
}
+
+ public static ProgramStageInstance createProgramStageInstance()
+ {
+ ProgramStageInstance programStageInstance = new ProgramStageInstance();
+ return programStageInstance;
+ }
public static TrackedEntityInstance createTrackedEntityInstance( char uniqueChar, OrganisationUnit organisationUnit,
TrackedEntityAttribute attribute )
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-05-08 18:38:58 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-05-18 17:05:23 +0000
@@ -84,6 +84,11 @@
$scope.stagesById[stage.id] = stage;
$scope.eventsByStage[stage.id] = [];
});
+
+ $scope.programStages = orderByFilter($scope.programStages, '-sortOrder').reverse();
+ if(!$scope.currentStage){
+ $scope.currentStage = $scope.programStages[0];
+ }
$scope.getEvents();
});
}
@@ -123,15 +128,15 @@
$scope.eventsByStage[dhis2Event.programStage].push(dhis2Event);
if($scope.currentStage && $scope.currentStage.id === dhis2Event.programStage){
- $scope.currentEvent = dhis2Event;
- $scope.showDataEntry($scope.currentEvent, true);
+ $scope.currentEvent = dhis2Event;
}
}
}
});
- }
-
- sortEventsByStage(null);
+
+ sortEventsByStage(null);
+ $scope.showDataEntry($scope.currentEvent, true);
+ }
};
var setEventEditing = function(dhis2Event, stage){
@@ -255,7 +260,10 @@
$scope.customForm = CustomFormService.getForProgramStage($scope.currentStage, $scope.prStDes);
$scope.displayCustomForm = $scope.customForm ? true:false;
- $scope.currentEventOriginal = angular.copy($scope.currentEvent);
+ $scope.currentEventOriginal = angular.copy($scope.currentEvent);
+
+ var period = {event: $scope.currentEvent.event, stage: $scope.currentEvent.programStage, name: $scope.currentEvent.sortingDate};
+ $scope.currentPeriod[$scope.currentEvent.programStage] = period;
};
var processEvent = function(event, stage){
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2015-04-21 07:42:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html 2015-05-18 17:05:23 +0000
@@ -45,7 +45,7 @@
</thead>
<tbody>
<tr>
- <td ng-repeat="stage in programStages| orderBy:'sortOrder':reverse">
+ <td ng-repeat="stage in programStages">
<div class="inline-block" ng-repeat="dhis2Event in eventsByStage[stage.id]">
<div class="event-container"
ng-class="getEventStyle(dhis2Event)"
@@ -76,7 +76,8 @@
<div ng-if="currentEvent">
<!-- event dates/scheduling begin -->
- <div class="row" ng-if="!currentStage.periodType">
+ <!--<div class="row" ng-if="!currentStage.periodType">-->
+ <div class="row">
<div class="col-md-6">
{{currentEvent.reportDateDescription}}
<input type="text"
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js 2015-04-27 08:24:30 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/overdue-events-controller.js 2015-05-18 17:05:23 +0000
@@ -5,7 +5,6 @@
$modal,
$location,
$translate,
- $filter,
DateUtils,
Paginator,
EventReportService,
@@ -100,7 +99,6 @@
$scope.overdueEvents = [];
EventReportService.getEventReport($scope.selectedOrgUnit.id, $scope.selectedOuMode, $scope.selectedProgram.id, null, null, 'ACTIVE','OVERDUE', $scope.pager).then(function(data){
-
if( data.pager ){
$scope.pager = data.pager;
$scope.pager.toolBarDisplay = 5;
@@ -121,12 +119,11 @@
overdueEvent.dueDate = DateUtils.formatFromApiToUser(row.dueDate);
overdueEvent.event = row.event;
overdueEvent.eventName = $scope.programStages[row.programStage].name;
- overdueEvent.orgUnitName = row.eventOrgUnitName;
+ overdueEvent.orgUnitName = row.orgUnitName;
overdueEvent.followup = row.followup;
overdueEvent.program = row.program;
overdueEvent.programStage = row.programStage;
overdueEvent.trackedEntityInstance = row.trackedEntityInstance;
- overdueEvent.created = DateUtils.formatFromApiToUser(row.registrationDate);;
$scope.overdueEvents.push(overdueEvent);
});
@@ -139,7 +136,6 @@
$scope.reportFinished = true;
$scope.reportStarted = false;
-
});
}
};
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2015-04-22 10:55:47 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary-controller.js 2015-05-18 17:05:23 +0000
@@ -12,6 +12,7 @@
ProgramStageFactory,
CurrentSelection,
OptionSetService,
+ EventReportService,
DHIS2EventFactory) {
$scope.today = DateUtils.getToday();
@@ -90,136 +91,40 @@
$scope.gridColumns = grid.columns;
});
- //fetch TEIs for the selected program and orgunit/mode
- TEIService.search($scope.selectedOrgUnit.id,
- $scope.selectedOuMode.name,
- null,
- 'program=' + $scope.selectedProgram.id,
- null,
- $scope.pager,
- false).then(function(data){
-
- //process tei grid
- var teis = TEIGridService.format(data,true, $scope.optionSets);
+ EventReportService.getEventReport($scope.selectedOrgUnit.id,
+ $scope.selectedOuMode.name,
+ $scope.selectedProgram.id,
+ DateUtils.formatFromUserToApi($scope.report.startDate),
+ DateUtils.formatFromUserToApi($scope.report.endDate),
+ null,
+ null,
+ $scope.pager).then(function(data){
+ $scope.dhis2Events = [];
$scope.teiList = [];
+ angular.forEach(data.eventRows, function(ev){
+ if(ev.trackedEntityInstance){
+ ev.name = $scope.stagesById[ev.programStage].name;
+ ev.programName = $scope.selectedProgram.name;
+ ev.statusColor = EventUtils.getEventStatusColor(ev);
+ ev.eventDate = DateUtils.formatFromApiToUser(ev.eventDate);
- DHIS2EventFactory.getByOrgUnitAndProgram($scope.selectedOrgUnit.id,
- $scope.selectedOuMode.name,
- $scope.selectedProgram.id,
- DateUtils.formatFromUserToApi(report.startDate),
- DateUtils.formatFromUserToApi(report.endDate)).then(function(eventList){
- $scope.dhis2Events = [];
- angular.forEach(eventList, function(ev){
- if(ev.trackedEntityInstance){
- ev.name = $scope.stagesById[ev.programStage].name;
- ev.programName = $scope.selectedProgram.name;
- ev.statusColor = EventUtils.getEventStatusColor(ev);
- ev.eventDate = DateUtils.formatFromApiToUser(ev.eventDate);
-
- angular.forEach(ev.dataValues, function(dv){
- ev[dv.dataElement] = dv.value;
- });
-
- if($scope.dhis2Events[ev.trackedEntityInstance]){
- if(teis.rows[ev.trackedEntityInstance]){
- $scope.teiList.push(teis.rows[ev.trackedEntityInstance]);
- delete teis.rows[ev.trackedEntityInstance];
- }
- $scope.dhis2Events[ev.trackedEntityInstance].push(ev);
- }
- else{
- if(teis.rows[ev.trackedEntityInstance]){
- $scope.teiList.push(teis.rows[ev.trackedEntityInstance]);
- delete teis.rows[ev.trackedEntityInstance];
- }
- $scope.dhis2Events[ev.trackedEntityInstance] = [ev];
- }
-
+ angular.forEach(ev.dataValues, function(dv){
+ ev[dv.dataElement] = dv.value;
$scope.stagesById[ev.programStage].hasData = true;
-
+ });
+
+ angular.forEach(ev.attributes, function(att){
+ ev[att.attribute] = att.value;
+ });
+
+ if($scope.teiList.indexOf(ev.trackedEntityInstance) === -1){
+ $scope.teiList.push( ev.trackedEntityInstance );
}
- });
- $scope.reportStarted = false;
- $scope.dataReady = true;
- });
- });
- };
-
- $scope.showEventDetails = function(dhis2Event, selectedTei){
-
- var modalInstance = $modal.open({
- templateUrl: 'components/report/event-details.html',
- controller: 'EventDetailsController',
- resolve: {
- dhis2Event: function () {
- return dhis2Event;
- },
- gridColumns: function(){
- return $scope.gridColumns;
- },
- selectedTei: function(){
- return selectedTei;
- },
- entityName: function(){
- return $scope.selectedProgram.trackedEntity.name;
- },
- reportMode: function(){
- return 'PROGRAM';
+ $scope.dhis2Events.push(ev);
}
- }
- });
-
- modalInstance.result.then({
+ });
+ $scope.reportStarted = false;
+ $scope.dataReady = true;
});
};
-})
-
-//Controller for event details
-.controller('EventDetailsController',
- function($scope,
- $modalInstance,
- orderByFilter,
- DateUtils,
- ProgramStageFactory,
- dhis2Event,
- selectedTei,
- gridColumns,
- entityName,
- reportMode){
-
- $scope.selectedTei = selectedTei;
- $scope.gridColumns = gridColumns;
- $scope.entityName = entityName;
- $scope.reportMode = reportMode;
- $scope.currentEvent = dhis2Event;
- $scope.currentEvent.providedElsewhere = [];
-
- if(!angular.isUndefined( $scope.currentEvent.notes)){
- $scope.currentEvent.notes = orderByFilter($scope.currentEvent.notes, '-storedDate');
- angular.forEach($scope.currentEvent.notes, function(note){
- note.storedDate = DateUtils.formatToHrsMins(note.storedDate);
- });
- }
-
- ProgramStageFactory.get($scope.currentEvent.programStage).then(function(stage){
- $scope.currentStage = stage;
-
- $scope.allowProvidedElsewhereExists = false;
- angular.forEach($scope.currentStage.programStageDataElements, function(prStDe){
- $scope.currentStage.programStageDataElements[prStDe.dataElement.id] = prStDe.dataElement;
- if(prStDe.allowProvidedElsewhere){
- $scope.allowProvidedElsewhereExists = true;
- $scope.currentEvent.providedElsewhere[prStDe.dataElement.id] = '';
- }
- });
- angular.forEach($scope.currentEvent.dataValues, function(dataValue){
- if(dataValue.dataElement){
- $scope.currentEvent[dataValue.dataElement] = dataValue;
- }
- });
- });
-
- $scope.close = function () {
- $modalInstance.close();
- };
});
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html 2015-04-22 10:55:47 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/report/program-summary.html 2015-05-18 17:05:23 +0000
@@ -60,11 +60,12 @@
</th>
</tr>
</thead>
- <tbody ng-repeat="tei in teiList" ng-if="dhis2Events[tei.id].length > 0">
- <tr ng-repeat="ev in dhis2Events[tei.id] | filter: {programStage: stage.id} | orderBy: 'eventDate'">
- <td rowspan="{{dhis2Events[tei.id].length}}" ng-if="$index === 0">
+ <tbody ng-repeat="tei in teiList">
+ <tr ng-repeat="ev in dhis2Events | filter: {programStage: stage.id, trackedEntityInstance: tei} | orderBy: 'eventDate'">
+ <td rowspan="{{(dhis2Events | filter: {programStage: stage.id, trackedEntityInstance: tei}).length}}"
+ ng-if="$index === 0">
<span ng-repeat="gridColumn in gridColumns" ng-if="gridColumn.displayInListNoProgram">
- <span class="bold">{{gridColumn.name}}:</span> {{tei[gridColumn.id]}}<br>
+ <span class="bold">{{gridColumn.name}}:</span> {{ev[gridColumn.id]}}<br>
</span>
</td>
<td>
@@ -78,24 +79,6 @@
</td>
</tr>
</tbody>
- <tbody ng-repeat="tei in teiList" ng-if="!dhis2Events[tei.id]">
- <tr>
- <td>
- <span ng-repeat="gridColumn in gridColumns" ng-if="gridColumn.displayInListNoProgram">
- <span class="bold">{{gridColumn.name}}:</span> {{tei[gridColumn.id]}}<br>
- </span>
- </td>
- <td>
- {{'no_data' | translate}}
- </td>
- <td>
- {{'no_data' | translate}}
- </td>
- <td ng-if="prStDe.displayInReports" ng-repeat="prStDe in stage.programStageDataElements">
- {{'no_data' | translate}}
- </td>
- </tr>
- </tbody>
</table>
</div>
<div ng-if="!stage.hasData">
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-05-04 07:52:12 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-05-18 17:05:23 +0000
@@ -64,6 +64,29 @@
return {year: moment(dateValue, calendarSetting.momentFormat).year(), month: moment(dateValue, calendarSetting.momentFormat).month(), week: moment(dateValue, calendarSetting.momentFormat).week(), day: moment(dateValue, calendarSetting.momentFormat).day()};
};
+ function processPeriodsForEvent(periods,event){
+ //console.log('the event: ', event.sortingDate, ' - ', periods);
+ var index = -1;
+ var occupied = null;
+ for(var i=0; i<periods.length && index === -1; i++){
+ //console.log(event.sortingDate, ' - ', periods[i].startDate, ' - ', periods[i].endDate);
+ if(moment(periods[i].endDate).isSame(event.sortingDate) ||
+ moment(periods[i].startDate).isSame(event.sortingDate) ||
+ moment(periods[i].endDate).isAfter(event.sortingDate) && moment(event.sortingDate).isAfter(periods[i].endDate)){
+ index = i;
+ occupied = angular.copy(periods[i]);
+ //console.log('Found it: ', event.sortingDate, ' - ', periods[i].startDate, ' - ', periods[i].endDate);
+ }
+ }
+
+ if(index !== -1){
+ periods.splice(index,1);
+ }
+
+ //console.log('the returned period: ', periods);
+ return {available: periods, occupied: occupied};
+ };
+
this.getPeriods = function(events, stage, enrollment){
if(!stage){
@@ -88,7 +111,7 @@
else{
var startDate = DateUtils.format( moment(referenceDate, calendarSetting.momentFormat).add(offset, 'days') );
- var periodOffset = splitDate(DateUtils.getToday()).year - splitDate(startDate).year;
+ var periodOffset = splitDate(startDate).year - splitDate(DateUtils.getToday()).year;
var eventDateOffSet = moment(referenceDate, calendarSetting.momentFormat).add('d', offset)._d;
eventDateOffSet = $filter('date')(eventDateOffSet, calendarSetting.keyDateFormat);
@@ -99,18 +122,27 @@
p.endDate = DateUtils.formatFromApiToUser(p.endDate);
p.startDate = DateUtils.formatFromApiToUser(p.startDate);
+ /*if(moment(p.endDate).isAfter(eventDateOffSet)){
+ availablePeriods[p.endDate] = p;
+ }*/
if(moment(p.endDate).isAfter(eventDateOffSet)){
- availablePeriods[p.endDate] = p;
- }
+ //availablePeriods[p.endDate] = p;
+ availablePeriods.push( p );
+ }
});
//get occupied periods
angular.forEach(events, function(event){
- var p = availablePeriods[event.sortingDate];
+ var ps = processPeriodsForEvent(availablePeriods, event);
+ availablePeriods = ps.available;
+ if(ps.occupied){
+ occupiedPeriods.push(ps.occupied);
+ }
+ /*var p = availablePeriods[event.sortingDate];
if(p){
occupiedPeriods.push({event: event.event, name: p.name, stage: stage.id, eventDate: event.sortingDate});
delete availablePeriods[event.sortingDate];
- }
+ }*/
});
}
return {occupiedPeriods: occupiedPeriods, availablePeriods: availablePeriods};
@@ -991,18 +1023,33 @@
})
/* factory for handling event reports */
-.factory('EventReportService', function($http, $q) {
+.factory('EventReportService', function($http) {
return {
- getEventReport: function(orgUnit, ouMode, program, startDate, endDate, programStatus, eventStatus, pager){
- var pgSize = pager ? pager.pageSize : 50;
- var pg = pager ? pager.page : 1;
- pgSize = pgSize > 1 ? pgSize : 1;
- pg = pg > 1 ? pg : 1;
- var url = '../api/events/eventRows.json?' + 'orgUnit=' + orgUnit + '&ouMode='+ ouMode + '&program=' + program + '&programStatus=' + programStatus + '&eventStatus='+ eventStatus;
+ getEventReport: function(orgUnit, ouMode, program, startDate, endDate, programStatus, eventStatus, pager){
+
+ var url = '../api/events/eventRows.json?' + 'orgUnit=' + orgUnit + '&ouMode='+ ouMode + '&program=' + program;
+
+ if( programStatus ){
+ url = url + '&programStatus=' + programStatus;
+ }
+
+ if( eventStatus ){
+ url = url + '&status=' + eventStatus;
+ }
+
if(startDate && endDate){
url = url + '&startDate=' + startDate + '&endDate=' + endDate ;
}
+
+ if( pager ){
+ var pgSize = pager ? pager.pageSize : 50;
+ var pg = pager ? pager.page : 1;
+ pgSize = pgSize > 1 ? pgSize : 1;
+ pg = pg > 1 ? pg : 1;
+ url = url + '&pageSize=' + pgSize + '&page=' + pg + '&totalPages=true';
+ }
+
var promise = $http.get( url ).then(function(response){
return response.data;
});
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveProgramEnrollmentAction.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/SaveProgramEnrollmentAction.java 2015-05-18 17:05:23 +0000
@@ -41,7 +41,9 @@
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramInstanceService;
import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
import org.hisp.dhis.program.comparator.ProgramStageInstanceVisitDateComparator;
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
@@ -79,7 +81,14 @@
{
this.programInstanceService = programInstanceService;
}
-
+
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
private SelectionTreeManager selectionTreeManager;
public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
@@ -162,15 +171,13 @@
return INPUT;
}
-
-
Date enrollment = (enrollmentDate == null || enrollmentDate.isEmpty()) ? null : format
.parseDate( enrollmentDate );
Date incident = (dateOfIncident == null || dateOfIncident.isEmpty()) ? null : format.parseDate( dateOfIncident );
- Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( entityInstance, program,
- ProgramInstance.STATUS_ACTIVE );
+ Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( entityInstance,
+ program, ProgramInstance.STATUS_ACTIVE );
if ( programInstances.iterator().hasNext() )
{
@@ -184,8 +191,22 @@
if ( programInstance == null )
{
OrganisationUnit orgunit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
-
- programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, enrollment, incident, orgunit );
+
+ programInstance = programInstanceService.enrollTrackedEntityInstance( entityInstance, program, enrollment,
+ incident, orgunit );
+
+ // ---------------------------------------------------------------------
+ // Generate events for program instance
+ // ---------------------------------------------------------------------
+
+ for ( ProgramStage programStage : program.getProgramStages() )
+ {
+ if ( programStage.getAutoGenerateEvent() )
+ {
+ programStageInstanceService.createProgramStageInstance( programInstance, programStage, enrollment,
+ incident, orgunit );
+ }
+ }
}
// ---------------------------------------------------------------------
@@ -204,8 +225,7 @@
// Get the active event of program-instance
// ---------------------------------------------------------------------
- List<ProgramStageInstance> programStageInstances = new ArrayList<>(
- programInstance.getProgramStageInstances() );
+ List<ProgramStageInstance> programStageInstances = new ArrayList<>( programInstance.getProgramStageInstances() );
Collections.sort( programStageInstances, new ProgramStageInstanceVisitDateComparator() );
activeProgramStageInstance = programInstance.getActiveProgramStageInstance();
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2014-12-04 06:39:46 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2015-05-18 17:05:23 +0000
@@ -515,7 +515,8 @@
scope="prototype">
<property name="entityInstanceService" ref="org.hisp.dhis.trackedentity.TrackedEntityInstanceService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+ <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
+ <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js 2015-05-08 19:23:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.directives.js 2015-05-18 17:05:23 +0000
@@ -47,7 +47,7 @@
};
})
-.directive('selectedOrgUnit', function($timeout, storage) {
+.directive('selectedOrgUnit', function($timeout) {
return {
restrict: 'A',
@@ -749,4 +749,4 @@
});
}
};
-});
\ No newline at end of file
+});