function navController(n,t){n.isActive=function(n){var i=t.absUrl();return i=i.substr(i.indexOf(n)),i.substr(0,n.length)===n}}function messageTypes(n){var i={Success:"success",Info:"info",Warning:"warning",Error:"danger"},t;return n=="success"||n=="info"||n=="warning"||n=="danger"?n:(t=i[n],t==null&&(t=i.Info),t)}function note(n,t,i,r){this.id=n;this.message=t;this.type=messageTypes(i);this.persistence=r}function alert(n,t){this.message=n;this.type=messageTypes(t)}function notifyController(n,t,i,r){function f(){n.alerts.splice(0,1)}n.notes=[];n.alerts=[];n.test="";n.num=0;n.$on("handleNotification",function(){n.appendNotification(r.note)});n.$on("handleAlert",function(){n.appendAlert(r.alert)});n.appendNotification=function(t){t.message!=null&&t.message!=""&&n.notes.push(t)};n.getSiteNotifications=function(){i({url:"/Notification/SiteNotifications/",method:"POST"}).then(function(t){for(var i,u=t.length,r=0;r<u;r++)i=t[r],i.Persistence=="Dismissed"?n.appendNotification(new note(i.NotificationId,i.NotificationBody[0].Body,i.Type,i.Persistence)):n.appendAlert(new alert(i.NotificationBody[0].Body,i.Type))},function(t){n.appendAlert(new alert(t.message,"Error"))})};n.dismissNote=function(t,r){t!=null&&t!=0&&i({url:"/Notification/Dismiss/",data:{notificationId:t},method:"POST"});n.notes.splice(r,1)};n.appendAlert=function(i){if(i.type=="warning"||i.type=="danger"){var r=new note(0,i.message,i.type,"Dismissed");n.notes.push(r)}else n.alerts.push(i),t(f,u)};var u=7e3}function notificationService(n){var t={};return t.note=null,t.alert=null,t.createNotification=function(n){this.note=n;this.invokeNotification()},t.createAlert=function(n){n.message==undefined&&n.type=="danger"&&(n.message="An unexpected server error occurred.");this.alert=n;this.invokeAlert()},t.invokeNotification=function(){n.$broadcast("handleNotification",this.note)},t.invokeAlert=function(){n.$broadcast("handleAlert",this.alert)},t}function loginController(n,t,i,r){function f(n){for(var i,u=window.location.search.substring(1),r=u.split("&"),t=0;t<r.length;t++)if(i=r[t].split("="),decodeURIComponent(i[0])==n)return decodeURIComponent(i[1]);return null}function u(){n.loginState=n.userId!==0?1:2}n.userId=0;n.username="";n.firstname="";n.lastname="";n.phone="";n.extension="";n.password="";n.newPassword="";n.newPasswordConfirm="";n.loginState=0;n.showLogin=!1;n.mustChangePassword=!1;n.mustAcceptEula=!1;n.acceptEula=!1;n.hasSignedEula=!1;n.employerCode="";n.providerFirstName="";n.providerLastName="";n.providerEmail="";n.authType="";n.organizationName="";n.greeting="";n.registered=!1;n.setPasswordMode=function(){n.employerCode="";n.providerFirstName="";n.providerLastName="";n.providerEmail=""};n.login=function(){var i,f;i={username:n.username,password:n.password};f="/Login/Login/";t({url:f,method:"POST",data:i}).then(function(t){if(t.data.success===!1)r.createAlert(new alert(t.data.message,"Error"));else{n.userId=t.data.data.UserId;n.username=t.data.data.Email;r.createAlert(new alert(t.data.message,"Success"));var i="";window.location.search.substring(1).split("&").forEach(function(n){n=n.split("=");n[0]=="ReturnUrl"&&(i=n[1])});window.location=i!=""?i:"/"}u()},function(n){r.createAlert(new alert(n.message,"Error"));u()})};n.logout=function(){t({url:"/Login/Logout/",method:"POST"}).then(function(){n.userId=0;n.username="";window.sessionStorage.clear();u();window.location="/"},function(n){r.createAlert(new alert(n.message,"Error"));u()})};n.getCurrentUser=function(){t({url:"/Login/GetCurrentUser/",method:"POST"}).then(function(t){n.userId=t.data.userId;n.username=t.data.userName;n.firstname=t.data.firstName;n.password=t.data.password;n.hasSignedEula=t.data.hasSignedEula;n.authType=t.data.authType;n.organizationName=t.data.organizationName;n.greeting=n.authType==="IP"?"Menu":"Hi, "+n.firstname;u()},function(n){r.createAlert(new alert(n.message,"Error"));u()})};n.signEULA=function(){t({url:"/Home/SignEULA/",method:"POST"}).then(function(){var n="";window.location.search.substring(1).split("&").forEach(function(t){t=t.split("=");t[0]=="ReturnUrl"&&(n=t[1])});window.location=n!=""?n:"/"},function(n){r.createAlert(new alert(n.message,"Error"))})};n.register=function(){data={firstName:n.firstname,lastName:n.lastname,email:n.email,phone:n.phone,extension:n.extension};t({url:"/Login/RegisterUser/",method:"POST",data:data}).then(function(t){if(t.data.success){n.registered=!0;r.createAlert(new alert(t.data.message,"success"));return}r.createAlert(new alert(t.data.message,"Error"));return},function(n){r.createAlert(new alert(n.data.message,"Error"))})};n.completeRegistration=function(){var i,e;if(n.newPasswordConfirm!=n.newPassword){r.createAlert(new alert("The confirmation password does not match. Please re-enter.","Error"));return}if(n.mustAcceptEula&&!n.acceptEula){r.createAlert(new alert("You must accept the Terms of Use to log on.","Error"));return}if(i=f("token"),!i){r.createAlert(new alert("Invalid token.","Error"));return}e={token:i,password:n.newPassword,acceptEula:n.acceptEula};t({url:"/Login/CompleteRegistration/",method:"POST",data:e}).then(function(t){if(t.success===!1){if(t.message=="eula"){n.mustAcceptEula=!0;return}r.createAlert(new alert(t.message,"Error"))}else n.userId=t.data.UserId,n.username=t.data.Email,window.location="/";u()},function(n){r.createAlert(new alert(n.message,"Error"));u()})}}function mtusController(n,t,i,r){n.username="";n.firstname="";n.lastname="";n.organizationName="";n.email="";n.stateLicenseType="";n.stateLicenseNumber="";n.nationalProviderId="";n.specialty="";n.privacyAccept=!1;n.usageOptOut=!1;n.practiceLocationState="";n.practiceLocationCity="";n.otherLicenseNumbers="";n.otherLicenseStates="";n.reasonPatientTreatment=!1;n.reasonEvaluation=!1;n.reasonUtilization=!1;n.reasonIMR=!1;n.reasonOther=!1;n.doubleClickDefender=!1;n.resetSpecialty=function(){n.specialty=""};n.otherLicenseNumbersChange=function(){n.otherLicenseNumbers||(n.otherLicenseStates="")};n.mtusValidateForm=function(){function t(n){return!n||0===n.length}return t(n.firstname)==!1&&t(n.lastname)==!1&&t(n.organizationName)==!1&&/\S+@\S+\.\S+/.test(n.email)==!0&&t(n.stateLicenseNumber)==!1&&t(n.nationalProviderId)==!1&&t(n.practiceLocationState)==!1&&t(n.practiceLocationCity)==!1&&t(n.stateLicenseType)==!1&&n.privacyAccept==!0&&(n.reasonPatientTreatment==!0||n.reasonEvaluation==!0||n.reasonUtilization==!0||n.reasonIMR==!0||n.reasonOther==!0)?!0:!1};n.mtusRegister=function(){var i,u;n.doubleClickDefender=!0;i=[];n.reasonPatientTreatment==!0&&i.push("patient treatment");n.reasonEvaluation==!0&&i.push("evaluation");n.reasonUtilization==!0&&i.push("utilization review");n.reasonIMR==!0&&i.push("IMR");n.reasonOther==!0&&i.push("other");u=i.join(",");data={firstName:n.firstname,lastName:n.lastname,organizationName:n.organizationName,email:n.email,stateLicenseType:n.stateLicenseType,stateLicenseNumber:n.stateLicenseNumber,nationalProviderId:n.nationalProviderId,specialty:n.specialty,practiceLocationState:n.practiceLocationState,practiceLocationCity:n.practiceLocationCity,otherLicenseNumbers:n.otherLicenseNumbers,otherLicenseStates:n.otherLicenseStates,reasonsForVisiting:u,usageOptOut:n.usageOptOut};t({url:"/Mtus/RegisterUser/",method:"POST",data:data}).then(function(t){if(t.data.success){n.registered=!0;r.createAlert(new alert(t.data.message,"success"));n.doubleClickDefender=!1;return}r.createAlert(new alert(t.data.message,"Error"));n.doubleClickDefender=!1;return},function(t){r.createAlert(new alert(t.data.message,"Error"));n.doubleClickDefender=!1;return})}}function startingLineController(n,t,i,r){n.acoem="";n.allowSubmit=!0;n.showError=!1;n.showSuccess=!1;n.errorMessage="";n.registrant={firstName:"",lastName:"",email:"",acoemId:"",occupation:"",otherOccupation:"",schoolName:"",schoolState:"",expectedGraduation:""};n.formIsValid=function(){return!n.registrant.firstName||!n.registrant.lastName||!n.registrant.email||!n.registrant.schoolName||!n.registrant.schoolState||!n.registrant.expectedGraduation?!1:n.acoem==="true"&&!n.registrant.acoemId?!1:n.acoem!=="true"&&!n.registrant.occupation?!1:n.acoem!=="true"&&n.registrant.occupation==="Other"&&!n.registrant.otherOccupation?!1:!0};n.submitForm=function(){if(n.formIsValid){if(n.acoem!=="true"&&n.registrant.email.substr(-4).toLowerCase()!==".edu"){r.createAlert(new alert('You must use a ".edu" email address to qualify for the Starting Line program.',"Error"));return}n.allowSubmit=!1;t({url:"/startingline/submit/",method:"POST",data:n.registrant}).then(function(t){if(t.data.success){n.showSuccess=!0;return}switch(t.data.message){case"invalid acoem id":n.errorMessage="The ACOEM member Id you provided was not recognized.";break;case"duplicate acoem id":n.errorMessage="The ACOEM member Id you provided has already been used to register for an MDGuidelines account.";break;case"duplicate org":case"duplicate user":n.errorMessage="You already have an MDGuidelines account.";break;default:n.errorMessage="We were not able to complete your registration."}n.showError=!0;return},function(){n.errorMessage="An unexpected error occurred. ";n.showError=!0;return})}}}function autoSuggestController(n,t,i){n.autosuggest=!1;n.showSuggestions=!1;n.showRecentSearches=!1;n.recentSearches=[];n.start=0;n.searchTime=0;n.rows=10;n.clicked=!1;n.autosuggestUrl=_API_URL+"/api/v1/autosuggest/";n.host=i.host()+(i.port()!=="80"?":"+i.port():"");n.tHost="//"+i.host();n.autocomplete=function(i){switch(i.keyCode){case 13:case 40:case 38:break;case 27:n.autosuggest=!1;break;default:n.phrase.length>2?t({method:"GET",url:n.autosuggestUrl+"?term="+n.phrase}).then(function(t){n.suggestions=t.topics;n.autosuggest=t.records>0?!0:!1;n.showSuggestions=!0},function(n,t,i){console.warn("autosuggest error: "+i)}):n.autosuggest=!1}};n.$watch("phrase",function(){n.autocomplete2()});n.autocomplete2=function(){n.phrase&&n.phrase.length>2?(t({method:"GET",url:n.autosuggestUrl+"?term="+encodeURIComponent(n.phrase)+"&relativize=true"}).then(function(t){n.suggestions=t.data.topics;n.showSuggestions=t.data.records>0;n.autosuggest=n.showSuggestions||n.showacoemSuggestions},function(n,t,i){console.warn("autosuggest error: "+i)}),t({method:"GET",url:n.autosuggestUrl+"?term="+encodeURIComponent(n.phrase)+"&collection=ACOEM&relativize=true"}).then(function(t){n.acoemSuggestions=t.data.topics;n.showacoemSuggestions=t.data.records>0;n.autosuggest=n.showSuggestions||n.showacoemSuggestions},function(n,t,i){console.warn("autosuggest error: "+i)})):(n.autosuggest=!1,n.autosuggestacoem=!1)};n.doBlur=function(){n.clicked===!1&&(n.autosuggest=!1)};n.doFocus=function(){t.get("/search/GetRecentSearches?"+(new Date).getTime()).then(function(t){t.length>0&&(n.recentSearches=[],angular.forEach(t,function(t){n.recentSearches.push({title:t.Term,url:"/search/#/"+t.Term.replace(/ /g,"+")})}),n.autosuggest=!0,n.showRecentSearches=!0)},function(){console.warn("recent search error")})};n.saveSearch=function(n,i){uri="/search/SaveSearch/"+n+"/";i!==""&&(uri=uri+"?url="+i);t({method:"POST",url:uri})};n.setLocation=function(t){n.autosuggest=!1;i.path()==="/"+t?hideSearchOverlay():window.location.href="/search/#"+$("#search-term").val().replace(/ /g,"+")}}function saveSearch(n){angular.element(document.getElementById("autoSuggestController")).scope().saveSearch(n,"");angular.element(document.getElementById("autoSuggestController")).scope().$apply()}function closeResults(){$("#auto-complete").is(":visible")&&(angular.element(document.getElementById("autoSuggestController")).scope().autosuggest=!1,angular.element(document.getElementById("autoSuggestController")).scope().$apply())}function jobController(n){n.init=function(){n.job=null;n.jobSearchLabel=null}}function searchResultsController(n,t,i){n.currentPage=1;n.searchUrl=_API_URL+"/api/v1/contentsearch/";n.codeSearchUrl=_API_URL+"/api/v1/codesearch/";n.host=i.host()+(i.port()!="80"?":"+i.port():"");n.init=function(){n.term=i.$$hash.replace(/\+/g," ")};n.searchSubmit=function(){window.location="/search/#/"+n.term};n.$on("$locationChangeSuccess",function(){n.term=i.$$hash.replace(/\+/g," ");n.term=n.term.indexOf("/")==0?n.term.substring(1):n.term})}function topicSearchResultsController(n,t,i){function r(){if(n.term){var i;n.chkRTW&&n.chkACOEM?(i="RTW,ACOEM",n.start=(n.currentPage-1)*n.numPerPage):n.chkRTW?(i="RTW",n.start=(n.currentPage-1)*n.numPerPage):n.chkACOEM?(i="ACOEM",n.start=(n.currentPage-1)*n.numPerPage):i="";t.get(n.searchUrl+"?term="+n.term.replace(".","%2E")+"&start="+n.start+"&rows="+n.numPerPage+"&collection="+i+"&relativize=true").then(function(t){n.topics=t.data.topics;n.numResults=t.data.records;n.totalPages=Math.ceil(n.numResults/n.numPerPage);n.showPager=n.numPages().length>1?!0:!1;u();n.numResults==0&&(n.start=-1)})}}function u(){n.pageModifier=n.currentPage>n.maxSize/2&&n.totalPages>n.maxSize?n.currentPage<n.totalPages-3?parseInt(n.currentPage)-5:n.totalPages-9:1}n.init=function(){n.chkRTW=!0;n.chkACOEM=!0;n.numPerPage=10;n.maxSize=10;$.ajax({url:"/getUserOptions",type:"POST",success:function(t){if(t)for(var i=0;i<t.length;i++)switch(t[i].OptionId){case 7:n.$apply(function(){n.chkRTW=t[i].Value=="true"});break;case 8:n.$apply(function(){n.chkACOEM=t[i].Value=="true"})}r()},error:function(){r()}})};n.$on("$locationChangeSuccess",function(){page=i.path().replace(/\+/g," ").replace("/","").match(/\/[0-9]+$/);n.currentPage=page?page[0].replace("/",""):1;n.start=(n.currentPage-1)*n.numPerPage;r()});n.chkRtwChange=function(){r();$.ajax({url:"/setOption/7/"+n.chkRTW,type:"POST"})};n.chkAcoemChange=function(){r();$.ajax({url:"/setOption/8/"+n.chkACOEM,type:"POST"})};n.numPages=function(){return new Array(Math.ceil(n.numResults/n.numPerPage)<n.maxSize?Math.ceil(n.numResults/n.numPerPage):n.maxSize)};n.page=function(n){i.path(i.path().replace("/","").replace(/\/.+$/,"")+"/"+n).replace()};n.getCurrentPage=function(t){return t==n.currentPage?"currentPage":""};n.showPrevious=function(){return n.currentPage>1?"previous":"no-previous"};n.movePrevious=function(){n.currentPage>1&&n.page(n.currentPage-1)};n.showNext=function(){return n.currentPage<n.totalPages?"next":"no-next"};n.moveNext=function(){n.currentPage<n.totalPages&&n.page(parseInt(n.currentPage)+1)}}function medcodeSearchResultsController(n,t){n.init=function(){n.codeSearches()};n.$on("$locationChangeSuccess",function(){n.codeSearches()});n.codeSearches=function(){n.term&&(t.get(n.codeSearchUrl+"?term="+n.term+"&start=0&rows=1000&types=ICD9CM&includeNonBillable=true").then(function(t){angular.forEach(t.data.codes,function(n){n.url=n.longDescription.replace(/ /g,"+").replace(";","").replace("/","%2F")});n.icd9cmcodes=t.data.codes}),t({url:n.codeSearchUrl+"?term="+n.term+"&start=0&rows=1000&types=ICD10CM&includeNonBillable=true",method:"GET"}).then(function(t){angular.forEach(t.data.codes,function(n){n.url=n.longDescription.replace(/ /g,"+").replace(";","").replace("/","%2F")});n.icd10cmcodes=t.data.codes}),t({url:n.codeSearchUrl+"?term="+n.term+"&start=0&rows=1000&types=ICD10WHO&includeNonBillable=true",method:"GET"}).then(function(t){angular.forEach(t.data.codes,function(n){n.url=n.longDescription.replace(/ /g,"+").replace(";","").replace("/","%2F")});n.icd10whocodes=t.data.codes}),t({url:n.codeSearchUrl+"?term="+n.term+"&start=0&rows=1000&types=CPT&includeNonBillable=true",method:"GET"}).then(function(t){angular.forEach(t.data.codes,function(n){n.url=n.longDescription.replace(/ /g,"+").replace(";","").replace("/","%2F")});n.cptcodes=t.data.codes}))}}function toolLayoutController(n,t){n.init=function(t,i,r,u,f){n.topicId=t;n.topicUrl=i;n.topicTitle=r;n.subTitle=u;n.toolName=f};n.usageLogEvent=function(n){t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:n}}).then({},{})}}function medicalCodeMappingController(n,t,i,r){n.init=function(){n.loadCodeTypes();n.selectedCulture="en";n.showResults=!1;n.mappingResults=[];n.mappingResultMessage="";n.medicalCodeTypes=[];n.searchCode="";n.searchDescription=null;n.codeLabel=null;n.codeType=null;n.$broadcast("mappingOpened");t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"IcdMappingOpen"}}).then({},{})};n.mapCodes=function(){if(n.searchCode.trim()===""){n.clearResults();return}t({url:"/Home/MapMedicalCodes/",method:"POST",data:{codes:n.searchCode}}).then(function(t){t.data.success?(n.showResults=!0,n.codeSearched=n.searchCode,n.mappingResults=t.data.data,n.mappingResultMessage=t.data.message):(n.showResults=!1,r.createAlert(new alert(t.data.message,"Error")))},function(t){n.showResults=!1;r.createAlert(new alert(t.data.message,"Error"))});var i=[];i.push({DetailKey:"SearchCode",DetailValue:n.searchCode});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"IcdMappingSearch",eventDetails:i}}).then({},{})};n.loadCodeTypes=function(){t({url:"/Home/MedicalCodeTypes/",method:"GET"}).then(function(t){n.medicalCodeTypes=t})};n.getCodeType=function(t){for(var r,i=0;i<n.medicalCodeTypes.length;i++)if(r=n.medicalCodeTypes[i],r.Key===t)return r.Value};n.getLongDescription=function(t){var i,r;if(t!=null)for(i=0;i<t.Descriptions.length;i++)if(r=t.Descriptions[i],r.Culture==n.selectedCulture)return r.LongDescription;return""};n.getTargetDescription=function(t,i){for(var u,r=0;r<i.Targets.length;r++)if(u=i.Targets[r],u.Code==t)return n.getLongDescription(u)};n.clearSearch=function(){n.searchCode="";n.codeLabel="";n.searchDescription=null};n.clearResults=function(){n.showResults=!1;n.mappingResults=[];n.searchCode="";n.codeLabel="";n.searchDescription=null};n.codeChanged=function(){n.searchCode=n.codeLabel};n.delayMapCodes=function(){i(n.mapCodes,100)};n.runSearch=function(t){n.searchCode=t;n.mapCodes()};n.searchExec=function(t){n.searchCode=t;n.mapCodes()};n.validateForm=function(){return n.searchCode.trim()!=""}}function medicalCostsController(n,t){n.init=function(){n.openMedicalCostDistributions();n.clearFilters();n.cpbInit();n.results={}};n.openMedicalCostDistributions=function(){n.ActiveTab="MedicalCostDistributions";n.createPlotlyGraph()};n.openTreatmentStatistics=function(){n.ActiveTab="TreatmentStatistics"};n.openCostProfileBulider=function(){n.ActiveTab="CostProfileBuilder"};n.clearFilters=function(){n.reasonForDisability="";n.reasonTopicId="";n.reasonTopicTitle="";n.reasonTopicUrl="";n.primaryTreatment="";n.programType="";n.inpatientOutpatient="";n.drgCode="";n.drgCodeDescription="";n.comorbids=[];n.zipcode="";n.age=""};n.fillPrimaryTreatments=function(i){t({url:"/medicalcosts/GetPrimaryTreatments/",method:"POST",data:{TopicId:i}}).then(function(t){n.primaryTreatments=t.data;n.primaryTreatment="-1"},function(){alert("error")})};n.fillComorbids=function(i){t({url:"/medicalcosts/GetComorbidGroups/",method:"POST",data:{TopicId:i}}).then(function(t){n.comorbidGroups=t.data},function(){alert("error")})};n.fillDrgs=function(i){t({url:"/medicalcosts/GetDrgsForDocument/",method:"POST",data:{DocumentId:i}}).then(function(t){n.drgCodeOptions=t.data;n.drgCodeOptions.length==0&&(n.inpatientOutpatient="0",n.drgCodeOptions.push({Key:"",Value:"Not Available"}))},function(){alert("error")})};n.$watch("reasonTopicId",function(t,i){t!=i&&(n.results={},t!=""&&(n.fillPrimaryTreatments(t),n.fillComorbids(t),n.fillDrgs(t)))});n.$watch("reasonTopicTitle",function(t,i){t!=i&&(n.results={},n.primaryTreatments=[],n.drgCodeOptions=[])});n.$watch("primaryTreatment",function(t,i){t!=i&&(n.results={})});n.$watch("programType",function(t,i){t!=i&&(n.results={})});n.$watch("inpatientOutpatient",function(t,i){t!=i&&(n.results={});t==0&&(n.drgCode="",n.drgCodeType="",n.drgCodeDisplay="",n.drgCodeDescription="")});n.$watch("drgCode",function(t,i){t!=i&&(n.results={})});n.$watch("zipcode",function(t,i){t!=i&&(n.results={})});n.$watch("age",function(t,i){t!=i&&(n.results={})});n.$watch("results.costDistributionVM.length",function(n){Plotly&&(n&&n!=0||Plotly.purge("graph"))});n.topicSelected=function(t,i,r){n.reasonTopicId=t;n.reasonTopicTitle=i;n.reasonTopicUrl=r};n.drgCodeChanged=function(){};n.toggleComorbid=function(t,i){for(var r=0;r<n.comorbids.length;r++)if(n.comorbids[r].code==t){n.comorbids.splice(r,1);n.newComorbid={};n.results={};return}n.comorbids.push({code:t,display:i,medCodes:[]});n.results={}};n.comorbidGroupChecked=function(t){for(var i=0;i<n.comorbids.length;i++)if(n.comorbids[i].code==t)return!0;return!1};n.validateForm=function(){return n.reasonTopicId!=""&&n.primaryTreatment!=""&&n.programType!=""&&n.inpatientOutpatient!=""&&n.age&&(n.inpatientOutpatient!=1||n.drgCode)};n.calculateDistributions=function(){n.result={};n.validateForm()&&t({url:"/medicalcosts/CalculateCostDistributions/",method:"POST",data:{reasonDocumentId:n.reasonTopicId,primaryTreatmentGroupId:n.primaryTreatment,programType:n.programType,inpatientStay:n.inpatientOutpatient,inpatientDRG:n.drgCode,zipcode:n.zipcode,age:n.age,comorbidCode1:n.comorbids.length>0?n.comorbids[0].code:undefined,comorbidCode2:n.comorbids.length>1?n.comorbids[1].code:undefined,comorbidCode3:n.comorbids.length>2?n.comorbids[2].code:undefined}}).then(function(t){if(n.results=t.data,n.results.inpatientCostsAvg=0,n.inpatientOutpatient==1){var i=n.results.costDistributionVM.filter(function(n){return n.Description==="Inpatient Costs"})[0];n.results.inpatientCostsLow=i.Low;n.results.inpatientCostsAvg=i.Predicted;n.results.inpatientCostsHigh=i.High}n.createPlotlyGraph()},function(){alert("error")})};n.createPlotlyGraph=function(){n.validateForm()&&(n.plotlyData=[],t({url:"/medicalcosts/CalculateCostThroughTime/",method:"POST",data:{reasonDocumentId:n.reasonTopicId,primaryTreatmentGroupId:n.primaryTreatment,programType:n.programType,inpatientStay:n.inpatientOutpatient,inpatientDRG:n.drgCode,zipcode:n.zipcode,age:n.age,comorbidCode1:n.comorbids.length>0?n.comorbids[0].code:undefined,comorbidCode2:n.comorbids.length>1?n.comorbids[1].code:undefined,comorbidCode3:n.comorbids.length>2?n.comorbids[2].code:undefined}}).then(function(t){var i=[],r=[],u=[],f=[],e=[],o=[],s,h,c,l,a,v,y=0,p=0,w=0;t.data.forEach(function(t){t.Day===7?(s=t.OutpatientCost,l=t.RxCost):t.Day===364&&(c=t.OutpatientCost,v=t.RxCost);t.Day<=Math.ceil(n.results.DurationVM[0].Predicted)?(i.push(t.Day/7),r.push(t.Cost+n.results.inpatientCostsAvg),h=t.OutpatientCost,a=t.RxCost):(u.push(t.Day/7),f.push(t.Cost+n.results.inpatientCostsAvg))});e.push(i.pop());o.push(r.pop());var b=[{name:"Below Predicted Duration",type:"bar",x:i,y:r,marker:{color:"#1f77b4"},hoverlabel:{namelength:0}},{name:"Predicted Duration",type:"bar",x:e,y:o,marker:{color:"#2ca02c"},hoverlabel:{namelength:0}},{name:"Above Predicted Duration",type:"bar",x:u,y:f,marker:{color:"#ff7f0e"},hoverlabel:{namelength:0}}];n.results.costDistributionVM.map(function(n){return n.Description}).indexOf("Outpatient Costs")==-1&&(n.results.costDistributionVM.push({Description:"Outpatient Costs",Low:s,Predicted:h,High:c,Order:2}),n.results.costDistributionVM.push({Description:"Rx Costs",Low:l,Predicted:a,High:v,Order:3}),n.results.costDistributionVM.forEach(function(n){y+=n.Low;p+=n.Predicted;w+=n.High}),n.results.costDistributionVM.push({Description:"Total",Low:y,Predicted:p,High:w,Order:4}));Plotly.newPlot(graph,b,{margin:{t:0},xaxis:{title:"Length of Disability Leave (Weeks)",size:18},yaxis:{tickformat:"$,.0f",title:"Cumulative Medical Costs ($)",size:18}},{displayModeBar:!1,responsive:!0})},function(){alert("error")}))};n.cpbInit=function(){n.cpbResults=[]};n.$watch("cpbCode",function(i,r){i!==r&&t({url:"/medicalcosts/GetMedCostsForCode/",method:"POST",data:{code:i}}).then(function(t){t.data.Lower===0&&t.data.Upper===0&&(t.data.Units=null,t.data.Description="There is insufficient data to provide a cost estimate for this code");n.cpbResults.push(t.data);n.calculateTotals();n.CodeDisplay=""},function(){alert("error")})});n.removeCpbCode=function(t){var i=n.cpbResults.indexOf(t);n.cpbResults.splice(i,1);n.calculateTotals()};n.calculateTotals=function(){n.cpbResultTotals={Lower:0,Predicted:0,Upper:0};n.cpbResults.forEach(function(t){t.displayLower=Math.round(inRange(t.Lower*(t.Units||0),.001,1)?1:t.Lower*t.Units);t.displayPredicted=Math.round(inRange(t.Predicted*(t.Units||0),.001,1)?1:t.Predicted*t.Units);t.displayUpper=Math.round(inRange(t.Upper*(t.Units||0),.001,1)?1:t.Upper*t.Units);n.cpbResultTotals.Lower+=t.displayLower;n.cpbResultTotals.Predicted+=t.displayPredicted;n.cpbResultTotals.Upper+=t.displayUpper})}}function atmController(n){n.init=function(){n.code=null;n.codeType=null;n.codeDescription=null;n.codeDisplay=null;n.result={};n.$broadcast("pasInit");n.skipSplash!=!0&&($("#divSplash").show(),n.skipSplash=!0)};n.codeSelected=function(){$("#divSplash").fadeOut(function(){$("#divDive").fadeIn()})};n.openTreatmentView=function(){n.ActiveTab="Treatment"};n.openDrugView=function(){n.ActiveTab="Drugs"};n.validateForm=function(){return n.ActiveTab=="Treatment"&&this.CptCode!=""&&this.Phase!=""};n.codeChanged=function(){n.$broadcast("pasInit")}}function atmTreatmentController(n,t){n.init=function(){n.clearCptCode();n.phase="";n.result={};n.claimNumber="";n.OrderByArray=[""];n.alternativesReverse=!1;n.alternativesFilterDescription="";n.claimSubmittedResponse={}};n.$on("pasInit",function(){n.init()});n.clearCptCode=function(){n.cptCode="";n.cptCodeDisplay="";n.cptCodeDescription="";n.result={}};n.clearResults=function(){n.result={}};n.validateForm=function(){return n.cptCode!=""&&n.phase!=""};n.checkRecommendation=function(){n.result={};t({url:"/atm/CheckProcedureRecommendation/",method:"POST",data:{DiagnosisCode:n.$parent.$parent.$parent.code,DiagnosisCodeType:n.$parent.$parent.$parent.codeType,CptCode:n.cptCode,Phase:n.phase}}).then(function(t){n.result.procedure=n.cptCodeDisplay;n.result.diagnosis=n.$parent.$parent.$parent.codeDisplay;n.result.isRecommended=t.data.data.IsRecommended;t.data.data.IsRecommended==!0?(n.result.recommendationPrefix="a",n.result.recommendation="RECOMMENDED",n.result.recommendationClass="recommended",n.result.recommendationId=t.data.data.RecommendationId,n.result.procedureDetail=t.data.data.ProcedureDetail):(n.result.recommendationPrefix="",n.result.recommendation="NOT A RECOMMENDED",n.result.recommendationClass="notrecommended",n.result.alternatives=t.data.data.Alternatives)},function(){alert("error")})};n.submitClaimNumber=function(){t({url:"/atm/SubmitProcedureClaimNumber/",method:"POST",data:{claimNumber:n.claimNumber,diagnosisMedCode:n.$parent.$parent.$parent.code,diagnosisMedCodeType:n.$parent.$parent.$parent.codeType,phase:n.phase,cptCode:n.cptCode,recommendationId:n.result.recommendationId}}).then(function(t){n.claimSubmittedResponse.treatmentAuthCode=t.data.AuthCode;n.claimSubmittedResponse.submittedByName=t.data.SubmittedByName;n.claimSubmittedResponse.submittedDate=t.data.SubmittedDate;$("#pasTreatmentModal").modal("show")},function(){alert("error")})};n.atmPrint=function(){window.printData=JSON.stringify({claimNumber:n.claimNumber,authCode:n.claimSubmittedResponse.treatmentAuthCode,diagnosis:n.result.diagnosis,treatment:n.result.procedure,phase:n.phase,submittedBy:n.claimSubmittedResponse.submittedDate+" - "+n.claimSubmittedResponse.submittedByName});var t=window.open("/tool/atmprint","_blank")};n.alternativesSetOrderBy=function(t){n.alternativesReverse=n.OrderByArray[0]==t?!n.alternativesReverse:!1;switch(t){case"CptCode":n.OrderByArray=n.alternativesReverse?["-CptCode"]:["CptCode"];break;case"CptDescription":n.OrderByArray=n.alternativesReverse?["-CptDescription"]:["CptDescription"]}};n.alternativesFilters=function(){var t={};return n.alternativesFilterId!=""&&(t.CptCode=n.alternativesFilterId),n.alternativesFilterDescription!=""&&(t.CptDescription=n.alternativesFilterDescription),t};n.alternativeSelect=function(t,i){n.cptCode=t;n.cptCodeDescription=i;n.cptCodeDisplay=t+" "+i;n.checkRecommendation()};n.windowOpen=function(n,t){window.open(n,t)}}function atmDrugsController(n,t){n.init=function(){n.clearDrug();n.pasDrugPhase="acute";n.pasPainClassId="";n.painClasses=null;n.result={};n.OrderByArray=[""];n.reverse=!1;n.filter="";n.claimSubmittedResponse={}};n.$on("pasInit",function(){n.init()});n.getPainClasses=function(){n.painClasses=null;n.pasDrugPhase!=""&&n.pasDrugName!=""&&t({url:"/atm/GetPainClasses/",method:"POST",data:{Diagnosis:n.$parent.$parent.$parent.code,DiagnosisCodeType:n.$parent.$parent.$parent.codeType,DrugId:n.pasDrug.DrugId,Phase:n.pasDrugPhase}}).then(function(t){t.data.data.length==0?(n.painClasses=[{PainClassification:"Any Pain Classification",PainId:"0"}],n.pasPainClassId="0"):(n.painClasses=t.data.data,n.pasPainClassId="")},function(){n.painClasses=["error"]})};n.validateForm=function(){return n.pasDrugPhase!=""&&n.pasDrug!=""&&n.pasPainClassId!=""};n.checkRecommendation=function(){t({url:"/atm/CheckFormularyRecommendation/",method:"POST",data:{Diagnosis:n.$parent.$parent.$parent.code,DiagnosisCodeType:n.$parent.$parent.$parent.codeType,DrugId:n.pasDrug.DrugId,Phase:n.pasDrugPhase,PainClassId:n.pasPainClassId}}).then(function(t){n.result.drugId=t.data.data.DrugId;n.result.drugDescription=n.pasDrug.DrugName;n.result.diagnosis=n.$parent.$parent.$parent.codeDisplay;n.result.isRecommended=t.data.data.IsRecommended;t.data.data.IsRecommended==!0?(n.result.recommendationPrefix="a",n.result.recommendation="RECOMMENDED",n.result.recommendationClass="recommended"):(n.result.recommendationPrefix="",n.result.recommendation="NOT A RECOMMENDED",n.result.recommendationClass="notrecommended",n.result.alternatives=t.data.data.Alternatives)},function(){alert("error")})};n.submitClaimNumber=function(){t({url:"/atm/SubmitFormularyClaimNumber/",method:"POST",data:{claimNumber:n.claimNumber,diagnosisMedCode:n.$parent.$parent.$parent.code,diagnosisMedCodeType:n.$parent.$parent.$parent.codeType,drugId:n.result.drugId,drugName:n.pasDrugName,phase:n.pasDrugPhase,painClass:n.pasPainClassId,recommendationId:n.result.recommendationId}}).then(function(t){n.claimSubmittedResponse.formularyAuthCode=t.AuthCode;n.claimSubmittedResponse.submittedByName=t.SubmittedByName;n.claimSubmittedResponse.submittedDate=t.SubmittedDate;$("#pasDrugModal").modal("show")},function(){alert("error")})};n.clearDrug=function(){n.pasDrug="";n.pasDrugName=""};n.clearResults=function(){n.result={}};n.$watch(function(n){return n.pasDrug},function(){n.clearResults();n.getPainClasses()});n.atmPrint=function(){window.printData=JSON.stringify({claimNumber:n.claimNumber,authCode:n.claimSubmittedResponse.formularyAuthCode,diagnosis:n.result.diagnosis,drugName:n.pasDrugName,phase:n.pasDrugPhase,submittedBy:n.claimSubmittedResponse.submittedDate+" - "+n.claimSubmittedResponse.submittedByName});var t=window.open("/tool/atmprint","_blank")};n.SetOrderBy=function(t){n.reverse=n.OrderByArray[0]==t?!n.reverse:!1;switch(t){case"DrugId":n.OrderByArray=n.reverse?["-DrugId"]:["DrugId"];break;case"DrugName":n.OrderByArray=n.reverse?["-DrugName"]:["DrugName"]}};n.altFilters=function(){var t={};return n.filterDrugId!=""&&(t.DrugId=n.filterDrugId),n.filterDrugName!=""&&(t.DrugName=n.filterDrugName),t};n.alternativeSelect=function(t,i){n.pasDrugName=i;n.pasDrug.DrugName=i;n.pasDrug.DrugId=t;n.checkRecommendation()};n.windowOpen=function(n,t){window.open(n,t)}}function nyMasTreatmentController(n,t,r,u){function e(){n.countries||(n.countries=[{code:"ABW",name:"Aruba"},{code:"AFG",name:"Afghanistan"},{code:"AGO",name:"Angola"},{code:"AIA",name:"Anguilla"},{code:"ALA",name:"Aland Islands"},{code:"ALB",name:"Albania"},{code:"AND",name:"Andorra"},{code:"ANT",name:"Netherlands Antilles"},{code:"ARE",name:"United Arab Emirates"},{code:"ARG",name:"Argentina"},{code:"ARM",name:"Armenia"},{code:"ASM",name:"American Samoa"},{code:"ATA",name:"Antarctica"},{code:"ATF",name:"French Southern Terr"},{code:"ATG",name:"Antigua & Barbuda"},{code:"AUS",name:"Australia"},{code:"AUT",name:"Austria"},{code:"AZE",name:"Azerbaijan"},{code:"BDI",name:"Burundi"},{code:"BEL",name:"Belgium"},{code:"BEN",name:"Benin"},{code:"BES",name:"Caribbean Netherlands (Bonaire, Sint Eustatius, Saba)"},{code:"BFA",name:"Burkina Faso"},{code:"BGD",name:"Bangladesh"},{code:"BGR",name:"Bulgaria"},{code:"BHR",name:"Bahrain"},{code:"BHS",name:"Bahamas"},{code:"BIH",name:"Bosnia & Herzegovina"},{code:"BLM",name:"Saint Barthelemy"},{code:"BLR",name:"Belarus"},{code:"BLZ",name:"Belize"},{code:"BMU",name:"Bermuda"},{code:"BOL",name:"Bolivia"},{code:"BRA",name:"Brazil"},{code:"BRB",name:"Barbados"},{code:"BRN",name:"Brunei Darussalam"},{code:"BTN",name:"Bhutan"},{code:"BVT",name:"Bouvet Island"},{code:"BWA",name:"Botswana"},{code:"CAF",name:"Central African Republic"},{code:"CAN",name:"Canada"},{code:"CCK",name:"Cocos (Keeling) Islands"},{code:"CHE",name:"Switzerland"},{code:"CHL",name:"Chile"},{code:"CHN",name:"China"},{code:"CIV",name:"Côte D’Ivoire"},{code:"CMR",name:"Cameroon"},{code:"COD",name:"Democratic Republic Of Congo"},{code:"COG",name:"Congo"},{code:"COK",name:"Cook Islands"},{code:"COL",name:"Colombia"},{code:"COM",name:"Comoros"},{code:"CPV",name:"Cape Verde"},{code:"CRI",name:"Costa Rica"},{code:"CUB",name:"Cuba"},{code:"CUW",name:"Curacao"},{code:"CXR",name:"Christmas Island"},{code:"CYM",name:"Cayman Islands"},{code:"CYP",name:"Cyprus"},{code:"CZE",name:"Czech Republic"},{code:"DEU",name:"Germany"},{code:"DJI",name:"Djibouti"},{code:"DMA",name:"Dominica"},{code:"DNK",name:"Denmark"},{code:"DOM",name:"Dominican Republic"},{code:"DZA",name:"Algeria"},{code:"ECU",name:"Ecuador"},{code:"EGY",name:"Egypt"},{code:"ERI",name:"Eritrea"},{code:"ESH",name:"Western Sahara"},{code:"ESP",name:"Spain"},{code:"EST",name:"Estonia"},{code:"ETH",name:"Ethiopia"},{code:"FIN",name:"Finland"},{code:"FJI",name:"Fiji"},{code:"FLK",name:"Falkland Islands (Malvinas)"},{code:"FRA",name:"France"},{code:"FRO",name:"Faroe Islands"},{code:"FSM",name:"Micronesia (Federated States)"},{code:"FXX",name:"France, Metropolitan"},{code:"GAB",name:"Gabon"},{code:"GBR",name:"United Kingdom"},{code:"GEO",name:"Georgia"},{code:"GHA",name:"Ghana"},{code:"GIB",name:"Gibraltar"},{code:"GIN",name:"Guinea"},{code:"GLP",name:"Guadeloupe"},{code:"GMB",name:"Gambia"},{code:"GNB",name:"Guinea-Bissau"},{code:"GNQ",name:"Equatorial Guinea"},{code:"GRC",name:"Greece"},{code:"GRD",name:"Grenada"},{code:"GRL",name:"Greenland"},{code:"GTM",name:"Guatemala"},{code:"GUE",name:"Guernsey"},{code:"GUF",name:"French Guiana"},{code:"GUM",name:"Guam"},{code:"GUY",name:"Guyana"},{code:"HKG",name:"Hong Kong"},{code:"HMD",name:"Heard Island & Mcdonald Islands"},{code:"HND",name:"Honduras"},{code:"HRV",name:"Croatia"},{code:"HTI",name:"Haiti"},{code:"HUN",name:"Hungary"},{code:"IDN",name:"Indonesia"},{code:"IMN",name:"Isle Of Man"},{code:"IND",name:"India"},{code:"IOT",name:"British Indian Ocean"},{code:"IRL",name:"Ireland"},{code:"IRN",name:"Iran (Islamic Republic)"},{code:"IRQ",name:"Iraq"},{code:"ISL",name:"Iceland"},{code:"ISR",name:"Israel"},{code:"ITA",name:"Italy"},{code:"JAM",name:"Jamaica"},{code:"JEY",name:"Jersey"},{code:"JOR",name:"Jordan"},{code:"JPN",name:"Japan"},{code:"KAZ",name:"Kazakhstan"},{code:"KEN",name:"Kenya"},{code:"KGZ",name:"Kyrgyzstan"},{code:"KHM",name:"Cambodia"},{code:"KIR",name:"Kiribati"},{code:"KNA",name:"Saint Kitts & Nevis"},{code:"KOR",name:"Korea, Republic Of"},{code:"KWT",name:"Kuwait"},{code:"LAO",name:"Lao Peoples Democrat"},{code:"LBN",name:"Lebanon"},{code:"LBR",name:"Liberia"},{code:"LBY",name:"Libyan Arab Jamahiri"},{code:"LCA",name:"Saint Lucia"},{code:"LIE",name:"Liechtenstein"},{code:"LKA",name:"Sri Lanka"},{code:"LSO",name:"Lesotho"},{code:"LTU",name:"Lithuania"},{code:"LUX",name:"Luxembourg"},{code:"LVA",name:"Latvia"},{code:"MAC",name:"Macau"},{code:"MAF",name:"Saint Martin (French part)"},{code:"MAR",name:"Morocco"},{code:"MCO",name:"Monaco"},{code:"MDA",name:"Moldova, Republic Of"},{code:"MDG",name:"Madagascar"},{code:"MDV",name:"Maldives"},{code:"MEX",name:"Mexico"},{code:"MHL",name:"Marshall Islands"},{code:"MLI",name:"Mali"},{code:"MLT",name:"Malta"},{code:"MMR",name:"Myanmar"},{code:"MNE",name:"Montenegro"},{code:"MNG",name:"Mongolia"},{code:"MNP",name:"Northern Mariana Islands"},{code:"MOZ",name:"Mozambique"},{code:"MRT",name:"Mauritania"},{code:"MSR",name:"Montserrat"},{code:"MTQ",name:"Martinique"},{code:"MUS",name:"Mauritius"},{code:"MWI",name:"Malawi"},{code:"MYS",name:"Malaysia"},{code:"MYT",name:"Mayotte"},{code:"NAM",name:"Namibia"},{code:"NCL",name:"New Caledonia"},{code:"NER",name:"Niger"},{code:"NFK",name:"Norfolk Island"},{code:"NGA",name:"Nigeria"},{code:"NIC",name:"Nicaragua"},{code:"NIU",name:"Niue"},{code:"NLD",name:"Netherlands"},{code:"NOR",name:"Norway"},{code:"NPL",name:"Nepal"},{code:"NRU",name:"Nauru"},{code:"NZL",name:"New Zealand"},{code:"OMN",name:"Oman"},{code:"PAK",name:"Pakistan"},{code:"PAN",name:"Panama"},{code:"PCN",name:"Pitcairn"},{code:"PER",name:"Peru"},{code:"PHL",name:"Philippines"},{code:"PLW",name:"Palau"},{code:"PNG",name:"Papua New Guinea"},{code:"POL",name:"Poland"},{code:"PRI",name:"Puerto Rico"},{code:"PRK",name:"Korea, Democratic People's Republic"},{code:"PRT",name:"Portugal"},{code:"PRY",name:"Paraguay"},{code:"PSE",name:"Occupied Palestine"},{code:"PYF",name:"French Polynesia"},{code:"QAT",name:"Qatar"},{code:"REU",name:"Réunion"},{code:"ROM",name:"Romania"},{code:"RUS",name:"Russian Federation"},{code:"RWA",name:"Rwanda"},{code:"SAU",name:"Saudi Arabia"},{code:"SCG",name:"Serbia"},{code:"SDN",name:"Sudan"},{code:"SEN",name:"Senegal"},{code:"SGP",name:"Singapore"},{code:"SGS",name:"South Georgia and the South Sandwich Islands"},{code:"SHN",name:"Saint Helena"},{code:"SJM",name:"Svalbard & Jan Mayen"},{code:"SLB",name:"Solomon Islands"},{code:"SLE",name:"Sierra Leone"},{code:"SLV",name:"El Salvador"},{code:"SMR",name:"San Marino"},{code:"SOM",name:"Somalia"},{code:"SPM",name:"Saint Pierre & Miquelon"},{code:"SSD",name:"South Sudan"},{code:"STP",name:"Sao Tome & Principe"},{code:"SUR",name:"Suriname"},{code:"SVK",name:"Slovakia"},{code:"SVN",name:"Slovenia"},{code:"SWE",name:"Sweden"},{code:"SWZ",name:"Swaziland"},{code:"SXM",name:"Saint Maarten"},{code:"SYC",name:"Seychelles"},{code:"SYR",name:"Syrian Arab Republic"},{code:"TCA",name:"Turks & Caicos Islands"},{code:"TCD",name:"Chad"},{code:"TGO",name:"Togo"},{code:"THA",name:"Thailand"},{code:"TJK",name:"Tajikistan"},{code:"TKL",name:"Tokelau"},{code:"TKM",name:"Turkmenistan"},{code:"TMP",name:"East Timor"},{code:"TON",name:"Tonga"},{code:"TTO",name:"Trinidad & Tobago"},{code:"TUN",name:"Tunisia"},{code:"TUR",name:"Turkey"},{code:"TUV",name:"Tuvalu"},{code:"TWN",name:"Taiwan, Province Of"},{code:"TZA",name:"Tanzania, United Republic of"},{code:"UGA",name:"Uganda"},{code:"UKR",name:"Ukraine"},{code:"UMI",name:"United States Minor Outlying Islands"},{code:"URY",name:"Uruguay"},{code:"USA",name:"United States"},{code:"UZB",name:"Uzbekistan"},{code:"VAT",name:"Vatican City (Holy See)"},{code:"VCT",name:"Saint Vincent & The Grenadines"},{code:"VEN",name:"Venezuela"},{code:"VGB",name:"Virgin Islands (British)"},{code:"VIR",name:"Virgin Islands (U.S.)"},{code:"VNM",name:"Viet Nam"},{code:"VUT",name:"Vanuatu"},{code:"WLF",name:"Wallis & Futuna Islands"},{code:"WSM",name:"Samoa"},{code:"YEM",name:"Yemen"},{code:"YUG",name:"Yugoslavia"},{code:"ZAF",name:"South Africa"},{code:"ZAR",name:"Zaire"},{code:"ZMB",name:"Zambia"},{code:"ZWE",name:"Zimbabwe"}],n.states=[{code:"AL",name:"Alabama"},{code:"AK",name:"Alaska"},{code:"AS",name:"American Samoa"},{code:"AZ",name:"Arizona"},{code:"AR",name:"Arkansas"},{code:"CA",name:"California"},{code:"CO",name:"Colorado"},{code:"CT",name:"Connecticut"},{code:"DE",name:"Delaware"},{code:"DC",name:"District Of Columbia"},{code:"FM",name:"Federated States Of Micronesia"},{code:"FL",name:"Florida"},{code:"GA",name:"Georgia"},{code:"GU",name:"Guam"},{code:"HI",name:"Hawaii"},{code:"ID",name:"Idaho"},{code:"IL",name:"Illinois"},{code:"IN",name:"Indiana"},{code:"IA",name:"Iowa"},{code:"KS",name:"Kansas"},{code:"KY",name:"Kentucky"},{code:"LA",name:"Louisiana"},{code:"ME",name:"Maine"},{code:"MH",name:"Marshall Islands"},{code:"MD",name:"Maryland"},{code:"MA",name:"Massachusetts"},{code:"MI",name:"Michigan"},{code:"MN",name:"Minnesota"},{code:"MS",name:"Mississippi"},{code:"MO",name:"Missouri"},{code:"MT",name:"Montana"},{code:"NE",name:"Nebraska"},{code:"NV",name:"Nevada"},{code:"NH",name:"New Hampshire"},{code:"NJ",name:"New Jersey"},{code:"NM",name:"New Mexico"},{code:"NY",name:"New York"},{code:"NC",name:"North Carolina"},{code:"ND",name:"North Dakota"},{code:"MP",name:"Northern Mariana Islands"},{code:"OH",name:"Ohio"},{code:"OK",name:"Oklahoma"},{code:"OR",name:"Oregon"},{code:"PW",name:"Palau"},{code:"PA",name:"Pennsylvania"},{code:"PR",name:"Puerto Rico"},{code:"RI",name:"Rhode Island"},{code:"SC",name:"South Carolina"},{code:"SD",name:"South Dakota"},{code:"TN",name:"Tennessee"},{code:"TX",name:"Texas"},{code:"UT",name:"Utah"},{code:"VT",name:"Vermont"},{code:"VI",name:"Virgin Islands"},{code:"VA",name:"Virginia"},{code:"WA",name:"Washington"},{code:"WV",name:"West Virginia"},{code:"WI",name:"Wisconsin"},{code:"WY",name:"Wyoming"}])}function f(n){var t=n.getDate(),i=n.getMonth()+1,r=n.getFullYear();return t<10&&(t="0"+t),i<10&&(i="0"+i),i+"/"+t+"/"+r}function o(n){return n.length<=4?n:n.substring(n.length-4)}n.datePickerOpen={searchDateInjury:!1,searchDateBirth:!1};n.init=function(){n.code=null;n.codeType=null;n.codeDescription=null;n.codeDisplay=null;n.currentView="treatmentSearch";n.caseFound=!1;e();n.lastSessionRequest=Date.now();n.interval=setInterval(n.checkTimeout,5e3);n.init2();u.scrollTo(0,0)};n.init2=function(){n.currentView="treatmentSearch";n.caseFound=!1;n.lastSessionRequest=Date.now();n.clearCptCode();n.phase="";n.result={};n.claimNumber="";n.OrderByArray=[""];n.alternativesReverse=!1;n.alternativesFilterDescription="";n.claimSubmittedResponse={};n.formDownloaded=!1;n.caseSearch={caseNumber:"",claimNumber:"",dateInjury:"",ssn:"",dateBirth:"",lastName:""};n.masks={shortUs:"99999-9?9?9?9?",longUs:"99999-9999",international:"@@@@@"};n.claimantZipMask=n.masks.shortUs;n.employerZipMask=n.masks.shortUs;u.scrollTo(0,0)};n.GetZipMask=function(t,i){return t!="USA"?n.masks.international:i.length<=5?n.masks.shortUs:n.masks.longUs};n.clearClaimantState=function(){n.case.ClaimantState=""};n.setClaimantZipMask=function(){n.claimantZipMask=n.GetZipMask(n.case.ClaimantCtryCd,n.case.ClaimantZip)};n.claimantCountryChanged=function(){n.clearClaimantState()};n.clearEmployerState=function(){n.case.EmployerState=""};n.setEmployerZipMask=function(){n.employerZipMask=n.GetZipMask(n.case.EmployerCountry,n.case.EmployerZip)};n.employerCountryChanged=function(){n.clearEmployerState()};n.codeChanged=function(){n.init2()};n.$on("masInit",function(){n.init()});n.clearCptCode=function(){n.cptCode="";n.cptCodeDisplay="";n.cptCodeDescription="";n.result={}};n.clearResults=function(){n.result={};n.caseSearch={};n.case={};n.currentView="treatmentSearch";n.caseFound=!1;n.mtgCaseEntryForm.$setUntouched()};n.validateForm=function(){return n.cptCode!=""&&n.phase!=""};n.validateCaseSearchForm=function(){if(!n.caseSearch.caseNumber&&!n.caseSearch.claimNumber)return!1;var t=0;return(n.caseSearch.dateInjury&&t++,n.caseSearch.ssn&&t++,n.caseSearch.dateBirth&&t++,n.caseSearch.lastName&&t++,t<2)?!1:!0};n.validateCaseEntryForm=function(){if(!n.case)return!1;var t=n.case.ClaimantFirstName&&n.case.ClaimantLastName&&n.case.ClaimantGender&&n.case.ClaimantDOB&&n.case.ClaimantAddr1&&n.case.ClaimantCity&&n.case.ClaimantState&&n.case.ClaimantZip&&n.case.ClaimantCtryCd&&n.case.EmployerName1&&n.case.EmployerAddress1&&n.case.EmployerCity&&n.case.EmployerState&&n.case.EmployerZip&&n.case.EmployerCountry&&n.case.InjuryDate&&n.case.InjuryIllness;return n.case.ClaimantSSN&&n.case.ClaimantSSN.length!=4&&(t=!1),n.case.ClaimantPhone&&n.case.ClaimantPhone.length!=12&&(t=!1),n.case.EmployerPhone&&n.case.EmployerPhone.length!=12&&(t=!1),t};n.checkRecommendation=function(){n.result={};t({url:"/ny/mas/CheckProcedureRecommendation/",method:"POST",data:{DiagnosisCode:n.code,DiagnosisCodeType:n.codeType,CptCode:n.cptCode,Phase:n.phase}}).then(function(t){n.result.procedure=n.cptCodeDisplay;n.result.diagnosis=n.codeDisplay;n.result.isRecommended=t.data.data.IsRecommended;t.data.data.IsRecommended==!0?(n.result.recommendationPrefix="a",n.result.recommendation="RECOMMENDED",n.result.recommendationClass="recommended",n.result.recommendationId=t.data.data.RecommendationId,n.result.procedureDetail=t.data.data.ProcedureDetail):(n.result.recommendationPrefix="",n.result.recommendation="NOT A RECOMMENDED",n.result.recommendationClass="notrecommended",n.result.alternatives=t.data.data.Alternatives);n.lastSessionRequest=Date.now()},function(){alert("error");n.lastSessionRequest=Date.now()})};n.openDatePicker=function(t,i){t.preventDefault();t.stopPropagation();switch(i){case"searchDateInjury":n.datePickerOpen.searchDateInjury=!n.datePickerOpen.searchDateInjury;break;case"searchDateBirth":n.datePickerOpen.searchDateBirth=!n.datePickerOpen.searchDateBirth;break;case"ClaimantDOB":n.datePickerOpen.ClaimantDOB=!n.datePickerOpen.ClaimantDOB;break;case"InjuryDate":n.datePickerOpen.InjuryDate=!n.datePickerOpen.InjuryDate}};n.openCaseSearch=function(){n.caseSearch={caseNumber:"",claimNumber:"",dateInjury:"",ssn:"",dateBirth:"",lastName:""};n.currentView="caseSearch";n.caseFound=!1;u.scrollTo(0,0)};n.openCaseEntry=function(){n.currentView="caseEntry";n.caseFound=!1;n.case.ClaimantCtryCd||(n.case.ClaimantCtryCd="USA");n.case.EmployerCountry||(n.case.EmployerCountry="USA");u.scrollTo(0,0)};n.openCaseConfirm=function(){n.currentView="caseConfirm";u.scrollTo(0,0)};n.searchCase=function(){n.caseSearch.dateInjury&&(n.caseSearch.dateInjury=f(n.caseSearch.dateInjury));n.caseSearch.dateBirth&&(n.caseSearch.dateBirth=f(n.caseSearch.dateBirth));t({url:"/ny/mas/SearchCase/",method:"POST",data:n.caseSearch}).then(function(t){if(t.status==200&&t.data&&t.data[0]){var i=t.data[0];if(i.CaseClosed.toLowerCase()==="y"){$("#mtgCaseClosedModal").modal("show");return}n.case=i;n.case.ClaimantSSN=o(n.case.ClaimantSSN);n.caseFound=!0;n.openCaseConfirm()}else $("#mtgNoCaseFoundModal").modal("show");n.lastSessionRequest=Date.now()},function(){$("#mtgNoCaseFoundModal").modal("show");n.lastSessionRequest=Date.now()})};n.downloadForm=function(){var r={},u="";for(i=0;i<n.case.AncrOdncr.length;i++)u+="|"+n.case.AncrOdncr[i].AddText;u.length>0&&(u=u.substring(1));r.claimaintName=(n.case.ClaimantFirstName+" "+n.caseClaimantMidName.substring(0,1)+" "+n.case.ClaimantLastName+" "+n.case.ClaimantTitle).trim();r.caseNumber=n.case.CaseID;r.dateOfInjury=n.case.InjuryDate;r.dateOfBirth=n.case.ClaimantDOB;r.claimantAddress=n.case.ClaimantAddr1+" "+n.case.ClaimantAddr2+" "+n.case.ClaimantCity+", "+n.case.ClaimantState+" "+n.case.ClaimantZip;r.employerName=(n.case.EmployerName1+" "+n.case.EmployerName2).trim();r.employerAddress=n.case.EmployerAddress1+" "+n.case.EmployerAddress2+" "+n.case.EmployerCity+", "+n.case.EmployerState+" "+n.case.EmployerZip;r.insurerName=(n.case.CarrierName1+" "+n.case.CarrierName2).trim();r.insurerId=n.case.CarrierNumber;r.claimAdminName=(n.case.ClaimAdminName1+" "+n.case.ClaimAdminName2).trim();r.claimAdminId=n.case.ClaimAdminNumber;r.diagnosis=n.result.diagnosis;r.treatment=n.result.procedure;r.confirmationCode=n.claimSubmittedResponse.treatmentAuthCode;r.ancr=u;r.descriptionOfInjury=n.case.InjuryDescription;r.claimNumber=n.case.CarrierCaseID;t({url:"/ny/mas/DownloadForm/",method:"POST",data:r,responseType:"blob"}).then(function(t){var r,f,e;headers=t.headers();var u=headers["x-filename"],o=headers["content-type"],i=document.createElement("a");try{r=new Blob([t.data],{type:o});f=window.URL.createObjectURL(r);typeof i.download!="undefined"?(i.setAttribute("href",f),i.setAttribute("download",u),e=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1}),i.dispatchEvent(e)):navigator.msSaveBlob(r,u)}catch(s){console.log(s)}n.formDownloaded=!0;n.lastSessionRequest=Date.now()},function(){n.lastSessionRequest=Date.now()})};n.confirmCase=function(){n.submitClaimNumber()};n.unconfirmCase=function(){n.caseFound?(n.case={},n.openCaseSearch()):n.openCaseEntry()};n.atmPrint=function(){window.printData=JSON.stringify({claimNumber:n.claimNumber,authCode:n.claimSubmittedResponse.treatmentAuthCode,diagnosis:n.result.diagnosis,treatment:n.result.procedure,phase:n.phase,submittedBy:n.claimSubmittedResponse.submittedDate+" - "+n.claimSubmittedResponse.submittedByName});var t=window.open("/tool/atmprint","_blank")};n.alternativesSetOrderBy=function(t){n.alternativesReverse=n.OrderByArray[0]==t?!n.alternativesReverse:!1;switch(t){case"CptCode":n.OrderByArray=n.alternativesReverse?["-CptCode"]:["CptCode"];break;case"CptDescription":n.OrderByArray=n.alternativesReverse?["-CptDescription"]:["CptDescription"]}};n.alternativesFilters=function(){var t={};return n.alternativesFilterId!=""&&(t.CptCode=n.alternativesFilterId),n.alternativesFilterDescription!=""&&(t.CptDescription=n.alternativesFilterDescription),t};n.alternativeSelect=function(t,i){n.cptCode=t;n.cptCodeDescription=i;n.cptCodeDisplay=t+" "+i;n.checkRecommendation()};n.windowOpen=function(n,t){window.open(n,t)};n.submitClaimNumber=function(){t({url:"/ny/mas/SubmitProcedureClaimNumber/",method:"POST",data:{caseId:n.case.CaseID,claimNumber:n.case.CarrierCaseID,claimantFirstName:n.case.ClaimantFirstName,claimantMidName:n.case.ClaimantMidName,claimantLastName:n.case.ClaimantLastName,claimantTitle:n.case.ClaimantTitle,dateOfInjury:n.case.InjuryDate,claimantDateOfBirth:n.case.ClaimantDOB,claimantAddress1:n.case.ClaimantAddr1,claimantAddress2:n.case.ClaimantAddr2,claimantCity:n.case.ClaimantCity,claimantState:n.case.ClaimantState,claimantZip:n.case.ClaimantZip,claimantCountry:n.case.ClaimantCtryCd,employerName1:n.case.EmployerName1,employerName2:n.case.EmployerName2,employerAddress1:n.case.EmployerAddress1,employerAddress2:n.case.EmployerAddress2,employerCity:n.case.EmployerCity,employerState:n.case.EmployerState,employerZip:n.case.EmployerZip,employerCountry:n.case.EmployerCountry,carrierName1:n.case.CarrierName1,carrierName2:n.case.CarrierName2,carrierNumber:n.case.CarrierNumber,claimAdminName1:n.case.ClaimAdminName1,claimAdminName2:n.case.ClaimAdminName2,claimAdminNumber:n.case.ClaimAdminNumber,diagnosisCode:n.code,diagnosisMedCodeType:n.codeType,treatmentCode:n.cptCode}}).then(function(t){n.claimSubmittedResponse.treatmentAuthCode=t.data.ConfirmationCode;n.claimSubmittedResponse.submittedByName=t.data.SubmittedByName;n.claimSubmittedResponse.submittedDate=t.data.SubmittedDate;t.data.UploadSuccessful?$("#mtgTreatmentModal").modal("show"):$("#mtgUploadFailedModal").modal("show");n.lastSessionRequest=Date.now()},function(){alert("error");n.lastSessionRequest=Date.now()})};n.startOver=function(){$("#mtgTreatmentModal").modal("hide");n.init()};n.checkTimeout=function(){var t=Date.now()-n.lastSessionRequest;t>12e5&&(clearInterval(n.interval),$("#mtgSessionExpiredModal").modal("show"))};n.goHome=function(){window.location.replace("/")}}function nyMasDrugsController(n,t){n.init=function(){n.categoryId=null;n.results=[];t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"NyFormularyOpen"}}).then({},{})};n.categoryChanged=function(){n.mtgDrugName="";n.clearResults();t({url:"/ny/mas/GetDrugsByCategory/",method:"POST",data:{categoryId:n.categoryId}}).then(function(t){n.results=t.data},function(){alert("error")});var i=[];i.push({DetailKey:"CategoryId",DetailValue:n.categoryId});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"NyFormularySearchByCategory",eventDetails:i}}).then({},{})};n.clearDrug=function(){n.mtgDrug="";n.mtgDrugName=""};n.clearResults=function(){n.results=[]};n.$watch(function(){return n.mtgDrug},function(){if(n.categoryId=null,n.clearResults(),n.mtgDrugName){t({url:"/ny/mas/GetDrugByGenericName",method:"POST",data:{name:n.mtgDrugName}}).then(function(t){n.results=t.data},function(){alert("error")});var i=[];i.push({DetailKey:"DrugName",DetailValue:n.mtgDrugName});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"NyFormularySearchByName",eventDetails:i}}).then({},{})}})}function nyMtgController(n,t,i){n.init=function(){n.ClearCondition();n.ClearTreatment();n.showDebug=getQueryVariable("debug");t({url:"/ny/GetGuidelines",method:"POST",data:{}}).then(function(t){n.Guidelines=t.data})};n.ConfirmPublish=function(){t({url:"/ny/PublishMtg",method:"POST"}).then(function(){n.PublishMessage="Publish successful";n.PublishMessageType="success"},function(){n.PublishMessage="Publish failed";n.PublishMessageType="danger"})};n.ClearTreatment=function(){n.ActiveTreatment={Id:null,Name:"",Synonyms:[]};n.ModifiedTreatment={Id:null,Name:"",Synonyms:[]};n.editTreatmentMessage=null};n.ModifiedTreatmentIsValid=function(){var t=!0;return n.editTreatmentMessage="",n.ModifiedTreatment&&n.ActiveTreatment?n.ModifiedTreatment&&n.ActiveTreatment&&angular.equals(n.ActiveTreatment,n.ModifiedTreatment)?t=!1:(n.ModifiedTreatment.Name.trim()===""&&(t=!1,n.ModifiedTreatment.InvalidName="Required"),n.ModifiedTreatment.Synonyms&&n.ModifiedCondition.Synonyms.filter(function(n){return n.Invalid}).length>0&&(t=!1,n.editTreatmentMessage="Form is invalid",n.editTreatmentMessageType="danger"),n.ModifiedTreatment.InvalidName&&(t=!1)):t=!1,t};n.CheckDuplicateTreatment=function(i,r,u){t({url:"/ny/GetTreatments",method:"POST",data:{nameOrSynonym:i}}).then(function(t){t.data.length>0&&t.data[0].TreatmentId!==n.ModifiedTreatment.Id?r():u()})};n.TreatmentSynonymKeyup=function(t,r){setTimeout(function(){n.ModifiedTreatment.Synonyms[t].Text===r&&i("filter")(n.ActiveTreatment.Synonyms,{Text:r},!0).length===0&&n.CheckDuplicateTreatment(r,function(){n.ModifiedTreatment.Synonyms[t].Invalid="Already exists"},function(){n.ModifiedTreatment.Synonyms[t].Invalid=null})},300)};n.SetTreatment=function(i){i&&(n.ActiveTreatment.Id=i);n.ActiveTreatment.Id&&(t({url:"/ny/GetTreatments",method:"POST",data:{id:n.ActiveTreatment.Id}}).then(function(t){n.ActiveTreatment.Name=t.data[0].TreatmentName;n.ActiveTreatment.Synonyms=t.data[0].TreatmentSynonyms.split(",").map(function(n){return{Text:n}});n.ActiveTreatment.ModifiedById=t.data[0].ModifiedById;n.ActiveTreatment.LastModified=t.data[0].LastModified.slice(6,-2);n.ActiveTreatment.ModifiedByName=t.data[0].ModifiedByName;n.editTreatmentMessage=null;n.ModifiedTreatment=angular.copy(n.ActiveTreatment)},function(n){console.log(n)}),n.GetTreatmentRecommendations(n.ActiveTreatment.Id))};n.GetTreatmentRecommendations=function(i){t({url:"/ny/GetRecommendations",method:"POST",data:{treatmentId:i}}).then(function(t){n.ActiveTreatment.Recommendations=t.data})};n.$watch("ActiveTreatment",function(t,i){n.editTreatmentMessage="";n.editTreatmentmessageType="";t.Id!==i.Id&&n.GetActiveRec()},!0);n.$watch("ModifiedTreatment.Name",function(t){t&&t.trim()!==""&&t!==n.ActiveTreatment.Name&&n.CheckDuplicateTreatment(t,function(){n.ModifiedTreatment.InvalidName="Already exists"},function(){n.ModifiedTreatment.InvalidName=null})});n.SaveTreatment=function(){if(n.ModifiedTreatmentIsValid()){var i=n.ModifiedTreatment.Synonyms.map(function(n){return n.Text}).filter(function(n){return n}).join(",");t({url:"/ny/EditTreatment",method:"POST",data:{treatmentName:n.ModifiedTreatment.Name,treatmentSynonyms:i,treatmentId:n.ModifiedTreatment.Id}}).then(function(t){$("#editTreatmentModal").modal("hide");n.ActiveTreatment.Id=t.data.TreatmentId;n.ActiveTreatment.Name=t.data.TreatmentName;n.ActiveTreatment.Synonyms=t.data.TreatmentSynonyms.split(",").map(function(n){return{Text:n}});n.ActiveTreatment.ModifiedById=t.data.ModifiedById;n.ActiveTreatment.ModifiedByName=t.data.ModifiedByName;n.ActiveTreatment.LastModified=t.data.LastModified.slice(6,-2);n.pageMessage="Treatment "+n.ActiveTreatment.Name+" saved.";n.pageMessageType="success";n.ModifiedTreatment=angular.copy(n.ActiveTreatment)},function(t){n.editTreatmentMessage="Treatment "+n.ActiveTreatment.Name+" not saved.";n.editTreatmentMessageType="danger";console.log(t)})}};n.ConfirmDeleteTreatment=function(){t({url:"/ny/DeleteTreatment",method:"POST",data:{treatmentId:n.ActiveTreatment.Id}}).then(function(){n.pageMessage="Treatment "+n.ActiveTreatment.Name+" deleted.";n.pageMessageType="Success";n.ClearTreatment();$("#deleteTreatmentModal").modal("hide")},function(t){n.deleteTreatmentMessage="Treatment "+n.ActiveTreatment.Name+" not deleted.";n.deleteTreatmentMessageType="Warning";console.log(t)})};n.ClearCondition=function(){n.ActiveCondition={Id:null,Name:"",Synonyms:[]};n.ModifiedCondition={Id:null,Name:"",Synonyms:[]};n.editConditionMessage=null};n.ModifiedConditionIsValid=function(){var t=!0;return n.editConditionMessage="",n.ModifiedCondition&&n.ActiveCondition?n.ModifiedCondition&&n.ActiveCondition&&angular.equals(n.ModifiedCondition,n.ActiveCondition)?t=!1:(n.ModifiedCondition.Name.trim()===""&&(t=!1,n.ModifiedCondition.InvalidName="Required"),n.ModifiedCondition.Synonyms&&n.ModifiedCondition.Synonyms.filter(function(n){return n.Invalid}).length>0&&(t=!1,n.editConditionMessage="Form is invalid",n.editConditionMessageType="danger"),n.ModifiedCondition.InvalidName&&(t=!1)):t=!1,t};n.CheckDuplicateCondition=function(i,r,u){t({url:"/ny/GetConditions",method:"POST",data:{nameOrSynonym:i}}).then(function(t){t.data.length>0&&t.data[0].ConditionId!==n.ModifiedCondition.Id?r():u()})};n.ConditionSynonymKeyup=function(t,r){setTimeout(function(){n.ModifiedCondition.Synonyms[t].Text===r&&i("filter")(n.ActiveCondition.Synonyms,{Text:r},!0).length===0&&n.CheckDuplicateCondition(r,function(){n.ModifiedCondition.Synonyms[t].Invalid="Already exists"},function(){n.ModifiedCondition.Synonyms[t].Invalid=null})},300)};n.SetCondition=function(i){i&&(n.ActiveCondition.Id=i);n.ActiveCondition.Id&&(t({url:"/ny/GetConditions",method:"POST",data:{id:n.ActiveCondition.Id}}).then(function(t){n.ActiveCondition.Name=t.data[0].ConditionName;n.ActiveCondition.Synonyms=t.data[0].ConditionSynonyms.split(",").map(function(n){return{Text:n}});n.ActiveCondition.ModifiedById=t.data[0].ModifiedById;n.ActiveCondition.LastModified=t.data[0].LastModified.slice(6,-2);n.ActiveCondition.ModifiedByName=t.data[0].ModifiedByName;n.editConditionMessage=null;n.ModifiedCondition=angular.copy(n.ActiveCondition)},function(n){console.log(n)}),n.GetConditionRecommendations(n.ActiveCondition.Id))};n.GetConditionRecommendations=function(i){t({url:"/ny/GetRecommendations",method:"POST",data:{conditionId:i}}).then(function(t){n.ActiveCondition.Recommendations=t.data})};n.$watch("ActiveCondition",function(t,i){n.editConditionMessage="";n.editConditionmessageType="";t.Id!==i.Id&&n.GetActiveRec()},!0);n.$watch("ModifiedCondition.Name",function(t){t&&t.trim()!==""&&t!==n.ActiveCondition.Name&&n.CheckDuplicateCondition(t,function(){n.ModifiedCondition.InvalidName="Already exists"},function(){n.ModifiedCondition.InvalidName=null})});n.SaveCondition=function(){if(n.ModifiedConditionIsValid()){var i=n.ModifiedCondition.Synonyms.map(function(n){return n.Text}).join(",");t({url:"/ny/EditCondition",method:"POST",data:{conditionName:n.ModifiedCondition.Name,conditionSynonyms:i,conditionId:n.ModifiedCondition.Id}}).then(function(t){$("#editConditionModal").modal("hide");n.ActiveCondition.Id=t.data.ConditionId;n.ActiveCondition.Name=t.data.ConditionName;n.ActiveCondition.Synonyms=t.data.ConditionSynonyms.split(",").map(function(n){return{Text:n}});n.ActiveCondition.ModifiedById=t.data.ModifiedById;n.ActiveCondition.ModifiedByName=t.data.ModifiedByName;n.ActiveCondition.LastModified=t.data.LastModified.slice(6,-2);n.pageMessage="Condition "+n.ActiveCondition.Name+" saved.";n.pageMessageType="success";n.ModifiedCondition=angular.copy(n.ActiveCondition)},function(t){n.editConditionMessage="Condition "+n.ActiveCondition.Name+" not saved.";n.editConditionMessageType="danger";console.log(t)})}};n.ConfirmDeleteCondition=function(){t({url:"/ny/DeleteCondition",method:"POST",data:{conditionId:n.ActiveCondition.Id}}).then(function(){n.pageMessage="Condition "+n.ActiveCondition.Name+" deleted.";n.pageMessageType="Success";n.ClearCondition();$("#deleteConditionModal").modal("hide")},function(t){n.deleteConditionMessage="Condition "+n.ActiveCondition.Name+" not deleted.";n.deleteConditionMessageType="Warning";console.log(t)})};n.GetActiveRec=function(){n.ActiveCondition.Id&&n.ActiveTreatment.Id&&t({url:"/ny/GetRecommendations",method:"POST",data:{conditionId:n.ActiveCondition.Id,treatmentId:n.ActiveTreatment.Id}}).then(function(t){n.ActiveRec={};t.data.length>0&&(n.ActiveRec.Id=t.data[0].RecommendationId,n.ActiveRec.TypeId=t.data[0].RecommendationTypeId,n.ActiveRec.Guideline=n.Guidelines.filter(function(n){return n.GuidelineId===t.data[0].GuidelineId})[0],n.ActiveRec.GuidelineId=t.data[0].GuidelineId,n.ActiveRec.Link=t.data[0].Link)},function(){})};n.SaveRec=function(){n.pageMessage="";n.ActiveRec.Id?t({url:"/ny/EditRecommendation",method:"POST",data:{recommendationId:n.ActiveRec.Id,conditionId:n.ActiveCondition.Id,treatmentId:n.ActiveTreatment.Id,recommendationType:n.ActiveRec.TypeId,guidelineId:n.ActiveRec.Guideline.GuidelineId}}).then(function(){n.pageMessage="Recommendation saved";n.pageMessageType="success";n.GetTreatmentRecommendations(n.ActiveTreatment.Id);n.GetConditionRecommendations(n.ActiveCondition.Id)},function(){}):t({url:"/ny/AddRecommendation",method:"POST",data:{conditionId:n.ActiveCondition.Id,treatmentId:n.ActiveTreatment.Id,recommendationType:n.ActiveRec.TypeId,guidelineId:n.ActiveRec.Guideline.GuidelineId}}).then(function(t){n.pageMessage="Recommendation added";n.pageMessageType="success";n.ActiveRec.Id=t.data.RecommendationId;n.ActiveRec.Link=t.data.Link;n.GetTreatmentRecommendations(n.ActiveTreatment.Id);n.GetConditionRecommendations(n.ActiveCondition.Id)},function(){})};n.DeleteRec=function(){n.ActiveRec.Id&&t({url:"/ny/DeleteRecommendation",method:"POST",data:{recommendationId:n.ActiveRec.Id}}).then(function(){$("#deleteRecommendationModal").modal("hide");n.pageMessage="Recommendation deleted";n.pageMessageType="success";n.ActiveRec={};n.GetTreatmentRecommendations(n.ActiveTreatment.Id);n.GetConditionRecommendations(n.ActiveCondition.Id)},function(){})}}function getQueryVariable(n){for(var i,u=window.location.search.substring(1),r=u.split("&"),t=0;t<r.length;t++)if(i=r[t].split("="),decodeURIComponent(i[0])===n)return decodeURIComponent(i[1]);return null}function durationsController(n,t){n.init=function(){n.code=null;n.codeType=null;n.codeDescription=null;n.codeDisplay=null;n.noResults=!1;n.durations=null;n.$parent.topicId>0&&n.getDurations();n.$broadcast("durationsModalOpened");t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"DurationsOpen"}}).then({},{})};n.clearCode=function(){n.code=null;n.codeType=null;n.codeDisplay=null;n.codeDescription=null;n.durations=null;n.noResults=!1};n.codeChanged=function(){n.codeDisplay.trim()===""?n.clearCode():n.clearTopic()};n.topicSelected=function(t,i,r){n.$parent.topicId=t;n.$parent.topicTitle=i;n.$parent.topicUrl=r};n.clearTopic=function(){n.$parent.topicId=0;n.$parent.topicTitle="";n.$parent.topicUrl="";n.topicTitle="";n.durations=null;n.noResults=!1};n.topicChanged=function(){n.topicTitle.trim()===""?n.clearTopic():n.clearCode()};n.getDurations=function(){var i=null,r=[],u;n.$parent.topicId?(i="/durations/bytopicid/"+n.$parent.topicId,r.push({DetailKey:"TopicId",DetailValue:n.$parent.topicId})):n.code&&(u=n.codeType.replace(/-/g,"").toLowerCase(),i="/durations/bymedicalcode/"+u+"/"+n.code,r.push({DetailKey:"CodeType",DetailValue:u}),r.push({DetailKey:"Code",DetailValue:n.code}));t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"DurationsSearch",eventDetails:r}}).then({},{});i&&t({url:i,method:"GET"}).then(function(t){n.durations=t.data;n.noResults=!(n.durations&&n.durations.length>0);setTimeout(function(){popoverArticle("#durationsTool")},500)},function(t){n.badNewsMessage=t.statusText})}}function durationViewsController(n,t,i){n.init=function(){n.primaryDiagnosisInitialize();n.populationViewInitialize();n.caseViewInitialize();n.summaryViewInitialize();n.firstVisit=$.cookie("durationViewFirstVisit");n.ignoreLogging=!1;n.activeTab=[];n.firstVisit==undefined&&(n.firstVisit=!0);$.ajax({url:"/getOrgOptions",type:"POST",data:{orgId:0},success:function(t){for(var i=0;i<t.length;i++)switch(t[i].OptionId){case 4:t[i].Value=="True"&&(n.suppressPhysiological=!0);break;case 5:t[i].Value=="True"&&(n.suppressPopulation=!0);break;case 6:t[i].Value=="True"&&(n.suppressCase=!0)}n.suppressAny=n.suppressPhysiological||n.suppressPopulation||n.suppressCase;n.suppressAny?(n.uoSkipSplash=!0,n.showDive()):$.ajax({url:"/getOption/3",type:"GET",success:function(t){n.$apply(function(){n.uoSkipSplash=t.toLowerCase()=="true"})},error:function(){n.$apply(function(){n.uoSkipSplash=!1})},complete:function(){n.uoSkipSplash==!1?$("#divSplash").show():n.showDive()}})},error:function(){alert("error")},complete:function(){}});i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"DurationViewsOpen"}}).then({},{})};n.showDive=function(){$("#divSplash").hide();$("#divDive").show();n.suppressPhysiological&&(n.suppressPopulation?n.suppressCase?n.error="All tabs suppressed.":n.activeTab[2]=!0:n.activeTab[1]=!0)};n.skipSplash=function(){$.ajax({url:"/setOption/3/"+n.uoSkipSplash,type:"POST"})};n.primaryDiagnosisSelected=function(){$.cookie("durationViewFirstVisit",!1,{expires:30});$("#divSplash").fadeOut(function(){$("#divDive").fadeIn()});i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"PhysiologicalOpen"}}).then({},{})};n.primaryDiagnosisChanged=function(){};n.primaryDiagnosisInitialize=function(){n.primaryDiagnosisCode="";n.primaryDiagnosisCodeType=null;n.primaryDiagnosisLabel=null;n.primaryDiagnosisDescription=null;n.primaryDiagnosisWarning=null};n.$watch(function(n){return n.primaryDiagnosisCode},function(){if(n.ignoreLogging=!0,n.isZeroEmptyUndefined(n.primaryDiagnosisCode))n.populationViewInitialize(),n.caseViewInitialize(),n.summaryViewInitialize();else{n.suppressPhysiological||n.getPhysioligical();n.suppressPopulation||n.getPopulation();n.suppressCase||n.getCaseViewComorbidGroups();n.suppressAny||n.summaryViewInitialize();var t=[];t.push({DetailKey:"PrimaryDiagnosisCode",DetailValue:n.primaryDiagnosisCode});i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"DurationViewsSearch",eventDetails:t}}).then({},{})}n.ignoreLogging=!1});n.physiologicalViewInitialize=function(){n.physiologicalResults=null;n.physiologicalWarning="";n.physiologicalMessage="";n.noResults=!1};n.getPhysioligical=function(){if(n.physiologicalViewInitialize(),!angular.isUndefined(n.primaryDiagnosisCode)&&n.primaryDiagnosisCode!=""){var t=null,r=n.primaryDiagnosisCodeType.replace(/-/g,"").toLowerCase();t="/durations/bymedicalcode/"+r+"/"+n.primaryDiagnosisCode;t&&i({url:t,method:"GET"}).then(function(t){t.data.Message&&t.data.Message.length>0?n.physiologicalMessage=t.data.Message:(n.physiologicalResults=t.data,n.physiologicalResults&&n.physiologicalResults.length==1&&(n.physiologicalResults[0].show=!0),n.sv.selectedFactor=n.physiologicalResults[0],setTimeout(function(){popoverArticle("#physiological-tool-results")},500))},function(t){n.physiologicalWarning=t.data&&t.data.length>0?t.data:t.statusText});n.ignoreLogging!=!0&&i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"PhysiologicalOpen"}}).then({},{})}};n.populationViewInitialize=function(){n.populationViewResults=null;n.populationViewMessage="";n.populationViewWarning="";n.popViewImgUrl=""};n.getPopulation=function(){if(n.populationViewInitialize(),!angular.isUndefined(n.primaryDiagnosisCode)&&n.primaryDiagnosisCode!=""){var t=_API_URL+"/api/v2/durations/population/"+n.primaryDiagnosisCode+"?includeIcd9=true&includeGrouper=true";response="";t&&i({url:t,method:"GET",headers:{"RG-LICENSE-KEY":"38A1C76C-16B1-42BF-BE7C-E4A4D2D96E4B"}}).then(function(t){var i,r;n.populationViewResults=t.data;n.populationViewResults==""||n.populationViewResults=="Not enough data."?n.populationViewWarning=t.statusText:(n.drawTimeline(),n.popViewImgUrl="/Content/Images/durationImages/"+n.populationViewResults.CodeGrouper+".png?"+Math.floor((1+Math.random())*65536).toString(16),i=new XMLHttpRequest,i.open("HEAD",n.popViewImgUrl,!1),i.send(),r=$("#imgPopulationGraph"),i.status==200?r.html('<img src="'+n.popViewImgUrl+'" style="max-width:1000px; width:100%" />'):(n.popViewImgUrl="",r.html("")))},function(t){n.populationViewWarning=t.statusText});n.ignoreLogging!=!0&&i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"PopulationOpen"}}).then({},{})}};n.caseViewInitialize=function(){n.cvClear();n.cvrClear()};n.cvClear=function(){n.cv={};n.cv.age=null;n.cv.gender=null;n.cv.jobClass=null;n.cv.programType=null;n.cv.warning="";n.comorbids=[];n.cv.showForm=!0;n.newComorbid={};n.newComorbid.display=null;n.newComorbid.code=null;n.newComorbid.groupCode=null};n.cvrClear=function(){var t,i;if(n.cvr={},n.cvr.totalDuration=0,n.cvr.baseDuration=0,n.cvr.intercept=0,n.cvr.ageModifier=0,n.cvr.age=0,n.cvr.sexModifier=0,n.cvr.sex,n.cvr.jobClassModifier=0,n.cvr.jobClass="",n.cvr.programType="",n.cvr.programTypeModifier=0,n.cvr.code="",n.cvr.codeDescription="",n.cvr.comorbid1Code="",n.cvr.comorbid1Modifier=0,n.cvr.comorbid1Description="",n.cvr.comorbid2Code="",n.cvr.comorbid2Modifier=0,n.cvr.comorbid2Description="",n.cvr.comorbid3Code="",n.cvr.comorbid3Modifier=0,n.cvr.comorbid3Description="",n.cvr.show=!1,!n.isZeroEmptyUndefined(n.sv)&&!n.isZeroEmptyUndefined(n.sv.selectedFactor))for(t=0;t<n.sv.jobClasses.length;t++)i=n.sv.jobClasses[t],i.Checked=!1};n.getCaseViewComorbidGroups=function(){if(n.caseViewInitialize(),n.comorbidGroups=null,!angular.isUndefined(n.primaryDiagnosisCode)&&n.primaryDiagnosisCode!=""){var t=_API_URL+"/api/v3/durations/case/fit/"+n.primaryDiagnosisCode+"?includeIcd9=true";i({url:t,method:"GET",headers:{"RG-LICENSE-KEY":"38A1C76C-16B1-42BF-BE7C-E4A4D2D96E4B"}}).then(function(t){n.comorbidGroups=t.data.ComorbidGroupRelevance;n.comorbidGroups==""&&(n.comorbidGroupMessage=t.statusText)},function(t){n.cv.warning=t.data&&t.data.length>0?t.data:t.statusText;n.cv.showForm=!1})}n.ignoreLogging!=!0&&i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"CaseOpen"}}).then({},{})};n.toggleComorbid=function(t,i){for(var r=0;r<n.comorbids.length;r++)if(n.comorbids[r].code==t){n.comorbids.splice(r,1);n.newComorbid={};document.getElementById("txtComorbid").focus();return}n.comorbids.push({code:t,display:i,medCodes:[]})};n.addComorbidCode=function(t,i,r){var u,f,e;if(t==n.primaryDiagnosisCode){n.newComorbid={};document.getElementById("txtComorbid").focus();return}if(n.isZeroEmptyUndefined(r)){for(u=0;u<n.comorbids.length;u++)if(n.comorbids[u].code==t){n.newComorbid={};document.getElementById("txtComorbid").focus();return}n.comorbids.push({code:t,display:i});n.newComorbid={};document.getElementById("txtComorbid").focus()}else{for(u=0;u<n.comorbids.length;u++)if(n.comorbids[u].code==r){for(f=0;f<n.comorbids[u].medCodes.length;f++)if(n.comorbids[u].medCodes[f].code==t){n.newComorbid={};document.getElementById("txtComorbid").focus();return}n.comorbids[u].medCodes.push({code:t,display:i});n.newComorbid={};document.getElementById("txtComorbid").focus();return}e=n.comorbidGroups.filter(function(n){return n.Code==r});n.comorbids.push({code:r,display:e[0].ToolName,medCodes:[{code:t,display:i}]});n.newComorbid={};document.getElementById("txtComorbid").focus()}};n.comorbidGroupChecked=function(t){for(var i=0;i<n.comorbids.length;i++)if(n.comorbids[i].code==t)return!0;return!1};n.$watch("cv",function(){n.cvrClear()},!0);n.$watch("comorbids.length",function(){n.cvrClear()});n.getCaseView=function(){var t,u,f,r;if(n.cvrClear(),t=_API_URL+"/api/v3/durations/case/"+n.primaryDiagnosisCode+"?",n.cv.gender!=null&&(t=t+"&sex="+n.cv.gender),n.cv.age!=null&&(t=t+"&age="+n.cv.age),n.cv.jobClass!=null&&(t=t+"&jobClass="+n.cv.jobClass.toLowerCase().replace(/\s/g,"")),n.cv.programType!=null&&(t=t+"&programType="+n.cv.programType.toLowerCase()),n.comorbids.length>0)for(t=t+"&comorbidities=",r=0;r<n.comorbids.length;r++)t=t+n.comorbids[r].code+",";if(i({url:t,method:"GET",headers:{"RG-LICENSE-KEY":"38A1C76C-16B1-42BF-BE7C-E4A4D2D96E4B"}}).then(function(t){var r,u,i;if(n.phase="results",n.cvr.codeDescription=t.data.PrimaryDiagnosis.Description,n.cvr.code=t.data.PrimaryDiagnosis.MedicalCode,n.cvr.baseDuration=t.data.BaseDuration,n.cvr.totalDuration=t.data.TotalPredictedDuration==-1?"Indefinite":t.data.TotalPredictedDuration,r=1,t.data.Factors!=null)for(u=0;u<t.data.Factors.length;u++){i=t.data.Factors[u];switch(i.FactorType.toLowerCase()){case"age":n.cvr.age=i.FactorValue;n.cvr.ageModifier=i.Rank>0;break;case"sex":n.cvr.sex=i.FactorValue;n.cvr.sexModifier=i.Rank>0;break;case"jobclass":n.cvr.jobClass=i.FactorValue.replace("veryheavy","very heavy");n.cvr.jobClassModifier=i.Rank>0;break;case"programtype":switch(i.FactorValue){case"std":n.cvr.programType="STD";break;case"wc":n.cvr.programType="Workers Comp";break;default:n.cvr.programType=i.FactorValue}n.cvr.programTypeModifier=i.Rank>0;break;case"comorbidgroup":case"medcode":switch(r){case 1:n.cvr.comorbid1Code=i.FactorValue;n.cvr.comorbid1Modifier=i.Rank>0;n.cvr.comorbid1Description=i.FactorType.toLowerCase()=="medcode"?i.FactorValue+" "+i.Description:i.Description;break;case 2:n.cvr.comorbid2Code=i.FactorValue;n.cvr.comorbid2Modifier=i.Rank>0;n.cvr.comorbid2Description=i.FactorType.toLowerCase()=="medcode"?i.FactorValue+" "+i.Description:i.Description;break;case 3:n.cvr.comorbid3Code=i.FactorValue;n.cvr.comorbid3Modifier=i.Rank>0;n.cvr.comorbid3Description=i.FactorType.toLowerCase()=="medcode"?i.FactorValue+" "+i.Description:i.Description}r=r+1}}},function(t){n.showResults=!1;n.cv.warning=t.Message?t.Message:t.statusText?t.statusText:t.data?t.data:t==null?"An unexpected error occurred.":t}),u=[],u.push({DetailKey:"PrimaryDiagnosisCode",DetailValue:n.primaryDiagnosisCode}),n.cv.gender!=null&&u.push({DetailKey:"Sex",DetailValue:n.cv.gender}),n.cv.age!=null&&u.push({DetailKey:"Age",DetailValue:n.cv.age}),n.cv.jobClass!=null&&u.push({DetailKey:"JobClass",DetailValue:n.cv.jobClass.toLowerCase().replace(/\s/g,"")}),n.cv.programType!=null&&u.push({DetailKey:"ProgramType",DetailValue:n.cv.programType.toLowerCase()}),n.comorbids.length>0){for(f="",r=0;r<n.comorbids.length;r++)f=f+n.comorbids[r].code+",";f=f.substring(0,f.length-1);u.push({DetailKey:"Comorbidities",DetailValue:f})}i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"CaseCalculate",eventDetails:u}}).then({},{})};n.summaryViewInitialize=function(){n.sv={};n.sv.startDate=new Date;n.sv.startDatePicker=!1;n.textBounds=[];n.sv.jobClasses=[]};n.openStartDatePicker=function(){n.sv.startDatePicker=n.sv.startDatePicker==!0?!1:!0};n.$watch(function(){return n.physiologicalResults},function(){var t,i;if(n.physiologicalResults!=null&&n.sv.selectedFactor!=null)for(n.sv.jobClasses=[],t=0;t<n.sv.selectedFactor.JobClasses.length;t++)i=n.sv.selectedFactor.JobClasses[t],n.sv.jobClasses.push({JobClass:i.JobClass,Optimum:i.Optimum,Checked:n.cvr.jobClass==i.JobClass})});n.$watch(function(){return n.cvr.jobClass},function(){var t,i;if(n.sv.jobClasses!=null&&n.cvr.jobClass!="")for(t=0;t<n.sv.jobClasses.length;t++)i=n.sv.jobClasses[t],i.JobClass.toLowerCase()==n.cvr.jobClass.toLowerCase()&&(i.Checked=!0)});n.$watch(function(n){return n.sv.startDate},function(){n.drawTimeline()});n.$watch(function(n){return n.cvr.totalDuration},function(){n.drawTimeline()});n.$watch(function(n){return n.sv.jobClasses},function(){n.drawTimeline()});n.$watch(function(n){return n.populationViewResults},function(){n.drawTimeline()});n.$watch(function(n){return n.sv.selectedFactor},function(){var r,t,i;if(n.sv.selectedFactor!=null){for(r=n.sv.jobClasses,n.sv.jobClasses=[],t=0;t<n.sv.selectedFactor.JobClasses.length;t++)i=n.sv.selectedFactor.JobClasses[t],n.sv.jobClasses.push({JobClass:i.JobClass,Optimum:i.Optimum,Checked:r[t].Checked});n.drawTimeline()}});n.drawBandSection=function(t,i,r,u){t.fillStyle=i;t.fillRect(n.bandmargin+n.bandwidth*r,n.topofband,n.bandwidth*u,n.bandheight)};n.drawText=function(t,i,r,u){for(var f=n.bandmargin+n.bandwidth*r,e={x1:f-t.measureText(i).width-2,y1:n.topofband-u- -2,x2:f-2,y2:n.topofband-u- -14},o=0;o<n.textBounds.length;o++)if(n.detectCollision(e,n.textBounds[o])){n.drawText(t,i,r,u+20);return}t.beginPath();t.moveTo(f,n.topofband-2);t.lineTo(f,n.topofband-u+2-8);t.stroke();t.fillText(i,e.x1,e.y1);n.textBounds.push(e)};n.detectCollision=function(n,t){return n.x1<t.x2&&n.x2>t.x1&&n.y1<t.y2&&n.y2>t.y1?!0:!1};n.drawBotText=function(t,i,r,u){t.moveTo(r,n.topofband+n.bandheight);t.lineTo(r,n.topofband+n.bandheight+u);t.stroke();t.font="12px Arial";t.fillStyle="black";t.fillText(i,r-t.measureText(i).width/2,n.topofband+n.bandheight+u+12+2)};n.openPhysiologicalView=function(){n.activeTab[0]=!0;n.ignoreLogging!=!0&&i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"PhysiologicalOpen"}}).then({},{})};n.openPopulationView=function(){n.activeTab[1]=!0;n.ignoreLogging!=!0&&i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"PopulationOpen"}}).then({},{})};n.openCaseView=function(){n.activeTab[2]=!0;document.getElementById("txtAge").focus();n.ignoreLogging!=!0&&i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"CaseOpen"}}).then({},{})};n.openSummaryView=function(){n.drawTimeline();n.activeTab[3]=!0;n.ignoreLogging!=!0&&i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"SummaryOpen"}}).then({},{})};n.redrawTimelineFromDate=function(t){if(n.sv.startDate!=null&&moment(n.sv.startDate).isValid()){n.drawTimeline();var r=[];r.push({DetailKey:"RefreshReason",DetailValue:t});i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"SummaryRefresh",eventDetails:r}}).then({},{})}};n.redrawTimeline=function(t){n.drawTimeline();var r=[];r.push({DetailKey:"RefreshReason",DetailValue:t});i({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"SummaryRefresh",eventDetails:r}}).then({},{})};n.drawTimeline=function(){var r,o,c,f,t,i,e,u,s,h;if(n.sv.timelineWarning="",r=document.getElementById("myCanvas"),!r||n.isZeroEmptyUndefined(n.sv.jobClasses)&&n.isZeroEmptyUndefined(n.populationViewResults)){n.hideCanvas=!0;return}for(n.hideCanvas=!1,o=r.parentElement,r.width=o.clientWidth===0?r.width:o.clientWidth,c=["#cde0ea","#9bc1d5","#076598"],n.bandwidth=r.width-n.bandmargin*2,n.sv.canvasWidth=r.width,n.sv.height=140,n.topofband=100,n.bandheight=40,n.bandmargin=65,f=r.getContext("2d"),f.clearRect(0,0,r.width,n.sv.height),n.textBounds=[],t=[],i=0;i<n.sv.jobClasses.length;i++)e=n.sv.jobClasses[i],e.Checked&&t.push({text:e.JobClass+": "+e.Optimum,daysFromStart:e.Optimum,bandColor:2});for(t.push({text:"Start Date",daysFromStart:0,bandColor:1}),n.isZeroEmptyUndefined(n.cvr.totalDuration)||(n.cvr.totalDuration==-1||n.cvr.totalDuration>365||String(n.cvr.totalDuration).toLowerCase()=="indefinite"?(t.push({text:"Case Prediction: Indefinite",daysFromStart:365}),n.sv.timelineWarning="The Case Duration for this case is determined to be too long to be predicted with any meaningful value and represents a high risk case that should be closely managed."):t.push({text:"Case Prediction: "+n.cvr.totalDuration,daysFromStart:n.cvr.totalDuration})),n.isZeroEmptyUndefined(n.populationViewResults)||t.push({text:"Median: "+n.populationViewResults._50thPercentileDurationInDays,daysFromStart:n.populationViewResults._50thPercentileDurationInDays,bandColor:3}),u=n.daysBetween(n.sv.startDate,new Date),u>365&&(n.sv.timelineWarning="This case has exceeded one year and should be closely managed."),u>.5&&u<=365&&(!n.isZeroEmptyUndefined(n.populationViewResults._50thPercentileDurationInDays)&&u>n.populationViewResults._50thPercentileDurationInDays?t.push({text:"Today: "+u,daysFromStart:u,color:"red"}):t.push({text:"Today: "+u,daysFromStart:u,color:"green"})),t.sort(function(n,t){return n.daysFromStart-t.daysFromStart}),n.sv.bandMax=t[t.length-1].daysFromStart,s=0,i=0;i<t.length;i++)f.font="10px Arial",f.fillStyle=n.isZeroEmptyUndefined(t[i].color)?"black":t[i].color,f.strokeStyle="#BBBBBB",n.drawText(f,t[i].text,t[i].daysFromStart/n.sv.bandMax,20,t[i].color),!n.isZeroEmptyUndefined(t[i].bandColor)&&t[i].bandColor>=s&&(h=t[i].daysFromStart/n.sv.bandMax,n.drawBandSection(f,c[t[i].bandColor-1],h,1-h),s=t[i].bandColor);n.makeCanvasPrintable()};n.treatAsUTC=function(n){var t=new Date(n);return t.setMinutes(t.getMinutes()-t.getTimezoneOffset()),t};n.daysBetween=function(t,i){return Math.floor((n.treatAsUTC(i)-n.treatAsUTC(t))/864e5)};n.isZeroEmptyUndefined=function(n){return n&&n!=0&&n!=""&&n!={}?!1:!0};Date.prototype.addDays=function(n){var t=new Date(this.valueOf());return t.setDate(t.getDate()+n),t};n.makeCanvasPrintable=function(){var t=document.getElementById("myCanvas"),i=new Image;n.canvasImg=t.toDataURL()}}function crosswalkController(n,t){n.init=function(){n.State="ACOEM";n.IcdCodeType="";n.IcdCode="";n.IcdCodeDescription="";n.IcdCodeDisplay="";n.CptCode="";n.CptCodeDescription="";n.CptCodeDisplay="";n.ServerMessage="";n.Success=!1;n.Data=null;n.IcdCodeResults=null;n.IcdDescriptionResults=null;n.IcdCodeTypeResults=null;n.CptCodeResults=null;n.CptDescriptionResults=null;n.$broadcast("crosswalkModalOpened");t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"CrosswalkOpen"}}).then({},{})};n.getCrosswalkModel=function(){var r,i;if(n.IcdCodeResults=null,n.IcdDescriptionResults=null,n.IcdCodeTypeResults=null,n.CptCodeResults=null,n.CptDescriptionResults=null,r=n.validateForm(),!r)return!1;t({url:"/Crosswalk/GetCrosswalk",method:"POST",data:{State:n.State,IcdCode:n.IcdCode,CptCode:n.CptCode,IcdCodeType:n.IcdCodeType,Phase:""}}).then(function(t){n.handleResults(t.data)},function(){n.handleError(response.data)});i=[];i.push({DetailKey:"State",DetailValue:n.State});i.push({DetailKey:"IcdCodeType",DetailValue:n.IcdCodeType});i.push({DetailKey:"IcdCode",DetailValue:n.IcdCode});i.push({DetailKey:"CptCode",DetailValue:n.CptCode});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"CrosswalkSearch",eventDetails:i}}).then({},{})};n.validateForm=function(){return n.crosswalkModelForm.$valid&&n.IcdCodeType&&(n.IcdCode||n.CptCode)};n.handleResults=function(t){n.ServerMessage=t.message;n.Success=t.success;n.Data=t.data;n.IcdCodeResults=angular.copy(n.IcdCode);n.IcdDescriptionResults=angular.copy(n.IcdCodeDisplay);n.IcdCodeTypeResults=angular.copy(n.IcdCodeType);n.CptCodeResults=angular.copy(n.CptCode);n.CptDescriptionResults=angular.copy(n.CptCodeDisplay);$(".modal-contents").scrollTo(0,0)};n.handleError=function(t){n.ServerMessage=t.message;n.Success=t.success};n.resolveIcdType=function(t){t!==null&&n.IcdCodeType!==t&&(n.clearCode("IcdCode"),n.IcdCodeType=t)};n.clearCode=function(t){switch(t){case"CptCode":n.CptCode=null;n.CptCodeDescription=null;n.CptCodeDisplay=null;break;case"IcdCode":n.IcdCode=null;n.IcdCodeDescription=null;n.IcdCodeDisplay=null}};n.IcdCodeChanged=function(){n.IcdCode=n.IcdCodeDisplay};n.CptCodeChanged=function(){n.CptCode=n.CptCodeDisplay}}function recommendationsController(n){n.init=function(){n.ActiveTab="Recommendation"};n.SearchByRecommendation=function(){n.ActiveTab="Recommendation"};n.SearchByTreatment=function(){n.ActiveTab="Treatment"}}function dartByRecommendationController(n,t){n.init=function(i){n.CategoryId="";n.CategoryObj=null;n.CategoryOptions=[];n.SearchType="Recommendation";n.PhaseOptions=[{Phase:"All"},{Phase:"Acute"},{Phase:"Subacute"},{Phase:"Chronic"},{Phase:"Surgical"}];n.Phase="All";n.$parent.topicId==""&&(n.$parent.topicTitle="");n.TextLimit=250;n.RecommendationFilter="All";n.StrengthOfEvidenceFilter="Any";n.TreatmentNameFilter="";n.OrderBy=null;n.Reverse=!1;n.OrderByArray="";n.SetOrderBy("RecommendationLevelSortOrder");n.InitializeResultVariables();i&&i!=""&&(n.CategoryId=i);n.$parent.topicId!=""&&n.topicSelected(n.$parent.topicId,n.$parent.topicTitle,n.$parent.topicUrl);n.$broadcast("dartModalOpened");var r=[];r.push({DetailKey:"TopicId",DetailValue:n.$parent.topicId});r.push({DetailKey:"CategoryId",DetailValue:n.CategoryId});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"DartOpen",eventDetails:r}}).then({},{})};n.InitializeResultVariables=function(){n.ServerMessage="";n.Success=!1;n.Data=null;n.TopicIdResults=null;n.TopicDisplayResults=null;n.CategoryResults=null;n.PhaseResults=null;n.StrengthOfEvidenceFilterList=null;n.DartResults=null;n.formSubmitted=!1};n.SetOrderBy=function(t){n.Reverse=n.OrderBy===t?!n.Reverse:!1;n.OrderBy=t;switch(n.OrderBy){case"RecommendationLevelSortOrder":n.OrderByArray=n.Reverse?["-RecommendationLevelSortOrder","StrengthOfEvidenceSortOrder","TreatmentName"]:["RecommendationLevelSortOrder","StrengthOfEvidenceSortOrder","TreatmentName"];break;case"StrengthOfEvidence":n.OrderByArray=n.Reverse?["-StrengthOfEvidenceSortOrder","RecommendationLevelSortOrder","TreatmentName"]:["StrengthOfEvidenceSortOrder","RecommendationLevelSortOrder","TreatmentName"];break;case"TreatmentName":n.OrderByArray=n.Reverse?["-TreatmentName"]:"TreatmentName"}};n.Filter=function(){var t={};return n.RecommendationFilter!="All"&&(t.RecommendationLevelFilter=n.RecommendationFilter),n.StrengthOfEvidenceFilter!="Any"&&(t.StrengthOfEvidence=n.StrengthOfEvidenceFilter),n.TreatmentNameFilter!=""&&(t.TreatmentName=n.TreatmentNameFilter),t};n.clearTopic=function(){n.$parent.topicId=0;n.$parent.topicTitle="";n.topicTitle="";this.topicTitle="";n.TopicChanged()};n.$watch("Phase",function(t,i){t!=i&&n.InitializeResultVariables()});n.validateForm=function(){return parseInt(this.topicId)>0&&n.CategoryOptions.length>0};n.TopicChanged=function(){n.$parent.topicId=n.topicTitle;n.CategoryId="";n.CategoryObj=null;n.CategoryOptions=[];n.Phase="";n.InitializeResultVariables()};n.getRecommendationModel=function(){var r=n.validateForm(),i;if(!r)return!1;n.RecommendationFilter="All";n.StrengthOfEvidenceFilter="Any";n.TreatmentNameFilter="";t({url:"/dart/GetRecommendations",method:"POST",data:{TopicId:n.$parent.topicId,Phase:n.Phase,Category:n.CategoryObj.CategoryId}}).then(function(t){n.handleResults(t.data)},function(t){n.handleError(t.data)});i=[];i.push({DetailKey:"TopicId",DetailValue:n.$parent.topicId});i.push({DetailKey:"CategoryId",DetailValue:n.CategoryId});i.push({DetailKey:"Phase",DetailValue:n.Phase});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"DartSearch",eventDetails:i}}).then({},{})};n.handleResults=function(t){n.ServerMessage=t.message;n.Success=t.success;n.DartResults=t.data.Recommendations;n.TopicIdResults=angular.copy(n.$parent.topicId);n.TopicDisplayResults=angular.copy(n.$parent.topicTitle);n.CategoryResults=angular.copy(n.CategoryId);n.PhaseResults=angular.copy(n.PhaseResults);n.StrengthOfEvidenceFilterList=t.data.StrengthOfEvidenceFilterList;$(".modal-contents").scrollTo(0,0)};n.handleError=function(t){n.ServerMessage=t.message;n.Success=t.success};n.RecommendationIcon=function(n){switch(n){case"Yes":return"glyphicon-ok-sign text-success";case"Sometimes":return"glyphicon-exclamation-sign text-warning";case"Not":return"glyphicon-remove-sign text-danger";case"No":return"glyphicon-minus-sign"}};n.topicSelected=function(i,r){n.$parent.topicId=i;n.$parent.topicTitle=r;n.topicTitle=r;t({url:"/dart/GetRecommendationBasicsForTopic/",method:"POST",data:{TopicId:i}}).then(function(t){n.CategoryOptions=t.data.data.Categories;n.CategoryOptions.length<=1&&(n.topicTitle="");n.SetSelectedCategory()},function(){alert("error")})};n.SetSelectedCategory=function(){n.CategoryId=n.CategoryId==""?0:parseInt(n.CategoryId,10);n.CategoryObj=n.CategoryOptions.filter(function(t){return parseInt(t.CategoryId,10)==n.CategoryId})[0];n.Phase="All"};n.CategoryChanged=function(){n.CategoryObj=n.CategoryOptions.filter(function(t){return parseInt(t.CategoryId,10)==parseInt(n.CategoryId,10)})[0];n.CategoryId=n.CategoryObj.CategoryId;n.Phase="All";n.InitializeResultVariables()}}function dartByTreatmentController(n,t){n.init=function(){n.clearInput();n.clearResults();n.PhaseOptions=[{Phase:"All"},{Phase:"Acute"},{Phase:"Subacute"},{Phase:"Chronic"},{Phase:"Surgical"}];n.formSubmitted=!1;n.TextLimit=250};n.validateForm=function(){return n.treatmentId!=""};n.clearInput=function(){n.treatmentId="";n.treatmentName="";n.Phase="All"};n.clearResults=function(){n.ShowResults=!1;n.ServerMessage=null;n.DartResults=null;n.OrderBy=null;n.Reverse=!1;n.OrderByArray="";n.SetOrderBy("RecommendationLevelSortOrder");n.StrengthOfEvidenceFilterList=null;n.CategoryFilterList=null;n.CategoryFilter="Any";n.RecommendationFilter="All";n.StrengthOfEvidenceFilter="Any"};n.SetOrderBy=function(t){n.Reverse=n.OrderBy===t?!n.Reverse:!1;n.OrderBy=t;switch(n.OrderBy){case"RecommendationLevelSortOrder":n.OrderByArray=n.Reverse?["-RecommendationLevelSortOrder","StrengthOfEvidenceSortOrder","Topic"]:["RecommendationLevelSortOrder","StrengthOfEvidenceSortOrder","Topic"];break;case"StrengthOfEvidence":n.OrderByArray=n.Reverse?["-StrengthOfEvidenceSortOrder","RecommendationLevelSortOrder","Topic"]:["StrengthOfEvidenceSortOrder","RecommendationLevelSortOrder","Topic"];break;case"Category":n.OrderByArray=n.Reverse?["-Category","-Topic"]:["Category","Topic"];break;case"Topic":n.OrderByArray=n.Reverse?["-Topic"]:"Topic"}};n.Filter=function(){var t={};return n.RecommendationFilter!="All"&&(t.RecommendationLevelFilter=n.RecommendationFilter),n.StrengthOfEvidenceFilter!="Any"&&(t.StrengthOfEvidence=n.StrengthOfEvidenceFilter),n.TopicFilter!=""&&(t.Topic=n.TopicFilter),n.CategoryFilter!="Any"&&(t.Category=n.CategoryFilter),t};n.go=function(){var r=n.validateForm(),i;if(!r)return!1;t({url:"/dart/GetDartByTreatment",method:"POST",data:{TreatmentId:n.treatmentId,Phase:n.Phase}}).then(function(t){n.handleResults(t.data)},function(t){n.handleError(t.data)});i=[];i.push({DetailKey:"TreatmentId",DetailValue:n.treatmentId});i.push({DetailKey:"Phase",DetailValue:n.Phase});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"DartSearch",eventDetails:i}}).then({},{})};n.handleResults=function(t){n.ServerMessage=t.message;n.ShowResults=t.success;n.DartResults=t.data.Rows;n.StrengthOfEvidenceFilterList=t.data.StrengthOfEvidenceFilterList;n.CategoryFilterList=t.data.CategoryFilterList;n.formSubmitted=!0};n.handleError=function(t){n.ServerMessage=t.message;n.ShowResults=t.success};n.RecommendationIcon=function(n){switch(n){case"Yes":return"glyphicon-ok-sign text-success";case"Sometimes":return"glyphicon-exclamation-sign text-warning";case"Not":return"glyphicon-remove-sign text-danger";case"No":return"glyphicon-minus-sign"}}}function formularyController(n,t){n.init=function(){n.CategoryOptions=[];n.ConditionOptions=[];n.SelectedCategory=null;n.SelectedCondition=null;n.SearchType="Condition";n.GetFormularyInputModel();n.drug=null;n.drugName=null;n.InitializeResultVariables();t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"FormularyOpen"}}).then({},{})};n.InitializeResultVariables=function(){n.ConditionServerMessage="";n.ConditionSuccess=null;n.ConditionFormularyResults=null;n.ConditionFormSubmitted=!1;n.SelectedConditionResults=null;n.SelectedCategoryResults=null;n.ConditionFilterDrugName="";n.ConditionFilterEvidenceSupport="";n.ConditionFilterEvidenceSupportList=[];n.ConditionOrderBy=null;n.ConditionReverse=!1;n.ConditionOrderByArray="";n.ConditionSetOrderBy("DrugClass");n.DrugServerMessage="";n.DrugSuccess=null;n.DrugFormularyResults=null;n.DrugFormSubmitted=!1;n.DrugFilterEvidenceSupportList=[];n.DrugFilterPhaseList=null;n.DrugOrderBy=null;n.DrugReverse=!1;n.DrugOrderByArray="";n.DrugSetOrderBy("Category")};n.SearchTypeCondition=function(){n.SearchType="Condition"};n.SearchTypeDrug=function(){n.SearchType="Drug"};n.GetFormularyInputModel=function(){t({url:"/formulary/GetFormularyInputModel/",method:"POST",data:{}}).then(function(t){n.CategoryOptions=t.data.data.CategoryOptions;n.ConditionOptions=t.data.data.ConditionOptions},function(){alert("error")})};n.getFormularyByConditionModel=function(){t({url:"/formulary/GetFormulary",method:"POST",data:{Id:this.SelectedCondition.Id}}).then(function(t){n.handleResults(t.data)},function(t){n.handleError(t.data)});var i=[];i.push({DetailKey:"ChapterId",DetailValue:this.SelectedCategory.Id});i.push({DetailKey:"ChapterName",DetailValue:this.SelectedCategory.Text});i.push({DetailKey:"InjuryId",DetailValue:this.SelectedCondition.Id});i.push({DetailKey:"InjuryName",DetailValue:this.SelectedCondition.Text});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"FormularySearch",eventDetails:i}}).then({},{})};n.getFormularyByDrugModel=function(){n.DrugFormSubmitted=!1;n.DrugFormularyResults=null;n.drug=this.drug;t({url:"/formulary/GetFormularyByDrug",method:"POST",data:{DrugId:this.drug.DrugId}}).then(function(t){n.handleDrugResults(t.data)},function(t){n.handleDrugError(t.data)});var i=[];i.push({DetailKey:"DrugId",DetailValue:this.drug.DrugId});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"FormularySearch",eventDetails:i}}).then({},{})};n.ConditionSetOrderBy=function(t){n.ConditionReverse=n.ConditionOrderBy===t?!n.ConditionReverse:!1;n.ConditionOrderBy=t;switch(n.ConditionOrderBy){case"GenericName":n.ConditionOrderByArray=n.ConditionReverse?["-DrugName","-EvidenceSupportSortOrder"]:["DrugName","EvidenceSupportSortOrder"];break;case"Phase":n.ConditionOrderByArray=n.ConditionReverse?["-Phase","DrugName","BrandName","EvidenceSupportSortOrder"]:["Phase","DrugName","BrandName","EvidenceSupportSortOrder"];break;case"DrugClass":n.ConditionOrderByArray=n.ConditionReverse?["-DrugClass","DrugName","BrandName","EvidenceSupportSortOrder"]:["DrugClass","DrugName","BrandName","EvidenceSupportSortOrder"];break;case"EvidenceSupport":n.ConditionOrderByArray=n.ConditionReverse?["-EvidenceSupportSortOrder","DrugName","BrandName"]:["EvidenceSupportSortOrder","DrugName","BrandName"];break;case"PainClass":n.ConditionOrderByArray=n.ConditionReverse?["-PainClass","DrugName","BrandName","EvidenceSupportSortOrder"]:["PainClass","DrugName","BrandName","EvidenceSupportSortOrder"]}};n.DrugSetOrderBy=function(t){n.DrugReverse=n.DrugOrderBy===t?!n.DrugReverse:!1;n.DrugOrderBy=t;switch(n.DrugOrderBy){case"Category":n.DrugOrderByArray=n.DrugReverse?["-Category","Condition","Phase","EvidenceSupportSortOrder"]:["Category","Condition","Phase","EvidenceSupportSortOrder"];break;case"Condition":n.DrugOrderByArray=n.DrugReverse?["-Condition","Category","Phase","EvidenceSupportSortOrder"]:["Condition","Category","Phase","EvidenceSupportSortOrder"];break;case"Phase":n.DrugOrderByArray=n.DrugReverse?["-Phase","DrugName","BrandName","EvidenceSupportSortOrder"]:["Phase","DrugName","BrandName","EvidenceSupportSortOrder"];break;case"EvidenceSupport":n.DrugOrderByArray=n.DrugReverse?["-EvidenceSupportSortOrder","DrugName","BrandName"]:["EvidenceSupportSortOrder","DrugName","BrandName"];break;case"PainClass":n.DrugOrderByArray=n.DrugReverse?["-PainClass","DrugName","BrandName"]:["PainClass","DrugName","BrandName"]}};n.ConditionFilters=function(){var t={};return n.ConditionFilterPhase!=null&&(t.Phase=n.ConditionFilterPhase.Phase),n.ConditionFilterDrugClass!=null&&(t.DrugClass=n.ConditionFilterDrugClass.DrugClass),n.ConditionFilterDrugName!=""&&(t.DrugName=n.ConditionFilterDrugName),n.ConditionFilterEvidenceSupport!=""&&(t.EvidenceSupport=n.ConditionFilterEvidenceSupport),n.ConditionFilterPainClass!=null&&(t.PainClass=n.ConditionFilterPainClass.PainClass),t};n.IsNullOrEmpty=function(n){var t=!0;return n&&(typeof n=="string"&&n.length>0&&(t=!1),typeof n!="string"&&(t=!1)),t};n.DrugFilters=function(t){if(n.IsNullOrEmpty(n.DrugFilterCategory)||!n.IsNullOrEmpty(n.DrugFilterCategory)&&n.DrugFilterCategory.Category==t.Category){if((n.IsNullOrEmpty(n.DrugFilterCondition)||!n.IsNullOrEmpty(n.DrugFilterCondition)&&n.DrugFilterCondition.Condition==t.Condition)&&(n.IsNullOrEmpty(n.DrugFilterPhase)||!n.IsNullOrEmpty(n.DrugFilterPhase)&&n.DrugFilterPhase.Phase==t.Phase)&&(n.IsNullOrEmpty(n.DrugFilterPainClass)||!n.IsNullOrEmpty(n.DrugFilterPainClass)&&n.DrugFilterPainClass.PainClass==t.PainClass)&&n.EvidenceSupport(n.DrugFilterEvidenceSupport,t.EvidenceSupport))return!0}else return!1};n.yesList=["Yes, Insufficient Evidence (I)","Yes, Limited Evidence (C)","Yes, Moderate Evidence (B)","Yes, Other","Yes, Strong Evidence (A)"];n.noList=["No Recommendation","No, Insufficient Evidence (I)","No, Limited Evidence (C)","No, Moderate Evidence (B)","No, Other","No, Strong Evidence (A)"];n.EvidenceSupport=function(t,i){return n.IsNullOrEmpty(t)||t==i?!0:t=="Yes"&&n.yesList.indexOf(i)!=-1?!0:t=="No"&&n.noList.indexOf(i)!=-1?!0:!1};n.validateForm=function(){return n.SearchType=="Condition"&&this.SelectedCondition&&this.SelectedCondition.Id>0||n.SearchType=="Drug"&&this.drug!=null&&parseInt(this.drug.DrugId)>0};n.EvidenceSupportIcon=function(n){switch(n){case"Yes":return"glyphicon-ok-sign text-success";case"No":return"glyphicon-remove-sign text-danger";case"None":return"glyphicon-minus-sign";case"HealthySystemsThing":return"glyphicon-question-sign text-info"}};n.handleResults=function(t){n.ConditionServerMessage=t.message;n.ConditionSuccess=t.success;n.ConditionFormularyResults=t.data.Formularies;n.ConditionFilterEvidenceSupportList=t.data.EvidenceSupportFilterList;n.SelectedConditionResults=angular.copy(n.SelectedCondition);n.SelectedCategoryResults=angular.copy(n.SelectedCategory);n.CategoryFormSubmitted=!0;n.$broadcast("formularyByConditionFormSubmitted");$(".modal-contents").scrollTo(0,0)};n.handleError=function(t){n.ConditionServerMessage=t.message;n.ConditionSuccess=t.success};n.handleDrugResults=function(t){n.DrugFilterEvidenceSupport=null;n.DrugFilterPhaseList=null;n.DrugServerMessage=t.message;n.DrugSuccess=t.success;n.DrugFormularyResults=t.data.Formularies;n.DrugFilterEvidenceSupportList=t.data.EvidenceSupportFilterList;n.DrugFormSubmitted=!0;n.$broadcast("formularyByDrugFormSubmitted");$(".modal-contents").scrollTo(0,0)};n.handleDrugError=function(t){n.DrugServerMessage=t.message;n.DrugSuccess=t.success};n.CategoryChanged=function(){this.SelectedCondition=null;n.SelectedCondition=null;n.SelectedCategory=this.SelectedCategory;n.ResetConditionTab()};n.ConditionChanged=function(){n.SelectedCondition=this.SelectedCondition;n.ResetConditionTab()};n.ResetConditionTab=function(){n.ConditionServerMessage="";n.ConditionSuccess=null;n.ConditionFormularyResults=null;n.ConditionFormSubmitted=!1;n.SelectedConditionResults=null;n.SelectedCategoryResults=null;n.CategroyFilterDrugClass="";n.ConditionFilterDrugName="";n.ConditionFilterEvidenceSupport="";n.ConditionFilterEvidenceSupportList=[];n.ConditionOrderBy=null;n.ConditionReverse=!1;n.ConditionOrderByArray="";n.ConditionSetOrderBy("DrugClass")};n.clearDrugId=function(){this.drug=null};n.resetDrugTab=function(){this.drug=null;this.drugName=null;n.DrugServerMessage="";n.DrugSuccess=null;n.DrugFormularyResults=null;n.DrugFormSubmitted=!1;n.DrugFilterPhase="";n.DrugFilterEvidenceSupport="";n.DrugFilterEvidenceSupportList=[];n.DrugFilterPhaseList=null;n.DrugFilterCategory="";n.DrugFilterPainClass="";n.DrugFilterCondition="";n.DrugOrderBy=null;n.DrugReverse=!1;n.DrugOrderByArray="";n.DrugSetOrderBy("Category")}}function formularyDrugSearchDirective(){return{restrict:"A",replace:!0,require:"ngModel",templateUrl:"/Scripts/angular-controllers/templates/formularyDrugSearchTemplate.html",scope:{drug:"=drug",drugName:"=drugname"},controller:["$scope","$http",function(n,t){n.baseUrl=_API_URL+"/api/v2/formularydrugsearch/";n.searchDrugs=function(i){var r=i.replace(/ /g,"+"),u=n.baseUrl+r+"/0/10";return t({url:u,method:"GET"}).then(function(t){var i,r;for(n.drugResults=[],i=0;i<t.data.FormularyDrugs.length;i++)n.drugResults.push(t.data.FormularyDrugs[i]);return r={DrugId:0,DrugName:"No Results Found",DrugClass:"",DrugPrice:""},n.drugResults.length==0&&n.drugResults.push(r),n.drugResults})};n.selectDrug=function(t){n.drug=t;n.drugName=t.DrugName}}]}}function nyDrugSearchDirective(){return{restrict:"A",replace:!0,require:"ngModel",templateUrl:"/Scripts/angular-controllers/templates/nyDrugSearchTemplate.html",scope:{drug:"=drug",drugName:"=drugname"},controller:["$scope","$http",function(n,t){n.baseUrl=_API_URL+"/api/v1/nyformularydrugsearch/";n.searchDrugs=function(i){var r=i.replace(/ /g,"+"),u=n.baseUrl+r+"/0/10";return t({url:u,method:"GET"}).then(function(t){var i,r;for(n.drugResults=[],i=0;i<t.data.NyFormularyDrugs.length;i++)n.drugResults.push(t.data.NyFormularyDrugs[i]);return n.drugResults.length===0&&(r={DrugId:0,DrugName:"No Results Found"},n.drugResults.push(r)),n.drugResults})};n.selectDrug=function(t){n.drug=t;n.drugName=t.DrugName}}]}}function nySearchDirective(){return{restrict:"A",replace:!0,require:"ngModel",templateUrl:"/Scripts/angular-controllers/templates/nySearchTemplate.html",scope:{datasources:"@datasources",environment:"@environment",obj:"=obj",onSelectCallback:"&"},controller:["$scope","$http",function(n,t){n.baseUrl=_API_URL+"/api/v1/nySearch/";n.search=function(i){var u=i.replace(/ /g,"+"),r=n.baseUrl+u;return r+="/"+n.environment,n.datasources&&(r+="/"+n.datasources),t({url:r,method:"GET"}).then(function(t){var i,r;for(n.results=[],i=0;i<t.data.NySearchResults.length;i++)n.results.push(t.data.NySearchResults[i]);return n.results.length===0&&(r={Id:0,Name:"No results found"},n.results.push(r)),n.results})};n.selectResult=function(t){n.obj=t;n.onSelectCallback({fusionobject:t,id:t.Id})}}]}}function codeSearchDirective(){return{restrict:"A",replace:!0,require:"ngModel",templateUrl:"/Scripts/angular-controllers/templates/codeSearchTemplate.html",scope:{codeTypes:"@types",codeApps:"@apps",includeNonBillable:"=nonbillable",selectedCode:"=code",codeType:"=codetype",description:"=description",label:"=label",groupcode:"=groupcode",onSelectCallback:"&"},controller:["$scope","$http",function(n,t){n.baseUrl=_API_URL+"/api/v1/codesuggest/";n.searchCodes=function(i){var r=i.replace(/ /g,"+"),u=n.baseUrl+r+"/?types="+n.codeTypes+"&applications="+n.codeApps+"&includenonbillable="+n.includeNonBillable;return t({url:u,method:"GET"}).then(function(n){for(var r,t=[],i=0;i<n.data.codes.length;i++)t.push(n.data.codes[i]);return r={longDescription:"No Results Found"},t.length==0&&t.push(r),t})};n.selectCode=function(t,i,r){n.selectedCode=t.code;n.codeType=t.codeType;t.code?(n.label=r,n.description=t.longDescription,n.groupcode=t.comorbidGroupCode,n.onSelectCallback()):(n.label=null,n.description=null,n.groupcode=null)}}]}}function topicSearchDirective(){return{restrict:"A",replace:!0,require:"ngModel",templateUrl:"/Scripts/angular-controllers/templates/topicSearchTemplate.html",scope:{withRecommendations:"@withrecommendations",withTreatmentGroups:"@withtreatmentgroups",selectedTopicId:"=topicid",label:"=label",topicSelected:"&topicselected",rows:"@rows"},controller:["$scope","$http",function(n,t){n.baseUrl=_API_URL+"/api/v1/autosuggest/";n.searchTopics=function(i){var u=i,r=n.baseUrl+u+"/?";return n.withRecommendations&&n.withRecommendations.toLowerCase()==="true"&&(r=r+"&hasRecommendations="+n.withRecommendations),n.withTreatmentGroups&&n.withTreatmentGroups.toLowerCase()==="true"&&(r=r+"&hasTreatmentGroups="+n.withTreatmentGroups),n.rows&&(r=r+"&rows="+n.rows),t({url:r,method:"GET"}).then(function(n){for(var r,t=[],i=0;i<n.data.topics.length;i++)t.push(n.data.topics[i]);return r={title:"No Results Found",topicId:0,url:""},t.length==0&&t.push(r),t})};n.selectTopicId=function(t,i,r){n.selectedTopicId=t.topicid;t.topicid?(n.label=r,n.topicSelected({topicid:n.selectedTopicId,topictitle:n.label,topicurl:t.url.substring(t.url.lastIndexOf("/")+1)})):n.label=null}}]}}function jobSearchDirective(){return{restrict:"A",replace:!0,require:"ngModel",templateUrl:"/Scripts/angular-controllers/templates/jobSearchTemplate.html",scope:{label:"=label",job:"=job"},controller:["$scope","$http",function(n,t){n.baseUrl=_API_URL+"/api/v1/jobsearch/";n.searchJobs=function(i){var r=i,u=n.baseUrl+r+"/0/10";return t({url:u,method:"GET"}).then(function(t){var i,r;for(n.jobResults=[],i=0;i<t.data.jobs.length;i++)n.jobResults.push(t.data.jobs[i]);return r={JobName:"No Results Found",JobId:0,url:""},n.jobResults.length==0&&n.jobResults.push(r),n.jobResults})};n.selectJob=function(i){n.label="";n.job=i;var r=[];r.push({DetailKey:"JobId",DetailValue:i.JobId});t({url:"/Log/LogUsageEvent",method:"POST",data:{eventType:"JobSelection",eventDetails:r}}).then({},{})}}]}}function treatmentSearchDirective(){return{restrict:"A",replace:!0,require:"ngModel",templateUrl:"/Scripts/angular-controllers/templates/treatmentSearchTemplate.html",scope:{treatmentId:"=treatmentid",treatmentName:"=treatmentname"},controller:["$scope","$http",function(n,t){n.baseUrl=_API_URL+"/api/v1/treatmentsearch/";n.searchTreatments=function(i){var r=i,u=n.baseUrl+r+"/";return t({url:u,method:"GET"}).then(function(n){for(var r,t=[],i=0;i<n.data.Treatments.length;i++)t.push(n.data.Treatments[i]);return r={TreatmentName:"No Results Found",TreatmentId:0},t.length==0&&t.push(r),t})};n.selectTreatment=function(t){n.treatmentName=t.TreatmentName;n.treatmentId=t.TreatmentId}}]}}function topicMedicalCodesController(n,t){n.codeType="icd9cm";n.oldCodeType="";n.showOverlay=!1;n.codes={ICD9CM:"ICD-9-CM",ICD10CM:"ICD-10-CM",ICD10WHO:"ICD-10 (WHO)",CPT:"CPT®"};n.getCodes=function(){n.medicalCodes=[];n.showOverlay=!0;t({method:"GET",url:"/content/GetMedicalCodes/"+n.documentUrl+"/"+n.codeType}).then(function(t){n.medicalCodes=[];angular.forEach(t.data,function(t){var i={code:t.Code,description:t.Description};n.medicalCodes.push(i)});n.codeType==n.oldCodeType&&(n.showOverlay=!1,$(".overlay-link").removeClass("active"),n.codeType="");n.oldCodeType=n.codeType},function(){alert("error")})}}var selectedOption,contentModule,blurFocusDirective;loginController.$inject=["$scope","$http","$location","notificationService"];$("#site-search").submit(function(n){n.preventDefault();selectedOption?(angular.element(document.getElementById("autoSuggestController")).scope().saveSearch(selectedOption.find("a").text(),selectedOption.find("a").attr("href")),window.location.href=selectedOption.find("a").attr("href")):window.location.pathname==="/search/"?(saveSearch($("#search-term").val()),angular.element(document.getElementById("autoSuggestController")).scope().setLocation($("#search-term").val().replace(/ /g,"+")),angular.element(document.getElementById("autoSuggestController")).scope().$apply(),trackEvent("Search"),$("#search-term").blur()):(saveSearch($("#search-term").val()),trackEvent("Recent Search"),window.location.href="/search/#"+$("#search-term").val().replace(/ /g,"+"))});$(document).keydown(function(n){switch(n.keyCode){case 27:closeResults();break;case 40:selectedOption?(selectedOption.removeClass("hover"),next=selectedOption.nextAll("li.selectable").first(),selectedOption=next.length>0?next.addClass("hover"):$("li.selectable").eq(0).addClass("hover")):selectedOption=$("li.selectable").eq(0).addClass("hover");break;case 38:selectedOption?(selectedOption.removeClass("hover"),next=selectedOption.prevAll("li.selectable").first(),selectedOption=next.length>0?next.addClass("hover"):$("li.selectable").last().addClass("hover")):selectedOption=$("li.selectable").last().addClass("hover")}});$("#auto-complete").css("display","block");$(function(){$("#topicMedicalCodes").css("display","block")});contentModule=angular.module("contentModule",["ui.bootstrap","ngResource","ngSanitize","ui.bootstrap.modal","trNgGrid","ngMask"]).controller("navController",["$scope","$location",navController]).controller("loginController",["$scope","$http","$location","notificationService",loginController]).controller("mtusController",["$scope","$http","$location","notificationService",mtusController]).controller("startingLineController",["$scope","$http","$location","notificationService",startingLineController]).controller("notifyController",["$scope","$timeout","$http","notificationService",notifyController]).factory("notificationService",["$rootScope",notificationService]).controller("autoSuggestController",["$scope","$http","$location",autoSuggestController]).controller("searchResultsController",["$scope","$http","$location","$anchorScroll",searchResultsController]).controller("topicSearchResultsController",["$scope","$http","$location",topicSearchResultsController]).controller("medcodeSearchResultsController",["$scope","$http","$location",medcodeSearchResultsController]).controller("topicMedicalCodesController",["$scope","$http","$location",topicMedicalCodesController]).controller("medicalCodeMappingController",["$scope","$http","$timeout","notificationService",medicalCodeMappingController]).controller("medicalCostsController",["$scope","$http","$location",medicalCostsController]).controller("atmController",["$scope","$http","$location",atmController]).controller("atmDrugsController",["$scope","$http","$location",atmDrugsController]).controller("atmTreatmentController",["$scope","$http","$location",atmTreatmentController]).controller("nyMasDrugsController",["$scope","$http","$location",nyMasDrugsController]).controller("nyMasTreatmentController",["$scope","$http","$location","$window",nyMasTreatmentController]).controller("nyMtgController",["$scope","$http","$filter","$location",nyMtgController]).controller("durationsController",["$scope","$http","$location","notificationService",durationsController]).controller("durationViewsController",["$scope","$filter","$http","$location","notificationService",durationViewsController]).controller("crosswalkController",["$scope","$http","$location","notificationService",crosswalkController]).controller("toolLayoutController",["$scope","$http","$location","notificationService",toolLayoutController]).controller("jobController",["$scope","$http","$location","notificationService",jobController]).controller("recommendationsController",["$scope","$http","$location","notificationService",recommendationsController]).controller("dartByRecommendationController",["$scope","$http","$location",dartByRecommendationController]).controller("dartByTreatmentController",["$scope","$http","$location",dartByTreatmentController]).controller("formularyController",["$scope","$http","$location","notificationService",formularyController]).directive("formularyDrugSearch",["$http","$timeout",formularyDrugSearchDirective]).directive("nyDrugSearch",["$http","$timeout",nyDrugSearchDirective]).directive("nySearch",[nySearchDirective]).directive("codeSearch",["$http","$timeout",codeSearchDirective]).directive("jobSearch",["$http","$timeout",jobSearchDirective]).directive("topicSearch",["$http","$timeout",topicSearchDirective]).directive("treatmentSearch",["$http","$timeout",treatmentSearchDirective]).directive("focusOn",["$timeout",function(n){return function(t,i,r){t.$on(r.focusOn,function(){n(function(){i[0].focus()},100)})}}]).directive("positiveInteger",function(){return{restrict:"A",link:function(n,t){t.on("keydown",function(n){return[110,190,69,189,107,109].indexOf(n.which)>-1?(n.preventDefault(),!1):!0})}}}).filter("titleCase",function(){return function(n){return n=n||"",n.replace(/\w\S*/g,function(n){return n.charAt(0).toUpperCase()+n.substr(1).toLowerCase()})}}).filter("unique",function(){return function(n,t){var r,u,i;if(n){for(r={},u=[],i=0;i<n.length;i++)typeof r[n[i][t]]=="undefined"&&(r[n[i][t]]="",u.push(n[i]));return u}}});blurFocusDirective=function(){return{restrict:"E",require:"?ngModel",link:function(n,t,i,r){if(r){t.addClass("ng-untouched");t.on("blur",function(){t.removeClass("ng-untouched");t.addClass("ng-touched")});t.closest("form").on("submit",function(){t.is(":visible")&&t.addClass("ng-touched")})}}}};contentModule.directive("input",blurFocusDirective);contentModule.directive("select",blurFocusDirective)