diff --git a/ui/app/clinical/common/services/treatmentService.js b/ui/app/clinical/common/services/treatmentService.js
index 9659b36d95..ce627660d4 100644
--- a/ui/app/clinical/common/services/treatmentService.js
+++ b/ui/app/clinical/common/services/treatmentService.js
@@ -177,18 +177,18 @@ angular.module('bahmni.clinical')
});
};
- var getOrderedProviderAttributesForPrint = function (providerAttributeData) {
- const providerAttributeTypesToFilter = appService.getAppDescriptor().getConfigValue("providerAttributesForPrint") || [];
- var filteredProviderAttributes = providerAttributeData.filter(function (attribute) {
- return providerAttributeTypesToFilter.includes(attribute.attributeType.display);
+ var getProviderAttributesForPrint = function (attributeData, attributeTypesToFilter) {
+ if (!attributeTypesToFilter) return;
+ var filteredAttributes = attributeData.filter(function (attribute) {
+ return attributeTypesToFilter.includes(attribute.attributeType.display);
});
- filteredProviderAttributes.sort(function (a, b) {
- return providerAttributeTypesToFilter.indexOf(a.attributeType.display) - providerAttributeTypesToFilter.indexOf(b.attributeType.display);
+ filteredAttributes.sort(function (a, b) {
+ return attributeTypesToFilter.indexOf(a.attributeType.display) - attributeTypesToFilter.indexOf(b.attributeType.display);
});
- return filteredProviderAttributes;
+ return filteredAttributes;
};
- var printSelectedPrescriptions = function (drugOrdersForPrint, patient, additionalInfo, diagnosesCodes) {
+ var printSelectedPrescriptions = function (printPrescriptionFeatureConfig, drugOrdersForPrint, patient, additionalInfo, diagnosesCodes, dispenserInfo, observationsEntries) {
if (drugOrdersForPrint.length > 0) {
var encounterDrugOrderMap = Object.values(drugOrdersForPrint.reduce(function (orderMap, item) {
const providerUuid = item.provider.uuid;
@@ -202,10 +202,14 @@ angular.module('bahmni.clinical')
return orderMap;
}, {}));
- var printParams = appService.getAppDescriptor().getConfigValue("prescriptionPrint") || {};
- var templateUrl = appService.getAppDescriptor().getConfigValue("prescriptionPrintTemplateUrl") || '../common/displaycontrols/prescription/views/prescription.html';
+ var printParams = {
+ title: printPrescriptionFeatureConfig.title || "",
+ header: printPrescriptionFeatureConfig.header || "",
+ logo: printPrescriptionFeatureConfig.logo || ""
+ };
+ var templateUrl = printPrescriptionFeatureConfig.templateUrl || '../common/displaycontrols/prescription/views/prescription.html';
var fileName = patient.givenName + patient.familyName + "_" + patient.identifier + "_Prescription";
- printer.print(templateUrl, { patient: patient, encounterDrugOrderMap: encounterDrugOrderMap, printParams: printParams, additionalInfo: additionalInfo, diagnosesCodes: diagnosesCodes }, fileName);
+ printer.print(templateUrl, { patient: patient, encounterDrugOrderMap: encounterDrugOrderMap, printParams: printParams, additionalInfo: additionalInfo, diagnosesCodes: diagnosesCodes, dispenserInfo: dispenserInfo, observationsEntries: observationsEntries }, fileName);
}
};
@@ -220,6 +224,6 @@ angular.module('bahmni.clinical')
voidDrugOrder: voidDrugOrder,
sharePrescriptions: sharePrescriptions,
printSelectedPrescriptions: printSelectedPrescriptions,
- getOrderedProviderAttributesForPrint: getOrderedProviderAttributesForPrint
+ getProviderAttributesForPrint: getProviderAttributesForPrint
};
}]);
diff --git a/ui/app/clinical/consultation/controllers/drugOrderHistoryController.js b/ui/app/clinical/consultation/controllers/drugOrderHistoryController.js
index 58f1e871fc..874d82d830 100644
--- a/ui/app/clinical/consultation/controllers/drugOrderHistoryController.js
+++ b/ui/app/clinical/consultation/controllers/drugOrderHistoryController.js
@@ -1,9 +1,9 @@
'use strict';
angular.module('bahmni.clinical')
- .controller('DrugOrderHistoryController', ['$scope', '$filter', '$stateParams', 'activeDrugOrders', 'appService',
+ .controller('DrugOrderHistoryController', ['$q', '$scope', '$filter', '$stateParams', 'activeDrugOrders', 'appService',
'treatmentConfig', 'treatmentService', 'spinner', 'drugOrderHistoryHelper', 'visitHistory', '$translate', '$rootScope', 'providerService', 'observationsService', 'diagnosisService',
- function ($scope, $filter, $stateParams, activeDrugOrders, appService, treatmentConfig, treatmentService, spinner,
+ function ($q, $scope, $filter, $stateParams, activeDrugOrders, appService, treatmentConfig, treatmentService, spinner,
drugOrderHistoryHelper, visitHistory, $translate, $rootScope, providerService, observationsService, diagnosisService) {
var DrugOrderViewModel = Bahmni.Clinical.DrugOrderViewModel;
var DateUtil = Bahmni.Common.Util.DateUtil;
@@ -13,7 +13,7 @@ angular.module('bahmni.clinical')
$scope.dispensePrivilege = Bahmni.Clinical.Constants.dispensePrivilege;
$scope.scheduledDate = DateUtil.getDateWithoutTime(DateUtil.addDays(DateUtil.now(), 1));
$scope.enableIPDFeature = appService.getAppDescriptor().getConfigValue("enableIPDFeature");
- $scope.enablePrintSelectedDrugs = appService.getAppDescriptor().getConfigValue("enablePrintSelectedDrugs");
+ $scope.printPrescriptionFeature = appService.getAppDescriptor().getConfigValue("printPrescriptionFeature");
$scope.selectedDrugs = {};
if ($scope.enableIPDFeature) {
@@ -93,6 +93,8 @@ angular.module('bahmni.clinical')
var drugOrdersForPrint = [];
var promises = [];
var diagnosesCodes = "";
+ var dispenserInfo = [];
+ var observationsEntries = [];
angular.forEach($scope.selectedDrugs, function (selected, drugOrderIndex) {
var selectedDrugOrder = drugOrderIndex.split("/");
@@ -106,7 +108,7 @@ angular.module('bahmni.clinical')
promises.push(promise);
promise.then(function (response) {
- drugOrder.provider.attributes = treatmentService.getOrderedProviderAttributesForPrint(response.data.results);
+ drugOrder.provider.attributes = treatmentService.getProviderAttributesForPrint(response.data.results, $scope.printPrescriptionFeature.providerAttributesForPrint);
}).catch(function (error) {
console.error("Error fetching provider attributes: ", error);
});
@@ -115,32 +117,29 @@ angular.module('bahmni.clinical')
}
});
- var diagnosesPromise = diagnosisService.getPatientDiagnosis($stateParams.patientUuid);
- promises.push(diagnosesPromise);
-
- diagnosesPromise.then(function (response) {
- var diagnoses = response.data;
- console.log(diagnoses);
+ var promise = $q.all([diagnosisService.getPatientDiagnosis($stateParams.patientUuid), providerService.getAttributesForProvider($rootScope.currentProvider.uuid), observationsService.fetch($stateParams.patientUuid, $scope.printPrescriptionFeature.observationsConcepts, "latest", null, null, null, null, null)]).then(function (response) {
+ const diagnoses = response[0].data;
+ const dispenserAttributes = response[1].data.results;
+ observationsEntries = response[2].data;
+ dispenserInfo = treatmentService.getProviderAttributesForPrint(dispenserAttributes, $scope.printPrescriptionFeature.providerAttributesForPrint);
angular.forEach(diagnoses, function (diagnosis) {
- console.log("g = ", diagnosis);
- if (diagnosis.order === "PRIMARY" && diagnosis.certainty === "CONFIRMED") {
+ if (diagnosis.order === $scope.printPrescriptionFeature.printDiagnosis.order &&
+ diagnosis.certainty === $scope.printPrescriptionFeature.printDiagnosis.certainity) {
if (diagnosesCodes.length > 0) {
diagnosesCodes += ", ";
}
diagnosesCodes += diagnosis.codedAnswer.mappings[0].code;
}
});
- }).catch(function (error) {
- console.error("Error fetching diagnosis: ", error);
});
+ promises.push(promise);
Promise.all(promises).then(function () {
var additionalInfo = {};
additionalInfo.visitType = currentVisit ? currentVisit.visitType.display : "";
additionalInfo.currentDate = new Date();
additionalInfo.facilityLocation = $rootScope.facilityLocation;
- treatmentService.printSelectedPrescriptions(drugOrdersForPrint, $scope.patient, additionalInfo, diagnosesCodes);
- console.log(diagnosesCodes);
+ treatmentService.printSelectedPrescriptions($scope.printPrescriptionFeature, drugOrdersForPrint, $scope.patient, additionalInfo, diagnosesCodes, dispenserInfo, observationsEntries);
$scope.selectedDrugs = {};
}).catch(function (error) {
console.error("Error fetching details for print: ", error);
diff --git a/ui/app/clinical/consultation/views/treatmentSections/drugOrderHistory.html b/ui/app/clinical/consultation/views/treatmentSections/drugOrderHistory.html
index d7038b2c98..dc16bdf971 100644
--- a/ui/app/clinical/consultation/views/treatmentSections/drugOrderHistory.html
+++ b/ui/app/clinical/consultation/views/treatmentSections/drugOrderHistory.html
@@ -10,7 +10,7 @@
{{drugOrderGroup.label | bahmniDate}}
-
+