5 lines
127 KiB
JavaScript
5 lines
127 KiB
JavaScript
![]() |
"use strict";var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},function(){var hostUrl=localStorage.getItem("host")?"https://"+localStorage.getItem("host"):"",rootDir=localStorage.getItem("rootDir")||"",RESTWS=hostUrl+"/openmrs/ws/rest",RESTWS_V1=hostUrl+"/openmrs/ws/rest/v1",BAHMNI_CORE=RESTWS_V1+"/bahmnicore",EMRAPI=RESTWS+"/emrapi",BACTERIOLOGY=RESTWS_V1,BASE_URL=hostUrl+"/bahmni_config/openmrs/apps/",CUSTOM_URL=hostUrl+"/implementation_config/openmrs/apps/",IE_APPS_API=RESTWS_V1+"/bahmniie",serverErrorMessages=[{serverMessage:"Cannot have more than one active order for the same orderable and care setting at same time",clientMessage:"One or more drugs you are trying to order are already active. Please change the start date of the conflicting drug or remove them from the new prescription."},{serverMessage:"[Order.cannot.have.more.than.one]",clientMessage:"One or more drugs you are trying to order are already active. Please change the start date of the conflicting drug or remove them from the new prescription."}],representation="custom:(uuid,name,names,conceptClass,setMembers:(uuid,name,names,conceptClass,setMembers:(uuid,name,names,conceptClass,setMembers:(uuid,name,names,conceptClass))))",unAuthenticatedReferenceDataMap={"/openmrs/ws/rest/v1/location?tags=Login+Location&s=byTags&v=default":"LoginLocations","/openmrs/ws/rest/v1/bahmnicore/sql/globalproperty?property=locale.allowed.list":"LocaleList"},authenticatedReferenceDataMap={"/openmrs/ws/rest/v1/idgen/identifiertype":"IdentifierTypes","/openmrs/module/addresshierarchy/ajax/getOrderedAddressHierarchyLevels.form":"AddressHierarchyLevels","/openmrs/ws/rest/v1/bahmnicore/sql/globalproperty?property=mrs.genders":"Genders","/openmrs/ws/rest/v1/bahmnicore/sql/globalproperty?property=bahmni.encountersession.duration":"encounterSessionDuration","/openmrs/ws/rest/v1/bahmnicore/sql/globalproperty?property=bahmni.relationshipTypeMap":"RelationshipTypeMap","/openmrs/ws/rest/v1/bahmnicore/config/bahmniencounter?callerContext=REGISTRATION_CONCEPTS":"RegistrationConcepts","/openmrs/ws/rest/v1/relationshiptype?v=custom:(aIsToB,bIsToA,uuid)":"RelationshipType","/openmrs/ws/rest/v1/personattributetype?v=custom:(uuid,name,sortWeight,description,format,concept)":"PersonAttributeType","/openmrs/ws/rest/v1/entitymapping?mappingType=loginlocation_visittype&s=byEntityAndMappingType":"LoginLocationToVisitTypeMapping","/openmrs/ws/rest/v1/bahmnicore/config/patient":"PatientConfig","/openmrs/ws/rest/v1/concept?s=byFullySpecifiedName&name=Consultation+Note&v=custom:(uuid,name,answers)":"ConsultationNote","/openmrs/ws/rest/v1/concept?s=byFullySpecifiedName&name=Lab+Order+Notes&v=custom:(uuid,name)":"LabOrderNotes","/openmrs/ws/rest/v1/concept?s=byFullySpecifiedName&name=Impression&v=custom:(uuid,name)":"RadiologyImpressionConfig","/openmrs/ws/rest/v1/concept?s=byFullySpecifiedName&name=All_Tests_and_Panels&v=custom:(uuid,name:(uuid,name),setMembers:(uuid,name:(uuid,name)))":"AllTestsAndPanelsConcept","/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
|
||
|
!_.isEmpty(providers.results)&&hasAnyActiveProvider(providers.results)?($rootScope.currentUser=new Bahmni.Auth.User(data.results[0]),$rootScope.currentUser.currentLocation=$bahmniCookieStore.get(Bahmni.Common.Constants.locationCookieName).name,$rootScope.$broadcast("event:user-credentialsLoaded",data.results[0]),deferrable.resolve(data.results[0])):(self.destroy(),deferrable.reject("YOU_HAVE_NOT_BEEN_SETUP_PROVIDER"))},function(){self.destroy(),deferrable.reject("COULD_NOT_GET_PROVIDER")})},function(){self.destroy(),deferrable.reject("Could not get roles for the current user.")}),deferrable.promise):(this.destroy().finally(function(){$rootScope.$broadcast("event:auth-loginRequired"),deferrable.reject("No User in session. Please login again.")}),deferrable.promise)},this.getLoginLocationUuid=function(){return $bahmniCookieStore.get(Bahmni.Common.Constants.locationCookieName)?$bahmniCookieStore.get(Bahmni.Common.Constants.locationCookieName).uuid:null},this.changePassword=function(currentUserUuid,oldPassword,newPassword){return $http({method:"POST",url:Bahmni.Common.Constants.passwordUrl,data:{oldPassword:oldPassword,newPassword:newPassword},headers:{"Content-Type":"application/json"}})},this.loadProviders=function(userInfo){return $http.get(Bahmni.Common.Constants.providerUrl,{method:"GET",params:{user:userInfo.uuid},cache:!1}).success(function(data){var providerUuid=data.results.length>0?data.results[0].uuid:void 0;$rootScope.currentProvider={uuid:providerUuid}})}}]).factory("authenticator",["$rootScope","$q","$window","sessionService",function($rootScope,$q,$window,sessionService){var authenticateUser=function(){var defer=$q.defer(),sessionDetails=sessionService.get();return sessionDetails.then(function(response){response.data.authenticated?defer.resolve():(defer.reject("User not authenticated"),$rootScope.$broadcast("event:auth-loginRequired"))}),defer.promise};return{authenticateUser:authenticateUser}}]).directive("logOut",["sessionService","$window","configurationService","auditLogService",function(sessionService,$window,configurationService,auditLogService){return{link:function(scope,element){element.bind("click",function(){scope.$apply(function(){auditLogService.log(void 0,"USER_LOGOUT_SUCCESS",void 0,"MODULE_LABEL_LOGOUT_KEY").then(function(){sessionService.destroy().then(function(){$window.location="../home/index.html#/login"})})})})}}}]).directive("btnUserInfo",[function(){return{restrict:"CA",link:function(scope,elem){elem.bind("click",function(event){$(this).next().toggleClass("active"),event.stopPropagation()}),$(document).find("body").bind("click",function(){$(elem).next().removeClass("active")})}}}]),angular.module("bahmni.common.appFramework",["authentication"]);var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},Bahmni.Common.AppFramework=Bahmni.Common.AppFramework||{},angular.module("bahmni.common.appFramework").config(["$compileProvider",function($compileProvider){$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|chrome-extension|file):/)}]).service("appService",["$http","$q","sessionService","$rootScope","mergeService","loadConfigService","messagingService","$translate",function($http,$q,sessionService,$rootScope,mergeService,loadConfigService,messagingService,$translate){var currentUser=null,baseUrl=Bahmni.Common.Constants.baseUrl,customUrl=Bahmni.Common.Constants.customUrl,appDescriptor=null;$rootScope.meetId=null;var loadConfig=function(url){return loadConfigService.loadConfig(url,appDescriptor.contextPath)},loadTemplate=function(appDescriptor){var deferrable=$q.defer();return loadConfig(baseUrl+appDescriptor.contextPath+"/appTemplate.json").then(function(result){_.keys(result.data).length>0&&appDescriptor.setTemplate(result.data),deferrable.resolve(appDescriptor)},function(error){404!==error.status?deferrable.reject(error):deferrable.resolve(appDescriptor)}),deferrable.promise},setDefinition=function(baseResultData,customResultData){customResultData&&(_.keys(baseResultData).length>0||_.keys(customResultData.length>0))?appDescriptor.setDefinition(baseResultData,customResultData)
|
||
|
locale:$rootScope.currentUser.userProperties.defaultLocale}})};return{getDispositionActions:getDispositionActions,getDispositionNoteConcept:getDispositionNoteConcept,getDispositionByVisit:getDispositionByVisit,getDispositionByPatient:getDispositionByPatient}}]),angular.module("bahmni.common.domain").service("visitService",["$http",function($http){this.getVisit=function(uuid,params){var parameters=params?params:"custom:(uuid,visitId,visitType,patient,encounters:(uuid,encounterType,voided,orders:(uuid,orderType,voided,concept:(uuid,set,name),),obs:(uuid,value,concept,obsDatetime,groupMembers:(uuid,concept:(uuid,name),obsDatetime,value:(uuid,name),groupMembers:(uuid,concept:(uuid,name),value:(uuid,name),groupMembers:(uuid,concept:(uuid,name),value:(uuid,name)))))))";return $http.get(Bahmni.Common.Constants.visitUrl+"/"+uuid,{params:{v:parameters}})},this.endVisit=function(visitUuid){return $http.post(Bahmni.Common.Constants.endVisitUrl+"?visitUuid="+visitUuid,{withCredentials:!0})},this.endVisitAndCreateEncounter=function(visitUuid,bahmniEncounterTransaction){return $http.post(Bahmni.Common.Constants.endVisitAndCreateEncounterUrl+"?visitUuid="+visitUuid,bahmniEncounterTransaction,{withCredentials:!0})},this.updateVisit=function(visitUuid,attributes){return $http.post(Bahmni.Common.Constants.visitUrl+"/"+visitUuid,attributes,{withCredentials:!0})},this.createVisit=function(visitDetails){return $http.post(Bahmni.Common.Constants.visitUrl,visitDetails,{withCredentials:!0})},this.getVisitSummary=function(visitUuid){return $http.get(Bahmni.Common.Constants.visitSummaryUrl,{params:{visitUuid:visitUuid},withCredentials:!0})},this.search=function(parameters){return $http.get(Bahmni.Common.Constants.visitUrl,{params:parameters,withCredentials:!0})},this.getVisitType=function(){return $http.get(Bahmni.Common.Constants.visitTypeUrl,{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});
|
||
|
valueCompletelyFilled()?$scope.model=getCompleteDate():$scope.isValid()?$scope.model="":$scope.model="Invalid Date"},$scope.isValid=function(){return valueNotFilled()||valueCompletelyFilled()},$scope.illegalMonth=function(){return(void 0===$scope.selectedMonth||null===$scope.selectedMonth)&&null!==$scope.selectedYear&&void 0!==$scope.selectedYear},$scope.illegalYear=function(){return null!==$scope.selectedMonth&&void 0!==$scope.selectedMonth&&(void 0===$scope.selectedYear||null===$scope.selectedYear)},$scope.model){var date=moment($scope.model).toDate();$scope.selectedMonth=date.getMonth(),$scope.selectedYear=date.getFullYear()}};return{restrict:"E",link:link,scope:{observation:"=",minYear:"=",maxYear:"=",illegalValue:"=",model:"="},template:'<span><select ng-model=\'selectedMonth\' ng-class="{\'illegalValue\': illegalMonth() || illegalValue}" ng-change="updateModel()" ng-options="monthNames.indexOf(month) as month for month in monthNames" ><option value="">{{\'CHOOSE_MONTH_KEY\' | translate}}</option>></select></span><span><select ng-model=\'selectedYear\' ng-class="{\'illegalValue\': illegalYear() || illegalValue}" ng-change="updateModel()" ng-options="year as year for year in years"><option value="">{{\'CHOOSE_YEAR_KEY\' | translate}}</option>></select></span>'}}]),angular.module("bahmni.common.uiHelper").directive("toggle",function(){var link=function($scope,element){$scope.toggle=void 0!==$scope.toggle&&$scope.toggle,$(element).click(function(){$scope.$apply(function(){$scope.toggle=!$scope.toggle})}),$scope.$watch("toggle",function(){$(element).toggleClass("active",$scope.toggle)}),$scope.$on("$destroy",function(){element.off("click")})};return{scope:{toggle:"="},link:link}}),angular.module("bahmni.common.uiHelper").directive("bmGallery",["$location","$rootScope","$compile",function($location,$rootScope,$compile){var controller=function($scope){$scope.albums=[],$scope.imagePosition={tag:void 0,index:0},this.image=function(record){var provider=record.provider;return{src:Bahmni.Common.Constants.documentsPath+"/"+record.imageObservation.value,title:record.concept.name,commentOnUpload:record.comment||record.imageObservation.comment,date:record.imageObservation.observationDateTime,uuid:record.imageObservation.uuid,providerName:provider?provider.name:null}},this.addImageObservation=function(record,tag){return this.addImage(this.image(record),tag)},this.addImage=function(image,tag,tagOrder){var matchedAlbum=getMatchingAlbum(tag);if(matchedAlbum){var index=image.imageIndex?image.imageIndex:matchedAlbum.images.length;matchedAlbum.images.splice(index,0,image)}else{var newAlbum={};newAlbum.tag=tag,newAlbum.images=[image],$scope.albums.splice(tagOrder,0,newAlbum)}return $scope.albums[0].images.length-1};var getMatchingAlbum=function(tag){return _.find($scope.albums,function(album){return album.tag==tag})};this.removeImage=function(image,tag,index){var matchedAlbum=getMatchingAlbum(tag);matchedAlbum&&matchedAlbum.images&&matchedAlbum.images.splice(index,1)},this.setIndex=function(tag,index){$scope.imagePosition.tag=tag,$scope.imagePosition.index=index},this.open=function(){$compile("<div bm-gallery-pane id='gallery-pane'></div>")($scope)}};return{controller:controller,scope:{patient:"=",accessImpression:"=?"}}}]).directive("bmGalleryItem",function(){var link=function($scope,element,attrs,imageGalleryController){var image={src:$scope.image.encodedValue,title:$scope.image.concept?$scope.image.concept.name:"",date:$scope.image.obsDatetime,uuid:$scope.image.obsUuid,providerName:$scope.image.provider?$scope.image.provider.name:"",imageIndex:$scope.image.imageIndex,commentOnUpload:$scope.image.comment};imageGalleryController.addImage(image,$scope.visitUuid,$scope.visitOrder),element.click(function(e){e.stopPropagation(),imageGalleryController.setIndex($scope.visitUuid,$scope.index),imageGalleryController.open()}),element.on("$destroy",function(){imageGalleryController.removeImage(image,$scope.visitUuid,$scope.index)})};return{link:link,scope:{image:"=",index:"@",visitUuid:"=",visitOrder:"@"},require:"^bmGallery"}}).directive("bmI
|
||
|
var setBackLinks=function(){var backLinks=[{label:"Home",url:"../home/",accessKey:"h",icon:"fa-home"}];appService.getAppDescriptor().getConfigValue("enableReportQueue")&&(backLinks.push({text:"REPORTS_HEADER_REPORTS",state:"dashboard.reports",accessKey:"d"}),backLinks.push({text:"REPORTS_HEADER_MY_REPORTS",state:"dashboard.myReports",accessKey:"m"})),$state.get("dashboard").data.backLinks=backLinks},init=function(){setBackLinks()};return init()}]),angular.module("bahmni.reports").config(["$urlRouterProvider","$stateProvider","$httpProvider","$bahmniTranslateProvider","$compileProvider",function($urlRouterProvider,$stateProvider,$httpProvider,$bahmniTranslateProvider,$compileProvider){$httpProvider.defaults.headers.common["Disable-WWW-Authenticate"]=!0,$urlRouterProvider.otherwise("/dashboard/reports"),$urlRouterProvider.when("/dashboard","/dashboard/reports"),$compileProvider.debugInfoEnabled(!1),$stateProvider.state("dashboard",{url:"/dashboard",abstract:!0,views:{"additional-header":{templateUrl:"views/dashboardHeader.html",controller:"DashboardHeaderController"},mainContent:{template:'<div class="opd-wrapper"><div ui-view="content" class="opd-content-wrapper"></div></div>'}},data:{backLinks:[]},resolve:{initializeConfig:function(initialization,$stateParams){return initialization($stateParams.appName)}}}).state("dashboard.reports",{url:"/reports?appName",views:{content:{templateUrl:"views/reports.html",controller:"ReportsController"}}}).state("dashboard.myReports",{url:"/myReports?appName",views:{content:{templateUrl:"views/myReports.html",controller:"MyReportsController"}}});var getAppName=function(){var val=location.hash.indexOf("appName=");return location.hash.substr(val).split("&")[0].split("=")[1]||"reports"};$bahmniTranslateProvider.init({app:getAppName(),shouldMerge:!0})}]).run(["$rootScope","$templateCache","$window",function($rootScope,$templateCache,$window){moment.locale($window.localStorage.NG_TRANSLATE_LANG_KEY||"en"),$rootScope.$on("$viewContentLoaded",function(){$templateCache.removeAll()})}]);
|