← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10751: Use setHeaderDelayMessage method instead of setMessage in patient module.

 

------------------------------------------------------------
revno: 10751
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-05-03 10:27:58 +0700
message:
  Use setHeaderDelayMessage method instead of setMessage in patient module.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dhis2.storage.anonymous.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramMetaData.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.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/webapp/dhis-web-caseentry/cacheManifest.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm	2013-05-03 03:27:58 +0000
@@ -39,11 +39,9 @@
 ../dhis-web-commons/javascripts/dhis2/dhis2.select.js
 ../dhis-web-commons/javascripts/dhis2/dhis2.comparator.js
 ../dhis-web-commons/javascripts/dhis2/dhis2.availability.js
-../dhis-web-commons/javascripts/dhis2/dhis2.storage.ls.js
-../dhis-web-commons/javascripts/dhis2/dhis2.storage.ss.js
-../dhis-web-commons/javascripts/dhis2/dhis2.storage.idb.js
-../dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js
 ../dhis-web-commons/javascripts/dhis2/dhis2.storage.js
+../dhis-web-commons/javascripts/dhis2/dhis2.storage.dom.js
+../dhis-web-commons/javascripts/dhis2/dhis2.storage.dom-ss.js
 ../dhis-web-commons/javascripts/jQuery/jquery.cookie.js
 ../dhis-web-commons/javascripts/jQuery/jquery.validate.js
 ../dhis-web-commons/javascripts/jQuery/jquery.validate.ext.js

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2013-03-11 13:09:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2013-05-03 03:27:58 +0000
@@ -78,6 +78,3 @@
 #parse( "dhis-web-commons/loader/loader.vm" )
 
 <div id='caseAggregationResult' style='none'></div>
-
-<span id='message'></span>
-

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm	2013-05-02 03:31:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationResult.vm	2013-05-03 03:27:58 +0000
@@ -36,11 +36,11 @@
 						#elseif($velocityCount==2)
 							#set($categoryoptioncomboid=$col)
 						#elseif($velocityCount==3)
-							#set($periodid=$col)
-						#elseif($velocityCount==4)
 							#set($organisationunitid=$col)
 						#elseif($velocityCount==$row.size())
 							#set($value=$col)
+						#elseif($velocityCount==6)
+							#set($periodid=$col)
 						#end
 						#set($item=$dataelementid + '_' + $categoryoptioncomboid + '_' + $periodid + '_' + $organisationunitid + '_' + $value)
 					#end

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-05-03 03:27:58 +0000
@@ -1,134 +1,74 @@
 var DAO = DAO || {};
 
-DAO.metaData = new dhis2.storage.Store( {
-    name: 'dhis2',
-    adapters: [ dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter ],
-    objectStores: [ 'programs', 'programStages', 'optionSets', 'usernames' ]
-} );
-
-DAO.offlineData = new dhis2.storage.Store( {
-    name: 'dhis2',
-    adapters: [ dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ],
-    objectStores: [ 'dataValues' ]
-} );
-
-DAO.metaData.open();
-DAO.offlineData.open();
-
-function loadPrograms() {
-    var def = $.Deferred();
-
-    $.ajax({
-        url: 'getProgramMetaData.action',
-        dataType: 'json'
-    } ).done(function(data) {
-        var programs = _.values( data.metaData.programs );
-        DAO.metaData.setAll('programs', programs ).then(function() {
-            def.resolve(data.metaData);
-        });
-    } ).always(function() {
-        def.resolve();
-    });
-
-    return def.promise();
-}
-
-function loadProgramStages( metaData ) {
-    if(!metaData) {
-        return;
-    }
-
-    var deferred1 = $.Deferred();
-    var deferred2 = $.Deferred();
-    var promise = deferred2.promise();
-
-    _.each( _.values(metaData.programs), function(el, idx) {
-        var psid = el.programStages[0].id;
-        var data = createProgramStage(psid);
-
-        promise = promise.then(function() {
-            return $.ajax( {
-                url: 'dataentryform.action',
-                data: data,
-                dataType: 'html'
-            } ).done(function(data) {
-                var obj = {};
-                obj.id = psid;
-                obj.form = data;
-                DAO.metaData.set('programStages', obj);
-            });
-        });
-    });
-
-    promise = promise.then(function() {
-        deferred1.resolve( metaData );
-    });
-
-    deferred2.resolve();
-
-    return deferred1.promise();
-}
-
-function loadOptionSets(metaData) {
-    if(!metaData) {
-        return;
-    }
-
-    var deferred1 = $.Deferred();
-    var deferred2 = $.Deferred();
-    var promise = deferred2.promise();
-
-    _.each( metaData.optionSets, function ( item, idx ) {
-        promise = promise.then( function () {
-            return $.ajax( {
-                url: 'getOptionSet.action?dataElementUid=' + item,
-                dataType: 'json'
-            } ).done( function ( data ) {
-                var obj = {};
-                obj.id = item;
-                obj.optionSet = data.optionSet;
-                DAO.metaData.set('optionSets', obj);
+var PROGRAMS_STORE = 'anonymousPrograms';
+var PROGRAM_STAGES_STORE = 'anonymousProgramStages';
+var OPTION_SET_STORE = 'optionSets';
+var USERNAME_STORE = 'usernames';
+var OFFLINE_DATA_STORE = 'anonymousOfflineData';
+
+function initalizeProgramStages() {
+    DAO.programStages = new dhis2.storage.Store( {name: PROGRAM_STAGES_STORE, adapter: 'dom-ss'}, function(store) {
+        $( document ).trigger('dhis2.anonymous.programStagesInitialized');
+    });
+}
+
+function initializePrograms() {
+    DAO.programs = new dhis2.storage.Store( {name: PROGRAMS_STORE, adapter: 'dom-ss'}, function ( store ) {
+        jQuery.getJSON( "getProgramMetaData.action", {},function ( data ) {
+            var keys = _.keys( data.metaData.programs );
+            var objs = _.values( data.metaData.programs );
+
+            DAO.programs.addAll( keys, objs, function ( store ) {
+                var deferred = $.Deferred();
+                var promise = deferred.promise();
+
+                _.each( _.values(data.metaData.programs), function(el, idx) {
+                    var psid = el.programStages[0].id;
+
+                    promise = promise.pipe(function () {
+                        return loadProgramStage(psid);
+                    });
+                });
+
+                promise = promise.pipe(function() {
+                    loadOptionSets( data.metaData.optionSets, data.metaData.usernames );
+                });
+
+                deferred.resolve();
+
+                selection.setListenerFunction( organisationUnitSelected );
+                $( document ).trigger('dhis2.anonymous.programsInitialized');
             } );
+        } ).fail( function () {
+            DAO.optionSets = new dhis2.storage.Store( {name: OPTION_SET_STORE, adapter: 'dom-ss'}, function() {} );
+            DAO.usernames = new dhis2.storage.Store( {name: USERNAME_STORE, adapter: 'dom-ss'}, function() {} );
+
+            selection.setListenerFunction( organisationUnitSelected );
+            $( document ).trigger('dhis2.anonymous.programsInitialized');
         } );
     } );
-
-    if ( metaData.usernames ) {
-        promise = promise.then( function() {
-            return $.ajax( {
-                url: 'getUsernames.action',
-                dataType: 'json'
-            } ).done( function (data) {
-                var obj = {};
-                obj.id = 'usernames';
-                obj.usernames = data.usernames;
-                DAO.metaData.set('usernames', obj);
-            } )
-        } );
-    }
-
-    promise = promise.then(function() {
-        deferred1.resolve( metaData );
+}
+
+function initializeOfflineData() {
+    DAO.offlineData = new dhis2.storage.Store( {name: OFFLINE_DATA_STORE, adapter: 'dom'}, function(store) {
+        $( document ).trigger('dhis2.anonymous.offlineData');
     });
-
-    deferred2.resolve();
-
-    return deferred1.promise();
 }
 
 function updateOfflineEvents() {
-    var no_offline_template = $( '#no-offline-event-template' );
-    var no_offline_template_compiled = _.template( no_offline_template.html() );
-
-    var offline_template = $( '#offline-event-template' );
-    var offline_template_compiled = _.template( offline_template.html() );
-
-    return DAO.offlineData.getAll( 'dataValues' ).done( function ( arr ) {
+    DAO.offlineData.fetchAll(function(store, arr) {
         var orgUnitId = selection.getSelected();
         var programId = $('#programId').val();
 
         var target = $( '#offlineEventList' );
         target.children().remove();
 
+        var no_offline_template = $( '#no-offline-event-template' );
+        var no_offline_template_compiled = _.template( no_offline_template.html() );
+
+        var offline_template = $( '#offline-event-template' );
+        var offline_template_compiled = _.template( offline_template.html() );
+
         if ( arr.length > 0 ) {
             var matched = false;
 
@@ -149,7 +89,9 @@
         } else {
             target.append( no_offline_template_compiled() );
         }
-    } );
+
+        $( document ).trigger('dhis2.anonymous.checkOfflineEvents');
+    });
 }
 
 function showOfflineEvents() {
@@ -163,10 +105,12 @@
 var haveLocalData = false;
 
 function checkOfflineData(callback) {
-    return DAO.offlineData.getAll( 'dataValues' ).done( function ( arr ) {
+    DAO.offlineData.fetchAll( function ( store, arr ) {
         haveLocalData = arr.length > 0;
+        $( document ).trigger('dhis2.anonymous.checkOfflineData');
+
         if(callback && typeof callback == 'function') callback(haveLocalData);
-    });
+    } );
 }
 
 function uploadOfflineData( item ) {
@@ -176,7 +120,7 @@
         data: JSON.stringify( item )
     } ).done(function(json) {
         if ( json.response == 'success' ) {
-            DAO.offlineData.delete( 'dataValues', item.id ).done( function () {
+            DAO.offlineData.remove( item.key, function ( store ) {
                 updateOfflineEvents();
                 searchEvents( eval( getFieldValue( 'listAll' ) ) );
             } );
@@ -187,7 +131,7 @@
 function uploadLocalData() {
     setHeaderWaitMessage( i18n_uploading_data_notification );
 
-    DAO.offlineData.getAll( 'dataValues' ).done( function ( arr ) {
+    DAO.offlineData.fetchAll( function ( store, arr ) {
         if(arr.length == 0) {
             setHeaderDelayMessage( i18n_sync_success );
             return;
@@ -207,7 +151,7 @@
         });
 
         deferred.resolve();
-    });
+    } );
 }
 
 function sync_failed_button() {
@@ -226,21 +170,16 @@
     } );
 
     $( "#orgUnitTree" ).one( "ouwtLoaded", function () {
-        var def = $.Deferred();
-        var promise = def.promise();
-        promise = promise.then(loadPrograms);
-        promise = promise.then(loadProgramStages);
-        promise = promise.then(loadOptionSets);
-        promise = promise.then(updateOfflineEvents);
-        promise = promise.then(checkOfflineData);
-        promise = promise.then(function() {
-            selection.setListenerFunction( organisationUnitSelected );
-
+        $( document ).one( 'dhis2.anonymous.programStagesInitialized', initializePrograms );
+        $( document ).one( 'dhis2.anonymous.programsInitialized', updateOfflineEvents );
+        $( document ).one( 'dhis2.anonymous.checkOfflineEvents', checkOfflineData );
+        $( document ).one( 'dhis2.anonymous.checkOfflineData', function () {
             dhis2.availability.startAvailabilityCheck();
             selection.responseReceived();
-        });
+        } );
 
-        def.resolve();
+        initalizeProgramStages();
+        initializeOfflineData();
     } );
 
     $( document ).bind( 'dhis2.online', function ( event, loggedIn ) {
@@ -353,7 +292,7 @@
     hideById( 'listDiv' );
     hideById( 'dataEntryInfor' );
 
-    DAO.metaData.getAll( 'programs' ).done( function (arr) {
+    DAO.programs.fetchAll( function ( store, arr ) {
         var programs = [];
 
         $.each( arr, function ( idx, item ) {
@@ -378,7 +317,7 @@
 
     for ( var i = 0; i < arr.length; i++ ) {
         jQuery( '#programId' ).append(
-            '<option value="' + arr[i].id
+            '<option value="' + arr[i].key
             + '" puid="' + arr[i].uid
             + '" programType="' + arr[i].type
             + '" psid="' + arr[i].programStages[0].id
@@ -808,9 +747,10 @@
 
     if( s.indexOf("local") != -1) {
         if ( confirm( i18n_comfirm_delete_event ) ) {
-            DAO.offlineData.delete( 'dataValues', programStageId ).always( function () {
+            DAO.offlineData.remove(programStageId, function(store) {
+                // redisplay list
                 updateOfflineEvents();
-            } );
+            });
         }
     } else {
         removeItem( programStageId, '', i18n_comfirm_delete_event, 'removeCurrentEncounter.action' );
@@ -970,7 +910,7 @@
                 }
             } ).fail( function () {
                 if(programStageInstanceId == 0) {
-                    DAO.offlineData.getKeys( 'dataValues' ).done( function ( keys ) {
+                    DAO.offlineData.keys(function(store, keys) {
                         var i = 100;
 
                         for(; i<10000; i++) {
@@ -984,11 +924,10 @@
                         showUpdateEvent( programStageInstanceId );
 
                         var data = {};
-                        data.id = programStageInstanceId;
                         data.executionDate = createExecutionDate(programId, programStageInstanceId, executionDate, organisationUnitId);
                         data.executionDate.completed = false;
 
-                        this.set( 'dataValues', data );
+                        DAO.offlineData.add(programStageInstanceId, data);
                     });
                 } else {
                     // if we have a programStageInstanceId, just reuse that one
@@ -1064,35 +1003,65 @@
     return data;
 }
 
-function createProgramStage( programStageId, programStageInstanceId, organisationUnitId ) {
-    var data = {};
-
-    if(programStageId)
-        data.programStageId = programStageId;
-
-    if(programStageInstanceId)
-        data.programStageInstanceId = programStageInstanceId;
-
-    if(organisationUnitId)
-        data.organisationUnitId = organisationUnitId;
-
-    return data;
-}
-
 function loadProgramStage( programStageId, programStageInstanceId, organisationUnitId, success, fail ) {
-    var data = createProgramStage( programStageId, programStageInstanceId, organisationUnitId );
-
-    DAO.metaData.get('programStages', programStageId ).done(function(obj) {
-        if(success) success(obj.form);
-    } ).fail(function() {
-        $.ajax( {
-            url: 'dataentryform.action',
-            data: data,
-            dataType: 'html'
-        } ).done(function(data) {
-            if(success) success(data);
-        } ).fail(function() {
-            if(fail) fail();
+    DAO.programStages.fetch(programStageId, function(store, arr) {
+        if ( arr.length > 0 ) {
+            if(success) success(arr[0]);
+        } else {
+            var data = {};
+
+            if(programStageId)
+                data.programStageId = programStageId;
+
+            if(programStageInstanceId)
+                data.programStageInstanceId = programStageInstanceId;
+
+            if(organisationUnitId)
+                data.organisationUnitId = organisationUnitId;
+
+            $.ajax( {
+                url: 'dataentryform.action',
+                data: data,
+                dataType: 'html'
+            } ).done(function(data) {
+                DAO.programStages.add(programStageId, data);
+                if(success) success(data);
+            } ).fail(function() {
+                if(fail) fail();
+            });
+        }
+    });
+}
+
+function loadOptionSets(uids, usernames, success ) {
+    DAO.optionSets = new dhis2.storage.Store( {name: OPTION_SET_STORE, adapter: 'dom-ss'}, function ( store ) {
+        DAO.usernames = new dhis2.storage.Store( {name: USERNAME_STORE, adapter: 'dom-ss'}, function ( store ) {
+            var deferred = $.Deferred();
+            var promise = deferred.promise();
+
+            _.each( uids, function(item, idx) {
+                promise = promise.pipe( $.ajax( {
+                    url: 'getOptionSet.action?dataElementUid=' + item,
+                    dataType: 'json',
+                    success: function ( json ) {
+                        DAO.optionSets.add( item, json );
+                        if ( success && typeof success == 'function' ) success( json );
+                    }
+                } ) );
+            });
+
+            if ( usernames ) {
+                promise = promise.pipe( $.ajax( {
+                    url: 'getUsernames.action',
+                    dataType: 'json',
+                    success: function ( json ) {
+                        DAO.usernames.add( 'usernames', json.usernames );
+                        if ( success && typeof success == 'function' ) success( json );
+                    }
+                } ) );
+            }
+
+            deferred.resolve();
         });
-    });
+    } );
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2013-05-02 03:31:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/caseagg.js	2013-05-03 03:27:58 +0000
@@ -69,7 +69,7 @@
 		, function(){
 			$( "#loaderDiv" ).hide();
 			showById('caseAggregationForm');
-			setMessage(i18n_aggregate_successfully);
+			setHeaderDelayMessage(i18n_aggregate_successfully);
 		});
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dhis2.storage.anonymous.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dhis2.storage.anonymous.js	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dhis2.storage.anonymous.js	2013-05-03 03:27:58 +0000
@@ -1,4 +1,3 @@
-/*
 dhis2.storage.Store.plugin( 'online-anonymous-programs', (function () {
     return {
         call: function ( args, success, failure ) {
@@ -29,4 +28,3 @@
         }
     };
 })() );
-*/

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-05-03 03:27:58 +0000
@@ -297,21 +297,22 @@
             var dataValueKey = $( '#programStageInstanceId' ).val();
             var key = dataElementUid;
 
-            DAO.offlineData.get( 'dataValues', dataValueKey ).done( function ( obj ) {
-                if ( !obj ) {
+            DAO.offlineData.fetch( dataValueKey, function ( store, arr ) {
+                if ( arr.length == 0 ) {
                     markValue( ERROR );
                     window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
                     return;
                 }
 
+                var obj = arr[0];
+
                 if ( !obj.values ) {
                     obj.values = {};
                 }
 
-                obj.id = dataValueKey;
                 obj.values[key] = data;
 
-                this.set( 'dataValues', obj );
+                store.add( dataValueKey, obj );
                 markValue( resultColor );
             } );
         } else {
@@ -597,13 +598,12 @@
                         jQuery(".stage-object-selected").css('border-color', COLOR_GREEN);
                         jQuery(".stage-object-selected").css('background-color', COLOR_LIGHT_GREEN);
 
-                        DAO.offlineData.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
-                            if ( !obj ) {
-                                return;
+                        DAO.offlineData.fetch( programStageInstanceId, function ( store, arr ) {
+                            if ( arr.length > 0 ) {
+                                var obj = arr[0];
+                                obj.executionDate.completed = true;
+                                DAO.offlineData.add( programStageInstanceId, obj );
                             }
-
-                            obj.executionDate.completed = true;
-                            DAO.offlineData.set('dataValues', obj);
                         } );
 
                         var blocked = jQuery('#entryFormContainer [id=blockEntryForm]').val();
@@ -645,13 +645,12 @@
                 var programStageInstanceId = getFieldValue( 'programStageInstanceId' );
 
                 if ( window.DAO && window.DAO.offlineData ) {
-                    DAO.offlineData.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
-                        if(!obj) {
-                            return;
+                    DAO.offlineData.fetch( programStageInstanceId, function ( store, arr ) {
+                        if ( arr.length > 0 ) {
+                            var obj = arr[0];
+                            obj.executionDate.completed = false;
+                            DAO.offlineData.add( programStageInstanceId, obj );
                         }
-
-                        obj.executionDate.completed = false;
-                        DAO.offlineData.set( 'dataValues', obj );
                     } );
                 }
 
@@ -724,23 +723,27 @@
         $( "#programStageInstanceId" ).val( programStageInstanceId );
         $( "#entryFormContainer input[id='programStageInstanceId']" ).val( programStageInstanceId );
 
-        DAO.offlineData.get( 'dataValues', programStageInstanceId ).done( function ( obj ) {
-            if(obj && obj.values !== undefined ) {
-                _.each( _.keys(obj.values), function(key, idx) {
-                    var fieldId = getProgramStageUid() + '-' + key + '-val';
-                    var field = $('#' + fieldId);
-
-                    if ( field ) {
-                        field.val( decodeURI( obj.values[key].value ) );
-                    }
-                });
+        DAO.offlineData.fetch(programStageInstanceId, function(store, arr) {
+            if(arr.length > 0 ) {
+                var obj = arr[0];
+
+                if(obj.values !== undefined ) {
+                    _.each( _.keys(obj.values), function(key, idx) {
+                        var fieldId = getProgramStageUid() + '-' + key + '-val';
+                        var field = $('#' + fieldId);
+
+                        if ( field ) {
+                            field.val( decodeURI( obj.values[key].value ) );
+                        }
+                    });
+                }
             }
 
             if( always ) always();
 
             $('#commentInput').attr('disabled', true);
             $('#validateBtn').attr('disabled', true);
-        } );
+        });
     } else {
         return $.ajax({
             url: 'getProgramStageInstance.action',
@@ -904,9 +907,10 @@
 }
 
 function searchOptionSet( uid, query, success ) {
-    if(window.DAO !== undefined && window.DAO.metaData !== undefined ) {
-        DAO.metaData.get( 'optionSets', uid ).done( function ( obj ) {
-            if(obj) {
+    if(window.DAO !== undefined && window.DAO.optionSets !== undefined ) {
+        DAO.optionSets.fetch(uid, function(store, arr) {
+            if ( arr.length > 0 ) {
+                var obj = arr[0];
                 var options = [];
 
                 if(query == null || query == "") {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramMetaData.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramMetaData.vm	2013-05-02 13:55:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramMetaData.vm	2013-05-03 03:27:58 +0000
@@ -5,7 +5,6 @@
 #set( $psize = $programs.size() )
 #foreach( $program in $programs )
 "${program.id}":{
-    "id":"${program.id}",
     "name":"$encoder.jsonEncode( ${program.displayName} )",
     "uid":"$encoder.jsonEncode( ${program.uid} )",
     "description":"$encoder.jsonEncode( ${program.description} )",

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm	2013-04-15 07:46:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm	2013-05-03 03:27:58 +0000
@@ -50,8 +50,6 @@
 <div id='addRelationshipDiv'></div> <!-- Add relationship -->
 <div id='migrationPatientDiv'></div> <!-- Migration Patient -->
 			
-<span id='message'></span>
-
 <script type="text/javascript">
 	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ) , "'")';
 	var i18n_please_select_village = '[' + '$encoder.jsEscape( $i18n.getString( "please_select_village" ), "'")' + ']';