Skip to content

Commit

Permalink
feat: flexible QIDO-RS 00081190
Browse files Browse the repository at this point in the history
- User can modify `DICOMWEB_HOST` in `.env` to combine 00081190
- User can use `{host}` with DICOMWEB_HOST of env
  - {host} would replace headers.host
- Support proxy url like `{host}/raccoon`
  - Url will generate like "xxx.com/raccoon/apiPath/studies"
  • Loading branch information
Chinlinlee committed Mar 31, 2023
1 parent 46dfb42 commit 18988e5
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion api/dicom-web/controller/QIDO-RS/service/QIDO-RS.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const urlObj = require("url");
const mongoose = require("mongoose");
const _ = require("lodash");
const { mongoDateQuery } = require("../../../../../models/mongodb/service");
Expand Down Expand Up @@ -60,7 +61,7 @@ class QidoRsService {
query: this.query,
skip: this.skip_,
limit: this.limit_,
retrieveBaseUrl: `${this.protocol}://${this.request.headers.host}/${dicomWebApiPath}/studies`,
retrieveBaseUrl: `${this.getBasicURL()}/studies`,
requestParams: this.request.params
};

Expand All @@ -84,6 +85,24 @@ class QidoRsService {
}
}

getBasicURL() {

let hostname = raccoonConfig.dicomWebConfig.host;

if (raccoonConfig.dicomWebConfig.host.includes("{host}")) {
hostname = raccoonConfig.dicomWebConfig.host.replace("{host}", this.request.headers.host);
}

let hostnameSplit = _.compact(hostname.split("/"));
let realHostname = hostnameSplit.shift();
let pathname = [...hostnameSplit, ...dicomWebApiPath.split("/")].join("/");
let basicUrlObj = new urlObj.URL(`${this.protocol}://${realHostname}`);

basicUrlObj.pathname = pathname;

return basicUrlObj.href;
}

}

class QidoDicomJsonFactory {
Expand Down

0 comments on commit 18988e5

Please sign in to comment.