Skip to content

Commit

Permalink
Handling associations with meta SOP classes
Browse files Browse the repository at this point in the history
  • Loading branch information
PantelisGeorgiadis committed Oct 13, 2024
1 parent 09ffc31 commit a98654b
Show file tree
Hide file tree
Showing 10 changed files with 292 additions and 156 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.7]
node-version: [14.x, 16.x, 18.x, 20.x]

steps:
- name: Checkout
Expand Down
52 changes: 45 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,12 @@ declare class Request extends Mixin(Command, AsyncEventEmitter) {
/**
* Creates an instance of Request.
*/
constructor(type: number, affectedOrRequestedClassUid: string, hasDataset: boolean);
constructor(
type: number,
affectedOrRequestedClassUid: string,
hasDataset: boolean,
metaSopClassUid?: string
);

/**
* Gets affected SOP class UID.
Expand All @@ -661,6 +666,16 @@ declare class Request extends Mixin(Command, AsyncEventEmitter) {
*/
setRequestedSopClassUid(requestedSopClassUid: string): void;

/**
* Gets meta SOP class UID.
*/
getMetaSopClassUid(): string | undefined;

/**
* Sets meta SOP class UID.
*/
setMetaSopClassUid(metaSopClassUid: string): void;

/**
* Gets affected SOP instance UID.
*/
Expand Down Expand Up @@ -1071,7 +1086,11 @@ declare class NCreateRequest extends Request {
/**
* Creates an instance of NCreateRequest.
*/
constructor(affectedSopClassUid: string, affectedSopInstanceUid: string);
constructor(
affectedSopClassUid: string,
affectedSopInstanceUid: string,
metaSopClassUid?: string
);
}

declare class NCreateResponse extends Response {
Expand All @@ -1095,7 +1114,12 @@ declare class NActionRequest extends Request {
/**
* Creates an instance of NActionRequest.
*/
constructor(requestedSopClassUid: string, requestedSopInstanceUid: string, actionTypeId: number);
constructor(
requestedSopClassUid: string,
requestedSopInstanceUid: string,
actionTypeId: number,
metaSopClassUid?: string
);

/**
* Gets action type ID.
Expand Down Expand Up @@ -1140,7 +1164,11 @@ declare class NDeleteRequest extends Request {
/**
* Creates an instance of NDeleteRequest.
*/
constructor(requestedSopClassUid: string, requestedSopInstanceUid: string);
constructor(
requestedSopClassUid: string,
requestedSopInstanceUid: string,
metaSopClassUid?: string
);
}

declare class NDeleteResponse extends Response {
Expand All @@ -1164,7 +1192,12 @@ declare class NEventReportRequest extends Request {
/**
* Creates an instance of NEventReportRequest.
*/
constructor(affectedSopClassUid: string, affectedSopInstanceUid: string, eventTypeID: number);
constructor(
affectedSopClassUid: string,
affectedSopInstanceUid: string,
eventTypeID: number,
metaSopClassUid?: string
);

/**
* Gets event type ID.
Expand Down Expand Up @@ -1212,7 +1245,8 @@ declare class NGetRequest extends Request {
constructor(
requestedSopClassUid: string,
requestedSopInstanceUid: string,
attributeIdentifierList: Array<string>
attributeIdentifierList: Array<string>,
metaSopClassUid?: string
);

/**
Expand Down Expand Up @@ -1247,7 +1281,11 @@ declare class NSetRequest extends Request {
/**
* Creates an instance of NSetRequest.
*/
constructor(requestedSopClassUid: string, requestedSopInstanceUid: string);
constructor(
requestedSopClassUid: string,
requestedSopInstanceUid: string,
metaSopClassUid?: string
);
}

declare class NSetResponse extends Response {
Expand Down
42 changes: 28 additions & 14 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,19 @@ expectType<number>(Implementation.getMaxPduLength());
expectError(Implementation.setMaxPduLength('1'));

// Request
expectError(new Request('1', 123, 'true'));
expectType<requests.Request>(new Request(1, '1.2.3.4.5', false));
expectError(new Request('1', 123, 'true', 1));
expectType<requests.Request>(new Request(1, '1.2.3.4.5', false, '5.4.3.2.1'));

const request = new Request(1, '1.2.3.4.5', false);
const request = new Request(1, '1.2.3.4.5', false, '5.4.3.2.1');
expectType<string>(request.getAffectedSopClassUid());
expectError(request.setAffectedSopClassUid(1));
expectType<void>(request.setAffectedSopClassUid('1.2.3.4'));
expectType<string>(request.getRequestedSopClassUid());
expectError(request.setRequestedSopClassUid(1));
expectType<void>(request.setRequestedSopClassUid('1.2.3.4'));
expectType<string | undefined>(request.getMetaSopClassUid());
expectError(request.setMetaSopClassUid(1));
expectType<void>(request.setRequestedSopClassUid('5.4.3.2.1'));
expectType<string>(request.getAffectedSopInstanceUid());
expectError(request.setAffectedSopInstanceUid(1));
expectType<void>(request.setAffectedSopInstanceUid('1.2.3.4'));
Expand Down Expand Up @@ -305,7 +308,10 @@ expectType<number>(getResponse.getFailures());
// NCreateRequest
expectError(new NCreateRequest(1));
expectError(new NCreateRequest('1', 2));
expectType<requests.NCreateRequest>(new NCreateRequest(SopClass.BasicFilmBox, '1.2.3.4.5'));
expectError(new NCreateRequest('1', 2, 3));
expectType<requests.NCreateRequest>(
new NCreateRequest(SopClass.BasicFilmBox, '1.2.3.4.5', '5.4.3.2.1')
);

// NCreateResponse
expectError(new NCreateResponse('1', 2, '3', 4));
Expand All @@ -315,13 +321,14 @@ expectType<responses.NCreateResponse>(

// NActionRequest
expectError(new NActionRequest(1));
expectError(new NActionRequest('1', 2, '3'));
expectError(new NActionRequest('1', 2, '3', 1));
expectType<requests.NActionRequest>(
new NActionRequest(SopClass.BasicFilmSession, '1.2.3.4.5', 0x01)
new NActionRequest(SopClass.BasicFilmSession, '1.2.3.4.5', 0x01, '5.4.3.2.1')
);

const actionRequest = new NActionRequest(SopClass.PrintJob, '1.2.3.4.5', 0x01);
expectType<number>(actionRequest.getActionTypeId());
expectType<string | undefined>(actionRequest.getMetaSopClassUid());
expectError(actionRequest.setActionTypeId('1'));

// NActionResponse
Expand All @@ -345,7 +352,10 @@ expectError(actionResponse.setActionTypeId('1'));
// NDeleteRequest
expectError(new NDeleteRequest(1));
expectError(new NDeleteRequest('1', 2));
expectType<requests.NDeleteRequest>(new NDeleteRequest(SopClass.BasicFilmSession, '1.2.3.4.5'));
expectError(new NDeleteRequest('1', 2, 3));
expectType<requests.NDeleteRequest>(
new NDeleteRequest(SopClass.BasicFilmSession, '1.2.3.4.5', '5.4.3.2.1')
);

// NDeleteResponse
expectError(new NDeleteResponse('1', 2, '3', 4));
Expand All @@ -356,8 +366,9 @@ expectType<responses.NDeleteResponse>(
// NEventReportRequest
expectError(new NEventReportRequest(1));
expectError(new NEventReportRequest('1', 2, '3'));
expectError(new NEventReportRequest('1', 2, '3', 4));
expectType<requests.NEventReportRequest>(
new NEventReportRequest(SopClass.PrintJob, '1.2.3.4.5', 0x01)
new NEventReportRequest(SopClass.PrintJob, '1.2.3.4.5', 0x01, '5.4.3.2.1')
);

const eventReportRequest = new NEventReportRequest(SopClass.PrintJob, '1.2.3.4.5', 0x01);
Expand Down Expand Up @@ -385,14 +396,14 @@ expectError(eventReportResponse.setEventTypeId('1'));
// NGetRequest
expectError(new NGetRequest(1));
expectError(new NGetRequest('1', 2));
expectError(new NGetRequest('1', 2, '3'));
expectError(new NGetRequest('1', 2, '3', 4));
expectType<requests.NGetRequest>(
new NGetRequest(SopClass.BasicGrayscaleImageBox, '1.2.3.4.5', ['PatientID'])
new NGetRequest(SopClass.BasicGrayscaleImageBox, '1.2.3.4.5', ['PatientID'], '5.4.3.2.1')
);

const cGetRequest = new NGetRequest(SopClass.BasicGrayscaleImageBox, '1.2.3.4.5', ['PatientID']);
expectType<Array<string>>(cGetRequest.getAttributeIdentifierList());
expectError(cGetRequest.setAttributeIdentifierList('1'));
const nGetRequest = new NGetRequest(SopClass.BasicGrayscaleImageBox, '1.2.3.4.5', ['PatientID']);
expectType<Array<string>>(nGetRequest.getAttributeIdentifierList());
expectError(nGetRequest.setAttributeIdentifierList('1'));

// NGetResponse
expectError(new NGetResponse('1', 2, '3', 4));
Expand All @@ -405,7 +416,10 @@ expectType<responses.NGetResponse>(
// NSetRequest
expectError(new NSetRequest(1));
expectError(new NSetRequest('1', 2));
expectType<requests.NSetRequest>(new NSetRequest(SopClass.BasicFilmSession, '1.2.3.4.5'));
expectError(new NSetRequest('1', 2, 3));
expectType<requests.NSetRequest>(
new NSetRequest(SopClass.BasicFilmSession, '1.2.3.4.5', undefined)
);

// NSetResponse
expectError(new NSetResponse('1', 2, '3', 4));
Expand Down
Loading

0 comments on commit a98654b

Please sign in to comment.