Skip to content

Commit

Permalink
feat: add DT mongodb schema definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Aug 11, 2023
1 parent 8810a32 commit 9e82bff
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions models/mongodb/schema/dicomJsonAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,28 @@ let dicomJsonAttributeDASchema = {
}
};

let dicomJsonAttributeDTSchema = {
vr: {
type: String
},
Value: {
type: [Date],
default: void 0,
set: function(v) {
let length = _.get(v, "length");
if (length > 0) {
return v.map((date) => moment(date, "YYYYMMDDhhmmss.SSSSSSZZ").toDate());
}
},
get: function (v) {
let length = _.get(v, "length");
if (length > 0) {
return v.map((date) => moment(date).format("YYYYMMDDhhmmss.SSSSSSZZ"));
}
}
}
};

let dicomJsonAttributeISSchema = {
vr: {
type: String
Expand Down Expand Up @@ -110,6 +132,13 @@ const vrSchemaMap = {
getters: true
}
}),
"DT": new mongoose.Schema(dicomJsonAttributeDTSchema, {
_id: false,
id: false,
toObject: {
getters: true
}
}),
"PN": new mongoose.Schema(
{
...dicomJsonAttributeSchema,
Expand Down

0 comments on commit 9e82bff

Please sign in to comment.