Skip to content

Commit

Permalink
feat: #15 dicom instances accessed for C-FIND
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Aug 29, 2023
1 parent 7bba8fb commit d479fe9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions dimse/instanceQueryTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class JsInstanceQueryTask extends JsSeriesQueryTask {
},
getInstance: async () => {
this.instance = await this.instanceCursor.next();
if (this.instance) this.auditDicomInstancesAccessed();
this.instanceAttr = this.instance ? await this.instance.getAttributes() : null;
},
findNextInstance: async () => {
Expand Down
1 change: 1 addition & 0 deletions dimse/seriesQueryTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class JsSeriesQueryTask extends JsStudyQueryTask {
},
getSeries: async () => {
this.series = await this.seriesCursor.next();
if (this.series) this.auditDicomInstancesAccessed();
this.seriesAttr = this.series ? await this.series.getAttributes() : null;
},
findNextSeries: async () => {
Expand Down
16 changes: 16 additions & 0 deletions dimse/studyQueryTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class JsStudyQueryTask extends JsPatientQueryTask {
},
getStudy: async () => {
this.study = await this.studyCursor.next();
this.auditDicomInstancesAccessed();
this.studyAttr = this.study ? await this.study.getAttributes() : null;
},
findNextStudy: async () => {
Expand Down Expand Up @@ -137,6 +138,21 @@ class JsStudyQueryTask extends JsPatientQueryTask {
...mongoQuery.$match
}, returnKeys);
}

async auditDicomInstancesAccessed() {
if (!this.study)
return;

let auditManager = new AuditManager(
auditMessageModel,
EventType.QUERY_ACCESSED_INSTANCE, EventOutcomeIndicator.Success,
await this.as.getRemoteAET(), await this.as.getRemoteHostName(),
await this.as.getLocalAET(), await this.as.getLocalHostName()
);

let studyUID = _.get(this.study, "0020000D.Value.0");
auditManager.onDicomInstancesAccessed([studyUID]);
}
}

module.exports.JsStudyQueryTask = JsStudyQueryTask;
11 changes: 4 additions & 7 deletions models/DICOM/audit/auditMessageFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,14 @@ class AuditMessageFactory {
* @param clientHostname 發送者的位址
* @param serverAETitle 伺服器端的AETitle
* @param serverHostname 伺服器端的位址
* @param StudyInstanceUIDs 所有此次傳輸有關聯的StudyInstanceUID
* @param SOPClassUIDs 所有此次傳輸有關聯的SOPClassUID
* @param PatientID 一個此次傳輸關聯的PatientID
* @param PatientName 一個此次傳輸關聯的PatientName
* @param studyInstanceUIDs 所有此次傳輸有關聯的StudyInstanceUID
* @return {Promise<JSON>}
*/
async getDicomInstancesAccessedMsg(
eventType, eventResult,
clientAETitle, clientHostname,
serverAETitle, serverHostname,
StudyInstanceUIDs
studyInstanceUIDs
) {
/**
Event
Expand All @@ -196,10 +193,10 @@ class AuditMessageFactory {
let theStudies = [];
// Participating Object: Patient (1); 存取的DICOM,其Patient。
let patientParticipatingObject;
for (let i = 0; i < StudyInstanceUIDs.length; i++) {
for (let i = 0; i < studyInstanceUIDs.length; i++) {
let participatingObjectFactory = new ParticipatingObjectFactory(
this.getInstanceModel(),
StudyInstanceUIDs[i]
studyInstanceUIDs[i]
);

let theStudy = await participatingObjectFactory.getStudyParticipatingObject();
Expand Down

0 comments on commit d479fe9

Please sign in to comment.