NINS_CODE/bahmniapps/adt/adt.min.288341b9.js

9 lines
264 KiB
JavaScript
Raw Normal View History

2024-12-12 22:37:39 +06:00
"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
},this.initializeRetrospectiveEntry=function(){var retrospectiveEncounterDateCookie=$bahmniCookieStore.get(Bahmni.Common.Constants.retrospectiveEntryEncounterDateCookieName);retrospectiveEncounterDateCookie&&($rootScope.retrospectiveEntry=Bahmni.Common.Domain.RetrospectiveEntry.createFrom(dateUtil.getDate(retrospectiveEncounterDateCookie)))},this.resetRetrospectiveEntry=function(date){$bahmniCookieStore.remove(Bahmni.Common.Constants.retrospectiveEntryEncounterDateCookieName,{path:"/",expires:1}),$rootScope.retrospectiveEntry=void 0,date&&!dateUtil.isSameDate(date,dateUtil.today())&&($rootScope.retrospectiveEntry=Bahmni.Common.Domain.RetrospectiveEntry.createFrom(dateUtil.getDate(date)),$bahmniCookieStore.put(Bahmni.Common.Constants.retrospectiveEntryEncounterDateCookieName,date,{path:"/",expires:1}))}}]),angular.module("bahmni.common.domain").service("diagnosisService",["$http","$rootScope",function($http,$rootScope){var self=this;this.getAllFor=function(searchTerm,locale){var url=Bahmni.Common.Constants.emrapiConceptUrl,parameters={term:searchTerm,limit:20};return locale&&(parameters.locale=locale),$http.get(url,{params:parameters})},this.getDiagnoses=function(patientUuid,visitUuid){var url=Bahmni.Common.Constants.bahmniDiagnosisUrl;return $http.get(url,{params:{patientUuid:patientUuid,visitUuid:visitUuid}})},this.deleteDiagnosis=function(obsUuid){var url=Bahmni.Common.Constants.bahmniDeleteDiagnosisUrl;return $http.get(url,{params:{obsUuid:obsUuid}})},this.getDiagnosisConceptSet=function(){return $http.get(Bahmni.Common.Constants.conceptUrl,{method:"GET",params:{v:"custom:(uuid,name,setMembers)",code:Bahmni.Common.Constants.diagnosisConceptSet,source:Bahmni.Common.Constants.emrapiConceptMappingSource},withCredentials:!0})},this.getPastAndCurrentDiagnoses=function(patientUuid,encounterUuid){return self.getDiagnoses(patientUuid).then(function(response){var diagnosisMapper=new Bahmni.DiagnosisMapper($rootScope.diagnosisStatus),allDiagnoses=diagnosisMapper.mapDiagnoses(response.data),pastDiagnoses=diagnosisMapper.mapPastDiagnosis(allDiagnoses,encounterUuid),savedDiagnosesFromCurrentEncounter=diagnosisMapper.mapSavedDiagnosesFromCurrentEncounter(allDiagnoses,encounterUuid);return{pastDiagnoses:pastDiagnoses,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("conditionsService",["$http",function($http){this.save=function(conditions,patientUuid){var body=_.map(conditions,function(condition){return{uuid:condition.uuid,patientUuid:patientUuid,concept:condition.concept,conditionNonCoded:condition.conditionNonCoded,status:condition.status,onSetDate:condition.onSetDate,endDate:condition.endDate,endReason:condition.endReason,additionalDetail:condition.additionalDetail,voided:condition.voided,voidReason:condition.voidReason}});return $http.post(Bahmni.Common.Constants.conditionUrl,body,{withCredentials:!0,headers:{Accept:"application/json","Content-Type":"application/json"}})},this.getConditionHistory=function(patientUuid){var params={patientUuid:patientUuid};return $http.get(Bahmni.Common.Constants.conditionHistoryUrl,{params:params,headers:{withCredentials:!0}})},this.getFollowUpConditionConcept=function(){return $http.get(Bahmni.Common.Constants.conceptSearchByFullNameUrl,{params:{name:Bahmni.Common.Constants.followUpConditionConcept,v:"custom:(uuid,name:(name))"},cache:!0})};var getLatestActiveCondition=function(conditionHistories,latestCondition){var conditionHistory=_.find(conditionHistories,{conceptUuid:latestCondition.concept.uuid,conditionNonCoded:latestCondition.conditionNonCoded});return Bahmni.Common.Domain.Conditions.getPreviousActiveCondition(latestCondition,conditionHistory.conditions)};this.getConditions=funct
});firstObs&&(firstObs.isFocused=!0)}},updateObservationsOnRootScope=function(){if($scope.rootObservation){for(var i=0;i<$scope.observations.length;i++)if($scope.observations[i].concept.uuid===$scope.rootObservation.concept.uuid)return void($scope.observations[i]=$scope.rootObservation);$scope.observations.push($scope.rootObservation)}},getObservationsOfCurrentTemplate=function(){return _.filter($scope.observations,function(observation){return _.toLower(observation.conceptSetName)===_.toLower($scope.rootObservation.concept.name)})},getDefaults=function(){var conceptSetUI=appService.getAppDescriptor().getConfigValue("conceptSetUI");if(conceptSetUI&&conceptSetUI.defaults)return conceptSetUI.defaults||{}},getCodedAnswerWithDefaultAnswerString=function(defaults,groupMember){var defaultCodedAnswer,possibleAnswers=groupMember.possibleAnswers,defaultAnswer=defaults[groupMember.concept.name];return defaultAnswer instanceof Array?(defaultCodedAnswer=[],_.each(defaultAnswer,function(answer){defaultCodedAnswer.push(_.find(possibleAnswers,{displayString:answer}))})):defaultCodedAnswer=_.find(possibleAnswers,{displayString:defaultAnswer}),defaultCodedAnswer},setDefaultsForGroupMembers=function(groupMembers,defaults){defaults&&_.each(groupMembers,function(groupMember){var conceptFullName=groupMember.concept.name,present=_.includes(_.keys(defaults),conceptFullName);present&&void 0==groupMember.value&&("Coded"==groupMember.concept.dataType?setDefaultsForCodedObservations(groupMember,defaults):groupMember.value=defaults[conceptFullName]),groupMember.groupMembers&&groupMember.groupMembers.length>0&&(setDefaultsForGroupMembers(groupMember.groupMembers,defaults),groupMember instanceof Bahmni.ConceptSet.ObservationNode&&defaults[groupMember.label]&&groupMember.abnormalObs&&void 0==groupMember.abnormalObs.value&&groupMember.onValueChanged(groupMember.value))})},setDefaultsForCodedObservations=function(observation,defaults){var defaultCodedAnswer=getCodedAnswerWithDefaultAnswerString(defaults,observation);observation.isMultiSelect?observation.hasValue()||_.each(defaultCodedAnswer,function(answer){observation.selectAnswer(answer)}):defaultCodedAnswer instanceof Array||(observation.value=defaultCodedAnswer)},getFlattenedObsValues=function(flattenedObs){return _.reduce(flattenedObs,function(flattenedObsValues,obs){if(void 0==flattenedObsValues[obs.concept.name+"|"+obs.uniqueId])if(obs.isMultiSelect){var selectedObsConceptNames=[];_.each(obs.selectedObs,function(observation){observation.voided||selectedObsConceptNames.push(observation.value.name),observation.voided||selectedObsConceptNames.push(observation.value.name)}),flattenedObsValues[obs.concept.name+"|"+obs.uniqueId]=selectedObsConceptNames}else if(obs.conceptUIConfig.multiSelect){var alreadyProcessedMultiSelect=[];_.each(_.keys(flattenedObsValues),function(eachObsKey){eachObsKey.split("|")[0]==obs.concept.name&&alreadyProcessedMultiSelect.push(eachObsKey)}),alreadyProcessedMultiSelect.length<2&&(flattenedObsValues[obs.concept.name+"|"+obs.uniqueId]=flattenedObsValues[obs.concept.name+"|undefined"])}else obs.value instanceof Object?flattenedObsValues[obs.concept.name+"|"+obs.uniqueId]=obs.value.name instanceof Object?obs.value.name.name:obs.value.name:flattenedObsValues[obs.concept.name+"|"+obs.uniqueId]=obs.value;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.forEac
canAddMore:function(){return 1==this.conceptUIConfig.allowAddMore},isStepperControl:function(){if(this.isNumeric())return 1==this.conceptUIConfig.stepper},isConciseText:function(){return 1==this.conceptUIConfig.conciseText},_getCodedControlType:function(){var conceptUIConfig=this.conceptUIConfig;return conceptUIConfig.autocomplete?"autocomplete":conceptUIConfig.dropdown?"dropdown":"buttonselect"},onValueChanged:function(){this.isNumeric()&&this.setErroneousValue()},setErroneousValue:function(){if(this.hasValue()){var erroneousValue=this.value>(this.concept.hiAbsolute||1/0)||this.value<(this.concept.lowAbsolute||0);this.erroneousValue=erroneousValue}else this.erroneousValue=void 0},getInputType:function(){return this.getDataTypeName()},atLeastOneValueSet:function(){return this.isGroup()?this.groupMembers.some(function(childNode){return childNode.atLeastOneValueSet()}):this.hasValue()&&!this.isVoided()},hasValue:function(){var value=this.value;return value===!1||(0===value||!(""===value||!value)&&(!(value instanceof Array)||value.length>0))},hasValueOf:function(value){return!(!this.value||!value)&&(this.value==value||this.value.uuid==value.uuid)},toggleSelection:function(answer){this.value&&this.value.uuid===answer.uuid?this.value=null:this.value=answer},isValidDate:function(){if(this.isComputed())return!0;if(!this.hasValue())return!0;var date=Bahmni.Common.Util.DateUtil.parse(this.value);if(!this.conceptUIConfig.allowFutureDates){var today=Bahmni.Common.Util.DateUtil.parse(moment().format("YYYY-MM-DD"));if(today<date)return!1}return date.getUTCFullYear()&&date.getUTCFullYear().toString().length<=4},hasInvalidDateTime:function(){if(this.isComputed())return!1;var date=Bahmni.Common.Util.DateUtil.parse(this.value);return!this.conceptUIConfig.allowFutureDates&&moment()<date||"Invalid Datetime"===this.value},isValid:function(checkRequiredFields,conceptSetRequired){if(this.isNumeric()&&!this.isValidNumeric())return!1;if(this.error)return!1;if(this.hidden)return!0;if(checkRequiredFields){if(this.isGroup())return this._hasValidChildren(checkRequiredFields,conceptSetRequired);if(conceptSetRequired&&this.isRequired()&&!this.hasValue())return!1;if(this.isRequired()&&!this.hasValue())return!1}return this._isDateDataType()?this.isValidDate():this._isDateTimeDataType()?!this.hasInvalidDateTime():!this.erroneousValue&&("autocomplete"!==this.getControlType()||(_.isEmpty(this.value)||_.isObject(this.value)))},isValueInAbsoluteRange:function(){return!this.erroneousValue&&(!this.isGroup()||this._areChildNodesInAbsoluteRange())},_isDateDataType:function(){return"Date"===this.getDataTypeName()},_isDateTimeDataType:function(){return"Datetime"===this.getDataTypeName()},isRequired:function(){return this.disabled=!!this.disabled&&this.disabled,this.conceptUIConfig.required===!0&&this.disabled===!1},isFormElement:function(){return(!this.concept.set||this.isGrid())&&!this.isComputed()},_hasValidChildren:function(checkRequiredFields,conceptSetRequired){return this.groupMembers.every(function(member){return member.isValid(checkRequiredFields,conceptSetRequired)})},_areChildNodesInAbsoluteRange:function(){return this.groupMembers.every(function(member){return"function"!=typeof member.isValueInAbsoluteRange||member.isValueInAbsoluteRange()})},markAsNonCoded:function(){this.markedAsNonCoded=!this.markedAsNonCoded},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 possibleAnsw
searchType.patientCount=response.data.length,$scope.search.isSelectedSearch(searchType)&&$scope.search.updatePatientList(response.data),patientListSpinner&&hideSpinner(spinner,patientListSpinner,$(".tab-content"))})}},hideSpinner=function(spinnerObj,data,container){spinnerObj.hide(data,container),$(container).children("patient-list-spinner").hide()};$scope.getHeadings=function(patients){if(patients&&patients.length>0){var headings=_.chain(patients[0]).keys().filter(function(heading){return _.indexOf(Bahmni.Common.PatientSearch.Constants.tabularViewIgnoreHeadingsList,heading)===-1}).value();return headings}return[]},$scope.isHeadingOfLinkColumn=function(heading){var identifierHeading=_.includes(Bahmni.Common.PatientSearch.Constants.identifierHeading,heading);return identifierHeading?identifierHeading:$scope.search.searchType&&$scope.search.searchType.links?_.find($scope.search.searchType.links,{linkColumn:heading}):$scope.search.searchType&&$scope.search.searchType.linkColumn?_.includes([$scope.search.searchType.linkColumn],heading):void 0},$scope.isHeadingOfName=function(heading){return _.includes(Bahmni.Common.PatientSearch.Constants.nameHeading,heading)},$scope.getPrintableHeadings=function(patients){var headings=$scope.getHeadings(patients),printableHeadings=headings.filter(function(heading){return _.indexOf(Bahmni.Common.PatientSearch.Constants.printIgnoreHeadingsList,heading)===-1});return printableHeadings},$scope.printPage=function(){null!=$scope.search.searchType.printHtmlLocation&&printer.printFromScope($scope.search.searchType.printHtmlLocation,$scope)};var mapExtensionToSearchType=function(appExtn){return{name:appExtn.label,display:appExtn.extensionParams.display,handler:appExtn.extensionParams.searchHandler,forwardUrl:appExtn.extensionParams.forwardUrl,id:appExtn.id,params:appExtn.extensionParams.searchParams,refreshTime:appExtn.extensionParams.refreshTime||0,view:appExtn.extensionParams.view||Bahmni.Common.PatientSearch.Constants.searchExtensionTileViewType,showPrint:appExtn.extensionParams.showPrint||!1,printHtmlLocation:appExtn.extensionParams.printHtmlLocation||null,additionalParams:appExtn.extensionParams.additionalParams,searchColumns:appExtn.extensionParams.searchColumns,translationKey:appExtn.extensionParams.translationKey,linkColumn:appExtn.extensionParams.linkColumn,links:appExtn.extensionParams.links}},debounceGetPatientCount=_.debounce(function(currentSearchType,patientListSpinner){getPatientCount(currentSearchType,patientListSpinner)},patientSearchConfig&&patientSearchConfig.fetchDelay||DEFAULT_FETCH_DELAY,{}),showSpinner=function(spinnerObj,container){return $(container).children("patient-list-spinner").show(),spinnerObj.show(container)},fetchPatients=function(currentSearchType){void 0!==patientListSpinner&&hideSpinner(spinner,patientListSpinner,$(".tab-content")),$rootScope.currentSearchType=currentSearchType,$scope.search.isCurrentSearchLookUp()&&(patientListSpinner=showSpinner(spinner,$(".tab-content")),patientSearchConfig&&patientSearchConfig.debounceSearch?debounceGetPatientCount(currentSearchType,patientListSpinner):getPatientCount(currentSearchType,patientListSpinner))};$scope.forwardPatient=function(patient,heading){var options=$.extend({},$stateParams);$rootScope.patientAdmitLocationStatus=patient.Status,$.extend(options,{patientUuid:patient.uuid,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(searc
var sameConceptsSubArray=[],j=i+1;for(sameConceptsSubArray.push(observation[i]);j<observation.length&&observation[i].conceptUuid===observation[j].conceptUuid;)sameConceptsSubArray.push(observation[j++]);sameConceptsSubArray=_.sortBy(sameConceptsSubArray,"observationDateTime"),sortedObservations.push(sameConceptsSubArray),i=j-1}else sortedObservations.push(observation[i]);return _.flatten(sortedObservations)},getValue=function(observation){if(observation.selectedObs)return observation.getValues();var obsValue;return obsValue=observation.value&&observation.value.name&&observation.value.name.name?observation.value.name.name:observation.value&&observation.value.name&&!observation.value.name.name?observation.value.name:observation.value,void 0===obsValue||null===obsValue?obsValue:obsValue.displayString||obsValue},collect=function(flattenedObservations,key,value){void 0!=value&&(flattenedObservations[key]=flattenedObservations[key]?_.uniq(_.flatten(_.union([flattenedObservations[key]],[value]))):value)},findLeafObservations=function(flattenedObservations,observation){_.isEmpty(observation.groupMembers)?collect(flattenedObservations,observation.concept.name,getValue(observation)):_.each(observation.groupMembers,function(member){findLeafObservations(flattenedObservations,member)})},flatten=function(observation){var flattenedObservation={};return _.isEmpty(observation)||findLeafObservations(flattenedObservation,observation),flattenedObservation},flattenObsToArray=function(observations){var flattened=[];return flattened.push.apply(flattened,observations),observations.forEach(function(obs){obs.groupMembers&&obs.groupMembers.length>0&&flattened.push.apply(flattened,flattenObsToArray(obs.groupMembers))}),flattened};return{sortSameConceptsWithObsDateTime:sortSameConceptsWithObsDateTime,flatten:flatten,flattenObsToArray:flattenObsToArray}}();var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},Bahmni.Common.DisplayControl=Bahmni.Common.DisplayControl||{},Bahmni.Common.DisplayControl.Dashboard=Bahmni.Common.DisplayControl.Dashboard||{},angular.module("bahmni.common.displaycontrol.dashboard",[]),angular.module("bahmni.common.displaycontrol.dashboard").directive("dashboard",[function(){var controller=function($scope,$filter){var init=function(){$scope.dashboard=Bahmni.Common.DisplayControl.Dashboard.create($scope.config||{},$filter)},checkDisplayType=function(sections,typeToCheck,index){return sections[index]&&sections[index].displayType&&sections[index].displayType===typeToCheck},isDisplayTypeWrong=function(sections){var allDisplayTypes=["Full-Page","LAYOUT_75_25","LAYOUT_25_75","Half-Page"];return allDisplayTypes.indexOf(sections[0].displayType)<=-1};$scope.isFullPageSection=function(sections){return checkDisplayType(sections,"Full-Page",0)},$scope.hasThreeFourthPageSection=function(sections,index){return checkDisplayType(sections,"LAYOUT_75_25",index)},$scope.isOneFourthPageSection=function(sections){return checkDisplayType(sections,"LAYOUT_25_75",0)},$scope.isHalfPageSection=function(sections){return sections[0]&&(checkDisplayType(sections,"Half-Page",0)||isDisplayTypeWrong(sections)||!sections[0].displayType)},$scope.containsThreeFourthPageSection=function(sections){var hasThreeFourthSection=this.hasThreeFourthPageSection(sections,0)||this.hasThreeFourthPageSection(sections,1);return 1==sections.length?this.hasThreeFourthPageSection(sections,0):hasThreeFourthSection},$scope.filterOdd=function(index){return function(){return index++%2===0}},$scope.filterEven=function(index){return function(){return index++%2===1}};var unbindWatch=$scope.$watch("config",init);$scope.$on("$stateChangeStart",unbindWatch)};return{restrict:"E",controller:controller,templateUrl:"../common/displaycontrols/dashboard/views/dashboard.html",scope:{config:"=",patient:"=",diseaseTemplates:"=",sectionGroups:"=",visitHistory:"=",activeVisitUuid:"=",visitSummary:"=",enrollment:"="}}}]),angular.module("bahmni.common.displaycontrol.dashboard").directive("dashboardSection",function(){var controller=function($scope){$scope.$on("no-data-present-event",function(){$scope.
scope:{params:"=",patientUuid:"=?",visitUuid:"=?"}}}]),angular.module("bahmni.common.displaycontrol.conditionsList",[]),angular.module("bahmni.common.displaycontrol.conditionsList").directive("conditionsList",["conditionsService","ngDialog",function(conditionsService,ngDialog){var controller=function($scope){return $scope.statuses=["ACTIVE","HISTORY_OF"],$scope.openSummaryDialog=function(){ngDialog.open({template:"../common/displaycontrols/conditionsList/views/conditionsList.html",className:"ngdialog-theme-default ng-dialog-all-details-page",data:{conditions:$scope.conditions},controller:function($scope){$scope.hideTitle=!0,$scope.statuses=["ACTIVE","HISTORY_OF","INACTIVE"],$scope.conditions=$scope.ngDialogData.conditions}})},conditionsService.getConditions($scope.patient.uuid).then(function(conditions){$scope.conditions=conditions})};return{restrict:"E",controller:controller,templateUrl:"../common/displaycontrols/conditionsList/views/conditionsList.html",scope:{params:"=",patient:"="}}}]);var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},Bahmni.Common.DisplayControl=Bahmni.Common.DisplayControl||{},Bahmni.Common.DisplayControl.AdmissionDetails=Bahmni.Common.DisplayControl.AdmissionDetails||{},angular.module("bahmni.common.displaycontrol.admissiondetails",[]),angular.module("bahmni.common.displaycontrol.admissiondetails").directive("admissionDetails",["bedService",function(bedService){var controller=function($scope){$scope.showDetailsButton=function(encounter){return $scope.params&&$scope.params.showDetailsButton&&!encounter.notes},$scope.toggle=function(element){element.show=!element.show},init($scope)},isReady=function($scope){return!_.isUndefined($scope.patientUuid)&&!_.isUndefined($scope.visitSummary)},onReady=function($scope){var visitUuid=_.get($scope.visitSummary,"uuid");bedService.getAssignedBedForPatient($scope.patientUuid,visitUuid).then(function(bedDetails){$scope.bedDetails=bedDetails})},init=function($scope){var stopWatching=$scope.$watchGroup(["patientUuid","visitSummary"],function(){isReady($scope)&&(stopWatching(),onReady($scope))});$scope.isDataPresent=function(){return!(!$scope.visitSummary||!$scope.visitSummary.admissionDetails&&!$scope.visitSummary.dischargeDetails)||$scope.$emit("no-data-present-event")&&!1}};return{restrict:"E",controller:controller,templateUrl:"../common/displaycontrols/admissiondetails/views/admissionDetails.html",scope:{params:"=",patientUuid:"=",visitSummary:"="}}}]);var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},Bahmni.Common.DisplayControl=Bahmni.Common.DisplayControl||{},Bahmni.Common.DisplayControl.PatientProfile=Bahmni.Common.DisplayControl.PatientProfile||{},angular.module("bahmni.common.displaycontrol.patientprofile",[]),angular.module("bahmni.common.displaycontrol.patientprofile").filter("titleCase",function(){return function(input){return input=input||"",input.replace(/\w\S*/g,function(txt){return txt.charAt(0).toUpperCase()+txt.substr(1).toLowerCase()})}}),angular.module("bahmni.common.displaycontrol.patientprofile").filter("booleanFilter",function(){return function(value){return value===!0?"Yes":value===!1?"No":value}}),function(){var getAddress=function($scope){var patient=$scope.patient,address=[];return void 0!=$scope.config.addressFields&&0!=$scope.config.addressFields.length?$scope.config.addressFields.forEach(function(addressField){patient.address[addressField]&&address.push(patient.address[addressField])}):_.includes($scope.config,"cityVillage")||address.push(patient.address.cityVillage),address.join(", ")},getPatientAttributeTypes=function($scope){var patient=$scope.patient;$scope.config.hasOwnProperty("ageLimit")&&patient.age>=$scope.config.ageLimit&&(patient.ageText=patient.age.toString()+" <span> years </span>");var patientAttributeTypes=[patient.genderText,patient.ageText];return patient.bloodGroupText&&patientAttributeTypes.push(patient.bloodGroupText),patientAttributeTypes.join(", ")},isAdmitted=function(admissionStatus){return"Admitted"===_.get(admissionStatus,"value")};angular.module("bahmni.common.displaycontrol.patientprofile").directive(
message:"EDIT_VISIT_MESSAGE"},CLOSE_VISIT:{eventType:"CLOSE_VISIT",message:"CLOSE_VISIT_MESSAGE"},CLOSE_VISIT_FAILED:{eventType:"CLOSE_VISIT_FAILED",message:"CLOSE_VISIT_FAILED_MESSAGE"},EDIT_ENCOUNTER:{eventType:"EDIT_ENCOUNTER",message:"EDIT_ENCOUNTER_MESSAGE"},VIEWED_REGISTRATION_PATIENT_SEARCH:{eventType:"VIEWED_REGISTRATION_PATIENT_SEARCH",message:"VIEWED_REGISTRATION_PATIENT_SEARCH_MESSAGE"},VIEWED_NEW_PATIENT_PAGE:{eventType:"VIEWED_NEW_PATIENT_PAGE",message:"VIEWED_NEW_PATIENT_PAGE_MESSAGE"},REGISTER_NEW_PATIENT:{eventType:"REGISTER_NEW_PATIENT",message:"REGISTER_NEW_PATIENT_MESSAGE"},EDIT_PATIENT_DETAILS:{eventType:"EDIT_PATIENT_DETAILS",message:"EDIT_PATIENT_DETAILS_MESSAGE"},ACCESSED_REGISTRATION_SECOND_PAGE:{eventType:"ACCESSED_REGISTRATION_SECOND_PAGE",message:"ACCESSED_REGISTRATION_SECOND_PAGE_MESSAGE"},VIEWED_PATIENT_DETAILS:{eventType:"VIEWED_PATIENT_DETAILS",message:"VIEWED_PATIENT_DETAILS_MESSAGE"},PRINT_PATIENT_STICKER:{eventType:"PRINT_PATIENT_STICKER",message:"PRINT_PATIENT_STICKER_MESSAGE"},VIEWED_CLINICAL_PATIENT_SEARCH:{eventType:"VIEWED_CLINICAL_PATIENT_SEARCH",message:"VIEWED_PATIENT_SEARCH_MESSAGE"},VIEWED_CLINICAL_DASHBOARD:{eventType:"VIEWED_CLINICAL_DASHBOARD",message:"VIEWED_CLINICAL_DASHBOARD_MESSAGE"},VIEWED_OBSERVATIONS_TAB:{eventType:"VIEWED_OBSERVATIONS_TAB",message:"VIEWED_OBSERVATIONS_TAB_MESSAGE"},VIEWED_DIAGNOSIS_TAB:{eventType:"VIEWED_DIAGNOSIS_TAB",message:"VIEWED_DIAGNOSIS_TAB_MESSAGE"},VIEWED_TREATMENT_TAB:{eventType:"VIEWED_TREATMENT_TAB",message:"VIEWED_TREATMENT_TAB_MESSAGE"},VIEWED_DISPOSITION_TAB:{eventType:"VIEWED_DISPOSITION_TAB",message:"VIEWED_DISPOSITION_TAB_MESSAGE"},VIEWED_DASHBOARD_SUMMARY:{eventType:"VIEWED_DASHBOARD_SUMMARY",message:"VIEWED_DASHBOARD_SUMMARY_MESSAGE"},VIEWED_ORDERS_TAB:{eventType:"VIEWED_ORDERS_TAB",message:"VIEWED_ORDERS_TAB_MESSAGE"},VIEWED_BACTERIOLOGY_TAB:{eventType:"VIEWED_BACTERIOLOGY_TAB",message:"VIEWED_BACTERIOLOGY_TAB_MESSAGE"},VIEWED_INVESTIGATION_TAB:{eventType:"VIEWED_INVESTIGATION_TAB",message:"VIEWED_INVESTIGATION_TAB_MESSAGE"},VIEWED_SUMMARY_PRINT:{eventType:"VIEWED_SUMMARY_PRINT",message:"VIEWED_SUMMARY_PRINT_MESSAGE"},VIEWED_VISIT_DASHBOARD:{eventType:"VIEWED_VISIT_DASHBOARD",message:"VIEWED_VISIT_DASHBOARD_MESSAGE"},VIEWED_VISIT_PRINT:{eventType:"VIEWED_VISIT_PRINT",message:"VIEWED_VISIT_PRINT_MESSAGE"},VIEWED_DASHBOARD_OBSERVATION:{eventType:"VIEWED_DASHBOARD_OBSERVATION",message:"VIEWED_DASHBOARD_OBSERVATION_MESSAGE"},VIEWED_PATIENTPROGRAM:{eventType:"VIEWED_PATIENTPROGRAM",message:"VIEWED_PATIENTPROGRAM_MESSAGE"},RUN_REPORT:{eventType:"RUN_REPORT",message:"RUN_REPORT_MESSAGE"}},angular.module("bahmni.adt").controller("BedManagementController",["$scope","$rootScope","$stateParams","spinner","wardService","backlinkService",function($scope,$rootScope,$stateParams,spinner,wardService,backlinkService){$scope.wards=null,$scope.encounterUuid=$stateParams.encounterUuid,$scope.visitUuid=$stateParams.visitUuid;var init=function(){loadAllWards(),$scope.$watch(function(){return $rootScope.bedDetails},function(newValue,oldValue){newValue!==oldValue&&loadAllWards()})},loadAllWards=function(){spinner.forPromise(wardService.getWardsList().success(function(wardsList){$scope.wards=wardsList.results}))};$scope.$on("$stateChangeSuccess",function(){backlinkService.addUrl({url:"#/patient/"+$scope.patient.uuid+"/visit/"+$scope.visitUuid+"/",title:"Back to IPD dashboard",icon:"fa-medkit fa-bed fa-white"})}),init()}]),angular.module("bahmni.adt").controller("WardsController",["$scope","$rootScope","$window","$document","spinner","wardService",function($scope,$rootScope,$window,$document,spinner,wardService){$scope.wards=null;var init=function(){return loadAllWards()},loadAllWards=function(){return wardService.getWardsList().success(function(wardsList){$scope.wards=wardsList.results})};spinner.forPromise(init())}]),angular.module("bahmni.adt").controller("WardController",["$scope","$rootScope","$window","spinner","wardService","bedManagementService","userService",function($scope,$rootScope,$window,spinner,wardService,bedManagementService,userService