Skip to content

Commit

Permalink
feat: #15 audit message for C-MOVE
Browse files Browse the repository at this point in the history
  • Loading branch information
Chinlinlee committed Aug 28, 2023
1 parent 8323117 commit ca4e537
Show file tree
Hide file tree
Showing 207 changed files with 9,445 additions and 9,206 deletions.
29 changes: 28 additions & 1 deletion dimse/c-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ const { createCGetSCPInjectProxy } = require("@java-wrapper/org/github/chinlinle
const { SimpleCGetSCP } = require("@java-wrapper/org/github/chinlinlee/dcm777/net/SimpleCGetSCP");
const { PATIENT_ROOT_LEVELS, STUDY_ROOT_LEVELS, PATIENT_STUDY_ONLY_LEVELS } = require("./level");
const { getInstancesFromKeysAttr } = require("./utils");
const { RetrieveTaskImpl } = require("@dcm4che/tool/dcmqrscp/RetrieveTaskImpl");
const { RetrieveTaskImpl } = require("@chinlinlee/dcm777/dcmqrscp/RetrieveTaskImpl");
const { createRetrieveAuditInjectProxy } = require("@java-wrapper/org/github/chinlinlee/dcm777/dcmqrscp/RetrieveAuditInject");
const { Dimse } = require("@dcm4che/net/Dimse");
const { EnumSet } = require("@java-wrapper/java/util/EnumSet");
const { QueryRetrieveLevel2 } = require("@dcm4che/net/service/QueryRetrieveLevel2");
const { DimseRetrieveAuditService } = require("./service/retrieveAudit.service");

class JsCGetScp {
constructor() { }
Expand Down Expand Up @@ -99,6 +101,7 @@ class JsCGetScp {
instances,
as,
withoutBulkData,
await this.getAuditInject(as),
0
);
await retrieveTask.setSendPendingRSP(false);
Expand All @@ -109,6 +112,30 @@ class JsCGetScp {

return cGetScpInjectProxyMethods;
};

getAuditInject(association) {
let dimseRetrieveAuditService = new DimseRetrieveAuditService(
association,
null,
null
);

return createRetrieveAuditInjectProxy(
{
onBeginTransferringDICOMInstances: async (studyUIDs) => {
dimseRetrieveAuditService.studyUID = studyUIDs[0];
await dimseRetrieveAuditService.onBeginRetrieve();
},
onDicomInstancesTransferred: async (studyUIDs) => {
dimseRetrieveAuditService.studyUID = studyUIDs[0];
await dimseRetrieveAuditService.completedRetrieve();
},
setEventResult: (eventResult) => {
dimseRetrieveAuditService.eventResult = eventResult;
}
}
);
}
}

module.exports.JsCGetScp = JsCGetScp;
43 changes: 41 additions & 2 deletions dimse/c-move.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ const { UID } = require("@dcm4che/data/UID");
const { PATIENT_ROOT_LEVELS, STUDY_ROOT_LEVELS, PATIENT_STUDY_ONLY_LEVELS } = require("./level");
const { AAssociateRQ } = require("@dcm4che/net/pdu/AAssociateRQ");
const { Connection } = require("@dcm4che/net/Connection");
const { RetrieveTaskImpl } = require("@dcm4che/tool/dcmqrscp/RetrieveTaskImpl");
const { RetrieveTaskImpl } = require("@chinlinlee/dcm777/dcmqrscp/RetrieveTaskImpl");
const { Dimse } = require("@dcm4che/net/Dimse");
const { getInstancesFromKeysAttr } = require("./utils");
const { createRetrieveAuditInjectProxy } = require("@java-wrapper/org/github/chinlinlee/dcm777/dcmqrscp/RetrieveAuditInject");
const { DimseRetrieveAuditService } = require("./service/retrieveAudit.service");

class JsCMoveScp {

constructor(dcmQrScp) {
/** @type { import("./index").DcmQrScp } */
this.dcmQrScp = dcmQrScp;

}

getPatientRootLevel() {
Expand Down Expand Up @@ -72,6 +76,7 @@ class JsCMoveScp {
let moveDest = await rq.getString(Tag.MoveDestination);
const remote = this.dcmQrScp.getRemoteConnection(moveDest);
if (!remote) {

throw new DicomServiceError(Status.MoveDestinationUnknown, `Move Destination: ${moveDest} unknown`);
}

Expand All @@ -82,6 +87,8 @@ class JsCMoveScp {

let aAssociateRq = await this.makeAAssociateRQ_(await as.getLocalAET(), moveDest, instances);
let storeAssociation = await this.openStoreAssociation_(as, remote, aAssociateRq);

let auditInject = await this.getAuditInject(as);
let retrieveTask = await RetrieveTaskImpl.newInstanceAsync(
Dimse.C_MOVE_RQ,
as,
Expand All @@ -90,7 +97,8 @@ class JsCMoveScp {
instances,
storeAssociation,
false,
0
0,
auditInject
);
await retrieveTask.setSendPendingRSPInterval(0);
return retrieveTask;
Expand All @@ -104,6 +112,37 @@ class JsCMoveScp {
return cMoveScpInjectProxyMethods;
}

getAuditInject(association) {
let dimseRetrieveAuditService = new DimseRetrieveAuditService(
association,
null,
null
);
if (this.auditInject)
return this.auditInject;

this.auditInject = createRetrieveAuditInjectProxy(
{
onBeginTransferringDICOMInstances: async (studyUID) => {
dimseRetrieveAuditService.studyUID = studyUID;
await dimseRetrieveAuditService.onBeginRetrieve();
},
onDicomInstancesTransferred: async (studyUID) => {
dimseRetrieveAuditService.studyUID = studyUID;
await dimseRetrieveAuditService.completedRetrieve();
},
setEventResult: (eventResult) => {
dimseRetrieveAuditService.eventResult = eventResult;
}
},
{
keepAsDaemon: true
}
);

return this.auditInject;
}

/**
* @private
* @param {string} callingAet
Expand Down
39 changes: 39 additions & 0 deletions dimse/service/retrieveAudit.service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const { Association } = require("@dcm4che/net/Association");
const { AuditManager } = require("@models/DICOM/audit/auditManager");
const { EventType } = require("@models/DICOM/audit/eventType");
const auditMessageModel = require("@models/mongodb/models/auditMessage");

class DimseRetrieveAuditService {
constructor(association, studyUID, eventResult) {
/** @type { Association } */
this.association = association;
this.studyUID = studyUID;
this.eventResult = eventResult;
}

async onBeginRetrieve() {
let auditManager = new AuditManager(
auditMessageModel,
EventType.RETRIEVE_BEGIN,
this.eventResult,
await this.association.getRemoteAET(), await this.association.getRemoteHostName(),
await this.association.getLocalAET(), await this.association.getLocalAET()
);

await auditManager.onBeginTransferringDicomInstances([this.studyUID]);
}

async completedRetrieve() {
let auditManager = new AuditManager(
auditMessageModel,
EventType.RETRIEVE_END,
this.eventResult,
await this.association.getRemoteAET(), await this.association.getRemoteHostName(),
await this.association.getLocalAET(), await this.association.getLocalHostName()
);

await auditManager.onDicomInstancesTransferred([this.studyUID]);
}
}

module.exports.DimseRetrieveAuditService = DimseRetrieveAuditService;
Binary file not shown.
32 changes: 16 additions & 16 deletions models/DICOM/dcm4che/wrapper/java/io/IOException.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { JavaClass, BasicOrJavaType } from "java-bridge";
import { PrintStream as java_io_PrintStream } from "./PrintStream";
import { PrintWriter as java_io_PrintWriter } from "./PrintWriter";
import { Throwable as java_lang_Throwable } from "./../lang/Throwable";
import { PrintStream as java_io_PrintStream } from "./PrintStream";
import { StackTraceElement as java_lang_StackTraceElement } from "./../lang/StackTraceElement";
import { Throwable as java_lang_Throwable } from "./../lang/Throwable";
import { Long as java_lang_Long } from "./../lang/Long";
import { Integer as java_lang_Integer } from "./../lang/Integer";
import { Class as java_lang_Class } from "./../lang/Class";
Expand All @@ -20,6 +20,16 @@ export declare class IOExceptionClass extends JavaClass {
* @return original return type: 'void'
*/
printStackTraceSync(): void;
/**
* @param var0 original type: 'java.io.PrintWriter'
* @return original return type: 'void'
*/
printStackTrace(var0: java_io_PrintWriter | null): Promise<void>;
/**
* @param var0 original type: 'java.io.PrintWriter'
* @return original return type: 'void'
*/
printStackTraceSync(var0: java_io_PrintWriter | null): void;
/**
* @param var0 original type: 'java.io.PrintStream'
* @return original return type: 'void'
Expand All @@ -31,15 +41,13 @@ export declare class IOExceptionClass extends JavaClass {
*/
printStackTraceSync(var0: java_io_PrintStream | null): void;
/**
* @param var0 original type: 'java.io.PrintWriter'
* @return original return type: 'void'
* @return original return type: 'java.lang.StackTraceElement[]'
*/
printStackTrace(var0: java_io_PrintWriter | null): Promise<void>;
getStackTrace(): Promise<(java_lang_StackTraceElement | null)[] | null>;
/**
* @param var0 original type: 'java.io.PrintWriter'
* @return original return type: 'void'
* @return original return type: 'java.lang.StackTraceElement[]'
*/
printStackTraceSync(var0: java_io_PrintWriter | null): void;
getStackTraceSync(): (java_lang_StackTraceElement | null)[] | null;
/**
* @return original return type: 'java.lang.Throwable'
*/
Expand Down Expand Up @@ -98,14 +106,6 @@ export declare class IOExceptionClass extends JavaClass {
* @return original return type: 'java.lang.String'
*/
getLocalizedMessageSync(): string | null;
/**
* @return original return type: 'java.lang.StackTraceElement[]'
*/
getStackTrace(): Promise<(java_lang_StackTraceElement | null)[] | null>;
/**
* @return original return type: 'java.lang.StackTraceElement[]'
*/
getStackTraceSync(): (java_lang_StackTraceElement | null)[] | null;
/**
* @param var0 original type: 'java.lang.StackTraceElement[]'
* @return original return type: 'void'
Expand Down
2 changes: 1 addition & 1 deletion models/DICOM/dcm4che/wrapper/java/io/IOException.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions models/DICOM/dcm4che/wrapper/java/io/Reader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ import { Class as java_lang_Class } from "./../lang/Class";
* You should probably not edit this.
*/
export declare class ReaderClass extends JavaClass {
/**
* @return original return type: 'java.io.Reader'
*/
static nullReader(): Promise<Reader | null>;
/**
* @return original return type: 'java.io.Reader'
*/
static nullReaderSync(): Reader | null;
/**
* @return original return type: 'boolean'
*/
ready(): Promise<boolean>;
/**
* @return original return type: 'boolean'
*/
readySync(): boolean;
/**
* @param var0 original type: 'char[]'
* @return original return type: 'int'
Expand Down Expand Up @@ -106,22 +122,6 @@ export declare class ReaderClass extends JavaClass {
* @return original return type: 'void'
*/
resetSync(): void;
/**
* @return original return type: 'boolean'
*/
ready(): Promise<boolean>;
/**
* @return original return type: 'boolean'
*/
readySync(): boolean;
/**
* @return original return type: 'java.io.Reader'
*/
static nullReader(): Promise<Reader | null>;
/**
* @return original return type: 'java.io.Reader'
*/
static nullReaderSync(): Reader | null;
/**
* @param var0 original type: 'long'
* @param var1 original type: 'int'
Expand Down
Loading

0 comments on commit ca4e537

Please sign in to comment.