Skip to content

Commit

Permalink
feat: #11
Browse files Browse the repository at this point in the history
- remove example config because of we generating automatically now
- use `raccoon-dimse-app.json` in `.env.template`
  • Loading branch information
Chinlinlee committed Jun 17, 2023
1 parent 4b6de1a commit 7d2d9ed
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 34 additions & 2 deletions config-class.js
Original file line number Diff line number Diff line change
@@ -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)) {
Expand Down Expand Up @@ -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++) {
Expand Down Expand Up @@ -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} */
Expand Down
17 changes: 0 additions & 17 deletions config/raccoon-dimse-app.example.json

This file was deleted.

0 comments on commit 7d2d9ed

Please sign in to comment.