diff --git a/ui/app/admin/controllers/auditLogController.js b/ui/app/admin/controllers/auditLogController.js index 2847f5590c..c821b037f0 100644 --- a/ui/app/admin/controllers/auditLogController.js +++ b/ui/app/admin/controllers/auditLogController.js @@ -92,7 +92,8 @@ angular.module('bahmni.admin') return; } var params = { - username: $scope.username, patientId: $scope.patientId, + username: $scope.username, + patientId: $scope.patientId, startFrom: $scope.startDate }; var promise = auditLogService.getLogs(mapParamsForRequest(params)).then(function (logs) { diff --git a/ui/app/adt/controllers/adtController.js b/ui/app/adt/controllers/adtController.js index ea6ad4e765..885d34580f 100644 --- a/ui/app/adt/controllers/adtController.js +++ b/ui/app/adt/controllers/adtController.js @@ -165,7 +165,7 @@ angular.module('bahmni.adt') }; $scope.visitExists = function () { - return $scope.visitSummary ? true : false; + return !!$scope.visitSummary; }; var getEncounterData = function (encounterTypeUuid, visitTypeUuid) { diff --git a/ui/app/bedmanagement/controllers/roomController.js b/ui/app/bedmanagement/controllers/roomController.js index a5e0ebcc36..82754a1fae 100644 --- a/ui/app/bedmanagement/controllers/roomController.js +++ b/ui/app/bedmanagement/controllers/roomController.js @@ -71,8 +71,7 @@ angular.module('bahmni.ipd') $scope.getTagName = function (tag) { if (tag === 'AVAILABLE') { return $translate.instant("KEY_AVAILABLE"); - } - else if (tag === 'OCCUPIED') { + } else if (tag === 'OCCUPIED') { return $translate.instant("KEY_OCCUPIED"); } }; diff --git a/ui/app/bedmanagement/controllers/roomGridController.js b/ui/app/bedmanagement/controllers/roomGridController.js index e1136c9358..3047c2474a 100644 --- a/ui/app/bedmanagement/controllers/roomGridController.js +++ b/ui/app/bedmanagement/controllers/roomGridController.js @@ -29,8 +29,7 @@ angular.module('bahmni.ipd') $rootScope.selectedBedInfo.bed = bed; var options = {bedId: bed.bedId}; $state.go("bedManagement.bed", options); - } - else if ($state.current.name === "bedManagement.patient") { + } else if ($state.current.name === "bedManagement.patient") { $rootScope.selectedBedInfo.bed = bed; if (bed.patient) { $scope.$emit("event:updateSelectedBedInfoForCurrentPatientVisit", bed.patient.uuid); diff --git a/ui/app/clinical/common/controllers/patientListHeaderController.js b/ui/app/clinical/common/controllers/patientListHeaderController.js index 39a696df19..8f04863856 100644 --- a/ui/app/clinical/common/controllers/patientListHeaderController.js +++ b/ui/app/clinical/common/controllers/patientListHeaderController.js @@ -48,7 +48,8 @@ angular.module('bahmni.clinical') }; $scope.popUpHandler = function () { - $scope.dialog = ngDialog.open({ template: 'consultation/views/defaultDataPopUp.html', className: 'test ngdialog-theme-default', + $scope.dialog = ngDialog.open({ template: 'consultation/views/defaultDataPopUp.html', + className: 'test ngdialog-theme-default', controller: 'PatientListHeaderController'}); $('body').addClass('show-controller-back'); }; diff --git a/ui/app/clinical/common/mappers/patientFileObservationsMapper.js b/ui/app/clinical/common/mappers/patientFileObservationsMapper.js index 7b3493aa71..38aabacfaf 100644 --- a/ui/app/clinical/common/mappers/patientFileObservationsMapper.js +++ b/ui/app/clinical/common/mappers/patientFileObservationsMapper.js @@ -26,9 +26,9 @@ Bahmni.Clinical.PatientFileObservationsMapper = function () { }); }); patientFileRecords.sort(function (record1, record2) { - return record1.imageObservation.observationDateTime !== record2.imageObservation.observationDateTime ? - DateUtil.parse(record1.imageObservation.observationDateTime) - DateUtil.parse(record2.imageObservation.observationDateTime) : - record1.id - record2.id; + return record1.imageObservation.observationDateTime !== record2.imageObservation.observationDateTime + ? DateUtil.parse(record1.imageObservation.observationDateTime) - DateUtil.parse(record2.imageObservation.observationDateTime) + : record1.id - record2.id; }); return patientFileRecords; }; diff --git a/ui/app/clinical/common/models/drugOrderViewModel.js b/ui/app/clinical/common/models/drugOrderViewModel.js index 496ef8b1bf..3cb5293ee2 100644 --- a/ui/app/clinical/common/models/drugOrderViewModel.js +++ b/ui/app/clinical/common/models/drugOrderViewModel.js @@ -94,7 +94,7 @@ Bahmni.Clinical.DrugOrderViewModel = function (config, proto, encounterDate) { return response; }; - this.encounterDate = encounterDate ? encounterDate : now; + this.encounterDate = encounterDate || now; this.asNeeded = this.asNeeded || false; this.route = this.route || undefined; this.durationUnit = this.durationUnit || inputOptionsConfig.defaultDurationUnit; @@ -121,7 +121,7 @@ Bahmni.Clinical.DrugOrderViewModel = function (config, proto, encounterDate) { this.isBeingEdited = this.isBeingEdited || false; this.orderAttributes = []; this.isNonCodedDrug = this.isNonCodedDrug || false; - this.isDurationRequired = inputOptionsConfig.duration && inputOptionsConfig.duration.required == false ? false : true; + this.isDurationRequired = !(inputOptionsConfig.duration && inputOptionsConfig.duration.required == false); if (inputOptionsConfig.defaultStartDate === false && !this.effectiveStartDate) { this.effectiveStartDate = null; @@ -620,7 +620,7 @@ Bahmni.Clinical.DrugOrderViewModel = function (config, proto, encounterDate) { return orderAttributesWithValues.map(function (orderAttribute) { return { uuid: orderAttribute.obsUuid, - value: orderAttribute.value ? true : false, + value: !!orderAttribute.value, orderUuid: self.uuid, concept: {uuid: orderAttribute.conceptUuid } }; @@ -727,7 +727,7 @@ Bahmni.Clinical.DrugOrderViewModel.createFromContract = function (drugOrderRespo viewModel.orderReasonText = drugOrderResponse.orderReasonText; viewModel.orderNumber = drugOrderResponse.orderNumber && parseInt(drugOrderResponse.orderNumber.replace("ORD-", "")); viewModel.drugNonCoded = drugOrderResponse.drugNonCoded; - viewModel.isNonCodedDrug = drugOrderResponse.drugNonCoded ? true : false; + viewModel.isNonCodedDrug = !!drugOrderResponse.drugNonCoded; viewModel.drugNameDisplay = viewModel.drugNonCoded || constructDrugNameDisplayWithConcept(viewModel.drug, viewModel.concept) || _.get(viewModel, 'concept.name'); if (config) { viewModel.loadOrderAttributes(drugOrderResponse); diff --git a/ui/app/clinical/consultation/controllers/diagnosisController.js b/ui/app/clinical/consultation/controllers/diagnosisController.js index 2fda0d49dd..774920c5e3 100644 --- a/ui/app/clinical/consultation/controllers/diagnosisController.js +++ b/ui/app/clinical/consultation/controllers/diagnosisController.js @@ -130,8 +130,8 @@ angular.module('bahmni.clinical') }); var isValidConditionForm = ($scope.consultation.condition.isEmpty() || $scope.consultation.condition.isValid()); return { - allow: invalidnewlyAddedDiagnoses.length === 0 && invalidPastDiagnoses.length === 0 - && invalidSavedDiagnosesFromCurrentEncounter.length === 0 && isValidConditionForm, + allow: invalidnewlyAddedDiagnoses.length === 0 && invalidPastDiagnoses.length === 0 && + invalidSavedDiagnosesFromCurrentEncounter.length === 0 && isValidConditionForm, errorMessage: $scope.errorMessage }; }; @@ -313,8 +313,8 @@ angular.module('bahmni.clinical') spinner.forPromise( diagnosisService.deleteDiagnosis(obsUUid).then(function () { messagingService.showMessage('info', 'DELETED_MESSAGE'); - var currentUuid = $scope.consultation.savedDiagnosesFromCurrentEncounter.length > 0 ? - $scope.consultation.savedDiagnosesFromCurrentEncounter[0].encounterUuid : ""; + var currentUuid = $scope.consultation.savedDiagnosesFromCurrentEncounter.length > 0 + ? $scope.consultation.savedDiagnosesFromCurrentEncounter[0].encounterUuid : ""; return reloadDiagnosesSection(currentUuid); })) .then(function () { diff --git a/ui/app/clinical/consultation/controllers/dispositionController.js b/ui/app/clinical/consultation/controllers/dispositionController.js index fb823f43f9..18031691c2 100644 --- a/ui/app/clinical/consultation/controllers/dispositionController.js +++ b/ui/app/clinical/consultation/controllers/dispositionController.js @@ -16,8 +16,7 @@ angular.module('bahmni.clinical') var previousDispositionNotes = getPreviousDispositionNote(); if (getSelectedConceptName($scope.dispositionCode, $scope.dispositionActions)) { return _.cloneDeep(previousDispositionNotes) || {concept: {uuid: $scope.dispositionNoteConceptUuid}}; - } - else { + } else { return {concept: {uuid: $scope.dispositionNoteConceptUuid}}; } }; @@ -52,12 +51,10 @@ angular.module('bahmni.clinical') var isVisitOpen = visitSummary ? _.isEmpty(visitSummary.stopDateTime) : false; if (visitSummary && visitSummary.isDischarged() && isVisitOpen) { finalDispositionActions = getDispositionActions(finalDispositionActions, dispositions, { code: defaultDispositions[0]}); - } - else if (visitSummary && visitSummary.isAdmitted() && isVisitOpen) { + } else if (visitSummary && visitSummary.isAdmitted() && isVisitOpen) { finalDispositionActions = getDispositionActions(finalDispositionActions, dispositions, { code: defaultDispositions[2]}); finalDispositionActions = getDispositionActions(finalDispositionActions, dispositions, { code: defaultDispositions[3]}); - } - else { + } else { finalDispositionActions = getDispositionActions(finalDispositionActions, dispositions, { code: defaultDispositions[1]}); } return finalDispositionActions; diff --git a/ui/app/clinical/consultation/controllers/drugOrderHistoryController.js b/ui/app/clinical/consultation/controllers/drugOrderHistoryController.js index 9a782efc9c..8864d8b379 100644 --- a/ui/app/clinical/consultation/controllers/drugOrderHistoryController.js +++ b/ui/app/clinical/consultation/controllers/drugOrderHistoryController.js @@ -187,7 +187,7 @@ angular.module('bahmni.clinical') $scope.updateAllOrderAttributesByName = function (orderAttribute, drugOrderGroup) { drugOrderGroup[orderAttribute.name] = drugOrderGroup[orderAttribute.name] || {}; - drugOrderGroup[orderAttribute.name].selected = drugOrderGroup[orderAttribute.name].selected ? false : true; + drugOrderGroup[orderAttribute.name].selected = !drugOrderGroup[orderAttribute.name].selected; drugOrderGroup.drugOrders.forEach(function (drugOrder) { var selectedOrderAttribute = getAttribute(drugOrder, orderAttribute.name); diff --git a/ui/app/clinical/consultation/controllers/investigationController.js b/ui/app/clinical/consultation/controllers/investigationController.js index ec5e5d88be..3f2e4d6625 100644 --- a/ui/app/clinical/consultation/controllers/investigationController.js +++ b/ui/app/clinical/consultation/controllers/investigationController.js @@ -45,11 +45,11 @@ angular.module('bahmni.clinical') $scope.activateTab($scope.tabs[0]); $scope.toggleNote = function () { - $scope.noteState = $scope.noteState ? false : true; + $scope.noteState = !$scope.noteState; }; var init = function () { - $scope.noteState = $scope.consultation.labOrderNote && $scope.consultation.labOrderNote.value ? true : false; + $scope.noteState = !!($scope.consultation.labOrderNote && $scope.consultation.labOrderNote.value); }; $scope.onNoteChanged = function () { diff --git a/ui/app/clinical/consultation/controllers/orderController.js b/ui/app/clinical/consultation/controllers/orderController.js index 7bc1cdf9c6..4261b4b687 100644 --- a/ui/app/clinical/consultation/controllers/orderController.js +++ b/ui/app/clinical/consultation/controllers/orderController.js @@ -92,7 +92,7 @@ angular.module('bahmni.clinical') $scope.tabs = []; _.forEach($scope.allOrdersTemplates, function (item) { var conceptName = $scope.getName(item); - $scope.tabs.push({name: conceptName ? conceptName : item.name.name, topLevelConcept: item.name.name}); + $scope.tabs.push({name: conceptName || item.name.name, topLevelConcept: item.name.name}); }); if ($scope.tabs) { $scope.activateTab($scope.tabs[0]); @@ -232,8 +232,8 @@ angular.module('bahmni.clinical') var configuredOptions = getConfiguredOptions(); return _.some(configuredOptions, function (option) { return option.toLowerCase() === 'needsprint'; - }) - && !isOrderSaved; + }) && + !isOrderSaved; }; $scope.isUrgent = function () { var configuredOptions = getConfiguredOptions(); diff --git a/ui/app/clinical/consultation/mappers/encounterTransactionMapper.js b/ui/app/clinical/consultation/mappers/encounterTransactionMapper.js index 9063a9584a..88e078b42b 100644 --- a/ui/app/clinical/consultation/mappers/encounterTransactionMapper.js +++ b/ui/app/clinical/consultation/mappers/encounterTransactionMapper.js @@ -71,8 +71,10 @@ Bahmni.Clinical.EncounterTransactionMapper = function () { } else if (order.isDiscontinued) { return Bahmni.Clinical.Order.discontinue(order); } - return { uuid: order.uuid, concept: {name: order.concept.name, uuid: order.concept.uuid }, - commentToFulfiller: order.commentToFulfiller, urgency: order.urgency}; + return { uuid: order.uuid, + concept: {name: order.concept.name, uuid: order.concept.uuid }, + commentToFulfiller: order.commentToFulfiller, + urgency: order.urgency}; }); encounterData.orders = encounterData.orders.concat(tempOrders); }; diff --git a/ui/app/clinical/consultation/models/Specimen.js b/ui/app/clinical/consultation/models/Specimen.js index 6d460a011c..4b26ecd287 100644 --- a/ui/app/clinical/consultation/models/Specimen.js +++ b/ui/app/clinical/consultation/models/Specimen.js @@ -24,10 +24,10 @@ Bahmni.Clinical.Specimen = function (specimen, allSamples) { }; self.isDirty = function () { - return (self.dateCollected && !self.type) || + return !!((self.dateCollected && !self.type) || (!self.dateCollected && !self.type && self.isAdditionalAttriburtesFilled()) || (!self.dateCollected && self.type) || - (!self.dateCollected && !self.type && self.identifier) || isDirtyRuleForFreeText() ? true : false; + (!self.dateCollected && !self.type && self.identifier) || isDirtyRuleForFreeText()); }; self.isEmpty = function () { diff --git a/ui/app/clinical/consultation/services/treatmentConfig.js b/ui/app/clinical/consultation/services/treatmentConfig.js index 4d4ef0e150..6584a3161b 100644 --- a/ui/app/clinical/consultation/services/treatmentConfig.js +++ b/ui/app/clinical/consultation/services/treatmentConfig.js @@ -119,7 +119,7 @@ angular.module('bahmni.clinical').factory('treatmentConfig', tabConfig.orderSet = tabConfig.orderSet || {}; var showDoseFractions = tabConfig.inputOptionsConfig.showDoseFractions; - tabConfig.inputOptionsConfig.showDoseFractions = showDoseFractions ? showDoseFractions : false; + tabConfig.inputOptionsConfig.showDoseFractions = showDoseFractions || false; tabConfig.drugOrderHistoryConfig = tabConfig.drugOrderHistoryConfig || {}; angular.extend(medicationTabConfig, commonConfig, tabConfig); drugOrderOptions = new Bahmni.Clinical.DrugOrderOptions(medicationTabConfig.inputOptionsConfig, medicationTabConfig); diff --git a/ui/app/clinical/dashboard/controllers/patientDashboardController.js b/ui/app/clinical/dashboard/controllers/patientDashboardController.js index b4479007c8..1ae19a2894 100644 --- a/ui/app/clinical/dashboard/controllers/patientDashboardController.js +++ b/ui/app/clinical/dashboard/controllers/patientDashboardController.js @@ -76,8 +76,8 @@ angular.module('bahmni.clinical') $scope.diseaseTemplates = diseaseTemplate; $scope.sectionGroups = dashboardModel.getSections($scope.diseaseTemplates); }); - $scope.currentDashboardTemplateUrl = $state.current.views['dashboard-content'] ? - $state.current.views['dashboard-content'].templateUrl : $state.current.views['dashboard-content']; + $scope.currentDashboardTemplateUrl = $state.current.views['dashboard-content'] + ? $state.current.views['dashboard-content'].templateUrl : $state.current.views['dashboard-content']; }; $scope.init(getCurrentTab()); diff --git a/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js b/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js index e5e499f6b3..cdbbb59af7 100644 --- a/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js +++ b/ui/app/clinical/dashboard/controllers/patientDashboardTreatmentController.js @@ -4,7 +4,7 @@ angular.module('bahmni.clinical') .controller('PatientDashboardTreatmentController', ['$scope', '$rootScope', 'ngDialog', 'visitActionsService', 'treatmentService', function ($scope, $rootScope, ngDialog, visitActionsService, treatmentService) { var treatmentConfigParams = $scope.dashboard.getSectionByType("treatment") || {}; - $scope.isEmailPresent = $scope.patient.email ? true : false; + $scope.isEmailPresent = !!$scope.patient.email; var patientParams = {"patientUuid": $scope.patient.uuid, "isEmailPresent": $scope.isEmailPresent}; var sharePrescriptionToggles = {"prescriptionEmailToggle": $rootScope.prescriptionEmailToggle}; var printParams = treatmentConfigParams.prescriptionPrint || {}; diff --git a/ui/app/clinical/dashboard/mappers/recordsMapper.js b/ui/app/clinical/dashboard/mappers/recordsMapper.js index 0a1598aed7..cce90b3ca5 100644 --- a/ui/app/clinical/dashboard/mappers/recordsMapper.js +++ b/ui/app/clinical/dashboard/mappers/recordsMapper.js @@ -4,9 +4,9 @@ Bahmni.Clinical.RecordsMapper = function () { var DateUtil = Bahmni.Common.Util.DateUtil; var sortByDateTimeOrId = function (record1, record2) { - return record2.imageObservation.observationDateTime !== record1.imageObservation.observationDateTime ? - DateUtil.parse(record2.imageObservation.observationDateTime) - DateUtil.parse(record1.imageObservation.observationDateTime) : - record2.id - record1.id; + return record2.imageObservation.observationDateTime !== record1.imageObservation.observationDateTime + ? DateUtil.parse(record2.imageObservation.observationDateTime) - DateUtil.parse(record1.imageObservation.observationDateTime) + : record2.id - record1.id; }; this.map = function (records) { diff --git a/ui/app/clinical/displaycontrols/investigationresults/directives/investigationTableRow.js b/ui/app/clinical/displaycontrols/investigationresults/directives/investigationTableRow.js index f2132d2ff5..74dbb212ff 100644 --- a/ui/app/clinical/displaycontrols/investigationresults/directives/investigationTableRow.js +++ b/ui/app/clinical/displaycontrols/investigationresults/directives/investigationTableRow.js @@ -11,7 +11,7 @@ angular.module('bahmni.clinical') $scope.params = angular.extend(defaultParams, $scope.params); $scope.hasNotes = function () { - return $scope.test.notes || $scope.test.showNotes ? true : false; + return !!($scope.test.notes || $scope.test.showNotes); }; $scope.getFormattedRange = function (test) { if (test.minNormal && test.maxNormal) { diff --git a/ui/app/common/concept-set/directives/conceptSetGroup.js b/ui/app/common/concept-set/directives/conceptSetGroup.js index 3fd86e9fdc..480267e916 100644 --- a/ui/app/common/concept-set/directives/conceptSetGroup.js +++ b/ui/app/common/concept-set/directives/conceptSetGroup.js @@ -121,8 +121,7 @@ angular.module('bahmni.common.conceptSet') }); if (anotherTemplate) { $scope.allTemplates.splice(index, 1); - } - else { + } else { $scope.allTemplates[index].isAdded = false; var clonedObj = $scope.allTemplates[index].clone(); $scope.allTemplates[index] = clonedObj; diff --git a/ui/app/common/concept-set/models/observationForm.js b/ui/app/common/concept-set/models/observationForm.js index c7d4ef2bd0..5d28d9f3a2 100644 --- a/ui/app/common/concept-set/models/observationForm.js +++ b/ui/app/common/concept-set/models/observationForm.js @@ -13,10 +13,10 @@ Bahmni.ObservationForm = function (formUuid, user, formName, formVersion, observ self.alwaysShow = user.isFavouriteObsTemplate(self.conceptName); self.observations = []; _.each(observations, function (observation) { - var observationFormField = observation.formFieldPath ? - Bahmni.Common.Util.FormFieldPathUtil.getFormNameAndVersion(observation.formFieldPath) : null; - if (observationFormField && observationFormField.formName === formName - && observationFormField.formVersion == formVersion) { + var observationFormField = observation.formFieldPath + ? Bahmni.Common.Util.FormFieldPathUtil.getFormNameAndVersion(observation.formFieldPath) : null; + if (observationFormField && observationFormField.formName === formName && + observationFormField.formVersion == formVersion) { self.observations.push(observation); } }); diff --git a/ui/app/common/displaycontrols/forms/directives/formsTable.js b/ui/app/common/displaycontrols/forms/directives/formsTable.js index 557c88ea55..caa68ad9fb 100644 --- a/ui/app/common/displaycontrols/forms/directives/formsTable.js +++ b/ui/app/common/displaycontrols/forms/directives/formsTable.js @@ -83,7 +83,7 @@ angular.module('bahmni.common.displaycontrol.forms') return displayName; }; var getLocaleSpecificConceptName = function (concept, locale, conceptNameType) { - conceptNameType = conceptNameType ? conceptNameType : "SHORT"; + conceptNameType = conceptNameType || "SHORT"; var localeSpecificName = _.filter(concept.names, function (name) { return ((name.locale === locale) && (name.conceptNameType === conceptNameType)); }); diff --git a/ui/app/common/displaycontrols/observation/directives/bahmniObservation.js b/ui/app/common/displaycontrols/observation/directives/bahmniObservation.js index 10ac971308..e189020727 100644 --- a/ui/app/common/displaycontrols/observation/directives/bahmniObservation.js +++ b/ui/app/common/displaycontrols/observation/directives/bahmniObservation.js @@ -11,8 +11,8 @@ angular.module('bahmni.common.displaycontrol.observation') $scope.showGroupDateTime = $scope.config.showGroupDateTime !== false; var mapObservation = function (observations) { - var conceptsConfig = $scope.config.formType === Bahmni.Common.Constants.forms2Type ? {} : - appService.getAppDescriptor().getConfigValue("conceptSetUI") || {}; + var conceptsConfig = $scope.config.formType === Bahmni.Common.Constants.forms2Type ? {} + : appService.getAppDescriptor().getConfigValue("conceptSetUI") || {}; observations = new Bahmni.Common.Obs.ObservationMapper().map(observations, conceptsConfig, null, $translate); diff --git a/ui/app/common/displaycontrols/observation/services/formRecordTreeBuildService.js b/ui/app/common/displaycontrols/observation/services/formRecordTreeBuildService.js index f7e8aa7b4c..3049ebe00a 100644 --- a/ui/app/common/displaycontrols/observation/services/formRecordTreeBuildService.js +++ b/ui/app/common/displaycontrols/observation/services/formRecordTreeBuildService.js @@ -65,8 +65,10 @@ angular.module('bahmni.common.displaycontrol.observation') }; var formName = value.formFieldPath.split('.')[0]; - var formBuilderForm = formBuilderForms.find(function (form) { return form.name === - formName; }); + var formBuilderForm = formBuilderForms.find(function (form) { + return form.name === + formName; + }); obsGroup.concept.shortName = formName; var locale = localStorage.getItem("NG_TRANSLATE_LANG_KEY") || "en"; var formNameTranslations = formBuilderForm && formBuilderForm.nameTranslation @@ -208,15 +210,13 @@ angular.module('bahmni.common.displaycontrol.observation') _.forEach(recordObservations, function (recordObservation) { obsGroup.groupMembers.push(recordObservation); }); - } - else if (record.control.type === 'section') { + } else if (record.control.type === 'section') { var sectionGroup = self.createObsGroup(record, translationData); self.createGroupMembers(record, sectionGroup, obsList, translationData); if (sectionGroup.groupMembers.length > 0) { obsGroup.groupMembers.push(sectionGroup); } - } - else if (record.control.type === "table") { + } else if (record.control.type === "table") { var tableGroup = self.createObsGroup(record, translationData); var columns = record.control.columnHeaders; self.createColumnGroupsForTable(record, columns, tableGroup, obsList, translationData); diff --git a/ui/app/common/displaycontrols/pivottable/directives/pivotTable.js b/ui/app/common/displaycontrols/pivottable/directives/pivotTable.js index 6ee35dde6b..478784011d 100644 --- a/ui/app/common/displaycontrols/pivottable/directives/pivotTable.js +++ b/ui/app/common/displaycontrols/pivottable/directives/pivotTable.js @@ -64,8 +64,7 @@ angular.module('bahmni.common.displaycontrol.pivottable').directive('pivotTable' scrollLeft: '20000px' }, 500); tablescroll = $('table.pivot-table tbody').scrollLeft(); clearInterval(checkIfPivotTableLoaded); - } - else if ($('table.pivot-table tbody tr').length < 12) { + } else if ($('table.pivot-table tbody tr').length < 12) { $('.btn-scroll-right, .btn-scroll-left').attr("disabled", true); clearInterval(checkIfPivotTableLoaded); } diff --git a/ui/app/common/domain/mappers/attributeTypeMapper.js b/ui/app/common/domain/mappers/attributeTypeMapper.js index e146bb8795..6d29457ca8 100644 --- a/ui/app/common/domain/mappers/attributeTypeMapper.js +++ b/ui/app/common/domain/mappers/attributeTypeMapper.js @@ -11,11 +11,11 @@ Bahmni.Common.Domain.AttributeTypeMapper = (function () { var element = _.find(mandatoryAttributes, function (mandatoryAttribute) { return mandatoryAttribute == mrsAttributeType.name; }); - return element ? true : false; + return !!element; }; var getLocaleSpecificConceptName = function (concept, locale, conceptNameType) { - conceptNameType = conceptNameType ? conceptNameType : "SHORT"; + conceptNameType = conceptNameType || "SHORT"; var localeSpecificName = _.filter(concept.names, function (name) { return name.locale == locale && name.conceptNameType == conceptNameType; }); diff --git a/ui/app/common/domain/models/condition.js b/ui/app/common/domain/models/condition.js index 7af7f0e353..0fa60fad60 100644 --- a/ui/app/common/domain/models/condition.js +++ b/ui/app/common/domain/models/condition.js @@ -41,8 +41,8 @@ return this.conditionNonCoded || this.concept.shortName || this.concept.name; }; Condition.prototype.isEmpty = function () { - return !this.status && !this.concept.name && !(this.isNonCoded || this.concept.uuid) - && !this.onSetDate && !this.additionalDetail; + return !this.status && !this.concept.name && !(this.isNonCoded || this.concept.uuid) && + !this.onSetDate && !this.additionalDetail; }; Condition.createFromDiagnosis = function (diagnosis) { diff --git a/ui/app/common/domain/services/encounterService.js b/ui/app/common/domain/services/encounterService.js index afc47cd4c6..4fd64d9a57 100644 --- a/ui/app/common/domain/services/encounterService.js +++ b/ui/app/common/domain/services/encounterService.js @@ -29,8 +29,8 @@ angular.module('bahmni.common.domain') var getBacteriologyGroupMembers = function (encounter) { var addBacteriologyMember = function (bacteriologyGroupMembers, member) { - bacteriologyGroupMembers = member.groupMembers.length ? bacteriologyGroupMembers.concat(member.groupMembers) : - bacteriologyGroupMembers.concat(member); + bacteriologyGroupMembers = member.groupMembers.length ? bacteriologyGroupMembers.concat(member.groupMembers) + : bacteriologyGroupMembers.concat(member); return bacteriologyGroupMembers; }; return encounter.extensions && encounter.extensions.mdrtbSpecimen ? encounter.extensions.mdrtbSpecimen.map(function (observation) { @@ -116,8 +116,8 @@ angular.module('bahmni.common.domain') } var deleteIfImageOrVideoObsIsVoided = function (obs) { - if (obs.voided && obs.groupMembers && !obs.groupMembers.length && obs.value - && isObsConceptClassVideoOrImage(obs)) { + if (obs.voided && obs.groupMembers && !obs.groupMembers.length && obs.value && + isObsConceptClassVideoOrImage(obs)) { var url = Bahmni.Common.Constants.RESTWS_V1 + "/bahmnicore/visitDocument?filename=" + obs.value; $http.delete(url, {withCredentials: true}); } diff --git a/ui/app/common/domain/services/visitService.js b/ui/app/common/domain/services/visitService.js index dd70bbac48..e3f4ec43e1 100644 --- a/ui/app/common/domain/services/visitService.js +++ b/ui/app/common/domain/services/visitService.js @@ -3,7 +3,7 @@ angular.module('bahmni.common.domain') .service('visitService', ['$http', function ($http) { this.getVisit = function (uuid, params) { - var parameters = params ? params : "custom:(uuid,visitId,visitType,patient,encounters:(uuid,encounterType,voided,orders:(uuid,orderType,voided,concept:(uuid,set,name),),obs:(uuid,value,concept,obsDatetime,groupMembers:(uuid,concept:(uuid,name),obsDatetime,value:(uuid,name),groupMembers:(uuid,concept:(uuid,name),value:(uuid,name),groupMembers:(uuid,concept:(uuid,name),value:(uuid,name)))))))"; + var parameters = params || "custom:(uuid,visitId,visitType,patient,encounters:(uuid,encounterType,voided,orders:(uuid,orderType,voided,concept:(uuid,set,name),),obs:(uuid,value,concept,obsDatetime,groupMembers:(uuid,concept:(uuid,name),obsDatetime,value:(uuid,name),groupMembers:(uuid,concept:(uuid,name),value:(uuid,name),groupMembers:(uuid,concept:(uuid,name),value:(uuid,name)))))))"; return $http.get(Bahmni.Common.Constants.visitUrl + '/' + uuid, { params: { diff --git a/ui/app/common/models/visitSummary.js b/ui/app/common/models/visitSummary.js index 511cdbb63d..6b1d4a476f 100644 --- a/ui/app/common/models/visitSummary.js +++ b/ui/app/common/models/visitSummary.js @@ -4,11 +4,11 @@ Bahmni.Common.VisitSummary = function (visitSummary) { angular.extend(this, visitSummary); this.isAdmitted = function () { - return this.admissionDetails && this.admissionDetails.uuid ? true : false; + return !!(this.admissionDetails && this.admissionDetails.uuid); }; this.isDischarged = function () { - return this.dischargeDetails && this.dischargeDetails.uuid ? true : false; + return !!(this.dischargeDetails && this.dischargeDetails.uuid); }; this.getAdmissionEncounterUuid = function () { diff --git a/ui/app/common/obs/directives/editObservation.js b/ui/app/common/obs/directives/editObservation.js index b337555549..a0d914f937 100644 --- a/ui/app/common/obs/directives/editObservation.js +++ b/ui/app/common/obs/directives/editObservation.js @@ -13,7 +13,7 @@ angular.module('bahmni.common.obs') }); }; var shouldEditSpecificObservation = function () { - return $scope.observation.uuid ? true : false; + return !!$scope.observation.uuid; }; var contextChange = function () { return contextChangeHandler.execute(); @@ -79,7 +79,7 @@ angular.module('bahmni.common.obs') }; var showErrorMessage = function (errMsg) { - var errorMessage = errMsg ? errMsg : "{{'CLINICAL_FORM_ERRORS_MESSAGE_KEY' | translate }}"; + var errorMessage = errMsg || "{{'CLINICAL_FORM_ERRORS_MESSAGE_KEY' | translate }}"; messagingService.showMessage('error', errorMessage); }; @@ -161,7 +161,8 @@ angular.module('bahmni.common.obs') return Bahmni.Clinical.Order.discontinue(order); } return { - uuid: order.uuid, concept: {name: order.concept.name, uuid: order.concept.uuid}, + uuid: order.uuid, + concept: {name: order.concept.name, uuid: order.concept.uuid}, commentToFulfiller: order.commentToFulfiller }; }); diff --git a/ui/app/common/patient-search/controllers/patientsListController.js b/ui/app/common/patient-search/controllers/patientsListController.js index ae7995da4e..f99144ae28 100644 --- a/ui/app/common/patient-search/controllers/patientsListController.js +++ b/ui/app/common/patient-search/controllers/patientsListController.js @@ -22,8 +22,7 @@ angular.module('bahmni.common.patientSearch') }); if (patientSearchConfig && patientSearchConfig.serializeSearch) { getPatientCountSeriallyBySearchIndex(0); - } - else { + } else { _.each($scope.search.searchTypes, function (searchType) { _.isEmpty(searchType) || ($scope.search.searchType != searchType && getPatientCount(searchType, null)); }); @@ -52,7 +51,8 @@ angular.module('bahmni.common.patientSearch') }; var getPatientCount = function (searchType, patientListSpinner) { if (searchType.handler) { - var params = { q: searchType.handler, v: "full", + var params = { q: searchType.handler, + v: "full", location_uuid: $bahmniCookieStore.get(Bahmni.Common.Constants.locationCookieName).uuid, provider_uuid: $rootScope.currentProvider.uuid }; if (searchType.additionalParams) { @@ -94,8 +94,7 @@ angular.module('bahmni.common.patientSearch') return identifierHeading; } else if ($scope.search.searchType && $scope.search.searchType.links) { return _.find($scope.search.searchType.links, {linkColumn: heading}); - } - else if ($scope.search.searchType && $scope.search.searchType.linkColumn) { + } else if ($scope.search.searchType && $scope.search.searchType.linkColumn) { return _.includes([$scope.search.searchType.linkColumn], heading); } }; @@ -153,8 +152,7 @@ angular.module('bahmni.common.patientSearch') patientListSpinner = showSpinner(spinner, $(".tab-content")); if (patientSearchConfig && patientSearchConfig.debounceSearch) { debounceGetPatientCount(currentSearchType, patientListSpinner); - } - else { + } else { getPatientCount(currentSearchType, patientListSpinner); } } diff --git a/ui/app/common/patient-search/models/search.js b/ui/app/common/patient-search/models/search.js index 2c1a004c11..8e0c17add0 100644 --- a/ui/app/common/patient-search/models/search.js +++ b/ui/app/common/patient-search/models/search.js @@ -59,7 +59,7 @@ Bahmni.Common.PatientSearch.Search = function (searchTypes) { }; self.filterPatients = function (matchingCriteria) { - matchingCriteria = matchingCriteria ? matchingCriteria : matchesNameOrId; + matchingCriteria = matchingCriteria || matchesNameOrId; self.searchResults = self.searchParameter ? self.activePatients.filter(matchingCriteria) : self.activePatients; }; @@ -105,7 +105,7 @@ Bahmni.Common.PatientSearch.Search = function (searchTypes) { } else if (patient.extraIdentifierVal) { extraIdentifier = patient.extraIdentifierVal; } - patient.extraIdentifier = patient.extraIdentifier ? patient.extraIdentifier : (extraIdentifier ? extraIdentifier : patient.identifier); + patient.extraIdentifier = patient.extraIdentifier ? patient.extraIdentifier : (extraIdentifier || patient.identifier); patient.image = Bahmni.Common.Constants.patientImageUrlByPatientUuid + patient.uuid; return patient; } diff --git a/ui/app/common/patient/mappers/patientContextMapper.js b/ui/app/common/patient/mappers/patientContextMapper.js index 1a872d6184..3377d9c658 100644 --- a/ui/app/common/patient/mappers/patientContextMapper.js +++ b/ui/app/common/patient/mappers/patientContextMapper.js @@ -6,12 +6,12 @@ Bahmni.PatientContextMapper = function () { patientContext.uuid = patient.uuid; patientContext.givenName = patient.person.names[0].givenName; var familyName = patient.person.names[0].familyName; - patientContext.familyName = familyName ? familyName : ""; + patientContext.familyName = familyName || ""; patientContext.middleName = patient.person.names[0].middleName; patientContext.gender = patient.person.gender; if (patient.identifiers) { var primaryIdentifier = patient.identifiers[0].primaryIdentifier; - patientContext.identifier = primaryIdentifier ? primaryIdentifier : patient.identifiers[0].identifier; + patientContext.identifier = primaryIdentifier || patient.identifiers[0].identifier; } if (patient.person.birthdate) { diff --git a/ui/app/common/patient/mappers/patientMapper.js b/ui/app/common/patient/mappers/patientMapper.js index d591a46ae9..39fbe90471 100644 --- a/ui/app/common/patient/mappers/patientMapper.js +++ b/ui/app/common/patient/mappers/patientMapper.js @@ -26,7 +26,7 @@ Bahmni.PatientMapper = function (patientConfig, $rootScope, $translate) { if (openmrsPatient.identifiers) { var primaryIdentifier = openmrsPatient.identifiers[0].primaryIdentifier; - patient.identifier = primaryIdentifier ? primaryIdentifier : openmrsPatient.identifiers[0].identifier; + patient.identifier = primaryIdentifier || openmrsPatient.identifiers[0].identifier; } if (openmrsPatient.identifiers && openmrsPatient.identifiers.length > 1) { diff --git a/ui/app/common/photo-capture/directives/capturePhoto.js b/ui/app/common/photo-capture/directives/capturePhoto.js index 708e1012b7..b0fb49c03a 100644 --- a/ui/app/common/photo-capture/directives/capturePhoto.js +++ b/ui/app/common/photo-capture/directives/capturePhoto.js @@ -108,7 +108,11 @@ angular.module('bahmni.common.photoCapture') }; captureDialogElement.dialog({ - autoOpen: false, height: 300, width: 500, modal: true, dialogClass: 'photo-capture-dialog', + autoOpen: false, + height: 300, + width: 500, + modal: true, + dialogClass: 'photo-capture-dialog', close: function () { dialogOpen = false; if (captureActiveStream) { @@ -175,7 +179,11 @@ angular.module('bahmni.common.photoCapture') }; uploadDialogElement.dialog({ - autoOpen: false, height: 350, width: 350, modal: true, dialogClass: 'photo-upload-dialog', + autoOpen: false, + height: 350, + width: 350, + modal: true, + dialogClass: 'photo-upload-dialog', close: function () { dialogOpen = false; } diff --git a/ui/app/common/services/formService.js b/ui/app/common/services/formService.js index 1396d3f6c4..b125d42da4 100644 --- a/ui/app/common/services/formService.js +++ b/ui/app/common/services/formService.js @@ -37,7 +37,9 @@ angular.module('bahmni.common.conceptSet') var getFormTranslate = function (formName, formVersion, locale, formUuid) { return $http.get(Bahmni.Common.Constants.formBuilderTranslationApi, { params: {formName: formName, - formVersion: formVersion, locale: locale, formUuid: formUuid}}); + formVersion: formVersion, + locale: locale, + formUuid: formUuid}}); }; return { diff --git a/ui/app/common/ui-helper/directives.js b/ui/app/common/ui-helper/directives.js index 1acb916d34..7e5baf67e5 100644 --- a/ui/app/common/ui-helper/directives.js +++ b/ui/app/common/ui-helper/directives.js @@ -132,7 +132,7 @@ angular.module('bahmni.common.uiHelper') var validationMessage = attrs.validationMessage || 'Please enter a valid detail'; var setValidity = function (value) { - var valid = value ? true : false; + var valid = !!value; ngModelCtrl.$setValidity('blank', valid); element[0].setCustomValidity(!valid ? validationMessage : ''); }; diff --git a/ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js b/ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js index 69edbcee88..024ecbba3b 100644 --- a/ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js +++ b/ui/app/common/uicontrols/programmanagement/controllers/manageProgramController.js @@ -144,8 +144,8 @@ angular.module('bahmni.common.uicontrols.programmanagment') if (_.isEmpty(activePatientProgramState) && patientProgram.selectedState != undefined) { return true; } - return patientProgram.selectedState - && (patientProgram.selectedState.uuid != activePatientProgramState.state.uuid); + return patientProgram.selectedState && + (patientProgram.selectedState.uuid != activePatientProgramState.state.uuid); }; var isOutcomeSelected = function (patientProgram) { @@ -167,8 +167,8 @@ angular.module('bahmni.common.uicontrols.programmanagment') if (isProgramStateChanged(patientProgram, activePatientProgramState)) { var startDate = getCurrentDate(); if (activePatientProgramState && DateUtil.isBeforeDate(startDate, activeStateDate)) { - messagingService.showMessage("error", "PROGRAM_MANAGEMENT_STATE_CANT_START_BEFORE_KEY" - + " (" + DateUtil.formatDateWithoutTime(activeStateDate) + ")"); + messagingService.showMessage("error", "PROGRAM_MANAGEMENT_STATE_CANT_START_BEFORE_KEY" + + " (" + DateUtil.formatDateWithoutTime(activeStateDate) + ")"); return; } patientProgram.states.push({ diff --git a/ui/app/common/uicontrols/programmanagement/mappers/programHelper.js b/ui/app/common/uicontrols/programmanagement/mappers/programHelper.js index ba793002f2..ceba264744 100644 --- a/ui/app/common/uicontrols/programmanagement/mappers/programHelper.js +++ b/ui/app/common/uicontrols/programmanagement/mappers/programHelper.js @@ -79,7 +79,7 @@ angular.module('bahmni.common.uicontrols.programmanagment') return progAttr.attributeType.display === configAttr.name; }); - attr = attr ? attr : { + attr = attr || { value: "" }; attr.attributeType = configAttr; diff --git a/ui/app/common/util/httpErrorInterceptor.js b/ui/app/common/util/httpErrorInterceptor.js index e0511644e3..77ca91b4c7 100644 --- a/ui/app/common/util/httpErrorInterceptor.js +++ b/ui/app/common/util/httpErrorInterceptor.js @@ -58,8 +58,8 @@ angular.module('httpErrorInterceptor', []) showError(errorMessage); } } else if (response.status === 404) { - if (!_.includes(response.config.url, "implementation_config") && !_.includes(response.config.url, "locale_") - && !_.includes(response.config.url, "offlineMetadata")) { + if (!_.includes(response.config.url, "implementation_config") && !_.includes(response.config.url, "locale_") && + !_.includes(response.config.url, "offlineMetadata")) { showError("The requested information does not exist"); } } diff --git a/ui/app/common/util/modernizr.tests.js b/ui/app/common/util/modernizr.tests.js index eaec776cbf..aae2f25a67 100644 --- a/ui/app/common/util/modernizr.tests.js +++ b/ui/app/common/util/modernizr.tests.js @@ -1,7 +1,7 @@ 'use strict'; Modernizr.addTest('ios', function () { - return navigator.userAgent.match(/(iPad|iPhone|iPod)/i) ? true : false; + return !!navigator.userAgent.match(/(iPad|iPhone|iPod)/i); }); Modernizr.addTest('windowOS', function () { diff --git a/ui/app/common/util/offlineStatusService.js b/ui/app/common/util/offlineStatusService.js index a1c3f5a948..1b47cee251 100644 --- a/ui/app/common/util/offlineStatusService.js +++ b/ui/app/common/util/offlineStatusService.js @@ -11,7 +11,7 @@ angular.module('bahmni.common.util') var networkConnectivity = appService.getAppDescriptor().getConfigValue("networkConnectivity"); var showNetworkStatusIndicator = networkConnectivity != null ? networkConnectivity.showNetworkStatusMessage : null; var intervalFrequency = networkConnectivity != null ? networkConnectivity.networkStatusCheckInterval : null; - intervalFrequency = intervalFrequency ? intervalFrequency : 5000; + intervalFrequency = intervalFrequency || 5000; Offline.options = { game: true, diff --git a/ui/app/document-upload/models/visit.js b/ui/app/document-upload/models/visit.js index cd043f60d0..de112040c2 100644 --- a/ui/app/document-upload/models/visit.js +++ b/ui/app/document-upload/models/visit.js @@ -112,7 +112,7 @@ Bahmni.DocumentUpload.Visit = function () { }; this.isSaved = function (file) { - return file.obsUuid ? true : false; + return !!file.obsUuid; }; this.removeFile = function (file) { @@ -140,10 +140,10 @@ Bahmni.DocumentUpload.Visit = function () { return !file.voided && (!file.concept || !file.concept.editableName || !file.concept.uuid); }); - return imageHasError ? true : false; + return !!imageHasError; }; this.hasVisitType = function () { - return this.visitType && this.visitType.uuid ? true : false; + return !!(this.visitType && this.visitType.uuid); }; }; diff --git a/ui/app/home/controllers/changePasswordController.js b/ui/app/home/controllers/changePasswordController.js index 3bd575d4c8..43c9b9e075 100644 --- a/ui/app/home/controllers/changePasswordController.js +++ b/ui/app/home/controllers/changePasswordController.js @@ -20,8 +20,7 @@ angular.module('bahmni.home') messagingService.showMessage("info", 'CHANGE_PASSWORD_SUCCESSFUL_MESSAGE'); clearPasswordFields(); }); - } - else { + } else { $scope.passwordDoesNotMatch = true; } }; diff --git a/ui/app/i18n/reports/locale_en.json b/ui/app/i18n/reports/locale_en.json index e0c7d0230f..64428837c9 100644 --- a/ui/app/i18n/reports/locale_en.json +++ b/ui/app/i18n/reports/locale_en.json @@ -5,43 +5,44 @@ "login": "Login", "selectLocation": "Select Location", "clinical_key": "Clinical", - "REPORTS_NAME_HEADER_KEY":"Name", + "REPORTS_NAME_HEADER_KEY": "Name", "REPORTS_START_DATE_HEADER_KEY": "Start Date", "REPORTS_END_DATE_HEADER_KEY": "End Date", "RUN_NOW_BUTTON_KEY": "Run Now", "RUN_REPORT_BUTTON_KEY": "Run Report", "QUEUE_BUTTON_KEY": "Queue", "REPORT_FORMAT_KEY": "Format", - "REPORTS_TITLE_KEY":"Reports", - "REPORTS_TITLE_WITHOUT_DATE_RANGE_KEY":"Reports without Date Range", - "REPORTS_MISSING_WARNING_MESSAGE_KEY":"New reports can be configured in a json file within openmrs/apps/reports/reports.json. Please consult the documentation for more information on configuring canned reports", - "MESSAGE_DIALOG_OPTION_COPY" : "Copy Error", + "REPORT_DATE_RANGE": "Select Date Range", + "REPORTS_TITLE_KEY": "Reports", + "REPORTS_TITLE_WITHOUT_DATE_RANGE_KEY": "Reports without Date Range", + "REPORTS_MISSING_WARNING_MESSAGE_KEY": "New reports can be configured in a json file within openmrs/apps/reports/reports.json. Please consult the documentation for more information on configuring canned reports", + "MESSAGE_DIALOG_OPTION_COPY": "Copy Error", "MESSAGE_DIALOG_OPTION_OKAY": "OK", "REPORTS_QUEUE": "Reports Queue", - "REPORTS_SEARCH_PLACEHOLDER" : "Search By Report Name", - "REPORT_STATUS" : "Status", - "REPORT_REQUEST_TIME" : "Request time", - "REPORT_DELETE_SUCCESSFUL" : "Successfully deleted report", - "REPORT_DELETE_ERROR" : "Error in deleting report", - "REPORT_DELETE_DIALOG" : "Do you want to delete the report?", - "REPORT_DOWNLOAD" : "Download", + "REPORTS_SEARCH_PLACEHOLDER": "Search By Report Name", + "REPORT_STATUS": "Status", + "REPORT_REQUEST_TIME": "Request time", + "REPORT_DELETE_SUCCESSFUL": "Successfully deleted report", + "REPORT_DELETE_ERROR": "Error in deleting report", + "REPORT_DELETE_DIALOG": "Do you want to delete the report?", + "REPORT_DOWNLOAD": "Download", "REPORT_ERROR": "Error", - "REPORT_DELETE" : "Delete", - "REPORTS_HEADER_REPORTS" : "Reports", - "REPORTS_HEADER_MY_REPORTS" : "My Reports", + "REPORT_DELETE": "Delete", + "REPORTS_HEADER_REPORTS": "Reports", + "REPORTS_HEADER_MY_REPORTS": "My Reports", "NO_RESULTS_FOUND": "No results found", "PRIVILEGE_REQUIRED": "User is logged in but doesn't have the relevant privilege", "NO_FULFILMENT_MESSAGE": "No observations captured for this order.", "NO_NAVIGATION_LINKS_AVAILABLE_MESSAGE": "No navigation links available.", "CHOOSE_REPORT_FORMAT": "Choose Format", - "ACCEPT":"Accept", + "ACCEPT": "Accept", "SELECT_VALUE_FROM_AUTOCOMPLETE_DEFAULT_MESSAGE": "Please select a value from auto complete", "CONCEPT_NOT_FOUND_MESSAGE": "concept not found.", "TIME_OF_BIRTH_LABEL": "Time of Birth", "PATIENT_PROFILE_RELATIONSHIPS_LABEL": "Relationships", - "BROWSER_DOES_NOT_SUPPORT_VIDEO_TAG_MESSAGE":"Your browser does not support the video tag.", + "BROWSER_DOES_NOT_SUPPORT_VIDEO_TAG_MESSAGE": "Your browser does not support the video tag.", "YEARS_LABEL": "Years", "CHOOSE_ANSWER_FROM_DROPDOWN_LABEL": "Choose Answer", "DELETE_LABEL": "Delete", "EDIT_LABEL": "Edit" -} +} \ No newline at end of file diff --git a/ui/app/i18n/reports/locale_fr.json b/ui/app/i18n/reports/locale_fr.json index c65ff16df4..ddf181349d 100644 --- a/ui/app/i18n/reports/locale_fr.json +++ b/ui/app/i18n/reports/locale_fr.json @@ -12,6 +12,7 @@ "RUN_REPORT_BUTTON_KEY": "Executer Rapport", "QUEUE_BUTTON_KEY": "Queue", "REPORT_FORMAT_KEY": "Format", + "REPORT_DATE_RANGE": "Select Date Range", "REPORTS_TITLE_KEY": "Rapports", "REPORTS_TITLE_WITHOUT_DATE_RANGE_KEY": "Rapport sans période", "REPORTS_MISSING_WARNING_MESSAGE_KEY": "Les nouveaux rapports peuvent être configurés dans un fichier json dans openmrs / apps / reports / reports.json. Veuillez consulter la documentation pour plus d'informations sur la configuration des rapports pré-construit.", diff --git a/ui/app/i18n/reports/locale_it.json b/ui/app/i18n/reports/locale_it.json index 8143c57f9f..091f9616a2 100644 --- a/ui/app/i18n/reports/locale_it.json +++ b/ui/app/i18n/reports/locale_it.json @@ -12,6 +12,7 @@ "RUN_REPORT_BUTTON_KEY": "Run Report", "QUEUE_BUTTON_KEY": "Queue", "REPORT_FORMAT_KEY": "Format", + "REPORT_DATE_RANGE": "Select Date Range", "REPORTS_TITLE_KEY": "Reports", "REPORTS_TITLE_WITHOUT_DATE_RANGE_KEY": "Reports without Date Range", "REPORTS_MISSING_WARNING_MESSAGE_KEY": "New reports can be configured in a json file within openmrs/apps/reports/reports.json. Please consult the documentation for more information on configuring canned reports", diff --git a/ui/app/ot/controller/calendarViewController.js b/ui/app/ot/controller/calendarViewController.js index 92d7ff0e32..2c4507f1ef 100644 --- a/ui/app/ot/controller/calendarViewController.js +++ b/ui/app/ot/controller/calendarViewController.js @@ -107,10 +107,10 @@ angular.module('bahmni.ot') }; $scope.isFilterApplied = function () { - return Object.keys($state.filterParams.locations).length != $scope.locations.length - || !_.isEmpty($state.filterParams.providers) - || !_.isEmpty($state.filterParams.patient) - || !_.isEmpty($state.filterParams.statusList); + return Object.keys($state.filterParams.locations).length != $scope.locations.length || + !_.isEmpty($state.filterParams.providers) || + !_.isEmpty($state.filterParams.patient) || + !_.isEmpty($state.filterParams.statusList); }; $scope.applyFilters = function () { diff --git a/ui/app/ot/controller/listViewController.js b/ui/app/ot/controller/listViewController.js index b2b66e8581..dcf323bd8b 100644 --- a/ui/app/ot/controller/listViewController.js +++ b/ui/app/ot/controller/listViewController.js @@ -41,8 +41,8 @@ angular.module('bahmni.ot') var attributeName = 'surgicalAppointmentAttributes.'.concat(attributeType.name, '.value'); return { heading: attributeType.name, - sortInfo: attributeType.format === Bahmni.OT.Constants.providerSurgicalAttributeFormat ? - attributeName.concat('.person.display') : attributeName + sortInfo: attributeType.format === Bahmni.OT.Constants.providerSurgicalAttributeFormat + ? attributeName.concat('.person.display') : attributeName }; }); } @@ -83,8 +83,8 @@ angular.module('bahmni.ot') var surgicalAppointmentEndDateTime = Bahmni.Common.Util.DateUtil.addMinutes(surgicalAppointmentStartDateTime, surgicalAppointment.derivedAttributes.duration); return surgicalAppointmentStartDateTime < endDatetime && surgicalAppointmentEndDateTime > startDatetime; } - return surgicalAppointment.derivedAttributes.expectedStartDate <= endDatetime - && surgicalAppointment.derivedAttributes.expectedStartDate >= startDatetime; + return surgicalAppointment.derivedAttributes.expectedStartDate <= endDatetime && + surgicalAppointment.derivedAttributes.expectedStartDate >= startDatetime; }); return surgicalBlock; }); diff --git a/ui/app/ot/controller/otCalendarController.js b/ui/app/ot/controller/otCalendarController.js index 84076d4658..0296063a2b 100644 --- a/ui/app/ot/controller/otCalendarController.js +++ b/ui/app/ot/controller/otCalendarController.js @@ -45,8 +45,8 @@ angular.module('bahmni.ot') }; $scope.isSurgicalBlockActiveOnGivenDate = function (surgicalBlock, weekDate) { - return Bahmni.Common.Util.DateUtil.isSameDate(moment(surgicalBlock.startDatetime).startOf('day').toDate(), weekDate) - || moment(surgicalBlock.endDatetime).toDate() > weekDate; + return Bahmni.Common.Util.DateUtil.isSameDate(moment(surgicalBlock.startDatetime).startOf('day').toDate(), weekDate) || + moment(surgicalBlock.endDatetime).toDate() > weekDate; }; $scope.intervals = function () { diff --git a/ui/app/ot/controller/surgicalAppointmentActualTimeController.js b/ui/app/ot/controller/surgicalAppointmentActualTimeController.js index f9bd8172b5..42eb6f79d8 100644 --- a/ui/app/ot/controller/surgicalAppointmentActualTimeController.js +++ b/ui/app/ot/controller/surgicalAppointmentActualTimeController.js @@ -23,8 +23,8 @@ angular.module('bahmni.ot').controller('surgicalAppointmentActualTimeController' var appointmentDuration = surgicalAppointmentHelper.getEstimatedDurationForAppointment(surgicalAppointment); $scope.actualStartTime = (surgicalAppointment.actualStartDatetime && moment(surgicalAppointment.actualStartDatetime).toDate()) || Bahmni.Common.Util.DateUtil.subtractSeconds(calculatedAppointmentEndTime, appointmentDuration * 60); - $scope.actualEndTime = (surgicalAppointment.actualEndDatetime && moment(surgicalAppointment.actualEndDatetime).toDate()) - || calculatedAppointmentEndTime; + $scope.actualEndTime = (surgicalAppointment.actualEndDatetime && moment(surgicalAppointment.actualEndDatetime).toDate()) || + calculatedAppointmentEndTime; $scope.notes = surgicalAppointment.notes; $scope.patientDisplayLabel = surgicalAppointmentHelper.getPatientDisplayLabel(surgicalAppointment.patient.display); }; diff --git a/ui/app/ot/controller/surgicalBlockController.js b/ui/app/ot/controller/surgicalBlockController.js index d73aeebaae..a2ef1a16c9 100644 --- a/ui/app/ot/controller/surgicalBlockController.js +++ b/ui/app/ot/controller/surgicalBlockController.js @@ -168,8 +168,7 @@ angular.module('bahmni.ot') return surgicalAppointment.sortWeight === appointment.sortWeight; }); $scope.surgicalForm.surgicalAppointments[appointmentIndex] = surgicalAppointment; - } - else { + } else { messagingService.showMessage('error', "{{'OT_SURGICAL_APPOINTMENT_EXCEEDS_BLOCK_DURATION' | translate}}"); } }; diff --git a/ui/app/ot/directives/otCalendarSurgicalBlock.js b/ui/app/ot/directives/otCalendarSurgicalBlock.js index 7d72a27382..3ba80943e8 100644 --- a/ui/app/ot/directives/otCalendarSurgicalBlock.js +++ b/ui/app/ot/directives/otCalendarSurgicalBlock.js @@ -106,9 +106,9 @@ angular.module('bahmni.ot') }; $scope.canShowInCalendarView = function (surgicalAppointment) { - return $scope.isValidSurgicalAppointment(surgicalAppointment) - && surgicalAppointment.derivedAttributes.expectedStartDatetime < getCalendarEndDateTime($scope.viewDate) - && surgicalAppointment.derivedAttributes.expectedEndDatetime > getCalendarStartDateTime($scope.viewDate); + return $scope.isValidSurgicalAppointment(surgicalAppointment) && + surgicalAppointment.derivedAttributes.expectedStartDatetime < getCalendarEndDateTime($scope.viewDate) && + surgicalAppointment.derivedAttributes.expectedEndDatetime > getCalendarStartDateTime($scope.viewDate); }; $scope.selectSurgicalBlock = function ($event) { diff --git a/ui/app/registration/controllers/createPatientController.js b/ui/app/registration/controllers/createPatientController.js index dda7cea1a1..df153c7f28 100644 --- a/ui/app/registration/controllers/createPatientController.js +++ b/ui/app/registration/controllers/createPatientController.js @@ -69,8 +69,7 @@ angular.module('bahmni.registration') var setDefaultValue = function (personAttributeType) { if (isDefaultValueToday(personAttributeType)) { $scope.patient[personAttributeType.name] = new Date(); - } - else { + } else { $scope.patient[personAttributeType.name] = ''; } }; @@ -88,7 +87,7 @@ angular.module('bahmni.registration') var notNullAttribute = _.find(section && section.attributes, function (attribute) { return $scope.patient[attribute.name] !== undefined; }); - section.expand = section.expanded || (notNullAttribute ? true : false); + section.expand = section.expanded || (!!notNullAttribute); }); }; diff --git a/ui/app/registration/controllers/editPatientController.js b/ui/app/registration/controllers/editPatientController.js index 8c91d32b3f..8ee66c0eb8 100644 --- a/ui/app/registration/controllers/editPatientController.js +++ b/ui/app/registration/controllers/editPatientController.js @@ -37,7 +37,7 @@ angular.module('bahmni.registration') var notNullAttribute = _.find(section && section.attributes, function (attribute) { return $scope.patient[attribute.name] !== undefined; }); - section.expand = section.expanded || (notNullAttribute ? true : false); + section.expand = section.expanded || (!!notNullAttribute); }); }; @@ -94,7 +94,7 @@ angular.module('bahmni.registration') }; $scope.isReadOnly = function (field) { - return $scope.readOnlyFields ? ($scope.readOnlyFields[field] ? true : false) : undefined; + return $scope.readOnlyFields ? (!!$scope.readOnlyFields[field]) : undefined; }; $scope.notifyOnWhatsAapp = function () { diff --git a/ui/app/registration/controllers/searchPatientController.js b/ui/app/registration/controllers/searchPatientController.js index 1b99e719f9..c765e81757 100644 --- a/ui/app/registration/controllers/searchPatientController.js +++ b/ui/app/registration/controllers/searchPatientController.js @@ -188,8 +188,8 @@ angular.module('bahmni.registration') if (_.isEmpty(patientSearchResultConfigs)) { resultsConfigNotFound = true; patientSearchResultConfigs.address = {"fields": allSearchConfigs.address ? [allSearchConfigs.address.field] : []}; - patientSearchResultConfigs.personAttributes - = {fields: allSearchConfigs.customAttributes ? allSearchConfigs.customAttributes.fields : {}}; + patientSearchResultConfigs.personAttributes = + {fields: allSearchConfigs.customAttributes ? allSearchConfigs.customAttributes.fields : {}}; } else { if (!patientSearchResultConfigs.address) patientSearchResultConfigs.address = {}; if (!patientSearchResultConfigs.personAttributes) patientSearchResultConfigs.personAttributes = {}; diff --git a/ui/app/reports/controllers/reportsController.js b/ui/app/reports/controllers/reportsController.js index a69f47d6a5..c59e943401 100644 --- a/ui/app/reports/controllers/reportsController.js +++ b/ui/app/reports/controllers/reportsController.js @@ -2,29 +2,54 @@ angular.module('bahmni.reports') .controller('ReportsController', ['$scope', 'appService', 'reportService', 'FileUploader', 'messagingService', 'spinner', '$rootScope', 'auditLogService', function ($scope, appService, reportService, FileUploader, messagingService, spinner, $rootScope, auditLogService) { + const format = _.values(reportService.getAvailableFormats()); + const dateRange = _.values(reportService.getAvailableDateRange()); + $scope.uploader = new FileUploader({ url: Bahmni.Common.Constants.uploadReportTemplateUrl, removeAfterUpload: true, autoUpload: true }); - $scope.uploader.onSuccessItem = function (fileItem, response) { fileItem.report.reportTemplateLocation = response; }; - $rootScope.default = _.isUndefined($rootScope.default) ? {reportsRequiringDateRange: {}, reportsNotRequiringDateRange: {}} : $rootScope.default; + $rootScope.default = _.isUndefined($rootScope.default) ? { + reportsRequiringDateRange: { + responseType: format[1], + dateRangeType: dateRange[0], + startDate: dateRange[0], + stopDate: dateRange[0], + report: { + responseType: format[1] + } + }, + reportsNotRequiringDateRange: {} + } : $rootScope.default; $scope.reportsDefined = true; $scope.enableReportQueue = appService.getAppDescriptor().getConfigValue("enableReportQueue"); - $scope.setDefault = function (item, header) { var setToChange = header === 'reportsRequiringDateRange' ? $rootScope.reportsRequiringDateRange : $rootScope.reportsNotRequiringDateRange; setToChange.forEach(function (report) { - report[item] = $rootScope.default[header][item]; + if (item == 'dateRangeType') { + $rootScope.default.reportsRequiringDateRange.startDate = $rootScope.default[header][item]; + $rootScope.default.reportsRequiringDateRange.stopDate = dateRange[0]; + report['startDate'] = $rootScope.default[header][item]; + report['stopDate'] = dateRange[0]; + } else if ($rootScope.default[header][item] === undefined) { + $rootScope.reportsRequiringDateRange.forEach(report => { + report.startDate = dateRange[0]; + report.stopDate = dateRange[0]; + report.responseType = format[1]; + }); + } else { + report[item] = $rootScope.default[header][item]; + } }); }; var isDateRangeRequiredFor = function (report) { - return _.find($rootScope.reportsRequiringDateRange, {name: report.name}); + return _.find($rootScope.reportsRequiringDateRange, { name: report.name }); }; var validateReport = function (report) { @@ -71,7 +96,7 @@ angular.module('bahmni.reports') }; var log = function (reportName) { - auditLogService.log(undefined, 'RUN_REPORT', {reportName: reportName}, "MODULE_LABEL_REPORTS_KEY"); + auditLogService.log(undefined, 'RUN_REPORT', { reportName: reportName }, "MODULE_LABEL_REPORTS_KEY"); }; $scope.scheduleReport = function (report) { @@ -97,6 +122,11 @@ angular.module('bahmni.reports') $scope.formats = _.pick(reportService.getAvailableFormats(), supportedFormats); }; + var initializeDateRange = function () { + var supportedDateRange = appService.getAppDescriptor().getConfigValue("supportedDateRange") || _.keys(reportService.getAvailableDateRange()); + $scope.dateRange = _.pick(reportService.getAvailableDateRange(), supportedDateRange); + }; + var initialization = function () { var reportList = appService.getAppDescriptor().getConfigForPage("reports"); $rootScope.reportsRequiringDateRange = _.isUndefined($rootScope.reportsRequiringDateRange) ? _.values(reportList).filter(function (report) { @@ -108,6 +138,7 @@ angular.module('bahmni.reports') $scope.reportsDefined = _.values(reportList).length > 0; initializeFormats(); + initializeDateRange(); }; initialization(); diff --git a/ui/app/reports/services/reportService.js b/ui/app/reports/services/reportService.js index 319c39b914..cba193841c 100644 --- a/ui/app/reports/services/reportService.js +++ b/ui/app/reports/services/reportService.js @@ -4,6 +4,7 @@ angular.module('bahmni.reports') .service('reportService', ['appService', '$bahmniCookieStore', '$http', function (appService, $bahmniCookieStore, $http) { var paperSize = appService.getAppDescriptor().getConfigValue("paperSize"); var appName = appService.getAppName() ? appService.getAppName() : "reports"; + let currentDate = new Date(); var availableFormats = { "CSV": "text/csv", "HTML": "text/html", @@ -12,6 +13,14 @@ angular.module('bahmni.reports') "CUSTOM EXCEL": "application/vnd.ms-excel-custom", "ODS": "application/vnd.oasis.opendocument.spreadsheet" }; + var avaialbleDateRange = { + "Today": currentDate, + "This Month": new Date(currentDate.getFullYear(), currentDate.getMonth(), 1), + "This Quater": new Date(currentDate.getFullYear(), Math.floor(currentDate.getMonth() / 3) * 3, 1), + "This Year": new Date(currentDate.getFullYear(), 0, 1), + "Previous Week": new Date(new Date().setDate(currentDate.getDate() - 6)), + "Previous Month": new Date(new Date().setDate(currentDate.getDate() - 30)) + }; var scheduleReport = function (report) { var url = Bahmni.Common.Constants.reportsUrl + "/schedule"; @@ -44,6 +53,9 @@ angular.module('bahmni.reports') } }); }; + var getAvailableDateRange = function () { + return avaialbleDateRange; + }; var deleteReport = function (id) { var url = Bahmni.Common.Constants.reportsUrl + "/delete/{0}"; url = url.format(id); @@ -63,6 +75,7 @@ angular.module('bahmni.reports') getFormatForMimeType: getFormatForMimeType, getMimeTypeForFormat: getMimeTypeForFormat, getAvailableFormats: getAvailableFormats, + getAvailableDateRange: getAvailableDateRange, scheduleReport: scheduleReport, getScheduledReports: getScheduledReports, deleteReport: deleteReport, diff --git a/ui/app/reports/views/reports.html b/ui/app/reports/views/reports.html index 87c27a620a..d74ec0e10c 100644 --- a/ui/app/reports/views/reports.html +++ b/ui/app/reports/views/reports.html @@ -5,12 +5,23 @@

{{::'REPORTS_TITLE_KEY' | translate}}

- + -
{{::'REPORTS_NAME_HEADER_KEY' | translate}} +
{{::'REPORTS_NAME_HEADER_KEY' | translate}}
+
+ {{::'REPORT_DATE_RANGE' | translate}} + * + +
+
{{::'REPORTS_START_DATE_HEADER_KEY ' |translate}} * + ng-change="setDefault('startDate', 'reportsRequiringDateRange')"> {{::'REPORTS_END_DATE_HEADER_KEY' |translate}} * @@ -18,13 +29,12 @@

{{::'REPORTS_TITLE_KEY' | translate}}

class="form-field start-date" type="date" min="{{default.reportsRequiringDateRange.startDate | date:'yyyy-MM-dd'}}" ng-change="setDefault('stopDate', 'reportsRequiringDateRange')">
- {{::'REPORT_FORMAT_KEY' | translate}} + {{::'REPORT_FORMAT_KEY' | translate}} * @@ -101,5 +111,4 @@

{{::'REPORTS_TITLE_WITHOUT_DATE_RANGE_KEY' | translate

- diff --git a/ui/app/styles/reports/_reports.scss b/ui/app/styles/reports/_reports.scss index 700a5a9586..70d53fcda2 100644 --- a/ui/app/styles/reports/_reports.scss +++ b/ui/app/styles/reports/_reports.scss @@ -3,91 +3,112 @@ @include clearfix(); margin-top: 10px; } - input[type="text"]{ - width:12.5em; + + input[type="text"] { + width: 12.5em; } + table { - th, td { + + th, + td { font-size: 14px; - box-sizing: border-box; + box-sizing: border-box; padding: 5px; vertical-align: top; text-align: left; - border-right:none; + border-right: none; } + thead th { font-size: 16px; border-bottom: 1px solid $lightGray; - input, select, button { + + input, + select, + button { font-size: 14px; } } + .reports-start-date, .reports-stop-date { width: 170px; } + .reports-format { width: 200px; } + .reports-action { width: 150px; - padding-right:0; + padding-right: 0; } - td.report-sort-date{ + + td.report-sort-date { padding: 10px 5px; color: #009384; border: none; - font-family:$primaryBoldFont; + font-family: $primaryBoldFont; } - td.reportStatus{ - &--Queued{ + + td.reportStatus { + &--Queued { color: rgba(255, 152, 0, 0.94); } - &--Processing{ + + &--Processing { color: #01BE24; } - &--link a{ + + &--link a { color: #0a5580; text-decoration: underline; } - &--error a{ + + &--error a { color: red; text-decoration: underline; } } - td button.delete-report{ + + td button.delete-report { font-size: 1.2em; padding: 0 !important; color: #666; line-height: 0; } + td button.run-report { font-size: 12px; padding: 5px 6px; } } - .input-file-upload.custom-file{ + + .input-file-upload.custom-file { width: 180px; padding: 0; margin-top: 3px; - border:none; + border: none; } } // implementation Specific Export Reports -a.button.small.report-download{ +a.button.small.report-download { padding: 8px 10px; - i{ - color:#666; + + i { + color: #666; } } .report.ngdialog.ngdialog-theme-default { - padding-top:200px; - .ngdialog-content{ - height:auto; + padding-top: 200px; + + .ngdialog-content { + height: auto; padding: 10px; } } \ No newline at end of file diff --git a/ui/test/unit/reports/controllers/reportsController.spec.js b/ui/test/unit/reports/controllers/reportsController.spec.js index c4122cdd30..0b828b4753 100644 --- a/ui/test/unit/reports/controllers/reportsController.spec.js +++ b/ui/test/unit/reports/controllers/reportsController.spec.js @@ -53,6 +53,10 @@ describe("ReportsController", function () { "CSV": "text/csv", "HTML": "text/html" }); + reportServiceMock.getAvailableDateRange.and.returnValue({ + "Today": new Date(), + "This Month": new Date(new Date().getFullYear(), new Date().getMonth(), 1) + }); controller = $controller; controller('ReportsController', { @@ -63,7 +67,7 @@ describe("ReportsController", function () { messagingService: messagingServiceMock, spinner: spinnerMock, $rootScope: rootScope, - FileUploader: function () {} + FileUploader: function () { } }); })); @@ -81,7 +85,7 @@ describe("ReportsController", function () { reportService: reportServiceMock, messagingService: messagingServiceMock, $rootScope: rootScope, - FileUploader: function () {} + FileUploader: function () { } }); expect(_.keys(scope.formats).length).toBe(2); @@ -89,6 +93,21 @@ describe("ReportsController", function () { expect(scope.formats['HTML']).toBe('text/html'); }); + it('should initialise formats with HTML', function () { + mockAppDescriptor.getConfigValue.and.returnValue(['html']); + controller('ReportsController', { + $scope: scope, + appService: appServiceMock, + reportService: reportServiceMock, + messagingService: messagingServiceMock, + $rootScope: rootScope, + FileUploader: function () { } + }); + + expect(_.keys(rootScope.default.reportsRequiringDateRange.responseType).length).toBe(1); + expect(rootScope.default.reportsRequiringDateRange.responseType['HTML']).toBe('text/html'); + }); + it('should initialise all available formats when supportedFormats config is not specified', function () { mockAppDescriptor.getConfigValue.and.returnValue(undefined); @@ -351,7 +370,7 @@ describe("ReportsController", function () { messagingService: messagingServiceMock, spinner: spinnerMock, $rootScope: rootScope, - FileUploader: function () {} + FileUploader: function () { } }); })); @@ -379,7 +398,7 @@ describe("ReportsController", function () { messagingService: messagingServiceMock, spinner: spinnerMock, $rootScope: rootScope, - FileUploader: function () {} + FileUploader: function () { } }); })); @@ -397,7 +416,7 @@ describe("ReportsController", function () { responseType: 'text/html' }); - var messageParams = {reportName: 'Vitals'}; + var messageParams = { reportName: 'Vitals' }; expect(mockAuditLogService.log).toHaveBeenCalledWith(undefined, 'RUN_REPORT', messageParams, 'MODULE_LABEL_REPORTS_KEY'); });