PageSourceSearch

https://vitlaccess.vitl.net/scripts/modules.8aa8a995.js

js vitl.net collected 2026-10-02 17:47:52 UTC 431,369 bytes, 8 lines download raw bytes

1/*! 
2=====
3Copyright © 2025 by MedicaSoft, LLC and S.C. Info World S.R.L. All Rights Reserved.
4Republication or redistribution of this software is prohibited without prior written consent of MedicaSoft, LLC.
5=====
6 */
7
8function multiSelect(){"use strict";return{restrict:"E",scope:{},controller:"MultiSelectCtrl",controllerAs:"multiSelect",templateUrl:"modules/reporting/directives/jasperInputControls/multiSelect/multiSelect.html",bindToController:{controlId:"=",controlValue:"=",onChanged:"&",isMandatory:"=",isDisabled:"=",customSlave:"=",customConfig:"=",customMaster:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}function MultiSelectController(e,t){"use strict";var n=this;n.$onInit=function(){n.dropdown={selected:[],all:[],isChecked:function(e){return _.find(n.selected,{value:n.all[e].value})},selectItem:function(e,t,i){_.find(n.selected,{value:e.value})?n.selected=_.reject(n.selected,{value:e.value}):e.value===i.exclusiveItemCode?n.selected=[e]:(_.remove(n.selected,function(e){return e.value===i.exclusiveItemCode}),n.selected=n.selected.concat(e)),n.selectOption(n.selected),t.updateInputList()},updateInputList:function(){return _.map(n.selected,"label").join()}},n.setState=function(){n.dropdown.all=angular.copy(n.controlValue),n.dropdown.selected=_.filter(n.dropdown.all,{selected:!0}),t.$broadcast("setInputDisplay"),_.isEmpty(n.dropdown.selected)||n.selectOption(n.dropdown.selected)},n.selectOption=function(t){var i={},a=e.mapSelectedValues(t),o=n.customSlave;i.control=e.createValue(n.controlId,a),_.isEmpty(o)||(i.slaveDependencies=n.customSlave),n.onChanged({control:i})},n.setState()}}app.dashboardWidgets.factory("WidgetResizer",["ResizerModel","$rootScope",function(e,t){"use strict";var n,i,a=25;function o(t,n,i){e.call(this,t,n,i),this.ctrlColumns=this.columns,this.intervene={selector:r,calculator:s,restrict:l}}function r(e){return i=angular.element(e),n=angular.element(e).closest("table")[0].id,angular.element(e).nextAll("th:visible").first()}function s(e,a){var o=e-a;return t.$emit("onResizeInProgress",n,i),o}function l(e){return e<a}return o.prototype=Object.create(e.prototype),o.prototype.calculate=function(e,t){return e+t},o.prototype.setup=function(){angular.element(this.container).css({overflowX:"hidden"}),angular.element(this.columns).first().css({width:"auto !important"})},o.prototype.handles=function(){return angular.element(this.columns).not(":last")},o.prototype.onFirstDrag=function(){angular.element(this.columns).each(function(e,t){angular.element(t).width(angular.element(t).width())})},o.prototype.onEndDrag=function(){var e=angular.element(this.table).outerWidth();angular.element(this.columns).each(function(t,n){var i=angular.element(n).outerWidth()/e*100+"%";angular.element(n).css({width:i})})},o.prototype.saveAttr=function(e){return angular.element(e)[0].style.width},o}]),app.dashboardWidgets.controller("nxtAllergyListCtrl",["gettextCatalog","$scope","$rootScope","CONSTANT","nxtInfiniteScrollSvc","$controller","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","NXT_ALLERGIES_WIDGET","$injector",function(e,t,n,i,a,o,r,s,l,d){"use strict";o("nxtDashboardWidgetsCtrl",{scope:t,rootScope:n,$injector:d});var c=[{id:"allergen-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Allergen"),visible:!0,sort:"code",code:"allergen",order:0},{id:"reaction-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Reaction"),visible:!0,code:"reaction-allergy",width:"25",order:1},{id:"comment-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Comment"),visible:!0,code:"comment-allergy",width:"20",order:2},{id:"date-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Date"),visible:!0,sort:"date",code:"date-allergy",width:"14",minWidth:"75",order:3},{id:"clinical-status-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Status"),visible:!0,sort:"clinical-status",code:"clinical-status-allergy",width:"7",order:4},{id:"source-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Source"),code:"source-allergy",visible:!0,width:"12",order:5},{id:"source-origin-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Source Document"),code:"source-origin-allergy",visible:t.isExpandedTable,width:"12",order:6}];t.widgetConfig=l,t.setFilters(),t.headers=_.sortBy(_.filter(t.setColumns(c),function(e){return e.visible}),"order");var u={},p={};function g(e){if(e&&e.length>0){t.setDisplayOriginAndSource(e);for(var n=0;n<e.length;n++)f(e[n])}}function f(e){e&&(e.reactionDisplay=e.recordedDateDisplay=e.onsetDis
8play="",e.reaction&&e.reaction.length>0&&e.reaction.forEach(function(n){n.manifestation&&n.manifestation.length>0&&(n.reactionDisplay=_.map(n.manifestation,"display").join(", ")),t.isExpandedTable||(e.reactionDisplay+=(e.reactionDisplay?", ":"")+n.reactionDisplay)}))}u.nxtAllergyIntoleranceSvc={methodName:"searchWithTotalRows"},t.infiniteScroll=a.create({services:u,limit:t.isExpandedTable?i.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:i.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),t.currentAppContextChecked||(t.sort={field:"date",direction:"-"}),t.$watch("mrnIds",function(){t.updateWidgetContext(),t.reloadTableData()}),t.reloadTableData=function(e,n){if(n||(t.allergies=null,t.hasMoreData=!1),t.patientContext&&t.mrnIds){if(t.waitingPatientDashboardCalls&&(delete t.waitingPatientDashboardCalls,s.PatientData[t.key]&&s.PatientData[t.key][t.code])){var i=angular.copy(s.PatientData[t.key][t.code].entries);return g(i),t.allergies=i,t.infiniteScroll.setDataFromControl([s.PatientData[t.key][t.code]]),t.hasMoreData=!t.infiniteScroll.disabled,void t.setNoSearchResultsFound(p.n
8xtAllergyIntoleranceSvc,t.allergies.length)}t.loading=!0,p.nxtAllergyIntoleranceSvc=_.extend({mrnIds:t.mrnIds,sort:"="+t.sort.direction+t.sort.field,withNoSessionReset:e},r.getAllergyParams({})),t.infiniteScroll.isBusy(!n,p)?t.infiniteScroll.disabled&&!t.infiniteScroll.busy&&(t.loading=!1):t.infiniteScroll.nextPage(!n).then(function(e){t.allergies||(t.allergies=[]),e||(e=[]),g(e),t.allergies=n?t.allergies.concat(e):e,t.hasMoreData=!t.infiniteScroll.disabled,t.setNoSearchResultsFound(p.nxtAllergyIntoleranceSvc,t.allergies.length),t.loading=!1},function(){t.loading=!1})}},t.viewAllergy=function(n){t.isViewDetailsAvailable()&&t.view(n.getText(),e.getString("View Allergy"),n.externalSources)}}]),app.dashboardWidgets.controller("nxtAttestingCtrl",["$scope","nxtUserContextSvc","nxtUserSvc","NXT_SSO_CONFIG","nxtAttestationSvc",function(e,t,n,i,a){"use strict";e.loading=!0,e.closeDialog=i.CloseDialog,a.getAttestation().then(function(t){t&&t.reason&&(t.reason=t.reason.reverse()),e.attestation=t,e.loading=!1},function(){e.loading=!1}),e.save=function(i){var a=_.find(e.attestation.reason,function(e){return e&&e.code===i});a&&(t.setCurrentPageContextProperty("attestationEnabled_"+e.patient.eid,!0),e.isSaving=!0,n.attestation({patient:e.patient,reason:a}).then(function(){e.$close(a)},function(t){e.errMessage=t,e.isSaving=!1}))},e.close=function(){e.$dismiss("cancel")}}]),app.dashboardWidgets.controller("nxtClinicalNotesListCtrl",["$scope","$rootScope","$locale","$filter","nxtDocumentFormatterSvc","nxtInfiniteScrollSvc","$controller","gettextCatalog","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","CONSTANT","NXT_DOCUMENTS_WIDGET","$timeout","$injector","$uibModal","$window","nxtUserContextSvc","nxtBinarySvc","nxtUtilsSvc",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m,v,S){"use strict";e.displayViewerInline=!u.DisplayCustomCDAViewer,e.isOrganizationUser=m.LoggedUserConfiguration&&m.LoggedUserConfiguration.organization,r("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:g});var C=[{id:"doc-name-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:s.getString("Description"),visible:!0,sort:"description",code:"description",order:0},{id:"doc-source-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:s.getString("Source"),code:"source-doc",visible:!0,width:e.isExpandedTable?"12":"25",order:e.isExpandedTable?5:2},{id:"doc-type-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:s.getString("Type"),visible:e.isExpandedTable,code:"type",sort:"type",width:"12",order:1},{id:"doc-created-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:s.getString("Created"),visible:!0,code:"created",sort:"created",width:e.isExpandedTable?"11":"22",minWidth:"110",order:e.isExpandedTable?2:1},{id:"doc-indexed-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:s.getString("Imported Date"),visible:e.isExpandedTable,code:"indexed",sort:"indexed",width:"11",minWidth:"110",order:3},{id:"doc-status-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:s.getString("Status"),visible:e.isExpandedTable,code:"docstatus",sort:"docstatus",width:"7",order:4},{id:"doc-suppressed-reason-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:s.getString("Reason"),visible:e.isExpandedTable,code:"docsuppressedreason",width:"7",order:5},{id:"doc-selection-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:"",code:"selection-mode",visible:e.isExpandedTable,width:"5",order:6}];function y(){let t=_.filter(C,function(e){return"docsuppressedreason"!==e.code});e.filter&&"entered-in-error"===e.filter.status&&(t=_.filter(C,function(e){return"docstatus"!==e.code})),e.headers=_.sortBy(_.filter(e.setColumns(t),function(e){return e.visible}),"order")}y(),e.hasPrintOptionColumn=_.find(e.headers,function(e){return"selection-mode"===e.code}),e.hasPrintOptionColumn&&(e.selectionMode=!0,e.selectedForPrintCount=0),e.widgetConfig=u,e.setFilters(!0);var b,x={},D={};if(x.nxtDocumentReferenceSvc={methodName:"searchWithTotalRows"},e.infiniteScroll=o.create({services:x,limit:e.isExpandedTable?c.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:c.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),!e.currentAppContextChecked){var T=null;u&&u.Filter&&u.Filter.Type&&u.Filter.Type.DefaultValue&&u.Filter.Type.DefaultValue.length>0&&(T=u.Filter.Type.DefaultValue.join()),e.filter={description:null,searchTypeText:null,type:T,status:"current"},e.sort={field:"created",direction:"-"}}if(e.filterDates={startFrom:null,startTo:null,indexedFrom:null,indexedTo:null},e.availableFilter&&_.find(e.availableFilter,function(e){return"imported-date"===e.Code}))var w=e.$on("indexed"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.indexedFrom=null,e.filterDates.indexedTo=null,e.filterDates.indexedIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.indexedFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.indexedTo=n.interval.endDate),e.filterDates.indexedIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),e.filter=_.extend(e.filter,{indexed:{from:e.filterDates.indexedFrom,to:e.filterDates.indexedTo,isAllInterval:e.filterDates.indexedIsAllInterval}}),t.stopPropagation()});if(e.availableFilter&&_.find(e.availableFilter,function(e){return"created"===e.Code}))var E=e.$on("start"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.startFrom=null,e.filterDates.startTo=null,e.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.startTo=n.interval.endDate),e.filterDates.startIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),e.filter=_.extend(e.filter,{start:{from:e.filterDates.startFrom,to:e.filterDates.startTo,isAllInterval:e.filterDates.startIsAllInterval}}),t.stopPropagation()});function P(t){if(t&&t.length>0){e.setDisplayOriginAndSource(t);for(let e=0;e<t.length;e++)I(t[e])}}function I(e){e&&(e.description&&(e.descriptionDisplay=e.description),e.docStatusDisplay=e.docStatus?"["+e.docStatus+"]":"",e.created?e.createdDateDisplay=i("date")(e.created,n.DATETIME_FORMATS.nxtDateFormat):e.createdDateDisplay="")}e.hasUploadDocument=m.HasUploadDocument,e.$watchCollection("[mrnIds, filter.description, filter.status, filterDates.startFrom, filterDates.startTo, filter.searchTypeText,filterDates.indexedFrom, filterDates.indexedTo]",function(t,n){!e.filterDates.startTo&&E||!e.filterDates.indexedTo&&w||(e.updateWidgetContext(),t&&n&&t[2]!==n[2]&&y(),u&&u.Upload&&u.Upload.Enabled&&e.refreshClinicalDocumentWidget(t&&t[0],n&&n[0])&&!e.hasUploadDocument?e.hasUploadDocument=!0:e.reloadTableData())}),e.reloadTableData=function(t,n){if(n||(e.clinicalNotesData=null,e.hasPrintOptionColumn&&(e.selectionMode=!0,e.selectedForPrintCount=0),e.hasMoreData=!1,e.isExpandedTable&&e.documentSelectedItem&&e.displayViewerInline&&(e.operation=null,e.changeSelection(null))),e.patientContext&&e.mrnIds){if(e.waitingPatientDashboardCalls&&(delete e.waitingPatientDashboardCalls,d.PatientData[e.key]&&d.PatientData[e.key][e.code])){var i=angular.copy(d.PatientData[e.key][e.code].entries);
8return P(i),e.clinicalNotesData=i,e.infiniteScroll.setDataFromControl([d.PatientData[e.key][e.code]]),e.hasMoreData=!e.infiniteScroll.disabled,void e.setNoSearchResultsFound(D.nxtDocumentReferenceSvc,e.clinicalNotesData.length)}e.loading=!0,D.nxtDocumentReferenceSvc=_.extend({mrnIds:e.mrnIds,sort:"="+e.sort.direction+e.sort.field,withNoSessionReset:t},l.getDocumentParams(e.filter)),e.infiniteScroll.isBusy(!n,D)?e.infiniteScroll.disabled&&!e.infiniteScroll.busy&&(e.loading=!1):e.infiniteScroll.nextPage(!n).then(function(t){e.clinicalNotesData||(e.clinicalNotesData=[]),t||(t=[]),P(t),e.clinicalNotesData=n?e.clinicalNotesData.concat(t):t,e.hasMoreData=!e.infiniteScroll.disabled,e.isExpandedTable&&!n&&e.displayViewerInline&&(e.operation=e.clinicalNotesData&&e.clinicalNotesData.length>0?"view":null,e.changeSelection(e.clinicalNotesData&&e.clinicalNotesData.length>0?e.clinicalNotesData[0]:null)),e.setNoSearchResultsFound(D.nxtDocumentReferenceSvc,e.clinicalNotesData.length),e.loading=!1},function(){e.loading=!1})}},e.isExpandedTable&&e.displayViewerInline&&e.$watch("documentSelectedItem",function(t,n){t&&t!==n&&(e.operation="view",e.documentViewerFile=null,b=p(function(){e.documentViewerFile={file:t}},1))},!0),e.selectForPrint=function(t,n,i){return t.stopPropagation(),n&&n.selectedForPrint?e.selectedForPrintCount--:e.selectedForPrintCount++,i&&(n.selectedForPrint=!n.selectedForPrint),!1},e.printReports=function(){var t;if(e.selectionMode&&(t=_.filter(e.clinicalNotesData,function(e){return e.selectedForPrint})),t){var n=e.$new();n.title="Print Documents",n.reportsToPrint=t,n.docLoading=!0,f.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:n,controller:["$scope","$uibModalInstance","$q","nxtPrintUtilsSvc","gettextCatalog",function(e,t,n,i,o){for(var r=[],s=0;s<e.reportsToPrint.length;s++)if(e.reportsToPrint[s].content&&e.reportsToPrint[s].content.length>0)for(let t=0;t<e.reportsToPrint[s].content.length;t++)(e.reportsToPrint[s].content[t].url||e.reportsToPrint[s].content[t].data)&&r.push({description:e.reportsToPrint[s].description,content:{resourceType:"DocumentReference",data:e.reportsToPrint[s].content[t].data,location:e.reportsToPrint[s].content[t].url,mimeType:e.reportsToPrint[s].content[t].contentType}});else r.push({description:e.reportsToPrint[s].description,content:{resourceType:"DocumentReference",location:e.reportsToPrint[s].location,mimeType:e.reportsToPrint[s].mimeType}});var l,d=[];if(r.length>0)for(let e=0;e<r.length;e++)"application/pdf"===(l=r[e]).content.mimeType?d.push(v.get(l.content.location,{responseType:"arraybuffer",headers:{Accept:"application/pdf"}})):d.push(a.getPreview(l));n.all(d).then(function(t){if(t&&t.length){e.hList=[];for(let n=0;n<t.length;n++)t[n].data&&"application/pdf"===t[n].type?e.hList.push({binary:t[n].data,description:r[n].description}):(t[n]=t[n].replace(/•/g,"&#8226;").replace(/·/g,"&#8208;"),t[n]=t[n].replace(/<caption>/g,'<div class="caption">').replace(/<\/caption>/g,"</div>"),e.hList.push({html:t[n],description:r[n].description}));i.generateDocumentsPdf(e.hList).then(function(t){var n;if(h.navigator&&h.navigator.msSaveOrOpenBlob){for(var i=atob(t),a=new Array(i.length),o=0;o<i.length;o++)a[o]=i.charCodeAt(o);var r=new Uint8Array(a);n=new Blob([r],{type:"application/pdf"}),h.navigator.msSaveOrOpenBlob(n)}else{n=S.b64toBlob(t,"application/pdf");var s=URL.createObjectURL(n);e.htmlList=['<iframe type="application/pdf" src="{{0}}#navpanes=0" width="100%" height="100%" class="viewer" scrolling="auto"></iframe>'.replace("{{0}}",s)]}e.docLoading=!1},function(){e.docLoading=!1,e.documentNotFound=!0,e.htmlList=['<div class="alert alert-danger alert-danger-instructions-documents">'+o.getString("Document could not be loaded")+"!</div>"]})}},function(){e.docLoading=!1,e.documentNotFound=!0,e.htmlList=['<div class="alert alert-danger alert-danger-instructions-documents">'+o.getString("Document could not be loaded")+"!</div>"]}),e.close=function(){t.dismiss("cancel")};var c=e.$on("onLoaded",function(t){e.docLoading=!1});e.$on("$destroy",function(){c&&c()})}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})}},e.viewDoc=function(n){if(n&&n.id){var i=e.$new();i.showButtonPrint=!0,i.showButtonDownload=!0,i.isExpanded=!0,i.file=n,i.dialogClass=t.showVerbiage?"nxt-full-popup-with-verbiage":"nxt-full-popup",i.keepDialogClass=!0,i.showSources=!0,a.viewFile(i)}},e.upload=function(){var n=e.$new();n.patient=angular.copy(e.patientContext&&e.patientContext.Patient),f.open({templateUrl:"modules/dashboardWidgets/clinicalNotes/uploadFile.html",scope:n,controller:"nxtUploadFileCtrl",backdrop:"static",windowClass:"nxt-light-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(e){if(e&&e.patient&&t.$emit("onUploadedFile",{mrn:_.find(e.patient.identifier,function(t){return t.system===e.info.mrn}),display:e.info.display}),e&&e.doc){var n=angular.copy(e.doc.content[0].attachment);e.doc.content=[n],t.$emit("onUploadedFileCompleted",e.doc)}},function(){})};var A=t.$on("onUploadedFileCompleted",function(t,n){e.clinicalNotesData||(e.clinicalNotesData=[]);var i=[angular.copy(n)];P(i),e.filter&&"current"===e.filter.status&&(e.clinicalNotesData=i.concat(e.clinicalNotesData),e.isExpandedTable&&e.displayViewerInline&&(e.operation=e.clinicalNotesData&&e.clinicalNotesData.length>0?"view":null,e.changeSelection(e.clinicalNotesData&&e.clinicalNotesData.length>0?e.clinicalNotesData[0]:null)))}),R=t.$on("onSupressFileCompleted",function(t,n){if(e.clinicalNotesData&&e.clinicalNotesData.length>0)for(var i=0;i<e.clinicalNotesData.length;i++)if(n===e.clinicalNotesData[i].id){e.clinicalNotesData.splice(i,1);break}e.isExpandedTable&&e.displayViewerInline&&e.documentSelectedItem&&n===e.documentSelectedItem.id&&(e.operation=e.clinicalNotesData&&e.clinicalNotesData.length>0?"view":null,e.changeSelection(e.clinicalNotesData&&e.clinicalNotesData.length>0?e.clinicalNotesData[0]:null))});e.$on("$destroy",function(){E&&E(),w&&w(),b&&p.cancel(b),A(),R()})}]),app.dashboardWidgets.controller("nxtSuppressionFileCtrl",["$scope","$uibModalInstance","nxtValueSetSvc","nxtDocumentReferenceSvc",function(e,t,n,i){"use strict";e.data={supressionReason:null},e.isLoading=!0,n.searchRecurrent({valueSetName:"UploadDocumentSuppresssionReason"}).then(function(t){e.supressionReasonList=t,e.data.supressionReason=_.find(t,function(e){return"entered-in-error"===e.code}),e.isLoading=!1},function(){e.isLoading=!1}),e.close=function(){t.dismiss("cancel")},e.save=function(){e.isSaving=!0,i.del({id:e.docId,supressionReason:e.data.supressionReason}).then(function(n){t.close(e.docId),e.isSaving=!1},function(){e.isSaving=!1})}}]),app.dashboardWidgets.controller("nxtUploadFileCtrl",["$scope","$uibModalInstance","fileReader","NXT_DOCUMENTS_WIDGET","nxtValueSetSvc","nxtPatientSvc","nxtUtilsSvc","nxtDocumentReferenceSvc","nxtUserContextSvc","NXT_LINK_ID","CONSTANT","nxtUserSvc","$q",function(e,t,n,i,a,o,r,s,l,d,c,u,p){"use strict";e.maxFileSize=i.Upload&&i.Upload.MaxFileSize?i.Upload.MaxFileSize:null,e.allowedFileExtensions=i.Upload&&i.Upload.AllowedFileExtensions?i.Upload.AllowedFileExtensions:"",e.acceptedExtensions=e.allowedFileExtensions.split(" ").map(function(e){return"."+e}).join(","),e.verbiage=i.Upload&&i.Upload.Verbiage?i.Upload.Verbiage:null,e.mrnSystem=i.Upload&&i.Upload.MrnSystem?i.Upload.MrnSystem:"",e.mrnDisplay=i.Upload&&i.Upload.MrnDisplay?i.Upload.MrnDisplay:"",e.isInvalidConfiguration=!1,e.msgMaliciousFile=c.ERROR.MSG_MALICIOUS_OBJECT,e.msgNotPDF=c.ERROR.MSG_INVALID_PDF_FILE;var g,f=["namePrefix","familyName","givenName","middleName","nameSuffix","gender.code","birthDate","phone","phoneNotes","mobilePhone","mobilePhoneNotes","email","homeAddress.line1","homeAddress.line2","homeAddress.city","homeAddress.state.code","homeAddress.zip","ssn"];function h(t){var n=s.create();n.description=e.doc.description,n.type=e.doc.type,n.indexed=new Date,n.patient=t,n.status="current",n.docStatus="final",n.content=[{attachment:{contentType:e.doc.file.mimeType}}],n.data=e.doc.data;let i={sourcePortalAuthor:l.loggedUser};return l.LoggedUserConfiguration.organization&&(i.sourcePortalOrganization=l.LoggedUserConfiguration.organization),n.initilaExternalSources=[{sourceOrganization:e.mrnSystem,sourceOrganizationDisplay:e.mrnDisplay}],n.externalSources=[{sourceOrganization:e.mrnSystem,sourceOrganizationDisplay:l.loggedUser.toFhirReference().display+(l.LoggedUserConfiguration.organization?" ("+l.LoggedUserConfiguration.organization.toFhirReference().display+")":"")}],n.portalSources=i,n}e.isLoading=!0,_.isEmpty(e.mrnSystem)||_.isEmpty(e.mrnDisplay)?e.isInvalidConfiguration=!0:a.searchRecurrent({valueSetName:"UploadDocumentType"}).then(function(t){e.documentTypesList=t,e.isLoading=!1},function(){e.isLoading=!1}),e.close=function(){t.dismiss("cancel")},e.save=function(){e.isSaving=!0;var n,i=_.find(e.patient.mrnList,function(t){return t.id&&t.id.indexOf(e.mrnSystem+"|")>-1});if(i){var a=_.extend(e.patient,{id:i.id});s.save(h(a),e.doc.file.mimeType).then(function(n){t.close({doc:n,info:{mrn:e.mrnSystem,display:e.mrnDisplay}}),e.isSaving=!1},function(t){t&&t.issue?(_.find(t.issue,function(e){return e.details&&e.details.code===c.ERROR.MSG_MALICIOUS_OBJECT.code})&&(e.isMaliciousFile=!0),_.find(t.issue,function(e){return e.details.code===c.ERROR.MSG_INVALID_PDF_FILE.code})&&(e.isNotPDF=!0)):(e.isMaliciousFile=!1,e.isNotPDF=!1),e.isSaving=!1})}else(n=_.extend(o.create(),_.omitBy(_.pick(e.patient,f),_.isNil))).identifier=[{system:e.mrnSystem,value:r.generateGUID().replace(/-/g,"")},{system:d,value:e.patient.eid}],n.externalSources=[{sourceOrganization:e.mrnSystem,sourceOrganizationDisplay:e.mrnDisplay}],o.save(n,!0).then(function(n){var i=[];i.push(s.save(h(n),e.doc.file.mimeType)),e.patient.breakGlassReason&&i.push(u.enableBreakGlass({patient:e.patient,reason:e.patient.breakGlassReason})),e.patient.attestationReason&&i.push(u.attestation({patient:e.patient,reason:e.patient.attestationReason})),p.all(i).then(function(i){var a=i[0];t.close({patient:n,doc:a,info:{mrn:e.mrnSystem,display:e.mrnDisplay}}),e.isSaving=!1},function(){e.isSaving=!1})},function(){e.isSaving=!1})},e.doc={},e.readFile=function(){if(g=this.mainForm,e.otherErrorMessage=null,e.isMaliciousFile=!1,e.isNotPDF=!1,g.$setValidity("otherErrorMessage",!0),!e.doc.file)return g.$setValidity("fileSize",!0),void g.$setValidity("fileExtension",!0);e.doc.title=e.doc.file.name;var t=_.last(e.doc.file.name.split(".")).toLowerCase();if(t){var i=e.doc.file.name.split("."+t);e.doc.description=i.splice(0,i.length-1).join(" ")}else e.doc.description=e.doc.file.name.split;g.$setValidity("fileSize",v(e.doc.file)),g.$setValidity("fileExtension",m(e.doc.file)),v(e.doc.file)&&m(e.doc.file)&&(e.isLoading=!0,n.readAsBuffer(e.doc.file,e).then(function(t){e.doc.data=t,e.isLoading=!1,g.$setValidity("fileSize",v(e.doc.file)),g.$setValidity("fileExtension",m(e.doc.file))},function(t){e.doc.data=void 0,e.isLoading=!1,g.$setValidity("fileSize",!0),g.$setValidity("fileExtension",!0)}))};var m=function(t){if(!t.name||t.name.indexOf(".")<0)return!1;var n=_.last(t.name.split(".")).toLowerCase();return e.allowedFileExtensions.split(" ").indexOf(n)>=0},v=function(t){return t.size<=1048576*e.maxFileSize}}]),app.dashboardWidgets.controller("nxtConditionListCtrl",["$scope","$rootScope","$controller","gettextCatalog","nxtInfiniteScrollSvc","CONSTANT","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","NXT_SOCIAL_HISTORY_WIDGET","$injector","NXT_PROBLEMS_WIDGET","NXT_FAMILY_HISTORY_WIDGET",function(e,t,n,i,a,o,r,s,l,d,c,u){"use strict";n("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:d}),e.category="medical";var p,g={},f={};if("pacConditions"!==e.code&&(e.widgetConfig="pacSocialHistory"===e.code?l:u,e.category="pacSocialHistory"===e.code?"social":"family",p=[{id:"cond-condition-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:"pacSocialHistory"===e.code?i.getString("Social Issues"):i.getString("Problem/Condition"),visible:!0,sort:"code",code:"condition",order:0},{id:"cond-category-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Category"),visible:e.isExpandedTable&&"social"===e.category,code:"category",width:"12",order:1},{id:"cond-relation-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Relation"),visible:e.isExpandedTable&&"family"===e.category,code:"relation",width:"12",order:1},{id:"cond-age-at-onset-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Age at Onset"),visible:e.isExpandedTable&&"family"===e.category,code:"age-at-onset",width:"5",order:2},{id:"cond-deceased-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Deceased"),visible:e.isExpandedTable&&"family"===e.category,code:"deceased",width:"5",order:3},{id:"cond-age-at-death-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Age at Death"),visible:e.isExpandedTable&&"family"===e.category,code:"age-at-death",width:"5",order:4},{id:"cond-onset-date-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Onset Date"),visible:!0,sort:"onset_date",code:"onset-date",width:e.isExpandedTable?"7":"14",minWidth:"75",order:e.isExpandedTable?"family"===e.category?5:2:1},{id:"cond-resolved-date-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Resolved Date"),visible:e.isExpandedTable,sort:"resolved-date",code:"resolved-date",width:"7",minWidth:"75",order:"family"===e.category?6:3},{id:"cond-status-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Status"),visible:e.isExpandedTable,sort:"clinical-status",code:"status",width:"7",order:"family"===e.category?7:4},{id:"cond-source-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source"),code:"source",visible:!0,width:e.isExpandedTable?"12":"25",order:e.isExpandedTable?"family"===e.category?8:5:2},{id:"cond-source-origin-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source Document"),code:"source-origin",visible:e.isExpandedTable,width:"12",order:"family"===e.category?9:6}]),"pacConditions"===e.code&&(e.widgetConfig=c,p=[{id:"cond-condition-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Problem/Condition"),visible:!0,sort:"code",code:"condition",order:0},{id:"cond-condition-code-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Code"),visible:!0,code:"condition-code",width:"20",order:1},{id:"cond-onset-date-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Onset Date"),visible:!0,sort:"onset_date",code:"onset-date",width:e.isExpandedTable?"7":"14",minWidth:"75",order:2},{id:"cond-resolved-date-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Resolved Date"),visible:e.isExpandedTable,sort:"resolved-date",code:"resolved-date",width:"7",minWidth:"75",order:3},{id:"cond-status-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Status"),visible:!0,sort:"clinical-status",code:"status",width:"7",order:e.isExpandedTable?4:3},{id:"cond-source-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source"),code:"source",visible:!0,width:e.isExpandedTable?"12":"25",order:e.isExpandedTable?5:4},{id:"cond-source-origin-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source Document"),code:"source-origin",visible:e.isExpandedTable,width:"12",order:6}]),e.setFilters(),e.headers=_.sortBy(_.filter(e.setColumns(p),function(e){return e.visible}),"order"),f.nxtConditionSvc={methodName:"searchWithTotalRows"},e.infiniteScroll=a.create({services:f,limit:e.isExpandedTable?o.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:o.GENER
8IC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),e.statusList=[{code:"",display:"All statuses"},{code:"active",display:"Active"},{code:"inactive",display:"Inactive"},{code:"recurrence",display:"Recurrence"},{code:"remission",display:"Remission"},{code:"resolved",display:"Resolved"}],"social"===e.category){for(var h=[{code:"",display:"All categories"},{code:o.CONCEPT.LOINC.SOCIAL_HISTORY_SMOKING_STATUS.code,display:o.CONCEPT.LOINC.SOCIAL_HISTORY_SMOKING_STATUS.text},{code:o.CONCEPT.LOINC.SOCIAL_HISTORY_OCCUPATION.code,display:o.CONCEPT.LOINC.SOCIAL_HISTORY_OCCUPATION.text},{code:o.CONCEPT.LOINC.SOCIAL_HISTORY_INDUSTRY.code,display:o.CONCEPT.LOINC.SOCIAL_HISTORY_INDUSTRY.text},{code:o.CONCEPT.LOINC.SOCIAL_HISTORY_ALCOHOL.code,display:o.CONCEPT.LOINC.SOCIAL_HISTORY_ALCOHOL.text},{code:o.CONCEPT.LOINC.SOCIAL_HISTORY_DRUG_TYPE.code,display:o.CONCEPT.LOINC.SOCIAL_HISTORY_DRUG_TYPE.text},{code:o.CONCEPT.LOINC.SOCIAL_HISTORY_DRUG_USE.code,display:o.CONCEPT.LOINC.SOCIAL_HISTORY_DRUG_USE.text}],m=h.length-1;m>-1;m--)h[m].code&&!_.find(l.Categories,function(e){return e.trim()===h[m].code.trim()})&&h.splice(m,1);e.categoryList=h}if(!e.currentAppContextChecked){var v={category:null,description:null,status:e.isExpandedTable?e.statusList[0]:e.statusList[1]};"social"===e.category&&(v.category=e.categoryList[0]),e.filter=v,e.sort={field:"onset_date",direction:"-"}}if(e.filterDates={startFrom:null,startTo:null,endFrom:null,endTo:null},"pacConditions"!==e.code&&e.availableFilter&&_.find(e.availableFilter,function(e){return"resolved-date"===e.Code}))var S=e.$on("end"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.endFrom=null,e.filterDates.endTo=null,e.filterDates.endIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.endFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.endTo=n.interval.endDate),e.filterDates.endIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),e.filter=_.extend(e.filter,{end:{from:e.filterDates.endFrom,to:e.filterDates.endTo,isAllInterval:e.filterDates.endIsAllInterval}}),t.stopPropagation()});if(e.availableFilter&&_.find(e.availableFilter,function(e){return"onset-date"===e.Code}))var C=e.$on("start"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.startFrom=null,e.filterDates.startTo=null,e.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.startTo=n.interval.endDate),e.filterDates.startIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),e.filter=_.extend(e.filter,{start:{from:e.filterDates.startFrom,to:e.filterDates.startTo,isAllInterval:e.filterDates.startIsAllInterval}}),t.stopPropagation()});function y(t){for(var n=0;n<t.length;n++)b(t[n]);e.setDisplayOriginAndSource(t)}function b(t){if(t){if(t.code){if(t.codeDisplay=t.code,"pacConditions"===e.code&&e.filter&&(e.filter.description||e.filter.multipleFields)&&t.codeList&&t.codeList.length>1)for(var n=0;n<t.codeList.length;n++){if(e.filter.description&&t.codeList[n].display&&t.codeList[n].display.toLowerCase()===e.filter.description.toLowerCase()){t.codeDisplay=t.codeList[n];break}if(e.filter.description&&t.codeList[n].code&&t.codeList[n].code.toLowerCase()===e.filter.description.toLowerCase()){t.codeDisplay=t.codeList[n];break}if(e.filter.multipleFields&&t.codeList[n].display&&t.codeList[n].display.toLowerCase().indexOf(e.filter.multipleFields.toLowerCase())>=0){t.codeDisplay=t.codeList[n];break}if(e.filter.multipleFields&&t.codeList[n].code&&t.codeList[n].code.toLowerCase().indexOf(e.filter.multipleFields.toLowerCase())>=0){t.codeDisplay=t.codeList[n];break}}if("pacConditions"===e.code&&e.filter&&e.filter.code&&t.codeList&&t.codeList.length>1)for(var i=0;i<t.codeList.length;i++)if(t.codeList[i].code&&t.codeList[i].code.toLowerCase()===e.filter.code.toLowerCase()){t.codeDisplay=t.codeList[i];break}}if(t.categoryList&&t.categoryList.length>0&&t.categoryList[0].code&&_.find(l.Categories,function(e){return e.trim()===t.categoryList[0].code.trim()}))switch(t.categoryList[0].code){case o.CONCEPT.LOINC.SOCIAL_HISTORY_SMOKING_STATUS.code:t.categoryDisplay=o.CONCEPT.LOINC.SOCIAL_HISTORY_SMOKING_STATUS.text;break;case o.CONCEPT.LOINC.SOCIAL_HISTORY_OCCUPATION.code:t.categoryDisplay=o.CONCEPT.LOINC.SOCIAL_HISTORY_OCCUPATION.text;break;case o.CONCEPT.LOINC.SOCIAL_HISTORY_INDUSTRY.code:t.categoryDisplay=o.CONCEPT.LOINC.SOCIAL_HISTORY_INDUSTRY.text;break;case o.CONCEPT.LOINC.SOCIAL_HISTORY_ALCOHOL.code:t.categoryDisplay=o.CONCEPT.LOINC.SOCIAL_HISTORY_ALCOHOL.text;break;case o.CONCEPT.LOINC.SOCIAL_HISTORY_DRUG_TYPE.code:t.categoryDisplay=o.CONCEPT.LOINC.SOCIAL_HISTORY_DRUG_TYPE.text;break;case o.CONCEPT.LOINC.SOCIAL_HISTORY_DRUG_USE.code:t.categoryDisplay=o.CONCEPT.LOINC.SOCIAL_HISTORY_DRUG_USE.text}if(!e.isExpandedTable&&t.category&&"family"===t.category.code&&t.details&&t.details.length>0){t.familyDisplay="";for(var a=[],r=0;r<t.details.length;r++)a.push(t.details[r].relationship.display);t.familyDisplay=_.orderBy(a).join(", ")}}}e.$watchCollection("[mrnIds, filter.multipleFields, filter.category, filter.description, filter.code, filter.status.code, filterDates.startFrom, filterDates.startTo, filterDates.endTo, filterDates.endFrom]",function(){!e.filterDates.startTo&&C||"pacConditions"!==e.code&&!e.filterDates.endTo&&S||(e.updateWidgetContext(),e.reloadTableData())}),e.reloadTableData=function(t,n){if(n||(e.conditions=null,e.hasMoreData=!1),e.patientContext&&e.mrnIds){if(e.waitingPatientDashboardCalls&&(delete e.waitingPatientDashboardCalls,s.PatientData[e.key]&&s.PatientData[e.key][e.code])){var i=angular.copy(s.PatientData[e.key][e.code].entries);
8return y(i),e.conditions=i,e.infiniteScroll.setDataFromControl([s.PatientData[e.key][e.code]]),e.hasMoreData=!e.infiniteScroll.disabled,void e.setNoSearchResultsFound(g.nxtConditionSvc,e.conditions.length)}e.loading=!0,g.nxtConditionSvc=_.extend({mrnIds:e.mrnIds,sort:"="+e.sort.direction+e.sort.field,withNoSessionReset:t},r.getConditionParams(e.filter,e.category)),e.infiniteScroll.isBusy(!n,g)?e.infiniteScroll.disabled&&!e.infiniteScroll.busy&&(e.loading=!1):e.infiniteScroll.nextPage(!n).then(function(t){e.conditions||(e.conditions=[]),t||(t=[]),y(t),e.conditions=n?e.conditions.concat(t):t,e.hasMoreData=!e.infiniteScroll.disabled,e.setNoSearchResultsFound(g.nxtConditionSvc,e.conditions.length),e.loading=!1},function(){e.loading=!1})}};var x=!1;e.viewCondition=function(t){e.isViewDetailsAvailable()&&(x||(x=!0,t.getText(e.category).then(function(n){var a=i.getString("View Problem");"social"===e.category&&(a=i.getString("View Social History")),"family"===e.category&&(a=i.getString("View Family History")),x=!1,e.view(n,a,t.externalSources)},function(){x=!1})))},e.$on("$destroy",function(){C&&C(),S&&S()})}]),app.dashboardWidgets.controller("demographicsCtrl",["$scope","nxtPatientSvc","$q","nxtUtilsSvc","nxtCoverageSvc","nxtRelatedPersonSvc","nxtTextSvc","$uibModal","NXT_EMERGENCY_CONTACT","nxtMessageHeaderSvc","NXT_INSURANCE","NXT_DEMOGRAPHICS","$window","$document",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g){"use strict";function f(t){e.isLoading=!0;var n=e.$new();n.data={patient:e.patient,insurances:e.insurances,emergencyList:e.emergencyList},n.operation=t,s.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:n,controller:["$scope","$uibModalInstance","nxtPrintUtilsSvc",function(t,n,i){t.docLoading=!0,t.title="Patient Demographics",i.generateDemographics(t.data).then(function(e){if("print"===t.operation)if(p.navigator&&p.navigator.msSaveOrOpenBlob)p.navigator.msSaveOrOpenBlob(e),t.close();else{var n='<iframe src="{{0}}"  type="{{1}}" width="100%" height="100%" class="viewer"></iframe>';t.htmlList=[n.replace("{{0}}",URL.createObjectURL(e)).replace(/\{\{1\}\}/g,"application/pdf")]}else if("download"===t.operation){var i=t.title+".pdf";if(navigator.msSaveBlob)return navigator.msSaveBlob(e,i);var a=g[0].createElement("a");a.href=URL.createObjectURL(e),a.setAttribute("download",i),g[0].body.appendChild(a),a.click(),t.close()}else t.htmlList=[n.replace("{{0}}",URL.createObjectURL(e)).replace(/\{\{1\}\}/g,"application/pdf")]},function(){e.docLoading=!1}),t.close=function(){n.dismiss("cancel")};var a=t.$on("onLoaded",function(e){t.docLoading=!1});t.$on("$destroy",function(){a&&a()})}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){e.isLoading=!1},function(){e.isLoading=!1})}e.isLoading=!0,e.disclaimerText=u.DisclaimerText,function(){e.mrnIds=i.getMrnIds(e.patient.mrnList);var r=[t.search({patientId:e.patient.eid,limit:1})];_.isEmpty(e.mrnIds)||(c&&c.ShowInsurancesAttachedToLatestADTMessage?r.push(d.search({mrnIds:e.mrnIds,messageType:"ADT",withNoSessionReset:null,limit:1,sort:"=-timestamp,-sequence_number"})):r.push(a.search({mrnIds:e.mrnIds,withNoSessionReset:null,limit:3,includePayor:!0,sort:"=-period_start"})),r.push(o.searchRecurrentWithTotalRows({mrnIds:e.mrnIds,sort:"=-name",limit:50})));n.all(r).then(function(t){var i=[],o=[];c&&c.ShowInsurancesAttachedToLatestADTMessage&&(t[1]&&t[1][0]&&t[1][0].parsedContent&&(i=_.filter(t[1][0].parsedContent,function(e){return e&&e.reference&&-1!==e.reference.indexOf("Coverage")})),i&&i.length>0&&o.push(a.search({mrnIds:e.mrnIds,ids:_.map(i,"reference").join(","),withNoSessionReset:null,limit:i.length,includePayor:!0,sort:"=-period_start"}))),n.all(o).then(function(n){if(e.patient=t[0][0],e.insurances=c&&c.ShowInsurancesAttachedToLatestADTMessage?_.orderBy(n[0],["order"],["asc"]):_.orderBy(t[1],["order"],["asc"]),t[2]&&t[2].entries&&t[2].entries.length>0){var i=[];if(l&&l.length>0){for(var a=0;a<l.length;a++)i=i.concat(_.filter(t[2].entries,function(e){return e.relationship&&e.relationship.code&&e.relationship.code.toLowerCase()===l[a].toLowerCase()}));i&&i.length>0&&(e.emergencyList=[_.orderBy(i,["period.start"],["desc"])[0]])}}e.isLoading=!1},function(){e.isLoading=!1})},function(){e.isLoading=!1})}(),e.getAddress=function(e){return r.getTextAddress(e)},e.getPatientName=function(t){return r.getHumanName(t?e.patient.alternativeName:e.patient)}
8,e.getValue=function(e){return e.valueReference?e.valueReference.display:e.text?e.text:e.display?e.display:e},e.getValues=function(t){return _.map(t,function(t){return e.getValue(t)}).join(", ")},e.getPeriod=function(e,t){return r.getTextPeriod(e,t)},e.close=function(){e.$dismiss("cancel")},e.download=function(){f("download")},e.print=function(){f("print")}}]),app.dashboardWidgets.controller("nxtDeviceListCtrl",["$scope","$rootScope","$filter","gettextCatalog","nxtInfiniteScrollSvc","$controller","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","CONSTANT","$injector","NXT_EQUIPMENT_DEVICES_WIDGET",function(e,t,n,i,a,o,r,s,l,d,c){"use strict";o("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:d}),e.widgetConfig=c;var u=[{id:"device-name-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Device"),visible:!0,sort:"focal_device",code:"description",order:0},{id:"device-date-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Date Implanted"),visible:!0,code:"date",sort:"date",width:e.isExpandedTable?"11":"22",minWidth:"110",order:1},{id:"device-location-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Body Location"),visible:!0,code:"location",width:e.isExpandedTable?"12":"22.5",order:2},{id:"device-provider-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Provider"),visible:e.isExpandedTable,code:"provider",sort:"organization",width:"12",order:3},{id:"device-manufacturer-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Manufacturer"),visible:e.isExpandedTable,code:"manufacturer",width:"12",order:4},{id:"device-model-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Model/Serial/Lot"),visible:e.isExpandedTable,code:"model",width:"12",order:4},{id:"device-expiration-date-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Expiration Date"),visible:e.isExpandedTable,code:"expiration-date",width:e.isExpandedTable?"11":"22",minWidth:"110",order:5},{id:"device-source-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source"),code:"source",visible:!0,width:e.isExpandedTable?"12":"22.5",order:e.isExpandedTable?6:3},{id:"device-source-origin-th"+e.code+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source Document"),code:"source-origin",visible:e.isExpandedTable,width:e.isExpandedTable?"12":"22.5",order:e.isExpandedTable?7:4}];e.headers=_.sortBy(_.filter(e.setColumns(u),function(e){return e.visible}),"order");var p={},g={};if(p.nxtProcedureSvc={methodName:"searchWithTotalRows"},e.infiniteScroll=a.create({services:p,limit:e.isExpandedTable?l.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:l.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),e.currentAppContextChecked||(e.filter={},e.sort={field:"focal_device",direction:"-"}),e.setFilters(),e.filterDates={startFrom:null,startTo:null},e.availableFilter&&_.find(e.availableFilter,function(e){return"date-implanted"===e.Code}))var f=e.$on("start"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.startFrom=null,e.filterDates.startTo=null,e.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.startTo=n.interval.endDate),e.filterDates.startIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),e.filter=_.extend(e.filter,{start:{from:e.filterDates.startFrom,to:e.filterDates.startTo,isAllInterval:e.filterDates.startIsAllInterval}}),t.stopPropagation()});e.$watchCollection("[mrnIds, filterDates.startFrom, filterDates.startTo]",function(){!e.filterDates.startTo&&f||(e.updateWidgetContext(),e.reloadTableData())}),e.reloadTableData=function(t,n){if(n||(e.devices=null,e.hasMoreData=!1),e.patientContext&&e.mrnIds){if(e.waitingPatientDashboardCalls&&(delete e.waitingPatientDashboardCalls,s.PatientData[e.key]&&s.PatientData[e.key][e.code])){var i=angular.copy(s.PatientData[e.key][e.code].entries);return e.setDisplayOriginAndSource(i),e.devices=i,e.infiniteScroll.setDataFromControl([s.PatientData[e.key][e.code]]),e.hasMoreData=!e.infiniteScroll.disabled,void e.setNoSearchResultsFound(g.nxtProcedureSvc,e.devices.length)}e.loading=!0,g.nxtProcedureSvc=_.extend({mrnIds:e.mrnIds,sort:"="+e.sort.direction+e.sort.field,withNoSessionReset:t},r.getDeviceParams(e.filter)),e.infiniteScroll.isBusy(!n,g)?e.infiniteScroll.disabled&&!e.infiniteScroll.busy&&(e.loading=!1):e.infiniteScroll.nextPage(!n).then(function(t){t||(t=[]),e.setDisplayOriginAndSource(t),e.devices=n?e.devices.concat(t):t,e.hasMoreData=!e.infiniteScroll.disabled,e.setNoSearchResultsFound(g.nxtProcedureSvc,e.devices.length),e.loading=!1},function(){e.loading=!1})}};var h=!1;e.viewDevice=function(t){e.isViewDetailsAvailable()&&(h||(h=!0,t.getTextDevice(e.mrnIds).then(function(n){h=!1,e.view(n,i.getString("View Device"),t.externalSources)},function(){h=!1})))},e.$on("$destroy",function(){f&&f()})}]),app.dashboardWidgets.directive("droppable",[function(){"use strict";return{link:function(e,t,n){function i(e){return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.dataTransfer||(e.dataTransfer=e.originalEvent.dataTransfer),e.dataTransfer.dropEffect="move",!1}function a(t){t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.dataTransfer||(t.dataTransfer=t.originalEvent.dataTransfer);var i=t.dataTransfer.getData("Text");i=angular.fromJson(i);var a=n.drop;e.$apply(function(){e[a](angular.fromJson(i.item),t.currentTarget.id)})}t.bind("dragover",i),t.bind("drop",a),e.$on("$destroy",function(){t.unbind("dragover",i),t.unbind("drop",a)})}}}]),app.dashboardWidgets.directive("draggable",["$document",function(e){"use strict";return{link:function(t,n,i){n.attr("draggable",!0);var a="",o="";i.$observe("dragdata",function(e){a=e}),i.$observe("dragimage",function(e){o=e}),n.bind("dragstart",function(n){var r=angular.toJson({html:n.currentTarget.innerHTML,item:a,width:n.currentTarget.clientWidth}
8);n.dataTransfer||(n.dataTransfer=n.originalEvent.dataTransfer),n.dataTransfer.setData("Text",r),"undefined"!==i.dragimage&&n.dataTransfer.setDragImage(e[0].getElementById(o),0,0);var s=i.drag;angular.isDefined(s)&&t.$apply(function(){t[s](r)})}),t.$on("$destroy",function(){n.unbind("dragstart")})}}}]),app.dashboardWidgets.factory("nxtDocumentFormatterSvc",["$rootScope","NXT_API_ENDPOINTS","$http","$q","nxtBinarySvc","nxtUtilsSvc","$uibModal","nxtDocumentSvc","NXT_DOCUMENTS_WIDGET","nxtEHxSvc","$window","$document","$timeout",function(e,t,n,i,a,o,r,s,l,d,c,u,p){"use strict";var g={getPreview:function(e){if(!e||!e.content){var t=i.defer();return t.reject(),t.promise}return x(e)}},f="{{0}}<hr/>",h='<div accordion close-others="0">{{0}}</div>',m='<div accordion-group is-open="1"><span accordion-heading>{{0}}<span class="expander"></span></span>',v="{{0}}</div>",S="<br/><p><b>This file does not have an associated viewer. Please download the file and use an appropiate external viewer.</b></p>",C="<br/><p><b>This file does not have an associated viewer. Please use an appropiate external viewer.</b></p>",y='<div class="alert alert-danger alert-danger-instructions-documents"><br/><p><b>Invalid CCD.</b></p></div>',b=["application/pdf","text/plain","text/html","text/xml","application/xml","application/hl7-v3+xml","text/rtf","application/rtf"];function x(e,a){var o;if(!e.content)return(o=i.defer()).reject(),o.promise;if(e.content.reference){o=i.defer();var r=e.title;if(!r&&a){var s=w(e.content.reference,a);s&&s.title&&(r=s.title)}var l=m.replace("{{0}}",r);return function(e,a){var o,r=i.defer();if(!e)return r.reject(),r.promise;if(a){var s=w(e,a);if(s&&s.content)return r.resolve(s.content),r.promise}o=/^(https?:)?\/\//i.test(e)?e:t.FhirURL+e;return n.get(o).then(function(e){r.resolve(e.data)},function(e){r.reject(e)}),r.promise}(e.content.reference,a).then(function(e){"Composition"===e.resourceType?T(e,a).then(function(e){e=v.replace("{{0}}",e),o.resolve(l+e)}):function(e){var t=i.defer();if(!e||!e.resourceType)return t.reject(),t.promise;var n=e.text&&e.text.div?e.text.div:"";return t.resolve(n),t.promise}(e).then(function(e){e=v.replace("{{0}}",e),o.resolve(l+e)})},function(t){var n='<span class="text-danger">'+(t.status||t.statusText?[t.status||"",t.statusText||""].join(" "):t)+" "+e.content.reference+" "+(e.content.reference.display||" ")+"</span>";n=v.replace("{{0}}",n),o.resolve(l+n)}),o.promise}if("Bundle"===e.content.resourceType)return x(e.content.entry.filter(function(e){return"Composition"===e.content.resourceType})[0],e.content);if("Composition"===e.content.resourceType)return o=i.defer(),a?T(e.content,a).then(function(e){o.resolve(e)}):(a=null,T(e.content,a).then(function(e){o.resolve(e)})),o.promise;if("DocumentReference"===e.content.resourceType){o=i.defer();var d=e.content.mimeType||"";return g.getDocumentPreviewHtml(d,e.content.location,e.content.data,e.content.eHxDetails,e.content.isEHxContext).then(function(e){o.resolve(e)},function(e){o.reject(e)}),o.promise}return(o=i.defer()).reject("unknown resourceType "+e.content.resourceType),o.promise}g.getDocumentPreviewHtml=function(e,t,r,s,l){var g=i.defer(),f=l;if(0===e.indexOf("image")||b.indexOf(e)>=0){var h;if(t&&!r)if(l)h=d.getBinary({participant:s.participant,repositoryUniqueId:s.repositoryUniqueId,homeCommunityId:s.homeCommunityId,id:t},e);else{var m={responseType:"arraybuffer"},v=null;"application/hl7-v3+xml"===e||"text/rtf"===e||"application/rtf"===e?(v="text/html",m.headers={Accept:v}):"text/plain"===e?m.headers={Accept:"text/plain"}:"application/pdf"===e&&(m.headers={Accept:"application/pdf"}),h=a.get(t,m)}i.resolve(h).then(function(i){var a=i&&i.data?i.data:r,s=i&&i.type?i.type:e;if(a){var l,d,h;try{c.atob(a),l=a.replace(/\s/g,"")}catch(e){if(l=o.base64FromArrayBuffer(a),s.indexOf("application/pdf")>-1){var m=o.b64toBlob(l,s);d=URL.createObjectURL(m),h='<iframe type="{{1}}" src="{{0}}#toolbar=0&navpanes=0" width="100%" height="100%" class="viewer" scrolling="auto"></iframe>'.replace("{{0}}",d).replace(/\{\{1\}\}/g,v||(i&&i.type?i.type:s))}}if(-1===s.indexOf("application/pdf")){var b=0===s.indexOf("image")?'<img longdesc="Content of the selected file." alt="Content of the selected file." aria-label="Content of the selected file." class="viewer" src="data:{{1}};base64,{{0}}" role="presentation" />':'<iframe type="{{1}}" src="data:{{1}};base64,{{0}}#toolbar=0&navpanes=0" width="100%" height="100%" class="viewer" scrolling="auto"></iframe>';h=b.replace("{{0}}",l).replace(/\{\{1\}\}/g,v||(i&&i.type?i.type:s))}(s.indexOf("text/plain")>-1||s.indexOf("text/html")>-1||s.indexOf("application/hl7-v3+xml")>-1)&&(h=decodeURIComponent(escape(c.atob(l))),s.indexOf("text/plain")>-1&&(h='<div class="font-family-monospace" style="white-space:pre-wrap;">'+h.replace(/\n/g,"<br />")+"</div>")),["application/hl7-v3+xml","text/xml","application/xml"].indexOf(s)>=0&&(f||r&&!t)?n.get("files/CDA.xsl").then(function(e){if(function(){var e=!1;if(D)e=!0;else if(!_.isNil(c.XMLHttpRequest)&&!_.isNil(c.XSLTProcessor)){var t=new XSLTProcessor;e=!angular.isFunction(t.transformDocument)||!_.isNil(c.XMLSerializer)}return e}()){h=decodeURIComponent(escape(c.atob(l)));var t,n=new DOMParser,i=new XSLTProcessor,a=!1,o=n.parseFromString(h,"text/xml"),r=n.parseFromString(e.data,"text/xml");if(/^\s*</.test(h)&&(angular.element(o.documentElement).text().indexOf("XML Parsing Error")>-1&&(a=!0),angular.element(o.documentElement).text().indexOf("This page contains the following errors:")>-1&&(a=!0)),a)g.resolve(y);else if(D)p(function(){try{var e=new ActiveXObject("Msxml2.DOMDocument.3.0");e.async=!1,e.loadXML(o);var t=new ActiveXObject("Msxml2.DOMDocument.3.0");t.async=!1,t.loadXML(r),g.resolve(e.transformNode(t))}catch(e){g.resolve(y)}},50);else try{angular.isFunction(i.transformDocument)?(t=u[0].implementation.createDocument("","",null),i.transformDocument(o,r,t,null)):(i.importStylesheet(r),t=i.transformToDocument(o)),t&&t.body?g.resolve((new XMLSerializer).serializeToString(t)):g.resolve(y)}catch(e){g.resolve(y)}}else g.resolve('<div class="alert alert-danger alert-danger-instructions-documents"><br/><p><b>This browser does not support XSLT in javascript, so we cannot continue, sorry.</b></p></div>')}):g.resolve(h)}else g.resolve(t?S:C)},function(e){g.reject(e)})}else g.resolve(t?S:C);return g.promise};var D="ActiveXObject"in c;function T(e,t){var n=i.defer();if(!e||!e.resourceType)return n.reject(),n.promise;var a="";if(e.text&&e.text.div&&(a+=f.replace("{{0}}",e.text.div)),"Composition"===e.resourceType&&e.section&&e.section.length){var o=e.section.map(function(e){return x(e,t)});i.all(o).then(function(e){a+=h.replace("{{0}}",e.join("\r\n")),n.resolve(a)})}else n.resolve(a);return n.promise}function w(e,n){var i=n.entry.filter(function(n){return n.id===e||n.id===t.FhirURL+e||t.FhirURL+n.id===e});return i.length?i[0]:null}return g.viewFile=function(t){if(t.isWorkspaceDocument)!function(e){s.getDocumentBundle(e.file.location).then(function(t){e.file.bundle=t,r.open({templateUrl:"modules/dashboardWidgets/documentViewer/wor
8kspaceDocumentViewer.html",scope:e,controller:["$scope","$uibModalInstance",function(e,t){e.close=function(){t.dismiss("cancel")}}],backdrop:"static",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(e){},function(e){})})}(t);else{t.ccdaMimeType="application/hl7-v3+xml";var n=t.dialogClass||"nxt-large-popup nxt-full-height-popup";t.keepDialogClass||(t.file&&t.file.content&&t.file.content[0]&&t.file.content[0].url&&t.file.content[0].contentType===t.ccdaMimeType&&(n=e.showVerbiage?"nxt-full-popup-with-verbiage":"nxt-full-popup"),l.DisplayCustomCDAViewer||(n="nxt-large-popup nxt-full-height-popup")),r.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:t,controller:"nxtDocumentViewCtrl",backdrop:"static",windowClass:n,windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(e){},function(e){})}},g}]),app.dashboardWidgets.controller("nxtDocumentViewCtrl",["$scope","nxtDocumentFormatterSvc","$q","nxtTextSvc","$sce","nxtBinarySvc","nxtUtilsSvc","nxtDocumentReferenceSvc","nxtUserContextSvc","nxtMessageHeaderSvc","NXT_DOCUMENTS_WIDGET","$http","$timeout","gettextCatalog","$rootScope","$uibModal","nxtEHxSvc","NXT_SHOW_EXPAND_DOCUMENT_LINK","$window",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m,v,S){"use strict";if(e.ccdaMimeType||(e.ccdaMimeType="application/hl7-v3+xml"),e.showExpandDocumentConfig=v,e.showVerbiage=f.showVerbiage||!1,e.isEnabledUploadFunctionality=c.Upload&&c.Upload.Enabled,e.file&&"current"!==e.file.status&&(e.suppressedDocument=!0,e.htmlList=['<div class="alert alert-danger alert-danger-instructions-documents">'+e.file.description+" was suppressed and is no longer viewable</div>"]),C(!0),e.file&&e.file.externalSources&&e.file.externalSources.length&&_.find(e.file.externalSources,function(e){return e&&e.sourceAuthor})&&(e.file.hasSourceAuthor=!0),e.isEnabledUploadFunctionality&&e.file&&e.file.portalSources&&(e.suppressPermission="",e.file.portalSources.sourcePortalAuthor.id===l.loggedUser.id&&(e.suppressPermission="UploadDocument.access"),e.suppressPermission&&(e.suppressPermission+=";"),e.suppressPermission+="SuppressAnyDocuments.access"),e.isXmlViewer=!1,e.suppressedDocument)C(!1);else if(e.isHL7Message)d.get(e.documentReferenceId).then(function(n){e.message=n,e.message&&e.message.focus&&(e.docLoading=!0,t.getDocumentPreviewHtml("text/plain",_.last(e.message.focus.split("Binary/"))).then(function(t){e.htmlList=[t],C(!1)},function(){C(!1)}))});else if(e.isEHxContext)D();else if(e.documentReferenceId&&!e.file){let t=l.PatientId;l.Patient&&l.Patient.attesting&&l.Patient.attesting.mrnList&&(t=r.getMrnIds(l.Patient.attesting.mrnList)),s.getDocumentReference(e.documentReferenceId,t).then(function(t){e.file=t,D()})}else D();function C(t){e.docLoading=t,e.xmlLoading=t}function y(t,n,i,a){e.isEHxContext?(e.docLoading=!0,m.getBinary(i,n).then(function(n){var i=new Uint8Array(n.data),a=new Blob([i],{type:n.type});S.navigator&&S.navigator.msSaveOrOpenBlob?S.navigator.msSaveOrOpenBlob(a):saveAs(a,t),e.docLoading=!1},function(){e.docLoading=!1})):o.downloadFile(t,n,i,a)}function b(t,n){var i=e.$new(!0);i.title=e.title,i.hList=_.map(t,function(t){return{html:t,description:e.title,isHL7Message:n,binary:t.binary,mimeType:t.mimeType}}),i.showButtonPrint=!1,i.showButtonDownload=!1,i.isHL7Message=n,h.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:i,controller:["$scope","$uibModalInstance","nxtPrintUtilsSvc","gettextCatalog",function(e,t,n,i){e.docLoading=!0,n.generateDocumentsPdf(e.hList).then(function(t){var n;if(S.navigator&&S.navigator.msSaveOrOpenBlob){for(var i=atob(t),a=new Array(i.length),o=0;o<i.length;o++)a[o]=i.charCodeAt(o);var s=new Uint8Array(a);n=new Blob([s],{type:"application/pdf"}),S.navigator.msSaveOrOpenBlob(n)}else{n=r.b64toBlob(t,"application/pdf");var l=URL.createObjectURL(n);e.htmlList=['<iframe type="application/pdf" src="{{0}}#navpanes=0" width="100%" height="100%" class="viewer" scrolling="auto"></iframe>'.replace("{{0}}",l)]}e.docLoading=!1},function(){e.docLoading=!1,e.documentNotFound=!0,e.htmlList=['<div class="alert alert-danger alert-danger-instructions-documents">'+i.getString("Document could not be loaded")+"!</div>"]}),e.close=function(){t.dismiss("cancel")};var a=e.$on("onLoaded",function(t){e.docLoading=!1});e.$on("$destroy",function(){a&&a()})}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})}e.close=function(){e.$dismiss("cancel")},e.expandDocument=function(){var n=e.$new(!0);n.showButtonPrint=!e.withoutPrint,n.showButtonDownload=!0,n.showExpandDocument=!1,n.isExpanded=!0,n.documentReferenceId=e.documentReferenceId,n.isHL7Message=e.isHL7Message,n.isEHxContext=e.isEHxContext,n.file=e.file,n.dialogClass=f.showVerbiage?"nxt-full-popup-with-verbiage":"nxt-full-popup",n.keepDialogClass=!0,n.showSources=!e.isXmlViewer&&!e.isCDAFile&&!e.isEHxContext,t.viewFile(n)},e.download=function(){if(e.isHL7Message)y("HL7V2 message","text/plain",e.message.focus,"text/plain");else if(angular.isDefined(e.downloadFile))e.downloadFile(e.file);else{var t=[];e.file.content&&e.file.content.length>0?_.each(e.file.content,function(n){if(e.isEHxContext){var i=n.contentType;_.isEmpty(i)&&n.format&&n.format.code&&(i=n.format.code);var a=n.title||e.file.description||"eHxFile";i&&n.size>0&&t.push({title:a,url:{participant:e.file.origin,repositoryUniqueId:e.file.repositoryUniqueId,homeCommunityId:e.file.homeCommunityId,id:e.file.eHxId},mimeType:i})}else n&&n.url&&t.push({title:n.title||e.file.description,url:n.url,mimeType:n.contentType})}):e.file.location&&t.push({title:e.file.description,url:e.file.location,mimeType:e.file.mimeType}),_.each(t,function(t){t&&t.url&&(t.mimeType===e.ccdaMimeType?function(e,t,n){var i=e;i.indexOf(".xml")<0&&(i+=".xml");y(i,t,n,t?t+",*/*":null),y(i+".html","text/html",n,"text/html,*/*")}(t.title,t.mimeType,t.url):y(t.title,t.mimeType,t.url,e.acceptHeader))})}},e.supress=function(){var t=e.$new();t.docId=angular.copy(e.file.id),h.open({templateUrl:"modules/dashboardWidgets/clinicalNotes/suppression.html",scope:t,controller:"nxtSuppressionFileCtrl",backdrop:"static",windowClass:"nxt-light-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(e){f.$emit("onSupressFileCompleted",e)},function(){})},e.hasHeightFull=function(){return e.isExpanded||!e.isExpanded&&e.isEHxContext&&e.isInlineDisplay},e.openViewDocumentPopup=function(n,i){var a=e.$new(!0);a.showButtonPrint=!0,a.showButtonDownload=!0,a.documentReferenceId=n,a.isHL7Message=i,a.dialogClass=i?null:f.showVerbiage?"nxt-full-popup-with-verbiage":"nxt-full-popup",t.viewFile(a)},e.print=function(){if(e.data||(e.data={userDisplay:l.loggedUser.toFhirReference().display},l.Patient&&(e.data.patient={name:l.Patient.DisplayName,dob:i.formatDate(l.Patient.birthDate)})),e.data.showVerbiage=e.showVerbiage,e.data.print=i.formatDateTime(new Date),e.isXmlViewer){if(e.xmlHtml)r.printContent(e.xmlHtml,e.data);else if(e.file&&e.file.content&&e.file.content[0]&&(e.file.content[0].url||e.file.content[0].data)){e.docLoading=!0;var n={content:{resourceType:"DocumentReference",location:e.file.content[0].url,data:e.file.content[0].data,mimeType:e.file.content[0].contentType}};t.getPreview(n).then(function(t){e.docLoading=!1,e.xmlHtml=t,r.printContent(t,e.data)},function(){e.docLoading=!1})}}else if(e.isHL7Message)r.printContent(e.htmlList,e.data);else if(e.file&&e.file.portalSources&&e.file.content&&e.file.content[0]&&"application/pdf"===e.file.content[0].contentType&&e.file.content[0].url)C(!0),o.get(e.file.content[0].url,{responseType:"arraybuffer",headers:{Accept:"application/pdf"}}).then(function(t){C(!1),b([{binary:t&&t.data,description:e.file.description}])});else if(e.printHtmlList&&e.printHtmlList.length>0)b(e.printHtmlList);else{angular.element("#tempContent").remove();var a=angular.element("#print")&&angular.element("#print")[0]&&angular.element("#print")[0].scrollHeight?angular.element("#print")[0].scrollHeight+"px":"100%",s=angular.element("<iframe></iframe>");s.attr("id","tempContent").attr("name","tempContent").css("width","100%").css("height",a).css("position","absolute").css("left","-9999px").appendTo(angular.element("body:first")),_.isNil(s)||(s.attr("src",e.htmlUrl),s.on("load",function(){var t=angular.element("#tempContent")[0],n=t.contentWindow?t.contentWindow:t.contentDocument.defaultView;r.printContent([n.document.body.innerHTML],e.data)}))}},e.html='<div class="loader centered active"><i class="fa fa-spinner fa-pulse"></i></div>';var x=[];function D(){if(x=[],e.file&&(e.title=e.file.description||e.file.display),e.isCDAFile=!e.isEHxContext&&(e.file&&e.file.externalSources&&!e.file.externalSources[0].sourceOrigin&&!e.file.portalSources),C(!0),e.isEHxContext){if(e.file.content&&e.file.content.length>0)for(let t=0;t<e.file.content.length;t++)if(e.file.content[t].size>0&&e.file.content[t].hash){var i=e.file.content[t].contentType;_.isEmpty(i)&&e.file.content[t].format&&e.file.content[t].format.code&&(i=e.file.content[t].format.code),x.push({content:{resourceType:"DocumentReference",location:e.file.eHxId,mimeType:i,data:e.file.content[t].data,eHxDetails:{participant:e.file.origin,repositoryUniqueId:e.file.repositoryUniqueId,homeCommunityId:e.file.homeCommunityId},isEHxContext:!0}})}}else if(e.file.content&&e.file.content.length>0)for(let t=0;t<e.file.content.length;t++)(e.file.content[t].url||e.file.content[t].data)&&x.push({content:{resourceType:"DocumentReference",location:e.file.content[t].url,data:e.file.content[t].data,mimeType:e.file.content[t].contentType}});else x.push({content:{resourceType:"DocumentReference",location:e.file.location,mimeType:e.file.mimeType}});var r,s=[],l=[];
8if(x.length>0)for(let n=0;n<x.length;n++)r=x[n],c.DisplayCustomCDAViewer&&r.content.mimeType===e.ccdaMimeType&&r.content.location?(l.push(o.get(r.content.location,{headers:{Accept:r.content.mimeType}})),e.isXmlViewer=!0):s.push(t.getPreview(r));e.documentNotFound=!0,n.all(s).then(function(t){if(e.htmlList=[],e.printHtmlList=[],e.documentNotFound=!1,t&&t.length){for(let a=0;a<t.length;a++){t[a]=t[a].replace(/•/g,"&#8226;").replace(/·/g,"&#8208;"),t[a]=t[a].replace(/<caption>/g,'<div class="caption">').replace(/<\/caption>/g,"</div>"),e.printHtmlList.push(angular.copy(t[a])),t[a]=t[a].replace(/href=\"\#/g,'scroll-to="');var n,i=angular.copy(t[a]);if(!c.DisplayCustomCDAViewer)if((i=i.replace(/\<table id\=\"page-report\"\>([\s\S]*?)\<div class=\"xslt-generated-document\"\>/g,'<div class="xslt-generated-document">')).match(new RegExp('<div class="page-footer-space">')))i=i.replace(/\<div class\=\"page-footer-space\"\>([\s\S]*?)\<\/body\>/g,"</body>"),["</td>","</tr>","</tbody>","<tfoot>","<tr>","<td>"].forEach(function(e){var t=i.toLowerCase().lastIndexOf(e.toLowerCase());n=new RegExp(e,"i"),i=i.slice(0,t)+i.slice(t).replace(n,"")});e.htmlList.push(i)}e.htmlUrl=a.trustAsResourceUrl(URL.createObjectURL(new Blob(t,{type:"text/html"})))}C(!1)},function(t){e.documentNotFound=!0,e.htmlList=['<div class="alert alert-danger alert-danger-instructions-documents">'+g.getString("Document could not be loaded")+"!</div>"],C(!1)}),!0===e.isXmlViewer&&(l.push(u.get("components/C-CDA_Viewer/cda.xsl")),n.all(l).then(function(t){try{var n,i="";if(_.each(t,function(t){t&&t.data&&(t.type===e.ccdaMimeType?i+=t.data:n=t.data)}),i){var a=new Transformation;a.setXml(i).setXslt(n).transform("viewcda");var o=p(function(){onXmlLoaded(a),C(!1),p.cancel(o)},200)}else C(!1)}catch(e){C(!1)}},function(e){C(!1)}))}}]),app.dashboardWidgets.directive("nxtDocumentViewer",["$compile","$timeout","$document",function(e,t,n){"use strict";return{restrict:"A",replace:!0,link:function(i,a,o){Object.prototype.hasOwnProperty.call(o,"isExpanded")&&Boolean.valueOf(o.isExpanded)&&(i.isExpanded=!0),i.withoutReloadDataOnResize=!!Object.prototype.hasOwnProperty.call(o,"withoutReloadDataOnResize");var r="";i.$watch(o.nxtDocumentViewer,function(o){if(o){i.openState=[];for(var s=0;o.indexOf("is-open='1'")>=0;){i.openState[s]=1,o=o.replace("is-open='1'","is-open='openState["+s+"]'");var l="<i class=\"pull-right fa\" ng-class=\"{'fa-caret-down': status.open, 'fa-caret-right': !status.open}\"></i>".replace(/status.open/g,"openState["+s+"]");o=o.replace("<span class='expander'></span>",l),s++}if(s){o='<div class="actions">
8<button type="button" class="btn btn-xs" ng-click="expandAll()">Expand all</button><button type="button" class="btn btn-xs" ng-click="collapseAll()">Collapse all</button></div>'+o}o=(o=o.replace(/•/g,"&#8226;").replace(/·/g,"&#8208;")).replace(/<caption>/g,'<div class="caption">').replace(/<\/caption>/g,"</div>")}var d="";o&&o.indexOf("<object")<0&&o.indexOf("Please download the file")>0&&(d=' style="min-height:100px;"'),i.isExpanded&&(d=' style="height: 100% !important; min-height: initial; max-height: initial; padding: 0px 10px 10px 20px;"'),i.file&&i.file.mimeType&&"application/pdf"===i.file.mimeType&&(i.showButtonDownload=i.showButtonPrint=!1),r='<div id="print" class="document-viewer expand_collapse"'+d+">"+o+"</div>",a.html(r);var c=e(a.contents())(i);angular.element(c.find("iframe").on("load",function(){var e=t(function(){if(n[0].getElementById("templateViewBody")){var a=n[0].getElementById("templateViewBody").clientHeight-n[0].querySelector("iframe").clientHeight-n[0].querySelector("iframe").offsetTop;n[0].querySelector("iframe").style.height=n[0].querySelector("iframe").clientHeight+a+"px"}t.cancel(e),i.$emit("onLoaded")})})),angular.element(c.find("object").on("load",function(){var e=t(function(){t.cancel(e),i.$emit("onLoaded")})}))}),i.expandAll=function(){i.openState=i.openState.map(function(){return 1})},i.collapseAll=function(){i.openState=i.openState.map(function(){return 0})},angular.element(window).on("resize",function(){i.withoutReloadDataOnResize||(a.html(r),e(a.contents())(i))}),i.$on("$destroy",function(e){angular.element(window).off("resize")})}}}]),app.dashboardWidgets.controller("nxtEncounterListCtrl",["gettextCatalog","$scope","$rootScope","nxtInfiniteScrollSvc","$controller","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","CONSTANT","NXT_ENCOUNTERS_WIDGET","$injector",function(e,t,n,i,a,o,r,s,l,d){"use strict";a("nxtDashboardWidgetsCtrl",{scope:t,rootScope:n,$injector:d});var c=[{id:"enc-type-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Encounter Type"),visible:!0,sort:"class",code:"type",order:0},{id:"enc-service-provider-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Facility Source"),visible:t.isExpandedTable,sort:"service-provider",code:"service-provider",width:"12",order:1},{id:"enc-admit-date-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Admit Date"),visible:t.isExpandedTable,sort:"start_date",code:"admit-date",width:"11",minWidth:"110",order:2},{id:"enc-discharge-date-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Discharge Date"),visible:t.isExpandedTable,sort:"end_date",code:"discharge-date",width:"11",minWidth:"110",order:3},{id:"enc-participant-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Provider"),visible:t.isExpandedTable,sort:"participant",code:"participant",width:"12",order:4},{id:"enc-location-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Location"),visible:t.isExpandedTable,code:"location",width:"12",order:5},{id:"enc-admit-reason-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Admit Reason"),visible:t.isExpandedTable,code:"admit-reason",width:"12",order:6},{id:"enc-source-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Source"),code:"source",visible:!0,width:t.isExpandedTable?"12":"25",order:t.isExpandedTable?7:2},{id:"enc-source-origin-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Source Document"),code:"source-origin",visible:t.isExpandedTable,width:"12",order:8},{id:"enc-hopitalization-period-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Admit - Discharge Dates"),visible:!t.isExpandedTable,sort:"start_date",code:"hopitalization-period",width:"36",minWidth:"195",order:1},{id:"enc-service-type-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Hospital Service"),visible:!1,sort:"service_type",code:"service-type",width:"10"},{id:"enc-enc-no-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Encounter Number"),visible:!1,code:"encounter-no",width:"10"}];t.widgetConfig=l,t.setFilters(),t.headers=_.sortBy(_.filter(t.setColumns(c),function(e){return e.visible}),"order");var u={},p={nxtEncounterSvc:{methodName:"searchWithTotalRows"}};if(t.infiniteScroll=i.create({services:p,limit:t.isExpandedTable?s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),t.patientClassList=[{code:"",display:"All encounter types"},{code:"ambulatory",display:"Ambulatory"},{code:"emergency",display:"Emergency"},{code:"inpatient",display:"Inpatient "}],t.currentAppContextChecked||(t.filter={reason:null,class:t.patientClassList[0],provider:null,organization:null,location:null},t.sort={field:"start_date",direction:"-"}),t.filterDates={startFrom:null,startTo:null,endFrom:null,endTo:null},t.availableFilter&&_.find(t.availableFilter,function(e){return"end-date"===e.Code}))var g=t.$on("end"+t.prefixId+"DateFilterChangedEvent",function(e,n){t.filterDates.endFrom=null,t.filterDates.endTo=null,t.filterDates.endIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(t.filterDates.endFrom=n.interval.startDate),n.interval.endDate&&(t.filterDates.endTo=n.interval.endDate),t.filterDates.endIsAllInterval=n.interval.isAllFilter),t.addFilterDateKeys(n.contextKeyName),t.filter=_.extend(t.filter,{end:{from:t.filterDates.endFrom,to:t.filterDates.endTo,isAllInterval:t.filterDates.endIsAllInterval}}),e.stopPropagation()});if(t.availableFilter&&_.find(t.availableFilter,function(e){return"start-date"===e.Code}))var f=t.$on("start"+t.prefixId+"DateFilterChangedEvent",function(e,n){t.filterDates.startFrom=null,t.filterDates.startTo=null,t.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(t.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(t.filterDates.startTo=n.interval.endDate),t.filterDates.startIsAllInterval=n.interval.isAllFilter),t.addFilterDateKeys(n.contextKeyName),t.filter=_.extend(t.filter,{start:{from:t.filterDates.startFrom,to:t.filterDates.startTo,isAllInterval:t.filterDates.startIsAllInterval}}),e.stopPropagation()});function h(e){if(e&&e.length>0){t.setDisplayOriginAndSource(e);for(var n=0;n<e.length;n++)m(e[n])}}function m(e){e&&(e.classDisplay="",e.encClass&&e.encClass.display&&(e.classDisplay=e.encClass.display.charAt(0).toUpperCase()+e.encClass.display.substr(1).toLowerCase()))}t.$watchCollection("[mrnIds, filterDates.startFrom, filterDates.startTo, filterDates.endTo, filterDates.endFrom, filter.reason, filter.class.code, filter.provider,f
8ilter.organization, filter.location, filter.multipleFields]",function(){!t.filterDates.startTo&&f||!t.filterDates.endTo&&g||(t.updateWidgetContext(),t.reloadTableData())}),t.reloadTableData=function(e,n){if(n||(t.encounters=null,t.hasMoreData=!1),t.patientContext&&t.mrnIds){if(t.waitingPatientDashboardCalls&&(delete t.waitingPatientDashboardCalls,r.PatientData[t.key]&&r.PatientData[t.key][t.code])){var i=angular.copy(r.PatientData[t.key][t.code].entries);return h(i),t.encounters=i,t.infiniteScroll.setDataFromControl([r.PatientData[t.key][t.code]]),t.hasMoreData=!t.infiniteScroll.disabled,void t.setNoSearchResultsFound(u.nxtEncounterSvc,t.encounters.length)}t.loading=!0,u.nxtEncounterSvc=_.extend({mrnIds:t.mrnIds,sort:"="+t.sort.direction+t.sort.field,withNoSessionReset:e},o.getEncounterParams(t.filter)),t.infiniteScroll.isBusy(!n,u)?t.infiniteScroll.disabled&&!t.infiniteScroll.busy&&(t.loading=!1):t.infiniteScroll.nextPage(!n).then(function(e){t.encounters||(t.encounters=[]),e||(e=[]),h(e),t.encounters=n?t.encounters.concat(e):e,t.hasMoreData=!t.infiniteScroll.disabled,t.setNoSearchResultsFound(u.nxtEncounterSvc,t.encounters.length),t.loading=!1},function(){t.loading=!1})}},t.viewEncounter=function(n){n&&t.isViewDetailsAvailable()&&t.view(n.getText(),e.getString("View Encounter"),n.externalSources)},t.$on("$destroy",function(){f&&f(),g&&g()})}]),app.dashboardWidgets.controller("nxtGraphsListCtrl",["$scope","nxtUserContextSvc","nxtUtilsSvc",function(e,t,n){"use strict";e.isExpandedTable=!(!e.subtab||e.subtab.code!==e.subtab.parentSubtab),e.isPatientDashboardContext=t.CurrentPageContext.patientDashboardContext;var i=e.$on("reloadPatientDataByMrnList",function(t,i,a){var o=n.getMrnIds(i);_.isEqual(e.patientContext.MrnIds,o)||(e.patientContext.MrnIds=o,a||e.$broadcast("refreshDataGraphView",e.patientContext.PatientId,e.subtab.code))});e.$on("$destroy",function(){i()})}]),app.dashboardWidgets.controller("nxtImmunizationListCtrl",["$rootScope","$scope","$q","gettextCatalog","$filter","nxtInfiniteScrollSvc","$locale","$controller","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","CONSTANT","NXT_IMMUNIZATION_WIDGET","$injector",function(e,t,n,i,a,o,r,s,l,d,c,u,p){"use strict";s("nxtDashboardWidgetsCtrl",{scope:t,rootScope:e,$injector:p}),t.widgetConfig=u;var g=[{id:"vaccine-code-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Immunization"),visible:!0,sort:"vaccine-code",code:"vaccine-code",order:0},{id:"imm-dose-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Dose"),visible:t.isExpandedTable,code:"dose",width:"5",order:1},{id:"imm-body-site-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Body Site"),visible:t.isExpandedTable,code:"body-site",width:"7",order:2},{id:"imm-route-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Route"),visible:t.isExpandedTable,code:"route",width:"7",order:3},{id:"imm-not-given-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Given"),visible:t.isExpandedTable,sort:"notGiven",code:"notGiven",width:"3",order:4},{id:"imm-refusal-reason-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Refusal Reason"),visible:t.isExpandedTable,sort:"reason-not-given",code:"refusal-reason",width:"12",order:5},{id:"imm-adm-date-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Administered Date"),visible:!0,sort:"date",code:"date",width:t.isExpandedTable?"11":"22",minWidth:"110",order:t.isExpandedTable?6:1},{id:"imm-lot-number-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Lot Number"),visible:t.isExpandedTable,sort:"lot-number",code:"lot-number",width:"7",order:7},{id:"imm-manufacturer-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Manufacturer"),visible:t.isExpandedTable,code:"manufacturer",width:"12",order:8},{id:"imm-source-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source"),code:"source",visible:!0,width:t.isExpandedTable?"12":"25",order:t.isExpandedTable?9:2},{id:"imm-source-origin-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source Document"),code:"source-origin",visible:t.isExpandedTable,width:"12",order:10},{id:"imm-refused-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Refused"),visible:!1,sort:"notGiven",code:"refused",width:"5"}];t.headers=_.sortBy(_.filter(t.setColumns(g),function(e){return e.visible}),"order"),t.setFilters();var f={},h={nxtImmunizationSvc:{methodName:"searchWithTotalRows"}};if(t.infiniteScroll=o.create({services:h,limit:t.isExpandedTable?c.GENER
8IC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:c.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),t.wasGivenList=[{code:"",display:"Given & Not given"},{code:"true",display:"Given"},{code:"false",display:"Not given"}],t.currentAppContextChecked||(t.filter={immunization:null,lotNumber:null,wasGiven:t.wasGivenList&&t.wasGivenList[0]},t.sort={field:"date",direction:"-"}),t.$watchCollection("[mrnIds, filter.immunization, filterDates.startFrom, filterDates.startTo, filter.lotNumber, filter.wasGiven, filter.multipleFields]",function(){!t.filterDates.startTo&&m||(t.updateWidgetContext(),t.reloadTableData())}),t.filterDates={startFrom:null,startTo:null},t.availableFilter&&_.find(t.availableFilter,function(e){return"administered-date"===e.Code}))var m=t.$on("start"+t.prefixId+"DateFilterChangedEvent",function(e,n){t.filterDates.startFrom=null,t.filterDates.startTo=null,t.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(t.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(t.filterDates.startTo=n.interval.endDate),t.filterDates.startIsAllInterval=n.interval.isAllFilter),t.addFilterDateKeys(n.contextKeyName),t.filter=_.extend(t.filter,{start:{from:t.filterDates.startFrom,to:t.filterDates.startTo,isAllInterval:t.filterDates.startIsAllInterval}}),e.stopPropagation()});function v(e){if(e&&e.length>0){t.setDisplayOriginAndSource(e);for(var n=0;n<e.length;n++)S(e[n])}}function S(e){e&&(e.dateDisplay=e.refusedIndicatorDisplay="",e.date&&(e.dateDisplay=_.isDate(e.date)?a("date")(e.date,r.DATETIME_FORMATS.nxtDateFormat):e.date),e.notGiven?e.refusedIndicatorDisplay="Not given":e.refusedIndicatorDisplay="")}t.reloadTableData=function(e,n){if(n||(t.immunizations=null,t.hasMoreData=!1),t.patientContext&&t.mrnIds){if(t.waitingPatientDashboardCalls&&(delete t.waitingPatientDashboardCalls,d.PatientData[t.key]&&d.PatientData[t.key][t.code])){var i=angular.copy(d.PatientData[t.key][t.code].entries);return v(i),t.immunizations=i,t.infiniteScroll.setDataFromControl([d.PatientData[t.key][t.code]]),t.hasMoreData=!t.infiniteScroll.disabled,void t.setNoSearchResultsFound(f.nxtImmunizationSvc,t.immunizations.length)}t.loading=!0,n||(t.immunizations=[]),f.nxtImmunizationSvc=_.extend({mrnIds:t.mrnIds,sort:"="+t.sort.direction+t.sort.field,withNoSessionReset:e},l.getImmunizationParams(t.filter)),t.infiniteScroll.isBusy(!n,f)?t.infiniteScroll.disabled&&!t.infiniteScroll.busy&&(t.loading=!1):t.infiniteScroll.nextPage(!n).then(function(e){t.immunizations||(t.immunizations=[]),e||(e=[]),v(e),t.immunizations=n?t.immunizations.concat(e):e,t.hasMoreData=!t.infiniteScroll.disabled,t.setNoSearchResultsFound(f.nxtImmunizationSvc,t.immunizations.length),t.loading=!1},function(){t.loading=!1})}},t.viewImmunization=function(e){t.isViewDetailsAvailable()&&t.view(e.getText(),i.getString("View Immunization"),e.externalSources)},t.$on("$destroy",function(){m&&m()})}]),app.dashboardWidgets.controller("nxtInsuranceListCtrl",["gettextCatalog","$scope","$rootScope","nxtInfiniteScrollSvc","$controller","nxtPatientDashboardSvc","CONSTANT","$injector","NXT_INSURANCE_WIDGET",function(e,t,n,i,a,o,r,s,l){"use strict";a("nxtDashboardWidgetsCtrl",{scope:t,rootScope:n,$injector:s}),t.widgetConfig=l;var d=[{id:"ins-description-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Insurance"),visible:!0,code:"insurance",order:0},{id:"ins-dates-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Effective Dates"),visible:!0,code:"dates",width:"22",minWidth:"110",order:1,sort:"period_start"},{id:"ins-source-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Source"),code:"source",visible:!0,width:"25",order:2},{id:"ins-source-origin-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Source Document"),code:"source-origin",visible:t.isExpandedTable,width:"25",order:3},{id:"ins-plan-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Plan"),code:"plan",visible:!1,width:"10",order:4},{id:"ins-type-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Insurance Type"),code:"type",visible:!1,width:"10",sort:"type",order:5},{id:"ins-policyNumber-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Policy Number"),code:"policyNumber",visible:!1,width:"10",order:6},{id:"ins-order-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Order"),code:"order",visible:!1,width:"10",order:7},{id:"ins-groupNumber-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Group Number"),code:"groupNumber",visible:!1,sort:"group",width:"10",order:8}];t.headers=_.sortBy(_.filter(t.setColumns(d),function(e){return e.visible}),"order"),t.setFilters();var c={},u={nxtCoverageSvc:{methodName:"searchWithTotalRows"}};t.infiniteScroll=i.create({services:u,limit:t.isExpandedTable?r.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:r.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),t.currentAppContextChecked||(t.sort={field:"period_start",direction:"-"}),t.$watch("mrnIds",function(){t.updateWidgetContext(),t.reloadTableData()}),t.reloadTableData=function(e,n){if(n||(t.insurances=null,t.hasMoreData=!1),t.patientContext&&t.mrnIds){if(t.waitingPatientDashboardCalls&&(delete t.waitingPatientDashboardCalls,o.PatientData[t.key]&&o.PatientData[t.key][t.code])){var i=angular.copy(o.PatientData[t.key][t.code].entries);return t.setDisplayOriginAndSource(i),t.insurances=i,t.infiniteScroll.
8setDataFromControl([o.PatientData[t.key][t.code]]),t.hasMoreData=!t.infiniteScroll.disabled,void t.setNoSearchResultsFound(c.nxtCoverageSvc,t.insurances.length)}t.loading=!0,c.nxtCoverageSvc={mrnIds:t.mrnIds,sort:"="+t.sort.direction+t.sort.field,withNoSessionReset:e},t.infiniteScroll.isBusy(!n,c)?t.infiniteScroll.disabled&&!t.infiniteScroll.busy&&(t.loading=!1):t.infiniteScroll.nextPage(!n).then(function(e){t.insurances||(t.insurances=[]),t.setDisplayOriginAndSource(e),t.insurances=n?t.insurances.concat(e):e,t.hasMoreData=!t.infiniteScroll.disabled,t.setNoSearchResultsFound(c.nxtCoverageSvc,t.insurances.length),t.loading=!1},function(){t.loading=!1})}},t.viewInsurance=function(n){t.isViewDetailsAvailable()&&t.view(n.getText(),e.getString("View Insurance"),n.externalSources)}}]),app.dashboardWidgets.filter("unsafe",["$sce",function(e){"use strict";return function(t){return e.trustAsHtml(t)}}]),app.dashboardWidgets.controller("nxtLabResultListCtrl",["$scope","$rootScope","$q","gettextCatalog","nxtDiagnosticReportSvc","nxtUtilsSvc","nxtUserContextSvc","$controller","nxtObservationSvc","$filter","$locale","CONSTANT","nxtPatientDashboardSvc","nxtTextSvc","$injector","NXT_LAB_TABLE_WIDGET",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h){"use strict";if(s("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:f}),e.isExpandedTable||(e.headers=e.setColumns([{id:"lab-result-panel-th",name:i.getString("Panel"),visible:!0,code:"panel",class:"text-right pad-right-5",order:0},{id:"lab-result-test-th",name:i.getString("Test"),visible:!0,width:"20",code:"test",class:"text-right pad-right-5",order:1},{id:"lab-result-value-th",name:i.getString("Value"),visible:!0,width:"10",code:"value",class:"text-right pad-right-5",order:2},{id:"lab-result-interpretation-th",name:i.getString("Interpretation"),visible:!0,width:"10",code:"interpretation",order:3},{id:"lab-result-sparkline-th",name:i.getString("Trendline"),visible:!0,width:"20",code:"sparkline",order:4},{id:"lab-result-date-th",name:i.getString("Elapsed Time"),visible:!0,width:"10",code:"date",order:5},{id:"lab-source-th",name:i.getString("Source"),visible:!1,width:"10",code:"source",order:6},{id:"lab-status-th",name:i.getString("Status"),visible:!1,width:"10",code:"status",order:7},{id:"lab-range-th",name:i.getString("Range"),visible:!1,width:"10",code:"range",order:8}])),e.isExpandedTable){if(e.currentAppContextChecked||(e.filter={group:[],test:[],pagination:{page:1,pageSize:10}}),e.widgetConfig=h,e.setFilters(),e.filterDates={start:null,end:null},e.availableFilter&&_.find(e.availableFilter,function(e){return"date"===e.Code}))var m=e.$on("start"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.start=null,e.filterDates.end=null,e.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.start=n.interval.startDate),n.interval.endDate&&(e.filterDates.end=n.interval.endDate),e.filterDates.startIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),t.stopPropagation()});e.$watchCollection("[mrnIds, filterDates.start, filterDates.end, filter.group.length, filter.test.length, filter.pagination.page, filter.pagination.pageSize]",function(t,n){!e.filterDates.end&&m||(n&&t[5]>1&&n[5]===t[5]?e.filter.pagination.page=1:(e.updateWidgetContext(),e.reloadTableData()))})}else e.$watch("mrnIds",function(){e.updateWidgetContext(),e.reloadTableData()});function v(t){if(e.labData=[],t&&t.length>0){for(var n,i,a=[],r=_.find(e.headers,function(e){return"panel"===e.code}),s=0;s<t.length;s++){for(var l=S(t[s]),d=0;d<l.length;d++)if(!l[d].displayPnl&&r.visible||(l[d].ageDisplay=o.getLos(l[d]._date,new Date),l[d].result&&l[d].result[0]&&(e.setDisplayOriginAndSource(l[d].result),l[d].labSource=l[d].result[0].source,l[d].labStatus=l[d].result[0].status)),l[d].result&&l[d].result[0]&&(l[d].labResultValue=o.getLabResultValue(l[d].result[0]),l[d].labResultUnit=o.getLabResultUnit(l[d].result[0]),l[d].labResultInterpretation=o.getInterpretation(l[d].result[0]),l[d].result[0].referenceRange&&l[d].result[0].referenceRange.length>0&&(l[d].labRange=g.getTextRange(l[d].result[0].referenceRange[0])),l[d].result[0].valueQuantity&&(n=null,i=null,l[d].result[0].referenceRange&&l[d].result[0].referenceRange.length>0&&(n=l[d].result[0].referenceRange[0].low?l[d].result[0].referenceRange[0].low.value:null,i=l[d].result[0].referenceRange[0].high?l[d].result[0].referenceRange[0].high.value:null),l[d].sparkLineData=[{value:l[d].result[0].valueQuantity.value,range:{low:n,high:i}}],l[d].result[0].previousResults&&l[d].result[0].previousResults.length>0)))for(var c=0;c<l[d].result[0].previousResults.length;
8c++)l[d].result[0].previousResults[c].valueQuantity&&(n=null,i=null,l[d].result[0].previousResults[c].referenceRange&&l[d].result[0].previousResults[c].referenceRange.length>0&&(n=l[d].result[0].previousResults[c].referenceRange[0].low?l[d].result[0].previousResults[c].referenceRange[0].low.value:null,i=l[d].result[0].previousResults[c].referenceRange[0].high?l[d].result[0].previousResults[c].referenceRange[0].high.value:null),l[d].sparkLineData.unshift({value:l[d].result[0].previousResults[c].valueQuantity.value,range:{low:n,high:i}}));a=a.concat(l)}e.labData=e.labData.concat(a)}}function S(e){var t=[];if(e.result&&e.result.length>1){var n=angular.copy(e.result);delete e.result;for(var i=null,a=0;a<n.length;a++)(i=angular.copy(e)).result=[n[a]],0===a&&(i.displayPnl=!0),i.id=i.id+"_"+a,t.push(i)}else e.displayPnl=!0,t.push(e);return t}e.filterDropdown={},e.filterDropdown.isChecked=function(e,t){for(var n in t.$parent.filter[t.propertyName]||(t.$parent.filter[t.propertyName]=[]),t.$parent.filter[t.propertyName])if(t.$parent.filter[t.propertyName][n].code===t.itemList[e].code)return!0;return!1},e.filterDropdown.selectItem=function(e,t,n){var i=t.itemList.indexOf(e);if(t.filterDropdown.isChecked(i,t,n)){for(var a in t.$parent.filter[t.propertyName])if(t.$parent.filter[t.propertyName][a].code===e.code){t.$parent.filter[t.propertyName].splice(a,1);break}}else t.$parent.filter[t.propertyName]||(t.$parent.filter[t.propertyName]=[]),t.$parent.filter[t.propertyName].push(e);t.updateInputList()},e.filterDropdown.updateInputList=function(e){var t=[];if(e.$parent.filter&&e.$parent.filter[e.propertyName])for(var n in e.$parent.filter[e.propertyName])e.$parent.filter[e.propertyName][n]&&t.push(e.$parent.filter[e.propertyName][n].display);return t.sort().join(", ")},e.reloadTableData=function(t){if(e.labData=null,e.patientContext&&e.mrnIds){if(e.waitingPatientDashboardCalls)if(delete e.waitingPatientDashboardCalls,p.PatientData[e.key]&&p.PatientData[e.key][e.code])return void v(angular.copy(p.PatientData[e.key][e.code]));if(e.loading=!0,e.isExpandedTable){var n={mrnIds:e.mrnIds,datePeriod:e.filterDates&&!e.filterDates.startIsAllInterval?e.filterDates:null,testCodes:e.filter.test&&e.filter.test.length>0?_.map(e.filter.test,function(e){return e.code}).join(","):null,groupCodes:e.filter.group&&e.filter.group.length>0?_.map(e.filter.group,function(e){return e.code}).join(","):null,count:10,page:e.filter.pagination.page,withNoSessionReset:t};l.getLabResultsFilteredWithTotalRows(n).then(function(t){if(t&&t.entries){var n=t.headers,i=t.entries,a=t.groups,r=[],s=[],l=null,u=null,p=null,g=null,f=null;if(r.push({title:"",field:"name",className:n?"xSmallWidth10":""}),n&&n.length>0)for(var h=0;h<n.length;h++){var m='<div nxt-tooltip="'+d("date")(n[h],c.DATETIME_FORMATS.nxtDateFormatSeconds)+'">'+d("date")(n[h],c.DATETIME_FORMATS.nxtDateFormatNoHours)+"<br/>"+d("date")(n[h],"HH:mm")+"</div>";r.push({title:m,field:"value"+(h+1),date:n[h],className:"div-max-class"}),u=n[h].getTime();var v=$.grep(i,function(e){return e.appliesPeriod&&e.appliesPeriod.start&&e.appliesPeriod.start.getTime()===u});for(let e=0;e<v.length;e++)for(var S=0;S<a.length;S++){_.find(a[S].tests,function(t){return t.code===v[e].name.code})&&(v[e].clinicalGroup=a[S])}v.sort(function(e,t){var n=e.clinicalGroup.name.display.toLowerCase(),i=t.clinicalGroup.name.display.toLowerCase();return n>i?1:n<i?-1:0});for(let e=0;e<v.length;e++){p=null,g=null;var C=_.find(a,function(t){return t.name.code===v[e].clinicalGroup.name.code});if(!C.exists){s.push({name:'<span class="bold black_lvl_four">'+C.name.display+"</span>",rowClass:"row-border-bottom"});for(var y=0;y<C.tests.length;y++)s.push({name:'<span class="bold black_lvl_three">'+C.tests[y].display+"</span>",code:C.name.code+"_"+C.tests[y].code,cellClass0:"text-right"})}p=o.getLabResultValue(v[e]),g=o.getInterpretation(v[e]),l=C.name.code+"_"+v[e].name.code,p&&(p='<span class="bold black_lvl_one lab-val">'+p+"</span>"+(g='<span class="bold danger_lvl lab-hl">'+(g||"")+"</span>")),delete v[e].clinicalGroup,s[f=s.map(function(e){return e.code}).indexOf(l)]["value"+(h+1)]=p,s[f]["observation"+(h+1)]=[v[e]],C.exists=!0}}else s.push({});r.length-1!=10&&r.push({title:"",field:""}),e.filter.pagination.totalResults=t.totalResults,e.sources={columns:r,data:s}}e.loading=!1})}else!function(t){a.searchLabResultsLatest(null,t,e.mrnIds).then(function(t){v(t),e.loading=!1},function(){e.loading=!1})}(t)}},e.viewLabResult=function(t){t[0]&&"Observation"===t[0].resourceType?t[0].parent?e.openViewLabResultPopup(t[0]):a.getByResultWithIncludes({observationId:t[0].id,patient:t[0].subject.id}).then(function(n){n&&(n.result=[angular.copy(t[0])],t[0].parent=n),e.o
8penViewLabResultPopup(t[0])}):e.openViewLabResultPopup(t[0])};var C=!1;e.openViewLabResultPopup=function(t){if(t){var n=t.parent||t;if(n.typesList=[{category:"LAB",code:"LAB",display:"Lab"}],"Observation"===n.resourceType)e.view(n.getTextLaboratoryResult(),i.getString("View  laboratory result"),n.externalSources);else{if(C)return;C=!0,n.getTextLaboratoryResult().then(function(t){C=!1,e.view(t,i.getString("View  laboratory result"),n.externalSources)},function(){C=!1})}}},e.openGraphView=function(){r.openSubtabByCode(e,u.GENERIC.EXPANDED_VIEWS.GRAPHS.code),e.activeTab.code=u.GENERIC.EXPANDED_VIEWS.GRAPHS.code},e.actions=[u.ACTION.GRAPH.get({command:e.openGraphView,permission:u.PERMISSION.SUBTABS.GRAPHS,hideOnNoPermission:!0})];var y=e.$on("changeColumnSelection",function(t,n){var i=_.filter(n,function(e){return!_.isNil(e)});i&&i.length>0&&e.viewLabResult(i)});e.$on("$destroy",function(){y(),m&&m()})}]),app.dashboardWidgets.controller("nxtMedicationListCtrl",["$scope","$rootScope","$controller","gettextCatalog","nxtInfiniteScrollSvc","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","CONSTANT","$injector","NXT_MEDICATIONS_WIDGET",function(e,t,n,i,a,o,r,s,l,d){"use strict";n("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:l}),e.widgetConfig=d;var c=[{id:"med-code-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Medication"),visible:!0,sort:"code",code:"code",order:0},{id:"med-route-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Route"),visible:!0,sort:"route_display",code:"route",width:e.isExpandedTable?"7":"12",order:1},{id:"med-dose-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Dose"),visible:e.isExpandedTable,code:"dose",width:"7",order:2},{id:"med-schedule-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Start/End Dates"),visible:!0,sort:"datestart",code:"schedule",width:e.isExpandedTable?"11":"22",minWidth:"122",order:e.isExpandedTable?3:2},{id:"med-date-written-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Date Written"),visible:!0,sort:"datewritten",code:"date-written",width:e.isExpandedTable?"11":"22",minWidth:"110",order:e.isExpandedTable?4:3},{id:"med-details-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Details"),visible:e.isExpandedTable,code:"details",width:"7",order:5},{id:"med-status-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Status"),visible:e.isExpandedTable,sort:"status",code:"status",width:"7",order:6},{id:"med-provider-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Provider"),visible:e.isExpandedTable,sort:"requester",code:"provider",width:"15",order:7},{id:"med-source-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source"),code:"source",visible:!0,width:e.isExpandedTable?"12":"25",order:e.isExpandedTable?8:4},{id:"med-source-origin-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source Document"),code:"source-origin",visible:e.isExpandedTable,width:"12",order:9},{id:"med-substitution-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Substitution"),code:"substitution",visible:!1,width:"12",order:10}];e.headers=_.sortBy(_.filter(e.setColumns(c),function(e){return e.visible}),"order"),e.setFilters();var u={},p={};if(u.nxtMedicationRequestSvc={methodName:"searchWithTotalRows"},e.infiniteScroll=a.create({services:u,limit:e.isExpandedTable?s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),e.statusList=[{code:"",display:"All statuses"},{code:"active",display:"Active"},{code:"cancelled",display:"Cancelled"},{code:"completed",display:"Completed"},{code:"draft",display:"Draft"},{code:"on-hold",display:"On hold"},{code:"stopped",display:"Stopped"},{code:"unknown",display:"Unknown"}],e.currentAppContextChecked||(e.filter={medication:null,status:e.statusList[e.isExpandedTable?0:1],route:null},e.sort={field:"datestart",direction:"-"}),e.filterDates={authoredOnFrom:null,authoredOnTo:null},e.availableFilter&&_.find(e.availableFilter,function(e){return"date-written"===e.Code}))var g=e.$on("authoredOn"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.authoredOnFrom=null,e.filterDates.authoredOnTo=null,e.filterDates.authoredOnIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.authoredOnFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.authoredOnTo=n.interval.endDate),e.filterDates.authoredOnIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),e.filter=_.extend(e.filter,{authoredOn:{from:e.filterDates.authoredOnFrom,to:e.filterDates.authoredOnTo,isAllInterval:e.filterDates.authoredOnIsAllInterval}}),t.stopPropagation()});e.$watchCollection("[mrnIds, filter.medication, filter.status, filter.route, filterDates.authoredOnFrom, filterDates.authoredOnTo
8]",function(t,n){!e.filterDates.authoredOnTo&&g||t&&!_.isEqual(angular.toJson(t),angular.toJson(n))&&(e.updateWidgetContext(),e.reloadTableData())}),e.reloadTableData=function(t,n){if(n||(e.medications=null,e.hasMoreData=!1),e.patientContext&&e.mrnIds){if(e.waitingPatientDashboardCalls&&(delete e.waitingPatientDashboardCalls,r.PatientData[e.key]&&r.PatientData[e.key][e.code])){var i=angular.copy(r.PatientData[e.key][e.code].entries);return e.setDisplayOriginAndSource(i),e.medications=i,e.infiniteScroll.setDataFromControl([r.PatientData[e.key][e.code]]),e.hasMoreData=!e.infiniteScroll.disabled,void e.setNoSearchResultsFound(p.nxtMedicationRequestSvc,e.medications.length)}e.loading=!0,p.nxtMedicationRequestSvc=_.extend({mrnIds:e.mrnIds,sort:"="+e.sort.direction+e.sort.field,withNoSessionReset:t},o.getMedicationParams(e.filter)),e.infiniteScroll.isBusy(!n,p)?e.infiniteScroll.disabled&&!e.infiniteScroll.busy&&(e.loading=!1):e.infiniteScroll.nextPage(!n).then(function(t){t||(t=[]),t&&t.length>0&&e.setDisplayOriginAndSource(t),e.medications=n?e.medications.concat(t):t,e.hasMoreData=!e.infiniteScroll.disabled,e.setNoSearchResultsFound(p.n
8xtMedicationRequestSvc,e.medications.length),e.loading=!1},function(){e.loading=!1})}},e.viewMedication=function(t){e.isViewDetailsAvailable()&&e.view(t.getText(),i.getString("View Medication"),t.externalSources)},e.$on("$destroy",function(){g&&g()})}]),app.dashboardWidgets.controller("nxtMedicationDispenseListCtrl",["$scope","$rootScope","$controller","gettextCatalog","nxtInfiniteScrollSvc","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","CONSTANT","$injector","NXT_MEDICATION_DISPENSE_WIDGET",function(e,t,n,i,a,o,r,s,l,d){"use strict";n("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:l});var c=[{id:"medd-code-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Medication"),visible:!0,sort:"code",code:"code",order:0},{id:"medd-prescription-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Prescription"),visible:e.isExpandedTable,sort:"prescription",code:"prescription",width:"10",order:1},{id:"medd-performer-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Pharmacy"),visible:!0,sort:"performer",code:"performer",width:e.isExpandedTable?"10":"20",order:e.isExpandedTable?2:1},{id:"medd-order-provider-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Ordering Provider"),visible:e.isExpandedTable,code:"ordering-provider",width:"10",order:3},{id:"medd-dose-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Dose Instruction"),visible:e.isExpandedTable,code:"dose",width:"12",minWidth:"122",order:4},{id:"medd-details-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Details"),visible:e.isExpandedTable,code:"details",width:"12",order:5},{id:"medd-whenhandedover-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Date Filled"),visible:!0,sort:"whenhandedover",code:"whenhandedover",width:e.isExpandedTable?"11":"22",minWidth:"110",order:e.isExpandedTable?6:2},{id:"medd-status-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Status"),visible:e.isExpandedTable,sort:"status",code:"status",width:"7",order:7},{id:"medd-source-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source"),code:"source",visible:!0,width:e.isExpandedTable?"10":"25",order:e.isExpandedTable?8:3},{id:"medd-source-origin-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source Document"),code:"source-origin",visible:e.isExpandedTable,width:"10",order:9}];e.headers=_.sortBy(_.filter(e.setColumns(c),function(e){return e.visible}),"order");var u={},p={};if(u.nxtMedicationDispenseSvc={methodName:"searchWithTotalRows"},e.infiniteScroll=a.create({services:u,limit:e.isExpandedTable?s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),e.statusList=[{code:"",display:"All statuses"},{code:"completed",display:"Completed"},{code:"in-progress",display:"In progress"},{code:"on-hold",display:"On hold"},{code:"preparation",display:"preparation"},{code:"stopped",display:"Stopped"}],e.currentAppContextChecked||(e.filter={medication:null,status:e.statusList[0],performer:null,prescription:null},e.sort={field:"medication",direction:"-"}),e.widgetConfig=d,e.setFilters(),e.filterDates={whenHandedOverFrom:null,whenHandedOverTo:null},e.availableFilter&&_.find(e.availableFilter,function(e){return"date-filled"===e.Code}))var g=e.$on("whenHandedOver"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.whenHandedOverFrom=null,e.filterDates.whenHandedOverTo=null,e.filterDates.whenHandedIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.whenHandedOverFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.whenHandedOverTo=n.interval.endDate),e.filterDates.whenHandedIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),e.filter=_.extend(e.filter,{whenHandedOver:{from:e.filterDates.whenHandedOverFrom,to:e.filterDates.whenHandedOverTo,isAllInterval:e.filterDates.whenHandedIsAllInterval}}),t.stopPropagation()});e.$watchCollection("[mrnIds, filter.medication, filter.status, filter.performer, filter.prescription, filterDates.whenHandedOverFrom, filterDates.whenHandedOverTo]",function(){!e.filterDates.whenHandedOverTo&&g||(e.updateWidgetContext(),e.reloadTableData())}),e.reloadTableData=function(t,n){if(n||(e.medications=null,e.hasMoreData=!1),e.patientContext&&e.mrnIds){if(e.waitingPatientDashboardCalls&&(delete e.waitingPatientDashboardCalls,r.PatientData[e.key]&&r.PatientData[e.key][e.code])){var i=angular.copy(r.PatientData[e.key][e.code].entries);return e.setDisplayOriginAndSource(i),e.medications=i,e.infiniteScroll.
8setDataFromControl([r.PatientData[e.key][e.code]]),e.hasMoreData=!e.infiniteScroll.disabled,void e.setNoSearchResultsFound(p.nxtMedicationDispenseSvc,e.medications.length)}e.loading=!0,p.nxtMedicationDispenseSvc=_.extend({mrnIds:e.mrnIds,sort:"="+e.sort.direction+e.sort.field,withNoSessionReset:t},o.getMedicationDispense(e.filter)),e.isExpandedTable&&(p.nxtMedicationDispenseSvc.includeMedRequest=!0),e.infiniteScroll.isBusy(!n,p)?e.infiniteScroll.disabled&&!e.infiniteScroll.busy&&(e.loading=!1):e.infiniteScroll.nextPage(!n).then(function(t){t||(t=[]),t&&t.length>0&&e.setDisplayOriginAndSource(t),e.medications=n?e.medications.concat(t):t,e.hasMoreData=!e.infiniteScroll.disabled,e.setNoSearchResultsFound(p.nxtMedicationDispenseSvc,e.medications.length),e.loading=!1},function(){e.loading=!1})}};var f=!1;e.viewMedication=function(t){e.isViewDetailsAvailable()&&(f||(f=!0,t.getText().then(function(n){f=!1,e.view(n,i.getString("View Dispensed Medication"),t.externalSources)},function(){f=!1})))},e.$on("$destroy",function(){g&&g()})}]),app.dashboardWidgets.controller("nxtNoteDialogCtrl",["$scope","$uibModalInstance",function(e,t){"use strict";e.save=function(){t.close(e.note)},e.close=function(){t.dismiss("cancel")}}]),app.dashboardWidgets.controller("nxtDashboardWidgetsCtrl",["scope","$rootScope","$injector","$window","CONSTANT","NXT_DOCUMENTS_WIDGET",function(e,t,n,i,a,o){"use strict";var r=n.get("nxtUserContextSvc"),s=n.get("nxtDocumentFormatterSvc"),l=n.get("nxtTemplateViewSvc"),d=n.get("gettextCatalog"),c=n.get("nxtPatientDashboardSvc"),u=n.get("nxtPatientDashboardPrintSvc"),p=n.get("nxtPatientDashboardParamsSvc"),g=n.get("$uibModal");e.isExpandedTable=!(!e.subtab||e.subtab.code!==e.subtab.parentSubtab),e.tableId=(e.isDoctorTabSelected||e.isSSOContext||e.isPatientConsentModule||e.isEhxTab?e.code:e.subtab.code)+(e.isExpandedTable?"_View":"")+"_Tbl",e.resizeMode="WidgetResizer",e.dragHead={code:"",width:"0px",html:"",th:null},e.dragImageId="dragtable_"+e.tableId,e.handleDrop=function(t,n){var i,a=_.find(e.headers,function(e){return e.id===n}),o=_.sortBy(angular.copy(e.headers),"order"),r=t.order,s=a.order;if(e.isSimpleView){var l=e.headers.length/2-1;if(r<=l&&s>l)return;if(r>l&&s<=l)return}if(r>s)for(var d=r;d>=s;d--)(i=_.find(o,function(e){return e.order===d})).order=i.id===t.id?s:i.order+1;else for(var c=s;c>=r;c--)(i=_.find(o,function(e){return e.order===c})).order=i.id===t.id?s:i.order-1;e.headers=_.sortBy(angular.copy(o),"order"),e.dragHead=angular.copy({code:"",width:"0px",html:"",th:null}),(e.isExpandedTable||e.isPatientConsentModule||e.isEhxTab)&&e.$broadcast("onDragAndDrop",e.subtab)},e.handleDrag=function(t){var n=angular.fromJson(t);e.dragHead={width:n.width,html:n.html,item:angular.fromJson(n.item)}};var f=t.$on("onResizeInProgress",function(t,n,i){n===e.tableId&&(e.$broadcast("onResizeHeaderInProgress",e.subtab,i),t.stopPropagation())});if(e.setFilters=function(t){var n=e.isExpandedTable?"Detail":"Summary";if(e.widgetConfig&&e.widgetConfig.Header&&e.widgetConfig.Header[n]&&e.widgetConfig.Header[n].length>0){var i=_.filter(e.widgetConfig.Header[n],function(e){return e.Visible});if(!t||e.hasPrintOptionColumn&&e.hasPrintOptionColumn.visible?e.availableFilter=i:e.availableFilter=_.filter(i,function(e){return"print"!==e.Code}),e.availableFilter&&e.availableFilter.length>0){var a=_.groupBy(_.orderBy(e.availableFilter,["Row","Order"]),"Row");a&&!_.isEmpty(a)&&(e.rows=a)}}},e.setColumns=function(t){var n=[],i=[];if(e.isDoctorTabSelected||"ssoPatientSearch"===e.code)i=r.ApplicationConfiguration&&r.ApplicationConfiguration.doctorWidgetsConfig;else if(e.isPatientConsentModule)i=r.ApplicationConfiguration&&r.ApplicationConfiguration&&r.ApplicationConfiguration.consent&&r.ApplicationConfiguration.consent.columns;else if(e.isEhxTab)r.ApplicationConfiguration&&r.ApplicationConfiguration.patientViewsTableConfig&&(i=r.ApplicationConfiguration&&r.ApplicationConfiguration.patientViewsTableConfig[e.subtab.eHxProperty]);else{var a=e.isExpandedTable?"patientViewsConfig":"patientWidgetsConfig";i=r.ApplicationConfiguration&&r.ApplicationConfiguration[a]}if(i&&(n=e.isPatientConsentModule||e.isEhxTab?i:"pacVitalS"===e.code?i[e.isSimpleView?"pacVitalS":"pacVitalSparklines"]:"ssoPatientSearch"===e.code?i.docPatientSearch:i[e.code])&&n.length>0){var o=_.intersectionBy(n,t,"code");if(o&&o.length>0)for(let e=0;e<t.length;e++){var s=angular.copy(_.find(o,function(n){return n.code===t[e].code}));s?(s.visible=!0,s.name=s.display,s.order=_.findIndex(o,function(n){return n.code===t[e].code}),t[e]=angular.extend(t[e],{visible:s.visible,order:s.order,name:s.display})):t[e].visible=!1}}if(t&&t.length>0){var l=0,d=0;for(let e=0;e<t.length;e++)t[e].visible&&t[e].width&&(l+=parseInt(t[e].width),d++);if(l>90)for(let e=0;e<t.length;e++)t[e].visible&&(t[e].width=100/d)}return t},e.setDisplayOriginAndSource=function(e){if(e&&0!==e.length)for(let t=0;t<e.length;t++)e[t].externalSources&&e[t].externalSources[0]&&(e[t].source=e[t].externalSources[0].sourceOrganizationDisplay||e[t].externalSources[0].sourceOrganization,e[t].origin=e[t].externalSources[0].sourceOrigin),e[t].portalSources&&(e[t].portalSources.sourcePortalAuthor&&(e[t].sourcePortalAuthor=e[t].portalSources.sourcePortalAuthor),e[t].portalSources.sourcePortalOrganization&&(e[t].sourcePortalOrganization=e[t].portalSources.sourcePortalOrganization))},e.addFilterDateKeys=function(t){e.filterDateKeys||(e.filterDateKeys=[]),_.find(e.filterDateKeys,function(e){return e===t})||e.filterDateKeys.push(t)},!(e.isDoctorTabSelected||e.isSSOContext||e.isPatientConsentModule||(e.widgetDefaultFilter={interval:{start:{code:"all",display:"All"},end:{code:"today",display:"Today"}}},e.filterDateKeys=[],e.isEhxTab))){e.prefixId=e.code+(e.isExpandedTable?"_View":""),e.waitingPatientDashboardCalls=!e.isExpandedTable,e.currentAppContextChecked=!1,e.checkWidgetContext=function(){if(!e.currentAppContextChecked){var t=r.getCurrentPageContextProperty(e.widgetContext);t&&(e.filter=_.omit(t,["sort","defaultFilter"]),e.sort=t.sort,e.currentAppContextChecked=!0)}},e.checkWidgetContext(),e.refreshClinicalDocumentWidget=function(e,t){let n=!1,i=!1,a=!1;
8return o.Upload&&o.Upload.Enabled&&o.Upload.MrnSystem&&(a=(n=e&&e.indexOf(o.Upload.MrnSystem)>-1)!==(i=t&&t.indexOf(o.Upload.MrnSystem)>-1)),a},e.$watchCollection("[patientContext.PatientId, patientContext.MrnIds]",function(t,n){e.refreshClinicalDocumentWidget(t&&t[1],n&&n[1])?e.code===a.GENERIC.WIDGETS.DOCUMENTS.code&&(e.mrnIds=e.patientContext.MrnIds,e.key=app.getPatientDashboardDataKey(e.patientContext.MrnIds)):(e.mrnIds=e.patientContext.MrnIds,e.key=app.getPatientDashboardDataKey(e.patientContext.MrnIds))});var h=t.$on("reloadPatientData",function(){e.reloadTableData()});e.getMoreData=function(){e.reloadTableData(null,!0)},e.setNoSearchResultsFound=function(t,n){c.ShowMessageNoSearchResultsFound&&(c.PatientData&&c.PatientData[e.key]&&c.PatientData[e.key][e.widgetContext]||c.updatePatientDashboardData(e.key,e.widgetContext,t),t||(t=c.PatientData[e.key][e.widgetContext]),p.hasWidgetFilter(e.code,t)?e.noSearchResultsFound='Filter(s) active - to view additional data adjust search criteria or filter(s), or <a href="" ng-class="{\'disabled-href-link\': loading}" ng-click="resetFilterToDefault()">reset to all</a>':e.noSearchResultsFound=n&&n>0?null:"No information is available.")},e.resetFilterToDefault=function(){e.filterDates={};var t=e.filter,n=r.getCurrentPageContextProperty(e.widgetContext);if(n&&n.defaultFilter&&(t=n.defaultFilter),e.filter=angular.copy(t),e.filterDateKeys&&e.filterDateKeys.length>0&&e.widgetDefaultFilter)for(let t=0;t<e.filterDateKeys.length;t++)r.setCurrentPageContextProperty(e.filterDateKeys[t]+"_EmitDateFilterChangedEvent",!0),r.setCurrentPageContextProperty(e.filterDateKeys[t],angular.copy(e.widgetDefaultFilter))},e.openViewDocumentPopup=function(n,i){e.isExpandedTable||(e.isDocumentOpening=!0);var a=e.$new();a.showButtonPrint=!0,a.showButtonDownload=!0,a.documentReferenceId=n,a.isHL7Message=i,a.dialogClass=i?null:t.showVerbiage?"nxt-full-popup-with-verbiage":"nxt-full-popup",s.viewFile(a)},e.isViewDetailsAvailable=function(){return!e.isDocumentOpening||(e.isDocumentOpening=!1,!1)},e.view=function(e,t,n,i,a,o){var r={closeButtonText:d.getString("Close"),headerText:t,bodyText:e,externalSources:n};i&&(r.selectedReportResource=i),o&&(r.hasCustomHeight=!0),l.showModal(r,a)}
8,e.updateWidgetContext=function(){var t=p.overwriteDefaultWidgetFilter(e.code,angular.copy(e.filter)),n=r.getCurrentPageContextProperty(e.widgetContext);n&&n.defaultFilter&&(t=angular.copy(n.defaultFilter)),r.setCurrentPageContextProperty(e.widgetContext,_.extend({sort:e.sort,defaultFilter:t},e.filter))},e.sortData=function(t){t!==e.sort.field?(e.sort.field=t,e.sort.direction=""):e.sort.direction=_.isEmpty(e.sort.direction)?"-":"",e.updateWidgetContext(),e.reloadTableData()},e.print=function(){var t=e.$new();t.title="Print Table Data",g.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:t,controller:["$scope","$uibModalInstance",function(t,n){t.docLoading=!0,u.generateWidgetPdf({code:e.code,isExpandedTable:e.isExpandedTable},e.headers).then(function(e){if(i.navigator&&i.navigator.msSaveOrOpenBlob)i.navigator.msSaveOrOpenBlob(e),t.close();else{var n=URL.createObjectURL(e);t.htmlList=['<iframe src="{{0}}"  type="{{1}}" width="100%" height="100%" class="viewer"></iframe>'.replace("{{0}}",n).replace(/\{\{1\}\}/g,"application/pdf")]}},function(){e.docLoading=!1}),t.close=function(){n.dismiss("cancel")};var a=t.$on("onLoaded",function(e){t.docLoading=!1});t.$on("$destroy",function(){a&&a()})}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})}}e.$on("$destroy",function(){h&&h(),f()})}]),app.dashboardWidgets.controller("nxtParticipantListCtrl",["gettextCatalog","$scope","$rootScope","nxtInfiniteScrollSvc","$controller","nxtPatientDashboardSvc","CONSTANT","$injector","NXT_PATIENT_RELATIONSHIPS_WIDGET","nxtPatientDashboardParamsSvc",function(e,t,n,i,a,o,r,s,l,d){"use strict";a("nxtDashboardWidgetsCtrl",{scope:t,rootScope:n,$injector:s}),t.widgetConfig=l;var c=[{id:"participant-name-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Name"),visible:!0,code:"name",sort:"name",order:0},{id:"participant-relation-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Relationship"),code:"relation",visible:!0,width:t.isExpandedTable?"12":"25",order:t.isExpandedTable?1:2},{id:"participant-gender-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Gender"),code:"gender",visible:t.isExpandedTable,sort:"gender",width:"7",order:3},{id:"participant-email-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Email"),code:"email",visible:t.isExpandedTable,sort:"email",width:"12",order:4},{id:"participant-phone-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Phone"),visible:!0,code:"phone",sort:"phone",width:t.isExpandedTable?"12":"25",order:t.isExpandedTable?5:1},{id:"participant-address-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Address"),code:"address",visible:t.isExpandedTable,sort:"address",width:"20",order:6},{id:"participant-source-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Source"),code:"source",visible:!0,width:t.isExpandedTable?"12":"25",order:t.isExpandedTable?7:3},{id:"participant-source-origin-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Source Document"),code:"source-origin",visible:t.isExpandedTable,width:"12",order:8},{id:"participant-date-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:e.getString("Date"),code:"date",visible:!1}];t.headers=_.sortBy(_.filter(t.setColumns(c),function(e){return e.visible}),"order"),t.setFilters();var u={},p={nxtRelatedPersonSvc:{methodName:"searchWithTotalRows"}};t.infiniteScroll=i.create({services:p,limit:t.isExpandedTable?r.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:r.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),t.genderList=[{code:"",display:"All genders"},{code:"female",display:"Female"},{code:"male",display:"Male"},{code:"other",display:"Other"},{code:"unknown",display:"Unknown"}],t.currentAppContextChecked||(t.filter={name:null,email:null,phone:null,address:null,gender:t.genderList[0]},t.sort={field:"name",direction:"-"}),t.$watchCollection("[mrnIds, filter.name, filter.email, filter.phone, filter.address, filter.gender.code, filter.multipleFields]",function(){t.updateWidgetContext(),t.reloadTableData()}),t.reloadTableData=function(e,n){if(n||(t.participants=null,t.hasMoreData=!1),t.patientContext&&t.mrnIds){if(t.waitingPatientDashboardCalls&&(delete t.waitingPatientDashboardCalls,o.PatientData[t.key]&&o.PatientData[t.key][t.code])){var i=angular.copy(o.PatientData[t.key][t.code].entries);return t.setDisplayOriginAndSource(i),t.participants=i,t.infiniteScroll.
8setDataFromControl([o.PatientData[t.key][t.code]]),t.hasMoreData=!t.infiniteScroll.disabled,void t.setNoSearchResultsFound(u.nxtRelatedPersonSvc,t.participants.length)}t.loading=!0,u.nxtRelatedPersonSvc=_.extend({mrnIds:t.mrnIds,sort:"="+t.sort.direction+t.sort.field,withNoSessionReset:e},d.getRelatedPersonParams(t.filter)),t.infiniteScroll.isBusy(!n,u)?t.infiniteScroll.disabled&&!t.infiniteScroll.busy&&(t.loading=!1):t.infiniteScroll.nextPage(!n).then(function(e){t.participants||(t.participants=[]),t.setDisplayOriginAndSource(e),t.participants=n?t.participants.concat(e):e,t.hasMoreData=!t.infiniteScroll.disabled,t.setNoSearchResultsFound(u.nxtRelatedPersonSvc,t.participants.length),t.loading=!1},function(){t.loading=!1})}},t.viewRelatedPerson=function(n){t.isViewDetailsAvailable()&&t.view(n.getText(),e.getString("View Patient Relationships"),n.externalSources)}}]),app.ui.dashboards.controller("nxtPatientResultsCtrl",["$scope","$rootScope","$locale","$filter","$window","$uibModal","nxtUserContextSvc","nxtInfiniteScrollSvc","nxtPrintUtilsSvc","nxtUserSvc","nxtDiagnosticReportSvc","nxtUtilsSvc","nxtDocumentFormatterSvc","NXT_PATIENT_RESULTS_QUERY_TAB",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g){"use strict";e.username=r.loggedUser.username,e.isClinicalInboxContext=r.getCurrentPageContextProperty("clinicianDashboardModuleContext"),e.isClinicalInboxContext&&r.removeCurrentPageContextProperty("clinicianDashboardModuleContext"),e.widgetContext=e.isClinicalInboxContext?"clinicalInbox":"patientResults",e.selectedForPrintCount=0,e.filter={readStatus:"all",status:"all",encClass:"all",alert:"all"};var f,h,m=e.isClinicalInboxContext?"clinicianResultsDateFilterChangedEvent":"patientResultsDateFilterChangedEvent";e.defaultDateFilter={interval:{start:{code:"all",display:"All"},end:{code:"today",display:"Today"}}},e.filterDates={startFrom:null,startTo:null},e.isClinicalInboxContext?(S(),f=e.$on("userConfigurationChanged",function(){var t=r.LoggedUserConfiguration&&r.LoggedUserConfiguration.organization?r.LoggedUserConfiguration.organization:null;_.isEqual(e.worksBehalfOfConfiguration.organization,t)||S()})):(e.userContextSvc=r,e.$watch("userContextSvc.Patient.id",function(){var t;r.Patient&&(t=r.Patient,e.mrnIds=null,t&&t.id?(t.attesting&&t.attesting.mrnList&&(e.mrnIds=u.getMrnIds(t.attesting.mrnList)),e.patientContext={Patient:t,PatientId:t.id,PatientEid:t.eid},e.initialLoad||w()):(e.patientContext=null,e.reportsData=[],e.operation=null,e.changeSelection(null)))}),e.initialLoad=!0,f=t.$on("reloadPatientData",function(){w()}),h=e.$on("reloadPatientDataByMrnList",function(t,n,i){var a=u.getMrnIds(n);_.isEqual(a,e.mrnIds)||(e.mrnIds=angular.copy(a),i||w())}));var v=e.isClinicalInboxContext?"[filter.patient, filter.performer, filter.status, filter.categories, filter.alert, filter.encClass, filter.readStatus, filterDates.startFrom, filterDates.startTo]":"[filter.status, filter.categories, filter.alert, filter.encClass, filterDates.startFrom, filterDates.startTo]";function S(){e.searchUser=d.search,e.worksBehalfOfConfiguration={};var t=!1,n=r.LoggedUserConfiguration&&r.LoggedUserConfiguration.organization?r.LoggedUserConfiguration.organization:null;if(n&&(e.worksBehalfOfConfiguration.organization=n,r.OrganizationUser&&r.OrganizationUser.length>0)){var i=_.find(r.OrganizationUser,function(e){return e.organization.id===n.id});i&&i.onBehalfOf&&i.onBehalfOf.type&&(t=!0,i.onBehalfOf.provider&&(e.worksBehalfOfConfiguration.providers=i.onBehalfOf.provider))}e.worksBehalfOfConfiguration.hasBehalfOf=t}e.$watchCollection(v,function(t,n){e.filterDates.startTo&&(_.isEqual(n,t)||w())});var C=[{code:"all",display:"All",selected:!0}];if(g.Filter.Type){if(g.Filter.Type.List&&g.Filter.Type.List.length>0&&(C=angular.copy(g.Filter.Type.List)),g.Filter.Type.DefaultValue&&g.Filter.Type.DefaultValue.length>0&&C.length>0){var y=angular.copy(g.Filter.Type.DefaultValue);y||(y=[]),y.length>1&&_.find(y,function(e){return"all"===e.toLowerCase()})&&(y=_.filter(y,function(e){return"all"===e.toLowerCase()}));for(var b=0;b<C.length>0;b++)_.find(y,function(e){return e.toLowerCase()===C[b].code.toLowerCase()})&&(C[b].selected=!0)}_.find(C,function(e){return e.selected})||_.each(C,function(e){"all"===e.code&&(e.selected=!0)})}e.typesList=C,e.widthSize=100/(e.typesList.length+1>8?e.typesList.length+1:8);var x={},D={nxtDiagnosticReportSvc:{methodName:"searchWithTotalRows"}};e.infiniteScroll=s.create({services:D}),e.$watch("reportSelectedItem",function(t,n){if(t&&!_.isEqual(_.get(t,"id",""),_.get(n,"id",""))){var i=angular.copy(e.reportSelectedItem);e.operation="view",function(t){e.reportViewText=null,e.reportViewHeader=null,e.selectedResultViewLoading=!0,delete e.selectedReportResource,t.typesList=e.typesList,t.getText("selectedReportResource").then(function(n){e.reportViewHeader=t.serviceCategoryDisplay,e.reportViewHeader+=t.code&&t.code.display?(e.reportViewHeader?": ":"")+t.code.display:"",n&&(e.reportViewText=n?n.text:""),e.selectedReportResource=n?n.resource:null,e.selectedResultViewLoading=!1,e.isClinicalInboxContext&&"read"!==t.readStatus&&c.markAsRead(t.id).then(function(){for(var n=0;n<e.reportsData.length;n++)if(e.reportsData[n]&&e.reportsData[n].id===t.id){e.reportsData[n].readStatus="read";break}})},function(){e.selectedResultViewLoading=!1})}(i)}},!0);var T=e.$on(m,function(t,n){e.filterDates.startFrom=null,e.filterDates.startTo=null,e.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.startTo=n.interval.endDate),e.filterDates.startIsAllInterval=n.interval.isAllFilter),e.filter=_.extend(e.filter,{start:{from:e.filterDates.startFrom,to:e.filterDates.startTo,isAllInterval:e.filterDates.startIsAllInterval}}),t.stopPropagation()});function w(t){if(t||(e.reportsData=[]),e.filter&&(e.isClinicalInboxContext||e.patientContext&&e.patientContext.Patient&&e.mrnIds)){if
8(e.isClinicalInboxContext&&"behalf"===e.filter.patient&&!e.filter.performer)return e.operation=null,e.changeSelection(null),void(e.reportsData=[]);if(x.nxtDiagnosticReportSvc={status:e.filter.status&&"all"!==e.filter.status?e.filter.status:null,serviceCategory:e.filter.categories&&"all"!==e.filter.categories?e.filter.categories:null,interpretation:e.filter.alert&&"all"!==e.filter.alert?e.filter.alert:null,encounterClass:e.filter.encClass&&"all"!==e.filter.encClass?e.filter.encClass:null,sort:e.sort&&e.sort.querySort?e.sort.querySort:"=-issued",startDate:e.filter&&e.filter.start&&!e.filter.start.isAllInterval&&e.filter.start.from?e.filter.start.from:null,endDate:e.filter&&e.filter.start&&!e.filter.start.isAllInterval&&e.filter.start.to?e.filter.start.to:null},e.isClinicalInboxContext){var n=r.loggedUser.id;e.filter.performer&&e.filter.performer.id&&(n=e.filter.performer.id),_.isNil(n)||(x.nxtDiagnosticReportSvc.performer="User/"+n),x.nxtDiagnosticReportSvc.readStatus=_.get(e.filter,"readStatus","all")}else x.nxtDiagnosticReportSvc.mrnIds=e.mrnIds;e.infiniteScroll.isBusy(!t,x)||(delete e.initialLoad,t||(e.operation=null,e.changeSelection(null),e.selectedForPrintCount=0),e.infiniteScroll.nextPage(!t).then(function(n){!function(e){if(e&&e.length>0)for(var t=0;t<e.length;t++)E(e[t])}(n),e.reportsData||(e.reportsData=[]),e.reportsData=t?e.reportsData.concat(n):n,t||(e.operation=e.reportsData&&e.reportsData.length>0?"view":null,e.changeSelection(e.reportsData&&e.reportsData.length>0?e.reportsData[0]:null))}))}}function E(t){t&&(t.dateDisplay="",t.issued&&(t.dateDisplay=i("date")(t.issued,n.DATETIME_FORMATS.nxtDateFormat)),t.interpretationAlert&&(t.alertDisplay=_.upperFirst(t.interpretationAlert)),t.status&&(t.statusDisplay=_.upperFirst(t.status)),t.externalSources&&t.externalSources[0]&&(t.source=t.externalSources[0].sourceOrganizationDisplay||t.externalSources[0].sourceOrganization,t.origin=t.externalSources[0].sourceOrigin),t.serviceCategory&&(t.serviceCategoryDisplay=function(t){if(!t)return null;var n=t.toUpperCase();_.isArray(e.typesList)&&e.typesList.forEach(function(e){e.code&&_.find(e.code.split(","),function(e){return e.toUpperCase()===n})&&(n=e.display)});return n}(t.serviceCategory.code)||t.serviceCategory.display))}e.getMoreData=function(){w(!0)},e.sortData=function(t){e.sort||(e.sort={field:null,direction:null}),t!==e.sort.field?(e.sort.field=t,e.sort.direction="asc"):e.sort.direction="asc"===e.sort.direction?"desc":"asc";var n=e.sort.field;e.sort.querySort="="+("desc"===e.sort.direction?"-":"")+n,w()},e.openViewDocumentPopup=function(n,i){var a=e.$new();a.showButtonPrint=!0,a.showButtonDownload=!0,a.documentReferenceId=n,a.isHL7Message=i,a.dialogClass=i?null:t.showVerbiage?"nxt-full-popup-with-verbiage":"nxt-full-popup",p.viewFile(a)},e.toggleTypeButton=function(t){t&&(e.filter||(e.filter={}),"all"===t?(e.filter.type="all",_.each(e.typesList,function(e){e.selected=!1})):_.each(e.typesList,function(e){e.code===t&&(e.selected=!e.selected),"all"===e.code&&(e.selected=!1)}),_.find(e.typesList,function(e){return e.selected})||_.each(e.typesList,function(e){"all"===e.code&&(e.selected=!0)}),e.filter.categories=_.map(_.filter(e.typesList,function(e){return e.selected}),"code").join(","))},e.selectForPrint=function(t,n){return t.stopPropagation(),n&&n.selectedForPrint?e.selectedForPrintCount++:e.selectedForPrintCount--,!1},e.printReports=function(){var t;t=e.selectionMode?_.filter(e.reportsData,function(e){return e.selectedForPrint}):[e.reportSelectedItem];var n=e.$new();if(n.title="Print Results",n.reportsToPrint=t,n.reportsToPrint)for(var i=0;i<n.reportsToPrint.length;i++)n.reportsToPrint[i].typesList=e.typesList;n.docLoading=!0,o.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:n,controller:["$scope","$uibModalInstance",function(e,t){l.generatePdf(e.reportsToPrint).then(function(t){if(a.navigator&&a.navigator.msSaveOrOpenBlob){for(var i=atob(t),o=new Array(i.length),r=0;r<i.length;r++)o[r]=i.charCodeAt(r);var s=new Uint8Array(o),l=new Blob([s],{type:"application/pdf"});a.navigator.msSaveOrOpenBlob(l),e.close()}else e.htmlList=['<object type="application/pdf" data="data:application/pdf;base64,'+t+'" width="100%" height="100%" class="viewer"></object>'];n.docLoading=!1}),e.close=function(){t.dismiss("cancel")}}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})},e.toggleSelectionMode=function(){e.selectionMode=!e.selectionMode,e.selectionMode||_.map(e.reportsData,function(e){delete e.selectedForPrint})},e.$on("$destroy",function(){f(),T(),h&&h()})}]),app.dashboardWidgets.controller("nxtPatientConsentOptOutCtrl",["$scope","$q","nxtUserSvc","nxtUserContextSvc","CONSTANT","nxtValueSetSvc","NXT_BREAK_GLASS_MESSAGE","NXT_SSO_CONFIG",function(e,t,n,i,a,o,r,s){"use strict";e.loading=!0,e.closeDialog=s.CloseDialog,t.all([o.get({valueSetName:"EmergencyAccessReason",limit:100}),app.checkPermission(a.PERMISSION.BREAK_GLASS)]).then(function(t){e.reasonList=t[0],e.breakGlassMessage=r[!0===t[1].result?"Enabled":"Disabled"],e.loading=!1},function(){e.loading=!1}),e.save=function(t){var a=_.find(e.reasonList,function(e){return e&&e.code===t});a&&(i.setCurrentPageContextProperty("breakGlassEnabled_"+e.patient.eid,!0),e.isSaving=!0,n.enableBreakGlass({patient:e.patient,reason:a}).then(function(){e.$close(a)},function(t){e.errMessage=t,e.isSaving=!1}))},e.close=function(){e.$dismiss("cancel")}}]),app.dashboardWidgets.controller("nxtPatientSearchListCtrl",["$scope","$controller","$rootScope","nxtTemplateViewSvc","gettextCatalog","nxtUserContextSvc","nxtInfiniteScrollSvc","nxtTextSvc","$timeout","nxtConsentSvc","NXT_CONSENT","$uibModal","NXT_IDS_CONFIG","nxtUtilsSvc","NXT_CLINICIAN_DASHBOARD_MODULE","nxtValueSetSvc","nxtUserSvc","NXT_PART_TWO_MRN_LIST","NXT_PATIENT_SEARCH_WIDGET","CONSTANT","$q","NXT_PATIENT_NAME","$injector","NXT_SSO_CONFIG",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m,v,S,C,y,b,x,D){"use strict";t("nxtDashboardWidgetsCtrl",{scope:e,rootScope:n,$injector:x}),e.NXT_IDS_CONFIG=p,e.ssoWidgetConfig=D.PatientSelectionDialog,e.closeDialog=D.CloseDialog,e.optOutConsentDisplay=f.ConsentOptOutText,e.concatenateFirstAndMiddleNames=b.ConcatenateFirstAndMiddleNames,e.widgetConfig=S,e.expandedList={};var T={LAST_NAME:"lastName",FIRST_NAME:"firstName",MIDDLE_NAME:"middleName",MRN:"mrn",GENDER:"gender",DOB:"dob",AGE:"age",ATTESTATION:"attestation",FACILITY:"facility"},w=[{id:"spatient-last-name-th",name:a.getString("Last name"),visible:!0,code:"last-name",sort:T.LAST_NAME,order:0},{id:"spatient-first-name-th",name:a.getString("First name"),visible:!0,code:"first-name",sort:T.FIRST_NAME,width:"15",order:1},{id:"spatient-mrn-th",name:a.getString("MRN"),visible:p.MRN.visible,code:"mrn",sort:T.MRN,width:"10",order:2},{id:"spatient-facility-th",name:a.getString("Facility"),visible:!1,code:"facility",sort:T.FACILITY},{id:"spatient-gender-th",name:a.getString("Gender"),visible:!0,code:"gender",sort:T.GENDER,width:"7",order:p.MRN.visible?3:2},{id:"spatient-dob-th",name:a.getString("DOB"),visible:!0,code:"dob",sort:T.DOB,width:"14",minWidth:"75",order:p.MRN.visible?4:3},{id:"spatient-age-th",name:a.getString("Age"),visible:!0,code:"age",sort:T.AGE,width:"5",order:p.MRN.visible?5:4},{id:"spatient-address-th",name:a.getString("Address"),visible:!0,code:"address",width:p.MRN.visible?"20":"30",order:p.MRN.visible?6:5},{id:"spatient-attestation-th",name:a.getString("Pt Records Available"),code:"attestation",visible:!0,width:"13",sort:T.ATTESTATION,order:p.MRN.visible?7:6},{id:"spatient-hie-consent-th",name:"",code:"consent",visible:!0,width:"7",order:p.MRN.visible?8:7},{id:"spatient-print-demographics-th",name:"Demographics",code:"print-demographics",visible:!1,width:"10"},{id:"spatient-middle-name-th",name:"Middle name",code:"middle-name",sort:T.MIDDLE_NAME,visible:!1,width:"10"}],E=_.filter(e.setColumns(w),function(e){return e.visible});e.concatenateFirstAndMiddleNames&&_.find(E,function(e){return"middle-name"===e.code})&&(E=_.filter(E,function(e){return"middle-name"!==e.code})),e.headers=_.sortBy(E,"order"),e.isSSOContext||(e.search={}),e.zip={};var P={},I={};function A(){if(!e.search||_.isEmpty(e.search))return!1;var t=0;return angular.forEach(e.search,function(e){(_.isNil(e)||_.isUndefined(e))&&t++}),t<=1}e.tblTitle="Patient Search",I.nxtPatientSvc={methodName:"searchWithTotalRowsGrouped"},e.infiniteScroll=r.create({services:I,limit:50});var R=!1;y.all([app.checkPermission(C.PERMISSION.PATIENT_CHART),app.checkPermission(C.PERMISSION.WIDGETS_READ)]).then(function(e){R=e&&e[0]&&e[0].result&&e[1]&&e[1].result});var N=!1;function L(t){var n=e.$new();n.patient=t,u.open({templateUrl:"modules/dashboardWidgets/demographicsPlus/demographics.html",scope:n,backdrop:"static",controller:"demographicsCtrl",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html",windowClass:"nxt-large-popup"}).result.then(function(){},function(){})}e.printDemographics=function(t){N=!0,t&&(t.isAccessible?(e.isLoading=!0,o.verifyPatientMrnList(t).then(function(n){t.mrnList=n.mrnList,t.attesting&&t.attesting.mrnList.length>0&&(t.attesting.mrnList=n.attestingMrnList),t.attesting&&t.attesting.mrnList.length>0&&(t.attesting.mrnList=_.sortBy(t.attesting.mrnList,"display")),e.isLoading=!1,e.performAction(t,!0)},function(){e.isLoading=!1})):i.showModal(g.getMessageMissingAttestation(t)))};var O=!1;function M(t){A()&&(t||(e.patients=[]),e.isLoading=!0,P.nxtPatientSvc={familyName:e.search.lastName,givenName:e.search.firstName,birthDate:e.search.dob,city:e.search.city,address:e.search.street,phone:e.search.phone,postalCode:e.search.zip1?e.search.zip1+(e.zip.zip2?"-"+e.zip.zip2:""):null,state:e.search.state&&e.search.state.code?e.search.state.code:null},e.infiniteScroll.isBusy(!t,P)?e.isLoading=!1:e.infiniteScroll.nextPage(!t).then(function(n){t||(e.noResultsFound=!n||0===n.length),e.patients||(e.patients=[]);var i=[],a={};_.each(n,function(e){if(g.setPatientPermission(e),e&&e.address&&e.address.length>0&&(e.addressDisplay=s.getTextAddress(e.homeAddress||e.address[0])),e.optOutMrnList&&e.optOutMrnList.length>0){var t=_.map(e.optOutMrnList,function(e){return c.MrnSystem+"|"+e});i=i.concat(t),a[e.eid]=t}}),d.getRecentConsent({patientId:i},a,_.map(n,"eid")).then(function(i){i&&i.length&&_.each(n,function(e){_.find(i,function(t){return t&&t.patient&&t.patient.eid===e.eid})&&(e.isOptOut=!0)}),e.patients=t?e.patients.concat(g.verifyPartTwoConsent(n)):g.verifyPartTwoConsent(n),e.hasMoreData=!e.infiniteScroll.disabled,e.isLoading=!1})}))}function $(e){return"boolean"==typeof o.getCurrentPageContextProperty(e)&&o.getCurrentPageContextProperty(e)}function F(t,n){if(t&&t.attesting&&t.attesting.requestAttesting&&!$("attestationEnabled_"+t.eid)){var i=e.$new();i.patient=angular.copy(t),u.open({templateUrl:"modules/dashboardWidgets/attesting/attesting.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtAttestingCtrl",scope:i,backdrop:"static"}).result.then(function(e){t.attestationReason=e,n?L(t):U(t)},function(){})}else n?L(t):U(t)}function U(t){e.isLoading=!0,e.isSSOContext?e.$close(t):o.updateLoggedUserList(t).then(function(e){o.openPatientTab(e)},function(){e.isLoading=!1})}function V(t){if(t&&(t=k(t),t=_.isEmpty(e.sort.direction)?t:_.reverse(t),e.widgetConfig.ShowIndividualRecords))for(var n=0;n<t.length;n++)t[n]&&t[n].patients&&(t[n].patients=k(t[n].patients),t[n].patients=_.isEmpty(e.sort.direction)?t[n].patients:_.reverse(t[n].patients));return t}function k(t){switch(e.sort.field){case T.LAST_NAME:t=_.sortBy(t,"familyName");break;case T.FIRST_NAME:t=e.concatenateFirstAndMiddleNames?_.sortBy(t,["givenName","middleName"]):_.sortBy(t,"givenName");break;case T.MIDDLE_NAME:t=_.sortBy(t,"middleName");break;case T.MRN:t=_.sortBy(t,"mrn");break;case T.GENDER:t=_.sortBy(t,"gender.display");break;case T.DOB:t=_.sortBy(t,"birthDate");break;case T.AGE:t=_.orderBy(t,"Age");break;case T.ATTESTATION:t=_.sortBy(t,"attesting.display");break;case T.FACILITY:t=_.sortBy(t,"source")}return t}e.expandData=function(t){if(!e.isLoading)if(O=!0,e.expandedList[t.eid])e.expandedList[t.eid]=!1;else{if(t.patients)return void(e.expandedList[t.eid]=!0);e.isLoading=!0,o.verifyPatientMrnList(t).then(function(n){var i=n.patients;if(i.length>0){for(var a=0;a<i.length;a++)i[a].address&&i[a].address.length>0&&(i[a].addressDisplay=s.getTextAddress(i[a].homeAddress||i[a].address[0]));e.setDisplayOriginAndSource(i)}e.sort&&!_.isEmpty(e.sort.field)?t.patients=V(angular.copy(i)):t.patients=angular.copy(i),e.expandedList[t.eid]=!0,e.isLoading=!1},function(){e.expandedList[t.eid]=!0,e.isLoading=!1})}},e.expandedAdvancedSearchFields=function(){e.USStates?e.isExpandedAdvancedSearchFields=!e.isExpandedAdvancedSearchFields:(e.isLoadingUsState=!0,h.get({valueSetName:"USStates",limit:100}).then(function(t){e.USStates=t,e.isExpandedAdvancedSearchFields=!e.isExpandedAdvancedSearchFields,e.isLoadingUsState=!1},function(){e.isLoadingUsState=!1}))},e.$watch("search",function(t,n){e.isSSOContext&&t?e.searchPatients():(t&&n&&!angular.equals(t,n)&&
8(e.noResultsFound=!1),e.isZip2Enabled=t&&t.zip1&&5===t.zip1.length,e.isZip2Enabled||delete e.zip.zip2)},!0),e.searchPatients=function(){e.patients=[],e.expandedList={},A()&&(e.sort={field:"",direction:""},M())},e.getMoreData=function(){M(!0)},e.performAction=function(t,n){if(O)O=!1;else if(N)N=!1;else if(R||n)if(t&&t.isAccessible){if(e.isLoading)return;if(!t.attesting||!t.attesting.hasNoAvailableData&&t.attesting.mrnList&&0!==t.attesting.mrnList.length)if(t&&t.isOptOut&&!$("breakGlassEnabled_"+t.eid))if(v&&v.length>0)e.isLoading=!0,h.get({valueSetName:"EmergencyAccessReason",limit:1}).then(function(i){m.enableBreakGlass({patient:t,reason:i[0]}).then(function(){e.isLoading=!1,o.setCurrentPageContextProperty("breakGlassEnabled_"+t.eid,!0),F(t,n)},function(t){e.isLoading=!1})},function(){e.isLoading=!1});else{var a=e.$new();a.patient=angular.copy(t),a.isSSOContext=e.isSSOContext,u.open({templateUrl:"modules/dashboardWidgets/patientSearch/patientConsentOptOut.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtPatientConsentOptOutCtrl",scope:a,backdrop:"static"}).result.then(function(e){t.breakGlassReason=e,F(t,n)},function(){})}else F(t,n);else i.showModal(g.getMessageMissingPatientData(t))}else i.showModal(g.getMessageMissingAttestation(t))},e.sortOnClientData=function(t){e.isLoading=!0,e.sort||(e.sort={field:"",direction:""}),t!==e.sort.field?(e.sort.field=t,e.sort.direction=""):e.sort.direction=_.isEmpty(e.sort.direction)?"-":"",e.patients=V(e.patients),e.isLoading=!1},e.isFieldRequired=function(){return(e.search.firstName?1:0)+(e.search.lastName?1:0)+(e.search.dob?1:0)<S.MinRequiredFields},e.close=function(){e.$dismiss("cancel")};var B=e.$on("userConfigurationChanged",function(){!function(){if(e.search={},e.mainForm&&(e.mainForm.resetForm(),e.mainForm.dateOfBirthCtrl))var t=l(function(){e.mainForm.dateOfBirthCtrl.$dirty=!1,l.cancel(t)},1)}(),e.patients=[]});e.$on("$destroy",function(){B()})}]),app.dashboardWidgets.controller("nxtSSOPatientSearchListCtrl",["$scope","$controller","$rootScope","nxtTemplateViewSvc","gettextCatalog","nxtInfiniteScrollSvc","nxtTextSvc","nxtConsentSvc","NXT_CONSENT","NXT_IDS_CONFIG","nxtUtilsSvc","NXT_CLINICIAN_DASHBOARD_MODULE","$injector","NXT_SSO_CONFIG",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g){"use strict";t("nxtDashboardWidgetsCtrl",{scope:e,rootScope:n,$injector:p}),e.NXT_IDS_CONFIG=d,e.optOutConsentDisplay=u.ConsentOptOutText,e.ssoWidgetConfig=g.PatientSelectionDialog,e.closeDialog=g.CloseDialog;var f={LAST_NAME:"lastName",FIRST_NAME:"firstName",MRN:"mrn",GENDER:"gender",DOB:"dob",AGE:"age",ATTESTATION:"attestation"},h=[{id:"spatient-last-name-th",name:a.getString("Last name"),visible:!0,code:"last-name",sort:f.LAST_NAME,order:0},{id:"spatient-first-name-th",name:a.getString("First name"),visible:!0,code:"first-name",sort:f.FIRST_NAME,width:"15",order:1},{id:"spatient-mrn-th",name:a.getString("MRN"),visible:d.MRN.visible,code:"mrn",sort:f.MRN,width:"10",order:2},{id:"spatient-gender-th",name:a.getString("Gender"),visible:!0,code:"gender",sort:f.GENDER,width:"7",order:d.MRN.visible?3:2},{id:"spatient-dob-th",name:a.getString("DOB"),visible:!0,code:"dob",sort:f.DOB,width:"14",minWidth:"75",order:d.MRN.visible?4:3},{id:"spatient-age-th",name:a.getString("Age"),visible:!0,code:"age",sort:f.AGE,width:"5",order:d.MRN.visible?5:4},{id:"spatient-address-th",name:a.getString("Address"),visible:!0,code:"address",width:d.MRN.visible?"20":"30",order:d.MRN.visible?6:5},{id:"rviewed-attestation-th",name:a.getString("Pt Records Available"),code:"attestation",visible:!0,width:"13",sort:f.ATTESTATION,order:d.MRN.visible?7:6},{id:"rviewed-hie-consent-th",name:"",code:"consent",visible:!0,width:"7",order:d.MRN.visible?8:7}];e.headers=_.sortBy(_.filter(h,function(e){return e.visible}),"order");var m={},v={};function S(t){t||(e.patients=[]),e.isLoading=!0,m.nxtPatientSvc={familyName:e.search.lastName,givenName:e.search.firstName,birthDate:e.search.dob},e.infiniteScroll.isBusy(!t,m)||e.infiniteScroll.nextPage(!t).then(function(n){e.patients||(e.patients=[]);var i=[],a={};_.each(n,function(e){if(c.setPatientPermission(e),e&&e.address&&e.address.length>0&&(e.addressDisplay=r.getTextAddress(e.homeAddress||e.address[0])),e.optOutMrnList&&e.optOutMrnList.length>0){var t=_.map(e.optOutMrnList,function(e){return l.MrnSystem+"|"+e});i=i.concat(t),a[e.eid]=t}}),s.getRecentConsent({patientId:i},a,_.map(n,"eid")).then(function(i){i&&i.length&&_.each(n,function(e){_.find(i,function(t){return t&&t.patient&&t.patient.eid===e.eid})&&(e.isOptOut=!0)}),e.patients=t?e.patients.concat(c.verifyPartTwoConsent(n)):c.verifyPartTwoConsent(n),e.isLoading=!1})})}e.tblTitle="Patient Search",v.nxtPatientSvc={methodName:"searchWithTotalRowsGrouped"},e.infiniteScroll=o.create({services:v,limit:50,infiniteScrollEventName:"ssoPatientTblEvent"+e.$id}),e.getMoreData=function(){S(!0)},S(),e.selectPatientTab=function(t){t&&t.isAccessible?t.attesting&&t.attesting.hasNoAvailableData?i.showModal(c.getMessageMissingPatientData(t)):e.$close(t):i.showModal(c.getMessageMissingAttestation(t))},e.close=function(){e.$dismiss("cancel")},e.sortOnClientData=function(t){e.isLoading=!0,e.sort||(e.sort={field:"",direction:""}),t!==e.sort.field?(e.sort.field=t,e.sort.direction=""):e.sort.direction=_.isEmpty(e.sort.direction)?"-":"",e.patients=function(t){switch(e.sort.field){case f.LAST_NAME:t=_.sortBy(t,"familyName");break;case f.FIRST_NAME:t=_.sortBy(t,["givenName","middleName"]);break;case f.MRN:t=_.sortBy(t,"mrn");break;case f.GENDER:t=_.sortBy(t,"gender.display");break;case f.DOB:t=_.sortBy(t,"birthDate");break;case f.AGE:t=_.orderBy(t,"Age");break;case f.ATTESTATION:t=_.sortBy(t,"attesting.display")}t&&(t=_.isEmpty(e.sort.direction)?t:_.reverse(t));return t}(e.patients),e.isLoading=!1}}]),app.dashboardWidgets.controller("nxtProcedureListCtrl",["$scope","$rootScope","$controller","gettextCatalog","nxtInfiniteScrollSvc","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","CONSTANT","$injector","NXT_PROCEDURES_WIDGET",function(e,t,n,i,a,o,r,s,l,d){"use strict";n("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:l}),e.widgetConfig=d;var c=[{id:"procedure-name-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Procedure"),visible:!0,sort:"code",code:"code",order:0},{id:"procedure-date-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Date"),visible:!0,sort:"date",code:"date_start",width:e.isExpandedTable?"7":"14",minWidth:"75",order:1},{id:"procedure-provider-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Provider"),visible:e.isExpandedTable,sort:"performer",code:"performer",width:"12",order:2},{id:"procedure-source-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source"),code:"source",visible:!0,width:e.isExpandedTable?"12":"25",order:e.isExpandedTable?3:2},{id:"procedure-source-origin-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source Document"),code:"source-origin",visible:e.isExpandedTable,width:"12",order:4},{id:"procedure-status-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Status"),code:"status",visible:!1,width:"12",sort:"status",order:5},{id:"procedure-code_code-th"+(e.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Code"),code:"code_code",visible:!1,width:"12",order:6}];e.headers=_.sortBy(_.filter(e.setColumns(c),function(e){return e.visible}),"order"),e.setFilters();var u={},p={nxtProcedureSvc:{methodName:"searchWithTotalRows"}};if(e.infiniteScroll=a.create({services:p,limit:e.isExpandedTable?s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),e.currentAppContextChecked||(e.filter={description:null,performer:null},e.sort={field:"date",direction:"-"}),e.filterDates={startFrom:null,startTo:null},e.availableFilter&&_.find(e.availableFilter,function(e){return"date"===e.Code}))var g=e.$on("start"+e.prefixId+"DateFilterChangedEvent",function(t,n){e.filterDates.startFrom=null,e.filterDates.startTo=null,e.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.startTo=n.interval.endDate),e.filterDates.startIsAllInterval=n.interval.isAllFilter),e.addFilterDateKeys(n.contextKeyName),e.filter=_.extend(e.filter,{start:{from:e.filterDates.startFrom,to:e.filterDates.startTo,isAllInterval:e.filterDates.startIsAllInterval}}),t.stopPropagation()});e.$watchCollection("[mrnIds, filter.description, filterDates.startFrom,filterDates.startTo, filter.performer, filter.multipleFields]",function(){!e.filterDates.startTo&&g||(e.updateWidgetContext(),e.reloadTableData())}),e.reloadTableData=function(t,n){if(n||(e.procedures=null,e.hasMoreData=!1),e.patientContext&&e.mrnIds){if(e.waitingPatientDashboardCalls&&(delete e.waitingPatientDashboardCalls,r.PatientData[e.key]&&r.PatientData[e.key][e.code])){var i=angular.copy(r.PatientData[e.key][e.code].entries);return e.setDisplayOriginAndSource(i),e.procedures=i,e.infiniteScroll.
8setDataFromControl([r.PatientData[e.key][e.code]]),e.hasMoreData=!e.infiniteScroll.disabled,void e.setNoSearchResultsFound(u.nxtProcedureSvc,e.procedures.length)}e.loading=!0,u.nxtProcedureSvc=_.extend({mrnIds:e.mrnIds,sort:"="+e.sort.direction+e.sort.field,withNoSessionReset:t},o.getProcedureParams(e.filter)),e.infiniteScroll.isBusy(!n,u)?e.infiniteScroll.disabled&&!e.infiniteScroll.busy&&(e.loading=!1):e.infiniteScroll.nextPage(!n).then(function(t){e.procedures||(e.procedures=[]),t||(t=[]),e.setDisplayOriginAndSource(t),e.procedures=n?e.procedures.concat(t):t,e.hasMoreData=!e.infiniteScroll.disabled,e.setNoSearchResultsFound(u.nxtProcedureSvc,e.procedures.length),e.loading=!1},function(){e.loading=!1})}},e.viewProcedure=function(t){e.isViewDetailsAvailable()&&e.view(t.getText(),i.getString("View Procedure"),t.externalSources)},e.$on("$destroy",function(){g&&g()})}]),app.dashboardWidgets.controller("nxtRadiologyResultsCtrl",["$rootScope","$scope","$filter","gettextCatalog","$locale","CONSTANT","nxtInfiniteScrollSvc","$controller","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","$injector","$uibModal","NXT_RADIOLOGY_RESULTS_WIDGET",function(e,t,n,i,a,o,r,s,l,d,c,u,p){"use strict";s("nxtDashboardWidgetsCtrl",{scope:t,rootScope:e,$injector:c}),t.widgetConfig=p;var g=[{id:"rad-result-test-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Test"),visible:!0,sort:"name_text",code:"code",order:0},{id:"rad-result-date-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Date"),visible:!0,sort:"date",code:"date",width:t.isExpandedTable?"11":"22",minWidth:"110",order:1},{id:"rad-result-performer-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Ordering provider"),visible:!0,code:"ordering-provider",width:"25",order:2},{id:"rad-result-source-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source"),code:"source",visible:!0,width:"25",order:3},{id:"rad-result-source-origin-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Source Document"),code:"source-origin",visible:t.isExpandedTable,width:"12",order:4},{id:"rad-result-status-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:i.getString("Status"),visible:!1,code:"status",sort:"status",width:"7"},{id:"rad-result-selection-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:"",code:"selection-mode",visible:t.isExpandedTable,width:"5",order:5}];t.headers=_.sortBy(_.filter(t.setColumns(g),function(e){return e.visible}),"order"),t.hasPrintOptionColumn=_.find(t.headers,function(e){return"selection-mode"===e.code}),t.hasPrintOptionColumn&&(t.selectionMode=!0,t.selectedForPrintCount=0),t.setFilters(!0);var f={},h={nxtDiagnosticReportSvc:{methodName:"searchWithTotalRows"}};if(t.infiniteScroll=r.create({services:h,limit:t.isExpandedTable?o.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:o.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),t.currentAppContextChecked||(t.filter={status:o.STATUS.DIAGNOSTIC_REPORT.FINAL+","+o.STATUS.DIAGNOSTIC_REPORT.CORRECTED,serviceCategory:"RAD"},t.sort={field:"date",direction:"-"}),t.filterDates={startFrom:null,startTo:null},t.availableFilter&&_.find(t.availableFilter,function(e){return"date"===e.Code}))var m=t.$on("start"+t.prefixId+"DateFilterChangedEvent",function(e,n){t.filterDates.startFrom=null,t.filterDates.startTo=null,t.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(t.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(t.filterDates.startTo=n.interval.endDate),t.filterDates.startIsAllInterval=n.interval.isAllFilter),t.addFilterDateKeys(n.contextKeyName),t.filter=_.extend(t.filter,{start:{from:t.filterDates.startFrom,to:t.filterDates.startTo,isAllInterval:t.filterDates.startIsAllInterval}}),e.stopPropagation()});function v(e){if(e){t.setDisplayOriginAndSource(e);for(var n=0;n<e.length;n++)S(e[n])}}function S(e){e&&(e.nameDisplay=e.resultDateDisplay="",e.nameDisplay=e.code?e.code.display:"",e.effectiveDateTime?e.resultDateDisplay=n("date")(e.effectiveDateTime,a.DATETIME_FORMATS.nxtDateFormat):e.effectivePeriod&&e.effectivePeriod.start&&(e.resultDateDisplay=n("date")(e.effectivePeriod.start,a.DATETIME_FORMATS.nxtDateFormat)),e.status&&(e.statusDisplay=_.upperFirst(e.status)))}t.isExpandedTable&&t.$watch("reportSelectedItem",function(e,n){if(e||(t.reportHeader="",t.reportViewText=""),e&&!_.isEqual(_.get(e,"id",""),_.get(n,"id",""))){var i=angular.copy(t.reportSelectedItem);t.operation="view",t.viewReport(i)}},!0),t.$watchCollection("[mrnIds, filterDates.startFrom, filterDates.startTo, filter.searchText]",function(){!t.filterDates.startTo&&m||(t.updateWidgetContext(),t.reloadTableData())}),t.reloadTableData=function(e,n){if(n||(t.resultsData=null,t.hasMoreData=!1,t.isExpandedTable&&t.reportSelectedItem&&(t.operation=null,t.changeSelection(null)),t.selectedForPrintCount=0),t.patientContext&&t.mrnIds){if(t.waitingPatientDashboardCalls&&(delete t.waitingPatientDashboardCalls,d.PatientData[t.key]&&d.PatientData[t.key][t.code])){var i=angular.copy(d.PatientData[t.key][t.code].entries);
8return v(i),t.resultsData=i,t.infiniteScroll.setDataFromControl([d.PatientData[t.key][t.code]]),t.hasMoreData=!t.infiniteScroll.disabled,void t.setNoSearchResultsFound(f.nxtDiagnosticReportSvc,t.resultsData?t.resultsData.length:0)}t.loading=!0,f.nxtDiagnosticReportSvc=_.extend({mrnIds:t.mrnIds,sort:"="+t.sort.direction+t.sort.field,withNoSessionReset:e},l.getResultReportsParams(t.filter)),t.infiniteScroll.isBusy(!n,f)?t.infiniteScroll.disabled&&!t.infiniteScroll.busy&&(t.loading=!1):t.infiniteScroll.nextPage(!n).then(function(e){n||(t.resultsData=[]),v(e),t.resultsData=n?t.resultsData.concat(e):e,t.hasMoreData=!t.infiniteScroll.disabled,t.setNoSearchResultsFound(f.nxtDiagnosticReportSvc,t.resultsData?t.resultsData.length:0),t.isExpandedTable&&!n&&(t.operation=t.resultsData&&t.resultsData.length>0?"view":null,t.changeSelection(t.resultsData&&t.resultsData.length>0?t.resultsData[0]:null)),t.loading=!1},function(){t.loading=!1})}},t.selectForPrint=function(e,n,i){return e.stopPropagation(),n&&n.selectedForPrint?t.selectedForPrintCount--:t.selectedForPrintCount++,i&&(n.selectedForPrint=!n.selectedForPrint),!1},t.printReports=function(){var e;e=t.selectionMode?_.filter(t.resultsData,function(e){return e.selectedForPrint}):[t.reportSelectedItem];var n=t.$new();if(n.title="Print Radiology Results",n.reportsToPrint=e,n.reportsToPrint)for(var i=0;i<n.reportsToPrint.length;i++)n.reportsToPrint[i].typesList=t.filter.types;n.docLoading=!0,u.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:n,controller:["$scope","$uibModalInstance","nxtPrintUtilsSvc","$window",function(e,t,i,a){i.generatePdf(e.reportsToPrint).then(function(t){if(a.navigator&&a.navigator.msSaveOrOpenBlob){for(var i=atob(t),o=new Array(i.length),r=0;r<i.length;r++)o[r]=i.charCodeAt(r);var s=new Uint8Array(o),l=new Blob([s],{type:"application/pdf"});a.navigator.msSaveOrOpenBlob(l),e.close()}else e.htmlList=['<object type="application/pdf" data="data:application/pdf;base64,'+t+'" width="100%" height="100%" class="viewer"></object>'];n.docLoading=!1}),e.close=function(){t.dismiss("cancel")}}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})};var C=!1;t.viewReport=function(e){if(t.isViewDetailsAvailable()){if(!t.isExpandedTable){if(C)return;C=!0}t.isExpandedTable&&(t.selectedResultViewLoading=!0,t.reportViewText=null,t.reportHeader=null),delete t.selectedReportResource,e.typesList=[{category:"RAD",code:"RAD",display:"Radiology"}],e.getTextRadiologyResult(t.isExpandedTable?"selectedReportResource":"modalOptions.selectedReportResource").then(function(n){t.reportHeader=e&&e.code&&e.code.display?e.code.display:"",t.selectedReportResource=n?n.resource:null,t.isExpandedTable?(t.reportViewText=n.text,t.selectedResultViewLoading=!1):(C=!1,t.view(n.text,t.reportHeader,e.externalSources,t.selectedReportResource))},function(){t.selectedResultViewLoading=!1,C=!1})}},t.$on("$destroy",function(){m&&m()})}]),app.dashboardWidgets.controller("nxtRadiologyResultsViewerCtrl",["$scope","nxtUserContextSvc",function(e,t){"use strict";var n=this,i=t.getCurrentPageContextProperty("patientDashboardRadiologyResultsViewerWidgetContext_"+e.patientContext.PatientId);i&&(n.diagnosticReport=i.diagnosticReport,n.orderDetails={name:n.diagnosticReport.nameDisplay,date:n.diagnosticReport.orderDateDisplay,status:n.diagnosticReport.orderStatus},n.selectId=i.selectId)}]),app.dashboardWidgets.controller("nxtRecentlyViewedPatientsListCtrl",["$scope","$rootScope","$controller","nxtTemplateViewSvc","gettextCatalog","nxtUserContextSvc","NXT_CONSENT","nxtPatientSvc","nxtConsentSvc","$uibModal","nxtUtilsSvc","NXT_CLINICIAN_DASHBOARD_MODULE","nxtTextSvc","nxtValueSetSvc","nxtUserSvc","NXT_PART_TWO_MRN_LIST","$q","CONSTANT","NXT_DELETED_PATIENT_MESSAGE","nxtDeleteMessageBoxSvc","$injector","NXT_RECENTLY_VIEWED_PATIENTS_WIDGET",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m,v,S,C,y,b){"use strict";n("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:y});var x=b&&b.TablePageSize,D=0;x||(x=40),e.patients=[],e.optOutConsentDisplay=u.ConsentOptOutText;var T={PATIENT:"patient",DATE:"date",ATTESTATION:"attestation"},w=[{id:"rviewed-patient-th",name:a.getString("Patient"),visible:!0,code:"patient",sort:T.PATIENT,order:0},{id:"rviewed-date-th",name:a.getString("Last Viewed Date"),code:"date",visible:!0,sort:T.DATE,width:"22",minWidth:"110",order:1},{id:"rviewed-attestation-th",name:a.getString("Pt Records Available"),code:"attestation",visible:!0,sort:T.ATTESTATION,width:"13",order:2},{id:"rviewed-address-th",name:a.getString("Address"),visible:!0,code:"address",width:"20",order:3},{id:"rviewed-hie-consent-th",name:"",code:"consent",visible:!0,width:"10",order:4},{id:"rviewed-print-demographics-th",name:"Demographics",code:"print-demographics",visible:!1,width:"10"}],E=[];function P(){e.loading=!0,o.setLoggedUserList().then(function(){o.LoggedUserList&&o.LoggedUserList.entries&&o.LoggedUserList.entries.length>0&&(E=angular.copy(o.LoggedUserList.entries)),A()},function(){e.loading=!1})}e.sort={field:"date",direction:"-"},e.headers=_.sortBy(_.filter(e.setColumns(w),function(e){return e.visible}),"order");var I=!1;function A(t){if(E&&E.length>0){var n=angular.copy(E.slice(D,D+x)),i=[],a={},o=_.map(n,"item.eid");s.searchRecurrentByPatientId({patientId:o,limit:o.length}).then(function(o){for(var s=0;s<n.length;s++)if(n[s]&&n[s].item&&n[s].item.eid&&(n[s].patient=_.find(o,function(e){return e&&e.id===n[s].item.eid}),n[s].patient&&(c.setPatientPermission(n[s].patient),n[s].patient&&n[s].patient.address&&n[s].patient.address.length>0&&(n[s].patient.addressDisplay=p.getTextAddress(n[s].patient.homeAddress||n[s].patient.address[0]))),n[s].patient&&n[s].patient.optOutMrnList&&n[s].patient.optOutMrnList.length>0)){var d=_.map(n[s].patient.optOutMrnList,function(e){return r.MrnSystem+"|"+e});i=i.concat(d),a[n[s].patient.eid]=d}l.getRecentConsent({patientId:i},a,_.map(n,"patient.eid")).then(function(i){i&&i.length&&_.each(n,function(e){_.find(i,function(t){return t&&t.patient&&e.patient&&t.patient.eid===e.patient.eid})&&(e.patient.isOptOut=!0)}),e.patients=function(t){switch(e.sort.field){case T.PATIENT:t=_.sortBy(t,"item.ListDisplayName");break;case T.DATE:t=_.orderBy(t,"date");break;case T.ATTESTATION:t=_.sortBy(t,"patient.attesting.display")}t&&(t=_.isEmpty(e.sort.direction)?t:_.reverse(t));return t}(t?c.verifyPartTwoConsent(n):e.patients.concat(c.verifyPartTwoConsent(n))),D+=x,e.hasMoreData=E.length>D,e.loading=!1},function(){e.loading=!1})},function(){e.loading=!1})}else e.loading=!1}function R(e){return"boolean"==typeof o.getCurrentPageContextProperty(e)&&o.getCurrentPageContextProperty(e)}e.loading=!0,m.all([app.checkPermission(v.PERMISSION.PATIENT_CHART),app.checkPermission(v.PERMISSION.WIDGETS_READ),o.setLoggedUserList()]).then(function(e){I=e&&e[0]&&e[0].result&&e[1]&&e[1].result,P()},function(){e.loading=!1}),e.getMoreData=function(){P()};var N=!1;function L(t){var n=e.$new();n.patient=angular.copy(t),d.open({templateUrl:"modules/dashboardWidgets/demographicsPlus/demographics.html",scope:n,backdrop:"static",controller:"demographicsCtrl",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html",windowClass:"nxt-large-popup"}).result.then(function(){},function(){})}function O(t,n){if(t&&t.patient&&t.patient.attesting&&t.patient.attesting.requestAttesting&&!R("attestationEnabled_"+t.patient.eid)){var i=e.$new();i.patient=angular.copy(t.patient),d.open({templateUrl:"modules/dashboardWidgets/attesting/attesting.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtAttestingCtrl",scope:i,backdrop:"static"}).result.then(function(e){t.patient.attestationReason=e,n?L(t.patient):M(t)},function(){})}else n?L(t.patient):M(t)}function M(t){var n=t.patient||t.item;e.loading=!0,o.updateLoggedUserList(n).then(function(e){o.openPatientTab(e)},function(){e.loading=!1})}e.printDemographics=function(t){N=!0,t&&t.patient&&(t.patient.isAccessible?(e.loading=!0,o.verifyPatientMrnList(t.patient).then(function(n){t.patient.mrnList=n.mrnList,t.patient&&t.patient.attesting&&t.patient.attesting.mrnList.length>0&&(t.patient.attesting.mrnList=n.attestingMrnList),t.patient&&t.patient.attesting&&t.patient.attesting.mrnList.length>0&&(t.patient.attesting.mrnList=_.sortBy(t.patient.attesting.mrnList,"display")),e.loading=!1,e.performAction(t,!0)},function(){e.loading=!1})):i.showModal(c.getMessageMissingAttestation(t.patient||t.item)))},e.performAction=function(t,n){if(N)N=!1;else if(t&&!t.patient){var a={showCloseButton:!1,actionButtonText:"Ok",headerText:S.Header,bodyText:S.Body};C.showModal(a).then(function(){e.loading=!0,o.updateLoggedUserList(t.item,!0).then(function(){e.patients=_.filter(e.patients,function(e){return e&&e.item&&e.item.eid!==t.item.eid}),E=_.filter(E,function(e){return e&&e.item&&e.item.eid!==t.item.eid}),D--,e.loading=!1},function(){e.loading=!1})},function(){})}else if(t&&t.patient){if(!I&&!n)return;if(t.patient.isAccessible){if(e.loading)return;if(!t.patient.attesting||!t.patient.attesting.hasNoAvailableData&&t.patient.attesting.mrnList&&0!==t.patient.attesting.mrnList.length)if(t&&t.patient&&t.patient.isOptOut&&!R("breakGlassEnabled_"+t.patient.eid))if(h&&h.length>0)e.loading=!0,g.get({valueSetName:"EmergencyAccessReason",limit:1}).then(function(i){f.enableBreakGlass({patient:t.patient,reason:i[0]}).then(function(){e.loading=!1,o.setCurrentPageContextProperty("breakGlassEnabled_"+t.patient.eid,!0),O(t,n)},function(t){e.loading=!1})},function(){e.loading=!1});else{var r=e.$new(!0);r.patient=angular.copy(t.patient),d.open({templateUrl:"modules/dashboardWidgets/patientSearch/patientConsentOptOut.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtPatientConsentOptOutCtrl",scope:r,backdrop:"static"}).result.then(function(e){t.patient.breakGlassReason=e,O(t,n)},function(){})}else O(t,n);else i.showModal(c.getMessageMissingPatientData(t.patient))}else i.showModal(c.getMessageMissingAttestation(t.patient||t.item))}},e.sortOnClientData=function(t){e.loading=!0,t!==e.sort.field?(e.sort.field=t,e.sort.direction=""):e.sort.direction=_.isEmpty(e.sort.direction)?"-":"",D=0,A(!0)}}]),app.dashboardWidgets.controller("nxtResultReportsCtrl",["$rootScope","$scope","NXT_ALL_RESULTS_WIDGET","$filter","gettextCatalog","$timeout","$locale","CONSTANT","nxtInfiniteScrollSvc","$controller","$uibModal","nxtPatientDashboardParamsSvc","nxtPatientDashboardSvc","$injector","NXT_SHOW_EXPAND_DOCUMENT_LINK",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f){"use strict";d("nxtDashboardWidgetsCtrl",{scope:t,rootScope:e,$injector:g});var h=[{id:"result-report-test-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:a.getString("Test"),visible:!0,sort:"name_text",code:"code",order:0},{id:"result-report-alert-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:a.getString("Alert"),visible:t.isExpandedTable,code:"alert",width:"7",order:1},{id:"result-report-problems-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:a.getString("Type"),visible:!0,sort:"category",code:"category",width:"7",order:t.isExpandedTable?2:1},{id:"result-report-date-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:a.getString("Date"),visible:!0,sort:"date",code:"date",width:t.isExpandedTable?"11":"22",minWidth:"110",order:t.isExpandedTable?3:2},{id:"result-report-performer-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:a.getString("Provider"),visible:!0,code:"ordering-provider",width:"25",order:t.isExpandedTable?4:3},{id:"result-report-status-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:a.getString("Status"),visible:!0,code:"status",sort:"status",width:"7",order:t.isExpandedTable?5:4},{id:"result-report-source-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:a.getString("Source"),code:"source",visible:!0,width:t.isExpandedTable?"12":"25",order:t.isExpandedTable?6:5},{id:"result-report-source-origin-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:a.getString("Source Document"),code:"source-origin",visible:t.isExpandedTable,width:"12",order:7},{id:"result-report-selection-th"+(t.isExpandedTable?"-view":"")+"-tbl",name:"",code:"selection-mode",visible:t.isExpandedTable,width:"5",order:8}];t.showExpandDocumentConfig=f,t.statusList=["all","final"];var m=t.statusList[1],v=[{code:"ALL",display:"All",selected:!0}];if(n&&n.Filter&&n.Filter&&(n.Filter.Status&&(n.Filter.Status.List&&n.Filter.Status.List.length>0&&(t.statusList=angular.copy(n.Filter.Status.List)),n.Filter.Status.DefaultValue&&(m=_.find(t.statusList,function(e){return e.toLowerCase()===n.Filter.Status.DefaultValue.toLowerCase()}))),n.Filter.Type&&(n.Filter.Type.List&&n.Filter.Type.List.length>0&&(v=angular.copy(n.Filter.Type.List)),n.Filter.Type.DefaultValue&&n.Filter.Type.DefaultValue.length>0&&v.length>0))){var S=angular.copy(n.Filter.Type.DefaultValue);S||(S=[]),S.length>1&&_.find(S,function(e){return"all"===e.toLowerCase()})&&(S=_.filter(S,function(e){return"all"===e.toLowerCase()}));for(var C=0;C<v.length>0;C++)_.find(S,function(e){return e.toLowerCase()===v[C].code.toLowerCase()})&&(v[C].selected=!0)}t.headers=_.sortBy(_.filter(t.setColumns(h),function(e){return e.visible}),"order"),t.hasPrintOptionColumn=_.find(t.headers,function(e){return"selection-mode"===e.code}),t.hasPrintOptionColumn&&(t.selectionMode=!0,t.selectedForPrintCount=0);var y={},b={nxtDiagnosticReportSvc:{methodName:"searchWithTotalRows"}};if(t.infiniteScroll=l.create({services:b,limit:t.isExpandedTable?s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.VIEW:s.GENERIC.PATIENT_DASHBOARD_WIDGETS_PAGE_SIZE.SUMMARY}),t.currentAppContextChecked||(_.find(v,function(e){return e.selected})||_.each(v,function(e){"ALL"===e.code&&(e.selected=!0)}),t.filter=_.extend(m?{status:m}:{},{types:v,categories:_.map(_.filter(v,function(e){return e.selected}),"code").join(",")}),t.sort={field:"date",direction:"-"}),t.widgetConfig=n,t.setFilters(!0),t.filterDates={startFrom:null,startTo:null},t.availableFilter&&_.find(t.availableFilter,function(e){return"date"===e.Code}))var x=t.$on("start"+t.prefixId+"DateFilterChangedEvent",function(e,n){t.filterDates.startFrom=null,t.filterDates.startTo=null,t.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(t.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(t.filterDates.startTo=n.interval.endDate),t.filterDates.startIsAllInterval=n.interval.isAllFilter),t.addFilterDateKeys(n.contextKeyName),t.filter=_.extend(t.filter,{start:{from:t.filterDates.startFrom,to:t.filterDates.startTo,isAllInterval:t.filterDates.startIsAllInterval}}),e.stopPropagation()});function D(e){if(e){t.setDisplayOriginAndSource(e);for(var n=0;n<e.length;n++)T(e[n])}}function T(e){e&&(e.nameDisplay=e.resultDateDisplay="",e.nameDisplay=e.code?e.code.display:"",e.interpretationAlert&&(e.alertDisplay=_.upperFirst(e.interpretationAlert)),e.effectiveDateTime?e.resultDateDisplay=i("date")(e.effectiveDateTime,r.DATETIME_FORMATS.nxtDateFormat):e.effectivePeriod&&e.effectivePeriod.start&&(e.resultDateDisplay=i("date")(e.effectivePeriod.start,r.DATETIME_FORMATS.nxtDateFormat)),e.status&&(e.statusDisplay=_.upperFirst(e.status)),e.serviceCategory&&(e.serviceCategoryDisplay=function(e){if(!e)return null;var n=e.toUpperCase();
8t.filter&&t.filter.types&&t.filter.types.forEach(function(e){e.code&&_.find(e.code.split(","),function(e){return e.toUpperCase()===n})&&(n=e.display)});return n}(e.serviceCategory.code)||e.serviceCategory.display))}t.isExpandedTable&&(t.$watch("reportSelectedItem",function(e,n){if(e||(t.reportHeader="",t.reportViewText=""),e&&!_.isEqual(_.get(e,"id",""),_.get(n,"id",""))){var i=angular.copy(t.reportSelectedItem);t.operation="view",t.viewReport(i)}},!0),t.toggleTypeButton=function(e){e&&("ALL"===e?_.each(t.filter.types,function(e){e.selected=!1}):_.each(t.filter.types,function(t){t.code===e&&(t.selected=!t.selected),"ALL"===t.code&&(t.selected=!1)}),_.find(t.filter.types,function(e){return e.selected})||_.each(t.filter.types,function(e){"ALL"===e.code&&(e.selected=!0)}),t.filter.categories=_.map(_.filter(t.filter.types,function(e){return e.selected}),"code").join(","))}),t.$watchCollection("[mrnIds, filterDates.startFrom, filterDates.startTo, filter.status, filter.categories, filter.multipleFields]",function(){t.filter&&t.filter.types&&_.find(t.filter.types,function(e){return e.selected&&("ALL"===e.code||"OTHER"===e.category||"LAB"===e.category)})?t.placeholderMultipleFields="Search For Report or Lab Test":t.placeholderMultipleFields="Search For Report",!t.filterDates.startTo&&x||(t.updateWidgetContext(),t.reloadTableData())}),t.reloadTableData=function(e,n){if(n||(t.resultsData=null,t.hasMoreData=!1,t.isExpandedTable&&t.reportSelectedItem&&(t.operation=null,t.changeSelection(null)),t.selectedForPrintCount=0),t.patientContext&&t.mrnIds){if(t.waitingPatientDashboardCalls&&(delete t.waitingPatientDashboardCalls,p.PatientData[t.key]&&p.PatientData[t.key][t.code])){var i=angular.copy(p.PatientData[t.key][t.code].entries);return D(i),t.resultsData=i,t.infiniteScroll.setDataFromControl([p.PatientData[t.key][t.code]]),t.hasMoreData=!t.infiniteScroll.disabled,void t.setNoSearchResultsFound(y.nxtDiagnosticReportSvc,t.resultsData?t.resultsData.length:0)}t.loading=!0,y.nxtDiagnosticReportSvc=_.extend({mrnIds:t.mrnIds,sort:"="+t.sort.direction+t.sort.field,withNoSessionReset:e},u.getResultReportsParams(t.filter)),t.infiniteScroll.isBusy(!n,y)?t.infiniteScroll.disabled&&!t.infiniteScroll.busy&&(t.loading=!1):t.infiniteScroll.nextPage(!n).then(function(e){n||(t.resultsData=[]),D(e),t.resultsData=n?t.resultsData.concat(e):e,t.hasMoreData=!t.infiniteScroll.disabled,t.setNoSearchResultsFound(y.nxtDiagnosticReportSvc,t.resultsData?t.resultsData.length:0),t.isExpandedTable&&!n&&(t.operation=t.resultsData&&t.resultsData.length>0?"view":null,t.changeSelection(t.resultsData&&t.resultsData.length>0?t.resultsData[0]:null)),t.loading=!1},function(){t.loading=!1})}},t.expandDocument=function(){var n=angular.copy(t.reportViewText);n.indexOf('nxt-document-viewer="')>0&&t.isExpandedTable&&(n=n.replace('nxt-document-viewer="','nxt-document-viewer="modalOptions.')),t.view(n,t.reportHeader,t.reportSelectedItem.externalSources,t.selectedReportResource,{windowClass:e.showVerbiage?"nxt-full-popup-with-verbiage":"nxt-full-popup"},!0)};var w=!1;t.viewReport=function(e){if(t.isViewDetailsAvailable()){if(t.isExpandedTable&&(t.selectedResultViewLoading=!0,t.reportViewText=null,t.reportHeader=null,t.hasIframeElement=!1),!t.isExpandedTable){if(w)return;w=!0}delete t.selectedReportResource,e.typesList=t.filter.types,e.getTextResultReport(t.isExpandedTable?"selectedReportResource":"modalOptions.selectedReportResource").then(function(n){t.reportHeader=e&&e.code&&e.code.display?e.code.display:"",t.selectedReportResource=n?n.resource:null,t.reportViewText=n.text,t.isExpandedTable?(t.selectedResultViewLoading=!1,t.reportViewText.indexOf('nxt-document-viewer="')>0&&t.selectedReportResource&&t.selectedReportResource.result&&t.selectedReportResource.result[0]&&t.selectedReportResource.result[0].valueAttachment&&t.selectedReportResource.result[0].valueAttachment.docViewerHtml&&t.selectedReportResource.result[0].valueAttachment.docViewerHtml.indexOf("iframe")>0&&(t.hasIframeElement=!0)):(w=!1,t.reportSelectedItem=angular.copy(e),t.expandDocument())},function(){w=!1,t.selectedResultViewLoading=!1})}},t.selectForPrint=function(e,n,i){return e.stopPropagation(),n&&n.selectedForPrint?t.selectedForPrintCount--:t.selectedForPrintCount++,i&&(n.selectedForPrint=!n.selectedForPrint),!1},t.printReports=function(){var e;e=t.selectionMode?_.filter(t.resultsData,function(e){return e.selectedForPrint}):[t.reportSelectedItem];var n=t.$new();if(n.title="Print Results",n.reportsToPrint=e,n.reportsToPrint)for(var i=0;i<n.reportsToPrint.length;i++)n.reportsToPrint[i].typesList=t.filter.types;n.docLoading=!0,c.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:n,controller:["$scope","$uibModalInstance","nxtPrintUtilsSvc","$window",function(e,t,i,a){i.generatePdf(e.reportsToPrint).then(function(t){if(a.navigator&&a.navigator.msSaveOrOpenBlob){for(var i=atob(t),o=new Array(i.length),r=0;r<i.length;r++)o[r]=i.charCodeAt(r);var s=new Uint8Array(o),l=new Blob([s],{type:"application/pdf"});a.navigator.msSaveOrOpenBlob(l),e.close()}else e.htmlList=['<object type="application/pdf" data="data:application/pdf;base64,'+t+'" width="100%" height="100%" class="viewer"></object>'];n.docLoading=!1}),e.close=function(){t.dismiss("cancel")}}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})},t.toggleSelectionMode=function(){t.selectionMode=!t.selectionMode,t.selectionMode?t.reportSelectedItem&&(_.each(t.resultsData,function(e){e.id!==t.reportSelectedItem.id&&e.selectedForPrint&&delete e.selectedForPrint,e.id===t.reportSelectedItem.id&&(e.selectedForPrint=!0)}),t.selectedForPrintCount++):(_.map(t.resultsData,function(e){delete e.selectedForPrint}),t.selectedForPrintCount=0)},t.$on("$destroy",function(){x&&x()})}]),app.dashboardWidgets.controller("nxtVitalSignListCtrl",["gettext","$scope","$rootScope","$controller","gettextCatalog","nxtObservationSvc","nxtUserContextSvc","nxtConversionsSvc","nxtUtilsSvc","CONSTANT","nxtTextSvc","NXT_EXPANDED_VITAL_SIGNS_COLUMNS","$filter","$locale","nxtPatientDashboardSvc","$injector","NXT_VITAL_SIGNS_WIDGET",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m){"use strict";if(i("nxtDashboardWidgetsCtrl",{scope:t,rootScope:n,$injector:h}),t.widgetConfig=m,t.vitalSignsTypes=l.allVitalSignsTypes,t.isExpandedTable){if(t.currentAppContextChecked||(t.filter={pagination:{page:1,pageSize:10}}),t.filterDates={start:null,end:null},t.setFilters(),t.availableFilter&&_.find(t.availableFilter,function(e){return"date"===e.Code}))var v=t.$on("start"+t.prefixId+"DateFilterChangedEvent",function(e,n){t.filterDates.start=null,t.filterDates.end=null,t.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(t.filterDates.start=n.interval.startDate),n.interval.endDate&&(t.filterDates.end=n.interval.endDate),t.filterDates.startIsAllInterval=n.interval.isAllFilter),t.addFilterDateKeys(n.contextKeyName),t.filter.filterDates=t.filterDates,e.stopPropagation()});t.$watchCollection("[mrnIds, filter.pagination.page, filterDates.start, filterDates.end]",function(e,n){!t.filterDates.end&&v||(n&&e[1]>1&&n[1]===e[1]?t.filter.pagination.page=1:(t.updateWidgetContext(),t.reloadTableData()))})}else{if(t.isSimpleView=function(e){e||(e=r.LoggedUserConfiguration.patientDashboardConfig);for(var t=0;t<e.length;t++)if(_.find(e[t],function(e){return"pacVitalS"===e.code&&"simple"===e.type}))return!0;return!1}(),t.isSimpleView){var S=[{code:"vital",name:a.getString("Vital sign"),visible:!0,order:0},{code:"interpretation",name:a.getString("Interpretation"),visible:!0,order:1},{name:a.getString("Value"),visible:!0,code:"value",order:2},{name:a.getString("Elapsed Time"),visible:!0,code:"date",order:3}],C=t.setColumns(S);t.separtorClass="column_"+_.filter(C,function(e){return e.visible}).length;for(var y=[],b=1;b<=2;b++){var x=1===b?"first":"second";for(let e=0;e<C.length;e++){var D={id:C[e].code+"-"+x+"-th",visible:C[e].visible,code:C[e].code+"-"+x,order:1*parseInt(C[e].order)+(1===b?0:C.length),name:C[e].name};switch(C[e].code){case"vital":D.class="text-right pad-right-5";break;case"interpretation":D.width="10";break;case"value":D.width="20";break;case"date":D.width="10",D.class="text-right"}y.push(D)}}t.headers=_.sortBy(_.filter(y,function(e){return e.visible}),"order")}else t.headers=t.setColumns([{id:"vital-name-th",name:a.getString("Vital sign"),visible:!0,code:"vital",class:"text-right pad-right-5",order:0},{id:"vital-interpretation-th",name:a.getString("Interpretation"),visible:!0,width:"10",code:"interpretation",order:1},{id:"vital-value-h",name:a.getString("Value"),visible:!0,width:"40",code:"value",order:2},{id:"vital-sparkline-th",name:a.getString("Trendline"),visible:!0,width:"20",code:"sparkline",order:3},{id:"vital-date-th",name:a.getString("Elapsed Time"),visible:!0,width:"10",class:"text-righ",code:"date",order:4}]);t.$watch("mrnIds",function(){t.updateWidgetContext(),t.reloadTableData()})}function T(e){for(var n,i,a,o=[],r=0;r<t.vitalSignsTypes.length;r++)i=null,a=null,(n=$.grep(e,function(e){return e.name.code===t.vitalSignsTypes[r].code}))&&n.length>0&&(i=w(n)),t.vitalSignsTypes[r].code===d.CONCEPT.LOINC.SYSTOLIC_BLOOD_PRESSURE.code&&i&&(a=w(n=$.grep(e,function(e){return e.name.code===t.vitalSignsTypes[r].secondCode})),i.siblingObs=a,i.sparkLineData.push(a.sparkLineData[0])),i?(i.displayInterpretation=I(i?a?[i,a]:[i]:null),i.displayValue=A(i?a?[i,a]:[i]:null,!0),i.displayTime=P(i?[i]:null),i.tooltip=c.getVitalSignsParamsText(a?[i,a]:[i])):i={id:r},i.displayName=t.vitalSignsTypes[r].display,o.push(i);return o&&o.length>0?o:null}function w(e){var t,n,i,a,o,r;if(e.sort(function(e,t){return e.issued>t.issued?1:e.issued<t.issued?-1:0}),(n=e[e.length-1].valueQuantity?s.ConvertObservation(e[e.length-1],!0):e[e.length-1]).valueString&&(n.valueQuantity={value:parseInt(n.valueString)}),n.valueDateTime)return n;if(!n.valueQuantity)return null;if(t=$.grep(e,function(e){return e.id!==n.id}),n.referenceRange&&n.referenceRange.length>0&&(i=n.referenceRange[0].low?n.referenceRange[0].low.value:null,a=n.referenceRange[0].high?n.referenceRange[0].high.value:null),o=[{value:n.valueQuantity.value,range:{low:i,high:a}}],t&&t.length>0)for(let e=0;e<t.length;e++)(r=t[e].valueQuantity?s.ConvertObservation(t[e],!0):t[e]).valueString&&(r.valueQuantity={value:parseInt(r.valueString)}),i=null,a=null,r.referenceRange&&r.referenceRange.length>0&&(i=r.referenceRange[0].low?r.referenceRange[0].low.value:null,a=r.referenceRange[0].high?r.referenceRange[0].high.value:null),o.unshift({value:r.valueQuantity.value,range:{low:i,high:a}});return n.sparkLineData=[o],n}function E(e){var n,i=null,a=null,o=[],r=[],s=0;n=Math.round(t.vitalSignsTypes.length/2);for(var l=0;l<t.vitalSignsTypes.length;l++){i=null;var u=$.grep(e,function(e){return e.name.code===t.vitalSignsTypes[l].code});u&&u.length>0&&(u.sort(function(e,t){return e.issued>t.issued?-1:e.issued<t.issued?1:0}),i=u[0]),o.push(i),t.vitalSignsTypes[l].code===d.CONCEPT.LOINC.SYSTOLIC_BLOOD_PRESSURE.code&&i&&(a=_.find(e,function(e){return e.name.code===t.vitalSignsTypes[l].secondCode&&e.issued.getTime()===i.issued.getTime()}),o.push(a)),l<n?(r.push({id:l,$isFirstSelected:!1,$isSecondSelected:!1,firstColName:t.vitalSignsTypes[l].display,firstColObsList:i?o:null,firstColCode:t.vitalSignsTypes[l].code,firstColInterpretation:I(i?o:null),firstColVSValue:A(i?o:null,!0),firstColTimeDisplay:P(i?o:null),firstColTooltip:c.getVitalSignsParamsText(i?o:null)}),t.vitalSignsTypes[l].secondCode&&(r[r.length-1].firstColSecondCode=t.vitalSignsTypes[l].secondCode)):(r[s].secondColName=t.vitalSignsTypes[l].display,r[s].secondColCode=t.vitalSignsTypes[l].code,r[s].secondColObsList=i?o:null,r[s].secondColInterpretation=I(i?o:null),r[s].secondColVSValue=A(i?o:null,!0),r[s].secondColTimeDisplay=P(i?o:null),r[s].secondColTooltip=c.getVitalSignsParamsText(i?o:null),t.vitalSignsTypes[l].secondCode&&(r[s].secondColSecondCode=t.vitalSignsTypes[l].secondCode),s++),o=[]}return r&&r.length>0?r:null}function P(e){if(!e)return null;return e&&e.length>0?l.getLos(e[0].issued,new Date):""}function I(e){if(e)return l.getHTMLInterpretation(e)}function A(e,t){if(e)return l.getVSValue(e,t)}t.reloadTableData=function(e){if(t.vitalSignsData=null,t.patientContext&&t.mrnIds){if(t.patientContext.Patient&&t.patientContext.Patient.gender&&"female"!==t.patientContext.Patient.gender.code&&(t.vitalSignsTypes=$.grep(l.allVitalSignsTypes,function(e){return e.code!==d.CONCEPT.LOINC.LMP.code})),t.waitingPatientDashboardCalls&&(delete t.waitingPatientDashboardCalls,f.PatientData[t.key]&&f.PatientData[t.key][t.code])){var n=angular.copy(f.PatientData[t.key][t.code]);return t.vitalSignsData=t.isSimpleView?E(n):T(n),void t.setNoSearchResultsFound(null,n&&n.length)}var i;t.loading=!0,t.isExpandedTable?(i={mrnIds:t.mrnIds,patientBirthDate:t.patientContext.Patient.birthDate},t.filterDates&&!t.filterDates.startIsAllInterval&&(i.filterDates=t.filterDates),o.getVitalSignsByIssuedDate(t.mrnIds,t.patientContext.Patient.birthDate,null,t.filterDates&&!t.filterDates.startIsAllInterval?t.filterDates:null,u,t.filter.pagination.page,e).then(function(e){!function(e,n,i,a){var o,r=null,s=null,d=null,c=null,f=[],h=[],m={},v=!1,S=null;if(f.push({title:"",field:"name",className:n?"th-fixed-width-50":""}),n){for(var C=0;C<n.length;C++){o="<div> "+p("date")(n[C],g.DATETIME_FORMATS.nxtDateFormatNoHours)+"<br/>"+p("date")(n[C],"hh:mm a")+"</div>",f.push({title:o,field:"value"+C,date:n[C],className:"div-max-class"}),S=n[C].getTime();for(let e=0;e<t.vitalSignsTypes.length;e++)r=_.find(i,function(n){return n.name.code===t.vitalSignsTypes[e].code&&n.issued.getTime()===S}),s=[r],c=l.getExpandedValue(r),t.vitalSignsTypes[e].secondCode&&(d=_.find(i,function(n){return n.name.code===t.vitalSignsTypes[e].secondCode&&n.issued.getTime()===S}
8),c=c?c+"/"+l.getExpandedValue(d):null,s.push(d)),v?(h[e]["value"+C]=c,h[e]["observation"+(C+1)]=s):((m={}).name='<span class="bold black_lvl_four">'+t.vitalSignsTypes[e].display+"</span>",m["value"+C]=c,m["observation"+(C+1)]=s,h.push(m));v=!0}t.filter.pagination.totalResults=a}else{for(let e=0;e<t.vitalSignsTypes.length;e++)(m={}).name='<span class="bold black_lvl_four">'+t.vitalSignsTypes[e].display+"</span>",m.value0=null,m.observation1=null,h.push(m);t.filter.pagination.totalResults=0}f.length-1!==u&&f.push({title:"",field:""});t.sources={columns:f,data:h}}(e.results,e.headers,e.vitalSigns,e.totalResults),t.setNoSearchResultsFound(i,e.totalResults),t.loading=!1})):(i={mrnIds:t.mrnIds,patientBirthDate:t.patientContext.Patient.birthDate,withNoSessionReset:e},o.getVitalSignsLatest(i).then(function(e){t.vitalSignsData=t.isSimpleView?E(e&&e.length>0?e:[]):T(e&&e.length>0?e:[]),t.setNoSearchResultsFound(i,t.vitalSignsData&&t.vitalSignsData.length),t.loading=!1},function(){t.loading=!1}))}},t.viewVitalSign=function(e,n){if(e){var i;if(t.isSimpleView?i=function(e,n,i){return t.isExpandedTable||t.isSimpleView?!e||e.length<1?null:1===(n>0?n:e[0].$isFirstSelected?1:2)?e[0].firstColObsList&&e[0].firstColObsList.length>0?!0===i?e[0].firstColObsList:e[0].firstColObsList[0]:null:e[0].secondColObsList&&e[0].secondColObsList.length>0?!0===i?e[0].secondColObsList:e[0].secondColObsList[0]:null:e[0]}(e,n,!0):(i=[e[0]],e[0].name.code===d.CONCEPT.LOINC.SYSTOLIC_BLOOD_PRESSURE.code&&i.push(e[0].siblingObs)),!i)return null;t.view(i[0].getTextVitalSign(i&&i.length>1?i[1]:null),a.getString("View Vital Sign"),i[0].externalSources)}},t.openGraphView=function(){r.openSubtabByCode(t,d.GENERIC.EXPANDED_VIEWS.GRAPHS.code),t.activeTab.code=d.GENERIC.EXPANDED_VIEWS.GRAPHS.code},t.actions=[d.ACTION.GRAPH.get({command:t.openGraphView,permission:d.PERMISSION.SUBTABS.GRAPHS,hideOnNoPermission:!0})];var R=t.$on("changeColumnSelection",function(e,n){var i=_.filter(n,function(e){return!_.isNil(e)});i&&i.length>0&&t.view(i[0].getTextVitalSign(i&&i.length>1?i[1]:null),a.getString("View Vital Sign"),i[0].externalSources)});t.$on("$destroy",function(){R(),v&&v()})}]),app.ui.dashboards.directive("nxtPatientBanner",["gettextCatalog","$uibModal","nxtTextSvc","nxtTemplateViewSvc","$filter","nxtUtilsSvc","$locale","nxtBinarySvc","$rootScope","nxtUserContextSvc","CONSTANT","$q","nxtCoverageSvc","NXT_IDS_CONFIG","NXT_PATIENT_BAR","nxtMessageHeaderSvc","NXT_INSURANCE",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m){"use strict";return{restrict:"AE",templateUrl:"modules/dashboards/banner/patientBanner.html",scope:!0,link:function(v,S){v.NXT_IDS_CONFIG=g,v.patientBarConfig=f,v.classes={},v.userConfiguration=angular.copy(d.LoggedUserConfiguration),v.$watch("patientContext.Patient",function(e){v.patient=e,v.patient&&(v.patient.nameDisplay=v.patient.DisplayName,(v.patient.gender&&v.patient.gender.code||v.patient.Age)&&(v.patient.nameDisplay+=" (",v.patient.gender&&v.patient.gender.code&&(v.patient.nameDisplay+=_.toUpper(v.patient.gender.code[0]),v.patient.Age&&(v.patient.nameDisplay+=", ")),v.patient.Age&&(v.patient.nameDisplay+=v.patient.Age),v.patient.nameDisplay+=")"),v.patient.birthDate?v.patient.birthDateDisplay=a("date")(v.patient.birthDate,r.DATETIME_FORMATS.nxtDateFormatNoHours):v.patient.birthDateDisplay="",v.patient.address&&v.patient.address[0]&&(v.patient.addressDisplay=n.getTextAddress(v.patient.homeAddress||v.patient.address[0])),(v.patient.isDeceased||v.patient.deceased)&&(v.patient.deceasedDisplay="Death date: "+(v.patient.deceased?a("date")(v.patient.deceased,r.DATETIME_FORMATS.nxtDateFormatNoHours):"unspecified")),v.patient.phonesDisplay={},v.patient.phonesDisplay.Mobile="",v.patient.phonesDisplay.Home="",v.patient.phonesDisplay.Work="",v.patient.phones&&v.patient.phones.length>0&&(v.patient.phonesDisplay.Mobile=_.map(_.filter(v.patient.phones,function(e){return"mobile"===e.use}),"value").join("; "),v.patient.phonesDisplay.Home=_.map(_.filter(v.patient.phones,function(e){return"home"===e.use}),"value").join("; "),v.patient.phonesDisplay.Work=_.map(_.filter(v.patient.phones,function(e){return"work"===e.use}),"value").join("; "))),function(){var e=u.defer(),t=[c.PERMISSION.PATIENT_BANNER.ADDRESS,c.PERMISSION.PATIENT_BANNER.INSURANCE,c.PERMISSION.PATIENT_BANNER.PRINT_CHART];v.patientBarConfig&&v.patientBarConfig.ShowNextOfKin&&t.push(c.PERMISSION.PATIENT_BANNER.NEXT_OF_KIN);return app.checkPermission(t).then(function(t){t||(t=[]),v.patientBarConfig&&v.patientBarConfig.ShowNextOfKin&&(C=v.showPatientNextOfkin=!!_.find(t,function(e){return e&&e.action===c.PERMISSION.PATIENT_BANNER.NEXT_OF_KIN&&!0===e.result}
8)),y=v.showPatientAddress=!!_.find(t,function(e){return e&&e.action===c.PERMISSION.PATIENT_BANNER.ADDRESS&&!0===e.result}),b=v.showPatientInsurance=!!_.find(t,function(e){return e&&e.action===c.PERMISSION.PATIENT_BANNER.INSURANCE&&!0===e.result}),x=v.showPatientPrintChart=!!_.find(t,function(e){return e&&e.action===c.PERMISSION.PATIENT_BANNER.PRINT_CHART&&!0===e.result}),e.resolve()}),e.promise}().then(function(){T(),v.hasImage=v.patient&&v.patient.photo&&v.patient.photo.data,w()})});var C,y,b,x,D=l.$on("onUserConfigurationChanged",function(e){v.userConfiguration=angular.copy(d.LoggedUserConfiguration),T(),w()});function T(){if(d.LoggedUserConfiguration){v.showPatientNextOfkin=C,v.showPatientAddress=y,v.showPatientInsurance=b,v.showPatientPrintChart=x,v.classes={},v.classes.patDemographics="col-xs-12";var e=d.LoggedUserConfiguration.patientBannerConfig;if(e&&e.length>0){for(var t=e.length-1;t>=0;t--)switch(e[t].code){case"patBannerAddress":v.showPatientAddress||e.splice(t,1);break;case"patBannerInsurance":v.showPatientInsurance||e.splice(t,1);break;case"patBannerNextOfKin":v.showPatientNextOfkin||e.splice(t,1);break;case"patPrintChart":v.showPatientPrintChart||e.splice(t,1)}C&&!_.find(e,function(e){return"patBannerNextOfKin"===e.code})&&(v.showPatientNextOfkin=!1),y&&!_.find(e,function(e){return"patBannerAddress"===e.code})&&(v.showPatientAddress=!1),b&&!_.find(e,function(e){return"patBannerInsurance"===e.code})&&(v.showPatientInsurance=!1),x&&!_.find(e,function(e){return"patPrintChart"===e.code})&&(v.showPatientPrintChart=!1)}else v.showPatientNextOfkin=!1,v.showPatientAddress=!1,v.showPatientInsurance=!1,v.showPatientPrintChart=!1;if(v.patientBannerVisibleList=e,v.patientBannerVisibleList&&v.patientBannerVisibleList.length>0){var n,i,a=v.patientBannerVisibleList.length+1;v.showPatientPrintChart?(n=Math.floor(11/(a-1)),i=11%(a-1)):(n=Math.floor(12/a),i=12%a),v.classes.patDemographics="col-xs-"+(n+(i>0?1:0)),i>0&&i--;for(let e=0;e<v.patientBannerVisibleList.length;e++)"patPrintChart"!==v.patientBannerVisibleList[e].code?"patBannerViewEHXInitiator"!==v.patientBannerVisibleList[e].code?(v.classes[v.patientBannerVisibleList[e].code]="col-xs-"+(n+(i>0?1:0)),i>0&&i--):v.classes[v.patientBannerVisibleList[e].code]="col-xs-2":v.classes[v.patientBannerVisibleList[e].code]="col-xs-1"}}}function w(e){var t=[];if(v.showPatientInsurance&&o.hasBannerInformation("patBannerInsurance")){var n=o.getMrnIds(v.patient.mrnList);_.isEmpty(n)||(v.userConfiguration&&(m&&m.ShowInsurancesAttachedToLatestADTMessage?t.push(h.search({mrnIds:n,messageType:"ADT",withNoSessionReset:null,limit:1,sort:"=-timestamp,-sequence_number"})):t.push(p.search({mrnIds:n,withNoSessionReset:null,limit:3,includePayor:!0,sort:"=-period_start"}))),u.all(t).then(function(e){if(t=[],m&&m.ShowInsurancesAttachedToLatestADTMessage){var i=[];e[0]&&e[0][0]&&e[0][0].parsedContent&&(i=_.filter(e[0][0].parsedContent,function(e){return e&&e.reference&&-1!==e.reference.indexOf("Coverage")})),i&&i.length>0&&t.push(p.search({mrnIds:n,ids:_.map(i,"reference").join(","),withNoSessionReset:null,limit:i.length,includePayor:!0,sort:"=-period_start"}))}u.all(t).then(function(t){E(m&&m.ShowInsurancesAttachedToLatestADTMessage?t[0]:e[0])})}))}}function E(e){v.patientInsurances=[],e&&e.length>0&&(v.patientInsurances=e&&e.length>4?_.orderBy(e,["order"],["asc"]).slice(0,3):e||[])}v.demographicsPlus=function(){var e=v.$new();e.patient=v.patient,t.open({templateUrl:"modules/dashboardWidgets/demographicsPlus/demographics.html",scope:e,backdrop:"static",controller:"demographicsCtrl",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",windowClass:"nxt-large-popup"}).result.then(function(){},function(){})},v.viewPatient=function(){var t={closeButtonText:e.getString("Close"),headerText:e.getString("View patient"),bodyText:v.patient.getText()};i.showModal(t)},v.viewAddress=function(){var t={closeButtonText:e.getString("Close"),headerText:e.getString("View address"),bodyText:v.patient.getAddressText()};i.showModal(t)},v.viewInsurance=function(t){if(t){var n={closeButtonText:e.getString("Close"),headerText:e.getString("View insurance"),bodyText:t.getText()};i.showModal(n)}},v.viewEHXInitiator=function(){d.openSubtabByCode(v,c.GENERIC.EXPANDED_VIEWS.EHX.code)},v.onPatientPhotoClick=function(){v.hasImage&&(v.patient.photo.url?s.get(v.patient.photo.url,{responseType:"arraybuffer"}).then(function(e){o.getPhoto(e,!0)}):(v.patient.photo.display='<img ng-src="'+v.patient.photo.data+'"/>',o.getPhoto(v.patient.photo.display)))},v.printChart=function(){var e=v.$new();t.open({templateUrl:"modules/dashboards/banner/printPatientRecord.html",scope:e,backdrop:"static",controller:"nxtPrintPatientRecordCtrl",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html",windowClass:"nxt-light-popup"}).result.then(function(){},function(){})};var P=l.$on("reloadPatientInsurances",function(e,t){E(t)});v.$on("$destroy",function(){D(),P()})}}}]),app.ui.dashboards.controller("nxtPrintPatientRecordCtrl",["$scope","$uibModal","nxtPatientDashboardPrintSvc","$window","$log",function(e,t,n,i,a){"use strict";e.interval={},e.print=function(){var o=e.$new();o.title="Print Clinical Data",t.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:o,controller:["$scope","$uibModalInstance",function(t,o){t.docLoading=!0,n.generatePatientChartPdf(e.interval).then(function(e){if(i.navigator&&i.navigator.msSaveOrOpenBlob)i.navigator.msSaveOrOpenBlob(e),t.close();else{a.log("Show Pdf -"+new Date);var n=URL.createObjectURL(e);t.htmlList=['<iframe src="{{0}}"  type="{{1}}" width="100%" height="100%" class="viewer"></iframe>'.replace("{{0}}",n).replace(/\{\{1\}\}/g,"application/pdf")]}},function(){e.docLoading=!1}),t.close=function(){o.dismiss("cancel")};var r=t.$on("onLoaded",function(e){t.docLoading=!1});t.$on("$destroy",function(){r&&r()})}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})},e.close=function(){e.$dismiss("cancel")}}]),app.ui.dashboards.config(["gettext",function(e){"use strict";app.ui.dashboards.link={url:"/dashboards",name:e("Patient Charts"),code:"dashboards"},app.routes.add("/dashboards/:sso/:mrn/:firstName/:lastName/:dob",e("Patient Charts"),{templateUrl:"modules/dashboards/index.html"}),app.routes.add("/dashboards/:sso/:token/",e("Patient Charts"),{templateUrl:"modules/dashboards/index.html"})}]),app.ui.dashboards.controller("nxtMainDashboardCtrl",["$scope","nxtUserContextSvc","$routeParams","nxtUtilsSvc","NXT_PATIENT_RESULTS_QUERY_TAB","jwtHelper","NXT_SSO_CONFIG",function(e,t,n,i,a,o,r){"use strict";e.wrongParameters=!1,e.checkPatientResultsQueryPermission=a.Visible,e.wrongParametersMsg=r.MissingPatientParamsMsg;var s={},l=n&&i.hasPropertyName(n,"sso")&&(i.hasPropertyName(n,"mrn")&&i.hasPropertyName(n,"firstname")&&i.hasPropertyName(n,"lastname")&&i.hasPropertyName(n,"dob")||i.hasPropertyName(n,"token"));if(_.isEmpty(n))e.isSSO=l;else if(l){if(e.isSSO=l,e.routeParams={},c(n),n.token){var d=o.decodeToken(n.token);d&&(s.clinicianFirstName=d.clinicianFirstName,s.clinicianLastName=d.clinicianLastName,s.clinicianIdentifier=d.clinicianIdentifier,d.patientContext&&i.hasPropertyName(d.patientContext,"mrn")&&i.hasPropertyName(d.patientContext,"firstname")&&i.hasPropertyName(d.patientContext,"lastname")&&i.hasPropertyName(d.patientContext,"dob")&&c(d.patientContext))}e.wrongParameters=!(e.routeParams.mrn&&e.routeParams.firstname&&e.routeParams.lastname&&e.routeParams.dob),e.wrongParameters&&delete e.routeParams}else e.wrongParameters=!0;function c(t){t.mrn&&(e.routeParams.mrn=t.mrn),t.firstname&&(e.routeParams.firstname=t.firstname),t.lastname&&(e.routeParams.lastname=t.lastname),t.dob&&(e.routeParams.dob=t.dob)}t.setCurrentPageContextProperty("SSODashboardContext",e.isSSO),e.isSSO&&!_.isEmpty(s)&&t.setCurrentPageContextProperty("SSOClinicianDashboardContext",s)}]),app.ui.dashboards.controller("nxtDashboardsCtrl",["$scope","$rootScope","$injector","nxtUserContextSvc","nxtPatientDashboardSvc","$controller",function(e,t,n,i,a,o){"use strict";i.setCurrentPageContextProperty("patientChartsContext",!0),o("nxtSourcesDashboardCtrl",{scope:e}),function(){if(e.currentPageContextChecked)return;var t=i.getCurrentPageContextProperty("patientChartsTabsContext");t&&t.selectedTabId&&i.setSelectedModuleTab(t.selectedTabId,"dashboards");e.currentPageContextChecked=!0}(),e.tabSelected=function(e){i.setCurrentPageContextProperty("patientChartsTabsContext",{selectedTabId:e})},a.loadWidgetsTemplates();var r=t.$on("onUserConfigurationOrganizationChanged",function(){e.$broadcast("userConfigurationChanged")}),s=t.$on("onUserConfigurationChanged",function(t,n){e.$broadcast("configurationChanged",n)});e.$on("$destroy",function(){r(),s()})}]),app.ui.dashboards.controller("nxtSSODashboardCtrl",["$scope","$rootScope","$injector","nxtUtilsSvc","$window","nxtPatientSvc","NXT_CONSENT","nxtConsentSvc","nxtUserContextSvc","nxtTemplateViewSvc","$uibModal","nxtPatientDashboardSvc","nxtUserProfileSvc","gettextCatalog","CONSTANT","nxtUserSvc","$q","NXT_PART_TWO_MRN_LIST","nxtValueSetSvc","NXT_SSO_CONFIG","$controller",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m,v,S,C,y){"use strict";y("nxtSourcesDashboardCtrl",{scope:e}),e.loading=!0,e.showPatientData=!1,e.ssoWidgetConfig=C.PatientSelectionDialog,u.loadWidgetsTemplates(),e.closedDialofMsg=C.ClosedDialogMsg;var b="Close Provider Portal";function x(e){return"boolean"==typeof l.getCurrentPageContextProperty(e)&&l.getCurrentPageContextProperty(e)}function D(t){if(e.loading=!1,t&&t.isAccessible)if(t.attesting&&t.attesting.hasNoAvailableData)d.showModalDialog(i.getMessageMissingPatientData(t,!0)).then(function(){E()});else if(t&&t.isOptOut&&!x("breakGlassEnabled_"+t.eid))if(v&&v.length>0)e.loading=!0,S.get({valueSetName:"EmergencyAccessReason",limit:1}).then(function(n){h.enableBreakGlass({patient:t,reason:n[0]}).then(function(){e.loading=!1,l.setCurrentPageContextProperty("breakGlassEnabled_"+t.eid,!0),T(t)},function(t){e.loading=!1})},function(){e.loading=!1});else{var n=e.$new();n.patient=angular.copy(t),n.isSSOContext=!0,c.open({templateUrl:"modules/dashboardWidgets/patientSearch/patientConsentOptOut.html",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html",controller:"nxtPatientConsentOptOutCtrl",scope:n,backdrop:"static"}).result.then(function(e){t.breakGlassReason=e,T(t)},function(){E()})}else T(t);else d.showModalDialog(i.getMessageMissingAttestation(t,!0)).then(function(){E()})}function T(t){t&&t.attesting&&t.attesting.requestAttesting&&!x("attestationEnabled_"+t.eid)?(e.loading=!0,h.attestation({patient:angular.copy(t),reason:f.CONCEPT.ATTESTATION_ACCESS_REASON.TREATMENT_SSO}).then(function(){w(t)},function(t){e.loading=!1;var n={closeButtonText:b,headerText:g.getString("Error"),bodyText:'<span class="red bold">'+t+"</span>"};d.showModalDialog(n).then(function(){E()})})):w(t)}function w(t){e.loading=!0,e.isLoadingData=!0,l.updateLoggedUserList(t).then(function(t){l.setCurrentPageContextProperty("currentContextInfo",t),e.setPatientById()},function(){e.loading=!1,e.isLoadingData=!1})}function E(){e.loading=!0;var t=C.CloseDialog&&C.CloseDialog.action;if("closeportal"===t)try{a.close()}finally{p.logout().then(function(){l.logoutCallback()},function(){l.logoutCallback()})}else"closedialog"===t?(e.showSSOMessageCloseDialod=!0,e.loading=!1):p.logout().then(function(){l.logoutCallback()},function(){l.logoutCallback()})}function P(e){i.setPatientPermission(e);var t=[],n={};e.optOutMrnList&&e.optOutMrnList.length>0&&(t=_.map(e.optOutMrnList,function(e){return r.MrnSystem+"|"+e}),n[e.eid]=t),s.getRecentConsent({patientId:t},n,[e.eid]).then(function(t){t&&t.length&&(e.isOptOut=!0),D(i.verifyPartTwoConsent(e))})}function I(t){if(t||(t=[]),0===t.length){e.loading=!1;var n={closeButtonText:b,headerText:C.PatientNotFound.Header,bodyText:'<span class="red bold">'+C.PatientNotFound.Body+"</span>"};d.showModalDialog(n,{windowClass:"nxt-light-popup"}).then(function(){E()})}else if(1===t.length)P(t[0]);else{e.loading=!1;var i=e.$new();i.isSSOContext=!0,i.search={dob:e.routeParams.dob,firstName:e.routeParams.firstname,lastName:e.routeParams.lastname},i.isLoading=!0,i.code="ssoPatientSearch",i.subtab={code:i.code,parentSubtab:i.code};var a="modules/dashboardWidgets/patientSearch/SSOPatientSearchList.html",o="nxtSSOPatientSearchListCtrl";e.ssoWidgetConfig&&e.ssoWidgetConfig.Body&&e.ssoWidgetConfig.Body.showPatientSearchWidget&&(a="modules/dashboardWidgets/patientSearch/patientSearchList.html",o="nxtPatientSearchListCtrl",i.isLoading=!1),c.open({templateUrl:a,windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:o,scope:i,windowClass:"nxt-huge-popup",backdrop:"static"}).result.then(function(e){D(e)},function(){E()}),e.$applyAsync()}}C.CloseDialog&&C.CloseDialog.text&&(b=C.CloseDialog.text);var A=e.routeParams.mrn?[o.search({identifier:e.routeParams.mrn})]:[o.searchWithTotalRowsGrouped({familyName:e.routeParams.lastname,givenName:e.routeParams.firstname,birthDate:e.routeParams.dob,limit:50,page:1})];m.all(A).then(function(t){if(e.routeParams.mrn){var n,i,a=t[0];(i=_.find(a,function(t){return t.id===e.routeParams.mrn}))&&i.eid&&(n=_.find(a,function(e){return e.eid===i.eid&&1===e.id.split("|").length})),n?P(n):o.searchWithTotalRowsGrouped({familyName:e.routeParams.lastname,givenName:e.routeParams.firstname,birthDate:e.routeParams.dob,limit:50,page:1}).then(function(e){I(e)})}else I(t[0])})}]),app.ui.dashboards.factory("nxtPatientDashboardUtilsSvc",["$rootScope","$q","nxtUserContextSvc","nxtUtilsSvc","nxtEncounterSvc","nxtPatientSvc","$filter","nxtValueSetSvc","gettextCatalog","CONSTANT",function(e,t,n,i,a,o,r,s,l,d){"use strict";var c,u={setInit:function(e){e.subtabsPageContext="patientDashboardSubtabs_"+e.patientContext.PatientId,(c=n.getCurrentPageContextProperty(e.subtabsPageContext+"_mainSubtabs"))&&0!==c.length||(c=angular.copy(i.patientMainTabs),e.activeTab=c[0]);(function(e,t){var i=[];if(t&&t.length>0)for(let e=0;e<t.length;e++)i.push(_.omit(t[e],["wasActivated"]));e.principalSubTabs=i,n.setCurrentPageContextProperty(e.subtabsPageContext+"_mainSubtabs",i)})(e,c),function(e){if(!e.patientContext||!e.patientContext.PatientId||!e.subtabsPageContext)return;var t=[],i=n.getCurrentPageContextProperty(e.subtabsPageContext);if(i&&i.length>0){for(let e=0;e<i.length;e++)t.push(_.omit(i[e],["wasActivated"]));n.setCurrentPageContextProperty(e.subtabsPageContext,t)}}(e)},getSubtabInfo:y,setPatientContext:function(e,t,i){e.patientContext={Patient:t&&i?t.patient:n.Patient,PatientId:t&&i?t.patient.id:n.PatientId,CurrentEncounter:t&&i?t.encounter:n.CurrentEncounter,CurrentEncounterId:t?t.encounter.id:n.CurrentEncounterId}},getSubTabWidgetContextKeys:C,renderMinimap:function(e,t){m(e,t)},minimapRefreshEvent:function(e){m(e,null,!0)},openRefillRequestEvent:function(e){f(e,"pacRefillRequest","patientRefillRequestContextDataChangedEvent")},openRxChangeRequestEvent:function(e){f(e,"pacRxChangeRequest","patientRxChangeRequestContextDataChangedEvent")},openMedManagementEvent:function(e){f(e,"pacMedManagement")},changeCurrentEncounterEvent:function(e,t){e.patientContext&&e.patientContext.PatientId===t.patient.id&&(e.patientContext.CurrentEncounterId=t.encounter.id,e.patientContext.CurrentEncounter=t.encounter)},setPatientDashConfig:function(e,t){var n=angular.copy(t),i=[];for(let e=0;e<n.length;e++)for(var a=0;a<n[e].length;a++)i.push(v(n[e][a],"permission"));app.checkPermission(i).then(function(t){var i,a=[];for(let r=0;r<n.length;r++){i=[];for(var o=0;o<n[r].length;o++)_.find(t,function(e){return e&&e.action===v(n[r][o],"permission")&&!0===e.result})&&(n[r][o].widgetPath=v(n[r][o],"path"),n[r][o].widgetDisplay=S(n[r][o]),n[r][o].widgetSubtab=y(n[r][o],e.subtabsPageContext,!0),n[r][o].widgetContextKey=v(n[r][o],"widgetContextKey"),n[r][o].filterContextKey=v(n[r][o],"filterContextKey"),n[r][o].widgetPath&&n[r][o].widgetSubtab&&i.push(n[r][o]));i.length>0&&a.push(i)}e.sizeColumn="col-xs-"+(12/a.length).toString(),e.patientDashConfig=a})},getPacWidgetCodeToPath:function(){return p},managePatientDashboardSubtabs:function(e,a){var o=t.defer();if(!e.patientContext||!e.patientContext.PatientId||!e.subtabsPageContext)return o.resolve(),o.promise;var r=[],s=[],l=[];n.LoggedUserConfiguration&&n.LoggedUserConfiguration.patientExpandedViewsConfig&&(r=n.LoggedUserConfiguration.patientExpandedViewsConfig);(s=angular.copy(n.getCurrentPageContextProperty(e.subtabsPageContext)))||(s=[]);var d=_.find(s,function(e){return e&&!0===e.active});e.patientTabs||(e.patientTabs=[]);l=angular.copy(e.patientTabs);var c=_.uniqBy(r.concat(s),"code"),u=angular.copy(c);if(c&&c.length>0){var p=[];if(n.LoggedUserConfiguration.patientDashboardConfig&&n.LoggedUserConfiguration.patientDashboardConfig.length)for(let e=0;e<n.LoggedUserConfiguration.patientDashboardConfig.length;e++)p=p.concat(_.map(n.LoggedUserConfiguration.patientDashboardConfig[e],function(e){return y(e)}));n.LoggedUserConfiguration.patientExpandedViewsConfig&&n.LoggedUserConfiguration.patientExpandedViewsConfig.length&&(p=p.concat(_.map(n.LoggedUserConfiguration.patientExpandedViewsConfig,function(e){return y(e)})),p=_.uniqBy(p,"code"));for(var f=0;f<c.length;f++)_.find(p,function(e){return e&&e.code===c[f].code})||_.remove(u,function(e){return e&&e.code===c[f].code})}var m=u.length===c.length;if(c=angular.copy(u),m&&a&&r&&a.join(",")===_.map(r,function(e){return e&&e.code}).join(","))return o.resolve(),o.promise;if(a&&a.length>0)for(let e=0;e<a.length;e++)_.find(r,function(t){return t&&t.code===a[e]})||_.remove(c,function(t){return t&&t.code===a[e]});if(c&&c.length>0){if(e.patientTabs.length>0&&i.stringify(_.map(c,"code"))===i.stringify(_.map(e.patientTabs,"code")))return o.resolve(),o.promise;var S=[];for(let e=0;e<c.length;e++)S.push(v(c[e],"permission"));app.checkPermission(S).then(function(t){var i=[];for(let e=0;e<c.length;e++)_.find(t,function(t){return t&&t.action===v(c[e],"permission")&&!0===t.result})&&i.push(c[e]);var r,s=-1;for(let t=0;t<i.length;t++)(r=y(i[t],e.subtabsPageContext))&&(!_.find(g,function(e){return e.subtabCode===r.code})||h(r.code,e.patientContext.PatientId)||a?d&&d.code===r.code?(n.openSubtab(r,!0,++s),e.activeTab={code:r.code}):n.openSubtab(r,!1,++s):n.closeSubtab(r));if(l.length>0)for(let t=0;t<l.length;t++)if(l[t]&&l[t].code&&!h(l[t].code,e.patientContext.PatientId)&&!_.find(i,function(e){return e.code===l[t].code})){var u=y(l[t],e.subtabsPageContext);n.closeSubtab(u)}var p=n.getCurrentPageContextProperty(e.subtabsPageContext);_.isUndefined(p)&&n.setCurrentPageContextProperty(e.subtabsPageContext,[]),e.patientTabs=n.getCurrentPageContextProperty(e.subtabsPageContext),e.patientSubtabsLoaded=!0,a&&e.$broadcast("nxtPatientDashboardSubtabsChanged_"+e.subtabsPageContext),o.resolve()})}else n.setCurrentPageContextProperty(e.subtabsPageContext,[]),e.patientTabs=n.getCurrentPageContextProperty(e.subtabsPageContext),e.patientSubtabsLoaded=!0,a&&e.$broadcast("nxtPatientDashboardSubtabsChanged_"+e.subtabsPageContext),o.resolve();return o.promise},clearPreviouslySubTabsPageContext:function(e){if(!e.subtabsPageContext)return;var t=angular.copy(e.patientTabs);if(t&&t.length>0)for(let o=0;o<t.length;o++){var i=C(e,t[o]);i.widgetContextKey&&n.removeCurrentPageContextProperty(i.widgetContextKey);var a=y(t[o],e.subtabsPageContext);n.closeSubtab(a)}n.removeCurrentPageContextProperty(e.subtabsPageContext),n.removeCurrentPageContextProperty(e.subtabsPageContext+"_mainSubtabs")}},p=i.patientDashboardWidgets.concat(i.patientDashboardAdditionalViews);
8var g=[{subtabCode:"pacRefillRequest",contextPartialKey:"refillRequestContextData_"},{subtabCode:"pacRxChangeRequest",contextPartialKey:"rxChangeRequestContextData_"},{subtabCode:"pacMedManagement",contextPartialKey:"medManagementContextData_"}];function f(e,t,i){if(e.patientTabs){var a=_.find(e.patientTabs,function(e){return e.code===t});a&&e.closeSubtab(a,null,!0)}n.openSubtab(y(_.find(p,function(e){return e.code===t}),e.subtabsPageContext)),i&&e.$broadcast(i)}function h(e,t){if(!e)return!1;var i=_.find(g,function(t){return t.subtabCode===e});if(i){var a=n.getCurrentPageContextProperty(i.contextPartialKey+t);if(a&&a.communication)return!0}return!1}function m(e,t,n){n||(e.isInView=t),e.isInView&&(e.summaryRedrawMinimap=null===e.summaryRedrawMinimap||!e.summaryRedrawMinimap)}function v(e,t){var n=_.find(p,function(t){return t.code===e.code});return n?n[t]:null}function S(e){var t;switch(e.code){case d.GENERIC.WIDGETS.VITAL_SIGNS.code:t={title:e.display,subTitle:"simple"===e.type?"":l.getString("(trendline displays last 5 values if available)")};break;case d.GENERIC.WIDGETS.RADIOLOGY_RESULTS.code:t={title:l.getString("Radiology"),subTitle:""};break;case d.GENERIC.WIDGETS.INSURANCES.code:t={title:l.getString("Insurances"),subTitle:""};break;case d.GENERIC.WIDGETS.LABORATORY_RESULTS.code:t={title:l.getString("Labs"),subTitle:l.getString("(last 5 panels displayed, trendline displays last 5 results if available)")};break;default:t={title:e.display,subTitle:""}}return t}function C(e,t){var n=_.find(p,function(e){return e.code===t.code});if(n){var i=angular.copy(n);return{widgetContextKey:i.widgetContextKey+e.patientContext.PatientId+"Expanded",filterContextKey:i.filterContextKey+e.patientContext.PatientId+"Expanded"}}return null}function y(e,t,n){var i=_.find(p,function(t){return t.code===e.code});if(i){var a=angular.copy(i);return a.parentSubtab=n?"pacDashMain":e.code,a.pageContext=t,a}return null}return u}]),app.ui.dashboards.controller("nxtSourcesDashboardCtrl",["scope","$rootScope","$injector","CONSTANT","gettextCatalog","$uibModal","$window","nxtUserSvc",function(e,t,n,i,a,o,r,s){const l=n.get("nxtUserContextSvc");e.mrnList=[],e.mrnsSelectAllDisplay=a.getString("All sources"),e.visibleControls={linkExternalData:l.Attesting===i.PERMISSION.ATTESTING.LOCAL_DATA_FOR_LOCAL_PATIENTS+"|"+i.PERMISSION.ATTESTING.MANUAL,dropDownOrganizations:l.Attesting&&-1===l.Attesting.indexOf(i.PERMISSION.ATTESTING.LOCAL_DATA_FOR_LOCAL_PATIENTS)},e.setPatientById=function(){const t=l.getCurrentPageContextProperty("currentContextInfo");e.set={display:"All"},t&&(e.isLoadingData=!0,l.setPatientById(t?t.eid:null,t).then(function(){if(e.patientFound=l.Patient,e.patientFound&&e.patientFound.attesting&&e.patientFound.attesting.requestAttesting&&!e.visibleControls.dropDownOrganizations&&(e.visibleControls.dropDownOrganizations=!0),e.patientFound&&e.visibleControls.linkExternalData){"boolean"==typeof l.getCurrentPageContextProperty("attestationEnabled_"+e.patientFound.eid)&&l.getCurrentPageContextProperty("attestationEnabled_"+e.patientFound.eid)&&l.Patient&&l.Patient&&l.Patient.mrnList&&(l.Patient.attesting||(l.Patient.attesting={}),l.Patient.attesting.mrnList=angular.copy(l.Patient.mrnList),e.visibleControls.dropDownOrganizations=!0,e.visibleControls.disabledLinkExternalData=!0)}l.Patient&&l.Patient.attesting&&l.Patient.attesting.mrnList?(e.mrnList=_.map(l.Patient.attesting.mrnList,function(e){return _.extend(e,{$selected:!0})}),l.Patient.mrnList.length!==e.mrnList.length&&(e.set.display=_.map(l.Patient.attesting.mrnList,function(e){return e.display}).join(", "))):e.mrnList=[],e.mrnList&&0!==e.mrnList.length||(e.set||(e.set={}),e.set.display="None"),e.isDisabledSourcesLink=!0,e.$broadcast("patientContextChanged"),e.isSSO&&(e.loading=!1,e.showPatientData=!0),e.isLoadingData=!1},function(){e.isSSO&&(e.loading=!1),e.isLoadingData=!1}))},e.isSSO||e.setPatientById(),e.showSourcesFilterDialog=function(){!function(){e.set.initialMrnList=angular.copy(e.mrnList),e.set.selectAllMrns=0===_.filter(e.mrnList,function(e){return!e.$selected}).length,e.showMessage=!1;var t=angular.element("body");angular.element("#divBlockerFilterDialog").length||t.prepend(d);angular.element("#divBlockerFilterDialog").width(t.outerWidth()),angular.element("#divBlockerFilterDialog").height(t.outerHeight()),angular.element("#divBlockerFilterDialog").show(),function(){var t=angular.element(".ddl-organizations"),n=t,i=t.find("a").first(),a=i.offset().top+i.outerHeight(),o=angular.element(r).height();t.closest(".container-patient").length&&(o=t.closest(".container-patient").height());e.below=a+n.outerHeight()<=o+angular.element(document).scrollTop()-25}()}(),e.showFilterDialogVisible=!0},e.selectAllMrnList=function(){for(var t=!e.set.selectAllMrns,n=0;n<e.mrnList.length;n++)e.mrnList[n].$selected!==t&&e.changeSelection(e.mrnList[n],t)},e.selectMrn=function(t){var n=!e.mrnList[t].$selected;e.set.selectAllMrns=!!n&&1===_.filter(e.mrnList,function(e){return!e.$selected}).length,e.changeSelection(e.mrnList[t],n),e.showMessage=0===_.filter(e.mrnList,function(e){return!0===e.$selected}).length},e.applyDateFilter=function(t,n){_.filter(e.mrnList,function(e){return!0===e.$selected}).length>0?(e.closeDateFilterDialog(t,!0),l.Patient.attesting&&(l.Patient.attesting.mrnList=_.filter(e.mrnList,function(e){return!0===e.$selected})),e.set.display=e.set.selectAllMrns?"All":_.map(l.Patient.attesting.mrnList,function(e){return e.display}).join(", "),e.isDisabledSourcesLink=!0,e.$broadcast("reloadPatientDataByMrnList",l.Patient.attesting.mrnList,n)):e.showMessage=!0},e.closeDateFilterDialog=function(t,n){t&&(t.resetForm(),n||(e.mrnList=angular.copy(e.set.initialMrnList)),e.showFilterDialogVisible=!1,angular.element("#divBlockerFilterDialog").length&&(angular.element("#divBlockerFilterDialog").width(0),angular.element("#divBlockerFilterDialog").height(0),angular.element("#divBlockerFilterDialog").hide()))};var d='<div id="divBlockerFilterDialog" style="display:none;position:absolute;top:0;left:0;background:transparent;z-index:1040;"></div>';function c(){e.mrnList=_.map(angular.copy(l.Patient.mrnList),function(e){return _.extend(e,{$selected:!0})}),e.visibleControls.dropDownOrganizations=!0,e.visibleControls.disabledLinkExternalData=!0,e.set.selectAllMrns=!0,e.a
8pplyDateFilter()}e.below=!0,e.showExternalData=function(){if(e.isSSO)e.loading=!0,s.attestation({patient:angular.copy(l.getCurrentPageContextProperty("currentContextInfo")),reason:i.CONCEPT.ATTESTATION_ACCESS_REASON.TREATMENT_SSO}).then(function(){c(),e.loading=!1},function(t){e.loading=!1});else{var t=e.$new();t.patient=angular.copy(l.Patient),o.open({templateUrl:"modules/dashboardWidgets/attesting/attesting.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtAttestingCtrl",scope:t,backdrop:"static"}).result.then(function(e){l.Patient.attestationReason=e,c()},function(){})}};var u=e.$on("loadingPatientDataCompleted",function(){e.mrnList&&e.mrnList.length>0&&(e.isDisabledSourcesLink=!1)}),p=t.$on("onUploadedFile",function(t,n){var i=angular.copy(n.mrn.system+"|"+n.mrn.value),a=angular.copy(n.display);l.Patient.identifier||(l.Patient.identifier=[]),l.Patient.identifier.push(n.mrn),l.HasUploadDocument=!0,l.Patient.mrnList||(l.Patient.mrnList=[]),l.Patient.mrnList.push({id:i,display:a,multipleIds:[i]}),e.mrnList&&e.mrnList.length>0&&(e.mrnList.push({id:i,display:a,multipleIds:[i],$selected:!0}),e.set.selectAllMrns=0===_.filter(e.mrnList,function(e){return!e.$selected}).length),e.applyDateFilter(null,!0)});e.$on("$destroy",function(){u(),p()})}]),app.ui.dashboards.controller("eHxAvailableDocumentsCtrl",["$scope","$rootScope","$injector","nxtEHxSvc","$controller",function(e,t,n,i,a){e.isEhxTab=!0,e.subtab={code:"eHxDocumentSearch"+e.patient.id+"-"+e.patient.origin+e.index,eHxProperty:"eHxDocumentSearch"};var o=10,r=0;e.isLoadingAvailableDocuments=!0,a("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:n});var s=[{id:"available-doc-type-th-"+e.patient.id+"-"+e.patient.origin+e.index,name:"Type",visible:!0,code:"type",order:0},{id:"available-doc-class-th"+e.patient.id+"-"+e.patient.origin+e.index,name:"Class",visible:!0,code:"class",width:"30",order:1},{id:"available-doc-author-th"+e.patient.id+"-"+e.patient.origin+e.index,name:"Author",visible:!0,code:"author",width:"20",order:2},{id:"available-doc-created-th"+e.patient.id+"-"+e.patient.origin+e.index,name:"Created Date",visible:!0,code:"createdDate",width:"20",minWidth:"75",order:3}];function l(){var t=_.map(angular.copy(e.totalDocuments.slice(r,r+o)),function(e){return"urn:uuid:"+e.id});i.getDocumentsByIds({participant:e.patient.origin,oids:t.join(",")}).then(function(t){t&&t.entries.length>0?(t.entries=_.map(t.entries,function(t){return _.extend(t,{origin:e.patient.origin})}),e.clinicalNotesData||(e.clinicalNotesData=[]),e.clinicalNotesData=e.clinicalNotesData.concat(t.entries),r+=o,e.hasMoreData=e.totalDocuments.length>r):e.clinicalNotesData=[],e.isLoadingAvailableDocuments=!1,e.$emit("onFinishedSearchAvailableDocuments",e.patient.id)},function(t){e.error=t,e.isLoadingAvailableDocuments=!1,e.$emit("onFinishedSearchAvailableDocuments",e.patient.id)})}e.headers=_.sortBy(_.filter(e.setColumns(s),function(e){return e.visible}),"order"),function(){var t={patient:e.patient.eHxId,participant:e.patient.origin};e.createdIsAllInterval||(e.createdStartDate&&(t.serviceStartDate=e.createdStartDate),e.createdEndDateDate&&(t.serviceStopEndDate=e.createdEndDateDate));i.findDocuments(t).then(function(t){e.totalDocuments=[],e.noSearchResultsFound="",t&&t.entries.length>0?(e.totalDocuments=t.entries,l()):(e.noSearchResultsFound="Your search returned no documents.",e.clinicalNotesData=[],e.isLoadingAvailableDocuments=!1,e.$emit("onFinishedSearchAvailableDocuments",e.patient.id))},function(t){e.error=t,e.isLoadingAvailableDocuments=!1,e.$emit("onFinishedSearchAvailableDocuments",e.patient.id)})}(),e.getMoreData=function(){e.isLoadingAvailableDocuments=!0,l()},e.changeDocumentSelection=function(n){if(n.$selected=!n.$selected,n.$selected)for(var i=0;i<e.clinicalNotesData.length;i++)e.clinicalNotesData[i].$selected&&e.clinicalNotesData[i].id!==n.id&&(e.clinicalNotesData[i].$selected=!1);t.$broadcast("onSelectedAvailableDcument",e.subtab.code)};var d=t.$on("onSelectedAvailableDcument",function(t,n){if(e.subtab.code===n){var i=_.find(e.clinicalNotesData,function(e){return!0===e.$selected});e.$emit("onAvailableDocumnetSelected",i)}else if(e.clinicalNotesData&&e.clinicalNotesData.length>0)for(var a=0;a<e.clinicalNotesData.length;a++)e.clinicalNotesData[a].$selected&&(e.clinicalNotesData[a].$selected=!1)});e.$on("$destroy",function(){d()})}]),app.ui.dashboards.controller("eHxIncludePatientsCtrl",["$scope","$rootScope","$injector","nxtEH
8xSvc","NXT_EHX_CONFIG","$controller","$timeout","nxtUserContextSvc",function(e,t,n,i,a,o,r,s){e.subtab={code:"eHxPatientSearch",eHxProperty:"eHxPatientSearch"},e.isEhxTab=!0,e.patientContext={Patient:s.Patient,PatientId:s.PatientId},e.widgetContext="eHxIncludePatients_key_"+e.patientContext.PatientId,e.filterContext="eHxIncludePatients_FilterContext_"+e.patientContext.PatientId,o("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:n});var l={LAST_NAME:"lastName",FIRST_NAME:"firstName",MIDDLE_NAME:"middleName",GENDER:"gender",DOB:"dob",AGE:"age",SOURCE:"source"},d=[{id:"ehxpateint-last-name-th",name:"Last name",visible:!0,code:"last-name",sort:l.LAST_NAME,order:0},{id:"ehxpateint-first-name-th",name:"First name",visible:!0,code:"first-name",sort:l.FIRST_NAME,width:"15",order:1},{id:"ehxpateint-middle-name-th",name:"Middle name",visible:!0,code:"middle-name",sort:l.MIDDLE_NAME,width:"15",order:2},{id:"ehxpateint-dob-th",name:"DOB",visible:!0,code:"dob",sort:l.DOB,width:"13",minWidth:"75",order:3},{id:"ehxpateint-age-th",name:"Age",visible:!0,code:"age",sort:l.AGE,width:"7",order:4},{id:"ehxpateint-gender-th",name:"Gender",visible:!0,code:"gender",sort:l.GENDER,width:"10",order:5},{id:"ehxpateint-source-th",name:"Source",code:"source",visible:!0,sort:l.SOURCE,width:"10",order:6},{id:"ehxpateint-include-th",name:"Include",code:"include",visible:!0,width:"10",order:7}];e.headers=_.sortBy(_.filter(e.setColumns(d),function(e){return e.visible}),"order"),e.sortOnClientData=function(t){e.isSortingEHXPatients=!0,e.sortEHxPatient||(e.sortEHxPatient={field:"",direction:""}),t!==e.sortEHxPatient.field?(e.sortEHxPatient.field=t,e.sortEHxPatient.direction=""):e.sortEHxPatient.direction=_.isEmpty(e.sortEHxPatient.direction)?"-":"",e.patients=function(t){switch(e.sortEHxPatient.field){case l.LAST_NAME:t=_.sortBy(t,"familyName");break;case l.FIRST_NAME:t=_.sortBy(t,"givenName");break;case l.MIDDLE_NAME:t=_.sortBy(t,"middleName");break;case l.GENDER:t=_.sortBy(t,"gender.display");break;case l.DOB:t=_.sortBy(t,"birthDate");break;case l.AGE:t=_.orderBy(t,"Age");break;case l.SOURCE:t=_.sortBy(t,"source")}t&&(t=_.isEmpty(e.sortEHxPatient.direction)?t:_.reverse(t));return t}(e.patients),e.isSortingEHXPatients=!1},e.filterDates={startFrom:null,startTo:null,endFrom:null,endTo:null};var c,u=e.$on("clinicalDateRangeDateFilterChangeEvent",function(t){t.stopPropagation(),e.$emit("onFilterParamsChanged")}),p=e.$on("clinicalDateRangeDateFilterSaveEvent",function(t,n){t.stopPropagation(),e.filterDates.startFrom=null,e.filterDates.startTo=null,e.filterDates.startIsAllInterval=!1,n&&n.interval&&(n.interval.startDate&&(e.filterDates.startFrom=n.interval.startDate),n.interval.endDate&&(e.filterDates.startTo=n.interval.endDate),e.filterDates.startIsAllInterval=n.interval.isAllFilter);for(var i=_.filter(e.patients,function(e){return e.$selected}),a=[],o=0;o<i.length;o++)i[o].nameDisplay=i[o].DisplayName,(i[o].gender&&i[o].gender.code||i[o].Age)&&(i[o].nameDisplay+=" (",i[o].gender&&i[o].gender.code&&(i[o].nameDisplay+=_.toUpper(i[o].gender.code[0]),i[o].Age&&(i[o].nameDisplay+=", ")),i[o].Age&&(i[o].nameDisplay+=i[o].Age),i[o].nameDisplay+=")"),a.push(_.extend({patient:i[o]},{from:e.filterDates.startFrom,to:e.filterDates.startTo,isAllInterval:e.filterDates.startIsAllInterval}));e.$emit("startSearchAvailableDocuments",a)});e.changeIncludePatientSelection=function(t){t.$selected=!t.$selected,e.hasIncludePatientsSelected=!!_.find(e.patients,function(e){return e.$selected}),e.$emit("onFilterParamsChanged")};var g=e.$on("searchEHxPatients",function(t,n){e.patients=[],s.setCurrentPageContextProperty("clinicalDateRange_DateRange_"+e.filterContext,null),e.isSearchingPatientsFinished=!1,t.preventDefault();var o={participants:_.map(n,function(e){return e.code}).join(",")};e.patientContext.Patient.familyName&&(o.familyName=e.patientContext.Patient.familyName),e.patientContext.Patient.givenName&&(o.givenName=e.patientContext.Patient.givenName),e.patientContext.Patient.birthDate&&(o.birthDate=e.patientContext.Patient.birthDate),e.patientContext.Patient.gender&&e.patientContext.Patient.gender.code&&(o.gender=e.patientContext.Patient.gender.code),e.patientContext.Patient.homeAddress&&(e.patientContext.Patient.homeAddress.city&&(o.city=e.patientContext.Patient.homeAddress.city),e.patientContext.Patient.homeAddress.state&&e.patientContext.Patient.homeAddress.state.code&&(o.state=e.patientContext.Patient.homeAddress.state.code),e.patientContext.Patient.homeAddress.postalCode&&(o.state=e.patientContext.Patient.homeAddress.postalCode),e.patientContext.Patient.homeAddress.country&&(o.country=e.patientContext.Patient.homeAddress.country),e.patientContext.Patient.homeAddress.line1&&(o.address=e.patientContext.Patient.homeAddress.line1)
8),e.patientContext.Patient.phone&&(o.phone=e.patientContext.Patient.phone),e.patientContext.Patient.businessPhone&&(o.businessPhone=e.patientContext.Patient.businessPhone),i.searchPatients(o).then(function(t){e.$emit("onFinishedSearchPatients",!1),function(e){if(e&&0!==e.length)for(var t=0;t<e.length;t++)if(e[t].externalSources&&e[t].externalSources[0]&&e[t].externalSources[0].sourceOrganization){var n=_.find(a.Participants,function(n){return n.code&&n.code.toUpperCase()===e[t].externalSources[0].sourceOrganization.toUpperCase()});e[t].source=n&&n.name?n.name:e[t].externalSources[0].sourceOrganization,e[t].origin=e[t].externalSources[0].sourceOrganization}}(t.entries),(c=r()).then(function(){for(var i=t.entries,a=[],o=0;o<n.length;o++)_.find(t.entries,function(e){return e.origin.toLowerCase()===n[o].code.toLowerCase()})||a.push(n[o].name);a.length>0&&(e.noMatchingSources="Your eHealth Exchange search returned no matching patients from: "+a.join(", ")+"."),e.patients=i,e.isSearchingPatientsFinished=!0,r.cancel(c)},10)},function(t){e.$emit("onFinishedSearchPatients",!0)})}),f=e.$on("changedSelectedSources",function(t){t.preventDefault(),e.isSearchingPatientsFinished=!1,e.hasIncludePatientsSelected=!1,e.filterDates={startFrom:null,startTo:null,endFrom:null,endTo:null},s.setCurrentPageContextProperty("clinicalDateRange_DateRange_"+e.filterContext,null),e.patients=[]});e.$on("$destroy",function(){g(),p(),f(),u(),c&&r.cancel(c)})}]),app.ui.dashboards.controller("eHxSourcesCtrl",["$scope","NXT_EHX_CONFIG",function(e,t){"use strict";e.eHxConfig=t,e.participantList&&e.participantList.length>0?e.selectedSources=angular.copy(e.participantList):e.selectedSources=angular.copy(_.sortBy(_.map(_.filter(e.eHxConfig.Participants,function(e){return e.selected}),function(e){return _.extend(e,{$selected:e.selected})}),"name")),e.isSearchForPatientsDisabled=function(){if(!e.selectedSources||0===e.selectedSources.length)return!1;var t=_.filter(e.selectedSources,function(e){return e.$selected});return e.exceededMsg=t.length>=e.eHxConfig.ParticipantSelection.MaxSelection?e.eHxConfig.ParticipantSelection.MaxSelectionExceededMsg:void 0,t.length>0&&t.length>=e.eHxConfig.ParticipantSelection.MaxSelection},e.$watch("filterBySource",function(t){var n=[];if(t){var i=[],a=_.words(t);a.forEach(function(t){i=_.first(a)===t?_.filter(e.eHxConfig.Participants,function(e){return e.name&&e.name.toLowerCase().indexOf(t.toLowerCase())>=0}):_.filter(i,function(e){return e.name&&e.name.toLowerCase().indexOf(t.toLowerCase())>=0})}),n=angular.copy(_.uniq(i,"code"))}else n=angular.copy(e.eHxConfig.Participants);if(n&&n.length>0)for(var o=0;o<n.length;o++)_.find(e.selectedSources,function(e){return e.code&&e.code===n[o].code})?n[o].$selected=!0:n[o].$selected=!1;e.availableSourcesList=_.sortBy(n,"name")}),e.removeSource=function(t){if(e.selectedSources=_.filter(e.selectedSources,function(e){return e.code.toLowerCase()!==t.code.toLowerCase()}),e.availableSourcesList&&e.availableSourcesList.length>0)for(var n=0;n<e.availableSourcesList.length;n++)if(e.availableSourcesList[n].code.toLowerCase()===t.code.toLowerCase()){e.availableSourcesList[n].$selected=!1;break}},e.selectSource=function(t){t.$selected||(t.$selected=!t.$selected,e.selectedSources||(e.selectedSources=[]),e.selectedSources.push(t))},e.save=function(){e.$close(e.selectedSources)},e.close=function(){e.$dismiss("cancel")}}]),app.ui.dashboards.controller("nxtEHxCtrl",["$scope","NXT_EHX_CONFIG","$timeout","$uibModal",function(e,t,n,i){function a(){e.searchAvailableDocuments=[],e.documentSelectedItem=null,e.documentViewerFile=null}e.eHxConfig=t,e.participantList=angular.copy(_.sortBy(_.map(_.filter(e.eHxConfig.Participants,function(e){return e.selected}),function(e){return _.extend(e,{$selected:e.selected})}),"name")),e.searchSources=function(){var t=e.$new();e.participantList&&e.participantList.length>0?t.participantList=e.participantList:t.participantList=[],i.open({templateUrl:"modules/dashboards/patientDashboard/eHxSources.html",scope:t,backdrop:"static",controller:"eHxSourcesCtrl",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html",windowClass:"nxt-big-popup"}).result.then(function(t){e.participantList=_.sortBy(t,"name"),a(),e.showIncludePatients&&e.$broadcast("changedSelectedSources")},function(){})},e.searchPatients=function(){e.isSearchingPatients=!0,e.showIncludePatients=!0;var t=_.filter(e.participantList,function(e){return e.$selected});a(),e.$broadcast("searchEHxPatients",t)};var o,r,s=e.$on("onFinishedSearchPatients",function(t){t.stopPropagation(),e.isSearchingPatients=!1}),l=e.$on("startSearchAvailableDocuments",function(t,i){t.stopPropagation(),e.isSearchingDocuments=!0,a(),o=n(function(){e.searchAvailableDocuments=angular.copy(i),e.finishedSearchAvailableDocuments=[]},1)}),d=e.$on("onFinishedSearchAvailableDocuments",function(t,n){t.stopPropagation(),e.finishedSearchAvailableDocuments.push(n),e.finishedSearchAvailableDocuments.length===e.searchAvailableDocuments.length&&(e.isSearchingDocuments=!1)}),c=e.$on("onAvailableDocumnetSelected",function(t,i){e.documentSelectedItem=i,e.documentViewerFile=null,i&&(r=n(function(){e.documentViewerFile={file:i}},10))}),u=e.$on("onFilterParamsChanged",function(e){e.stopPropagation(),a()});e.$on("$destroy",function(){s(),l(),d(),c(),u(),r&&n.cancel(r),o&&n.cancel(o)})}]),app.ui.dashboards.controller("nxtPatientDashboardCtrl",["$scope","$rootScope","gettext","nxtUserContextSvc","nxtUtilsSvc","nxtPatientDashboardUtilsSvc","nxtConfigurationSvc","$q","CONSTANT","nxtPatientDashboardSvc",function(e,t,n,i,a,o,r,s,l,d){"use strict";e.graphCode=l.GENERIC.EXPANDED_VIEWS.GRAPHS.code,e.loadingPatientData={loading:!1},i.Patient&&i.Patient.id&&p(i.Patient);var c=e.$on("patientContextChanged",function(){var t=i.Patient&&i.Patient.eid?i.Patient.eid:null;(!e.patientContext||e.patientContext&&e.patientContext.PatientEid!==t)&&p(i.Patient)}),u=e.$on("reloadPatientDataByMrnList",function(t,n,o){if(e.patientContext){var r=a.getMrnIds(n);_.isEqual(e.patientContext.MrnIds,r)||o?(o&&(e.patientContext.MrnIds=r),e.$emit("loadingPatientDataCompleted")):(e.loadingPatientData={loading:!0},d.loadPatientDashboardData(null,!1,null,i.Patient).then(function(){e.loadingPatientData={loading:!1},e.$emit("loadingPatientDataCompleted"),e.patientContext.MrnIds=r},function(){e.loadingPatientData={loading:!1},e.$emit("loadingPatientDataCompleted"),e.patientContext.MrnIds=r}))}});function p(t){var n;(o.clearPreviouslySubTabsPageContext(e),t&&t.id)&&(t&&t.attesting&&t.attesting.mrnList&&(n=a.getMrnIds(t.attesting.mrnList)),e.patientContext=t&&t.id?{Patient:t,PatientId:t.id,PatientEid:t.eid,MrnIds:n}:null,o.setInit(e),g(),e.loadingPatientData={loading:!0},d.loadPatientDashboardData(null,!1,null,t).then(function(){e.loadingPatientData={loading:!1},e.$emit("loadingPatientDataCompleted")},function(){e.loadingPatientData={loading:!1},e.$emit("loadingPatientDataCompleted")}))}function g(t){var n;i.LoggedUserConfiguration&&(i.LoggedUserConfiguration.patientDashboardConfig&&(e.isDragDrop?(n=!0,e.isDragDrop=!1,e.sizeColumn="col-xs-"+(12/i.LoggedUserConfiguration.patientDashboardConfig.length).toString()):o.setPatientDashConfig(e,i.LoggedUserConfiguration.patientDashboardConfig)),n||o.managePatientDashboardSubtabs(e,t))}var f=null;e.dropWidgetCallback=function(t,n){var a=n.code,o=angular.copy(n.isMinimized);e.isDragDrop=!0;var l=[f?r.get(f):r.search({owner:"User/"+i.loggedUser.id})];return s.all(l).then(function(t){var n=f?t[0]:t[0][0];if(f||(f=n.id),n.patientDashboardConfig=e.patientDashConfig,n.patientDashboardConfig&&n.patientDashboardConfig.length>0)for(var s=0;s<n.patientDashboardConfig.length;s++)n.patientDashboardConfig[s]&&n.patientDashboardConfig[s].length>0&&(n.patientDashboardConfig[s]=_.uniqBy(n.patientDashboardConfig[s],"code"));r.save(n).then(function(e){for(var t=[],n=0;n<e.patientDashboardConfig.length;n++){for(var r=[],s=0;s<e.patientDashboardConfig[n].length;s++){var l={code:e.patientDashboardConfig[n][s].code,display:e.patientDashboardConfig[n][s].display};e.patientDashboardConfig[n][s].type&&(l.type=e.patientDashboardConfig[n][s].type),l.code===a&&(l.isMinimized=o),r.push(l)}r.length>0&&t.push(r)}i.updatePropertyConfig({name:"patientDashboardConfig",value:t}),g()},function(){e.isDragDrop=!1})},function(){e.isDragDrop=!1}),n},e.getSubtabInfo=function(t,n){return o.getSubtabInfo(t,e.subtabsPageContext,n)},e.getSubTabWidgetContextKeys=function(t){return o.getSubTabWidgetContextKeys(e,t)},e.getWidgetContextKey=function(t){return t+e.patientContext.PatientId},e.getSubtabOptionDisplay=function(e){return e.displayFn?e.displayFn():e.display};var h=e.$on("configurationChanged",function(e,t){var n;t.patientExpandedViewsConfig&&t.patientExpandedViewsConfig.length>0&&(n=_.map(t.patientExpandedViewsConfig,function(e){return e.code})),g(n)});e.$on("$destroy",function(){c(),h(),u()})}]),app.ui.administration.controller("nxtApplicationConfigCtrl",["gettextCatalog","$scope","nxtUserInfoStoreSvc","nxtApplicationConfigurationSvc","CONSTANT","NXT_IDS_CONFIG","$q","NXT_PATIENT_SEARCH_WIDGET","NXT_CONSENT","NXT_USER_SECURITY_QUESTIONS","NXT_EHX_CONFIG","nxtUserContextSvc",function(e,t,n,i,a,o,r,s,l,d,c,u){"use strict";t.isAwsCognitoFlowEnabled=n.state.isCognitoAuthorizationFlow,t.showSecurityAnswersConfig=d.VerifySecurityQuestions,t.isEHxEnabled=c.Enabled;var p="(?=.*[A-Z])",g="(?=.*[a-z])",f="(?=.*\\d)",h="(?=.*[^a-zA-Z0-9])",m={},v=["oneCol","secondCol"];t.intConfigFields={oneCol:[{name:"accountExpiry",label:"Account Expiry (days)",minVal:0,maxVal:720,placeholder:"No expiration"},{name:"passwordHistoryLength",label:"Password History Length",minVal:0,maxVal:50,placeholder:"No history"},{name:"maxNumberOfSessions",label:"Max Number Of Sessions",minVal:0,maxVal:1e3,placeholder:"Unlimited"}],secondCol:[{name:"passwordExpiry",label:"Password Expiry (days)",minVal:0,maxVal:720,placeholder:"No expiration"},{name:"passwordExpiryReminder",label:"Password Expiry Reminder (days)",minVal:0,maxVal:"applicationConfig.passwordExpiry",placeholder:"No reminder"},{name:"maxFailedLoginAttempts",label:"Max Failed Login Attempts",minVal:2,maxVal:100,placeholder:""}]};
8var S=[{code:"pacVitalSparklines",display:e.getString("Vitals Sparklines")}];for(let e in a.GENERIC.WIDGETS)S.push(a.GENERIC.WIDGETS[e]);if(t.doctorWidgets=_.sortBy(_.filter(S,function(e){return"docPatientSearch"===e.code||"docLastAccessedPatients"===e.code}),"display"),t.patientWidgets=_.sortBy(_.filter(S,function(e){return"docPatientSearch"!==e.code&&"docLastAccessedPatients"!==e.code}),"display"),t.isEHxEnabled&&a.GENERIC.EXPANDED_VIEWS.EHX.child&&a.GENERIC.EXPANDED_VIEWS.EHX.child.length>0){t.eHxTables=[];for(let e=0;e<a.GENERIC.EXPANDED_VIEWS.EHX.child.length>0;e++)"eHxPatientSearch"===a.GENERIC.EXPANDED_VIEWS.EHX.child[e]?t.eHxTables.push({code:a.GENERIC.EXPANDED_VIEWS.EHX.child[e],display:"eHx Patients (all columns)"}):t.eHxTables.push({code:a.GENERIC.EXPANDED_VIEWS.EHX.child[e],display:"eHx Documents (all columns)"})}var C=[{name:"Last name",code:"last-name"},{name:"First name",code:"first-name"},{name:"Middle name",code:"middle-name"},{name:"MRN",code:"mrn"},{name:"Facility",code:"facility"},{name:"Gender",code:"gender"},{name:"DOB",code:"dob"},{name:"Age",code:"age"},{name:"Address",code:"address"},{name:"Demographics",code:"print-demographics"},{name:"Pt Records Available",code:"attestation"},{name:"Status",code:"consent"}];s.ShowIndividualRecords||o.MRN&&o.MRN.visible||(C=_.filter(C,function(e){return"mrn"!==e.code})),s.ShowIndividualRecords||(C=_.filter(C,function(e){return"facility"!==e.code}));var y,b,x,D=[{type:"patient",columns:{pacResultReports:[{name:"Report",code:"code"},{name:"Alert",code:"alert"},{name:"Type",code:"category"},{name:"Date",code:"date"},{name:"Provider",code:"ordering-provider"},{name:"Status",code:"status"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"},{name:"Print Options",code:"selection-mode"}],pacRadRes:[{name:"Test",code:"code"},{name:"Date",code:"date"},{name:"Ordering provider",code:"ordering-provider"},{name:"Status",code:"status"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"},{name:"Print Options",code:"selection-mode"}],pacProcs:[{name:"Procedure",code:"code"},{name:"Date",code:"date_start"},{name:"Status",code:"status"},{name:"Code",code:"code_code"},{name:"Provider",code:"performer"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacRelatedPersons:[{name:"Name",code:"name"},{name:"Date",code:"date"},{name:"Relationship",code:"relation"},{name:"Gender",code:"gender"},{name:"Email",code:"email"},{name:"Phone",code:"phone"},{name:"Address",code:"address"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacMedicationDispense:[{name:"Medication",code:"code"},{name:"Prescription",code:"prescription"},{name:"Pharmacy",code:"performer"},{name:"Ordering Provider",code:"ordering-provider"},{name:"Dose Instruction",code:"dose"},{name:"Details",code:"details"},{name:"Date Filled",code:"whenhandedover"},{name:"Status",code:"status"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacMedication:[{name:"Medication",code:"code"},{name:"Route",code:"route"},{name:"Dose",code:"dose"},{name:"Start/End Dates",code:"schedule"},{name:"Date Written",code:"date-written"},{name:"Details",code:"details"},{name:"Status",code:"status"},{name:"Provider",code:"provider"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"},{name:"Substitution",code:"substitution"}],pacInsurances:[{name:"Order",code:"order"},{name:"Group Number",code:"groupNumber"},{name:"Insurance",code:"insurance"},{name:"Policy Number",code:"policyNumber"},{name:"Insurance Plan",code:"plan"},{name:"Insurance Type",code:"type"},{name:"Effective Dates",code:"dates"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacImmunizations:[{name:"Immunization",code:"vaccine-code"},{name:"Dose",code:"dose"},{name:"Body Site",code:"body-site"},{name:"Route",code:"route"},{name:"Given",code:"notGiven"},{name:"Refused",code:"refused"},{name:"Refusal Reason",code:"refusal-reason"},{name:"Administered Date",code:"date"},{name:"Lot Number",code:"lot-number"},{name:"Manufacturer",code:"manufacturer"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacEncounters:[{name:"Encounter Type",code:"type"},{name:"Facility Source",code:"service-provider"},{name:"Admit Date",code:"admit-date"},{name:"Discharge Date",code:"discharge-date"},{name:"Provider",code:"participant"},{name:"Location",code:"location"},{name:"Admit Reason",code:"admit-reason"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"},{name:"Admit - Discharge Dates",code:"hopitalization-period"},{name:"Hospital Service",code:"service-type"},{name:"Encounter Number",code:"encounter-no"}],pacDevices:[{name:"Device",code:"description"},{name:"Date Implanted",code:"date"},{name:"Body Location",code:"location"},{name:"Provider",code:"provider"},{name:"Manufacturer",code:"manufacturer"},{name:"Model/Serial/Lot",code:"model"},{name:"Expiration Date",code:"expiration-date"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacClinNotes:[{name:"Description",code:"description"},{name:"Source",code:"source-doc"},{name:"Type",code:"type"},{name:"Created",code:"created"},{name:"Imported Date",code:"indexed"},{name:"Status",code:"docstatus"},{name:"Reason",code:"docsuppressedreason"},{name:"Print Options",code:"selection-mode"}],pacAllergies:[{name:"Allergen",code:"allergen"},{name:"Reaction",code:"reaction-allergy"},{name:"Comment",code:"comment-allergy"},{name:"Date",code:"date-allergy"},{name:"Status",code:"clinical-status-allergy"},{name:"Source",code:"source-allergy"},{name:"Source Document",code:"source-origin-allergy"}],pacFamilyHistory:[{name:"Problem/Condition",code:"condition"},{name:"Relation",code:"relation"},{name:"Age at Onset",code:"age-at-onset"},{name:"Deceased",code:"deceased"},{name:"Age at Death",code:"age-at-death"},{name:"Onset Date",code:"onset-date"},{name:"Resolved Date",code:"resolved-date"},{name:"Status",code:"status"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacConditions:[{name:"Problem/Condition",code:"condition"},{name:"Code",code:"condition-code"},{name:"Onset Date",code:"onset-date"},{name:"Resolved Date",code:"resolved-date"},{name:"Status",code:"status"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacSocialHistory:[{name:"Social Issues",code:"condition"},{name:"Category",code:"category"},{name:"Onset Date",code:"onset-date"},{name:"Resolved Date",code:"resolved-date"},{name:"Status",code:"status"},{name:"Source",code:"source"},{name:"Source Document",code:"source-origin"}],pacVitalS:[{name:"Vital sign",code:"vital"},{name:"Interpretation",code:"interpretation"},{name:"Value",code:"value"},{name:"Elapsed Time",code:"date"}],pacVitalSparklines:[{name:"Vital sign",code:"vital"},{name:"Interpretation",code:"interpretation"},{name:"Value",code:"value"},{name:"Trendline",code:"sparkline"},{name:"Elapsed Time",code:"date"}],pacLabRes:[{name:"Panel",code:"panel"},{name:"Test",code:"test"},{name:"Value",code:"value"},{name:"Interpretation",code:"interpretation"},{name:"Trendline",code:"sparkline"},{name:"Elapsed Time",code:"date"},{name:"Status",code:"status"},{name:"Range",code:"range"},{name:"Source",code:"source"}]}}
8,{type:"doctor",columns:{docPatientSearch:C,docLastAccessedPatients:[{name:"Patient",code:"patient"},{name:"Last Viewed Date",code:"date"},{name:"Address",code:"address"},{name:"Demographics",code:"print-demographics"},{name:"Pt Records Available",code:"attestation"},{name:"Status",code:"consent"}]}}],T=_.filter(C,function(e){return"consent"!==e.code&&"attestation"!==e.code&&"print-demographics"!==e.code}).concat([{name:"Date Signed",code:"dateSigned"},{name:"Expiration Date",code:"expirationDate"},{name:"Status",code:"status"}]),w=[{code:"eHxPatientSearch",columns:[{name:"Last name",display:"Last name",code:"last-name"},{name:"First name",display:"First name",code:"first-name"},{name:"Middle name",display:"Middle name",code:"middle-name"},{name:"DOB",display:"DOB",code:"dob"},{name:"Age",display:"Age",code:"age"},{name:"Gender",display:"Gender",code:"gender"},{name:"Source",display:"Source",code:"source"},{name:"Include",display:"Include",code:"include"}]},{code:"eHxDocumentSearch",columns:[{name:"Type",display:"Type",code:"type"},{name:"Class",display:"Class",code:"class"},{name:"Author",display:"Author",code:"author"},{name:"Created Date",display:"Created Date",code:"createdDate"}]}];for(let e=0;e<D.length;e++)if(D[e].columns)for(let t in D[e].columns)D[e].columns[t]=_.map(D[e].columns[t],function(e){return _.extend({display:e.name},_.pick(e,["name","code"]))});if(T&&T.length>0){var E=l.Fields;T=_.map(T,function(e){var t=_.extend({display:e.name},_.pick(e,["name","code"]));return"status"===e.code&&E.Status&&E.Status.label&&(t.display=E.Status.label),"dateSigned"===e.code&&E.DateSigned&&E.DateSigned.label&&(t.display=E.DateSigned.label),t})}function P(e,n,i){for(let t=0;t<n.length;t++){let a=n[t],o=a+"WidgetsConfig";e[o]||(e[o]={}),i&&!x[o]&&(x[o]={}),e[o=a+"ViewsConfig"]||(e[o]={}),i&&!x[o]&&(x[o]={})}for(let d=0;d<n.length;d++){let c=n[d];var a=c+"Widgets",o=c+"WidgetsConfig",r=c+"ViewsConfig",s=_.find(D,function(e){return e.type===c}).columns;for(let n=0;n<t[a].length>0;n++){i&&(x[o][t[a][n].code]||(x[o][t[a][n].code]=[]),e[o][t[a][n].code]=angular.copy(x[o][t[a][n].code])),e[o][t[a][n].code]||(e[o][t[a][n].code]=[]),e["available"+o]||(e["available"+o]={});var l=s[t[a][n].code];e["available"+o][t[a][n].code]=angular.copy(_.differenceBy(l,i?x[o][t[a][n].code]:e[o][t[a][n].code],"code")),"patient"===c&&(i&&(x[r][t[a][n].code]||(x[r][t[a][n].code]=[]),e[r][t[a][n].code]=angular.copy(x[r][t[a][n].code])),e[r][t[a][n].code]||(e[r][t[a][n].code]=[]),e["available"+r]||(e["available"+r]={}),e["available"+r][t[a][n].code]=angular.copy(_.differenceBy(s[t[a][n].code],i?x[r][t[a][n].code]:e[r][t[a][n].code],"code")))}}}function I(e,t){t&&!x.consent&&(x.consent={}),t&&!x.consent.columns&&(x.consent.columns=[]),t&&(e.consent||(e.consent={}),e.consent.columns=angular.copy(x.consent.columns)),e.consent||(e.consent={}),e.consent.columns||(e.consent.columns=[]),e.availableConsentColumns||(e.availableConsentColumns=[]),e.availableConsentColumns=angular.copy(_.differenceBy(T,t?x.consent.columns:e.consent.columns,"code"))}function A(e,n){if(!t.isEHxEnabled)return;let i="patientViewsTableParentConfig",o="patientViewsTableConfig",r=a.GENERIC.EXPANDED_VIEWS.EHX.code,s=a.GENERIC.EXPANDED_VIEWS.EHX.child;if(s&&s.length>0){e[i]||(e[i]={}),e[i]&&!e[i][r]&&(e[i][r]=s),n&&!x[i]&&(x[i]={}),n&&!x[i][r]&&(x[i][r]=s),e[o]||(e[o]={}),n&&!x[o]&&(x[o]={});for(let t=0;t<s.length>0;t++){n&&(x[o][s[t]]||(x[o][s[t]]=[]),e[o][s[t]]=angular.copy(x[o][s[t]])),e[o][s[t]]||(e[o][s[t]]=[]),e["available"+o]||(e["available"+o]={});var l=_.find(w,function(e){return e.code===s[t]});l&&l.columns&&(e["available"+o][s[t]]=angular.copy(_.differenceBy(l.columns,n?x[o][s[t]]:e[o][s[t]],"code")))}}}function R(){t.isLoading=!0,i.get().then(function(e){t.showSecurityAnswersConfig&&(e.securityAnswers||(e.securityAnswers={}),e.securityAnswers.partialLocked||(e.securityAnswers.partialLocked={})),P(e,["patient","doctor"]),I(e),A(e);for(let n=0;n<v.length;n++)_.each(t.intConfigFields[v[n]],function(t){0===e[t.name]&&delete e[t.name],t.minMaxValMsg="The value has to be between "+(t.minVal+1)+" and "+("passwordExpiryReminder"===t.name?" the Password Expiry value":t.maxVal)+"!",(e[t.name]||"maxFailedLoginAttempts"===t.name)&&(t[t.name+"Enabled"]=!0)});t.applicationConfig=e,t.isLoading=!1},function(e){t.isLoading=!1})}function N(e,t){return e.display+=(e.display?", "+(e.contor?"":"and at least one "):"The password must contain at least one ")+t,e.contor++,e}t.hideData=function(e){"showSecurity"!==e&&(t.showSecurity=!1),"showLinks"!==e&&(t.showLinks=!1),"showPatientChartsColumns"!==e&&(t.showPatientChartsColumns=!1),"showClinicianDashboardColumns"!==e&&(t.showClinicianDashboardColumns=!1),"showPatientConsentColumns"!==e&&(t.showPatientConsentColumns=!1),"showSecurityAnswers"
8!==e&&(t.showSecurityAnswers=!1)},t.hideData(),t.expandData=function(e){t.hideData(e),t[e]=!t[e]},t.onIntConfigEnabled=function(e,n){t.applicationConfig&&(n||(delete t.applicationConfig[e],"passwordExpiry"===e&&(_.each(t.intConfigFields.secondCol,function(e){"passwordExpiryReminder"===e.name&&(e.passwordExpiryReminderEnabled=!1)}),delete t.applicationConfig.passwordExpiryReminder)))},R(),t.operation="view",t.$watch("applicationConfig.auth.password.validation.options.isCustomRegex",function(e,n){_.isNil(n)||e!==n&&(e?(y=t.applicationConfig.auth.password.validation.display,t.applicationConfig.auth.password.validation.regex=null,t.applicationConfig.auth.password.validation.display=null):(b=!0,t.applicationConfig.auth.password||(t.applicationConfig.auth.password={}),t.applicationConfig.auth.password.validation||(t.applicationConfig.auth.password.validation={}),t.applicationConfig.auth.password.validation.display=y||null))}),t.resetAllToDefault=function(e){t.isLoading=!0,r.all(x?null:[i.getDefaultColumns()]).then(function(n){x||(x=n&&n[0]),x&&("patientConsent"!==e?(P(t.applicationConfig,[e],!0),"patient"===e&&A(t.applicationConfig,!0)):I(t.applicationConfig,!0)),t.isLoading=!1},function(){t.isLoading=!1})},t.requiredOptions={password:!1},t.$watchCollection("[applicationConfig.auth.password.validation.options.hasNumber, applicationConfig.auth.password.validation.options.hasSpecialCharacter,applicationConfig.auth.password.validation.options.hasUpperCaseLetter, applicationConfig.auth.password.validation.options.hasLowerCaseLetter,applicationConfig.auth.password.validation.options.minLength, applicationConfig.auth.password.validation.options.maxLength]",function(e,n){t.applicationConfig&&t.applicationConfig.auth&&t.applicationConfig.auth.password.validation&&t.applicationConfig.auth.password.validation.options&&!t.applicationConfig.auth.password.validation.options.isCustomRegex&&(t.requiredOptions.password=!(e[0]||e[1]||e[2]||e[3])),!b&&(_.isNil(n)||_.isNil(n[0])&&_.isNil(n[1])&&_.isNil(n[2])&&_.isNil(n[3])&&_.isNil(n[4])&&_.isNil(n[5]))||t.applicationConfig.auth.password.validation.options.isCustomRegex||function(e){var n;"password"===e&&(n=t.applicationConfig.auth.password);if(!n)return;var i={display:"",contor:0};n.validation.options.minLength&&n.validation.options.maxLength&&(i.display+="The password must contain between "+n.validation.options.minLength+" and "+n.validation.options.maxLength+" characters ");n.validation.options.hasUpperCaseLetter&&(i=N(i,"upper-case letters"));n.validation.options.hasLowerCaseLetter&&(i=N(i,"lower-case letters"));n.validation.options.hasNumber&&(i=N(i,"numbers"));n.validation.options.hasSpecialCharacter&&(i=N(i,"special characters"));i.contor?t.requiredOptions[e]=!1:t.requiredOptions[e]=!0;i.contor>1&&(i.display=i.display.replace("and at least one","and at least one each of"));n.validation.display=i.display+"."}("password")}),t.editSettings=function(){angular.copy(t.applicationConfig,m),t.operation="edit"},t.cancelChange=function(){t.operation="view",angular.copy(m,t.applicationConfig),t.mainForm.resetForm(),t.requiredOptions.signature=!1},t.addLink=function(){t.applicationConfig.links||(t.applicationConfig.links=[]),t.applicationConfig.links.push({}),t.mainForm.resetForm()},t.removeLink=function(e){t.applicationConfig.links&&t.applicationConfig.links.splice(e,1)},t.save=function(){t.requiredOptions.password||(t.isSaving=!0,function(e,n){var i="";if(e.options.isCustomRegex)e.options.hasUpperCaseLetter&&delete e.options.hasUpperCaseLetter,e.options.hasLowerCaseLetter&&delete e.options.hasLowerCaseLetter,e.options.hasNumber&&delete e.options.hasNumber,e.options.hasSpecialCharacter&&delete e.options.hasSpecialCharacter,e.options.maxLength&&delete e.options.maxLength,e.options.minLength&&delete e.options.minLength;else{if(e.options.hasUpperCaseLetter&&(i+=p),e.options.hasLowerCaseLetter&&(i+=g),e.options.hasNumber&&(i+=f),e.options.hasSpecialCharacter&&(i+=h),!i)return t.requiredOptions[n]=!0,void(t.isSaving=!1);e.regex="^"+i+".{"+e.options.minLength+","+e.options.maxLength+"}$"}}(t.applicationConfig.auth.password.validation,"password"),i.save(t.applicationConfig).then(function(e){u.updateApplicationConfiguration(angular.copy(e)),t.isSaving=!1,t.operation="view"},function(e){t.isSaving=!1}))};var L=t.$on("nxtReloadData",function(e,t){"securitySettings"===t&&R()});t.$on("$destroy",function(){L()})}]),app.ui.administration.controller("nxtApplicationToolsCtrl",["$scope","nxtOrganizationSvc","$uibModal","$q","$document","$window","nxtUserSvc","nxtTemplateViewSvc",function(e,t,n,i,a,o,r,s){"use strict";e.isLoading=!0,e.uploadUsers=function(){var t=e.$new();n.open({templateUrl:"modules/administration/applicationTools/uploadUsers.html",scope:t,controller:"nxtUploadUsersCtrl",backdrop:"static",windowClass:"nxt-lightL-popup",windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})},e.downloadSourceMapping=function(){e.isLoading=!0,t.getSourceMapping().then(function(t){var n=atob(t.data),i=new Blob([n],{type:"data:application/octet-stream;base64"}),r="Current_Source_Mapping.csv";if(o.navigator&&o.navigator.msSaveOrOpenBlob)navigator.msSaveBlob(i,r);else{var s=o.URL.createObjectURL(i),l=a[0].createElement("a");l.href=s,l.target="_blank",l.download=r,a[0].body.appendChild(l),l.click()}e.isLoading=!1},function(){e.isLoading=!1})},e.importData=function(t){var i=e.$new();i.operation=t,n.open({templateUrl:"modules/administration/applicationTools/importData.html",scope:i,controller:"nxtImportDataCtrl",backdrop:"static",windowClass:"nxt-light-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){})},e.downloadTemplate=function(){e.isLoading=!0,r.downloadBulkUserTemplate().then(function(t){var n=new Uint8Array(t),i=new Blob([n],{type:"application/octet-stream"});if(o.navigator&&o.navigator.msSaveOrOpenBlob)navigator.msSaveBlob(i,"BulkUploadTemplate.xlsx");else{var r=o.URL.createObjectURL(i),s=a[0].createElement("a");s.href=r,s.target="_blank",s.download="BulkUploadTemplate.xlsx",a[0].body.appendChild(s),s.click()}e.isLoading=!1},function(t){e.isLoading=!1;s.showModal({closeButtonText:"Close",headerText:"Download Bulk Upload Template",bodyText:"The template download cannot be completed because the Bulk Upload Template file is either missing or invalid."})})},i.all([app.checkPermission("UploadUsers.access"),app.checkPermission("UploadSourceMapping.access")]).then(function(t){e.hasImportUserPermission=t&&t[0]&&t[0].result,e.hasSourceMappingPermission=t&&t[1]&&t[1].result,e.isLoading=!1},function(){e.isLoading=!1})}]),app.ui.administration.controller("nxtImportDataCtrl",["$scope","$uibModalInstance","fileReader","NXT_UPLOAD_CONFIG","nxtOrganizationSvc","CONSTANT","$q",function(e,t,n,i,a,o,r){"use strict";var s;e.maxFileSize=i.MAX_FILE_SIZE,e.allowedFileExtensions="source_mapping"===e.operation?"csv":"xlsx",e.acceptedExtensions=e.allowedFileExtensions.split(" ").map(function(e){return"."+e}).join(","),e.close=function(){t.dismiss("cancel")},e.save=function(){e.isSaving=!0,e.isImportedSuccessfully=!1,r.all("source_mapping"===e.operation?[a.importSourceMapping(e.doc.data)]:[a.importCodeset(e.doc.data,e.doc.title)]).then(function(t){e.isSaving=!1,e.isSaved=!0,e.isImportedSuccessfully=!0},function(t){e.isSaving=!1,e.isImportedSuccessfully=!1;var n=[];if(e.otherErrorMessage="",t&&t.issue&&t.issue.length)for(var i=0;i<t.issue.length;i++)if(t.issue[i]&&t.issue[i].details)switch(t.issue[i].details.code){case o.ERROR.MSG_MISSING_SOURCE_CODE.code:n.push(o.ERROR.MSG_MISSING_SOURCE_CODE.display);break;case o.ERROR.MSG_MISSING_HL7FIELD1_OR_CDAFIELD1.code:n.push(o.ERROR.MSG_MISSING_HL7FIELD1_OR_CDAFIELD1.display);break;case o.ERROR.MSG_INVALID_HL7FIELD1.code:n.push(o.ERROR.MSG_INVALID_HL7FIELD1.display);break;case o.ERROR.MSG_INVALID_CDAFIELD1.code:n.push(o.ERROR.MSG_INVALID_CDAFIELD1.display);break;case o.ERROR.MSG_INVALID_CODESETS.code:n.push(o.ERROR.MSG_INVALID_CODESETS.display);break;case o.ERROR.MSG_FILE_NOT_READABLE.code:n.push(o.ERROR.MSG_FILE_NOT_READABLE.display);break;case o.ERROR.MSG_INVALID_SHEET_NAME.code:n.push(o.ERROR.MSG_INVALID_SHEET_NAME.display)}
80===n.length&&n.push(t&&t.display?t.display:_.isEmpty(t)?"":t),e.otherErrorMessage=n.join("</br>"),e.mainForm.$setValidity("otherErrorMessage",!1)})},e.doc={},e.readFile=function(){if(s=this.mainForm,e.otherErrorMessage=null,e.isImportedSuccessfully=!1,s.$setValidity("otherErrorMessage",!0),!e.doc.file)return s.$setValidity("fileSize",!0),void s.$setValidity("fileExtension",!0);e.doc.title=e.doc.file.name,s.$setValidity("fileSize",d(e.doc.file)),s.$setValidity("fileExtension",l(e.doc.file)),d(e.doc.file)&&l(e.doc.file)&&(e.isLoading=!0,n.readAsDataUrl(e.doc.file,e).then(function(t){e.doc.data=t,e.isLoading=!1,s.$setValidity("fileSize",d(e.doc.file)),s.$setValidity("fileExtension",l(e.doc.file))},function(t){e.doc.data=void 0,e.isLoading=!1,s.$setValidity("fileSize",!0),s.$setValidity("fileExtension",!0)}))};var l=function(t){if(!t.name||t.name.indexOf(".")<0)return!1;var n=_.last(t.name.split(".")).toLowerCase();return e.allowedFileExtensions.split(" ").indexOf(n)>=0},d=function(t){return t.size<=1048576*e.maxFileSize}}]),app.ui.administration.controller("nxtUploadUsersCtrl",["$scope","$uibModalInstance","fileReader","NXT_UPLOAD_CONFIG","nxtUserSvc","CONSTANT","NXT_USERNAME_PATTERN",function(e,t,n,i,a,o,r){"use strict";var s;e.maxFileSize=i.MAX_FILE_SIZE,e.allowedFileExtensions="xlsx",e.acceptedExtensions=e.allowedFileExtensions.split(" ").map(function(e){return"."+e}).join(","),e.sort={field:"username",direction:""},e.usernamePatternMessage=r.PatternMessage,e.close=function(){t.dismiss("cancel")},e.save=function(){e.isSaving=!0,e.item=null,a.import(e.doc.data).then(function(t){e.isSaving=!1,e.isSaved=!0,e.sort={field:"username",direction:""},t.lines=_.sortBy(t.lines,e.sort.field),e.item=t},function(t){e.isSaving=!1,e.item=null,t&&t.issue&&t.issue.length&&t.issue[0]&&t.issue[0].details.code&&(t.issue[0].details.code===o.ERROR.MSG_INVALID_HEADERS.code?(e.otherErrorMessage=o.ERROR.MSG_INVALID_HEADERS.display,t.issue[0].diagnostics&&(e.otherErrorMessage+=" "+t.issue[0].diagnostics)):t.issue[0].details.code===o.ERROR.MSG_INVALID_SHEET_NAME.code?e.otherErrorMessage=o.ERROR.MSG_INVALID_SHEET_NAME.display:t.issue[0].details.code===o.ERROR.MSG_INVALID_UPLOAD_USER_CONFIGURATION.code&&(e.otherErrorMessage=o.ERROR.MSG_INVALID_UPLOAD_USER_CONFIGURATION.display)),_.isEmpty(e.otherErrorMessage)&&(e.otherErrorMessage=t&&t.display?t.display:_.isEmpty(t)?"":t),e.mainForm.$setValidity("otherErrorMessage",!1)})},e.sortData=function(t){t!==e.sort.field?(e.sort.field=t,e.sort.direction=""):e.sort.direction=_.isEmpty(e.sort.direction)?"-":"",_.isEmpty(e.sort.direction)?e.item.lines=_.sortBy(e.item.lines,e.sort.field):e.item.lines=_.reverse(_.sortBy(e.item.lines,e.sort.field))},e.doc={},e.readFile=function(){if(s=this.mainForm,e.otherErrorMessage=null,s.$setValidity("otherErrorMessage",!0),!e.doc.file)return s.$setValidity("fileSize",!0),void s.$setValidity("fileExtension",!0);e.doc.title=e.doc.file.name,s.$setValidity("fileSize",d(e.doc.file)),s.$setValidity("fileExtension",l(e.doc.file)),d(e.doc.file)&&l(e.doc.file)&&(e.isLoading=!0,n.readAsDataUrl(e.doc.file,e).then(function(t){e.doc.data=t,e.isLoading=!1,s.$setValidity("fileSize",d(e.doc.file)),s.$setValidity("fileExtension",l(e.doc.file))},function(t){e.doc.data=void 0,e.isLoading=!1,s.$setValidity("fileSize",!0),s.$setValidity("fileExtension",!0)}))};var l=function(t){if(!t.name||t.name.indexOf(".")<0)return!1;var n=_.last(t.name.split(".")).toLowerCase();return e.allowedFileExtensions.split(" ").indexOf(n)>=0},d=function(t){return t.size<=1048576*e.maxFileSize}}]),app.ui.administration.controller("nxtClinicalLabGroupsCtrl",["$scope","$q","nxtValueSetSvc","nxtConceptSvc","gettextCatalog","nxtDeleteMessageBoxSvc","nxtTemplateViewSvc","nxtFilterDataSvc","nxtResourceTypesSvc","nxtInfiniteScrollSvc","nxtUserContextSvc",function(e,t,n,i,a,o,r,s,l,d,c){"use strict";var u,p,g={name:"Locked",valueBoolean:!1,language:"en",propertyType:{code:"valueBoolean"}},f={locked:angular.copy(g),group:new l.Concept({system:"http://infoworld.ro/nxt/clinical-lab-groups",valueSet:[{id:"http://infoworld.ro/nxt/vs/clinical-lab-groups",name:"ClinicalLabGroups"}]})},h={},m={};h.nxtValueSetSvc={methodName:"get"},e.infiniteScroll=d.create({services:h,limit:100}),e.filterBy={name:null};var v="admClinicalLabGroupsContext";function S(t){e.loadingLaboratoryTest&&(e.loadingLaboratoryTest=!0),t||(e.clinicalLabGroupList=[]),m.nxtValueSetSvc={valueSetName:"ClinicalLabGroups",limit:100,withoutSummary:!0,text:e.filterBy&&e.filterBy.name?e.filterBy.name:null},e.infiniteScroll.isBusy(!t,m)||e.infiniteScroll.nextPage(!t).then(function(n){e.clinicalLabGroupList||(e.clinicalLabGroupList=[]),e.clinicalLabGroupList=t?e.clinicalLabGroupList.concat(n):n,e.setClinicalLabGroup(e.clinicalLabGroupList[0]),t||(e.operation=e.clinicalLabGroupList&&e.clinicalLabGroupList.length>0?"view":null,e.changeSelection(e.clinicalLabGroupList&&e.clinicalLabGroupList.length>0?e.clinicalLabGroupList[0]:null))})}e.$watch("filterBy.name",function(t,n){(!t||t&&t.length>=3)&&(S(),c.setCurrentPageContextProperty(v,{name:e.filterBy.name}))}),function(){if(!e.currentPageContextChecked){var t=c.getCurrentPageContextProperty(v);t&&(e.filterBy.name=t.name,e.currentPageContextChecked=!0)}}(),e.selectedGroup=angular.copy(f),e.getMoreData=function(){S(!0)},e.filterLabTest=function(e){return!0!==e.isDeleted};var C=0;function y(){var n=e.selectedGroup.group,a=!1;if(n.property&&n.property.length>0)for(let t=0;t<n.property.length;t++)if("Locked"===n.property[t].name){a=!0,n.property[t]=e.selectedGroup.locked;break}a||(n.property||(n.property=[]),n.property.push(e.selectedGroup.locked)),"add"===e.operation&&(n.code=u);var o=[];o.push(i.save(n));for(let t=0;t<e.labTestList.length;t++){var r=new l.Concept(e.labTestList[t].labTest,e.labTestList[t].labTest.i
8d);e.labTestList[t].isAdded&&(r.relationship||(r.relationship=[]),r.relationship.push({valueset:"ClinicalLabGroups",type:"is-part-of",target:u}),o.push(i.save(r))),e.labTestList[t].isDeleted&&(r.relationship=$.grep(r.relationship,function(e){return"ClinicalLabGroups"!==e.valueset&&"is-part-of"!==e.type}),o.push(i.save(r)))}t.all(o).then(function(t){if("add"===e.operation)e.clinicalLabGroupListSelectedItem=null,e.clinicalLabGroupList=[t[0]].concat(e.clinicalLabGroupList);else for(let n=0;n<e.clinicalLabGroupList.length;n++)if(e.clinicalLabGroupList[n].code===u){e.clinicalLabGroupList[n].display=t[0].display,e.clinicalLabGroupList[n].property=t[0].property,e.selectedGroup=null;break}t[0].id=t[0].id,e.operation="view",e.setClinicalLabGroup(t[0],!0)},function(t){e.loadingLaboratoryTest=!1})}function b(){u=null,p=!1,e.labTestList=[],e.loadingLaboratoryTest=!1,e.groupForm&&e.groupForm.resetForm()}e.addLabTest=function(){e.labTestList||(e.labTestList=[]),C++,e.labTestList.push({id:C,htmlControlName:"labTestCtrl"+C,isAdded:!0})},e.setClinicalLabGroup=function(t,n,a){if("add"!==e.operation&&"edit"!==e.operation)if(t){if(!e.selectedGroup||!t||e.selectedGroup.group.code!==t.code||n||a){e.groupForm&&e.groupForm.resetForm(),e.loadingLaboratoryTest=!0;var o={group:new l.Concept(t,t.id),locked:angular.copy(g)};if(o.group.id=t.id,t.property&&t.property.length>0){var r=$.grep(t.property,function(e){return"Locked"===e.name});r&&r.length>0&&(o.locked.valueBoolean=r[0].valueBoolean)}else o.locked.valueBoolean=!0;if(e.selectedGroup=angular.copy(o),p=e.selectedGroup.locked.valueBoolean,n){if(e.labTestList&&e.labTestList.length>0)for(let t=0;t<e.labTestList.length;t++)Object.prototype.hasOwnProperty.call(e.labTestList[t],"isAdded")&&(e.labTestList[t].labTest.relationship||(e.labTestList[t].labTest.relationship=[]),e.labTestList[t].labTest.relationship.push({valueset:"ClinicalLabGroups",sequence:"3",type:"is-part-of",target:u}),delete e.labTestList[t].isAdded);e.labTestList=$.grep(e.labTestList,function(e){return!e.isDeleted}),e.loadingLaboratoryTest=!1}else e.labTestList=[],i.getConceptRelationship({code:e.selectedGroup.group.code,valueSetName:"LaboratoryResultsTest",relationshipType:"is-part-of"}).then(function(t){if(t&&t.length>0)for(let n=0;n<t.length;n++)C++,e.labTestList.push({htmlControlName:"labTestCtrl"+C,id:C,labTest:t[n]});e.loadingLaboratoryTest=!1},function(t){e.loadingLaboratoryTest=!1});e.clinicalLabGroupListSelectedItem?e.clinicalLabGroupListSelectedItem.$selected||e.changeSelection(e.clinicalLabGroupListSelectedItem):e.changeSelection(e.clinicalLabGroupList[0])}}else e.clinicalLabGroupListSelectedItem=null},e.addClinicalLabGroup=function(){e.selectedGroup=angular.copy(f),b(),e.operation="add",e.resetFocus=!e.resetFocus},e.editClinicalLabGroup=function(){e.operation="edit",e.resetFocus=!e.resetFocus},e.close=function(){e.operation=e.clinicalLabGroupList.length>0?"view":null,"view"===e.operation&&(e.selectedGroup.group.code?e.setClinicalLabGroup(_.find(e.clinicalLabGroupList,function(t){return t.code===e.selectedGroup.group.code}),null,!0):e.setClinicalLabGroup(e.clinicalLabGroupList[0]))},e.deleteClinicalLabGroup=function(){var n=[],d=null;e.loadingLaboratoryTest=!0,s.search({type:"labResults",paramCode:e.selectedGroup.group.code}).then(function(s){if(s&&s.length>0){let t={closeButtonText:a.getString("Close"),headerText:a.getString("Clinical lab group"),bodyText:'<div style="margin-bottom: 20px !important; margin-top: 10px !important;">'+a.getString("You cannot delete this clinical lab group because it is being used by filter data")+"</div>"};r.showModalDialog(t).then(function(){e.loadingLaboratoryTest=!1},function(t){e.loadingLaboratoryTest=!1})}else{var c=(p?"This grouped is locked and represents a commonly used clinical lab group. ":"")+"Are you sure you want to delete it?";let r={closeButtonText:a.getString("Cancel"),actionButtonText:a.getString("Ok"),headerText:a.getString("Clinical lab group"),bodyText:c};o.showModal(r).then(function(){for(let t=0;t<e.labTestList.length;t++)(d=new l.Concept(e.labTestList[t].labTest,e.labTestList[t].labTest.i
8d)).relationship=$.grep(d.relationship,function(e){return"ClinicalLabGroups"!==e.valueset&&"is-part-of"!==e.type}),n.push(i.save(d));n.push(i.del(e.selectedGroup.group.id)),t.all(n).then(function(t){for(let t=0;t<e.clinicalLabGroupList.length;t++)if(e.clinicalLabGroupList[t].code===e.selectedGroup.group.code){e.clinicalLabGroupList.splice(t,1),e.clinicalLabGroupListSelectedItem=null;break}e.operation=e.clinicalLabGroupList.length>0?"view":null,b(),e.clinicalLabGroupList&&e.clinicalLabGroupList.length>0&&e.setClinicalLabGroup(e.clinicalLabGroupList[0])},function(t){e.loadingLaboratoryTest=!1})},function(t){e.loadingLaboratoryTest=!1})}},function(t){e.loadingLaboratoryTest=!1})},e.deleteLabTest=function(t){var n=t.id,i=$.grep(e.labTestList,function(e){return e.id===n})[0];Object.prototype.hasOwnProperty.call(i,"isAdded")?e.labTestList=$.grep(e.labTestList,function(e){return e.id!==n}):i.isDeleted=!0,e.currentDeletedLab=t},e.saveClinicalLabGroup=function(){if(e.loadingLaboratoryTest=!0,u=e.selectedGroup.group.code,"edit"===e.operation&&p&&p!==e.selectedGroup.locked.valueBoolean){let t={closeButtonText:a.getString("Cancel"),actionButtonText:a.getString("Ok"),headerText:a.getString("Clinical lab group"),bodyText:a.getString("This grouped is locked and represents a commonly used clinical lab group. Are you sure you want to unlock it?")};o.showModal(t).then(function(){y()},function(t){e.loadingLaboratoryTest=!1})}else y()};var x=e.$on("nxtReloadData",function(e,t){"clinicalLabGroups"===t&&S()});e.$on("$destroy",function(){x()})}]),app.dashboardWidgets.directive("nxtAccountOptions",["$compile","nxtUserContextSvc","NXT_SSO_CONFIG",function(e,t,n){"use strict";return{restrict:"E",scope:!0,replace:!0,terminal:!0,compile:function(i,a,o){return{pre:function(i,a,o){var r=angular.element('<div class="height-align"><a href="" nxt-popup="$next:ul" nxt-popup-centered="true" data-module="administration" ng-controller="nxtUserProfileCtrl" ng-class="{\'disabled-href-link\': isMenuDisabled}"  aria-label="Click to open user profile" ng-click="myLinks.show=false;"><i class="fa fa-user"></i><span>{{userNameProfile}}</span><span class="to-be-hidden">Click to open user profile</span></a><ul id="account-option-list" class="uib-dropdown-menu dropdown-menu multi-action-sel" aria-label="Account options"><li tabindex="0"><a href="" data-module="administration" ng-controller="nxtUserProfileCtrl" ng-click="selectUserProfile()">My Profile</a></li><li tabindex="0"><a href="" data-module="administration" ng-controller="nxtUserProfileCtrl" ng-click="userSettings()">User Settings</a></li><li tabindex="0" ng-if="myLinks.values" class="nxt-popup-no-hide"><a href="" ng-click="toggleMyLinks($event)">My Links</a></li><li tabindex="0" ng-if="myLinks.values&&myLinks.show" ng-show="myLinks.show" class="nxt-account-sublink" ng-repeat="link in myLinks.values"><a href="{{link.url}}" target="_blank" class="padding-left-20">{{link.display}}</a></li></ul></div>');a.replaceWith(e(r)(i)),i.myLinks={},i.$watch(function(){return t.LoggedUserConfiguration},function(e){e&&e.links&&e.links.length?i.myLinks.values=e.links:i.myLinks.values=null}),i.$watch(function(){return app.ui.SSO},function(e){e&&(i.isMenuDisabled=!n.EnabledMenuItems)}),i.toggleMyLinks=function(e){e.preventDefault(),i.myLinks||(i.myLinks={}),i.myLinks.show=!i.myLinks.show}},post:function(e,t,n){}}}}}]),app.ui.administration.directive("nxtGroupAlreadyExists",["nxtValueSetSvc",function(e){"use strict";return{require:"ngModel",scope:{system:"=",operation:"="},link:function(t,n,i,a){var o=function(n){return n&&i.nxtGroupAlreadyExists?e.search({text:n,valueSetName:"ClinicalLabGroups",limit:2,searchField:"display_raw:exact"}).then(function(e){var n=!0;e&&e.length>1?n=!1:e&&e.length>0&&("add"===t.operation?n=!1:e[0].code!==i.nxtGroupAlreadyExists&&e[0].system===t.system&&(n=!1)),a.$setValidity("groupAlreadyExists",n)},function(e){a.$setValidity("groupAlreadyExists",!1)}):a.$setValidity("groupAlreadyExists",!0),n};a.$parsers.unshift(o),a.$formatters.push(o),i.$observe("nxtGroupAlreadyExists",function(e){return o(a.$viewValue)})}}}]),app.ui.administration.directive("nxtLabAlreadyExists",["$parse",function(e){"use strict";return{require:"ngModel",scope:{labTestList:"=",groupCode:"="},link:function(t,n,i,a){t.test=null;var o=function(e,n){if(n||(t.test=e),t.test&&t.test.isAdded&&t.test.labTest)if(t.test.labTest.relationship&&t.test.labTest.relationship.length>
80){if(r())return void a.$setValidity("labAlreadyExists",!1);var i=$.grep(t.test.labTest.relationship,function(e){return"ClinicalLabGroups"===e.valueset&&"is-part-of"===e.type});if(i&&i.length>0){var o=!(!t.groupCode||i[0].target!==t.groupCode);return a.$setValidity("labAlreadyExists",o),o?t.test:void 0}}else if(r())return void a.$setValidity("labAlreadyExists",!1);return a.$setValidity("labAlreadyExists",!0),t.test},r=function(){for(var e=0;e<t.labTestList.length;e++)if(t.labTestList[e].id!==t.test.id&&t.labTestList[e].labTest&&t.test.labTest&&t.labTestList[e].labTest.code===t.test.labTest.code&&!t.labTestList[e].isDeleted)return!0;return!1};a.$parsers.unshift(o),a.$formatters.push(o),i.$observe("nxtLabAlreadyExists",function(n){return t.test=e(n)(t),o(e(n)(t))},!0),i.$observe("nxtDeletedLab",function(e){if(e)return o(null,!0)},!0)}}}]),app.ui.administration.config(["gettext",function(e){"use strict";app.ui.administration.link={url:"/administration",name:e("Administration"),code:"administration"}}]),app.ui.administration.controller("nxtAdministrationCtrl",["$scope","nxtUserContextSvc",function(e,t){"use strict";t.setCurrentPageContextProperty("serviceCategoryManagementContext",!0),function(){if(e.currentPageContextChecked)return;var n=t.getCurrentPageContextProperty("administrationTabsContext");n&&n.selectedTabId&&t.setSelectedModuleTab(n.selectedTabId,"administration");e.currentPageContextChecked=!0}(),e.tabSelected=function(n){t.setCurrentPageContextProperty("administrationTabsContext",{selectedTabId:n}),e.$broadcast("nxtReloadData",n)}}]),app.ui.administration.controller("nxtUserProfileCtrl",["$scope","$uibModal","nxtUserContextSvc","NXT_SSO_CONFIG","NXT_SHOW_USERNAME",function(e,t,n,i,a){"use strict";function o(t){var n=e.profileSvc.loggedUser.family+" "+e.profileSvc.loggedUser.given,o=a?"("+e.profileSvc.loggedUser.username+")":"";return app.ui.SSO&&(i.ShowJWTClinicianName&&(n="",t&&t.clinicianFirstName&&(n=t.clinicianFirstName),t&&t.clinicianLastName&&(n+=(n?" ":"")+t.clinicianLastName)),a&&i.ShowJWTClinicianIdentifier&&(o=t&&t.clinicianIdentifier?"("+t.clinicianIdentifier+")":"")),n+(o&&n?" ":"")+(o||"")}e.profileSvc=n,e.$watch(function(){return n.getCurrentPageContextProperty("SSOClinicianDashboardContext")},function(){if(e.profileSvc.loggedUser&&app.ui.SSO){var t=n.getCurrentPageContextProperty("SSOClinicianDashboardContext");e.userNameProfile=o(t)}else e.profileSvc.loggedUser?e.userNameProfile=o():e.userNameProfile=null}),e.$watch("profileSvc.loggedUser.username",function(){e.profileSvc.loggedUser&&!app.ui.SSO?e.userNameProfile=o():e.userNameProfile=null},!0),e.selectUserProfile=function(){var n=e.$new();n.operation="profile",t.open({templateUrl:"modules/administration/users/userEdit.html",scope:n,backdrop:"static",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtUserEditCtrl",windowClass:"nxt-big-popup"}).result.then(function(e){},function(){})},e.userSettings=function(){var n=e.$new();t.open({templateUrl:"modules/administration/users/userSettings.html",scope:n,backdrop:"static",controller:"nxtUserSettingsCtrl",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",windowClass:"modal-settings"}).result.then(function(e){},function(){})},e.workstationConfiguration=function(){var n=e.$new();t.open({templateUrl:"modules/administration/users/workstationConfiguration.html",scope:n,backdrop:"static",controller:"nxtWorkstationConfigurationCtrl",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",windowClass:"modal-settings"}).result.then(function(e){},function(){})},e.privacyPolicy=function(){var n=e.$new();t.open({templateUrl:"modules/administration/privacyPolicy/index.html",scope:n,windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtPrivacyPolicyCtrl",backdrop:"static"}).result.then(function(){},function(){})},e.support=function(){var n=e.$new();t.open({templateUrl:"modules/administration/support/support.html",scope:n,windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtSupportCtrl",backdrop:"static"}).result.then(function(){},function(){})}}]),app.ui.administration.controller("nxtOrganizationAddEditCtrl",["$scope","nxtOrganizationSvc","gettextCatalog","CONSTANT","nxtValueSetSvc","$q","NXT_PHONE_NUMBER","NXT_SYNC_USER_STATUS_BASED_ON_ORGANIZATION","nxtDeleteMessageBoxSvc","NXT_ENABLED_2FA",function(e,t,n,i,a,o,r,s,l,d){"use strict";if(e.searchSource=t.searchSource,e.searchOrganization=t.search,e.phoneNumberConfig=r,e.isEnabled2FA=d,e.popupTitle||("edit"===e.operation?e.popupTitle="organization"===e.category?n.getString("Edit organization"):n.get
8String("Edit suborganization"):"add"===e.operation?e.popupTitle="organization"===e.category?n.getString("Add organization"):n.getString("Add suborganization to ")+(e.partOf.name||e.partOf.display):e.popupTitle="organization"===e.category?n.getString("View organization"):n.getString("View suborganization")),"edit"===e.operation&&e.organizationId){var c=[];e.isLoading=!0,c[0]=t.get(e.organizationId,"organization"===e.category),c[1]=p(),o.all(c).then(function(t){e.organization=t[0],u(),e.isLoading=!1},function(t){e.isLoading=!1})}else"add"===e.operation?(e.isLoading=!0,p().then(function(){e.isLoading=!1},function(){e.isLoading=!1}),e.organization=t.create(),e.organization.active=!0,e.partOf&&(e.organization.partOf=e.partOf),e.category&&(e.organization.category=e.category),e.root&&(e.organization.root=e.root),u()):"view"===e.operation&&e.organization&&u();function u(){e.isEnabled2FA&&(e.organization.mandatory2FA=e.organization.mandatory2FA||!1),e.initialOrganizationStatus="organization"===e.organization.category?e.organization.active:null,"organization"!==e.organization.category||e.organization.labAccounts&&0!==e.organization.labAccounts.length||g()}function p(){var t=o.defer();return a.searchRecurrent({valueSetName:"practiceSetting"}).then(function(n){e.organizationTypes=n,t.resolve()},function(){t.reject()}),t.promise}function g(){e.organization.labAccounts||(e.organization.labAccounts=[]),e.organization.labAccounts.push({organization:null,number:null})}function f(){var n=angular.copy(e.organization);if(n.labAccounts&&n.labAccounts.length>0){var a=_.filter(n.labAccounts,function(e){return!_.isNil(e.organization)&&!_.isEmpty(e.organization)});n.labAccounts=a&&a.length>0?a:[{organization:null,number:null}]}e.organization=n,t.save(e.organization).then(function(){e.$emit("onOrganizationSavedEvent",e.organization,e.operation),e.isSaving=!1},function(t){if(t&&t.issue&&t.issue.length)for(var n=0;n<t.issue.length;n++){var a;if(t.issue[n].targetResource&&(a=t.issue[n].targetResource.display),t.issue[n]&&t.issue[n].details){if(t.issue[n].details.code===i.ERROR.MSG_ORGANIZATION_UNIQUE_NAME.code){e.errorMessage=i.ERROR.MSG_ORGANIZATION_UNIQUE_NAME.display;break}if(t.issue[n].details.code===i.ERROR.MSG_DUPLICATE_IDENTIFIER_NPI.code){e.npiNumberErrorMsg=i.ERROR.MSG_DUPLICATE_IDENTIFIER_NPI.display+" "+a;break}}}e.isSaving=!1})}e.$watch("organization.npiNumber",function(t,n){t!==n&&(e.npiNumberErrorMsg=null)}),e.$watch("organization.tinNumber",function(t,n){t!==n&&(e.tinNumberErrorMsg=null)}),e.customMaxLength=200,e.initialOrganizationStatus,e.$watch("organization.name",function(t,n){t!==n&&(e.errorMessage=null)}),e.addLabAccount=function(){g()},e.removeLabAccount=function(t){e.organization.labAccounts.splice(t,1)},e.save=function(){if(e.isSaving=!0,s&&"edit"===e.operation&&null!==e.initialOrganizationStatus&&e.initialOrganizationStatus!==e.organization.active){let t={closeButtonText:n.getString("Cancel"),actionButtonText:n.getString("Ok"),headerText:e.organization.active?n.getString("Activate organization"):n.getString("Inactivate organization"),bodyText:e.organization.active?n.getString("All users who are members of this organization will be re-activate.")+"<br/>"+n.getString("Are you sure you want to activate this organization?"):n.getString("All users who are members of this organization will be inactivate.")+"<br/>"+n.getString("Are you sure you want to inactivate this organization?")};l.showModal(t).then(function(){f()},function(){e.isSaving=!1})}else f()},e.cancel=function(){e.$emit("onOrganizationCancelledEvent")}}]),app.ui.administration.controller("nxtOrganizationCtrl",["$scope","nxtOrganizationSvc","gettextCatalog","$timeout","nxtUserContextSvc","nxtInfiniteScrollSvc","$q",function(e,t,n,i,a,o,r){"use strict";e.selectedNode={},e.treeData=[],e.treeOrganizationsControl={};var s,l,d=100,c="=name",u={},p="admOrganizationTreeContext",g=[];function f(){e.operation=e.treeData&&e.treeData.length>0?"view":null,"view"===e.operation?(e.selectedNode&&e.selectedNode.data||(e.selectedNode=e.treeData[0],e.selectedNode.selected=!0,e.selectedNode.initialSelectedId=e.treeData[0].data.id),v("view")):e.organizationTreeData=null}function h(n,i){e.isLoading=!0;var a=i||e.selectedNode;return n||(n=r.defer()),t.searchWithTotalRows({category:"suborganization",partOf:a.data,limit:d,pageNo:a.data.nodePage,sort:c,showAllOrganizations:!0}).then(function(t){if(t&&t.entries&&t.entries.length>0){g=g.concat(t.entries);var i=_.find(g,function(e){return e.id===t.entries[0].root.id});for(let e=0;e<t.entries.length;e++)a.children.push(m(t.entries[e],i));a.children=_.sortBy(a.children,"label"),a.noLeaf=0!==a.children.length,t.totalResults>a.children.length?(a.data.nodePage++,h(n,a)):(a.children=_.uniqBy(a.children,"data.id"),a.childrenLoaded=!0,n.resolve(a))}else n.resolve(a);e.isLoading=!1},function(t){e.isLoading=!1}),n.promise}function m(t,n){if(t){var i={};return i.label=t.name,i.data=t,i.noLeaf=!0,e.filter.showAllOrganizations?(n||(n=b(t)),i.label+=" ["+(n.active?"active":"inactive")+"]",i.classes=n.active?[]:["abn_tree_row_inactive"]):i.classes=[],i}}function v(t,n,a,o){e.operation=t,e.organizationTreeData=null,s=i(function(){if(a||(a=e.selectedNode&&e.selectedNode.data&&e.selectedNode.data.category),a){var i={operation:t};"suborganization"===a&&"add"===t&&(i.root=b(e.selectedNode.data)),i.category=a,"add"===t?i.partOf=o:"edit"===t?i.organizationId=n:"view"===t&&e.selectedNode&&(i.organization=angular.copy(e.selectedNode.data)),e.organizationTreeData=i}},10)}function S(t,n){_.find(g,function(e){return e.id===t.id})||g.push(t),function(t){if("organization"!==t.category||e.filter.showAllOrganizations||t.active){var n=m(t);"suborganization"===t.category?(_.find(e.selectedNode.children,function(e){e.data.id,n.data.id})||e.selectedNode.children.push(n),e.selectedNode.children=_.sortBy(e.selectedNode.children,"label")):(e.treeData||(e.treeData=[]),e.treeData.unshift(n),e.treeData.children=_.sortBy(e.treeData.children,"label"))}}(t),l=i(function(){e.operation="view",n?e.treeOrganizationsControl.select_branch(_.find(e.selectedNode.children,function(e){return e.data.id===t.id})):e.treeOrganizationsControl.select_first_branch()},10)}u.nxtOrganizationSvc={methodName:"searchWithTotalRows"},e.infiniteScroll=o.create({services:u,limit:100}),!a.LoggedUserConfiguration||a.LoggedUserConfiguration.organization&&a.LoggedUserConfiguration.organization.id||(e.isSystemAdmin=!0),e.filter={filterByName:e.isSystemAdmin?null:a.LoggedUserConfiguration.organization.name,showAllOrganizations:!1},e.$watchCollection("[filter.filterByName, filter.showAllOrganizations]",function(t,n){(!t[0]||t[0]&&t[0].length>=3)&&(e.getNextPage(),a.setCurrentPageContextProperty(p,{name:e.filter.filterByName,showAllOrganizations:e.filter.showAllOrganizations}))}),function(){if(e.currentPageContextChecked)return;var t=a.getCurrentPageContextProperty(p);t&&(e.filter.filterByName=t.name,e.filter.showAllOrganizations=t.showAllOrganizations,e.currentPageContextChecked=!0)}(),e.getNextPage=function(t){t||(e.treeData=[],e.selectedNode=null);var n={};n.nxtOrganizationSvc={text:e.filter.filterByName,sort:c,showAllOrganizations:e.filter.showAllOrganizations,category:"organization"},e.infiniteScroll.isBusy(!t,n)||e.infiniteScroll.nextPage(!t).then(function(n){e.treeData||(e.treeData=[]);var i=[];for(let e=0;e<n.length;e++)i.push(m(n[e]));e.treeData=t?e.treeData.concat(i):i,g=t?g.concat(n):n,t||f()})},e.loadData=function(t){if("add"===e.operation||"edit"===e.operation)return e.selectedNode&&(e.selectedNode.selected=!0),void(t.selected=!1);var n=!1;
8if(e.selectedNode&&Object.prototype.hasOwnProperty.call(e.selectedNode,"initialSelectedId"))if(e.selectedNode.initialSelectedId===t.initialSelectedId)n=!0;else for(let t=0;t<e.treeData.length;t++)if(Object.prototype.hasOwnProperty.call(e.treeData[t],"initialSelectedId")&&e.treeData[t].initialSelectedId===e.selectedNode.initialSelectedId){delete e.treeData[t].initialSelectedId;break}!n&&e.selectedNode&&e.selectedNode.selected&&!e.selectedNode.expanded&&(e.selectedNode.selected=!1),e.selectedNode=t,t.childrenLoaded?f():(t.children||(t.children=[]),t.data.nodePage||(t.data.nodePage=1),h(null,t).then(function(){f()}))},e.addEditOrganization=function(t,n){t?v("edit",e.selectedNode.data.id,e.selectedNode.data.category||"organization"):v("add",null,n||"organization","suborganization"===n?e.selectedNode.data:null)};var C=e.$on("onOrganizationCancelledEvent",function(e){e.stopPropagation(),f()}),y=e.$on("onOrganizationSavedEvent",function(t,n,i){if(t.stopPropagation(),"edit"!==i)n&&n.partOf&&n.partOf.id?e.selectedNode.expanded?S(n,!0):h().then(function(t){e.selectedNode=angular.extend(t,{expanded:!0,selected:!1}),S(n,!0)}):S(n,!1);else{if(e.filter.showAllOrganizations||n.active){if("organization"===n.category)for(let e=0;e<g.length;e++)if(g[e].id===n.id){g[e]=n;break}var a=b(n);e.selectedNode.data=n,e.selectedNode.label=e.selectedNode.data.name,e.selectedNode.label+=e.filter.showAllOrganizations?" ["+(a.active?"active":"inactive")+"]":"",e.selectedNode.selected=!0,a.active?e.selectedNode.classes=_.filter(e.selectedNode.classes,function(e){return"abn_tree_row_inactive"!==e}):(e.selectedNode.classes||(e.selectedNode.classes=[]),e.selectedNode.classes.push("abn_tree_row_inactive")),e.filter.showAllOrganizations&&function t(n,i){for(let a=0;a<n.children.length;++a)n.children[a].label=n.children[a].data.name+(e.filter.showAllOrganizations?" ["+(i?"active":"inactive")+"]":""),t(n.children[a],i)}(e.selectedNode,a.active)}else for(let t=0;t<e.treeData.length;t++)if(e.treeData[t].data.id===n.id){e.treeData.splice(t,1),e.selectedNode=null;break}f()}});function b(e){return"suborganization"===e.category?e&&e.root&&e.root.id?_.find(g,function(t){return t.id===e.root.id}):b(_.find(g,function(t){return t.id===e.partOf.id})):e}e.editNode=function(){e.addEditOrganization(!0)},e.addNode=function(){e.addEditOrganization(!1,"suborganization")},e.getTypeDisplay=function(e){return e&&"suborganization"===e.category?n.getString("Suborganization"):n.getString("Organization")};var x=e.$on("nxtReloadData",function(t,n){"organizationManagement"===n&&e.getNextPage()});e.$on("$destroy",function(){x(),C(),y(),s&&i.cancel(s),l&&i.cancel(l)})}]),app.ui.administration.controller("nxtPrivacyPolicyCtrl",["$scope","$uibModalInstance","nxtUserContextSvc","nxtUserProfileSvc","nxtUserSvc",function(e,t,n,i,a){"use strict";e.acceptPrivacyPolicy=function(){e.loading=!0;var i=n.loggedUser;i.agreements||(i.agreements=[]);var o=new Date;i.agreements.push(new Date(o.getFullYear(),o.getMonth(),o.getDate(),0,0,0)),a.save(i).then(function(){t.close()},function(){e.closePrivacyPolicy()})},e.closePrivacyPolicy=function(){e.acceptAgreement?(e.loading=!0,i.logout().then(function(){n.logoutCallback(),t.dismiss("cancel")},function(){n.logoutCallback(),t.dismiss("cancel"),e.loading=!1})):t.dismiss("cancel")}}]),app.ui.administration.controller("nxtRoleConfigurationCtrl",["$scope","$q","nxtSecuritySvc","nxtInfiniteScrollSvc","nxtConfigurationSvc","nxtUserContextSvc","gettextCatalog","nxtUtilsSvc","CONSTANT","NXT_API_ENDPOINTS","nxtDeleteMessageBoxSvc","NXT_ALLOW_MODIFY_USERS_CONFIG_ACCORDING_TO_ROLE_CONFIG","NXT_AUTHORIZATION_ENABLED","$timeout","nxtAttestationSvc",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f){"use strict";var h={},m={},v="admRoleConfigurationContext";m.nxtSecuritySvc={methodName:"getRolesWithTotalRows"},e.infiniteScroll=i.create({services:m,limit:100}),e.filterBy={name:null},e.conflictsVitalsList=["pacVitalS","pacVitalSparklines"];var S=[];e.roleConfig={};var C=_.map(s.doctorDashboardWidgets,function(e){return{code:e.code,display:e.display}}),y=_.map(s.patientBannerList,function(e){return{code:e.code,display:e.display}}),b=_.map(s.patientDashboardWidgets,function(e){var t={code:e.code,display:e.display.replace("Review","").trim()};return"pacVitalS"===e.code&&(t.display=r.getString("Vitals simple list"),t.type="simple"),"pacLabRes"===e.code&&(t.display=r.getString("Lab")),t});b.push({code:"pacVitalSparklines",type:"sparklines",display:r.getString("Vitals sparklines list")});var x=[l.GENERIC.EXPANDED_VIEWS.GRAPHS.code,l.GENERIC.EXPANDED_VIEWS.EHX.code],D=_.map(_.filter(s.patientDashboardWidgets,function(e){return"pacTasks"!==e.code&&"pacEPrescriptions"!==e.code}),function(e){return{code:e.code,display:e.displayFn?e.displayFn():e.display}});
8D=D.concat(_.map(_.filter(s.patientDashboardAdditionalViews,function(e){return x.indexOf(e.code)>=0}),function(e){return{code:e.code,display:e.displayFn?e.displayFn():e.display}}));let T=[];function w(t){t||(e.roles=[]),h.nxtSecuritySvc={sort:"name",name:e.filterBy.name,type:null},e.infiniteScroll.isBusy(!t,h)||e.infiniteScroll.nextPage(!t).then(function(n){e.roles||(e.roles=[]),e.roles=t?e.roles.concat(n):n,t||(e.operation=e.roles&&e.roles.length>0?"view":null,e.changeSelection(e.roles&&e.roles.length>0?e.roles[0]:null)),!e.operation&&e.roleSelectedItem&&(e.roleSelectedItem=null)})}var E;function P(t){return!!_.find(e.openedRole.permission,function(e){return e.id===t})}function I(t){var n=[];if(s[t]&&s[t].length>0)for(let i=0;i<s[t].length;i++)_.find(e.openedRole.permission,function(e){return e.id===s[t][i].permission})&&(n.push(s[t][i].code),"pacVitalS"===s[t][i].code&&n.push("pacVitalSparklines"));n&&n.length>0&&(S=S.concat(n))}function A(i,o){e.isLoadingRoleDetails||(e.hasSummaryAcces=!1,e.hasLandingPageAccess=!1,e.roleConfig=null,e.configuration=null,e.openedRole=null,e.isLoadingRoleDetails=!0,e.operation=i,S=[],t.all([n.getActionsByRole(o.id),a.search({id:o.id,limit:1,type:"role"}),f.getDefaultAttestation()]).then(function(t){e.openedRole=t[0],e.openedRole&&e.openedRole.permission&&e.openedRole.permission.length>0?(e.hasSummaryAccess=!0===p&&P(l.PERMISSION.PATIENT_CHART)&&P(l.PERMISSION.WIDGETS_READ),e.hasLandingPageAccess=!0===p&&P(l.PERMISSION.CLINICIAN_MODULE)&&P(l.PERMISSION.DOCTOR_WIDGETS_READ),I("doctorDashboardWidgets"),I("patientDashboardWidgets"),I("patientBannerList"),I("patientDashboardAdditionalViews")):(e.hasSummaryAccess=!1,e.hasLandingPageAccess=!1);let n=t&&1===t[1].length?t[1][0]:function(e){var t=new a.create;return t.owner=angular.copy(e),t.id=angular.copy(e.id),t.language={code:"en_US",display:"English US"},t.type="role",t.isAdded=!0,t}(o);!function(t,n){e.roleConfig||(e.roleConfig={});if(e.roleConfig.sourceAttestingReasonItems=[],e.roleConfig.resultAttestingReasonItems=[],T=n&&n.reason?n.reason:[],!t.attestation){const e=["treatment","healthcare_operations","network_operations"];t.attestation=angular.copy(n),t.attestation.reason&&(t.attestation.reason=_.filter(t.attestation.reason,function(e){return"submit_this_attestation"!==e.code}),t.attestation.reason.sort((t,n)=>e.indexOf(t.code)-e.indexOf(n.code)))}for(let n=0;n<t.attestation.reason.length;n++)e.roleConfig.resultAttestingReasonItems.push(t.attestation.reason[n]);for(let i=0;i<n.reason.length;i++)_.find(t.attestation.reason,function(e){return e.code===n.reason[i].code})||e.roleConfig.sourceAttestingReasonItems.push(n.reason[i]);if(e.roleConfig.resultAttestingReasonItems&&e.roleConfig.resultAttestingReasonItems.length>0)for(var i=e.roleConfig.resultAttestingReasonItems.length-1;i>=0;i--)_.find(n.reason,function(t){return t.code===e.roleConfig.resultAttestingReasonItems[i].code})||(e.roleConfig.resultAttestingReasonItems[i].invalid=!0);if(e.roleConfig.sourceAttestingReasonItems&&e.roleConfig.sourceAttestingReasonItems.length>0)for(var a=e.roleConfig.sourceAttestingReasonItems.length-1;a>=0;a--)_.find(n.reason,function(t){return t.code===e.roleConfig.sourceAttestingReasonItems[a].code})||e.roleConfig.sourceAttestingReasonItems.splice(a,1)}(n,t[2]),e.configuration=n,N(),L(),function(){e.roleConfig||(e.roleConfig={});if(e.roleConfig.sourceBannerItems=[],e.roleConfig.resultBannerItems=[],e.configuration.patientBannerConfig){for(let t=0;t<e.configuration.patientBannerConfig.length;t++)_.find(y,function(n){return n.code===e.configuration.patientBannerConfig[t].code})&&e.roleConfig.resultBannerItems.push(e.configuration.patientBannerConfig[t]);for(let t=0;t<y.length;t++)_.find(e.configuration.patientBannerConfig,function(e){return e.code===y[t].code})||e.roleConfig.sourceBannerItems.push(y[t])}else e.roleConfig.sourceBannerItems=y.slice();if(e.roleConfig.resultBannerItems&&e.roleConfig.resultBannerItems.length>0)for(var t=e.roleConfig.resultBannerItems.length-1;t>=0;t--)_.find(S,function(n){return n===e.roleConfig.resultBannerItems[t].code})||(e.roleConfig.resultBannerItems[t].invalid=!0);if(e.roleConfig.sourceBannerItems&&e.roleConfig.sourceBannerItems.length>0)for(var n=e.roleConfig.sourceBannerItems.length-1;n>=0;n--)_.find(S,function(t){return t===e.roleConfig.sourceBannerItems[n].code})||e.roleConfig.sourceBannerItems.splice(n,1)}(),e.initialRoleConfig=angular.copy(e.roleConfig),e.isLoadingRoleDetails=!1},function(){e.configuration=null,e.isLoadingRoleDetails=null}),e.resetFocus=!e.resetFocus)}function R(){if(e.operation=e.roles&&e.roles.length>0?"view":null,"view"===e.operation){A("view",e.roleSelectedItem&&e.roleSelectedItem.id?angular.copy(e.roleSelectedItem):angular.copy(e.roles[0]))}else e.roleSelectedItem=null}function N(){var t=[],n=[];if(e.configuration.patientDashboardConfig){for(let t=0;t<e.configuration.patientDashboardConfig.length;t++)if(e.configuration.patientDashboardConfig[t].length>0){var i=_.find(e.configuration.patientDashboardConfig[t],function(e){return"pacVitalS"===e.code});if(i){var a=_.find(b,function(e){return e.code===(i.type&&"simple"!==i.type?"pacVitalSparklines":"pacVitalS")});a&&(i.code=a.code,i.display=a.display)}n=n.concat(e.configuration.patientDashboardConfig[t])}for(let e=0;e<b.length;e++)_.find(n,function(t){return t.code===b[e].code})||t.push(b[e])}else t=b.slice();if(n&&n.length>0)for(var o=n.length-1;o>=0;o--)_.find(S,function(e){return e===n[o].code})||(n[o].invalid=!0);if(t&&t.length>0)for(var r=t.length-1;r>=0;r--)_.find(S,function(e){return e===t[r].code})||t.splice(r,1);if(e.roleConfig||(e.roleConfig={}),e.roleConfig.sourcePatientExpandedViews=[],e.roleConfig.resultPatientExpandedViews=e.roleConfig.resultPatientExpandedViews?_.filter(e.roleConfig.resultPatientExpandedViews,function(e){return x.indexOf(e.code)>=0}):[],e.configuration.patientExpandedViewsConfig){for(let t=0;t<e.configuration.patientExpandedViewsConfig.length;t++)(_.find(D,function(n){return x.indexOf(e.configuration.patientExpandedViewsConfig[t].code)>=0}
8)||_.find(n,function(n){return("pacVitalSparklines"===n.code?"pacVitalS":n.code)===e.configuration.patientExpandedViewsConfig[t].code}))&&_.find(D,function(n){return e.configuration.patientExpandedViewsConfig[t].code===n.code})&&e.roleConfig.resultPatientExpandedViews.push(e.configuration.patientExpandedViewsConfig[t]);for(let t=0;t<D.length;t++)_.find(n,function(e){return("pacVitalSparklines"===e.code?"pacVitalS":e.code)===D[t].code})&&(_.find(e.roleConfig.resultPatientExpandedViews,function(e){return("pacVitalSparklines"===e.code?"pacVitalS":e.code)===D[t].code})||e.roleConfig.sourcePatientExpandedViews.push(D[t]))}else if(n)for(let t=0;t<n.length;t++){var s=_.find(D,function(e){return e.code===("pacVitalSparklines"===n[t].code?"pacVitalS":n[t].code)});s&&e.roleConfig.sourcePatientExpandedViews.push(s)}if(e.roleConfig.resultPatientExpandedViews&&e.roleConfig.resultPatientExpandedViews.length>0)for(var l=e.roleConfig.resultPatientExpandedViews.length-1;l>=0;l--)_.find(S,function(t){return t===e.roleConfig.resultPatientExpandedViews[l].code})||(e.roleConfig.resultPatientExpandedViews[l].invalid=!0);var d=_.filter(D,function(e){return x.indexOf(e.code)>=0});_.forEach(d,function(t){!_.find(S,function(e){return e===t.code})||_.find(e.roleConfig.sourcePatientExpandedViews,function(e){return e.code===t.code})||_.find(e.roleConfig.resultPatientExpandedViews,function(e){return e.code===t.code})||e.roleConfig.sourcePatientExpandedViews.push(t)}),e.roleConfig.patientSourceWidgets=angular.copy(t),e.configuration.patientDashboardConfig&&e.configuration.patientDashboardConfig.length||(e.configuration.patientDashboardConfig=[[]]),e.roleConfig.patientDashColumn=e.configuration.patientDashboardConfig.length}function L(){var t=[],n=[];if(e.configuration.doctorDashboardConfig){for(let t=0;t<e.configuration.doctorDashboardConfig.length;t++)e.configuration.doctorDashboardConfig[t].length>0&&(n=n.concat(e.configuration.doctorDashboardConfig[t]));for(let e=0;e<C.length;e++)_.find(n,function(t){return t.code===C[e].code})||t.push(C[e])}else t=C.slice();if(n&&n.length>0)for(var i=n.length-1;i>=0;i--)_.find(S,function(e){return e===n[i].code})||(n[i].invalid=!0);if(t&&t.length>0)for(var a=t.length-1;a>=0;a--)_.find(S,function(e){return e===t[a].code})||t.splice(a,1);e.roleConfig||(e.roleConfig={}),e.roleConfig.doctorSourceWidgets=angular.copy(t),e.configuration.doctorDashboardConfig&&e.configuration.doctorDashboardConfig.length||(e.configuration.doctorDashboardConfig=[[]]),e.roleConfig.doctorDashColumn=e.configuration.doctorDashboardConfig.length}function O(t,n){if(e.isSaving=!0,t&&(e.form=t),!e.hasLandingPageAccess&&e.configuration.doctorDashboardConfig&&delete e.configuration.doctorDashboardConfig,e.configuration.patientDashboardConfig)for(let t=0;t<e.configuration.patientDashboardConfig.length;t++)for(var i=0;i<e.configuration.patientDashboardConfig[t].length;i++)"pacVitalSparklines"!==e.configuration.patientDashboardConfig[t][i].code&&"pacVitalS"!==e.configuration.patientDashboardConfig[t][i].code||(e.configuration.patientDashboardConfig[t][i].type="simple","pacVitalSparklines"===e.configuration.patientDashboardConfig[t][i].code&&(e.configuration.patientDashboardConfig[t][i].type="sparklines",e.configuration.patientDashboardConfig[t][i].code="pacVitalS"),e.configuration.patientDashboardConfig[t][i].display="Vital signs");e.configuration.patientExpandedViewsConfig=[];for(let t=0;t<e.roleConfig.resultPatientExpandedViews.length;t++)e.configuration.patientExpandedViewsConfig.push({code:e.roleConfig.resultPatientExpandedViews[t].code,display:e.roleConfig.resultPatientExpandedViews[t].display});e.configuration.patientBannerConfig=[];for(let t=0;t<e.roleConfig.resultBannerItems.length;t++)e.configuration.patientBannerConfig.push({code:e.roleConfig.resultBannerItems[t].code,display:e.roleConfig.resultBannerItems[t].display});e.configuration.attestation||(e.configuration.attestation={}),e.configuration.attestation.reason=[];for(let t=0;t<e.roleConfig.resultAttestingReasonItems.length;t++)e.configuration.attestation.reason.push({code:e.roleConfig.resultAttestingReasonItems[t].code,display:e.roleConfig.resultAttestingReasonItems[t].display,system:e.roleConfig.resultAttestingReasonItems[t].system});!e.hasSummaryAccess&&e.configuration.patientDashboardConfig&&delete e.configuration.patientDashboardConfig,!e.hasSummaryAccess&&e.configuration.patientExpandedViewsConfig&&delete e.configuration.patientExpandedViewsConfig,!e.hasSummaryAccess&&e.configuration.patientBannerConfig&&delete e.configuration.patientBannerConfig,!e.hasSummaryAccess&&e.configuration.attestation&&delete e.configuration.attestation;var o={resourceType:"Bundle",type:"transaction",entry:[],id:s.generateGUID()};o.entry.push({resource:e.configuration.toFhir(),request:{method:e.configuration.isAdded?"POST":"PUT",url:"Configuration"},fullUrl:d.ConfigurationApiURL+"/"+e.configuration.id}),o.entry[o.entry.length-1].resource.id=e.configuration.id,e.configuration.isAdded&&delete e.configuration.isAdded,a.saveBulkData(o).then(function(){_.isEmpty(n)?(R(),e.isSaving=!1,e.form&&e.form.resetForm()):a.updateUsersConfiguration(e.configuration.owner.id,n).then(function(t){R(),e.isSaving=!1,e.form&&e.form.resetForm()},function(t){e.isSaving=!1})},function(t){e.isSaving=!1})}e.$watch("filterBy.name",function(t){(!t||t&&t.length>=3)&&(w(),o.setCurrentPageContextProperty(v,{name:e.filterBy.name}))}),function(){if(e.currentPageContextChecked)return;var t=o.getCurrentPageContextProperty(v);t&&(e.filterBy.name=t.name,e.currentPageContextChecked=!0)}(),e.getMoreData=function(){w(!0)},e.textAreaSetup=function(e){e.attr("role","textbox"),e.attr("tabindex","0")},e.$watch("roleSelectedItem",function(t,n){t&&t.id&&(!n||t.id!==n.id&&t.id&&n.id)&&(e.operation=null,E=g(function(){A("view",angular.copy(e.roleSelectedItem))}
8,1))},!0),e.edit=function(){e.operation=null,E=g(function(){e.operation="edit"},1)},e.patientDashSourceItemMoved=function(t){for(let i=0;i<t.length;i++){var n=_.find(D,function(e){return e.code===("pacVitalSparklines"===t[i].code?"pacVitalS":t[i].code)});n&&!_.find(e.roleConfig.sourcePatientExpandedViews,function(e){return e.code===n.code})&&e.roleConfig.sourcePatientExpandedViews.push(n)}},e.patientDashResultItemMoved=function(t){var n;for(let i=0;i<t.length;i++)n="pacVitalSparklines"===t[i].code?"pacVitalS":t[i].code,_.find(S,function(e){return e===n})||(e.roleConfig.patientSourceWidgets="pacVitalS"===n?_.filter(e.roleConfig.patientSourceWidgets,function(e){return e.code!==n&&"pacVitalSparklines"!==e.code}):_.filter(e.roleConfig.patientSourceWidgets,function(e){return e.code!==n})),e.roleConfig.sourcePatientExpandedViews=_.filter(e.roleConfig.sourcePatientExpandedViews,function(e){return e.code!==n}),e.roleConfig.resultPatientExpandedViews=_.filter(e.roleConfig.resultPatientExpandedViews,function(e){return e.code!==n})},e.resultItemMoved=function(t,n){var i;for(let a=0;a<t.length;a++)i=t[a].code,"sourceAttestingReasonItems"===n&&(_.find(T,function(e){return e.code===i})||(e.roleConfig[n]=_.filter(e.roleConfig[n],function(e){return e.code!==i}))),"sourceAttestingReasonItems"!==n&&(_.find(S,function(e){return e===i})||(e.roleConfig[n]=_.filter(e.roleConfig[n],function(e){return e.code!==i})))},e.patientViewResultItemMoved=function(t){var n=_.filter(t,function(e){return x.indexOf(e.code)>=0});n&&n.length>0&&e.resultItemMoved(n,"sourcePatientExpandedViews")},e.$watchCollection("[roleConfig.patientDashColumn, roleConfig.doctorDashColumn]",function(t,n){if((t[0]||t[1]||n[0]||n[1])&&e.configuration){if(!_.isNil(n[0])&&t[0]!==n[0]){e.configuration.patientDashboardConfig=[];for(let n=0;n<t[0];n++)e.configuration.patientDashboardConfig.push([]);N()}if(!_.isNil(n[1])&&t[1]!==n[1]){e.configuration.doctorDashboardConfig=[];for(let n=0;n<t[1];n++)e.configuration.doctorDashboardConfig.push([]);L()}}}),e.cancel=function(){e.form&&e.form.resetForm(),R()},e.save=function(t){if(u){var n={},i=[],a=[],o=[],s=[];if(e.roleConfig&&e.initialRoleConfig.doctorSourceWidgets&&e.initialRoleConfig.doctorSourceWidgets.length>0)for(let t=0;t<e.initialRoleConfig.doctorSourceWidgets.length;t++)_.find(e.roleConfig.doctorSourceWidgets,function(n){return n.code===e.initialRoleConfig.doctorSourceWidgets[t].code})||i.push({code:e.initialRoleConfig.doctorSourceWidgets[t].code,display:e.initialRoleConfig.doctorSourceWidgets[t].display});if(e.initialRoleConfig&&e.initialRoleConfig.patientSourceWidgets&&e.initialRoleConfig.patientSourceWidgets.length>0){var l;a=[];for(let t=0;t<e.initialRoleConfig.patientSourceWidgets.length;t++)_.find(e.roleConfig.patientSourceWidgets,function(n){return n.code===e.initialRoleConfig.patientSourceWidgets[t].code})||("pacVitalSparklines"!==(l=angular.copy(e.initialRoleConfig.patientSourceWidgets[t])).code&&"pacVitalS"!==l.code||(l.display="Vital signs"),a.push({code:l.code,display:l.display}))}if(e.roleConfig&&e.roleConfig.resultPatientExpandedViews&&e.roleConfig.resultPatientExpandedViews.length>0)for(let t=0;t<e.roleConfig.resultPatientExpandedViews.length;t++)_.find(e.initialRoleConfig.resultPatientExpandedViews,function(n){return n.code===e.roleConfig.resultPatientExpandedViews[t].code})||o.push({code:e.roleConfig.resultPatientExpandedViews[t].code,display:e.roleConfig.resultPatientExpandedViews[t].display});if(e.roleConfig&&e.roleConfig.resultBannerItems&&e.roleConfig.resultBannerItems.length>0)for(let t=0;t<e.roleConfig.resultBannerItems.length;t++)_.find(e.initialRoleConfig.resultBannerItems,function(n){return n.code===e.roleConfig.resultBannerItems[t].code})||s.push({code:e.roleConfig.resultBannerItems[t].code,display:e.roleConfig.resultBannerItems[t].display});if(i.length>0||a.length>0||o.length>0||s.length){n.dashboard=[],i.length>0&&n.dashboard.push({type:"doctor",widgets:i});var d={};a.length>0&&(d.widgets=a),o.length>0&&(d.expandedViews=o),s.length>0&&(d.banner=s),_.isEmpty(d)||(d.type="patient",n.dashboard.push(d))}if(_.isEmpty(n))O(t);else{var p={closeButtonText:r.getString("No"),actionButtonText:r.getString("Yes"),headerText:r.getString("Role configuration"),bodyText:"You have added new widgets to be visible to the users that belong to this role. <br /> Do you want to apply this change also to the existing users?"};c.showModal(p).then(function(){O(t,n)},function(e){O(t)})}}else O(t)};var M=e.$on("nxtReloadData",function(t,n){"roleConfiguration"===n&&(e.roleSelectedItem=null,w())});e.$on("$destroy",function(){M(),E&&g.cancel(E)})}]),app.ui.administration.controller("nxtRoleManagementCtrl",["$scope","nxtSecuritySvc","$q","nxtInfiniteScrollSvc","nxtResourceTypesSvc","gettextCatalog","nxtDeleteMessageBoxSvc","nxtUserSvc","nxtTemplateViewSvc","CONSTANT","nxtUserContextSvc","nxtValueSetSvc",function(e,t,n,i,a,o,r,s,l,d,c,u){"use strict";var p={},g={},f="admRoleManagementContext";g.nxtSecuritySvc={methodName:"getRolesWithTotalRows"},e.infiniteScroll=i.create({services:g,limit:100});var h=[];function m(t){t||(e.roles=[]),p.nxtSecuritySvc={sort:"name",name:e.filterBy.name,type:"all"===e.filterBy.type?null:e.filterBy.type},e.infiniteScroll.isBusy(!t,p)||e.infiniteScroll.nextPage(!t).then(function(n){e.roles||(e.roles=[]),e.roles=t?e.roles.concat(n):n,t||(e.operation=e.roles&&e.roles.length>0?"view":null,e.changeSelection(e.roles&&e.roles.length>0?e.roles[0]:null)),!e.operation&&e.roleSelectedItem&&(e.roleSelectedItem=null)})}function v(i,o){if(!e.isLoadingRoleDetails){e.isLoadingRoleDetails=!0,e.operation=i;var r=angular.copy(e.filterPermissionsBy);e.filterPermissionsBy.state="all",e.filterPermissionsBy.name=null,e.selected.permission=null,"edit"===i||"view"===i?(e.permissionsList=[],n.all([t.getActionsByRole(o),t.getRoles({id:o})]).then(function(t){e.openedRole=t[0],C(),e.roleSelectedItem=t[1][0],e.isLoadingRoleDetails=!1},function(t){e.isLoadingRoleDetails=!1})):"add"===i&&(_.isEqual(r,e.filterPermissionsBy)&&C(),e.roleSelectedItem=new a.Role,e.roleSelectedItem.type="system",e.isLoadingRoleDetails=!1),e.resetFocus=!e.resetFocus}}function S(){if(e.operation=e.roles&&e.roles.length>0?"view":null,"view"===e.operation){v("view",(e.roleSelectedItem&&e.roleSelectedItem.id?angular.copy(e.roleSelectedItem):angular.copy(e.roles[0])).id)}else e.roleSelectedItem=null}function C(){if(e.openedRole){for(var t=angular.copy(h),n=0;n<t.length;n++){_.find(e.openedRole.permission,function(e){return e.id===t[n].id})&&(t[n].$selected=!0),t[n].toKeep=!0}e.permissionsList=t}}e.filterPermissionsBy={state:"all"},e.filterBy={name:null,type:"all"},e.organizationTypeDropDown={},function(){if(e.organizationTypesList&&e.organizationTypesList.length)return;u.searchRecurrent({valueSetName:"practiceSetting"}).then(function(t){e.organizationTypesList=t})}(),e.$watchCollection("[filterBy.name, filterBy.type]",function(t,n){(!t[0]||t[0]&&t[0].length>=3)&&(m(),c.setCurrentPageContextProperty(f,{name:e.filterBy.name,type:e.filterBy.type}))}),function(){if(e.currentPageContextChecked)return;var t=c.getCurrentPageContextProperty(f);t&&(e.filterBy.name=t.name,e.filterBy.type=t.type,e.currentPageContextChecked=!0)}(),t.getAllActions().then(function(e){h=_.sortBy(e,function(e){return e.name})}),e.selected={permission:null},e.getMoreData=function(){m(!0)},e.$watch("roleSelectedItem",function(t,n){t&&t.id&&(!n||t.id!==n.id&&t.id&&n.id)&&v("view",angular.copy(e.roleSelectedItem).id);e.$broadcast("setInputDisplay")},!0),e.$watch("roleSelectedItem.name",function(t,n){t!==n&&(e.passwordErrorMsgOnSave=null)}),e.editRole=function(){e.operation="edit",e.isAdminOrPatient="patient"===e.roleSelectedItem.id||"administrator"===e.roleSelectedItem.id,v("edit",e.roleSelectedItem.id)},e.addRole=function(){e.operation="add",e.isAdminOrPatient=!1,e.openedRole=new a.Permission,v("add")},e.cancel=function(){e.form&&e.form.resetForm(),S()},e.toggleSelection=function(t){if("edit"===e.operation||"add"===e.operation)if(t.$selected=!t.$selected,t.$selected)e.openedRole.permission.push(t);else{var n=_.find(e.openedRole.permission,function(e){return e.id===t.id});n&&e.openedRole.permission.splice(e.openedRole.permission.indexOf(n),1)}},e.$watchCollection("[filterPermissionsBy.state, filterPermissionsBy.name]",function(t){if(t[0])switch(t[0]){case"all":C();break;case"current":!function(){if(!e.openedRole)return;for(var t=angular.copy(h),n=0;n<t.length;n++){var i=_.find(e.openedRole.permission,function(e){return e.id===t[n].id});i&&(t[n].$selected=!0),t[n].toKeep=!!i}e.permissionsList=t}();break;case"missing":!function(){if(!e.openedRole)return;for(var t=angular.copy(h),n=0;n<t.length;n++){var i=_.find(e.openedRole.permission,function(e){return e.id===t[n].id});t[n].toKeep=!i,t[n].$selected=!!i}e.permissionsList=t}()}if(t[1]&&t[1].length>=3)for(var n=t[1].toLowerCase().split(" "),i=0;i<e.permissionsList.length;i++){for(var a=!1,o=[],r=0;r<n.length;r++)a=!!(e.permissionsList[i].name.toLowerCase().indexOf(n[r])>-1&&e.permissionsList[i].toKeep),o.push(a);e.permissionsList[i].toKeep=_.filter(o).length===o.length}}),e.save=function(n){e.isSaving=!0,n&&(e.form=n),"system"===e.roleSelectedItem.type&&delete e.roleSelectedItem.serviceCategories,t.saveRole(e.roleSelectedItem).then(function(n){e.openedRole.id=n.id,t.saveActionsForRole(e.openedRole).then(function(){if("edit"===e.operation){var t=_.find(e.roles,function(t){return t.id===e.roleSelectedItem.id});t&&(e.roleSelectedItem.type===e.filterBy.type||"all"===e.filterBy.type?e.roles.splice(e.roles.indexOf(t),1,e.roleSelectedItem):e.roles.splice(e.roles.indexOf(t),1))}else"add"===e.operation&&(e.roles||(e.roles=[]),e.roleSelectedItem.type!==e.filterBy.type&&"all"!==e.filterBy.type||e.roles.unshift(e.roleSelectedItem));e.roleSelectedItem.type!==e.filterBy.type&&"all"!==e.filterBy.type&&(e.roleSelectedItem=null),S(),e.isSaving=!1,e.form&&e.form.resetForm()})},function(t){t&&t.issue&&t.issue[0]&&t.issue[0].details&&t.issue[0].details.code===d.ERROR.MSG_DUPLICATE_ROLE_NAME.co
8de&&(e.passwordErrorMsgOnSave=t.display),e.isSaving=!1})},e.deleteRole=function(){s.searchWithTotalRows({role:e.roleSelectedItem.id,limit:20}).then(function(n){if(0===n.totalResults){let n={closeButtonText:o.getString("Cancel"),actionButtonText:o.getString("Ok"),headerText:o.getString("Delete role"),bodyText:o.getString("Are you sure you want to delete this role?")};r.showModal(n).then(function(){t.del(e.roleSelectedItem.id).then(function(){for(var t=0;t<e.roles.length;t++)if(e.roles[t].id===e.roleSelectedItem.id){e.roles.splice(t,1);break}e.roleSelectedItem=null,S()},function(e){})},function(e){})}else{var i=_.map(n.entries,function(e){return e.family+" "+e.given}).join(", "),a="<b>"+o.getString("You cannot delete this role because it is being used.");a+=" "+o.getString("There is/are")+" "+n.totalResults+" "+o.getString("user(s) with")+" "+e.roleSelectedItem.name+" "+o.getString("role.")+"</b><br/>("+i+"...)";let t={closeButtonText:o.getString("Cancel"),headerText:o.getString("Delete role"),bodyText:a};l.showModal(t)}},function(e){})};var y=e.$on("nxtReloadData",function(e,t){"roleManagement"===t&&m()});e.$on("$destroy",function(){y()})}]),app.ui.administration.controller("nxtSupportCtrl",["$scope","$uibModalInstance","nxtSupportSvc","gettextCatalog","nxtTemplateViewSvc","NXT_SUPPORT",function(e,t,n,i,a,o){"use strict";e.supportConfig=o,e.popupsTitle=e.supportConfig.Header,e.popupText=e.supportConfig.Body,e.helpRequest={text:null},e.save=function(){e.isSaving=!0,n.save(e.helpRequest.text,e.supportConfig.SubmitUrl).then(function(){t.dismiss("ok");var n={closeButtonText:i.getString("Close"),headerText:e.popupsTitle,bodyText:i.getString("The request has been sent.")};a.showModal(n)},function(t){e.isSaving=!1;var n={closeButtonText:i.getString("Close"),headerText:e.popupsTitle,bodyText:i.getString("The request couldn't be sent.")};a.showModal(n)})},e.close=function(){t.dismiss("cancel")}}]),app.ui.administration.controller("nxtUserEditCtrl",["$scope","$q","nxtUserSvc","nxtUserContextSvc","nxtResourceTypesSvc","nxtSecuritySvc","$uibModal","nxtOrganizationSvc","CONSTANT","nxtValueSetSvc","nxtUtilsSvc","NXT_API_ENDPOINTS","NXT_USERNAME_PATTERN","gettextCatalog","nxtUserInfoStoreSvc","NXT_IDS_CONFIG","NXT_USER_PROFILE","NXT_USER_SECURITY_QUESTIONS","NXT_PHONE_NUMBER","NXT_ENABLED_WORKS_ON_BEHALF_OF","NXT_USER_INACTIVITY_REASON_ACCOUNT","NXT_ENABLED_2FA",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m,v,S,C,y,b){"use strict";e.inactivateUserReasonBasedOnOrganization=l.GENERIC.INACTIVATE_USER_REASON_BASED_ON_ORGANIZATION,e.isNpiNumberRequired=h.NPI.required,e.isAwsCognitoFlowEnabled=f.state.isCognitoAuthorizationFlow,e.isEnabledWorksOnBehalfOf=C,e.inactivityReasonConfig=y,e.searchOrganization=s.search,e.searchUser=n.search,e.pattern=p.Pattern,e.patternMessage=p.PatternMessage,e.phoneNumberConfig=S,v&&v.AnswerMinRequiredLength&&v.AnswerMinRequiredLength>0&&(e.answerMinRequiredLength=v.AnswerMinRequiredLength);var x={system:"system",organization:"organization"};e.isAdminOrg=!1,e.isEnabled2FA=b,e.secondFactorAuthMethodList=[{code:"none",display:"None"},{code:"email",display:"E-mail"},{code:"sms_home",display:"SMS"}],e.isEnabled2FA=b,i.LoggedUserConfiguration&&i.LoggedUserConfiguration.organization&&i.LoggedUserConfiguration.organization.id&&(e.isAdminOrg=!0),"profile"===e.operation&&(e.formConfig=m,i.LoggedUserConfiguration.organization&&i.LoggedUserConfiguration.organization.mandatory2FA&&(e.secondFactorAuthMethodList=e.secondFactorAuthMethodList.filter(e=>"none"!==e.code))),function(){e.isLoading=!0;var r=[],s={},l=0;_.isNil(e.accountExpiry)&&(e.accountExpiry=0);_.isNil(e.passwordExpiry)&&(e.passwordExpiry=0);_.isNil(e.maxFailedLoginAttempts)&&(e.maxFailedLoginAttempts=0);_.isNil(e.maxFailedQuestionAttempts)&&(e.maxFailedQuestionAttempts=0);"add"!==e.operation&&(r.push(n.getByIdWithIncludeOrganization(e.userId||i.loggedUser.id)),s.user=l,l++);"view"!==e.operation&&(r.push(o.getPasswordValidationRule()),s.rules=l,l++);"view"!==e.operation&&"profile"!==e.operation&&(r.push(o.getRoles({sort:"name"})),s.roles=l,l++);if(!e.isAwsCognitoFlowEnabled&&"view"!==e){let e=null;v&&v.FilterBy&&(e="customer="+v.FilterBy.toUpperCase()),r.push(d.get({valueSetName:"UserSecurityQuestion",limit:50,property:e})),s.vsQuestions=l,l++}if(!e.isAwsCognitoFlowEnabled&&"view"!==e.operation&&"profile"!==e.operation&&e.inactivityReasonConfig&&e.inactivityReasonConfig.InactivityReason&&e.inactivityReasonConfig.InactivityReason.visible){let t=null;e.inactivityReasonConfig.InactivityReason.FilterBy&&(t="customer="+e.inactivityReasonConfig.InactivityReason.FilterBy.toUpperCase()),r.push(d.get({valueSetName:"UserInactivityReason",limit:50,property:t})),s.vsInactivityReason=l,l++}t.all(r).then(function(t){if(t&&t.length>0)for(var n in s)switch(n){case"user":t[s[n]]&&(e.user=t[s[n]],w());break;case"rules":e.rule=t[s[n]];break;case"roles":t[s[n]]&&(e.initialRoleList=t[s[n]]&&t[s[n]].length>0?t[s[n]]:[]);break;case"vsQuestions":t[s[n]]&&(e.securityQuestionsList=t[s[n]]);break;
8case"vsInactivityReason":t[s[n]]&&(e.inactivityReasonDetailsList=t[s[n]])}!function(){"add"===e.operation&&(e.user=new a.User,e.user.detailedStatus={status:e.user.status,isPasswordExpired:!1},E());e.initialDetailedStatus=e.user&&e.user.detailedStatus,e.user&&(e.isEnabled2FA&&e.user.secondFactorAuthMethod&&e.user.secondFactorAuthMethod.code||(e.user.secondFactorAuthMethod=e.secondFactorAuthMethodList[0])),I(!0),P(!0),e.originalPhone=e.user.phone,e.original2FAMethod=e.user.secondFactorAuthMethod.code}(),e.isLoading=!1},function(t){e.isLoading=!1})}();var D=null,T=null;function w(){var t=angular.copy(e.user.roles);if(t)if("view"!==e.operation&&"profile"!==e.operation){var n=_.map(_.filter(t,function(e){return e&&e.adminOrganization&&e.adminOrganization.id}),"adminOrganization.id");(n=n.concat(_.map(_.filter(t,function(e){return e&&e.adminOrganization&&e.adminOrganization.root&&e.adminOrganization.root.id}),"adminOrganization.root.id"))).length?(e.isLoadingUserRoles=!0,s.getByIds({ids:n,limit:n.length}).then(function(n){_.each(t,function(e){e&&e.adminOrganization&&(e.adminOrganization=_.find(n,function(t){return t&&t.id===e.adminOrganization.id}),e.adminOrganization&&"suborganization"===e.adminOrganization.category&&(e.adminOrganization.root=_.find(n,function(t){return t&&t.id===e.adminOrganization.root.id})))}),E(t),e.isLoadingUserRoles=!1})):E(t)}else E(t);else E(t)}function E(t){t||(t=[]),e.userRoles=_.map(_.filter(t,function(e){return"active"===e.status}),function(e){return e.onBehalfOf||(e.onBehalfOf={type:"none"}),e}),e.inactiveUserRoles=_.filter(t,function(e){return"inactive"===e.status}),"add"===e.operation||"edit"===e.operation?(e.userRoles&&e.userRoles.length>0&&(T=e.userRoles[0].adminOrganization?x.organization:e.isAdminOrg?x.organization:x.system,D=angular.copy(e.userRoles)),e.filter={roleType:T||(e.isAdminOrg?x.organization:x.system)}):e.filter={roleType:e.userRoles&&e.userRoles.length>0&&e.userRoles[0].adminOrganization?"organization":e.isAdminOrg?x.organization:x.system},e.userRoles&&0!==e.userRoles.length||e.addRole()}function P(t){if(!e.isAwsCognitoFlowEnabled)if(t){if(e.user)if(e.user.inactivityReasonDetails||e.user.inactivityDate){var n={};e.user.inactivityReasonDetails&&(n.details=e.user.inactivityReasonDetails),n.details&&!n.details.code&&n.details.display&&(n.isOther=!0,n.otherDetails=n.details.display,delete n.details),e.inactivityReasonDetails=n}else e.inactivityReasonDetails={details:null,otherDetails:null}}else e.user.inactivityReasonDetails&&delete e.user.inactivityReasonDetails,e.inactivityReasonDetails&&(e.inactivityReasonDetails.isOther&&e.inactivityReasonDetails.otherDetails&&(e.user.inactivityReasonDetails={display:e.inactivityReasonDetails.otherDetails}),!e.inactivityReasonDetails.isOther&&e.inactivityReasonDetails.details&&(e.user.inactivityReasonDetails=e.inactivityReasonDetails.details))}function I(t){var n;if(t){if(e.user)if(e.user.securityQuestions&&e.user.securityQuestions.length>0){var i=[];for(let t=0;t<e.user.securityQuestions.length;t++)e.user.securityQuestions[t]&&(n={},e.user.securityQuestions[t].question&&(e.user.securityQuestions[t].question.code?n.question=e.user.securityQuestions[t].question:e.user.securityQuestions[t].question.display&&(n.otherQuestion=e.user.securityQuestions[t].question.display,n.isOther=!0)),n.answer=e.user.securityQuestions[t].answer,i.push(n));i&&i.length>0&&(e.securityQuestions=i),0===e.securityQuestions.length?e.securityQuestions=[{question:null,answer:null},{question:null,answer:null}]:1===e.securityQuestions.length&&e.securityQuestions.push({question:null,answer:null})}else e.securityQuestions=[{question:null,answer:null},{question:null,answer:null}]}else if(e.securityQuestions&&e.securityQuestions.length>0){e.user.securityQuestions=[];for(let t=0;t<e.securityQuestions.length;t++)e.securityQuestions[t]&&(n={},e.securityQuestions[t].isOther&&e.securityQuestions[t].otherQuestion?n.question={display:e.securityQuestions[t].otherQuestion}:e.securityQuestions[t].question&&e.securityQuestions[t].question.code&&(n.question=e.securityQuestions[t].question),e.securityQuestions[t].answer&&(n.answer=e.securityQuestions[t].answer),n.question&&n.answer&&e.user.securityQuestions.push(n))}}if(e.$watch("user.secondFactorAuthMethod.code",function(t){e.nxtPhoneInputClass="sms_home"===t?"col-xs-8":"col-xs-4"}),"add"!==e.operation&&"edit"!==e.operation||(e.$watch("filter.roleType",function(t,n){t&&(e.roleList=_.filter(e.initialRoleList,function(e){return e.type===t}),n&&(e.userRoles="system"===t?null:_.filter(D,function(e){return!_.isNil(e.adminOrganization)}),e.userRoles&&0!==e.userRoles.length||e.addRole()))}),e.$watch(function(e){return e.userRoles?_.map(e.userRoles,function(e){return e}):[]},function(t,n){if(t&&t.length>0)for(let r=0;r<t.length;r++){if(t[r].onBehalfOf&&t[r].onBehalfOf.provider&&t[r].onBehalfOf.provider.length>0&&"list"!==t[r].onBehalfOf.type){delete t[r].onBehalfOf.provider,e.$broadcast("setInputDisplay");break}var i=null;if(t[r]&&t[r].adminOrganization&&(i=t[r].adminOrganization,"suborganization"===t[r].adminOrganization.category&&(i=t[r].adminOrganization.root)),i&&i.serviceCategory){var a=null;n&&n[r]&&n[r].adminOrganization&&(a=n&&n[r]&&n[r].adminOrganization,"suborganization"===n[r].adminOrganization.category&&(a=n[r].adminOrganization.root));var o=a&&a.serviceCategory?a.serviceCategory.code:null;if(o&&o===i.serviceCategory.code&&t[r].roleList)continue;t[r].roleList=_.filter(e.roleList,function(e){return e&&e.serviceCategories&&_.find(e.serviceCategories,function(e){return e&&e.code===i.serviceCategory.code})}),t[r].role&&t[r].role[0]&&t[r].role[0].id&&!_.find(t[r].roleList,function(e){return e&&e.id===t[r].role[0].id})&&(t[r].role=[]),!t[r].roleList||1!==t[r].roleList.length||t[r].role&&t[r].role.length||(t[r].role=[t[r].roleList[0]])}else e.filter.roleType!==x.system&&(t[r].roleList=e.roleList,t[r].adminOrganization||(t[r].role=[]))}},!0)),"view"!==e.operation){var A=!0;e.$watch(function(e){return _.map(e.securityQuestions,function(e){return e})},function(t,n){if(e.securityQuestions)if(A)A=!1;else for(let e=0;e<t.length;e++){var i=t[e],a=n&&n[e]?n[e]:{};!i.question&&a.question||!a.otherQuestion&&a.otherQuestion?i.answer=null:_.isEqual(i.isOther,a.isOther)||(i.question=null,i.otherQuestion=null,i.answer=null)}},!0)}if("add"===e.operation||"edit"===e.operation){if(e.isAwsCognitoFlowEnabled)return;
8e.$watch("inactivityReasonDetails",function(t,n){e.user&&t&&n&&(_.isEqual(t.isOther,n.isOther)||(t.details=null,t.otherDetails=null))},!0),e.$watch("user.detailedStatus.status",function(t,n){e.user&&"inactive"===t&&"inactive"!==e.initialDetailedStatus&&(e.inactivityReasonDetails||(e.inactivityReasonDetails={}),e.user.inactivityDate=new Date)})}function R(t,i){n.updateProfile(t).then(function(){N(i),e.isSaving=!1},function(){e.isSaving=!1})}function N(t){e.$close?e.$close(t):e.$emit("onUserSavedEvent",t)}e.addRole=function(){e.userRoles||(e.userRoles=[]);var t={role:[],status:"active",adminOrganization:null,onBehalfOf:null,idx:parseInt(1e4*Math.random())};e.filter.roleType===x.organization&&(t.onBehalfOf={type:"none"},e.isAdminOrg&&(t.adminOrganization=angular.copy(i.LoggedUserConfiguration.organization))),e.userRoles.push(t)},e.removeRole=function(t){e.userRoles[t].id&&(e.inactiveUserRoles||(e.inactiveUserRoles=[]),e.inactiveUserRoles.push(angular.copy(e.userRoles[t])),e.inactiveUserRoles[e.inactiveUserRoles.length-1].status="inactive"),e.userRoles.splice(t,1)},e.$watch("user.username",function(t,n){e.user&&t!==n&&(e.usernameAlreadyAddedMsgOnSave=null,e.isAwsCognitoFlowEnabled&&e.assignCognitoUser&&(e.assignCognitoUser=!1))}),e.$watch("user.password",function(t,n){t!==n&&(e.passwordErrorMsgOnSave=null)}),e.$watch("user.npi",function(t,n){t!==n&&(e.npiErrorMsg=null)}),e.isAwsCognitoFlowEnabled&&("profile"===e.operation&&(e.tooltipAwsProfile=g.getString("Please contact your administrator to make updates to this field.")),e.$watch("user.contactEmail",function(t,n){t!==n&&(e.emailAlreadyAddedMsgOnSave=null)})),e.assignCognitoUser=!1,e.save=function(){e.isSaving=!0,I(),P();var i={resourceType:"Bundle",type:"transaction",entry:[],id:c.generateGUID()},o=_.extend(angular.copy(e.user),{resourceType:"User"});if(e.isEnabled2FA&&"profile"===e.operation&&!e.isAwsCognitoFlowEnabled){var s=[];"none"!==e.user.secondFactorAuthMethod.code&&(e.originalPhone!==e.user.phone&&"sms_home"===e.user.secondFactorAuthMethod.code||e.original2FAMethod!==e.user.secondFactorAuthMethod.code)&&s.push(n.apiValidate2FA(o.id,"sms_home"===e.user.secondFactorAuthMethod.code?e.user.phone:e.user.contactEmail,e.user.secondFactorAuthMethod.code)),t.all(s).then(function(t){var n=t&&t[0];i.entry.push({resource:o.toFhir(),request:{method:"add"===e.operation?"POST":"PUT",url:"User"},fullUrl:u.UserApiURL+"/"+o.id}),i.entry[i.entry.length-1].resource.id=o.id;var a=n&&n.issue&&n.issue.length>0?_.find(n.issue,function(e){return e.details&&(e.details.code===l.ERROR.MSG_TOKEN_SENT_TO_SMS.code||e.details.code===l.ERROR.MSG_TOKEN_SENT_TO_EMAIL.code)}):null;if(a){e.isSaving=!1;var s=e.$new();s.secondFactorMessage=n.display,s.verificationCode=a.uniqueId?a.uniqueId+" - ":null,s.bundle=i,r.open({templateUrl:"modules/administration/users/userEditToken.html",scope:s,backdrop:"static",controller:"nxtUserEditTokenCtrl",windowClass:"nxt-token-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){e.isSaving=!0,R(i,o)},function(t){e.isSaving=!1})}else R(i,o)},function(t){if(t&&t.issue&&t.issue.length)for(let n=0;n<t.issue.length;n++)if(t.issue[n]&&t.issue[n].details)switch(t.issue[n].details.code){case l.ERROR.MSG_MISSING_OR_INVALID_PARAMETER.code:e.twoFAErrorMgs=l.ERROR.MSG_MISSING_OR_INVALID_PARAMETER.display;break;case l.ERROR.MSG_MISSING_OR_INVALID_TOKEN.code:e.twoFAErrorMgs=l.ERROR.MSG_MISSING_OR_INVALID_TOKEN.display;break;case l.ERROR.MSG_FAILED_TO_SEND_EMAIL.code:e.twoFAErrorMgs=l.ERROR.MSG_FAILED_TO_SEND_EMAIL.display;break;case l.ERROR.MSG_DATABASE_ERROR.code:e.twoFAErrorMgs=l.ERROR.MSG_DATABASE_ERROR.display;break;case l.ERROR.MSG_COMPROMISED_PASSWORD.code:e.passwordErrorMsgOnSave=t.display;break;default:e.twoFAErrorMgs=t.issue[n].details.display||t.issue[n].details.code}_.isEmpty(e.twoFAErrorMgs)&&(e.twoFAErrorMgs=t&&t.display?t.display:_.isEmpty(t)?"An error has occurred! Please contact your administrator!":t),e.isSaving=!1})}else{var d=[];"add"===e.operation&&(o.id=c.generateGUID());var p=angular.copy(e.userRoles);if(e.inactiveUserRoles&&e.inactiveUserRoles.length>0&&(p=p.concat(e.inactiveUserRoles)),T!==e.filter.roleType&&D&&D.length>0){for(let e=0;e<D.length>0;e++)D[e].status="inactive";p=p.concat(D)}if("profile"!==e.operation&&p&&p.length>0){for(let e=p.length-1;e>=0;e--){var g=!1;p[e].adminOrganization&&(g="suborganization"===p[e].adminOrganization.category||_.isEmpty(p[e].adminOrganization.category)&&p[e].suborganization&&p[e].suborganization.id===p[e].adminOrganization.id),g?(p[e].suborganization=angular.copy(p[e].adminOrganization),p[e].organization=angular.copy(p[e].adminOrganization.root||p[e].organization)):(p[e].organization=angular.copy(p[e].adminOrganization),p[e].suborganization&&delete p[e].suborganization)}var f,h,m,v=_.groupBy(p,"organization.id"),S=[];_.each(v,function(e,t){t&&e&&(e.length>1&&(f=_.findIndex(e,function(e){return e&&"active"===e.status}),h=_.findIndex(e,function(e){return e&&"inactive"===e.status}),f>=0&&h>=0&&(e[f].id&&e[f].organization&&D&&D.length&&(m=_.find(D,function(t){return t&&t.organization&&t.organization.id!==e[f].organization.id&&t.id===e[f].id}))&&(m.status="inactive",e.push(m)),e[f].id=e[h].id,e.splice(h,1))),e[0]&&e[0].id&&e[0].organization&&D&&D.length&&(m=_.find(D,function(t){return t&&t.organization&&t.organization.id!==e[0].organization.id&&t.id===e[0].id}))&&(m.status="inactive",e.push(m),delete e[0].id)),e&&e.length>0&&(S=S.concat(e))}),p=S;for(let e=0;e<p.length>0;e++){var C=new a.OrganizationUser;C.resourceType="OrganizationUser",C.status=p[e].status,C.user=o,C.role=p[e].role,p[e].adminOrganization&&(C.adminOrganization=p[e].adminOrganization,p[e].suborganization&&(C.suborganization=p[e].adminOrganization),C.organization=p[e].organization,C.onBehalfOf=p[e].onBehalfOf,!p[e].onBehalfOf||p[e].onBehalfOf.type&&"none"!==p[e].onBehalfOf.type||delete C.onBehalfOf);var y=angular.copy(p[e].id||c.generateGUID());i.entry.push({resource:C.toFhir(),request:{method:p[e].id?"PUT":"POST",url:"OrganizationUser"},fullUrl:u.OrganizationUserURL+"/"+y}),i.entry[i.entry.length-1].resource.id=y,d.push(angular.copy(C))}}i.entry.push({resource:o.toFhir(),request:{method:"add"===e.operation?"POST":"PUT",url:"User"},fullUrl:u.UserApiURL+"/"+o.id}),i.entry[i.entry.length-1].resource.id=o.id,n.saveBulkData(i,e.assignCognitoUser).then(function(){"profile"!==e.operation&&(o.roles=angular.copy(d)),N(o),e.
8isSaving=!1},function(t){if(t&&t.issue&&t.issue.length)for(let c=0;c<t.issue.length;c++){var n="";if(t.issue[c].targetResource&&(n=t.issue[c].targetResource.display),t.issue[c]&&t.issue[c].details)switch(t.issue[c].details.code){case l.ERROR.MSG_DUPLICATE_IDENTIFIER_NPI.code:e.npiErrorMsg=l.ERROR.MSG_DUPLICATE_IDENTIFIER_NPI.display+" "+n;break;case l.ERROR.MSG_PASSWORD_ISSUE.code:case l.ERROR.MSG_COMPROMISED_PASSWORD.code:e.passwordErrorMsgOnSave=t.display;break;case l.ERROR.MSG_USERNAME_ALREADY_ADDED.code:e.usernameAlreadyAddedMsgOnSave=t.display;break;case l.ERROR.MSG_EMAIL_DUPLICATE.code:e.emailAlreadyAddedMsgOnSave=t.display;break;case l.ERROR.MSG_COGNITO_USERNAME_ALREADY_EXISTS.code:var i=t.issue[c].cognitoUser,s=new a.CognitoUser(null,o),d=e.$new();d.cognitoAttrs=i,d.ppAttrs=s,r.open({templateUrl:"modules/administration/users/userLink.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",scope:d,controller:"userLinkCtrl",backdrop:"static"}).result.then(function(t){for(var n in e.refresh=!e.refresh,t){var i=null;switch(n){case"email":i="contactEmail";break;case"familyName":i="given";break;case"givenName":i="family";break;case"phone":i="phone"}e.user[i]=t[n]}e.assignCognitoUser=!0,e.save()},function(){})}}e.isSaving=!1})}},e.cancel=function(){e.$dismiss?e.$dismiss("cancel"):e.$emit("onUserCancelledEvent")}}]),app.ui.administration.controller("nxtUserListCtrl",["$timeout","$scope","$q","nxtInfiniteScrollSvc","nxtSecuritySvc","nxtOrganizationSvc","nxtUserContextSvc","nxtUserInfoStoreSvc","NXT_USER_SECURITY_QUESTIONS",function(e,t,n,i,a,o,r,s,l){"use strict";t.users=[],t.rolesList=[];var d={id:null,name:"All roles"},c=0,u=0,p=0,g=0;t.searchOrganization=o.search,t.isCognitoAuthorizationFlow=s.state.isCognitoAuthorizationFlow;var f=[{code:"",display:"All Account Statuses"},{code:"active",display:"Active Account"},{code:"inactive",display:"Inactive Account"}];t.passwordStatusList=[{code:"",display:"All Password Statuses"},{code:"active",display:"Active Password"},{code:"password-expired",display:"Expired Password"}];var h,m={},v={},S="admUsersListContext";function C(){var e=angular.copy(f),i=!1;if(!t.isCognitoAuthorizationFlow){var o=r.ApplicationConfiguration;(c=o&&o.accountExpiry>0?o.accountExpiry:0)>0?_.find(e,function(e){return"expired"===e.code})||e.push({code:"expired",display:"Expired Account"}):t.filterBy.status&&"expired"===t.filterBy.status.code&&(i=!0),u=o&&o.passwordExpiry>0?o.passwordExpiry:0,t.showPasswordFilter=u>0,(p=o&&o.maxFailedLoginAttempts>0?o.maxFailedLoginAttempts:0)>0?_.find(e,function(e){return"password-locked"===e.code})||e.push({code:"password-locked",display:"Password Locked"}):t.filterBy.status&&"password-locked"===t.filterBy.status.code&&(i=!0),l.VerifySecurityQuestions&&(g=o&&o.securityAnswers&&o.securityAnswers.maxAttempts>0?o.securityAnswers.maxAttempts:0)>0?_.find(e,function(e){return"question-locked"===e.code})||e.push({code:"question-locked",display:"Questions Locked"}):t.filterBy.status&&"question-locked"===t.filterBy.status.code&&(i=!0),_.find(e,function(e){return"never-activated"===e.code})||e.push({code:"never-activated",display:"Never Activated"})}t.statusList=e,t.filterBy=_.extend(t.filterBy,{status:i?t.statusList[0]:t.filterBy.status,passwordStatus:t.showPasswordFilter?t.filterBy.passwordStatus?t.filterBy.passwordStatus:t.isCognitoAuthorizationFlow?null:t.passwordStatusList[0]:null});var s=[a.getRoles()];n.all(s).then(function(e){t.rolesList=e[0]&&e[0].length>0?e[0]:[],t.rolesList.unshift(d),t.filterBy.isLoadFilterSectionData=!0},function(e){})}function y(e){if(t.filterBy.isLoadFilterSectionData){e||(t.users=[]);var n=r.getCurrentPageContextProperty("syncCognitoUsers");n||r.setCurrentPageContextProperty("syncCognitoUsers",!0),m.nxtUserSvc={name:t.filterBy.name,role:t.filterBy.role?t.filterBy.role.id:null,status:t.filterBy.status?t.filterBy.status.code:null,sort:"=username",organization:t.filterBy.facility&&"organization"===t.filterBy.facility.category?t.filterBy.facility.id:null,subOrganization:t.filterBy.facility&&"suborganization"===t.filterBy.facility.category?t.filterBy.facility.id:null,npiNumber:t.filterBy.npi,expireddays:c,includeOrganizationUser:!0,syncCognito:!n,maxFailedLoginAttempts:p,maxFailedQuestionAttempts:g,passwordExpiry:t.showPasswordFilter?u:null,passwordStatus:t.showPasswordFilter&&t.filterBy.passwordStatus?t.filterBy.passwordStatus.code:null},t.infiniteScroll.isBusy(!e,m)||t.infiniteScroll.nextPage(!e).then(function(n){t.users||
8(t.users=[]),t.users=e?t.users.concat(n):n,e||(t.operation=t.users&&t.users.length>0?"view":null,t.changeSelection(t.users&&t.users.length>0?t.users[0]:null)),!t.operation&&t.userData&&(t.userData=null)})}}function b(n,i,a){t.operation=n,t.userData=null,h=e(function(){t.userData={operation:n,accountExpiry:c,passwordExpiry:u,maxFailedLoginAttempts:p,maxFailedQuestionAttempts:g},"edit"!==n&&"view"!==n||!t.userSelectedItem||(t.userData.userId=i,t.userData.userSecureEmail=t.userSelectedItem.email)},1)}v.nxtUserSvc={methodName:"searchWithTotalRowsAndIncludeOrganizationUser"},t.infiniteScroll=i.create({services:v,limit:100}),t.filterBy={name:null,role:d,status:t.isCognitoAuthorizationFlow?f[1]:f[0],facility:null,npi:null,isLoadFilterSectionData:!1,passwordStatus:t.isCognitoAuthorizationFlow?null:t.passwordStatusList[0]},C(),t.$watchCollection("[filterBy.name, filterBy.role.id, filterBy.status.code, filterBy.facility.id, filterBy.npi, filterBy.isLoadFilterSectionData, filterBy.passwordStatus]",function(e,n){(!e[0]||e[0]&&e[0].length>=3)&&(y(),r.setCurrentPageContextProperty(S,{name:t.filterBy.name,role:t.filterBy.role,status:t.filterBy.status,passwordStatus:t.filterBy.passwordStatus,facility:t.filterBy.facility,npi:t.filterBy.npi}))}),function(){if(t.currentPageContextChecked)return;var e=r.getCurrentPageContextProperty(S);e&&(t.filterBy.name=e.name,t.filterBy.role=e.role,t.filterBy.status=e.status,t.filterBy.facility=e.facility,t.filterBy.passwordStatus=e.passwordStatus,t.filterBy.npi=e.npi,t.currentPageContextChecked=!0)}(),t.getMoreData=function(){y(!0)},t.getRoles=function(e){var t="";if(e.roles&&e.roles.length>0)for(var n=0;n<e.roles.length;n++)if("inactive"!==e.roles[n].status){var i=e.roles[n].adminOrganization&&e.roles[n].adminOrganization.name?e.roles[n].adminOrganization.name:"";if(e.roles[n].role&&e.roles[n].role.length>0){var a=_.map(e.roles[n].role,function(e){return e.name||e.display}).join(", ");i+=(_.isEmpty(i)?"":" - ")+a}i&&(t+=(_.isEmpty(t)?"":"; ")+i)}return t},t.addUser=function(){t.operation="add",b("add",null,null)},t.editUser=function(e){t.operation="edit",b("edit",t.userSelectedItem.id,t.userSelectedItem)},t.$watch("userSelectedItem",function(e,n){e&&b("view",t.userSelectedItem.id)},!0);var x=t.$on("onUserCancelledEvent",function(e){e.stopPropagation(),T()}),D=t.$on("onUserSavedEvent",function(e,n){if(e.stopPropagation(),n&&n.id&&t.userData)if("add"===t.userData.operation)t.users||(t.users=[]),t.users.unshift(n),t.userSelectedItem=null;else if("edit"===t.userData.operation&&t.users)for(var i=0;i<t.users.length;i++)if(t.users[i].id===n.id){t.users[i]=n;break}T()});function T(){if(t.operation=t.users&&t.users.length>0?"view":null,"view"===t.operation)if(t.userSelectedItem){var e=angular.copy(t.userSelectedItem);b("view",e.id)}else t.changeSelection(t.users[0]);else t.userData=null}var w=t.$on("nxtReloadData",function(e,n){"userManagement"===n&&(t.users=[],t.userSelectedItem=null,T(),t.filterBy&&t.filterBy.isLoadFilterSectionData&&(t.filterBy.isLoadFilterSectionData=!1),C())});t.$on("$destroy",function(){w(),x(),D(),h&&e.cancel(h)})}]),app.ui.administration.controller("nxtUserEditTokenCtrl",["$scope","$uibModalInstance","nxtUserSvc","CONSTANT","$q",function(e,t,n,i,a){"use strict";e.isSaving=!1,e.data={},e.$watch("data.token",function(){e.wrongTokenMessage&&e.wrongTokenMessage&&(e.wrongTokenMessage=null)}),e.save=function(){e.isSaving=!0;var o=[];e.urlToken?o.push(n.validate2FA(e.urlToken,e.telecomValue,e.authenticationType,e.data.token)):o.push(n.apiValidate2FA(e.user.id,"sms_home"===e.user.secondFactorAuthMethod.code?e.user.phone:e.user.contactEmail,e.user.secondFactorAuthMethod.code,e.data.token)),a.all(o).then(function(n){t.close(e.token)},function(t){(t&&t.issue&&t.issue.length>0?_.find(t.issue,function(e){return e.details&&e.details.code===i.ERROR.MSG_MISSING_OR_INVALID_TOKEN.code}):null)&&(e.wrongTokenMessage=t.display),e.isSaving=!1})},e.resend=function(){e.isSaving=!0,e.data={},e.mainForm.resetForm();var t=[];e.urlToken?t.push(n.validate2FA(e.urlToken,e.telecomValue,e.authenticationType,e.data.token)):t.push(n.apiValidate2FA(e.user.id,"sms_home"===e.user.secondFactorAuthMethod.code?e.user.phone:e.user.contactEmail,e.user.secondFactorAuthMethod.code,e.data.token)),a.all(t).then(function(t){var n=t&&t[0]&&t[0].issue&&t[0].issue.length>0?_.find(t[0].issue,function(e){return e.details&&(e.details.code===i.ERROR.MSG_TOKEN_SENT_TO_S
8MS.code||e.details.code===i.ERROR.MSG_TOKEN_SENT_TO_EMAIL.code)}):null;n&&(e.secondFactorMessage=t[0].display,e.verificationCode=n.uniqueId?n.uniqueId+" - ":null),e.isSaving=!1},function(t){e.isSaving=!1})},e.close=function(){t.dismiss("cancel")}}]),app.ui.administration.controller("userLinkCtrl",["$scope","nxtResourceTypesSvc",function(e,t){"use strict";for(var n in e.mergeAttrs=new t.CognitoUser,e.requiredAttrs={},e.nxtRequiredAttrs={},e.hasConflicts=!1,e.mergeAttrs)e.nxtRequiredAttrs[n]="phone"!==n,e.cognitoAttrs[n]&&e.ppAttrs[n]&&e.cognitoAttrs[n].toLowerCase()!==e.ppAttrs[n].toLowerCase()?e.requiredAttrs[n]=!0:e.cognitoAttrs[n]&&!e.ppAttrs[n]?e.requiredAttrs[n]=!0:!e.cognitoAttrs[n]&&e.ppAttrs[n]?e.requiredAttrs[n]=!0:e.requiredAttrs[n]=!1,e.requiredAttrs[n]&&!e.hasConflicts&&(e.hasConflicts=!0),e.mergeAttrs[n]=_.isNil(e.cognitoAttrs[n])?e.ppAttrs[n]:e.cognitoAttrs[n];e.link=function(){e.$close(e.mergeAttrs)},e.cancel=function(){e.$dismiss("cancel")}}]),app.ui.administration.controller("userSessionTimeoutCtrl",["$scope","$uibModalInstance","nxtUserContextSvc","nxtUserSvc",function(e,t,n,i){"use strict";e.resetSession=function(){n.loggedUser&&n.loggedUser.id&&(e.isSaving=!0,i.get(n.loggedUser.id).then(function(){e.isSaving=!1,t.close()},function(){e.isSaving=!1}))},e.$on("IdleTimeout",function(){e.isSaving=!0,n.logoutUser().then(function(){n.logoutCallback()},function(){n.logoutCallback()})})}]),app.ui.administration.controller("nxtUserSettingsCtrl",["$scope","$q","CONSTANT","NXT_AUTHORIZATION_ENABLED","$rootScope","nxtConfigurationSvc","nxtUserContextSvc","nxtUtilsSvc","NXT_SHOW_CHANGE_LOCALE","NXT_LANGUAGES_INFO","gettextCatalog",function(e,t,n,i,a,o,r,s,l,d,c){"use strict";e.isLoading=!0,e.showChangeLocale=l,e.languages=d.languages,e.fonts=s.getFontList(),e.conflictsVitalsList=["pacVitalS","pacVitalSparklines"],e.sourcePatientBannerInformation=null,e.resultPatientBannerInformation=null,e.notConfigurationMessage=c.getString("This user role doesn't have any associated application configuration.");var u=_.map(s.doctorDashboardWidgets,function(e){return{code:e.code,display:e.display}}),p=_.map(s.patientDashboardWidgets,function(e){var t={code:e.code,display:e.display.replace("Vital signs","Vitals").trim()};return"pacVitalS"===e.code&&(t.display=c.getString("Vitals simple list"),t.type="simple"),"pacLabRes"===e.code&&(t.display=c.getString("Lab")),t});p.push({code:"pacVitalSparklines",type:"sparklines",display:c.getString("Vitals sparklines list")});var g=[],f=_.map(s.patientBannerList,function(e){return{code:e.code,display:e.display}}),h=[n.GENERIC.EXPANDED_VIEWS.GRAPHS.code,n.GENERIC.EXPANDED_VIEWS.EHX.code],m=_.map(_.filter(s.patientDashboardWidgets,function(e){return"pacTasks"!==e.code&&"pacEPrescriptions"!==e.code}),function(e){return{code:e.code,display:e.displayFn?e.displayFn():e.display}});m=m.concat(_.map(_.filter(s.patientDashboardAdditionalViews,function(e){return h.indexOf(e.code)>=0}),function(e){return{code:e.code,display:e.displayFn?e.displayFn():e.display}})),e.sourceDoctorDashItems=null,e.resultDoctorDashItems=null,e.sourcePatientDashItems=null,e.hasOrganizationRoles=r.OrganizationUser&&r.OrganizationUser.length>0&&r.OrganizationUser[0].organization,e.facilities=r.LoggedUserConfiguration.facilities;var v=[o.search({owner:"User/"+r.loggedUser.id}),app.checkPermission(n.PERMISSION.PATIENT_CHART),app.checkPermission(n.PERMISSION.WIDGETS_READ),app.checkPermission(n.PERMISSION.CLINICIAN_MODULE),app.checkPermission(n.PERMISSION.DOCTOR_WIDGETS_READ)].concat(_.map(s.patientDashboardWidgets,function(e){return app.checkPermission(e.permission)}));function S(){var t=[],n=[];if(e.configuration.doctorDashboardConfig){for(let t=0;t<e.configuration.doctorDashboardConfig.length;t++)e.configuration.doctorDashboardConfig[t].length>0&&(n=n.concat(e.configuration.doctorDashboardConfig[t]));for(let e=0;e<u.length;e++)_.find(n,function(t){return t.code===u[e].code})||t.push(u[e])}else t=u.slice();if(n&&n.length>0)for(var i=n.length-1;i>=0;i--)_.find(g,function(e){return e===n[i].code})||(n[i].invalid=!0);if(t&&t.length>0)for(var a=t.length-1;a>=0;a--)_.find(g,function(e){return e===t[a].code})||t.splice(a,1);e.sourceDoctorDashItems=angular.copy(t),e.doctorDashConfig||(e.doctorDashConfig={selectedColumn:0}),!e.doctorDashConfig.selectedColumn&&e.configuration.doctorDashboardConfig&&e.configuration.doctorDashboardConfig.length>0&&(e.doctorDashConfig.selectedColumn=e.configuration.doctorDashboardConfig.length)}function C(){var t=[],n=[];if(e.configuration.patientDashboardConfig){for(let t=0;t<e.configuration.patientDashboardConfig.length;t++)if(e.configuration.patientDashboardConfig[t].length>0){var i=_.find(e.configuration.patientDashboardConfig[t],function(e){return"pacVitalS"===e.code});if(i){var a=_.find(p,function(e){return e.code===(i.type&&"simple"!==i.type?"pacVitalSparklines":"pacVitalS")});a&&(i.code=a.code,i.display=a.display)}n=n.concat(e.configuration.patientDashboardConfig[t])}for(let e=0;e<p.length;e++)_.find(n,function(t){return t.code===p[e].code})||t.push(p[e])}else t=p.slice();if(n&&n.length>0)for(var o=n.length-1;o>=0;o--)_.find(g,function(e){return e===n[o].code})||(n[o].invalid=!0);if(t&&t.length>0)for(var r=t.length-1;r>=0;r--)_.find(g,function(e){return e===t[r].code})||t.splice(r,1);if(e.sourcePatientExpandedViews=[],e.resultPatientExpandedViews=e.resultPatientExpandedViews?_.filter(e.resultPatientExpandedViews,function(e){return h.indexOf(e.code)>=0}):[],e.configuration.patientExpandedViewsConfig){for(let t=0;t<e.configuration.patientExpandedViewsConfig.length;t++)(_.find(m,function(n){return h.indexOf(e.configuration.patientExpandedViewsConfig[t].code)>=0}
8)||_.find(n,function(n){return("pacVitalSparklines"===n.code?"pacVitalS":n.code)===e.configuration.patientExpandedViewsConfig[t].code}))&&_.find(m,function(n){return e.configuration.patientExpandedViewsConfig[t].code===n.code})&&e.resultPatientExpandedViews.push(e.configuration.patientExpandedViewsConfig[t]);for(let t=0;t<m.length;t++)_.find(n,function(e){return("pacVitalSparklines"===e.code?"pacVitalS":e.code)===m[t].code})&&(_.find(e.resultPatientExpandedViews,function(e){return("pacVitalSparklines"===e.code?"pacVitalS":e.code)===m[t].code})||e.sourcePatientExpandedViews.push(m[t]))}else if(n)for(let t=0;t<n.length;t++){var s=_.find(m,function(e){return e.code===("pacVitalSparklines"===n[t].code?"pacVitalS":n[t].code)});s&&e.sourcePatientExpandedViews.push(s)}if(e.resultPatientExpandedViews&&e.resultPatientExpandedViews.length>0)for(var l=e.resultPatientExpandedViews.length-1;l>=0;l--)_.find(g,function(t){return t===e.resultPatientExpandedViews[l].code})||(e.resultPatientExpandedViews[l].invalid=!0);var d=_.filter(m,function(e){return h.indexOf(e.code)>=0});_.forEach(d,function(t){!_.find(g,function(e){return e===t.code})||_.find(e.sourcePatientExpandedViews,function(e){return e.code===t.code})||_.find(e.resultPatientExpandedViews,function(e){return e.code===t.code})||e.sourcePatientExpandedViews.push(t)}),e.sourcePatientDashItems=angular.copy(t),e.resultPatientDashItems=angular.copy(n),e.patientDashConfig||(e.patientDashConfig={selectedColumn:0}),!e.patientDashConfig.selectedColumn&&e.configuration.patientDashboardConfig&&e.configuration.patientDashboardConfig.length>0&&(e.patientDashConfig.selectedColumn=e.configuration.patientDashboardConfig.length)}v=(v=(v=v.concat(_.map(s.doctorDashboardWidgets,function(e){return app.checkPermission(e.permission)}))).concat(_.map(s.patientBannerList,function(e){return app.checkPermission(e.permission)}))).concat(_.map(s.patientDashboardAdditionalViews,function(e){return app.checkPermission(e.permission)})),t.all(v).then(function(t){if(e.hasSummaryAccess=t&&t[1]&&!0===t[1].result&&t[2]&&!0===t[2].result&&!0===i,e.hasLandingPageAccess=t&&t[3]&&!0===t[3].result&&t[4]&&!0===t[4].result&&!0===i,t&&t[0]&&t[0].length>0&&t[0][0]){var n=t[0][0];if(e.hasOrganizationRoles&&n.organizationUser&&n.organizationUser.id){var a=_.find(r.OrganizationUser,function(e){return e.id===n.organizationUser.id});a&&a.organization&&(n.organization=a.organization)}e.configuration=angular.copy(n),e.initialConfiguration=angular.copy(n)}for(let e=t.length-s.patientDashboardWidgets.length-s.doctorDashboardWidgets.length-s.patientBannerList.length-s.patientDashboardAdditionalViews.length;e<t.length;e++){var o=null;t[e].result&&((o=_.find(s.patientDashboardWidgets,function(n){return n.permission===t[e].action}))||(o=_.find(s.doctorDashboardWidgets,function(n){return n.permission===t[e].action})),o||(o=_.find(s.patientBannerList,function(n){return n.permission===t[e].action})),o||(o=_.find(s.patientDashboardAdditionalViews,function(n){return n.permission===t[e].action})),o&&(g.push(o.code),"pacVitalS"===o.code&&g.push("pacVitalSparklines")))}C(),S(),function(t,n,i,a){e.configuration[t]?e[n]=[]:e[n]=a.slice();if(e[i]=[],e.configuration[t]){for(let n=0;n<e.configuration[t].length;n++)_.find(a,function(i){return i.code===e.configuration[t][n].code})&&e[i].push(e.configuration[t][n]);for(let i=0;i<a.length;i++)_.find(e.configuration[t],function(e){return e.code===a[i].code})||e[n].push(a[i])}if(e[i]&&e[i].length>0)for(var o=e[i].length-1;o>=0;o--)_.find(g,function(t){return t===e[i][o].code})||(e[i][o].invalid=!0);if(e[n]&&e[n].length>0)for(var r=e[n].length-1;r>=0;r--)_.find(g,function(t){return t===e[n][r].code})||e[n].splice(r,1)}("patientBannerConfig","sourcePatientBannerInformation","resultPatientBannerInformation",f),e.isLoading=!1},function(){e.isLoading=!1}),e.patientDashSourceItemMoved=function(t){for(let i=0;i<t.length;i++){var n=_.find(m,function(e){return e.code===("pacVitalSparklines"===t[i].code?"pacVitalS":t[i].code)});n&&!_.find(e.sourcePatientExpandedViews,function(e){return e.code===n.code})&&e.sourcePatientExpandedViews.push(n)}},e.patientDashResultItemMoved=function(t){var n;for(let i=0;i<t.length;i++)n="pacVitalSparklines"===t[i].code?"pacVitalS":t[i].code,_.find(g,function(e){return e===n})||(e.sourcePatientDashItems="pacVitalS"===n?_.filter(e.sourcePatientDashItems,function(e){return e.code!==n&&"pacVitalSparklines"!==e.code}):_.filter(e.sourcePatientDashItems,function(e){return e.code!==n})),e.sourcePatientExpandedViews=_.filter(e.sourcePatientExpandedViews,function(e){return e.code!==n}),e.resultPatientExpandedViews=_.filter(e.resultPatientExpandedViews,function(e){return e.code!==n})},e.resultItemMoved=function(t,n){var i;for(let a=0;a<t.length;a++)i=t[a].code,_.find(g,function(e){return e===i})||(e[n]=_.filter(e[n],function(e){return e.code!==i}))},e.patientViewResultItemMoved=function(t){var n=_.filter(t,function(e){return h.indexOf(e.code)>=0});n&&n.length>0&&e.resultItemMoved(n,"sourcePatientExpandedViews")},e.$watchCollection("[patientDashConfig.selectedColumn, doctorDashConfig.selectedColumn]",function(t,n){if(t[0]||t[1]||n[0]||n[1]){if
8(!_.isNil(n[0])&&t[0]!==n[0]){e.configuration.patientDashboardConfig=[];for(let n=0;n<t[0];n++)e.configuration.patientDashboardConfig.push([]);e.configuration.patientExpandedViewsConfig=[],C()}if(!_.isNil(n[1])&&t[1]!==n[1]){e.configuration.doctorDashboardConfig=[];for(let n=0;n<t[1];n++)e.configuration.doctorDashboardConfig.push([]);S()}}}),e.isClinicianDashboardInvalid=function(){if(!e.hasLandingPageAccess)return!1;var t=!1;if(e.configuration&&e.configuration.doctorDashboardConfig&&e.configuration.doctorDashboardConfig.length>0)for(let n=0;n<e.configuration.doctorDashboardConfig.length&&(e.configuration.doctorDashboardConfig[n]&&e.configuration.doctorDashboardConfig[n].length>0&&(t=_.find(e.configuration.doctorDashboardConfig[n],function(e){return e.invalid})),!t);n++);return t},e.isPatientChartInvalid=function(){if(!e.hasSummaryAccess)return!1;var t=!1;if(e.configuration&&e.configuration.patientDashboardConfig&&e.configuration.patientDashboardConfig.length>0)for(let n=0;n<e.configuration.patientDashboardConfig.length&&(e.configuration.patientDashboardConfig[n]&&e.configuration.patientDashboardConfig[n].length>0&&(t=_.find(e.configuration.patientDashboardConfig[n],function(e){return e.invalid})),!t);n++);return!t&&e.configuration&&e.configuration.resultPatientExpandedViews&&e.configuration.resultPatientExpandedViews.length>0&&(t=_.find(e.configuration.resultPatientExpandedViews,function(e){return e.invalid})),!t&&e.resultPatientBannerInformation&&e.resultPatientBannerInformation.length>0&&(t=_.find(e.resultPatientBannerInformation,function(e){return e.invalid})),t},e.save=function(){if(e.isSaving=!0,e.configuration.organization&&e.configuration.organization.id&&(e.configuration.organizationUser=_.find(r.OrganizationUser,function(t){return t.organization.id===e.configuration.organization.id})),e.configuration.patientDashboardConfig)for(let n=0;n<e.configuration.patientDashboardConfig.length;n++)for(var t=0;t<e.configuration.patientDashboardConfig[n].length;t++)"pacVitalSparklines"!==e.configuration.patientDashboardConfig[n][t].code&&"pacVitalS"!==e.configuration.patientDashboardConfig[n][t].code||(e.configuration.patientDashboardConfig[n][t].type="simple","pacVitalSparklines"===e.configuration.patientDashboardConfig[n][t].code&&(e.configuration.patientDashboardConfig[n][t].type="sparklines",e.configuration.patientDashboardConfig[n][t].code="pacVitalS"),e.configuration.patientDashboardConfig[n][t].display="Vital signs");if(e.configuration.patientExpandedViewsConfig=[],e.resultPatientExpandedViews)for(let t=0;t<e.resultPatientExpandedViews.length;t++)e.configuration.patientExpandedViewsConfig.push({code:e.resultPatientExpandedViews[t].code,display:e.resultPatientExpandedViews[t].display});if(e.configuration.patientBannerConfig=[],e.resultPatientBannerInformation)for(let t=0;t<e.resultPatientBannerInformation.length;t++)e.configuration.patientBannerConfig.push({code:e.resultPatientBannerInformation[t].code,display:e.resultPatientBannerInformation[t].display});o.save(e.configuration).then(function(){r.updateUserConfiguration(e.configuration);var t=e.initialConfiguration&&e.initialConfiguration.organization?e.initialConfiguration.organization.id:null,n=e.configuration&&e.configuration.organization?e.configuration.organization.id:null;_.isEqual(t,n)?a.$emit("onUserConfigurationChanged",e.initialConfiguration):a.$emit("onUserConfigurationOrganizationChanged"),e.$close(r.LoggedUserConfiguration)},function(t){e.isSaving=!1})},e.hideData=function(t){"showClinicianDashboard"!==t&&(e.showClinicianDashboard=!1),"showPatientChart"!==t&&(e.showPatientChart=!1),"showPreferredInterfaceLanguage"!==t&&(e.showPreferredInterfaceLanguage=!1)},e.hideData(),e.expandData=function(t){e.hideData(t),e[t]=!e[t]},e.close=function(){e.$dismiss("cancel")}}]),app.ui.audit.config(["gettext",function(e){"use strict";app.ui.audit.link={url:"/audit",name:e("Audit"),code:"audit"}}]),app.ui.audit.controller("nxtAuditListCtrl",["$scope","gettextCatalog","$q","nxtUserContextSvc","nxtUserSvc","nxtOrganizationSvc","nxtInfiniteScrollSvc","$filter","CONSTANT","$timeout","nxtValueSetSvc","NXT_EHX_CONFIG",function(e,t,n,i,a,o,r,s,l,d,c,u){"use strict";e.isEHxEnabled=u.Enabled,e.eHxResources="ehxpatient,ehxdocument,ehxbinary",e.clinicalResources="diagnosticreport,documentreference,observation,device,medicationdispense,medicationrequest,allergyintolerance,coverage,condition,immunization,relatedpers
8on,procedure,encounter,breakglass,attestation",e.administrativeResources="user,organization,login,logout,consent,role,applicationconfiguration",e.allResources=e.clinicalResources+","+e.administrativeResources+(u.Enabled?","+e.eHxResources:""),e.filter={user:null,breakGlass:null,breakGlassReason:[],attestation:null,attestationReason:[],operation:[],resourceType:e.allResources},e.defaultDateFilter={interval:{start:{code:"all",display:"All"},end:{code:"today",display:"Today"}}};var p={},g={},f="auditListContext";g.nxtAuditSvc={methodName:"searchWithoutTotalRows"},e.infiniteScroll=r.create({services:g,limit:100}),e.searchUser=a.search,e.searchOrganization=o.search,n.all([c.get({valueSetName:"EmergencyAccessReason",limit:100}),c.get({valueSetName:"AttestationAccessReason",limit:100})]).then(function(t){e.breakGlassReasons=t[0],e.attestationReasons=t[1]}),e.operationTypes=[{display:"Create",code:"create"},{display:"Update",code:"update"},{display:"Delete",code:"delete"},{display:"Download",code:"download"},{display:"Login",code:"login"},{display:"Logout",code:"logout"},{display:"Search",code:"search"},{display:"View",code:"view"},{display:"Break glass",code:"breakglass"},{display:"Attestation",code:"attestation"}],u.Enabled&&e.operationTypes.push({display:"eHealth Exchange",code:"eHx"});var h,m=e.$on("auditListDateFilterChangedEvent",function(t,n){e.filter.startDate=null,e.filter.endDate=null,e.filter.isAllFilter=!1,n&&n.interval&&(n.interval.startDate&&(e.filter.startDate=n.interval.startDate),n.interval.endDate&&(e.filter.endDate=n.interval.endDate),e.filter.isAllFilter=n.interval.isAllFilter),v(),t.stopPropagation()});function v(t){t||(e.vsData=[]),p.nxtAuditSvc={user:e.filter.user?e.filter.user.id:null,startDate:!e.filter.isAllFilter&&e.filter.startDate?e.filter.startDate:null,endDate:!e.filter.isAllFilter&&e.filter.endDate?e.filter.endDate:null,breakGlass:e.filter.breakGlass,breakGlassReason:e.filter.breakGlass&&e.filter.breakGlassReason&&e.filter.breakGlassReason.length?e.filter.breakGlassReason:null,operation:e.filter.operation&&e.filter.operation.length?e.filter.operation:null,organization:e.filter.organization?e.filter.organization.id:null,resourceType:e.filter.resourceType?e.filter.resourceType:null,attestation:e.filter.attestation,attestationReason:e.filter.attestation&&e.filter.attestationReason&&e.filter.attestationReason.length?e.filter.attestationReason:null,sortBy:":desc=date"},e.infiniteScroll.isBusy(!t,p)||e.infiniteScroll.nextPage(!t).then(function(n){e.vsData||(e.vsData=[]),e.vsData=t?e.vsData.concat(n):n,t||(e.operation=e.vsData&&e.vsData.length>0?"view":null,e.changeSelection(e.vsData&&e.vsData.length>0?e.vsData[0]:null)),!e.operation&&e.auditData&&(e.auditData=null)})}function S(e,n){return'<label class="control-label content-without-padd-top" >'+t.getString(e)+':</label>&nbsp<span class="bold">'+n+"</span>&nbsp"}function C(t){e.operation=t,e.auditData=null,h=d(function(){e.auditData={operation:t},e.auditSelectedItem&&("history"===t?e.auditData.auditItem=angular.copy(e.auditSelectedItem):e.auditData.auditId=e.auditSelectedItem.id)},1)}e.$watchCollection("[filter.user, filter.breakGlass, filter.operation.length, filter.organization, filter.resourceType, filter.attestation, filter.breakGlassReason.length, filter.attestationReason.length]",function(t,n){_.isEqual(t,n)||(v(),i.setCurrentPageContextProperty(f,{user:e.filter.user,breakGlass:e.filter.breakGlass,operation:e.filter.operation,organization:e.filter.organization,resourceType:e.filter.resourceType,breakGlassReason:e.filter.breakGlassReason,attestation:e.filter.attestation,attestationReason:e.filter.attestationReason}))}),e.$watch("auditSelectedItem",function(e){e&&C("view")},!0),function(){if(e.currentPageContextChecked)return;var t=i.getCurrentPageContextProperty(f);t&&(e.filter.user=t.user,e.filter.breakGlass=t.breakGlass,e.filter.operation=t.operation,e.filter.organization=t.organization,e.filter.resourceType=t.resourceType,e.filter.breakGlassReason=t.breakGlassReason,e.filter.attestation=t.attestation,e.filter.attestationReason=t.attestationReason,e.currentPageContextChecked=!0)}(),e.getMoreData=function(){v(!0)},e.setEntryDisplay=function(e){var t,n="";return n+='<div class="col-xs-4 break-word-audit no-pad">
8',e.dateTime&&(n+=S("Date",(t=e.dateTime)?s("date")(t,"MM/dd/yyyy HH:mm"):"")),e.user&&e.user.display&&(n+="<br/>",n+=S("User",e.user.display),e.sso&&(e.sso.lastName&&(n+="<br/>",n+=S("SSO User Last Name",e.sso.lastName||"")),e.sso.firstName&&(n+="<br/>",n+=S("SSO User First Name",e.sso.firstName||"")))),e.organization&&e.organization.display&&(n+="<br/>",n+=S("Organization",e.organization.display)),e.userRoles&&e.userRoles.length&&e.userRoles[0]&&(n+="<br/>",n+=S("Role",e.userRoles[0].name)),n+="</div>",n+='<div class="col-xs-4 no-pad">',e.type&&(n+=S("Operation",e.type)),e.displayResourceType&&(n+="<br/>",n+=S("Resource",e.displayResourceType)),e.subject&&(e.subject.display||e.subject.id)&&(n+="<br/>",n+=S(("eHx"===e.type?"eHx ":"")+"Patient",e.subject.display||e.subject.id&&"Patient/"+e.subject.id)),e.details&&(n+="<br/>",n+=S("Details",e.details)),n+="</div>",n+='<div class="col-xs-4 no-pad">',e.breakGlassReason?n+=S("Access Type","With Break Glass"):n+=S("Access Type","Normal"),n+="<br/>",e.attestationReason?n+=S("Attestation Type","With Attestation"):n+=S("Attestation Type","Normal"),n+="</div>"},e.actionMenuId="historyItem",e.historyDetails=function(){C("history")},e.actions=[l.ACTION.HISTORY.get({command:e.historyDetails})],e.getRowActions=function(t){var n=!0;return t.event&&t.event.subtype&&t.event.subtype.length>0&&-1!==["create","update","delete"].indexOf(t.event.subtype[0].display)&&(n=!1),[l.ACTION.HISTORY.get({command:e.historyDetails,disabled:n})]};var y=e.$on("onHistoryDetailsCancelledEvent",function(t){t.stopPropagation(),e.operation=e.vsData&&e.vsData.length>0?"view":null,"view"===e.operation&&(e.auditSelectedItem?(e.auditSelectedItem.$selected||e.changeSelection(e.auditSelectedItem),C("view")):e.changeSelection(e.vsData[0]))});e.$on("$destroy",function(){y(),m(),h&&d.cancel(h)})}]),app.ui.audit.controller("nxtViewDetailsCtrl",["$scope","gettext","nxtAuditSvc",function(e,t,n){"use strict";e.auditId&&(e.isLoading=!0,n.get(e.auditId).then(function(t){e.auditEvent=t,e.isLoading=!1},function(){e.isLoading=!1})),app.ui.audit.filter("unsafe",["$sce",function(e){return function(t){return e.trustAsHtml(t)}}]),app.ui.audit.filter("formatDate",["$sce","$locale",function(e,t){return function(e){if(!e)return e;var n=e.match(/\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\dZ/g);if(!n)return e;for(var i=0;i<n.length;i++){var a=moment(n[i]).toDate();e=e.replace(new RegExp(n[i],"g"),a.toString(t.DATETIME_FORMATS.nxtDateFormat))}return e}}]),e.getPerformerDisplay=function(e){if(e&&e.performer&&e.performer.length)return _.join(_.map(e.performer,function(e){return e.display||"Practitioner/"+e.id}),", ")},e.getUserRolesDisplay=function(e){if(e&&e.userRoles&&e.userRoles.length&&e.userRoles[0])return e.userRoles[0].name},e.getSubjectDisplay=function(e){if(e&&e.subject&&e.subject.length)return _.join(_.map(e.subject,function(e){return e.display||e.reference}),", ")}}]),app.login.directive("nxtAppNotifications",["nxtSecuritySvc","nxtUserContextSvc","$q","$templateCache","Notification","$uibModal","NXT_APP_NOTIFICATION",function(e,t,n,i,a,o,r){"use strict";return{restrict:"E",scope:!1,link:function(s){function l(e){if(_.isNil(e)||""===e)return{isValid:!0,value:null};try{if(moment(e,["MM/DD/YYYY HH:mm"],!0).isValid())return{isValid:!0,value:moment(e).toDate()}}catch(e){return{isValid:!1}}return{isValid:!1}}t.loggedUser&&(s.$watch(function(){return t.getCurrentPageContextProperty("successfulLoginEvent")||t.getCurrentPageContextProperty("SSODashboardContext")},function(o){o&&function(){t.removeCurrentPageContextProperty("successfulLoginEvent");var o,d=[];s.notifications=[],s.passwordExpiredConfig,s.isSSOContext=t.getCurrentPageContextProperty("SSODashboardContext"),s.isSSOContext||(d.push(e.getPasswordExpiry()),d.push(e.getPasswordExpiryReminder()));n.all(d).then(function(e){if(e&&e.length){var n={passwordExpiry:e[0]&&e[0].days,passwordExpiryReminder:e[1]&&e[1].days};$.isNumeric(n.passwordExpiry)&&n.passwordExpiry>0&&$.isNumeric(n.passwordExpiryReminder)&&n.passwordExpiryReminder>0&&t.loggedUser&&(s.passwordExpiredConfig=n)}if(r&&r.length>0){o=(new Date).getTime();for(var d=0;d<r.length;d++){var c={isValid:!0}
8,u={isValid:!0};if(s.appNotificationStyle=r[d].Style,r[d].Period&&(c=l(r[d].Period.Start),u=l(r[d].Period.End)),c.isValid&&u.isValid){var p=!c.value||c.value.getTime()<=o;p&&(p=!u.value||u.value.getTime()>o),p&&s.notifications.push(angular.extend({id:d,isClosed:!1},angular.copy(r[d])))}}}(s.passwordExpiredConfig||s.notifications.length>0)&&function(){var e='<div class="ui-notification custom-template">';if(s.passwordExpiredConfig){var n=t.loggedUser.lastPasswordChangeDate||t.loggedUser.created,o=moment(n).add(s.passwordExpiredConfig.passwordExpiry,"days").toDate(),r=moment(o).subtract(s.passwordExpiredConfig.passwordExpiryReminder,"days").toDate(),l=new Date;l>r&&(s.showPasswordExpiry=!0,e+='<div ng-if="!isClosePasswordExpiry" ng-class="{\'margin-bottom-5\': notifications.length > 0 }" class="password-change"><div class="close close-notification"><span ng-click="closeNotification()"><i class="fa fa-remove"></i></span></div><div class="message"><span translate> Your password will expire <span ng-if="daysLeft>0">in {{daysLeft}} </span> <span ng-if="daysLeft>1" translate>days.</span><span ng-if="daysLeft===1" translate>day.</span></span><span ng-if="daysLeft===0" translate>today.</span> <span ng-if="!isSSOContext" translate> <a href="" ng-click="openPatientProfile()"><u>Click here to change your password.</u></a></span></div></div>'),s.daysLeft=moment(o).diff(moment(l),"days")}s.notifications.length>0&&(e+='<div ng-repeat="it in notifications" ng-show="!it.isClosed" ng-class="{\'margin-bottom-5\': !$last }" class="app-notification"'+(s.appNotificationStyle?'ng-attr-style="background-color: {{it.Style.backgroundColor}} !important"':"")+'> <div class="close close-notification"><span ng-click="closeNotification(it)"><i class="fa fa-remove"></i></span></div><div class="message"'+(s.appNotificationStyle?'ng-attr-style="color: {{it.Style.fontColor}}"':"")+'><span nxt-compile-html="it.Verbiage"></span></div></div>');e+="</div>",i.put("appNotificationTemplate.html",e),s.notifPromise=a.primary({templateUrl:"appNotificationTemplate.html",positionY:"top",positionX:"center",delay:null,closeOnClick:!1,scope:s})}()})}()}),s.$on("$destroy",function(){s.notifPromise&&s.notifPromise.then(function(e){e.kill(!0)})}),s.openPatientProfile=function(){var e=s.$new();e.operation="profile",o.open({templateUrl:"modules/administration/users/userEdit.html",scope:e,backdrop:"static",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",controller:"nxtUserEditCtrl",windowClass:"nxt-big-popup"}).result.then(function(){},function(){}),0===s.notifications.length||0===_.filter(s.notifications,function(e){return!e.isClosed}).length?s.notifPromise.then(function(e){e.kill()}):s.isClosePasswordExpiry=!0},s.closeNotification=function(e){if(e){for(var t=0;t<s.notifications.length;t++)if(s.notifications[t].id===e.id){s.notifications[t].isClosed=!0;break}}else s.isClosePasswordExpiry=!0;!(!s.showPasswordExpiry||s.showPasswordExpiry&&s.isClosePasswordExpiry)||0!==s.notifications.length&&0!==_.filter(s.notifications,function(e){return!e.isClosed}).length||s.notifPromise.then(function(e){e.kill()})})}}}]),app.login.config([function(){"use strict";app.routes.add("/unauthorized","Unauthorized",{templateUrl:"modules/login/unauthorized.html"}),app.routes.add("/missingOrganization","Missing Organization",{templateUrl:"modules/login/missingOrganization.html"}),app.routes.add("/login/:code","Unauthorized",{templateUrl:"modules/login/index.html"}),app.routes.add("/resetCredentials","Having Trouble logging in?",{templateUrl:"modules/login/havingTroubleLoggingIn.html"}),app.routes.add("/2fa","Security Questions",{templateUrl:"modules/login/2fa.html"}),app.routes.add("/securityQuestions","Security Questions",{templateUrl:"modules/login/securityQuestions.html"}),app.routes.add("/loggedOut","Logged Out",{templateUrl:"modules/login/loggedOut.html"}),app.routes.add("/sso","Patient Charts",{templateUrl:"modules/login/sso.html"})}]),app.login.controller("mainLoginCtrl",["gettextCatalog","$scope","nxtUserContextSvc","nxtUserProfileSvc","$location","NXT_APP_BRAND","$document",function(e,t,n,i,a,o,r){"use strict";t.$watch("locale",function(){"/login"===_.toLower(a.path())&&(r[0].title=o.AppTitle+" - "+e.getString("Login"))}),t.logout=function(){i.logout().then(function(){n.logoutCallback()},function(){n.logoutCallback()})}}]),app.login.controller("nxtLoginCtrl",["$rootScope","$scope","nxtUserProfileSvc","nxtUserContextSvc","$location","$uibModal","nxtUserInfoStoreSvc","NXT_APP_BRAND","CONSTANT","NXT_APP_VERSION","$window","$sce","NXT_AWS_COGNITO_DATA","nxtAwsCognitoSvc","NXT_EULA","NXT_USER_PASSWORD_BUTTONS",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h){"use strict";function m(){t.mainForm&&(t.mainForm.$setValidity("wrongCredentials",!0),t.mainForm.$setValidity("passwordExpired",!0),t.mainForm.$setValidity("passwordTemporary",!0),t.mainForm.$setValidity("loginError",!0))}function v(){n.loginWithJwtToken(g.getAccessToken()).then(function(){e.userLoggedIn=!0,"token"===p.ResponseType?a.hash(""):a.search(""),a.path("/")},function(e){t.error="",_.each(e.issue,function(e){t.error+=e.details.display}),t.verifyToken=!1})}if(i.clearSessionCheckInterval(),t.isAwsCognitoFlowEnabled=r.state.isCognitoAuthorizationFlow,t.EULAConfig=f,t.isViewPasswordButtonVisible=h&&h.ViewButtonVisible,t.inputPasswordType="password",t.view=function(e){e.stopPropagation(),t.isOpen=!t.isOpen,t.inputPasswordType=t.isOpen?"text":"password"},t.isAwsCognitoFlowEnabled){var S,C,y,b;
8if(!r.state.loggdeIn)if("token"===p.ResponseType&&(S=_.isEmpty(a.hash()),_.isEmpty(a.hash())||(y=function(e){var t,n,i=e.split("&"),a={};for(t=0;t<i.length;t++)(n=i[t].split("=")).length<2&&n.push(""),-1!==n[0].indexOf("#")?a[decodeURIComponent(n[0].split("#")[1])]=decodeURIComponent(n[1]):a[decodeURIComponent(n[0])]=decodeURIComponent(n[1]);return a}(a.hash().replace(/\+/g," ")))),"code"===p.ResponseType&&(C=_.isEmpty(a.search())||_.isEmpty(a.search().code),y=a.search()),y&&!_.isEmpty(y)&&y.error_description&&-1!==y.error_description.indexOf("Already found an entry for username"))b=p.IdentityProvider&&!_.isEmpty(p.IdentityProvider)?u.trustAsResourceUrl("https://"+p.Domain+".auth."+p.Region+".amazoncognito.com/oauth2/authorize?response_type="+p.ResponseType+"&client_id="+p.ClientId+"&redirect_uri="+p.RedirectUri+"&identity_provider="+p.IdentityProvider):u.trustAsResourceUrl("https://"+p.Domain+".auth."+p.Region+".amazoncognito.com/login?redirect_uri="+p.RedirectUri+"&response_type="+p.ResponseType+"&client_id="+p.ClientId),c.location.href=b;else S||C?c.location.href=u.trustAsResourceUrl("https://"+p.Domain+".auth."+p.Region+".amazoncognito.com/login?redirect_uri="+p.RedirectUri+"&response_type="+p.ResponseType+"&client_id="+p.ClientId):(g.cognitoAuth().then(function(){t.verifyToken=!0,v()},function(e){t.error=e&&e.data&&e.data.error?e.data.error:""}),g.auth().parseCognitoWebResponse(c.location.href));t.back=function(){g.logout()}}else t.idLoginTextFooter=s.Copyright(d,moment().year()),t.buttonsDisabled=!1,t.login={userName:null,password:null,token:null},t.$watch("login.userName",function(){m()}),t.$watch("login.password",function(){m()}),t.$watch("login.token",function(){m()}),t.submit=function(){t.isSecondFactorAuth?t.submitToken():t.login()},t.login=function(){t.buttonsDisabled=!0,n.login(t.login.userName,t.login.password).then(function(){x()},function(e){t.buttonsDisabled=!1,t.loginError="",_.each(e.issue,function(n){switch(n.details.code){case l.ERROR.MSG_AUTH_ACCOUNT_EXPIRED.code:case l.ERROR.MSG_AUTH_GENERIC.code:case l.ERROR.MSG_AUTH_MAX_SESSIONS.code:case l.ERROR.MSG_AUTH_TOO_MANY_ATTEMPTS.code:case l.ERROR.MSG_AUTH_USER_INACTIVE.code:case l.ERROR.MSG_FAILED_TO_SEND_EMAIL.code:case l.ERROR.MSG_AUTH_QUESTIONS_TOO_MANY_ATTEMPTS.code:t.mainForm.$setValidity("loginError",!1);break;case l.ERROR.MSG_AUTH_PASSWORD_EXPIRED.code:t.mainForm.$setValidity("passwordExpired",!1),t.passwordChangeToken=n.location[0].split("/")[0];break;case l.ERROR.MSG_AUTH_PASSWORD_TEMPORARY.code:t.mainForm.$setValidity("passwordTemporary",!1),t.passwordChangeToken=n.location[0].split("/")[0];break;case l.ERROR.MSG_AUTH_EMAIL_REQUIRED.code:case l.ERROR.MSG_TOKEN_SENT_TO_SMS.code:t.secondFactorMessage=e.display,t.verificationCode=n.uniqueId?n.uniqueId+" - ":"",t.isSecondFactorAuth=!0,t.mainForm.resetForm();break;case l.ERROR.MSG_AUTH_REQUIRED.code:t.mainForm.$setValidity("loginError",!1)}t.isSecondFactorAuth||(t.loginError+=n.details.display)})})},t.resendToken=function(){t.login.token=null,t.mainForm.resetForm(),t.login()},t.submitToken=function(){t.buttonsDisabled=!0,n.secondFactorLogin(t.login.token).then(function(){x()},function(e){t.buttonsDisabled=!1,t.loginError=e.display,t.mainForm.$setValidity("loginError",!1)})},t.goToChangePassword=function(){a.path("/changePassword/"+t.passwordChangeToken)},t.forgotUsername=function(){var e=t.$new();o.open({templateUrl:"modules/login/forgotUsername.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",scope:e,controller:"forgotUsernameCtrl",backdrop:"static",windowClass:"nxt-medium-popup"})},t.forgotPassword=function(){var e=t.$new();o.open({templateUrl:"modules/login/forgotPassword.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",scope:e,controller:"forgotPasswordCtrl",backdrop:"static",windowClass:"nxt-medium-popup"})};function x(){if(e.userLoggedIn=!0,t.EULAConfig&&t.EULAConfig.Enabled)if(t.EULAConfig.Updated){var r=new moment.utc(t.EULAConfig.Updated),s=i.loggedUser.agreement?new moment.utc(moment(i.loggedUser.agreement).format("MM/DD/YYYY")):null;if(!s||s.isBefore(r)){var l=t.$new();l.acceptAgreement=!0,o.open({templateUrl:"modules/administration/privacyPolicy/index.html",scope:l,windowTemplateUrl:"directives/control
8s/nxtModalHeader/nxtModalHeader.html",controller:"nxtPrivacyPolicyCtrl",backdrop:"static"}).result.then(function(){a.path("/"),i.setCurrentPageContextProperty("successfulLoginEvent",!0)},function(){t.buttonsDisabled=!1})}else a.path("/"),i.setCurrentPageContextProperty("successfulLoginEvent",!0)}else n.logout().then(function(){i.logoutCallback(),t.buttonsDisabled=!1},function(){i.logoutCallback(),t.buttonsDisabled=!1});else a.path("/"),i.setCurrentPageContextProperty("successfulLoginEvent",!0)}}]),app.login.controller("nxtHavingTroubleLoggingInCtrl",["$scope","$uibModal","$uibModalInstance",function(e,t,n){"use strict";e.forgotUsername=function(){var n=e.$new();t.open({templateUrl:"modules/login/forgotUsername.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",scope:n,controller:"forgotUsernameCtrl",backdrop:"static",windowClass:"nxt-medium-popup"})},e.forgotPassword=function(){var n=e.$new();t.open({templateUrl:"modules/login/forgotPassword.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",scope:n,controller:"forgotPasswordCtrl",backdrop:"static",windowClass:"nxt-medium-popup"})},e.cancel=function(){n.dismiss("cancel")}}]),app.login.controller("forgotUsernameCtrl",["$scope","nxtUserSvc","$uibModalInstance","nxtTemplateViewSvc","NXT_USER_FORGOT_USERNAME",function(e,t,n,i,a){"use strict";e.data={email:null},e.sendUsernameEmail=function(){e.isSaving=!0,t.retrieveUsername(e.data.email).then(function(){n.dismiss("cancel"),e.isSaving=!1;var t={closeButtonText:"Close",headerText:"",isHeaderHidden:!0,bodyText:a.ResponseMessage};i.showModal(t,{windowClass:"nxt-light-popup"})},function(t){e.isSaving=!1})},e.cancel=function(){n.dismiss("cancel")}}]),app.login.controller("forgotPasswordCtrl",["$scope","nxtUserSvc","$uibModalInstance","NXT_USERNAME_PATTERN","nxtTemplateViewSvc","NXT_USER_RESET_PASSWORD",function(e,t,n,i,a,o){"use strict";e.pattern=i.Pattern,e.patternMessage=i.PatternMessage,e.data={username:null},e.sendPasswordEmail=function(){e.isSaving=!0,t.resetPassword(e.data.username).then(function(){n.dismiss("cancel"),e.isSaving=!1;var t={closeButtonText:"Close",headerText:"",isHeaderHidden:!0,bodyText:o.ResponseMessage};a.showModal(t,{windowClass:"nxt-light-popup"})},function(t){e.isSaving=!1})},e.cancel=function(){n.dismiss("cancel")}}]),app.login.controller("unauthorizedCtrl",["gettextCatalog","$scope","$location","NXT_APP_BRAND","nxtUserProfileSvc","nxtUserContextSvc","NXT_SSO_CONFIG","$window","$document",function(e,t,n,i,a,o,r,s,l){"use strict";t.$watch("locale",function(){"/unauthorized"===_.toLower(n.path())&&(l[0].title=i.AppTitle+" - "+e.getString("Unauthorized"))}),t.isSSOContext=app.ui.SSO,t.isSSOContext&&(t.isInvisibleCloseButton=r.UnauthorizedForm&&!r.UnauthorizedForm.isVisibleCloseButton),t.back=function(){if(t.isSSOContext){t.isLoading=!0;try{s.close()}finally{a.logout().then(function(){o.logoutCallback()},function(){o.logoutCallback()})}}else app.ui.forUser.length>0?n.path(app.ui.forUser[0].link.url):n.path("/")}}]),app.login.controller("loggedOutCtrl",["$scope","$location",function(e,t){"use strict";_.isEmpty(t.hash())||t.hash(""),_.isEmpty(t.search())||t.search(""),e.goToLogin=function(){e.isLoading=!0,t.path("/login")}}]),app.login.controller("nxtSSOCtrl",["$scope","$location","NXT_APP_BRAND","nxtUserProfileSvc","nxtUserContextSvc","$document",function(e,t,n,i,a,o){"use strict";var r;e.$watch("locale",function(){"/sso"===_.toLower(t.path())&&(o[0].title=n.AppTitle+" - Patient Charts")}),e.isSSOContext=app.ui.SSO,e.verifyToken=!0,a.clearSessionCheckInterval(),_.isEmpty(t.hash())?t.path("/unauthorized").search({sso:!0}):(r=function(e){var t,n,i=e.split("&"),a={};for(t=0;t<i.length;t++)(n=i[t].split("=")).length<2&&n.push(""),-1!==n[0].indexOf("#")?a[decodeURIComponent(n[0].split("#")[1])]=decodeURIComponent(n[1]):a[decodeURIComponent(n[0])]=decodeURIComponent(n[1]);return a}(t.hash().replace(/\+/g," ")),!_.isEmpty(r)&&r.access_token?i.loginWithJwtToken(r.access_token).then(function(){t.hash(""),t.path("/dashboards").search({sso:!0,token:r.access_token})},function(n){e.verifyToken=!1,t.path("/unauthorized").search({sso:!0})}):t.path("/unauthorized").search({sso:!0}))}]),app.login.controller("nxt2faCtrl",["$scope","$q","$location","nxtUserSvc","nxtUserContextSvc","NXT_PHONE_NUMBER","CONSTANT","nxtUtilsSvc","NXT_API_ENDPOINTS","$uibModal",function(e,t,n,i,a,o,r,s,l,d){"use strict";e.isLoading=!0,e.phoneNumberConfig=o,e.authenticationType=null,e.CONSTANT=r;var c=[];
8a.loggedUser||c.push(i.get(a.loggedUser.id)),t.all(c).then(function(t){e.user=t[0]||a.loggedUser,e.user.secondFactorAuthMethod||(e.user.secondFactorAuthMethod={}),e.data={phone:e.user.phone,phoneNotes:e.user.phoneNotes},"none"!==e.user.secondFactorAuthMethod.code&&(e.authenticationType=e.user.secondFactorAuthMethod.code),e.isLoading=!1},function(){e.isLoading=!1}),e.submit=function(){e.isSaving=!0,e.user.phone=e.data.phone,e.user.phoneNotes=e.data.phoneNotes,e.user.secondFactorAuthMethod.code=e.authenticationType,e.save()},e.save=function(){var t={resourceType:"Bundle",type:"transaction",entry:[],id:s.generateGUID()},o=_.extend(angular.copy(e.user),{resourceType:"User"});t.entry.push({resource:o.toFhir(),request:{method:"PUT",url:"User"},fullUrl:l.UserApiURL+"/"+o.id}),t.entry[t.entry.length-1].resource.id=o.id,i.updateProfile(t).then(function(i){var o=i&&i.issue&&i.issue.length>0?_.find(i.issue,function(e){return e.details&&(e.details.code===r.ERROR.MSG_TOKEN_SENT_TO_SMS.code||e.details.code===r.ERROR.MSG_TOKEN_SENT_TO_EMAIL.code)}):null;if(o){e.isSaving=!1;var s=e.$new();s.secondFactorMessage=i.display,s.verificationCode=o.uniqueId?o.uniqueId+" - ":null,s.bundle=t,d.open({templateUrl:"modules/administration/users/userEditToken.html",scope:s,backdrop:"static",controller:"nxtUserEditTokenCtrl",windowClass:"nxt-token-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){a.updateLoggedUser(e.user),n.path("/"),e.isSaving=!1},function(t){e.isSaving=!1})}else e.isSaving=!1},function(t){if(t&&t.issue&&t.issue.length)for(let n=0;n<t.issue.length;n++)if(t.issue[n]&&t.issue[n].details)switch(t.issue[n].details.code){case r.ERROR.MSG_MISSING_OR_INVALID_PARAMETER.code:e.twoFAErrorMgs=r.ERROR.MSG_MISSING_OR_INVALID_PARAMETER.display;break;case r.ERROR.MSG_MISSING_OR_INVALID_TOKEN.code:e.twoFAErrorMgs=r.ERROR.MSG_MISSING_OR_INVALID_TOKEN.display;break;case r.ERROR.MSG_FAILED_TO_SEND_EMAIL.code:e.twoFAErrorMgs=r.ERROR.MSG_FAILED_TO_SEND_EMAIL.display;break;case r.ERROR.MSG_DATABASE_ERROR.code:e.twoFAErrorMgs=r.ERROR.MSG_DATABASE_ERROR.display;break;case r.ERROR.MSG_COMPROMISED_PASSWORD.code:e.passwordErrorMsgOnSave=t.display;break;default:e.twoFAErrorMgs=t.issue[n].details.display||t.issue[n].details.code}_.isEmpty(e.twoFAErrorMgs)&&(e.twoFAErrorMgs=t&&t.display?t.display:_.isEmpty(t)?"An error has occurred! Please contact your administrator!":t),e.isSaving=!1})}}]),app.login.controller("nxtMissingOrganizationCtrl",["$scope","nxtConfigurationSvc","nxtUserContextSvc","$location",function(e,t,n,i){"use strict";e.isLoading=!0,e.facilities=n.LoggedUserConfiguration.facilities,t.search({owner:"User/"+n.loggedUser.id}).then(function(t){e.configuration=t[0],e.isLoading=!1},function(){e.isLoading=!1}),e.save=function(){e.isSaving=!0,e.configuration.organizationUser=_.find(n.OrganizationUser,function(t){return t.organization.id===e.configuration.organization.id}),t.save(e.configuration).then(function(){n.updateUserConfiguration(e.configuration),app.ui.forUser.length>0?i.path(app.ui.forUser[0].link.url):i.path("/")},function(){e.isSaving=!1})}}]),app.login.controller("nxtSecurityQuestionsCtrl",["$scope","$q","$location","nxtValueSetSvc","nxtUserSvc","nxtUserContextSvc","NXT_USER_SECURITY_QUESTIONS","NXT_PHONE_NUMBER",function(e,t,n,i,a,o,r,s){"use strict";e.isLoading=!0,e.phoneNumberConfig=s,e.securityQuestionsConfig=r;var l=null;r&&r.AnswerMinRequiredLength&&r.AnswerMinRequiredLength>0&&(e.answerMinRequiredLength=r.AnswerMinRequiredLength),r&&r.FilterBy&&(l="customer="+r.FilterBy.toUpperCase()),t.all([a.get(o.loggedUser.id),i.get({valueSetName:"UserSecurityQuestion",limit:50,property:l})]).then(function(t){e.isLoading=!1,e.user=t[0],e.securityQuestionsList=t[1];var n=[];if(e.user.securityQuestions&&e.user.securityQuestions.length>0)for(var i,a=0;a<e.user.securityQuestions.length;a++)e.user.securityQuestions[a]&&(i={},e.user.securityQuestions[a].question&&(e.user.securityQuestions[a].question.code?i.question=e.user.securityQuestions[a].question:e.user.securityQuestions[a].question.display&&(i.otherQuestion=e.user.securityQuestions[a].question.display,i.isOther=!0)),i.answer=e.user.securityQuestions[a].answer,n.push(i));0===n.length?n=[{question:null,answer:null},{question:null,answer:null}]:1===n.length&&n.push({question:null,answer:null}),e.data={securityQuestions:n,phone:e.user.phone,phoneNotes:e.user.phoneNotes}},function(){e.isLoading=!1}),e.submit=function(){if(e.isSaving=!0,e.data.securityQuestions&&e.data.securityQuestions.length>0){var t;e.user.securityQuestions=[];for(var i=0;i<e.data.securityQuestions.length;i++)e.data.securityQuestions[i]&&(t={},e.data.securityQuestions[i].isOther&&e.data.securityQuestions[i].otherQuestion?t.question={display:e.data.securityQuestions[i].otherQuestion}:e.data.securityQuestions[i].question&&e.data.securityQuestions[i].question.code&&(t.question=e.data.securityQuestions[i].question),e.data.securityQuestions[i].answer&&(t.answer=e.data.securityQuestions[i].answer),t.question&&t.answer&&e.user.securityQuestions.push(t))}e.user.phone=e.data.phone,e.user.phoneNotes=e.data.phoneNotes,a.save(e.user).then(function(){o.updateLoggedUser(e.user),n.path("/")},function(){e.isSaving=!1})}}]),function(){"use strict";function e(e){var t=this;t.valueChanged=function(){var n=e.createValue(t.controlId,t.controlValue);
8t.onChanged({control:{control:n}})}}app.ui.reporting.directive("jicCheckbox",function(){return{restrict:"E",scope:{},controller:"CheckboxCtrl",controllerAs:"checkbox",templateUrl:"modules/reporting/directives/jasperInputControls/checkbox/checkbox.html",bindToController:{controlId:"=",controlValue:"=",onChanged:"&",isMandatory:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}).controller("CheckboxCtrl",e),e.$inject=["nxtJasperInputControlsSvc"],Object.defineProperty(e.prototype,"controlValue",{get:function(){return this.$controlValue},set:function(e){this.$controlValue=e}})}(),function(){"use strict";function e(e){var t=this,n={name:"colName",value:"colValue",show:!0,sortable:!0,sortOrder:"asc",groupBy:!1,groupable:!1,no:e.getString("No"),yes:e.getString("Yes")};function i(e){var n=_.chain(e).filter({show:!0}).map("value").value(),i=_.chain(e).filter(function(e){return"none"!==e.sortOrder}).map(function(e){return e.value+"/"+e.sortOrder}).value(),a=_.chain(e).filter({groupBy:!0}).map("value").value(),o={};return o[_.get(t.data,"columns.id")]=n,o[_.get(t.data,"sortBy.id")]=i,o[_.get(t.data,"groupBy.id")]=a,o}function a(e){var i=e&&e.columns&&e.columns.state.options,a=e&&e.sortBy&&e.sortBy.state.options,o=e&&e.groupBy&&e.groupBy.state.options;return t.showSortBy=!_.isEmpty(a),t.showGroupBy=!_.isEmpty(o),t.groupByMandatory=e.groupBy&&e.groupBy.mandatory,_.map(i,function(e){var t,i,r=!!_.find(o,function(t){return t.value===e.value}),s=!!_.find(a,function(t){return _.first(t.value.split("/"))===e.value}),l=(i=e.value,_.chain(a).filter(function(e){return _.first(e.value.split("/"))===i&&e.selected}).map(function(e){return e&&e.value?_.last(e.value.split("/")):"none"}).head().value()||"none"),d=(t=e.value,!_.chain(o).filter(function(e){return e.value===t&&e.selected}).isEmpty().value());return e.selected=!!d||e.selected,_.assign({},n,{name:e.label,value:e.value,sortOrder:l,sortable:s,groupBy:d,groupable:r,show:e.selected,sortByDisabled:d,groupByDisabled:!e.selected,columnDisabled:d})})}t.sortOptions={ASCENDING:"asc",DESCENDING:"desc",NONE:"none"},t.columnNamesDisabled=!1,t.showSortBy=!0,t.showGroupBy=!0,t.groupByMandatory=!0,t.setData=function(e){t.columns=a(e),t.columnNamesDisabled=e.disabled},t.onColumnSelected=function(){var e=i(t.columns);t.onChanged({control:e})},t.onSortChanged=function(e){t.columns=_.map(t.columns,function(t){return t.sortOrder=e.value!==t.value?"none":t.sortOrder,t});var n=i(t.columns);t.onChanged({control:n})},t.onGroupChanged=function(e){t.columns=_.map(t.columns,function(n){return n.groupBy=t.groupByMandatory||!1!==e.groupBy?e.value===n.value:e.value,n});var n=i(t.columns);t.onChanged({control:n})},t.setData(t.data)}app.ui.reporting.directive("jicColumnManagement",function(){return{restrict:"E",controller:"ColumnManagementCtrl",controllerAs:"$ctrl",templateUrl:"modules/reporting/directives/jasperInputControls/columns/columns.html",scope:{},bindToController:{data:"<",onChanged:"&"}}}).controller("ColumnManagementCtrl",e),e.$inject=["gettextCatalog"],Object.defineProperty(e.prototype,"data",{get:function(){return this.$data},set:function(e){this.$data!==e&&(this.$data=e,angular.isFunction(this.setData)&&this.setData(e))}})}(),app.ui.reporting.directive("jicCondition",function(){"use strict";return{restrict:"E",controller:"ConditionCtrl",controllerAs:"$ctrl",templateUrl:"modules/reporting/directives/jasperInputControls/condition/condition.html",scope:{},bindToController:{data:"<",controlType:"<",inputControl:"<",onChanged:"&"}}}).controller("ConditionCtrl",["nxtUtilsSvc","CONSTANT","gettextCatalog",function(e,t,n){"use strict";var i=this,a=t.JASPER.INPUT_CONTROLS.TYPES,o={Numeric:[{name:n.getString("Equals"),value:"eq"},{name:n.getString("Does not equal"),value:"notEq"},{name:n.getString("Greater than"),value:"gt"},{name:n.getString("Greater than or equal to"),value:"gte"},{name:n.getString("Less than"),value:"lt"},{name:n.getString("Less than or equal to"),value:"lte"},{name:n.getString("Is between"),value:"btwn"},{name:n.getString("Is not between "),value:"notBtwn"}],Date:[{name:n.getString("Equals"),value:"eq"},{name:n.getString("Is not equal to"),value:"notEq"},{name:n.getString("Is between"),value:"btwn"},{name:n.getString("Is not between"),value:"notBtwn"},{name:n.getString("Is on or before"),value:"onBef"},{name:n.getString("Is before"),value:"bef"},{name:n.getString("Is on or after"),value:"onAft"},{name:n.getString("Is after"),value:"aft"}],Text:[{name:n.getString("Equals"),value:"eq"},{name:n.getString("Is not equal to"),value:"notEq"},{name:n.getString("Contains"),value:"contains"},{name:n.getString("Does not contain"),value:"notContains"},{name:n.getString("Starts with"),value:"startsWith"},{name:n.getString("Does not start with"),value:"notStartsWith"},{name:n.getString("Ends with"),value:"end"},{name:n.getString("Does not end with"),value:"notEnd"}],Default:[{name:"Equals",value:"eq"}]};function r(e){!function(e){var t=e.viewType;t===a.SINGLE_VALUE_NUMBER||angular.isNumber(t)?(i.isNumeric=!0,i.conditionsVm=o.Numeric,i.condition=_.find(i.conditionsVm,{value:"eq"}),i.isDisabled=!1,i.onConditionSelected()):(i.conditionsVm=o.Default,i.condition=_.find(i.conditionsVm,{value:"eq"}),i.isDisabled=!0)}(e)}i.isDisabled=!1,i.onConditionSelected=function(){i.onChanged({condition:{id:i.inputControl.id,condition:i.condition.value}})},i.$onChanges=function(t){e.isValueChanged(t.inputControl)&&r(t.inputControl.currentValue)}}]),app.ui.reporting.directive("jasperInputControls",function(){"use strict";return{restrict:"E",scope:{},controller:"JasperInputControlsCtrl",controllerAs:"$ctrl",templateUrl:"modules/reporting/directives/jasperInputControls/inputControls.html",bindToController:{report
8Uri:"<",inputControlsDefaults:"<",showActionBtn:"<",parameterValues:"<",saveControlsState:"<",controlsRefresh:"<",onControlsChanged:"&",onControlsLoaded:"&",onGenerateReport:"&",isValid:"&",computedPeriod:"<",options:"<",configurations:"<",onSaveConfiguration:"&"},transclude:{additionalInfo:"?div"}}}).controller("JasperInputControlsCtrl",["CONSTANT","nxtJasperInputControlsSvc","nxtJasperInputControlsDataSvc","nxtUserContextSvc","$q","$timeout","nxtUtilsSvc","$transclude",function(e,t,n,i,a,o,r,s){"use strict";var l,d,c=this,u=[];c.inputControls=[],c.columns={},c.inputControlsForState=[],c.controlValues={},c.InputControlsSvc=t,c.controlTypes=e.JASPER.INPUT_CONTROLS.TYPES,c.loaded=!1,c.defaultOptions={mode:"withInfo",hideDate:!1,showColumnManagement:!1,showParameters:!0,showConfigurations:!1,showActionPanel:!0,showActions:!0,hideParametersLegend:!1},c.settings={},c.showColumnManagement=!1,c.showParameters=!0,c.showConfigurations=!1,c.showActionPanel=!1;var p={columnManagement:["col-xs-5","col-xs-offset-1-5"],configurations:["col-xs-4","col-xs-offset-1-5"],configurationsAndColumns:["col-xs-4","col-xs-offset-1-5"],inputControls:["col-xs-7"],inputControl:["col-xs-6"],clearfixCount:2},g={columnManagement:["col-xs-5","col-xs-offset-4"],configurations:["col-xs-4","col-xs-offset-4"],configurationsAndColumns:["col-xs-4"],inputControls:["col-xs-12"],clearfixCount:3};function f(){c.inputControls=[],c.controlValues=[],c.columns=null,c.resetControlsForm()}function h(e){var n,i,a=[],o={},r={};if(e.data){if(u=t.mapToVm(e.data.inputControl),i=t.hasCustomDefaults(u),_.isEmpty(c.parameterValues))_.isEmpty(i)?r.inputControls=u:(n=t.createCustomDefaults(i),c.controlValues=t.mapToValues(u),t.haveSlaveDependencies(n)?_.each(n,function(e){var n=_.find(u,{id:e.id}),i=t.hasSlaveDependencies(n);o[e.id]=t.getValueFromComplexType(t.getValueByType(e)),i&&_.each(n.slaveDependencies,function(e){a.push(e),o[e]=c.controlValues[e]}),r.controlsToUpdate=a,r.valuesToUpdate=o}):r.inputControls=_.chain(u).keyBy("id").extend(_.keyBy(n,"id")).values().value(),u=_.chain(u).keyBy("id").extend(_.keyBy(n,"id")).values().value());else{var s=t.createParameterValues(c.parameterValues,u);r.inputControls=_.chain(u).keyBy("id").extend(_.keyBy(s,"id")).values().value()}return r}}function m(e){var i,a,o,r={};if(e){if(!e.inputControls)return n.setInputControlsValues(e.controlsToUpdate,e.valuesToUpdate,c.reportUri).then(function(n){c.inputControls=t.updateControls(u,e.data.inputControlState),c.controlValues=t.mapToValues(c.inputControls),c.loaded=!0,c.inputControlsForState=angular.copy(c.inputControls)});c.loaded=!0,c.inputControls=e.inputControls,i=_.find(c.inputControls,{viewType:"columns"}),a=_.find(c.inputControls,{viewType:"sortBy"}),o=_.find(c.inputControls,{viewType:"groupBy"}),i&&(_.forEach(_.compact([i,a,o]),function(e){r[e.viewType]=e}),r.disabled=i.description.disabled,c.columns=r),c.controlValues=t.mapToValues(c.inputControls),c.inputControlsForState=angular.copy(c.inputControls)}}function v(e){var t,n,i,a=(t=e,n=moment(),i={daily:function(){return n.subtract(1,"days").toDate()},today:function(){return n.toDate()},yesterday:function(){return n.subtract(1,"days").toDate()},weekly:function(){return n.subtract(1,"weeks").toDate()},monthly:function(){return n.subtract(1,"months").toDate()},biMonthly:function(){return n.subtract(2,"months").toDate()},quarterly:function(){return n.subtract(3,"months").toDate()},secondTrimester:function(){return n.subtract(4,"months").toDate()},semesterly:function(){return n.subtract(6,"months").toDate()},yearly:function(){return n.subtract(1,"years").toDate()},custom:function(){return null}},angular.isFunction(i[t])?angular.noop():i[t]()),o=function(e){var t=moment(),n={yesterday:function(){return t.subtract(1,"days").toDate()},custom:function(){return null}};return angular.isFunction(n[e])?t.toDate():n[e]()}(e);c.range={startDate:a,endDate:o}}function S(e){c.settings=_.assign({},c.defaultOptions,e),"withInfo"===c.settings.mode&&(c.styleClasses=p,c.settings.showActions=!1,c.settings.showColumnManagement=!1),"withTemplates"===c.settings.mode&&(c.styleClasses=g,c.settings.showActions=!1,c.settings.showColumnManagement=!1,c.settings.showConfigurations=!0),"full"===c.settings.mode&&(c.styleClasses=g,c.settings.showActions=!1,c.settings.showColumnManagement=!0)}c.onConditionChanged=function(t){var n=c.controlValues[t.id][0].split("/");_.find(c.inputControls,{id:t.id}).condition=t.condition,n.pop(),c.controlValues[t.id]=[_.isEmpty(n)||n===e.JASPER.INPUT_CONTROLS.DEFAULTS.VALUE?"":n.concat(t.condition).join("/")],c.onControlsChanged({controls:c.controlValues})},c.getInputControls=function(){return c.onControlsLoaded({loaded:!1}),f(),c.loaded=!1,c.getSavedPageState().then(function(e){return l&&l.resolve(),l=a.defer(),c.onControlsLoaded({loaded:!1}),n.getInputControls(e,l.promise)}).then(h).then(m).catch(c.clearSavedState).finally(function(){c.onControlsLoaded({loaded:!0})})},c.onInputControlChanged=function(e){var i,a=_.find(u,{id:e.control.id}),r=t.hasSlaveDependencies(a),s="search"===a.viewType&&!_.isEmpty(e.slaveDependencies),l=a.customConfig&&!_.isEmpty(e.slaveDependencies),p={},g=[];if(c.computedPeriod&&_.includes(a.uiSlaveDependencies,"startDate")&&_.includes(a.uiSlaveDependencies,"endDate")&&v(e.control.value),r)return p[e.control.id]=_.isArray(e.control.value)?e.control.value:[e.control.value],_.each(a.slaveDependencies,function(e){g.push(e),p[e]=c.controlValues[e]}),i=t.updateControls(c.inputControls,[e.control]),n.setInputControlsValues(g,p,c.reportUri).then(function(n){c.inputControls=t.updateControls(i,e.data.inputControlState),c.controlValues=t.addOrUpdateValues(c.controlValues,e.control),c.onControlsChanged({controls:c.controlValues})});s&&(e.control&&e.control.stopClear||t.clearDependentFields(c.inputControls,e.slaveDependencies),e.control.value||e.control.selected?t.updateSlaveDependenciesParams(c.inputControls,e.slaveDependencies,e.control.selected,e.control.id):(t.setValueByType(_.find(c.inputControls,{id:e.control.id}),""),t.updateSlaveDependenciesParams(c.inputControls,e.slaveDependencies,e.control.selected,e.control.id),t.disableDependentControls(c.inputControls,e.slaveDependencies))),l&&t.updateCustomSlaveDependencies(c.inputControls,e.slaveDependencies,e.control.value,e.control.id),c.controlValues=t.addOrUpdateValues(c.controlValues,e.control),c.onControlsChanged({controls:c.controlValues}),e.control.type=a.type,c.inputControlsForState=t.updateControls(c.inputControlsForState,[e.control]),d=o(function(){c.inputControlsForm&&c.isValid({isValid:c.inputControlsForm.$valid})},200)},c.onColumnsChanged=function(e){var n=_.find(c.inputControls,{viewT
8ype:"columns"}),i=_.find(c.inputControls,{viewType:"sortBy"}),a=_.find(c.inputControls,{viewType:"groupBy"}),o={};_.forEach(_.compact([n,i,a]),function(n){o[n.viewType]=t.setValueByType(n,e[n.id])}),o.disabled=n.description.disabled,c.columns=o,c.controlValues=_.assign(c.controlValues,e),c.onControlsChanged({controls:c.controlValues})},c.generateReport=function(){c.onGenerateReport()},c.resetControlsForm=function(){c.inputControlsForm&&c.inputControlsForm.resetForm()},c.getSavedPageState=function(){var e=i.getCurrentPageContextProperty("inputControls"),t=i.getCurrentPageContextProperty("initialInputControls"),n=i.getCurrentPageContextProperty("controlValues"),o=i.getCurrentPageContextProperty("controlColumns");return c.showActionBtn&&e&&t&&n?(c.inputControls=e||[],c.inputControlsForState=angular.copy(c.inputControls),c.controlValues=n||[],c.columns=o||null,u=t||[],c.loaded=!0,a.reject()):a.when(c.reportUri)},c.clearSavedState=function(){i.removeCurrentPageContextProperty("inputControls"),i.removeCurrentPageContextProperty("initialInputControls"),i.removeCurrentPageContextProperty("controlValues"),i.removeCurrentPageContextProperty("controlColumns")},c.$onChanges=function(e){var n,i,a,o=r.isValueChanged(e.options);e.reportUri&&(e.reportUri.currentValue?c.getInputControls():f()),!e.reportUri&&e.controlsRefresh&&e.controlsRefresh.currentValue&&c.getInputControls(),e.parameterValues&&!_.isEmpty(c.inputControls)&&(n=e.parameterValues.currentValue,i=t.createParameterValues(n,u),(a={}).inputControls=_.chain(u).keyBy("id").extend(_.keyBy(i,"id")).values().value(),m(a)),o&&S(e.options.currentValue)},c.$onInit=function(){c.saveControlsState=c.saveControlsState||!1,c.showActionBtn=!!_.isNil(c.showActionBtn)||c.showActionBtn,c.hasTranclusion=s.isSlotFilled("additionalInfo"),c.computedPeriod=!!_.isNil(c.computedPeriod)||c.computedPeriod,S(c.options)},c.$onDestroy=function(){c.saveControlsState&&(i.setCurrentPageContextProperty("inputControls",c.inputControlsForState),i.setCurrentPageContextProperty("initialInputControls",u),i.setCurrentPageContextProperty("controlValues",c.controlValues),i.setCurrentPageContextProperty("controlColumns",c.columns)),l&&l.resolve(),o.cancel(d)}}]),app.ui.reporting.directive("jicMultiSelect",multiSelect).controller("MultiSelectCtrl",MultiSelectController),MultiSelectController.$inject=["nxtJasperInputControlsSvc","$rootScope"],Object.defineProperty(MultiSelectController.prototype,"controlValue",{get:function(){"use strict";return this.$controlValue},set:function(e){"use strict";_.each(e,function(e){e.display=e.label}),this.$controlValue=e,angular.isFunction(this.setState)&&this.setState()}}),function(){"use strict";function e(e,t,n,i){var a=this;a.$onInit=function(){function o(i,o){var r,s,l,d={},c=a.customSlave;return i===n.JASPER.INPUT_CONTROLS.DEFAULTS.VALUE||i===n.JASPER.INPUT_CONTROLS.DEFAULTS.OPTION_VALUE||_.includes(i,"undefined")||!i||_.isObject(i)&&_.has(i,"value")&&!i.value?l=n.JASPER.INPUT_CONTROLS.DEFAULTS.VALUE:_.isObject(i)?l=a.valueMember?i[a.valueMember]:angular.isFunction(i.toFhirReference)?i.toFhirReference().reference:"":(r=t.get(a.searchConfig.service.name),a.searchConfig.params.valueSetName?r.searchSpecificConcept(i,a.searchConfig.params.valueSetName).then(function(e){o?a.selectedViewValue=_.head(e):a.selectedValue=_.head(e)}):(s=_.last(i.split("/")),r.get(s).then(function(e){o?a.selectedViewValue=e:a.selectedValue=e}))),_.isEmpty(c)||(d.slaveDependencies=a.customSlave),d.control=e.createValue(a.controlId,l),d.control.selected=i,d}a.selectedValue=a.selectedValue||null,a.limit=100,a.displayName=a.displayName||"display",a.createSearch=function(){var e,n,o,r=a.searchConfig.service&&a.searchConfig.service.name&&a.searchConfig.service.method;a.valueMember=a.searchConfig.valueMember,a.searchConfig.params.limit=a.limit,a.displayName=a.searchConfig.displayName||a.displayName,a.searchMethod=r?(e=a.searchConfig.service.name,n=a.searchConfig.service.method,t.get(e)[n]):angular.noop,a.searchParams=(o=a.searchConfig.params,Object.prototype.hasOwnProperty.call(o,"partOfId")&&"configuration"===o.partOfId&&(o.partOfId=i.FacilityId),o)},a.setInputControlValue=function(e){var t=o(e,!1);t.control.stopClear=!0,a.onChanged({control:t})}
8,a.setInputControlValueFromView=function(e){var t=o(e,!0);a.onChanged({control:t})},a.updateSearchParams=function(e){var t,n,i;a.searchParams=(t=a.searchParams,n=e,i=_.reduce(n,function(e,t){return e[t.name]=t.value,e},{}),_.assign(a.searchParams,t,i))}},a.$onInit(),a.$onChanges=function(){a.createSearch(),a.cascadingSearchParams&&a.updateSearchParams(a.cascadingSearchParams),a.selectedValue&&a.setInputControlValue(a.selectedValue)}}app.ui.reporting.directive("jicSearch",function(){return{restrict:"E",scope:{},controller:"ReportSearchCtrl",controllerAs:"search",templateUrl:"modules/reporting/directives/jasperInputControls/search/search.html",bindToController:{onChanged:"&",controlId:"=",controlValue:"=",searchConfig:"=",cascadingSearchParams:"=",isMandatory:"=",selectedValue:"=",customSlave:"=",customMaster:"=",isDisabled:"=",isTree:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}).controller("ReportSearchCtrl",e),e.$inject=["nxtJasperInputControlsSvc","$injector","CONSTANT","nxtUserContextSvc"],Object.defineProperty(e.prototype,"selectedViewValue",{get:function(){return this.$selected},set:function(e){angular.equals(this.$selected,e)||(this.$selected=e,angular.isFunction(this.setInputControlValue)&&this.setInputControlValueFromView(e))}}),Object.defineProperty(e.prototype,"selectedValue",{get:function(){return this.$selected},set:function(e){angular.equals(this.$selected,e)||(this.$selected=e,angular.isFunction(this.setInputControlValue)&&this.setInputControlValue(e))}}),Object.defineProperty(e.prototype,"cascadingSearchParams",{get:function(){return this.$cascadingSearchParams},set:function(e){this.$cascadingSearchParams=e,angular.isFunction(this.updateSearchParams)&&this.updateSearchParams(e)}}),Object.defineProperty(e.prototype,"controlValue",{get:function(){return this.$controlValue},set:function(e){this.$controlValue=e}})}(),function(){"use strict";function e(e){var t=this;t.$onInit=function(){t.setState=function(){t.options=t.controlValue,t.selectedOption=_.find(t.options,{selected:!0}),t.selectedOption&&t.selectOption(t.selectedOption)},t.selectOption=function(n){var i={},a=t.customSlave;i.control=e.createValue(t.controlId,n.value),_.isEmpty(a)||(i.slaveDependencies=t.customSlave),t.onChanged({control:i})},t.setState()}}app.ui.reporting.directive("jicSingleSelect",function(){return{restrict:"E",scope:{},controller:"SingleSelectCtrl",controllerAs:"singleSelect",templateUrl:"modules/reporting/directives/jasperInputControls/singleSelect/singleSelect.html",bindToController:{controlId:"=",controlValue:"=",onChanged:"&",isMandatory:"=",isDisabled:"=",customSlave:"=",customConfig:"=",customMaster:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}).controller("SingleSelectCtrl",e),e.$inject=["nxtJasperInputControlsSvc"],Object.defineProperty(e.prototype,"controlValue",{configurable:!0,get:function(){return this.$controlValue},set:function(e){this.$controlValue=e,angular.isFunction(this.setState)&&this.setState()}})}(),function(){"use strict";function e(t,n){var i,a=this;a.$onInit=function(){a.dateChanged=function(e){var o,r=a.customSlave,s={};!e||_.isDate(e)||e===n.JASPER.INPUT_CONTROLS.DEFAULTS.VALUE?(o=t.toLocalDate(e,i),s.control=t.createValue(a.controlId,o),_.isEmpty(r)||(s.slaveDependencies=a.customSlave),a.onChanged({control:s})):a.selectedDate=moment(e).toDate()},i=-1!==a.controlId.toLowerCase().indexOf("end")?"end":"start",a.controlValue===n.JASPER.INPUT_CONTROLS.DEFAULTS.VALUE?delete a.selectedDate:a.selectedDate=a.controlValue},Object.defineProperty(e.prototype,"selectedDate",{configurable:!0,get:function(){return a.$selectedDate},set:function(e){e!==a.$selectedDate&&angular.isFunction(a.dateChanged)&&(a.$selectedDate=e,a.dateChanged(e))}}),Object.defineProperty(e.prototype,"controlValue",{configurable:!0,get:function(){return a.$controlValue},set:function(e){a.$controlValue=e}})}app.ui.reporting.directive("jicSingleValueDate",function(){return{restrict:"E",scope:{},controller:"SingleValueDateCtrl",controllerAs:"singleValueDate",templateUrl:"modules/reporting/directives/jasperInputControls/singleValueDate/singleValueDate.html",bindToController:{controlId:"=",controlValue:"=",selectedDate:"=",onChanged:"&",isMandatory:"=",isDisabled:"=",customSlave:"=",customConfig:"=",customMaster:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}).controller("SingleValueDateCtrl",e),e.$inject=["nxtJasperInputControlsSvc","CONSTANT"]}
8(),function(){"use strict";function e(e){var t=this;t.dateChanged=function(n){var i,a={},o=t.customSlave;_.isDate(n)?(i=e.dateWithHoursToISO(n),a.control=e.createValue(t.controlId,i),_.isEmpty(o)||(a.slaveDependencies=t.customSlave),t.onChanged({control:a})):t.selectedDate=new Date(n)},t.selectedDate=t.controlValue}app.ui.reporting.directive("jicSingleValueDateTime",function(){return{restrict:"E",scope:{},controller:"SingleValueDateTimeCtrl",controllerAs:"singleValueDateTime",templateUrl:"modules/reporting/directives/jasperInputControls/singleValueDateTime/singleValueDateTime.html",bindToController:{controlId:"=",controlValue:"=",selectedDate:"=",onChanged:"&",isMandatory:"=",isDisabled:"=",customSlave:"=",customConfig:"=",customMaster:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}).controller("SingleValueDateTimeCtrl",e),e.$inject=["nxtJasperInputControlsSvc"],Object.defineProperty(e.prototype,"selectedDate",{get:function(){return this.$selectedDate},set:function(e){e&&e!==this.$selectedDate&&angular.isFunction(this.dateChanged)&&(this.$selectedDate=e,this.dateChanged(e))}}),Object.defineProperty(e.prototype,"controlValue",{get:function(){return this.$controlValue},set:function(e){this.$controlValue=e}})}(),function(){"use strict";function e(e,t){var n=this;n.showRange=!1,n.from="",n.to="",n.valueChanged=function(){var t={},i=n.customSlave;n.contolValue=n.controlValue=n.showRange?n.from+"/"+n.to:n.from,t.control=e.createValue(n.controlId,n.controlValue),_.isEmpty(i)||(t.slaveDependencies=n.customSlave),n.onChanged({control:t})},n.setCondition=function(e){n.showRange="btwn"===e||"notBtwn"===e,n.to=n.showRange&&n.to||"",n.controlValue=n.showRange?n.from+"/"+n.to:n.from},n.setControlValue=function(e){var i,a;n.$controlValue!==e&&(i=(i=_.isArray(e)?e[0]:e)===t.JASPER.INPUT_CONTROLS.DEFAULTS.VALUE?"":i,n.$controlValue=i,a=e.split("/"),n.from=a[0],n.to=a[1])},n.setControlValue(n.controlValue)}app.ui.reporting.directive("jicSingleValueNumber",function(){return{restrict:"E",scope:{},controller:"SingleValueNumberCtrl",controllerAs:"singleValueNumber",templateUrl:"modules/reporting/directives/jasperInputControls/singleValueNumber/singleValueNumber.html",bindToController:{controlId:"=",controlValue:"=",onChanged:"&",isMandatory:"=",isDisabled:"=",customSlave:"=",customConfig:"=",customMaster:"=",condition:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}).controller("SingleValueNumberCtrl",e),e.$inject=["nxtJasperInputControlsSvc","CONSTANT"],Object.defineProperty(e.prototype,"controlValue",{get:function(){return this.$controlValue},set:function(e){angular.isFunction(this.setControlValue)&&this.setControlValue(e)}}),Object.defineProperty(e.prototype,"condition",{get:function(){return this.$condition},set:function(e){this.$condition!==e&&(this.$condition=e,angular.isFunction(this.setCondition)&&this.setCondition(e))}})}(),function(){"use strict";function e(e){var t=this;t.dateChanged=function(n){var i,a={},o=t.customSlave;_.isDate(n)?(i=e.dateToISO(n),a.control=e.createValue(t.controlId,i),_.isEmpty(o)||(a.slaveDependencies=t.customSlave),t.onChanged({control:a})):t.selectedDate=new Date(n)},t.selectedDate=t.controlValue}app.ui.reporting.directive("jicSingleValueTime",function(){return{restrict:"E",scope:{},controller:"SingleValueTimeCtrl",controllerAs:"singleValueTime",templateUrl:"modules/reporting/directives/jasperInputControls/singleValueTime/singleValueTime.html",bindToController:{controlId:"=",controlValue:"=",selectedDate:"=",onChanged:"&",isMandatory:"=",isDisabled:"=",customSlave:"=",customConfig:"=",customMaster:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}).controller("SingleValueTimeCtrl",e),e.$inject=["nxtJasperInputControlsSvc"],Object.defineProperty(e.prototype,"selectedDate",{get:function(){return this.$selectedDate},set:function(e){e&&e!==this.$selectedDate&&angular.isFunction(this.dateChanged)&&(this.$selectedDate=e,this.dateChanged(e))}}),Object.defineProperty(e.prototype,"controlValue",{get:function(){return this.$controlValue},set:function(e){this.$controlValue=e}})}(),function(){"use strict";function e(e,t){var n=this;n.valueChanged=function(){var t={},i=n.customSlave;t.control=e.createValue(n.controlId,n.controlValue),_.isEmpty(i)||(t.slaveDependencies=n.customSlave),n.onChanged({control:t})},n.onControlValueSet=function(e){(e=e||n.controlValue)===t.JASPER.INPUT_CONTROLS.DEFAULTS.VALUE&&(n.controlValue="")},n.onControlValueSet()}app.ui.reporting.directive("jicStringValue",function(){return{restrict:"E",scope:{},controller:"StringValueCtrl",controllerAs:"stringValue",templateUrl:"modules/reporting/directives/jasperInputControls/stringValue/stringValue.html",bindToController:{controlId:"=",controlValue:"=",onChanged:"&",isMandatory:"=",isDisabled:"=",customSlave:"=",customConfig:"=",customMaster:"="},require:"^^jasperInputControls",link:function(e,t,n,i){e.ipForm=i.inputControlsForm}}}
8).controller("StringValueCtrl",e),e.$inject=["nxtJasperInputControlsSvc","CONSTANT"],Object.defineProperty(e.prototype,"controlValue",{get:function(){return this.$controlValue},set:function(e){this.$controlValue!==e&&(this.$controlValue=e,angular.isDefined(this.onControlValueSet)&&this.onControlValueSet(e))}})}(),app.ui.reporting.config(["gettext",function(e){"use strict";app.ui.reporting.link={url:"/reporting",name:e("Reporting"),code:"reporting"}}]),app.ui.reporting.controller("reportingCtrl",["$scope","nxtUserContextSvc","$timeout",function(e,t,n){"use strict";var i,a=t.getCurrentPageContextProperty("reportingReportTabs");e.reportTabs=a||[],e.getSelected=function(t){return _.find(e.reportTabs,{id:t})},e.onTabSelected=function(t){e.reportTabs=_.map(e.reportTabs,function(e){return e.selected=e.id===t,e})},e.onTabClose=function(t){e.reportTabs=_.reject(e.reportTabs,{id:t})},e.$on("onAddTab",function(t,n){e.reportTabs=_.unionBy([n],e.reportTabs,"id")}),e.$on("onSelectedTab",function(e,t){i=n(function(){var e=nxtModuleTabs.reportingTabs,n=t?_.find(e.tabs,{tabId:t.tabId}):e[0];e.selectTab(n)},100)}),t.setCurrentPageContextProperty("currentModule","reporting"),e.$on("$destroy",function(){t.setCurrentPageContextProperty("reportingReportTabs",e.reportTabs),t.removeCurrentPageContextProperty("currentModule"),n.cancel(i)})}]),app.ui.reporting.controller("ReportCtrl",["$scope","nxtJasperInputControlsSvc","nxtJasperReportsDataSvc","$window","nxtUtilsSvc","CONSTANT",function(e,t,n,i,a,o){"use strict";function r(t){return e.totalPages=t.data.totalPages,e.requestId=t.data.requestId,n.getReportOutput(t.data.requestId,t.data.exports[0].id)}function s(t){e.reportHtml=t.data}function l(){d(),e.isLoading=!1}function d(){e.isDisabled=!e.isDisabled}e.isDisabled=!1,e.reportHtml="",e.controlsLoaded=!1,e.isLoading=!1,e.getReport=function(i){var a=!_.isEmpty(e.controlValues);if((i=angular.extend({},i)).outputFormat="html",i.reportUnitUri=e.report.uri,i.freshData=!0,i.parameters={reportParameter:t.mapValuesToReportParams(e.controlValues)},d(),e.isLoading=!0,e.page=1,a)return n.getReport(i).then(r).then(s).finally(l);n.getReport(i).then(r).then(s).finally(l)},e.onPaginationChanged=function(t){var i={outputFormat:"html",pages:t};e.page=t,d(),e.isLoading=!0,n.getReportExport(e.requestId,i).then(function(t){return n.getReportOutput(e.requestId,t.exportId)}).then(s).finally(l)},e.clearReport=function(){e.reportHtml="",e.isLoading=!0},e.exportExecute=function(t){var a={outputFormat:t};n.getReportExport(e.requestId,a).then(function(t){return n.getReportOutput(e.requestId,t.exportId,!0).then(function(t){var n,a,r,s=new Blob([t.data],{type:t.headers("content-type")}),l=(n=e.report.label,a=t.headers("content-type"),n&&a?(r=_.last(a.split("/")),[n,o.JASPER.EXPORT.CONTENT_TYPE_EXTENSION[r]].join(".")):"");i.saveAs(s,l)})})},e.$watchCollection("[controlValues, report]",function(t){t&&(e.clearReport(),e.getReport(t[0]))})}]).directive("reportGenerate",function(){"use strict";return{controller:"ReportCtrl",templateUrl:"modules/reporting/report/report.html",scope:{report:"=",controlValues:"="}}}),app.ui.reporting.controller("ReportExportCtrl",["$scope","CONSTANT",function(e,t){"use strict";e.exportControls=[{name:"PDF",format:t.JASPER.EXPORT.TYPES.pdf},{name:"Excel(xls)",format:t.JASPER.EXPORT.TYPES.xls},{name:"Excel(xlsx)",format:t.JASPER.EXPORT.TYPES.xlsx},{name:"Word(docx)",format:t.JASPER.EXPORT.TYPES.docx},{name:"CSV",format:t.JASPER.EXPORT.TYPES.csv}],e.generate=function(t){e.onExportExecute({format:t})}}]).directive("reportExport",function(){"use strict";return{restrict:"E",controller:"ReportExportCtrl",templateUrl:"modules/reporting/reports/export/export.html",scope:{onExportExecute:"&"}}}),app.ui.reporting.controller("nxtReportsTableCtrl",["$scope","nxtUserContextSvc","$timeout","nxtInfiniteScrollSvc",function(e,t,n,i){"use strict";var a={},o={};a.nxtJasperReportsDataSvc={methodName:"getAllReports"},e.infiniteScroll=i.create({services:a,infiniteScrollEventName:"reportTblEvent"+e.$id});var r=t.getCurrentPageContextProperty("reportingReportTabs");function s(t){t||(e.reportsList=[]),o.nxtJasperReportsDataSvc={},e.infiniteScroll.isBusy(!t,o)||e.infiniteScroll.nextPage(!t).then(function(n){e.reportsList||(e.reportsList=[]),e.reportsList=t?e.reportsList.concat(n):n,t||(e.operation=e.reportsList&&e.reportsList.length>0?"view":null,e.changeSelection(e.reportsList&&e.reportsList.length>0?e.reportsList[0]:null))})}e.operation="view",function(){if(!e.currentPageContextChecked){var n=t.getCurrentPageContextProperty(e.currentModule);n&&n.selectedReport&&(e.selectedReport=n.selectedReport),n&&n.inputControls&&(e.inputControls=n.inputControls),n&&n.reportsList&&(e.reportsList=n.reportsList)}}(),s(),e.$watchCollection("[selectedReport, inputControls, reportsList]",function(n,i){var a,o;a=e.currentModule,o={selectedReport:e.selectedReport,inputControls:e.inputControls,reportsList:e.reportsList},t.setCurrentPageContextProperty(a,o)}),e.getMoreData=function(){s(!0)},e.onInputControlsChanged=function(t){e.controlValues=t.controls},e.isInputControlsValid=function(t){e.inputControlsFormValid=t},e.getReport=function(){if(e.inputControlsFormValid){e.loading=!0,e.reportTabs||(e.reportTabs=[]);var t={tabId:e.selectedReport.uri,id:e.selectedReport.uri,title:e.selectedReport.label,selected:!0,visible:!0,data:{report:_.cloneDeep(e.selectedReport),controlValues:_.cloneDeep(e.controlValues)}};e.$emit("onAddTab",t),e.$emit("onSelectedTab",{tabId:e.selectedReport.uri}),e.loading=!1}},e.reportTabs=r||[],t.setCurrentPageContextProperty("currentModule","reporting"),e.$on("$destroy",function(){t.removeCurrentPageContextProperty("currentModule"),n.cancel(void 0)})}]),app.ui.clinicianDashboard.controller("nxtLandingPageCtrl",["$scope","$rootScope","nxtUtilsSvc","nxtUserContextSvc","$q","nxtConfigurationSvc",function(e,t,n,i,a,o){"use strict";var r=angular.copy(n.doctorDashboardWidgets),s=t.$on("onUserConfigurationChanged",function(e,t){var n=d(i.LoggedUserConfiguration.doctorDashboardConfig),a=d(t.doctorDashboardConfig),o=i.LoggedUserConfiguration.doctorDashboardConfig&&i.LoggedUserConfiguration.doctorDashboardConfig.length,r=t.doctorDashboardConfig&&t.doctorDashboardConfig.length;n===a&&o===r||l(i.LoggedUserConfiguration.doctorDashboardConfig)});function l(t){if(t){for(var n=[],i=0;i<t.length;i++)for(var a=0;a<t[i].length;a++){var o=_.find(r,function(e){return e.code===t[i][a].code});o&&n.push(o.permission)}app.checkPermission(n).then(function(n){var i,a=[];if(t.length>0)for(var o=0;o<t.length;o++){for(var s=[],l=0;l<t[o].length;++l)(i=_.find(r,function(e){return e.code===t[o][l].code}))&&_.find(n,function(e){return e&&e.action===i.permission&&!0===e.result})&&(i.init={isDoctorDashboard:!0},s.push(i));a.push(s)}e.sizeColumn="col-xs-"+(12/a.length).toString(),e.doctorDashConfig=a})}}function d(e){if(e&&e.length>0){for(var t=[],n=0;n<e.length;n++)t=t.concat(e[n]);if(t&&t.length>0)return _.map(t,function(e){return e.code}).join(",")}return null}l(i.LoggedUserConfiguration.doctorDashboardConfig);var c=null;e.dropWidgetCallback=function(t,n){e.isDragDrop=!0;var r=[c?o.get(c):o.search({owner:"User/"+i.loggedUser.id})];return a.all(r).then(function(t){var n=c?t[0]:t[0][0];
8if(c||(c=n.id),n.doctorDashboardConfig=e.doctorDashConfig,n.doctorDashboardConfig&&n.doctorDashboardConfig.length>0)for(var a=0;a<n.doctorDashboardConfig.length;a++)n.doctorDashboardConfig[a]&&n.doctorDashboardConfig[a].length>0&&(n.doctorDashboardConfig[a]=_.uniqBy(n.doctorDashboardConfig[a],"code"));o.save(n).then(function(t){for(var n=[],a=0;a<t.doctorDashboardConfig.length;a++){for(var o=[],r=0;r<t.doctorDashboardConfig[a].length;r++){var s={code:t.doctorDashboardConfig[a][r].code,display:t.doctorDashboardConfig[a][r].display};o.push(s)}o.length>0&&n.push(o)}i.updatePropertyConfig({name:"doctorDashboardConfig",value:n}),l(n),e.isDragDrop=!1},function(){e.isDragDrop=!1})},function(){e.isDragDrop=!1}),n};var u=e.$on("configurationChanged",function(){l()});e.$on("$destroy",function(){s(),u()})}]),app.ui.clinicianDashboard.config(["gettext",function(e){"use strict";app.ui.clinicianDashboard.link={url:"/clinicianDashboard",name:e("Clinician Dashboard"),code:"clinicianDashboard"}}]),app.ui.clinicianDashboard.controller("nxtClinicianDashboardCtrl",["$scope","$rootScope","nxtUserContextSvc","nxtDoctorDashboardSvc","NXT_CLINICIAN_DASHBOARD_MODULE",function(e,t,n,i,a){"use strict";n.setCurrentPageContextProperty("clinicianDashboardModuleContext",!0),e.landingPageTabTitle=a.TabName,function(){if(e.currentPageContextChecked)return;var t=n.getCurrentPageContextProperty("clinicianDashboardTabsContext");t&&t.selectedTabId&&n.setSelectedModuleTab(t.selectedTabId,"clinicianDashboardTabs");e.currentPageContextChecked=!0}(),e.tabSelected=function(e){n.setCurrentPageContextProperty("clinicianDashboardTabsContext",{selectedTabId:e})},i.loadWidgetsTemplates();var o=t.$on("onUserConfigurationOrganizationChanged",function(t,n){e.$broadcast("userConfigurationChanged",n)}),r=t.$on("onUserConfigurationChanged",function(t,n){e.$broadcast("configurationChanged",n)});e.$on("$destroy",function(){n.removeCurrentPageContextProperty("clinicianDashboardModuleContext"),o(),r()})}]),app.registration.config([function(){"use strict";app.routes.add("/activateAccount","Welcome to VITLAccess",{templateUrl:"modules/registration/activateAccount.html"}),app.routes.add("/changePassword/:token","Change Password",{templateUrl:"modules/registration/changePassword.html"}),app.routes.add("/setPassword/:token","Set a VITLAccess Password",{templateUrl:"modules/registration/setPassword.html"})}]),app.registration.controller("changePasswordCtrl",["gettextCatalog","$scope","$location","nxtUserSvc","$routeParams","$interval","nxtUtilsSvc","$uibModal","$q","NXT_APP_BRAND","nxtSecuritySvc","NXT_VALIDATION_TOKEN_FAILED","CONSTANT","NXT_USER_SECURITY_QUESTIONS","NXT_USER_SET_PASSWORD","NXT_PHONE_NUMBER","$document",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m){"use strict";t.loading=!0,t.showForm=!0,t.hasErrors=!1,t.token=a.token,t.questions=[],t.isUserPartialLocked=!1,t.setPassword=!1,t.trustedHtml=u.ChangePassword.InvalidTokenMessage,t.setPasswordConfig=f,t.phoneNumberConfig=h,g&&g.AnswerMinRequiredLength&&g.AnswerMinRequiredLength>0&&(t.answerMinRequiredLength=g.AnswerMinRequiredLength);var v=null;g&&g.FilterBy&&(v=g.FilterBy.toUpperCase());var S=[i.validateToken(t.token,g.VerifySecurityQuestions,null,v),c.getPasswordValidationRule()];function C(e){t.isUserPartialLocked=!0,t.counter=r.getSecondsDifference(new Date,e),g.WrongSecurityAnswers&&g.WrongSecurityAnswers.PartialLockedUserMessage?t.warningMsg=g.WrongSecurityAnswers.PartialLockedUserMessage.replace("{{0}}","{{counter | counter | date:'mm:ss'}}"):t.warningMsg="Please wait {{counter | counter | date:'mm:ss'}} minutes";var n=o(function(){t.counter--,t.counter<=0&&(o.cancel(n),t.isUserPartialLocked=!1,delete t.warningMsg,t.questions&&2===t.questions.length||(t.missingSecurityQuestions=g.MissingSecurityQuestions))},1e3)}function y(e){if(t.isSaving=!1,t.showForm=!0,e&&e.issue&&e.issue.length)for(var n=0;n<e.issue.length;n++)if(e.issue[n]&&e.issue[n].details)switch(e.issue[n].details.code){case p.ERROR.MSG_WRONG_ANSWERS_TOO_MANY_TIMES.code:t.isUserLocked=!0,t.lockedMessage=g.WrongSecurityAnswers&&g.WrongSecurityAnswers.LockedUserMessage?g.WrongSecurityAnswers.LockedUserMessage:e.display||e}t.isUserLocked||(t.hasErrors=!0,t.error=e.display||e)}function b(){t.data&&t.data.retypePassword&&delete t.data.retypePassword,t.mainForm&&t.mainForm.resetForm()}l.all(S).then(function(e){if(g.VerifySecurityQuestions){if(u.ChangePassword.AllowUserToSetSecurityQuestions&&e[0]&&e[0].securityQuestions&&e[0].securityQuestions.length>0)t.setPassword=!0,t.securityQuestionsList=e[0]&&e[0].securityQuestions;else{t.setPassword=!1,t.questions=e[0]&&e[0].questions;var n=e[0]&&e[0].outcome;n&&n.issue&&n.issue.length>0&&n.issue[0]&&n.issue[0].details&&"MSG_WRONG_ANSWERS_PARTIAL_LOCKED"===n.issue[0].details.code&&n.issue[0].userPartilaLockedDate&&C(n.issue[0].userPartilaLockedDate),t.isUserPartialLocked||t.questions&&2===t.questions.length||(t.missingSecurityQuestions=g.MissingSecurityQuestions)}t.step="questions"}else t.step="password";t.rule=e[1],t.loading=!1}
8,function(e){if(e&&e.issue&&e.issue.length)for(var n=0;n<e.issue.length;n++)if(e.issue[n]&&e.issue[n].details)switch(e.issue[n].details.code){case p.ERROR.MSG_VALIDATE_TOKEN_FAILED.code:case p.ERROR.MSG_TOKEN_NOT_FOUND.code:case p.ERROR.MSG_AUTH_TOKEN_EXPIRED.code:t.isInvalidToken=!0;break;case p.ERROR.MSG_WRONG_ANSWERS_TOO_MANY_TIMES.code:t.step="questions",t.isUserLocked=!0,t.lockedMessage=g.WrongSecurityAnswers&&g.WrongSecurityAnswers.LockedUserMessage?g.WrongSecurityAnswers.LockedUserMessage:e.display}t.isUserLocked||(t.error=e),t.loading=!1}),t.$watch("locale",function(){0===_.toLower(n.path()).indexOf("/registration")&&(m[0].title=d.AppTitle+" - "+e.getString("Change password"))}),t.data={password:null,retypePassword:null,phone:null,securityQuestions:[{question:null,answer:null},{question:null,answer:null}]},t.submit=function(){if(t.isSaving=!0,function(){t.hasErrors=!1,t.error&&delete t.error;t.warningMsg&&delete t.warningMsg}(),"questions"!==t.step||t.setPassword)if("questions"===t.step&&t.setPassword)b(),t.step="password",t.isSaving=!1;else{t.isSaving=!0;var e=[];if(t.setPassword){if(t.data.securityQuestions&&t.data.securityQuestions.length>0)for(var n,a=0;a<t.data.securityQuestions.length;a++)t.data.securityQuestions[a]&&(n={},t.data.securityQuestions[a].isOther&&t.data.securityQuestions[a].otherQuestion?n.question={display:t.data.securityQuestions[a].otherQuestion}:t.data.securityQuestions[a].question&&t.data.securityQuestions[a].question.code&&(n.question=t.data.securityQuestions[a].question),t.data.securityQuestions[a].answer&&(n.answer=t.data.securityQuestions[a].answer),n.question&&n.answer&&e.push(n))}else e=t.questions;i.initializeUser(t.token,t.data.password,null,g.VerifySecurityQuestions?e:null,t.setPassword?{phone:t.data.phone,phoneNotes:t.data.phoneNotes}:null,g.VerifySecurityQuestions?"reset-password":null).then(function(){t.showForm=!1,t.isSaving=!1},function(e){y(e)})}else i.checkSecurityAnswers(t.token,t.questions).then(function(e){e&&e.issue&&e.issue.length>0&&e.issue[0]&&e.issue[0].details&&"MSG_WRONG_ANSWERS_PARTIAL_LOCKED"===e.issue[0].details.code?e.issue[0].userPartilaLockedDate?C(e.issue[0].userPartilaLockedDate):t.warningMsg=g.WrongSecurityAnswers&&g.WrongSecurityAnswers.WrongAnswersMessage?g.WrongSecurityAnswers.WrongAnswersMessage:e.display:(b(),t.step="password"),t.isSaving=!1},function(e){y(e)})},t.goToLogin=function(){n.path("/login")},t.resetProcess=function(){var e=t.$new();s.open({templateUrl:"modules/login/forgotPassword.html",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html",scope:e,controller:"forgotPasswordCtrl",backdrop:"static",windowClass:"nxt-medium-popup"})}}]),app.registration.controller("setPasswordCtrl",["$scope","$location","nxtUserSvc","$routeParams","nxtSecuritySvc","$uibModal","$q","CONSTANT","NXT_VALIDATION_TOKEN_FAILED","NXT_USER_SECURITY_QUESTIONS","NXT_PHONE_NUMBER","NXT_USER_SET_PASSWORD","NXT_ENABLED_2FA","$uibModal",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g){"use strict";e.securityQuestionsConfig=d,e.setPasswordConfig=u,e.phoneNumberConfig=c,e.loading=!0,e.isSaving=!1,e.hasErrors=!1,e.token=i.token,e.verifySecurityQuestions=d.VerifySecurityQuestions,e.CONSTANT=s,e.trustedHtml=l.ActivateAccount;var f=null;function h(){e.hasErrors=!1,e.error&&delete e.error}function m(){e.data&&e.data.retypePassword&&delete e.data.retypePassword,e.mainForm&&e.mainForm.resetForm()}d&&d.AnswerMinRequiredLength&&d.AnswerMinRequiredLength>0&&(e.answerMinRequiredLength=d.AnswerMinRequiredLength),d&&d.FilterBy&&(f=d.FilterBy.toUpperCase()),r.all([n.validateToken(e.token,null,e.verifySecurityQuestions,f),a.getPasswordValidationRule(),n.details2FA(e.token)]).then(function(t){e.securityQuestionsList=t[0]&&t[0].securityQuestions,p&&t[2]&&t[2].mandatory2FA?(e.enabled2FA=!0,t[2].email&&(e.email=t[2].email),t[2].phone&&(e.phone=t[2].phone),e.step="2FA"):e.verifySecurityQuestions?e.step="questions":e.step="password",e.rule=t[1],e.loading=!1},function(t){if(t&&t.issue&&t.issue.length)for(var n=0;n<t.issue.length;n++)if(t.issue[n]&&t.issue[n].details)switch(t.issue[n].details.code){case s.ERROR.MSG_VALIDATE_TOKEN_FAILED.code:case s.ERROR.MSG_TOKEN_NOT_FOUND.code:case s.ERROR.MSG_AUTH_TOKEN_EXPIRED.code:e.isInvalidToken=!0}e.error=t,e.loading=!1}),e.data={password:null,retypePassword:null,phone:null,securityQuestions:[{question:null,answer:null},{question:null,answer:null}],authenticationType:"",telecomValue:""},e.onEmailClick=function(){e.data.telecomValue=e.email,e.data.authenticationType="email"},e.onPhoneClick=function(){e.data.telecomValue=e.phone,e.data.authenticationType="sms_home"},e.submit=function(){if(e.loading=!0,"2FA"===e.step)n.validate2FA(e.token,e.data.telecomValue,e.data.authenticationType,null).then(function(t){var n=t&&t.issue&&t.issue.length>0?_.find(t.issue,function(e){return e.details&&(e.details.code===s.ERROR.MSG_TOKEN_SENT_TO_S
8MS.code||e.details.code===s.ERROR.MSG_TOKEN_SENT_TO_EMAIL.code)}):null,i=e.$new();i.urlToken=e.token,i.secondFactorMessage=t.display,i.telecomValue=e.data.telecomValue,i.authenticationType=e.data.authenticationType,i.verificationCode=n.uniqueId?n.uniqueId+" - ":null,g.open({templateUrl:"modules/administration/users/userEditToken.html",scope:i,backdrop:"static",controller:"nxtUserEditTokenCtrl",windowClass:"nxt-token-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){e.step="questions",m(),h()},function(e){}),e.loading=!1},function(t){e.loading=!1});else if("questions"===e.step)e.loading=!1,e.step="password",m(),h();else if("password"===e.step){e.isSaving=!0;var i=[];if(e.data.securityQuestions&&e.data.securityQuestions.length>0)for(var a,r=0;r<e.data.securityQuestions.length;r++)e.data.securityQuestions[r]&&(a={},e.data.securityQuestions[r].isOther&&e.data.securityQuestions[r].otherQuestion?a.question={display:e.data.securityQuestions[r].otherQuestion}:e.data.securityQuestions[r].question&&e.data.securityQuestions[r].question.code&&(a.question=e.data.securityQuestions[r].question),e.data.securityQuestions[r].answer&&(a.answer=e.data.securityQuestions[r].answer),a.question&&a.answer&&i.push(a));n.initializeUser(e.token,e.data.password,null,e.verifySecurityQuestions?i:null,e.verifySecurityQuestions?{phone:e.data.phone,phoneNotes:e.data.phoneNotes}:null,e.verifySecurityQuestions?"activate":null).then(function(){e.hasErrors=!1,e.isSaving=!1;var n=e.$new();o.open({template:'<div class="modal-header" ng-hide="true">\n\t\t\t\t\t\t\t\t\t&nbsp;\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class="modal-body">\n\t\t\t\t\t\t\t\t\t<div id="templateViewBody" style="margin-bottom: 10px;">\n\t\t\t\t\t\t\t\t\t\t<div> <p class="txt-justify">Your password has been set successfully.</p> </div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t<div class="modal-buttons">\n\t\t\t\t\t\t\t\t\t\t<div class="pull-right"><a href="" ng-click="goToLogin()">Go to login page</a></div>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>',scope:n,controller:["$scope","$uibModalInstance",function(e,t){e.goToLogin=function(){t.dismiss("cancel")}}],backdrop:"static",windowClass:"nxt-light-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(){},function(){t.path("/login")})},function(t){var n;n=t,e.isSaving=!1,e.loading=!1,e.hasErrors=!0,e.error=n.display||n})}},e.back=function(){e.step="questions",h(),m()},e.goToLogin=function(){t.path("/login")},e.resetProcess=function(){t.path("/activateAccount")}}]),app.registration.controller("activateAccountCtrl",["$scope","nxtUserSvc","NXT_USER_ACTIVATE_ACCOUNT",function(e,t,n){"use strict";e.activateAccountConfig=n,e.data={email:null},e.submit=function(){e.loading=!0,e.error=null,t.activateAccount(e.data.email).then(function(){e.loading=!1,e.showResponseMessage=!0},function(t){e.error=t,e.loading=!1})}}]),app.filter("counter",[function(){return function(e){return new Date(1970,0,1).setSeconds(e)}}]),app.ui.patientConsent.config(["gettext",function(e){"use strict";app.ui.patientConsent.link={url:"/patientConsent",name:e("Patient Consent"),code:"patientConsent"}}]),app.ui.patientConsent.controller("nxtPatientConsentCtrl",["$scope","$rootScope","nxtInfiniteScrollSvc","nxtConsentSvc","nxtUserContextSvc","nxtPatientSvc","nxtValueSetSvc","$timeout","nxtDataTypesSvc","NXT_CONSENT","NXT_PATIENT_NAME","$uibModal","$q","CONSTANT","gettextCatalog","NXT_IDS_CONFIG","nxtTextSvc","nxtUtilsSvc","$controller","$injector","NXT_PATIENT_SEARCH_WIDGET","NXT_PHONE_NUMBER",function(e,t,n,i,a,o,r,s,l,d,c,u,p,g,f,h,m,v,S,C,y,b){"use strict";e.code="consent_module",e.subtab={code:"consent_module"},e.isPatientConsentModule=!0,S("nxtDashboardWidgetsCtrl",{scope:e,rootScope:t,$injector:C}),e.MPISearch=d.MPISearch,e.fields=d.Fields;var x={},D={},T=d.PolicyRule||"http://myhealth.org/consent/policy/opt-out";e.statusList=g.STATUS.CONSENT,e.types=d.Types,e.isMissingConsentType=_.find(e.types,function(e){return"MISSING"===e.type}),e.patientSearchWidgetConfig=y,e.minSearchStringLength=y.MinSearchStringLength,e.consentTypes=g.CONCEPT.CONSENT_TYPE,e.phoneNumberConfig=b;var w=null;e.isMissingConsentType||(_.find(e.types,function(e){return"PART_TWO"===e.type})&&(w=g.CONCEPT.CONSENT_TYPE.PART_TWO.code),!w&&_.find(e.types,function(e){return"HIE"===e.type})&&(w=g.CONCEPT.CONSENT_TYPE.HIE.code)),e.filterBy={lastname:null,firstname:null,birthdate:null,status:null,type:w},r.get({valueSetName:"USStates",limit:100}).then(function(t){e.USStates=t});var E=e.isMissingConsentType&&e.isMissingConsentType.active===g.STATUS.CONSENT.OPTIN;e.concatenateFirstAndMiddleNames=c.ConcatenateFirstAndMiddleNames;var P=["id","identifier","eid","optOutMrnList","mrn","mrnList","externalSources","created","lastUpdated","sourceOrganization"],I=[{id:"consent-last-name-th",name:f.getString("Last name"),visible:!0,code:"last-name",order:0},{id:"consent-first-name-th",name:f.getString("First name"),visible:!0,code:"first-name",width:"15",order:1},{id:"consent-mrn-th",name:f.getString("MRN"),visible:h.MRN.visible,code:"mrn",width:"10",order:2},{id:"consent-facility-th",name:f.getString("Facility"),visible:!1,
8code:"facility",width:"14",order:3},{id:"consent-gender-th",name:f.getString("Gender"),visible:!1,code:"gender",width:"7",order:4},{id:"consent-dob-th",name:f.getString("Birth date"),visible:!0,code:"dob",width:"14",minWidth:"75",order:5},{id:"consent-age-th",name:f.getString("Age"),visible:!1,code:"age",width:"5",order:6},{id:"consent-address-th",name:f.getString("Address"),visible:!1,code:"address",width:"20",order:7},{id:"consent-hie-consent-th",name:e.fields&&e.fields.Status&&e.fields.Status.label?e.fields.Status.label:f.getString("Status"),code:"status",visible:!0,width:"12",order:8},{id:"consent-middle-name-th",name:f.getString("Middle name"),code:"middle-name",visible:!1,width:"15",order:9},{id:"consent-date-signed-th",name:e.fields&&e.fields.DateSigned&&e.fields.DateSigned.label?e.fields.DateSigned.label:f.getString("Date Signed"),code:"dateSigned",visible:!0,width:"14",order:10},{id:"consent-expiration-date-th",name:f.getString("Expiration Date"),code:"expirationDate",visible:E,width:"14",order:11},{id:"consent-type-th",name:f.getString("Consent Type"),code:"type",visible:!0,width:"14",order:12}];function A(t){e.MPISearch?function(t){if(!L())return;t||(e.expandedList={});x.nxtPatientSvc={familyName:e.filterBy.lastname,givenName:e.filterBy.firstname,birthDate:e.filterBy.birthdate},e.infiniteScroll.isBusy(!t,x)||(e.loading=!0,e.infiniteScroll.nextPage(!t).then(function(n){var a=[],o={};_.each(n,function(e){if(R(e),e.optOutMrnList&&e.optOutMrnList.length>0){var t=_.map(e.optOutMrnList,function(e){return d.MrnSystem+"|"+e});a=a.concat(t),o[e.eid]=t}}),i.getRecentConsent({patientId:a,includePatient:!0},o,_.map(n,"eid"),!0).then(function(a){a&&a.length&&_.each(n,function(e){var t=null;if((t=_.find(a,function(t){return t&&t.patient&&t.patient.eid===e.eid}))&&t.id){t.originalPatient=angular.copy(t.patient);var n=angular.copy(_.extend(_.pick(t.patient,P),_.omit(e,P)));e.consent=angular.copy(_.extend(t,{eid:e.eid,patient:n}))}});var o=N();"active"===o?n=_.filter(n,function(e){return e.consent&&"active"===e.consent.status}):"inactive"===o&&(n=_.filter(n,function(e){return!e.consent||e.consent&&"inactive"===e.consent.status})),_.each(n,function(e){if(!e.consent||!e.consent.id){var t=i.create();t.patient=angular.copy(e),t.status=E?"active":"inactive",t.dateTime=new Date,t.policyRule=T,t.eid=e.eid,e.consent=angular.copy(t)}}),e.patients=t?e.patients.concat(n):n,t||(e.noResultsFound=!n||0===n.length,e.operation=e.patients&&e.patients.length>0?"view":null,e.selectPatient(e.patients&&e.patients.length>0?e.patients[0]:null)),e.loading=!1},function(){e.loading=!1})},function(){e.loading=!1}))}(t):function(t){t||(e.consentList=[]);x.nxtConsentSvc={familyName:e.filterBy.lastname,givenName:e.filterBy.firstname,birthDate:e.filterBy.birthdate,status:N(),sort:":desc=date",includePatient:!0,category:e.filterBy.type},e.infiniteScroll.isBusy(!t,x)||e.infiniteScroll.nextPage(!t).then(function(n){if(e.consentList||(e.consentList=[]),n&&n.length>0)for(let e=0;e<n.length;e++)R(n[e].patient,!0);e.consentList=t?e.consentList.concat(n):n,t||(e.operation=e.consentList&&e.consentList.length>0?"view":null,e.changeSelection(e.consentList&&e.consentList.length>0?e.consentList[0]:null))})}(t)}function R(e,t){e&&(e&&e.address&&e.address.length>0&&(e.addressDisplay=m.getTextAddress(e.homeAddress||e.address[0])),t&&v.setDisplayOriginAndSource(e))}function N(){var t=null;if(e.filterBy.status){var n=e.isMissingConsentType;e.isMissingConsentType||e.filterBy.type&&(e.filterBy.type===g.CONCEPT.CONSENT_TYPE.PART_TWO.code?n=_.find(e.types,function(e){return"PART_TWO"===e.type}):e.filterBy.type===g.CONCEPT.CONSENT_TYPE.HIE.code&&(n=_.find(e.types,function(e){return"HIE"===e.type}))),n&&(e.filterBy.status===e.statusList.OPTOUT?t=n.active===g.STATUS.CONSENT.OPTIN?"inactive":"active":e.filterBy.status===e.statusList.OPTIN&&(t=n.active===g.STATUS.CONSENT.OPTIN?"active":"inactive"))}return t}function L(){if(!e.filterBy||_.isEmpty(e.filterBy))return!1;var t=0;return angular.forEach(_.omit(e.filterBy,["status","type"]),function(e){(_.isNil(e)||_.isUndefined(e))&&t++}),t<=1}e.headers=_.sortBy(_.filter(e.setColumns(I),function(e){return e.visible}),"order"),e.MPISearch?(D.nxtPatientSvc={methodName:"searchWithTotalRowsGrouped"},e.infiniteScroll=n.create({services:D,limit:50,infiniteScrollEventName:"consentTblEvent"+e.$id}),e.$watch("filterBy",function(t,n){t&&n&&!angular.equals(t,n)&&
8(e.noResultsFound=!1)},!0)):(D.nxtConsentSvc={methodName:"searchWithTotalRows"},e.infiniteScroll=n.create({services:D,limit:100}),e.$watchCollection("[filterBy.lastname, filterBy.firstname, filterBy.birthdate, filterBy.status, filterBy.type]",function(e,t){e&&!_.isEqual(e,t)&&(!e[0]||e[0]&&e[0].length>=3)&&(!e[1]||e[1]&&e[1].length>=3)&&A()})),A(),e.MPISearch||e.$watch("consentSelectedItem",function(t,n){var i=e.MPISearch?"eid":"id";t&&t[i]&&(!n||t[i]!==n[i]&&t[i]&&n[i])&&$("view",e.consentSelectedItem)},!0),e.searchPatients=function(){e.patients=[],L()&&A()},e.getConsentStatusConfig=function(t){var n=e.isMissingConsentType,i=t&&t.category&&t.category.length>0&&t.category[0];return e.isMissingConsentType||i&&(i.code===g.CONCEPT.CONSENT_TYPE.PART_TWO.code?n=_.find(e.types,function(e){return"PART_TWO"===e.type}):i.code===g.CONCEPT.CONSENT_TYPE.HIE.code&&(n=_.find(e.types,function(e){return"HIE"===e.type}))),n},e.isOptOutConsent=function(t){var n=e.getConsentStatusConfig(t);return n&&n.active!==g.STATUS.CONSENT.OPTIN?t&&"active"===t.status:!(!n||n.active!==g.STATUS.CONSENT.OPTIN)&&(t&&"active"!==t.status)},e.selectPatient=function(t){O?O=!1:e.changeSelection(t||null)};var O=!1;function M(t,n){var i=n?angular.extend({patient:e.consentSelectedItem.patient},n):function(e){if(e.except&&e.except.length>0){var t={patient:e.patient};for(let n=0;n<e.except.length;n++)if(e.period.start.getTime()===e.except[n].period.start.getTime())return angular.extend(t,e.except[n])}return e}(e.consentSelectedItem);if(i.document&&i.document&&i.document.data){var a=e.$new();a.file=i.document,a.consent=angular.copy(i),a.operation=t,u.open({templateUrl:"modules/dashboardWidgets/documentViewer/documentViewer.html",scope:a,controller:["$scope","$uibModalInstance","nxtPrintUtilsSvc","$window","$document",function(t,n,i,a,o){t.docLoading=!0,t.title=t.file.title,i.generateConsentPdf(t.file,t.consent).then(function(e){if("print"===t.operation)if(a.navigator&&a.navigator.msSaveOrOpenBlob)a.navigator.msSaveOrOpenBlob(e),t.close();else{var n='<iframe src="{{0}}"  type="{{1}}" width="100%" height="100%" class="viewer"></iframe>';t.htmlList=[n.replace("{{0}}",URL.createObjectURL(e)).replace(/\{\{1\}\}/g,"application/pdf")]}else if("download"===t.operation){var i=t.title+".pdf";if(navigator.msSaveBlob)return navigator.msSaveBlob(e,i);var r=o[0].createElement("a");r.href=URL.createObjectURL(e),r.setAttribute("download",i),o[0].body.appendChild(r),r.click(),t.close()}else t.htmlList=[n.replace("{{0}}",URL.createObjectURL(e)).replace(/\{\{1\}\}/g,"application/pdf")]},function(){e.docLoading=!1}),t.close=function(){n.dismiss("cancel")};var r=t.$on("onLoaded",function(e){t.docLoading=!1});t.$on("$destroy",function(){r&&r()})}],backdrop:"static",windowClass:"nxt-large-popup",windowTemplateUrl:"directives/controls/nxtModalHeader/nxtModalHeader.html"}).result.then(function(e){},function(e){})}}function $(t,n){e.data={},e.operation=null,e.initialData=null;var a=s(function(){if("add"!==t&&n){if(e.data.patient=angular.copy(n.patient),e.data.consent=angular.copy(n),e.initialData={consent:angular.copy(n),patient:angular.copy(n.patient),originalPatient:angular.copy(n.originalPatient)},e.data.consent.except&&e.data.consent.except.length>1){e.data.consentList=[];var r=_.orderBy(e.data.consent.except,["period.start"],["asc"]);for(let t=0;t<r.length;t++)r[t+1]&&(r[t].dateRevoked=r[t+1].period.start,e.data.consentList.push(r[t]));e.data.consentList=_.orderBy(e.data.consentList,["dateRevoked"],["desc"])}}else e.data.patient=o.create(),e.data.patient.gender={code:"unknown"},e.data.consent=i.create(),e.data.consent.status="active",e.data.consent.policyRule=T,e.MPISearch&&(e.data.consent.dateTime=new Date);e.operation=t,s.cancel(a)},1)}function F(){var t=e.MPISearch?"patients":"consentList",n=e.MPISearch?"patientSelectedItem":"consentSelectedItem";if(e.operation=e[t]&&e[t].length>0?"view":null,"view"===e.operation){var i=null;$("view",(i=e[n]&&e[n].id?angular.copy(e[n]):angular.copy(e[t][0])).consent||i)}else e[n]=null}e.expandData=function(t){if(!e.loading)if(O=!0,e.expandedList||(e.expandedList={}),t.isExpanded=!t.isExpanded,e.expandedList[t.eid])e.expandedList[t.eid]=!1;else{if(t.patients)return void(e.expandedList[t.eid]=!0);e.loading=!0,a.verifyPatientMrnList(t).then(function(n){var i=n.patients;if(i.length>0)for(var a=0;a<i.length;a++)R(i[a],!0);t.patients=angular.copy(i),e.expandedList[t.eid]=!0,e.loading=!1},function(){e.expandedList[t.eid]=!0,e.loading=!1})}},e.MPISearch&&e.$watch("patientSelectedItem",function(t,n){var i=e.MPISearch?"eid":"id";t&&t[i]&&(!n||t[i]!==n[i]&&t[i]&&n[i])&&(e.consentSelectedItem=angular.copy(e.patientSelectedItem.consent),$("view",e.patientSelectedItem.consent))},!0),e.getMoreData=function(){A(!0)},e.changeConsentStatus=function(){e.fields.DateSigned.readonly&&(e.data.consent.dateTime=new Date)},e.add=function(){$("add")},e.edit=function(){e.consentSelectedItem.id||(e.consentSelectedItem.status=E?"inactive":"active"),$("edit",e.consentSelectedItem)},e.download=function(e){M("download",e)},e.print=function(e){M("print",e)},e.cancel=function(){e.form&&e.form.resetForm(),F()};var U=["namePrefix","familyName","givenName","middleName","nameSuffix","gender.code","birthDate","phone","phoneNotes","mobilePhone","mobilePhoneNotes","email","homeAddress.line1","homeAddress.line2","homeAddress.city","homeAddress.state.code","homeAddress.zip"];function V(t,n){e.data.consent.originalPatient&&delete e.data.consent.originalPatient,e.data.consent.except||(e.data.consent.except=[]),("add"===e.operation||"edit"===e.operation&&!e.data.consent.id||"edit"===e.operation&&e.initialData&&e.initialData.consent&&e.initialData.consent.status!==e.data.consent.status)&&(_.each(e.data.consent.except,function(t){t&&t.period&&t.period.start&&!t.period.end&&(t.period.end=e.data.consent.dateTime)}),E?e.data.consent.except.push({type:"active"===e.data.consent.status?"permit":"deny",period:{start:e.data.consent.dateTime}}):e.data.consent.except.push({type:"active"===e.data.consent.status?"deny":"permit",period:{start:e.data.consent.dateTime}})),i.save(e.data.consent).then(function(i){if(e.MPISearch){i.patient.eid||(i.patient.eid=t.eid),i.eid||(i.eid=t.eid),e.patients||(e.patients=[]),"add"===e.operation&&e.patients.unshift(angular.copy(t));for(let a=0;a<e.patients.length;a++)if(e.patients[a].eid===i.patient.eid){n?(i.patient=angular.copy(n),i.originalPatient=angular.copy(t)):i.patient=angular.copy(t),e.patients[a].consent=angular.copy(i),e.consentSelectedItem&&e.consentSelectedItem.eid===i.patient.eid&&(e.consentSelectedItem=angular.copy(i));break}}else if(t.name=t.display=l.getFullHumanName(t),i.patient=t,"add"===e.operation)e.consentList||(e.consentList=[]),e.consentList.unshift(i),e.consentSelectedItem=null;else if("edit"===e.operation&&e.consentList)for(let t=0;t<e.consentList.length;t++)if(e.consentList[t].id===i.id){e.consentList[t]=i,e.consentSelectedItem&&e.consentSelectedItem.id===i.id&&(e.consentSelectedItem=angular.copy(i));break}F(),e.isSaving=!1,e.form&&e.form.resetForm()})}e.fields&&e.fields.SSN&&e.fields.SSN.visible&&U.push("ssn"),e.save=function(t){e.isSaving=!0,t&&(e.form=t);var n,i,a,r=angular.copy(e.data.patient);if(e.initialData&&e.initialData.originalPatient&&(n=angular.copy(e.initialData.patient),r=angular.copy(e.initialData.originalPatient)),"edit"===e.operation&&(i=_.omitBy(_.pick(e.initialData.patient,U),_.isNil),a=_.omitBy(_.pick(e.data.patient,U),_.isNil),_.isEqual(i,a))&&e.data.consent.id)V(r,n);else{if("edit"===e.operation&&!e.data.consent.id){var s=_.filter(r.
8identifier,function(e){return e.value===r.eid});(r=_.extend(o.create(),_.omit(r,P))).identifier=s&&s.length>0?s:[]}o.save(r).then(function(t){e.data.consent.patient=o.create(t.toFhirReference()),e.MPISearch&&(r.eid?t.eid=r.eid:r.identifier&&r.identifier[0]&&r.identifier[0].value?t.eid=r.identifier[0].value:t.eid=t.id),V(t,n)})}}}]),app.ui.healthDashboard.config(["gettext",function(e){"use strict";app.ui.healthDashboard.link={url:"/healthDashboard",name:e("NXT Health Dashboard"),code:"healthDashboard"}}]),app.ui.healthDashboard.controller("nxtHealthDashboardCtrl",["$scope","NXT_API_ENDPOINTS","$timeout","$document",function(e,t,n,i){"use strict";e.isLoading=!0;e.htmlData='<iframe id="healthDashboardFrame" src="{{0}}"  type="{{1}}" width="100%" height="100%" frameborder="0" scrolling="auto" style="display:none"></iframe>'.replace("{{0}}",t.HealthDashboardURL+"?"+(new Date).getTime()).replace(/\{\{1\}\}/g,"text/html");var a=e.$on("onLoaded",function(t){var a=n(function(){i[0].querySelector("#healthDashboardFrame").style.display="initial",n.cancel(a),e.isLoading=!1},500)});e.$on("$destroy",function(){a&&a()})}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.