dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17438
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6937: (patient) Improve Tabular report.
------------------------------------------------------------
revno: 6937
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-05-15 09:36:43 +0700
message:
(patient) Improve Tabular report.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
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/hibernate/HibernateProgramStageInstanceStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
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/resources/org/hisp/dhis/caseentry/i18n_module.properties
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/jsonTabularReport.vm
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.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/patientreport/PatientTabularReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java 2012-05-10 01:21:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java 2012-05-15 02:36:43 +0000
@@ -49,10 +49,16 @@
{
private static final long serialVersionUID = -2880334669266185058L;
+ public static String PREFIX_EXECUTION_DATE = "executiondate";
+
+ public static String PREFIX_ORGUNIT = "orgunit";
+
public static String PREFIX_META_DATA = "meta";
-
+
public static String PREFIX_IDENTIFIER_TYPE = "iden";
+ public static String PREFIX_FIXED_ATTRIBUTE = "fixedAttr";
+
public static String PREFIX_PATIENT_ATTRIBUTE = "attr";
public static String PREFIX_DATA_ELEMENT = "de";
=== 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-05-02 08:15:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2012-05-15 02:36:43 +0000
@@ -88,9 +88,7 @@
List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed );
List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed );
-
- List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max );
-
+
Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols, List<PatientIdentifierType> idens, List<String> fixedAttributes, List<PatientAttribute> attributes, List<DataElement> dataElements, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n );
Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols, List<PatientIdentifierType> idens, List<String> fixedAttributes, List<PatientAttribute> attributes, List<DataElement> dataElements, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n );
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-05-02 08:15:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2012-05-15 02:36:43 +0000
@@ -71,9 +71,13 @@
List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
- List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max );
+ /** Get all values and put it on the map.
+ * @return key: key-word_object-id
+ * value: value
+ **/
+ Map<String, String> get( ProgramStage programStage, List<String> keys, Map<Integer,String> searchingIdenKeys, List<String> fixedAttributes, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max );
- List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc );
+ Map<String, String> get( ProgramStage programStage, List<String> keys, Map<Integer,String> searchingIdenKeys, List<String> fixedAttributes, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc );
int count( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingKeys, Collection<Integer> 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-05-02 08:15:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2012-05-15 02:36:43 +0000
@@ -34,7 +34,6 @@
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;
@@ -44,13 +43,10 @@
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.patient.Patient;
import org.hisp.dhis.patient.PatientAttribute;
-import org.hisp.dhis.patient.PatientIdentifier;
-import org.hisp.dhis.patient.PatientIdentifierService;
import org.hisp.dhis.patient.PatientIdentifierType;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
-import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
import org.hisp.dhis.patientdatavalue.PatientDataValue;
import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+import org.hisp.dhis.patientreport.PatientTabularReport;
import org.hisp.dhis.system.grid.ListGrid;
import org.springframework.transaction.annotation.Transactional;
@@ -87,20 +83,6 @@
this.organisationUnitService = organisationUnitService;
}
- private PatientIdentifierService identifierService;
-
- public void setIdentifierService( PatientIdentifierService identifierService )
- {
- this.identifierService = identifierService;
- }
-
- private PatientAttributeValueService patientAttributeValueService;
-
- public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
- {
- this.patientAttributeValueService = patientAttributeValueService;
- }
-
// -------------------------------------------------------------------------
// Implementation methods
// -------------------------------------------------------------------------
@@ -215,50 +197,46 @@
return programStageInstanceStore.get( patient, completed );
}
- public List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage,
- Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
- Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate,
- boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max )
- {
- return programStageInstanceStore.get( programStage, searchingIdenKeys, searchingAttrKeys, searchingDEKeys,
- upperOrgunitIds, bottomOrgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc, min, max );
- }
-
- public List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage,
- Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
- Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate,
- boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc )
- {
- return programStageInstanceStore.get( programStage, searchingIdenKeys, searchingAttrKeys, searchingDEKeys,
- upperOrgunitIds, bottomOrgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc );
- }
-
- public Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols,
- List<PatientIdentifierType> idens, List<String> fixedAttributes, List<PatientAttribute> attributes,
- List<DataElement> dataElements, Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
- Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate,
- boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n )
- {
- List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage,
- searchingIdenKeys, searchingAttrKeys, searchingDEKeys, upperOrgunitIds, bottomOrgunitIds, startDate, endDate, orderByOrgunitAsc,
- orderByExecutionDateByAsc, min, max );
-
- return createTabularGrid( level, hiddenCols, programStage, programStageInstances, idens, fixedAttributes,
- attributes, dataElements, startDate, endDate, format, i18n );
- }
-
- public Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols,
- List<PatientIdentifierType> idens, List<String> fixedAttributes, List<PatientAttribute> attributes,
- List<DataElement> dataElements, Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
- Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate,
- boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n )
- {
- List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage,
- searchingIdenKeys, searchingAttrKeys, searchingDEKeys, upperOrgunitIds, bottomOrgunitIds, startDate, endDate, orderByOrgunitAsc,
- orderByExecutionDateByAsc );
-
- return createTabularGrid( level, hiddenCols, programStage, programStageInstances, idens, fixedAttributes,
- attributes, dataElements, startDate, endDate, format, i18n );
+ public Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols,
+ List<PatientIdentifierType> idens, List<String> fixedAttributes, List<PatientAttribute> attributes,
+ List<DataElement> dataElements, Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
+ Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds,
+ Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc,
+ boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n )
+ {
+ List<String> keys = new ArrayList<String>();
+ Map<String, String> valuesMap = programStageInstanceStore.get( programStage, keys, searchingIdenKeys,
+ fixedAttributes, searchingAttrKeys, searchingDEKeys, upperOrgunitIds, bottomOrgunitIds, startDate, endDate,
+ orderByOrgunitAsc, orderByExecutionDateByAsc, min, max );
+
+ if ( keys != null && keys.size() > 0 )
+ {
+ return createTabularGrid( level, hiddenCols, programStage, keys, valuesMap, idens, fixedAttributes,
+ attributes, dataElements, startDate, endDate, format, i18n );
+ }
+
+ return null;
+ }
+
+ public Grid getTabularReport( ProgramStage programStage, List<Boolean> hiddenCols,
+ List<PatientIdentifierType> idens, List<String> fixedAttributes, List<PatientAttribute> attributes,
+ List<DataElement> dataElements, Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
+ Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds,
+ Collection<Integer> bottomOrgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc,
+ boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n )
+ {
+ List<String> keys = new ArrayList<String>();
+ Map<String, String> valuesMap = programStageInstanceStore.get( programStage, keys, searchingIdenKeys,
+ fixedAttributes, searchingAttrKeys, searchingDEKeys, upperOrgunitIds, bottomOrgunitIds, startDate, endDate,
+ orderByOrgunitAsc, orderByExecutionDateByAsc );
+
+ if ( keys != null && keys.size() > 0 )
+ {
+ return createTabularGrid( level, hiddenCols, programStage, keys, valuesMap, idens, fixedAttributes,
+ attributes, dataElements, startDate, endDate, format, i18n );
+ }
+
+ return null;
}
@Override
@@ -344,225 +322,217 @@
// -------------------------------------------------------------------------
private Grid createTabularGrid( Integer level, List<Boolean> hiddenCols, ProgramStage programStage,
- List<ProgramStageInstance> programStageInstances, List<PatientIdentifierType> idens,
+ List<String> keys, Map<String, String> valuesMap, List<PatientIdentifierType> idens,
List<String> fixedAttributes, List<PatientAttribute> attributes, List<DataElement> dataElements,
Date startDate, Date endDate, I18nFormat format, I18n i18n )
{
Grid grid = new ListGrid();
- if ( programStageInstances.size() > 0 )
- {
- Program program = programStage.getProgram();
-
- // ---------------------------------------------------------------------
- // Create a grid
- // ---------------------------------------------------------------------
-
- grid.setTitle( program.getName() + " - " + programStage.getName() );
- grid.setSubtitle( i18n.getString( "from" ) + " " + format.formatDate( startDate ) + " "
- + i18n.getString( "to" ) + " " + format.formatDate( endDate ) );
-
- // ---------------------------------------------------------------------
- // Headers
- // ---------------------------------------------------------------------
-
+ Program program = programStage.getProgram();
+
+ // ---------------------------------------------------------------------
+ // Create a grid
+ // ---------------------------------------------------------------------
+
+ grid.setTitle( program.getName() + " - " + programStage.getName() );
+ grid.setSubtitle( i18n.getString( "from" ) + " " + format.formatDate( startDate ) + " " + i18n.getString( "to" )
+ + " " + format.formatDate( endDate ) );
+
+ // ---------------------------------------------------------------------
+ // Headers
+ // ---------------------------------------------------------------------
+
+ // Report-date
+ grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) );
+
+ // Organisation units
+ int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
+
+ boolean hasMetaData = !(hiddenCols.size() == idens.size() + attributes.size() + dataElements.size());
+ int index = 0;
+
+ if ( !hasMetaData )
+ {
+ // Organisation units
+ for ( int i = level; i <= maxLevel; i++ )
+ {
+ grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i ).getName(),
+ false, true ) );
+ }
+
+ // Fixed Attributes
+ if ( fixedAttributes != null && fixedAttributes.size() > 0 )
+ {
+ for ( String fixedAttribute : fixedAttributes )
+ {
+ grid.addHeader( new GridHeader( i18n.getString( fixedAttribute ), false, true ) );
+ }
+ }
+ }
+ else
+ {
+ for ( int i = level; i <= maxLevel; i++ )
+ {
+ grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i ).getName(),
+ hiddenCols.get( index ), true ) );
+ index++;
+ }
+ // Fixed Attributes
+ if ( fixedAttributes != null && fixedAttributes.size() > 0 )
+ {
+ for ( String fixedAttribute : fixedAttributes )
+ {
+ grid.addHeader( new GridHeader( i18n.getString( fixedAttribute ), hiddenCols.get( index ), true ) );
+ index++;
+ }
+ }
+ }
+
+ // Identifier types
+ if ( idens != null && idens.size() > 0 )
+ {
+ for ( PatientIdentifierType identifierType : idens )
+ {
+ grid.addHeader( new GridHeader( identifierType.getName(), hiddenCols.get( index ), true ) );
+ index++;
+ }
+ }
+
+ // Attributes
+ if ( attributes != null && attributes.size() > 0 )
+ {
+ for ( PatientAttribute attribute : attributes )
+ {
+ grid.addHeader( new GridHeader( attribute.getName(), hiddenCols.get( index ), true ) );
+ index++;
+ }
+ }
+
+ // Dataelements
+ if ( dataElements != null && dataElements.size() > 0 )
+ {
+ for ( DataElement dataElement : dataElements )
+ {
+ grid.addHeader( new GridHeader( dataElement.getName(), hiddenCols.get( index ), true ) );
+ index++;
+ }
+ }
+
+ // ---------------------------------------------------------------------
+ // Get patient-identifiers
+ // ---------------------------------------------------------------------
+
+ for ( String key : keys )
+ {
+ grid.addRow();
+
+ // -------------------------------------------------------------
// Report-date
- grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) );
-
- // Organisation units
- int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
-
- boolean hasMetaData = !(hiddenCols.size() == idens.size() + attributes.size() + dataElements.size());
- int index = 0;
-
- if ( !hasMetaData )
- {
- // Organisation units
- for ( int i = level; i <= maxLevel; i++ )
- {
- grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i )
- .getName(), false, true ) );
- }
- // Fixed Attributes
- if ( fixedAttributes != null && fixedAttributes.size() > 0 )
- {
- for ( String fixedAttribute : fixedAttributes )
- {
- grid.addHeader( new GridHeader( i18n.getString( fixedAttribute), false, true ) );
- }
- }
- }
- else
- {
- for ( int i = level; i <= maxLevel; i++ )
- {
- grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i )
- .getName(), hiddenCols.get( index ), true ) );
- index++;
- }
- // Fixed Attributes
- if ( fixedAttributes != null && fixedAttributes.size() > 0 )
- {
- for ( String fixedAttribute : fixedAttributes )
- {
- grid.addHeader( new GridHeader( i18n.getString( fixedAttribute), hiddenCols.get( index ), true ) );
- index ++;
- }
- }
- }
-
- // Identifier types
- if ( idens != null && idens.size() > 0 )
- {
- for ( PatientIdentifierType identifierType : idens )
- {
- grid.addHeader( new GridHeader( identifierType.getName(), hiddenCols.get( index ), true ) );
- index++;
- }
- }
-
- // Attributes
- if ( attributes != null && attributes.size() > 0 )
- {
- for ( PatientAttribute attribute : attributes )
- {
- grid.addHeader( new GridHeader( attribute.getName(), hiddenCols.get( index ), true ) );
- index++;
- }
- }
-
- // Dataelements
- if ( dataElements != null && dataElements.size() > 0 )
- {
- for ( DataElement dataElement : dataElements )
- {
- grid.addHeader( new GridHeader( dataElement.getName(), hiddenCols.get( index ), true ) );
- index++;
- }
- }
-
- // ---------------------------------------------------------------------
- // Get patient-identifiers
- // ---------------------------------------------------------------------
-
- for ( ProgramStageInstance programStageInstance : programStageInstances )
- {
- grid.addRow();
-
- // -------------------------------------------------------------
- // Report-date
- // -------------------------------------------------------------
-
- grid.addValue( format.formatDate( programStageInstance.getExecutionDate() ) );
-
- // -------------------------------------------------------------
- // Add organisation units
- // -------------------------------------------------------------
-
- Map<Integer, String> hierarchyOrgunit = getHierarchyOrgunit(
- programStageInstance.getOrganisationUnit(), level );
-
- for ( int i = level; i <= maxLevel; i++ )
- {
- if ( hierarchyOrgunit.get( i ) != null )
- {
- grid.addValue( hierarchyOrgunit.get( i ) );
- }
- else
- {
- grid.addValue( "" );
- }
- }
-
- // -------------------------------------------------------------
- // Fixed Attributes
- // -------------------------------------------------------------
-
- if ( fixedAttributes != null && fixedAttributes.size() > 0 )
- {
- Patient patient = programStageInstance.getProgramInstance().getPatient();
- for ( String fixedAttribute : fixedAttributes )
- {
- String value = getValueByFixedAttribute( patient, fixedAttribute, format );
- grid.addValue( value );
- }
- }
-
- // -------------------------------------------------------------
- // Add patient-identifiers
- // -------------------------------------------------------------
-
- for ( PatientIdentifierType identifierType : idens )
- {
- Patient patient = programStageInstance.getProgramInstance().getPatient();
-
- PatientIdentifier patientIdentifier = identifierService.getPatientIdentifier( identifierType,
- patient );
-
- if ( patientIdentifier != null )
- {
- grid.addValue( i18n.getString( patientIdentifier.getIdentifier() ) );
- }
- else
- {
- grid.addValue( "" );
- }
- }
-
- // ---------------------------------------------------------------------
- // Get patient-attribute-values
- // ---------------------------------------------------------------------
-
- for ( PatientAttribute attribute : attributes )
- {
- Patient patient = programStageInstance.getProgramInstance().getPatient();
-
- PatientAttributeValue patientAttributeValue = patientAttributeValueService
- .getPatientAttributeValue( patient, attribute );
-
- if ( patientAttributeValue != null )
- {
- grid.addValue( i18n.getString( patientAttributeValue.getValue() ) );
- }
- else
- {
- grid.addValue( "" );
- }
- }
-
- for ( DataElement dataElement : dataElements )
- {
- PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue(
- programStageInstance, dataElement );
-
- if ( patientDataValue != null )
- {
- if ( dataElement.getType().equals( DataElement.VALUE_TYPE_BOOL ) )
- {
- grid.addValue( i18n.getString( patientDataValue.getValue() ) );
- }
- else
- {
- grid.addValue( patientDataValue.getValue() );
- }
- }
- else
- {
- grid.addValue( "" );
- }
- }
-
- }// end for
+ // -------------------------------------------------------------
+
+ grid.addValue( valuesMap.get( key + "_" + PatientTabularReport.PREFIX_EXECUTION_DATE ) );
+
+ // -------------------------------------------------------------
+ // Add organisation units
+ // -------------------------------------------------------------
+
+ Integer orgunitId = Integer.parseInt( valuesMap.get( key + "_" + PatientTabularReport.PREFIX_ORGUNIT ) );
+ Map<Integer, String> hierarchyOrgunit = getHierarchyOrgunit( orgunitId, level );
+
+ for ( int i = level; i <= maxLevel; i++ )
+ {
+ if ( hierarchyOrgunit.get( i ) != null )
+ {
+ grid.addValue( hierarchyOrgunit.get( i ) );
+ }
+ else
+ {
+ grid.addValue( "" );
+ }
+ }
+
+ // -------------------------------------------------------------
+ // Fixed Attributes
+ // -------------------------------------------------------------
+
+ if ( fixedAttributes != null && fixedAttributes.size() > 0 )
+ {
+ for ( String fixedAttr : fixedAttributes )
+ {
+ grid.addValue( valuesMap.get( key + "_" + PatientTabularReport.PREFIX_FIXED_ATTRIBUTE + "_"
+ + fixedAttr ) );
+ }
+ }
+
+ // -------------------------------------------------------------
+ // Add patient-identifiers
+ // -------------------------------------------------------------
+
+ for ( PatientIdentifierType identifierType : idens )
+ {
+ String value = valuesMap.get( key + "_" + PatientTabularReport.PREFIX_IDENTIFIER_TYPE + "_"
+ + identifierType.getId() );
+ value = (value == null) ? "" : value;
+ grid.addValue( value );
+ }
+
+ // ---------------------------------------------------------------------
+ // Get patient-attribute-values
+ // ---------------------------------------------------------------------
+
+ for ( PatientAttribute attribute : attributes )
+ {
+ String value = valuesMap.get( key + "_" + PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE + "_"
+ + attribute.getId() );
+
+ value = (value == null) ? "" : value;
+
+ if ( attribute.getValueType().equals( PatientAttribute.TYPE_BOOL ) )
+ {
+ if ( value.equals( "true" ) )
+ {
+ value = i18n.getString( "yes" );
+ }
+ else if ( value.equals( "false" ) )
+ {
+ value = i18n.getString( "no" );
+ }
+ }
+
+ grid.addValue( value );
+ }
+
+ for ( DataElement dataElement : dataElements )
+ {
+ String value = valuesMap.get( key + "_" + PatientTabularReport.PREFIX_DATA_ELEMENT + "_"
+ + dataElement.getId() );
+ value = (value == null) ? "" : value;
+ if ( dataElement.getType().equals( DataElement.VALUE_TYPE_BOOL ) )
+ {
+ if ( value.equals( "true" ) )
+ {
+ value = i18n.getString( "yes" );
+ }
+ else if ( value.equals( "false" ) )
+ {
+ value = i18n.getString( "no" );
+ }
+ }
+
+ grid.addValue( value );
+ }
}
return grid;
}
- private Map<Integer, String> getHierarchyOrgunit( OrganisationUnit orgunit, int level )
+ private Map<Integer, String> getHierarchyOrgunit( int orgunitid, int level )
{
+ OrganisationUnit orgunit = organisationUnitService.getOrganisationUnit( orgunitid );
+
Map<Integer, String> hierarchyOrgunit = new HashMap<Integer, String>();
-
+
hierarchyOrgunit.put( organisationUnitService.getLevelOfOrganisationUnit( orgunit.getId() ), orgunit.getName() );
orgunit = orgunit.getParent();
@@ -577,26 +547,4 @@
return hierarchyOrgunit;
}
-
- private String getValueByFixedAttribute( Patient patient, String propertyName, I18nFormat format )
- {
- propertyName = StringUtils.capitalize( propertyName );
-
- try
- {
- Object object = Patient.class.getMethod( "get" + propertyName ).invoke( patient );
-
- if( object instanceof Date )
- {
- return format.formatDate( (Date) object );
- }
-
- return object.toString();
- }
- catch ( Exception e )
- {
- return "";
- }
- }
-
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-05-02 08:15:45 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2012-05-15 02:36:43 +0000
@@ -27,10 +27,12 @@
package org.hisp.dhis.program.hibernate;
import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -44,6 +46,7 @@
import org.hisp.dhis.jdbc.StatementBuilder;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patientreport.PatientTabularReport;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
@@ -58,7 +61,6 @@
extends HibernateGenericStore<ProgramStageInstance>
implements ProgramStageInstanceStore
{
-
// -------------------------------------------------------------------------
// Dependency
// -------------------------------------------------------------------------
@@ -185,99 +187,176 @@
.setFirstResult( min ).setMaxResults( max ).list();
}
- public List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer, String> searchingIdenKeys,
- Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds,
- Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max )
+ public Map<String, String> get( ProgramStage programStage, List<String> keys,
+ Map<Integer, String> searchingIdenKeys, List<String> fixedAttributes, Map<Integer, String> searchingAttrKeys,
+ Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds,
+ Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc,
+ boolean orderByExecutionDateByAsc, int min, int max )
{
- String sql = getTabularReportStatement( false, programStage, searchingIdenKeys, searchingAttrKeys,
+ String sql = getTabularReportStatement( 1, programStage, searchingIdenKeys, fixedAttributes, searchingAttrKeys,
searchingDEKeys, upperOrgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc );
-
- if( bottomOrgunitIds.size() > 0 )
+
+ if ( bottomOrgunitIds.size() > 0 )
{
- String sqlBottom = getTabularReportStatement( false, programStage, searchingIdenKeys, searchingAttrKeys,
- searchingDEKeys, bottomOrgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc );
- sql = "( "+ sqlBottom + ") union all ( " + sql + " ) ";
+ String sqlBottom = getTabularReportStatement( 1, programStage, searchingIdenKeys, fixedAttributes,
+ searchingAttrKeys, searchingDEKeys, bottomOrgunitIds, startDate, endDate, orderByOrgunitAsc,
+ orderByExecutionDateByAsc );
+ sql = "( " + sqlBottom + ") union all ( " + sql + " ) ";
}
-
+
sql += statementBuilder.limitRecord( min, max );
-
List<Integer> ids = executeSQL( sql );
-
- List<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
-
- for ( Integer id : ids )
+ if ( ids != null && ids.size() > 0 )
{
- programStageInstances.add( get( id ) );
+ sql = getTabularReportStatement( ids, searchingIdenKeys, fixedAttributes, searchingAttrKeys,
+ orderByOrgunitAsc, orderByExecutionDateByAsc );
+ return executeSQL( sql, keys, fixedAttributes );
}
- return programStageInstances;
+ return null;
}
- public List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer, String> searchingIdenKeys,
- Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds, Collection<Integer> bottomOrgunitIds,
- Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc )
+ public Map<String, String> get( ProgramStage programStage, List<String> keys,
+ Map<Integer, String> searchingIdenKeys, List<String> fixedAttributes, Map<Integer, String> searchingAttrKeys,
+ Map<Integer, String> searchingDEKeys, Collection<Integer> upperOrgunitIds,
+ Collection<Integer> bottomOrgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc,
+ boolean orderByExecutionDateByAsc )
{
- String sql = getTabularReportStatement( false, programStage, searchingIdenKeys, searchingAttrKeys,
+ String sql = getTabularReportStatement( 1, programStage, searchingIdenKeys, fixedAttributes, searchingAttrKeys,
searchingDEKeys, upperOrgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc );
-
- if( bottomOrgunitIds.size() > 0 )
+
+ if ( bottomOrgunitIds.size() > 0 )
{
- String sqlBottom = getTabularReportStatement( false, programStage, searchingIdenKeys, searchingAttrKeys,
- searchingDEKeys, bottomOrgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc );
- sql = "( "+ sqlBottom + ") union all ( " + sql + " ) ";
+ String sqlBottom = getTabularReportStatement( 1, programStage, searchingIdenKeys, fixedAttributes,
+ searchingAttrKeys, searchingDEKeys, bottomOrgunitIds, startDate, endDate, orderByOrgunitAsc,
+ orderByExecutionDateByAsc );
+ sql = "( " + sqlBottom + ") union all ( " + sql + " ) ";
}
-
+
List<Integer> ids = executeSQL( sql );
-
- List<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
-
- for ( Integer id : ids )
+ if ( ids != null && ids.size() > 0 )
{
- programStageInstances.add( get( id ) );
+ sql = getTabularReportStatement( ids, searchingIdenKeys, fixedAttributes, searchingAttrKeys,
+ orderByOrgunitAsc, orderByExecutionDateByAsc );
+
+ return executeSQL( sql, keys, fixedAttributes );
}
- return programStageInstances;
+ return null;
}
public int count( ProgramStage programStage, Map<Integer, String> searchingIdenKeys,
Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds,
Date startDate, Date endDate )
{
- String sql = getTabularReportStatement( true, programStage, searchingIdenKeys, searchingAttrKeys,
+ String sql = getTabularReportStatement( 0, programStage, searchingIdenKeys, null, searchingAttrKeys,
searchingDEKeys, orgunitIds, startDate, endDate, true, true );
- List<Integer> countRow = executeSQL( sql );
- return (countRow != null && countRow.size() > 0) ? countRow.get( 0 ) : 0;
+ return executeCountSQL( sql );
}
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
-
- private String getTabularReportStatement( boolean isCount, ProgramStage programStage,
- Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
+
+ private String getData( int mark, Map<Integer, String> searchingIdenKeys, List<String> fixedAttributes,
+ Map<Integer, String> searchingAttrKeys )
+ {
+ String select = "";
+ switch ( mark )
+ {
+ // count result
+ case 0:
+ select = "select count( distinct psi.programstageinstanceid ) ";
+ break;
+ // Get data with limit
+ case 1:
+ select = "SELECT distinct psi.programstageinstanceid, ogu.name , psi.executiondate ";
+ break;
+ case 2:
+ select = "SELECT psi.programstageinstanceid AS psiid, ogu.organisationunitid AS orgunitid, ogu.name AS orgunitname, psi.executiondate AS "
+ + PatientTabularReport.PREFIX_EXECUTION_DATE;
+
+ if ( fixedAttributes != null )
+ {
+ for ( String fixedAttribute : fixedAttributes )
+ {
+ select += ",p." + fixedAttribute + " AS " + PatientTabularReport.PREFIX_FIXED_ATTRIBUTE + "_"
+ + fixedAttribute;
+ }
+ }
+ if ( searchingIdenKeys.size() > 0 )
+ {
+ select += ",pid.patientidentifiertypeid AS " + PatientTabularReport.PREFIX_IDENTIFIER_TYPE
+ + "_id, pid.identifier AS " + PatientTabularReport.PREFIX_IDENTIFIER_TYPE + "_value";
+ }
+ if ( searchingAttrKeys.size() > 0 )
+ {
+ select += ",pav.patientattributeid AS " + PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE
+ + "_id, pav.value AS " + PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE + "_value ";
+ }
+ break;
+ default:
+ return "";
+ }
+
+ if ( mark == 2 )
+ {
+ select += ",pdv.dataelementid AS " + PatientTabularReport.PREFIX_DATA_ELEMENT + "_id, pdv.value AS "
+ + PatientTabularReport.PREFIX_DATA_ELEMENT + "_value FROM programstageinstance AS psi "
+ + " INNER JOIN patientdatavalue AS pdv ON pdv.programstageinstanceid=psi.programstageinstanceid "
+ + " INNER JOIN programinstance pi ON pi.programinstanceid=psi.programinstanceid "
+ + " INNER JOIN organisationunit ogu ON ogu.organisationunitid=psi.organisationunitid ";
+
+ if ( (fixedAttributes != null && fixedAttributes.size() > 0) || searchingIdenKeys.size() > 0
+ || searchingAttrKeys.size() > 0 )
+ {
+ select += " INNER JOIN patient AS p on p.patientid = pi.patientid ";
+ }
+
+ if ( searchingIdenKeys.size() > 0 )
+ {
+ select += " INNER JOIN patientidentifier AS pid ON pid.patientid = p.patientid ";
+ }
+ if ( searchingAttrKeys.size() > 0 )
+ {
+ select += " INNER JOIN patientattributevalue AS pav ON pav.patientid = p.patientid ";
+ }
+ }
+ else
+ {
+ select += " FROM programstageinstance AS psi "
+ + " INNER JOIN patientdatavalue AS pdv ON pdv.programstageinstanceid=psi.programstageinstanceid "
+ + " INNER JOIN programinstance pi ON pi.programinstanceid=psi.programinstanceid "
+ + " INNER JOIN organisationunit ogu ON ogu.organisationunitid=psi.organisationunitid ";
+ }
+
+ return select;
+ }
+
+ private String getTabularReportStatement( int mark, ProgramStage programStage,
+ Map<Integer, String> searchingIdenKeys, List<String> fixedAttributes, Map<Integer, String> searchingAttrKeys,
Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,
boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc )
{
- String select = "SELECT distinct psi.programstageinstanceid, ogu.name , psi.executiondate ";
-
+ String select = getData( mark, searchingIdenKeys, fixedAttributes, searchingAttrKeys );
+
String sqlID = " select distinct psi.programstageinstanceid from patientdatavalue pdv "
+ "inner join programstageinstance psi on pdv.programstageinstanceid=psi.programstageinstanceid "
+ "INNER JOIN patientidentifier as pid ON pid.patientid = p.patientid "
+ "INNER JOIN patientidentifiertype as pit ON pid.patientidentifiertypeid = pit.patientidentifiertypeid ";
-
- String sqlATTR = " select distinct psi.programstageinstanceid from patientdatavalue pdv "
- + "inner join programstageinstance psi on pdv.programstageinstanceid=psi.programstageinstanceid ";
-
+
+ String sqlATTR = " SELECT distinct psi.programstageinstanceid " + "FROM programstageinstance AS psi "
+ + "INNER JOIN patientdatavalue AS pdv ON pdv.programstageinstanceid=psi.programstageinstanceid "
+ + "INNER JOIN programinstance pi ON pi.programinstanceid=psi.programinstanceid "
+ + "INNER JOIN organisationunit ogu ON ogu.organisationunitid=psi.organisationunitid "
+ + "INNER JOIN patient AS p on p.patientid = pi.patientid "
+ + "INNER JOIN patientattributevalue AS pav ON pav.patientid = p.patientid ";
+
String sqlDE = " select distinct psi.programstageinstanceid from patientdatavalue pdv "
+ "inner join programstageinstance psi on pdv.programstageinstanceid=psi.programstageinstanceid ";
- String condition = "FROM patientdatavalue pdv "
- + "INNER JOIN programstageinstance psi ON pdv.programstageinstanceid=psi.programstageinstanceid "
- + "INNER JOIN programinstance pi ON pi.programinstanceid=psi.programinstanceid "
- + "INNER JOIN organisationunit ogu ON ogu.organisationunitid=psi.organisationunitid ";
-
- condition += " WHERE psi.executiondate >= '" + DateUtils.getMediumDateString( startDate )
+ String condition = " WHERE psi.executiondate >= '" + DateUtils.getMediumDateString( startDate )
+ "' AND psi.executiondate <= '" + DateUtils.getMediumDateString( endDate ) + "' "
+ " AND psi.organisationunitid in " + splitListHelper( orgunitIds ) + " AND psi.programstageid = "
+ programStage.getId() + " ";
@@ -378,9 +457,9 @@
condition += ") ";
}
- if ( isCount )
+ if ( mark == 0 )
{
- return "select count( distinct psi.programstageinstanceid ) " + condition;
+ return select + condition;
}
condition += " ORDER BY ogu.name ";
@@ -390,13 +469,50 @@
return select + condition;
}
-
+
+ private String getTabularReportStatement( List<Integer> ids, Map<Integer, String> searchingIdenKeys,
+ List<String> fixedAttributes, Map<Integer, String> searchingAttrKeys, boolean orderByOrgunitAsc,
+ boolean orderByExecutionDateByAsc )
+ {
+ String sql = getData( 2, searchingIdenKeys, fixedAttributes, searchingAttrKeys );
+
+ sql += " WHERE psi.programstageinstanceid in " + splitListHelper( ids ) + " ";
+ sql += " ORDER BY ogu.name ";
+ sql += orderByOrgunitAsc ? "asc" : "desc";
+ sql += ", psi.executiondate ";
+ sql += orderByExecutionDateByAsc ? "asc" : "desc";
+
+ return sql;
+ }
+
+ private Map<String, String> executeSQL( String sql, List<String> keys, List<String> fixedAttributes )
+ {
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ Statement statement = holder.getStatement();
+
+ ResultSet resultSet = statement.executeQuery( sql );
+
+ return gridMapping( resultSet, fixedAttributes, keys );
+ }
+ catch ( Exception ex )
+ {
+ return null;
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
private List<Integer> executeSQL( String sql )
{
+ List<Integer> result = new ArrayList<Integer>();
+
StatementHolder holder = statementManager.getHolder();
- List<Integer> ids = new ArrayList<Integer>();
-
try
{
Statement statement = holder.getStatement();
@@ -405,18 +521,36 @@
while ( resultSet.next() )
{
- int id = resultSet.getInt( 1 );
-
- ids.add( id );
+ result.add( resultSet.getInt( 1 ) );
}
- return ids;
-
- }
- catch ( Exception ex )
- {
- ex.printStackTrace();
- return new ArrayList<Integer>();
+ return result;
+ }
+ catch ( Exception ex )
+ {
+ return null;
+ }
+ finally
+ {
+ holder.close();
+ }
+ }
+
+ private int executeCountSQL( String sql )
+ {
+ StatementHolder holder = statementManager.getHolder();
+
+ try
+ {
+ Statement statement = holder.getStatement();
+
+ ResultSet resultSet = statement.executeQuery( sql );
+
+ return (resultSet != null && resultSet.next()) ? resultSet.getInt( 1 ) : 0;
+ }
+ catch ( Exception ex )
+ {
+ return 0;
}
finally
{
@@ -453,4 +587,96 @@
return sb.toString();
}
+ private Map<String, String> gridMapping( ResultSet resultSet, List<String> fixedAttributes, List<String> keys )
+ {
+ Map<String, String> valuesMap = new HashMap<String, String>();
+
+ try
+ {
+ ResultSetMetaData meta = resultSet.getMetaData();
+
+ while ( resultSet.next() )
+ {
+ String key = resultSet.getString( "psiid" );
+
+ // Get execution-date
+ if ( !keys.contains( key ) )
+ {
+ keys.add( key );
+ }
+
+ valuesMap.put( key + "_" + PatientTabularReport.PREFIX_EXECUTION_DATE, resultSet
+ .getString( PatientTabularReport.PREFIX_EXECUTION_DATE ) );
+
+ // Get orgunit-id
+ valuesMap.put( key + "_" + PatientTabularReport.PREFIX_ORGUNIT, resultSet.getString( "orgunitid" ) );
+
+ for ( String fixedAttr : fixedAttributes )
+ {
+ // Get fixed-attributes
+ key = resultSet.getInt( "psiid" ) + "_" + PatientTabularReport.PREFIX_FIXED_ATTRIBUTE + "_"
+ + fixedAttr;
+ valuesMap.put( key, resultSet.getString( fixedAttr ) );
+ }
+
+ // Get idens
+ String colname = PatientTabularReport.PREFIX_IDENTIFIER_TYPE + "_id";
+ if ( existedCol( colname, meta ) )
+ {
+ key = resultSet.getInt( "psiid" ) + "_" + PatientTabularReport.PREFIX_IDENTIFIER_TYPE + "_"
+ + resultSet.getString( colname );
+ valuesMap.put( key, resultSet.getString( PatientTabularReport.PREFIX_IDENTIFIER_TYPE + "_value" ) );
+ }
+
+ // Get dynmic-attributes
+ colname = PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE + "_id";
+ if ( existedCol( colname, meta ) )
+ {
+ key = resultSet.getInt( "psiid" ) + "_" + PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE + "_"
+ + resultSet.getString( colname );
+ valuesMap
+ .put( key, resultSet.getString( PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE + "_value" ) );
+ }
+
+ // Get data-elements
+ colname = PatientTabularReport.PREFIX_DATA_ELEMENT + "_id";
+ if ( existedCol( colname, meta ) )
+ {
+ key = resultSet.getInt( "psiid" ) + "_" + PatientTabularReport.PREFIX_DATA_ELEMENT + "_"
+ + resultSet.getString( colname );
+ valuesMap.put( key, resultSet.getString( PatientTabularReport.PREFIX_DATA_ELEMENT + "_value" ) );
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+
+ return valuesMap;
+ }
+
+ private boolean existedCol( String colname, ResultSetMetaData meta )
+ {
+ int numCol = 0;
+ try
+ {
+ numCol = meta.getColumnCount();
+
+ for ( int i = 1; i < numCol + 1; i++ )
+ {
+ if ( meta.getColumnName( i ).equals( colname ) )
+ {
+ return true;
+ }
+
+ }
+ }
+ catch ( Exception e )
+ {
+ return false;
+ }
+
+ return false;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-05-09 08:30:28 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml 2012-05-15 02:36:43 +0000
@@ -213,10 +213,6 @@
ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
<property name="organisationUnitService"
ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- <property name="identifierService"
- ref="org.hisp.dhis.patient.PatientIdentifierService" />
- <property name="patientAttributeValueService"
- ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
</bean>
<bean id="org.hisp.dhis.program.ProgramInstanceService" class="org.hisp.dhis.program.DefaultProgramInstanceService">
=== 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-05-09 08:30:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java 2012-05-15 02:36:43 +0000
@@ -431,7 +431,7 @@
String value = infor[3].trim();
if ( attribute.getValueType().equals( PatientAttribute.TYPE_BOOL ) )
{
- value = value.equals( i18n.getString( "yes" ) ) ? "true" : "false";
+ value = (value.indexOf( i18n.getString( "yes" ) ) != -1) ? "true" : "false";
}
values.add( value );
}
@@ -454,12 +454,16 @@
if ( infor.length == 4 )
{
- searchingDEKeys.put( objectId, infor[3].trim() );
String value = infor[3].trim();
if ( dataElement.getType().equals( DataElement.VALUE_TYPE_BOOL ) )
{
- value = value.equals( i18n.getString( "yes" ) ) ? "true" : "false";
- }
+ int startIndx = value.indexOf( '\'' ) + 1;
+ int endIndx = value.lastIndexOf( '\'' );
+ String key = value.substring( startIndx, endIndx );
+
+ value = (key.equals(i18n.getString( "yes" ))) ? value.replace( key, "true" ) : value.replace( key, "false" );
+ }
+ searchingDEKeys.put( objectId, value );
values.add( value );
}
else
=== 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-05-09 09:50:16 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2012-05-15 02:36:43 +0000
@@ -339,4 +339,5 @@
rename_favorite=Rename favorite
delete_object=Delete
delete_favorite=Delete favorite
-are_you_sure=Are you sure?
\ No newline at end of file
+are_you_sure=Are you sure?
+loading = Loading
\ 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-05-10 01:21:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js 2012-05-15 02:36:43 +0000
@@ -253,7 +253,7 @@
a.store.filterBy( function(r) {
var filter = true;
s.store.each( function(r2) {
- if (r.data.id === r2.data.id) {
+ if (r.data.id == r2.data.id) {
filter = false;
}
});
@@ -585,9 +585,9 @@
// DATAELEMENT
TR.store.dataelement.selected.removeAll();
- if (f.dataelements) {
- for (var i = 0; i < f.dataelements.length; i++) {
- TR.cmp.params.dataelement.objects.push({id: f.dataelements[i].id, name: TR.util.string.getEncodedString(f.dataelements[i].name)});
+ if (f.dataElements) {
+ for (var i = 0; i < f.dataElements.length; i++) {
+ TR.cmp.params.dataelement.objects.push({id: f.dataElements[i].id, name: TR.util.string.getEncodedString(f.dataElements[i].name)});
}
TR.store.dataelement.selected.add(TR.cmp.params.dataelement.objects);
@@ -595,7 +595,7 @@
store.parent = f.programStageId;
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);
+ TR.util.multiselect.filterAvailable(TR.cmp.params.dataelement.available, TR.cmp.params.dataelement.selected);
}
else {
store.load({params: {programStageId: f.programStageId}});
@@ -857,18 +857,19 @@
var col = cols[i];
var dataIndex = col.dataIndex;
- if( dataIndex== 'col1' )
- {
- p.searchingValues.push( col.name + col.hidden + "_" );
- }
- else if( col.name )
+ if( col.name )
{
var value = editor.data[dataIndex];
+ var hidden = (col.hidden==undefined)? false : col.hidden;
if( value!=null && value!= '')
{
value = TR.util.getValueFormula(value);
- }
- p.searchingValues.push( col.name + col.hidden + "_" + value );
+ p.searchingValues.push( col.name + hidden + "_" + value );
+ }
+ else
+ {
+ p.searchingValues.push( col.name + hidden + "_" );
+ }
}
}
}
@@ -926,7 +927,8 @@
{
value = TR.util.getValueFormula(value);
}
- p += "&searchingValues=" + col.name + col.hidden + "_" + value;
+ var hidden = (col.hidden==undefined)? false : col.hidden;
+ p += "&searchingValues=" + col.name + hidden + "_" + value;
}
}
}
@@ -945,6 +947,7 @@
p += "&searchingValues=" + 'de_' + r.data.id + '_false_';
});
}
+
return p;
},
validation: {
@@ -1005,7 +1008,6 @@
{
return 'textfield';
}
-
return TR.value.valueTypes[index].valueType;
},
getSuggestedValues: function( index )
@@ -1014,7 +1016,6 @@
{
return [];
}
-
return TR.value.valueTypes[index].suggestedValues;
}
};
@@ -1048,7 +1049,6 @@
header: TR.value.columns[1],
dataIndex: 'col1',
height: TR.conf.layout.east_gridcolumn_height,
- name:"meta_1_",
sortable: false,
draggable: false,
hideable: false
@@ -1107,7 +1107,7 @@
allowBlank: true,
store: new Ext.data.ArrayStore({
fields: ['name'],
- data: TR.value.getSuggestedValues(index),
+ data: TR.value.TR.value.valueTypes(index)
})
}
};
@@ -1134,7 +1134,7 @@
allowBlank: true,
store: new Ext.data.ArrayStore({
fields: ['name'],
- data: TR.value.getSuggestedValues('col' + index),
+ data: TR.value.getSuggestedValues(index)
})
}
};
@@ -1390,7 +1390,7 @@
{
// IDENTIFIER TYPE
var storeIdentifierType = TR.store.identifierType.available;
- TR.store.identifierType.selected.loadData([],false);
+ TR.store.identifierType.selected.removeAll();
storeIdentifierType.parent = pId;
if (TR.util.store.containsParent(storeIdentifierType)) {
@@ -1404,7 +1404,7 @@
// PATIENT ATTRIBUTE
var storePatientAttribute = TR.store.patientAttribute.available;
storePatientAttribute.parent = pId;
- TR.store.patientAttribute.selected.loadData([],false);
+ TR.store.patientAttribute.selected.removeAll();
if (TR.util.store.containsParent(storePatientAttribute)) {
TR.util.store.loadFromStorage(storePatientAttribute);
@@ -1419,16 +1419,17 @@
{
TR.util.setDisabledFixedAttr();
- TR.store.identifierType.available.loadData([],false);
- TR.store.identifierType.selected.loadData([],false);
+ TR.store.identifierType.available.removeAll();
+ TR.store.identifierType.selected.removeAll();
- TR.store.patientAttribute.available.loadData([],false);
- TR.store.patientAttribute.selected.loadData([],false);
+ TR.store.patientAttribute.available.removeAll();
+ TR.store.patientAttribute.selected.removeAll();
}
// PROGRAM-STAGE
var storeProgramStage = TR.store.programStage;
- TR.store.dataelement.selected.loadData([],false);
+ TR.store.dataelement.available.removeAll();
+ TR.store.dataelement.selected.removeAll();
storeProgramStage.parent = pId;
storeProgramStage.load({params: {programId: pId}});
}
=== 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-05-10 01:21:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm 2012-05-15 02:36:43 +0000
@@ -42,7 +42,7 @@
#if( $velocityCount < $size ),#end
#end
],
- "dataelements": [
+ "dataElements": [
#set( $size = ${tabularReport.dataElements.size()} )
#set( $dataElements = ${tabularReport.dataElements} )
#foreach( ${dataElement} in $!{dataElements} )
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm 2012-05-10 16:25:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReportResult.vm 2012-05-15 02:36:43 +0000
@@ -1,5 +1,5 @@
{
-#if( $grid.getRows().size() > 0)
+#if( $grid && $grid.getRows().size() > 0)
#set( $noHeader = $grid.getHeaders().size() )
#set ( $metaData = $noHeader - $valueTypes.size())
'total': "$total",
@@ -56,8 +56,8 @@
'hidden':[
#set( $index = 2 )
#set($col="col" + $index )
- #foreach( $col in $grid.getHeaders() )
- {"$col":"$col.hidden"}
+ #foreach( $header in $grid.getHeaders() )
+ {"$col":"$header.hidden"}
#if( $velocityCount < $noHeader ),#end
#set( $index = $index + 1 )
#end