=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-04-18 04:03:50 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-04-18 10:28:39 +0000 @@ -91,9 +91,9 @@ List searchProgramStageInstances( ProgramStage programStage, Map searchingIdenKeys, Map searchingAttrKeys, Map searchingDEKeys, Collection orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max ); - Grid getTabularReport( ProgramStage programStage, List hiddenCols, List idens, List attributes, List dataElements, Map searchingIdenKeys, Map searchingAttrKeys, Map searchingDEKeys, Collection orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n ); + Grid getTabularReport( ProgramStage programStage, List hiddenCols, List idens, List fixedAttributes, List attributes, List dataElements, Map searchingIdenKeys, Map searchingAttrKeys, Map searchingDEKeys, Collection orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n ); - Grid getTabularReport( ProgramStage programStage, List hiddenCols, List idens, List attributes, List dataElements, Map searchingIdenKeys, Map searchingAttrKeys, Map searchingDEKeys, Collection orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n ); + Grid getTabularReport( ProgramStage programStage, List hiddenCols, List idens, List fixedAttributes, List attributes, List dataElements, Map searchingIdenKeys, Map searchingAttrKeys, Map searchingDEKeys, Collection orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n ); int countProgramStageInstances( ProgramStage programStage, Map searchingIdenKeys, Map searchingAttrKeys, Map searchingDEKeys, Collection orgunitIds, Date startDate, Date endDate ); === modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java' --- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-04-18 07:44:54 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-04-18 10:28:39 +0000 @@ -34,6 +34,7 @@ import java.util.List; import java.util.Map; +import org.apache.commons.lang.StringUtils; import org.hisp.dhis.common.Grid; import org.hisp.dhis.common.GridHeader; import org.hisp.dhis.dataelement.DataElement; @@ -233,8 +234,8 @@ } public Grid getTabularReport( ProgramStage programStage, List hiddenCols, - List idens, List attributes, List dataElements, - Map searchingIdenKeys, Map searchingAttrKeys, + List idens, List fixedAttributes, List attributes, + List dataElements, Map searchingIdenKeys, Map searchingAttrKeys, Map searchingDEKeys, Collection orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n ) { @@ -242,13 +243,13 @@ searchingIdenKeys, searchingAttrKeys, searchingDEKeys, orgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc, min, max ); - return createTabularGrid( level, hiddenCols, programStage, programStageInstances, idens, attributes, - dataElements, startDate, endDate, format, i18n ); + return createTabularGrid( level, hiddenCols, programStage, programStageInstances, idens, fixedAttributes, + attributes, dataElements, startDate, endDate, format, i18n ); } public Grid getTabularReport( ProgramStage programStage, List hiddenCols, - List idens, List attributes, List dataElements, - Map searchingIdenKeys, Map searchingAttrKeys, + List idens, List fixedAttributes, List attributes, + List dataElements, Map searchingIdenKeys, Map searchingAttrKeys, Map searchingDEKeys, Collection orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n ) { @@ -256,8 +257,8 @@ searchingIdenKeys, searchingAttrKeys, searchingDEKeys, orgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc ); - return createTabularGrid( level, hiddenCols, programStage, programStageInstances, idens, attributes, - dataElements, startDate, endDate, format, i18n ); + return createTabularGrid( level, hiddenCols, programStage, programStageInstances, idens, fixedAttributes, + attributes, dataElements, startDate, endDate, format, i18n ); } @Override @@ -344,8 +345,8 @@ private Grid createTabularGrid( Integer level, List hiddenCols, ProgramStage programStage, List programStageInstances, List idens, - List attributes, List dataElements, Date startDate, Date endDate, - I18nFormat format, I18n i18n ) + List fixedAttributes, List attributes, List dataElements, + Date startDate, Date endDate, I18nFormat format, I18n i18n ) { Grid grid = new ListGrid(); @@ -392,6 +393,15 @@ // Report-date grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) ); + // Fixed Attributes + if ( fixedAttributes != null && fixedAttributes.size() > 0 ) + { + for ( String fixedAttribute : fixedAttributes ) + { + grid.addHeader( new GridHeader( i18n.getString( fixedAttribute), false, true ) ); + } + } + // Identifier types if ( idens != null && idens.size() > 0 ) { @@ -456,6 +466,20 @@ grid.addValue( format.formatDate( programStageInstance.getExecutionDate() ) ); // ------------------------------------------------------------- + // Fixed Attributes + // ------------------------------------------------------------- + + if ( fixedAttributes != null && fixedAttributes.size() > 0 ) + { + Patient patient = programStageInstance.getProgramInstance().getPatient(); + for ( String fixedAttribute : fixedAttributes ) + { + String value = getValueByFixedAttribute( patient, fixedAttribute ).toString(); + grid.addValue( value ); + } + } + + // ------------------------------------------------------------- // Add patient-identifiers // ------------------------------------------------------------- @@ -544,4 +568,18 @@ return hierarchyOrgunit; } + private Object getValueByFixedAttribute( Patient patient, String propertyName ) + { + propertyName = StringUtils.capitalize( propertyName ); + + try + { + return Patient.class.getMethod( "get" + propertyName ).invoke( patient ); + } + catch ( Exception e ) + { + return ""; + } + } + } === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java 2012-04-18 07:44:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java 2012-04-18 10:28:39 +0000 @@ -63,7 +63,7 @@ extends ActionPagingSupport { private String PREFIX_ORGANISTAION_UNIT = "org"; - + private String PREFIX_IDENTIFIER_TYPE = "iden"; private String PREFIX_PATIENT_ATTRIBUTE = "attr"; @@ -163,7 +163,7 @@ { this.searchingValues = searchingValues; } - + private boolean orderByOrgunitAsc; public void setOrderByOrgunitAsc( boolean orderByOrgunitAsc ) @@ -255,6 +255,13 @@ return valueTypes; } + private List fixedAttributes = new ArrayList(); + + public void setFixedAttributes( List fixedAttributes ) + { + this.fixedAttributes = fixedAttributes; + } + private Map> mapSuggestedValues = new HashMap>(); public Map> getMapSuggestedValues() @@ -269,7 +276,7 @@ private Map searchingDEKeys = new HashMap(); private List hiddenCols = new ArrayList(); - + // ------------------------------------------------------------------------- // Implementation Action // ------------------------------------------------------------------------- @@ -332,17 +339,17 @@ this.paging = createPaging( totalRecords ); - grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes, patientAttributes, - dataElements, searchingIdenKeys, searchingAttrKeys, searchingDEKeys, orgunitIds, level, startValue, - endValue, orderByOrgunitAsc, orderByExecutionDateByAsc, paging.getStartPos(), paging.getPageSize(), - format, i18n ); + grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes, + fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys, + searchingDEKeys, orgunitIds, level, startValue, endValue, orderByOrgunitAsc, orderByExecutionDateByAsc, + paging.getStartPos(), paging.getPageSize(), format, i18n ); return SUCCESS; } - grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes, patientAttributes, - dataElements, searchingIdenKeys, searchingAttrKeys, searchingDEKeys, orgunitIds, level, startValue, - endValue, orderByOrgunitAsc, orderByExecutionDateByAsc, format, i18n ); + grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes, + fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys, searchingDEKeys, + orgunitIds, level, startValue, endValue, orderByOrgunitAsc, orderByExecutionDateByAsc, format, i18n ); return type; } @@ -369,7 +376,7 @@ String objectType = infor[0]; int objectId = Integer.parseInt( infor[1] ); - if( objectType.equals( PREFIX_ORGANISTAION_UNIT )) + if ( objectType.equals( PREFIX_ORGANISTAION_UNIT ) ) { hiddenCols.add( Boolean.parseBoolean( infor[2] ) ); } @@ -397,7 +404,7 @@ { PatientAttribute attribute = patientAttributeService.getPatientAttribute( objectId ); patientAttributes.add( attribute ); - + // Get value-type && suggested-values valueTypes.add( attribute.getValueType() ); mapSuggestedValues.put( index, getSuggestedAttrValues( attribute ) ); @@ -418,7 +425,7 @@ { DataElement dataElement = dataElementService.getDataElement( objectId ); dataElements.add( dataElement ); - + // Get value-type && suggested-values String valueType = (dataElement.getOptionSet() != null) ? VALUE_TYPE_OPTION_SET : dataElement.getType(); valueTypes.add( valueType ); === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributesAction.java' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributesAction.java 2012-04-11 06:25:02 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributesAction.java 2012-04-18 10:28:39 +0000 @@ -109,7 +109,9 @@ throws Exception { Program program = programService.getProgram( programId ); - patientAttributes = attributeService.getPatientAttributes( program ); + patientAttributes = attributeService.getAllPatientAttributes(); + + patientAttributes.addAll( attributeService.getPatientAttributes( program ) ); if ( attributeGroupId == null ) { === 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 2012-04-18 07:44:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-04-18 10:28:39 +0000 @@ -24,6 +24,8 @@ sort_by=Sort By no_value=Please Select provided_elsewhere=Provided elsewhere +fixed_attributes=Fixed attributes +dynamic_attributes=Dynamic attributes attributes=Attributes enrolled_in_program=Enrolled in Programs saving_value_failed_status_code=Saving value failed with status code @@ -316,4 +318,12 @@ em_no_orgunits = Please select an organisation unit. reset = Reset no = No. -options = Options \ No newline at end of file +options = Options +fullName = Full name +gender = Gender +birthDate = Date of Birth +bloodGroup = Blood group +phoneNumber = Phone number +deathdate = Death date +registrationDate = Date of registration +dobType = DOB Type \ No newline at end of file === 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 2012-04-18 07:44:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-04-18 10:28:39 +0000 @@ -136,7 +136,10 @@ patientAttribute: {}, programStage: {}, dataelement: {}, - organisationunit: {} + organisationunit: {}, + fixedAttributes:{ + checkbox: [] + } }, options: {}, toolbar: { @@ -588,6 +591,15 @@ p.programStageId = TR.cmp.params.programStage.getValue(); p.currentPage = this.currentPage; + // Get fixed attributes + p.fixedAttributes = []; + var fixedAttributes = TR.cmp.params.fixedAttributes.checkbox; + Ext.Array.each(fixedAttributes, function(item) { + if( item.value ) + p.fixedAttributes.push( item.paramName ); + }); + + // Get searching values p.searchingValues = []; if( TR.store.datatable && TR.store.datatable.data.length) { @@ -639,6 +651,13 @@ p += "&programStageId=" + TR.cmp.params.programStage.getValue(); p += "&type=" + type; + // Get fixed attributes + var fixedAttributes = TR.cmp.params.fixedAttributes.checkbox; + Ext.Array.each(fixedAttributes, function(item) { + if( item.value ) + p+="&fixedAttributes=" + item.paramName; + }); + if( TR.store.datatable && TR.store.datatable.data.length) { var grid = TR.datatable.datatable; @@ -756,10 +775,10 @@ + TR.cmp.params.patientAttribute.selected.store.data.length + TR.cmp.params.dataelement.selected.store.data.length; - var orgunitColsLen = TR.value.columns.length - paramsLen - 2; + var orgunitColsLen = TR.value.columns.length - paramsLen ; var index = 1; - for( index=1; index < orgunitColsLen + 1; index++ ) + for( index=1; index < orgunitColsLen ; index++ ) { cols[index] = { header: TR.value.columns[index], @@ -774,6 +793,7 @@ } } + cols[index] = { header: TR.i18n.report_date, dataIndex: 'col' + index, @@ -785,7 +805,6 @@ sortDescText: TR.i18n.desc }; - index++; TR.cmp.params.identifierType.selected.store.each( function(r) { var dataIndex = "col" + index; cols[index] = { @@ -820,7 +839,7 @@ groupable: true, emptyText: TR.i18n.et_no_data, editor: { - xtype: TR.value.valueTypes[index - orgunitColsLen - 2].valueType, + xtype: TR.value.valueTypes[index].valueType, queryMode: 'local', editable: true, valueField: 'name', @@ -828,7 +847,7 @@ allowBlank: true, store: new Ext.data.ArrayStore({ fields: ['name'], - data: TR.value.valueTypes[index - orgunitColsLen - 2].suggestedValues, + data: TR.value.valueTypes[index].suggestedValues, }) } }; @@ -849,7 +868,7 @@ draggable: false, groupable: true, editor: { - xtype: TR.value.valueTypes[index - orgunitColsLen - 2].valueType, + xtype: TR.value.valueTypes[index].valueType, queryMode: 'local', editable: true, valueField: 'name', @@ -857,7 +876,7 @@ allowBlank: true, store: new Ext.data.ArrayStore({ fields: ['name'], - data: TR.value.valueTypes[index - orgunitColsLen - 2].suggestedValues, + data: TR.value.valueTypes[index].suggestedValues, }) } }; @@ -1443,6 +1462,115 @@ hideCollapseTool: true, items: [ { + xtype: 'label', + text: TR.i18n.fixed_attributes + }, + { + xtype: 'panel', + layout: 'column', + bodyStyle: 'border-style:none; padding:10px 10px;', + items: [ + { + xtype: 'panel', + layout: 'anchor', + bodyStyle: 'border-style:none; ', + defaults: { + labelSeparator: '', + listeners: { + added: function(chb) { + if (chb.xtype === 'checkbox') { + TR.cmp.params.fixedAttributes.checkbox.push(chb); + } + } + } + }, + items: [ + { + xtype: 'checkbox', + paramName: 'fullName', + boxLabel: TR.i18n.full_name + }, + { + xtype: 'checkbox', + paramName: 'gender', + boxLabel: TR.i18n.gender + }, + { + xtype: 'checkbox', + paramName: 'birthDate', + boxLabel: TR.i18n.date_of_birth + } + ] + }, + { + xtype: 'panel', + layout: 'anchor', + bodyStyle: 'border-style:none; padding:0 0 0 32px', + defaults: { + labelSeparator: '', + listeners: { + added: function(chb) { + if (chb.xtype === 'checkbox') { + TR.cmp.params.fixedAttributes.checkbox.push(chb); + } + } + } + }, + items: [ + { + xtype: 'checkbox', + paramName: 'bloodGroup', + boxLabel: TR.i18n.blood_group + }, + { + xtype: 'checkbox', + paramName: 'phoneNumber', + boxLabel: TR.i18n.phone_number + }, + { + xtype: 'checkbox', + paramName: 'deathdate', + boxLabel: TR.i18n.death_date + } + ] + }, + + { + xtype: 'panel', + layout: 'anchor', + bodyStyle: 'border-style:none; padding:0 0 0 32px', + defaults: { + labelSeparator: '', + listeners: { + added: function(chb) { + if (chb.xtype === 'checkbox') { + TR.cmp.params.fixedAttributes.checkbox.push(chb); + } + } + } + }, + items: [ + { + xtype: 'checkbox', + paramName: 'registrationDate', + boxLabel: TR.i18n.registration_date + }, + { + xtype: 'checkbox', + paramName: 'dobType', + boxLabel: TR.i18n.dob_type + } + ] + } + + ] + }, + + { + xtype: 'label', + text: TR.i18n.dynamic_attributes + }, + { 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 2012-04-18 07:44:54 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm 2012-04-18 10:28:39 +0000 @@ -42,5 +42,15 @@ reset:'$encoder.jsEscape($i18n.getString( 'reset' ) , "'")', no:'$encoder.jsEscape($i18n.getString( 'no' ) , "'")', asc:'$encoder.jsEscape($i18n.getString( 'asc' ) , "'")', -desc:'$encoder.jsEscape($i18n.getString( 'desc' ) , "'")' +desc:'$encoder.jsEscape($i18n.getString( 'desc' ) , "'")', +full_name:'$encoder.jsEscape($i18n.getString( 'full_name' ) , "'")', +gender:'$encoder.jsEscape($i18n.getString( 'gender' ) , "'")', +date_of_birth:'$encoder.jsEscape($i18n.getString( 'date_of_birth' ) , "'")', +blood_group:'$encoder.jsEscape($i18n.getString( 'blood_group' ) , "'")', +phone_number:'$encoder.jsEscape($i18n.getString( 'phone_number' ) , "'")', +death_date:'$encoder.jsEscape($i18n.getString( 'death_date' ) , "'")', +registration_date:'$encoder.jsEscape($i18n.getString( 'registration_date' ) , "'")', +dob_type:'$encoder.jsEscape($i18n.getString( 'dob_type' ) , "'")', +fixed_attributes:'$encoder.jsEscape($i18n.getString( 'fixed_attributes' ) , "'")', +dynamic_attributes:'$encoder.jsEscape($i18n.getString( 'dynamic_attributes' ) , "'")', }; \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm' --- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm 2012-04-18 04:03:50 +0000 +++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm 2012-04-18 10:28:39 +0000 @@ -7,7 +7,7 @@ #foreach( $col in $grid.getVisibleHeaders() ) #if ($velocityCount <= $noOrgunit + 1) { - "valueType": "", + "valueType": "textfield", "suggestedValues": [] }, #end