dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16224
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6119: (patient) Only allow a single registration per patient.
------------------------------------------------------------
revno: 6119
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-02-27 15:39:22 +0700
message:
(patient) Only allow a single registration per patient.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm
--
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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java 2011-12-14 07:53:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java 2012-02-27 08:39:22 +0000
@@ -28,11 +28,15 @@
import java.util.Collection;
import java.util.HashSet;
+import java.util.Iterator;
import org.hisp.dhis.caseentry.state.SelectedStateManager;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientService;
import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramInstance;
+import org.hisp.dhis.program.ProgramInstanceService;
import org.hisp.dhis.program.ProgramService;
import com.opensymphony.xwork2.Action;
@@ -69,6 +73,13 @@
this.selectedStateManager = selectedStateManager;
}
+ private ProgramInstanceService programInstanceService;
+
+ public void setProgramInstanceService( ProgramInstanceService programInstanceService )
+ {
+ this.programInstanceService = programInstanceService;
+ }
+
// -------------------------------------------------------------------------
// Input/Output
// -------------------------------------------------------------------------
@@ -101,13 +112,38 @@
public String execute()
throws Exception
{
+ OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
+
patient = patientService.getPatient( patientId );
- programs.addAll( patient.getPrograms() );
-
- programs.addAll( programService.getPrograms( true, false ) );
-
- programs.retainAll( programService.getPrograms( selectedStateManager.getSelectedOrganisationUnit() ) );
+ // ---------------------------------------------------------------------
+ // Get single programs with un-completed program-instances
+ // ---------------------------------------------------------------------
+
+ Collection<ProgramInstance> programInstances = programInstanceService
+ .getProgramInstances( patient, true );
+
+ Collection<Program> completedPrograms = new HashSet<Program>();
+
+ for ( ProgramInstance programInstance : programInstances )
+ {
+ if( programInstance.getProgram().getSingleEvent() )
+ {
+ completedPrograms.add( programInstance.getProgram() );
+ }
+ }
+
+ // ---------------------------------------------------------------------
+ // Get programs which patient enrolls
+ // ---------------------------------------------------------------------
+
+ programs = programService.getPrograms( orgunit );
+
+ programs.retainAll( patient.getPrograms() );
+
+ programs.addAll( programService.getPrograms( true, false, orgunit ) );
+
+ programs.removeAll( completedPrograms );
selectedStateManager.setSelectedPatient( patient );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-02-27 05:35:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2012-02-27 08:39:22 +0000
@@ -54,6 +54,7 @@
<property name="selectedStateManager"
ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+ <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-02-27 02:09:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js 2012-02-27 08:39:22 +0000
@@ -652,6 +652,12 @@
enable('newEncounterBtn');
}
+ var selectedProgram = jQuery('#dataRecordingSelectForm [name=programId] option:selected');
+ if( selectedProgram.attr('singleevent')=='true' )
+ {
+ selectedProgram.remove();
+ }
+
enable('createEventBtn');
selection.enable();
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm 2012-02-17 18:18:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm 2012-02-27 08:39:22 +0000
@@ -103,20 +103,19 @@
});
});
+ jQuery("#tabs").tabs();
+ datePickerValid( 'enrollmentDate' );
+ datePickerValid( 'dateOfIncident' );
- jQuery("#tabs").tabs();
- datePickerValid( 'enrollmentDate' );
- datePickerValid( 'dateOfIncident' );
-
- $( "#tabs" ).tabs( "option", "selected", 0 );
- #if($registerEvent == 'true')
- $('#tabs').bind('tabsselect', function(event, ui) {
- if( ui.index == 1 )
- {
- showSelectedDataRecoding( getFieldValue('patientId') );
- }
- });
- #else
- $("#tabs").tabs("option", "disabled", [1]);
- #end
+ $( "#tabs" ).tabs( "option", "selected", 0 );
+ #if($registerEvent == 'true')
+ $('#tabs').bind('tabsselect', function(event, ui) {
+ if( ui.index == 1 )
+ {
+ showSelectedDataRecoding( getFieldValue('patientId') );
+ }
+ });
+ #else
+ $("#tabs").tabs("option", "disabled", [1]);
+ #end
</script>