From 662da7f98cc4a7924f5d4446afc6c1b41f77050f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CBlackjuiceplug=E2=80=9D?= <“blackjuicefx@gmail.com”> Date: Thu, 17 Jul 2025 09:46:44 +0200 Subject: [PATCH] Fix: customTreatmentChart directive rendering bug and corrected casing of treatmentService --- openmrs/apps/customDisplayControl/js/customControl.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/openmrs/apps/customDisplayControl/js/customControl.js b/openmrs/apps/customDisplayControl/js/customControl.js index f1bc152ef..3d804eaf5 100644 --- a/openmrs/apps/customDisplayControl/js/customControl.js +++ b/openmrs/apps/customDisplayControl/js/customControl.js @@ -30,7 +30,7 @@ angular.module('bahmni.common.displaycontrol.custom') link: link, template: '' } - }]).directive('customTreatmentChart', ['appService', 'treatmentConfig', 'TreatmentService', 'spinner', '$q', function (appService, treatmentConfig, treatmentService, spinner, $q) { + }]).directive('customTreatmentChart', ['appService', 'treatmentConfig', 'treatmentService', 'spinner', '$q', function (appService, treatmentConfig, treatmentService, spinner, $q) { var link = function ($scope) { var Constants = Bahmni.Clinical.Constants; var days = [ @@ -41,7 +41,9 @@ angular.module('bahmni.common.displaycontrol.custom') 'Thursday', 'Friday', 'Saturday' - ]; + ];// Corrected function name from `TreatmentService to `treatmentService` + // This was preventing the chart from rendering correctly + $scope.contentUrl = appService.configBaseUrl() + "/customDisplayControl/views/customTreatmentChart.html"; $scope.atLeastOneDrugForDay = function (day) { @@ -60,7 +62,10 @@ angular.module('bahmni.common.displaycontrol.custom') $scope.getStatusOnDate = function (drug, date) { var activeDrugOrders = _.filter(drug.orders, function (order) { - if ($scope.config.frequenciesToBeHandled.indexOf(order.getFrequency()) !== -1) { + + // Ensure 'frequenciesToBeHandled' is defined to avoid indexOf error + // This fixes a bug that was preventing the customTreatmentChart from rendering correctly + if (($scope.config.frequenciesToBeHandled || []).indexOf(order.getFrequency()) !== -1) { return getStatusBasedOnFrequency(order, date); } else { return drug.getStatusOnDate(date) === 'active';