diff --git a/.env.template b/.env.template index a39805b7..1daa7920 100644 --- a/.env.template +++ b/.env.template @@ -32,7 +32,7 @@ DCM4CHE_QRSCP_COMMAND=`[ "--filepath", "DICOM/{0020000D,hash}/{0020000E,hash}/{00080018,hash}.dcm", "--raccoon", - "{project}/config/raccoon-dimse-app.example.json" + "{project}/config/raccoon-dimse-app.json" ]` # FHIR diff --git a/config-class.js b/config-class.js index 9ac79535..32f14eee 100644 --- a/config-class.js +++ b/config-class.js @@ -1,5 +1,6 @@ const fs = require("fs"); const path = require("path"); +const { URL } = require("url"); let dotenvPath = path.join(__dirname, ".env"); if (!fs.existsSync(dotenvPath)) { @@ -53,14 +54,45 @@ class DicomWebConfig { } class DicomDimseConfig { - constructor() { + constructor(mongodbConfig, serverConfig, dicomWebConfig) { + /** @type { MongoDbConfig } */ + this.mongodbConfig = mongodbConfig; + /** @type { ServerConfig } */ + this.serverConfig = serverConfig; + /** @type { DicomWebConfig } */ + this.dicomWebConfig = dicomWebConfig; this.enableDimse = env.get("ENABLE_DIMSE").default("true").asBool(); if (this.enableDimse) { this.dcm4cheQrscpArgv = env.get("DCM4CHE_QRSCP_COMMAND").required().asJsonArray(); + this.generateDimseJsonConfig(); this.replacePathInArgv(); } } + + generateDimseJsonConfig() { + let stowUrlObj = new URL(`http://${this.serverConfig.host}`); + stowUrlObj.port = this.serverConfig.port; + stowUrlObj.pathname = "dicom-web/studies"; + + let dimseConfig = { + mongodb: { + hosts: this.mongodbConfig.hosts, + ports: this.mongodbConfig.ports, + username: this.mongodbConfig.user, + password: this.mongodbConfig.password, + authSource: this.mongodbConfig.authSource, + database: this.mongodbConfig.dbName + }, + raccoon: { + dicomStoreRoot: this.dicomWebConfig.storeRootPath, + raccoonUploadScriptPath: path.join(__dirname, "./local/dicom-uploader-stow.js"), + mode: "STOW", + stowUrl: stowUrlObj.href + } + }; + fs.writeFileSync(path.join(__dirname, "./config/raccoon-dimse-app.json"), JSON.stringify(dimseConfig)); + } replacePathInArgv() { for(let i = 0 ; i < this.dcm4cheQrscpArgv.length ; i++) { @@ -100,7 +132,7 @@ class RaccoonConfig { this.mongoDbConfig = new MongoDbConfig(); this.serverConfig = new ServerConfig(); this.dicomWebConfig = new DicomWebConfig(); - this.dicomDimseConfig = new DicomDimseConfig(); + this.dicomDimseConfig = new DicomDimseConfig(this.mongoDbConfig, this.serverConfig, this.dicomWebConfig); this.fhirConfig = new FhirConfig(); /** @type {string} */ diff --git a/config/raccoon-dimse-app.example.json b/config/raccoon-dimse-app.example.json deleted file mode 100644 index 94a0a949..00000000 --- a/config/raccoon-dimse-app.example.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "mongodb": { - "hosts": ["mongodb"], - "ports": [27017], - "username": "root", - "password": "root", - "authSource": "admin", - "database": "raccoon-dicom", - "debug": false - }, - "raccoon": { - "dicomStoreRoot": "/dicomFiles", - "raccoonUploadScriptPath": "/nodejs/raccoon/local/dicom-uploader-stow.js", - "mode": "STOW", - "stowUrl": "http://127.0.0.1:8081/dicom-web/studies" - } -} \ No newline at end of file