Skip to content

Commit

Permalink
fix: missing baseUrl in BulkDataURI
Browse files Browse the repository at this point in the history
# Problems
- Incorrect way to get tags have `BulkDataURI`
- `binaryTag` always undefined

# Solutions
- Use `json-path` instead original way
- Add `jsonpath-plus` package
  • Loading branch information
Chinlinlee committed Apr 2, 2023
1 parent b636f48 commit 07d4cad
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
36 changes: 13 additions & 23 deletions api/dicom-web/controller/WADO-RS/service/WADO-RS.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { raccoonConfig } = require("../../../../../config-class");
const {
rootPath: dicomStoreRootPath
} = raccoonConfig.dicomWebConfig;
const { JSONPath } = require("jsonpath-plus");


/**
Expand Down Expand Up @@ -80,30 +81,19 @@ function sendNotSupportedMediaType(res, type) {
}

function addHostnameOfBulkDataUrl(metadata, req) {
let flattenMetadata = flatten(metadata);
let objKeys = Object.keys(flattenMetadata);
let binaryTag = objKeys
.filter(
v => v.indexOf(".vr") > -1
)
.filter(
v => {
let value = _.get(flattenMetadata, v);
return (value.indexOf("OB") > -1) ||
(value.indexOf("OW") > -1);
}
)
.map(
v => v.substring(0 , v.lastIndexOf(".vr"))
);

let protocol = req.secure ? "https" : "http";
for (let i = 0 ; i < binaryTag.length; i++) {
let tag = binaryTag[i];
let relativeUrl = flattenMetadata[`${tag}.BulkDataURI`];
// Reset VR to UR, because BulkDataURI is URI
_.set(metadata, `${tag}.vr`, "UR");
_.set(metadata, `${tag}.BulkDataURI`, `${protocol}://${req.headers.host}${relativeUrl}`);

let urItems = JSONPath({
path: "$..BulkDataURI",
json: metadata,
resultType: "all"
});

for(let urItem of urItems) {
let bulkDataUriPath = JSONPath.toPathArray(urItem.path).join(".").substring(2);
let relativeUrl = _.get(metadata, bulkDataUriPath);

_.set(metadata, bulkDataUriPath, `${protocol}://${req.headers.host}${relativeUrl}`);
}
}

Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"imagemagick-cli": "^0.5.0",
"java-bridge": "^2.2.3",
"joi": "^17.6.0",
"jsonpath-plus": "^7.2.0",
"lodash": "^4.17.21",
"log4js": "^6.4.5",
"mkdirp": "^1.0.4",
Expand Down

0 comments on commit 07d4cad

Please sign in to comment.