9 lines
258 KiB
JavaScript
9 lines
258 KiB
JavaScript
![]() |
"use strict";angular.module("bahmni.common.routeErrorHandler",["ui.router"]).run(["$rootScope",function($rootScope){$rootScope.$on("$stateChangeError",function(event){event.preventDefault()})}]),angular.module("httpErrorInterceptor",[]).config(["$httpProvider",function($httpProvider){var interceptor=["$rootScope","$q",function($rootScope,$q){function stringAfter(value,searchString){var indexOfFirstColon=value.indexOf(searchString);return value.substr(indexOfFirstColon+1).trim()}function getServerError(message){return stringAfter(message,":")}function success(response){return response}function shouldRedirectToLogin(response){var errorMessage=response.data.error?response.data.error.message:response.data;if(errorMessage.search("HTTP Status 403 - Session timed out")>0)return!0}function error(response){var data=response.data,unexpectedError="There was an unexpected issue on the server. Please try again";if(500===response.status){var errorMessage=data.error&&data.error.message?getServerError(data.error.message):unexpectedError;showError(errorMessage)}else if(409===response.status){var errorMessage=data.error&&data.error.message?getServerError(data.error.message):"Duplicate entry error";showError(errorMessage)}else if(0===response.status)showError("Could not connect to the server. Please check your connection and try again");else if(405===response.status)showError(unexpectedError);else if(400===response.status){var errorMessage=data.error&&data.error.message?data.error.message:data.localizedMessage||"Could not connect to the server. Please check your connection and try again";showError(errorMessage)}else if(403===response.status){var errorMessage=data.error&&data.error.message?data.error.message:unexpectedError;shouldRedirectToLogin(response)?$rootScope.$broadcast("event:auth-loginRequired"):showError(errorMessage)}else 404===response.status&&(_.includes(response.config.url,"implementation_config")||_.includes(response.config.url,"locale_")||_.includes(response.config.url,"offlineMetadata")||showError("The requested information does not exist"));return $q.reject(response)}var serverErrorMessages=Bahmni.Common.Constants.serverErrorMessages,showError=function(errorMessage){var result=_.find(serverErrorMessages,function(listItem){return listItem.serverMessage===errorMessage});_.isEmpty(result)&&$rootScope.$broadcast("event:serverError",errorMessage)};return{response:success,responseError:error}}];$httpProvider.interceptors.push(interceptor)}]);var Bahmni=Bahmni||{};Bahmni.Auth=Bahmni.Auth||{},angular.module("authentication",["ui.router"]),Bahmni.Auth.User=function(user){angular.extend(this,user),this.userProperties=user.userProperties||{},this.favouriteObsTemplates=this.userProperties.favouriteObsTemplates?this.userProperties.favouriteObsTemplates.split("###"):[],this.favouriteWards=this.userProperties.favouriteWards?this.userProperties.favouriteWards.split("###"):[],this.recentlyViewedPatients=this.userProperties.recentlyViewedPatients?JSON.parse(this.userProperties.recentlyViewedPatients):[],this.toContract=function(){var user=angular.copy(this);return user.userProperties.favouriteObsTemplates=this.favouriteObsTemplates.join("###"),user.userProperties.favouriteWards=this.favouriteWards.join("###"),user.userProperties.recentlyViewedPatients=JSON.stringify(this.recentlyViewedPatients),delete user.favouriteObsTemplates,delete user.favouriteWards,delete user.recentlyViewedPatients,user},this.addDefaultLocale=function(locale){this.userProperties.defaultLocale=locale},this.addToRecentlyViewed=function(patient,maxPatients){_.some(this.recentlyViewedPatients,{uuid:patient.uuid})||(this.recentlyViewedPatients.unshift({uuid:patient.uuid,name:patient.name,identifier:patient.identifier}),_.size(this.recentlyViewedPatients)>=maxPatients&&(this.recentlyViewedPatients=_.take(this.recentlyViewedPatients,maxPatients)))},this.isFavouriteObsTemplate=function(conceptName){return _.includes(this.favouriteObsTemplates,conceptName)},this.toggleFavoriteObsTemplate=function(conceptName){this.isFavouriteObsTemplate(conceptName)?this.favouriteObsTemplate
|
||
|
"/openmrs/ws/rest/v1/bahmnicore/sql/globalproperty?property=bahmni.encounterType.default":"DefaultEncounterType","/openmrs/ws/rest/v1/concept?s=byFullySpecifiedName&name=Stopped+Order+Reason&v=custom:(uuid,name,answers)":"StoppedOrderReasonConfig","/openmrs/ws/rest/v1/ordertype":"OrderType","/openmrs/ws/rest/v1/bahmnicore/config/drugOrders":"DrugOrderConfig","/openmrs/ws/rest/v1/bahmnicore/sql/globalproperty?property=drugOrder.drugOther":"NonCodedDrugConcept"};authenticatedReferenceDataMap["/openmrs/ws/rest/v1/entitymapping?mappingType=location_encountertype&s=byEntityAndMappingType&entityUuid="+(localStorage.getItem("LoginInformation")?JSON.parse(localStorage.getItem("LoginInformation")).currentLocation.uuid:"")]="LoginLocationToEncounterTypeMapping",Bahmni.Common.Constants={hostURL:hostUrl,dateFormat:"dd/mm/yyyy",dateDisplayFormat:"DD-MMM-YYYY",timeDisplayFormat:"hh:mm",emrapiDiagnosisUrl:EMRAPI+"/diagnosis",bahmniDiagnosisUrl:BAHMNI_CORE+"/diagnosis/search",bahmniDeleteDiagnosisUrl:BAHMNI_CORE+"/diagnosis/delete",diseaseTemplateUrl:BAHMNI_CORE+"/diseaseTemplates",AllDiseaseTemplateUrl:BAHMNI_CORE+"/diseaseTemplate",emrapiConceptUrl:EMRAPI+"/concept",encounterConfigurationUrl:BAHMNI_CORE+"/config/bahmniencounter",patientConfigurationUrl:BAHMNI_CORE+"/config/patient",drugOrderConfigurationUrl:BAHMNI_CORE+"/config/drugOrders",emrEncounterUrl:EMRAPI+"/encounter",encounterUrl:RESTWS_V1+"/encounter",locationUrl:RESTWS_V1+"/location",bahmniVisitLocationUrl:BAHMNI_CORE+"/visitLocation",bahmniOrderUrl:BAHMNI_CORE+"/orders",bahmniDrugOrderUrl:BAHMNI_CORE+"/drugOrders",bahmniDispositionByVisitUrl:BAHMNI_CORE+"/disposition/visit",bahmniDispositionByPatientUrl:BAHMNI_CORE+"/disposition/patient",bahmniSearchUrl:BAHMNI_CORE+"/search",bahmniLabOrderResultsUrl:BAHMNI_CORE+"/labOrderResults",bahmniEncounterUrl:BAHMNI_CORE+"/bahmniencounter",conceptUrl:RESTWS_V1+"/concept",bahmniConceptAnswerUrl:RESTWS_V1+"/bahmniconceptanswer",conceptSearchByFullNameUrl:RESTWS_V1+"/concept?s=byFullySpecifiedName",visitUrl:RESTWS_V1+"/visit",endVisitUrl:BAHMNI_CORE+"/visit/endVisit",endVisitAndCreateEncounterUrl:BAHMNI_CORE+"/visit/endVisitAndCreateEncounter",visitTypeUrl:RESTWS_V1+"/visittype",patientImageUrlByPatientUuid:RESTWS_V1+"/patientImage?patientUuid=",labResultUploadedFileNameUrl:"/uploaded_results/",visitSummaryUrl:BAHMNI_CORE+"/visit/summary",encounterModifierUrl:BAHMNI_CORE+"/bahmniencountermodifier",openmrsUrl:hostUrl+"/openmrs",loggingUrl:hostUrl+"/log/",idgenConfigurationURL:RESTWS_V1+"/idgen/identifiertype",bahmniRESTBaseURL:BAHMNI_CORE+"",observationsUrl:BAHMNI_CORE+"/observations",obsRelationshipUrl:BAHMNI_CORE+"/obsrelationships",encounterImportUrl:BAHMNI_CORE+"/admin/upload/encounter",programImportUrl:BAHMNI_CORE+"/admin/upload/program",conceptImportUrl:BAHMNI_CORE+"/admin/upload/concept",conceptSetImportUrl:BAHMNI_CORE+"/admin/upload/conceptset",drugImportUrl:BAHMNI_CORE+"/admin/upload/drug",labResultsImportUrl:BAHMNI_CORE+"/admin/upload/labResults",referenceTermsImportUrl:BAHMNI_CORE+"/admin/upload/referenceterms",relationshipImportUrl:BAHMNI_CORE+"/admin/upload/relationship",conceptSetExportUrl:BAHMNI_CORE+"/admin/export/conceptset?conceptName=:conceptName",patientImportUrl:BAHMNI_CORE+"/admin/upload/patient",adminImportStatusUrl:BAHMNI_CORE+"/admin/upload/status",programUrl:RESTWS_V1+"/program",programEnrollPatientUrl:RESTWS_V1+"/bahmniprogramenrollment",programStateDeletionUrl:RESTWS_V1+"/programenrollment",programEnrollmentDefaultInformation:"default",programEnrollmentFullInformation:"full",programAttributeTypes:RESTWS_V1+"/programattributetype",relationshipTypesUrl:RESTWS_V1+"/relationshiptype",personAttributeTypeUrl:RESTWS_V1+"/personattributetype",diseaseSummaryPivotUrl:BAHMNI_CORE+"/diseaseSummaryData",allTestsAndPanelsConceptName:"All_Tests_and_Panels",dosageFrequencyConceptName:"Dosage Frequency",dosageInstructionConceptName:"Dosage Instructions",stoppedOrderReasonConceptName:"Stopped Order Reason",consultationNoteConceptName:"Consultation Note",diagnosisConceptSet:"Diagnosis Concept Set",radiologyOrderType:"Radiology O
|
||
|
}).then(mapBedDetails)},this.assignBed=function(bedId,patientUuid,encounterUuid){var patientJson={patientUuid:patientUuid,encounterUuid:encounterUuid};return $http.post(Bahmni.Common.Constants.bedFromVisit+"/"+bedId,patientJson,{withCredentials:!0,headers:{Accept:"application/json","Content-Type":"application/json"}})},this.getBedInfo=function(bedId){return $http.get(Bahmni.Common.Constants.bedFromVisit+"/"+bedId+"?v=custom:(bedId,bedNumber,patients:(uuid,person:(age,personName:(givenName,familyName),gender),identifiers:(uuid,identifier),),physicalLocation:(name))",{withCredentials:!0})},this.getCompleteBedDetailsByBedId=function(bedId){return $http.get(Bahmni.Common.Constants.bedFromVisit+"/"+bedId,{withCredentials:!0})}}]),angular.module("bahmni.common.domain").factory("configurationService",["$http","$q",function($http,$q){var configurationFunctions={};configurationFunctions.encounterConfig=function(){return $http.get(Bahmni.Common.Constants.encounterConfigurationUrl,{params:{callerContext:"REGISTRATION_CONCEPTS"},withCredentials:!0})},configurationFunctions.patientConfig=function(){var patientConfig=$http.get(Bahmni.Common.Constants.patientConfigurationUrl,{withCredentials:!0});return patientConfig},configurationFunctions.patientAttributesConfig=function(){return $http.get(Bahmni.Common.Constants.personAttributeTypeUrl,{params:{v:"custom:(uuid,name,sortWeight,description,format,concept)"},withCredentials:!0})},configurationFunctions.dosageFrequencyConfig=function(){var dosageFrequencyConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name,answers)",name:Bahmni.Common.Constants.dosageFrequencyConceptName},withCredentials:!0});return dosageFrequencyConfig},configurationFunctions.dosageInstructionConfig=function(){var dosageInstructionConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name,answers)",name:Bahmni.Common.Constants.dosageInstructionConceptName},withCredentials:!0});return dosageInstructionConfig},configurationFunctions.stoppedOrderReasonConfig=function(){var stoppedOrderReasonConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name,answers)",name:Bahmni.Common.Constants.stoppedOrderReasonConceptName},withCredentials:!0});return stoppedOrderReasonConfig},configurationFunctions.consultationNoteConfig=function(){var consultationNoteConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name,answers)",name:Bahmni.Common.Constants.consultationNoteConceptName},withCredentials:!0});return consultationNoteConfig},configurationFunctions.radiologyObservationConfig=function(){var radiologyObservationConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name)",name:Bahmni.Common.Constants.radiologyResultConceptName},withCredentials:!0});return radiologyObservationConfig},configurationFunctions.labOrderNotesConfig=function(){var labOrderNotesConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name)",name:Bahmni.Common.Constants.labOrderNotesConcept},withCredentials:!0});return labOrderNotesConfig},configurationFunctions.defaultEncounterType=function(){return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{params:{property:"bahmni.encounterType.default"},withCredentials:!0,transformResponse:[function(data){return data}]})},configurationFunctions.radiologyImpressionConfig=function(){var radiologyImpressionConfig=$http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name)",name:Bahmni.Common.Constants.impressionConcept},withCredentials:!0});return radiologyImpressionConfig},configurationFunctions.addressLevels=function(){return $http.get(Bahmni.Common.Constants.openmrsUrl+"/module/addresshierarchy/ajax/getOrderedAddressHierarchyLevels.form",{withCredentials:!0})},configurationFunctions.allTestsAndPanelsConcept=function(){var allTestsAndPanelsConcept=$http.ge
|
||
|
}),_.each(conditions.disable,function(subConditionConceptName){var conditionFn=Bahmni.ConceptSet.FormConditions.rules&&Bahmni.ConceptSet.FormConditions.rules[subConditionConceptName];null!=conditionFn&&_.each(flattenedObs,function(obs){obs.concept.name==subConditionConceptName&&runFormConditionForObs(!1,formName,conditionFn,subConditionConceptName,flattenedObs)})}),_.each(conditions.show,function(subConditionConceptName){var conditionFn=Bahmni.ConceptSet.FormConditions.rules&&Bahmni.ConceptSet.FormConditions.rules[subConditionConceptName];conditionFn&&runFormConditionForObs(!0,formName,conditionFn,subConditionConceptName,flattenedObs)}),_.each(conditions.hide,function(subConditionConceptName){var conditionFn=Bahmni.ConceptSet.FormConditions.rules&&Bahmni.ConceptSet.FormConditions.rules[subConditionConceptName];conditionFn&&_.each(flattenedObs,function(obs){obs.concept.name==subConditionConceptName&&runFormConditionForObs(!1,formName,conditionFn,subConditionConceptName,flattenedObs)})}))}})},updateFormConditions=function(observationsOfCurrentTemplate,rootObservation){Bahmni.ConceptSet.FormConditions.rules&&runFormConditionForAllObsRecursively(rootObservation.concept.name,rootObservation)},runFormConditionForAllObsRecursively=function(formName,rootObservation){_.each(rootObservation.groupMembers,function(observation){var conditionFn=Bahmni.ConceptSet.FormConditions.rules&&Bahmni.ConceptSet.FormConditions.rules[observation.concept.name];if(null!=conditionFn){var flattenedObs=ObservationUtil.flattenObsToArray([rootObservation]);runFormConditionForObs(!1,formName,conditionFn,observation.concept.name,flattenedObs)}observation.groupMembers&&observation.groupMembers.length>0&&runFormConditionForAllObsRecursively(formName,observation)})},addDummyImage=function(){_.each($scope.rootObservation.groupMembers,function(observation){addDummyImageObservationForSavedObs(observation,$scope.rootObservation)})},addDummyImageObservationForSavedObs=function(observation,rootObservation){if(_.each(observation.groupMembers,function(childObservation){addDummyImageObservationForSavedObs(childObservation,observation)}),"image"===observation.getControlType()&&observation.value&&rootObservation.groupMembers.indexOf(observation)===rootObservation.groupMembers.length-1)return void rootObservation.groupMembers.push(observation.cloneNew())},init=function(){return conceptSetService.getConcept({name:conceptSetName,v:"bahmni"}).then(function(response){if($scope.conceptSet=response.data.results[0],$scope.rootObservation=$scope.conceptSet?observationMapper.map($scope.observations,$scope.conceptSet,conceptSetUIConfig):null,$scope.rootObservation){$scope.rootObservation.conceptSetName=$scope.conceptSetName,focusFirstObs(),updateObservationsOnRootScope();var groupMembers=getObservationsOfCurrentTemplate()[0].groupMembers,defaults=getDefaults();addDummyImage(),setDefaultsForGroupMembers(groupMembers,defaults);var observationsOfCurrentTemplate=getObservationsOfCurrentTemplate();updateFormConditions(observationsOfCurrentTemplate,$scope.rootObservation)}else $scope.showEmptyConceptSetMessage=!0})["catch"](function(error){messagingService.showMessage("error",error.message)})};spinner.forPromise(init(),id);var validateObservationTree=function(){if("undefined"==typeof $scope.rootObservation||null===$scope.rootObservation)return{allow:!0,errorMessage:null};$scope.atLeastOneValueIsSet=$scope.rootObservation&&$scope.rootObservation.atLeastOneValueSet(),$scope.conceptSetRequired=!$scope.required||$scope.required;var nodes=$scope.rootObservation&&findInvalidNodes($scope.rootObservation.groupMembers,$scope.rootObservation);return{allow:!nodes.status,errorMessage:nodes.message}},findInvalidNodes=function(members,parentNode){var errorMessage=null,status=members.some(function(childNode){if(childNode.voided)return!1;var groupMembers=childNode.groupMembers||[];for(var index in groupMembers){var information=groupMembers[index].groupMembers&&groupMembers[index].groupMembers.length?findInvalidNodes(groupMembers[index].groupMembers,groupMembers[index]):validateChildNode(groupMembers[
|
||
|
return conceptUIConfig.autocomplete&&conceptUIConfig.nonCodedConceptName&&conceptUIConfig.codedConceptName};Bahmni.ConceptSet.ObservationNode=function(observation,savedObs,conceptUIConfig,concept){angular.extend(this,observation),this.conceptUIConfig=conceptUIConfig[concept.name.name]||!_.isEmpty(concept.setMembers)&&conceptUIConfig[concept.setMembers[0].name.name]||{},this.cloneNew=function(){var oldObs=angular.copy(observation);oldObs.groupMembers=_.map(oldObs.groupMembers,function(member){return member.cloneNew()});var clone=new Bahmni.ConceptSet.ObservationNode(oldObs,null,conceptUIConfig,concept);return clone.comment=void 0,clone};var getPrimaryObservationValue=function(){return this.primaryObs&&_.get(this,"primaryObs.value.name")||_.get(this,"primaryObs.value")},setFreeTextPrimaryObservationValue=function(newValue){var codedObservation=findObservationByConceptName(this.groupMembers,this.conceptUIConfig.codedConceptName),nonCodedObservation=findObservationByConceptName(this.groupMembers,this.conceptUIConfig.nonCodedConceptName);"object"==typeof newValue?(setNewObservation(codedObservation,newValue),voidObservation(nonCodedObservation),this.markedAsNonCoded=!1):(setNewObservation(nonCodedObservation,newValue),voidObservation(codedObservation)),this.onValueChanged(newValue)},setFirstObservationValue=function(newValue){setNewObservation(this.primaryObs,newValue),this.onValueChanged(newValue)};Object.defineProperty(this,"value",{enumerable:!0,get:getPrimaryObservationValue,set:isFreeTextAutocompleteType(this.conceptUIConfig)?setFreeTextPrimaryObservationValue:setFirstObservationValue});var getFreeTextPrimaryObservation=function(){var isAlreadySavedObservation=function(observation){return _.isString(_.get(observation,"value"))&&!_.get(observation,"voided")},codedConceptObservation=findObservationByConceptName(this.groupMembers,this.conceptUIConfig.codedConceptName),nonCodedConceptObservation=findObservationByConceptName(this.groupMembers,this.conceptUIConfig.nonCodedConceptName);if(isAlreadySavedObservation(nonCodedConceptObservation))return nonCodedConceptObservation;if(!codedConceptObservation)throw new Error("Configuration Error: Concept '"+this.conceptUIConfig.codedConceptName+"' is not a set member of '"+concept.name.name+"'.");return codedConceptObservation},getGroupMembersWithoutClass=function(groupMembers,classNames){return _.filter(groupMembers,function(member){return!(_.includes(classNames,member.concept.conceptClass.name)||_.includes(classNames,member.concept.conceptClass))})},getFirstObservation=function(){var observations=getGroupMembersWithoutClass(this.groupMembers,[Bahmni.Common.Constants.abnormalConceptClassName,Bahmni.Common.Constants.unknownConceptClassName,Bahmni.Common.Constants.durationConceptClassName]);if(_.isEmpty(observations))return this.groupMembers[0];var primaryObs=observations[1]&&observations[1].uuid&&!observations[1].voided?observations[1]:observations[0];return observations[0].isMultiSelect?observations[0]:primaryObs.uuid&&!primaryObs.voided?primaryObs:!observations[1]||!observations[1].value&&""!==observations[1].value||observations[1].voided?observations[0]:observations[1]};Object.defineProperty(this,"primaryObs",{enumerable:!0,get:isFreeTextAutocompleteType(this.conceptUIConfig)?getFreeTextPrimaryObservation:getFirstObservation}),this.isObservationNode=!0,this.uniqueId=_.uniqueId("observation_"),this.durationObs=findObservationByClassName(this.groupMembers,Bahmni.Common.Constants.durationConceptClassName),this.abnormalObs=findObservationByClassName(this.groupMembers,Bahmni.Common.Constants.abnormalConceptClassName),this.unknownObs=findObservationByClassName(this.groupMembers,Bahmni.Common.Constants.unknownConceptClassName),this.markedAsNonCoded="Coded"!==this.primaryObs.concept.dataType&&this.primaryObs.uuid,savedObs?(this.uuid=savedObs.uuid,this.observationDateTime=savedObs.observationDateTime):this.value=this.conceptUIConfig.defaultValue},Bahmni.ConceptSet.ObservationNode.prototype={canAddMore:function(){return 1==this.conceptUIConfig.allowAddMore},isStepperControl:function(){retur
|
||
|
var controller=function($scope){$scope.targetElements=[];var hideTargetElements=function(){$scope.targetElements.forEach(function(el){el.hide()})},showTargetElements=function(){$scope.targetElements.forEach(function(el){el.show()})};this.registerTriggerElement=function(triggerElement){$scope.triggerElement=triggerElement;var docClickHandler=function(){$scope.autoclose&&(hideTargetElements(),$scope.isTargetOpen=!1,$(document).off("click",docClickHandler))};$scope.triggerElement.on("click",function(event){$scope.isTargetOpen?($scope.isTargetOpen=!1,hideTargetElements(0),$(document).off("click",docClickHandler)):($scope.isTargetOpen=!0,showTargetElements(),$(document).on("click",docClickHandler),event.stopImmediatePropagation())}),$scope.$on("$destroy",function(){$(document).off("click",docClickHandler)})},this.registerTargetElement=function(targetElement){targetElement.hide(),$scope.targetElements.push(targetElement)};var hideOrShowTargetElements=function(){$scope.isTargetOpen&&($scope.isTargetOpen=!1,hideTargetElements(0))};$(document).on("click",".reg-wrapper",hideOrShowTargetElements),$scope.$on("$destroy",function(){$(document).off("click",".reg-wrapper",hideOrShowTargetElements)})};return{restrict:"A",controller:controller,scope:{autoclose:"="}}}).directive("bmPopOverTarget",function(){var link=function($scope,element,attrs,popOverController){popOverController.registerTargetElement(element)};return{restrict:"A",require:"^bmPopOver",link:link}}).directive("bmPopOverTrigger",function(){var link=function($scope,element,attrs,popOverController){popOverController.registerTriggerElement(element)};return{restrict:"A",require:"^bmPopOver",link:link}}),angular.module("bahmni.common.uiHelper").directive("splitButton",["$timeout",function($timeout){var controller=function($scope){$scope.primaryOption=$scope.primaryOption||$scope.options[0],$scope.secondaryOptions=_.without($scope.options,$scope.primaryOption),$scope.hasMultipleOptions=function(){return $scope.secondaryOptions.length>0}},link=function(scope,element){var shouldScroll=function(elementPosition,elementHeight){var windowHeight=window.innerHeight+$(window).scrollTop();return windowHeight<elementHeight+elementPosition};scope.scrollToBottom=function(){var timeout=$timeout(function(){var scrollHeight=$(element)[0].scrollHeight;shouldScroll(element.position().top,scrollHeight)&&(window.scrollBy(0,scrollHeight),$timeout.cancel(timeout))})}};return{restrict:"A",template:'<div class="split-button" bm-pop-over><button bm-pop-over-trigger class="toggle-button fa fa-caret-down" ng-show="::hasMultipleOptions()" ng-click="scrollToBottom()" ng-disabled="optionDisabled" type="button"></button><ul class="options"><li class="primaryOption"><button class="buttonClass" ng-click="optionClick()(primaryOption)" accesskey="{{::primaryOption.shortcutKey}}" ng-disabled="optionDisabled" ng-bind-html="::optionText()(primaryOption,\'primary\') | translate "></button></li><ul class="hidden-options"><li bm-pop-over-target ng-repeat="option in ::secondaryOptions" class="secondaryOption"><button class="buttonClass" ng-click="optionClick()(option)" accesskey="{{::option.shortcutKey}}" ng-disabled="optionDisabled" ng-bind-html="::optionText()(option) | translate"></button></li></ul></ul></div>',controller:controller,link:link,scope:{options:"=",primaryOption:"=",optionText:"&",optionClick:"&",optionDisabled:"="}}}]),angular.module("bahmni.common.uiHelper").directive("bmBackLinks",function(){return{template:'<ul><li ng-repeat="backLink in backLinks"><a class="back-btn" ng-if="backLink.action" accesskey="{{backLink.accessKey}}" ng-click="closeAllDialogs();backLink.action()" id="{{backLink.id}}"> <span ng-bind-html="backLink.label"></span> </a><a class="back-btn" ng-class="{\'dashboard-link\':backLink.image}" ng-if="backLink.url" accesskey="{{backLink.accessKey}}" ng-href="{{backLink.url}}" ng-click="closeAllDialogs()" id="{{backLink.id}}" title="{{backLink.title}}"> <img ng-if="backLink.image" ng-src="{{backLink.image}}" onerror="this.onerror=null; this.src=\'../images/blank-user.gif\'"/><i ng-if="bac
|
||
|
return this.addOneFourthElementToLastSection(lastSection,lastElement,lastSectionIndex,nextSection)?sectionGroups[lastElement].push(section):sectionGroups.push([section]),sectionGroups},this.addOneFourthElementToLastSection=function(lastSection,lastElement,lastSectionIndex,nextSection){var lastSectionLength=lastSection.length,isNextSectionThreeFourth=!!nextSection&&this.isThreeFourthPageSection(nextSection),isLastSectionNotThreeFourth=!this.isThreeFourthPageSection(lastSection[lastSectionIndex])&&!this.isThreeFourthPageSection(lastSection[0]);return lastSection.length<=1&&(this.isThreeFourthPageSection(lastSection[0])||!isNextSectionThreeFourth)||lastSectionLength>=2&&isLastSectionNotThreeFourth&&!isNextSectionThreeFourth},this.groupHalfPageSection=function(lastSection,lastElement,lastSectionIndex,section,sectionGroups){var lastSectionLength=lastSection.length,isLastSectionNotThreeFourth=!this.isThreeFourthPageSection(lastSection[lastSectionIndex])&&!this.isThreeFourthPageSection(lastSection[0]);return _.isEmpty(lastSection)||lastSectionLength>2||isLastSectionNotThreeFourth?sectionGroups[lastElement].push(section):sectionGroups.push([section]),sectionGroups}},Bahmni.Common.DisplayControl.Dashboard.create=function(config,$filter){return new Bahmni.Common.DisplayControl.Dashboard(config,$filter)},function(){var OBSERVATION_SECTION_URL="../common/displaycontrols/dashboard/views/sections/observationSection.html",COMMON_DISPLAY_CONTROL_URL="../common/displaycontrols/dashboard/views/sections/SECTION_NAME.html",CLINICAL_DISPLAY_CONTROL_URL="../clinical/dashboard/views/dashboardSections/SECTION_NAME.html",commonDisplayControlNames=["admissionDetails","bacteriologyResultsControl","chronicTreatmentChart","custom","diagnosis","disposition","drugOrderDetails","forms","observationGraph","obsToObsFlowSheet","pacsOrders","patientInformation","conditionsList"],getViewUrl=function(section){if(section.isObservation)return OBSERVATION_SECTION_URL;var isCommonDisplayControl=_.includes(commonDisplayControlNames,section.type);return isCommonDisplayControl?COMMON_DISPLAY_CONTROL_URL.replace("SECTION_NAME",section.type):CLINICAL_DISPLAY_CONTROL_URL.replace("SECTION_NAME",section.type)},getId=function(section,$filter){if("custom"!==section.type){var key=section.translationKey||section.title;return!_.isUndefined($filter)&&key?$filter("titleTranslate")(key).toValidId():key}};Bahmni.Common.DisplayControl.Dashboard.Section=function(section,$filter){angular.extend(this,section),this.displayOrder=section.displayOrder,this.data=section.data||{},this.isObservation=!!section.isObservation,this.patientAttributes=section.patientAttributes||[],this.viewName=getViewUrl(this),this.hideEmptyDisplayControl=void 0!=section.hideEmptyDisplayControl&§ion.hideEmptyDisplayControl,this.isDataAvailable=!0,this.id=getId(this,$filter)},Bahmni.Common.DisplayControl.Dashboard.Section.create=function(section,$filter){return new Bahmni.Common.DisplayControl.Dashboard.Section(section,$filter)}}(),angular.module("bahmni.common.displaycontrol.dashboard").controller("PatientDashboardDiagnosisController",["$scope","ngDialog",function($scope,ngDialog){$scope.section=$scope.dashboard.getSectionByType("diagnosis")||{},$scope.openSummaryDialog=function(){ngDialog.open({template:"../common/displaycontrols/dashboard/views/sections/diagnosisSummary.html",className:"ngdialog-theme-default ng-dialog-all-details-page",scope:$scope})};var cleanUpListener=$scope.$on("ngDialog.closing",function(){$("body").removeClass("ngdialog-open")});$scope.$on("$destroy",cleanUpListener)}]);var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},Bahmni.Common.DisplayControl=Bahmni.Common.DisplayControl||{},Bahmni.Common.DisplayControl.Observation=Bahmni.Common.DisplayControl.Observation||{},angular.module("bahmni.common.displaycontrol.observation",["bahmni.common.conceptSet","pascalprecht.translate"]),angular.module("bahmni.common.displaycontrol.observation").service("formHierarchyService",["formService",function(formService){var self=this;self.build=function(observations){var obs=self.preProcessMultipl
|
||
|
})}}}).state("bedManagement.patient",{url:"/patient/:patientUuid",templateUrl:"views/bedManagement.html",controller:"BedManagementController",resolve:{patientResolution:function($stateParams,bedInitialization,patientInitialization){return patientInitialization($stateParams.patientUuid).then(function(){return bedInitialization(void 0,$stateParams.patientUuid)})}}}).state("dashboard",{url:"/patient/:patientUuid/visit/:visitUuid/dashboard",data:{homeBackLink:homeBackLink,navigationLinks:navigationLinks},views:{content:{templateUrl:"views/dashboard.html",controller:"AdtController"},"additional-header":{templateUrl:" views/header.html",controller:"HeaderController"}},resolve:{initialization:"initialization",patientResolution:function($stateParams,bedInitialization,patientInitialization){return patientInitialization($stateParams.patientUuid).then(function(){return bedInitialization(void 0,$stateParams.patientUuid)})}}}),$bahmniTranslateProvider.init({app:"ipd",shouldMerge:!0})}]),angular.module("bahmni.ipd").factory("initialization",["$rootScope","$q","$bahmniCookieStore","appService","configurations","authenticator","spinner","locationService",function($rootScope,$q,$bahmniCookieStore,appService,configurations,authenticator,spinner,locationService){var getConfigs=function(){var config=$q.defer(),configNames=["encounterConfig","patientConfig","genderMap","relationshipTypeMap"];return configurations.load(configNames).then(function(){$rootScope.encounterConfig=angular.extend(new EncounterConfig,configurations.encounterConfig()),$rootScope.patientConfig=configurations.patientConfig(),$rootScope.genderMap=configurations.genderMap(),$rootScope.relationshipTypeMap=configurations.relationshipTypeMap(),$rootScope.diagnosisStatus=appService.getAppDescriptor().getConfig("diagnosisStatus")&&appService.getAppDescriptor().getConfig("diagnosisStatus").value||"RULED OUT",config.resolve()}),config.promise},initApp=function(){return appService.initApp("ipd",{app:!0,extension:!0}).then(function(data){var config=data.getConfig("onAdmissionForwardTo",!1);data.baseConfigs.dashboard.value.sections=_.sortBy(data.baseConfigs.dashboard.value.sections,function(section){return section.displayOrder}),data.baseConfigs.isBedManagementEnabled={name:"isBedManagementEnabled",value:_.includes(config[0].value,"bed")},config[1]&&(data.customConfigs.isBedManagementEnabled={name:"isBedManagementEnabled",value:_.includes(config[1].value,"bed")}),initVisitLocation()})},initVisitLocation=function(){var loginLocationUuid=$bahmniCookieStore.get(Bahmni.Common.Constants.locationCookieName).uuid;locationService.getVisitLocation(loginLocationUuid).then(function(response){response.data&&($rootScope.visitLocationUuid=response.data.uuid)})};return spinner.forPromise(authenticator.authenticateUser().then(initApp).then(getConfigs))}]),angular.module("bahmni.ipd").factory("patientInitialization",["$rootScope","$q","patientService","initialization","bedService","spinner","$translate",function($rootScope,$q,patientService,initialization,bedService,spinner,$translate){return function(patientUuid){var getPatient=function(){var patientMapper=new Bahmni.PatientMapper($rootScope.patientConfig,$rootScope,$translate),patientPromise=$q.defer();return patientService.getPatient(patientUuid).then(function(response){$rootScope.patient=patientMapper.map(response.data),patientPromise.resolve()}),patientPromise.promise};return spinner.forPromise(initialization.then(getPatient))}}]),angular.module("bahmni.ipd").factory("bedInitialization",["$rootScope","$q","patientService","initialization","bedService","spinner",function($rootScope,$q,patientService,initialization,bedService,spinner){return function(bedId,patientUuid){var initializeBedInfo=function(){return bedId?bedService.getCompleteBedDetailsByBedId(bedId).then(function(response){var bedInfo=response.data;return bedInfo.wardName=response.data.physicalLocation.parentLocation.display,bedInfo.wardUuid=response.data.physicalLocation.parentLocation.uuid,bedInfo.physicalLocationName=response.data.physicalLocation.name,$rootScope.bedDetails=bedInfo
|
||
|
var getEncounterDataFor=function(obs,encounterTypeUuid,visitTypeUuid){var encounterData={};return encounterData.patientUuid=$scope.patient.uuid,encounterData.encounterTypeUuid=encounterTypeUuid,encounterData.visitTypeUuid=visitTypeUuid,encounterData.observations=angular.copy(obs),encounterData.locationUuid=sessionService.getLoginLocationUuid(),encounterData},toggleDisabledObservation=function(editMode){$scope.editMode=editMode,_.each($scope.observations[0].groupMembers,function(member){member.disabled=!editMode})},getNonEmptyObservations=function(){var observations=angular.copy($scope.observations[0]);return observations.groupMembers=_.filter(observations.groupMembers,function(member){return!_.isEmpty(member.value)}),_.isEmpty(observations.groupMembers)?(messagingService.showMessage("error","Date of Discharge and Reason for discharge cannot be empty."),setValuesForObservations($scope.savedObservations),[]):[observations]};$scope.edit=function(){$scope.savedObservations=angular.copy($scope.observations[0]),toggleDisabledObservation(!0)},$scope.save=function(){toggleDisabledObservation(!1);var observations=getNonEmptyObservations();if(null!==$scope.visitTypeUuid&&!_.isEmpty(observations)){var encounterData=getEncounterDataFor(observations,$rootScope.encounterConfig.getConsultationEncounterTypeUuid(),$scope.visitTypeUuid);return encounterService.create(encounterData).then(function(){toggleDisabledObservation(!1)})}},$scope.cancel=function(){setValuesForObservations($scope.savedObservations),toggleDisabledObservation(!1)};var resetObservationValues=function(){_.each($scope.observations[0].groupMembers,function(member){member.value=void 0})},fetchLatestObsFor=function(conceptNames){return observationsService.fetch($scope.patient.uuid,conceptNames,"latest",null,null,null,null,null).then(function(response){resetObservationValues(),toggleDisabledObservation(!1),response.data.length&&setValuesForObservations(response.data[0])})};$scope.$watch("patient",function(oldValue,newValue){if(oldValue!==newValue)return fetchLatestObsFor($scope.conceptSetName)});var getConceptSetByConceptName=function(conceptSetName){return conceptSetService.getConcept({name:conceptSetName,v:"bahmni"}).then(function(response){return response.data.results[0]})},constructObservationTemplate=function(conceptSetName){return getConceptSetByConceptName(conceptSetName).then(function(conceptSet){var observationMapper=new Bahmni.ConceptSet.ObservationMapper;return observationMapper.map([],conceptSet,conceptSetUiConfigService.getConfig())})},setValuesForObservations=function(obsGroup){$scope.observations[0].value=obsGroup.value,_.each(obsGroup.groupMembers,function(obsGroupMember){_.each($scope.observations[0].groupMembers,function(member){member.concept.uuid===obsGroupMember.concept.uuid&&(member.value=obsGroupMember.value,member.disabled=!0)})})},init=function(){return $scope.promiseResolved=!1,$scope.observations=[],$scope.editMode=!1,$scope.onBedManagement=$state.current&&"bedManagement.bed"===$state.current.name,constructObservationTemplate($scope.conceptSetName).then(function(observation){if($scope.observations[0]=observation,toggleDisabledObservation(!1),$scope.promiseResolved=!0,$rootScope.patient&&$rootScope.bedDetails)return observationsService.fetch($scope.patient.uuid,[$scope.conceptSetName],"latest",1,null,null,null,null).then(function(response){response.data.length&&setValuesForObservations(response.data[0])})})};spinner.forPromise(init())};return{restrict:"E",scope:{patient:"=",conceptSetName:"=",editMode:"=",visitTypeUuid:"="},controller:controller,templateUrl:"views/editAdtObservations.html"}}]),angular.module("bahmni.ipd").directive("roomList",[function(){return{restrict:"E",controller:"RoomListController",scope:{room:"="},templateUrl:"../bedmanagement/views/roomList.html"}}]),angular.module("bahmni.ipd").directive("roomGrid",[function(){return{restrict:"E",controller:"RoomGridController",scope:{room:"="},templateUrl:"../bedmanagement/views/roomGrid.html"}}]),angular.module("bahmni.ipd").directive("backLinksCacheBuster",["$state","$window",function
|