Integration TrizRis OHIF: key images, annotations, layouts, access control and reconstruction
Build and Deploy Docs / build-and-deploy-docs (push) Canceled after 0s
Build and Deploy Docs / build-and-deploy-docs (push) Canceled after 0s
This commit is contained in:
1 parent
bbe37ff388
commit
f00379a672
28 files changed
+1898
-105
No files matched your search
@@ -28,6 +28,7 @@ import { useViewportsByPositionStore } from './stores/useViewportsByPositionStor
|
||||
import { useToggleOneUpViewportGridStore } from './stores/useToggleOneUpViewportGridStore';
|
||||
import requestDisplaySetCreationForStudy from './Panels/requestDisplaySetCreationForStudy';
|
||||
import promptSaveReport from './utils/promptSaveReport';
|
||||
import { saveLayoutPreference } from './services/TrizRisLayoutApi';
|
||||
|
||||
export type HangingProtocolParams = {
|
||||
protocolId?: string;
|
||||
@@ -498,12 +499,21 @@ const commandsModule = ({
|
||||
/**
|
||||
* Changes the viewport grid layout in terms of the MxN layout.
|
||||
*/
|
||||
setViewportGridLayout: ({ numRows, numCols, isHangingProtocolLayout = false }) => {
|
||||
const { protocol } = hangingProtocolService.getActiveProtocol();
|
||||
const onLayoutChange = protocol.callbacks?.onLayoutChange;
|
||||
if (commandsManager.run(onLayoutChange, { numRows, numCols }) === false) {
|
||||
// Don't apply the layout if the run command returns false
|
||||
return;
|
||||
setViewportGridLayout: ({
|
||||
numRows,
|
||||
numCols,
|
||||
isHangingProtocolLayout = false,
|
||||
savePreference = true,
|
||||
}) => {
|
||||
const activeProtocol = hangingProtocolService.getActiveProtocol();
|
||||
const protocol = activeProtocol?.protocol;
|
||||
|
||||
const onLayoutChange = protocol?.callbacks?.onLayoutChange;
|
||||
|
||||
if (onLayoutChange) {
|
||||
if (commandsManager.run(onLayoutChange, { numRows, numCols }) === false) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const completeLayout = () => {
|
||||
@@ -525,9 +535,49 @@ const commandsModule = ({
|
||||
findOrCreateViewport,
|
||||
isHangingProtocolLayout,
|
||||
});
|
||||
|
||||
console.log('### LAYOUT CHOISI ###');
|
||||
console.log('numRows =', numRows);
|
||||
console.log('numCols =', numCols);
|
||||
console.log('isHangingProtocolLayout =', isHangingProtocolLayout);
|
||||
|
||||
if (!isHangingProtocolLayout && savePreference) {
|
||||
const hangingProtocolState = hangingProtocolService.getState();
|
||||
|
||||
const studyInstanceUID = hangingProtocolState.activeStudyUID;
|
||||
|
||||
console.log('### STUDY UID POUR LAYOUT ###', studyInstanceUID);
|
||||
if (!studyInstanceUID) {
|
||||
console.error('StudyInstanceUID introuvable dans URL');
|
||||
return;
|
||||
}
|
||||
saveLayoutPreference(numRows, numCols, studyInstanceUID)
|
||||
.then(() => {
|
||||
console.log('### LAYOUT SAUVEGARDE AVEC SUCCES ###');
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('### ERREUR SAUVEGARDE LAYOUT ###', error);
|
||||
});
|
||||
}
|
||||
};
|
||||
// Need to finish any work in the callback
|
||||
window.setTimeout(completeLayout, 0);
|
||||
const applyLayoutWhenReady = () => {
|
||||
const hpState = hangingProtocolService.getState();
|
||||
|
||||
if (!hpState) {
|
||||
console.log('### HANGING PROTOCOL PAS ENCORE PRET -> ATTENTE ###');
|
||||
|
||||
window.setTimeout(applyLayoutWhenReady, 100);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('### HANGING PROTOCOL PRET -> APPLICATION LAYOUT ###');
|
||||
|
||||
completeLayout();
|
||||
};
|
||||
|
||||
applyLayoutWhenReady();
|
||||
},
|
||||
|
||||
toggleOneUp() {
|
||||
@@ -805,9 +855,7 @@ const commandsModule = ({
|
||||
}
|
||||
const reportBlob = datasetToDicomBlob(instances[0]);
|
||||
const type = defaultContentType || 'application/dicom';
|
||||
await navigator.clipboard.write([
|
||||
new ClipboardItem({ [type]: reportBlob }),
|
||||
]);
|
||||
await navigator.clipboard.write([new ClipboardItem({ [type]: reportBlob })]);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { TrizRisConfig } from '@ohif/core/src/config/TrizRisConfig';
|
||||
|
||||
const ACCESS_URL = `${TrizRisConfig.apiBaseUrl}/ohif/access`;
|
||||
|
||||
export async function checkTrizRisAccess(): Promise<boolean> {
|
||||
try {
|
||||
const response = await fetch(ACCESS_URL, {
|
||||
method: 'GET',
|
||||
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
return result.authorized === true;
|
||||
} catch (error) {
|
||||
console.error('### ERREUR VERIFICATION ACCES TRIZRIS ###', error);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { TrizRisConfig } from '@ohif/core/src/config/TrizRisConfig';
|
||||
const BASE_URL = `${TrizRisConfig.apiBaseUrl}/image-view-state/current`;
|
||||
|
||||
export type ImageViewState = {
|
||||
zoom: number;
|
||||
rotation: number;
|
||||
studyInstanceUID: string;
|
||||
seriesInstanceUID: string;
|
||||
sopInstanceUID: string;
|
||||
};
|
||||
|
||||
export async function saveImageViewState(state: ImageViewState): Promise<void> {
|
||||
const response = await fetch(BASE_URL, {
|
||||
method: 'POST',
|
||||
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
},
|
||||
|
||||
credentials: 'include',
|
||||
|
||||
body: JSON.stringify(state),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur sauvegarde image view state : ${response.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getImageViewState(
|
||||
studyInstanceUID: string,
|
||||
seriesInstanceUID: string,
|
||||
sopInstanceUID: string
|
||||
): Promise<ImageViewState | null> {
|
||||
const url =
|
||||
`${BASE_URL}` +
|
||||
`?studyInstanceUID=${encodeURIComponent(studyInstanceUID)}` +
|
||||
`&seriesInstanceUID=${encodeURIComponent(seriesInstanceUID)}` +
|
||||
`&sopInstanceUID=${encodeURIComponent(sopInstanceUID)}`;
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: 'GET',
|
||||
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
|
||||
credentials: 'include',
|
||||
});
|
||||
|
||||
if (response.status === 204) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur récupération image view state : ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import { TrizRisConfig } from '@ohif/core/src/config/TrizRisConfig';
|
||||
const BASE_URL = `${TrizRisConfig.apiBaseUrl}/layout/current`;
|
||||
|
||||
export type SavedLayout = {
|
||||
numRows: number;
|
||||
numCols: number;
|
||||
};
|
||||
|
||||
export async function saveLayoutPreference(
|
||||
numRows: number,
|
||||
numCols: number,
|
||||
studyInstanceUID: string
|
||||
): Promise<void> {
|
||||
const response = await fetch(BASE_URL, {
|
||||
method: 'POST',
|
||||
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
},
|
||||
|
||||
credentials: 'include',
|
||||
|
||||
body: JSON.stringify({
|
||||
numRows,
|
||||
numCols,
|
||||
studyInstanceUID,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur sauvegarde layout TrizRis : ${response.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function getLayoutPreference(studyInstanceUID: string): Promise<SavedLayout | null> {
|
||||
const response = await fetch(
|
||||
`${BASE_URL}?studyInstanceUID=${encodeURIComponent(studyInstanceUID)}`,
|
||||
{
|
||||
method: 'GET',
|
||||
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status === 204) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur récupération layout TrizRis : ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
Reference in new issue
Block a user