use of org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance in project dhis2-core by dhis2.
the class HandleRelationshipsTrackedEntityInstanceServiceTest method createTeiToTeiRelationship.
private Relationship createTeiToTeiRelationship(char key, RelationshipType relationshipType, TrackedEntityInstance trackedEntityInstanceA, TrackedEntityInstance trackedEntityInstanceB) {
RelationshipItem relationshipItemTeiA = new RelationshipItem();
relationshipItemTeiA.setTrackedEntityInstance(trackedEntityInstanceA);
RelationshipItem relationshipItemTeiB = new RelationshipItem();
relationshipItemTeiB.setTrackedEntityInstance(trackedEntityInstanceB);
Relationship relationship = new Relationship();
relationship.setFrom(relationshipItemTeiA);
relationship.setTo(relationshipItemTeiB);
relationship.setRelationshipType(relationshipType.getUid());
relationship.setRelationship("UID_" + key);
relationship.setRelationshipName("Person to person");
relationship.setBidirectional(relationshipType.isBidirectional());
return relationship;
}
use of org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance in project dhis2-core by dhis2.
the class ProgramInstancePreProcessorTest method verifyEnrollmentIsNotSetOnEventWhenMultipleProgramInstanceAreFound.
@Test
void verifyEnrollmentIsNotSetOnEventWhenMultipleProgramInstanceAreFound() {
//
// Tracked Entity Instance
//
TrackedEntityInstance tei = createTrackedEntityInstance(createOrganisationUnit('A'));
Map<String, Pair<TrackedEntityInstance, Boolean>> teiMap = new HashMap<>();
teiMap.put(event.getUid(), Pair.of(tei, true));
when(workContext.getTrackedEntityInstanceMap()).thenReturn(teiMap);
ProgramInstance programInstance1 = new ProgramInstance();
ProgramInstance programInstance2 = new ProgramInstance();
when(programInstanceStore.get(tei, program, ProgramStatus.ACTIVE)).thenReturn(Lists.newArrayList(programInstance1, programInstance2));
event.setProgram(program.getUid());
subject.process(event, workContext);
assertThat(event.getEnrollment(), is(nullValue()));
assertThat(programInstanceMap.get(event.getUid()), is(nullValue()));
}
use of org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance in project dhis2-core by dhis2.
the class TrackerTest method createEnrollmentWithEvents.
private Enrollment createEnrollmentWithEvents(Program program, TrackedEntityInstance trackedEntityInstance, int events) {
Enrollment enrollment = new Enrollment();
enrollment.setEnrollment(CodeGenerator.generateUid());
enrollment.setOrgUnit(organisationUnitA.getUid());
enrollment.setProgram(program.getUid());
enrollment.setTrackedEntityInstance(trackedEntityInstance.getUid());
enrollment.setEnrollmentDate(new Date());
enrollment.setStatus(EnrollmentStatus.COMPLETED);
enrollment.setIncidentDate(new Date());
enrollment.setCompletedDate(new Date());
enrollment.setCompletedBy("hello-world");
if (events > 0) {
List<Event> eventList = new ArrayList<>();
String now = DateUtils.getIso8601NoTz(new Date());
for (int i = 0; i < events; i++) {
Event event1 = new Event();
event1.setEnrollment(enrollment.getEnrollment());
event1.setEventDate(DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.ENGLISH).format(LocalDateTime.now()));
event1.setProgram(programA.getUid());
event1.setProgramStage(programStageA1.getUid());
event1.setStatus(EventStatus.COMPLETED);
event1.setTrackedEntityInstance(trackedEntityInstance.getUid());
event1.setOrgUnit(organisationUnitA.getUid());
event1.setAttributeOptionCombo(DEF_COC_UID);
event1.setCreatedAtClient(now);
event1.setLastUpdatedAtClient(now);
event1.setCompletedDate(now);
event1.setCompletedBy("[Unknown]");
eventList.add(event1);
}
enrollment.setEvents(eventList);
}
return enrollment;
}
use of org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance in project dhis2-core by dhis2.
the class TrackedEntityInstanceAttributesAggregateTest method testTrackedEntityInstanceIncludeSpecificProtectedProgram.
@Test
void testTrackedEntityInstanceIncludeSpecificProtectedProgram() {
populatePrerequisites(false);
TrackedEntityInstanceQueryParams queryParams = new TrackedEntityInstanceQueryParams();
queryParams.setOrganisationUnits(Sets.newHashSet(organisationUnitA));
queryParams.setProgram(programB);
TrackedEntityInstanceParams params = new TrackedEntityInstanceParams();
final List<TrackedEntityInstance> trackedEntityInstances = trackedEntityInstanceService.getTrackedEntityInstances(queryParams, params, false, true);
assertAttributes(trackedEntityInstances.get(0).getAttributes(), "A", "B", "E");
}
use of org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance in project dhis2-core by dhis2.
the class TrackedEntityInstanceAttributesAggregateTest method testTrackedEntityInstanceIncludeAllAttributes.
@Test
void testTrackedEntityInstanceIncludeAllAttributes() {
populatePrerequisites(false);
TrackedEntityInstanceQueryParams queryParams = new TrackedEntityInstanceQueryParams();
queryParams.setOrganisationUnits(Sets.newHashSet(organisationUnitA));
queryParams.setTrackedEntityType(trackedEntityTypeA);
queryParams.setIncludeAllAttributes(true);
TrackedEntityInstanceParams params = new TrackedEntityInstanceParams();
final List<TrackedEntityInstance> trackedEntityInstances = trackedEntityInstanceService.getTrackedEntityInstances(queryParams, params, false, true);
assertAttributes(trackedEntityInstances.get(0).getAttributes(), "A", "B", "C", "E");
}
Aggregations