use of org.hisp.dhis.program.ProgramInstance in project dhis2-core by dhis2.
the class AbstractEnrollmentService method incompleteEnrollment.
@Override
public void incompleteEnrollment(String uid) {
ProgramInstance programInstance = programInstanceService.getProgramInstance(uid);
programInstanceService.incompleteProgramInstanceStatus(programInstance);
manager.update(programInstance.getEntityInstance());
}
use of org.hisp.dhis.program.ProgramInstance in project dhis2-core by dhis2.
the class AbstractEnrollmentService method updateEnrollmentForNote.
@Override
public ImportSummary updateEnrollmentForNote(Enrollment enrollment) {
if (enrollment == null || enrollment.getEnrollment() == null) {
return new ImportSummary(ImportStatus.ERROR, "No enrollment or enrollment ID was supplied").incrementIgnored();
}
ImportSummary importSummary = new ImportSummary(enrollment.getEnrollment());
ProgramInstance programInstance = programInstanceService.getProgramInstance(enrollment.getEnrollment());
if (programInstance == null) {
return new ImportSummary(ImportStatus.ERROR, "Enrollment ID was not valid.").incrementIgnored();
}
saveTrackedEntityComment(programInstance, enrollment);
importSummary.setReference(enrollment.getEnrollment());
importSummary.getImportCount().incrementUpdated();
return importSummary;
}
use of org.hisp.dhis.program.ProgramInstance in project dhis2-core by dhis2.
the class AbstractEnrollmentService method completeEnrollment.
@Override
public void completeEnrollment(String uid) {
ProgramInstance programInstance = programInstanceService.getProgramInstance(uid);
programInstanceService.completeProgramInstanceStatus(programInstance);
manager.update(programInstance.getEntityInstance());
}
use of org.hisp.dhis.program.ProgramInstance in project dhis2-core by dhis2.
the class ActivityReportingServiceImpl method saveSingleEventWithoutRegistration.
@Override
public String saveSingleEventWithoutRegistration(org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStage mobileProgramStage, int orgUnitId) throws NotAllowedException {
ProgramStage programStage = programStageService.getProgramStage(mobileProgramStage.getId());
Program program = programStage.getProgram();
ProgramInstance programInstance = new ProgramInstance();
programInstance.setEnrollmentDate(new Date());
programInstance.setIncidentDate(new Date());
programInstance.setProgram(program);
programInstance.setStatus(ProgramStatus.COMPLETED);
programInstanceService.addProgramInstance(programInstance);
ProgramStageInstance programStageInstance = new ProgramStageInstance();
programStageInstance.setProgramInstance(programInstance);
programStageInstance.setProgramStage(programStage);
programStageInstance.setDueDate(new Date());
programStageInstance.setExecutionDate(new Date());
programStageInstance.setStatus(EventStatus.COMPLETED);
programStageInstance.setOrganisationUnit(organisationUnitService.getOrganisationUnit(orgUnitId));
programStageInstanceService.addProgramStageInstance(programStageInstance);
for (org.hisp.dhis.api.mobile.model.LWUITmodel.ProgramStageDataElement mobileDataElement : mobileProgramStage.getDataElements()) {
TrackedEntityDataValue trackedEntityDataValue = new TrackedEntityDataValue();
trackedEntityDataValue.setDataElement(dataElementService.getDataElement(mobileDataElement.getId()));
String value = mobileDataElement.getValue();
if (value != null && !value.trim().equals("")) {
trackedEntityDataValue.setValue(value);
trackedEntityDataValue.setProgramStageInstance(programStageInstance);
trackedEntityDataValue.setProvidedElsewhere(false);
trackedEntityDataValue.setLastUpdated(new Date());
dataValueService.saveTrackedEntityDataValue(trackedEntityDataValue);
}
}
return SINGLE_EVENT_WITHOUT_REGISTRATION_UPLOADED;
}
use of org.hisp.dhis.program.ProgramInstance in project dhis2-core by dhis2.
the class ProgramController method postCreateEntity.
@Override
protected void postCreateEntity(Program program) {
if (program.isWithoutRegistration()) {
ProgramInstance programInstance = new ProgramInstance();
programInstance.setEnrollmentDate(new Date());
programInstance.setIncidentDate(new Date());
programInstance.setProgram(program);
programInstance.setStatus(ProgramStatus.ACTIVE);
programInstanceService.addProgramInstance(programInstance);
}
}
Aggregations