diff --git a/d2-tracker/dhis2.angular.services.js b/d2-tracker/dhis2.angular.services.js index a7e363e9a..69c01fe56 100644 --- a/d2-tracker/dhis2.angular.services.js +++ b/d2-tracker/dhis2.angular.services.js @@ -1779,21 +1779,21 @@ var d2Services = angular.module('d2Services', ['ngResource']) variables = pushVariable(variables, 'environment', 'WebClient',null,'TEXT',true,'V','',false); variables = pushVariable(variables, 'current_date', DateUtils.getToday(), null, 'DATE', true, 'V', '', false ); - variables = pushVariable(variables, 'event_date', executingEvent.eventDate, null, 'DATE', true, 'V', '', false ); - variables = pushVariable(variables, 'due_date', executingEvent.dueDate, null, 'DATE', true, 'V', '' ); + variables = pushVariable(variables, 'event_date', executingEvent.eventDate, null, 'DATE', !!executingEvent.eventDate, 'V', '', false ); + variables = pushVariable(variables, 'due_date', executingEvent.dueDate, null, 'DATE', !!executingEvent.dueDate, 'V', '' ); variables = pushVariable(variables, 'event_count', evs ? evs.all.length : 0, null, 'INTEGER', true, 'V', '', false ); - variables = pushVariable(variables, 'enrollment_date', selectedEnrollment ? selectedEnrollment.enrollmentDate : '', null, 'DATE', selectedEnrollment ? selectedEnrollment.enrollmentDate ? true : false : false, 'V', '', false ); - variables = pushVariable(variables, 'enrollment_id', selectedEnrollment ? selectedEnrollment.enrollment : '', null, 'TEXT', selectedEnrollment ? true : false, 'V', '', false ); - variables = pushVariable(variables, 'event_id', executingEvent ? executingEvent.event : '', null, 'TEXT', executingEvent ? true : false, 'V', executingEvent ? executingEvent.eventDate : false, false); - variables = pushVariable(variables, 'event_status', executingEvent ? executingEvent.status : '', null, 'TEXT', executingEvent ? true : false, 'V', executingEvent ? executingEvent.eventDate : false, false); + variables = pushVariable(variables, 'enrollment_date', selectedEnrollment ? selectedEnrollment.enrollmentDate : '', null, 'DATE', !!(selectedEnrollment && selectedEnrollment.enrollmentDate), 'V', '', false ); + variables = pushVariable(variables, 'enrollment_id', selectedEnrollment ? selectedEnrollment.enrollment : '', null, 'TEXT', !!selectedEnrollment, 'V', '', false ); + variables = pushVariable(variables, 'event_id', executingEvent ? executingEvent.event : '', null, 'TEXT', !!executingEvent, 'V', executingEvent ? executingEvent.eventDate : false, false); + variables = pushVariable(variables, 'event_status', executingEvent ? executingEvent.status : '', null, 'TEXT', !!executingEvent, 'V', executingEvent ? executingEvent.eventDate : false, false); - variables = pushVariable(variables, 'incident_date', selectedEnrollment ? selectedEnrollment.incidentDate : '', null, 'DATE', selectedEnrollment ? true : false, 'V', '', false); + variables = pushVariable(variables, 'incident_date', selectedEnrollment ? selectedEnrollment.incidentDate : '', null, 'DATE', !!selectedEnrollment, 'V', '', false); variables = pushVariable(variables, 'enrollment_count', selectedEnrollment ? 1 : 0, null, 'INTEGER', true, 'V', '', false); variables = pushVariable(variables, 'tei_count', selectedEnrollment ? 1 : 0, null, 'INTEGER', true, 'V', '', false); - variables = pushVariable(variables, 'program_stage_id',(selectedProgramStage && selectedProgramStage.id) || '', null, 'TEXT', selectedProgramStage && selectedProgramStage.id ? true : false, 'V', '', false); - variables = pushVariable(variables, 'program_stage_name',(selectedProgramStage && selectedProgramStage.name) || '', null, 'TEXT', selectedProgramStage && selectedProgramStage.name ? true : false, 'V', '', false); + variables = pushVariable(variables, 'program_stage_id',(selectedProgramStage && selectedProgramStage.id) || '', null, 'TEXT', !!(selectedProgramStage && selectedProgramStage.id), 'V', '', false); + variables = pushVariable(variables, 'program_stage_name',(selectedProgramStage && selectedProgramStage.name) || '', null, 'TEXT', !!(selectedProgramStage && selectedProgramStage.name), 'V', '', false); //Push all constant values: @@ -1802,7 +1802,7 @@ var d2Services = angular.module('d2Services', ['ngResource']) }); if(selectedOrgUnit){ - variables = pushVariable(variables, 'orgunit_code', selectedOrgUnit.code, null, 'TEXT', selectedOrgUnit.code ? true : false, 'V', '', false); + variables = pushVariable(variables, 'orgunit_code', selectedOrgUnit.code, null, 'TEXT', !!selectedOrgUnit.code, 'V', '', false); } return variables; @@ -2646,12 +2646,7 @@ var d2Services = angular.module('d2Services', ['ngResource']) }, "d2:concatenate": { execute: function(parameters) { - var returnString = "'"; - for (var i = 0; i < parameters.length; i++) { - returnString += parameters[i]; - } - returnString += "'"; - return returnString; + return parameters.join(''); }, }, "d2:addDays": { @@ -2659,9 +2654,7 @@ var d2Services = angular.module('d2Services', ['ngResource']) execute: function(parameters) { var date = $filter('trimquotes')(parameters[0]); var daystoadd = $filter('trimquotes')(parameters[1]); - var newdate = DateUtils.format( moment(date, CalendarService.getSetting().momentFormat).add(daystoadd, 'days') ); - var newdatestring = "'" + newdate + "'"; - return newdatestring + return DateUtils.format( moment(date, CalendarService.getSetting().momentFormat).add(daystoadd, 'days') ); }, }, "d2:zing": { @@ -2822,7 +2815,7 @@ var d2Services = angular.module('d2Services', ['ngResource']) execute: function(parameters, variablesHash) { var variableName = parameters[0]; var variableObject = variablesHash[variableName]; - var valueFound = "''"; + var valueFound = ""; if(variableObject) { if(variableObject.variableEventDate){ @@ -2937,7 +2930,7 @@ var d2Services = angular.module('d2Services', ['ngResource']) var startChar = string.length < parameters[1] - 1 ? -1 : parameters[1]; var endChar = string.length < parameters[2] ? -1 : parameters[2]; if(startChar < 0 || endChar < 0) { - return "''"; + return ""; } var returnString = string.substring(startChar, endChar); returnString = VariableService.processValue(returnString, 'TEXT'); @@ -3138,7 +3131,7 @@ var d2Services = angular.module('d2Services', ['ngResource']) accExpression += 'false'; } else { const dhisFunctionResult = dhisFunction.execute(evaluatedArguments, variablesHash, selectedOrgUnit); - accExpression += dhisFunctionResult; + accExpression += getInjectionValue(dhisFunctionResult); } return {