Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions openmrs/apps/customDisplayControl/js/customControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ angular.module('bahmni.common.displaycontrol.custom')
link: link,
template: '<ng-include src="contentUrl"/>'
}
}]).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 = [
Expand All @@ -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) {
Expand All @@ -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';
Expand Down