Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(data, id) {
super();
this._id = id;
this._arrayBuffer = data.buffer;
let byteArray = new Uint8Array(this._arrayBuffer);
// catch error
// throw error if any!
this._dataSet = null;
try {
this._dataSet = DicomParser.parseDicom(byteArray);
} catch (e) {
console.log(e);
const error = new Error('parsers.dicom could not parse the file');
throw error;
}
}
const parseFile = async (file) => {
// Read
const arrayBuffer = await PromiseFileReader.readAsArrayBuffer(file)
// Parse
const byteArray = new Uint8Array(arrayBuffer)
const dicomMetaData = dicomParser.parseDicom(byteArray)
// Add to patientDict
const tag = DICOMPatient.primaryTag
const patientId = dicomMetaData.string(DICOM_DICTIONARY[tag])
var patient = patientDict[patientId]
if (patient === undefined) {
patient = new DICOMPatient()
patientDict[patientId] = patient
}
patient.parseMetaData(dicomMetaData, file)
}
parseByteArray = byteArray => {
const options = {
untilTag: '',
};
let dataSet;
try {
dataSet = dicomParser.parseDicom(byteArray, options);
} catch (error) {
this.setState({
error,
});
}
return dataSet;
};