Search in sources :

Example 41 with ProgramStage

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

the class LabelMapperTest method testGetHeaderNameFor_NAME_EVENT_DATE.

@Test
void testGetHeaderNameFor_NAME_EVENT_DATE() {
    // Given
    final ProgramStage aMockedProgramStageWithLabels = mockProgramStageWithLabels();
    // When
    final String actualName = LabelMapper.getEventDateLabel(aMockedProgramStageWithLabels, EVENT_DATE);
    // Then
    assertThat(actualName, is(aMockedProgramStageWithLabels.getExecutionDateLabel()));
}
Also used : ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 42 with ProgramStage

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

the class LabelMapperTest method mockProgramStageWithoutLabels.

private ProgramStage mockProgramStageWithoutLabels() {
    final ProgramStage programStage = new ProgramStage();
    final Program program = new Program();
    programStage.setProgram(program);
    return programStage;
}
Also used : Program(org.hisp.dhis.program.Program) ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 43 with ProgramStage

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

the class LabelMapperTest method testGetHeaderNameWhenProgramStageIsNull.

@Test
void testGetHeaderNameWhenProgramStageIsNull() {
    // Given
    final ProgramStage nullProgramStage = null;
    // When
    final String actualName = LabelMapper.getIncidentDateLabel(nullProgramStage, INCIDENT_DATE);
    // Then
    assertThat(actualName, is(INCIDENT_DATE));
}
Also used : ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 44 with ProgramStage

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

the class LabelMapperTest method mockProgramStageWithLabels.

private ProgramStage mockProgramStageWithLabels() {
    final ProgramStage programStage = new ProgramStage();
    programStage.setExecutionDateLabel("execution date label");
    final Program program = new Program();
    program.setEnrollmentDateLabel("enrollment date label");
    program.setIncidentDateLabel("incident date label");
    programStage.setProgram(program);
    return programStage;
}
Also used : Program(org.hisp.dhis.program.Program) ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 45 with ProgramStage

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

the class ProgramItemStageElement method getDescription.

@Override
public Object getDescription(ExprContext ctx, CommonExpressionVisitor visitor) {
    assumeStageElementSyntax(ctx);
    String programStageId = ctx.uid0.getText();
    String dataElementId = ctx.uid1.getText();
    ProgramStageService stageService = visitor.getProgramStageService();
    ProgramStage programStage = stageService.getProgramStage(programStageId);
    DataElement dataElement = visitor.getIdObjectManager().get(DataElement.class, dataElementId);
    if (programStage == null) {
        throw new ParserExceptionWithoutContext("Program stage " + programStageId + " not found");
    }
    if (dataElement == null) {
        throw new ParserExceptionWithoutContext("Data element " + dataElementId + " not found");
    }
    if (isNonDefaultStageOffset(visitor.getState().getStageOffset()) && !isRepeatableStage(stageService, programStageId)) {
        throw new ParserException(getErrorMessage(programStageId));
    }
    String description = programStage.getDisplayName() + ProgramIndicator.SEPARATOR_ID + dataElement.getDisplayName();
    visitor.getItemDescriptions().put(ctx.getText(), description);
    return ValidationUtils.getNullReplacementValue(dataElement.getValueType());
}
Also used : ParserExceptionWithoutContext(org.hisp.dhis.antlr.ParserExceptionWithoutContext) DataElement(org.hisp.dhis.dataelement.DataElement) ParserException(org.hisp.dhis.antlr.ParserException) ProgramStageService(org.hisp.dhis.program.ProgramStageService) ProgramStage(org.hisp.dhis.program.ProgramStage)

Aggregations

ProgramStage (org.hisp.dhis.program.ProgramStage)209 Test (org.junit.jupiter.api.Test)86 Program (org.hisp.dhis.program.Program)82 DataElement (org.hisp.dhis.dataelement.DataElement)67 Event (org.hisp.dhis.tracker.domain.Event)47 ValidationErrorReporter (org.hisp.dhis.tracker.report.ValidationErrorReporter)40 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)39 ProgramStageDataElement (org.hisp.dhis.program.ProgramStageDataElement)39 ProgramInstance (org.hisp.dhis.program.ProgramInstance)38 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)26 DhisConvenienceTest.createProgramStage (org.hisp.dhis.DhisConvenienceTest.createProgramStage)22 DataValue (org.hisp.dhis.tracker.domain.DataValue)22 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)21 User (org.hisp.dhis.user.User)20 TrackerBundle (org.hisp.dhis.tracker.bundle.TrackerBundle)17 ArrayList (java.util.ArrayList)16 Date (java.util.Date)16 List (java.util.List)16 DhisConvenienceTest.createDataElement (org.hisp.dhis.DhisConvenienceTest.createDataElement)16 TrackerImportValidationContext (org.hisp.dhis.tracker.validation.TrackerImportValidationContext)16