Skip to content

Commit

Permalink
feat: add mediaStorageUID, ID
Browse files Browse the repository at this point in the history
- Add `generateUidFromGuid` to generate mediaStorageUID
- NAME_SPACE is generate by uuidv5 with value `raccoon`
- Use `dbName` of mediaStorageID
  • Loading branch information
Chinlinlee committed Apr 10, 2023
1 parent 7a31d28 commit 7b77892
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions config-class.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
require("dotenv").config();
const { logger } = require("env-var");
const uuid = require("uuid");

const env = require("env-var").from(process.env, {}, logger);
const NAME_SPACE = "be81894e-49fc-50cf-8c11-5983da942dac";

function generateUidFromGuid(iGuid) {
let guidBytes = `0x${iGuid.replace(/-/g, "")}`; //add prefix 0 and remove `-`
let bigInteger = BigInt(guidBytes, 16); //As big integer are not still in all browser supported I use BigInteger **) packaged to parse the integer with base 16 from uuid string
return `2.25.${bigInteger.toString()}`; //Output the previus parsed integer as string by adding `2.25.` as prefix
}

class MongoDbConfig {
constructor() {
Expand Down Expand Up @@ -46,6 +55,14 @@ class RaccoonConfig {
this.serverConfig = new ServerConfig();
this.dicomWebConfig = new DicomWebConfig();
this.fhirConfig = new FhirConfig();

/** @type {string} */
this.mediaStorageUID = generateUidFromGuid(
uuid.v5(this.mongoDbConfig.dbName, NAME_SPACE)
);

/** @type {string} */
this.mediaStorageID = this.mongoDbConfig.dbName;
}
}

Expand Down

0 comments on commit 7b77892

Please sign in to comment.