Skip to content

Commit

Permalink
fix: cannot perform storeDest (split undefined)
Browse files Browse the repository at this point in the history
# Problems
- StudyTime maybe empty cause `startedDate`'s value is "1234undefined"
- that cannot convert to Date type

# Solutions
- Use only study date to get year and month,
because study time may be empty
- and we just need the year and month
  • Loading branch information
Chinlinlee committed Mar 25, 2023
1 parent 68f8929 commit 92161d5
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions api/dicom-web/stow/service/stow.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,20 @@ function detachBigValuesDicomJson(dicomJson) {
* @param {Object} dicomJson
*/
function getStoreDest(dicomJson) {
let startedDate = "";
startedDate =
dcm2jsonV8.dcmString(dicomJson, "00080020") +
dcm2jsonV8.dcmString(dicomJson, "00080030");
if (!startedDate) startedDate = Date.now();
startedDate = moment(startedDate, "YYYYMMDDhhmmss").toISOString();
let startedDateSplit = startedDate.split("-");
let year = startedDateSplit[0];
let month = startedDateSplit[1];
let uid = dcm2jsonV8.dcmString(dicomJson, "0020000E");
let shortUID = sh.unique(uid);
let relativeStorePath = `files/${year}/${month}/${shortUID}/`;
let studyDate = dcm2jsonV8.dcmString(dicomJson, "00080020");
let studyDateString;
if (!studyDate) {
studyDateString = moment().format("YYYY-MM-DD");
} else {
studyDateString = moment(studyDate, "YYYYMMDD").format("YYYY-MM-DD");
}
let studyDateSplit = studyDateString.split("-");
let year = studyDateSplit[0];
let month = studyDateSplit[1];
let seriesUID = dcm2jsonV8.dcmString(dicomJson, "0020000E");
let shortSeriesUID = sh.unique(seriesUID);

let relativeStorePath = `files/${year}/${month}/${shortSeriesUID}/`;
let fullStorePath = path.join(
process.env.DICOM_STORE_ROOTPATH,
relativeStorePath
Expand Down

0 comments on commit 92161d5

Please sign in to comment.