"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[488],{12342:(e,t,r)=>{r.d(t,{A:()=>a});let a=r(91040).A.create({timeout:18e4})},25544:(e,t,r)=>{r.d(t,{h:()=>n});var a=r(96130);let n=()=>{var e,t,r;let n=(0,a.D0)(),i=null!=(e=n.enableBrickMortarProgramFlowCareCompass)&&e;console.log("ldFlags value",n);let s=null!=(t=n.enableHealthyBodyProgram)&&t,l=null!=(r=n.enableLabAnalytingUploads)&&r;return console.log("labAnalytingEnabled value: ",l),{isOrganizationFieldEnabled:i,isHealthyBodyProgramEnabled:s,isLabAnalytingEnabled:l,ldFlags:n}}},45383:(e,t,r)=>{r.d(t,{s:()=>i,X:()=>s.X});var a=r(37876),n=r(37477);let i=e=>(0,a.jsx)(n.Flex,{px:{base:"spacer-6",md:"spacer-9",lg:"spacer-14",xl:"spacer-20",xxl:"spacer-28"},py:{base:"spacer-5",lg:"spacer-12"},maxWidth:"90rem",marginY:"0",marginX:"auto",...e});var s=r(52036)},50941:(e,t,r)=>{r.d(t,{Ay:()=>d});var a=r(46512),n=r(91123),i=r.n(n),s=r(99742),l=r(99742);class o{run(e,t){let r=this.currentId++;return this.storage.set(r,e),t().finally(()=>this.storage.delete(r))}getContext(){return this.storage.get(this.currentId-1)}setContext(e){this.storage.set(this.currentId-1,e)}constructor(){this.storage=new Map,this.currentId=0}}class c{setContext(e){let t=this.contextStorage.getContext()||{};this.contextStorage.setContext({...t,...e})}async withContext(e,t){return this.contextStorage.run(e,t)}createRequestContext(e,t,r){let n=(0,a.Ak)();r.setHeader("x-request-id",n);let i={host:t.headers.host,referer:t.headers.referer,handler:e,requestId:n,method:t.method,url:t.url,path:t.url?new URL(t.url,"http://".concat(t.headers.host)).pathname:void 0,query:t.query,params:t.query,timestamp:new Date().toISOString(),..."dev"===l.env.NODE&&{body:t.body}};return this.setContext(i),i}createLogEntry(e,t){let r=this.contextStorage.getContext();return{...r,environment:"production",service:(null==r?void 0:r.service)||"flyte-registration",branch:l.env.AWS_BRANCH||l.env.BRANCH||"local",...t,message:e}}error(e,t){this.pinoLogger.error(this.createLogEntry(e,t))}warn(e,t){this.pinoLogger.warn(this.createLogEntry(e,t))}info(e,t){this.pinoLogger.info(this.createLogEntry(e,t))}debug(e,t){this.pinoLogger.debug(this.createLogEntry(e,t))}constructor(){this.pinoLogger=i()({level:s.env.LOG_LEVEL||"info",formatters:{level:e=>({level:e.toUpperCase()})},timestamp:()=>',"time":"'.concat(new Date(Date.now()).toISOString(),'"'),base:{environment:"production",service:"flyte-registration",branch:s.env.AWS_BRANCH||s.env.BRANCH||"local"}}),this.contextStorage=new o}}let d=new c},52036:(e,t,r)=>{r.d(t,{X:()=>s});var a=r(37876),n=r(37477),i=r(45383);let s=e=>(0,a.jsx)(i.s,{direction:{base:"column",lg:"row"},gap:{base:"spacer-10",lg:"spacer-16",xl:"spacer-28",xxl:"spacer-44"},...e});s.Side=e=>(0,a.jsx)(n.Flex,{direction:"column",gap:{base:"spacer-6",lg:"spacer-8"},flex:1,...e}),s.Form=e=>(0,a.jsx)(n.Flex,{direction:"column",gap:"spacer-9",flex:1,...e})},61032:(e,t,r)=>{function a(e){var t;return t=(e.diabetes,e.bariatric),["Complete Blood Count (CBC)","Comprehensive Metabolic Panel (CMP)","Hemoglobin A1C (HbA1c)","Cholesterol Panel (Lipid Panel)","Thyroid Function Test (TSH with FT4 reflex)"]}r.d(t,{o:()=>a})},81488:(e,t,r)=>{r.d(t,{x:()=>y});var a=r(37876),n=r(37477),i=r(52036),s=r(25544),l=r(89099),o=r(14232);function c(e){let{name:t,onDelete:r}=e;return(0,a.jsxs)(n.Flex,{justify:"space-between",align:"center",borderBottomWidth:"1px",borderBottomColor:"border-subtle",borderBottomStyle:"solid",width:"100%",children:[(0,a.jsx)(n.Text,{variant:"text-body-regular",color:"text-primary",fontWeight:"normal",children:t}),(0,a.jsx)(n.ButtonIcon,{variant:"ghost",onClick:r,icon:(0,a.jsx)(n.IconTrash,{}),size:"l","aria-label":"delete",borderRadius:"radii-2",p:"spacer-1",m:"spacer-1"})]})}function d(){let{onSubmit:e,isSubmitting:t=!1,onRequestLabOrder:r,onSubmitLater:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[s,l]=(0,o.useState)([]),d=(0,o.useRef)(null),x=(0,n.useToast)(),u=()=>{if(0===s.length)return void x({title:"Error",description:"Please upload at least one file",status:"error"});let t=s.map(e=>e.file);e?e(t):x({title:"Success",description:"Submitting ".concat(s.length," file(s): ").concat(s.map(e=>e.name).join(", ")),status:"success"})};return(0,a.jsxs)(n.Box,{children:[(0,a.jsxs)(n.Box,{py:"spacer-4",px:"spacer-3",bg:"background-dark",borderRadius:"radii-4",mb:"spacer-4",children:[(0,a.jsx)(n.Text,{variant:"text-header-M",color:"text-light",pb:"spacer-4",children:"Upload Your Lab Results"}),(0,a.jsxs)(n.Button,{borderRadius:"radii-3",as:"label",htmlFor:"input-files",variant:"secondary",w:"full",bg:"white",color:"text-link-secondary-default",_hover:{bg:"background-action-hover"},children:[(0,a.jsx)(n.IconFileUpload,{w:"24px",h:"24px"}),"Add File"]})]}),(0,a.jsx)("input",{id:"input-files",type:"file",ref:d,onChange:e=>{let t=e.target.files;if(!t||0===t.length)return;let r=Array.from(t).map(e=>({id:Math.random().toString(36).substring(2,9),name:e.name,file:e}));l(e=>[...e,...r]),d.current&&(d.current.value="")},style:{display:"none"},multiple:!0,accept:".pdf,.jpg,.jpeg,.png"}),s.length>0&&(0,a.jsx)(n.Box,{mb:"spacer-6",mt:"spacer-4",children:s.map(e=>(0,a.jsx)(c,{name:e.name,onDelete:()=>{var t;return t=e.id,void l(e=>e.filter(e=>e.id!==t))}},e.id))}),(0,a.jsx)(n.Box,{mt:"spacer-9",display:{base:"none",md:s.length>0?"block":"none"},children:(0,a.jsx)(n.Button,{onClick:u,variant:"primary",w:"full",h:"50px",borderRadius:"3xl",isDisabled:0===s.length||t,isLoading:t,children:"Submit Lab Results"})}),(0,a.jsxs)(n.Box,{display:{base:"block",md:"none"},mt:"spacer-9",children:[(0,a.jsx)(n.Text,{variant:"text-header-S",color:"text-primary",children:"Don't have lab results yet?"}),(0,a.jsx)(n.Box,{my:"spacer-3",children:(0,a.jsx)(n.Button,{size:"s",variant:"link",onClick:r,children:"Request a lab order"})}),(0,a.jsx)(n.Text,{mt:"spacer-6",variant:"text-header-S",color:"text-primary",children:"Not ready?"}),(0,a.jsx)(n.Box,{my:"spacer-3",children:(0,a.jsx)(n.Button,{size:"s",variant:"link",onClick:i,children:"Submit lab results later"})})]}),(0,a.jsx)(n.Box,{h:"70px"}),(0,a.jsx)(n.Box,{display:{base:"block",md:"none"},position:"fixed",bottom:"0",left:"0",right:"0",p:"spacer-4",bg:"white",zIndex:"sticky",border:"none",background:"white",children:(0,a.jsx)(n.Button,{onClick:u,variant:"primary",w:"full",h:"50px",borderRadius:"3xl",isDisabled:0===s.length||t,isLoading:t,children:"Submit Lab Results"})})]})}var x=r(61032);function u(e){let{isOpen:t,onClose:r,diabetes:i,bariatric:s}=e;if(!t)return null;let l=(0,x.o)({diabetes:i,bariatric:s,labName:"generic"});return(0,a.jsx)(n.Box,{position:"fixed",top:0,left:0,right:0,bottom:0,bg:"background-overlay",zIndex:9999,display:"flex",alignItems:"center",justifyContent:"center",p:"spacer-4",children:(0,a.jsxs)(n.Box,{bg:"background-card",borderRadius:"lg",p:"spacer-8",maxW:"500px",w:"100%",children:[(0,a.jsxs)(n.Flex,{alignItems:"center",justifyContent:"space-between",mb:"spacer-6",children:[(0,a.jsx)(n.Text,{variant:"text-header-M",color:"text-primary",children:"Required labs"}),(0,a.jsx)(n.IconX,{color:"text-secondary",cursor:"pointer",onClick:r})]}),(0,a.jsx)(n.Box,{as:"ul",pl:"spacer-6",mb:"spacer-4",maxH:"400px",overflowY:"auto",children:l.map(e=>(0,a.jsx)(n.Text,{as:"li",color:"text-secondary",mb:"spacer-2",children:e},e))})]})})}function p(e){let{isOpen:t,onClose:r,onSubmitLater:i,onRequestLabs:s}=e;return(0,a.jsxs)(n.Modal,{isOpen:t,onClose:r,isCentered:!0,children:[(0,a.jsx)(n.Modal.Overlay,{}),(0,a.jsxs)(n.Modal.Content,{px:{base:"spacer-6",lg:"spacer-8"},pb:"spacer-8",gap:"spacer-6",mx:0,maxWidth:{base:"100%",md:"420px"},mb:{base:0,md:"auto"},borderBottomRadius:0,children:[(0,a.jsxs)(n.Modal.Header,{p:0,children:[(0,a.jsx)(n.Text,{variant:"text-header-M",color:"text-primary",pt:"20px",children:"Submit labs later?"}),(0,a.jsx)(n.Modal.CloseButton,{color:"text-secondary"})]}),(0,a.jsxs)(n.Modal.Body,{p:0,display:"flex",flexDirection:"column",children:[(0,a.jsx)(n.Text,{variant:"text-body-large-regular",color:"text-secondary",mb:"spacer-6",children:'By selecting "Submit later" you acknowledge that you will not be able to schedule a visit with a provider until labs are completed. You can submit labs using the FlyteHealth patient app or you can request new labs below.'}),(0,a.jsxs)(n.Flex,{direction:"column",gap:"spacer-4",children:[(0,a.jsx)(n.Button,{variant:"primary",onClick:i,borderRadius:"3xl",size:{base:"m",md:"l"},children:"Submit labs later"}),(0,a.jsx)(n.Button,{variant:"primary-alt",onClick:s,borderRadius:"3xl",size:{base:"m",md:"l"},children:"Request Labs"})]})]})]})]})}let h=()=>(0,a.jsxs)(n.Box,{position:"fixed",top:"0",left:"0",width:"100vw",height:"100vh",backgroundColor:"background-overlay",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",zIndex:"overlay",children:[(0,a.jsx)(n.Spinner,{size:"s",color:"text-light"}),(0,a.jsx)(n.Text,{variant:"text-body-bold",color:"text-light",mt:"spacer-3",children:"We're sending your lab results"}),(0,a.jsx)(n.Text,{variant:"text-body-regular",color:"text-light",mt:"spacer-2",maxW:"300px",textAlign:"center",children:"This may take a few seconds, do not close this window."})]});var m=r(12342),b=r(50941);let g={submitLabs:async(e,t)=>{b.Ay.info("Submitting ".concat(e.length," lab PDF(s) to Evolve API for patient ").concat(t));let r=new FormData;return r.append("patientId",t),e.forEach(e=>{r.append("file",e)}),(await m.A.post("/api/submit-labs",r,{headers:{"Content-Type":"multipart/form-data"}})).data}};function y(e){let{patientId:t,onSubmitLabsLater:r,onLabSubmitted:c,onGoBackToRequestLabs:x,diabetes:m,bariatric:b,isLogoutFunctionality:y}=e,f=(0,n.useToast)(),j=(0,l.useRouter)(),[v,C]=(0,o.useState)(!1),[S,B]=(0,o.useState)(!1),[w,k]=(0,o.useState)(!1),{isLabAnalytingEnabled:L}=(0,s.h)();console.log("labAnalytingEnabled value: ",L);let R=async e=>{if((e=>{if(e.length>10)return f({title:"Error",description:"You can only upload up to ".concat(10," files"),status:"error"}),!1;let t=L?["application/pdf","image/jpeg","image/png","image/heic"]:["application/pdf"];for(let r of e){if(r.size>5242880)return f({title:"Error",description:"File ".concat(r.name," exceeds the maximum size of 5MB"),status:"error"}),!1;if(!t.includes(r.type))return f({title:"Error",description:"File ".concat(r.name," must be ").concat(L?"PDF, JPG, PNG, or HEIC":"a PDF"),status:"error"}),!1}return!0})(e))try{k(!0);let r=await g.submitLabs(e,t);c(),f({title:"Success",description:r.message,status:"success"})}catch(e){f({title:"Error",description:e instanceof Error?e.message:"Failed to submit lab results",status:"error"})}finally{k(!1)}},F=()=>{B(!0)},T=()=>{B(!1),x()};return w?(0,a.jsx)(h,{}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u,{isOpen:v,onClose:()=>{C(!1)},diabetes:m,bariatric:b}),(0,a.jsx)(p,{isOpen:S,onClose:()=>B(!1),onSubmitLater:()=>{B(!1),r()},onRequestLabs:T}),(0,a.jsxs)(i.X,{children:[(0,a.jsxs)(i.X.Side,{children:[(0,a.jsxs)(n.TextPairing,{variant:"textpairing-header-2XL",children:[(0,a.jsx)(n.TextPairing.Label,{color:"text-primary",children:"Submit Lab Results"}),(0,a.jsxs)(n.TextPairing.SubLabel,{color:"text-secondary",fontSize:"20px",children:["Before uploading, please confirm that your documents:",(0,a.jsxs)(n.Box,{as:"ul",listStyleType:"disc",pl:"spacer-6",ml:"0",mt:"spacer-3",sx:{"& li":{fontSize:"20px",lineHeight:"1",mb:"spacer-2"},"& li::marker":{fontSize:"24px"}},children:[(0,a.jsx)("li",{children:"Are dated within the last 90 days"}),(0,a.jsx)("li",{children:"Include your full name"}),(0,a.jsxs)("li",{children:["Include all"," ",(0,a.jsx)(n.Button,{fontSize:20,variant:"link",fontWeight:"400",onClick:()=>{C(!0)},children:"required labs."})]})]}),"Our team will review uploaded files and will be in touch if there are any issues or if new labs are needed."]})]}),(0,a.jsxs)(n.Box,{display:{base:"none",md:"block"},children:[(0,a.jsx)(n.Text,{variant:"text-header-S",color:"text-primary",children:"Don't have lab results yet?"}),(0,a.jsx)(n.Box,{my:"spacer-3",children:(0,a.jsx)(n.Button,{size:"s",variant:"link",onClick:T,children:"Request a lab order"})}),(0,a.jsx)(n.Text,{mt:"spacer-6",variant:"text-header-S",color:"text-primary",children:"Not ready?"}),(0,a.jsx)(n.Box,{my:"spacer-3",children:(0,a.jsx)(n.Button,{size:"s",variant:"link",onClick:F,children:"Submit lab results later"})}),y&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(n.Text,{mt:"spacer-6",variant:"text-header-S",color:"text-primary",children:"Logout"}),(0,a.jsx)(n.Box,{my:"spacer-3",children:(0,a.jsx)(n.Button,{size:"s",variant:"link",onClick:()=>{localStorage.removeItem("evolve_access_token"),localStorage.removeItem("evolve_user_email"),j.replace("/lab-flow-testing/login")},children:"Logout"})})]})]})]}),(0,a.jsx)(i.X.Form,{children:(0,a.jsx)(d,{onSubmit:R,isSubmitting:w,onRequestLabOrder:T,onSubmitLater:F})})]})]})}}}]);