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
@@ -0,0 +1,13 @@
|
||||
const TRIZRIS_BASE_URL = 'http://localhost:9090/TrizRis';
|
||||
const ORTHANC_BASE_URL = 'http://localhost:8042';
|
||||
|
||||
export const TrizRisConfig = {
|
||||
apiBaseUrl: `${TRIZRIS_BASE_URL}/api`,
|
||||
accessUrl: `${TRIZRIS_BASE_URL}/ohif/access`,
|
||||
|
||||
orthancBaseUrl: ORTHANC_BASE_URL,
|
||||
orthancDicomWebUrl: `${ORTHANC_BASE_URL}/dicom-web`,
|
||||
orthancWadoUrl: `${ORTHANC_BASE_URL}/wado`,
|
||||
|
||||
ohifBaseUrl: 'http://localhost:3000',
|
||||
};
|
||||
+17
-3
@@ -1,5 +1,6 @@
|
||||
import { annotation } from '@cornerstonejs/tools';
|
||||
import LocalStorageAnnotationPersistenceBackend from './LocalStorageAnnotationPersistenceBackend';
|
||||
import TrizRisAnnotationPersistenceBackend from './TrizRisAnnotationPersistenceBackend';
|
||||
|
||||
export interface AnnotationPersistenceBackend {
|
||||
save(record: Record<string, any>): Promise<void> | void;
|
||||
@@ -28,7 +29,8 @@ export default class AnnotationPersistenceService {
|
||||
name: 'annotationPersistenceService',
|
||||
altName: 'AnnotationPersistenceService',
|
||||
create: ({ servicesManager }: { servicesManager: any }) => {
|
||||
const backend = new LocalStorageAnnotationPersistenceBackend();
|
||||
// = new LocalStorageAnnotationPersistenceBackend();
|
||||
const backend = new TrizRisAnnotationPersistenceBackend();
|
||||
return new AnnotationPersistenceService(backend, {
|
||||
services: {
|
||||
measurementService: servicesManager.services.measurementService,
|
||||
@@ -207,8 +209,7 @@ export default class AnnotationPersistenceService {
|
||||
const resolvedSource =
|
||||
(persistedSource?.name && persistedSource?.version
|
||||
? measurementService.getSource(persistedSource.name, persistedSource.version)
|
||||
: null) ||
|
||||
measurementService.getSource('Cornerstone3DTools', '0.1');
|
||||
: null) || measurementService.getSource('Cornerstone3DTools', '0.1');
|
||||
|
||||
if (!resolvedSource) {
|
||||
console.warn('Annotation persistence: no registered source found, skipping restore');
|
||||
@@ -232,7 +233,20 @@ export default class AnnotationPersistenceService {
|
||||
|
||||
const normalizedAnnotation = this._normalizePersistedAnnotation(record.annotation);
|
||||
const rebuiltAnnotation = this._buildRestoredAnnotation(measurement, normalizedAnnotation);
|
||||
console.log('====================================');
|
||||
console.log('### RESTAURATION MEASUREMENT ###');
|
||||
|
||||
console.log('referencedImageId =', rebuiltAnnotation?.metadata?.referencedImageId);
|
||||
|
||||
console.log('FrameOfReferenceUID =', rebuiltAnnotation?.metadata?.FrameOfReferenceUID);
|
||||
|
||||
console.log('points JSON =', JSON.stringify(rebuiltAnnotation?.data?.handles?.points));
|
||||
|
||||
console.log('cachedStats JSON =', JSON.stringify(rebuiltAnnotation?.data?.cachedStats));
|
||||
|
||||
console.log('measurement JSON =', JSON.stringify(measurement));
|
||||
|
||||
console.log('====================================');
|
||||
measurementService.addOrUpdateMeasurement?.(measurement, {
|
||||
annotation: rebuiltAnnotation,
|
||||
});
|
||||
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
export interface AnnotationPersistenceBackend {
|
||||
save(record: Record<string, any>): Promise<void> | void;
|
||||
update(record: Record<string, any>): Promise<void> | void;
|
||||
delete(uid: string): Promise<void> | void;
|
||||
load(studyInstanceUID: string): Promise<any[]> | any[];
|
||||
}
|
||||
|
||||
const BASE_URL = 'http://localhost:9090/TrizRis/api/annotation';
|
||||
|
||||
export default class TrizRisAnnotationPersistenceBackend implements AnnotationPersistenceBackend {
|
||||
public async save(record: Record<string, any>): Promise<void> {
|
||||
console.log('### SAUVEGARDE ANNOTATION TRIZRIS ###');
|
||||
|
||||
console.log(record);
|
||||
|
||||
const response = await fetch(BASE_URL, {
|
||||
method: 'POST',
|
||||
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
|
||||
body: JSON.stringify(record),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur sauvegarde annotation : ${response.status}`);
|
||||
}
|
||||
|
||||
const resultat = await response.text();
|
||||
|
||||
console.log('Réponse TrizRis =', resultat);
|
||||
}
|
||||
|
||||
public async update(record: Record<string, any>): Promise<void> {
|
||||
console.log('### MODIFICATION ANNOTATION TRIZRIS ###');
|
||||
|
||||
console.log(record);
|
||||
|
||||
const response = await fetch(BASE_URL, {
|
||||
method: 'PUT',
|
||||
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
|
||||
body: JSON.stringify(record),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur modification annotation : ${response.status}`);
|
||||
}
|
||||
|
||||
const resultat = await response.text();
|
||||
|
||||
console.log('Réponse TrizRis =', resultat);
|
||||
}
|
||||
|
||||
public async delete(uid: string): Promise<void> {
|
||||
console.log('### SUPPRESSION ANNOTATION TRIZRIS ###');
|
||||
|
||||
console.log('UID =', uid);
|
||||
|
||||
const response = await fetch(`${BASE_URL}/${encodeURIComponent(uid)}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur suppression annotation : ${response.status}`);
|
||||
}
|
||||
|
||||
const resultat = await response.text();
|
||||
|
||||
console.log('Réponse TrizRis =', resultat);
|
||||
}
|
||||
|
||||
public async load(studyInstanceUID: string): Promise<any[]> {
|
||||
console.log('### CHARGEMENT ANNOTATIONS TRIZRIS ###');
|
||||
|
||||
console.log('StudyInstanceUID =', studyInstanceUID);
|
||||
|
||||
const response = await fetch(
|
||||
`${BASE_URL}?studyInstanceUID=${encodeURIComponent(studyInstanceUID)}`
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur chargement annotations : ${response.status}`);
|
||||
}
|
||||
|
||||
const records = await response.json();
|
||||
|
||||
console.log('Annotations reçues =', records);
|
||||
|
||||
return Array.isArray(records) ? records : [];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user