=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2015-09-28 19:06:45 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java 2015-09-28 21:49:39 +0000 @@ -36,6 +36,7 @@ import org.hisp.dhis.common.OrganisationUnitSelectionMode; import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore; import org.hisp.dhis.commons.util.SqlHelper; +import org.hisp.dhis.event.EventStatus; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.program.Program; import org.hisp.dhis.program.ProgramInstance; @@ -467,10 +468,10 @@ + " ON org.organisationunitid = p.organisationunitid INNER JOIN trackedentityinstancereminder prm " + " ON prm.programid = pi.programid INNER JOIN trackedentityattributevalue pav " + " ON pav.trackedentityinstanceid=p.trackedentityinstanceid INNER JOIN trackedentityattribute pa " - + " ON pa.trackedentityattributeid=pav.trackedentityattributeid " - + " WHERE pi.status= '" + ProgramStatus.ACTIVE + "'" + + " ON pa.trackedentityattributeid=pav.trackedentityattributeid " + " WHERE pi.status= " + + EventStatus.ACTIVE.name() + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null and pa.valuetype='phoneNumber' " + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null and pa.valuetype='phoneNumber' " + " and ( DATE(now()) - DATE(pi." + dateToCompare + ") ) = prm.daysallowedsendmessage " + " and prm.whenToSend is null and prm.dateToCompare='" + dateToCompare + "' and prm.sendto = " + TrackedEntityInstanceReminder.SEND_TO_TRACKED_ENTITY_INSTANCE; @@ -485,10 +486,10 @@ + " ON p.trackedentityinstanceid=pi.trackedentityinstanceid INNER JOIN program pg " + " ON pg.programid=pi.programid INNER JOIN organisationunit org " + " ON org.organisationunitid = p.organisationunitid INNER JOIN trackedentityinstancereminder prm " - + " ON prm.programid = pi.programid " + " WHERE pi.status = '" + ProgramStatus.ACTIVE + "'" + + " ON prm.programid = pi.programid " + " WHERE pi.status = " + EventStatus.ACTIVE.name() + " and org.phonenumber is not NULL and org.phonenumber != '' " + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null " + " and ( DATE(now()) - DATE( pi." + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null " + " and ( DATE(now()) - DATE( pi." + dateToCompare + " ) ) = prm.daysallowedsendmessage " + " and prm.dateToCompare='" + dateToCompare + "' and prm.whenToSend is null and prm.sendto = " + TrackedEntityInstanceReminder.SEND_TO_ORGUGNIT_REGISTERED; } @@ -505,10 +506,11 @@ + " ON prm.programid = pi.programid INNER JOIN usermembership ums " + " ON ums.organisationunitid = p.organisationunitid INNER JOIN userinfo uif " + " ON uif.userinfoid = ums.userinfoid " - + "WHERE pi.status= '" + ProgramStatus.ACTIVE + "'" + + "WHERE pi.status= " + + EventStatus.ACTIVE.name() + " and uif.phonenumber is not NULL and uif.phonenumber != '' " + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null " + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null " + " and ( DATE(now()) - DATE( " + dateToCompare + " ) ) = prm.daysallowedsendmessage " @@ -528,11 +530,10 @@ + " INNER JOIN organisationunit org " + " ON org.organisationunitid = p.organisationunitid " + " INNER JOIN trackedentityinstancereminder prm " + " ON prm.programid = pg.programid " + " INNER JOIN usergroupmembers ugm " + " ON ugm.usergroupid = prm.usergroupid " - + " INNER JOIN userinfo uif " + " ON uif.userinfoid = ugm.userid " - + " WHERE pi.status= '" + ProgramStatus.ACTIVE + "'" - + " and uif.phonenumber is not NULL and uif.phonenumber != '' " + + " INNER JOIN userinfo uif " + " ON uif.userinfoid = ugm.userid " + " WHERE pi.status= " + + EventStatus.ACTIVE.name() + " and uif.phonenumber is not NULL and uif.phonenumber != '' " + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null " + " and ( DATE(now()) - DATE(" + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null " + " and ( DATE(now()) - DATE(" + dateToCompare + ") ) = prm.daysallowedsendmessage " + " and prm.whentosend is null " + " and prm.sendto = " + TrackedEntityInstanceReminder.SEND_TO_USER_GROUP; } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2015-09-24 08:32:10 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2015-09-28 21:49:39 +0000 @@ -363,9 +363,9 @@ + " INNER JOIN trackedentityattribute pa " + " ON pa.trackedentityattributeid=pav.trackedentityattributeid " + "WHERE pi.status=" - + ProgramStatus.ACTIVE + + EventStatus.ACTIVE.name() + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null " + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null " + " and psi.executiondate is null and pa.valuetype='phoneNumber' " + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " + " and prm.whentosend is null and prm.sendto = " + TrackedEntityInstanceReminder.SEND_TO_TRACKED_ENTITY_INSTANCE; @@ -394,10 +394,11 @@ + " ON pa.trackedentityattributeid=pav.trackedentityattributeid " + " INNER JOIN userinfo uif " + " ON pav.value=concat(uif.userinfoid ,'') " - + " WHERE pi.status='" + ProgramStatus.ACTIVE + "'" + + " WHERE pi.status=" + + EventStatus.ACTIVE.name() + " and pa.valueType='users' and uif.phonenumber is not NULL and uif.phonenumber != '' " + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null " + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null " + " and psi.executiondate is null " + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " + " and prm.whentosend is null and prm.sendto = " + TrackedEntityInstanceReminder.SEND_TO_ATTRIBUTE_TYPE_USERS; @@ -422,10 +423,11 @@ + " ON prm.programstageid = ps.programstageid " + " INNER JOIN organisationunit ou " + " ON ou.organisationunitid=p.organisationunitid " - + "WHERE pi.status= '" + ProgramStatus.ACTIVE + "'" + + "WHERE pi.status= " + + EventStatus.ACTIVE.name() + " and ou.phonenumber is not NULL and ou.phonenumber != '' " + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null " + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null " + " and psi.executiondate is null " + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " + " and prm.whentosend is null and prm.sendto = " @@ -453,10 +455,11 @@ + " ON ums.organisationunitid = p.organisationunitid " + " INNER JOIN userinfo uif " + " ON uif.userinfoid = ums.userinfoid " - + " WHERE pi.status= '" + ProgramStatus.ACTIVE + "'" + + " WHERE pi.status= " + + EventStatus.ACTIVE.name() + " and uif.phonenumber is not NULL and uif.phonenumber != '' " + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null " + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null " + " and psi.executiondate is null " + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " + " and prm.whentosend is null and prm.sendto = " @@ -484,10 +487,11 @@ + " ON ugm.usergroupid = prm.usergroupid " + " INNER JOIN userinfo uif " + " ON uif.userinfoid = ugm.userid " - + " WHERE pi.status= '"+ ProgramStatus.ACTIVE + "'" + + " WHERE pi.status= " + + EventStatus.ACTIVE.name() + " and uif.phonenumber is not NULL and uif.phonenumber != '' " + " and prm.templatemessage is not NULL and prm.templatemessage != '' " - + " and pg.type=1 and prm.daysallowedsendmessage is not null " + + " and pg.type='WITH_REGISTRATION' and prm.daysallowedsendmessage is not null " + " and psi.executiondate is not null " + " and ( DATE(now()) - DATE(psi.duedate) ) = prm.daysallowedsendmessage " + " and prm.whentosend is null " + " and prm.sendto = " + TrackedEntityInstanceReminder.SEND_TO_USER_GROUP;