1"use strict";(self.webpackChunkscriptsure_react=self.webpackChunkscriptsure_react||[]).push([[82398],{7538:(e,s,t)=>{t.d(s,{A:()=>r});var i=t(65043);const r=i.forwardRef((function(e,s){return i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:s},e),i.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",clipRule:"evenodd"}))}))},8906:(e,s,t)=>{t.d(s,{V:()=>a});var i=t(39119);function r(e,s){const t=(0,i.a)(e),r=(0,i.a)(s),n=t.getTime()-r.getTime();return n<0?-1:n>0?1:n}function n(e,s){const t=(0,i.a)(e),r=(0,i.a)(s);return t.getFullYear()-r.getFullYear()}function a(e,s){const t=(0,i.a)(e),a=(0,i.a)(s),o=r(t,a),c=Math.abs(n(t,a));t.setFullYear(1584),a.setFullYear(1584);const l=o*(c-+(r(t,a)===-o));return 0===l?0:l}},9236:(e,s,t)=>{t.d(s,{z:()=>y});var i=t(64812),r=t(83364),n=t(92373),a=t(67797),o=t(93251),c=t(97459),l=t(13665),d=t(86015),u=t(83893),h=t(40795),g=t(77094),p=t(85451),m=t(46898),v=t(38717);class y{static instance(){return n.y.instance.get("setupService")}get isStopUsage(){return[m.Gb.BAA,m.Gb.ID_PROOF,m.Gb.APPROVAL_IDME,m.Gb.EULA].some((e=>{const s=this.getCheckStatus(e);return(e!==m.Gb.ID_PROOF||s!==m.vX.PENDING)&&((e!==m.Gb.EULA||s!==m.vX.PENDING)&&(s!==m.vX.SKIP&&s!==m.vX.COMPLETE))}))}get hasPending(){return[m.Gb.ID_PROOF].some((e=>this.getCheckStatus(e)===m.vX.PENDING))}get hasRequiredActions(){return[m.Gb.BAA,m.Gb.ID_PROOF,m.Gb.APPROVAL_IDME,m.Gb.EPCS_SETUP_USER,m.Gb.EULA].some((e=>{const s=this.getCheckStatus(e);return s!==m.vX.SKIP&&s!==m.vX.COMPLETE}))}get canViewDashboard(){return this.hasBasicAdminAccess||this.hasFullAdminAccess||this.hasRequiredActions}getCheckStatus(e){return this.checks.get(e)}getBlockMessage(e){return this.blockMessages.get(e)}get signedBaaDocuments(){return(0,r.z)(this._signedBaaDocuments,"Signed BAA Documents")}get eulaData(){return this._eulaData}get accessRequests(){return this._accessRequests}get epcsRequests(){return this._epcsRequests}get hasBasicAdminAccess(){return this.currentEntityService.hasBusinessUnitBasicAdminAccess(this.currentPractice.businessUnitId)}get hasFullAdminAccess(){return this.currentEntityService.hasBusinessUnitFullAdminAccess(this.currentPractice.businessUnitId)}get isCurrentUserPrescriber(){return this.currentUser.prescriber}get userStore(){return u.L.instance()}get currentEntityService(){return d.M.instance()}get accessRequestsService(){return h.F.instance()}get epcsService(){return g.D.instance()}get stripeService(){return p.d.instance()}get isVeterinarianApprovalOrg(){return this.currentEntityService.isVeterinarianApprovalOrg}get currentBusinessUnit(){return this.currentEntityService.currentBusinessUnit}get currentOrganization(){return this.currentEntityService.currentOrganization}get currentUser(){return this.currentEntityService.currentUser}get currentPractice(){return this.currentEntityService.currentPractice}constructor(){this.setupCheckNeed=!0,this.checks=new Map,this.blockMessages=new Map,this._signedBaaDocuments=null,this._eulaData=null,this.lastChecks={accessRequests:new Date,epcsRequests:new Date},this.checkCurrentActions={accessRequests:new a.w,epcsRequests:new a.w},this._accessRequests=[],this._epcsRequests=[],this.setupCheckAction=new a.w,this.disposer=new o.W,(0,i.l_)(this,void 0,{autoBind:!0})}purge(){this.disposer.dispose()}async refresh(){await this.userStore.refreshSession(),await this.userStore.refreshUser(),await this.performSetupChecks()}async performSetupChecksIfNeed(){this.setupCheckNeed&&await this.performSetupChecks()}async performSetupChecks(){const e=this.setupCheckAction.start();this.blockMessages.clear(),this.setupCheckNeed=!1;const s=await this.checkUserSetup();if(!this.setupCheckAction.is(e))return;if(s.forEach((e=>{var s,t;(this.checks.set(e.checkId,e.status),e.blockMessage&&this.blockMessages.set(e.checkId,e.blockMessage),e.checkId===m.Gb.BAA)&&(this._signedBaaDocuments=null!==(s=e.documents)&&void 0!==s?s:[]);e.checkId===m.Gb.EULA&&(this._eulaData=null!==(t=e.data)&&void 0!==t?t:null)})),await Promise.all([this.checkEpcs(),this.checkAccessRequest()]),!this.setupCheckAction.is(e))return;this.disposer.push((0,c.P4)((()=>{this.setupCheckAction.is(e)&&(0,i.h5)((()=>{this.setupCheckNeed=!0}))}),3e5))}async checkEpcs(){const e=this.checkCurrentActions.epcsRequests.start();if(this.isVeterinarianApprovalOrg)return;const s=await this.epcsService.getEpcsPending(this.currentUser.id);this.checkCurrentActions.epcsRequests.is(e)&&(this._epcsRequests=s,this.lastChecks.epcsRequests=new Date)}async checkAccessRequest(){const e=this.checkCurrentActions.accessRequests.start(),s=await this.accessRequestsService.getAccessRequestPending(this.currentUser.id);this.checkCurrentActions.accessRequests.is(e)&&(this._accessRequests=s,this.lastChecks.accessRequests=new Date)}async checkUserSetup(e=[]){const s=[...e];return l.l2&&s.push(m.Gb.BILLING,m.Gb.BAA),(0,v.In)((0,m.c_)({skipChecks:Array.from(new Set(s))}))}async recheck(...e){const s=[m.Gb.BILLING,m.Gb.EPCS,m.Gb.ID_PROOF,m.Gb.ACCESS_REQUEST,m.Gb.EPCS_SETUP_USER,m.Gb.EPA,m.Gb.EULA,m.Gb.BAA,m.Gb.PRACTICE_LOCATIONS,m.Gb.APPROVAL_IDME].filter((s=>!e.includes(s)));(await this.checkUserSetup(s)).filter((s=>
1e.includes(s.checkId))).forEach((e=>{var s;(this.checks.set(e.checkId,e.status),e.blockMessage?this.blockMessages.set(e.checkId,e.blockMessage):this.blockMessages.has(e.checkId)&&this.blockMessages.delete(e.checkId),e.checkId===m.Gb.BAA)&&(this._signedBaaDocuments=null!==(s=e.documents)&&void 0!==s?s:[])}))}}n.y.setSetupFn("setupService",(()=>new y))},11579:(e,s,t)=>{t.d(s,{m:()=>r});var i=t(58316);const r=e=>{var s,t,r,n,a,o,c,l,d,u;const h={};var g,p,m;if(e.pharmacyNote&&(h.Note=e.pharmacyNote),e.combinationMed)h.DrugDescription=null!==(g=null!==(p=e.compoundTitle)&&void 0!==p?p:e.drugName)&&void 0!==g?g:void 0,h.Product={},h.Product.CompoundInformation={FinalCompoundPharmaceuticalDosageForm:e.compoundQuantityQualifier,CompoundIngredients:(null===(m=e.PrescriptionDrugs)||void 0===m?void 0:m.map((e=>{var s;return{CompoundIngredient:{DEASchedule:Number(e.MED_REF_DEA_CD)?{Code:(0,i.Yp)(e.MED_REF_DEA_CD)}:void 0,CompoundIngredientItemDescription:e.drugName||"",ItemNumber:e.manufacturer||e.ndc?{NDC:null!==(s=e.manufacturer)&&void 0!==s?s:e.ndc}:void 0},Quantity:{Value:e.quantity?String(e.quantity):"",CodeListQualifier:"38",QuantityUnitOfMeasure:{Code:e.quantityQualifier||""}}}})))||[]},e.compoundQuantity&&(h.Quantity={Value:String(e.compoundQuantity),CodeListQualifier:"CF",QuantityUnitOfMeasure:{Code:e.compoundQuantityQualifier}});else if(null!==(s=e.PrescriptionDrugs)&&void 0!==s&&s[0]){var v;const s=e.PrescriptionDrugs[0];h.DrugDescription=s.drugName,h.Product={},h.Product.DrugCoded={NDC:null!==(v=s.manufacturer)&&void 0!==v?v:s.ndc,ProductCode:s.rxnorm?{Code:s.rxnorm,Qualifier:s.rxnormQualifier}:void 0},s.quantity&&(h.Quantity={Value:String(s.quantity),CodeListQualifier:"38",QuantityUnitOfMeasure:{Code:s.quantityQualifier}})}e.writtenDate&&(h.WrittenDate={Date:e.writtenDate}),e.fillDate&&(h.LastFillDate={Date:e.fillDate});const y=null!==(t=null===(r=e.PrescriptionDrugs)||void 0===r||null===(n=r[0])||void 0===n?void 0:n.useSubstitution)&&void 0!==t?t:e.useSubstitution;if(void 0!==y&&(h.Substitutions={Substitutions:y?"0":"1"}),null!==(a=e.PrescriptionCompoundSigs)&&void 0!==a&&null!==(o=a[0])&&void 0!==o&&o.line3)h.Sig={SigText:e.PrescriptionCompoundSigs[0].line3};else if(null!==(c=e.PrescriptionDrugs)&&void 0!==c&&null!==(l=c[0])&&void 0!==l&&null!==(d=l.PrescriptionSigs)&&void 0!==d&&null!==(u=d[0])&&void 0!==u&&u.line3){var f,A;h.Sig={SigText:null===(f=e.PrescriptionDrugs)||void 0===f||null===(A=f[0])||void 0===A?void 0:A.PrescriptionSigs[0].line3}}return void 0!==e.refill&&(h.NumberOfRefills=e.refill),{...h}}},16632:(e,s,t)=>{t.d(s,{z:()=>n});var i=t(72187),r=t(16815);function n(e,s){return(0,i.A)(e,s*r.Cg)}},19586:(e,s,t)=>{t.d(s,{L:()=>i});const i=async(e,s=300)=>{const t=[];let i=0,r=0;do{var n,a;const o=await e({offset:i,limit:s}),c=null!==(n=o.data)&&void 0!==n?n:[];if(t.push(...c),r=null!==(a=o.totalCount)&&void 0!==a?a:t.length,i+=s,0===c.length)break}while(t.length<r);return t}},30969:(e,s,t)=>{t.d(s,{A:()=>l});var i=t(65043),r=t(92350),n=t(78510),a=t(74040),o=t(70579);const c=({isLoading:e,show:s=!0,hideBackDrop:t,children:c})=>{const[l,d]=(0,i.useState)(!1),u=(0,i.useRef)(null);return(0,i.useEffect)((()=>{const s=setTimeout((()=>{d(!e)}),e?350:50);return()=>{clearTimeout(s)}}),[e]),(0,o.jsxs)(n.A,{open:s,classes:{foreFront:"!bg-transparent !border-none !shadow-none"},hideBackdrop:t,disableOverlay:!0,unmount:!0,noMobileFullscreen:!0,initialFocus:u,children:[(e||!l)&&(0,o.jsx)(r.n1,{contain:e,children:(0,o.jsx)("button",{ref:u,type:"button",className:"cursor-default",children:(0,o.jsx)(a.A,{size:"xl"})})}),l&&(0,o.jsx)(o.Fragment,{children:c})]})};c.displayName="FullScreenLoader";const l=c},31021:(e,s,t)=>{t.d(s,{c:()=>n});var i=t(60147),r=t(39119);function n(e,s){const t=(0,r.a)(e),n=(0,r.a)(s),o=a(t,n),c=Math.abs((0,i.m)(t,n));t.setDate(t.getDate()-o*c);const l=o*(c-Number(a(t,n)===-o));return 0===l?0:l}function a(e,s){const t=e.getFullYear()-s.getFullYear()||e.getMonth()-s.getMonth()||e.getDate()-s.getDate()||e.getHours()-s.getHours()||e.getMinutes()-s.getMinutes()||e.getSeconds()-s.getSeconds()||e.getMilliseconds()-s.getMilliseconds();return t<0?-1:t>0?1:t}},31447:(e,s,t)=>{t.d(s,{B:()=>v});var i=t(64812),r=t(53536),n=t(33418),a=t(67421),o=t(36892),c=t(92373),l=t(38717),d=t(84991),u=t(92325),h=t(16354),g=t(19586);const p={offset:0,limit:20},m={sortedBy:"lastName",desc:!1};class v{static instance(){return c.y.instance.get("practiceService")}constructor(){(0,i.l_)(this,void 0,{autoBind:!0})}async updateCurrentAdminPractice(e,s){return(0,l.In)((0,o.Hx)(e,s))}async addPractice(e){return(0,l.In)((0,o.Dh)(e))}async exportUserList(e,s){const t=await(0,l.In)((0,o.O4)(e,s));(0,n.SP)(t,(s?"fullUserList":"userList")+".xlsx")}async getAdminPracticeNew(e,s){return(0,l.In)((0,o.Y4)(e),s)}async getPracticeUsers(e){return(0,g.L)((s=>this.getPracticeUsersPaginated(e,s,m)))}async getPracticeUserInvites(e){return(0,g.L)((s=>this.getPracticeUserInvitesPaginated(e,s,m)))}async getPracticeUsersPaginated(e,s=p,t=m,i){return(0,l.In)((0,o.b$)(e,s,t,i))}async getPracticeUserInvitesPaginated(e,s=p,t=m,i){return(0,l.In)((0,o.Cv)(e,s,t,i))}async getPracticeUsersActiveCount(e){return(0,l.In)((0,o.Oz)(e))}async getPracticeAdmins(e){return(0,l.In)((0,o.O5)(e))}async updatePracticeUsers(e,s){return(0,l.In)((0,o.HO)(e,s))}async activatePractice(e){return(0,l.In)((0,o.R4)(e))}async inactivatePractice(e){return(0,l.In)((0,o.MA)(e))}async movePractice(e,s){return(0,l.In)((0,o.Zg)(e,s))}async testPracticeMoveHasIssues(e,s){return(0,l.In)((0,o.uw)(e,s))}async checkPracticeHasPrescribers(e){var s;return(null!==(s=await this.getPracticeUsers(e))&&void 0!==s?s:[]).some((e=>e.prescriber&&e.userStatus===d.ZI.ACTIVE))}async pushPracticeNotification(e){return(0,l.In)((0,o.zk)(e))}async getPracticeHighLevelInactiveEntity(e){const s={},t=await(0,l.In)((0,u.Zn)(e));t.businessUnitStatus!==u.mj.ACTIVE&&(s.businessUnit=t);const i=await(0,l.In)((0,h.SA)(t.organizationId));
1return i.organizationStatus!==h.D9.ACTIVE&&(s.organization=i),(0,r.isEmpty)(s)?null:s}async getPracticeActivateConfirmContent(e){const s=await this.getPracticeHighLevelInactiveEntity(e);return null!==s&&void 0!==s&&s.businessUnit&&null!==s&&void 0!==s&&s.organization?new a.Z("practice.activation.with.inactive.bu.and.organization.confirm"):null!==s&&void 0!==s&&s.businessUnit?new a.Z("practice.activation.with.inactive.bu.confirm"):null!==s&&void 0!==s&&s.organization?new a.Z("practice.activation.with.inactive.organization.confirm"):new a.Z("practice.activation.confirm")}async pushPatientRecordsOfPracticeNotification(e){return(0,l.In)((0,o.HK)(e))}}c.y.setSetupFn("practiceService",(()=>new v))},33483:(e,s,t)=>{t.d(s,{Y:()=>o});var i=t(64812),r=t(72165),n=t(92373),a=t(38717);class o{static instance(){return n.y.instance.get("orderSetService")}constructor(){(0,i.l_)(this,void 0,{autoBind:!0})}async getOrder(e){return(0,a.In)((0,r.r$)(e))}async saveOrdersetSequence(e){return(0,a.In)((0,r.b5)(e))}async updateOrderSetSequence(e){const s=JSON.stringify(e).replace("OrderDrugs","PrescriptionDrugs");return(0,a.In)((0,r.R)(JSON.parse(s)))}async updateOrderSet(e){return(0,a.In)((0,r.E9)(e))}async saveOrderSet(e){return(0,a.In)((0,r.gx)(e))}async updateDiagnosis(e){return(0,a.In)((0,r.Dv)(e))}async deleteOrderDrugDiagnosis(e,s,t){return(0,a.In)((0,r.Xc)({orderId:e,diagnosisId:s,conceptId:t}))}async getOrdersets(e){return(0,a.In)((0,r.iU)(e))}async getOrderSetDetail(e){return(0,a.In)((0,r.Kz)(e))}async getOrderSetsByPractice(e,s){return(0,a.In)((0,r.TS)(e,s))}async getDrugSearchOrderSetsByPractice(e,s){return(0,a.In)((0,r.PR)(e,s))}async getPaginatedOrderSetsByPractice(e,s){return(0,a.In)((0,r.cv)(e,s))}async deleteOrderSet(e){return(0,a.In)((0,r.ul)(e))}async favoriteAll(e){return(0,a.In)((0,r.cZ)(e))}async deleteFavoriteOrderset(e){return(0,a.In)((0,r.GJ)(e))}async saveOrderSetUser(e){return(0,a.In)((0,r.xZ)(e))}async deleteOrderSetUser(e,s){return(0,a.In)((0,r.tI)(e,s))}async saveOrderSetPractice(e){return(0,a.In)((0,r.fX)(e))}async deleteOrderSetPractice(e,s){return(0,a.In)((0,r.pD)(e,s))}async deleteOrderSetSequence(e,s){return(0,a.In)((0,r.nw)(e,s))}async cloneOrderSet(e,s,t){return(0,a.In)((0,r.Kh)(e,s,t))}getOrderSetOrderDiagnoses(e){var s;const t=[];return null===(s=e.OrdersetSequences)||void 0===s||s.forEach((e=>{var s;e.ordersetType===r.kj.DIAGNOSIS&&(null===(s=e.OrderDiagnoses)||void 0===s||s.forEach((e=>{t.push(e)})))})),t}async getOrderSet(e){return(0,a.In)((0,r.LK)(e))}async updateOrderSetInsurance(e){return(0,a.In)((0,r.gB)(e))}async getOrderSetsByVendor(e){return(0,a.In)((0,r.g)(e))}async getVendorOrdersetsDrugFormats(e,s){return(0,a.In)((0,r.Gm)(e,s))}async getVendorOrderSetDetail(e){return(0,a.In)((0,r.cx)(e))}async cloneVendorOrderSet(e,s,t,i){return(0,a.In)((0,r.IL)(e,s,t,i))}async updateVendorOrderSet(e,s){return(0,a.In)((0,r.w8)(e,s))}async saveVendorOrderSet(e){return(0,a.In)((0,r.W$)(e))}async deleteOrderSetVendor(e){return(0,a.In)((0,r.ox)(e))}}n.y.setSetupFn("orderSetService",(()=>new o))},33787:(e,s,t)=>{t.d(s,{A:()=>r});var i=t(65043);const r=i.forwardRef((function(e,s){return i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:s},e),i.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-8.707l-3-3a1 1 0 00-1.414 1.414L10.586 9H7a1 1 0 100 2h3.586l-1.293 1.293a1 1 0 101.414 1.414l3-3a1 1 0 000-1.414z",clipRule:"evenodd"}))}))},34096:(e,s,t)=>{function i(e){if(e)if("function"!==typeof e.throwIfAborted){if(e.aborted){if(e.reason)throw e.reason;if("undefined"!==typeof DOMException)throw new DOMException("Aborted","AbortError");const s=new Error("Aborted");throw s.name="AbortError",s}}else e.throwIfAborted()}t.d(s,{T:()=>i})},36135:(e,s,t)=>{t.d(s,{A:()=>r});var i=t(65043);const r=i.forwardRef((function(e,s){return i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:s},e),i.createElement("path",{fillRule:"evenodd",d:"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",clipRule:"evenodd"}))}))},36870:(e,s,t)=>{t.d(s,{D:()=>r});var i=t(39119);function r(e){const s=(0,i.a)(e);return s.setHours(23,59,59,999),s}},40795:(e,s,t)=>{t.d(s,{F:()=>o});var i=t(64812),r=t(38717),n=t(92373),a=t(53834);class o{static instance(){return n.y.instance.get("accessRequestService")}constructor(){(0,i.l_)(this,void 0,{autoBind:!0})}async removeAccessRequest(e,s){return(0,r.In)((0,a.Y7)(e,s))}
1async saveAccessRequest(e){return(0,r.In)((0,a.jA)(e))}async getAccessRequestPending(e){return(0,r.In)((0,a.f3)(e))}}n.y.setSetupFn("accessRequestService",(()=>new o))},46566:(e,s,t)=>{t.d(s,{A:()=>r});var i=t(65043);const r=i.forwardRef((function(e,s){return i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:s},e),i.createElement("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"}))}))},46898:(e,s,t)=>{t.d(s,{Gb:()=>o,vX:()=>a,c_:()=>n});var i=t(16082),r=t(13665);const n=e=>(0,i.Ay)({method:"POST",url:`${r.dK}/v3/setup`,body:e});let a=function(e){return e.SKIP="SKIP",e.BLOCKED="BLOCKED",e.INCOMPLETE="INCOMPLETE",e.PARTIALLY_COMPLETE="PARTIALLY_COMPLETE",e.COMPLETE="COMPLETE",e.PENDING="PENDING",e}({}),o=function(e){return e[e.BILLING=1]="BILLING",e[e.EPCS=2]="EPCS",e[e.ID_PROOF=3]="ID_PROOF",e[e.ACCESS_REQUEST=4]="ACCESS_REQUEST",e[e.EPCS_SETUP_USER=5]="EPCS_SETUP_USER",e[e.EPA=6]="EPA",e[e.EULA=7]="EULA",e[e.BAA=8]="BAA",e[e.PRACTICE_LOCATIONS=9]="PRACTICE_LOCATIONS",e[e.APPROVAL_IDME=10]="APPROVAL_IDME",e}({})},48233:(e,s,t)=>{t.d(s,{I:()=>c});var i=t(42798),r=t(97459),n=t(58316),a=t(38717),o=t(43591);const c=async e=>{var s,t,c,l,d,u,h,g,p;const m={};e.Note&&(m.pharmacyNote=e.Note);const v=!Number((0,o.ab)(e));m.combinationMed=!!e.CompoundInformation||!(null===(s=e.Product)||void 0===s||!s.CompoundInformation),m.writtenDate=null!==(t=null===(c=e.WrittenDate)||void 0===c?void 0:c.DateTime)&&void 0!==t?t:null===(l=e.WrittenDate)||void 0===l?void 0:l.Date,m.fillDate=null!==(d=null===(u=e.LastFillDate)||void 0===u?void 0:u.DateTime)&&void 0!==d?d:null===(h=e.LastFillDate)||void 0===h?void 0:h.Date,m.useSubstitution=v;const y=null!==(g=e.NumberOfRefills)&&void 0!==g?g:(0,o.NW)(e.Extension,"NumberOfRefills");if(m.refill=void 0!==y?Number(y):void 0,m.drugName=e.DrugDescription,m.combinationMed){var f,A,R,D,M,w,S,C,x;m.compoundTitle=e.DrugDescription,m.compoundQuantityQualifier=null===(f=e.Quantity)||void 0===f||null===(A=f.QuantityUnitOfMeasure)||void 0===A?void 0:A.Code,m.compoundQuantity=null!==(R=e.Quantity)&&void 0!==R&&R.Value?Number(null===(D=e.Quantity)||void 0===D?void 0:D.Value):void 0,m.PrescriptionCompoundSigs=[{line3:null===(M=e.Sig)||void 0===M?void 0:M.SigText,doseQuantity:0,durationNumericValue:void 0,durationText:void 0,durationTextCode:void 0}];const s=(0,r.eC)(null!==(w=null===(S=e.CompoundInformation)||void 0===S?void 0:S.CompoundIngredientsLotNotUsed)&&void 0!==w?w:null===(C=e.Product)||void 0===C||null===(x=C.CompoundInformation)||void 0===x?void 0:x.CompoundIngredients);m.PrescriptionDrugs=s.map((e=>{var s,t,i,r,a;return{MED_REF_DEA_CD:(0,n.hM)(null===(s=e.CompoundIngredient)||void 0===s||null===(t=s.DEASchedule)||void 0===t?void 0:t.Code),drugName:null===(i=e.CompoundIngredient)||void 0===i?void 0:i.CompoundIngredientItemDescription,quantity:e.Quantity.Value,quantityQualifier:e.Quantity.QuantityUnitOfMeasure.Code,GCN_SEQNO:null,ndc:null===(r=e.CompoundIngredient)||void 0===r||null===(a=r.ItemNumber)||void 0===a?void 0:a.NDC}}))}else{var E,P,I,b,N,O,_,k,j,U,T,q,B,F;m.PrescriptionDrugs=[{ndc:(0,o.bk)(e)||null,rxnorm:(null===(E=e.Product)||void 0===E||null===(P=E.DrugCoded)||void 0===P||null===(I=P.ProductCode)||void 0===I?void 0:I.Code)||"",rxnormQualifier:(null===(b=e.Product)||void 0===b||null===(N=b.DrugCoded)||void 0===N||null===(O=N.ProductCode)||void 0===O?void 0:O.Qualifier)||"",ROUTED_MED_ID:0,GCN_SEQNO:0,MED_REF_DEA_CD:(0,n.hM)(null===(_=e.Product)||void 0===_||null===(k=_.DrugCoded)||void 0===k||null===(j=k.DEASchedule)||void 0===j?void 0:j.Code),drugName:e.DrugDescription||"",epn:e.DrugDescription,quantity:null!==(U=e.Quantity)&&void 0!==U&&U.Value?Number(null===(T=e.Quantity)||void 0===T?void 0:T.Value):void 0,quantityQualifier:null===(q=e.Quantity)||void 0===q||null===(B=q.QuantityUnitOfMeasure)||void 0===B?void 0:B.Code,useSubstitution:v,line1:"",PrescriptionSigs:[{line3:null===(F=e.Sig)||void 0===F?void 0:F.SigText}],formatId:0,drugId:0,drugOrder:0,maxDaily:0,calculate:0,line2:"",DrugOpioid:{ROUTED_MED_ID:0}
1}]}return null!==(p=m.PrescriptionDrugs)&&void 0!==p&&p.length&&(m.PrescriptionDrugs=await Promise.all(m.PrescriptionDrugs.map((async e=>{if(!e.ndc)return e;try{const[s]=await(0,a.In)((0,i.w0)(e.ndc));return s?{...e,ROUTED_MED_ID:s.ROUTED_MED_ID,GCN_SEQNO:s.GCN_SEQNO,rxnorm:s.rxNorm,rxnormQualifier:s.rxNormQualifier,MED_REF_DEA_CD:s.MED_REF_DEA_CD}:e}catch(s){return console.error(s),e}})))),{...m}}},53226:(e,s,t)=>{t.d(s,{A:()=>l});var i=t(6326),r=t(65043),n=t(23169),a=t(97);function o(e){var s=(0,a.A)(),t=s.formatMessage,i=s.textComponent,n=void 0===i?r.Fragment:i,o=e.id,c=e.description,l=e.defaultMessage,d=e.values,u=e.children,h=e.tagName,g=void 0===h?n:h,p=t({id:o,description:c,defaultMessage:l},d,{ignoreTag:e.ignoreTag});return"function"===typeof u?u(Array.isArray(p)?p:[p]):g?r.createElement(g,null,r.Children.toArray(p)):r.createElement(r.Fragment,null,p)}o.displayName="FormattedMessage";var c=r.memo(o,(function(e,s){var t=e.values,r=(0,i.Tt)(e,["values"]),a=s.values,o=(0,i.Tt)(s,["values"]);return(0,n.bN)(a,t)&&(0,n.bN)(r,o)}));c.displayName="MemoizedFormattedMessage";const l=c},53834:(e,s,t)=>{t.d(s,{Rd:()=>c,f3:()=>o,Y7:()=>a,jA:()=>n});var i=t(13665),r=t(16082);const n=e=>(0,r.Ay)({url:`${i.dK}/v3/accessrequest/user/request`,method:"POST",body:{...e}}),a=(e,s)=>(0,r.Ay)({url:`${i.dK}/v3/accessrequest/user/request/${e}/${s}`,method:"DELETE"}),o=e=>(0,r.Ay)({url:`${i.dK}/v3/accessrequest/user/request/${e}`,method:"GET"});let c=function(e){return e[e.ACTIVE=0]="ACTIVE",e[e.REQUESTED=1]="REQUESTED",e[e.APPROVED=2]="APPROVED",e[e.DENIED=3]="DENIED",e}({})},60742:(e,s,t)=>{t.d(s,{A:()=>r});var i=t(65043);const r=i.forwardRef((function(e,s){return i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:s},e),i.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"}))}))},62582:(e,s,t)=>{t.r(s),t.d(s,{BrowserRouter:()=>d,HashRouter:()=>u,Link:()=>y,MemoryRouter:()=>i.fS,NavLink:()=>R,Prompt:()=>i.XG,Redirect:()=>i.rd,Route:()=>i.qh,Router:()=>i.Ix,StaticRouter:()=>i.kO,Switch:()=>i.dO,generatePath:()=>i.tW,matchPath:()=>i.B6,useHistory:()=>i.W6,useLocation:()=>i.zy,useParams:()=>i.g,useRouteMatch:()=>i.W5,withRouter:()=>i.y});var i=t(91688),r=t(25540),n=t(65043),a=t(77321),o=t(58168),c=t(98587),l=t(3404),d=function(e){function s(){for(var s,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return(s=e.call.apply(e,[this].concat(i))||this).history=(0,a.createBrowserHistory)(s.props),s}return(0,r.A)(s,e),s.prototype.render=function(){return n.createElement(i.Ix,{history:this.history,children:this.props.children})},s}(n.Component);var u=function(e){function s(){for(var s,t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return(s=e.call.apply(e,[this].concat(i))||this).history=(0,a.createHashHistory)(s.props),s}return(0,r.A)(s,e),s.prototype.render=function(){return n.createElement(i.Ix,{history:this.history,children:this.props.children})},s}(n.Component);var h=function(e,s){return"function"===typeof e?e(s):e},g=function(e,s){return"string"===typeof e?(0,a.createLocation)(e,null,null,s):e},p=function(e){return e},m=n.forwardRef;"undefined"===typeof m&&(m=p);var v=m((function(e,s){var t=e.innerRef,i=e.navigate,r=e.onClick,a=(0,c.A)(e,["innerRef","navigate","onClick"]),l=a.target,d=(0,o.A)({},a,{onClick:function(e){try{r&&r(e)}catch(s){throw e.preventDefault(),s}e.defaultPrevented||0!==e.button||l&&"_self"!==l||function(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}(e)||(e.preventDefault(),i())}});return d.ref=p!==m&&s||t,n.createElement("a",d)}));var y=m((function(e,s){var t=e.component,r=void 0===t?v:t,d=e.replace,u=e.to,y=e.innerRef,f=(0,c.A)(e,["component","replace","to","innerRef"]);return n.createElement(i.XZ.Consumer,null,(function(e){e||(0,l.A)(!1);var t=e.history,i=g(h(u,e.location),e.location),c=i?t.createHref(i):"",v=(0,o.A)({},f,{href:c,navigate:function(){var s=h(u,e.location),i=(0,a.createPath)(e.location)===(0,a.createPath)(g(s));(d||i?t.replace:t.push)(s)}});return p!==m?v.ref=s||y:v.innerRef=y,n.createElement(r,v)}))}
1)),f=function(e){return e},A=n.forwardRef;"undefined"===typeof A&&(A=f);var R=A((function(e,s){var t=e["aria-current"],r=void 0===t?"page":t,a=e.activeClassName,d=void 0===a?"active":a,u=e.activeStyle,p=e.className,m=e.exact,v=e.isActive,R=e.location,D=e.sensitive,M=e.strict,w=e.style,S=e.to,C=e.innerRef,x=(0,c.A)(e,["aria-current","activeClassName","activeStyle","className","exact","isActive","location","sensitive","strict","style","to","innerRef"]);return n.createElement(i.XZ.Consumer,null,(function(e){e||(0,l.A)(!1);var t=R||e.location,a=g(h(S,t),t),c=a.pathname,E=c&&c.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1"),P=E?(0,i.B6)(t.pathname,{path:E,exact:m,sensitive:D,strict:M}):null,I=!!(v?v(P,t):P),b="function"===typeof p?p(I):p,N="function"===typeof w?w(I):w;I&&(b=function(){for(var e=arguments.length,s=new Array(e),t=0;t<e;t++)s[t]=arguments[t];return s.filter((function(e){return e})).join(" ")}(b,d),N=(0,o.A)({},N,u));var O=(0,o.A)({"aria-current":I&&r||null,className:b,style:N,to:a},x);return f!==A?O.ref=s||C:O.innerRef=C,n.createElement(y,O)}))}))},62656:(e,s,t)=>{t.d(s,{A:()=>i.A});var i=t(78510)},74144:(e,s,t)=>{t.d(s,{n:()=>c});var i=t(64812),r=t(72582),n=t(35129),a=t(92373),o=t(38717);class c{static instance(){return a.y.instance.get("compoundService")}constructor(){(0,i.l_)(this,void 0,{autoBind:!0})}async getCompoundDetail(e){const{response:s}=await(0,r.s)((0,n.dt)(e));return s}async saveCompound(e){return(0,o.In)((0,n.$h)(e))}async saveVendorCompound(e){return(0,o.In)((0,n.NR)(e))}async updateCompound(e){return(0,o.In)((0,n.HR)(e))}async updateVendorCompound(e,s){return(0,o.In)((0,n.Jd)(e,s))}*updateCompoundDetail(e){const{response:s}=yield(0,r.s)((0,n.WG)(e));return s}*deleteCompoundDrugDiagnosis(e,s,t){const{response:i}=yield(0,r.s)((0,n.Ui)(e,s,t));return i}async getCompoundsByPractice(e,s,t){const{response:i}=await(0,r.s)((0,n.iC)(e,null!==s&&void 0!==s&&s,t));return i}async getDrugSearchCompoundsByPractice(e,s){const{response:t}=await(0,r.s)((0,n.yf)(e,s));return t}async getPaginatedCompoundsByPractice(e,s,t){return(0,o.In)((0,n.DI)(e,null!==s&&void 0!==s&&s,t))}async getVendorCompounds(e){const{response:s}=await(0,r.s)((0,n.VG)(e));return s}async getDrugSearchCompoundsByVendor(e){const{response:s}=await(0,r.s)((0,n.hh)(e));return s}async getVendorCompoundDetail(e){const{response:s}=await(0,r.s)((0,n.xK)(e));return s}async getCompoundById(e){return(0,o.In)((0,n.AY)(e))}*deleteCompound(e){const{response:s}=yield(0,r.s)((0,n.dx)(e));return s}async deleteVendorCompound(e){const{response:s}=await(0,r.s)((0,n.Rc)(e));return s}*favoriteAll(e){const{response:s}=yield(0,r.s)((0,n.cZ)(e));return s}*deleteFavoriteCompound(e){const{response:s}=yield(0,r.s)((0,n.XG)(e));return s}*deleteCompoundPractice(e,s){const{response:t}=yield(0,r.s)((0,n.ip)(e,s));return t}*deleteCompoundUser(e,s){const{response:t}=yield(0,r.s)((0,n.QF)(e,s));return t}async cloneCompound(e,s,t){return(0,o.In)((0,n.XU)(e,s,t))}async cloneVendorCompound(e,s,t,i){return(0,o.In)((0,n.Ro)(e,s,t,i))}*saveCompoundUsers(e){const{response:s}=yield(0,r.s)((0,n.HK)(e));return s}*saveCompoundPractices(e){const{response:s}=yield(0,r.s)((0,n.Pd)(e));return s}}a.y.setSetupFn("compoundService",(()=>new c))},77094:(e,s,t)=>{t.d(s,{D:()=>l});var i=t(92373),r=t(84991),n=t(38717),a=t(3444),o=t(86015),c=t(49411);class l{static instance(){return i.y.instance.get("epcsService")}get currentEntityService(){return o.M.instance()}get currentUser(){return this.currentEntityService.currentUser}get securityStore(){return c.y.instance()}async getEpcsPending(e){return(0,n.In)((0,r.F7)(e))}async saveEpcs(e){return(0,n.In)((0,r.iD)(e))}async deleteEpcsById(e){return(0,n.In)((0,a.z3)(e))}async getEpcsPracticeUser(e,s){return(0,n.In)((0,r.u9)(e,s))}async approveEpcsNoAlert(e,s){if(!this.securityStore.can("EPCSRequestApprove",!0))return!1;if(this.currentUser.id===e.userId)return!1;switch(s){case r.Vu.APPROVED:return await this.saveEpcs({...e,reviewedUserId:this.currentUser.id,reviewedUserName:`${this.currentUser.firstName} ${this.currentUser.lastName}`,status:r.Vu.APPROVED}),!0;case r.Vu.DECLINED:return await this.saveEpcs({...e,reviewedUserId:this.currentUser.id,reviewedUserName:`${this.currentUser.firstName} ${this.currentUser.lastName}`,status:r.Vu.DECLINED}),!0;default:return!1}}}i.y.setSetupFn("epcsService",(()=>new l))},85451:(e,s,t)=>{t.d(s,{d:()=>l});var i=t(64812),r=t(83364),n=t(92373),a=t(13665),o=t(38717),c=t(73722);class l{static instance(){return n.y.instance.get("stripeService")}get isInitialized(){return this._isInitialized}get stripe(){return(0,r.z)(this._stripe,"Stripe")}constructor(){this._isInitialized=!1,this.stripePromise=void 0,this._stripe=void 0,(0,i.l_)(this,void 0,{autoBind:!0})}*init(){this._isInitialized||(this.stripePromise&&(yield this.stripePromise),this.stripePromise=t.e(74397).then(t.bind(t,74397)).then((({loadStripe:e})=>e(a.kz))),this._stripe=yield this.stripePromise,this.stripePromise=null,this._isInitialized=!0)}async getCustomer(e){return(0,o.In)((0,c.xt)(e))}async checkBilling(e){return(0,o.In)((0,c.KX)(e))}}n.y.setSetupFn("stripeService",(()=>new l))},98245:(e,s,t)=>{t.r(s),t.d(s,{default:()=>he});var i=t(65043),r=t(68703);const n=i.forwardRef((function(e,s){return i.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:s},e),i.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm.707-10.293a1 1 0 00-1.414-1.414l-3 3a1 1 0 000 1.414l3 3a1 1 0 001.414-1.414L9.414 11H13a1 1 0 100-2H9.414l1.293-1.293z",clipRule:"evenodd"}))}));var a=t(33787),o=t(23180),c=t(1684),l=t(62656),d=t(76903),u=t(26762),h=t(67146),g=t(64266),p=t(67714),m=t(19167),v=t
1(23246),y=t(89579),f=t(51432),A=t(28580),R=t(13665),D=t(68154),M=t(64812),w=t(53536),S=t(72582),C=t(86178),x=t.n(C),E=t(16800),P=t(37693),I=t(50084),b=t(42798),N=t(39570),O=t(28706),_=t(67421),k=t(23217),j=t(59667),U=t(86015),T=t(6164),q=t(137),B=t(83160),F=t(38717),L=t(83893),X=t(83364),Q=t(48608),z=t(29872),H=t(30730),G=t(5022),V=t(78060),Z=t(49411),$=t(58316),K=t(55709),Y=t(1840),W=t(48233),J=t(11579),ee=t(74966),se=t(63115);class te{get isInitialized(){return this._isInitialized}get isLoading(){return this._isLoading}get hasUpdate(){return this._hasUpdate}get securityStore(){return Z.y.instance()}get messageService(){return G.b.instance()}get userStore(){return L.L.instance()}get errorService(){return j.I.instance()}get drugHistoryService(){return Q.M.instance()}get hasDawAccess(){return this.currentEntityService.hasDawAccess}get rootEvents(){return q.U.instance()}get prescriptionService(){return z.q.instance()}get isEpaEnabled(){return!R.c7&&this.currentEntityService.hasOrganizationPermission("EPA_ENABLED")&&this.userStore.practiceSettings.get("ENABLE_EPA_PRACTICE")&&!this.userStore.doctorSettings.get("DISABLE_EPA_DOCTOR")}async refreshMessageXml(){const e=this.messages[this.currentMessage],s=await(0,F.In)((0,E.kA)(e.messageId));this.message.messageXml=s.Message.Body[e.messageType]}createPrescriptionAccessRules(){return new V.u$({prescription:this.message,type:V.DE.PRESCRIPTION_MESSAGE})}get patientStore(){return k.v.instance()}get pharmacyService(){return H.J.instance()}get currentEntityService(){return U.M.instance()}get currentUser(){return this.currentEntityService.currentUser}get canRespondChangeRx(){return(0,K.cj)(this.message,this.message.messageHistory)}*setResponse(e){try{this.response=e,yield this.parse(),this.message.comment="",this.message.prescriberAuthorization=void 0,this.message.priorAuthorization=void 0}catch(s){this.errorService.handleError(s)}}get responseTitle(){return this.config.responseTitle||("A"===this.response?"Approve":N.JC[this.response])}get dialog(){return this.config.dialog}get isHeldByEpa(){var e,s;return null!==(e=null===(s=this.epaProgressBlockModel)||void 0===s?void 0:s.isRxHeldByEpa)&&void 0!==e&&e}constructor(e){this.config=e,this._isInitialized=!1,this._isLoading=!0,this._hasUpdate=!1,this.prescriptionHospiceFormularyApproveModel=null,this.messages=[],this.wait=null,this.stopSend=!1,this.comments=[],this.pharmacy=null,this.maxRefill=98,this._message={messageId:"",messageType:"",requestId:0},this.initialMessageXml=null,this.response="",this.initialResponse="",this.quantityQualifiers=[],this.currentMessage=0,this.currentMessageTitle="",this.expires="",this.showRefill=!1,this.isProcessing=!1,this.prescribeMedicationModel=new A.mu,this.prescriptionActionsModel=new A.R(!1),this.dialogs=new B.l,this.messageHistoryActivityModel=null,this.epaProgressBlockModel=null,(0,M.l_)(this,{messages:M.sH,isProcessing:M.sH,showRefill:M.sH,currentMessageTitle:M.sH,currentMessage:M.sH},{autoBind:!0}),this.initialResponse=this.config.response}*update(){try{this._isLoading=!0,yield this.getMessageHistory(!0)}catch(e){this.handleActionError(e)}finally{this._isLoading=!1}}*init(){try{var e,s;if(this.response=this.config.response,yield this.setQuantityQualifier(),this.config.selectedMessages&&(yield this.setMessages(this.config.selectedMessages)),!R.c7&&this.currentEntityService.hasOrganizationPermission("REALTIME_FORMULARY_ENABLED")&&this.message.prescriptionId&&(this.prescriptionHospiceFormularyApproveModel=new Y.fm({prescriptionId:this.message.prescriptionId,onAfterCancelPrescription:()=>this.close(!0),onAfterConfirmCoverage:()=>{this.refreshMessageXml(),this.rootEvents.emit("refreshMedications"),this.currentEntityService.currentPatientOrNull&&this.rootEvents.emit("refreshPatientCurrentMedications")}}),yield this.prescriptionHospiceFormularyApproveModel.prepareData()),this.messageHistoryActivityModel=new ee.w({getHistory:()=>this.message.messageHistory||[]}),this.isEpaEnabled&&null!==(e=this.message)&&void 0!==e&&e.messageId)this.epaProgressBlockModel=new se.O({rxMessageId:null===(s=this.message)||void 0===s?void 0:s.messageId}),yield this.epaProgressBlockModel.init();this._isInitialized=!0}catch(t){this.errorService.handleError(t)}}get message(){return this._message}*getComments(){var e,s;if(null!==(e=this.messages)&&void 0!==e&&null!==(s=e[this.currentMessage])&&void 0!==s&&s.practiceId){var t,i;const{response:e}=yield(0,S.s)((0,I.vr)(null===(t=this.messages)||void 0===t||null===(i=t[this.currentMessage])||void 0===i?void 0:i.practiceId,1));this.comments=e}}*parse(){var e,s;this.showRefill=!0,this._message=this.messages[this.currentMessage],this._message.duration=0,this.setExpiration(),this._message.messageStatus=this.messages[this.currentMessage].messageStatus,(0,w.has)(this._message,"comment")||(this._message.comment=""),(0,w.has)(this._message,"refill")||(this._message.refill=0),null!==(e=this.messages[this.currentMessage])&&void 0!==e&&null!==(s=e.messageType)&&void 0!==s&&s.includes("CancelRx")&&(this.messages[this.currentMessage].messageType=m.cF.NewRx);try{yield this.getComments()}catch(t){this.handleActionError(t)}this.messages.length&&(this._message=this.messages[this.currentMessage]);try{yield this.getMessageHistory(!0)}catch(t){this.handleActionError(t),this.close(void 0)}finally{this._isLoading=!1}}*setQuantityQualifier(){this.quantityQualifiers=yield this.prescriptionService.getQuantityQualifiers()}*prescribeMedication(e){if(e.formatId&&e.delivered)try{if(!this.message.patientId)throw new Error("patientId is not set in message");const s=yield this.patientStore.getPatientDetail(this.message.patientId),t=yield this.prescribeMedicationModel.prescribeMedicationMessageResponse(e,s);if(!t)return;yield this.createMedicationResponse(t),yield this.prescriptionActionsModel.send(this.response,this.pharmacy,this.message,this.maxRefill),this.close(!0)}catch(s){this.handleActionError(s)}else try{this.addFormat(e,null,null,{})}catch(s){this.handleActionError(s)}}*send(e){try{if((0,m.v1)(this.message)){(yield this._sendRefill(e))&&(yield this.update())}else{(yield this._sendChange(e))&&(yield this.update())}}catch(s){this.errorService.handleError(s)}}handleActionError(e){this.errorService.handleError(e)}*_sendRefill(e){if("A"===e){this.securityStore.canOrError("CannotApproveRefills");if(!(yield this.dialogs.confirm.show({title:new _.Z("prescription.approve.refill"),content:new _.Z("prescription.approve.refill.desc")})))return}else{this.securityStore.canOrError("CannotDenyRefills");if(!(yield this.dialogs.confirm.show({title:new _.Z("prescription.deny.refill"),content:new _.Z("prescription.deny.refill.desc")})))return}yield this.setPracticeUser(this.message.doctorId),yield this.prescriptionActionsModel.send(null!==e&&void 0!==e?e:this.response,this.pharmacy,this.message,this.maxRefill),this.close(!0)}*_sendChange(e){if("A"===e){let e="prescription.approve.change",r="prescription.approve.change.desc";var s,t,i;if(this.currentEntityService.hasOrganizationPermission("EPA_ENABLED"))null!==(s=this.epaProgressBlockModel)&&void 0!==s&&s.epaExists||"P"!==(null===(t=this.message.messageXml)||void 0===t?void 0:t.MessageRequestCode)||(e="epa.changerx.approve.epa.not.started.header",r="epa.changerx.approve.epa.not.started.content"),null!==(i=this.epaProgressBlockModel)&&void 0!==i&&i.epaExists&&(this.epaProgressBlockModel.isEpaFinishedNotApproved&&(e="epa.changerx.approve.epa.not.approved.header",r="epa.changerx.approve.epa.not.approved.content"),this.epaProgressBlockModel.isEpaInProgress&&(e="epa.changerx.approve.epa.not.complete.header",r="epa.changerx.approve.epa.not.complete.content"));if(!(yield this.dialogs.confirm.show({title:new _.Z(e),content:new _.Z(r)}
1)))return}else{if(!(yield this.dialogs.confirm.show({title:new _.Z("prescription.deny.change"),content:new _.Z("prescription.deny.change.desc")})))return}yield this.setPracticeUser(this.message.doctorId),yield this.prescriptionActionsModel.send(null!==e&&void 0!==e?e:this.response,this.pharmacy,this.message,this.maxRefill),this.close(!0)}*addFormat(e,s,t,i){try{if(!this.message.patientId)throw new Error("patientId is not set in message");e&&(0,w.assign)(e,{epn:e.MED_MEDID_DESC});const s=yield this.patientStore.getPatientDetail(this.message.patientId),t=yield this.prescribeMedicationModel.addFormatMessageResponse(e,s);t&&(this._message.messageRequestedSelected=this.createMedicationResponse(t),this._message.approved="A",yield this.prescriptionActionsModel.send(this.response,this.pharmacy,this.message,this.maxRefill),this.close(!0))}catch(r){this.handleActionError(r)}}createMedicationResponse(e){const s={};if(s.isControlled=e.isControlled,s.drugDescription=`${e.PrescriptionDrugs[0].drugName||""} ${e.PrescriptionDrugs[0].line1||""}`,s.urgencyIndicatorCode=e.urgencyIndicatorCode,s.ndc=e.PrescriptionDrugs[0].ndc,s.rxnorm=e.PrescriptionDrugs[0].rxnorm,s.rxnormQualifier=e.PrescriptionDrugs[0].rxnormQualifier,e.PrescriptionDrugs[0].MED_REF_DEA_CD)switch(e.PrescriptionDrugs[0].MED_REF_DEA_CD){case"2":s.deaSchedule="C48675";break;case"3":s.deaSchedule="C48676";break;case"4":s.deaSchedule="C48677";break;case"5":s.deaSchedule="C48679"}const t=(0,w.find)(this.quantityQualifiers,(function(s){return s.potencyUnit===e.PrescriptionDrugs[0].quantityQualifier})),i=new Date,r=(0,$.ZK)(s.fillDate,i);return s.quantity=e.PrescriptionDrugs[0].quantity,s.potencyUnitCode=t.potencyUnit,s.effectiveDate=(0,$.Xs)(i,this.currentEntityService.currentPrescriberOrNull),s.writtenDate=(0,$.Xs)(r,this.currentEntityService.currentPrescriberOrNull),s.substitution=!0===e.PrescriptionDrugs[0].useSubstitution?0:1,s.refill=e.refill,s.diagnosis=e.diagnosis,s.pharmacyNote=e.pharmacyNote,e.freeFormDirections&&e.freeFormDirections.length>0?s.freeFormDirections=e.freeFormDirections.trim().toString():s.PrescriptionSigs=e.PrescriptionDrugs[0].PrescriptionSigs,this._message.messageRequestedSelected=s,"A"===this._message.approved&&(this._message.approved="C"),s}*getMessageHistory(e){var s,t,i,r,n,a,o,c,l,d,u,h,g,p,v,y,f,A,R,D,M,C,x,P,I,N,O,k,j,U,q,B,F,L,X,Q,z,H,G,V,Z;const $=yield(0,S.s)((0,E.Vy)(null===(s=this.messages[this.currentMessage])||void 0===s?void 0:s.requestId,this.messages[this.currentMessage].messageId));if(this._message.messageHistory=$.response||[],!e)return;const{response:K}=yield(0,S.s)((0,E.kA)(this.messages[this.currentMessage].messageId));if(!K)return;let Y="";const W={...K};if((0,w.has)(null===W||void 0===W||null===(t=W.Message)||void 0===t||null===(i=t.Body)||void 0===i||null===(r=i[null===(o=this.messages)||void 0===o||null===(c=o[this.currentMessage])||void 0===c?void 0:c.messageType])||void 0===r||null===(n=r.MedicationPrescribed)||void 0===n||null===(a=n.Product)||void 0===a?void 0:a.DrugCoded,"NDC")&&(Y=K.Message.Body[this.messages[this.currentMessage].messageType].MedicationPrescribed.Product.DrugCoded.NDC),"string"===typeof K)return;this._message.isOldScript=K.isOldScript;const[J]=Object.keys(K.Message.Body[this.messages[this.currentMessage].messageType].Patient);this._message.human=J;const[ee]=Object.keys(K.Message.Body[this.messages[this.currentMessage].messageType].Prescriber);var se,te,ie,re,ne,ae;if((this._message.veterinarian=ee,this._message.relatesToMessageId=K.Message.Header.RelatesToMessageID,this._message.messageXml=K.Message.Body[this.messages[this.currentMessage].messageType],this.initialMessageXml=K,this._message.ncpdpId=K.Message.Body[this.messages[this.currentMessage].messageType].Pharmacy.Identification.NCPDPID,this.messages[this.currentMessage].messageType===m.cF.RxChangeRequest)&&("T"===(null===K||void 0===K||null===(se=K.Message)||void 0===se||null===(te=se.Body)||void 0===te||null===(ie=te[null===(ne=this.messages)||void 0===ne||null===(ae=ne[this.currentMessage])||void 0===ae?void 0:ae.messageType])||void 0===ie||null===(re=ie.Request)||void 0===re?void 0:re.ChangeRequestType)&&this._message.patientId&&this._message.patientId>0&&this._message.patientId)){const e=yield this.patientStore.getPatientDetail(this._message.patientId);if(e&&e.patientId>0){const s=yield this.patientStore.getEligibility(e);if((0,w.assign)(e,{eligibilityItems:s}),e.eligibilityItems.length>0){(0,w.assign)(e,{currentEligibility:s[0]}),(0,w.assign)(e,{currentEligibilityIndex:0});const t={FormularyId:e.eligibilityItems[e.currentEligibilityIndex].formularyId,CoPayId:e.eligibilityItems[e.currentEligibilityIndex].copayId,CoverageId:e.eligibilityItems[e.currentEligibilityIndex].coverageId,Pbm:e.eligibilityItems[e.currentEligibilityIndex].pbm.identificationCode};if(Y)try{const{response:e}=yield(0,S.s)((0,E.be)(Y,t));e&&(this._message.alternatives=e.detail)}catch(Xe){this.handleActionError(Xe)}}}}let oe="0";switch(this.messages[this.currentMessage].messageType){case"RxRenewalRequest":if((0,w.has)(this.messages[this.currentMessage].messageXml,"MedicationDispensed")){var ce,le,de,ue,he,ge,pe,me,ve,ye,fe,Ae,Re,De;if(this.messages[this.currentMessage].messageXml.MedicationDispensed.PharmacyRequestedRefills&&(this._message.refill=Number(this.messages[this.currentMessage].messageXml.MedicationDispensed.PharmacyRequestedRefills)),null!==(ce=this.messages[this.currentMessage].messageXml)&&void 0!==ce&&null!==(le=ce.MedicationDispensed)&&void 0!==le&&null!==(de=le.Product)&&void 0!==de&&null!==(ue=de.DrugCoded)&&void 0!==ue&&ue.DEASc
1hedule){var Me;switch(null===(Me=this.messages[this.currentMessage].messageXml.MedicationDispensed.Product.DrugCoded.DEASchedule)||void 0===Me?void 0:Me.Code){case"C48672":oe="1";break;case"C48675":oe="2";break;case"C48676":oe="3";break;case"C48677":oe="4";break;case"C48679":oe="5"}}if((0,w.isArray)(null===(he=this.messages[this.currentMessage].messageXml)||void 0===he||null===(ge=he.MedicationDispensed)||void 0===ge||null===(pe=ge.Product)||void 0===pe||null===(me=pe.CompoundInformation)||void 0===me?void 0:me.CompoundIngredients)&&(0,w.forEach)(this.messages[this.currentMessage].messageXml.MedicationDispensed.Product.CompoundInformation.CompoundIngredients,(e=>{if((0,w.has)(e.CompoundIngredient,"DEASchedule"))switch(e.CompoundIngredient.DEASchedule.Code){case"C48672":oe="1";break;case"C48675":oe="2";break;case"C48676":oe="3";break;case"C48677":oe="4";break;case"C48679":oe="5"}})),null!==(ve=this.messages[this.currentMessage].messageXml)&&void 0!==ve&&null!==(ye=ve.MedicationDispensed)&&void 0!==ye&&null!==(fe=ye.Product)&&void 0!==fe&&null!==(Ae=fe.CompoundInformation)&&void 0!==Ae&&null!==(Re=Ae.CompoundIngredients)&&void 0!==Re&&null!==(De=Re.CompoundIngredient)&&void 0!==De&&De.DEASchedule)switch(this.messages[this.currentMessage].messageXml.MedicationDispensed.Product.CompoundInformation.CompoundIngredients.CompoundIngredient.DEASchedule.Code){case"C48672":oe="1";break;case"C48675":oe="2";break;case"C48676":oe="3";break;case"C48677":oe="4";break;case"C48679":oe="5"}}this._message.refill&&0!==this._message.refill||(this._message.refill=1);break;case"RxChangeRequest":if(null!==(l=this.messages[this.currentMessage].messageXml)&&void 0!==l&&null!==(d=l.MedicationPrescribed)&&void 0!==d&&null!==(u=d.Product)&&void 0!==u&&null!==(h=u.DrugCoded)&&void 0!==h&&h.DEASchedule){switch(this.messages[this.currentMessage].messageXml.MedicationPrescribed.Product.DrugCoded.DEASchedule.Code){case"C48672":oe="1";break;case"C48675":oe="2";break;case"C48676":oe="3";break;case"C48677":oe="4";break;case"C48679":oe="5"}}}this.messages[this.currentMessage].drugcode=oe;let we,Se="";if((0,w.has)(null===(g=this.messages[this.currentMessage])||void 0===g||null===(p=g.messageXml)||void 0===p||null===(v=p.MedicationDispensed)||void 0===v||null===(y=v.Product)||void 0===y?void 0:y.DrugCoded,"NDC")&&(Se=this.messages[this.currentMessage].messageXml.MedicationDispensed.Product.DrugCoded.NDC),Se&&"0"===oe){const{response:e}=yield(0,S.s)((0,b.w0)(Se)),s=e[0];switch(s&&(oe=s.MED_REF_DEA_CD,this.messages[this.currentMessage].drugcode=oe),oe){case"1":case"2":(0,w.has)(null===(f=K.Message.Body)||void 0===f||null===(A=f[null===(R=this.messages)||void 0===R||null===(D=R[this.currentMessage])||void 0===D?void 0:D.messageType])||void 0===A?void 0:A.MedicationPrescribed,"NumberOfRefills")&&(W.Message.Body[this.messages[this.currentMessage].messageType].MedicationPrescribed.NumberOfRefills=1),(0,w.has)(null===(M=K.Message.Body)||void 0===M||null===(C=M[null===(x=this.messages)||void 0===x||null===(P=x[this.currentMessage])||void 0===P?void 0:P.messageType])||void 0===C?void 0:C.MedicationResponse,"NumberOfRefills")&&(W.Message.Body[this.messages[this.currentMessage].messageType].MedicationResponse.NumberOfRefills=1),this.showRefill=!1;break;case"3":case"4":case"5":(0,w.has)(null===(I=K.Message.Body)||void 0===I||null===(N=I[null===(O=this.messages)||void 0===O||null===(k=O[this.currentMessage])||void 0===k?void 0:k.messageType])||void 0===N?void 0:N.MedicationPrescribed,"NumberOfRefills")&&(W.Message.Body[this.messages[this.currentMessage].messageType].MedicationPrescribed.NumberOfRefills=1),(0,w.has)(null===(j=K.Message.Body)||void 0===j||null===(U=j[null===(q=this.messages)||void 0===q||null===(B=q[this.currentMessage])||void 0===B?void 0:B.messageType])||void 0===U?void 0:U.MedicationResponse,"NumberOfRefills")&&(W.Message.Body[this.messages[this.currentMessage].messageType].MedicationResponse.NumberOfRefills=1),this.maxRefill=4,this.showRefill=!0;break;case"0":if("ZZ"===this.response&&this.messages[this.currentMessage].messageType!==m.cF.RxChangeRequest){if(yield this.dialogs.confirm.show({content:new _.Z("prescription.detail.replace.description"),title:new _.Z("prescription.detail.replace"),ok:new _.Z("ok"),shownCancel:!1,type:"info"}))return void this.close(void 0)}this.showRefill=!0;break;default:this.showRefill=!0}}if("RxRenewalRequest"===this.messages[this.currentMessage].messageType)if(we=(null===(F=this.messages)||void 0===F||null===(L=F[this.currentMessage])||void 0===L?void 0:L.messageHistory)||null,this.currentMessage&&we&&null!==(X=we)&&void 0!==X&&X.length){var Ce;const e=we[(null===(Ce=we)||void 0===Ce?void 0:Ce.length)-1];var xe,Ee,Pe,Ie,be,Ne,Oe,_e,ke,je;if((0,w.has)(e.messageXml.Message.Body,"RxRenewalResponse"))this.messages[this.currentMessage].refill=Number(e.messageXml.Message.Body.RxRenewalResponse.MedicationResponse.NumberOfRefills)-1,(0,w.has)(null===(xe=e.messageXml.Message)||void 0===xe||null===(Ee=xe.Body)||void 0===Ee||null===(Pe=Ee.RxRenewalResponse)||void 0===Pe||null===(Ie=Pe.Response)||void 0===Ie?void 0:Ie.Denied,"DenialReason")&&(this.messages[this.currentMessage].comment=e.messageXml.Message.Body.RxRenewalResponse.Response.Denied.DenialReason),(0,w.has)(null===(be=e.messageXml.Message.Body)||void 0===be||null===(Ne=be.RxRenewalResponse)||void 0===Ne||null===(Oe=Ne.Response)||void 0===Oe?void 0:Oe.Approved,"Note")&&(this.messages[this.currentMessage].comment=e.messageXml.Message.Body.RxRenewalResponse.Response.Approved.Note),(0,w.has)(null===(_e=e.messageXml.Message.Body)||void 0===_e||null===(ke=_e.RxRenewalResponse)||void 0===ke||null===(je=ke.Response)||void 0===je?void 0:je.ApprovedWithChanges,"Note")&&(this.messages[this.currentMessage].comment=e.messageXml.Message.Body.RxRenewalResponse.Response.ApprovedWithChanges.Note)}const Ue=this._message.ncpdpId,Te="0000000"===Ue;if(Ue&&!Te){var qe;const e=yield this.pharmacyService.getPharmacy(Ue);this.pharmacy=e||(null===(qe=this._message.messageXml)||void 0===qe?void 0:qe.Pharmacy)}else if(Te){var Be;this.pharmacy=null===(Be=this._message.messageXml)||void 0===Be?void 0:Be.Pharmacy}var Fe,Le;"ZZ"===this.response&&"0"!==oe&&(null!==(Fe=this.pharmacy)&&void 0!==Fe&&Fe.version&&(null===(Le=this.pharmacy.version)||void 0===Le?void 0:Le.indexOf("v6"))<0&&(yield this.dialogs.confirm.show({content:new _.Z("prescription.replace.description"),title:new _.Z("prescription.replace"),ok:new _.Z("ok"),shownCancel:!1,type:"info"}),this.stopSend=!0));this._message.messageXml=W.Message.Body[this.messages[this.currentMessage].messageType],!(0,m.RZ)(this.message)||"OS"!==(null===(Q=this.message.messageXml)||void 0===Q?void 0:Q.MessageRequestCode)&&"S"!==(null===(z=this.message.messageXml)||void 0===z?void 0:z.MessageRequestCode)&&"D"!==(null===(H=this.message.messageXml)||void 0===H?void 0:H.MessageRequestCode)&&"G"!==(null===(G=this.message.messageXml)||void 0===G?void 0:G.MessageRequestCode)||null!==(V=this.message)&&void 0!==V&&null!==(Z=V.messageXml)&&void 0!==Z&&Z.MedicationRequested||T.Ew.warning({content:new _.Z("prescription.medication.requested.missing")})}setDea(){var e,s,t,i,r,n,a,o,c,l,d,u;const h=(null===(e=this.message)||void 0===e||null===(s=e.messageXml)||void 0===s||null===(t=s.MedicationDispensed)||void 0===t||null===(i=t.Product)||void 0===i||null===(r=i.DrugCoded)||void 0===r||null===(n=r.DEASchedule)||void 0===n?void 0:n.Code)||(null===(a=this.message)||void 0===a||null===(o=a.messageXml)||void 0===o||null===(c=o.MedicationPrescribed)||void 0===c||null===(l=c.Product)||void 0===l||null===(d=l.DrugCoded)||void 0===d||null===(u=d.DEASchedule)||void 0===u?void 0:u.Code);let g="0";if(h)switch(h){case"C48672":g="1";break;case"C48675":g="2";break;case"C48676":g="3";break;case"C48677":g="4";break;case"C48679":g="5"}else g="0";this.message.MED_REF_DEA_CD=g}*setMessages(e){this.messages=e,this.messages.length>0&&(yield this.parse(),this.setDea()),this.messages.length>1&&(this.currentMessageTitle=`${this.currentMessage+1} ${new _.Z("measures.of")} ${this.messages.length}`)}*showDetail(e,s){yield this.dialogs.medicationDetail.show({detailOnly:e,prescription:s})}setExpiration(){if(!this._message)return;let e=Number(this._message.duration);var s,t;this._message.duration&&(null!==(s=this._message)&&void 0!==s&&null!==(t=s.messageRequestedSelected)&&void 0!==t&&t.NumberOfRefills&&(e=Number(this._message.messageRequestedSelected.NumberOfRefills)>0?this._message.duration*Number(this._message.messageRequestedSelected.NumberOfRefills):this._message.duration));this.expires=x()().add(e,"d").format("MM-DD-YYYY")}*nextMessage(){this.messages.length===this.currentMessage+1?this.currentMessage=0:this.currentMessage+=1,yield this.parse(),this.currentMessageTitle=`${this.currentMessage+1} of ${this.messages.length}`}*previousMessage(){0===this.currentMessage?this.currentMessage=this.messages.length-1:this.currentMessage-=1,yield this.parse(),this.currentMessageTitle=`${this.currentMessage+1} of ${this.messages.length}`}*updateMessageStatus(e,s,t=!1){yield(0,S.s)((0,E.vc)(e,s));let i=!0;
1this._hasUpdate=!0,(0,w.forEach)(this.messages,(e=>{"WaitingApproval"!==e.messageStatus&&"Pending"!==e.messageStatus||(this.nextMessage(),i=!1)})),i&&!t&&this.close(this.messages)}*reviewedMessage(e){try{var s,t,i,r;const n={reviewedUserId:null!==(s=null===(t=this.currentUser)||void 0===t?void 0:t.id)&&void 0!==s?s:null,reviewedUserName:`${(null===(i=this.currentUser)||void 0===i?void 0:i.firstName)||""} ${(null===(r=this.currentUser)||void 0===r?void 0:r.lastName)||""}`,reviewedDate:(new Date).toISOString()};return yield(0,S.s)((0,E.YY)(e,n)),n}catch(n){return void this.handleActionError(n)}}async updateMedicationRequested(e){var s,t,i,r,n,a,o;e.NumberOfRefills&&(this.message.refill=e.NumberOfRefills);const c=(0,w.cloneDeep)(null!==(s=e.modified)&&void 0!==s?s:e),l=await this.dialogs.editMedication.show({requestedMedication:await(0,W.I)(c)});if(!l)return;const d=e=>{const s=(0,J.m)(l);s.DrugDescription=c.DrugDescription,s.Diagnosis=c.Diagnosis;const t={...e,modified:void 0,Substitutions:void 0,NumberOfRefills:void 0,Note:void 0,...s};return Object.keys(t).forEach((e=>{(0,w.isNil)(t[e])&&delete t[e]})),t.updatedMedication=!0,t};if(null!==(t=this.message)&&void 0!==t&&null!==(i=t.messageXml)&&void 0!==i&&i.MedicationRequested){var u,h;if((0,w.isArray)(null===(u=this.message)||void 0===u||null===(h=u.messageXml)||void 0===h?void 0:h.MedicationRequested)){const s=(0,w.find)(this.message.messageXml.MedicationRequested,(s=>{var t,i,r,n;return e.DrugDescription===s.DrugDescription&&(null===(t=e.Product)||void 0===t||null===(i=t.DrugCoded)||void 0===i?void 0:i.NDC)===s.Product.DrugCoded.NDC&&(null===(r=e.Quantity)||void 0===r?void 0:r.Value)===s.Quantity.V
1alue&&(null===(n=e.Sig)||void 0===n?void 0:n.SigText)===s.Sig.SigText}));return void(s&&(s.modified=d(s)))}this.message.messageXml.MedicationRequested.modified=d(this.message.messageXml.MedicationRequested)}else if(null!==(r=this.message)&&void 0!==r&&null!==(n=r.messageXml)&&void 0!==n&&n.MedicationDispensed){const e=d(this.message.messageXml.MedicationDispensed);e.NumberOfRefills&&0!==e.NumberOfRefills||(e.NumberOfRefills=1),this.message.messageXml.MedicationDispensed.modified=e}else if(null!==(a=this.message)&&void 0!==a&&null!==(o=a.messageXml)&&void 0!==o&&o.MedicationPrescribed){var g,p;if((0,w.isArray)(null===(g=this.message)||void 0===g||null===(p=g.messageXml)||void 0===p?void 0:p.MedicationPrescribed)){const s=(0,w.find)(this.message.messageXml.MedicationPrescribed,(s=>{var t,i,r,n;return e.DrugDescription===s.DrugDescription&&(null===(t=e.Product)||void 0===t||null===(i=t.DrugCoded)||void 0===i?void 0:i.NDC)===s.Product.DrugCoded.NDC&&(null===(r=e.Quantity)||void 0===r?void 0:r.Value)===s.Quantity.Value&&(null===(n=e.Sig)||void 0===n?void 0:n.SigText)===s.Sig.SigText}));return void(s&&(s.modified=d(s)))}this.message.messageXml.MedicationPrescribed.modified=d(this.message.messageXml.MedicationPrescribed)}}get userId(){var e;return null===(e=this.currentEntityService.currentUser)||void 0===e?void 0:e.id}close(e){var s,t;null===(s=this.dialog)||void 0===s||s.close(e||!(null===(t=this.prescriptionHospiceFormularyApproveModel)||void 0===t||!t.isUpdated))}*editPrescription(){try{if(this.createPrescriptionAccessRules().isNotAgentAndNotPrescriberOfPrescriptionAccessNotification)T.Ew.warning({content:new _.Z("drug.history.warning.agent")});else{var e,s,t,i;if(yield this.prescriptionActionsModel.deleteMessageIfPrescriptionIdNotFound(null===(e=this.message)||void 0===e?void 0:e.messageId,null===(s=this.message)||void 0===s?void 0:s.prescriptionId))return void this.close([this.message]);const r=(0,w.cloneDeep)(this.message),n=yield this.drugHistoryService.getPrescriptionByMessageId(r.messageId);r.Prescription={prescriptionId:n.prescriptionId,PrescriptionDrugs:[{ROUTED_MED_ID:null===(t=n.PrescriptionDrugs)||void 0===t?void 0:t[0].ROUTED_MED_ID,GCN_SEQNO:null===(i=n.PrescriptionDrugs)||void 0===i?void 0:i[0].GCN_SEQNO}],combinationMed:n.combinationMed},yield this.prescriptionActionsModel.editPrescription(r),yield this.update(),this.close([this.message])}}catch(r){this.handleActionError(r)}}*deletePrescription(){try{if(this.createPrescriptionAccessRules().isNotAgentAndNotPrescriberOfPrescriptionAccessNotification)T.Ew.warning({content:new _.Z("drug.history.warning.agent")});else{var e,s,t;if(yield this.prescriptionActionsModel.deleteMessageIfPrescriptionIdNotFound(null===(e=this.message)||void 0===e?void 0:e.messageId,null===(s=this.message)||void 0===s?void 0:s.prescriptionId))return void this.close([this.message]);(yield this.prescriptionActionsModel.deletePrescriptionByPrescriptionId(null===(t=this.message)||void 0===t?void 0:t.prescriptionId,!1))&&this.close([this.message])}}catch(i){this.handleActionError(i)}}*approveMessage(){try{var e,s,t;if(yield this.prescriptionActionsModel.deleteMessageIfPrescriptionIdNotFound(null===(e=this.message)||void 0===e?void 0:e.messageId,null===(s=this.message)||void 0===s?void 0:s.prescriptionId))return void this.close([this.message]);(yield this.prescriptionActionsModel.approveByPrescriptionId(null===(t=this.message)||void 0===t?void 0:t.prescriptionId))&&this.close([this.message])}catch(i){this.handleActionError(i)}}*denyPrescription(){try{var e,s,t;if(yield this.prescriptionActionsModel.deleteMessageIfPrescriptionIdNotFound(null===(e=this.message)||void 0===e?void 0:e.messageId,null===(s=this.message)||void 0===s?void 0:s.prescriptionId))return void this.close([this.message]);(yield this.prescriptionActionsModel.deletePrescriptionByPrescriptionId(null===(t=this.message)||void 0===t?void 0:t.prescriptionId,!0))&&this.close([this.message])}catch(i){this.errorService.handleError(i)}}get isControlled(){return this.createPrescriptionAccessRules().prescriptionIsControlled}get isPrescriber(){return this.currentEntityService.currentUser.prescriber}get messageHasPrescription(){return!(0,w.isNil)(this.message.MED_REF_DEA_CD)}get isShowSendDenialOrSendApproval(){return this.createPrescriptionAccessRules().isShowSendDenialOrSendApproval}*setPracticeUser(e){var s;const t=e?(0,X.z)(e):(0,X.z)(this.message.userId),i=(0,X.z)(this.message.practiceId);if((null===(s=this.currentEntityService.currentPrescriberOrNull)||void 0===s?void 0:s.id)===t&&this.currentEntityService.currentPracticeId===i)return;const r=(0,w.find)(this.currentEntityService.currentUserPracticesOrNull,(e=>e.id===i));let n;if(!r)throw new Error("Current logged in user does not have access to the physician associated with the script");
1if(n=(0,w.find)(r.prescribers,(e=>e.id===t)),!n&&this.createPrescriptionAccessRules().isEditByAllPrescribersAllowed&&this.currentEntityService.currentPrescriberId&&(n=(0,w.find)(r.prescribers,(e=>e.id===this.currentEntityService.currentPrescriberId))),!n)throw new Error("Current logged in user does not have access to the physician associated with the script");yield this.userStore.setPracticeAndPrescriber({practice:r,prescriber:n}),yield this.userStore.refreshUser(),T.Ew.success({content:new _.Z("messages.currentPractice")}),this.rootEvents.emit("refreshMedications")}*_represcribe(e){const s=yield this.drugHistoryService.getPrescriptionByMessageId(e);yield this.setPracticeUser(),yield this.patientStore.getPatient(Number(s.patientId));const t=yield this.prescriptionActionsModel.prescribeByPrescriptionDrug({prescription:s,currentStatus:null,newrx:null,formqualifiers:null,statuses:null,ncpdpId:null,saveMethod:O.sF.SAVE});return this.patientStore.refreshPatientCurrentMedications(),t?s:null}*represcribe(){try{const e=yield this._represcribe(this.message.messageId);if(e){(yield this.dialogs.confirm.show({content:new _.Z("messages.removeOriginal"),ok:new _.Z("yes"),cancel:new _.Z("no"),type:"warn"}))&&e.prescriptionId&&(yield(0,S.s)((0,P.Ig)(e.prescriptionId,"Medication removed and re-prescribed from the message page")),this.rootEvents.emit("messageRefresh"))}this.close(!0)}catch(e){this.errorService.handleError(e)}}*setMessageMarkAsUnread(e){try{yield(0,S.s)((0,E.F_)(e)),this.rootEvents.emit("messageRefresh")}catch(s){this.errorService.handleError(s)}}*deleteMessage(e){try{(yield this.dialogs.confirm.show({content:new _.Z("messages.delete.message"),title:new _.Z("measures.delete"),ok:new _.Z("yes"),cancel:new _.Z("cancel"),type:"warn"}))&&(yield this.messageService.deleteMessage(e.requestId,e.messageId),this.rootEvents.emit("messageRefresh"),T.Ew.success({content:new _.Z("messages.deleted.success")}))}catch(s){this.errorService.handleError(s)}}async cancelPrescription(){try{var e;this._isLoading=!0,await this.patientStore.getPatient(Number(this.message.patientId)),(0,X.p)(this.currentEntityService.currentPatient,"Current Patient"),await this.setPracticeUser(this.message.doctorId);let i=null===(e=this.message)||void 0===e?void 0:e.prescriptionId;var s,t;if(!i&&[m.cF.RxRenewalRequest,m.cF.RxChangeRequest].includes(this.message.messageType))i=await this.prescriptionActionsModel.getPrescriptionByRequestId(null===(s=this.message)||void 0===s?void 0:s.requestId,null===(t=this.message)||void 0===t?void 0:t.messageType.replace("Request","Response"));(0,X.p)(i,"PrescriptionID");await this.prescriptionActionsModel.cancelPrescriptionByPrescriptionId(i)&&(T.Ew.success({content:new _.Z("messages.cancel.success")}),this.close(!0))}catch(i){this.handleActionError(i)}finally{this._isLoading=!1}}}var ie=t(2129),re=t(73491),ne=t(10437),ae=t(92664),oe=t(98139),ce=t.n(oe),le=t(45422),de=t(70579);v.h.preload(["confirm","vitalPrescription","prompt","prescription","prescriptionCompound","prescriptionConfirm","drugCheck","otp","idme","print","medicationDetail","editMedication"]);const ue=(0,r.PA)((({dialog:e})=>{var s,t;const i=(0,ie.F)((()=>new te(e.config)),[e.config]),{t:r,formatIntlMessageObj:v}=(0,c.U4)();if(!i)throw new Error("Model must be set");const M=(0,V.xE)({prescription:i.message,type:le.D.PRESCRIPTION_MESSAGE}),{isInitialized:w,currentMessageTitle:S,message:C,messages:x,previousMessage:E,nextMessage:P,updateMessageStatus:I,reviewedMessage:b,dialogs:N,close:O,hasUpdate:_,represcribe:k,setMessageMarkAsUnread:j,pharmacy:U,maxRefill:T,showRefill:q,responseTitle:B,response:F,send:L,initialResponse:X,canRespondChangeRx:Q,prescriptionHospiceFormularyApproveModel:z}=i,H=(0,ie.F)((()=>new ne.p9({message:C,pharmacy:U,maxRefill:T,showRefill:q,responseTitle:B,response:F,initialResponse:X,canRespondChangeRx:Q,setResponse:i.setResponse,isShowSendDenialOrSendApproval:i.isShowSendDenialOrSendApproval,showDetail:i.showDetail,send:L,updateMedicationRequested:i.updateMedicationRequested,prescribeMedication:i.prescribeMedication,addFormat:i.addFormat,messageXml:i.initialMessageXml})),[C,U,T,q,B,F,Q,i.initialMessageXml]),G=!C.isOldScript&&"Pending"!==C.messageStatus&&"WaitingApproval"!==C.messageStatus&&!(null===C||void 0===C||null===(s=C.messageHistory)||void 0===s||!s.length);let Z=!1;switch(null===C||void 0===C||null===(t=C.messageXml)||void 0===t?void 0:t.MessageRequestCode){case"T":case"OS":case"G":case"D":Z=!0;break;default:Z="RxRenewalRequest"===C.messageType}const $=()=>{switch(C.messageType){case m.cF.NewRx:return C.messageStatus===m.RA.AdminApprovalDenied?r("messages.AdminApprovalDenied"):(0,m.xH)(C)?"QueuedRx-Denied":(0,m.fJ)(C)?"QueuedRx":null!==z&&void 0!==z&&z.isAdminApprovalRequired?r("prescription.adminApproval.statusLabel.approval"):r("messages.newPrescription");case m.cF.RxChangeRequest:case m.cF.RxChangeResponse:return(0,m.xH)(C)?"ChangeRx-Denied":"ChangeRx";case m.cF.CancelRx:return r("cancel prescription");case m.cF.CancelRxResponse:return(0,m.xH)(C)?"CancelRx-Denied":"CancelRx";case m.cF.RxRenewalRequest:case m.cF.RxRenewalResponse:return(0,m.xH)(C)?"RefillRx-Denied":(0,m.tu)(C)?"CancelRx":"RefillRx";default:return null}},K=(0,m.xH)(C)&&(0,de.jsx)("div",{className:"min-h-[40px] bg-red-300 dark:bg-red-700 w-full flex justify-between items-center py-2 text-white",children:(0,de.jsxs)("div",{className:"flex flex-col items-start leading-4 text-xs md:text-sm pl-8 gap-x-1",children:[$()&&(0,de.jsx)("div",{children:$()}),(null===C||void 0===C?void 0:C.denyName)&&(0,de.jsxs)("div",{children:[(0,de.jsx)("span",{children:C.denyName}),(null===C||void 0===C?void 0:C.denyDate)&&(0,de.jsxs)("span",{children:[" ","(",(0,de.jsx)(y.Q0,{date:C.denyDate,timeWidth:"medium"}),")"]})]}),(null===C||void 0===C?void 0:C.note)&&(0,de.jsxs)("div",{children:[r("messages.reason.for.denial"),": ",null===C||void 0===C?void 0:C.note]})]})});return(0,de.jsxs)(l.A,{open:e.isOpen,isInitialized:w,keyboard:!1,unmount:!0,hideBackdrop:!1,classes:{foreFrontTransition:"mx-auto",foreFront:"sm:!min-w-min lg:!w-[1024px] md:!w-[768px] sm:!w-[100vw] mx-auto
1sm:!h-[901px] !m-auto !border-none"},children:[(0,de.jsxs)(l.A.Header,{className:"!bg-beta-500 dark:!bg-secondary",children:[(0,de.jsxs)(l.A.Title,{as:"h4",className:"title !text-white",children:[r({id:"prescription.detail"}),$()&&(0,de.jsx)("span",{children:` - ${$()}`}),i.isHeldByEpa&&(0,de.jsxs)("span",{children:[" - ",r("drug.history.STATUS_HELD_BY_EPA")]})]}),x.length>1&&(0,de.jsxs)("div",{className:"items-center hidden xl:flex",children:[(0,de.jsx)(d.A,{onClick:E,children:(0,de.jsx)(n,{className:"w-5 h-5"})}),(0,de.jsx)("span",{children:S}),(0,de.jsx)(d.A,{onClick:P,children:(0,de.jsx)(a.A,{className:"w-5 h-5"})})]}),(0,de.jsx)(re.g,{container:null,items:[{name:r("messages.mark.as.unread"),action:()=>j(C.requestId),className:"!border-0 dark:!text-white !text-primary"}],children:(0,de.jsx)(d.A,{variant:"text",disabled:R.c7,children:(0,de.jsx)(f.ME,{className:"w-6 h-6 !text-white"})})})]}),(0,de.jsx)(l.A.Body,{children:(0,de.jsxs)("div",{className:"flex flex-col",children:[(0,de.jsxs)("div",{className:"text-xs flex-col flex sm:flex-row justify-between pb-2 pt-2 font-semibold",children:[(0,de.jsxs)("div",{className:"flex flex-col sm:flex-row",children:[(0,de.jsx)("div",{children:(0,de.jsxs)("span",{className:"text-gray-500",children:[r("message.MESSAGE_ID"),":"]})}),(0,de.jsx)("div",{children:(0,de.jsxs)(d.A,{variant:"text",onClick:()=>(0,ae.l)(null===C||void 0===C?void 0:C.messageId),className:"!w-0 !flex-grow !justify-start sm:pl-1 !text-gray-900 dark:!text-white",children:[(0,de.jsx)("span",{className:"contents whitespace-nowrap truncate",children:null===C||void 0===C?void 0:C.messageId}),(0,de.jsx)(g.A,{className:"ml-1 dark:text-gray-400",as:p.A})]})})]}),(0,de.jsxs)("div",{children:[(0,de.jsxs)("span",{className:"text-gray-500",children:[r("messages.messageDate"),": "]}),(0,de.jsx)("span",{className:"dark:text-white",children:(0,de.jsx)(y.Q0,{date:null===C||void 0===C?void 0:C.messageDate})})]})]}),(0,de.jsxs)(ne.Ot,{value:H,children:[G&&i.messageHistoryActivityModel&&!(null!==z&&void 0!==z&&z.requiresAdminApproval)&&(0,de.jsx)(ee.L,{model:i.messageHistoryActivityModel,beforeActivityLabel:K}),(0,m.RZ)(C)&&!Q&&(0,de.jsx)("span",{className:"text-red-500 text-sm",children:r("messages.change.rx.not.found.prescription")}),(null===C||void 0===C?void 0:C.messageXml)&&(0,de.jsx)(h.c,{requiresAdminApproval:null===z||void 0===z?void 0:z.isAdminApprovalRequired}),(null===z||void 0===z?void 0:z.isRealtimeFormularyOn)&&(0,de.jsx)(Y.a5,{className:"mt-5",model:z})]})]})}),C.patientId||(0,m.v1)(C)||(0,m.RZ)(C)?(0,de.jsxs)(l.A.Footer,{className:"flex bg-primary gap-2 w-full justify-between !text-primary",children:[[m.RA.CancelRxRequest,m.RA.CancelRx,m.RA.CancelRxApproved,m.RA.CancelRxDenied].includes(C.messageStatus)&&C.reviewedUserName&&(0,de.jsxs)("div",{className:ce()("flex flex-col text-xs font-bold text-primary"),children:[(0,de.jsx)("span",{children:null!==C&&void 0!==C&&C.reviewedUserName?`Reviewed by ${C.reviewedUserName}`:"Reviewed"}),(null===C||void 0===C?void 0:C.reviewedDate)&&(0,de.jsx)(y.Q0,{date:C.reviewedDate})]}),(0,m.qO)(C)&&(C.messageStatus===m.RA.Success||C.messageStatus===m.RA.PendingNewRx)&&(0,de.jsx)(d.A,{disabled:R.c7,size:"sm",variant:"outlined",color:"gray",onClick:()=>i.cancelPrescription(),children:r({id:"prescription.cancel.this.prescription"})}),(C.messageStatus===m.RA.Error||C.messageStatus===m.RA.ErrorReviewed)&&(0,de.jsxs)("div",{className:"flex items-center gap-2",children:[C.messageStatus!==m.RA.ErrorReviewed&&(0,de.jsx)(d.A,{disabled:R.c7,variant:"filled",color:"alpha",size:"sm",onClick:async()=>{const e=await b(C.requestId);I(C.requestId,"Error Reviewed",!0),C.messageStatus=m.RA.ErrorReviewed,e&&(C.reviewedDate=e.reviewedDate,C.reviewedUserName=e.reviewedUserName)},children:r({id:"prescription.reviewed"})}),C.messageStatus===m.RA.ErrorReviewed&&(0,de.jsxs)("span",{className:"flex flex-col text-sm text-primary leading-4 font-medium px-2",children:[null!==C&&void 0!==C&&C.reviewedUserName?(0,de.jsx)("span",{children:`Reviewed by ${C.reviewedUserName}`}):(0,de.jsx)("span",{className:"rounded-full px-2 py-1 text-xs font-medium uppercase text-white bg-alpha-500",children:r("message.reviewed")}),(null===C||void 0===C?void 0:C.reviewedDate)&&(0,de.jsx)("span",{children:(0,de.jsx)(y.Q0,{date:C.reviewedDate})})]}),C.messageType===m.cF.NewRx&&(0,de.jsx)(d.A,{disabled:R.c7,variant:"filled",color:"alpha",size:"sm",onClick:()=>k(),children:r({id:"messages.represcribe"})})]}),!(0,m.qO)(C)&&i.messageHasPrescription&&C.messageStatus!==m.RA.Error&&C.messageStatus!==m.RA.ErrorReviewed&&(0,de.jsxs)(de.Fragment,{children:[F&&C.messageType===m.cF.RxRenewalRequest&&(0,de.jsxs)("div",{className:"flex gap-x-3 items-center",children:[R.vp&&!!M.errorSendDenialOrSendApproval().length&&(0,de.jsx)(u.Ay,{classes:{root:"!max-w-[320px]"},content:(0,de.jsx)("div",{className:"flex flex-col",children:M.errorSendDenialOrSendApproval().map((e=>(0,de.jsxs)("p",{children:[(0,de.jsx)("span",{className:"font-bold",children:v(e.title)}),(0,de.jsx)("span",{className:"font-medium",children:v(e.description)})]},e.title.descriptor.id)))}),children:(0,de.jsx)(d.A,{as:"span",variant:"text",shape:"circle",color:"beta",size:"sm",stopPropagation:!0,className:"!p-1",children:(0,de.jsx)(g.A,{as:o.A,className:"w-5 h-5"})})}),"A"===F&&i.isShowSendDenialOrSendApproval&&(0,de.jsx)(d.A,{disabled:R.c7,variant:"filled",color:"alpha",size:"sm",onClick:()=>{L("A")},children:r({id:"prescription.request.send.approval"})}),"A"!==F&&i.isShowSendDenialOrSendApproval&&(0,de.jsx)(d.A,{disabled:R.c7,variant:"outlined",color:"red",size:"sm",onClick:()=>{L(F)},children:r({id:"prescription.request.send.denial"})}),R.c7&&i.hasDawAccess&&(0,de.jsx)(d.A,{size:"sm",color:"red",variant:"outlined",className:"uppercase",onClick:()=>i.deleteMessage(C),children:r({id:"measures.delete"})})]}),(F||!X)&&C.messageType===m.cF.RxChangeRequest&&(0,de.jsxs)("div",{className:"flex gap-x-3 items-center",children:[R.vp&&!!M.errorSendDenialOrSendApproval().length&&(0,de.jsx)(u.Ay,{classes:{root:"!max-w-[320px]"},content:(0,de.jsx)("div",{className:"flex flex-col",children:M.errorSendDenialOrSendApproval().map((e=>(0,de.jsxs)("p",{children:[(0,de.jsx)("span",{className:"font-bold",children:v(e.title)}),(0,de.jsx)("span",{className:"font-medium",children:v(e.description)})]},e.title.descriptor.id)))}),children:(0,de.jsx)(d.A,{as:"span",variant:"text",shape:"circle",color:"beta",size:"sm",stopPropagation:!0,className:"!p-1",children:(0,de.jsx)(g.A,{as:o.A,className:"w-5 h-5"})})}),"A"===F&&i.isShowSendDenialOrSendApproval&&function(){var e;switch(null===C||void 0===C||null===(e=C.messageXml)||void 0===e?void 0:e.Me
1ssageRequestCode){case"T":case"OS":case"D":case"G":case"P":case"S":return!1;case"U":return!0}return!0}()&&(0,de.jsx)(d.A,{disabled:R.c7||!Q,variant:"filled",color:"alpha",size:"sm",onClick:()=>{L("A")},children:r({id:"prescription.request.send.approval"})}),"A"!==F&&i.isShowSendDenialOrSendApproval&&(0,de.jsx)(d.A,{disabled:R.c7||!Q,variant:"outlined",color:"red",size:"sm",onClick:()=>{L("D")},children:r({id:"prescription.request.send.denial"})}),R.c7&&i.hasDawAccess&&(0,de.jsx)(d.A,{size:"sm",color:"red",variant:"outlined",className:"uppercase",onClick:()=>i.deleteMessage(C),children:r({id:"measures.delete"})})]}),C.messageType===m.cF.NewRx&&C.messageStatus===m.RA.WaitingApproval&&(0,de.jsxs)("div",{className:"flex gap-x-3 items-center",children:[R.vp&&!!M.errors.length&&(0,de.jsx)(u.Ay,{classes:{root:"!max-w-[320px]"},content:(0,de.jsx)("div",{className:"flex flex-col",children:M.errors.map((e=>(0,de.jsxs)("p",{children:[(0,de.jsx)("span",{className:"font-bold",children:v(e.title)}),e.description&&(0,de.jsx)("span",{className:"font-medium",children:v(e.description)})]},e.title.descriptor.id)))}),children:(0,de.jsx)(d.A,{as:"span",variant:"text",shape:"circle",color:"beta",size:"sm",stopPropagation:!0,className:"!p-1",children:(0,de.jsx)(g.A,{as:o.A,className:"w-5 h-5"})})}),(M.canApprove||M.isEditInsteadApprove)&&(0,de.jsx)(d.A,{disabled:R.c7,size:"sm",variant:"filled",color:"alpha",onClick:()=>i.approveMessage(),children:r({id:"messages.approve"})}),M.canDeny&&(0,de.jsx)(u.Ay,{content:r({id:"messages.deletePrescription"}),children:(0,de.jsx)(d.A,{disabled:R.c7,size:"sm",color:"red",variant:"outlined",className:"uppercase",onClick:()=>i.denyPrescription(),children:r({id:"dialog.button.deny"})})}),(M.canEdit||M.isNotAgentAndNotPrescriberOfPrescriptionAccessNotification)&&(0,de.jsx)(u.Ay,{content:r({id:"measures.edit"}),children:(0,de.jsx)(d.A,{disabled:R.c7,variant:"filled",color:"beta",size:"sm",className:"focus:bg-beta-50 px-1",onClick:()=>i.editPrescription(),children:r({id:"measures.edit"})})}),(M.canDelete||M.isNotAgentAndNotPrescriberOfPrescriptionAccessNotification)&&(0,de.jsx)(u.Ay,{content:r({id:"messages.deletePrescription"}),children:(0,de.jsx)(d.A,{disabled:R.c7,size:"sm",color:"red",variant:"outlined",className:"uppercase",onClick:()=>i.deletePrescription(),children:r({id:"dialog.button.delete"})})})]})]}),z?(0,de.jsxs)("div",{className:"flex gap-2 w-full justify-between",children:[(0,de.jsx)(Y.F6,{model:z}),(0,de.jsx)("div",{className:"flex flex-grow justify-end",children:(0,de.jsx)(d.A,{size:"sm",variant:"outlined",className:"md:!w-24",onClick:()=>O(_),children:r(F?{id:"cancel"}:{id:"close"})})})]}):(0,de.jsx)("div",{className:"flex grow justify-end",children:(0,de.jsx)(d.A,{size:"sm",variant:"outlined",className:"md:!w-24",onClick:()=>O(_),children:r(F?{id:"cancel"}:{id:"close"})})})]}):(0,de.jsx)(l.A.Footer,{className:"flex bg-primary gap-2 w-full justify-between !text-primary",children:(0,de.jsx)(d.A,{size:"sm",variant:"outlined",className:"md:!w-24",onClick:()=>O(_),children:r({id:"close"})})}),(0,de.jsx)(D.X,{dialogCreator:N}),(0,de.jsx)(A.gL,{model:i.prescribeMedicationModel}),(0,de.jsx)(A.gL,{model:i.prescriptionActionsModel}),(0,de.jsx)(l.A.Loader,{isLoading:i.isLoading})]})}));ue.displayName="PrescriptionDetail";const he=ue}}]); 2//# sourceMappingURL=82398.f2540640.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.