dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17393
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6902: (local) Dataentry for hospital.
------------------------------------------------------------
revno: 6902
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-05-10 23:18:43 +0700
message:
(local) Dataentry for hospital.
added:
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/DefaultLocalDataSetService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/LocalDataSetService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/LocalDataSetStore.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/hibernate/
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLocalDataSetStore.java
local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadAttributeValuesAction.java
local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java
local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDepartmentsAction.java
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/jsonDepartments.vm
modified:
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/DefaultLocalAttributeValueService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/LocalAttributeValueService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/LocalAttributeValueStore.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DefaultLocalDataElementService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementService.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementStore.java
local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java
local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml
local/vn/dhis-web-dataentry-hospital/pom.xml
local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java
local/vn/dhis-web-dataentry-hospital/src/main/resources/META-INF/dhis/beans.xml
local/vn/dhis-web-dataentry-hospital/src/main/resources/org/hisp/dhis/de/i18n_module.properties
local/vn/dhis-web-dataentry-hospital/src/main/resources/struts.xml
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/entry.js
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/jsonAttributeValues.vm
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/responseDataSets.vm
local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/select.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 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/DefaultLocalAttributeValueService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/DefaultLocalAttributeValueService.java 2012-04-16 03:00:30 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/DefaultLocalAttributeValueService.java 2012-05-10 16:18:43 +0000
@@ -31,6 +31,7 @@
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeValue;
+import org.hisp.dhis.dataset.DataSet;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -66,4 +67,14 @@
{
return localAttributeValueStore.getDistinctValuesByAttribute( attribute );
}
+
+ public boolean hasAttributesByDataSet( DataSet dataSet )
+ {
+ return localAttributeValueStore.hasAttributesByDataSet( dataSet );
+ }
+
+ public Collection<String> getValuesByDataSet( DataSet dataSet )
+ {
+ return localAttributeValueStore.getByDataSet( dataSet );
+ }
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/LocalAttributeValueService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/LocalAttributeValueService.java 2012-04-16 03:00:30 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/LocalAttributeValueService.java 2012-05-10 16:18:43 +0000
@@ -31,6 +31,7 @@
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeValue;
+import org.hisp.dhis.dataset.DataSet;
/**
* @author Chau Thu Tran
@@ -42,4 +43,8 @@
Collection<AttributeValue> getAttributeValuesByAttribute( Attribute attribute );
Collection<String> getDistinctValuesByAttribute( Attribute attribute );
+
+ boolean hasAttributesByDataSet( DataSet dataSet );
+
+ Collection<String> getValuesByDataSet( DataSet dataSet );
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/LocalAttributeValueStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/LocalAttributeValueStore.java 2012-04-16 03:00:30 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/LocalAttributeValueStore.java 2012-05-10 16:18:43 +0000
@@ -31,6 +31,7 @@
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeValue;
+import org.hisp.dhis.dataset.DataSet;
/**
* @author Chau Thu Tran
@@ -42,4 +43,8 @@
Collection<AttributeValue> getByAttribute( Attribute attribute );
Collection<String> getDistinctValuesByAttribute( Attribute attribute );
+
+ boolean hasAttributesByDataSet( DataSet dataSet );
+
+ Collection<String> getByDataSet( DataSet dataSet );
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java 2012-04-16 03:00:30 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/attribute/hibernate/HibernateLocalAttributeValueStore.java 2012-05-10 16:18:43 +0000
@@ -27,13 +27,18 @@
package org.hisp.dhis.attribute.hibernate;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Collection;
+import java.util.HashSet;
+import org.amplecode.quick.StatementManager;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeValue;
import org.hisp.dhis.attribute.LocalAttributeValueStore;
+import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.hibernate.HibernateGenericStore;
/**
@@ -45,6 +50,13 @@
extends HibernateGenericStore<AttributeValue>
implements LocalAttributeValueStore
{
+ private StatementManager statementManager;
+
+ public void setStatementManager( StatementManager statementManager )
+ {
+ this.statementManager = statementManager;
+ }
+
@SuppressWarnings( "unchecked" )
@Override
public Collection<AttributeValue> getByAttribute( Attribute attribute )
@@ -59,4 +71,47 @@
return getCriteria().add( Restrictions.eq( "attribute", attribute ) ).add( Restrictions.ne( "value", "" ) )
.setProjection( Projections.distinct( Projections.property( "value" ) ) ).list();
}
+
+ public boolean hasAttributesByDataSet( DataSet dataSet )
+ {
+ String sql = "select count(*) from datasetmembers dsm " +
+ "inner join dataelementattributevalues deav on deav.dataelementid = dsm.dataelementid " +
+ "inner join attributevalue av on av.attributevalueid = deav.attributevalueid " +
+ "inner join attribute att on att.attributeid = av.attributeid " +
+ "where dsm.datasetid = " + dataSet.getId();
+
+ return ( statementManager.getHolder().queryForInteger( sql ) > 0 ) ? true : false;
+ }
+
+ public Collection<String> getByDataSet( DataSet dataSet )
+ {
+ Collection<String> result = new HashSet<String>();
+ try
+ {
+ String sql = "select distinct(av.value) from datasetmembers dsm " +
+ "inner join dataelementattributevalues deav on deav.dataelementid = dsm.dataelementid " +
+ "inner join attributevalue av on av.attributevalueid = deav.attributevalueid " +
+ "inner join attribute att on att.attributeid = av.attributeid " +
+ "where dsm.datasetid = " + dataSet.getId();
+
+ ResultSet resultSet = statementManager.getHolder().getStatement().executeQuery( sql );
+
+ while( resultSet.next() )
+ {
+ result.add( resultSet.getString( 1 ) );
+ }
+
+ return result;
+ }
+ catch ( SQLException e )
+ {
+ e.printStackTrace();
+ return new HashSet<String>();
+ }
+ finally
+ {
+ statementManager.getHolder().close();
+ }
+
+ }
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DefaultLocalDataElementService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DefaultLocalDataElementService.java 2012-04-25 09:59:24 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/DefaultLocalDataElementService.java 2012-05-10 16:18:43 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.dataset.DataSet;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -65,4 +66,9 @@
{
return dataElementStore.getDataElementCount( dataElementId, attributeId, value );
}
+
+ public Collection<DataElement> getDataElements( DataSet dataSet, String value )
+ {
+ return dataElementStore.get( dataSet, value );
+ }
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementService.java 2012-04-25 09:59:24 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementService.java 2012-05-10 16:18:43 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.dataset.DataSet;
/**
* @author Chau Thu Tran
@@ -41,4 +42,6 @@
Collection<DataElement> getDataElementsByAttribute( Attribute attribute, String value );
int getDataElementCount( Integer dataElementId, Integer attributeId, String value );
+
+ Collection<DataElement> getDataElements( DataSet dataSet, String value );
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementStore.java 2012-04-25 09:59:24 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/LocalDataElementStore.java 2012-05-10 16:18:43 +0000
@@ -30,6 +30,7 @@
import java.util.Collection;
import org.hisp.dhis.attribute.Attribute;
+import org.hisp.dhis.dataset.DataSet;
/**
* @author Chau Thu Tran
@@ -41,4 +42,6 @@
Collection<DataElement> getByAttributeValue( Attribute attribute, String value );
int getDataElementCount( Integer dataElementId, Integer attributeId, String value );
+
+ Collection<DataElement> get( DataSet dataSet, String value );
}
=== modified file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java 2012-04-25 09:59:24 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateLocalDataElementStore.java 2012-05-10 16:18:43 +0000
@@ -27,14 +27,20 @@
package org.hisp.dhis.dataelement.hibernate;
+import java.sql.ResultSet;
+import java.sql.SQLException;
import java.util.Collection;
+import java.util.HashSet;
+import org.amplecode.quick.StatementManager;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataelement.LocalDataElementStore;
+import org.hisp.dhis.dataset.DataSet;
/**
* @author Chau Thu Tran
@@ -45,6 +51,20 @@
extends HibernateIdentifiableObjectStore<DataElement>
implements LocalDataElementStore
{
+ private StatementManager statementManager;
+
+ public void setStatementManager( StatementManager statementManager )
+ {
+ this.statementManager = statementManager;
+ }
+
+ private DataElementService dataElementService;
+
+ public void setDataElementService( DataElementService dataElementService )
+ {
+ this.dataElementService = dataElementService;
+ }
+
@SuppressWarnings( "unchecked" )
public Collection<DataElement> getByAttributeValue( Attribute attribute, String value )
{
@@ -56,13 +76,43 @@
@Override
public int getDataElementCount( Integer dataElementId, Integer attributeId, String value )
{
- Number rs = (Number) getCriteria()
- .add( Restrictions.eq( "id", dataElementId ) )
- .createAlias( "attributeValues", "attributeValue" )
- .add( Restrictions.eq( "attributeValue.attribute.id", attributeId ) )
+ Number rs = (Number) getCriteria().add( Restrictions.eq( "id", dataElementId ) ).createAlias(
+ "attributeValues", "attributeValue" ).add( Restrictions.eq( "attributeValue.attribute.id", attributeId ) )
.add( Restrictions.eq( "attributeValue.value", value ).ignoreCase() )
.setProjection( Projections.rowCount() ).uniqueResult();
return rs != null ? rs.intValue() : 0;
}
+
+ @Override
+ public Collection<DataElement> get( DataSet dataSet, String value )
+ {
+ Collection<DataElement> result = new HashSet<DataElement>();
+ try
+ {
+ String sql = "select distinct(deav.dataelementid) from datasetmembers dsm "
+ + "inner join dataelementattributevalues deav on deav.dataelementid = dsm.dataelementid "
+ + "inner join attributevalue av on av.attributevalueid = deav.attributevalueid "
+ + "inner join attribute att on att.attributeid = av.attributeid " + "where dsm.datasetid = "
+ + dataSet.getId() + " and av.value='" + value + "'";
+
+ ResultSet resultSet = statementManager.getHolder().getStatement().executeQuery( sql );
+
+ while ( resultSet.next() )
+ {
+ result.add( dataElementService.getDataElement( resultSet.getInt( 1 ) ) );
+ }
+
+ return result;
+ }
+ catch ( SQLException e )
+ {
+ e.printStackTrace();
+ return new HashSet<DataElement>();
+ }
+ finally
+ {
+ statementManager.getHolder().close();
+ }
+ }
}
=== added directory 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset'
=== added file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/DefaultLocalDataSetService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/DefaultLocalDataSetService.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/DefaultLocalDataSetService.java 2012-05-10 16:18:43 +0000
@@ -0,0 +1,67 @@
+/*
+ * 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.dataset;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $DefaultLocalDataSetService.java May 10, 2012 8:00:11 AM$
+ */
+public class DefaultLocalDataSetService
+ implements LocalDataSetService
+{
+ // -------------------------------------------------------------------------
+ // Dependency
+ // -------------------------------------------------------------------------
+
+ private LocalDataSetStore localDataSetStore;
+
+ public void setLocalDataSetStore( LocalDataSetStore localDataSetStore )
+ {
+ this.localDataSetStore = localDataSetStore;
+ }
+
+ // -------------------------------------------------------------------------
+ // Implementation methods
+ // -------------------------------------------------------------------------
+
+ @Override
+ public Collection<DataSet> getDataSetsByDescription( String description )
+ {
+ return localDataSetStore.getByDescription( description );
+ }
+
+ public DataElementCategoryOptionCombo getDepartmentByDataSet( DataSet dataSet )
+ {
+ return localDataSetStore.getDepartmentByDataSet( dataSet );
+ }
+}
=== added file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/LocalDataSetService.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/LocalDataSetService.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/LocalDataSetService.java 2012-05-10 16:18:43 +0000
@@ -0,0 +1,44 @@
+/*
+ * 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.dataset;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $LocalDataSetService.java May 10, 2012 7:55:22 AM$
+ */
+public interface LocalDataSetService
+{
+ Collection<DataSet> getDataSetsByDescription( String description );
+
+ DataElementCategoryOptionCombo getDepartmentByDataSet( DataSet dataSet );
+}
=== added file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/LocalDataSetStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/LocalDataSetStore.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/LocalDataSetStore.java 2012-05-10 16:18:43 +0000
@@ -0,0 +1,44 @@
+/*
+ * 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.dataset;
+
+import java.util.Collection;
+
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $LocalDataSetService.java May 10, 2012 7:55:22 AM$
+ */
+public interface LocalDataSetStore
+{
+ Collection<DataSet> getByDescription(String description);
+
+ DataElementCategoryOptionCombo getDepartmentByDataSet( DataSet dataSet );
+}
=== added directory 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/hibernate'
=== added file 'local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLocalDataSetStore.java'
--- local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLocalDataSetStore.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-service-vn/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLocalDataSetStore.java 2012-05-10 16:18:43 +0000
@@ -0,0 +1,103 @@
+/*
+ * 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.dataset.hibernate;
+
+import java.util.Collection;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.hibernate.Query;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataelement.DataElementCategoryService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.LocalDataSetStore;
+import org.hisp.dhis.hibernate.HibernateGenericStore;
+import org.hisp.dhis.program.ProgramDataEntryService;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $HibernateLocalDataSetStore.java May 10, 2012 8:04:58 AM$
+ */
+public class HibernateLocalDataSetStore
+ extends HibernateGenericStore<DataSet>
+ implements LocalDataSetStore
+{
+ private DataElementCategoryService categoryService;
+
+ public void setCategoryService( DataElementCategoryService categoryService )
+ {
+ this.categoryService = categoryService;
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Collection<DataSet> getByDescription( String description )
+ {
+ String hql = "from DataSet d where d.description = '" + description + "'";
+ Query query = sessionFactory.getCurrentSession().createQuery( hql );
+
+ return query.list();
+ }
+
+ public DataElementCategoryOptionCombo getDepartmentByDataSet( DataSet dataSet )
+ {
+ String htmlCode = dataSet.getDataEntryForm().getHtmlCode();
+
+ final Pattern INPUT_PATTERN = Pattern.compile( "(<input.*?)[/]?>", Pattern.DOTALL );
+
+ // ---------------------------------------------------------------------
+ // Pattern to match data elements in the HTML code
+ // ---------------------------------------------------------------------
+
+ Matcher inputMatcher = INPUT_PATTERN.matcher( htmlCode );
+
+ // ---------------------------------------------------------------------
+ // Iterate through all matching data element fields
+ // ---------------------------------------------------------------------
+ DataElementCategoryOptionCombo optionCombo = null;
+
+ while ( inputMatcher.find() )
+ {
+ String dataElementCode = inputMatcher.group( 1 );
+
+ String inputHTML = inputMatcher.group();
+ inputHTML = inputHTML.replace( ">", "" );
+
+ Matcher identifierMatcher = ProgramDataEntryService.IDENTIFIER_PATTERN_FIELD.matcher( dataElementCode );
+
+ if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
+ {
+ int optionComboId = Integer.parseInt( identifierMatcher.group( 2 ) );
+ optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
+ return optionCombo;
+ }
+ }
+
+ return null;
+ }
+}
=== modified file 'local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml 2012-03-26 02:41:46 +0000
+++ local/vn/dhis-service-vn/src/main/resources/META-INF/dhis/beans.xml 2012-05-10 16:18:43 +0000
@@ -4,7 +4,7 @@
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
- <!-- LocalDataElementService -->
+ <!-- LocalDataElement -->
<bean id="org.hisp.dhis.dataelement.LocalDataElementService"
class="org.hisp.dhis.dataelement.DefaultLocalDataElementService">
@@ -15,6 +15,8 @@
class="org.hisp.dhis.dataelement.hibernate.HibernateLocalDataElementStore">
<property name="clazz" value="org.hisp.dhis.dataelement.DataElement" />
<property name="sessionFactory" ref="sessionFactory" />
+ <property name="statementManager" ref="statementManager" />
+ <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
</bean>
<!-- LocalAttributeValue -->
@@ -28,6 +30,21 @@
class="org.hisp.dhis.attribute.hibernate.HibernateLocalAttributeValueStore">
<property name="clazz" value="org.hisp.dhis.attribute.AttributeValue" />
<property name="sessionFactory" ref="sessionFactory" />
+ <property name="statementManager" ref="statementManager" />
+ </bean>
+
+ <!-- LocalDataSet -->
+
+ <bean id="org.hisp.dhis.dataset.LocalDataSetService"
+ class="org.hisp.dhis.dataset.DefaultLocalDataSetService">
+ <property name="localDataSetStore" ref="org.hisp.dhis.dataset.LocalDataSetStore"/>
+ </bean>
+
+ <bean id="org.hisp.dhis.dataset.LocalDataSetStore"
+ class="org.hisp.dhis.dataset.hibernate.HibernateLocalDataSetStore">
+ <property name="clazz" value="org.hisp.dhis.dataset.DataSet" />
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="categoryService" ref="org.hisp.dhis.dataelement.DataElementCategoryService"/>
</bean>
</beans>
=== modified file 'local/vn/dhis-web-dataentry-hospital/pom.xml'
--- local/vn/dhis-web-dataentry-hospital/pom.xml 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/pom.xml 2012-05-10 16:18:43 +0000
@@ -35,6 +35,11 @@
<artifactId>dhis-service-vn</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-spreadsheet-reporting</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<properties>
=== added file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadAttributeValuesAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadAttributeValuesAction.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadAttributeValuesAction.java 2012-05-10 16:18:43 +0000
@@ -0,0 +1,96 @@
+/*
+ * 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.de.action;
+
+import java.util.Collection;
+
+import org.hisp.dhis.attribute.LocalAttributeValueService;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $LoadAttributeValuesByAttributeAction.java Mar 24, 2012 9:10:52 AM$
+ */
+public class LoadAttributeValuesAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private LocalAttributeValueService localAttributeValueService;
+
+ private DataSetService dataSetService;
+
+ // -------------------------------------------------------------------------
+ // Input && Output
+ // -------------------------------------------------------------------------
+
+ private Integer dataSetId;
+
+ private Collection<String> values;
+
+ public Collection<String> getValues()
+ {
+ return values;
+ }
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ public void setLocalAttributeValueService( LocalAttributeValueService localAttributeValueService )
+ {
+ this.localAttributeValueService = localAttributeValueService;
+ }
+
+ public void setDataSetId( Integer dataSetId )
+ {
+ this.dataSetId = dataSetId;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ DataSet dataset = dataSetService.getDataSet( dataSetId );
+
+ values = localAttributeValueService.getValuesByDataSet( dataset );
+
+ return SUCCESS;
+ }
+}
=== added file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDataSetsAction.java 2012-05-10 16:18:43 +0000
@@ -0,0 +1,92 @@
+/*
+ * 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.de.action;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $LoadDataSetsAction.java May 8, 2012 1:00:28 PM$
+ */
+public class LoadDataSetsAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitSelectionManager selectionManager;
+
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+ {
+ this.selectionManager = selectionManager;
+ }
+
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Collection<DataSet> dataSets = new HashSet<DataSet>();
+
+ public Collection<DataSet> getDataSets()
+ {
+ return dataSets;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action implementation
+ // -------------------------------------------------------------------------
+
+ public String execute()
+ {
+ Collection<OrganisationUnit> sources = new HashSet<OrganisationUnit>();
+
+ sources.add( selectionManager.getSelectedOrganisationUnit() );
+
+ dataSets = dataSetService.getDataSetsBySources( sources );
+
+ return SUCCESS;
+ }
+
+}
=== added file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDepartmentsAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDepartmentsAction.java 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadDepartmentsAction.java 2012-05-10 16:18:43 +0000
@@ -0,0 +1,153 @@
+/*
+ * 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.de.action;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.dataset.LocalDataSetService;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.reportsheet.CategoryOptionAssociation;
+import org.hisp.dhis.reportsheet.CategoryOptionAssociationService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ *
+ * @version $LoadDepartmentsAction.java May 10, 2012 3:05:03 PM$
+ */
+public class LoadDepartmentsAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitSelectionManager selectionManager;
+
+ public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+ {
+ this.selectionManager = selectionManager;
+ }
+
+ private CategoryOptionAssociationService associationService;
+
+ public void setAssociationService( CategoryOptionAssociationService associationService )
+ {
+ this.associationService = associationService;
+ }
+
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
+ private LocalDataSetService localDataSetService;
+
+ public void setLocalDataSetService( LocalDataSetService localDataSetService )
+ {
+ this.localDataSetService = localDataSetService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Input && Output
+ // -------------------------------------------------------------------------
+
+ private Integer dataSetId;
+
+ public void setDataSetId( Integer dataSetId )
+ {
+ this.dataSetId = dataSetId;
+ }
+
+ private Collection<CategoryOptionAssociation> associations;
+
+ public Collection<CategoryOptionAssociation> getAssociations()
+ {
+ return associations;
+ }
+
+ private Map<Integer, String> mapDataSets = new HashMap<Integer, String>();
+
+ public Map<Integer, String> getMapDataSets()
+ {
+ return mapDataSets;
+ }
+
+ // -------------------------------------------------------------------------
+ // Action Implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ associations = associationService
+ .getCategoryOptionAssociations( selectionManager.getSelectedOrganisationUnit() );
+
+ Collection<DataElementCategoryOptionCombo> departmentInOrgunit = new HashSet<DataElementCategoryOptionCombo>();
+
+ for( CategoryOptionAssociation association : associations )
+ {
+ departmentInOrgunit.addAll( association.getCategoryOption().getCategoryOptionCombos() );
+ }
+ System.out.println("\n\n === \n departmentInOrgunit : " + departmentInOrgunit );
+ DataSet dataSet = dataSetService.getDataSet( dataSetId );
+
+ String description = dataSet.getDescription();
+ if ( description != null && !description.trim().isEmpty() )
+ {
+ Collection<DataSet> dataSets = localDataSetService.getDataSetsByDescription( description );
+ dataSets.remove( dataSet );
+System.out.println("\n\n dataSets : " + dataSets );
+ for ( DataSet relativedataSet : dataSets )
+ {
+ if ( relativedataSet.getDataEntryForm() != null )
+ {
+ DataElementCategoryOptionCombo optionCombo = localDataSetService.getDepartmentByDataSet( relativedataSet );
+System.out.println("\n\n optionCombo : " + optionCombo );
+System.out.println("\n\n departmentInOrgunit.contains( optionCombo ) : " + departmentInOrgunit.contains( optionCombo ) );
+ if( departmentInOrgunit.contains( optionCombo ) )
+ {
+ mapDataSets.put( relativedataSet.getId(), optionCombo.getName() );
+ }
+ }
+ }
+ }
+
+ return SUCCESS;
+ }
+}
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java'
--- local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2012-05-10 16:18:43 +0000
@@ -50,6 +50,7 @@
import org.hisp.dhis.dataentryform.DataEntryFormService;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.dataset.LocalDataSetService;
import org.hisp.dhis.dataset.Section;
import org.hisp.dhis.dataset.comparator.SectionOrderComparator;
import org.hisp.dhis.i18n.I18n;
@@ -72,8 +73,6 @@
private DataSetService dataSetService;
- private AttributeService attributeService;
-
private LocalDataElementService localDataElementService;
// -------------------------------------------------------------------------
@@ -95,11 +94,6 @@
this.dataSetService = dataSetService;
}
- public void setAttributeService( AttributeService attributeService )
- {
- this.attributeService = attributeService;
- }
-
public void setLocalDataElementService( LocalDataElementService localDataElementService )
{
this.localDataElementService = localDataElementService;
@@ -123,13 +117,6 @@
this.dataSetId = dataSetId;
}
- private Integer attributeId;
-
- public void setAttributeId( Integer attributeId )
- {
- this.attributeId = attributeId;
- }
-
private String value;
public void setValue( String value )
@@ -229,22 +216,18 @@
List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
+ if ( value != null && !value.trim().isEmpty() )
+ {
+ Collection<DataElement> dataElementsByAttr = localDataElementService.getDataElements( dataSet, value );
+
+ dataElements.retainAll( dataElementsByAttr );
+ }
+
if ( dataElements.isEmpty() )
{
return INPUT;
}
- if ( attributeId != null )
- {
- Attribute attribute = attributeService.getAttribute( attributeId );
-
- Collection<DataElement> dataElementsByAttr = localDataElementService.getDataElementsByAttribute( attribute,
- value );
-
- dataElements.retainAll( dataElementsByAttr );
-
- }
-
Collections.sort( dataElements, new DataElementFormNameComparator() );
orderedDataElements = dataElementService.getGroupedDataElementsByCategoryCombo( dataElements );
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/resources/META-INF/dhis/beans.xml'
--- local/vn/dhis-web-dataentry-hospital/src/main/resources/META-INF/dhis/beans.xml 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/resources/META-INF/dhis/beans.xml 2012-05-10 16:18:43 +0000
@@ -37,7 +37,6 @@
<property name="dataEntryFormService" ref="org.hisp.dhis.dataentryform.DataEntryFormService" />
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
- <property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
<property name="localDataElementService" ref="org.hisp.dhis.dataelement.LocalDataElementService" />
</bean>
@@ -137,5 +136,22 @@
<property name="attributeService" ref="org.hisp.dhis.attribute.AttributeService" />
<property name="localAttributeValueService" ref="org.hisp.dhis.attribute.LocalAttributeValueService" />
</bean>
+
+ <bean id="org.hisp.dhis.de.action.LoadDataSetsAction" class="org.hisp.dhis.de.action.LoadDataSetsAction" scope="prototype">
+ <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.de.action.LoadAttributeValuesAction" class="org.hisp.dhis.de.action.LoadAttributeValuesAction" scope="prototype">
+ <property name="localAttributeValueService" ref="org.hisp.dhis.attribute.LocalAttributeValueService" />
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ </bean>
+
+ <bean id="org.hisp.dhis.de.action.LoadDepartmentsAction" class="org.hisp.dhis.de.action.LoadDepartmentsAction" scope="prototype">
+ <property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+ <property name="associationService" ref="org.hisp.dhis.reportsheet.CategoryOptionAssociationService" />
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+ <property name="localDataSetService" ref="org.hisp.dhis.dataset.LocalDataSetService" />
+ </bean>
</beans>
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/resources/org/hisp/dhis/de/i18n_module.properties'
--- local/vn/dhis-web-dataentry-hospital/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2012-05-03 02:32:28 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/resources/org/hisp/dhis/de/i18n_module.properties 2012-05-10 16:18:43 +0000
@@ -100,3 +100,5 @@
load_entry_form = Load entry form
show_all_items = Show all items
value = Value
+show_data = Show data
+please_select_department = Please select department
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/resources/struts.xml'
--- local/vn/dhis-web-dataentry-hospital/src/main/resources/struts.xml 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/resources/struts.xml 2012-05-10 16:18:43 +0000
@@ -93,6 +93,18 @@
<action name="loadAttributeValuesByAttribute" class="org.hisp.dhis.dataelement.LoadAttributeValuesByAttributeAction">
<result name="success" type="velocity-json">/dhis-web-dataentry-hospital/jsonAttributeValues.vm</result>
</action>
+
+ <action name="loadDataSet" class="org.hisp.dhis.de.action.LoadDataSetsAction">
+ <result name="success" type="velocity-json">/dhis-web-dataentry-hospital/responseDataSets.vm</result>
+ </action>
+
+ <action name="loadAttribueValues" class="org.hisp.dhis.de.action.LoadAttributeValuesAction">
+ <result name="success" type="velocity-json">/dhis-web-dataentry-hospital/jsonAttributeValues.vm</result>
+ </action>
+
+ <action name="loadDepartments" class="org.hisp.dhis.de.action.LoadDepartmentsAction">
+ <result name="success" type="velocity-json">/dhis-web-dataentry-hospital/jsonDepartments.vm</result>
+ </action>
</package>
</struts>
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/entry.js'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/entry.js 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/entry.js 2012-05-10 16:18:43 +0000
@@ -121,7 +121,7 @@
$( fieldId ).css( 'background-color', COLOR_YELLOW );
- var periodId = $( '#selectedPeriodId' ).val();
+ var periodId = $( '#selectedPeriodId option:selected' ).val();
if ( value == null )
{
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/javascript/form.js 2012-05-10 16:18:43 +0000
@@ -67,241 +67,56 @@
* 1. Load ouwt 2. Load meta-data (and notify ouwt) 3. Check and potentially
* download updated forms from server
*/
-$( document ).ready( function()
-{
- $.ajaxSetup( {
- type: 'POST',
- cache: false
- } );
-
- selection.setListenerFunction( organisationUnitSelected );
- $( '#loaderSpan' ).show();
-
- $( '#orgUnitTree' ).one( 'ouwtLoaded', function()
- {
- log( 'Ouwt loaded' );
- loadMetaData();
- } );
-
- $( document ).bind( 'dhis2.online', function( event, loggedIn )
- {
- if ( loggedIn )
- {
- if ( storageManager.hasLocalData() )
- {
- var message = i18n_need_to_sync_notification
- + ' <button id="sync_button" type="button">' + i18n_sync_now
- + '</button>';
-
- setHeaderMessage( message );
-
- $( '#sync_button' ).bind( 'click', uploadLocalData );
- }
- else
- {
- setHeaderDelayMessage( i18n_online_notification );
- }
- }
- else
- {
- setHeaderMessage( '<form style="display:inline;"><label for="username">Username</label><input name="username" id="username" type="text" size="10"/><label for="password">Password</label><input name="password" id="password" type="password" size="10"/><button id="login_button" type="button">Login</button></form>' );
- ajax_login();
- }
- } );
-
- $( document ).bind( 'dhis2.offline', function()
- {
- setHeaderMessage( i18n_offline_notification );
- } );
-
- dhis2.availability.startAvailabilityCheck();
-} );
-
-function ajax_login()
-{
- $( '#login_button' ).bind( 'click', function()
- {
- var username = $( '#username' ).val();
- var password = $( '#password' ).val();
-
- $.post( '../dhis-web-commons-security/login.action', {
- 'j_username' : username,
- 'j_password' : password
- } ).success( function()
- {
- var ret = dhis2.availability.syncCheckAvailability();
-
- if ( !ret )
- {
- alert( i18n_ajax_login_failed );
- }
- } );
- } );
-}
-
-function loadMetaData()
-{
- var KEY_METADATA = 'metadata';
-
- $.ajax( {
- url: 'getMetaData.action',
+
+function organisationUnitSelected( orgUnits, orgUnitNames )
+{
+ clearEntryForm();
+
+ currentOrganisationUnitId = orgUnits[0];
+ var organisationUnitName = orgUnitNames[0];
+
+ $( '#selectedOrganisationUnit' ).html( organisationUnitName );
+ $( '#currentOrganisationUnit' ).html( organisationUnitName );
+
+ $.ajax({
+ url: 'loadDataSet.action',
dataType: 'json',
success: function( json )
{
- sessionStorage[KEY_METADATA] = JSON.stringify( json.metaData );
- },
- complete: function()
- {
- var metaData = JSON.parse( sessionStorage[KEY_METADATA] );
-
- significantZeros = metaData.significantZeros;
- dataElements = metaData.dataElements;
- indicatorFormulas = metaData.indicatorFormulas;
- dataSets = metaData.dataSets;
- dataSetAssociationSets = metaData.dataSetAssociationSets;
- organisationUnitAssociationSetMap = metaData.organisationUnitAssociationSetMap;
-
- metaDataIsLoaded = true;
- selection.responseReceived(); // Notify that meta data is loaded
- $( '#loaderSpan' ).hide();
- log( 'Meta-data loaded' );
-
- updateForms();
- }
- } );
-}
-
-function uploadLocalData()
-{
- if ( !storageManager.hasLocalData() )
- {
- return;
- }
-
- var dataValues = storageManager.getAllDataValues();
- var completeDataSets = storageManager.getCompleteDataSets();
-
- setHeaderWaitMessage( i18n_uploading_data_notification );
-
- var dataValuesArray = dataValues ? Object.keys( dataValues ) : [];
- var completeDataSetsArray = completeDataSets ? Object.keys( completeDataSets ) : [];
-
- function pushCompleteDataSets( array )
- {
- if ( array.length < 1 )
- {
- return;
- }
-
- var key = array[0];
- var value = completeDataSets[key];
-
- log( 'Uploaded complete data set: ' + key + ', with value: ' + value );
-
- $.ajax( {
- url: 'registerCompleteDataSet.action',
- data: value,
- dataType: 'json',
- success: function( data, textStatus, jqXHR )
- {
- if ( data.status == 2 )
- {
- log( 'DataSet is locked' );
- setHeaderMessage( i18n_register_complete_failed_dataset_is_locked );
- }
- else
- {
- log( 'Successfully saved complete dataset with value: ' + value );
- storageManager.clearCompleteDataSet( value );
- ( array = array.slice( 1 ) ).length && pushCompleteDataSets( array );
-
- if ( array.length < 1 )
- {
- setHeaderDelayMessage( i18n_sync_success );
- }
- }
- },
- error: function( jqXHR, textStatus, errorThrown )
- {
- var message = i18n_sync_failed
- + ' <button id="sync_button" type="button">' + i18n_sync_now
- + '</button>';
-
- setHeaderMessage( message );
-
- $( '#sync_button' ).bind( 'click', uploadLocalData );
- }
- } );
- };
-
- ( function pushDataValues( array )
- {
- if ( array.length < 1 )
- {
- setHeaderDelayMessage( i18n_online_notification );
-
- pushCompleteDataSets( completeDataSetsArray );
-
- return;
- }
-
- var key = array[0];
- var value = dataValues[key];
-
- log( 'Uploaded data value: ' + key + ', with value: ' + value );
-
- $.ajax( {
- url: 'saveValue.action',
- data: value,
- dataType: 'json',
- success: function( data, textStatus, jqXHR )
- {
- if ( data.c == 2 ) {
- log( 'DataSet is locked' );
- setHeaderMessage( i18n_saving_value_failed_dataset_is_locked );
- }
- else
- {
- storageManager.clearDataValueJSON( value );
- log( 'Successfully saved data value with value: ' + value );
- ( array = array.slice( 1 ) ).length && pushDataValues( array );
-
- if ( array.length < 1 && completeDataSetsArray.length > 0 )
- {
- pushCompleteDataSets( completeDataSetsArray );
- }
- else
- {
- setHeaderDelayMessage( i18n_sync_success );
- }
- }
- },
- error: function( jqXHR, textStatus, errorThrown )
- {
- var message = i18n_sync_failed
- + ' <button id="sync_button" type="button">' + i18n_sync_now
- + '</button>';
-
- setHeaderMessage( message );
-
- $( '#sync_button' ).bind( 'click', uploadLocalData );
- }
- } );
- } )( dataValuesArray );
+ var dataSetList = json.dataSets;
+
+ $( '#selectedDataSetId' ).removeAttr( 'disabled' );
+
+ var dataSetId = $( '#selectedDataSetId option:selected' ).val();
+ var periodId = $( '#selectedPeriodId option:selected' ).val();
+
+ clearListById( 'selectedDataSetId' );
+ //addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
+
+ var dataSetValid = false;
+
+ for ( i in dataSetList )
+ {
+ $('#selectedDataSetId').append('<option value=' + dataSetList[i].id + ' formType="'+ dataSetList[i].formType + '" periodType="' + dataSetList[i].periodType + '" >' + dataSetList[i].name + '</option>');
+ }
+
+ enable('selectedDataSetId');
+ }
+
+ });
}
function addEventListeners()
{
- var dataSetId = $( '#selectedDataSetId' ).val();
- var formType = dataSets[dataSetId].type;
+ var dataSetId = $( '#selectedDataSetId option:selected' ).val();
+ var formType = $( '#selectedDataSetId option:selected' ).attr('formType');
$( '[name="entryfield"]' ).each( function( i )
{
var id = $( this ).attr( 'id' );
var dataElementId = id.split( '-' )[0];
var optionComboId = id.split( '-' )[1];
- var type = getDataElementType( dataElementId );
-
+
$( this ).unbind( 'focus' );
$( this ).unbind( 'blur' );
$( this ).unbind( 'change' );
@@ -332,12 +147,6 @@
$( this ).css( 'width', '100%' );
$( this ).css( 'text-align', 'center' );
}
-
- if ( type == 'date' )
- {
- $( this ).css( 'width', '80%' );
- datePicker( id );
- }
} );
$( '[name="entryselect"]' ).each( function( i )
@@ -380,28 +189,15 @@
$( '#infoDiv' ).hide();
}
-function loadForm( dataSetId, attributeId, value )
+function loadForm( dataSetId, value )
{
- if ( storageManager.formExists( dataSetId, attributeId, value ) )
- {
- log( 'Loading form locally: ' + dataSetId );
-
- var html = storageManager.getForm( dataSetId, attributeId, value );
-
- $( '#contentDiv' ).html( html );
-
- loadDataValues();
- }
- else
- {
- log( 'Loading form remotely: ' + dataSetId );
-
- $( '#contentDiv' ).load( 'loadForm.action', {
- dataSetId : dataSetId,
- attributeId: attributeId,
- value: value
- }, loadDataValues );
- }
+ showLoader();
+ $( '#contentDiv' ).load( 'loadForm.action', {
+ dataSetId : dataSetId,
+ value: value
+ }, function(html){
+ loadDataValues();
+ });
}
function getDataElementType( dataElementId )
@@ -411,23 +207,10 @@
return dataElements[dataElementId];
}
- log( 'Data element not present in data set, falling back to default type: ' + dataElementId );
+ //log( 'Data element not present in data set, falling back to default type: ' + dataElementId );
return DEFAULT_TYPE;
}
-function getDataElementName( dataElementId )
-{
- var span = $( '#' + dataElementId + '-dataelement' );
-
- if ( span != null )
- {
- return span.text();
- }
-
- log( 'Data element not present in form, falling back to default name: ' + dataElementId );
- return DEFAULT_NAME;
-}
-
function getOptionComboName( optionComboId )
{
var span = $( '#' + optionComboId + '-optioncombo' );
@@ -437,7 +220,7 @@
return span.text();
}
- log( 'Category option combo not present in form, falling back to default name: ' + optionComboId );
+ //log( 'Category option combo not present in form, falling back to default name: ' + optionComboId );
return DEFAULT_NAME;
}
@@ -475,57 +258,6 @@
return dataSetList;
}
-function organisationUnitSelected( orgUnits, orgUnitNames )
-{
- if ( metaDataIsLoaded == false )
- {
- return false;
- }
-
- currentOrganisationUnitId = orgUnits[0];
- var organisationUnitName = orgUnitNames[0];
-
- $( '#selectedOrganisationUnit' ).val( organisationUnitName );
- $( '#currentOrganisationUnit' ).html( organisationUnitName );
-
- var dataSetList = getSortedDataSetList();
-
- $( '#selectedDataSetId' ).removeAttr( 'disabled' );
-
- var dataSetId = $( '#selectedDataSetId' ).val();
- var periodId = $( '#selectedPeriodId' ).val();
-
- clearListById( 'selectedDataSetId' );
- addOptionById( 'selectedDataSetId', '-1', '[ ' + i18n_select_data_set + ' ]' );
-
- var dataSetValid = false;
-
- for ( i in dataSetList )
- {
- addOptionById( 'selectedDataSetId', dataSetList[i].id, dataSetList[i].name );
-
- if ( dataSetId == dataSetList[i].id )
- {
- dataSetValid = true;
- }
- }
-
- if ( dataSetValid && dataSetId != null )
- {
- $( '#selectedDataSetId' ).val( dataSetId );
-
- if ( periodId && periodId != -1 && dataEntryFormIsLoaded )
- {
- showLoader();
- loadDataValues();
- }
- }
- else
- {
- clearPeriod();
- }
-}
-
// -----------------------------------------------------------------------------
// Next/Previous Periods Selection
// -----------------------------------------------------------------------------
@@ -547,14 +279,14 @@
function displayPeriodsInternal()
{
- var dataSetId = $( '#selectedDataSetId' ).val();
- var periodType = dataSets[dataSetId].periodType;
+ var dataSetId = $( '#selectedDataSetId option:selected' ).val();
+ var periodType = $( '#selectedDataSetId option:selected' ).attr('periodType');
var periods = periodTypeFactory.get( periodType ).generatePeriods( currentPeriodOffset );
periods = periodTypeFactory.filterFuturePeriods( periods );
clearListById( 'selectedPeriodId' );
- addOptionById( 'selectedPeriodId', '-1', '[ ' + i18n_select_period + ' ]' );
+ //addOptionById( 'selectedPeriodId', '-1', '[ ' + i18n_select_period + ' ]' );
for ( i in periods )
{
@@ -568,34 +300,36 @@
function dataSetSelected()
{
- $( '#selectedPeriodId' ).removeAttr( 'disabled' );
+ clearEntryForm();
+
+ clearListById( 'selectedPeriodId' );
+ hideById('attributeDiv');
+
+ $( '#selectedPeriodId' ).removeAttr( 'disabled' );
$( '#prevButton' ).removeAttr( 'disabled' );
$( '#nextButton' ).removeAttr( 'disabled' );
-
- var dataSetId = $( '#selectedDataSetId' ).val();
- var periodId = $( '#selectedPeriodId' ).val();
- var periodType = dataSets[dataSetId].periodType;
+ $( '#valueInput' ).val('');
+ var dataSetId = $( '#selectedDataSetId option:selected' ).val();
+ var periodId = $( '#selectedPeriodId option:selected' ).val();
+ var periodType = $( '#selectedDataSetId option:selected' ).attr('periodType');
var periods = periodTypeFactory.get( periodType ).generatePeriods( currentPeriodOffset );
periods = periodTypeFactory.filterFuturePeriods( periods );
- if ( dataSetId && dataSetId != -1 )
+ if ( dataSetId != -1 )
{
- clearListById( 'selectedPeriodId' );
-
- addOptionById( 'selectedPeriodId', '-1', '[ ' + i18n_select_period + ' ]' );
+
+ //addOptionById( 'selectedPeriodId', '-1', '[ ' + i18n_select_period + ' ]' );
for ( i in periods )
{
addOptionById( 'selectedPeriodId', periods[i].id, periods[i].name );
}
- var previousPeriodType = currentDataSetId ? dataSets[currentDataSetId].periodType : null;
+ var previousPeriodType = currentDataSetId ? periodType : null;
if ( periodId && periodId != -1 && previousPeriodType && previousPeriodType == periodType )
{
- showLoader();
$( '#selectedPeriodId' ).val( periodId );
- loadForm( dataSetId, getFieldValue( 'attributeId' ), byId( 'valueInput' ).value );
}
else
{
@@ -603,17 +337,100 @@
}
currentDataSetId = dataSetId;
+
+ loadSubDataSets(dataSetId);
}
}
+function loadSubDataSets( dataSetId )
+{
+ $.getJSON( 'loadDepartments.action',
+ {
+ dataSetId: dataSetId
+ },
+ function( json )
+ {
+ if( json.department.length > 0 )
+ {
+ clearListById( 'subDataSetId' );
+ $('#subDataSetId').append('<option value=-1>' + i18n_please_select_department + '</option>');
+ for ( i in json.department )
+ {
+ $('#subDataSetId').append('<option value=' + json.department[i].id + '>' + json.department[i].name + '</option>');
+ }
+ showById('departmentDiv');
+
+ jQuery("#valueInput").unbind('change');
+ jQuery("#value").unbind('select');
+ jQuery('#selectedPeriodId').unbind('change');
+ }
+ else
+ {
+ loadAttributeValues( dataSetId );
+ hideById('departmentDiv');
+ }
+ } );
+}
+
+function loadAttributeValues( dataSetId )
+{
+ $.getJSON( 'loadAttribueValues.action',
+ {
+ dataSetId: dataSetId
+ }
+ , function( json )
+ {
+ if( json.attributeValues.length > 0 )
+ {
+ clearListById( 'value' );
+ for ( i in json.attributeValues )
+ {
+ $('#value').append('<option value=' + json.attributeValues[i] + '>' + json.attributeValues[i] + '</option>');
+ }
+ autoCompletedField();
+ jQuery("#valueInput").bind('change', periodSelected);
+ jQuery("#value").bind('select', periodSelected);
+ jQuery('#selectedPeriodId').unbind('change');
+ showById('attributeDiv');
+ }
+ else
+ {
+ jQuery("#valueInput").unbind('change');
+ jQuery("#value").unbind('change');
+ jQuery('#selectedPeriodId').bind('change', periodSelected);
+ hideById('attributeDiv');
+ }
+ } );
+}
+
// -----------------------------------------------------------------------------
// Period Selection
// -----------------------------------------------------------------------------
+function loadDepartmentFormSelected()
+{
+ var periodName = $( '#selectedPeriodId option:selected' ).text();
+ var dataSetId = $( '#subDataSetId option:selected' ).val();
+
+ $( '#currentPeriod' ).html( periodName );
+
+ var periodId = $( '#selectedPeriodId' ).val();
+
+ if ( periodId && periodId != -1 && dataSetId != -1 )
+ {
+ showLoader();
+ loadForm( dataSetId, byId( 'valueInput' ).value );
+ }
+ else
+ {
+ clearEntryForm();
+ }
+}
+
function periodSelected()
{
- var periodName = $( '#selectedPeriodId :selected' ).text();
- var dataSetId = $( '#selectedDataSetId' ).val();
+ var periodName = $( '#selectedPeriodId option:selected' ).text();
+ var dataSetId = $( '#selectedDataSetId option:selected' ).val();
$( '#currentPeriod' ).html( periodName );
@@ -622,16 +439,12 @@
if ( periodId && periodId != -1 )
{
showLoader();
-
- //if ( dataEntryFormIsLoaded )
- //{
- // loadDataValues();
- //}
- //else
- //{
- loadForm( dataSetId, getFieldValue( 'attributeId' ), byId( 'valueInput' ).value );
- //}
+ loadForm( dataSetId, byId( 'valueInput' ).value );
}
+ else
+ {
+ clearEntryForm();
+ }
}
// -----------------------------------------------------------------------------
@@ -653,8 +466,8 @@
var dataValueMap = [];
currentMinMaxValueMap = []; // Reset
- var periodId = $( '#selectedPeriodId' ).val();
- var dataSetId = $( '#selectedDataSetId' ).val();
+ var periodId = $( '#selectedPeriodId option:selected' ).val();
+ var dataSetId = $( '#selectedDataSetId option:selected' ).val();
// Clear existing values and colors, grey disabled fields
@@ -763,6 +576,10 @@
$( '#undoButton' ).attr( 'disabled', 'disabled' );
$( '#infoDiv' ).hide();
}
+
+
+ showById('completenessDiv');
+ hideLoader();
}
} );
}
@@ -773,7 +590,6 @@
$( '#validationButton' ).removeAttr( 'disabled' );
- dataEntryFormIsLoaded = true;
hideLoader();
}
@@ -1001,8 +817,8 @@
function validate()
{
- var periodId = $( '#selectedPeriodId' ).val();
- var dataSetId = $( '#selectedDataSetId' ).val();
+ var periodId = $( '#selectedPeriodId option:selected' ).val();
+ var dataSetId = $( '#selectedDataSetId option:selected' ).val();
$( '#validationDiv' ).load( 'validate.action', {
periodId : periodId,
@@ -1035,6 +851,19 @@
} );
}
+function getDataElementName( dataElementId )
+{
+ var span = $( '#' + dataElementId + '-dataelement' );
+
+ if ( span != null )
+ {
+ return span.text();
+ }
+
+ log( 'Data element not present in form, falling back to default name: ' + dataElementId );
+ return DEFAULT_NAME;
+}
+
function viewHist( dataElementId, optionComboId )
{
var periodId = $( '#selectedPeriodId' ).val();
@@ -1427,7 +1256,7 @@
var dataValues = {};
- if ( localStorage[KEY_DATAVALUES] != null )
+ /* if ( localStorage[KEY_DATAVALUES] != null )
{
dataValues = JSON.parse( localStorage[KEY_DATAVALUES] );
}
@@ -1442,7 +1271,7 @@
} catch ( e )
{
log( 'Max local storage quota reached, ignored data value' );
- }
+ } */
};
/**
@@ -1537,8 +1366,8 @@
this.getCurrentCompleteDataSetParams = function()
{
var params = {
- 'periodId' : $( '#selectedPeriodId' ).val(),
- 'dataSetId' : $( '#selectedDataSetId' ).val(),
+ 'periodId' : $( '#selectedPeriodId option:selected' ).val(),
+ 'dataSetId' : $( '#selectedDataSetId option:selected' ).val(),
'organisationUnitId' : currentOrganisationUnitId
};
@@ -1706,6 +1535,7 @@
},
select: function( event, ui ) {
ui.item.option.selected = true;
+ periodSelected();
},
change: function( event, ui ) {
if ( !ui.item ) {
@@ -1714,14 +1544,11 @@
select.children( "option" ).each(function() {
if ( $( this ).text().match( matcher ) ) {
this.selected = valid = true;
+ periodSelected();
return false;
}
});
if ( !valid ) {
- // remove invalid value, as it didn't match anything
- //$( this ).val( "" );
- //select.val( "" );
- //input.data( "autocomplete" ).term = "";
return false;
}
}
@@ -1751,6 +1578,7 @@
// close if already visible
if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
input.autocomplete( "close" );
+ periodSelected();
return;
}
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/jsonAttributeValues.vm'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/jsonAttributeValues.vm 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/jsonAttributeValues.vm 2012-05-10 16:18:43 +0000
@@ -1,9 +1,10 @@
#set( $size = $values.size() )
{ "attributeValues": [
#foreach( $value in $values )
- {
- "value": "$!encoder.jsonEncode( $value )"
- }#if( $velocityCount < $size ),#end
+ #if($value!='')
+ "$!encoder.jsonEncode( $value )"
+ #end
+ #if( $velocityCount < $size ),#end
#end
]
}
\ No newline at end of file
=== added file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/jsonDepartments.vm'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/jsonDepartments.vm 1970-01-01 00:00:00 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/jsonDepartments.vm 2012-05-10 16:18:43 +0000
@@ -0,0 +1,10 @@
+#set( $size = $mapDataSets.keySet().size() )
+{ "department": [
+ #foreach( $id in $mapDataSets.keySet() )
+ {
+ "id": "$id",
+ "name": "$mapDataSets.get($id)"
+ }#if( $velocityCount < $size ),#end
+ #end
+ ]
+}
\ No newline at end of file
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/responseDataSets.vm'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/responseDataSets.vm 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/responseDataSets.vm 2012-05-10 16:18:43 +0000
@@ -3,8 +3,16 @@
#foreach( $dataSet in $dataSets )
{
"id": $!{dataSet.id},
- "name": "$!encoder.jsonEncode( ${dataSet.name} )"
+ "name": "$!encoder.jsonEncode( ${dataSet.name} )",
+ "periodType": "${dataSet.periodType.name}",
+ "formType":
+ #if(!$dataSet.dataEntry)
+ "custom"
+ #elseif(!$dataSet.sections)
+ "section"
+ #else
+ "default"
+ #end
}#if( $velocityCount < $size ),#end
-#end ],
- "dataSetValid": ${dataSetValid}
+#end ]
}
\ No newline at end of file
=== modified file 'local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/select.vm'
--- local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/select.vm 2012-05-03 02:23:12 +0000
+++ local/vn/dhis-web-dataentry-hospital/src/main/webapp/dhis-web-dataentry-hospital/select.vm 2012-05-10 16:18:43 +0000
@@ -1,4 +1,5 @@
<script type="text/javascript">
+leftBar.hideAnimated();
var i18n_select_data_set = '$encoder.jsEscape( $i18n.getString( "select_data_set" ) , "'")';
var i18n_select_period = '$encoder.jsEscape( $i18n.getString( "select_period" ) , "'")';
var i18n_register_complete_dataset_success = '$encoder.jsEscape( $i18n.getString( "register_complete_dataset_success" ) , "'")';
@@ -38,9 +39,7 @@
var i18n_unregister_complete_failed_dataset_is_locked = '$encoder.jsEscape( $i18n.getString( "unregister_complete_failed_dataset_is_locked" ) , "'")';
var i18n_please_select_attribute = "[ " + '$encoder.jsEscape( $i18n.getString( "please_select_attribute" ) , "'")' + " ]";
var i18n_show_all_items = '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'")';
-jQuery(document).ready( function(){
- getAttributes();
-});
+var i18n_please_select_department = "[ " + '$encoder.jsEscape( $i18n.getString( "please_select_department" ) , "'")' + " ]";
</script>
<h3>$i18n.getString( "data_entry" ) #openHelp( "dataEntry" )</h3>
@@ -54,44 +53,49 @@
<div id="actions">
<input type="button" value="$i18n.getString( 'run_validation' )" onclick="validate()" id="validationButton" style="width:150px;" disabled="disabled"/>
</div>
+<input type='button' id='showDataBtn' value='$i18n.getString( "show_data" )' onclick="showById('inputCriteria'); hideById('showDataBtn');" style='display:none;'>
-<div class="inputCriteria" style="width:504px;height:130px;">
+<div class="inputCriteria" id='inputCriteria' style="width:620px;height:270px;">
+<input type='hidden' id='dataSetId' name='dataSetId'>
<table>
<tr>
- <td><label for="selectedOrganisationUnit">$i18n.getString( "organisation_unit" )</label></td>
- <td><input type="text" id="selectedOrganisationUnit" readonly="readonly" value="[ $i18n.getString( 'select_from_tree' ) ]" style="width:367px"></td>
- </tr>
- <tr>
- <td><label for="selectedDataSetId">$i18n.getString( "data_set" )</label></td>
- <td><select id="selectedDataSetId" name="selectedDataSetId" style="width:371px" onchange="dataSetSelected()" disabled="disabled"></select>
+ <td><label class='bold' for="selectedOrganisationUnit">$i18n.getString( "organisation_unit" )</label>
+ <td colspan='2' align='right'><img src='../images/hide_active.png' style='cursor: pointer;' onclick="hideById('inputCriteria'); showById('showDataBtn');">
+ </tr>
+ <tr>
+ <td>
+ <span id="selectedOrganisationUnit">[ $i18n.getString( 'select_from_tree' ) ]</span></td>
+ </td>
+ </tr>
+ <tr>
+ <td><label class='bold' for="selectedDataSetId">$i18n.getString( "data_set" )</label></td>
+ <td><label class='bold' for="selectedPeriodId">$i18n.getString( "period" )</label></td>
+ </tr>
+ <tr>
+ <td><select id="selectedDataSetId" name="selectedDataSetId" multiple size='10' style="width:371px" onchange="dataSetSelected()" disabled="disabled"></select>
<span id="loaderSpan" style="display:none"><img src='../images/ajax-loader-bar.gif'></span></td>
- </tr>
- <tr>
- <td><label for="selectedPeriodId">$i18n.getString( "period" )</label></td>
- <td><select id="selectedPeriodId" name="selectedPeriodId" style="width:215px" disabled="disabled"></select>
+ <td><select id="selectedPeriodId" name="selectedPeriodId" multiple size='9' style="width:215px" disabled="disabled" ></select>
<input type="button" id="prevButton" style="width:75px" value="$i18n.getString( 'prev_year' )" title="$i18n.getString('earlier_periods')" onclick="previousPeriodsSelected()" disabled="disabled">
<input type="button" id="nextButton" style="width:75px" value="$i18n.getString( 'next_year' )" title="$i18n.getString('later_periods')" onclick="nextPeriodsSelected()" disabled="disabled">
</td>
</tr>
- <tr>
- <td><label for="attributeId">$i18n.getString( "attribute" )</label></td>
- <td>
- <select id="attributeId" name="attributeId" style="width:215px" onchange='getSuggestedAttrValue();'></select>
- <select id='value' name='value' style='display:none;' /></select>
-
- <input type="text" id="valueInput" name="valueInput" />
- <button type='button' id='valueButton' class='small-button' > </button>
-
- </td>
- </tr>
+ <tr id='attributeDiv' style='display:none;'>
+ <td>
+ <label class='bold' for="attributeId">$i18n.getString( "attribute" )</label>
+ <select id='value' name='value' style='display:none;' /></select>
+ <input type="text" id="valueInput" style="width:330px" name="valueInput" />
+ <button type='button' id='valueButton' class='small-button' > </button>
+ </td>
+ </tr>
+
+ <tr id='departmentDiv' style='display:none;'>
+ <td>
+ <label class='bold' for="attributeId">$i18n.getString( "department" )</label><br>
+ <select id='subDataSetId' name='subDataSetId' onchange='javascript:loadDepartmentFormSelected();' /></select>
+ </td>
+ </tr>
- <tr>
- <td><p></p></td>
- <td>
- <input type='button' id='loadButton' value='$i18n.getString("load_entry_form")' onclick='periodSelected();'>
- </td>
- </tr>
</table>
</div>