-
Notifications
You must be signed in to change notification settings - Fork 0
/
451.bundle.2640358078ce35cce3c5.js
2 lines (2 loc) · 7.03 KB
/
451.bundle.2640358078ce35cce3c5.js
1
2
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[451],{4451:(e,t,n)=>{n.r(t),n.d(t,{default:()=>g});var a=n(3827),s=n.n(a),r=n(43001),i=n(69190),o=n(71771),l=n(22582);const c=function(e,t,n){const{tools:a}=t.get("cornerstone.overlayViewportTools")??{};return e.createToolGroupAndAddTools(n,a)},u={NO_NEVER:-1,CANCEL:0,HYDRATE_SEG:5};const p=function(e){let{servicesManager:t,segDisplaySet:n,viewportId:a,preHydrateCallbacks:s,hydrateSEGDisplaySet:r}=e;const{uiViewportDialogService:i}=t.services;return new Promise((async function(e,t){const o=await function(e,t){return new Promise((function(n,a){const s="Do you want to open this Segmentation?",r=[{type:l.LZ.dt.secondary,text:"No",value:u.CANCEL},{type:l.LZ.dt.primary,text:"Yes",value:u.HYDRATE_SEG}],i=t=>{e.hide(),n(t)};e.show({viewportId:t,type:"info",message:s,actions:r,onSubmit:i,onOutsideClick:()=>{e.hide(),n(u.CANCEL)}})}))}(i,a);if(o===u.HYDRATE_SEG){s?.forEach((e=>{e()}));e(await r({segDisplaySet:n,viewportId:a}))}}))};function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},d.apply(this,arguments)}const{formatDate:m}=o.utils;function S(e){const{children:t,displaySets:n,viewportOptions:a,viewportLabel:s,servicesManager:u,extensionManager:S,commandsManager:g}=e,{t:y}=(0,i.$G)("SEGViewport"),E=a.viewportId,{displaySetService:v,toolGroupService:f,segmentationService:w,uiNotificationService:D,customizationService:b}=u.services,h=`SEGToolGroup-${E}`;if(n.length>1)throw new Error("SEG viewport should only have a single display set");const I=n[0],[N,C]=(0,l.O_)(),[T,k]=(0,r.useState)(1),[G,A]=(0,r.useState)(I.isHydrated),[P,O]=(0,r.useState)(!I.isLoaded),[x,M]=(0,r.useState)(null),[L,U]=(0,r.useState)({percentComplete:null,totalSegments:null}),V=(0,r.useRef)(null),{viewports:R,activeViewportId:_}=N,H=I.getReferenceDisplaySet(),j=function(e,t){const{SharedFunctionalGroupsSequence:n}=t.instance,a=Array.isArray(n)?n[0]:n,{PixelMeasuresSequence:s}=a,r=Array.isArray(s)?s[0]:s,{SpacingBetweenSlices:i,SliceThickness:o}=r,l=e.images[0],c={PatientID:l.PatientID,PatientName:l.PatientName,PatientSex:l.PatientSex,PatientAge:l.PatientAge,SliceThickness:l.SliceThickness||o,StudyDate:l.StudyDate,SeriesDescription:l.SeriesDescription,SeriesInstanceUID:l.SeriesInstanceUID,SeriesNumber:l.SeriesNumber,ManufacturerModelName:l.ManufacturerModelName,SpacingBetweenSlices:l.SpacingBetweenSlices||i};return c}(H,I);V.current={displaySet:H,metadata:j};const F=e=>{M(e.detail.element)},Y=()=>{M(null)},q=(0,r.useCallback)((()=>{N?.viewports.forEach((e=>{let{viewportId:t}=e;g.runCommand("storePresentation",{viewportId:t})}))}),[N]),B=(0,r.useCallback)((()=>{const{component:t}=S.getModuleEntry("@ohif/extension-cornerstone.viewportModule.cornerstone"),{displaySet:n}=V.current;return r.createElement(t,d({},e,{displaySets:[n,I],viewportOptions:{viewportType:"volume",toolGroupId:h,orientation:a.orientation,viewportId:a.viewportId},onElementEnabled:F,onElementDisabled:Y}))}),[E,I,h]),$=(0,r.useCallback)((e=>{e="left"===e?-1:1;const t=I.displaySetInstanceUID,n=w.getSegmentation(t),{segments:a}=n,s=Object.keys(a).length;let r=T+e;r>s-1?r=1:0===r&&(r=s-1),w.jumpToSegmentCenter(t,r,h),k(r)}),[T]);(0,r.useEffect)((()=>{P||p({servicesManager:u,viewportId:E,segDisplaySet:I,preHydrateCallbacks:[q],hydrateSEGDisplaySet:ae}).then((e=>{e&&A(!0)}))}),[u,E,I,P]),(0,r.useEffect)((()=>{const{unsubscribe:e}=w.subscribe(w.EVENTS.SEGMENTATION_LOADING_COMPLETE,(e=>{e.segDisplaySet.displaySetInstanceUID===I.displaySetInstanceUID&&O(!1),e.overlappingSegments&&D.show({title:"Overlapping Segments",message:"Overlapping segments detected which is not currently supported",type:"warning"})}));return()=>{e()}}),[I]),(0,r.useEffect)((()=>{const{unsubscribe:e}=w.subscribe(w.EVENTS.SEGMENT_LOADING_COMPLETE,(e=>{let{percentComplete:t,numSegments:n}=e;U({percentComplete:t,totalSegments:n})}));return()=>{e()}}),[I]),(0,r.useEffect)((()=>{const e=v.subscribe(v.EVENTS.DISPLAY_SETS_REMOVED,(e=>{let{displaySetInstanceUIDs:t}=e;const n=R.get(_);t.includes(n.displaySetInstanceUID)&&C.setDisplaySetsForViewport({viewportId:_,displaySetInstanceUIDs:[]})}));return()=>{e.unsubscribe()}}),[]),(0,r.useEffect)((()=>{let e=f.getToolGroup(h);if(!e)return e=c(f,b,h),()=>{w.removeSegmentationRepresentationFromToolGroup(h),f.destroyToolGroup(h)}}),[]),(0,r.useEffect)((()=>(A(I.isHydrated),()=>{w.removeSegmentationRepresentationFromToolGroup(h),V.current=null})),[I]);let J=null;if(!V.current||H.displaySetInstanceUID!==V.current.displaySet.displaySetInstanceUID)return null;t&&t.length&&(J=t.map(((e,t)=>e&&r.cloneElement(e,{viewportId:E,key:t}))));const{PatientID:Z,PatientName:z,PatientSex:K,PatientAge:Q,SliceThickness:W,ManufacturerModelName:X,StudyDate:ee,SeriesDescription:te,SpacingBetweenSlices:ne}=V.current.metadata,ae=e=>{let{segDisplaySet:t,viewportId:n}=e;g.runCommand("loadSegmentationDisplaySetsForViewport",{displaySets:[t],viewportId:n})},se=async()=>{q();const e=await ae({segDisplaySet:I,viewportId:E});A(e)};return r.createElement(r.Fragment,null,r.createElement(l.uY,{onDoubleClick:e=>{e.stopPropagation(),e.preventDefault()},onArrowsClick:$,getStatusComponent:()=>function(e){let{isHydrated:t,onStatusClick:n}=e,a=null,s=null;const{t:o}=(0,i.$G)("Common"),c=o("LOAD");switch(t){case!0:s=()=>r.createElement(l.JO,{name:"status-alert"}),a=()=>r.createElement("div",null,"This Segmentation is loaded in the segmentation panel");break;case!1:s=()=>r.createElement(l.JO,{className:"text-aqua-pale",name:"status-untracked"}),a=()=>r.createElement("div",null,"Click LOAD to load segmentation.")}const u=()=>r.createElement("div",{className:"flex h-6 cursor-default text-sm leading-6 text-white"},r.createElement("div",{className:"bg-customgray-100 flex min-w-[45px] items-center rounded-l-xl rounded-r p-1"},r.createElement(s,null),r.createElement("span",{className:"ml-1"},"SEG")),!t&&r.createElement("div",{className:"bg-primary-main hover:bg-primary-light ml-1 cursor-pointer rounded px-1.5 hover:text-black",onMouseUp:n},c));return r.createElement(r.Fragment,null,a&&r.createElement(l.u,{content:r.createElement(a,null),position:"bottom-left"},r.createElement(u,null)),!a&&r.createElement(u,null))}({isHydrated:G,onStatusClick:se}),studyData:{label:s,useAltStyling:!0,studyDate:m(ee),seriesDescription:`SEG Viewport ${te}`,patientInformation:{patientName:z?o.default.utils.formatPN(z.Alphabetic):"",patientSex:K||"",patientAge:Q||"",MRN:Z||"",thickness:W?o.utils.roundNumber(W,2):"",thicknessUnits:void 0!==W?"mm":"",spacing:void 0!==ne?o.utils.roundNumber(ne,2):"",scanner:X||""}}}),r.createElement("div",{className:"relative flex h-full w-full flex-row overflow-hidden"},P&&r.createElement(l.bk,{className:"h-full w-full",totalNumbers:L.totalSegments,percentComplete:L.percentComplete,loadingText:"Loading SEG..."}),B(),J))}S.propTypes={displaySets:s().arrayOf(s().object),viewportId:s().string.isRequired,dataSource:s().object,children:s().node,customProps:s().object},S.defaultProps={customProps:{}};const g=S}}]);
//# sourceMappingURL=451.bundle.2640358078ce35cce3c5.js.map