UNPKG

bahmniapps-commons

Version:

Common Modules carved out from bahmniapps.

268 lines (233 loc) 14 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else { var a = factory(); for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; } })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 57); /******/ }) /************************************************************************/ /******/ ({ /***/ 12: /***/ (function(module, exports, __webpack_require__) { "use strict"; var Bahmni = Bahmni || {}; Bahmni.Common = Bahmni.Common || {}; Bahmni.Common.DisplayControl = Bahmni.Common.DisplayControl || {}; Bahmni.Common.DisplayControl.PatientProfile = Bahmni.Common.DisplayControl.PatientProfile || {}; angular.module('bahmni.common.displaycontrol.patientprofile', []); __webpack_require__(58); __webpack_require__(59); __webpack_require__(60); /***/ }), /***/ 57: /***/ (function(module, exports, __webpack_require__) { "use strict"; window.Bahmni = Bahmni || {}; Bahmni.Common = Bahmni.Common || {}; Bahmni.Common.DisplayControl = Bahmni.Common.DisplayControl || {}; angular.module('bahmni.common.displaycontrol', []); __webpack_require__(12); /***/ }), /***/ 58: /***/ (function(module, exports, __webpack_require__) { "use strict"; (function () { var getAddress = function ($scope) { var patient = $scope.patient; var address = []; if ($scope.config.addressFields != undefined && $scope.config.addressFields.length != 0) { $scope.config.addressFields.forEach(function (addressField) { if (patient.address[addressField]) { address.push(patient.address[addressField]); } }); } else if (!_.includes($scope.config, "cityVillage")) { address.push(patient.address["cityVillage"]); } return address.join(", "); }; var getPatientAttributeTypes = function ($scope) { var patient = $scope.patient; if ($scope.config.hasOwnProperty("ageLimit") && patient.age >= $scope.config.ageLimit) { patient.ageText = patient.age.toString() + " <span> years </span>"; } var patientAttributeTypes = [patient.genderText, patient.ageText]; if (patient.bloodGroupText) { patientAttributeTypes.push(patient.bloodGroupText); } return patientAttributeTypes.join(", "); }; var isAdmitted = function (admissionStatus) { return _.get(admissionStatus, 'value') === "Admitted"; }; angular.module('bahmni.common.displaycontrol.patientprofile').directive('patientProfile', ['patientService', 'spinner', '$sce', '$rootScope', '$stateParams', '$window', '$translate', 'configurations', '$q', 'visitService', function (patientService, spinner, $sce, $rootScope, $stateParams, $window, $translate, configurations, $q, visitService) { var controller = function ($scope) { $scope.isProviderRelationship = function (relationship) { return _.includes($rootScope.relationshipTypeMap.provider, relationship.relationshipType.aIsToB); }; $scope.openPatientDashboard = function (patientUuid) { var configName = $stateParams.configName || Bahmni.Common.Constants.defaultExtensionName; $window.open("../clinical/#/" + configName + "/patient/" + patientUuid + "/dashboard"); }; 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 assignRelationshipDetails = function () { return patientService.getRelationships($scope.patientUuid).then(function (response) { $scope.relationships = response.data.results; }); }; var assignAdmissionDetails = function () { var REP = "custom:(attributes:(value,attributeType:(display,name)))"; var ADMISSION_STATUS_ATTRIBUTE = "Admission Status"; return visitService.getVisit($scope.visitUuid, REP).then(function (response) { var attributes = response.data.attributes; var admissionStatus = _.find(attributes, { attributeType: { name: ADMISSION_STATUS_ATTRIBUTE } }); $scope.hasBeenAdmitted = isAdmitted(admissionStatus); }); }; var setHasBeenAdmittedOnVisitUuidChange = function () { $scope.$watch('visitUuid', function (visitUuid) { if (!_.isEmpty(visitUuid)) { assignAdmissionDetails(); } }); }; var setDirectiveAsReady = function () { $scope.isDirectiveReady = true; }; var onDirectiveReady = function () { $scope.addressLine = getAddress($scope); $scope.patientAttributeTypes = $sce.trustAsHtml(getPatientAttributeTypes($scope)); $scope.showBirthDate = $scope.config.showDOB !== false; $scope.showBirthDate = $scope.showBirthDate && !!$scope.patient.birthdate; }; var initPromise = $q.all([assignPatientDetails(), assignRelationshipDetails()]); initPromise.then(onDirectiveReady); initPromise.then(setHasBeenAdmittedOnVisitUuidChange); initPromise.then(setDirectiveAsReady); $scope.initialization = initPromise; }; var link = function ($scope, element) { spinner.forPromise($scope.initialization, element); }; return { restrict: 'E', controller: controller, link: link, scope: { patientUuid: "@", visitUuid: "@", config: "=" }, template: __webpack_require__(63) }; }]); })(); /***/ }), /***/ 59: /***/ (function(module, exports, __webpack_require__) { "use strict"; angular.module('bahmni.common.displaycontrol.patientprofile').filter('booleanFilter', function () { return function (value) { if (value === true) { return "Yes"; } else if (value === false) { return "No"; } return value; }; }); /***/ }), /***/ 60: /***/ (function(module, exports, __webpack_require__) { "use strict"; angular.module('bahmni.common.displaycontrol.patientprofile').filter('titleCase', function () { return function (input) { input = input || ''; return input.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); }; }); /***/ }), /***/ 63: /***/ (function(module, exports) { module.exports = "<div>\n <div class=\"dashboard-patientInformation-section\" id=\"patient_information\" ng-if=\"::isDirectiveReady\">\n <section bindonce=\"patient\" class=\"block patientInformation dashboard-section\" ng-class=\"::{'more': patientSummary.show}\">\n <table class=\"patient dashboard-table\">\n <tbody>\n <tr class=\"patient-info\">\n <td colspan=\"2\">\n <span class=\"patient-img\">\n <img class=\"patient-image\" ng-src=\"{{::patient.image}}\" fallback-src=\"../images/blank-user.gif\">\n </span>\n <div class=\"patient-value\">\n <span class=\"patient-name\">\n {{::patient.name | titleCase}} ({{::patient.identifier}})</span> -\n <span class=\"patient-gender-age\" ng-bind-html=\"::patientAttributeTypes\"></span>\n <span class=\"patient-estimated-text\" ng-if=\"::patient.birthdateEstimated\"> (est.)</span>\n <span class=\"patient-birth-time\" ng-show=\"::patient.birthtime\">\n <span>{{ 'TIME_OF_BIRTH_LABEL'|translate }}</span>\n <span ng-bind-html=\"::patient.birthtime | date:'hh:mm a'\"></span>\n </span>\n <span class=\"patient-address\">\n {{::addressLine}}\n </span>\n <i class=\"ipd-indication fa fa-bed\" ng-if=\"::hasBeenAdmitted\"></i>\n </div>\n </td>\n </tr>\n <tr ng-if=\"::showBirthDate\" >\n <td class=\"name\">{{ 'DOB_LABEL' | translate }}</td>\n <td class=\"value\">{{::patient.birthdate | bahmniDate}}\n <span ng-if=\"::patient.birthdateEstimated\" class=\"patient-estimated-text\"> (est.)</span>\n </td>\n </tr>\n <tr ng-repeat=\"attribute in config.patientAttributes\" ng-if=\"::patient[attribute]\"\n ng-show=\"::config.patientAttributes.length\" ng-class=\"attribute\">\n <td class=\"name\">{{::patient[attribute].label}}</td>\n <td class=\"value\" ng-if=\"::!patient[attribute].isDateField\">{{::(patient[attribute].value.display || patient[attribute].value) | booleanFilter}}</td>\n <td class=\"value\" ng-if=\"::patient[attribute].isDateField\">{{::patient[attribute].value | bahmniDate}}</td>\n </tr>\n <tr ng-if=\"::relationships && relationships.length > 0\">\n <td>{{ 'PATIENT_PROFILE_RELATIONSHIPS_LABEL'|translate }}</td>\n </tr>\n <tr ng-repeat=\"relationship in relationships track by relationship.uuid\">\n <td class=\"name relationshipType\" ng-if=\"::relationship.personA.uuid === patient.uuid\">{{::relationship.relationshipType.aIsToB}}</td>\n <td class=\"value\" ng-if=\"::relationship.personA.uuid === patient.uuid\">\n <a ng-click=\"::openPatientDashboard(relationship.personB.uuid)\"\n title=\"Go to Clinical Dashboard\" ng-if=\"::!isProviderRelationship(relationship)\">\n {{::relationship.personB.display}}\n </a>\n <span ng-if=\"::isProviderRelationship(relationship)\">{{::relationship.personB.display}}</span>\n </td>\n <td class=\"name\" ng-if=\"::relationship.personB.uuid === patient.uuid\">{{::relationship.relationshipType.bIsToA}}</td>\n <td ng-if=\"::relationship.personB.uuid === patient.uuid\" class=\"value\">\n <a ng-click=\"::openPatientDashboard(relationship.personA.uuid)\"\n title=\"Go to Clinical Dashboard\">\n {{::relationship.personA.display}}\n </a>\n </td>\n </tr>\n </tbody>\n </table>\n </section>\n </div>\n</div>"; /***/ }) /******/ }); });