-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1278960
commit 5415ece
Showing
13 changed files
with
643 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
const path = require("path"); | ||
const { Commands } = require("@dcm4che/net/Commands"); | ||
const { Status } = require("@dcm4che/net/Status"); | ||
const { DicomServiceError } = require("@error/dicom-service"); | ||
const { createStgCmtSCPInjectProxy } = require("../models/DICOM/dcm4che/wrapper/org/github/chinlinlee/dcm777/net/StgCmtSCPInject"); | ||
const { Attributes } = require("@dcm4che/data/Attributes"); | ||
const { Tag } = require("@dcm4che/data/Tag"); | ||
const { VR } = require("@dcm4che/data/VR"); | ||
const { raccoonConfig } = require("@root/config-class"); | ||
const { findOneInstanceFromKeysAttr } = require("./utils"); | ||
const fileExist = require("@root/utils/file/fileExist"); | ||
const { SimpleStgCmtSCP } = require("@chinlinlee/dcm777/net/SimpleStgCmtSCP"); | ||
const { SendStgCmtResult } = require("@chinlinlee/dcm777/dcmqrscp/SendStgCmtResult"); | ||
|
||
class JsStgCmtScp { | ||
constructor(dcmQrScp) { | ||
/** @type { import("./index").DcmQrScp } */ | ||
this.dcmQrScp = dcmQrScp; | ||
} | ||
|
||
get() { | ||
return new SimpleStgCmtSCP( | ||
this.getStgCmtInjectProxy() | ||
); | ||
} | ||
|
||
getStgCmtInjectProxy() { | ||
/** @type { import("../models/DICOM/dcm4che/wrapper/org/github/chinlinlee/dcm777/net/StgCmtSCPInject").StgCmtSCPInjectInterface } */ | ||
const stgCmtInjectProxyMethods = { | ||
onDimseRQ: async (as, pc, dimse, rq, actionInfo) => { | ||
let rsp = await Commands.mkNActionRSP(rq, Status.Success); | ||
let callingAet = await as.getCallingAET(); | ||
let calledAet = await as.getCalledAET(); | ||
|
||
let remoteConnection = this.dcmQrScp.getRemoteConnection(callingAet); | ||
if (!remoteConnection) | ||
throw new DicomServiceError(Status.ProcessingFailure, `Unknown Calling AET: ${callingAet}`); | ||
|
||
let eventInfo; | ||
try { | ||
eventInfo = await this.calculateStorageCommitmentResult(calledAet, actionInfo); | ||
} catch(e) { | ||
console.error(e); | ||
throw e; | ||
} | ||
|
||
try { | ||
await as.writeDimseRSP(pc, rsp, null); | ||
|
||
await this.dcmQrScp.device.execute( | ||
await SendStgCmtResult.newInstanceAsync( | ||
as, | ||
eventInfo, | ||
false, | ||
remoteConnection | ||
) | ||
); | ||
} catch(e) { | ||
console.error(`${await as.toString()} << N-ACTION-RSP failed: ${e}`); | ||
} | ||
} | ||
}; | ||
|
||
return createStgCmtSCPInjectProxy(stgCmtInjectProxyMethods, { | ||
keepAsDaemon: true | ||
}); | ||
} | ||
|
||
/** | ||
* | ||
* @param {string} calledAet | ||
* @param {Attributes} actionInfo | ||
* @returns { Promise<Attributes> } | ||
*/ | ||
async calculateStorageCommitmentResult(calledAet, actionInfo) { | ||
let requestReq = await actionInfo.getSequence(Tag.ReferencedSOPSequence); | ||
let size = await requestReq.size(); | ||
|
||
let eventInfo = await Attributes.newInstanceAsync(6); | ||
|
||
await eventInfo.setString(Tag.RetrieveAETitle, VR.AE, calledAet); | ||
await eventInfo.setString(Tag.StorageMediaFileSetID, VR.SH, raccoonConfig.mediaStorageID); | ||
await eventInfo.setString(Tag.StorageMediaFileSetUID, VR.SH, raccoonConfig.mediaStorageUID); | ||
await eventInfo.setString(Tag.TransactionUID, VR.UI, await actionInfo.getString(Tag.TransactionUID)); | ||
let successSeq = await eventInfo.newSequence(Tag.ReferencedSOPSequence, size); | ||
let failedSeq = await eventInfo.newSequence(Tag.FailedSOPSequence, size); | ||
|
||
let uidMap = {}; | ||
for (let i = 0; i < size; i++) { | ||
/** @type { Attributes } */ | ||
let item = await requestReq.get(i); | ||
uidMap[await item.getString(Tag.ReferencedSOPInstanceUID)] = await item.getString(Tag.ReferencedSOPClassUID); | ||
} | ||
|
||
for (let key in uidMap) { | ||
let classUid = uidMap[key]; | ||
let attr = await Attributes.newInstanceAsync(); | ||
await attr.setString(Tag.SOPInstanceUID, VR.UI, key); | ||
await attr.setString(Tag.SOPClassUID, VR.UI, classUid); | ||
|
||
let instance = await findOneInstanceFromKeysAttr(attr); | ||
if (instance) { | ||
let isExist = await fileExist( | ||
path.join( | ||
raccoonConfig.dicomWebConfig.storeRootPath, | ||
instance.instancePath | ||
) | ||
); | ||
if (isExist) { | ||
await successSeq.add( | ||
await JsStgCmtScp.refSOP(key, classUid, Status.Success) | ||
); | ||
} else { | ||
await failedSeq.add( | ||
await JsStgCmtScp.refSOP(key, classUid, Status.NoSuchObjectInstance) | ||
); | ||
} | ||
} else { | ||
await failedSeq.add( | ||
await JsStgCmtScp.refSOP(key, classUid, Status.NoSuchObjectInstance) | ||
); | ||
} | ||
} | ||
|
||
if (await failedSeq.isEmpty()) | ||
await eventInfo.remove(Tag.FailedSOPSequence); | ||
|
||
return eventInfo; | ||
} | ||
|
||
/** | ||
* @private | ||
* @param {string} instanceUid | ||
* @param {string} classUid | ||
* @param {number} failureReason | ||
* @returns { Promise<Attributes> } | ||
*/ | ||
static async refSOP(instanceUid, classUid, failureReason) { | ||
let attr = await Attributes.newInstanceAsync(3); | ||
await attr.setString(Tag.ReferencedSOPClassUID, VR.UI, classUid); | ||
await attr.setString(Tag.ReferencedSOPInstanceUID, VR.UI, instanceUid); | ||
if (failureReason !== Status.Success) { | ||
await attr.setInt(Tag.FailureReason, VR.US, failureReason); | ||
} | ||
return attr; | ||
} | ||
} | ||
|
||
module.exports.JsStgCmtScp = JsStgCmtScp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+3.72 KB
(120%)
models/DICOM/dcm4che/javaNode/dcm4chee/lib/qrscp/dcm777-5.29.2.jar
Binary file not shown.
132 changes: 132 additions & 0 deletions
132
models/DICOM/dcm4che/wrapper/org/github/chinlinlee/dcm777/dcmqrscp/SendStgCmtResult.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { JavaClass, BasicOrJavaType } from "java-bridge"; | ||
import { Long as java_lang_Long } from "./../../../../../java/lang/Long"; | ||
import { Integer as java_lang_Integer } from "./../../../../../java/lang/Integer"; | ||
import { Class as java_lang_Class } from "./../../../../../java/lang/Class"; | ||
import { Association as org_dcm4che3_net_Association } from "./../../../../dcm4che3/net/Association"; | ||
import { Attributes as org_dcm4che3_data_Attributes } from "./../../../../dcm4che3/data/Attributes"; | ||
import { Boolean as java_lang_Boolean } from "./../../../../../java/lang/Boolean"; | ||
import { Connection as org_dcm4che3_net_Connection } from "./../../../../dcm4che3/net/Connection"; | ||
/** | ||
* This class just defines types, you should import {@link SendStgCmtResult} instead of this. | ||
* This was generated by java-bridge. | ||
* You should probably not edit this. | ||
*/ | ||
export declare class SendStgCmtResultClass extends JavaClass { | ||
/** | ||
* @return original return type: 'void' | ||
*/ | ||
run(): Promise<void>; | ||
/** | ||
* @return original return type: 'void' | ||
*/ | ||
runSync(): void; | ||
/** | ||
* @param var0 original type: 'long' | ||
* @param var1 original type: 'int' | ||
* @return original return type: 'void' | ||
*/ | ||
wait(var0: java_lang_Long | bigint | number, var1: java_lang_Integer | number): Promise<void>; | ||
/** | ||
* @param var0 original type: 'long' | ||
* @param var1 original type: 'int' | ||
* @return original return type: 'void' | ||
*/ | ||
waitSync(var0: java_lang_Long | bigint | number, var1: java_lang_Integer | number): void; | ||
/** | ||
* @return original return type: 'void' | ||
*/ | ||
wait(): Promise<void>; | ||
/** | ||
* @return original return type: 'void' | ||
*/ | ||
waitSync(): void; | ||
/** | ||
* @param var0 original type: 'long' | ||
* @return original return type: 'void' | ||
*/ | ||
wait(var0: java_lang_Long | bigint | number): Promise<void>; | ||
/** | ||
* @param var0 original type: 'long' | ||
* @return original return type: 'void' | ||
*/ | ||
waitSync(var0: java_lang_Long | bigint | number): void; | ||
/** | ||
* @param var0 original type: 'java.lang.Object' | ||
* @return original return type: 'boolean' | ||
*/ | ||
equals(var0: BasicOrJavaType | null): Promise<boolean>; | ||
/** | ||
* @param var0 original type: 'java.lang.Object' | ||
* @return original return type: 'boolean' | ||
*/ | ||
equalsSync(var0: BasicOrJavaType | null): boolean; | ||
/** | ||
* @return original return type: 'java.lang.String' | ||
*/ | ||
toString(): Promise<string>; | ||
/** | ||
* @return original return type: 'java.lang.String' | ||
*/ | ||
toStringSync(): string; | ||
/** | ||
* @return original return type: 'int' | ||
*/ | ||
hashCode(): Promise<number>; | ||
/** | ||
* @return original return type: 'int' | ||
*/ | ||
hashCodeSync(): number; | ||
/** | ||
* @return original return type: 'java.lang.Class' | ||
*/ | ||
getClass(): Promise<java_lang_Class>; | ||
/** | ||
* @return original return type: 'java.lang.Class' | ||
*/ | ||
getClassSync(): java_lang_Class; | ||
/** | ||
* @return original return type: 'void' | ||
*/ | ||
notify(): Promise<void>; | ||
/** | ||
* @return original return type: 'void' | ||
*/ | ||
notifySync(): void; | ||
/** | ||
* @return original return type: 'void' | ||
*/ | ||
notifyAll(): Promise<void>; | ||
/** | ||
* @return original return type: 'void' | ||
*/ | ||
notifyAllSync(): void; | ||
/** | ||
* @param var0 original type: 'org.dcm4che3.net.Association' | ||
* @param var1 original type: 'org.dcm4che3.data.Attributes' | ||
* @param var2 original type: 'boolean' | ||
* @param var3 original type: 'org.dcm4che3.net.Connection' | ||
* @return original return type: 'org.github.chinlinlee.dcm777.dcmqrscp.SendStgCmtResult' | ||
*/ | ||
static newInstanceAsync(var0: org_dcm4che3_net_Association | null, var1: org_dcm4che3_data_Attributes | null, var2: java_lang_Boolean | boolean, var3: org_dcm4che3_net_Connection | null): Promise<SendStgCmtResult>; | ||
/** | ||
* @param var0 original type: 'org.dcm4che3.net.Association' | ||
* @param var1 original type: 'org.dcm4che3.data.Attributes' | ||
* @param var2 original type: 'boolean' | ||
* @param var3 original type: 'org.dcm4che3.net.Connection' | ||
*/ | ||
constructor(var0: org_dcm4che3_net_Association | null, var1: org_dcm4che3_data_Attributes | null, var2: java_lang_Boolean | boolean, var3: org_dcm4che3_net_Connection | null); | ||
} | ||
declare const SendStgCmtResult_base: typeof SendStgCmtResultClass; | ||
/** | ||
* Class org.github.chinlinlee.dcm777.dcmqrscp.SendStgCmtResult. | ||
* | ||
* This actually imports the java class for further use. | ||
* The class {@link SendStgCmtResultClass} only defines types, this is the class you should actually import. | ||
* Please note that this statement imports the underlying java class at runtime, which may take a while. | ||
* This was generated by java-bridge. | ||
* You should probably not edit this. | ||
*/ | ||
export declare class SendStgCmtResult extends SendStgCmtResult_base { | ||
} | ||
export default SendStgCmtResult; | ||
//# sourceMappingURL=SendStgCmtResult.d.ts.map |
1 change: 1 addition & 0 deletions
1
models/DICOM/dcm4che/wrapper/org/github/chinlinlee/dcm777/dcmqrscp/SendStgCmtResult.d.ts.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
models/DICOM/dcm4che/wrapper/org/github/chinlinlee/dcm777/dcmqrscp/SendStgCmtResult.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SendStgCmtResult = void 0; | ||
const java_bridge_1 = require("java-bridge"); | ||
/** | ||
* Class org.github.chinlinlee.dcm777.dcmqrscp.SendStgCmtResult. | ||
* | ||
* This actually imports the java class for further use. | ||
* The class {@link SendStgCmtResultClass} only defines types, this is the class you should actually import. | ||
* Please note that this statement imports the underlying java class at runtime, which may take a while. | ||
* This was generated by java-bridge. | ||
* You should probably not edit this. | ||
*/ | ||
class SendStgCmtResult extends (0, java_bridge_1.importClass)('org.github.chinlinlee.dcm777.dcmqrscp.SendStgCmtResult') { | ||
} | ||
exports.SendStgCmtResult = SendStgCmtResult; | ||
exports.default = SendStgCmtResult; |
Oops, something went wrong.