dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11390
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3225: Fix bug: Null pointer excepption when using custom data entry forms for Name-Based Data Records.
------------------------------------------------------------
revno: 3225
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-03-31 12:38:57 +0700
message:
Fix bug: Null pointer excepption when using custom data entry forms for Name-Based Data Records.
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CustomDataEntryAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/screen/DefaultDataEntryScreenManager.java
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CustomDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CustomDataEntryAction.java 2011-03-31 01:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/CustomDataEntryAction.java 2011-03-31 05:38:57 +0000
@@ -84,13 +84,6 @@
this.patientService = patientService;
}
- private ProgramService programService;
-
- public void setProgramService( ProgramService programService )
- {
- this.programService = programService;
- }
-
private ProgramInstanceService programInstanceService;
public void setProgramInstanceService( ProgramInstanceService programInstanceService )
@@ -163,18 +156,6 @@
return id;
}
- private Integer programId;
-
- public void setProgramId( Integer programId )
- {
- this.programId = programId;
- }
-
- public Integer getProgramId()
- {
- return programId;
- }
-
private Integer programStageId;
public Integer getProgramStageId()
@@ -328,8 +309,8 @@
patient = patientService.getPatient( id );
patientIdentifier = patientIdentifierService.getPatientIdentifier( patient );
-
- program = programService.getProgram( programId );
+
+ program = selectedStateManager.getSelectedProgram( );
programStage = programStageService.getProgramStage( programStageId );
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java 2011-03-31 01:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/DataRecordingSelectAction.java 2011-03-31 05:38:57 +0000
@@ -355,7 +355,8 @@
{
customDataEntryFormExists = true;
}
-
+System.out.println("\n\n ++++++++++ \n customDataEntryFormExists : " + customDataEntryFormExists );
+System.out.println("\n\n useDefaultForm : " + useDefaultForm );
if ( customDataEntryFormExists && useDefaultForm == null )
{
return CUSTOM_DATAENTRY_FORM;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/screen/DefaultDataEntryScreenManager.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/screen/DefaultDataEntryScreenManager.java 2011-03-31 01:49:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/screen/DefaultDataEntryScreenManager.java 2011-03-31 05:38:57 +0000
@@ -316,7 +316,13 @@
else
{
dataElement = dataElementMap.get( dataElementId );
+ if ( dataElement == null )
+ {
+ return i18n.getString( "program_stage_lack_data_elements" );
+ }
+
ProgramStageDataElement psde = programStageDataElementService.get( programStage, dataElement );
+
compulsory = BooleanUtils.toStringTrueFalse( psde.isCompulsory() );
}
@@ -386,6 +392,7 @@
}
}
+
// -------------------------------------------------------------
// Insert value of data element in output code
// -------------------------------------------------------------
@@ -446,6 +453,7 @@
// -----------------------------------------------------------
//
// -----------------------------------------------------------
+
String orgUnitName = i18n.getString( NOTAVAILABLE );
if ( patientDataValue != null )
{
@@ -491,8 +499,7 @@
// ---------------------------------------------------------------------
final String jsCodeForBoolean = " name=\"entryselect\" data=\"{compulsory:$COMPULSORY, dataElementId:$DATAELEMENTID, dataElementName:'$DATAELEMENTNAME', dataElementType:'$DATAELEMENTTYPE', programStageId:$PROGRAMSTAGEID, programStageName: '$PROGRAMSTAGENAME', orgUnitName:'$ORGUNITNAME'}\" $DISABLED onchange=\"saveChoiceCustom( $PROGRAMSTAGEID, $DATAELEMENTID,this)\"";
- // final String historyCode =
- // " ondblclick='javascript:viewHistory( $DATAELEMENTID, $OPTIONCOMBOID, true )' ";
+
final String calDataElementCode = " class=\"calculated\" disabled ";
// ---------------------------------------------------------------------
@@ -527,6 +534,7 @@
// -----------------------------------------------------------------
// Get HTML input field code
// -----------------------------------------------------------------
+
String compulsory = "null";
String dataElementCode = dataElementMatcher.group( 1 );
Matcher identifierMatcher = identifierPattern.matcher( dataElementCode );
@@ -537,7 +545,7 @@
// -------------------------------------------------------------
int programStageId = Integer.parseInt( identifierMatcher.group( 1 ) );
- // logger.info( "programStageId: " + programStageId );
+
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
DataElement dataElement = null;
@@ -554,7 +562,13 @@
else
{
dataElement = dataElementMap.get( dataElementId );
+ if ( dataElement == null )
+ {
+ return i18n.getString( "program_stage_lack_data_elements" );
+ }
+
ProgramStageDataElement psde = programStageDataElementService.get( programStage, dataElement );
+
compulsory = BooleanUtils.toStringTrueFalse( psde.isCompulsory() );
}
@@ -595,7 +609,7 @@
}
patientDataValue = getValue( patientDataValues, dataElementId );
- // logger.info( "patientDataValue: " + patientDataValue );
+
dataElementValue = patientDataValue != null ? patientDataValue.getValue() : dataElementValue;
}
else
@@ -627,9 +641,11 @@
String appendCode = dataElementCode;
appendCode = appendCode.replace( "name=\"entryselect\"", jsCodeForBoolean );
+
// -------------------------------------------------------------
// Insert value of data element in output code
// -------------------------------------------------------------
+
if ( patientDataValue != null )
{
@@ -648,6 +664,7 @@
}
appendCode += "</select>";
+
// -------------------------------------------------------------
// Remove placeholder view attribute from input field
// -------------------------------------------------------------
@@ -689,8 +706,6 @@
// If programStagsInstance is completed then disabled it
// -----------------------------------------------------------
- // System.out.println("programStageInstance.isCompleted() : "+programStageInstance.isCompleted()
- // +"id: "+programStageInstance.getId());
disabled = "";
if ( programStageId != programStage.getId() || programStageInstance.isCompleted() )
{
@@ -707,6 +722,7 @@
// -----------------------------------------------------------
//
// -----------------------------------------------------------
+
String orgUnitName = i18n.getString( NOTAVAILABLE );
if ( patientDataValue != null )
{
@@ -756,8 +772,7 @@
// ---------------------------------------------------------------------
final String jsCodeForCombo = " name=\"entryselect\" $DISABLED data=\"{compulsory:$COMPULSORY, dataElementId:$DATAELEMENTID, dataElementName:'$DATAELEMENTNAME', dataElementType:'$DATAELEMENTTYPE', programStageId:$PROGRAMSTAGEID, programStageName: '$PROGRAMSTAGENAME', orgUnitName:'$ORGUNITNAME'}\" onchange=\"saveChoiceCustom( $PROGRAMSTAGEID, $DATAELEMENTID,this)\"";
- // final String historyCode =
- // " ondblclick='javascript:viewHistory( $DATAELEMENTID, $OPTIONCOMBOID, true )' ";
+
final String calDataElementCode = " class=\"calculated\" disabled ";
// ---------------------------------------------------------------------
@@ -795,9 +810,7 @@
// -----------------------------------------------------------------
String dataElementCode = dataElementMatcher.group( 1 );
-
- // System.out.println("boolean dataElementCode : "+dataElementCode);
-
+
Matcher identifierMatcher = identifierPattern.matcher( dataElementCode );
String compulsory = "null";
@@ -825,7 +838,13 @@
else
{
dataElement = dataElementMap.get( dataElementId );
+ if ( dataElement == null )
+ {
+ return i18n.getString( "program_stage_lack_data_elements" );
+ }
+
ProgramStageDataElement psde = programStageDataElementService.get( programStage, dataElement );
+
compulsory = BooleanUtils.toStringTrueFalse( psde.isCompulsory() );
}
@@ -837,6 +856,7 @@
{
continue;
}
+
// -------------------------------------------------------------
// Find type of data element
// -------------------------------------------------------------
@@ -846,6 +866,7 @@
// -------------------------------------------------------------
// Find existing value of data element in data set
// -------------------------------------------------------------
+
PatientDataValue patientDataValue = null;
String dataElementValue = EMPTY;
if ( programStageId != programStage.getId() )
@@ -862,7 +883,7 @@
}
patientDataValue = getValue( patientDataValues, dataElementId );
- // logger.info( "patientDataValue: " + patientDataValue );
+
dataElementValue = patientDataValue != null ? patientDataValue.getValue() : dataElementValue;
}
else
@@ -893,21 +914,20 @@
String appendCode = dataElementCode;
appendCode = appendCode.replace( "name=\"entryselect\"", jsCodeForCombo );
+
// -------------------------------------------------------------
// Insert value of data element in output code
// -------------------------------------------------------------
+
if ( patientDataValue != null )
{
- // System.out.println("optioncomboId: "+patientDataValue.getOptionCombo().getId()
- // + " ===name: "+
- // patientDataValue.getOptionCombo().getName());
- appendCode = appendCode.replace( "id=\"combo[" + patientDataValue.getOptionCombo().getId()
+ appendCode = appendCode.replace( "id=\"combo[" + patientDataValue.getOptionCombo().getId()
+ "].combo\"", "id=\"combo[" + patientDataValue.getOptionCombo().getId()
+ "].combo\" selected=\"selected\"" );
- // System.out.println("appendCode: "+appendCode);
}
appendCode += "</select>";
+
// -------------------------------------------------------------
// Remove placeholder view attribute from input field
// -------------------------------------------------------------
@@ -948,6 +968,7 @@
// disable
// If programStagsInstance is completed then disabled it
// -----------------------------------------------------------
+
disabled = "";
if ( programStageId != programStage.getId() || programStageInstance.isCompleted() )
{
@@ -958,12 +979,14 @@
// -----------------------------------------------------------
// Add ProvidedByOtherFacility checkbox
// -----------------------------------------------------------
+
appendCode = addProvidedByOtherFacilityCheckbox( appendCode, patientDataValue );
}
// -----------------------------------------------------------
//
// -----------------------------------------------------------
+
String orgUnitName = i18n.getString( NOTAVAILABLE );
if ( patientDataValue != null )
{
@@ -1009,10 +1032,7 @@
// ---------------------------------------------------------------------
final String jsCodeForDate = " name=\"entryfield\" $DISABLED onchange=\"saveDateCustom( this )\" data=\"{compulsory:$COMPULSORY, dataElementId:$DATAELEMENTID, dataElementName:'$DATAELEMENTNAME', dataElementType:'$DATAELEMENTTYPE', programStageId:$PROGRAMSTAGEID, programStageName: '$PROGRAMSTAGENAME', orgUnitName:'$ORGUNITNAME'}\"";
- // final String historyCode =
- // " ondblclick='javascript:viewHistory( $DATAELEMENTID, $OPTIONCOMBOID, true )' ";
- // final String calDataElementCode = " class=\"calculated\" disabled ";
-
+
// ---------------------------------------------------------------------
// Metadata code to add to HTML before outputting
// ---------------------------------------------------------------------
@@ -1050,10 +1070,10 @@
// -----------------------------------------------------------------
// Get HTML input field code
// -----------------------------------------------------------------
+
String compulsory = "null";
String dataElementCode = dataElementMatcher.group( 1 );
- // System.out.println("DATE+++++++=====================================================");
- // System.out.println(dataElementCode);
+
Matcher identifierMatcher = identifierPattern.matcher( dataElementCode );
if ( identifierMatcher.find() && identifierMatcher.groupCount() > 0 )
@@ -1061,6 +1081,7 @@
// -------------------------------------------------------------
// Get data element ID of data element
// -------------------------------------------------------------
+
int programStageId = Integer.parseInt( identifierMatcher.group( 1 ) );
int dataElementId = Integer.parseInt( identifierMatcher.group( 2 ) );
@@ -1078,7 +1099,13 @@
else
{
dataElement = dataElementMap.get( dataElementId );
+ if ( dataElement == null )
+ {
+ return i18n.getString( "program_stage_lack_data_elements" );
+ }
+
ProgramStageDataElement psde = programStageDataElementService.get( programStage, dataElement );
+
compulsory = BooleanUtils.toStringTrueFalse( psde.isCompulsory() );
}
@@ -1117,7 +1144,7 @@
}
patientDataValue = getValue( patientDataValues, dataElementId );
- // logger.info( "patientDataValue: " + patientDataValue );
+
dataElementValue = patientDataValue != null ? patientDataValue.getValue() : dataElementValue;
}
else
@@ -1166,6 +1193,7 @@
// -------------------------------------------------------------
dataElementCode = dataElementCode.replaceAll( "view=\".*?\"", "" );
+
// -------------------------------------------------------------
// Append Javascript code and meta data (type/min/max) for
// persisting to output code, and insert value and type for
@@ -1174,8 +1202,7 @@
String appendCode = dataElementCode + "/>";
appendCode = appendCode.replace( "name=\"entryfield\"", jsCodeForDate );
- // appendCode += "</script>";
-
+
appendCode += metaDataCode;
// -----------------------------------------------------------
@@ -1183,6 +1210,7 @@
// disable
// If programStagsInstance is completed then disabled it
// -----------------------------------------------------------
+
disabled = "";
if ( programStageId != programStage.getId() || programStageInstance.isCompleted() )
{
@@ -1202,6 +1230,7 @@
// -----------------------------------------------------------
// Get Org Unit name
// -----------------------------------------------------------
+
String orgUnitName = i18n.getString( NOTAVAILABLE );
if ( patientDataValue != null )
{
@@ -1319,8 +1348,6 @@
private String addProvidedByOtherFacilityCheckbox( String appendCode, PatientDataValue patientDataValue )
{
appendCode += "<label for=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\" title=\"is provided by another Facility ?\" ></label><input name=\"providedByAnotherFacility\" title=\"is provided by another Facility ?\" id=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\" type=\"checkbox\" ";
- // appendCoe
- // +="<input name=\"providedByAnotherFacility\" title=\"is provided by another Facility ?\" id=\"$PROGRAMSTAGEID_$DATAELEMENTID_facility\" type=\"checkbox\" ";
if ( patientDataValue != null && patientDataValue.isProvidedByAnotherFacility() )
{
@@ -1340,8 +1367,6 @@
// Pattern to match i18n strings in the HTML code
// ---------------------------------------------------------------------
- // Pattern i18nPattern = Pattern.compile( "(<i18n::.*?)[/]?>",
- // Pattern.DOTALL );
Pattern i18nPattern = Pattern.compile( "(<i18n.*?)[/]?</i18n>", Pattern.DOTALL );
Matcher i18nMatcher = i18nPattern.matcher( dataEntryFormCode );
@@ -1405,7 +1430,6 @@
dataElement );
result.add( programStageDataElement );
-
}
return result;
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2011-03-24 03:34:53 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2011-03-31 05:38:57 +0000
@@ -178,7 +178,6 @@
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
- <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-03-29 03:06:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties 2011-03-31 05:38:57 +0000
@@ -293,4 +293,4 @@
common_info = Common information
dob_type = DOB Type
blood_group = Blood group
-
+program_stage_lack_data_elements = The program stage lack data elements
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2011-03-24 17:27:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm 2011-03-31 05:38:57 +0000
@@ -19,29 +19,18 @@
<div id="dragDiv">
<table id="listInfo">
- <tr>
- <td style="text-align:left">
- <strong>$i18n.getString("org_unit_name") :</strong></td> <td id="orgUnitName" style="text-align:right">
- </td>
- </tr>
- <tr>
- <td style="text-align:left">
- <strong>$i18n.getString("program_stage_name") :</strong></td> <td id="programStageName" style="text-align:right">
- </td>
- </tr>
- <tr>
- <td style="text-align:left">
- <strong>$i18n.getString("datae_element_name") :</strong></td> <td id="dataelementName" style="text-align:right">
- </td>
- </tr>
+ <tr><td style="text-align:left"><strong>$i18n.getString("org_unit_name") :</strong></td> <td id="orgUnitName" style="text-align:right"></td></tr>
+ <tr><td style="text-align:left"><strong>$i18n.getString("program_stage_name") :</strong></td> <td id="programStageName" style="text-align:right"></td></tr>
+ <tr><td style="text-align:left"><strong>$i18n.getString("datae_element_name") :</strong></td> <td id="dataelementName" style="text-align:right"></td></tr>
</table>
</div>
-<span id="startMsg" style="font-style:italic; color:blue"> $i18n.getString( "report_date_warning" )</span>
+<span id="startMsg" style="font-style:italic; color:blue"> $i18n.getString( "report_date_warning" )
+</span>
<div id="entryFormContainer" >
-#if ( $customDataEntryFormExists && !$useDefaultForm )
+#if ( $!customDataEntryFormCode && !$useDefaultForm )
<div id="customEntryScreenContainer">
#if( $customDataEntryFormCode )
$customDataEntryFormCode
@@ -49,11 +38,10 @@
#end
</span>
</div>
-<script type="text/javascript">
+<script>
initCustomCheckboxes();
DRAG_DIV.init();
</script>
-
#else
<table class="mainPageTable">
@@ -139,7 +127,6 @@
#end
</div>
-
<div id="completeDataEntryFormContainer">
<form id="completeDataEntryForm" name="completeDataEntry" method="post" action="completeDataEntry.action">
<input type="hidden" name="id" value="$id"/>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm 2011-03-23 03:34:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewDataEntryForm.vm 2011-03-31 05:38:57 +0000
@@ -44,7 +44,7 @@
<form id="saveDataEntryForm" name="saveDataEntryForm" action="saveDataEntryForm.action" method="post" onsubmit=' validateDataEntryForm(); return false;'>
<input type="hidden" name="programStageId" id="programStageId" value="$!programStage.id"/>
-<input type="hidden" name="dataEntryFormId" id="dataEntryFormId"/>
+<input type="hidden" name="dataEntryFormId" id="dataEntryFormId" value="$!programStage.dataEntryForm.id"/>
<h3>$i18n.getString( "dataentryform_management_for_program_stage" ): $programStage.name </h3>
<div class="container" >
<table id="detailsList" width="100%">