=== modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/EquipmentService.java' --- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/EquipmentService.java 2012-05-15 12:19:04 +0000 +++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/EquipmentService.java 2012-05-19 14:42:20 +0000 @@ -1,6 +1,7 @@ package org.hisp.dhis.coldchain.inventory; import java.util.Collection; +import java.util.List; public interface EquipmentService { @@ -17,4 +18,8 @@ Collection getEquipments( EquipmentInstance equipmentInstance ); Equipment getEquipment( EquipmentInstance equipmentInstance, InventoryTypeAttribute inventoryTypeAttribute ); + + //Map inventryTypeAttributeAndValue( EquipmentInstance equipmentInstance, List inventoryTypeAttributeList ); + + String inventryTypeAttributeAndValue( EquipmentInstance equipmentInstance, List inventoryTypeAttributeList ); } === modified file 'local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/comparator/InventoryTypeAttributeMandatoryComparator.java' --- local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/comparator/InventoryTypeAttributeMandatoryComparator.java 2012-05-02 09:18:42 +0000 +++ local/in/dhis-in-api/src/main/java/org/hisp/dhis/coldchain/inventory/comparator/InventoryTypeAttributeMandatoryComparator.java 2012-05-19 14:42:20 +0000 @@ -8,9 +8,21 @@ { public int compare( InventoryTypeAttribute inventoryTypeAttribute0, InventoryTypeAttribute inventoryTypeAttribute1 ) { + if( ( inventoryTypeAttribute0.isMandatory() ) && ( inventoryTypeAttribute1.isMandatory() ) ) + { + return inventoryTypeAttribute0.getName().compareToIgnoreCase( inventoryTypeAttribute1.getName() ); + //Boolean boolean1 = inventoryTypeAttribute0.isMandatory(); + //return boolean1.compareTo( inventoryTypeAttribute1.isMandatory() ); + } + else + { + return inventoryTypeAttribute0.getName().compareToIgnoreCase( inventoryTypeAttribute1.getName() ); + } + /* if( inventoryTypeAttribute0.isMandatory() ) return 1; else return 0; + */ } } === modified file 'local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/inventory/DefaultEquipmentService.java' --- local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/inventory/DefaultEquipmentService.java 2012-05-15 12:19:04 +0000 +++ local/in/dhis-in-services/dhis-in-service-coldchain/src/main/java/org/hisp/dhis/coldchain/inventory/DefaultEquipmentService.java 2012-05-19 14:42:20 +0000 @@ -1,6 +1,7 @@ package org.hisp.dhis.coldchain.inventory; import java.util.Collection; +import java.util.List; import org.springframework.transaction.annotation.Transactional; @Transactional @@ -51,5 +52,85 @@ { return equipmentStore.getEquipment( equipmentInstance, inventoryTypeAttribute ); } + /* + public Map inventryTypeAttributeAndValue( EquipmentInstance equipmentInstance, List inventoryTypeAttributeList ) + { + String inventoryTypeAttributeName = ""; + + String inventoryTypeAttributeValue = ""; + + String inventoryTypeAttributeNameValue = ""; + + Map inventryTypeAttributeAndValueMap = new HashMap(); + + for( InventoryTypeAttribute inventoryTypeAttribute : inventoryTypeAttributeList ) + { + Equipment equipmentDetail = getEquipment( equipmentInstance, inventoryTypeAttribute ); + if( equipmentDetail != null && equipmentDetail.getValue() != null ) + { + + if ( InventoryTypeAttribute.TYPE_COMBO.equalsIgnoreCase( equipmentDetail.getInventoryTypeAttribute().getValueType() ) ) + { + inventryTypeAttributeAndValueMap.put( inventoryTypeAttribute.getName(), equipmentDetail.getInventoryTypeAttributeOption().getName() ); + + inventoryTypeAttributeName += "--" + inventoryTypeAttribute.getName(); + inventoryTypeAttributeValue += "--" + equipmentDetail.getInventoryTypeAttributeOption().getName(); + } + else + { + inventryTypeAttributeAndValueMap.put( inventoryTypeAttribute.getName(), equipmentDetail.getValue() ); + + inventoryTypeAttributeName += "--" + inventoryTypeAttribute.getName(); + inventoryTypeAttributeValue += "--" + equipmentDetail.getValue(); + } + + inventoryTypeAttributeNameValue = inventoryTypeAttributeName + "#@" + inventoryTypeAttributeValue; + } + } + + + + return inventryTypeAttributeAndValueMap; + } + */ + public String inventryTypeAttributeAndValue( EquipmentInstance equipmentInstance, List inventoryTypeAttributeList ) + { + String inventoryTypeAttributeName = ""; + + String inventoryTypeAttributeValue = ""; + + String inventoryTypeAttributeNameValue = ""; + + //Map inventryTypeAttributeAndValueMap = new HashMap(); + + for( InventoryTypeAttribute inventoryTypeAttribute : inventoryTypeAttributeList ) + { + Equipment equipmentDetail = getEquipment( equipmentInstance, inventoryTypeAttribute ); + if( equipmentDetail != null && equipmentDetail.getValue() != null ) + { + + if ( InventoryTypeAttribute.TYPE_COMBO.equalsIgnoreCase( equipmentDetail.getInventoryTypeAttribute().getValueType() ) ) + { + //inventryTypeAttributeAndValueMap.put( inventoryTypeAttribute.getName(), equipmentDetail.getInventoryTypeAttributeOption().getName() ); + + inventoryTypeAttributeName += "--" + inventoryTypeAttribute.getName(); + inventoryTypeAttributeValue += "--" + equipmentDetail.getInventoryTypeAttributeOption().getName(); + } + else + { + //inventryTypeAttributeAndValueMap.put( inventoryTypeAttribute.getName(), equipmentDetail.getValue() ); + + inventoryTypeAttributeName += "--" + inventoryTypeAttribute.getName(); + inventoryTypeAttributeValue += "--" + equipmentDetail.getValue(); + } + + inventoryTypeAttributeNameValue = inventoryTypeAttributeName.substring( 2 ) + "#@#" + inventoryTypeAttributeValue.substring( 2 ); + } + } + + //System.out.println( inventoryTypeAttributeName + "#@#" + inventoryTypeAttributeValue ); + + return inventoryTypeAttributeNameValue; + } } === added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/GetMetaDataAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/GetMetaDataAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/GetMetaDataAction.java 2012-05-19 14:42:20 +0000 @@ -0,0 +1,131 @@ +package org.hisp.dhis.coldchain.equipment.action; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.expression.ExpressionService; +import org.hisp.dhis.indicator.Indicator; +import org.hisp.dhis.indicator.IndicatorService; +import org.hisp.dhis.organisationunit.OrganisationUnitDataSetAssociationSet; +import org.hisp.dhis.organisationunit.OrganisationUnitService; + +import com.opensymphony.xwork2.Action; + +public class GetMetaDataAction implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + + private ExpressionService expressionService; + + public void setExpressionService( ExpressionService expressionService ) + { + this.expressionService = expressionService; + } + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Collection significantZeros; + + public Collection getSignificantZeros() + { + return significantZeros; + } + + private Collection dataElements; + + public Collection getDataElements() + { + return dataElements; + } + + private Collection indicators; + + public Collection getIndicators() + { + return indicators; + } + + private Collection dataSets; + + public Collection getDataSets() + { + return dataSets; + } + + private List> dataSetAssociationSets; + + public List> getDataSetAssociationSets() + { + return dataSetAssociationSets; + } + + private Map organisationUnitAssociationSetMap; + + public Map getOrganisationUnitAssociationSetMap() + { + return organisationUnitAssociationSetMap; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + significantZeros = dataElementService.getDataElementsByZeroIsSignificant( true ); + + dataElements = dataElementService.getDataElementsWithDataSets(); + + indicators = indicatorService.getIndicatorsWithDataSets(); + + expressionService.explodeAndSubstituteExpressions( indicators, null ); + + OrganisationUnitDataSetAssociationSet organisationUnitSet = organisationUnitService.getOrganisationUnitDataSetAssociationSet(); + + dataSetAssociationSets = organisationUnitSet.getDataSetAssociationSets(); + + organisationUnitAssociationSetMap = organisationUnitSet.getOrganisationUnitAssociationSetMap(); + + dataSets = dataSetService.getDataSets( organisationUnitSet.getDistinctDataSets() ); + + return SUCCESS; + } +} === added file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/LoadFormAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/LoadFormAction.java 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/LoadFormAction.java 2012-05-19 14:42:20 +0000 @@ -0,0 +1,302 @@ +package org.hisp.dhis.coldchain.equipment.action; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategory; +import org.hisp.dhis.dataelement.DataElementCategoryCombo; +import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.dataentryform.DataEntryForm; +import org.hisp.dhis.dataentryform.DataEntryFormService; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.i18n.I18n; + +import com.opensymphony.xwork2.Action; + +public class LoadFormAction implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + private DataEntryFormService dataEntryFormService; + + public void setDataEntryFormService( DataEntryFormService dataEntryFormService ) + { + this.dataEntryFormService = dataEntryFormService; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Comparator + // ------------------------------------------------------------------------- + + private Comparator dataElementComparator; + + public void setDataElementComparator( Comparator dataElementComparator ) + { + this.dataElementComparator = dataElementComparator; + } + + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Integer dataSetId; + + public void setDataSetId( Integer dataSetId ) + { + this.dataSetId = dataSetId; + } + + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Map> orderedDataElements = new HashMap>(); + + public Map> getOrderedDataElements() + { + return orderedDataElements; + } + + private List orderedCategoryCombos = new ArrayList(); + + public List getOrderedCategoryCombos() + { + return orderedCategoryCombos; + } + + + private Map numberOfTotalColumns = new HashMap(); + + public Map getNumberOfTotalColumns() + { + return numberOfTotalColumns; + } + + private Map> orderdCategoryOptionCombos = new HashMap>(); + + public Map> getOrderdCategoryOptionCombos() + { + return orderdCategoryOptionCombos; + } + + private Map> orderedCategories = new HashMap>(); + + public Map> getOrderedCategories() + { + return orderedCategories; + } + + private Map>> orderedOptionsMap = new HashMap>>(); + + public Map>> getOrderedOptionsMap() + { + return orderedOptionsMap; + } + + private Map>> catColRepeat = new HashMap>>(); + + public Map>> getCatColRepeat() + { + return catColRepeat; + } + + private String customDataEntryFormCode; + + public String getCustomDataEntryFormCode() + { + return this.customDataEntryFormCode; + } + + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() throws Exception + { + + DataSet dataSet = dataSetService.getDataSet( dataSetId, true, false, false ); + + List dataElements = new ArrayList( dataSet.getDataElements() ); + + if ( dataElements.isEmpty() ) + { + return INPUT; + } + + Collections.sort( dataElements, dataElementComparator ); + + orderedDataElements = dataElementService.getGroupedDataElementsByCategoryCombo( dataElements ); + + orderedCategoryCombos = dataElementService.getDataElementCategoryCombos( dataElements ); + + + for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos ) + { + List optionCombos = categoryCombo.getSortedOptionCombos(); + + orderdCategoryOptionCombos.put( categoryCombo.getId(), optionCombos ); + + // ----------------------------------------------------------------- + // Perform ordering of categories and their options so that they + // could be displayed as in the paper form. Note that the total + // number of entry cells to be generated are the multiple of options + // from each category. + // ----------------------------------------------------------------- + + numberOfTotalColumns.put( categoryCombo.getId(), optionCombos.size() ); + + orderedCategories.put( categoryCombo.getId(), categoryCombo.getCategories() ); + + Map> optionsMap = new HashMap>(); + + for ( DataElementCategory dec : categoryCombo.getCategories() ) + { + optionsMap.put( dec.getId(), dec.getCategoryOptions() ); + } + + orderedOptionsMap.put( categoryCombo.getId(), optionsMap ); + + // ----------------------------------------------------------------- + // Calculating the number of times each category should be repeated + // ----------------------------------------------------------------- + + Map catRepeat = new HashMap(); + + Map> colRepeat = new HashMap>(); + + int catColSpan = optionCombos.size(); + + for ( DataElementCategory cat : categoryCombo.getCategories() ) + { + int categoryOptionSize = cat.getCategoryOptions().size(); + + if ( catColSpan > 0 && categoryOptionSize > 0 ) + { + catColSpan = catColSpan / categoryOptionSize; + int total = optionCombos.size() / (catColSpan * categoryOptionSize); + Collection cols = new ArrayList( total ); + + for ( int i = 0; i < total; i++ ) + { + cols.add( i ); + } + + colRepeat.put( cat.getId(), cols ); + + catRepeat.put( cat.getId(), catColSpan ); + } + } + + catColRepeat.put( categoryCombo.getId(), colRepeat ); + } + + // --------------------------------------------------------------------- + // Get data entry form + // --------------------------------------------------------------------- + + String displayMode = dataSet.getDataSetType(); + + if ( displayMode.equals( DataSet.TYPE_SECTION ) ) + { + //getSectionForm( dataElements, dataSet ); + } + else + { + getOtherDataEntryForm( dataElements, dataSet ); + } + + + System.out.println( displayMode ); + + return displayMode; + } + + // ------------------------------------------------------------------------- + // Supportive methods + // ------------------------------------------------------------------------- + /* + private void getSectionForm( Collection dataElements, DataSet dataSet ) + { + sections = new ArrayList
( dataSet.getSections() ); + + Collections.sort( sections, new SectionOrderComparator() ); + + for ( Section section : sections ) + { + DataElementCategoryCombo sectionCategoryCombo = section.getCategoryCombo(); + + if ( sectionCategoryCombo != null ) + { + orderedCategoryCombos.add( sectionCategoryCombo ); + + sectionCombos.put( section.getId(), sectionCategoryCombo.getId() ); + } + + for ( DataElementOperand operand : section.getGreyedFields() ) + { + greyedFields.put( operand.getDataElement().getId() + ":" + + operand.getCategoryOptionCombo().getId(), true ); + } + } + } + */ + private void getOtherDataEntryForm( List dataElements, DataSet dataSet ) + { + DataEntryForm dataEntryForm = dataSet.getDataEntryForm(); + + if ( dataEntryForm != null ) + { + customDataEntryFormCode = dataEntryFormService.prepareDataEntryFormForEntry( dataEntryForm.getHtmlCode(), + i18n, dataSet ); + } + + List des = new ArrayList(); + + for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos ) + { + des = (List) orderedDataElements.get( categoryCombo ); + + Collections.sort( des, IdentifiableObjectNameComparator.INSTANCE ); + + orderedDataElements.put( categoryCombo, des ); + } + } + +} + === modified file 'local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/ShowEquipmentDataEntryFormAction.java' --- local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/ShowEquipmentDataEntryFormAction.java 2012-05-17 09:53:19 +0000 +++ local/in/dhis-web-coldchain/src/main/java/org/hisp/dhis/coldchain/equipment/action/ShowEquipmentDataEntryFormAction.java 2012-05-19 14:42:20 +0000 @@ -1,6 +1,24 @@ package org.hisp.dhis.coldchain.equipment.action; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.hisp.dhis.coldchain.inventory.Equipment; import org.hisp.dhis.coldchain.inventory.EquipmentDataValueService; +import org.hisp.dhis.coldchain.inventory.EquipmentInstance; +import org.hisp.dhis.coldchain.inventory.EquipmentInstanceService; +import org.hisp.dhis.coldchain.inventory.EquipmentService; +import org.hisp.dhis.coldchain.inventory.InventoryType; +import org.hisp.dhis.coldchain.inventory.InventoryTypeAttribute; +import org.hisp.dhis.coldchain.inventory.InventoryTypeService; +import org.hisp.dhis.coldchain.inventory.comparator.InventoryTypeAttributeMandatoryComparator; +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.organisationunit.OrganisationUnit; import com.opensymphony.xwork2.Action; @@ -18,6 +36,26 @@ this.equipmentDataValueService = equipmentDataValueService; } + private EquipmentInstanceService equipmentInstanceService; + + public void setEquipmentInstanceService( EquipmentInstanceService equipmentInstanceService ) + { + this.equipmentInstanceService = equipmentInstanceService; + } + + private InventoryTypeService inventoryTypeService; + + public void setInventoryTypeService( InventoryTypeService inventoryTypeService ) + { + this.inventoryTypeService = inventoryTypeService; + } + private EquipmentService equipmentService; + + public void setEquipmentService( EquipmentService equipmentService ) + { + this.equipmentService = equipmentService; + } + // ------------------------------------------------------------------------- // Input & Output // ------------------------------------------------------------------------- @@ -43,6 +81,64 @@ this.periodId = periodId; } + private List dataSetList; + + public List getDataSetList() + { + return dataSetList; + } + + private OrganisationUnit organisationUnit; + + public OrganisationUnit getOrganisationUnit() + { + return organisationUnit; + } + + private InventoryType inventoryType; + + public InventoryType getInventoryType() + { + return inventoryType; + } + + public List inventoryTypeAttributeList; + + public List getInventoryTypeAttributeList() + { + return inventoryTypeAttributeList; + } + + private Map inventryTypeAttributeAndValueMap; + + + + public Map getInventryTypeAttributeAndValueMap() + { + return inventryTypeAttributeAndValueMap; + } + + private String inventoryTypeAttributeNameValue; + + public String getInventoryTypeAttributeNameValue() + { + return inventoryTypeAttributeNameValue; + } + + private String inventoryTypeAttributeName; + + public String getInventoryTypeAttributeName() + { + return inventoryTypeAttributeName; + } + + private String inventoryTypeAttributeValue; + + public String getInventoryTypeAttributeValue() + { + return inventoryTypeAttributeValue; + } + @@ -51,7 +147,96 @@ // ------------------------------------------------------------------------- public String execute() throws Exception { - + + EquipmentInstance equipmentInstance = equipmentInstanceService.getEquipmentInstance( equipmentInstanceId ); + //equipmentInstance.getInventoryType().getDataSets(); + organisationUnit = equipmentInstance.getOrganisationUnit(); + inventoryType = equipmentInstance.getInventoryType(); + dataSetList = new ArrayList( equipmentInstance.getInventoryType().getDataSets() ); + + Collections.sort( dataSetList, IdentifiableObjectNameComparator.INSTANCE ); + + for( DataSet dataSet : dataSetList ) + { + System.out.println( dataSet.getPeriodType().getId() +"--------" +dataSet.getPeriodType().getName()); + } + + + inventoryTypeAttributeList = new ArrayList( inventoryTypeService.getAllInventoryTypeAttributesForDisplay( inventoryType )); + + if( inventoryTypeAttributeList == null || inventoryTypeAttributeList.size() == 0 ) + { + inventoryTypeAttributeList = new ArrayList( inventoryType.getInventoryTypeAttributes() ); + Collections.sort( inventoryTypeAttributeList, new InventoryTypeAttributeMandatoryComparator() ); + if( inventoryTypeAttributeList != null && inventoryTypeAttributeList.size() > 3 ) + { + int count = 1; + Iterator iterator = inventoryTypeAttributeList.iterator(); + while( iterator.hasNext() ) + { + iterator.next(); + + if( count > 3 ) + iterator.remove(); + + count++; + } + } + + } + //List equipmentDetailsList = new ArrayList( equipmentService.getEquipments( equipmentInstance ) ); + + //inventryTypeAttributeAndValueMap = new HashMap(); + + //inventryTypeAttributeAndValueMap.putAll( equipmentService.inventryTypeAttributeAndValue( equipmentInstance, inventoryTypeAttributeList )); + + inventoryTypeAttributeNameValue = equipmentService.inventryTypeAttributeAndValue( equipmentInstance, inventoryTypeAttributeList ); + String[] tempNameValue = inventoryTypeAttributeNameValue.split( "#@#" ); + + inventoryTypeAttributeName = tempNameValue[0]; + + inventoryTypeAttributeValue = tempNameValue[1]; + + System.out.println( inventoryTypeAttributeName + "---" + inventoryTypeAttributeValue ); + + /* + for( InventoryTypeAttribute inventoryTypeAttribute : inventoryTypeAttributeList ) + { + + System.out.println( inventoryTypeAttribute.getName() + "---" + inventryTypeAttributeAndValueMap.get( inventoryTypeAttribute.getName()) ); + + + Equipment equipmentDetails = equipmentService.getEquipment( equipmentInstance, inventoryTypeAttribute ); + if( equipmentDetails != null && equipmentDetails.getValue() != null ) + { + //System.out.println( inventoryTypeAttribute.getName() + "---" + equipmentDetails.getValue() ); + + + //equipmentDetailsMap.put( equipmentInstance.getId()+":"+inventoryTypeAttribute1.getId(), equipmentDetails.getValue() ); + } + + } + */ + + + + + + /* + + for( Equipment equipmentDetails : equipmentDetailsList ) + { + if ( InventoryTypeAttribute.TYPE_COMBO.equalsIgnoreCase( equipmentDetails.getInventoryTypeAttribute().getValueType() ) ) + { + equipmentValueMap.put( equipmentDetails.getInventoryTypeAttribute().getId(), equipmentDetails.getInventoryTypeAttributeOption().getName() ); + } + else + { + equipmentValueMap.put( equipmentDetails.getInventoryTypeAttribute().getId(), equipmentDetails.getValue() ); + } + } + */ + return SUCCESS; } === modified file 'local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml' --- local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-05-17 07:33:28 +0000 +++ local/in/dhis-web-coldchain/src/main/resources/META-INF/dhis/beans.xml 2012-05-19 14:42:20 +0000 @@ -461,4 +461,29 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file === modified file 'local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties' --- local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-05-17 07:33:28 +0000 +++ local/in/dhis-web-coldchain/src/main/resources/org/hisp/dhis/coldchain/i18n_module.properties 2012-05-19 14:42:20 +0000 @@ -100,4 +100,9 @@ display = For display available_datasets = Available datasets selected_datasets = Selected datasets -dataset_inventorytype = Dataset inventorytype \ No newline at end of file +dataset_inventorytype = Dataset inventorytype +dataset = Dataset +equipment_dataentry = Equipment dataentry +period = Period +prev_year = Prev year +next_year = Next year \ No newline at end of file === modified file 'local/in/dhis-web-coldchain/src/main/resources/struts.xml' --- local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-05-17 07:33:28 +0000 +++ local/in/dhis-web-coldchain/src/main/resources/struts.xml 2012-05-19 14:42:20 +0000 @@ -463,6 +463,30 @@ /dhis-web-commons/ajax/jsonResponseError.vm F_EQUIPMENT_DELETE + + + + /main.vm + /dhis-web-coldchain/equipmentDataEntry.vm + /dhis-web-coldchain/menu.vm + css/equipmentDataentry.css + ../dhis-web-commons/ouwt/ouwt.js,javascript/equipment.js,javascript/equipmentDataEntry.js + + + + + /dhis-web-coldchain/responseMetaData.vm + + + + /dhis-web-coldchain/customForm.vm + + /dhis-web-coldchain/defaultForm.vm + /dhis-web-coldchain/responseVoid.vm + + \ No newline at end of file === added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/css/equipmentDataentry.css' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/css/equipmentDataentry.css 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/css/equipmentDataentry.css 2012-05-19 14:42:20 +0000 @@ -0,0 +1,33 @@ + +#currentSelection +{ + padding: 6px; + background-color: #e0e0e0; + border: 1px solid #a0a0a0; + font-size: 14px; + text-align: right; + position: fixed; + top: 55px; + right: 10px; + filter: alpha(opacity=85); + opacity: 0.85; + border-radius: 3px; +} + +.currentRow +{ + background-color: #d5ffc5; + padding-right: 50px; +} + +#actions +{ + float: right; + width: 160px; + text-align: right; +} + +.hidden +{ + display: none; +} === added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/customForm.vm' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/customForm.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/customForm.vm 2012-05-19 14:42:20 +0000 @@ -0,0 +1,1 @@ +$customDataEntryFormCode === added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/defaultForm.vm' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/defaultForm.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/defaultForm.vm 2012-05-19 14:42:20 +0000 @@ -0,0 +1,60 @@ +#set( $tabIndex = 1 ) +##set( $hasAccess = $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) + +#foreach( $categoryCombo in $orderedCategoryCombos ) + + #set( $colCount = $numberOfTotalColumns.get( $categoryCombo.id ) ) + #set( $categories = $orderedCategories.get( $categoryCombo.id ) ) + #set( $optionsMap = $orderedOptionsMap.get( $categoryCombo.id ) ) + #set( $colRepeat = $catColRepeat.get( $categoryCombo.id ) ) + + #foreach( $category in $categories ) + #set( $categoryOptions = $optionsMap.get( $category.id ) ) + #set( $colCount = $colCount / $categoryOptions.size() ) + + + #set( $cols = $colRepeat.get( $category.id ) ) + #foreach( $col in $cols ) + #foreach( $categoryOption in $categoryOptions ) + + #end + #end + + #end + + #set( $count = 0 ) + #set( $dataElements = $orderedDataElements.get( $categoryCombo ) ) + #set( $optionCombos = $orderdCategoryOptionCombos.get( $categoryCombo.id ) ) + #set( $mark = 0 ) + #foreach( $optionCombo in $optionCombos ) + #end + #foreach( $dataElement in $dataElements ) + #if( $mark == 1 ) + #set( $mark = 0 ) + #else + #set( $mark = 1 ) + #end + #set( $count = $count + 1 ) + + + #foreach( $optionCombo in $optionCombos ) + #set( $dataEntryId = "${dataElement.id}-${optionCombo.id}-val" ) + + #set( $tabIndex = $tabIndex + 1 ) + #end + + #end +
#if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.name )}#end
${encoder.htmlEncode( $dataElement.getFormNameFallback() )} + #if( $dataElement.type == "bool" ) + + #else + + #end +
+
+
+#end === added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentDataEntry.vm' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentDataEntry.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentDataEntry.vm 2012-05-19 14:42:20 +0000 @@ -0,0 +1,105 @@ + + +

$i18n.getString( "equipment_dataentry" ) #openHelp( "equipmentDataEntry" )

+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
$inventoryTypeAttributeName
$inventoryTypeAttributeValue
+
+ + +
+
+ +#parse( "dhis-web-commons/loader/loader.vm" ) + +
+ +
+ +
+ + + + + + + === modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentInstanceList.vm' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentInstanceList.vm 2012-05-17 09:53:19 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/equipmentInstanceList.vm 2012-05-19 14:42:20 +0000 @@ -61,7 +61,7 @@ #end $i18n.getString( "edit_equipment" ) - $i18n.getString( "equipment_tracking" ) + $i18n.getString( "equipment_tracking" ) #if( $inventoryType.tracking ) $i18n.getString( "equipment_tracking" ) $i18n.getString( "equipment_tracking_history" ) === added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/images/data_entry.png' Binary files local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/images/data_entry.png 1970-01-01 00:00:00 +0000 and local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/images/data_entry.png 2012-05-19 14:42:20 +0000 differ === modified file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/equipment.js' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/equipment.js 2012-05-17 09:53:19 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/equipment.js 2012-05-19 14:42:20 +0000 @@ -442,6 +442,9 @@ function showEquipmentDataEntryForm( equipmentInstanceId ) { + + window.location.href = "showEquipmentDataEntryForm.action?equipmentInstanceId=" + equipmentInstanceId; + /* hideById('listEquipmentDiv'); hideById('selectDiv'); hideById('searchEquipmentDiv'); @@ -458,6 +461,7 @@ }); jQuery('#resultSearchDiv').dialog('close'); + */ } function updateEquipmentDataEntry() === added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/equipmentDataEntry.js' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/equipmentDataEntry.js 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/javascript/equipmentDataEntry.js 2012-05-19 14:42:20 +0000 @@ -0,0 +1,303 @@ +// Identifiers for which zero values are insignificant, also used in entry.js +var significantZeros = []; + +// Array with associative arrays for each data element, populated in select.vm +var dataElements = []; + +// Associative array with [indicator id, expression] for indicators in form, +// also used in entry.js +var indicatorFormulas = []; + +// Array with associative arrays for each data set, populated in select.vm +var dataSets = []; + +// Associative array with identifier and array of assigned data sets +var dataSetAssociationSets = []; + +// Associate array with mapping between organisation unit identifier and data +// set association set identifier +var organisationUnitAssociationSetMap = []; + +// Array with keys on form {dataelementid}-{optioncomboid}-min/max with min/max +// values +var currentMinMaxValueMap = []; + +// Indicates whether any data entry form has been loaded +var dataEntryFormIsLoaded = false; + +// Indicates whether meta data is loaded +var metaDataIsLoaded = false; + +// Currently selected organisation unit identifier +var currentOrganisationUnitId = null; + +// Currently selected data set identifier +var currentDataSetId = null; + +// Current offset, next or previous corresponding to increasing or decreasing +// value with one +var currentPeriodOffset = 0; + +// Username of user who marked the current data set as complete if any +var currentCompletedByUser = null; + +// Period type object +var periodTypeFactory = new PeriodType(); + + +var COLOR_GREEN = '#b9ffb9'; +var COLOR_YELLOW = '#fffe8c'; +var COLOR_RED = '#ff8a8a'; +var COLOR_ORANGE = '#ff6600'; +var COLOR_WHITE = '#ffffff'; +var COLOR_GREY = '#cccccc'; + +var DEFAULT_TYPE = 'int'; +var DEFAULT_NAME = '[unknown]'; + +var FORMTYPE_CUSTOM = 'custom'; +var FORMTYPE_SECTION = 'section'; +var FORMTYPE_DEFAULT = 'default'; + + + +//dataSets = dataSets + + + +function loadMetaData() +{ + var KEY_METADATA = 'metadata'; + + $.ajax( { + url: 'getMetaData.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(); + } + } ); +} + + + +// ----------------------------------------------------------------------------- +// DataSet Selection +// ----------------------------------------------------------------------------- + +//function dataSetSelected() +function getPeriods( periodType, periodId, periodId, timespan ) +{ + $( '#selectedPeriodId' ).removeAttr( 'disabled' ); + $( '#prevButton' ).removeAttr( 'disabled' ); + $( '#nextButton' ).removeAttr( 'disabled' ); + + var dataSetId = $( '#selectedDataSetId' ).val(); + + var dataSetPeriod = dataSetId.split(":"); + + var dataSetId = dataSetPeriod[0]; + var periodTypeId = dataSetPeriod[1]; + + // var periodId = $( '#selectedPeriodId' ).val(); + + $( "#periodId" ).removeAttr( "disabled" ); + + //var periodId = ""; + + //alert( periodId ); + //var periodId = $( '#periodId' ); + getAvailablePeriodsTemp( periodTypeId, periodId, periodId, timespan ); + + //var periodType = dataSets[dataSetId].periodType; + + /* + var periodType = "monthly"; + var periods = periodTypeFactory.get( periodType ).generatePeriods( currentPeriodOffset ); + periods = periodTypeFactory.filterFuturePeriods( periods ); + + if ( dataSetId && dataSetId != -1 ) + { + clearListById( 'selectedPeriodId' ); + + 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; + + if ( periodId && periodId != -1 && previousPeriodType && previousPeriodType == periodType ) + { + showLoader(); + $( '#selectedPeriodId' ).val( periodId ); + loadForm( dataSetId ); + } + else + { + clearEntryForm(); + } + + currentDataSetId = dataSetId; + } + */ +} + +function getAvailablePeriodsPre( selectedDataSetId, periodId, periodId, timespan ) +{ + var dataSetId = $( '#selectedDataSetId' ).val(); + + var dataSetPeriod = dataSetId.split(":"); + + var dataSetId = dataSetPeriod[0]; + var periodTypeId = dataSetPeriod[1]; + + getAvailablePeriodsTemp( periodTypeId, periodId, periodId, timespan ); + +} + +function getAvailablePeriodsNext( selectedDataSetId, periodId, periodId, timespan ) +{ + var dataSetId = $( '#selectedDataSetId' ).val(); + + var dataSetPeriod = dataSetId.split(":"); + + var dataSetId = dataSetPeriod[0]; + var periodTypeId = dataSetPeriod[1]; + + getAvailablePeriodsTemp( periodTypeId, periodId, periodId, timespan ); + +} + +function getAvailablePeriodsTemp( periodTypeId, availablePeriodsId, selectedPeriodsId, year ) +{ + $.getJSON( "../dhis-web-commons-ajax-json/getAvailablePeriods.action", { + "periodType": periodTypeId , + "year": year }, + function( json ) { + var availableList = document.getElementById( availablePeriodsId ); + var selectedList = document.getElementById( selectedPeriodsId ); + clearList( availableList ); + + for ( var i = 0; i < json.periods.length; i++ ) + { + if ( listContains( selectedList, json.periods[i].externalId ) == false ) + { + addValue( availableList, json.periods[i].name, json.periods[i].externalId ); + } + } + } ); +} + + +function dataEntryForm() +{ + + var tempDataSetId = $( '#selectedDataSetId' ).val(); + + var dataSetPeriod = tempDataSetId.split(":"); + + var dataSetId = dataSetPeriod[0]; + var periodTypeId = dataSetPeriod[1]; + + var periodId = $( '#periodId' ).val(); + + if ( periodId && periodId != -1 ) + { + showLoader(); + + //if ( dataEntryFormIsLoaded ) + //{ + //loadDataValues(); + //} + //else + //{ + loadForm( dataSetId ); + //} + } +} + +function loadForm( dataSetId ) +{ + //window.location.href = "loadForm.action?dataSetId=" + dataSetId; + + + $( '#contentDiv' ).load( 'loadForm.action', { + dataSetId : dataSetId + } ); + + + + + /* + if ( storageManager.formExists( dataSetId ) ) + { + log( 'Loading form locally: ' + dataSetId ); + + var html = storageManager.getForm( dataSetId ); + + $( '#contentDiv' ).html( html ); + + loadDataValues(); + } + else + { + log( 'Loading form remotely: ' + dataSetId ); + + $( '#contentDiv' ).load( 'loadForm.action', { + dataSetId : dataSetId + }, loadDataValues ); + } + */ +} + + + + + + + + + + +/* +function getAvailablePeriods( periodTypeId, availablePeriodsId, selectedPeriodsId, year ) +{ + $.getJSON( "../dhis-web-commons-ajax-json/getAvailablePeriods.action", { + "periodType": $( "#" + periodTypeId ).val(), + "year": year }, + function( json ) { + var availableList = document.getElementById( availablePeriodsId ); + var selectedList = document.getElementById( selectedPeriodsId ); + clearList( availableList ); + + for ( var i = 0; i < json.periods.length; i++ ) + { + if ( listContains( selectedList, json.periods[i].externalId ) == false ) + { + addValue( availableList, json.periods[i].name, json.periods[i].externalId ); + } + } + } ); +} +*/ === added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/responseMetaData.vm' --- local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/responseMetaData.vm 1970-01-01 00:00:00 +0000 +++ local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/responseMetaData.vm 2012-05-19 14:42:20 +0000 @@ -0,0 +1,48 @@ +{ "metaData": { + +"significantZeros": [ +#set( $size = $significantZeros.size() ) +#foreach( $dataElement in $significantZeros ) +${dataElement.id}#if( $velocityCount < $size ),#end +#end ], + +"dataElements": { +#set( $size = $dataElements.size() ) +#foreach( $dataElement in $dataElements ) +"${dataElement.id}":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )" +#if( $velocityCount < $size ),#end +#end }, + +"indicatorFormulas": { +#set( $size = $indicators.size() ) +#foreach( $indicator in $indicators ) +"${indicator.id}":"($!{indicator.explodedNumerator})/($!{indicator.explodedDenominator})*($!{indicator.indicatorType.factor})" +#if( $velocityCount < $size ),#end +#end }, + +"dataSets": { +#set( $size = $dataSets.size() ) +#foreach( $dataSet in $dataSets ) +"${dataSet.id}":{"name":"$encoder.jsonEncode( ${dataSet.displayName} )","periodType":"$encoder.jsonEncode( ${dataSet.periodType.name} )", +"version":"${dataSet.version}","type":"${dataSet.getDataSetType()}","expiryDays":"${dataSet.expiryDays}" +}#if( $velocityCount < $size ),#end +#end }, + +"dataSetAssociationSets": { +#set( $size1 = $dataSetAssociationSets.size() ) +#set( $index = 0 ) +#foreach( $associationSet in $dataSetAssociationSets ) +"${index}": [ +#set( $index = $index + 1 ) +#set( $size2 = $associationSet.size() ) +#foreach( $id in $associationSet ) +${id}#if( $velocityCount < $size2 ),#end +#end ]#if( $velocityCount < $size1 ),#end +#end }, + +"organisationUnitAssociationSetMap": { +#set( $size = $organisationUnitAssociationSetMap.size() ) +#foreach( $orgUnit in $organisationUnitAssociationSetMap.keySet() ) +"${orgUnit}":"$organisationUnitAssociationSetMap.get( ${orgUnit} )"#if( $velocityCount < $size ),#end +#end } +} } \ No newline at end of file === added file 'local/in/dhis-web-coldchain/src/main/webapp/dhis-web-coldchain/responseVoid.vm'