"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})},45383:(e,t,r)=>{r.d(t,{s:()=>i,X:()=>n.X});var a=r(37876),s=r(37477);let i=e=>(0,a.jsx)(s.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 n=r(52036)},50941:(e,t,r)=>{r.d(t,{Ay:()=>d});var a=r(46512),s=r(91123),i=r.n(s),n=r(99742),o=r(99742);class l{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 s=(0,a.Ak)();r.setHeader("x-request-id",s);let i={host:t.headers.host,referer:t.headers.referer,handler:e,requestId:s,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"===o.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:o.env.AWS_BRANCH||o.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:n.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:n.env.AWS_BRANCH||n.env.BRANCH||"local"}}),this.contextStorage=new l}}let d=new c},52036:(e,t,r)=>{r.d(t,{X:()=>n});var a=r(37876),s=r(37477),i=r(45383);let n=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});n.Side=e=>(0,a.jsx)(s.Flex,{direction:"column",gap:{base:"spacer-6",lg:"spacer-8"},flex:1,...e}),n.Form=e=>(0,a.jsx)(s.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:()=>g});var a=r(37876),s=r(37477),i=r(52036),n=r(89099),o=r(14232);function l(e){let{name:t,onDelete:r}=e;return(0,a.jsxs)(s.Flex,{justify:"space-between",align:"center",borderBottomWidth:"1px",borderBottomColor:"border-subtle",borderBottomStyle:"solid",width:"100%",children:[(0,a.jsx)(s.Text,{variant:"text-body-regular",color:"text-primary",fontWeight:"normal",children:t}),(0,a.jsx)(s.ButtonIcon,{variant:"ghost",onClick:r,icon:(0,a.jsx)(s.IconTrash,{}),size:"l","aria-label":"delete",borderRadius:"radii-2",p:"spacer-1",m:"spacer-1"})]})}function c(){let{onSubmit:e,isSubmitting:t=!1,onRequestLabOrder:r,onSubmitLater:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[n,c]=(0,o.useState)([]),d=(0,o.useRef)(null),x=(0,s.useToast)(),u=()=>{if(0===n.length)return void x({title:"Error",description:"Please upload at least one file",status:"error"});let t=n.map(e=>e.file);e?e(t):x({title:"Success",description:"Submitting ".concat(n.length," file(s): ").concat(n.map(e=>e.name).join(", ")),status:"success"})};return(0,a.jsxs)(s.Box,{children:[(0,a.jsxs)(s.Box,{py:"spacer-4",px:"spacer-3",bg:"background-dark",borderRadius:"radii-4",mb:"spacer-4",children:[(0,a.jsx)(s.Text,{variant:"text-header-M",color:"text-light",pb:"spacer-4",children:"Upload Your Lab Results"}),(0,a.jsxs)(s.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)(s.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}));c(e=>[...e,...r]),d.current&&(d.current.value="")},style:{display:"none"},multiple:!0,accept:".pdf,.jpg,.jpeg,.png"}),n.length>0&&(0,a.jsx)(s.Box,{mb:"spacer-6",mt:"spacer-4",children:n.map(e=>(0,a.jsx)(l,{name:e.name,onDelete:()=>{var t;return t=e.id,void c(e=>e.filter(e=>e.id!==t))}},e.id))}),(0,a.jsx)(s.Box,{mt:"spacer-9",display:{base:"none",md:n.length>0?"block":"none"},children:(0,a.jsx)(s.Button,{onClick:u,variant:"primary",w:"full",h:"50px",borderRadius:"3xl",isDisabled:0===n.length||t,isLoading:t,children:"Submit Lab Results"})}),(0,a.jsxs)(s.Box,{display:{base:"block",md:"none"},mt:"spacer-9",children:[(0,a.jsx)(s.Text,{variant:"text-header-S",color:"text-primary",children:"Don't have lab results yet?"}),(0,a.jsx)(s.Box,{my:"spacer-3",children:(0,a.jsx)(s.Button,{size:"s",variant:"link",onClick:r,children:"Request a lab order"})}),(0,a.jsx)(s.Text,{mt:"spacer-6",variant:"text-header-S",color:"text-primary",children:"Not ready?"}),(0,a.jsx)(s.Box,{my:"spacer-3",children:(0,a.jsx)(s.Button,{size:"s",variant:"link",onClick:i,children:"Submit lab results later"})})]}),(0,a.jsx)(s.Box,{h:"70px"}),(0,a.jsx)(s.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)(s.Button,{onClick:u,variant:"primary",w:"full",h:"50px",borderRadius:"3xl",isDisabled:0===n.length||t,isLoading:t,children:"Submit Lab Results"})})]})}var d=r(61032);function x(e){let{isOpen:t,onClose:r,diabetes:i,bariatric:n}=e;if(!t)return null;let o=(0,d.o)({diabetes:i,bariatric:n,labName:"generic"});return(0,a.jsx)(s.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)(s.Box,{bg:"background-card",borderRadius:"lg",p:"spacer-8",maxW:"500px",w:"100%",children:[(0,a.jsxs)(s.Flex,{alignItems:"center",justifyContent:"space-between",mb:"spacer-6",children:[(0,a.jsx)(s.Text,{variant:"text-header-M",color:"text-primary",children:"Required labs"}),(0,a.jsx)(s.IconX,{color:"text-secondary",cursor:"pointer",onClick:r})]}),(0,a.jsx)(s.Box,{as:"ul",pl:"spacer-6",mb:"spacer-4",maxH:"400px",overflowY:"auto",children:o.map(e=>(0,a.jsx)(s.Text,{as:"li",color:"text-secondary",mb:"spacer-2",children:e},e))})]})})}function u(e){let{isOpen:t,onClose:r,onSubmitLater:i,onRequestLabs:n}=e;return(0,a.jsxs)(s.Modal,{isOpen:t,onClose:r,isCentered:!0,children:[(0,a.jsx)(s.Modal.Overlay,{}),(0,a.jsxs)(s.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)(s.Modal.Header,{p:0,children:[(0,a.jsx)(s.Text,{variant:"text-header-M",color:"text-primary",pt:"20px",children:"Submit labs later?"}),(0,a.jsx)(s.Modal.CloseButton,{color:"text-secondary"})]}),(0,a.jsxs)(s.Modal.Body,{p:0,display:"flex",flexDirection:"column",children:[(0,a.jsx)(s.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)(s.Flex,{direction:"column",gap:"spacer-4",children:[(0,a.jsx)(s.Button,{variant:"primary",onClick:i,borderRadius:"3xl",size:{base:"m",md:"l"},children:"Submit labs later"}),(0,a.jsx)(s.Button,{variant:"primary-alt",onClick:n,borderRadius:"3xl",size:{base:"m",md:"l"},children:"Request Labs"})]})]})]})]})}let p=()=>(0,a.jsxs)(s.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)(s.Spinner,{size:"s",color:"text-light"}),(0,a.jsx)(s.Text,{variant:"text-body-bold",color:"text-light",mt:"spacer-3",children:"We're sending your lab results"}),(0,a.jsx)(s.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 h=r(12342),m=r(50941);let b={submitLabs:async(e,t)=>{m.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 h.A.post("/api/submit-labs",r,{headers:{"Content-Type":"multipart/form-data"}})).data}};function g(e){let{patientId:t,onSubmitLabsLater:r,onLabSubmitted:l,onGoBackToRequestLabs:d,diabetes:h,bariatric:m,isLogoutFunctionality:g}=e,y=(0,s.useToast)(),f=(0,n.useRouter)(),[j,v]=(0,o.useState)(!1),[S,C]=(0,o.useState)(!1),[w,B]=(0,o.useState)(!1),k=async e=>{if((e=>{if(e.length>10)return y({title:"Error",description:"You can only upload up to ".concat(10," files"),status:"error"}),!1;for(let t of e){if(t.size>5242880)return y({title:"Error",description:"File ".concat(t.name," exceeds the maximum size of 5MB"),status:"error"}),!1;if("application/pdf"!==t.type)return y({title:"Error",description:"File ".concat(t.name," must be a PDF"),status:"error"}),!1}return!0})(e))try{B(!0);let r=await b.submitLabs(e,t);l(),y({title:"Success",description:r.message,status:"success"})}catch(e){y({title:"Error",description:e instanceof Error?e.message:"Failed to submit lab results",status:"error"})}finally{B(!1)}},L=()=>{C(!0)},R=()=>{C(!1),d()};return w?(0,a.jsx)(p,{}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x,{isOpen:j,onClose:()=>{v(!1)},diabetes:h,bariatric:m}),(0,a.jsx)(u,{isOpen:S,onClose:()=>C(!1),onSubmitLater:()=>{C(!1),r()},onRequestLabs:R}),(0,a.jsxs)(i.X,{children:[(0,a.jsxs)(i.X.Side,{children:[(0,a.jsxs)(s.TextPairing,{variant:"textpairing-header-2XL",children:[(0,a.jsx)(s.TextPairing.Label,{color:"text-primary",children:"Submit Lab Results"}),(0,a.jsxs)(s.TextPairing.SubLabel,{color:"text-secondary",fontSize:"20px",children:["Before uploading, please confirm that your documents:",(0,a.jsxs)(s.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)(s.Button,{fontSize:20,variant:"link",fontWeight:"400",onClick:()=>{v(!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)(s.Box,{display:{base:"none",md:"block"},children:[(0,a.jsx)(s.Text,{variant:"text-header-S",color:"text-primary",children:"Don't have lab results yet?"}),(0,a.jsx)(s.Box,{my:"spacer-3",children:(0,a.jsx)(s.Button,{size:"s",variant:"link",onClick:R,children:"Request a lab order"})}),(0,a.jsx)(s.Text,{mt:"spacer-6",variant:"text-header-S",color:"text-primary",children:"Not ready?"}),(0,a.jsx)(s.Box,{my:"spacer-3",children:(0,a.jsx)(s.Button,{size:"s",variant:"link",onClick:L,children:"Submit lab results later"})}),g&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.Text,{mt:"spacer-6",variant:"text-header-S",color:"text-primary",children:"Logout"}),(0,a.jsx)(s.Box,{my:"spacer-3",children:(0,a.jsx)(s.Button,{size:"s",variant:"link",onClick:()=>{localStorage.removeItem("evolve_access_token"),localStorage.removeItem("evolve_user_email"),f.replace("/lab-flow-testing/login")},children:"Logout"})})]})]})]}),(0,a.jsx)(i.X.Form,{children:(0,a.jsx)(c,{onSubmit:k,isSubmitting:w,onRequestLabOrder:R,onSubmitLater:L})})]})]})}}}]);