dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35938
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18406: for programs with onlyEnrollOnce property set, respect this property when enrolling into a progra...
------------------------------------------------------------
revno: 18406
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-02-25 15:23:37 +0700
message:
for programs with onlyEnrollOnce property set, respect this property when enrolling into a program (only allow enrolling one time, even if the old PI is completed)
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2015-02-20 03:59:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2015-02-25 08:23:37 +0000
@@ -211,6 +211,7 @@
this.setterMethod = setter;
}
+ @Override
@JsonProperty
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Class<?> getKlass()
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-02-20 12:35:55 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java 2015-02-25 08:23:37 +0000
@@ -352,6 +352,22 @@
return importSummary;
}
+ if ( program.getOnlyEnrollOnce() )
+ {
+ enrollments = getEnrollments( program, trackedEntityInstance, EnrollmentStatus.COMPLETED );
+
+ if ( !enrollments.getEnrollments().isEmpty() )
+ {
+ importSummary.setStatus( ImportStatus.ERROR );
+ importSummary.setDescription( "TrackedEntityInstance " + trackedEntityInstance.getTrackedEntityInstance()
+ + " already have a completed enrollment in program " + program.getUid() + ", and this program is" +
+ " configured to only allow enrolling one time." );
+ importSummary.getImportCount().incrementIgnored();
+
+ return importSummary;
+ }
+ }
+
List<ImportConflict> importConflicts = new ArrayList<>();
importConflicts.addAll( checkAttributes( enrollment ) );