1import{ap as C,j as e,r as f,b as k,d as N,ar as L,g as j,f as P,i as $,k as u,B as H,M as S,a as B,C as U}from"./index-ChXoPu6S.js";import{P as V}from"./PageBreadcrumb-Cjqn50UQ.js";import{T as _,R as z}from"./SnakeGame-CsMt9RAa.js";import{c as R,b as O,I as q,S as G}from"./react-select.esm-Ct896mvA.js";import{d as J,o as K}from"./formatoArchivos-BBWclpKc.js";import"./config-DTzykzoJ.js";import"./extends-CF3RwP-h.js";import"./emotion-react.browser.esm-Bhyw9kUC.js";import"./emotion-element-5486c51c.browser.esm-Db1GmnPa.js";function Q(){return{leerTipoEstudios:()=>C.get("/docPacientes/TipoEstudios"),leerEstudio:(t,s)=>C.get(`/docPacientes/Estudios/${encodeURIComponent(t)}/${s}`),buscarDocumento:t=>C.get(`/docPacientes/SearchDoc/${encodeURIComponent(t)}`,{responseType:"blob"})}}const I=Q(),W=({html:t})=>e.jsx("div",{dangerouslySetInnerHTML:{__html:t}}),A=t=>e.jsx("img",{src:t.data.icon,alt:"logo",className:"rounded",style:{height:"25px",width:"25px",marginRight:"10px"}}),X=({children:t,...s})=>e.jsxs(R.SingleValue,{...s,children:[A(s),e.jsx("span",{className:"fontTexto",children:t})]}),Y=t=>e.jsxs(R.Option,{...t,children:[A(t),e.jsx("span",{className:"fontTexto",children:t.data.label})]});function F(){const[t,s]=f.useState(!1),{user:n,removeSession:l,isAuthenticated:x}=k(),o=N(),{tipoEstudios:v,guardarTipoEstudios:E,estudios:M,guardarEstudios:d,showModalInterpretaciom:a,abrirModalInterpretacion:h,cerrarModalInterpretacion:g}=L(),b=async()=>{s(!0);try{await I.leerTipoEstudios().then(async r=>{const p=r.data;E(p)}).catch(r=>{var i;!c((i=r==null?void 0:r.response)==null?void 0:i.status)&&x&&j(o.formatMessage({id:"errorLoadingMedicalStudyTypes"}),"warning")})}catch{j(o.formatMessage({id:"generalError"}),"warning")}finally{s(!1)}},T=async r=>{s(!0);try{const p=await P(n.cvePaciente);await I.leerEstudio(p,r).then(async i=>{const m=i.data;d(m)}).catch(i=>{var y;!c((y=i==null?void 0:i.response)==null?void 0:y.status)&&x&&j(o.formatMessage({id:"errorLoadingMedicalStudies"}),"warning")})}catch{j(o.formatMessage({id:"generalError"}),"warning")}finally{s(!1)}},w=async(r,p)=>{s(!0);try{const i=await P(r.toString());await I.buscarDocumento(i).then(async m=>{const y=new Blob([m.data],{type:m.headers["content-type"]});J(y,p)}).catch(m=>{var D;!c((D=m==null?void 0:m.response)==null?void 0:D.status)&&x&&j(o.formatMessage({id:"errorDownloadingFile"}),"warning")})}catch{j(o.formatMessage({id:"generalError"}),"warning")}finally{s(!1)}},c=r=>r==$.Unauthorized?(l(),!0):!1;return{loading:t,tipoEstudios:v,leerTipoEstudios:b,estudios:M,leerEstudio:T,buscarDocumento:w,showModalInterpretaciom:a,abrirModalInterpretacion:h,cerrarModalInterpretacion:g}}const Z=({setInterpretacion:t})=>{const s=N(),{loading:n,estudios:l,abrirModalInterpretacion:x,buscarDocumento:o}=F(),v=a=>a.docExterno>0||a.cveInterpretacion>0,E=a=>{if((a==null?void 0:a.docExterno)>0)window.open(a.ruta,"_blank","noopener noreferrer");else if((a==null?void 0:a.cveInterpretacion)>0)t(a),x();else{const h=K(a.ruta),g=`${a.documento}${h}`;o(a.cveDocumento,g)}},M=[{Header:u("date"),accessor:"fecha",defaultCanSort:!0,Cell:({value:a})=>e.jsxs("span",{children:[" ",s.formatDate(a,{year:"numeric",month:"short",day:"numeric"})]})},{Header:u("document"),accessor:"documento",defaultCanSort:!1},{Header:u("actions"),accessor:"cveDocumento",defaultCanSort:!1,Cell:({row:a})=>{let h=a.values,g=l.find(b=>b.cveDocumento==h.cveDocumento);return e.jsx(e.Fragment,{children:e.jsx("div",{className:"text-center",children:e.jsx(H,{disabled:n,style:{width:"60%"},variant:"primary",className:"botonElegirHora",onClick:()=>E(g),children:v(g)?e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"ri-file-text-line"})," ",u("view")]}):e.jsxs(e.Fragment,{children:[e.jsx("i",{className:"ri-download-2-line"})," ",u("download")]})})})})}}],d=[{text:"5",value:5},{text:"10",value:10},{text:"25",value:25},{text:"All",value:l.length}];return e.jsx(_,{columns:M,data:l,pageSize:10,sizePerPageList:d,isSortable:!0,pagination:!0,isSearchable:!0})},ee=({showModalInterpretacion:t,manejarCerrarModal:s,interpretacion:n})=>e.jsxs(S,{show:t,centered:!0,children:[e.jsx(S.Header,{children:e.jsx(S.Title,{children:n==null?void 0:n.documento})}),e.jsx(S.Body,{children:e.jsx(W,{html:(n==null?void 0:n.interpretacion)??""})}),e.jsx(S.Footer,{children:e.jsx(H,{variant:"danger",onClick:()=>s(),children:u("close")})})]}),de=()=>{const t=f.useRef(!0),{user:s}=k(),{config:n}=B(),{tipoEstudios:l,leerTipoEstudios:x,estudios:o,leerEstudio:v,showModalInterpretaciom:E,cerrarModalInterpretacion:M}=F(),[d,a]=f.useState(),[h,g]=f.useState();f.useEffect(()=>{if((s==null?void 0:s.cvePaciente)>0)if(t.current)x(),t.current=!1;else{const c=setTimeout(()=>{x()},1e3);return()=>clearTimeout(c)}},[n.Lang,s==null?void 0:s.cvePaciente]),f.useEffect(()=>{d&&(d==null?void 0:d.value)>0&&v(d.value)},[d]);const b=f.useMemo(()=>l==null?void 0:l.map(c=>({value:c.cveTipoDocPaciente,label:c.nombreEstudio,icon:O(q,c.icon)})),[l]),T=c=>{a(c)},w=()=>{M()};return e.jsxs(e.Fragment,{children:[e.jsx(V,{subName:u("medicalStudies")}),e.jsx(z,{children:e.jsx(U,{xl:12,children:e.jsx("div",{className:"divContainer",children:e.jsxs("div",{style:{padding:"1rem"},children:[e.jsx("h4",{className:"mb-2 header-title",children:u("medicalStudies")}),e.jsx(G,{className:"mb-3",placeholder:u("selectMedicalStudy"),options:b,onChange:T,components:{Option:Y,SingleValue:X}}),(o==null?void 0:o.length)>
10?e.jsx(Z,{setInterpretacion:g}):u("noResultsMedicalStudy")]})})})}),E&&e.jsx(ee,{showModalInterpretacion:E,manejarCerrarModal:w,interpretacion:h})]})};export{de as default};
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.