Mini Shell
import{_ as b,j as y,i as c,a as I,o as r,c as l,b as i,n as g,t as d,k as n,l as p,e as D,p as S,f as w}from"./index-BPjHW1Sm.js";import{a as u,b as f,d as k,f as _}from"./cornerstoneWADOImageLoader.bundle.min-EU_ZCHA5.js";const T={data(){return{moment:y,currentIndex:0,imageIds:[],element:null,dicomMetadata:null,isSidebarClosed:!1}},props:{currentSelectedDisplayItem:{type:Object,required:!0}},mounted(){this.$nextTick(()=>{this.loadFromUrl()})},methods:{closeDicomViewer(){this.$emit("closeDicomViewer")},isURLDicomImage(t){return t.split("?")[0].split("#")[0].toLowerCase().endsWith(".dcm")},loadAndDisplayImage(t){u.loadAndCacheImage(t).then(a=>{u.displayImage(this.element,a),this.extractMetadataFromUrl(t)}).catch(a=>{console.error(`Error loading image: ${a}`)})},loadFromUrl(){if(this.isURLDicomImage(this.currentSelectedDisplayItem.filePath))if(this.element=this.$refs.dicomImage,this.element){u.enable(this.element),f.external.cornerstone=k,f.external.dicomParser=_,f.configure({beforeSend:function(a){}}),u.registerImageLoader("wadouri",f.wadouri.loadImage);const t=`wadouri:${this.currentSelectedDisplayItem.filePath}`;this.loadAndDisplayImage(t)}else console.error("Failed to find the DICOM image element.")},extractMetadataFromUrl(t){const a=t.replace("wadouri:","");fetch(a).then(e=>e.arrayBuffer()).then(e=>{const o=_.parseDicom(new Uint8Array(e)),s=this.extractImportantMetadata(o);this.dicomMetadata=s,console.log(s)}).catch(e=>{console.error(`Error fetching metadata: ${e}`)})},extractImportantMetadata(t){return{patientName:t.string("x00100010"),studyDate:t.string("x00080020"),modality:t.string("x00080060"),institutionName:t.string("x00080080"),studyDescription:t.string("x00081030"),seriesDescription:t.string("x0008103e")}},async getFileImage(t){this.showFileTableLoader=!0;let a={};try{t&&(a.uuid=t),await this.$http.get("api/v1/files",{params:a}).then(e=>{const o=e.data;o.status&&(console.log("dataa",o),this.currentSelectedDisplayItem.fileData=o.data,this.showFileTableLoader=!1)})}catch(e){if(this.showFileTableLoader=!1,e.response){const o=e.response.status;o===401?await this.refreshToken(this.getFileImage):(console.error(`Error ${o}: ${e.response.data.message}`),c.error(`Error ${o}: ${e.response.data.message}`,{autoClose:3e3,position:c.POSITION.TOP_RIGHT}))}else e.request?(console.error("No response received:",e.request),c.error("No response received. Please try again later.",{autoClose:3e3,position:c.POSITION.TOP_RIGHT})):(console.error("Error",e),c.error(`Error: ${e.message}`,{autoClose:3e3,position:c.POSITION.TOP_RIGHT}))}},async getFiles(t=null,a=null){this.showFileTableLoader=!0;let e={};try{t&&(e.page=t),a&&(e.search=a),console.log("herte",t),await this.$http.get("api/v1/files",{params:e}).then(o=>{const s=o.data;s.status&&(this.filesData=s,this.showFileTableLoader=!1)})}catch(o){if(this.showFileTableLoader=!1,o.response){const s=o.response.status;s===401?await this.refreshToken(this.getFiles):(console.error(`Error ${s}: ${o.response.data.message}`),c.error(`Error ${s}: ${o.response.data.message}`,{autoClose:3e3,position:c.POSITION.TOP_RIGHT}))}else o.request?(console.error("No response received:",o.request),c.error("No response received. Please try again later.",{autoClose:3e3,position:c.POSITION.TOP_RIGHT})):(console.error("Error",o),c.error(`Error: ${o.message}`,{autoClose:3e3,position:c.POSITION.TOP_RIGHT}))}},async refreshToken(t){try{const a=await this.$http.post("api/token/refresh",{refresh:this.$store.state.refresh});a.data.access?(this.$store.commit("setAccess",a.data.access),I.defaults.headers.common.Authorization=`Bearer ${a.data.access}`,await t()):this.$router.push("/login")}catch(a){console.error("Failed to refresh token",a),this.$router.push("/login")}}}},h=t=>(S("data-v-46e5904b"),t=t(),w(),t),C={class:"modal-dicom-viewer"},M={class:"modal-content"},P={class:"close-modal"},x=h(()=>i("span",null,null,-1)),N=h(()=>i("h3",{class:"title"},null,-1)),O={class:"sidebar-control"},F={key:0,class:"basic-info side"},L={key:0},E=h(()=>i("p",null,[i("i",{class:"fa-solid fa-copy"}),p("1")],-1)),U={key:1,class:"basic-info"},R={key:0},V={key:1},A={style:{color:"var(--primary)"}},B=h(()=>i("div",{class:"pic-box"},[i("div",{class:"img-box"})],-1)),G={class:"right"},H=D('<div class="controls" data-v-46e5904b><div class="ruler" data-v-46e5904b><button class="length" data-v-46e5904b><i class="fa-solid fa-ruler" data-v-46e5904b></i></button></div><div class="zoom" data-v-46e5904b><button class="zoom-control" data-v-46e5904b><i class="fa-solid fa-magnifying-glass" data-v-46e5904b></i></button></div><div class="rotate" data-v-46e5904b><button class="rotate-left" data-v-46e5904b><i class="fas fa-undo" data-v-46e5904b></i></button></div><div class="contrast" data-v-46e5904b><button class="contrast-minus active" data-v-46e5904b><i class="fa-solid fa-circle-half-stroke" data-v-46e5904b></i></button></div><div class="move" data-v-46e5904b><button class="move" data-v-46e5904b><i class="fa-solid fa-up-down-left-right" data-v-46e5904b></i></button></div><div class="rotate" data-v-46e5904b><button class="rotate-right" data-v-46e5904b><i class="fas fa-redo" data-v-46e5904b></i></button></div><div class="reset" data-v-46e5904b><button data-v-46e5904b><i class="fas fa-sync" data-v-46e5904b></i></button></div></div>',1),q={class:"dicom-viewer"},z={key:0,id:"dicomViewer",ref:"dicomViewer"},Y={key:0,class:"split"},j={key:0,class:"left"},W=["src"],J={key:0,class:"loading table"},K=h(()=>i("div",{class:"loader"},null,-1)),Q=[K],X={key:1,class:""},Z={class:"right"},$=["src"],ee={key:1,class:"single"},te={key:0,class:"left"},se=["src"],ae={key:1,class:"left dicom"},ie={id:"dicomImage",ref:"dicomImage",class:"img",style:{width:"600px",height:"600px",margin:"auto"}};function oe(t,a,e,o,s,m){return r(),l("div",C,[i("div",M,[i("div",P,[i("i",{class:"fa-solid fa-angles-left",onClick:a[0]||(a[0]=(...v)=>m.closeDicomViewer&&m.closeDicomViewer(...v))}),x]),N,i("div",{class:g(["main",{close:s.isSidebarClosed}])},[i("div",{class:g(["sidebar",{close:s.isSidebarClosed}]),style:{position:"relative",display:"block"}},[i("div",O,[s.isSidebarClosed?(r(),l("i",{key:1,class:"fa-solid fa-angles-right",onClick:a[2]||(a[2]=v=>s.isSidebarClosed=!s.isSidebarClosed)})):(r(),l("i",{key:0,class:"fa-solid fa-angles-left",onClick:a[1]||(a[1]=v=>s.isSidebarClosed=!s.isSidebarClosed)}))]),s.isSidebarClosed?n("",!0):(r(),l("div",F,[e.currentSelectedDisplayItem&&!s.dicomMetadata?(r(),l("p",L,d(s.moment(e.currentSelectedDisplayItem.date_added).format("DD MMM, YYYY -> hh:mm:ss A")),1)):n("",!0),E])),s.isSidebarClosed?n("",!0):(r(),l("div",U,[s.dicomMetadata?(r(),l("div",R,[i("p",null,"NAME/LABEL: "+d(s.dicomMetadata.patientName.replace("^"," ")),1),i("p",null,"Modality: "+d(s.dicomMetadata.modality),1),i("p",null,"Institution Name: "+d(s.dicomMetadata.institutionName),1),i("p",null,"Study Date: "+d(s.dicomMetadata.studyDate.slice(6,8))+"-"+d(s.dicomMetadata.studyDate.slice(4,6))+"-"+d(s.dicomMetadata.studyDate.slice(0,4)),1),i("p",null,"study Description: "+d(s.dicomMetadata.studyDescription),1)])):n("",!0),e.currentSelectedDisplayItem.model_name?(r(),l("p",V,[p("Model Name: "),i("span",A,d(e.currentSelectedDisplayItem.model_name),1)])):n("",!0)])),B],2),i("div",G,[H,i("div",q,[e.currentSelectedDisplayItem?(r(),l("div",z,[e.currentSelectedDisplayItem.mode=="split"?(r(),l("div",Y,[e.currentSelectedDisplayItem.fileData?(r(),l("div",j,[i("img",{src:e.currentSelectedDisplayItem.fileData.getFileURL,alt:""},null,8,W),t.showFileTableLoader?(r(),l("div",J,Q)):n("",!0)])):(r(),l("div",X,d(m.getFileImage(e.currentSelectedDisplayItem.fileUUID)),1)),i("div",Z,[i("img",{src:e.currentSelectedDisplayItem.getResultURL||t.getResultImage(e.currentSelectedDisplayItem.result.uuid),alt:""},null,8,$)])])):(r(),l("div",ee,[m.isURLDicomImage(e.currentSelectedDisplayItem.filePath)?(r(),l("div",ae,[i("div",ie,null,512)])):(r(),l("div",te,[i("img",{src:e.currentSelectedDisplayItem.filePath||m.getFileImage(e.currentSelectedDisplayItem.fileUUID)||t.img2,alt:""},null,8,se)]))]))],512)):n("",!0)])])],2)])])}const ce=b(T,[["render",oe],["__scopeId","data-v-46e5904b"]]);export{ce as D};