Search in sources :

Example 6 with ProgramInstance

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());
}
Also used : ProgramInstance(org.hisp.dhis.program.ProgramInstance)

Example 7 with ProgramInstance

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;
}
Also used : ImportSummary(org.hisp.dhis.dxf2.importsummary.ImportSummary) ProgramInstance(org.hisp.dhis.program.ProgramInstance)

Example 8 with ProgramInstance

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());
}
Also used : ProgramInstance(org.hisp.dhis.program.ProgramInstance)

Example 9 with ProgramInstance

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;
}
Also used : Program(org.hisp.dhis.program.Program) ProgramInstance(org.hisp.dhis.program.ProgramInstance) TrackedEntityDataValue(org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValue) ProgramStage(org.hisp.dhis.program.ProgramStage) Date(java.util.Date) ProgramStageInstance(org.hisp.dhis.program.ProgramStageInstance)

Example 10 with ProgramInstance

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);
    }
}
Also used : ProgramInstance(org.hisp.dhis.program.ProgramInstance) Date(java.util.Date)

Aggregations

ProgramInstance (org.hisp.dhis.program.ProgramInstance)24 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)10 Date (java.util.Date)9 Program (org.hisp.dhis.program.Program)9 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)7 ProgramStage (org.hisp.dhis.program.ProgramStage)7 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)7 HashSet (java.util.HashSet)5 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)5 ArrayList (java.util.ArrayList)4 ImportOptions (org.hisp.dhis.dxf2.common.ImportOptions)3 ProgramInstanceQueryParams (org.hisp.dhis.program.ProgramInstanceQueryParams)3 Patient (org.hisp.dhis.api.mobile.model.LWUITmodel.Patient)2 ImportConflict (org.hisp.dhis.dxf2.importsummary.ImportConflict)2 ProgramStageDataElement (org.hisp.dhis.program.ProgramStageDataElement)2 Relationship (org.hisp.dhis.relationship.Relationship)2 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)2 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)2 TrackedEntityDataValue (org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValue)2 Lists (com.google.common.collect.Lists)1