Skip to content

Commit

Permalink
fix: Add method to increment delete status for hierarchical image
Browse files Browse the repository at this point in the history
deletion

# Problems
- Series and instances under study are not delete
- Instances under series are not deleted

# Solutions
- Add methods to increment delete status for series and study models to
facilitate hierarchical image deletion. This ensures proper update of
delete status across related entities.
  • Loading branch information
Chinlinlee committed Jan 6, 2024
1 parent 1c8350e commit bb4616a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions models/mongodb/models/series.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ let dicomSeriesSchemaOptions = _.merge(
DicomSchemaOptionsFactory.get("series", SeriesDocDicomJsonHandler),
{
methods: {
incrementDeleteStatus: async function () {
await mongoose.model("dicom").updateMany({
seriesUID: this.seriesUID
}, {
$inc: {
deleteStatus: 1
}
});
this.deleteStatus += 1;
await this.save();
},
deleteDicomInstances: async function () {
let seriesPath = this.seriesPath;
logger.warn("Permanently delete series folder: " + seriesPath);
Expand Down
20 changes: 20 additions & 0 deletions models/mongodb/models/study.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ let dicomStudySchemaOptions = _.merge(
DicomSchemaOptionsFactory.get("study", StudyDocDicomJsonHandler),
{
methods: {
incrementDeleteStatus: async function() {
await Promise.all([
mongoose.model("dicomSeries").updateMany({
studyUID: this.studyUID
}, {
$inc : {
deleteStatus: 1
}
}),
mongoose.model("dicom").updateMany({
studyUID: this.studyUID
}, {
$inc: {
deleteStatus: 1
}
})
]);
this.deleteStatus += 1;
await this.save();
},
deleteDicomInstances: async function () {

let studyPath = this.studyPath;
Expand Down

0 comments on commit bb4616a

Please sign in to comment.