use of org.hisp.dhis.api.mobile.model.ActivityPlan in project dhis2-core by dhis2.
the class ActivityReportingServiceImpl method getCurrentActivityPlan.
@Override
public ActivityPlan getCurrentActivityPlan(OrganisationUnit unit, String localeString) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, 30);
long upperBound = cal.getTime().getTime();
cal.add(Calendar.DATE, -60);
long lowerBound = cal.getTime().getTime();
List<Activity> items = new ArrayList<>();
TrackedEntityInstanceQueryParams param = new TrackedEntityInstanceQueryParams().addOrganisationUnit(unit);
Grid trackedEntityDrid = entityInstanceService.getTrackedEntityInstancesGrid(param);
List<List<Object>> entityInstanceList = trackedEntityDrid.getRows();
for (List<Object> entityInstance : entityInstanceList) {
TrackedEntityInstance trackedEntityInstance = entityInstanceService.getTrackedEntityInstance(entityInstance.get(0).toString());
for (ProgramStageInstance programStageInstance : programStageInstanceService.getProgramStageInstances(trackedEntityInstance, EventStatus.ACTIVE)) {
if (programStageInstance.getDueDate().getTime() >= lowerBound && programStageInstance.getDueDate().getTime() <= upperBound) {
items.add(getActivity(programStageInstance, false));
}
}
}
if (items.isEmpty()) {
return null;
}
Collections.sort(items, activityComparator);
return new ActivityPlan(items);
}
use of org.hisp.dhis.api.mobile.model.ActivityPlan in project dhis2-core by dhis2.
the class ActivityReportingServiceImpl method getAllActivityPlan.
@Override
public ActivityPlan getAllActivityPlan(OrganisationUnit unit, String localeString) {
List<Activity> items = new ArrayList<>();
TrackedEntityInstanceQueryParams param = new TrackedEntityInstanceQueryParams();
param.addOrganisationUnit(unit);
Grid trackedEntityDrid = entityInstanceService.getTrackedEntityInstancesGrid(param);
List<List<Object>> entityInstanceList = trackedEntityDrid.getRows();
for (List<Object> entityInstance : entityInstanceList) {
TrackedEntityInstance trackedEntityInstance = entityInstanceService.getTrackedEntityInstance(entityInstance.get(0).toString());
for (ProgramStageInstance programStageInstance : programStageInstanceService.getProgramStageInstances(trackedEntityInstance, EventStatus.ACTIVE)) {
items.add(getActivity(programStageInstance, false));
}
}
if (items.isEmpty()) {
return null;
}
Collections.sort(items, activityComparator);
return new ActivityPlan(items);
}
Aggregations