Skip to content

Commit

Permalink
feat: add getInstancePathsByQueryOpts in instance model
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Mar 1, 2024
1 parent 630a7ab commit ab04e91
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 20 additions & 1 deletion models/mongodb/models/instance.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const {
dicomJsonAttributeDASchema,
getVRSchema
} = require("../schema/dicomJsonAttribute");
const { getStoreDicomFullPath, IncludeFieldsFactory } = require("../service");
const { getStoreDicomFullPath, IncludeFieldsFactory, getStoreDicomFullPathGroup } = require("../service");
const { logger } = require("../../../utils/logs/log");
const { raccoonConfig } = require("@root/config-class");
const { dictionary } = require("@models/DICOM/dicom-tags-dic");
Expand Down Expand Up @@ -150,6 +150,25 @@ let dicomSchemaOptions = _.merge(
]
};
},
/**
*
* @type { import("@root/utils/typeDef/models/instance").InstanceModelConstructor["getInstanceFilesByQueryOpts"] }
*/
getInstancePathsByQueryOpts: async function (queryOptions) {
let docs = await mongoose.model("dicom").find({
...queryOptions.query,
deleteStatus: {
$eq: queryOptions.isRecycle ? 1 : 0
}
}, { instancePath: 1, studyUID: 1, seriesUID: 1, instanceUID: 1 })
.limit(queryOptions.limit)
.skip(queryOptions.skip)
.lean();

if (!docs) return [];

return await getStoreDicomFullPathGroup(docs);
},
/**
* @type { import("@root/utils/typeDef/models/instance").InstanceModelConstructor["getInstanceOfMedianIndex"] }
*/
Expand Down
2 changes: 2 additions & 0 deletions utils/typeDef/models/instance.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { DicomJsonQueryOptions } from "../dicom";
import type { ImagePathObj, InstanceFrameObj } from "../dicomImage";
import type { ImageModelConstructor, ImageModel } from "./imageModel";

Expand All @@ -21,6 +22,7 @@ export interface InstanceModelConstructor extends ImageModelConstructor {
public static getPathOfInstance(iParam: { studyUID: string, seriesUID: string, instanceUID: string }): Promise<ImagePathObj>;
public static getInstanceOfMedianIndex(query: { studyUID: string }): Promise<InstanceModel>;
public static getInstanceFrame(iParam: { studyUID: string, seriesUID: string, instanceUID: string }): Promise<InstanceFrameObj | undefined>;
public static getInstancePathsByQueryOpts(queryOptions: DicomJsonQueryOptions): Promise<ImagePathObj[]>
}

export interface InstanceModel extends ImageModel {
Expand Down

0 comments on commit ab04e91

Please sign in to comment.