use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class RegistrationSingleEventServiceTest method createEnrollment.
private Enrollment createEnrollment(String program, String person) {
Enrollment enrollment = new Enrollment();
enrollment.setOrgUnit(organisationUnitA.getUid());
enrollment.setProgram(program);
enrollment.setTrackedEntityInstance(person);
enrollment.setEnrollmentDate(new Date());
enrollment.setIncidentDate(new Date());
return enrollment;
}
use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class RegistrationSingleEventServiceTest method testDeleteEnrollmentShouldReturnReference.
@Test
void testDeleteEnrollmentShouldReturnReference() {
Enrollment enrollment = createEnrollment(programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
ImportSummary importSummary = enrollmentService.addEnrollment(enrollment, null, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
TrackedEntityInstance tei = trackedEntityInstanceService.getTrackedEntityInstance(maleA.getUid());
importSummary = enrollmentService.deleteEnrollment(tei.getEnrollments().get(0).getEnrollment());
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertNotNull(importSummary.getReference());
assertEquals(tei.getEnrollments().get(0).getEnrollment(), importSummary.getReference());
}
use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class RegistrationSingleEventServiceTest method testSavingMultipleEventsShouldOnlyUpdate.
@Test
@Disabled
void testSavingMultipleEventsShouldOnlyUpdate() {
Enrollment enrollment = createEnrollment(programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
ImportSummary importSummary = enrollmentService.addEnrollment(enrollment, null, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
importSummary = eventService.addEvent(event, null, false);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
EventSearchParams params = new EventSearchParams();
params.setProgram(programA);
params.setOrgUnit(organisationUnitA);
params.setOrgUnitSelectionMode(OrganisationUnitSelectionMode.SELECTED);
assertEquals(1, eventService.getEvents(params).getEvents().size());
event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
importSummary = eventService.addEvent(event, null, false);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(1, eventService.getEvents(params).getEvents().size());
event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
importSummary = eventService.addEvent(event, null, false);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(1, eventService.getEvents(params).getEvents().size());
}
use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class TrackerAccessManagerTest method createEnrollment.
private Enrollment createEnrollment(String program, String person) {
Enrollment enrollment = new Enrollment();
enrollment.setEnrollment(CodeGenerator.generateUid());
enrollment.setOrgUnit(organisationUnitA.getUid());
enrollment.setProgram(program);
enrollment.setTrackedEntityInstance(person);
enrollment.setEnrollmentDate(new Date());
enrollment.setIncidentDate(new Date());
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(programStageA.getUid());
event1.setStatus(EventStatus.COMPLETED);
event1.setTrackedEntityInstance(maleA.getUid());
event1.setOrgUnit(organisationUnitA.getUid());
Event event2 = new Event();
event2.setEnrollment(enrollment.getEnrollment());
event2.setDueDate(DateTimeFormatter.ofPattern("yyyy-MM-dd", Locale.ENGLISH).format(LocalDateTime.now().plusDays(10)));
event2.setProgram(programA.getUid());
event2.setProgramStage(programStageB.getUid());
event2.setStatus(EventStatus.SCHEDULE);
event2.setTrackedEntityInstance(maleA.getUid());
event2.setOrgUnit(organisationUnitB.getUid());
enrollment.setEvents(Arrays.asList(event1, event2));
return enrollment;
}
use of org.hisp.dhis.dxf2.events.enrollment.Enrollment in project dhis2-core by dhis2.
the class EnrollmentController method startAsyncImport.
// -------------------------------------------------------------------------
// HELPERS
// -------------------------------------------------------------------------
/**
* Starts an asynchronous enrollment task.
*
* @param importOptions the ImportOptions.
* @param enrollments the enrollments to import.
*/
private WebMessage startAsyncImport(ImportOptions importOptions, List<Enrollment> enrollments) {
JobConfiguration jobId = new JobConfiguration("inMemoryEventImport", ENROLLMENT_IMPORT, currentUserService.getCurrentUser().getUid(), true);
taskExecutor.executeTask(new ImportEnrollmentsTask(enrollments, enrollmentService, importOptions, jobId));
return jobConfigurationReport(jobId).setLocation("/system/tasks/" + ENROLLMENT_IMPORT);
}
Aggregations