Search in sources :

Example 91 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class DataValidatorTest method setUp.

@BeforeEach
public void setUp() {
    dataValidator = new DataValidator(categoryService, organisationUnitService, dataSetService, idObjectManager, dataValueService, inputUtils, fileResourceService, calendarService, accessManager);
    periodJan = createPeriod("202001");
    periodFeb = createPeriod("202002");
    periodMar = createPeriod("202003");
    dataSetA = new DataSet("dataSet", new MonthlyPeriodType());
    dataElementA = new DataElement();
    categoryOptionA = new CategoryOption();
    optionComboA = new CategoryOptionCombo();
    dataSetA.addDataSetElement(dataElementA);
    dataElementA.getDataSetElements().addAll(dataSetA.getDataSetElements());
    optionComboA.addCategoryOption(categoryOptionA);
    jan15 = getDate(2020, 1, 15);
    feb15 = getDate(2020, 2, 15);
}
Also used : DataElement(org.hisp.dhis.dataelement.DataElement) DataSet(org.hisp.dhis.dataset.DataSet) MonthlyPeriodType(org.hisp.dhis.period.MonthlyPeriodType) CategoryOption(org.hisp.dhis.category.CategoryOption) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 92 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class GenerateDataSetReportAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    // ---------------------------------------------------------------------
    // Configure response
    // ---------------------------------------------------------------------
    HttpServletResponse response = ServletActionContext.getResponse();
    contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.RESPECT_SYSTEM_SETTING, null, false);
    // ---------------------------------------------------------------------
    // Assemble report
    // ---------------------------------------------------------------------
    selectedDataSet = dataSetService.getDataSetNoAcl(ds);
    if (pe != null) {
        selectedPeriod = PeriodType.getPeriodFromIsoString(pe);
        selectedPeriod = periodService.reloadPeriod(selectedPeriod);
    }
    selectedOrgunit = organisationUnitService.getOrganisationUnit(ou);
    FormType formType = selectedDataSet.getFormType();
    CategoryOptionCombo attributeOptionCombo = categoryService.getDefaultCategoryOptionCombo();
    registration = registrationService.getCompleteDataSetRegistration(selectedDataSet, selectedPeriod, selectedOrgunit, attributeOptionCombo);
    if (formType.isCustom() && type == null) {
        customDataEntryFormCode = dataSetReportService.getCustomDataSetReport(selectedDataSet, newArrayList(selectedPeriod), selectedOrgunit, dimension, selectedUnitOnly);
    } else {
        grids = dataSetReportService.getDataSetReportAsGrid(selectedDataSet, newArrayList(selectedPeriod), selectedOrgunit, dimension, selectedUnitOnly);
    }
    return type != null ? type : formType.toString();
}
Also used : FormType(org.hisp.dhis.dataset.FormType) HttpServletResponse(javax.servlet.http.HttpServletResponse) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo)

Example 93 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class HandleRelationshipsTrackedEntityInstanceServiceTest method setUpTest.

@Override
protected void setUpTest() throws Exception {
    organisationUnitA = createOrganisationUnit('A');
    trackedEntityType = createTrackedEntityType('A');
    trackedEntityTypeService.addTrackedEntityType(trackedEntityType);
    trackedEntityInstanceA = createTrackedEntityInstance(organisationUnitA);
    trackedEntityInstanceA.setTrackedEntityType(trackedEntityType);
    trackedEntityInstanceB = createTrackedEntityInstance(organisationUnitA);
    trackedEntityInstanceB.setTrackedEntityType(trackedEntityType);
    programA = createProgram('A', new HashSet<>(), organisationUnitA);
    programA.setProgramType(ProgramType.WITH_REGISTRATION);
    programStageA1 = createProgramStage('1', programA);
    programStageA2 = createProgramStage('2', programA);
    programA.setProgramStages(Stream.of(programStageA1, programStageA2).collect(Collectors.toCollection(HashSet::new)));
    manager.save(organisationUnitA);
    manager.save(trackedEntityInstanceA);
    manager.save(trackedEntityInstanceB);
    manager.save(programA);
    manager.save(programStageA1);
    manager.save(programStageA2);
    ProgramInstance programInstanceA = programInstanceService.enrollTrackedEntityInstance(trackedEntityInstanceA, programA, null, null, organisationUnitA);
    programStageInstanceA = new ProgramStageInstance(programInstanceA, programStageA1);
    programStageInstanceA.setDueDate(null);
    programStageInstanceA.setUid("UID-A");
    CategoryCombo categoryComboA = createCategoryCombo('A');
    CategoryOptionCombo categoryOptionComboA = createCategoryOptionCombo('A');
    categoryOptionComboA.setCategoryCombo(categoryComboA);
    manager.save(categoryComboA);
    manager.save(categoryOptionComboA);
    programStageInstanceA.setAttributeOptionCombo(categoryOptionComboA);
    programStageInstanceService.addProgramStageInstance(programStageInstanceA);
}
Also used : CategoryCombo(org.hisp.dhis.category.CategoryCombo) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo)

Example 94 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class AttributeOptionComboDateCheckTest method failOnCategoryOptionEndDateBeforeEventDate.

@Test
void failOnCategoryOptionEndDateBeforeEventDate() {
    event.setEventDate("2019-05-01");
    event.setDueDate("2019-05-10");
    CategoryOptionCombo categoryOptionCombo = createCategoryOptionCombo("2019-04-01", false);
    mockContext(categoryOptionCombo);
    ImportSummary importSummary = rule.check(new ImmutableEvent(event), this.workContext);
    assertHasError(importSummary, event, "Event date 2019-05-01 is after end date 2019-04-01 for attributeOption 'test' in program 'TestProgram'");
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) ImmutableEvent(org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent) Test(org.junit.jupiter.api.Test) BaseValidationTest(org.hisp.dhis.dxf2.events.importer.validation.BaseValidationTest)

Example 95 with CategoryOptionCombo

use of org.hisp.dhis.category.CategoryOptionCombo in project dhis2-core by dhis2.

the class AttributeOptionComboDateCheckTest method succeedBeforeOpenDaysAfterCoEndDate.

@Test
void succeedBeforeOpenDaysAfterCoEndDate() {
    event.setEventDate("2019-05-01");
    event.setDueDate("2019-05-10");
    program.setOpenDaysAfterCoEndDate(31);
    CategoryOptionCombo categoryOptionCombo = createCategoryOptionCombo("2019-04-01", false);
    mockContext(categoryOptionCombo);
    ImportSummary importSummary = rule.check(new ImmutableEvent(event), this.workContext);
    assertNoError(importSummary);
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) ImmutableEvent(org.hisp.dhis.dxf2.events.importer.shared.ImmutableEvent) Test(org.junit.jupiter.api.Test) BaseValidationTest(org.hisp.dhis.dxf2.events.importer.validation.BaseValidationTest)

Aggregations

CategoryOptionCombo (org.hisp.dhis.category.CategoryOptionCombo)218 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)94 DataElement (org.hisp.dhis.dataelement.DataElement)68 Period (org.hisp.dhis.period.Period)67 Test (org.junit.jupiter.api.Test)58 CategoryCombo (org.hisp.dhis.category.CategoryCombo)52 CategoryOption (org.hisp.dhis.category.CategoryOption)51 ArrayList (java.util.ArrayList)39 Program (org.hisp.dhis.program.Program)31 DataValue (org.hisp.dhis.datavalue.DataValue)30 Collectors (java.util.stream.Collectors)26 Category (org.hisp.dhis.category.Category)26 Date (java.util.Date)25 DataElementOperand (org.hisp.dhis.dataelement.DataElementOperand)25 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)23 CategoryService (org.hisp.dhis.category.CategoryService)20 DataSet (org.hisp.dhis.dataset.DataSet)20 ProgramStage (org.hisp.dhis.program.ProgramStage)20 Event (org.hisp.dhis.tracker.domain.Event)20 ProgramInstance (org.hisp.dhis.program.ProgramInstance)16