← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7173: (patient) Show provided elsewhere into the selected data-element of program-stage.

 

------------------------------------------------------------
revno: 7173
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-06-04 17:03:56 +0700
message:
  (patient) Show provided elsewhere into the selected data-element of program-stage.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientdatavalue/hibernate/PatientDataValue.hbm.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElement.hbm.xml
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveProvidingFacilityAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.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/dataEntryForm.vm
  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/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.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-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java	2012-05-23 15:02:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientdatavalue/PatientDataValue.java	2012-06-04 10:03:56 +0000
@@ -53,7 +53,7 @@
 
     private String value;
 
-    //private boolean providedElsewhere;
+    private Boolean providedElsewhere;
     
     // -------------------------------------------------------------------------
     // Constructors
@@ -135,6 +135,16 @@
         this.programStageInstance = programStageInstance;
     }
 
+    public Boolean getProvidedElsewhere()
+    {
+        return providedElsewhere;
+    }
+
+    public void setProvidedElsewhere( Boolean providedElsewhere )
+    {
+        this.providedElsewhere = providedElsewhere;
+    }
+
     public ProgramStageInstance getProgramStageInstance()
     {
         return programStageInstance;
@@ -169,4 +179,5 @@
     {
         return value;
     }
+
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java	2012-06-04 06:14:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageDataElement.java	2012-06-04 10:03:56 +0000
@@ -58,15 +58,15 @@
      * programStage
      */
     private boolean compulsory = false;
-    
-    private boolean allowProvidedElsewhere;
+
+    private Boolean allowProvidedElsewhere;
 
     private Integer sortOrder;
 
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
-    
+
     public ProgramStageDataElement( ProgramStage programStage, DataElement dataElement, boolean compulsory )
     {
         this.programStage = programStage;
@@ -107,12 +107,12 @@
         this.dataElement = dataElement;
     }
 
-    public boolean isAllowProvidedElsewhere()
+    public Boolean getAllowProvidedElsewhere()
     {
         return allowProvidedElsewhere;
     }
 
-    public void setAllowProvidedElsewhere( boolean allowProvidedElsewhere )
+    public void setAllowProvidedElsewhere( Boolean allowProvidedElsewhere )
     {
         this.allowProvidedElsewhere = allowProvidedElsewhere;
     }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java	2012-03-15 09:25:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstance.java	2012-06-04 10:03:56 +0000
@@ -46,9 +46,9 @@
     public static final String COLOR_RED = "#fb4754";
 
     public static final String COLOR_YELLOW = "#f9f95a";
-    
+
     public static final String COLOR_GREEN = "#8ffe8f";
-    
+
     public static final String COLOR_LIGHTRED = "#fb6bfb";
 
     private int id;
@@ -62,13 +62,11 @@
     private Date dueDate;
 
     private Date executionDate;
-    
+
     private OrganisationUnit organisationUnit;
 
     private boolean completed = false;
 
-    private Boolean providedByAnotherFacility = false;
-    
     private String storedBy;
 
     // -------------------------------------------------------------------------
@@ -122,7 +120,7 @@
         result = result * prime + programInstance.hashCode();
         result = result * prime + programStage.hashCode();
         result = result * prime + dueDate.hashCode();
-        result = result * prime + ( ( executionDate == null) ? 0 : executionDate.hashCode() );
+        result = result * prime + ((executionDate == null) ? 0 : executionDate.hashCode());
         result = result * prime + stageInProgram;
 
         return result;
@@ -227,7 +225,7 @@
     {
         return stageInProgram;
     }
-    
+
     /**
      * @return the completed
      */
@@ -253,15 +251,6 @@
     {
         this.organisationUnit = organisationUnit;
     }
-    public void setProvidedByAnotherFacility( Boolean providedByAnotherFacility )
-    {
-        this.providedByAnotherFacility = providedByAnotherFacility;
-    }
-
-    public Boolean isProvidedByAnotherFacility()
-    {
-        return providedByAnotherFacility;
-    }
 
     public String getStoredBy()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-06-04 10:03:56 +0000
@@ -94,7 +94,7 @@
         executeSql( "ALTER TABLE program DROP COLUMN anonymous" );
         executeSql( "UPDATE program SET type=1 where type is null" );
 
-        executeSql( "UPDATE programstage set irregular=false where irregular is null" );
+        executeSql( "UPDATE programstage SET irregular=false WHERE irregular is null" );
 
         executeSql( "DROP TABLE programattributevalue" );
         executeSql( "DROP TABLE programinstance_attributes" );
@@ -110,6 +110,10 @@
 
         executeSql( "ALTER TABLE caseaggregationcondition RENAME description TO name" );
         updateCaseAggregationCondition();
+        
+        executeSql( "UPDATE programstage_dataelements SET allowProvidedElsewhere=false WHERE allowProvidedElsewhere is null" );
+        executeSql( "UPDATE patientdatavalue SET providedElsewhere=false WHERE providedElsewhere is null" );
+        executeSql( "ALTER TABLE programstageinstance DROP COLUMN providedbyanotherfacility" );
     }
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2012-05-30 03:30:10 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2012-06-04 10:03:56 +0000
@@ -366,6 +366,8 @@
             // -----------------------------------------------------------------
 
             String compulsory = "null";
+            boolean allowProvidedElsewhere = false;
+            
             String dataElementCode = dataElementMatcher.group( 1 );
             Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( dataElementCode );
             if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
@@ -375,7 +377,6 @@
                 // -------------------------------------------------------------
 
                 int programStageId = Integer.parseInt( identifierMatcher.group( 1 ) );
-
                 int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
 
                 DataElement dataElement = null;
@@ -400,6 +401,7 @@
                     ProgramStageDataElement psde = programStageDataElementService.get( programStage, dataElement );
 
                     compulsory = BooleanUtils.toStringTrueFalse( psde.isCompulsory() );
+                    allowProvidedElsewhere = psde.getAllowProvidedElsewhere();
                 }
 
                 if ( dataElement == null )
@@ -509,7 +511,15 @@
                 {
                     disabled = "disabled";
                 }
+                else if ( !programStageInstance.isCompleted() && allowProvidedElsewhere)
+                {
+                    // -----------------------------------------------------------
+                    // Add ProvidedByOtherFacility checkbox
+                    // -----------------------------------------------------------
 
+                    appendCode = addProvidedElsewherCheckbox( appendCode, patientDataValue, programStage );
+                }
+                
                 // -----------------------------------------------------------
                 // 
                 // -----------------------------------------------------------
@@ -570,6 +580,7 @@
             // -----------------------------------------------------------------
 
             String compulsory = "null";
+            boolean providedElsewhere = false;
             String dataElementCode = dataElementMatcher.group( 1 );
 
             Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( dataElementCode );
@@ -606,6 +617,7 @@
                     ProgramStageDataElement psde = programStageDataElementService.get( programStage, dataElement );
 
                     compulsory = BooleanUtils.toStringTrueFalse( psde.isCompulsory() );
+                    providedElsewhere = psde.getAllowProvidedElsewhere();
                 }
 
                 if ( dataElement == null )
@@ -708,11 +720,21 @@
                 // -----------------------------------------------------------
 
                 disabled = "";
+                
                 if ( programStageId != programStage.getId() )
                 {
                     disabled = "disabled=\"\"";
                 }
+                
+                else if ( !programStageInstance.isCompleted() && providedElsewhere )
+                {
+                    // -----------------------------------------------------------
+                    // Add ProvidedByOtherFacility checkbox
+                    // -----------------------------------------------------------
 
+                    appendCode = addProvidedElsewherCheckbox( appendCode, patientDataValue, programStage );
+                }
+                
                 // -----------------------------------------------------------
                 // 
                 // -----------------------------------------------------------
@@ -779,8 +801,9 @@
             // -----------------------------------------------------------------
 
             String compulsory = "null";
+            boolean allowProvidedElsewhere = false;
+
             String dataElementCode = dataElementMatcher.group( 1 );
-
             Matcher identifierMatcher = IDENTIFIER_PATTERN_FIELD.matcher( dataElementCode );
 
             if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
@@ -814,6 +837,7 @@
                     ProgramStageDataElement psde = programStageDataElementService.get( programStage, dataElement );
 
                     compulsory = BooleanUtils.toStringTrueFalse( psde.isCompulsory() );
+                    allowProvidedElsewhere = psde.getAllowProvidedElsewhere();
                 }
 
                 if ( dataElement == null )
@@ -914,6 +938,15 @@
 
                 appendCode += jQueryCalendar;
 
+                if ( programStageId == programStage.getId() && !programStageInstance.isCompleted() && allowProvidedElsewhere )
+                {
+                    // -----------------------------------------------------------
+                    // Add ProvidedByOtherFacility checkbox
+                    // -----------------------------------------------------------
+
+                    appendCode = addProvidedElsewherCheckbox( appendCode, patientDataValue, programStage );
+                }
+                
                 // -------------------------------------------------------------
                 // 
                 // -------------------------------------------------------------
@@ -937,7 +970,25 @@
 
         return sb.toString();
     }
-
+    
+    private String addProvidedElsewherCheckbox( String appendCode, PatientDataValue patientDataValue, ProgramStage programStage )
+    {
+        appendCode += "<label for=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\" title=\"is provided by another Facility ?\" ></label><input name=\"providedByAnotherFacility\"  title=\"is provided by another Facility ?\"  id=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\"  type=\"checkbox\" style=\"display:$DISPLAY;\" ";
+        
+        if ( patientDataValue != null && patientDataValue.getProvidedElsewhere() )
+        {
+            appendCode += " checked=\"checked\" ";
+        }
+        
+        appendCode += "onChange=\"updateProvidingFacility( $DATAELEMENTID, this )\"  >";
+
+        String display = ( !programStage.getProgram().isRegistration() ) ? "none" : "block";  
+        appendCode = appendCode.replace( "$DISPLAY", display );
+        
+        return appendCode;
+
+    }
+    
     /**
      * Returns the value of the PatientDataValue in the Collection of DataValues
      * with the given data element identifier.

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientdatavalue/hibernate/PatientDataValue.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientdatavalue/hibernate/PatientDataValue.hbm.xml	2012-03-05 04:22:57 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientdatavalue/hibernate/PatientDataValue.hbm.xml	2012-06-04 10:03:56 +0000
@@ -16,6 +16,8 @@
     <property name="value" />
 
     <property name="timestamp" type="date" />
+    
+    <property name="providedElsewhere" />
 
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElement.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElement.hbm.xml	2012-03-07 02:40:08 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageDataElement.hbm.xml	2012-06-04 10:03:56 +0000
@@ -14,6 +14,8 @@
     </composite-id>
 
     <property name="compulsory" column="compulsory" not-null="true" />
+    
+	<property name="allowProvidedElsewhere" column="allowprovidedelsewhere" />
 	  
 	<property name="sortOrder" column="sort_order" /> 
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml	2012-03-15 09:25:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/program/hibernate/ProgramStageInstance.hbm.xml	2012-06-04 10:03:56 +0000
@@ -26,8 +26,6 @@
     
     <many-to-one name="organisationUnit" class="org.hisp.dhis.organisationunit.OrganisationUnit"
         column="organisationunitid" foreign-key="fk_programstageinstance_organisationunitid" />
-        
-    <property name="providedByAnotherFacility" column="providedbyanotherfacility"  />
     
     <property name="storedBy" column="storedby" length="31" />
     

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java	2012-03-05 08:41:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CreateAnonymousEncounterAction.java	2012-06-04 10:03:56 +0000
@@ -138,7 +138,6 @@
             programStageInstance.setDueDate( date );
             programStageInstance.setExecutionDate( date );
             programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
-            programStageInstance.setProvidedByAnotherFacility( false );
 
             programStageInstanceService.addProgramStageInstance( programStageInstance );
             

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java	2012-05-24 10:44:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveExecutionDateAction.java	2012-06-04 10:03:56 +0000
@@ -100,13 +100,14 @@
     {
         this.format = format;
     }
-    
+
     private CurrentUserService currentUserService;
 
     public void setCurrentUserService( CurrentUserService currentUserService )
     {
         this.currentUserService = currentUserService;
     }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -157,11 +158,12 @@
                 ProgramStage programStage = programStageService.getProgramStage( programStageId );
                 Program program = programStage.getProgram();
                 int type = program.getType();
-
+                ProgramInstance programInstance = null;
+                
                 if ( type == Program.SINGLE_EVENT_WITH_REGISTRATION )
                 {
                     // Add a new program-instance
-                    ProgramInstance programInstance = new ProgramInstance();
+                    programInstance = new ProgramInstance();
                     programInstance.setEnrollmentDate( dateValue );
                     programInstance.setDateOfIncident( dateValue );
                     programInstance.setProgram( program );
@@ -172,40 +174,25 @@
                     patientService.updatePatient( patient );
 
                     programInstanceService.addProgramInstance( programInstance );
-
-                    // Add a new program-stage-instance
-                    programStageInstance = new ProgramStageInstance();
-                    programStageInstance.setProgramInstance( programInstance );
-                    programStageInstance.setProgramStage( programStage );
-                    programStageInstance.setStageInProgram( programStage.getStageInProgram() );
-                    programStageInstance.setDueDate( dateValue );
-                    programStageInstance.setExecutionDate( dateValue );
-                    programStageInstance.setStoredBy( storedBy );
-                    programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
-                    programStageInstance.setProvidedByAnotherFacility( false );
-
-                    programStageInstanceService.addProgramStageInstance( programStageInstance );
-                    selectedStateManager.setSelectedProgramInstance( programInstance );
                 }
                 else if ( type == Program.SINGLE_EVENT_WITHOUT_REGISTRATION )
                 {
-                    ProgramInstance programInstance = programInstanceService.getProgramInstances( patient, program ).iterator().next();
-                    
-                    // Add a new program-stage-instance
-                    programStageInstance = new ProgramStageInstance();
-                    programStageInstance.setProgramInstance( programInstance );
-                    programStageInstance.setProgramStage( programStage );
-                    programStageInstance.setStageInProgram( programStage.getStageInProgram() );
-                    programStageInstance.setDueDate( dateValue );
-                    programStageInstance.setExecutionDate( dateValue );
-                    programStageInstance.setStoredBy( storedBy );
-                    programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
-                    programStageInstance.setProvidedByAnotherFacility( false );
-
-                    programStageInstanceService.addProgramStageInstance( programStageInstance );
-                    selectedStateManager.setSelectedProgramInstance( programInstance );
+                    programInstance = programInstanceService.getProgramInstances( patient, program )
+                        .iterator().next();
                 }
 
+                // Add a new program-stage-instance
+                programStageInstance = new ProgramStageInstance();
+                programStageInstance.setProgramInstance( programInstance );
+                programStageInstance.setProgramStage( programStage );
+                programStageInstance.setStageInProgram( programStage.getStageInProgram() );
+                programStageInstance.setDueDate( dateValue );
+                programStageInstance.setExecutionDate( dateValue );
+                programStageInstance.setStoredBy( storedBy );
+                programStageInstance.setOrganisationUnit( selectedStateManager.getSelectedOrganisationUnit() );
+
+                programStageInstanceService.addProgramStageInstance( programStageInstance );
+                selectedStateManager.setSelectedProgramInstance( programInstance );
                 selectedStateManager.setSelectedProgramStageInstance( programStageInstance );
             }
             else

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveProvidingFacilityAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveProvidingFacilityAction.java	2012-03-16 02:00:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveProvidingFacilityAction.java	2012-06-04 10:03:56 +0000
@@ -28,9 +28,11 @@
 package org.hisp.dhis.caseentry.action.caseentry;
 
 import org.hisp.dhis.caseentry.state.SelectedStateManager;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.patientdatavalue.PatientDataValue;
+import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.program.ProgramStageInstance;
-import org.hisp.dhis.program.ProgramStageInstanceService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -52,22 +54,36 @@
         this.selectedStateManager = selectedStateManager;
     }
 
-    private ProgramStageInstanceService programStageInstanceService;
-
-    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
-    {
-        this.programStageInstanceService = programStageInstanceService;
+    private DataElementService dataElementService;
+
+    public void setDataElementService( DataElementService dataElementService )
+    {
+        this.dataElementService = dataElementService;
+    }
+
+    private PatientDataValueService patientDataValueService;
+
+    public void setPatientDataValueService( PatientDataValueService patientDataValueService )
+    {
+        this.patientDataValueService = patientDataValueService;
     }
 
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private boolean providedByAnotherFacility;
-
-    public void setProvidedByAnotherFacility( boolean providedByAnotherFacility )
-    {
-        this.providedByAnotherFacility = providedByAnotherFacility;
+    private int dataElementId;
+
+    public void setDataElementId( int dataElementId )
+    {
+        this.dataElementId = dataElementId;
+    }
+
+    private Boolean providedElsewhere;
+
+    public void setProvidedElsewhere( Boolean providedElsewhere )
+    {
+        this.providedElsewhere = providedElsewhere;
     }
 
     private int statusCode;
@@ -86,21 +102,18 @@
     {
         ProgramStageInstance programStageInstance = selectedStateManager.getSelectedProgramStageInstance();
 
-        if ( programStageInstance != null )
+        DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+        PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue( programStageInstance,
+            dataElement );
+
+        if ( patientDataValue != null )
         {
-            if ( programStageInstance.getOrganisationUnit() == null )
-            {
-                OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
-                programStageInstance.setOrganisationUnit( organisationUnit );
-            }
-            
-            programStageInstance.setProvidedByAnotherFacility( providedByAnotherFacility );
+            patientDataValue.setProvidedElsewhere( providedElsewhere );
 
-            programStageInstanceService.updateProgramStageInstance( programStageInstance );
+            patientDataValueService.updatePatientDataValue( patientDataValue );
         }
 
-        statusCode = 0;
-
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2012-05-30 15:51:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/SaveValueAction.java	2012-06-04 10:03:56 +0000
@@ -83,6 +83,13 @@
         this.selectedStateManager = selectedStateManager;
     }
 
+    private Boolean providedElsewhere;
+
+    public void setProvidedElsewhere( Boolean providedElsewhere )
+    {
+        this.providedElsewhere = providedElsewhere;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -158,11 +165,14 @@
             programStageInstanceService.updateProgramStageInstance( programStageInstance );
         }
 
+        providedElsewhere = (providedElsewhere == null) ? false : true;
+
         if ( patientDataValue == null && value != null )
         {
             LOG.debug( "Adding PatientDataValue, value added" );
 
             patientDataValue = new PatientDataValue( programStageInstance, dataElement, new Date(), value );
+            patientDataValue.setProvidedElsewhere( providedElsewhere );
 
             patientDataValueService.savePatientDataValue( patientDataValue );
         }
@@ -172,6 +182,7 @@
 
             patientDataValue.setValue( value );
             patientDataValue.setTimestamp( new Date() );
+            patientDataValue.setProvidedElsewhere( providedElsewhere );
 
             patientDataValueService.updatePatientDataValue( patientDataValue );
         }

=== 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-05-31 04:22:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-06-04 10:03:56 +0000
@@ -90,8 +90,10 @@
 		scope="prototype">
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-		<property name="programStageInstanceService"
-			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+		<property name="dataElementService"
+			ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="patientDataValueService"
+			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-05-30 15:51:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2012-06-04 10:03:56 +0000
@@ -38,27 +38,6 @@
 <input type='hidden' name='completed' id='completed' value='$!programStageInstance.completed'>
 
 <div id='entryForm' #if($!programStageInstance.executionDate) class='visible' #else class='hidden' #end>
-	##providedByAnotherFacility
-	<table class='entryScreen'>	
-		#if($programStageInstance.programInstance.program.displayProvidedOtherFacility == 'true' )
-		<tr>
-			<th>				
-				#set( $id = $programStageInstance.programStage.id + '_facility' )
-				#if( $!programStageInstance.providedByAnotherFacility)
-					#if( $!programStageInstance.providedByAnotherFacility == 'true' ) 					
-						$i18n.getString( "orgunit_provided_service" ): $programStageInstance.organisationUnit.name
-					#elseif( $!programStageInstance.providedByAnotherFacility == 'false' ) 
-						$i18n.getString( "orgunit_provided_service" ): $i18n.getString("other_facility")
-					#end
-				#else
-					$i18n.getString( "provided_elsewhere" ) 
-					<input type="checkbox" id='$id' onclick="updateProvidingFacility();">
-				#end
-			</th>
-		</tr>
-		#end
-	</table>
-
 	#if( $customDataEntryFormCode )
 		<div id="customEntryScreenContainer">
 		   $customDataEntryFormCode
@@ -76,6 +55,7 @@
 			<tr>
 				<th>$i18n.getString( "data_element" )</th>                   
 				<th>$i18n.getString( "entry" )</th>
+				<th>$i18n.getString( "provided_elsewhere" )</th>
 			</tr>
 		#set( $dataElementRowCount = 0 )
 		#set( $mark = true )
@@ -118,10 +98,19 @@
 					#else
 						<input name="entryfield" data="{compulsory: $programStageDataElement.compulsory, deName:'$programStageDataElement.dataElement.name', deType:'$programStageDataElement.dataElement.getDetailedNumberType()' }" id="$id" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onchange="saveVal( $programStageDataElement.dataElement.id )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex">
 					#end
-				</td>  
+				</td> 
+				
+				<td>
+					#set( $id = $programStageDataElement.programStage.id + '_' + $programStageDataElement.dataElement.id + '_facility' )
+					#if( $programStageDataElement.allowProvidedElsewhere == 'true')
+						<input name="$id" id="$id" type="checkbox" 
+							onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )" 
+							#if($patientDataValue.providedElsewhere == 'true') checked #end />
+					#end
+				</td>
 			</tr>
-			#set( $tabIndex = $tabIndex + 1 )
-		#end
+		#end				
+		#set( $tabIndex = $tabIndex + 1 )
 		</table>
 	#end
 </div>

=== 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-05-30 03:30:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2012-06-04 10:03:56 +0000
@@ -227,13 +227,13 @@
     valueSaver.save();
 }
 
-function updateProvidingFacility()
+function updateProvidingFacility( dataElementId, checkField )
 {
 	var programStageId = byId( 'programStageId' ).value;
-	var checkField = byId( programStageId + '_facility');
+	var checked= checkField.checked;
     checkField.style.backgroundColor = '#ffffcc';
 	
-    var facilitySaver = new FacilitySaver( checkField.checked, '#ccffcc' );
+    var facilitySaver = new FacilitySaver( dataElementId, checked, '#ccffcc' );
     facilitySaver.save();
     
 }
@@ -381,6 +381,7 @@
     var ERROR = '#ccccff';
 	
     var dataElementId = dataElementId_;
+	var providedElsewhereId = getFieldValue('programStageId') + "_" + dataElementId_ + "_facility";
 	var value = value_;
 	var type = dataElementType_;
     var resultColor = resultColor_;
@@ -388,7 +389,8 @@
     this.save = function()
     {
 		var params  = 'dataElementId=' + dataElementId;
-			params += '&value=' ;
+			params += '&value=';
+			params += '&providedElsewhere=' + byId( providedElsewhereId ).checked;
 		if( value != '')
 			params += htmlEncode(value);
 		
@@ -442,17 +444,19 @@
     }
 }
 
-function FacilitySaver( providedByAnotherFacility_, resultColor_ )
+function FacilitySaver( dataElementId_, providedElsewhere_, resultColor_ )
 {
     var SUCCESS = 'success';
     var ERROR = '#error';
 	
-    var providedByAnotherFacility = providedByAnotherFacility_;
+    var dataElementId = dataElementId_;
+	var providedElsewhere = providedElsewhere_;
     var resultColor = resultColor_;
 
     this.save = function()
     {
-		var params = 'providedByAnotherFacility=' + providedByAnotherFacility ;
+		var params  = 'dataElementId=' + dataElementId;
+			params += '&providedElsewhere=' + providedElsewhere ;
 		$.ajax({
 			   type: "POST",
 			   url: "saveProvidingFacility.action",

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-06-04 08:37:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2012-06-04 10:03:56 +0000
@@ -821,7 +821,7 @@
 	$.ajax({
 		url: 'searchRegistrationPatient.action',
 		type:"POST",
-		data: getParamsForDiv( 'searchPatientDiv' ),
+		data: getParamsForDiv('searchPatientDiv'),
 		success: function( html ){
 				statusSearching = 1;
 				setInnerHTML( 'listPatientDiv', html );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm	2012-05-30 06:36:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/report.vm	2012-06-04 10:03:56 +0000
@@ -10,7 +10,7 @@
             #foreach( $programInstance in $programInstances )
                 <tr #alternate( $mark )>                
 					<td>
-						<a href="javascript:showPatientHistory( $programInstance.patient.id )" title='$i18n.getString( "patient_details_and_history" )'>$programInstance.patient.getFullName()</a>
+						<input type='button' class='buttonInfo' style='border-color:#bbbbbb;background-color:#cccccc' value='$programInstance.patient.getFullName()' onclick='javascript:showPatientHistory( $programInstance.patient.id )' title='$i18n.getString( "patient_details_and_history" )'>
 					</td>				
                     #foreach( $programStageInstance in $programInstance.programStageInstances )
 						<td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java	2012-05-23 16:19:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/AddProgramStageAction.java	2012-06-04 10:03:56 +0000
@@ -131,6 +131,13 @@
     {
         this.compulsories = compulsories;
     }
+    
+    private List<Boolean> allowProvidedElsewhere = new ArrayList<Boolean>();
+    
+    public void setAllowProvidedElsewhere( List<Boolean> allowProvidedElsewhere )
+    {
+        this.allowProvidedElsewhere = allowProvidedElsewhere;
+    }
 
     private Boolean irregular;
 
@@ -177,6 +184,7 @@
             DataElement dataElement = dataElementService.getDataElement( selectedDataElementsValidator.get( i ) );
             ProgramStageDataElement programStageDataElement = new ProgramStageDataElement( programStage, dataElement,
                 this.compulsories.get( i ), new Integer( i ) );
+            programStageDataElement.setAllowProvidedElsewhere( allowProvidedElsewhere.get( i ) );
             programStageDataElementService.addProgramStageDataElement( programStageDataElement );
         }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java	2012-05-23 16:19:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/programstage/UpdateProgramStageAction.java	2012-06-04 10:03:56 +0000
@@ -119,7 +119,12 @@
     {
         this.compulsories = compulsories;
     }
-
+ private List<Boolean> allowProvidedElsewhere = new ArrayList<Boolean>();
+    
+    public void setAllowProvidedElsewhere( List<Boolean> allowProvidedElsewhere )
+    {
+        this.allowProvidedElsewhere = allowProvidedElsewhere;
+    }
     private int programId;
 
     public int getProgramId()
@@ -184,6 +189,8 @@
 
                 programStageDataElement.setSortOrder( new Integer( i ) );
 
+                programStageDataElement.setAllowProvidedElsewhere( allowProvidedElsewhere.get( i ) );
+                
                 programStageDataElementService.updateProgramStageDataElement( programStageDataElement );
 
                 programStageDataElements.remove( programStageDataElement );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2012-06-04 10:03:56 +0000
@@ -243,4 +243,5 @@
 due_date=Due date
 stage_visited = Stage visited
 report_date = Report date
-program_stage_properties = Program stage properties
\ No newline at end of file
+program_stage_properties = Program stage properties
+allow_provided_elsewhere = Allow provided elsewhere
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm	2012-05-26 17:38:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addProgramStageForm.vm	2012-06-04 10:03:56 +0000
@@ -48,6 +48,7 @@
         <th>$i18n.getString( "selected_data_elements" )							
 			<select id="selectedDataElementsValidator" name='selectedDataElementsValidator' multiple="multiple" class="hidden" ></select>
 			<select id="compulsories" name='compulsories' multiple="multiple" class="hidden"></select>     
+			<select id="allowProvidedElsewhere" name='allowProvidedElsewhere' multiple="multiple" class="hidden"></select>     
 		</th>
       </tr>
     </thead>
@@ -68,6 +69,7 @@
 						<tr>
 							<th>$i18n.getString( "dataelement" )</th>
 							<th width="20px">$i18n.getString( "compulsory" )</th>
+							<th width="20px">$i18n.getString( "allow_provided_elsewhere" )</th>
 					</thead>
 					<tbody id="selectedList"></tbody>
 				</table>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js	2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/addProgramStageForm.js	2012-06-04 10:03:56 +0000
@@ -3,17 +3,26 @@
 	validation( 'addProgramStageForm', function( form ){ 
 		form.submit();
 	}, function(){
-		selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
+		var selectedDataElementsValidator = jQuery( "#selectedDataElementsValidator" );
 		selectedDataElementsValidator.empty();
 		
-		compulsories = jQuery( "#compulsories" );
+		var compulsories = jQuery( "#compulsories" );
 		compulsories.empty();
 		
+		allowProvidedElsewhere = jQuery( "#allowProvidedElsewhere" );
+		allowProvidedElsewhere.empty();
+		
 		jQuery("#selectedList").find("tr").each( function( i, item ){ 
+			
 			selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
+			
 			var compulsory = jQuery( item ).find( "input[name='compulsory']:first");
 			var checked = compulsory.attr('checked') ? true : false;
 			compulsories.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
+			
+			var allowProvided = jQuery( item ).find( "input[name='allowProvided']:first");
+			checked = allowProvided.attr('checked') ? true : false;
+			allowProvidedElsewhere.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
 		});
 	});
 	

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2012-05-23 16:19:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programStage.js	2012-06-04 10:03:56 +0000
@@ -65,6 +65,7 @@
 		if( item.selected ){
 			html = "<tr class='selected' id='" + item.value + "' ondblclick='unSelectDataElement( this )'><td onclick='select(this)'>" + item.text + "</td>";
 			html += "<td align='center'><input type='checkbox' name='compulsory' value='" + item.value + "'></td>";
+			html += "<td align='center'><input type='checkbox' name='allowProvided' value='" + item.value + "'></td>";
 			html += "</tr>";
 			selectedList.append( html );
 			jQuery( item ).remove();

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js	2012-06-04 04:06:04 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/updateProgramStageForm.js	2012-06-04 10:03:56 +0000
@@ -9,13 +9,21 @@
 		compulsories = jQuery( "#compulsories" );
 		compulsories.empty();
 		
+		allowProvidedElsewhere = jQuery( "#allowProvidedElsewhere" );
+		allowProvidedElsewhere.empty();
+		
 		jQuery("#selectedList").find("tr").each( function( i, item ){ 
+			
 			selectedDataElementsValidator.append( "<option value='" + item.id + "' selected='true'>" + item.id + "</option>" );
+			
 			var compulsory = jQuery( item ).find( "input[name='compulsory']:first");
-			var isShow = jQuery( item ).find( "input[name='isShow']:first");
-
 			var checked = compulsory.attr('checked') ? true : false;
 			compulsories.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
+			
+			
+			var allowProvided = jQuery( item ).find( "input[name='allowProvided']:first");
+			checked = allowProvided.attr('checked') ? true : false;
+			allowProvidedElsewhere.append( "<option value='" + checked + "' selected='true'>" + checked + "</option>" );
 		});
 	});
 	

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2012-05-30 03:38:42 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateProgramStageForm.vm	2012-06-04 10:03:56 +0000
@@ -47,6 +47,7 @@
 				<th>$i18n.getString( "selected_data_elements" )
 					<select id="selectedDataElementsValidator" name='selectedDataElementsValidator' multiple="multiple" class="hidden" > </select>
 					<select id="compulsories" name='compulsories' multiple="multiple" class="hidden"></select>
+					<select id="allowProvidedElsewhere" name='allowProvidedElsewhere' multiple="multiple" class="hidden"></select>
 				</th>
 			</tr>
 		</thead>
@@ -68,6 +69,7 @@
 							<tr>
 								<th>$i18n.getString( "dataelement" )</th>
 								<th width="20px">$i18n.getString( "compulsory" )</th>
+								<th width="20px">$i18n.getString( "allow_provided_elsewhere" )</th>
 							</tr>
 						</thead>
 						<tbody id="selectedList">
@@ -75,6 +77,7 @@
 								<tr ondblclick="unSelectDataElement( this )" id="$programStageDataElement.dataElement.id">
 									<td onclick="select(this)">$encoder.htmlEncode( $programStageDataElement.dataElement.name )</td>
 									<td align="center"><input type="checkbox" name="compulsory" value="$programStageDataElement.dataElement.id" #if($programStageDataElement.compulsory == true ) checked #end /></td>
+									<td align="center"><input type="checkbox" name="allowProvided" value="$programStageDataElement.dataElement.id" #if($programStageDataElement.allowProvidedElsewhere == true ) checked #end /></td>
 								</tr>
 							#end
 						</tbody>