Search in sources :

Example 1 with ActivityPlan

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);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) Grid(org.hisp.dhis.common.Grid) ActivityPlan(org.hisp.dhis.api.mobile.model.ActivityPlan) ArrayList(java.util.ArrayList) Activity(org.hisp.dhis.api.mobile.model.Activity) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) List(java.util.List) PatientList(org.hisp.dhis.api.mobile.model.LWUITmodel.PatientList) ArrayList(java.util.ArrayList) TrackedEntityInstanceQueryParams(org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance)

Example 2 with ActivityPlan

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);
}
Also used : Grid(org.hisp.dhis.common.Grid) ActivityPlan(org.hisp.dhis.api.mobile.model.ActivityPlan) ArrayList(java.util.ArrayList) Activity(org.hisp.dhis.api.mobile.model.Activity) List(java.util.List) PatientList(org.hisp.dhis.api.mobile.model.LWUITmodel.PatientList) ArrayList(java.util.ArrayList) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) TrackedEntityInstanceQueryParams(org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Activity (org.hisp.dhis.api.mobile.model.Activity)2 ActivityPlan (org.hisp.dhis.api.mobile.model.ActivityPlan)2 PatientList (org.hisp.dhis.api.mobile.model.LWUITmodel.PatientList)2 Grid (org.hisp.dhis.common.Grid)2 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)2 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)2 TrackedEntityInstanceQueryParams (org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams)2 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1