dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13304
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4223: Validate for case aggregation in Patient module.
------------------------------------------------------------
revno: 4223
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-07-28 13:36:51 +0700
message:
Validate for case aggregation in Patient module.
added:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ValidateCaseAggregationConditionAction.java
modified:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ValidatePatientAttributeAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
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/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js
--
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
=== added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ValidateCaseAggregationConditionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ValidateCaseAggregationConditionAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/caseaggregation/ValidateCaseAggregationConditionAction.java 2011-07-28 06:36:51 +0000
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2004-2009, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.patient.action.caseaggregation;
+
+import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
+import org.hisp.dhis.caseaggregation.CaseAggregationConditionService;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.i18n.I18n;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ ValidateCaseAggregationConditionAction.java Jul 28, 2011 12:53:50
+ * PM $
+ *
+ */
+public class ValidateCaseAggregationConditionAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private CaseAggregationConditionService aggregationConditionService;
+
+ public void setAggregationConditionService( CaseAggregationConditionService aggregationConditionService )
+ {
+ this.aggregationConditionService = aggregationConditionService;
+ }
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
+ private DataElementCategoryService dataElementCategoryService;
+
+ public void setDataElementCategoryService( DataElementCategoryService dataElementCategoryService )
+ {
+ this.dataElementCategoryService = dataElementCategoryService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input
+ // -------------------------------------------------------------------------
+
+ private String aggregationDataElementId;
+
+ public void setAggregationDataElementId( String aggregationDataElementId )
+ {
+ this.aggregationDataElementId = aggregationDataElementId;
+ }
+
+ private String message;
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ private I18n i18n;
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ String[] ids = aggregationDataElementId.split( "\\." );
+
+ DataElement aggregationDataElement = dataElementService.getDataElement( Integer.parseInt( ids[0] ) );
+
+ DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
+ .getDataElementCategoryOptionCombo( Integer.parseInt( ids[1] ) );
+
+ CaseAggregationCondition condition = aggregationConditionService.getCaseAggregationCondition(
+ aggregationDataElement, optionCombo );
+
+ if ( condition != null )
+ {
+ message = i18n.getString( "aggregation_data_element_in_use" );
+
+ return INPUT;
+ }
+
+ message = i18n.getString( "everything_is_ok" );
+
+ return SUCCESS;
+
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ValidatePatientAttributeAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ValidatePatientAttributeAction.java 2011-03-31 01:42:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/ValidatePatientAttributeAction.java 2011-07-28 06:36:51 +0000
@@ -98,7 +98,7 @@
if ( match != null && (id == null || match.getId() != id) )
{
- message = i18n.getString( "name_in_use" );
+ message = i18n.getString( "aggregation_data_element_in_use" );
return INPUT;
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-07-21 09:03:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-07-28 06:36:51 +0000
@@ -1122,6 +1122,21 @@
</property>
</bean>
+ <bean
+ id="org.hisp.dhis.patient.action.caseaggregation.ValidateCaseAggregationConditionAction"
+ class="org.hisp.dhis.patient.action.caseaggregation.ValidateCaseAggregationConditionAction"
+ scope="prototype">
+ <property name="aggregationConditionService">
+ <ref bean="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
+ </property>
+ <property name="dataElementService">
+ <ref bean="org.hisp.dhis.dataelement.DataElementService" />
+ </property>
+ <property name="dataElementCategoryService">
+ <ref bean="org.hisp.dhis.dataelement.DataElementCategoryService" />
+ </property>
+ </bean>
+
<!-- Validation - PatientValidationCriteria -->
<bean
=== 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 2011-07-28 02:46:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2011-07-28 06:36:51 +0000
@@ -472,4 +472,7 @@
min_days_from_start = Mininum number of days from start
warning_delete_program_attribute_option = This option has relationship with ProgramAttributeValue. You must not delete it.
success_delete_program_attribute_option = Delete program attribute option successfully.
-validation_criteria_management = Validation criteria management
\ No newline at end of file
+validation_criteria_management = Validation criteria management
+aggregation_data_element = Aggregation data element
+aggregation_expression = Aggregation expression
+aggregation_data_element_in_use = Aggregation data element is in use
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2011-07-21 09:03:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/struts.xml 2011-07-28 06:36:51 +0000
@@ -1053,6 +1053,15 @@
<param name="onExceptionReturn">plainTextError</param>
</action>
+ <action name="validateCaseAggregation"
+ class="org.hisp.dhis.patient.action.caseaggregation.ValidateCaseAggregationConditionAction">
+ <result name="success" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseSuccess.vm</result>
+ <result name="input" type="velocity-json">
+ /dhis-web-commons/ajax/jsonResponseInput.vm</result>
+ <param name="onExceptionReturn">plainTextError</param>
+ </action>
+
<!-- Validation - PatientValidationCriteria -->
<action name="validationCriteria"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm 2011-07-13 02:28:39 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm 2011-07-28 06:36:51 +0000
@@ -3,6 +3,8 @@
validation( 'addCaseAggregationForm', function(form){
form.submit();
});
+
+ checkValueIsExist( "aggregationDataElementId", "validateCaseAggregation.action");
});
</script>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm 2011-07-28 02:46:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm 2011-07-28 06:36:51 +0000
@@ -52,9 +52,9 @@
<p><label>$i18n.getString( "id" ):</label><br><span id="idField"></span></p>
<p><label>$i18n.getString( "description" ):</label><br><span id="descriptionField"></span></p>
<p><label>$i18n.getString( "operator" ):</label><br><span id="operatorField"></span></p>
- <p><label>$i18n.getString( "aggregationDataElement" ):</label><br><span id="aggregationDataElementField"></span></p>
- <p><label>$i18n.getString( "optionCombo" ):</label><br><span id="optionComboField"></span></p>
- <p><label>$i18n.getString( "aggregationExpression" ):</label><br><span id="aggregationExpressionField"></span></p>
+ <p><label>$i18n.getString( "aggregation_data_element" ):</label><br><span id="aggregationDataElementField"></span></p>
+ <p><label>$i18n.getString( "option_combo" ):</label><br><span id="optionComboField"></span></p>
+ <p><label>$i18n.getString( "aggregation_expression" ):</label><br><span id="aggregationExpressionField"></span></p>
</div>
</td>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2011-07-22 03:53:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/caseaggregation.js 2011-07-28 06:36:51 +0000
@@ -11,34 +11,30 @@
clearList( byId('aggregationDataElementId'));
return;
}
- $.ajax({
- url: 'getAggDataElements.action?dataElementGroupId=' + dataElementGroupId,
- cache: false,
- dataType: "xml",
- success: getAggDataElementsCompleted
- });
+
+ $.post( 'getAggDataElements.action', { dataElementGroupId:dataElementGroupId }, getAggDataElementsCompleted );
}
function getAggDataElementsCompleted( dataelementElement )
{
- var de = document.getElementById( 'aggregationDataElementId' );
-
- clearList( de );
-
- var dataElementList = dataelementElement.getElementsByTagName( 'dataelement' );
-
- for ( var i = 0; i < dataElementList.length; i++ )
- {
- var id = dataElementList[ i ].getElementsByTagName("id")[0].firstChild.nodeValue;
- var name = dataElementList[ i ].getElementsByTagName("name")[0].firstChild.nodeValue;
+ var de = document.getElementById( 'aggregationDataElementId' );
+
+ clearList( de );
+
+ var dataElementList = $(dataelementElement).find( 'dataelement' );
+
+ $( dataElementList ).each( function( i, item )
+ {
+ var id = $(item).find("id").text();
+ var name = $(item).find("name").text();
var option = document.createElement("option");
option.value = id;
option.text = name;
option.title = name;
- de.add(option, null);
- }
+ de.add(option, null);
+ } );
}
//------------------------------------------------------------------------------
@@ -56,12 +52,7 @@
return;
}
- $.ajax({
- url: 'getProgramStages.action?programId=' + programId,
- cache: false,
- dataType: "xml",
- success: getProgramStagesCompleted
- });
+ $.post( 'getProgramStages.action', { programId:programId }, getProgramStagesCompleted );
}
function getProgramStagesCompleted( programstageElement )
@@ -100,12 +91,7 @@
var programStage = document.getElementById( 'programStage' );
var psId = programStage.options[ programStage.selectedIndex ].value;
- $.ajax({
- url: 'getPSDataElements.action?psId=' + psId,
- cache: false,
- dataType: "xml",
- success: getPrgramStageDataElementsCompleted
- });
+ $.post( 'getPSDataElements.action', { psId:psId }, getPrgramStageDataElementsCompleted );
}
function getPrgramStageDataElementsCompleted( dataelementElement )
@@ -160,12 +146,7 @@
function showCaseAggregationDetails( caseAggregationId )
{
- $.ajax({
- url: 'getCaseAggregation.action?id=' + caseAggregationId,
- cache: false,
- dataType: "xml",
- success: caseAggregationReceived
- });
+ $.post( 'getCaseAggregation.action', { id:caseAggregationId }, caseAggregationReceived );
}
function caseAggregationReceived( caseAggregationElement )
@@ -186,12 +167,12 @@
function getConditionDescription()
{
- $.post("getCaseAggregationDescription.action",
- {
- condition: getFieldValue('aggregationCondition')
- },
- function (data)
+ $.post( 'getCaseAggregationDescription.action',
+ {
+ condition:getFieldValue('aggregationCondition')
+ },function (data)
{
byId('aggregationDescription').innerHTML = data;
},'html');
-}
\ No newline at end of file
+}
+