Search in sources :

Example 31 with ProgramStage

use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.

the class GetSelectedDataElementsAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    ProgramStage programStage = programStageService.getProgramStage(associationId);
    dataElementList = new ArrayList<>(programStage.getAllDataElements());
    Collections.sort(dataElementList);
    return SUCCESS;
}
Also used : ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 32 with ProgramStage

use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.

the class SMSCommandAction method getProgramStageDataElementList.

public Collection<ProgramStageDataElement> getProgramStageDataElementList() {
    if (smsCommand != null) {
        Program program = smsCommand.getProgram();
        ProgramStage programStage = program.getProgramStages().iterator().next();
        if (programStage != null) {
            programStageDataElementList = programStage.getProgramStageDataElements();
        }
        return programStageDataElementList;
    }
    return new ArrayList<ProgramStageDataElement>();
}
Also used : Program(org.hisp.dhis.program.Program) ArrayList(java.util.ArrayList) ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 33 with ProgramStage

use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.

the class SelectProgramStageDataElementAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    programStage = programStageService.getProgramStage(programStageId);
    if (programStage != null) {
        Program program = programStage.getProgram();
        if (program != null) {
            programStages = new ArrayList<>(program.getProgramStages());
            for (ProgramStage ps : programStages) {
                if (ps.equals(programStage)) {
                    programStages.remove(ps);
                    break;
                }
            }
            Collections.sort(programStages);
        }
    }
    return SUCCESS;
}
Also used : Program(org.hisp.dhis.program.Program) ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 34 with ProgramStage

use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.

the class ProgramStageObjectBundleHook method preCreate.

@Override
public <T extends IdentifiableObject> void preCreate(T object, ObjectBundle bundle) {
    if (!ProgramStage.class.isInstance(object))
        return;
    ProgramStage programStage = (ProgramStage) object;
    if (programStage.getPeriodType() != null) {
        PeriodType periodType = bundle.getPreheat().getPeriodTypeMap().get(programStage.getPeriodType().getName());
        programStage.setPeriodType(periodType);
    }
}
Also used : PeriodType(org.hisp.dhis.period.PeriodType) ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 35 with ProgramStage

use of org.hisp.dhis.program.ProgramStage in project dhis2-core by dhis2.

the class FormUtils method fromProgram.

public static Form fromProgram(Program program) {
    Assert.notNull(program, "Program cannot be null");
    Form form = new Form();
    form.setLabel(program.getDisplayName());
    if (!StringUtils.isEmpty(program.getDescription())) {
        form.getOptions().put("description", program.getDescription());
    }
    if (!StringUtils.isEmpty(program.getEnrollmentDateLabel())) {
        form.getOptions().put("dateOfEnrollmentDescription", program.getEnrollmentDateLabel());
    }
    if (!StringUtils.isEmpty(program.getIncidentDateLabel())) {
        form.getOptions().put("dateOfIncidentDescription", program.getIncidentDateLabel());
    }
    form.getOptions().put("type", program.getProgramType().getValue());
    ProgramStage programStage = program.getProgramStageByStage(1);
    if (programStage == null) {
        if (program.isWithoutRegistration()) {
            throw new IllegalStateException("Program is without registration");
        } else {
            return form;
        }
    }
    form.getOptions().put("captureCoordinates", programStage.getCaptureCoordinates());
    if (programStage.getProgramStageSections().size() > 0) {
        for (ProgramStageSection section : programStage.getProgramStageSections()) {
            List<Field> fields = inputFromDataElements(section.getDataElements());
            Group group = new Group();
            group.setLabel(section.getDisplayName());
            group.setDataElementCount(section.getDataElements().size());
            group.setFields(fields);
            form.getGroups().add(group);
        }
    } else {
        List<Field> fields = inputFromProgramStageDataElements(new ArrayList<>(programStage.getProgramStageDataElements()));
        Group group = new Group();
        group.setLabel("default");
        group.setFields(fields);
        group.setDataElementCount(programStage.getProgramStageDataElements().size());
        form.getGroups().add(group);
    }
    return form;
}
Also used : ProgramStageSection(org.hisp.dhis.program.ProgramStageSection) Field(org.hisp.dhis.webapi.webdomain.form.Field) Group(org.hisp.dhis.webapi.webdomain.form.Group) Form(org.hisp.dhis.webapi.webdomain.form.Form) ProgramStage(org.hisp.dhis.program.ProgramStage)

Aggregations

ProgramStage (org.hisp.dhis.program.ProgramStage)40 Program (org.hisp.dhis.program.Program)24 DataElement (org.hisp.dhis.dataelement.DataElement)13 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 ProgramStageDataElement (org.hisp.dhis.program.ProgramStageDataElement)10 ArrayList (java.util.ArrayList)7 ProgramInstance (org.hisp.dhis.program.ProgramInstance)7 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)7 PeriodType (org.hisp.dhis.period.PeriodType)6 Date (java.util.Date)5 ProgramStageSection (org.hisp.dhis.program.ProgramStageSection)5 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)5 Test (org.junit.Test)4 HashSet (java.util.HashSet)3 List (java.util.List)3 DhisSpringTest (org.hisp.dhis.DhisSpringTest)3 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)3 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)3 ProgramTrackedEntityAttribute (org.hisp.dhis.program.ProgramTrackedEntityAttribute)3 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)3