We should pass patient.uuid and section to the <test-patient/> directive to make patient details available to the view.
If you want the display control to be available in all the Bahmni modules then add all display control files in common folder (eg:ui/app/common/displaycontrols/dashboard/views/sections/). Otherwise add it in the specific module (eg: ui/app/<clinical>/dashboard/views/). Bahmni supports adding display controls in patient dashboard, Visit page, inpatient dashboard and programs dashboard.
Step 2:
Create the folder structure in the ui/app/common/displaycontrols/ path
Below is the code snippet for testPatient.js file
Expand source
'use strict';
angular.module('bahmni.common.displaycontrol.testPatient')
.directive('testPatient', ['patientService', 'spinner', '$sce', '$rootScope', '$stateParams', '$window', '$translate',
'configurations', '$q', 'visitService',
function (patientService, spinner, $sce, $rootScope, $stateParams, $window, $translate, configurations, $q) {
var controller = function ($scope) {
var assignPatientDetails = function () {
var patientMapper = new Bahmni.PatientMapper(configurations.patientConfig(), $rootScope, $translate);
return patientService.getPatient($scope.patientUuid).then(function (response) {
var openMrsPatient = response.data;
$scope.patient = patientMapper.map(openMrsPatient);
});
};
var initPromise = $q.all([assignPatientDetails()]);
$scope.initialization = initPromise;
};
var link = function ($scope, element) {
spinner.forPromise($scope.initialization, element);
};
return {
restrict: 'E',
controller: controller,
link: link,
scope: {
patientUuid: "@",
visitUuid: "@",
config: "="
},
templateUrl: "../common/displaycontrols/testPatient/views/testPatient.html"
};