NINS_CODE/bahmniapps/orders/orders.min.96a7bef6.js

9 lines
259 KiB
JavaScript
Raw Normal View History

2024-12-12 22:37:39 +06:00
"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
return shouldMerge||void 0===shouldMerge?mergeService.merge(baseResponse.data,customResponse.data):[baseResponse.data,customResponse.data]},function(){return baseResponse.data}):baseResponse.data})},this.loadMandatoryConfig=function(path){return $http.get(path)},this.getAppName=function(){return this.appName},this.checkPrivilege=function(privilegeName){return hasPrivilegeOf(privilegeName)?$q.when(!0):(messagingService.showMessage("error",$translate.instant(Bahmni.Common.Constants.privilegeRequiredErrorMessage)+" [Privileges required: "+privilegeName+"]"),$q.reject())},this.initApp=function(appName,options,extensionFileSuffix,configPages){this.appName=appName;var appLoader=$q.defer(),extensionFileName=extensionFileSuffix&&"default"!==extensionFileSuffix.toLowerCase()?"/extension-"+extensionFileSuffix+".json":"/extension.json",promises=[],opts=options||{app:!0,extension:!0},inheritAppContext=!opts.inherit||opts.inherit;appDescriptor=new Bahmni.Common.AppFramework.AppDescriptor(appName,inheritAppContext,function(){return currentUser},mergeService);var loadCredentialsPromise=sessionService.loadCredentials(),loadProviderPromise=loadCredentialsPromise.then(sessionService.loadProviders);return promises.push(loadCredentialsPromise),promises.push(loadProviderPromise),opts.extension&&promises.push(loadExtensions(appDescriptor,extensionFileName)),opts.template&&promises.push(loadTemplate(appDescriptor)),opts.app&&promises.push(loadDefinition(appDescriptor)),_.isEmpty(configPages)||configPages.forEach(function(configPage){promises.push(loadPageConfig(configPage,appDescriptor))}),$q.all(promises).then(function(results){currentUser=results[0],appLoader.resolve(appDescriptor),$rootScope.$broadcast("event:appExtensions-loaded")},function(errors){appLoader.reject(errors)}),appLoader.promise}}]),angular.module("bahmni.common.appFramework").service("mergeService",[function(){this.merge=function(base,custom){var mergeResult=$.extend(!0,{},base,custom);return deleteNullValuedKeys(mergeResult)};var deleteNullValuedKeys=function(currentObject){return _.forOwn(currentObject,function(value,key){(_.isUndefined(value)||_.isNull(value)||_.isNaN(value)||_.isObject(value)&&_.isNull(deleteNullValuedKeys(value)))&&delete currentObject[key]}),currentObject}}]),angular.module("bahmni.common.appFramework").directive("appExtensionList",["appService",function(appService){var appDescriptor=appService.getAppDescriptor();return{restrict:"EA",template:'<ul><li ng-repeat="appExtn in appExtensions"><a href="{{formatUrl(appExtn.url, extnParams)}}" class="{{appExtn.icon}}" onclick="return false;" title="{{appExtn.label}}" ng-click="extnLinkClick(appExtn, extnParams)"> <span ng-show="showLabel">{{appExtn.label}}</span></a></li></ul>',scope:{extnPointId:"@",showLabel:"@",onExtensionClick:"&",contextModel:"&"},compile:function(cElement,cAttrs){var extnList=appDescriptor.getExtensions(cAttrs.extnPointId);return function(scope){scope.appExtensions=extnList;var model=scope.contextModel();scope.extnParams=model||{}}},controller:function($scope,$location){$scope.formatUrl=appDescriptor.formatUrl,$scope.extnLinkClick=function(extn,params){var proceedWithDefault=!0,clickHandler=$scope.onExtensionClick(),target=appDescriptor.formatUrl(extn.url,params);if(clickHandler){var event={src:extn,target:target,params:params,preventDefault:function(){proceedWithDefault=!1}};clickHandler(event)}proceedWithDefault&&$location.url(target)}}}}]),Bahmni.Common.AppFramework.AppDescriptor=function(context,inheritContext,retrieveUserCallback,mergeService){this.id=null,this.instanceOf=null,this.description=null,this.contextModel=null,this.baseExtensionPoints=[],this.customExtensionPoints=[],this.baseExtensions={},this.customExtensions={},this.customConfigs={},this.baseConfigs={},this.extensionPath=context,this.contextPath=inheritContext?context.split("/")[0]:context;var self=this,setExtensionPointsFromExtensions=function(currentExtensions,currentExtensionPoints){_.values(currentExtensions).forEach(function(extn){if(extn){var existing=self[currentExtensionPoints].filter(function(ep){return ep.i
},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.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{method:"GET",params:{v:"custom:(uuid,name:(uuid,name),setMembers:(uuid,name:(uuid,name)))",name:Bahmni.Common.Constants.allTestsAndPanelsConceptName},withCredentials:!0});return allTestsAndPanelsConcept},configurationFunctions.identifierTypesConfig=function(){return $http.get(Bahmni.Common.Constants.idgenConfigurationURL,{withCredentials:!0})},configurationFunctions.genderMap=function(){return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{method:"GET",params:{property:"mrs.genders"},withCredentials:!0})},configurationFunctions.relationshipTypeMap=function(){return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{method:"GET",params:{property:"bahmni.relationshipTypeMap"},withCredentials:!0})},configurationFunctions.relationshipTypeConfig=function(){return $http.get(Bahmni.Common.Constants.relationshipTypesUrl,{withCredentials:!0,params:{v:"custom:(aIsToB,bIsToA,uuid)"}})},configurationFunctions.loginLocationToVisitTypeMapping=function(){var url=Bahmni.Common.Constants.entityMappingUrl;return $http.get(url,{params:{mappingType:"loginlocation_visittype",s:"byEntityAndMappingType"}})},configurationFunctions.enableAuditLog=function(){return $http.get(Bahmni.Common.Constants.globalPropertyUrl,{method:"GET",params:{property:"bahmni.enableAuditLog"},withCredentials:!0})};var existingPromises={},configurations={},getConfigurations=function(configurationNames){var configurationsPromiseDefer=$q.defer(),promises=[];return configurationNames.forEach(function(configurationName){existingPromises[configurationName]||(existingPromises[configurationName]=configurationFunctions[configurationName]().then(function(response){configurations[configurationName]=response.data}),promises.push(existingPromises[configurationName]))}),$q.all(promises).then(function(){configurationsPromiseDefer.resolve(configurations)}),configurationsPromiseDefer.promise};return{getConfigurations:getConfigurations}}]),angular.module("bahmni.common.domain").service("visitDocumentService",["$http","auditLogService","configurations","$q",function($http,auditLogService,configurations,$q){var removeVoidedDocuments=function(documents){documents.forEach(function(document){if(document.voided&&document.image){var url=Bahmni.Common.Constants.RESTWS_V1+"/bahmnicore/visitDocument?filename="+document.image;$http.delete(url,{withCredentials:!0})}})};this.save=function(visitDocument){var url=Bahmni.Common.Constants.RESTWS_V1+"/bahmnicore/visitDocument",isNewVisit=!visitDocument.visitUuid;removeVoidedDocuments(visitDocument.documents);var visitTypeName=configurations.encounterConfig().getVisitTypeByUuid(visitDocument.visitTypeUuid).name,encounterTypeName=configurations.encounterConfig().getEncounterTypeByUuid(visitDocument.encounterTypeUuid).name;return $http.post(url,visitDocument).then(function(response){var promise=isNewVisit?auditLogService.log(visitDocument.patientUuid,"O
}},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[index],childNode);if(information.status)return errorMessage=information.message,!0}return information=validateChildNode(childNode,parentNode),information.status?(errorMessage=information.message,!0):!childNode.isValid($scope.atLeastOneValueIsSet,$scope.conceptSetRequired)});return{message:errorMessage,status:status}},validateChildNode=function(childNode,parentNode){var errorMessage;if(childNode.possibleAnswers&&!childNode.possibleAnswers.length){if("function"==typeof childNode.isValueInAbsoluteRange&&!childNode.isValueInAbsoluteRange())return errorMessage="The value you entered (red field) is outside the range of allowable values for that record. Please check the value.",{message:errorMessage,status:!0};if(childNode.isNumeric()){if(!childNode.isValidNumeric())return errorMessage="Please enter Integer value, decimal value is not allowed",{message:errorMessage,status:!0};if(parentNode){if(!childNode.isValidNumericValue()||!parentNode.isValidNumericValue())return errorMessage="Please enter Numeric values",{message:errorMessage,status:!0}}else if(!childNode.isValidNumericValue())return errorMessage="Please enter Numeric values",{message:errorMessage,status:!0}}}return{status:!1}};validationHandler.add(validateObservationTree);var cleanUpListenerShowPrevious=$scope.$on("event:showPrevious"+conceptSetName,function(){return spinner.forPromise(observationsService.fetch($scope.patient.uuid,$scope.conceptSetName,null,$scope.numberOfVisits,null,!0),id).then(function(response){var recentObservations=ObservationUtil.flattenObsToArray(response.data),conceptSetObservation=$scope.observations.filter(function(observation){return observation.conceptSetName===$scope.conceptSetName});ObservationUtil.flattenObsToArray(conceptSetObservation).forEach(function(obs){var correspondingRecentObs=_.filter(recentObservations,function(recentObs){return obs.concept.uuid===recentObs.concept.uuid});null!=correspondingRecentObs&&correspondingRecentObs.length>0&&(correspondingRecentObs.sort(function(obs1,obs2){return new Date(obs2.encounterDateTime)-new Date(obs1.encounterDateTime)}),obs.previous=correspondingRecentObs.map(function(previousObs){return{value:Bahmni.Common.Domain.ObservationValueMapper.map(previousObs),date:previousObs.observationDateTime}}))})})}),deregisterAddMore=$scope.$root.$on("event:addMore",function(event,observation){updateFormConditions([observation],observation)}),deregisterObservationUpdated=$scope.$root.$on("event:observationUpdated-"+conceptSetName,function(event,conceptName,rootObservation){var formName=rootObservation.concept.name,formCondition=Bahmni.ConceptSet.FormConditions.rules&&Bahmni.ConceptSet.FormConditions.rules[conceptName];if(formCondition){var flattenedObs=ObservationUtil.flattenObsToArray([rootObservation]);runFormConditionForObs(!0,formName,formCondition,conceptName,flattenedObs)}});$scope.$on("$destroy",function(){deregisterObservationUpdated(),deregisterAddMore(),cleanUpListenerShowPrevious()})};return{restrict:"E",scope:{conceptSetName:"=",observations:"=?",required:"=?",showTitle:"&",validationHandler:"&",patient:"=",conceptSetFocused:"=?",collapseInnerSections:"=?",atLeastOneValueIsSet:"=?",sectionId:"="},templateUrl:"../common/concept-set/views/conceptSet.html",controller:controller}}]),angular.module("bahmni.common.conceptSet").directive("concept",["RecursionHelper","spinner","$filter","messagingService","$rootScope","$translate",function(RecursionHelper,spinner,$filter,messagingService,$rootScope,$translate){var link=function(scope){var hideAbnormalbuttonConfig=scope.observation&&scope.observation.conceptUIConfig&&scope.observation.conceptUIConfig.hideAbnormalButton;scope.now=moment().format("YYYY-MM-DD
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()&&notYetSet(this.value))return!1;if(this.isRequired()&&notYetSet(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),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
var link=function($scope){$scope.showPatientDetails=!1,$scope.togglePatientDetails=function(){$scope.showPatientDetails=!$scope.showPatientDetails},$scope.onImageClick=function(){$scope.onImageClickHandler&&$scope.onImageClickHandler()}};return{restrict:"E",templateUrl:"../common/patient/header/views/patientSummary.html",link:link,required:"patient",scope:{patient:"=",bedDetails:"=",onImageClickHandler:"&"}}}),angular.module("bahmni.common.patient").directive("fallbackSrc",function(){return{restrict:"A",link:function(scope,element,attrs){_.isEmpty(attrs.ngSrc)&&element.attr("src",attrs.fallbackSrc),element.bind("error",function(){element.attr("src",attrs.fallbackSrc)})}}}),angular.module("bahmni.common.gallery",[]),angular.module("bahmni.common.gallery").directive("bmGalleryPane",["$rootScope","$document","observationsService","encounterService","spinner","configurations","ngDialog",function($rootScope,$document,observationsService,encounterService,spinner,configurations,ngDialog){function close(){$("body #gallery-pane").remove(),$body.removeClass("gallery-open"),keyboardJS.releaseKey("right"),keyboardJS.releaseKey("left")}var $body=$document.find("body");$rootScope.$on("$stateChangeStart",function(){close()});var link=function($scope,element){$scope.galleryElement=element,$body.prepend($scope.galleryElement).addClass("gallery-open"),keyboardJS.on("right",function(){$scope.$apply(function(){$scope.getTotalLength()>1&&$scope.showNext()})}),keyboardJS.on("left",function(){$scope.$apply(function(){$scope.getTotalLength()>1&&$scope.showPrev()})})},controller=function($scope){$scope.imageIndex=$scope.imagePosition.index?$scope.imagePosition.index:0,$scope.albumTag=$scope.imagePosition.tag?$scope.imagePosition.tag:"defaultTag",$scope.showImpression=!1,$scope.isActive=function(index,tag){return $scope.imageIndex==index&&$scope.albumTag==tag};var getAlbumIndex=function(){return _.findIndex($scope.albums,function(album){return album.tag==$scope.albumTag})};$scope.showPrev=function(){var albumIndex=getAlbumIndex();if($scope.imageIndex>0)--$scope.imageIndex;else{0==albumIndex&&(albumIndex=$scope.albums.length);var previousAlbum=$scope.albums[albumIndex-1];0==previousAlbum.images.length&&$scope.showPrev(albumIndex-1),$scope.albumTag=previousAlbum.tag,$scope.imageIndex=previousAlbum.images.length-1}},$scope.showNext=function(){var albumIndex=getAlbumIndex();if($scope.imageIndex<$scope.albums[albumIndex].images.length-1)++$scope.imageIndex;else{albumIndex==$scope.albums.length-1&&(albumIndex=-1);var nextAlbum=$scope.albums[albumIndex+1];0==nextAlbum.images.length&&$scope.showNext(albumIndex+1),$scope.albumTag=nextAlbum.tag,$scope.imageIndex=0}},$scope.isPdf=function(image){return image.src&&image.src.indexOf(".pdf")>0},$scope.getTotalLength=function(){var totalLength=0;return angular.forEach($scope.albums,function(album){totalLength+=album.images.length}),totalLength},$scope.getCurrentIndex=function(){for(var currentIndex=1,i=0;i<getAlbumIndex();i++)currentIndex+=$scope.albums[i].images.length;return currentIndex+parseInt($scope.imageIndex)},$scope.close=function(){close($scope)},$scope.toggleImpression=function(){$scope.showImpression=!$scope.showImpression},$scope.hasObsRelationship=function(image){return image.commentOnUpload||image.sourceObs&&image.sourceObs.length>0},$scope.saveImpression=function(image){var bahmniEncounterTransaction=mapBahmniEncounterTransaction(image);spinner.forPromise(encounterService.create(bahmniEncounterTransaction).then(function(){constructNewSourceObs(image),fetchObsRelationship(image)}))};var init=function(){$scope.accessImpression&&$scope.albums.forEach(function(album){album.images.forEach(function(image){fetchObsRelationship(image),constructNewSourceObs(image)})}),ngDialog.openConfirm({template:"../common/gallery/views/gallery.html",scope:$scope,closeByEscape:!0,className:"gallery-dialog ngdialog-theme-default"})},fetchObsRelationship=function(image){observationsService.getObsRelationship(image.uuid).then(function(response){image.sourceObs=response.data})},constructNewSourceObs=function(image){image
value&&$timeout(function(){$(elem).focus()})})}}]),angular.module("bahmni.common.uiHelper").directive("dateConverter",[function(){return{require:"ngModel",link:function(scope,element,attrs,ngModelController){var DateUtil=Bahmni.Common.Util.DateUtil;ngModelController.$parsers.push(function(date){return DateUtil.parse(date)}),ngModelController.$formatters.push(function(date){return DateUtil.parse(DateUtil.getDateWithoutTime(date))})}}}]),angular.module("bahmni.common.uiHelper").directive("providerDirective",function(){var template='<span><span ng-if=":: creatorName && providerName && (creatorName != providerName)">{{::creatorName}} {{"ON_BEHALF_OF_TRANSLATION_KEY"|translate}} </span>{{::providerName}} <span ng-if=":: providerDate"> {{::providerDate | bahmniTime}} </span></span>';return{restrict:"EA",replace:!0,scope:{creatorName:"@",providerName:"@",providerDate:"=?"},template:template}}),angular.module("bahmni.common.uiHelper").controller("MessageController",["$scope","messagingService",function($scope,messagingService){$scope.messages=messagingService.messages,$scope.getMessageText=function(level){var string="";return $scope.messages[level].forEach(function(message){string=string.concat(message.value)}),string},$scope.hideMessage=function(level){messagingService.hideMessages(level)},$scope.isErrorMessagePresent=function(){return $scope.messages.error.length>0},$scope.isInfoMessagePresent=function(){return $scope.messages.info.length>0}}]),angular.module("bahmni.common.uiHelper").service("messagingService",["$rootScope","$timeout",function($rootScope,$timeout){this.messages={error:[],info:[]};var self=this;$rootScope.$on("event:serverError",function(event,errorMessage){self.showMessage("error",errorMessage,"serverError")}),this.showMessage=function(level,message,errorEvent){var messageObject={value:"",isServerError:!1};messageObject.value=message,errorEvent?messageObject.isServerError=!0:"info"==level&&this.createTimeout("info",4e3);var index=_.findIndex(this.messages[level],function(msg){return msg.value==messageObject.value});index>=0&&this.messages[level].splice(index,1),this.messages[level].push(messageObject)},this.createTimeout=function(level,time){$timeout(function(){self.messages[level]=[]},time,!0)},this.hideMessages=function(level){self.messages[level].length=0},this.clearAll=function(){self.messages.error=[],self.messages.info=[]}}]);var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},Bahmni.Common.UIControls=Bahmni.Common.UIControls||{},angular.module("bahmni.common.uicontrols",[]),function(){var constructSearchResult=function(concept){var conceptName=concept.shortName||concept.name.name||concept.name;return{label:conceptName,value:conceptName,concept:concept,uuid:concept.uuid,name:conceptName}},find=function(allAnswers,savedAnswer){return _.find(allAnswers,function(answer){return savedAnswer&&savedAnswer.uuid===answer.concept.uuid})},toBeInjected=["conceptService"],conceptDropdown=function(conceptService){var controller=function($scope){$scope.onChange=$scope.onChange();var response=function(answers){$scope.answers=answers,$scope.selectedAnswer=find(answers,$scope.selectedAnswer)};return!$scope.answersConceptName&&$scope.defaultConcept?void conceptService.getAnswers($scope.defaultConcept).then(function(results){return _.map(results,constructSearchResult)}).then(response):void conceptService.getAnswersForConceptName({answersConceptName:$scope.answersConceptName}).then(function(results){return _.map(results,constructSearchResult)}).then(response)};return{controller:controller,restrict:"E",scope:{selectedAnswer:"=model",answersConceptName:"=?",defaultConcept:"=",onChange:"&",onInvalidClass:"@",isValid:"=",ngDisabled:"="},templateUrl:"../common/uicontrols/concept-dropdown/views/conceptDropdown.html"}};conceptDropdown.$inject=toBeInjected,angular.module("bahmni.common.uicontrols").directive("conceptDropdown",conceptDropdown)}(),angular.module("bahmni.common.routeErrorHandler",["ui.router"]).run(["$rootScope",function($rootScope){$rootScope.$on("$stateChangeError",function(event){event.preventDefault()})}]),Bahm
});return multiSelectObject.formFieldPath=observations[0].formFieldPath,multiSelectObject.encounterUuid=observations[0].encounterUuid,multiSelectObject},self.preProcessMultiSelectObs=function(value){var clonedGroupMembers=_.cloneDeep(value);return _.forEach(clonedGroupMembers,function(member){if(member&&0===member.groupMembers.length){var obsWithSameFormFieldPath=self.getRecordObservations(member.formFieldPath,value);if(obsWithSameFormFieldPath.length>1){var multiSelectObject=self.createMultiSelectObservation(obsWithSameFormFieldPath);value.push(multiSelectObject)}else 1===obsWithSameFormFieldPath.length&&value.push(obsWithSameFormFieldPath[0])}else if(member.groupMembers.length>0){var obsGroups=self.getRecordObservations(member.formFieldPath,value);_.forEach(obsGroups,function(obsGroup){obsGroup.groupMembers=self.preProcessMultiSelectObs(obsGroup.groupMembers),value.push(obsGroup)})}}),value},self.createObsGroupForForm=function(observations,formBuilderFroms){return _.forEach(observations,function(obs){var newValues=[];_.forEach(obs.value,function(value){if(!value.formFieldPath)return void newValues.push(value);var obsGroup={groupMembers:[],concept:{shortName:"",conceptClass:null},encounterUuid:""},formName=value.formFieldPath.split(".")[0],formBuilderForm=formBuilderFroms.find(function(form){return form.name===formName});obsGroup.concept.shortName=formName;var locale=localStorage.getItem("NG_TRANSLATE_LANG_KEY")||"en",formNameTranslations=formBuilderForm&&formBuilderForm.nameTranslation?JSON.parse(formBuilderForm.nameTranslation):[];if(formNameTranslations.length>0){var currentLabel=formNameTranslations.find(function(formNameTranslation){return formNameTranslation.locale===locale});currentLabel&&(obsGroup.concept.shortName=currentLabel.display)}obsGroup.encounterUuid=value.encounterUuid;var previousObsGroupFound;_.forEach(newValues,function(newValue){obsGroup.concept.shortName===newValue.concept.shortName&&(newValue.groupMembers.push(value),previousObsGroupFound=!0)}),previousObsGroupFound||(obsGroup.groupMembers.push(value),newValues.push(obsGroup))}),obs.value=newValues}),observations};var updateObservationsWithFormDefinition=function(observations,formBuildFroms){var allForms=formBuildFroms;_.forEach(observations,function(observation){var forms=[];_.forEach(observation.value,function(form){if(form.concept.conceptClass)return void forms.push(form);var observationForm=self.getFormByFormName(allForms,self.getFormName(form.groupMembers),self.getFormVersion(form.groupMembers));observationForm&&formService.getFormDetail(observationForm.uuid,{v:"custom:(resources:(value))"}).then(function(response){var formDetailsAsString=_.get(response,"data.resources[0].value");if(formDetailsAsString){var formDef=JSON.parse(formDetailsAsString);formDef.version=observationForm.version;var locale=$window.localStorage.NG_TRANSLATE_LANG_KEY||"en";return formService.getFormTranslate(formDef.name,formDef.version,locale,formDef.uuid).then(function(response){var translationData=response.data;forms.push(self.updateObservationsWithRecordTree(formDef,form,translationData)),observation.value=forms})}observation.value=forms})})})};self.getFormByFormName=function(formList,formName,formVersion){return _.find(formList,function(form){return form.name===formName&&form.version===formVersion})},self.getFormName=function(members){var member=_.find(members,function(member){return null!==member.formFieldPath});return member?member.formFieldPath.split(".")[0]:void 0},self.getFormVersion=function(members){var member=_.find(members,function(member){return null!==member.formFieldPath});return member?member.formFieldPath.split(".")[1].split("/")[0]:void 0},self.updateObservationsWithRecordTree=function(formDef,form,translationData){var recordTree=getRecordTree(formDef,form.groupMembers);return recordTree=JSON.parse(JSON.stringify(recordTree)),self.createGroupMembers(recordTree,form,form.groupMembers,translationData),form},self.createColumnGroupsForTable=function(record,columns,tableGroup,obsList,translationData){_.forEach(columns,function(column,index){var obsGroup=
var baseFileData=result[0]?result[0].data:void 0,customFileData=result[1]?result[1].data:void 0;return options.shouldMerge||void 0===options.shouldMerge?mergeService.merge(baseFileData,customFileData):[baseFileData,customFileData]};return $q.all([loadBahmniTranslations(),loadCustomTranslations()]).then(mergeTranslations)};return mergeLocaleFile(options)}}]),angular.module("orders",["ui.router","bahmni.orders","bahmni.common.domain","bahmni.common.patient","authentication","bahmni.common.config","bahmni.common.appFramework","httpErrorInterceptor","bahmni.common.routeErrorHandler","bahmni.common.uiHelper","bahmni.common.patientSearch","bahmni.common.util","bahmni.common.conceptSet","RecursionHelper","infinite-scroll","bahmni.common.displaycontrol.patientprofile","bahmni.common.obs","bahmni.common.displaycontrol.orders","bahmni.common.i18n","bahmni.common.displaycontrol.observation","bahmni.common.orders","pascalprecht.translate","ngCookies","bahmni.common.uicontrols","bahmni.common.logging","bahmni.common.gallery"]).config(["$urlRouterProvider","$stateProvider","$httpProvider","$bahmniTranslateProvider","$compileProvider",function($urlRouterProvider,$stateProvider,$httpProvider,$bahmniTranslateProvider,$compileProvider){$httpProvider.defaults.headers.common["Disable-WWW-Authenticate"]=!0,$urlRouterProvider.otherwise("/search");var homeBacklink={label:"Home",url:"../home/",accessKey:"h",icon:"fa-home"},searchBacklink={label:"Search",state:"search",accessKey:"p",icon:"fa-users"};$compileProvider.debugInfoEnabled(!1),$stateProvider.state("search",{url:"/search",data:{extensionPointId:"org.bahmni.orders.search",backLinks:[homeBacklink]},views:{content:{templateUrl:"../common/patient-search/views/patientsList.html",controller:"PatientsListController"}},resolve:{initialization:"initialization"}}).state("orderFulfillment",{url:"/patient/:patientUuid/fulfillment/:orderType",data:{backLinks:[homeBacklink,searchBacklink]},views:{"additional-header":{templateUrl:"views/header.html",controller:function($scope,$rootScope,patientContext){$scope.patient=patientContext.patient,$scope.save=function(){$rootScope.$broadcast("event:saveOrderObservations")}}},content:{templateUrl:"views/orderFulfillment.html",controller:"OrderFulfillmentController",resolve:{orderFulfillmentConfig:function(orderFulfillmentConfig,$stateParams){var formName=$stateParams.orderType+Bahmni.Common.Constants.fulfillmentFormSuffix;return orderFulfillmentConfig(formName)}}}},resolve:{initialization:"initialization",patientContext:function(initialization,patientInitialization,$stateParams){return patientInitialization($stateParams.patientUuid)}}}),$bahmniTranslateProvider.init({app:"orders",shouldMerge:!0})}]).run(["backlinkService","$window",function(backlinkService,$window){moment.locale($window.localStorage.NG_TRANSLATE_LANG_KEY||"en"),backlinkService.addUrl({label:"Patient Search",url:"../home/"})}]);var Bahmni=Bahmni||{};Bahmni.Orders=Bahmni.Orders||{},angular.module("bahmni.orders",["bahmni.common.uiHelper","bahmni.common.util","bahmni.common.appFramework","bahmni.common.conceptSet","ui.router","infinite-scroll","ngDialog"]),angular.module("bahmni.orders").factory("orderFulfillmentConfig",["conceptSetService",function(conceptSetService){return function(formName){return conceptSetService.getConcept({name:formName,v:Bahmni.Common.Constants.conceptSetRepresentationForOrderFulfillmentConfig}).then(function(response){var config={},formMembers=response.data.results[0].setMembers;return config.conceptNames=_.map(formMembers,function(concept){return concept.name.name}),config.isObservation=!0,config.showDetailsButton=!0,config.hideIfEmpty=!1,config.showHeader=!1,config.scope="latest",config})}}]),angular.module("bahmni.orders").factory("initialization",["$rootScope","$q","appService","spinner","configurations","orderTypeService","locationService",function($rootScope,$q,appService,spinner,configurations,orderTypeService,locationService){var getConfigs=function(){var config=$q.defer(),configNames=["encounterConfig","patientConfig","genderMap","relationshipTypeMap"];return c