Migration from dcm4che2 to dcm4che3

旧街凉风 提交于 2019-12-03 15:48:24

As you have already observed, the BasicDicomObject is history -- alongside quite a few others.

The new "Dicom object" is Attributes -- an object is a collection of attributes.

Therefore, you create Attributes, populate them with the tags you need for RQ-behaviour (C-FIND, etc) and what you get in return is another Attributes object from which you pull the tags you want.

In my opinion, dcm4che 2.x was vague on the subject of dealing with individual value representations. dcm4che 3.x is quite a bit clearer.

The migration demands a rewrite of your code regarding how you query and how you treat individual tags. On the other hand, dcm4che 3.x makes the new code less convoluted.

A fairly complete example, retrieving studies from a PACS given accession numbers; setting up the query and handling the result:

    String modality = null;
    String accessionNumber = "1234567890";

    //--------------------------------------------------------
    // HERE follows setup of a query, using an Attributes object
    //--------------------------------------------------------
    Attributes query = new Attributes();

    // Indicate character set
    {
        int tag = Tag.SpecificCharacterSet;
        VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));
        query.setString(tag, vr, "ISO_IR 100");
    }

    // Study level query
    {
        int tag = Tag.QueryRetrieveLevel;
        VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));
        query.setString(tag, vr, "STUDY");
    }

    // Accession number
    {
        int tag = Tag.AccessionNumber;
        VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));
        query.setString(tag, vr, accessionNumber);
    }

    // Optionally filter on modality in study if 'modality' is provided,
    // otherwise retrieve modality
    {
        int tag = Tag.ModalitiesInStudy; 
        VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));
        if (null != modality && modality.length() > 0) {
            query.setString(tag, vr, modality);
         } else {
            query.setNull(tag, vr);
         }
    }

    // We are interested in study instance UID
    {
        int tag = Tag.StudyInstanceUID;
        VR vr = ElementDictionary.vrOf(tag, query.getPrivateCreator(tag));
        query.setNull(tag, vr);
    }

    // Do the actual query, needing an AppliationEntity (ae), 
    // a local (local) and remote (remote) Connection, and 
    // an AAssociateRQ (rq) set up earlier.

    // 1) Open a connection to the SCP
    Association as = ae.connect(local, remote, rq);

    // 2) Query
    int priority = 0x0002; // low for the sake of demo :)
    as.cfind(UID.StudyRootQueryRetrieveInformationModelFIND, query, null,
             new DimseRSPHandler(as.nextMessageID()) {

        @Override
        public void onDimseRSP(Association assoc, Attributes cmd,
                               Attributes response) {

            super.onDimseRSP(assoc, cmd, response);

            int status = cmd.getInt(Tag.Status, -1);
            if (Status.isPending(status)) {
                //--------------------------------------------------------
                // HERE follows handling of the response, which
                // is just another Attributes object
                //--------------------------------------------------------
                String studyInstanceUID = response.getString(Tag.StudyInstanceUID);
                // etc...
            }
        }
    });

    // 3) Close the connection to the SCP
    if (as != null && as.isReadyForDataTransfer()) {
        as.waitForOutstandingRSP();
        as.release();
        as = null;
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!