mau coba di hangtuah yang sudah oke fitur exp nya
This commit is contained in:
@@ -71,11 +71,25 @@ const SidePanelWithServices = ({
|
||||
const activatePanelSubscription = panelService.subscribe(
|
||||
panelService.EVENTS.ACTIVATE_PANEL,
|
||||
(activatePanelEvent: Types.ActivatePanelEvent) => {
|
||||
if (sidePanelOpen || activatePanelEvent.forceActive) {
|
||||
const tabIndex = tabs.findIndex(tab => tab.id === activatePanelEvent.panelId);
|
||||
if (tabIndex !== -1) {
|
||||
setActiveTabIndex(tabIndex);
|
||||
// Handle the `-exp` suffix logic
|
||||
const isExpertisePanel = activatePanelEvent.panelId.endsWith('-exp');
|
||||
const realPanelID = isExpertisePanel
|
||||
? activatePanelEvent.panelId.replace(/-exp$/, '')
|
||||
: activatePanelEvent.panelId;
|
||||
|
||||
const tabIndex = tabs.findIndex(tab => tab.id === realPanelID);
|
||||
|
||||
if (isExpertisePanel && side === 'right') {
|
||||
const shouldOpen = !sidePanelOpen; // Use sidePanelOpen to determine toggle state
|
||||
setSidePanelOpen(shouldOpen);
|
||||
|
||||
if (shouldOpen) {
|
||||
setActiveTabIndex(tabIndex !== -1 ? tabIndex : null);
|
||||
} else {
|
||||
setActiveTabIndex(null);
|
||||
}
|
||||
} else if (tabIndex !== -1) {
|
||||
setActiveTabIndex(tabIndex);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -95,6 +109,7 @@ const SidePanelWithServices = ({
|
||||
onClose={handleClose}
|
||||
onActiveTabIndexChange={handleActiveTabIndexChange}
|
||||
expandedWidth={expandedWidth}
|
||||
servicesManager={servicesManager} // Pass servicesManager ke SidePanel
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { Icons } from '../Icons';
|
||||
import { TooltipTrigger, TooltipContent, TooltipProvider, Tooltip } from '../Tooltip';
|
||||
import { Separator } from '../Separator';
|
||||
import { ScrollArea } from '../ScrollArea';
|
||||
|
||||
type StyleMap = {
|
||||
open: {
|
||||
@@ -152,10 +153,22 @@ const SidePanel = ({
|
||||
onClose,
|
||||
expandedWidth = 280,
|
||||
onActiveTabIndexChange,
|
||||
servicesManager, // Tambah servicesManager as a prop
|
||||
}) => {
|
||||
const [panelOpen, setPanelOpen] = useState(activeTabIndexProp !== null);
|
||||
const [activeTabIndex, setActiveTabIndex] = useState(0);
|
||||
|
||||
const [isExpertiseVisible, setIsExpertiseVisible] = useState(false); // New state for expertise visibility
|
||||
const [expertiseData, setExpertiseData] = useState(null);
|
||||
const [isExpertiseLoading, setIsExpertiseLoading] = useState(false);
|
||||
|
||||
const { cornerstoneViewportService } = servicesManager.services;
|
||||
const [viewportData, setViewportData] = useState(null);
|
||||
|
||||
// Harusnya (viewportId), tapi karena gabutuh perubahan viewport maka dihardcode 'default'
|
||||
const viewportInfo = cornerstoneViewportService.getViewportInfo('default');
|
||||
const studyInstanceUID = viewportInfo?.viewportData?.data?.[0]?.StudyInstanceUID || '';
|
||||
|
||||
const styleMap = createStyleMap(expandedWidth, borderSize, collapsedWidth);
|
||||
const baseStyle = createBaseStyle(expandedWidth);
|
||||
const gridAvailableWidth = expandedWidth - closeIconWidth - gridHorizontalPadding;
|
||||
@@ -196,6 +209,16 @@ const SidePanel = ({
|
||||
updateActiveTabIndex(activeTabIndexProp);
|
||||
}, [activeTabIndexProp, updateActiveTabIndex]);
|
||||
|
||||
const toggleExpertiseVisibility = () => {
|
||||
const shouldOpenExpertise = !isExpertiseVisible;
|
||||
setIsExpertiseVisible(shouldOpenExpertise);
|
||||
|
||||
// Open the side panel if the expertise panel is being shown
|
||||
if (shouldOpenExpertise && !panelOpen) {
|
||||
updatePanelOpen(true);
|
||||
}
|
||||
};
|
||||
|
||||
const getCloseStateComponent = () => {
|
||||
const _childComponents = Array.isArray(tabs) ? tabs : [tabs];
|
||||
return (
|
||||
@@ -255,6 +278,230 @@ const SidePanel = ({
|
||||
);
|
||||
};
|
||||
|
||||
// Tambahkan di atas useEffect fetchExpertiseData
|
||||
useEffect(() => {
|
||||
const fetchAccessionNumber = async () => {
|
||||
if (!studyInstanceUID) {
|
||||
console.warn('No StudyInstanceUID available');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const qidoRootUrl = getQidoRootUrl();
|
||||
if (!qidoRootUrl) {
|
||||
console.warn('QIDO root URL not configured');
|
||||
return;
|
||||
}
|
||||
|
||||
// Fetch data with specific fields including Accession Number
|
||||
const response = await fetch(
|
||||
`${qidoRootUrl}/studies?includefield=00080050&StudyInstanceUID=${studyInstanceUID}`
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch study data');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data && data.length > 0) {
|
||||
// Extract accession number from DICOM tag 00080050
|
||||
const accessionNumber = data[0]['00080050']?.Value?.[0] || '';
|
||||
|
||||
// If we have an accession number, call fetchExpertiseData
|
||||
if (accessionNumber) {
|
||||
console.log('Found Accession Number:', accessionNumber);
|
||||
fetchExpertiseData(accessionNumber);
|
||||
} else {
|
||||
console.warn('Accession number not found in study data');
|
||||
}
|
||||
} else {
|
||||
console.warn('No study data returned');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching accession number:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Helper function to get QIDO root URL
|
||||
const getQidoRootUrl = () => {
|
||||
const { config } = window;
|
||||
if (!config?.dataSources || !config.defaultDataSourceName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const dataSource = config.dataSources.find(
|
||||
ds => ds.sourceName === config.defaultDataSourceName
|
||||
);
|
||||
|
||||
return dataSource?.configuration?.qidoRoot;
|
||||
};
|
||||
|
||||
fetchAccessionNumber();
|
||||
}, [studyInstanceUID]); // Run when studyInstanceUID changes
|
||||
|
||||
// Ubah fungsi fetchExpertiseData menjadi dengan parameter accessionNumber
|
||||
const fetchExpertiseData = async accessionNumber => {
|
||||
try {
|
||||
// Check if window.config.expertise_host exists
|
||||
if (!window.config?.expertise_host) {
|
||||
console.warn('Expertise host not configured in window.config.expertise_host');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!accessionNumber) {
|
||||
console.warn('No accession number available for expertise lookup');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsExpertiseLoading(true);
|
||||
const url = `${window.config.expertise_host}/nv/query.php?method=view&AccessionNumber=${encodeURIComponent(accessionNumber)}`;
|
||||
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
// console.log('Study data:', data);
|
||||
|
||||
const data = {
|
||||
study: {
|
||||
accession_no: 'CR.250411.001',
|
||||
study_iuid: '1.2.826.0.1.3680043.9.7307.1.20250411001',
|
||||
study_description: '',
|
||||
study_datetime: '20250411093937',
|
||||
number_of_series: '1',
|
||||
number_of_instances: '1',
|
||||
modality: 'CR',
|
||||
patient_mrn: '00000941',
|
||||
patient_name: 'NEFANNY RIDWAN',
|
||||
patient_sex: 'F',
|
||||
patient_date_of_birth: '19881127',
|
||||
patient_age: '36Y 4M 14D',
|
||||
expertise: [
|
||||
{
|
||||
expertise:
|
||||
'Keterangan : MCU\r\n\r\nRadiografi Thorax PA (inspirasi kurang)\r\n\r\nCor : besar dan bentuk normal\r\nPulmo : tak tampak infiltrat\r\nTrachea tampak di tengah\r\nSinus phrenicocostalis kanan kiri tajam\r\nHemidiafragma kanan kiri tampak baik\r\nTulang-tulang tampak baik\r\nSoft tissue tak tampak kelainan\r\n\r\nKesan :\r\nTidak tampak kelainan signifikan pada pemeriksaan saat ini\r\n\r\nBTK,',
|
||||
radiologist: 'dr. Hendra Boy Situmorang, Sp.Rad ',
|
||||
expertise_dttm: '2025-04-11 09:43',
|
||||
radiologist_edit: null,
|
||||
expertise_edit_dttm: '0000-00-00 00:00',
|
||||
ordering_physician: 'dr. Laksmitasari Dewi',
|
||||
},
|
||||
],
|
||||
series: [
|
||||
{
|
||||
series_number: '1',
|
||||
series_iuid: '1.2.156.112536.2.560.28134011043131122.1519098341436.1',
|
||||
series_description: 'V04_0014',
|
||||
number_of_instances: 1,
|
||||
thumbnail:
|
||||
'http://192.168.22.3/nv/wado_proxy_thumb.php?requestType=WADO&studyUID=1.2.826.0.1.3680043.9.7307.1.20250411001&seriesUID=1.2.156.112536.2.560.28134011043131122.1519098341436.1&objectUID=1.2.156.112536.2.560.28134011043131122.1519098341436.4&rows=123',
|
||||
sop_iuids: ['1.2.156.112536.2.560.28134011043131122.1519098341436.4'],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
if (data?.study?.expertise && data.study.expertise.length > 0) {
|
||||
setExpertiseData(data.study.expertise[0]);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching expertise data:', error);
|
||||
} finally {
|
||||
setIsExpertiseLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const getExpertisePanel = () => {
|
||||
if (side !== 'right') return null; // Only show in the right side panel
|
||||
|
||||
if (isExpertiseLoading) {
|
||||
return (
|
||||
<div className="flex h-[500px] w-[350px] items-center justify-center text-white">
|
||||
Loading expertise data...
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!expertiseData) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parseExpertise = text => {
|
||||
if (!text) return {};
|
||||
|
||||
const result = {};
|
||||
let currentSection = 'Keterangan';
|
||||
|
||||
// Split expertise text by lines and process each line
|
||||
const lines = text.split('\r\n').filter(line => line.trim() !== '');
|
||||
|
||||
lines.forEach(line => {
|
||||
// Check if this is a section header
|
||||
if (line.includes(':') && !line.trim().startsWith('-')) {
|
||||
const parts = line.split(':');
|
||||
currentSection = parts[0].trim();
|
||||
const value = parts[1]?.trim() || '';
|
||||
|
||||
if (value) {
|
||||
if (!result[currentSection]) {
|
||||
result[currentSection] = [];
|
||||
}
|
||||
result[currentSection].push(value);
|
||||
}
|
||||
} else if (line.toLowerCase().includes('kesan')) {
|
||||
currentSection = 'Kesan';
|
||||
} else {
|
||||
// Add line to current section
|
||||
if (!result[currentSection]) {
|
||||
result[currentSection] = [];
|
||||
}
|
||||
result[currentSection].push(line.trim());
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const parsedSections = parseExpertise(expertiseData.expertise);
|
||||
|
||||
// Create formatted data structure
|
||||
const formattedData = [
|
||||
{ label: 'Dokter Pengirim', value: expertiseData.ordering_physician || '' },
|
||||
{ label: 'Dokter Radiologis', value: expertiseData.radiologist || '' },
|
||||
{ label: 'Waktu Expertise', value: expertiseData.expertise_dttm || '' },
|
||||
];
|
||||
|
||||
// Add additional sections from parsed text
|
||||
Object.entries(parsedSections).forEach(([key, value]) => {
|
||||
formattedData.push({
|
||||
label: key,
|
||||
value: Array.isArray(value) ? value : [value],
|
||||
});
|
||||
});
|
||||
|
||||
return (
|
||||
<ScrollArea className="border-input bg-background h-[500px] w-[350px] rounded-md border p-2 text-sm text-white">
|
||||
<h3 className="mb-4 text-lg font-bold">Expertise</h3>
|
||||
{formattedData.map((section, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="mb-4"
|
||||
>
|
||||
<h5 className="text-base font-bold">{section.label}:</h5>
|
||||
{Array.isArray(section.value) ? (
|
||||
<ul className="list-disc pl-6">
|
||||
{section.value.map((item, idx) => (
|
||||
<li key={idx}>{item}</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>{section.value}</p>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</ScrollArea>
|
||||
);
|
||||
};
|
||||
|
||||
const getCloseIcon = () => {
|
||||
return (
|
||||
<div
|
||||
@@ -386,6 +633,7 @@ const SidePanel = ({
|
||||
}
|
||||
return null;
|
||||
})}
|
||||
{getExpertisePanel()} {/* Add expertise panel here */}
|
||||
</>
|
||||
) : (
|
||||
<React.Fragment>{getCloseStateComponent()}</React.Fragment>
|
||||
@@ -413,6 +661,7 @@ SidePanel.propTypes = {
|
||||
onClose: PropTypes.func,
|
||||
onActiveTabIndexChange: PropTypes.func,
|
||||
expandedWidth: PropTypes.number,
|
||||
servicesManager: PropTypes.object.isRequired, // Tambah servicesManager prop
|
||||
};
|
||||
|
||||
export { SidePanel };
|
||||
|
||||
@@ -62,6 +62,7 @@ const StudyBrowser = ({
|
||||
data-cy="thumbnail-list"
|
||||
viewPreset={viewPreset}
|
||||
onThumbnailContextMenu={onThumbnailContextMenu}
|
||||
servicesManager={servicesManager} // Pass servicesManager ke Study Item
|
||||
/>
|
||||
</React.Fragment>
|
||||
);
|
||||
|
||||
@@ -20,6 +20,7 @@ const StudyItem = ({
|
||||
onClickUntrack,
|
||||
viewPreset = 'thumbnails',
|
||||
onThumbnailContextMenu,
|
||||
servicesManager, // Tambah servicesManager as a prop
|
||||
}: withAppTypes) => {
|
||||
return (
|
||||
<Accordion
|
||||
@@ -55,15 +56,32 @@ const StudyItem = ({
|
||||
}}
|
||||
>
|
||||
{isExpanded && displaySets && (
|
||||
<ThumbnailList
|
||||
thumbnails={displaySets}
|
||||
activeDisplaySetInstanceUIDs={activeDisplaySetInstanceUIDs}
|
||||
onThumbnailClick={onClickThumbnail}
|
||||
onThumbnailDoubleClick={onDoubleClickThumbnail}
|
||||
onClickUntrack={onClickUntrack}
|
||||
viewPreset={viewPreset}
|
||||
onThumbnailContextMenu={onThumbnailContextMenu}
|
||||
/>
|
||||
<>
|
||||
{/* Expertise Button */}
|
||||
<div
|
||||
className="bg-primary-dark hover:bg-primary-active my-4 w-full cursor-pointer border border-white py-2 text-center text-white"
|
||||
onClick={() => {
|
||||
// Trigger the expertise panel in the right side panel (segmentation Panel)
|
||||
servicesManager.services.panelService.activatePanel(
|
||||
'@ohif/extension-cornerstone.panelModule.panelSegmentation-exp',
|
||||
true
|
||||
);
|
||||
}}
|
||||
>
|
||||
View Expertise
|
||||
</div>
|
||||
|
||||
{/* Thumbnails */}
|
||||
<ThumbnailList
|
||||
thumbnails={displaySets}
|
||||
activeDisplaySetInstanceUIDs={activeDisplaySetInstanceUIDs}
|
||||
onThumbnailClick={onClickThumbnail}
|
||||
onThumbnailDoubleClick={onDoubleClickThumbnail}
|
||||
onClickUntrack={onClickUntrack}
|
||||
viewPreset={viewPreset}
|
||||
onThumbnailContextMenu={onThumbnailContextMenu}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</AccordionContent>
|
||||
</AccordionItem>
|
||||
@@ -86,6 +104,7 @@ StudyItem.propTypes = {
|
||||
onDoubleClickThumbnail: PropTypes.func,
|
||||
onClickUntrack: PropTypes.func,
|
||||
viewPreset: PropTypes.string,
|
||||
servicesManager: PropTypes.object.isRequired, // Tambah servicesManager prop
|
||||
};
|
||||
|
||||
export { StudyItem };
|
||||
|
||||
Reference in New Issue
Block a user