dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #25377
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12578: Allow to display radio buttons for option-sets in custom entry form.
------------------------------------------------------------
revno: 12578
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-10-11 15:49:29 +0700
message:
Allow to display radio buttons for option-sets in custom entry form.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
--
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 2013-10-10 09:04:12 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java 2013-10-11 08:49:29 +0000
@@ -101,9 +101,8 @@
// -------------------------------------------------------------------------
@Override
- public String prepareDataEntryFormForEntry( String htmlCode, Collection<PatientDataValue> dataValues,
- I18n i18n, ProgramStage programStage, ProgramStageInstance programStageInstance,
- OrganisationUnit organisationUnit )
+ public String prepareDataEntryFormForEntry( String htmlCode, Collection<PatientDataValue> dataValues, I18n i18n,
+ ProgramStage programStage, ProgramStageInstance programStageInstance, OrganisationUnit organisationUnit )
{
Map<String, Collection<PatientDataValue>> mapDataValue = new HashMap<String, Collection<PatientDataValue>>();
@@ -246,7 +245,13 @@
tabindex++;
- if ( DataElement.VALUE_TYPE_INT.equals( dataElement.getType() )
+ if ( dataElement.getOptionSet() != null && dataElement.getOptionSet().getOptions().size() < 7
+ && programStage.getProgram().getDataEntryMethod() )
+ {
+ String idField = programStageUid + "-" + dataElementUid + "-val";
+ inputHTML = populateCustomDataEntryForOptionSet( dataElement, idField, patientDataValue, i18n );
+ }
+ else if ( DataElement.VALUE_TYPE_INT.equals( dataElement.getType() )
|| DataElement.VALUE_TYPE_STRING.equals( dataElement.getType() )
|| DataElement.VALUE_TYPE_USER_NAME.equals( dataElement.getType() ) )
{
@@ -298,7 +303,7 @@
inputHTML = inputHTML.replace( "$VALUE", dataElementValue );
inputHTML = inputHTML.replace( "$PROGRAMSTAGEID", String.valueOf( programStageUid ) );
inputHTML = inputHTML.replace( "$PROGRAMSTAGENAME", programStageName );
- inputHTML = inputHTML.replace( "$DATAELEMENTNAME", dataElement.getName() );
+ inputHTML = inputHTML.replace( "$DATAELEMENTNAME", dataElement.getFormNameFallback() );
inputHTML = inputHTML.replace( "$DATAELEMENTTYPE", dataElementType );
inputHTML = inputHTML.replace( "$DISABLED", disabled );
inputHTML = inputHTML.replace( "$COMPULSORY", compulsory );
@@ -561,7 +566,65 @@
// -------------------------------------------------------------------------
// Supportive methods
// -------------------------------------------------------------------------
-
+
+ private String populateCustomDataEntryForOptionSet( DataElement dataElement, String id,
+ PatientDataValue patientDataValue, I18n i18n )
+ {
+ String inputHTML = "";
+ if ( dataElement != null )
+ {
+ String metaData = "<input id=\'" + id + "\' name=\'" + id + "\' options=\'no\' type=\'radio\' optionset='"
+ + dataElement.getOptionSet().getUid() + "'";
+ metaData += " data=\"{compulsory:$COMPULSORY, deName:\'$DATAELEMENTNAME\', deType:\'"
+ + dataElement.getDetailedNumberType() + "\' }\" ";
+
+ inputHTML = "<table style=\'width:100%\'>";
+ inputHTML += "<tr>";
+ inputHTML += "<td>";
+ inputHTML += metaData;
+
+ if ( patientDataValue == null )
+ {
+ inputHTML += " checked ";
+ }
+
+ inputHTML += "onclick=\"saveRadio( \'" + dataElement.getUid() + "\', \'$option\' )\" />"
+ + i18n.getString( "non_value" );
+ inputHTML += " </td>";
+
+ int index = 1;
+
+ for ( String optionValue : dataElement.getOptionSet().getOptions() )
+ {
+ if ( index == 4 )
+ {
+ inputHTML += "</tr><tr>";
+ index = 0;
+ }
+
+ inputHTML += "<td>" + metaData;
+ if ( patientDataValue != null && patientDataValue.getValue().equals( optionValue ) )
+ {
+ inputHTML += " checked ";
+ }
+ inputHTML += " onclick=\"saveRadio( \'" + dataElement.getUid() + "\', \'" + optionValue + "\' )\" />"
+ + optionValue;
+ inputHTML += "</td>";
+ index++;
+ }
+ inputHTML += " </tr>";
+ inputHTML += " </table>";
+
+ }
+ else
+ {
+ inputHTML = inputHTML.contains( EMPTY_VALUE_TAG ) ? " value=\"[" + DATA_ELEMENT_DOES_NOT_EXIST + "]\" "
+ : " value=\"[ " + DATA_ELEMENT_DOES_NOT_EXIST + " ]\"";
+ }
+
+ return inputHTML;
+ }
+
private String populateCustomDataEntryForTextBox( DataElement dataElement, String inputHTML )
{
if ( dataElement != null )
@@ -674,7 +737,8 @@
}
else
{
- inputHTML += " class=\"optionset\" optionset=\"" + dataElement.getOptionSet().getUid() + "\" data-optionset=\"" + dataElement.getOptionSet().getUid() + "\" ";
+ inputHTML += " class=\"optionset\" optionset=\"" + dataElement.getOptionSet().getUid()
+ + "\" data-optionset=\"" + dataElement.getOptionSet().getUid() + "\" ";
}
if ( DataElement.VALUE_TYPE_LONG_TEXT.equals( dataElement.getDetailedTextType() ) )