← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14325: [mobile]option for data completeness in sms reporting

 

------------------------------------------------------------
revno: 14325
committer: Long <long.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2014-03-21 11:09:08 +0700
message:
  [mobile]option for data completeness in sms reporting
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.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-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/smscommand/SMSCommand.java	2014-03-21 04:09:08 +0000
@@ -36,12 +36,22 @@
 
 public class SMSCommand
 {
+    //Default message
+    
     public static final String WRONG_FORMAT_MESSAGE = "Wrong format for command";
     
     public static final String MORE_THAN_ONE_ORGUNIT_MESSAGE = "Found more than one org unit for this number. Please specify one organisation unit";
     
     public static final String NO_USER_MESSAGE = "No user associated with this phone number. Please contact your supervisor.";
     
+    //Completeness method code
+    
+    public static final int RECEIVE_ALL_DATAVALUE = 1;
+    
+    public static final int RECEIVE_AT_LEAST_ONE_DATAVALUE = 2;
+    
+    public static final int DO_NOT_MARK_COMPLETE = 3;
+    
     private int id;
 
     private String name;
@@ -64,6 +74,8 @@
 
     private boolean currentPeriodUsedForReporting = false; // default is prev
     
+    private Integer completenessMethod;
+    
     //Messages
     
     private String defaultMessage;
@@ -339,4 +351,16 @@
     {
         this.moreThanOneOrgUnitMessage = moreThanOneOrgUnitMessage;
     }
+
+    public Integer getCompletenessMethod()
+    {
+        return completenessMethod;
+    }
+
+    public void setCompletenessMethod( Integer completenessMethod )
+    {
+        this.completenessMethod = completenessMethod;
+    }
+    
+    
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/DataValueSMSListener.java	2014-03-21 04:09:08 +0000
@@ -73,6 +73,7 @@
 public class DataValueSMSListener
     implements IncomingSmsListener
 {
+   
     private static final String defaultPattern = "([a-zA-Z]+)\\s*(\\d+)";
 
     private CompleteDataSetRegistrationService registrationService;
@@ -470,7 +471,7 @@
         SMSCommand command, Date date )
     {
         Period period = null;
-
+        int numberOfEmptyValue = 0;
         for ( SMSCode code : command.getCodes() )
         {
 
@@ -483,10 +484,33 @@
 
             if ( dv == null && !StringUtils.isEmpty( code.getCode() ) )
             {
-                return; // not marked as complete
-            }
-        }
-
+                numberOfEmptyValue++;
+                // emptyValue = true;
+                // return; // not marked as complete
+            }
+        }
+
+        // Check completeness method
+        if ( command.getCompletenessMethod() == SMSCommand.RECEIVE_ALL_DATAVALUE )
+        {
+            if ( numberOfEmptyValue > 0 )
+            {
+                return;
+            }
+        }
+        else if ( command.getCompletenessMethod() == SMSCommand.RECEIVE_AT_LEAST_ONE_DATAVALUE )
+        {
+            if ( numberOfEmptyValue == command.getCodes().size() )
+            {
+                return;
+            }
+        }
+        else if ( command.getCompletenessMethod() == SMSCommand.DO_NOT_MARK_COMPLETE )
+        {
+            return;
+        }
+
+        // Go through the complete process
         String storedBy = getUser( sender, command ).getUsername();
 
         if ( StringUtils.isBlank( storedBy ) )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml	2014-03-11 08:23:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/sms/hibernate/SMSCommand.hbm.xml	2014-03-21 04:09:08 +0000
@@ -29,6 +29,7 @@
     <property name="noUserMessage" type="text" />
     <property name="moreThanOneOrgUnitMessage" type="text" />
     <property name="currentPeriodUsedForReporting" type="boolean" />
+    <property name="completenessMethod" />
 
     <many-to-one name="dataset" class="org.hisp.dhis.dataset.DataSet" column="datasetid" foreign-key="fk_dataset_datasetid" />
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/java/org/hisp/dhis/mobile/action/smscommand/EditSMSCommandForm.java	2014-03-21 04:09:08 +0000
@@ -55,26 +55,26 @@
     // Dependencies
     // -------------------------------------------------------------------------
     private SMSCommandService smsCommandService;
-    
+
     public void setSmsCommandService( SMSCommandService smsCommandService )
     {
         this.smsCommandService = smsCommandService;
     }
 
     private DataSetService dataSetService;
-    
+
     public void setDataSetService( DataSetService dataSetService )
     {
         this.dataSetService = dataSetService;
     }
 
     private DataElementService dataElementService;
-    
+
     public void setDataElementService( DataElementService dataElementService )
     {
         this.dataElementService = dataElementService;
     }
-    
+
     private UserGroupService userGroupService;
 
     public void setUserGroupService( UserGroupService userGroupService )
@@ -89,11 +89,11 @@
     private String name;
 
     private int selectedDataSetID;
-    
+
     private Integer userGroupID;
 
     private String codeDataelementOption;
-    
+
     private String specialCharactersInfo;
 
     private String separator;
@@ -101,15 +101,17 @@
     private String codeSeparator;
 
     private String defaultMessage;
-    
+
     private String receivedMessage;
-    
+
     private String wrongFormatMessage;
-    
+
     private String noUserMessage;
-    
+
     private String moreThanOneOrgUnitMessage;
 
+    private Integer completenessMethod;
+
     private int selectedCommandID = -1;
 
     private boolean currentPeriodUsedForReporting = false;
@@ -134,9 +136,10 @@
             c.setOptionId( x.getInt( "optionId" ) );
             codeSet.add( c );
         }
-        
+
         @SuppressWarnings( "unchecked" )
-        List<JSONObject> jsonSpecialCharacters = (List<JSONObject>) JSONObject.fromObject( specialCharactersInfo ).get( "specialCharacters" );
+        List<JSONObject> jsonSpecialCharacters = (List<JSONObject>) JSONObject.fromObject( specialCharactersInfo ).get(
+            "specialCharacters" );
         Set<SMSSpecialCharacter> specialCharacterSet = new HashSet<SMSSpecialCharacter>();
         for ( JSONObject x : jsonSpecialCharacters )
         {
@@ -153,31 +156,36 @@
         }
 
         SMSCommand c = getSMSCommand();
-        
+
         if ( selectedDataSetID > -1 && c != null )
         {
             c.setCurrentPeriodUsedForReporting( currentPeriodUsedForReporting );
             c.setName( name );
             c.setSeparator( separator );
-            
-            //remove codes
+
+            if ( completenessMethod != null )
+            {
+                c.setCompletenessMethod( completenessMethod );
+            }
+
+            // remove codes
             Set<SMSCode> toRemoveCodes = c.getCodes();
             smsCommandService.deleteCodeSet( toRemoveCodes );
-            
-            //remove special characters
+
+            // remove special characters
             Set<SMSSpecialCharacter> toRemoveCharacters = c.getSpecialCharacters();
             smsCommandService.deleteSpecialCharacterSet( toRemoveCharacters );
-            
+
             c.setCodes( codeSet );
-            
+
             // message
             c.setDefaultMessage( defaultMessage );
             c.setReceivedMessage( receivedMessage );
             c.setMoreThanOneOrgUnitMessage( moreThanOneOrgUnitMessage );
             c.setNoUserMessage( noUserMessage );
             c.setWrongFormatMessage( wrongFormatMessage );
-            
-            if( userGroupID != null && userGroupID > -1 )
+
+            if ( userGroupID != null && userGroupID > -1 )
             {
                 c.setUserGroup( userGroupService.getUserGroup( userGroupID ) );
             }
@@ -208,7 +216,6 @@
         return smsCommandService.getSMSCommand( selectedCommandID );
     }
 
-
     public int getSelectedDataSetID()
     {
         return selectedDataSetID;
@@ -345,4 +352,14 @@
     {
         this.moreThanOneOrgUnitMessage = moreThanOneOrgUnitMessage;
     }
+
+    public int getCompletenessMethod()
+    {
+        return completenessMethod;
+    }
+
+    public void setCompletenessMethod( int completenessMethod )
+    {
+        this.completenessMethod = completenessMethod;
+    }
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2014-03-17 14:29:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/resources/org/hisp/dhis/mobile/i18n_module.properties	2014-03-21 04:09:08 +0000
@@ -141,5 +141,5 @@
 more_than_one_orgunit_message=User belong to more than one OrgUnit message
 completeness_method=Completeness method
 receive_at_least_one_datavalue=Receive at least one data value
-receive_all_compulsory_datavalue=Receive all compulsory data value
+do_not_mark_complete=Do not mark as complete
 receive_all_datavalue=Receive all data value
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm	2014-03-17 14:29:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-mobile/src/main/webapp/dhis-web-maintenance-mobile/smscommand/edit-sms-command.vm	2014-03-21 04:09:08 +0000
@@ -135,10 +135,10 @@
 		<tr>
 		<td>$i18n.getString( "completeness_method" )</td>
 			<td>
-				<select>
-					<option>$i18n.getString( "receive_at_least_one_datavalue" )</option>
-					<option>$i18n.getString( "receive_all_compulsory_datavalue" )</option>
-					<option>$i18n.getString( "receive_all_datavalue" )</option>
+				<select id="completenessMethod" name="completenessMethod">
+					<option value="1" #if($smsCommand.completenessMethod == 1) selected #end>$i18n.getString( "receive_all_datavalue" )</option>
+					<option value="2" #if($smsCommand.completenessMethod == 2) selected #end>$i18n.getString( "receive_at_least_one_datavalue" )</option>
+					<option value="3" #if($smsCommand.completenessMethod == 3) selected #end>$i18n.getString( "do_not_mark_complete" )</option>
 				</select>
 			</td>
 		</tr>