Skip to content

Commit

Permalink
refactor: the data of instances level is only stored in specified tags
Browse files Browse the repository at this point in the history
- Storing too many fields will cause longer insert time and unnecessary use of so many fields for actual searches.
  • Loading branch information
Chinlinlee committed Aug 26, 2024
1 parent 10f2df9 commit a450521
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion models/DICOM/dicom-json-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,55 @@ class DicomJsonModel {
* @param {import("@root/utils/typeDef/dicom").GeneralDicomJson} dicomJson
*/
async storeInstanceCollection(dicomJson) {
const INSTANCE_STORE_TAGS = {
"00080005": true,
"00080201": true,
"00020010": true,
"00080016": true,
"00080018": true,
"00080022": true,
"00080023": true,
"0008002A": true,
"00080033": true,
"00200013": true,
"0040A043": true,
"0040A073": true,
"0040A491": true,
"0040A493": true,
"0040A730": true,
"00080008": true,
"0040A032": true,
"00081115": true,
"00280008": true,
"00280010": true,
"00280011": true,
"00280100": true,
"0040A370": true,
"0040A375": true,
"0040A504": true,
"0040A525": true,
"00420010": true,
"00420012": true,
"00700080": true,
"00700081": true,
"00700082": true,
"00700083": true,
"00700084": true,
"00081190": true,
"00080054": true,
"00080056": true,
...tagsNeedStore.Patient,
...tagsNeedStore.Study,
...tagsNeedStore.Series
};

fsP.writeFile("item.json", JSON.stringify(Object.keys(INSTANCE_STORE_TAGS).sort()));

let sanitizedDicomJson = {};
for (let key in INSTANCE_STORE_TAGS) {
if (dicomJson[key]) sanitizedDicomJson[key] = dicomJson[key];
}

let query = {
$and: [
{
Expand All @@ -216,7 +265,7 @@ class DicomJsonModel {
]
};

await mongoose.model("dicom").findOneAndUpdate(query, dicomJson, {
await mongoose.model("dicom").findOneAndUpdate(query, sanitizedDicomJson, {
upsert: true,
new: true
});
Expand Down

0 comments on commit a450521

Please sign in to comment.