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;
}
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>();
}
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;
}
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);
}
}
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;
}
Aggregations