irc_dicom_service/app/model/series.js

70 lines
1.3 KiB
JavaScript

/**
* study信息
*/
module.exports = app => {
const mongoose = app.mongoose;
const Schema = mongoose.Schema;
const SeriesSchema = new Schema({
SeriesInstanceUID: {
type: String,
index: true
}, //SeriesInstanceUID 一个序列的唯一标识ID
StudyInstanceUID: {
type: String
},
Modality: {
type: String,
},
SeriesNumber: {
type: String,
},
PatientID: {
type: String,
},
userName: {
type: String,
},
userId: {
type: String,
},
status: {
type: String,
},
meta: {
createdAt: {
type: Date,
default: new Date()
},
updatedAt: {
type: Date,
default: new Date()
}
}
}, {
toObject: {
virtuals: true
},
toJSON: {
virtuals: true
}
});
// 定义虚拟属性是否锁了
SeriesSchema.virtual("imageNum").get(function () {
if (this.images_ids) {
return this.images_ids.length.toString();
}
});
SeriesSchema.pre("save", function (next) {
if (this.isNew) {
this.meta.createdAt = this.meta.updatedAt = new Date();
} else {
this.meta.updatedAt = new Date();
}
next();
});
return mongoose.model("Series", SeriesSchema);
};