Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Purpose

Display controls are widgets that can be added to various pages to better configure them. They can be customized to show specific information and will automatically align to the context of the screen. For example, a Treatment Display Control on the Patient Dashboard may show all treatments for a patient, but will limit treatments for a single visit when used on the Visit page. 

Configuration

Common Configuration

Code Block
languagejs
titleCommon Configuration
linenumberstrue
"sectionName": { //Should be a unique name
    "translationKey": "Internationalization key or Title", //Title of the display control
    "displayType": "Full-Page | Half-Page", //Default is Half-Page
    "displayOrder": 0 // All display controls are show in the order mentioned here
    "showOnlyInPrint": true/false //Show this display control only when printing. Default false.
}


List of Display Controls

Panel
titleColorWhite
titleBGColor#F17D50
titleBahmni Display Controls
Child pages (Children Display)
alltrue
styleh3
sorttitle
excerptTypesimple

Custom Display Control

Bahmni allows implementers to create their own custom display control.

Custom Control on Visit Dashboard

The following configuration needs to be added in visit.json (openmrs/apps/clinical/visit.json) to display the custom display control in different visit tabs.

Consider the following example to configure the birth certificate:

Code Block
languagejs
linenumberstrue
"birthCertificate": {
    "title": "Birth Certificate",
    "printing": {
        "title": "Bahmni",
        "header": "Certificate",
        "logo": "../images/bahmniLogo.png"
    },
    "sections": {
        "Birth Certificate": {
            "type": "custom",
            "config": {
                "title": "Birth Certificate",
                "template": "<birth-certificate></birth-certificate>"
            }
        }
    }
}
KeyInformationtitleTitle of the visit tab.Y

printing

Add printing section to enable the print button on visit page.Ytitle - Title in print out.header - Header in print out.logo - Logo to display in print out.type"custom" (Required and should always be custom)Yconfigconfiguration for the custom display control.

title - title of the custom directive

Ytemplate - the directive which you want to show.Y

Custom control on Patient Dashboard

The following configuration needs to be added under sections in dashboard.json (openmrs/apps/clinical/dashboard.json) to display the custom display control in different dashboard tabs.

Consider the following example to configure the birth certificate:

Code Block
languagejs
linenumberstrue
"General": {
    "translationKey": "DASHBOARD_TAB_GENERAL_KEY",
    "sections": {
        "Birth Certificate": {
            "name": "custom",
            "config": {
                "title": "Birth Certificate",
                "template": "<birth-certificate></birth-certificate>"
            }
        }
    }
}
KeyInformationMandatoryname*"custom" (Required and should always be custom)Yconfig

configuration for the custom display control.

keyInformationtitletitle of the custom directiveYtemplatethe directive which you want to showY

Bahmni provides customDisplayControl module which provides basic connection between the application and configuration.

You can add new directives as per your requirement in the "openmrs/apps/customDisplayControl/js/customControl.js" file. (Make sure you can create new custom directives only in the existing file)

New directives should be under the same module. ("bahmni.common.displaycontrol.custom"). The scope of the new directive will have patient, visitUuid and config.

Consider the following example to add a birthCertificate as a new directive:

Code Block
languagejs
linenumberstrue
'use strict';
angular.module('bahmni.common.displaycontrol.custom')
    .directive('birthCertificate', ['observationsService', 'appService', 'spinner', function (observationsService, appService, spinner) {
            var link = function ($scope,element) {
                var conceptNames = ["HEIGHT"];
                $scope.contentUrl = appService.configBaseUrl() + "/customDisplayControl/views/birthCertificate.html";
                spinner.forPromise(observationsService.fetch($scope.patient.uuid, conceptNames, "latest", undefined, $scope.visitUuid, undefined).then(function (response) {
                    $scope.observations = response.data;
                }), element);
            };
            return {
                restrict: 'E',
                template: '<ng-include src="contentUrl"/>',
                link: link
            }
    }])

In the above example, the concept names we want to fetch is configured in the variable conceptNames.

To display spinner for each display control while loading, element should be passed in spinner.forPromise() as shown in above example.

You can create your own template in the directive "openmrs/apps/customDisplayControl/views/"

Consider the following example to create a birthCertificate.html:

Code Block
languagexml
linenumberstrue
<div>
    {{config.title}}
    <section class="dashboard-section">
        <ul class="form-field">
            <li ng-repeat="obsGroup in observations">
                <span class="obs-date"> {{obsGroup.conceptNameToDisplay }} </span>
                <span class="obs-date"> {{obsGroup.value}} </span>
            </li>
        </ul>
    </section>
</div>
Note

1. Make sure you don't create a different file for new directives (all custom directives should be in the same file.)
2. Don't forget to change the contentUrl to the html file you are referring to.

Tip
titleOn this Page

Table of Contents
maxLevel2