Search in sources :

Example 51 with ProgramStage

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

the class EventWithoutRegistrationPreProcessorTest method testEnrollmentIsAddedIntoEventWhenItBelongsToProgramWithoutRegistration.

@Test
void testEnrollmentIsAddedIntoEventWhenItBelongsToProgramWithoutRegistration() {
    // Given
    Event event = new Event();
    event.setProgramStage("programStageUid");
    TrackerBundle bundle = TrackerBundle.builder().events(Collections.singletonList(event)).build();
    ProgramInstance programInstance = new ProgramInstance();
    programInstance.setUid("programInstanceUid");
    Program program = new Program();
    program.setUid("programUid");
    ProgramStage programStage = new ProgramStage();
    programStage.setUid("programStageUid");
    programStage.setProgram(program);
    TrackerPreheat preheat = new TrackerPreheat();
    preheat.putProgramInstancesWithoutRegistration("programUid", programInstance);
    preheat.put(TrackerIdentifier.UID, programStage);
    bundle.setPreheat(preheat);
    // When
    preProcessorToTest.process(bundle);
    // Then
    assertEquals("programInstanceUid", bundle.getEvents().get(0).getEnrollment());
}
Also used : Program(org.hisp.dhis.program.Program) ProgramInstance(org.hisp.dhis.program.ProgramInstance) Event(org.hisp.dhis.tracker.domain.Event) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) TrackerPreheat(org.hisp.dhis.tracker.preheat.TrackerPreheat) ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 52 with ProgramStage

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

the class EventWithoutRegistrationPreProcessorTest method testEnrollmentIsNotAddedIntoEventWhenItProgramStageHasNoReferenceToProgram.

@Test
void testEnrollmentIsNotAddedIntoEventWhenItProgramStageHasNoReferenceToProgram() {
    // Given
    Event event = new Event();
    event.setProgramStage("programStageUid");
    TrackerBundle bundle = TrackerBundle.builder().events(Collections.singletonList(event)).build();
    ProgramInstance programInstance = new ProgramInstance();
    programInstance.setUid("programInstanceUid");
    Program program = new Program();
    program.setUid("programUid");
    ProgramStage programStage = new ProgramStage();
    programStage.setUid("programStageUid");
    TrackerPreheat preheat = new TrackerPreheat();
    preheat.putProgramInstancesWithoutRegistration("programUid", programInstance);
    preheat.put(TrackerIdentifier.UID, programStage);
    bundle.setPreheat(preheat);
    // When
    preProcessorToTest.process(bundle);
    // Then
    assertNull(bundle.getEvents().get(0).getEnrollment(), "programInstanceUid");
}
Also used : Program(org.hisp.dhis.program.Program) ProgramInstance(org.hisp.dhis.program.ProgramInstance) Event(org.hisp.dhis.tracker.domain.Event) TrackerBundle(org.hisp.dhis.tracker.bundle.TrackerBundle) TrackerPreheat(org.hisp.dhis.tracker.preheat.TrackerPreheat) ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 53 with ProgramStage

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

the class DhisConvenienceTest method createProgramStage.

public static ProgramStage createProgramStage(char uniqueCharacter, int minDays, boolean repeatable) {
    ProgramStage programStage = new ProgramStage();
    programStage.setAutoFields();
    programStage.setUid(BASE_PG_UID + uniqueCharacter);
    programStage.setName("ProgramStage" + uniqueCharacter);
    programStage.setDescription("description" + uniqueCharacter);
    programStage.setMinDaysFromStart(minDays);
    programStage.setRepeatable(repeatable);
    return programStage;
}
Also used : ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 54 with ProgramStage

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

the class DhisConvenienceTest method createProgramStage.

public static ProgramStage createProgramStage(char uniqueCharacter, Program program) {
    ProgramStage stage = createProgramStage(uniqueCharacter, 0, false);
    stage.setProgram(program);
    return stage;
}
Also used : ProgramStage(org.hisp.dhis.program.ProgramStage)

Example 55 with ProgramStage

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

the class ProgramRuleEngineServiceTest method setUpInstances.

// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
private void setUpInstances() {
    OrganisationUnit organisationUnitA = createOrganisationUnit('A');
    Program programA = createProgram('A', new HashSet<>(), organisationUnitA);
    ProgramStage programStageA = createProgramStage('A', programA);
    programRuleA = createProgramRule('R', programA);
    programRuleActionA = createProgramRuleAction('T');
    programRuleA.setProgram(programA);
    programInstance = new ProgramInstance();
    programInstance.setProgram(programA);
    programStageA = createProgramStage('S', programA);
    programA.getProgramStages().add(programStageA);
    programStageInstance = new ProgramStageInstance();
    programStageInstance.setProgramStage(programStageA);
    programStageInstance.setProgramInstance(programInstance);
    programStageInstance.setUid("PSI1");
    programRules.add(programRuleA);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Program(org.hisp.dhis.program.Program) ProgramInstance(org.hisp.dhis.program.ProgramInstance) ProgramStage(org.hisp.dhis.program.ProgramStage) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance)

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