dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22933
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11147: Add functionality for fitlering data elements by section of selected program stage in tabular rep...
------------------------------------------------------------
revno: 11147
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-06-06 10:06:52 +0700
message:
Add functionality for fitlering data elements by section of selected program stage in tabular report.
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comparator/PatientAttributeSortOrderComparator.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageSections.vm
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.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/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comparator/PatientAttributeSortOrderComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comparator/PatientAttributeSortOrderComparator.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/comparator/PatientAttributeSortOrderComparator.java 2013-06-06 03:06:52 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2004-2012, 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.comparator;
+
+import java.util.Comparator;
+
+import org.hisp.dhis.patient.PatientAttribute;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ PatientAttributeSortOrderComparator.java Jun 5, 2013 10:24:33 AM $
+ */
+public class PatientAttributeSortOrderComparator
+ implements Comparator<PatientAttribute>
+{
+ public int compare( PatientAttribute patientAttribute0, PatientAttribute patientAttribute1 )
+ {
+ if ( patientAttribute0.getSortOrderInVisitSchedule() == null
+ || patientAttribute0.getSortOrderInVisitSchedule() == 0 )
+ {
+ return patientAttribute0.getName().compareTo( patientAttribute1.getName() );
+ }
+
+ if ( patientAttribute1.getSortOrderInVisitSchedule() == null
+ || patientAttribute1.getSortOrderInVisitSchedule() == 0 )
+ {
+ return patientAttribute0.getName().compareTo( patientAttribute1.getName() );
+ }
+
+ return patientAttribute0.getSortOrderInVisitSchedule() - patientAttribute1.getSortOrderInVisitSchedule();
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetProgramStageSectionsAction.java 2013-06-06 03:06:52 +0000
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2004-2012, 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.caseentry.action.report;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.program.ProgramStageSection;
+import org.hisp.dhis.program.ProgramStageService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $ GetProgramStageSectionsAction.java Jun 5, 2013 1:43:18 PM $
+ */
+public class GetProgramStageSectionsAction
+ implements Action
+{
+
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ProgramStageService programStageService;
+
+ public void setProgramStageService( ProgramStageService programStageService )
+ {
+ this.programStageService = programStageService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input/output
+ // -------------------------------------------------------------------------
+
+ private Integer programStageId;
+
+ public void setProgramStageId( Integer programStageId )
+ {
+ this.programStageId = programStageId;
+ }
+
+ private List<ProgramStageSection> sections;
+
+ public List<ProgramStageSection> getSections()
+ {
+ return sections;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ sections = new ArrayList<ProgramStageSection>( programStageService.getProgramStage( programStageId )
+ .getProgramStageSections() );
+
+ return SUCCESS;
+ }
+
+}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java 2012-04-11 06:25:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java 2013-06-06 03:06:52 +0000
@@ -30,6 +30,8 @@
import java.util.Collection;
import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.program.ProgramStageSection;
+import org.hisp.dhis.program.ProgramStageSectionService;
import org.hisp.dhis.program.ProgramStageService;
import com.opensymphony.xwork2.Action;
@@ -53,6 +55,13 @@
this.programStageService = programStageService;
}
+ private ProgramStageSectionService programStageSectionService;
+
+ public void setProgramStageSectionService( ProgramStageSectionService programStageSectionService )
+ {
+ this.programStageSectionService = programStageSectionService;
+ }
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
@@ -64,6 +73,13 @@
this.programStageId = programStageId;
}
+ private Integer sectionId;
+
+ public void setSectionId( Integer sectionId )
+ {
+ this.sectionId = sectionId;
+ }
+
private Collection<ProgramStageDataElement> psDataElements;
public Collection<ProgramStageDataElement> getPsDataElements()
@@ -83,6 +99,11 @@
{
psDataElements = programStageService.getProgramStage( programStageId ).getProgramStageDataElements();
}
+ else if( sectionId != null )
+ {
+ ProgramStageSection section = programStageSectionService.getProgramStageSection( sectionId );
+ psDataElements = section.getProgramStageDataElements();
+ }
return SUCCESS;
}
=== 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 2013-05-24 09:10:42 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-06-06 03:06:52 +0000
@@ -215,8 +215,10 @@
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
- <property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+ <property name="patientAttributeService"
+ ref="org.hisp.dhis.patient.PatientAttributeService" />
+ <property name="patientAttributeValueService"
+ ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
</bean>
<!-- Single-event DataEntry -->
@@ -894,6 +896,8 @@
class="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction"
scope="prototype">
<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ <property name="programStageSectionService"
+ ref="org.hisp.dhis.program.ProgramStageSectionService" />
</bean>
<bean
@@ -967,7 +971,6 @@
ref="org.hisp.dhis.patientreport.PatientTabularReportService" />
</bean>
-
<bean
id="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction"
class="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction"
@@ -976,6 +979,11 @@
ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
</bean>
+ <bean id="org.hisp.dhis.caseentry.action.report.GetProgramStageSectionsAction"
+ class="org.hisp.dhis.caseentry.action.report.GetProgramStageSectionsAction"
+ scope="prototype">
+ <property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+ </bean>
<!-- Patient Aggregate Report -->
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-05-30 09:08:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2013-06-06 03:06:52 +0000
@@ -654,4 +654,5 @@
toggle_risk_status = Toggle risk status
with = with
status_events = events
-use_data_element_form_names = Use data element form names
\ No newline at end of file
+use_data_element_form_names = Use data element form names
+section = Section
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-05-28 06:42:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml 2013-06-06 03:06:52 +0000
@@ -865,6 +865,13 @@
</result>
<param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
</action>
+
+ <action name="loadProgramStageSections"
+ class="org.hisp.dhis.caseentry.action.report.GetProgramStageSectionsAction">
+ <result name="success" type="velocity-json">/dhis-web-caseentry/jsonProgramStageSections.vm
+ </result>
+ <param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
+ </action>
<action name="loadDataElements"
class="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction">
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2013-05-30 09:08:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2013-06-06 03:06:52 +0000
@@ -46,6 +46,7 @@
initialize: 'tabularInitialize.action',
patientproperties_get: 'loadPatientProperties.action',
programstages_get: 'loadReportProgramStages.action',
+ programstagesections_get: 'loadProgramStageSections.action',
dataelements_get: 'loadDataElements.action',
organisationunitchildren_get: 'getOrganisationUnitChildren.action',
organisationunit_getbygroup: 'getOrganisationUnitPathsByGroup.action',
@@ -1506,12 +1507,31 @@
}
else
{
+ var programStageId = TR.store.programStage.data.items[0].raw.id;
+
Ext.getCmp('programStageCombobox').disable();
- var programStageId = TR.store.programStage.data.items[0].raw.id;
Ext.getCmp('programStageCombobox').setValue( programStageId );
+ // Load sections if any
+
+ var store = TR.store.programStageSection;
+ TR.store.programStageSection.loadData([],false);
+ if( !TR.store.programStageSection.isLoad )
+ {
+ store.loadData([],false);
+ }
+ store.parent = programStageId;
+
+ if (TR.util.store.containsParent(store)) {
+ TR.util.store.loadFromStorage(store);
+ }
+ else {
+ store.load({params: {programStageId: programStageId}});
+ }
+
// Load data element list
- var store = TR.store.dataelement.available;
+
+ store = TR.store.dataelement.available;
TR.store.dataelement.available.loadData([],false);
if( !TR.store.programStage.isLoadFromFavorite)
{
@@ -1530,6 +1550,39 @@
}
}
}),
+ programStageSection: Ext.create('Ext.data.Store', {
+ fields: ['id', 'name'],
+ proxy: {
+ type: 'ajax',
+ url: TR.conf.finals.ajax.path_commons + TR.conf.finals.ajax.programstagesections_get,
+ reader: {
+ type: 'json',
+ root: 'sections'
+ }
+ },
+ isLoad: false,
+ listeners:{
+ load: function(s) {
+ Ext.override(Ext.LoadMask, {
+ onHide: function() {
+ this.callParent();
+ }
+ });
+
+ if( TR.store.programStageSection.data.items.length == 0 ){
+ Ext.getCmp('sectionCombobox').setVisible(false);
+ }
+ else{
+ Ext.getCmp('sectionCombobox').setVisible(true);
+ TR.store.programStageSection.insert(0, {
+ 'id': "",
+ 'name': TR.i18n.please_select
+ });
+ }
+ Ext.getCmp('sectionCombobox').setValue( "" );
+ }
+ }
+ }),
dataelement: {
available: Ext.create('Ext.data.Store', {
fields: ['id', 'uid', 'name', 'compulsory', 'valueType'],
@@ -4773,6 +4826,8 @@
TR.store.patientProperty.available.removeAll();
TR.store.patientProperty.selected.removeAll();
}
+
+ TR.store.programStageSection.loadData([],false);
// PROGRAM-STAGE
var storeProgramStage = TR.store.programStage;
@@ -4811,10 +4866,27 @@
TR.cmp.params.programStage = this;
},
select: function(cb) {
+ var programStageId = cb.getValue();
+
+ // Get section from the selected program stage
+
+ var sectionStore = TR.store.programStageSection;
+ sectionStore.loadData([],false);
+ sectionStore.parent = programStageId;
+
+ if (TR.util.store.containsParent(sectionStore)) {
+ TR.util.store.loadFromStorage(sectionStore);
+ }
+ else {
+ sectionStore.load({params: {programStageId: cb.getValue()}});
+ }
+
+ // Get data element from the selected program stage
+
TR.state.isFilter = false;
var store = TR.store.dataelement.available;
TR.store.dataelement.selected.loadData([],false);
- store.parent = cb.getValue();
+ store.parent = programStageId;
if (TR.util.store.containsParent(store)) {
TR.util.store.loadFromStorage(store);
@@ -5960,6 +6032,43 @@
hideCollapseTool: true,
items: [
{
+ xtype: 'combobox',
+ cls: 'tr-combo',
+ id: 'sectionCombobox',
+ fieldLabel: TR.i18n.section,
+ emptyText: TR.i18n.please_select,
+ queryMode: 'local',
+ editable: false,
+ valueField: 'id',
+ displayField: 'name',
+ width: TR.conf.layout.west_fieldset_width - 20,
+ store: TR.store.programStageSection,
+ listeners: {
+ added: function() {
+ TR.cmp.settings.programStageSections = this;
+ },
+ select: function(cb) {
+ var store = TR.store.dataelement.available;
+ TR.store.dataelement.selected.loadData([],false);
+ store.parent = cb.getValue();
+
+ if (TR.util.store.containsParent(store)) {
+ TR.util.store.loadFromStorage(store);
+ TR.util.multiselect.filterAvailable(TR.cmp.params.dataelement.available, TR.cmp.params.dataelement.selected);
+ }
+ else {
+ if( cb.getValue() == '' ){
+ var programStageId = TR.cmp.params.programStage.getValue();
+ store.load({params: {programStageId: programStageId}});
+ }
+ else{
+ store.load({params: {sectionId: cb.getValue()}});
+ }
+ }
+ }
+ }
+ },
+ {
xtype: 'panel',
layout: 'column',
bodyStyle: 'border-style:none',
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2013-05-30 09:08:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2013-06-06 03:06:52 +0000
@@ -194,5 +194,6 @@
can_edit_and_view: '$encoder.jsEscape($i18n.getString( 'can_edit_and_view' ) , "'")',
public_access: '$encoder.jsEscape($i18n.getString( 'public_access' ) , "'")',
display_orgunit_code: '$encoder.jsEscape($i18n.getString( 'display_orgunit_code' ) , "'")',
-use_data_element_form_names: '$encoder.jsEscape($i18n.getString( 'use_data_element_form_names' ) , "'")'
+use_data_element_form_names: '$encoder.jsEscape($i18n.getString( 'use_data_element_form_names' ) , "'")',
+section: '$encoder.jsEscape($i18n.getString( 'section' ) , "'")'
};
\ No newline at end of file
=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageSections.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageSections.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramStageSections.vm 2013-06-06 03:06:52 +0000
@@ -0,0 +1,10 @@
+#set( $size = ${sections.size()} )
+{ "sections": [
+ #foreach( ${section} in $!{sections} )
+ {
+ "id": "${section.id}",
+ "name": "$!encoder.jsonEncode( ${section.displayName} )"
+ }#if( $velocityCount < $size ),#end
+ #end
+ ]
+}
\ No newline at end of file