9 lines
272 KiB
JavaScript
9 lines
272 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/concept?s=byFullySpecifiedName&name=Dosage+Frequency&v=custom:(uuid,name,answers)":"DosageFrequencyConfig","/openmrs/ws/rest/v1/concept?s=byFullySpecifiedName&name=Dosage+Instructions&v=custom:(uuid,name,answers)":"DosageInstructionConfig","/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/visitWithLocale",bahmniDispositionByPatientUrl:BAHMNI_CORE+"/disposition/patientWithLocale",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",updateReferenceTermsImportUrl:BAHMNI_CORE+"/admin/upload/referenceterms/new",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:B
|
||
|
savedDiagnosesFromCurrentEncounter:savedDiagnosesFromCurrentEncounter}})},this.populateDiagnosisInformation=function(patientUuid,consultation){return this.getPastAndCurrentDiagnoses(patientUuid,consultation.encounterUuid).then(function(diagnosis){return consultation.pastDiagnoses=diagnosis.pastDiagnoses,consultation.savedDiagnosesFromCurrentEncounter=diagnosis.savedDiagnosesFromCurrentEncounter,consultation})}}]),angular.module("bahmni.common.domain").service("bedService",["$http","$rootScope",function($http,$rootScope){var mapBedDetails=function(response){var results=response.data.results;if(!_.isEmpty(results)){var bed=_.first(results);return{wardName:bed.physicalLocation.parentLocation.display,wardUuid:bed.physicalLocation.parentLocation.uuid,physicalLocationName:bed.physicalLocation.name,bedNumber:bed.bedNumber,bedId:bed.bedId}}};this.setBedDetailsForPatientOnRootScope=function(uuid){var promise=this.getAssignedBedForPatient(uuid);return promise.then(function(bedDetails){$rootScope.bedDetails=bedDetails}),promise},this.getAssignedBedForPatient=function(patientUuid,visitUuid){var params={patientUuid:patientUuid,v:"full"};return visitUuid&&(params.visitUuid=visitUuid,params.s="bedDetailsFromVisit"),$http.get(Bahmni.Common.Constants.bedFromVisit,{method:"GET",params:params,withCredentials:!0}).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(Ba
|
||
|
return flattenedObsValues},{})},clearFieldValuesOnDisabling=function(obs){if(obs.comment=void 0,obs.value||obs.isBoolean)obs.value=void 0;else if(obs.isMultiSelect)for(var key in obs.selectedObs)obs.selectedObs[key].voided||obs.toggleSelection(obs.selectedObs[key].value)},setObservationState=function(obsArray,disable,error,hide){_.isEmpty(obsArray)||_.each(obsArray,function(obs){obs.disabled=disable||hide,obs.error=error,obs.hide=hide,(hide||obs.disabled)&&clearFieldValuesOnDisabling(obs),obs.groupMembers&&_.each(obs.groupMembers,function(groupMember){groupMember&&setObservationState([groupMember],disable,error,hide)})})},processConditions=function(flattenedObs,fields,disable,error,hide){_.each(fields,function(field){var clonedObsInSameGroup,matchingObsArray=[];flattenedObs.forEach(function(obs){0!=clonedObsInSameGroup&&obs.concept.name==field?(matchingObsArray.push(obs),clonedObsInSameGroup=!0):clonedObsInSameGroup&&obs.concept.name!=field&&(clonedObsInSameGroup=!1)}),_.isEmpty(matchingObsArray)?messagingService.showMessage("error","No element found with name : "+field):setObservationState(matchingObsArray,disable,error,hide)})},runFormConditionForObs=function(enableCase,formName,formCondition,conceptName,flattenedObs){var conceptSetObsValues=getFlattenedObsValues(flattenedObs);_.each(_.keys(conceptSetObsValues),function(eachObsKey){if(eachObsKey.split("|")[0]==conceptName&&"undefined"!=eachObsKey.split("|")[1]){var valueMap=_.reduce(conceptSetObsValues,function(conceptSetValueMap,obsValue,conceptName){return conceptSetValueMap[conceptName.split("|")[0]]=obsValue,conceptSetValueMap},{}),conditions=formCondition(formName,valueMap,$scope.patient);_.isUndefined(conditions)||(conditions.error&&!_.isEmpty(conditions.error)?(messagingService.showMessage("error",conditions.error),processConditions(flattenedObs,[conceptName],!1,!0,!1)):enableCase&&processConditions(flattenedObs,[conceptName],!1,!1,!1),processConditions(flattenedObs,conditions.disable,!0),processConditions(flattenedObs,conditions.enable,!1),processConditions(flattenedObs,conditions.show,!1,void 0,!1),processConditions(flattenedObs,conditions.hide,!1,void 0,!0),_.each(conditions.enable,function(subConditionConceptName){var conditionFn=Bahmni.ConceptSet.FormConditions.rules&&Bahmni.ConceptSet.FormConditions.rules[subConditionConceptName];null!=conditionFn&&runFormConditionForObs(!0,formName,conditionFn,subConditionConceptName,flattenedObs)}),_.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.groupMem
|
||
|
},toggleVoidingOfImage:function(){this.voided=!this.voided},assignAddMoreButtonID:function(){return this.concept.name.split(" ").join("_").toLowerCase()+"_addmore_"+this.uniqueId}},Bahmni.ConceptSet.BooleanObservation=function(observation,conceptUIConfig){angular.extend(this,observation),this.isBoolean=!0,this.conceptUIConfig=conceptUIConfig[this.concept.name]||{},this.cloneNew=function(){var clone=new Bahmni.ConceptSet.BooleanObservation(angular.copy(observation),conceptUIConfig);return clone.value=void 0,clone.comment=void 0,clone.uuid=null,clone.disabled=this.disabled,clone};var possibleAnswers=[{displayString:"OBS_BOOLEAN_YES_KEY",value:!0},{displayString:"OBS_BOOLEAN_NO_KEY",value:!1}];this.getPossibleAnswers=function(){return possibleAnswers},this.hasValueOf=function(answer){return this.value===answer.value},this.toggleSelection=function(answer){this.value===answer.value?this.value=null:this.value=answer.value},this.isFormElement=function(){return!0},this.getControlType=function(){return"buttonselect"},this.isRequired=function(){return this.disabled=!!this.disabled&&this.disabled,this.getConceptUIConfig().required===!0&&this.disabled===!1},this.isComputedAndEditable=function(){return"Computed/Editable"===this.concept.conceptClass},this.atLeastOneValueSet=function(){return void 0!=this.value},this.isValid=function(checkRequiredFields,conceptSetRequired){if(this.error)return!1;var notYetSet=function(value){return"undefined"==typeof value||null==value};if(checkRequiredFields){if(conceptSetRequired&&this.isRequired()&¬YetSet(this.value))return!1;if(this.isRequired()&¬YetSet(this.value))return!1}return!0},this.canHaveComment=function(){return!this.getConceptUIConfig().disableAddNotes||!this.getConceptUIConfig().disableAddNotes},this.getConceptUIConfig=function(){return this.conceptUIConfig},this.canAddMore=function(){return 1==this.getConceptUIConfig().allowAddMore},this.isComputed=function(){return"Computed"===this.concept.conceptClass},this.getDataTypeName=function(){return this.concept.dataType},this.hasValue=function(){var value=this.value;return value===!1||(0===value||!(""===value||!value)&&(!(value instanceof Array)||value.length>0))},this.isNumeric=function(){return"Numeric"===this.getDataTypeName()},this.isText=function(){return"Text"===this.getDataTypeName()},this.isCoded=function(){return"Coded"===this.getDataTypeName()},this._isDateTimeDataType=function(){return"Datetime"===this.getDataTypeName()}},function(){var findObservationByClassName=function(groupMembers,conceptClassName){return _.find(groupMembers,function(member){return member.concept.conceptClass.name===conceptClassName||member.concept.conceptClass===conceptClassName})},findObservationByConceptName=function(groupMembers,conceptName){return _.find(groupMembers,{concept:{name:conceptName}})},setNewObservation=function(observation,newValue){observation&&(observation.__prevValue=observation.value,observation.value=newValue,observation.voided=!1)},voidObservation=function(observation){observation&&(observation.uuid?observation.voided=!0:observation.value=void 0)},isFreeTextAutocompleteType=function(conceptUIConfig){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),nonCodedO
|
||
|
visitUuid:patient.activeVisitUuid||null,encounterUuid:$stateParams.encounterUuid||"active",programUuid:patient.programUuid||null,enrollment:patient.enrollment||null,forwardUrl:patient.forwardUrl||null,dateEnrolled:patient.dateEnrolled||null});var link=options.forwardUrl?{url:options.forwardUrl,newTab:!0}:{url:$scope.search.searchType.forwardUrl,newTab:!1};$scope.search.searchType.links&&(link=_.find($scope.search.searchType.links,{linkColumn:heading})||link),link.url&&null!==link.url&&$window.open(appService.getAppDescriptor().formatUrl(link.url,options,!0),link.newTab?"_blank":"_self")};var getPatientCountSeriallyBySearchIndex=function(index){if(index!==$scope.search.searchTypes.length){var searchType=$scope.search.searchTypes[index];if(searchType.handler){var params={q:searchType.handler,v:"full",location_uuid:$bahmniCookieStore.get(Bahmni.Common.Constants.locationCookieName).uuid,provider_uuid:$rootScope.currentProvider.uuid};searchType.additionalParams&&(params.additionalParams=searchType.additionalParams),patientService.findPatients(params).then(function(response){return searchType.patientCount=response.data.length,$scope.search.isSelectedSearch(searchType)&&$scope.search.updatePatientList(response.data),getPatientCountSeriallyBySearchIndex(index+1)})}}};initialize()}]),angular.module("bahmni.common.uiHelper",["ngClipboard"]),angular.module("bahmni.common.uiHelper").service("backlinkService",["$window",function($window){var self=this,urls=[];self.reset=function(){urls=[]},self.setUrls=function(backLinks){self.reset(),angular.forEach(backLinks,function(backLink){self.addUrl(backLink)})},self.addUrl=function(backLink){urls.push(backLink)},self.addBackUrl=function(label){var backLabel=label||"Back";urls.push({label:backLabel,action:$window.history.back})},self.getUrlByLabel=function(label){return urls.filter(function(url){return url.label===label})},self.getAllUrls=function(){return urls}}]),angular.module("bahmni.common.uiHelper").service("contextChangeHandler",["$rootScope",function($rootScope){var callbacks=[],self=this;$rootScope.$on("$stateChangeSuccess",function(){self.reset()}),this.reset=function(){callbacks=[]},this.add=function(callback){callbacks.push(callback)},this.execute=function(){var allow=!0,callBackReturn=null,errorMessage=null;return callbacks.forEach(function(callback){callBackReturn=callback(),allow=allow&&callBackReturn.allow,_.isEmpty(errorMessage)&&(errorMessage=callBackReturn.errorMessage)}),callBackReturn&&errorMessage?{allow:allow,errorMessage:errorMessage}:{allow:allow}}}]),angular.module("bahmni.common.uiHelper").directive("bmPopOver",function(){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}})
|
||
|
section.startDate=config.startDate,section.endDate=config.endDate});var _sections=_.sortBy(_.map(config.sections,function(section){return Bahmni.Common.DisplayControl.Dashboard.Section.create(section,$filter)}),function(section){return section.displayOrder});this.getSectionByType=function(name){return _.find(_sections,function(section){return section.type===name})||{}},this.getSections=function(diseaseTemplates){var sections=_.filter(_sections,function(section){return"diseaseTemplate"!==section.type||_.find(diseaseTemplates,function(diseaseTemplate){return diseaseTemplate.name===section.templateName&&diseaseTemplate.obsTemplates.length>0})});return this.groupSectionsByType(sections)},this.groupSectionsByType=function(sections){var sectionGroups=[[]];for(var sectionId in sections){var section=sections[sectionId],nextSection=sectionId<sections.length?sections[++sectionId]:null,lastElement=sectionGroups.length-1;this.isFullPageSection(section)?(_.isEmpty(sectionGroups[lastElement])&§ionGroups.pop(),sectionGroups.push([section]),sectionGroups.push([])):sectionGroups=this.groupSectionsIfNotFullPage(section,sectionGroups,lastElement,nextSection)}return sectionGroups},this.isFullPageSection=function(section){return this.checkDisplayType(section,"Full-Page")},this.isThreeFourthPageSection=function(section){return this.checkDisplayType(section,"LAYOUT_75_25")},this.isOneFourthPageSection=function(section){return this.checkDisplayType(section,"LAYOUT_25_75")},this.isHalfPageSection=function(section){return this.checkDisplayType(section,"Half-Page")||this.isDisplayTypeWrong(section)||!section.displayType},this.isDisplayTypeWrong=function(section){var allDisplayTypes=["Full-Page","LAYOUT_75_25","LAYOUT_25_75","Half-Page"];return allDisplayTypes.indexOf(section.displayType)<=-1},this.checkDisplayType=function(section,typeToCheck){return section&§ion.displayType&§ion.displayType===typeToCheck},this.groupSectionsIfNotFullPage=function(section,sectionGroups,lastElement,nextSection){var lastSection=sectionGroups[lastElement],lastSectionIndex=_.isEmpty(lastSection)?0:lastSection.length-1;return sectionGroups=this.isThreeFourthPageSection(section)?this.groupThreeFourthPageSection(lastSection,lastElement,lastSectionIndex,section,sectionGroups):this.isOneFourthPageSection(section)?this.groupOneFourthPageSection(lastSection,lastElement,lastSectionIndex,section,sectionGroups,nextSection):this.groupHalfPageSection(lastSection,lastElement,lastSectionIndex,section,sectionGroups)},this.groupThreeFourthPageSection=function(lastSection,lastElement,lastSectionIndex,section,sectionGroups){var lastSectionLength=lastSection.length,isLastSectionOneFourth=1==lastSectionLength&&this.isOneFourthPageSection(lastSection[lastSectionIndex]);return _.isEmpty(lastSection)||isLastSectionOneFourth?sectionGroups[lastElement].push(section):sectionGroups.push([section]),sectionGroups},this.groupOneFourthPageSection=function(lastSection,lastElement,lastSectionIndex,section,sectionGroups,nextSection){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||isLastSectionNo
|
||
|
return function(diagnoses){var primaryDiagnoses=_.filter(diagnoses,function(diagnosis){return diagnosis.isPrimary()}),otherDiagnoses=_.filter(diagnoses,function(diagnosis){return!diagnosis.isPrimary()});return primaryDiagnoses.concat(otherDiagnoses)}}),angular.module("bahmni.common.displaycontrol.diagnosis").directive("bahmniDiagnosis",["diagnosisService","$q","spinner","$rootScope","$filter","$translate",function(diagnosisService,$q,spinner,$rootScope,$filter,$translate){var controller=function($scope){var getAllDiagnosis=function(){return diagnosisService.getDiagnoses($scope.patientUuid,$scope.visitUuid).then(function(response){var diagnosisMapper=new Bahmni.DiagnosisMapper($rootScope.diagnosisStatus);$scope.allDiagnoses=diagnosisMapper.mapDiagnoses(response.data),0==$scope.showRuledOutDiagnoses&&($scope.allDiagnoses=_.filter($scope.allDiagnoses,function(diagnoses){return diagnoses.diagnosisStatus!==$rootScope.diagnosisStatus})),$scope.isDataPresent=function(){return!$scope.allDiagnoses||0!=$scope.allDiagnoses.length||($scope.$emit("no-data-present-event"),!1)}})};$scope.title=$scope.config.title,$scope.toggle=function(diagnosis,toggleLatest){toggleLatest?(diagnosis.showDetails=!1,diagnosis.showLatestDetails=!diagnosis.showLatestDetails):(diagnosis.showLatestDetails=!1,diagnosis.showDetails=!diagnosis.showDetails)};var getPromises=function(){return[getAllDiagnosis()]};$scope.isLatestDiagnosis=function(diagnosis){return!!diagnosis.latestDiagnosis&&diagnosis.existingObs==diagnosis.latestDiagnosis.existingObs},$scope.translateDiagnosisLabels=function(key,type){if(key){var translationKey="CLINICAL_DIAGNOSIS_"+type+"_"+key.toUpperCase(),translation=$translate.instant(translationKey);if(translation!=translationKey)return translation}return key},$scope.initialization=$q.all(getPromises())},link=function($scope,element){spinner.forPromise($scope.initialization,element)};return{restrict:"E",controller:controller,link:link,templateUrl:"../common/displaycontrols/diagnosis/views/diagnosisDisplayControl.html",scope:{patientUuid:"=",config:"=",visitUuid:"=?",showRuledOutDiagnoses:"=?",hideTitle:"=?",showLatestDiagnosis:"@showLatestDiagnosis"}}}]);var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},Bahmni.Common.DisplayControl=Bahmni.Common.DisplayControl||{},Bahmni.Common.DisplayControl.navigationLinks=Bahmni.Common.DisplayControl.navigationLinks||{},angular.module("bahmni.common.displaycontrol.navigationlinks",["ui.router","ui.router.util"]),angular.module("bahmni.common.displaycontrol.navigationlinks").directive("navigationLinks",["$state","appService",function($state,appService){var controller=function($scope){(!$scope.params.showLinks&&!$scope.params.customLinks||$scope.params.showLinks&&$scope.params.customLinks&&0==$scope.params.showLinks.length&&0==$scope.params.customLinks.length)&&($scope.noNavigationLinksMessage=Bahmni.Common.Constants.noNavigationLinksMessage),$scope.standardLinks=[{name:"home",translationKey:"HOME_DASHBOARD_KEY",url:"../home/#/dashboard"},{name:"visit",url:"../clinical/#/default/patient/{{patientUuid}}/dashboard/visit/{{visitUuid}}/?encounterUuid=active",translationKey:"PATIENT_VISIT_PAGE_KEY"},{name:"inpatient",translationKey:"PATIENT_ADT_PAGE_KEY",url:"../adt/#/patient/{{patientUuid}}/visit/{{visitUuid}}/"},{name:"enrolment",translationKey:"PROGRAM_MANAGEMENT_PAGE_KEY",url:"../clinical/#/programs/patient/{{patientUuid}}/consultationContext"},{name:"visitAttribute",translationKey:"PATIENT_VISIT_ATTRIBUTES_PAGE_KEY",url:"../registration/#/patient/{{patientUuid}}/visit"},{name:"registration",translationKey:"PATIENT_REGISTRATION_PAGE_KEY",url:"../registration/#/patient/{{patientUuid}}"}];var filterLinks=function(links,showLinks){var linksSpecifiedInShowLinks=function(){return _.filter(links,function(link){return showLinks.indexOf(link.name)>-1})};return showLinks&&linksSpecifiedInShowLinks()};$scope.getLinks=function(){return _.union(filterLinks($scope.standardLinks,$scope.params.showLinks),$scope.params.customLinks)},$scope.getUrl=function(link){var url=getFormattedURL(link);window.open(url,link.title)
|
||
|
};$scope.disableDischargeButton=function(){return!($rootScope.patient&&$rootScope.bedDetails&&isCurrentPatientPresentOnSelectedBed())||$scope.buttonClicked},$scope.transfer=function(){setButtonClicked(),angular.isUndefined($rootScope.selectedBedInfo.bed)||$rootScope.selectedBedInfo.bed.bedId===$rootScope.bedDetails.bedId?messagingService.showMessage("error","SELECT_BED_TO_TRANSFER_MESSAGE"):ngDialog.openConfirm({template:"views/transferConfirmation.html",scope:$scope,closeByEscape:!0,className:"ngdialog-theme-default ng-dialog-adt-popUp",preCloseCallback:unsetButtonClicked})};var reloadStateWithContextParams=function(){var selectedBedInfo=$rootScope.selectedBedInfo,options={patientUuid:$scope.patient.uuid,context:{roomName:selectedBedInfo.roomName,department:{uuid:selectedBedInfo.wardUuid,name:selectedBedInfo.wardName,roomName:selectedBedInfo.roomName}}};$state.transitionTo("bedManagement.patient",options,{reload:!0,inherit:!1,notify:!0})},disableButton=function(){$scope.isDisabled=!0};$scope.transferConfirmation=function(){var encounterData=getEncounterData($scope.encounterConfig.getTransferEncounterTypeUuid(),getCurrentVisitTypeUuid());disableButton(),spinner.forPromise(bedService.getCompleteBedDetailsByBedId($rootScope.selectedBedInfo.bed.bedId).then(function(response){var bedDetails=response.data;bedDetails.patients.length?(showErrorMessage(bedDetails),reloadStateWithContextParams()):spinner.forPromise(encounterService.create(encounterData).then(function(response){assignBedToPatient($rootScope.selectedBedInfo.bed,response.data.patientUuid,response.data.encounterUuid),ngDialog.close(),forwardUrl(response.data,"onTransferForwardTo")}))}))},$scope.discharge=function(){setButtonClicked(),$rootScope.bedDetails.bedNumber?visitService.search({patient:$scope.patient.uuid,v:customVisitParams,includeInactive:!1}).then(function(visitResponse){var visitUuid=getPatientSpecificActiveVisits(visitResponse);visitUuid?ngDialog.openConfirm({template:"views/dischargeConfirmation.html",scope:$scope,closeByEscape:!0,className:"ngdialog-theme-default ng-dialog-adt-popUp",preCloseCallback:unsetButtonClicked}):messagingService.showMessage("error","NO_ACTIVE_VISIT_MESSAGE")}):messagingService.showMessage("error","SELECT_BED_TO_DISCHARGE_MESSAGE")},$scope.dischargeConfirmation=function(){var encounterData=getEncounterData($scope.encounterConfig.getDischargeEncounterTypeUuid());return spinner.forPromise(encounterService.discharge(encounterData).then(function(response){ngDialog.close(),forwardUrl(response.data,"onDischargeForwardTo");var bedNumber=_.get($rootScope.bedDetails,"bedNumber")||_.get($rootScope.selectedBedInfo,"bed.bedNumber");messagingService.showMessage("info",$translate.instant("SUCCESSFULLY_DISCHARGED_MESSAGE",{bed:bedNumber}))}))};var showErrorMessage=function(bedDetails){var patient=bedDetails.patients[0],identifier=patient.display&&patient.display.split(" - ")[0];patient.identifiers[0].identifier=identifier,messagingService.showMessage("error",$translate.instant("SELECT_AVAILABLE_BED_DEFAULT_MESSAGE",{identifier:identifier})),$scope.cancelConfirmationDialog()};$scope.admitConfirmation=function(){spinner.forPromise(bedService.getCompleteBedDetailsByBedId($rootScope.selectedBedInfo.bed.bedId).then(function(response){var bedDetails=response.data;return bedDetails.patients.length?(showErrorMessage(bedDetails),void reloadStateWithContextParams()):void(hideStartNewVisitPopUp&&$scope.visitSummary&&getVisitTypeUuid($scope.visitSummary.visitType)!==defaultVisitTypeUuid?$scope.closeCurrentVisitAndStartNewVisit():(createEncounterAndContinue(),$scope.cancelConfirmationDialog()))}))}}]),angular.module("bahmni.ipd").controller("WardController",["$scope","$rootScope","$stateParams","$state",function($scope,$rootScope,$stateParams,$state){var init=function(){$stateParams.context&&$stateParams.context.roomName?expandAdmissionMasterForRoom($stateParams.context.roomName):$rootScope.bedDetails&&expandAdmissionMasterForRoom($rootScope.bedDetails.physicalLocationName)},getSelectedRoom=function(roomName){var admissionRoom=_.filter($scope.ward.rooms,
|