use of org.hisp.dhis.api.mobile.model.Activity 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.Activity 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);
}
use of org.hisp.dhis.api.mobile.model.Activity in project dhis2-core by dhis2.
the class ActivityReportingServiceImpl method getActivity.
// -------------------------------------------------------------------------
// Supportive method
// -------------------------------------------------------------------------
private Activity getActivity(ProgramStageInstance instance, boolean late) {
Activity activity = new Activity();
TrackedEntityInstance patient = instance.getProgramInstance().getEntityInstance();
activity.setBeneficiary(getBeneficiaryModel(patient));
activity.setDueDate(instance.getDueDate());
activity.setTask(getTask(instance));
activity.setLate(late);
activity.setExpireDate(DateUtils.getDateAfterAddition(instance.getDueDate(), 30));
return activity;
}
Aggregations