Skip to content

Commit

Permalink
feat: store {instanceUID}.dcm instead of incoming filename
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Mar 4, 2024
1 parent f3d4ecb commit 00f2925
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions api/dicom-web/controller/STOW-RS/service/dicom-file-saver.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class DicomFileSaver {
try {
let {
studyUID,
seriesUID
seriesUID,
instanceUID
} = this.dicomJsonModel.uidObj;
let shortStudyUID = shortHash(studyUID);
let shortSeriesUID = shortHash(seriesUID);
Expand All @@ -36,9 +37,9 @@ class DicomFileSaver {
let relativeStorePath = `files/${year}/${month}/${shortStudyUID}/${shortSeriesUID}/`;

let fullStorePath = this.getFullStorePath_(relativeStorePath);
let instanceStorePath = this.getInstanceStorePath_(fullStorePath);
let instanceStorePath = this.getInstanceStorePath_(fullStorePath, instanceUID);

await this.createDirectoryAndMoveUploadTempFile(fullStorePath);
await this.createDirectoryAndMoveUploadTempFile(fullStorePath, instanceStorePath);
logger.info(
`[STOW-RS] [Move uploaded temp DICOM file "${this.file.filepath}" to "${instanceStorePath}"`
);
Expand All @@ -62,14 +63,24 @@ class DicomFileSaver {
);
}

getInstanceStorePath_(fullStorePath) {
return path.join(fullStorePath, this.originalFilename);
/**
*
* @param {string} fullStorePath
* @param {string} instanceUID
* @returns
*/
getInstanceStorePath_(fullStorePath, instanceUID) {
return path.join(fullStorePath, `${instanceUID}.dcm`);
}

async createDirectoryAndMoveUploadTempFile(fullStorePath) {
/**
*
* @param {string} fullStorePath
* @param {string} instanceStorePath
*/
async createDirectoryAndMoveUploadTempFile(fullStorePath, instanceStorePath) {
mkdirp.sync(fullStorePath, "0755");

let instanceStorePath = this.getInstanceStorePath_(fullStorePath);
await moveFile(this.file.filepath, instanceStorePath, {
overwrite: true
});
Expand Down

0 comments on commit 00f2925

Please sign in to comment.