* feat: 🎸 DICOM SR STOW on MeasurementAPI Closes: #758 * feat: 🎸 Adding the dataExchance from DICOM SR * feat: 🎸 Fix some issues and get the retrieve measurements working * feat: 🎸 Preventing measurement tool helpers to broke because the data is not Number (it comes as string from dcmjs) * feat: 🎸 Adding a button to start testing SATE functionality * feat: 🎸Small fixes into the code * feat: 🎸 MAke sure we get latest SR in the study, even on lazyLoad mode * Revert "feat: 🎸 Preventing measurement tool helpers to broke because the data is not Number (it comes as string from dcmjs)" This reverts commit 4b3a1efb5810487d2319826fd59c03d779882b5e. * feat: 🎸 Make sure after sync we update the viewports and also that annotation tools are set to passive, so it can be drawn in the viewports * feat: 🎸 Remove console logs and start using OHIF.log * feat: 🎸 Refactor measurement table to use Snackbar service of messages and make sure we only show save button if server type is dicomWeb * feat: 🎸 Refactor to remove mocked wadoRoot and use server * Fix to expose error once we can't save the SR * Update DCMJS into latest dev version * Update dcmjs with latest fixes * Fix PR callouts * Logging error on MeasurementReport creation * Preventing from breaking on non supported tools and also warning that some toolType is not sopported * Small error message update * Expose better the errors and when we have unsopported tools into the measurements * Renaming variable * Expose dcmjs tool support check * Change the way we warn the unsupportedTools * Adding style to the button * Small change on button style * Fix git conflicts * Fix after merge with latest master * Fix after merge with master, btn was not clickable * Fixing callouts * Adding util functions into files and refactor with JSDocs * Refactoring code, adding some basic JSDocs * Bump dcmjs with latest version and fixes * JSDocs and small refactors * yarn lock file after dcmjs update * Remove unused parameters * Registering a plain copy of server into measurementAPI * Small refactor * Start changing from toolType to toolName * Rename a function to get instanceMetadata * Adding error if server is not DICOMWeb on retrieve * Move snackbar outside of UI component and use UINotificationService * Refactor and JSDocs * Small fixes on JSDocs (style) * Remove unused import * Improve JSDocs on MeasurementApi * Remove refactor leftover * Improve JSDocs and propTypes * JSDocs and small refactors
85 lines
2.7 KiB
JavaScript
85 lines
2.7 KiB
JavaScript
import * as dcmjs from 'dcmjs';
|
|
import { DICOMWeb } from '@ohif/core';
|
|
import parseDicomStructuredReport from './parseDicomStructuredReport';
|
|
import parseMeasurementsData from './parseMeasurementsData';
|
|
import getAllDisplaySets from './utils/getAllDisplaySets';
|
|
|
|
import { api } from 'dicomweb-client';
|
|
|
|
const VERSION_NAME = 'dcmjs-0.0';
|
|
const TRANSFER_SYNTAX_UID = '1.2.840.10008.1.2.1';
|
|
|
|
/**
|
|
* Function to retrieve measurements from DICOM Structured Reports coming from determined server
|
|
*
|
|
* @param {Array} series - List of all series metaData loaded
|
|
* @param {Array} studies - List of all studies metaData loaded
|
|
* @param {string} serverUrl - Server URL to be used on request
|
|
* @returns {Object} MeasurementData
|
|
*/
|
|
const retrieveMeasurementFromSR = async (series, studies, serverUrl) => {
|
|
const config = {
|
|
url: serverUrl,
|
|
headers: DICOMWeb.getAuthorizationHeader(),
|
|
};
|
|
|
|
const dicomWeb = new api.DICOMwebClient(config);
|
|
|
|
const instance = series.getFirstInstance();
|
|
const options = {
|
|
studyInstanceUID: instance.getStudyInstanceUID(),
|
|
seriesInstanceUID: instance.getSeriesInstanceUID(),
|
|
sopInstanceUID: instance.getSOPInstanceUID(),
|
|
};
|
|
|
|
const part10SRArrayBuffer = await dicomWeb.retrieveInstance(options);
|
|
const displaySets = getAllDisplaySets(studies);
|
|
const measurementsData = parseDicomStructuredReport(part10SRArrayBuffer, displaySets);
|
|
|
|
return measurementsData;
|
|
};
|
|
|
|
/**
|
|
* Function to store measurements to DICOM Structured Reports in determined server
|
|
*
|
|
* @param {Object} measurements - OHIF measurementData object
|
|
* @param {string} serverUrl - Server URL to be used on request
|
|
* @returns {Promise}
|
|
*/
|
|
const stowSRFromMeasurements = async (measurements, serverUrl) => {
|
|
const { dataset } = parseMeasurementsData(
|
|
measurements
|
|
);
|
|
const { DicomMetaDictionary, DicomDict } = dcmjs.data;
|
|
const meta = {
|
|
FileMetaInformationVersion:
|
|
dataset._meta.FileMetaInformationVersion.Value,
|
|
MediaStorageSOPClassUID: dataset.SOPClassUID,
|
|
MediaStorageSOPInstanceUID: dataset.SOPInstanceUID,
|
|
TransferSyntaxUID: TRANSFER_SYNTAX_UID,
|
|
ImplementationClassUID: DicomMetaDictionary.uid(),
|
|
ImplementationVersionName: VERSION_NAME,
|
|
};
|
|
|
|
const denaturalized = DicomMetaDictionary.denaturalizeDataset(meta);
|
|
const dicomDict = new DicomDict(denaturalized);
|
|
|
|
dicomDict.dict = DicomMetaDictionary.denaturalizeDataset(dataset);
|
|
|
|
const part10Buffer = dicomDict.write();
|
|
|
|
const config = {
|
|
url: serverUrl,
|
|
headers: DICOMWeb.getAuthorizationHeader(),
|
|
};
|
|
|
|
const dicomWeb = new api.DICOMwebClient(config);
|
|
const options = {
|
|
datasets: [part10Buffer],
|
|
};
|
|
|
|
await dicomWeb.storeInstances(options);
|
|
};
|
|
|
|
export { retrieveMeasurementFromSR, stowSRFromMeasurements };
|