dcmjs-dimse
dcmjs-dimse copied to clipboard
add elements tags type and eventMap
I tried to add the enumeration of listening events of Server class, Client class and Request class, and added the type definitions of all Dicom tags
Dicom Tags export
export interface Types {
T_DicomElements: Partial<DicomElements>;
T_DicomElements_WML: Partial<DicomElements_WML>;
}
Server class
declare class Server extends AsyncEventEmitter<ServerEventName.EventMap<ServerEventMap>> {
...
on(event: keyof ServerEventMap, listener: ServerEventName.EventMap<ServerEventMap>[keyof ServerEventMap]): this;
...
}
Client class
declare class Client extends AsyncEventEmitter<ServerEventName.EventMap<ClientEventMap>> {
/**
* Creates an instance of Client.
*/
constructor();
on(event: keyof ClientEventMap & string, listener: ServerEventName.EventMap<ClientEventMap>[keyof ClientEventMap]): this;
...
}
Reqeust class
declare class Request extends Mixin(Command, AsyncEventEmitter<ServerEventName.EventMap<RequestEventMap>>) {
/**
* Creates an instance of Request.
*/
constructor(type: number, affectedOrRequestedClassUid: string, hasDataset: boolean);
on<E extends keyof RequestEventMap>(event: E & string, listener: ServerEventName.EventMap<RequestEventMap>[E]): this;
...
evnetMap.dto.ts file
declare type ServerEventMap = {
networkError: 'networkError',
listening: 'listening',
cEchoRequest: 'cEchoRequest'
}
declare type RequestEventMap = {
response: 'response',
instance: 'instance',
done: 'done',
}
declare type ClientEventMap = {
connected: 'connected',
associationAccepted: 'associationAccepted',
associationReleased: 'associationReleased',
cStoreRequest: 'cStoreRequest',
nEventReportRequest: 'nEventReportRequest',
networkError: 'networkError',
close: 'close',
}
declare namespace ServerEventName {
type AsyncListener<T, R> = ((data: T, callback: (result?: R) => void) => Promise<R>) | ((data: T, callback: (result?: R) => void) => void);
type EventMap<T> = {
[event in keyof T]: AsyncListener<any, any>;
};
}
My code is poorly written. I'm looking forward to your suggestions for modification
Great work @CloudWoR!
As I commented in the https://github.com/PantelisGeorgiadis/dcmjs-dimse/pull/28, is there any way to extract the DicomElements
and DicomElements_WML
(which can be consolidated, they both contain DICOM tags) information from dcmjs's dictionary?