use of org.hisp.dhis.program.ProgramStageSection in project dhis2-core by dhis2.
the class ActivityReportingServiceImpl method getMobileProgramStages.
private List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> getMobileProgramStages(ProgramInstance programInstance) {
List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> mobileProgramStages = new ArrayList<>();
List<ProgramStageInstance> proStageInstanceList = new ArrayList<>(programInstance.getProgramStageInstances());
Collections.sort(proStageInstanceList, new ProgramStageInstanceVisitDateComparator());
for (ProgramStageInstance eachProgramStageInstance : proStageInstanceList) {
// instance. This condition should be removed in the future
if (eachProgramStageInstance != null) {
ProgramStage programStage = eachProgramStageInstance.getProgramStage();
org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage mobileProgramStage = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage();
List<org.hisp.dhis.api.mobile.model.LWUITmodel.Section> mobileSections = new ArrayList<>();
mobileProgramStage.setId(eachProgramStageInstance.getId());
/* mobileProgramStage.setName( eachProgramStage.getName() ); */
mobileProgramStage.setName(programStage.getName());
// get report date
if (eachProgramStageInstance.getExecutionDate() != null) {
mobileProgramStage.setReportDate(DateUtils.getMediumDateString(eachProgramStageInstance.getExecutionDate()));
} else {
mobileProgramStage.setReportDate("");
}
if (programStage.getExecutionDateLabel() == null) {
mobileProgramStage.setReportDateDescription("Report Date");
} else {
mobileProgramStage.setReportDateDescription(programStage.getExecutionDateLabel());
}
// get due date
if (eachProgramStageInstance.getDueDate() != null) {
mobileProgramStage.setDueDate(DateUtils.getMediumDateString(eachProgramStageInstance.getDueDate()));
} else {
mobileProgramStage.setDueDate("");
}
// is repeatable
mobileProgramStage.setRepeatable(programStage.getRepeatable());
if (programStage.getStandardInterval() == null) {
mobileProgramStage.setStandardInterval(0);
} else {
mobileProgramStage.setStandardInterval(programStage.getStandardInterval());
}
// is completed
/*
* mobileProgramStage.setCompleted(
* checkIfProgramStageCompleted( patient,
* programInstance.getProgram(), programStage ) );
*/
mobileProgramStage.setCompleted(eachProgramStageInstance.isCompleted());
// is single event
mobileProgramStage.setSingleEvent(programInstance.getProgram().isWithoutRegistration());
// Set all data elements
mobileProgramStage.setDataElements(getDataElementsForMobile(programStage, eachProgramStageInstance));
// Set all program sections
if (programStage.getProgramStageSections().size() > 0) {
for (ProgramStageSection eachSection : programStage.getProgramStageSections()) {
org.hisp.dhis.api.mobile.model.LWUITmodel.Section mobileSection = new org.hisp.dhis.api.mobile.model.LWUITmodel.Section();
mobileSection.setId(eachSection.getId());
mobileSection.setName(eachSection.getName());
// Set all data elements' id, then we could have full
// from
// data element list of program stage
List<Integer> dataElementIds = new ArrayList<>();
for (DataElement dataElement : eachSection.getDataElements()) {
dataElementIds.add(dataElement.getId());
}
mobileSection.setDataElementIds(dataElementIds);
mobileSections.add(mobileSection);
}
}
mobileProgramStage.setSections(mobileSections);
mobileProgramStages.add(mobileProgramStage);
}
}
return mobileProgramStages;
}
use of org.hisp.dhis.program.ProgramStageSection in project dhis2-core by dhis2.
the class DefaultProgramService method getProgramLWUIT.
@Override
public org.hisp.dhis.api.mobile.model.LWUITmodel.Program getProgramLWUIT(int programId) {
org.hisp.dhis.program.Program program = programService.getProgram(programId);
org.hisp.dhis.api.mobile.model.LWUITmodel.Program pr = new org.hisp.dhis.api.mobile.model.LWUITmodel.Program();
pr.setId(program.getId());
pr.setName(program.getName());
pr.setType(program.getProgramType().getValue());
pr.setVersion(program.getVersion());
pr.setDateOfEnrollmentDescription(program.getEnrollmentDateLabel());
pr.setDateOfIncidentDescription(program.getIncidentDateLabel());
if (program.getTrackedEntity() != null && program.getTrackedEntity().getName() != null) {
pr.setTrackedEntityName(program.getTrackedEntity().getName());
}
List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage> prStgs = new ArrayList<>();
for (org.hisp.dhis.program.ProgramStage programStage : program.getProgramStages()) {
org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage prStg = new org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage();
// add report date
prStg.setReportDate("");
prStg.setReportDateDescription(programStage.getExecutionDateLabel());
prStg.setDueDate("");
prStg.setId(programStage.getId());
prStg.setName(programStage.getName());
prStg.setRepeatable(programStage.getRepeatable());
if (programStage.getStandardInterval() == null) {
prStg.setStandardInterval(0);
} else {
prStg.setStandardInterval(programStage.getStandardInterval());
}
prStg.setCompleted(false);
prStg.setSingleEvent(program.isWithoutRegistration());
List<org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement> des = new ArrayList<>();
Set<ProgramStageDataElement> programStageDataElements = programStage.getProgramStageDataElements();
for (ProgramStageDataElement programStageDataElement : programStageDataElements) {
org.hisp.dhis.dataelement.DataElement dataElement = programStageDataElement.getDataElement();
org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement de = ModelMapping.getDataElementLWUIT(dataElement);
de.setCompulsory(programStageDataElement.isCompulsory());
de.setNumberType(null);
des.add(de);
}
prStg.setDataElements(des);
// Set all program sections
List<org.hisp.dhis.api.mobile.model.LWUITmodel.Section> mobileSections = new ArrayList<>();
if (programStage.getProgramStageSections().size() > 0) {
for (ProgramStageSection eachSection : programStage.getProgramStageSections()) {
org.hisp.dhis.api.mobile.model.LWUITmodel.Section mobileSection = new org.hisp.dhis.api.mobile.model.LWUITmodel.Section();
mobileSection.setId(eachSection.getId());
mobileSection.setName(eachSection.getName());
// Set all data elements' id, then we could have full from
// data element list of program stage
List<Integer> dataElementIds = new ArrayList<>();
for (org.hisp.dhis.dataelement.DataElement element : eachSection.getDataElements()) {
dataElementIds.add(element.getId());
}
mobileSection.setDataElementIds(dataElementIds);
mobileSections.add(mobileSection);
}
}
prStg.setSections(mobileSections);
prStgs.add(prStg);
}
pr.setProgramStages(prStgs);
List<ProgramTrackedEntityAttribute> programPatientAttributes = new ArrayList<>(program.getProgramAttributes());
for (ProgramTrackedEntityAttribute ppa : programPatientAttributes) {
pr.getProgramAttributes().add(this.getPatientAttributeForMobile(ppa));
}
if (program.getRelatedProgram() != null) {
pr.setRelationshipText(program.getRelationshipText());
pr.setRelatedProgramId(program.getRelatedProgram().getId());
pr.setRelationshipType(program.getRelationshipType().getId());
}
return pr;
}
use of org.hisp.dhis.program.ProgramStageSection in project dhis2-core by dhis2.
the class DhisConvenienceTest method createProgramStageSection.
public static ProgramStageSection createProgramStageSection(char uniqueCharacter, Integer sortOrder) {
ProgramStageSection section = new ProgramStageSection();
section.setAutoFields();
section.setName("ProgramStageSection" + uniqueCharacter);
section.setSortOrder(sortOrder);
return section;
}
Aggregations