13 lines
390 KiB
JavaScript
13 lines
390 KiB
JavaScript
![]() |
"use strict";function getWatchers(element){var elementToWatch=element?angular.element(element):angular.element(document.getElementsByTagName("body")),watchers=[],f=function(element){angular.forEach(["$scope","$isolateScope"],function(scopeProperty){element.data()&&element.data().hasOwnProperty(scopeProperty)&&angular.forEach(element.data()[scopeProperty].$$watchers,function(watcher){watchers.push(watcher)})}),angular.forEach(element.children(),function(childElement){f(angular.element(childElement))})};f(elementToWatch);var watchersWithoutDuplicates=[];return angular.forEach(watchers,function(item){watchersWithoutDuplicates.indexOf(item)<0&&watchersWithoutDuplicates.push(item)}),console.log(watchersWithoutDuplicates),watchersWithoutDuplicates}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":"DefaultEncounterTy
|
||
|
case"[object Date]":return+n==+t;case"[object Error]":return n.name==t.name&&n.message==t.message;case"[object Number]":return n!=+n?t!=+t:n==+t;case"[object RegExp]":case"[object String]":return n==t+"";case"[object Map]":var i=M;case"[object Set]":return i||(i=$),(2&o||n.size==t.size)&&e(i(n),i(t),u,1|o);case"[object Symbol]":return!!vu&&Tu.call(n)==Tu.call(t)}return!1}function jr(n,t,r,e,u,o){var i=2&u,f=Fe(n),c=f.length,a=Fe(t).length;if(c!=a&&!i)return!1;for(var l=c;l--;){var s=f[l];if(!(i?s in t:pt(t,s)))return!1}if(a=o.get(n))return a==t;a=!0,o.set(n,t);for(var h=i;++l<c;){var s=f[l],p=n[s],_=t[s];if(e)var g=i?e(_,p,s,t,n,o):e(p,_,s,n,t,o);if(g===Z?p!==_&&!r(p,_,e,u,o):!g){a=!1;break}h||(h="constructor"==s)}return a&&!h&&(r=n.constructor,e=t.constructor,r!=e&&"constructor"in n&&"constructor"in t&&!("function"==typeof r&&r instanceof r&&"function"==typeof e&&e instanceof e)&&(a=!1)),o.delete(n),a}function mr(n){for(var t=n.name+"",r=Gu[t],e=cu.call(Gu,t)?r.length:0;e--;){var u=r[e],o=u.func;if(null==o||o==n)return u.name}return t}function wr(){var n=yn.iteratee||Je,n=n===Je?xt:n;return arguments.length?n(arguments[0],arguments[1]):n}function Ar(n){n=De(n);for(var t=n.length;t--;){var r,e=n[t];r=n[t][1],r=r===r&&!xe(r),e[2]=r}return n}function Or(n,t){var r=null==n?Z:n[t];return me(r)?r:Z}function kr(n){return su.call(n)}function Er(n,t,r){if(null==n)return!1;var e=r(n,t);return e||Cr(t)||(t=Nt(t),n=$r(n,t),null!=n&&(t=Kr(t),e=r(n,t))),r=n?n.length:Z,e||!!r&&be(r)&&U(t,r)&&(No(n)||ke(n)||pe(n))}function Ir(n){var t=n.length,r=n.constructor(t);return t&&"string"==typeof n[0]&&cu.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function Sr(n){return Mr(n)?{}:(n=n.constructor,Vu(de(n)?n.prototype:Z))}function Rr(r,e,u){var o=r.constructor;switch(e){case"[object ArrayBuffer]":return Gt(r);case"[object Boolean]":case"[object Date]":return new o(+r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return e=r.buffer,new r.constructor(u?Gt(e):e,r.byteOffset,r.length);case"[object Map]":return u=r.constructor,s(M(r),n,new u);case"[object Number]":case"[object String]":return new o(r);case"[object RegExp]":return u=new r.constructor(r.source,hn.exec(r)),u.lastIndex=r.lastIndex,u;case"[object Set]":return u=r.constructor,s($(r),t,new u);case"[object Symbol]":return vu?Object(Tu.call(r)):{}}}function Wr(n){var t=n?n.length:Z;return be(t)&&(No(n)||ke(n)||pe(n))?j(t,String):null}function Br(n,t,r){if(!xe(r))return!1;var e=typeof t;return!!("number"==e?_e(r)&&U(t,r.length):"string"==e&&t in r)&&se(r[t],n)}function Cr(n,t){return"number"==typeof n||!No(n)&&(rn.test(n)||!tn.test(n)||null!=t&&n in Object(t))}function Ur(n){var t=typeof n;return"number"==t||"boolean"==t||"string"==t&&"__proto__"!==n||null==n}function zr(n){var t=mr(n),r=yn[t];return"function"==typeof r&&t in An.prototype&&(n===r||(t=to(r),!!t&&n===t[0]))}function Mr(n){var t=n&&n.constructor;return n===("function"==typeof t&&t.prototype||iu)}function Lr(n,t,r,e,u,o){return xe(n)&&xe(t)&&(o.set(t,n),Ot(n,t,Z,Lr,o)),n}function $r(n,t){return 1==t.length?n:Me(n,zt(t,0,-1))}function Fr(n){var t=[];return ze(n).replace(en,function(n,r,e,u){t.push(e?u.replace(ln,"$1"):r||n)}),t}function Nr(n){return ge(n)?n:[]}function Dr(n){return"function"==typeof n?n:Ve}function Zr(n){if(n instanceof An)return n.clone();var t=new wn(n.__wrapped__,n.__chain__);return t.__actions__=Yt(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function qr(n,t,r){var e=n?n.length:0;return e?(t=r||t===Z?1:We(t),zt(n,0>t?0:t,e)):[]}function Pr(n,t,r){var e=n?n.length:0;return e?(t=r||t===Z?1:We(t),t=e-t,zt(n,0,0>t?0:t)):[]}function Tr(n){return n?n[0]:Z}function Kr(n){var t=n?n.length:0;return t?n[t-1]:Z}function Gr(n,t){return n&&n.length&&t&&t.length?Wt(n,t):n}function Vr(n){return n?zu.call(n):n}function Jr(n){if(!n||!n.length)return[];var t=0;return n=i(n,function(n){return ge(n)?(t=
|
||
|
},yn.toString=ze,yn.toUpper=function(n){return ze(n).toUpperCase()},yn.trim=function(n,t,r){return(n=ze(n))?r||t===Z?n.replace(fn,""):(t+="")?(n=n.match(kn),t=t.match(kn),n.slice(O(n,t),k(n,t)+1).join("")):n:n},yn.trimEnd=function(n,t,r){return(n=ze(n))?r||t===Z?n.replace(an,""):(t+="")?(n=n.match(kn),n.slice(0,k(n,t.match(kn))+1).join("")):n:n},yn.trimStart=function(n,t,r){return(n=ze(n))?r||t===Z?n.replace(cn,""):(t+="")?(n=n.match(kn),n.slice(O(n,t.match(kn))).join("")):n:n},yn.truncate=function(n,t){var r=30,e="...";if(xe(t))var u="separator"in t?t.separator:u,r="length"in t?We(t.length):r,e="omission"in t?ze(t.omission):e;n=ze(n);var o=n.length;if(En.test(n))var i=n.match(kn),o=i.length;if(r>=o)return n;if(o=r-F(e),1>o)return e;if(r=i?i.slice(0,o).join(""):n.slice(0,o),u===Z)return r+e;if(i&&(o+=r.length-o),Oe(u)){if(n.slice(o).search(u)){var f=r;for(u.global||(u=eu(u.source,ze(hn.exec(u))+"g")),u.lastIndex=0;i=u.exec(f);)var c=i.index;r=r.slice(0,c===Z?o:c)}}else n.indexOf(u,o)!=o&&(u=r.lastIndexOf(u),u>-1&&(r=r.slice(0,u)));return r+e},yn.unescape=function(n){return(n=ze(n))&&Y.test(n)?n.replace(V,N):n},yn.uniqueId=function(n){var t=++au;return ze(n)+t},yn.upperCase=ai,yn.upperFirst=ii,yn.each=ne,yn.eachRight=te,yn.first=Tr,Ye(yn,function(){var n={};return at(yn,function(t,r){cu.call(yn.prototype,r)||(n[r]=t)}),n}(),{chain:!1}),yn.VERSION="4.3.0",u("bind bindKey curry curryRight partial partialRight".split(" "),function(n){yn[n].placeholder=yn}),u(["drop","take"],function(n,t){An.prototype[n]=function(r){var e=this.__filtered__;if(e&&!t)return new An(this);r=r===Z?1:Wu(We(r),0);var u=this.clone();return e?u.__takeCount__=Bu(r,u.__takeCount__):u.__views__.push({size:Bu(r,4294967295),type:n+(0>u.__dir__?"Right":"")}),u},An.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),u(["filter","map","takeWhile"],function(n,t){var r=t+1,e=1==r||3==r;An.prototype[n]=function(n){var t=this.clone();return t.__iteratees__.push({iteratee:wr(n,3),type:r}),t.__filtered__=t.__filtered__||e,t}}),u(["head","last"],function(n,t){var r="take"+(t?"Right":"");An.prototype[n]=function(){return this[r](1).value()[0]}}),u(["initial","tail"],function(n,t){var r="drop"+(t?"":"Right");An.prototype[n]=function(){return this.__filtered__?new An(this):this[r](1)}}),An.prototype.compact=function(){return this.filter(Ve)},An.prototype.find=function(n){return this.filter(n).head()},An.prototype.findLast=function(n){return this.reverse().find(n)},An.prototype.invokeMap=le(function(n,t){return"function"==typeof n?new An(this):this.map(function(r){return dt(r,n,t)})}),An.prototype.reject=function(n){return n=wr(n,3),this.filter(function(t){return!n(t)})},An.prototype.slice=function(n,t){n=We(n);var r=this;return r.__filtered__&&(n>0||0>t)?new An(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==Z&&(t=We(t),r=0>t?r.dropRight(-t):r.take(t-n)),r)},An.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},An.prototype.toArray=function(){return this.take(4294967295)},at(An.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=yn[e?"take"+("last"==t?"Right":""):t],o=e||/^find/.test(t);u&&(yn.prototype[t]=function(){var t=this.__wrapped__,i=e?[1]:arguments,f=t instanceof An,c=i[0],a=f||No(t),s=function(n){return n=u.apply(yn,l([n],i)),e&&h?n[0]:n};a&&r&&"function"==typeof c&&1!=c.length&&(f=a=!1);var h=this.__chain__,p=!!this.__actions__.length,c=o&&!h,f=f&&!p;return!o&&a?(t=f?t:new An(this),t=n.apply(t,i),t.__actions__.push({func:Qr,args:[s],thisArg:Z}),new wn(t,h)):c&&f?n.apply(this,i):(t=this.thru(s),c?e?t.value()[0]:t.value():t)})}),u("pop push shift sort splice unshift".split(" "),function(n){var t=ou[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/.test(n);yn.prototype[n]=function(){var n=arguments;return e&&!this.__chain__?t.apply(this.value(),n):this[r](function(r){return t.apply(r,n)})}}),at(An.prototype,function(n,t){var r=yn[t];if(r){var e=r.name+"";(Gu[e]||(Gu[e]=[])).push({name:t,func:r})}}),Gu[lr(Z,2).name]=[{name:"wrapper",fu
|
||
|
}}},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)}]),Bahmni.Common.VisitControl=function(visitTypes,defaultVisitTypeName,encounterService,$translate,visitService){var self=this;self.visitTypes=visitTypes,self.defaultVisitTypeName=defaultVisitTypeName,self.defaultVisitType=visitTypes.filter(function(visitType){return visitType.name===defaultVisitTypeName})[0],self.startButtonText=function(visitType){return $translate.instant("REGISTRATION_START_VISIT",{visitType:visitType.name})},self.startVisit=function(visitType){self.onStartVisit(),self.selectedVisitType=visitType},self.createVisitOnly=function(patientUuid,visitLocationUuid){var visitType=self.selectedVisitType||self.defaultVisitType,visitDetails={patient:patientUuid,visitType:visitType.uuid,location:visitLocationUuid};return visitService.createVisit(visitDetails)}},Bahmni.Common.Util.TranslationUtil={translateAttribute:function(attribute,moduleName,$translate){if("undefined"!=typeof attribute){if(null==moduleName||"undefined"==typeof moduleName)var keyPrefix=" ";else keyPrefix=moduleName;var keyName=attribute.toUpperCase().replace(/\s\s+/g," ").replace(/[^a-zA-Z0-9 _]/g,"").trim().replace(/ /g,"_"),translationKey=keyPrefix+"_"+keyName,translation=$translate.instant(translationKey);translation!=translationKey&&(attribute=translation)}return attribute}},Bahmni.Common.Util.GenderUtil={translateGender:function(genderMap,$translate){_.forEach(genderMap,function(value,key){var translationKey="GENDER_"+key.toUpperCase(),translatedGender=$translate.instant(translationKey);translatedGender!=translationKey&&(genderMap[key]=translatedGender)})}},angular.module("bahmni.common.config",[]),angular.module("bahmni.common.config").service("configurations",["configurationService",function(configurationService){this.configs={},this.load=function(configNames){var self=this;return configurationSer
|
||
|
return yearList};$scope.years=getYearList();var valueCompletelyFilled=function(){return null!=$scope.selectedMonth&&null!=$scope.selectedYear},valueNotFilled=function(){return null==$scope.selectedMonth&&null==$scope.selectedYear},getCompleteDate=function(){var month=$scope.selectedMonth+1;return $scope.selectedYear+"-"+month+"-01"};if($scope.updateModel=function(){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("singleClick",function(){var ignoreClick=!1,link=function(scope,element){var clickHandler=function(){ignoreClick||(ignoreClick=!0,scope.singleClick().finally(function(){ignoreClick=!1}))};element.on("click",clickHandler),scope.$on("$destroy",function(){element.off("click",clickHandler)})};return{scope:{singleClick:"&"},restrict:"A",link:link}}),angular.module("bahmni.common.uiHelper").directive("singleSubmit",function(){var ignoreSubmit=!1,link=function(scope,element){var submitHandler=function(){ignoreSubmit||(ignoreSubmit=!0,scope.singleSubmit().finally(function(){ignoreSubmit=!1}))};element.on("submit",submitHandler),scope.$on("$destroy",function(){element.off("submit",submitHandler)})};return{scope:{singleSubmit:"&"},restrict:"A",link:link}});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.attributeTypes",[]).directive("attributeTypes",[function(){return{scope:{t
|
||
|
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.patient",[]),angular.module("bahmni.common.patient").filter("age",function(){return function(age){return age.years?age.years+" y":age.months?age.months+" m":age.days+" d"}});var Bahmni=Bahmni||{};Bahmni.ConceptSet=Bahmni.ConceptSet||{},Bahmni.ConceptSet.FormConditions=Bahmni.ConceptSet.FormConditions||{},angular.module("bahmni.common.conceptSet",["bahmni.common.uiHelper","ui.select2","pasvaz.bindonce","ngSanitize","ngTagsInput"]),angular.module("bahmni.common.conceptSet").controller("ConceptSetGroupController",["$scope","contextChangeHandler","spinner","messagingService","conceptSetService","$rootScope","sessionService","encounterService","treatmentConfig","retrospectiveEntryService","userService","conceptSetUiConfigService","$timeout","clinicalAppConfigService","$stateParams","$translate",function($scope,contextChangeHandler,spinner,messagingService,conceptSetService,$rootScope,sessionService,encounterService,treatmentConfig,retrospectiveEntryService,userService,conceptSetUiConfigService,$timeout,clinicalAppConfigService,$stateParams,$translate){var conceptSetUIConfig=conceptSetUiConfigService.getConfig(),init=function(){$scope.validationHandler=new Bahmni.ConceptSet.ConceptSetGroupPanelViewValidationHandler($scope.allTemplates),contextChangeHandler.add($scope.validationHandler.validate)};$scope.toggleSideBar=function(){$rootScope.showLeftpanelToggle=!$rootScope.showLeftpanelToggle},$scope.showLeftpanelToggle=function(){return $rootScope.showLeftpanelToggle},$scope.togglePref=function(conceptSet,conceptName){$rootScope.currentUser.toggleFavoriteObsTemplate(conceptName),spinner.forPromise(userService.savePreferences())},$scope.getNormalized=function(conceptName){return conceptName.replace(/['\.\s\(\)\/,\\]+/g,"_")},$scope.showPreviousButton=function(conceptSetName){return conceptSetUIConfig[conceptSetName]&&conceptSetUIConfig[conceptSetName].showPreviousButton},$scope.showPrevious=function(conceptSetName,event){event.stopPropagation(),$timeout(function(){$scope.$broadcast("event:showPrevious"+conceptSetName)})},$scope.isInEditEncounterMode=function(){return void 0!==$stateParams.encounterUuid&&"active"!==$stateParams.encounterUuid},$scope.computeField=function(conceptSet,event){event.stopPropagation(),$scope.consultation.preSaveHandler.fire();var defaultRetrospectiveVisitType=clinicalAppConfigService.getVisitTypeForRetrospectiveEntries(),encounterData=(new Bahmni.Clinical.EncounterTransactionMapper).map(angular.copy($scope.consultation),$scope.patient,sessionService.getLoginLocationUuid(),retrospectiveEntryService.getRetrospectiveEntry(),defaultRetrospectiveVisitType,$scope.isInEditEncounterMode());encounterData=encounterService.buildEncounter(encounterData),encounterData.drugOrders=[];var conceptSetData={name:conceptSet.conceptName,uuid:conceptSet.uuid},data={encounterModi
|
||
|
currValue>scope.obs.concept.lowNormal&&updateModel(-1)}else updateModel(-1)}}}}),angular.module("bahmni.common.conceptSet").directive("obsConstraints",function(){var attributesMap={Numeric:"number",Date:"date",Datetime:"datetime"},link=function($scope,element){var attributes={},obsConcept=$scope.obs.concept;obsConcept.conceptClass==Bahmni.Common.Constants.conceptDetailsClassName&&(obsConcept=$scope.obs.primaryObs.concept),attributes.type=attributesMap[obsConcept.dataType]||"text","number"===attributes.type&&(attributes.step="any"),obsConcept.hiNormal&&(attributes.max=obsConcept.hiNormal),obsConcept.lowNormal&&(attributes.min=obsConcept.lowNormal),"date"==attributes.type&&(null!=$scope.obs.conceptUIConfig&&$scope.obs.conceptUIConfig.allowFutureDates||(attributes.max=Bahmni.Common.Util.DateTimeFormatter.getDateWithoutTime())),element.attr(attributes)};return{link:link,scope:{obs:"="},require:"ngModel"}}),angular.module("bahmni.common.conceptSet").directive("duration",["contextChangeHandler",function(contextChangeHandler){var link=function($scope,element,attrs,ngModelController){var setValue=function(){if($scope.unitValue&&$scope.measureValue){var value=$scope.unitValue*$scope.measureValue;ngModelController.$setViewValue(value)}else ngModelController.$setViewValue(void 0)};$scope.$watch("measureValue",setValue),$scope.$watch("unitValue",setValue),$scope.$watch("disabled",function(value){value&&($scope.unitValue=void 0,$scope.measureValue=void 0,$scope.hours=void 0)});var illegalValueChecker=$scope.$watch("illegalValue",function(value){$scope.illegalDurationValue=value;var contextChange=function(){return{allow:!$scope.illegalDurationValue}};contextChangeHandler.add(contextChange)});$scope.$on("$destroy",function(){$scope.illegalDurationValue=!1,illegalValueChecker()})},controller=function($scope){var valueAndUnit=Bahmni.Common.Util.DateUtil.convertToUnits($scope.hours);$scope.units=valueAndUnit.allUnits,$scope.measureValue=valueAndUnit.value,$scope.unitValue=valueAndUnit.unitValueInMinutes;var durations=Object.keys($scope.units).reverse();$scope.displayUnits=durations.map(function(duration){return{name:duration,value:$scope.units[duration]}})};return{restrict:"E",require:"ngModel",controller:controller,scope:{hours:"=ngModel",illegalValue:"=",disabled:"="},link:link,template:'<span><input tabindex="1" style="float: left;" type="number" min="0" class="duration-value" ng-class="{\'illegalValue\': illegalValue}" ng-model=\'measureValue\' ng-disabled="disabled"/></span><span><select tabindex="1" ng-model=\'unitValue\' class="duration-unit" ng-class="{\'illegalValue\': illegalValue}" ng-options="displayUnit.value as displayUnit.name for displayUnit in displayUnits" ng-disabled="disabled"><option value=""></option>></select></span>'}}]),angular.module("bahmni.common.conceptSet").directive("latestObs",function(){var controller=function($scope,observationsService,$q,spinner){var init=function(){spinner.forPromise(observationsService.fetch($scope.patientUuid,$scope.conceptNames,"latest").then(function(response){var observations=(new Bahmni.Common.Obs.ObservationMapper).map(response.data,[]);$scope.observations=_.sortBy(observations,"sortWeight")}))};init()};return{restrict:"E",controller:controller,templateUrl:"../common/concept-set/views/latestObs.html",scope:{patientUuid:"=",conceptNames:"="}}}),Bahmni.ConceptSet.ConceptSetGroupValidationHandler=function(conceptSetSections){var validations=[];this.add=function(validation){validations.push(validation)},this.validate=function(){var errorMessage="",allConceptSetSectionsValid=!0;return validations.forEach(function(validation){var validationReturn=validation();_.isEmpty(errorMessage)&&(errorMessage=validationReturn.errorMessage),allConceptSetSectionsValid=allConceptSetSectionsValid&&validationReturn.allow}),allConceptSetSectionsValid||conceptSetSections.filter(_.property("isLoaded")).forEach(function(conceptSetSection){conceptSetSection.show()}),{allow:allConceptSetSectionsValid,errorMessage:errorMessage}}},Bahmni.ConceptSet.Observation=function(observation,savedObs,conceptUIConfig){va
|
||
|
obs.value&&values.push(obs.value.shortName||obs.value.name)}),values},this.isComputed=function(){return"Computed"===this.concept.conceptClass},this.getDataTypeName=function(){return this.concept.dataType},this._isDateTimeDataType=function(){return"Datetime"===this.getDataTypeName()},this.isNumeric=function(){return"Numeric"===this.getDataTypeName()},this.isText=function(){return"Text"===this.getDataTypeName()},this.isCoded=function(){return"Coded"===this.getDataTypeName()}},Bahmni.ConceptSet.CustomRepresentationBuilder={build:function(fields,childPropertyName,numberOfLevels){for(var childPropertyRep=childPropertyName+":{{entity_fileds}}",singleEntityString="("+fields.concat(childPropertyRep).join(",")+")",customRepresentation=singleEntityString,i=0;i<numberOfLevels;i++)customRepresentation=customRepresentation.replace("{{entity_fileds}}",singleEntityString);return customRepresentation=customRepresentation.replace(","+childPropertyRep,"")}},Bahmni.ConceptSet.ConceptSetSection=function(extensions,user,config,observations,conceptSet){var self=this;self.clone=function(){var clonedConceptSetSection=new Bahmni.ConceptSet.ConceptSetSection(extensions,user,config,[],conceptSet);return clonedConceptSetSection.isAdded=!0,clonedConceptSetSection};var init=function(){self.observations=observations,self.options=extensions.extensionParams||{},self.conceptName=conceptSet.name?conceptSet.name.name:self.options.conceptName;var conceptName=_.find(conceptSet.names,{conceptNameType:"SHORT"})||_.find(conceptSet.names,{conceptNameType:"FULLY_SPECIFIED"});conceptName=conceptName?conceptName.name:conceptName,self.label=conceptName||self.conceptName||self.options.conceptName,self.isLoaded=self.isOpen,self.collapseInnerSections={value:!1},self.uuid=conceptSet.uuid,self.alwaysShow=user.isFavouriteObsTemplate(self.conceptName),self.allowAddMore=config.allowAddMore,self.id="concept-set-"+conceptSet.uuid},getShowIfFunction=function(){if(!self.showIfFunction){var showIfFunctionStrings=self.options.showIf||["return true;"];self.showIfFunction=new Function("context",showIfFunctionStrings.join("\n"))}return self.showIfFunction},atLeastOneValueSet=function(observation){return observation.groupMembers&&observation.groupMembers.length>0?observation.groupMembers.some(function(groupMember){return atLeastOneValueSet(groupMember)}):!(_.isUndefined(observation.value)||""===observation.value)};self.isAvailable=function(context){return getShowIfFunction()(context||{})},self.show=function(){self.isOpen=!0,self.isLoaded=!0},self.hide=function(){self.isOpen=!1},self.getObservationsForConceptSection=function(){return self.observations.filter(function(observation){return observation.concept.name===self.conceptName})},self.hasSomeValue=function(){var observations=self.getObservationsForConceptSection();return _.some(observations,function(observation){return atLeastOneValueSet(observation)})},self.showComputeButton=function(){return config.computeDrugs===!0},self.toggle=function(){self.added=!self.added,self.added&&self.show()},self.maximizeInnerSections=function(event){event.stopPropagation(),self.collapseInnerSections={value:!1}},self.minimizeInnerSections=function(event){event.stopPropagation(),self.collapseInnerSections={value:!0}},self.toggleDisplay=function(){self.isOpen?self.hide():self.show()},self.canToggle=function(){return!self.hasSomeValue()},self.canAddMore=function(){return 1==self.allowAddMore},Object.defineProperty(self,"isOpen",{get:function(){return void 0===self.open&&(self.open=self.hasSomeValue()),self.open},set:function(value){self.open=value}}),self.isDefault=function(){return self.options.default},Object.defineProperty(self,"isAdded",{get:function(){return void 0===self.added&&(self.options.default?self.added=!0:self.added=self.hasSomeValue()),self.added},set:function(value){self.added=value}}),init()},Bahmni.ObservationForm=function(formUuid,user,formName,formVersion,observations,label,extension){function hide(){self.isOpen=!1}function show(){self.isOpen=!0}var self=this,init=function(){self.formUuid=formUuid,self.formVersion=formVersion,self.fo
|
||
|
return obsGroup.concept.shortName=self.getTranslatedShortName(translationData,translationKey,obsGroup,defaultShortName),obsGroup}}]),angular.module("bahmni.common.displaycontrol.observation").directive("bahmniObservation",["encounterService","observationsService","appService","$q","spinner","$rootScope","formRecordTreeBuildService","$translate",function(encounterService,observationsService,appService,$q,spinner,$rootScope,formRecordTreeBuildService,$translate){var controller=function($scope){$scope.print=$rootScope.isBeingPrinted||!1,$scope.showGroupDateTime=$scope.config.showGroupDateTime!==!1;var mapObservation=function(observations){var conceptsConfig=$scope.config.formType===Bahmni.Common.Constants.forms2Type?{}:appService.getAppDescriptor().getConfigValue("conceptSetUI")||{};observations=(new Bahmni.Common.Obs.ObservationMapper).map(observations,conceptsConfig),$scope.config.conceptNames&&(observations=_.filter(observations,function(observation){return _.some($scope.config.conceptNames,function(conceptName){return _.toLower(conceptName)===_.toLower(_.get(observation,"concept.name"))})})),$scope.config.persistOrderOfConcepts?$scope.bahmniObservations=(new Bahmni.Common.DisplayControl.Observation.GroupingFunctions).persistOrderOfConceptNames(observations):$scope.bahmniObservations=(new Bahmni.Common.DisplayControl.Observation.GroupingFunctions).groupByEncounterDate(observations),_.isEmpty($scope.bahmniObservations)?($scope.noObsMessage=$translate.instant(Bahmni.Common.Constants.messageForNoObservation),$scope.$emit("no-data-present-event")):$scope.showGroupDateTime?$scope.bahmniObservations[0].isOpen=!0:_.forEach($scope.bahmniObservations,function(bahmniObs){bahmniObs.isOpen=!0});var formObservations=_.filter(observations,function(obs){return obs.formFieldPath});formObservations.length>0&&formRecordTreeBuildService.build($scope.bahmniObservations,$scope.hasNoHierarchy)},fetchObservations=function(){if($scope.config.formType===Bahmni.Common.Constants.formBuilderDisplayControlType){var getFormNameAndVersion=Bahmni.Common.Util.FormFieldPathUtil.getFormNameAndVersion;encounterService.findByEncounterUuid($scope.config.encounterUuid,{includeAll:!1}).then(function(reponse){var encounterTransaction=reponse.data,observationsForSelectedForm=_.filter(encounterTransaction.observations,function(obs){if(obs.formFieldPath){var obsFormNameAndVersion=getFormNameAndVersion(obs.formFieldPath);return obsFormNameAndVersion.formName===$scope.config.formName}});mapObservation(observationsForSelectedForm)}),$scope.title=$scope.config.formDisplayName}else if($scope.observations)mapObservation($scope.observations,$scope.config),$scope.isFulfilmentDisplayControl=!0;else if($scope.config.observationUuid)$scope.initialization=observationsService.getByUuid($scope.config.observationUuid).then(function(response){mapObservation([response.data],$scope.config)});else if($scope.config.encounterUuid){var fetchForEncounter=observationsService.fetchForEncounter($scope.config.encounterUuid,$scope.config.conceptNames);$scope.initialization=fetchForEncounter.then(function(response){mapObservation(response.data,$scope.config)})}else $scope.enrollment?$scope.initialization=observationsService.fetchForPatientProgram($scope.enrollment,$scope.config.conceptNames,$scope.config.scope,$scope.config.obsIgnoreList).then(function(response){mapObservation(response.data,$scope.config)}):$scope.initialization=observationsService.fetch($scope.patient.uuid,$scope.config.conceptNames,$scope.config.scope,$scope.config.numberOfVisits,$scope.visitUuid,$scope.config.obsIgnoreList,null).then(function(response){mapObservation(response.data,$scope.config)})};$scope.translateAttributeName=function(attribute){var keyName=attribute.toUpperCase().replace(/\s\s+/g," ").replace(/[^a-zA-Z0-9 _]/g,"").trim().replace(/ /g,"_"),translationKey=keyName,translation=$translate.instant(translationKey);return translation==translationKey?translation:translation},$scope.toggle=function(element){element.isOpen=!element.isOpen},$scope.isClickable=function(){return $scope.isOnDashboard&&$scope.section.
|
||
|
return initialization()}}}).state("patient",{url:"/patient/:patientUuid",abstract:!0,views:{layout:{template:'<div ui-view="layout"></div>'}},resolve:{initialize:function(initialization){return initialization()}}}).state("patient.edit",{url:"?serverError",views:{layout:{templateUrl:"views/layout.html",controller:"EditPatientController"},"content@patient.edit":{templateUrl:"views/editpatient.html"},"headerExtension@patient.edit":{template:"<div print-options></div>"}}}).state("patient.visit",{url:"/visit",views:{layout:{templateUrl:"views/layout.html",controller:"VisitController"},"content@patient.visit":{templateUrl:"views/visit.html"},"headerExtension@patient.visit":{template:"<div print-options></div>"}}}).state("patient.printSticker",{url:"/printSticker",views:{layout:{templateUrl:"views/layout.html"},"content@patient.printSticker":{templateUrl:"views/notimplemented.html"}}}),$bahmniTranslateProvider.init({app:"registration",shouldMerge:!0})}]).run(["$rootScope","$templateCache","$bahmniCookieStore","locationService","messagingService","auditLogService","$window",function($rootScope,$templateCache,$bahmniCookieStore,locationService,messagingService,auditLogService,$window){var getStates=function(toState,fromState){var states=[];return"newpatient"!==fromState||"patient.edit"!==toState&&"patient.visit"!==toState||states.push("newpatient.save"),"patient.edit"===toState?states.push("patient.view"):states.push(toState),states};moment.locale($window.localStorage.NG_TRANSLATE_LANG_KEY||"en");var loginLocationUuid=$bahmniCookieStore.get(Bahmni.Common.Constants.locationCookieName).uuid;locationService.getVisitLocation(loginLocationUuid).then(function(response){response.data&&($rootScope.visitLocation=response.data.uuid)}),$rootScope.$on("$stateChangeStart",function(){messagingService.hideMessages("error")}),$rootScope.createAuditLog=function(event,toState,toParams,fromState){var states=getStates(toState.name,fromState.name);states.forEach(function(state){auditLogService.log(toParams.patientUuid,Bahmni.Registration.StateNameEvenTypeMap[state],void 0,"MODULE_LABEL_REGISTRATION_KEY")})},$rootScope.$on("$stateChangeSuccess",$rootScope.createAuditLog)}]),angular.module("bahmni.registration").factory("initialization",["$rootScope","$q","configurations","authenticator","appService","spinner","preferences","locationService","mergeService","$translate",function($rootScope,$q,configurations,authenticator,appService,spinner,preferences,locationService,mergeService,$translate){var getConfigs=function(){var configNames=["encounterConfig","patientAttributesConfig","identifierTypesConfig","addressLevels","genderMap","relationshipTypeConfig","relationshipTypeMap","loginLocationToVisitTypeMapping"];return configurations.load(configNames).then(function(){var mandatoryPersonAttributes=appService.getAppDescriptor().getConfigValue("mandatoryPersonAttributes"),patientAttributeTypes=(new Bahmni.Common.Domain.AttributeTypeMapper).mapFromOpenmrsAttributeTypes(configurations.patientAttributesConfig(),mandatoryPersonAttributes,{},$rootScope.currentUser.userProperties.defaultLocale);$rootScope.regEncounterConfiguration=angular.extend(new Bahmni.Registration.RegistrationEncounterConfig,configurations.encounterConfig()),$rootScope.encounterConfig=angular.extend(new EncounterConfig,configurations.encounterConfig()),$rootScope.patientConfiguration=new Bahmni.Registration.PatientConfig(patientAttributeTypes.attributeTypes,configurations.identifierTypesConfig(),appService.getAppDescriptor().getConfigValue("patientInformation")),$rootScope.regEncounterConfiguration.loginLocationToVisitTypeMap=configurations.loginLocationToVisitTypeMapping(),$rootScope.addressLevels=configurations.addressLevels(),$rootScope.fieldValidation=appService.getAppDescriptor().getConfigValue("fieldValidation"),$rootScope.genderMap=configurations.genderMap(),Bahmni.Common.Util.GenderUtil.translateGender($rootScope.genderMap,$translate),$rootScope.relationshipTypeMap=configurations.relationshipTypeMap(),$rootScope.relationshipTypes=configurations.relationshipTypes()})},loadValidators=fun
|
||
|
setPatientIdentifierSearchConfig(),setAddressSearchConfig(),setCustomAttributesSearchConfig(),setProgramAttributesSearchConfig(),setSearchResultsConfig()},identifyParams=function(querystring){querystring=querystring.substring(querystring.indexOf("?")+1).split("&");for(var pair,params={},d=decodeURIComponent,i=querystring.length-1;i>=0;i--)pair=querystring[i].split("="),params[d(pair[0])]=d(pair[1]);return params};initialize(),$scope.disableSearchButton=function(){return!($scope.searchParameters.name||$scope.searchParameters.addressFieldValue||$scope.searchParameters.customAttribute||$scope.searchParameters.programAttributeFieldValue)},$scope.$watch(function(){return $location.search()},function(){showSearchResults(searchBasedOnQueryParameters(0))}),$scope.searchById=function(){if(!isUserPrivilegedForSearch())return void showInsufficientPrivMessage();if($scope.searchParameters.registrationNumber){$scope.results=[];var patientIdentifier=$scope.searchParameters.registrationNumber;$location.search({registrationNumber:$scope.searchParameters.registrationNumber,programAttributeFieldName:$scope.programAttributesSearchConfig.field,patientAttributes:$scope.customAttributesSearchConfig.fields,programAttributeFieldValue:$scope.searchParameters.programAttributeFieldValue,addressSearchResultsConfig:$scope.addressSearchResultsConfig.fields,personSearchResultsConfig:$scope.personSearchResultsConfig.fields});var searchPromise=patientService.search(void 0,patientIdentifier,$scope.addressSearchConfig.field,void 0,void 0,void 0,$scope.customAttributesSearchConfig.fields,$scope.programAttributesSearchConfig.field,$scope.searchParameters.programAttributeFieldValue,$scope.addressSearchResultsConfig.fields,$scope.personSearchResultsConfig.fields,$scope.isExtraIdentifierConfigured()).then(function(data){if(mapExtraIdentifiers(data),mapCustomAttributesSearchResults(data),mapAddressAttributesSearchResults(data),mapProgramAttributesSearchResults(data),1===data.pageOfResults.length){var patient=data.pageOfResults[0],forwardUrl=appService.getAppDescriptor().getConfigValue("searchByIdForwardUrl")||"/patient/{{patientUuid}}";$location.url(appService.getAppDescriptor().formatUrl(forwardUrl,{patientUuid:patient.uuid}))}else data.pageOfResults.length>1?($scope.results=data.pageOfResults,$scope.noResultsMessage=null):($scope.patientIdentifier={patientIdentifier:patientIdentifier},$scope.noResultsMessage="REGISTRATION_LABEL_COULD_NOT_FIND_PATIENT")});spinner.forPromise(searchPromise)}};var isUserPrivilegedForSearch=function(){var applicablePrivs=[Bahmni.Common.Constants.viewPatientsPrivilege,Bahmni.Common.Constants.editPatientsPrivilege,Bahmni.Common.Constants.addVisitsPrivilege,Bahmni.Common.Constants.deleteVisitsPrivilege],userPrivs=_.map($rootScope.currentUser.privileges,function(privilege){return privilege.name}),result=_.some(userPrivs,function(privName){return _.includes(applicablePrivs,privName)});return result},showInsufficientPrivMessage=function(){var message=$translate.instant("REGISTRATION_INSUFFICIENT_PRIVILEGE");messagingService.showMessage("error",message)};$scope.loadingMoreResults=function(){return searching&&!$scope.noMoreResultsPresent},$scope.searchPatients=function(){if(!isUserPrivilegedForSearch())return void showInsufficientPrivMessage();var queryParams={};$scope.results=[],$scope.searchParameters.name&&(queryParams.name=$scope.searchParameters.name),$scope.searchParameters.addressFieldValue&&(queryParams.addressFieldValue=$scope.searchParameters.addressFieldValue),$scope.searchParameters.customAttribute&&$scope.customAttributesSearchConfig.show&&(queryParams.customAttribute=$scope.searchParameters.customAttribute),$scope.searchParameters.programAttributeFieldValue&&$scope.programAttributesSearchConfig.show&&(queryParams.programAttributeFieldName=$scope.programAttributesSearchConfig.field,queryParams.programAttributeFieldValue=$scope.searchParameters.programAttributeFieldValue),$location.search(queryParams)},$scope.resultsPresent=function(){return angular.isDefined($scope.results)&&$scope.results.length>0},$scope.editPatientUrl=func
|
||
|
}).then(function(){messagingService.showMessage("error","NO_LOCATION_TAGGED_TO_VISIT_LOCATION")}):void spinner.forPromise($scope.visitControl.createVisitOnly(patientProfileData.patient.uuid,$rootScope.visitLocation).then(function(response){if(auditLogService.log(patientProfileData.patient.uuid,"OPEN_VISIT",{visitUuid:response.data.uuid,visitType:response.data.visitType.display},"MODULE_LABEL_REGISTRATION_KEY"),forwardUrl){var updatedForwardUrl=appService.getAppDescriptor().formatUrl(forwardUrl,{patientUuid:patientProfileData.patient.uuid});$window.location.href=updatedForwardUrl}else goToVisitPage(patientProfileData)},function(){$state.go("patient.edit",{patientUuid:$scope.patient.uuid})}))};init()};return{restrict:"E",templateUrl:"views/patientAction.html",controller:controller}}]),angular.module("bahmni.registration").controller("VisitController",["$window","$scope","$rootScope","$state","$bahmniCookieStore","patientService","encounterService","$stateParams","spinner","$timeout","$q","appService","openmrsPatientMapper","contextChangeHandler","messagingService","sessionService","visitService","$location","$translate","auditLogService","formService",function($window,$scope,$rootScope,$state,$bahmniCookieStore,patientService,encounterService,$stateParams,spinner,$timeout,$q,appService,openmrsPatientMapper,contextChangeHandler,messagingService,sessionService,visitService,$location,$translate,auditLogService,formService){var vm=this,patientUuid=$stateParams.patientUuid,extensions=appService.getAppDescriptor().getExtensions("org.bahmni.registration.conceptSetGroup.observations","config"),formExtensions=appService.getAppDescriptor().getExtensions("org.bahmni.registration.conceptSetGroup.observations","forms"),locationUuid=sessionService.getLoginLocationUuid(),selectedProvider=$rootScope.currentProvider,regEncounterTypeUuid=$rootScope.regEncounterConfiguration.encounterTypes[Bahmni.Registration.Constants.registrationEncounterType],visitLocationUuid=$rootScope.visitLocation,getPatient=function(){var deferred=$q.defer();return patientService.get(patientUuid).then(function(openMRSPatient){deferred.resolve(openMRSPatient),$scope.patient=openmrsPatientMapper.map(openMRSPatient),$scope.patient.name=openMRSPatient.patient.person.names[0].display,$scope.patient.uuid=openMRSPatient.patient.uuid}),deferred.promise},getActiveEncounter=function(){var deferred=$q.defer();return encounterService.find({patientUuid:patientUuid,providerUuids:_.isEmpty($scope.currentProvider.uuid)?null:[$scope.currentProvider.uuid],includeAll:!1,locationUuid:locationUuid,encounterTypeUuids:[regEncounterTypeUuid]}).then(function(response){deferred.resolve(response),$scope.encounterUuid=response.data.encounterUuid,$scope.observations=response.data.observations}),deferred.promise},getAllForms=function(){var deferred=$q.defer();return formService.getFormList($scope.encounterUuid).then(function(response){$scope.conceptSets=extensions.map(function(extension){return new Bahmni.ConceptSet.ConceptSetSection(extension,$rootScope.currentUser,{},[],{})}),$scope.observationForms=getObservationForms(formExtensions,response.data),$scope.conceptSets=$scope.conceptSets.concat($scope.observationForms),$scope.availableConceptSets=$scope.conceptSets.filter(function(conceptSet){return conceptSet.isAvailable($scope.context)}),deferred.resolve(response.data)}),deferred.promise};$scope.hideFields=appService.getAppDescriptor().getConfigValue("hideFields"),$scope.back=function(){$state.go("patient.edit")},$scope.updatePatientImage=function(image){var updateImagePromise=patientService.updateImage($scope.patient.uuid,image.replace("data:image/jpeg;base64,",""));return spinner.forPromise(updateImagePromise),updateImagePromise};var save=function(){$scope.encounter={patientUuid:$scope.patient.uuid,locationUuid:locationUuid,encounterTypeUuid:regEncounterTypeUuid,orders:[],drugOrders:[],extensions:{}},$bahmniCookieStore.put(Bahmni.Common.Constants.grantProviderAccessDataCookieName,selectedProvider,{path:"/",expires:1}),$scope.encounter.observations=$scope.observations,$scope.encounter.observa
|
||
|
return{hasOldIdentifier:!1}}]),Bahmni.Registration.RegistrationEncounterConfig=function(){function RegistrationEncounterConfig(conceptData,encounterTypes,visitTypes){this.conceptData=conceptData,this.encounterTypes=encounterTypes,this.visitTypes=visitTypes}return RegistrationEncounterConfig.prototype={getVisitTypesAsArray:function(){var visitTypesArray=[];for(var name in this.visitTypes)visitTypesArray.push({name:name,uuid:this.visitTypes[name]});return visitTypesArray},getDefaultVisitType:function(locationUuid){var visitType=null;return _.each(this.loginLocationToVisitTypeMap.results,function(result){result.entity.uuid===locationUuid&&(visitType=result.mappings[0].name)}),visitType}},RegistrationEncounterConfig}(),Bahmni.Registration.PatientConfig=function(){function PatientConfig(patientAttributeTypes,identifierTypes,patientInformation){this.attributeTypes=patientAttributeTypes,this.identifierTypes=identifierTypes;var patientAttributesSections={};if(!this.attributeRows&&this.attributeTypes){if(!patientInformation)return void(this.attributeRows=this.splitAsRows(this.attributeTypes));var hiddenAttributes=patientInformation.hidden&&patientInformation.hidden.attributes;delete patientInformation.hidden;var otherInformationAttributes=this.attributeTypes.map(function(item){return item.keyPrefix="PATIENT_ATTRIBUTE_",item}).filter(function(item){return!isHiddenPatientAttribute(hiddenAttributes,item)&&!isItemAMandatoryField(item)&&!isAttributeInOtherSection(patientInformation,patientAttributesSections,item)});this.attributeRows=this.splitAsRows(otherInformationAttributes),this.patientAttributesSections=patientAttributesSections}}function isHiddenPatientAttribute(hiddenAttributes,item){return hiddenAttributes&&hiddenAttributes.indexOf(item.name)>-1}function isAttributeInOtherSection(patientInformation,patientAttributesSections,item){return _.find(patientInformation,function(section,key){return _.find(section.attributes,function(attribute){if(attribute===item.name){var sectionObject=patientAttributesSections[key];return sectionObject||(sectionObject={attributes:[],title:section.title,expanded:section.expanded,translationKey:section.translationKey,shortcutKey:section.shortcutKey,order:section.order,canShow:!0}),sectionObject.attributes.push(item),patientAttributesSections[key]=sectionObject,!0}return!1})})}function isItemAMandatoryField(item){var mandatoryPatientAttributes=["healthCenter","givenNameLocal","middleNameLocal","familyNameLocal"];return mandatoryPatientAttributes.indexOf(item.name)>-1}return PatientConfig.prototype={get:function(attributeUuid){return this.attributeTypes.filter(function(item){return item.uuid===attributeUuid})[0]},customAttributeRows:function(){return this.attributeRows},getPatientAttributesSections:function(){return this.patientAttributesSections},getOrderedPatientAttributesSections:function(){return _.sortBy(this.patientAttributesSections,"order")},splitAsRows:function(attributes){var attributeRows=[],row=[];for(var i in attributes)row.push(attributes[i]),0!==i&&i%2!==0&&(attributeRows.push(row),row=[]);return row.length>0&&attributeRows.push(row),attributeRows},heathCentreAttribute:function(){return this.attributeTypes.filter(function(item){return"healthCenter"===item.name})[0]},local:function(){var givenName=this.attributeTypes.filter(function(item){return"givenNameLocal"===item.name})[0],middleName=this.attributeTypes.filter(function(item){return"middleNameLocal"===item.name})[0],familyName=this.attributeTypes.filter(function(item){return"familyNameLocal"===item.name})[0];return givenName&&middleName&&familyName?{showNameField:!0,labelForNameField:givenName.description,placeholderForGivenName:givenName.description,placeholderForMiddleName:middleName.description,placeholderForFamilyName:familyName.description}:{showNameField:!1}}},PatientConfig}();var Bahmni=Bahmni||{};Bahmni.Common=Bahmni.Common||{},Bahmni.Common.PatientSearch=Bahmni.Common.PatientSearch||{},Bahmni.Common.PatientSearch.Constants={searchExtensionTileViewType:"tile",searchExtensionTabularViewType:"tabular",tabularViewIgnoreHeadingsLi
|