首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DCM4CHE,网络操作,处理C移动呼叫

DCM4CHE,网络操作,处理C移动呼叫
EN

Stack Overflow用户
提问于 2017-02-14 08:10:37
回答 1查看 756关注 0票数 2

嗨,我正在尝试用Java制作一个PACS服务器。dcm4che似乎相当受欢迎。但我找不到任何好的例子。

作为起点,我检查了dcmqrscp,它成功地存储了一个DICOM映像。但我处理不了C移动电话。这是我的CMove处理程序。它发现被请求的DICOM文件添加了一个URL和其他东西,它不会抛出任何异常,但是客户端没有收到任何文件。

代码语言:javascript
复制
private final class CMoveSCPImpl extends BasicCMoveSCP {

    private final String[] qrLevels;
    private final QueryRetrieveLevel rootLevel;

    public CMoveSCPImpl(String sopClass, String... qrLevels) {
        super(sopClass);
        this.qrLevels = qrLevels;
        this.rootLevel = QueryRetrieveLevel.valueOf(qrLevels[0]);
    }

    @Override
    protected RetrieveTask calculateMatches(Association as, PresentationContext pc, final Attributes rq, Attributes keys) throws DicomServiceException {
        QueryRetrieveLevel level = QueryRetrieveLevel.valueOf(keys, qrLevels);
        try {
            level.validateRetrieveKeys(keys, rootLevel, relational(as, rq));
        } catch (Exception e) {
            e.printStackTrace();
        }
        String moveDest = rq.getString(Tag.MoveDestination);
        final Connection remote = new Connection("reciverAE",as.getSocket().getInetAddress().getHostAddress(), 11113);
        if (remote == null)
            throw new DicomServiceException(Status.MoveDestinationUnknown, "Move Destination: " + moveDest + " unknown");
        List<T> matches = DcmQRSCP.this.calculateMatches(keys);
        if (matches.isEmpty())
            return null;
        AAssociateRQ aarq;
        Association storeas = null;
        try {
            aarq = makeAAssociateRQ(as.getLocalAET(), moveDest, matches);
            storeas = openStoreAssociation(as, remote, aarq);
        } catch (Exception e) {
            e.printStackTrace();
        }
        BasicRetrieveTask<T> retrieveTask = null;
        retrieveTask = new BasicRetrieveTask<T>(Dimse.C_MOVE_RQ, as, pc, rq, matches, storeas, new BasicCStoreSCU<T>());
        retrieveTask.setSendPendingRSPInterval(getSendPendingCMoveInterval());

        return retrieveTask;
    }

    private Association openStoreAssociation(Association as, Connection remote, AAssociateRQ aarq)
            throws DicomServiceException {
        try {
            return as.getApplicationEntity().connect(as.getConnection(),
                    remote, aarq);
        } catch (Exception e) {
            throw new DicomServiceException(
                    Status.UnableToPerformSubOperations, e);
        }
    }

    private AAssociateRQ makeAAssociateRQ(String callingAET,
                                          String calledAET, List<T> matches) {
        AAssociateRQ aarq = new AAssociateRQ();
        aarq.setCalledAET(calledAET);
        aarq.setCallingAET(callingAET);
        for (InstanceLocator match : matches) {
            if (aarq.addPresentationContextFor(match.cuid, match.tsuid)) {
                if (!UID.ExplicitVRLittleEndian.equals(match.tsuid))
                    aarq.addPresentationContextFor(match.cuid,
                            UID.ExplicitVRLittleEndian);
                if (!UID.ImplicitVRLittleEndian.equals(match.tsuid))
                    aarq.addPresentationContextFor(match.cuid,
                            UID.ImplicitVRLittleEndian);
            }
        }
        return aarq;
    }

    private boolean relational(Association as, Attributes rq) {
        String cuid = rq.getString(Tag.AffectedSOPClassUID);
        ExtendedNegotiation extNeg = as.getAAssociateAC().getExtNegotiationFor(cuid);
        return QueryOption.toOptions(extNeg).contains(
                QueryOption.RELATIONAL);
    }
}

我添加了下面的代码来发送DICOM文件作为响应:

代码语言:javascript
复制
String cuid = rq.getString(Tag.AffectedSOPClassUID);
String iuid = rq.getString(Tag.AffectedSOPInstanceUID);
String tsuid = pc.getTransferSyntax();

try {
    DcmQRSCP.this.as=as;
    File f = new File("D:\\dcmqrscpTestDCMDir\\1.2.840.113619.2.30.1.1762295590.1623.978668949.886\\1.2.840.113619.2.30.1.1762295590.1623.978668949.887\\1.2.840.113619.2.30.1.1762295590.1623.978668949.888");
    FileInputStream in = new FileInputStream(f);
    InputStreamDataWriter data = new InputStreamDataWriter(in);
    // !1! as.cmove(cuid,1,keys,tsuid,"STORESCU");
    as.cstore(cuid,iuid,1,data,tsuid,rspHandlerFactory.createDimseRSPHandler(f));
} catch (Exception e) {
    e.printStackTrace();
}

抛出此异常

org.dcm4che3.net.NoRoleSelectionException: SOP类别1.2.840.10008.5.1.4.1.2.2.2 -研究根查询/检索信息模型-按SCU协议移动

EN

回答 1

Stack Overflow用户

发布于 2021-04-28 12:47:59

您应该向应用程序实例添加一个角色,如下所示:

代码语言:javascript
复制
applicationEntity.addTransferCapability(
     new TransferCapability(null, "*", TransferCapability.Role.SCP, "*"));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42220875

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档