dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13637
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4424: Error when loading an existed entry form into design case-entry form ( Patient module ).
------------------------------------------------------------
revno: 4424
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-08-24 15:57:39 +0700
message:
Error when loading an existed entry form into design case-entry form ( Patient module ).
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ShowDataEntryFormAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2011-07-25 02:08:33 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2011-08-24 08:57:39 +0000
@@ -57,7 +57,7 @@
private static final String NOTAVAILABLE = "not_available";
- private static final String DATA_ELEMENT_DOES_NOT_EXIST = "[ Data element doesn't exist ]";
+ private static final String DATA_ELEMENT_DOES_NOT_EXIST = "[ Data element does not exist ]";
private static final String EMPTY_VALUE_TAG = "value=\"\"";
@@ -195,18 +195,23 @@
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
+ if ( dataElement != null && !dataElement.getDetailedNumberType().equals( DataElement.VALUE_TYPE_STRING ) )
+ {
+ continue;
+ }
+
int optionComboId = Integer.parseInt( identifierMatcher.group( 3 ) );
DataElementCategoryOptionCombo optionCombo = categoryService
.getDataElementCategoryOptionCombo( optionComboId );
- String displayValue = (dataElement == null || optionCombo == null) ? "value=\""
- + DATA_ELEMENT_DOES_NOT_EXIST + "\"" : "value=\"[ " + dataElement.getName() + " "
+ String displayValue = (dataElement == null || optionCombo == null) ? " value=\""
+ + DATA_ELEMENT_DOES_NOT_EXIST + "\" " : " value=\"[ " + dataElement.getName() + " "
+ optionCombo.getName() + " ]\"";
inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
: inputHTML + " " + displayValue;
- String displayTitle = (dataElement == null || optionCombo == null) ? "title=\""
- + DATA_ELEMENT_DOES_NOT_EXIST + "\"" : "title=\"" + dataElement.getId() + "."
+ String displayTitle = (dataElement == null || optionCombo == null) ? " title=\""
+ + DATA_ELEMENT_DOES_NOT_EXIST + "\" " : " title=\"" + dataElement.getId() + "."
+ dataElement.getName() + "-" + optionComboId + "." + optionCombo.getName() + "-"
+ dataElement.getDetailedNumberType() + "\" ";
inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
@@ -230,7 +235,7 @@
// ---------------------------------------------------------------------
StringBuffer sb = new StringBuffer();
-
+
// ---------------------------------------------------------------------
// Pattern to match data elements in the HTML code
// ---------------------------------------------------------------------
@@ -263,13 +268,18 @@
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
- String displayValue = (dataElement == null) ? "value=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
- : "value=\"[ " + dataElement.getName() + " ]\"";
+ if ( dataElement != null && !dataElement.getDetailedNumberType().equals( DataElement.VALUE_TYPE_STRING ) )
+ {
+ continue;
+ }
+
+ String displayValue = (dataElement == null) ? " value=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\" "
+ : " value=\"[ " + dataElement.getName() + " ]\" ";
inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
: inputHTML + " " + displayValue;
- String displayTitle = (dataElement == null) ? "title=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
- : "title=\"" + dataElement.getId() + "." + dataElement.getName() + "-"
+ String displayTitle = (dataElement == null) ? " title=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\" "
+ : " title=\"" + dataElement.getId() + "." + dataElement.getName() + "-"
+ dataElement.getDetailedNumberType() + "\" ";
inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
: inputHTML + " " + displayTitle;
@@ -326,13 +336,18 @@
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
DataElement dataElement = dataElementService.getDataElement( dataElementId );
- String displayValue = (dataElement == null) ? "value=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
- : "value=\"[ " + dataElement.getName() + " ]\"";
+ if ( dataElement != null && !dataElement.getDetailedNumberType().equals( DataElement.VALUE_TYPE_DATE ) )
+ {
+ continue;
+ }
+
+ String displayValue = (dataElement == null) ? " value=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
+ : " value=\"[ " + dataElement.getName() + " ]\"";
inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? inputHTML.replace( EMPTY_VALUE_TAG, displayValue )
: inputHTML + " " + displayValue;
- String displayTitle = (dataElement == null) ? "title=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
- : "title=\"" + dataElement.getId() + "." + dataElement.getName() + "-"
+ String displayTitle = (dataElement == null) ? " title=\"" + DATA_ELEMENT_DOES_NOT_EXIST + "\""
+ : " title=\"" + dataElement.getId() + "." + dataElement.getName() + "-"
+ dataElement.getDetailedNumberType() + "\" ";
inputHTML = inputHTML.contains( EMPTY_TITLE_TAG ) ? inputHTML.replace( EMPTY_TITLE_TAG, displayTitle )
: inputHTML + " " + displayTitle;
@@ -482,25 +497,26 @@
{
dataElementCode += "value=\"" + dataElementValue + "\"";
}
-
+
// -------------------------------------------------------------
// Insert title information - Data element id, name, type, min,
// max
// -------------------------------------------------------------
- DataElementCategoryOptionCombo optionCombo = categoryService.getDataElementCategoryOptionCombo( optionComboId );
-
+ DataElementCategoryOptionCombo optionCombo = categoryService
+ .getDataElementCategoryOptionCombo( optionComboId );
+
if ( dataElementCode.contains( "title=\"\"" ) )
{
- dataElementCode = dataElementCode.replace( "title=\"\"", "title=\"" + dataElement.getId()
- + "." + dataElement.getName() +"-"
- + optionComboId + optionCombo.getName() + "-" + dataElementType + "\" " );
+ dataElementCode = dataElementCode.replace( "title=\"\"", "title=\"" + dataElement.getId() + "."
+ + dataElement.getName() + "-" + optionComboId + optionCombo.getName() + "-" + dataElementType
+ + "\" " );
}
else
{
- dataElementCode += "title=\"" + dataElement.getId() + "." + dataElement.getName()
- +"-" + optionComboId + optionCombo.getName() + "-" + dataElementType + "\" ";
+ dataElementCode += "title=\"" + dataElement.getId() + "." + dataElement.getName() + "-"
+ + optionComboId + optionCombo.getName() + "-" + dataElementType + "\" ";
}
-
+
// -------------------------------------------------------------
// Append Javascript code and meta data (type/min/max) for
// persisting to output code, and insert value and type for
@@ -512,7 +528,7 @@
appendCode += jsCodeForInputs;
appendCode += " />";
-
+
// -----------------------------------------------------------
// Check if this dataElement is from another programStage then
// disable
@@ -693,27 +709,27 @@
String appendCode = dataElementCode.replaceFirst( "input", "select" );
appendCode = appendCode.replace( "name=\"entryselect\"", jsCodeForBoolean );
-
+
// -------------------------------------------------------------
// Add title
// -------------------------------------------------------------
if ( dataElementCode.contains( "title=\"\"" ) )
{
- appendCode = appendCode.replace( "title=\"\"", "title=\"" + dataElement.getId()
- + "." + dataElement.getName() + "-" + dataElementType + "\" " );
+ appendCode = appendCode.replace( "title=\"\"", "title=\"" + dataElement.getId() + "."
+ + dataElement.getName() + "-" + dataElementType + "\" " );
}
else
{
- appendCode += "title=\"" + dataElement.getId() + "." + dataElement.getName()
- + "-" + dataElementType + "\" ";
+ appendCode += "title=\"" + dataElement.getId() + "." + dataElement.getName() + "-"
+ + dataElementType + "\" ";
}
-
+
appendCode += ">";
appendCode += "<option value=\"\">" + i18n.getString( "no_value" ) + "</option>";
appendCode += "<option value=\"true\">" + i18n.getString( "yes" ) + "</option>";
appendCode += "<option value=\"false\">" + i18n.getString( "no" ) + "</option>";
-
+
// -------------------------------------------------------------
// Insert value of data element in output code
// -------------------------------------------------------------
@@ -732,7 +748,7 @@
+ i18n.getString( "false" ) + "\" selected>" );
}
}
-
+
appendCode += "</select>";
// -----------------------------------------------------------
@@ -751,7 +767,7 @@
// -----------------------------------------------------------
// Add ProvidedByOtherFacility checkbox
// -----------------------------------------------------------
-
+
appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue );
}
@@ -796,10 +812,9 @@
return sb.toString();
}
- private String populateCustomDataEntryForCombo( String dataEntryFormCode,
- Collection<PatientDataValue> dataValues, String disabled, I18n i18n, ProgramStage programStage,
- ProgramStageInstance programStageInstance, OrganisationUnit organisationUnit,
- Map<Integer, Collection<PatientDataValue>> mapDataValue )
+ private String populateCustomDataEntryForCombo( String dataEntryFormCode, Collection<PatientDataValue> dataValues,
+ String disabled, I18n i18n, ProgramStage programStage, ProgramStageInstance programStageInstance,
+ OrganisationUnit organisationUnit, Map<Integer, Collection<PatientDataValue>> mapDataValue )
{
// ---------------------------------------------------------------------
@@ -839,7 +854,7 @@
// -------------------------------------------------------------
// Get data element ID of data element
// -------------------------------------------------------------
-
+
int programStageId = Integer.parseInt( identifierMatcher.group( 1 ) );
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
@@ -912,28 +927,31 @@
dataElementValue = patientDataValue != null ? patientDataValue.getValue() : dataElementValue;
}
- String appendCode = dataElementCode.replaceFirst( "input", "select" );;
+ String appendCode = dataElementCode.replaceFirst( "input", "select" );
+ ;
appendCode = appendCode.replace( "name=\"entryselect\"", jsCodeForCombo );
appendCode += ">";
appendCode += "<option value=\"\">" + i18n.getString( "no_value" ) + "</option>";
- for( DataElementCategoryOptionCombo optionCombo : dataElement.getCategoryCombo().getOptionCombos() )
+ for ( DataElementCategoryOptionCombo optionCombo : dataElement.getCategoryCombo().getOptionCombos() )
{
- appendCode += "<option value=\"" + optionCombo.getId() + "\">" + optionCombo.getName() + "</option>";
+ appendCode += "<option value=\"" + optionCombo.getId() + "\">" + optionCombo.getName()
+ + "</option>";
}
-
+
// -------------------------------------------------------------
// Insert value of data element in output code
// -------------------------------------------------------------
if ( patientDataValue != null )
{
- appendCode = appendCode.replace( "<option value=\"" + patientDataValue.getOptionCombo().getId() + "\">",
- "<option value=\"" + patientDataValue.getOptionCombo().getId() + "\" selected=\"selected\">" );
+ appendCode = appendCode.replace( "<option value=\"" + patientDataValue.getOptionCombo().getId()
+ + "\">", "<option value=\"" + patientDataValue.getOptionCombo().getId()
+ + "\" selected=\"selected\">" );
}
appendCode += "</select>";
-
+
// -------------------------------------------------------------
// Insert title information - Data element id, name, type, min,
// max
@@ -941,13 +959,13 @@
if ( dataElementCode.contains( "title=\"\"" ) )
{
- dataElementCode = dataElementCode.replace( "title=\"\"", "title=\"" + dataElement.getId()
- + "." + dataElement.getName() + " (" + dataElementType + ")\" " );
+ dataElementCode = dataElementCode.replace( "title=\"\"", "title=\"" + dataElement.getId() + "."
+ + dataElement.getName() + " (" + dataElementType + ")\" " );
}
else
{
- dataElementCode += "title=\"" + dataElement.getId() + "." + dataElement.getName()
- + " (" + dataElementType + ")\" ";
+ dataElementCode += "title=\"" + dataElement.getId() + "." + dataElement.getName() + " ("
+ + dataElementType + ")\" ";
}
// -----------------------------------------------------------
@@ -1022,8 +1040,7 @@
// Metadata code to add to HTML before outputting
// ---------------------------------------------------------------------
- final String jQueryCalendar = "<script> "
- + "datePicker(\"$PROGRAMSTAGEID-$DATAELEMENTID-val\", false)"
+ final String jQueryCalendar = "<script> " + "datePicker(\"$PROGRAMSTAGEID-$DATAELEMENTID-val\", false)"
+ ";</script>";
StringBuffer sb = new StringBuffer();
@@ -1155,15 +1172,15 @@
if ( dataElementCode.contains( "title=\"\"" ) )
{
- dataElementCode = dataElementCode.replace( "title=\"\"", "title=\"" + dataElement.getId()
- + "." + dataElement.getName() + " (" + dataElementType + ")\" " );
+ dataElementCode = dataElementCode.replace( "title=\"\"", "title=\"" + dataElement.getId() + "."
+ + dataElement.getName() + " (" + dataElementType + ")\" " );
}
else
{
- dataElementCode += "title=\"" + dataElement.getId() + "." + dataElement.getName()
- + " (" + dataElementType + ")\" ";
+ dataElementCode += "title=\"" + dataElement.getId() + "." + dataElement.getName() + " ("
+ + dataElementType + ")\" ";
}
-
+
// -------------------------------------------------------------
// Append Javascript code and meta data (type/min/max) for
// persisting to output code, and insert value and type for
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ShowDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ShowDataEntryFormAction.java 2011-05-08 14:16:09 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/ShowDataEntryFormAction.java 2011-08-24 08:57:39 +0000
@@ -29,6 +29,7 @@
import org.hisp.dhis.dataentryform.DataEntryForm;
import org.hisp.dhis.dataentryform.DataEntryFormService;
+import org.hisp.dhis.program.ProgramDataEntryService;
import com.opensymphony.xwork2.Action;
@@ -51,6 +52,13 @@
this.dataEntryFormService = dataEntryFormService;
}
+ private ProgramDataEntryService programDataEntryService;
+
+ public void setProgramDataEntryService( ProgramDataEntryService programDataEntryService )
+ {
+ this.programDataEntryService = programDataEntryService;
+ }
+
// -------------------------------------------------------------------------
// Getters & Setters
// -------------------------------------------------------------------------
@@ -82,7 +90,7 @@
if ( dataEntryForm != null )
{
- dataEntryFormCode = dataEntryFormService.prepareDataEntryFormForEdit( dataEntryForm.getHtmlCode() );
+ dataEntryFormCode = programDataEntryService.prepareDataEntryFormForEdit( dataEntryForm.getHtmlCode() );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-08-02 09:12:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/META-INF/dhis/beans.xml 2011-08-24 08:57:39 +0000
@@ -754,6 +754,9 @@
<property name="dataEntryFormService">
<ref bean="org.hisp.dhis.dataentryform.DataEntryFormService" />
</property>
+ <property name="programDataEntryService">
+ <ref bean="org.hisp.dhis.program.ProgramDataEntryService" />
+ </property>
</bean>
<bean
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js 2011-07-21 07:54:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/programValidation.js 2011-08-24 08:57:39 +0000
@@ -45,6 +45,9 @@
function insertDataElement( element, target, decriptionDiv )
{
+ if( element.selectedIndex == -1)
+ return;
+
var value = " " + element.options[element.selectedIndex].value + " ";
insertTextCommon( target, value );