Project

General

Profile

Howto: Create a Mammography CAD SR Document

Here's an example that shows how to start from scratch:

Source Code

#include "dcmtk/config/osconfig.h" 
#include "dcmtk/dcmsr/dsrdoc.h" 
#include "dcmtk/dcmdata/dcfilefo.h" 

int main(int /*argc*/, char * /*argv*/ [])
{
  DSRDocument *doc = new DSRDocument();
  if (doc != NULL)
  {
    doc->createNewDocument(DSRTypes::DT_MammographyCadSR);

    doc->setPatientsName("Last Name^First Name");
    doc->setPatientsSex("O");
    doc->setManufacturer("OFFIS e.V.");
    doc->setReferringPhysiciansName("Last Name^First Name");

    doc->getTree().addContentItem(DSRTypes::RT_isRoot, DSRTypes::VT_Container);
    doc->getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue("111036", "DCM", "Mammography CAD Report"));
    doc->getTree().getCurrentContentItem().setTemplateIdentification("4000","DCMR"); 

    doc->getTree().addContentItem(DSRTypes::RT_hasConceptMod, DSRTypes::VT_Code, DSRTypes::AM_belowCurrent); 
    doc->getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue("121049", "DCM", "Language of Content Item and Descendants"));
    doc->getTree().getCurrentContentItem().setCodeValue(DSRCodedEntryValue("eng","ISO639_2","English"));

    doc->getTree().addContentItem(DSRTypes::RT_hasConceptMod, DSRTypes::VT_Code, DSRTypes::AM_belowCurrent); 
    doc->getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue("121046", "DCM", "Country of Language"));
    doc->getTree().getCurrentContentItem().setCodeValue(DSRCodedEntryValue("US","ISO3166_1","UNITED STATES"));

    doc->getTree().goUp();

    doc->getTree().addContentItem(DSRTypes::RT_contains, DSRTypes::VT_Container); 
    doc->getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue("111028", "DCM", "Image Library"));

    /* proceed with adding content items according to TID 4000 ... */

    DcmFileFormat *fileformat = new DcmFileFormat();
    DcmDataset *dataset = NULL;
    if (fileformat != NULL)
      dataset = fileformat->getDataset();
    if (dataset != NULL)
    {
      if (doc->write(*dataset).good())
        fileformat->saveFile("mamcadsr.dcm", EXS_LittleEndianExplicit);
    }
    delete fileformat;
  }
  delete doc;

  return 0; 
}

Dump

The resulting output (from dsrdump) looks like this:

Mammography CAD SR Document

Patient            : Last Name^First Name (O)
Referring Physician: Last Name^First Name
Manufacturer       : OFFIS e.V.
Completion Flag    : PARTIAL
Verification Flag  : UNVERIFIED
Content Date/Time  : 20080710 175805

<CONTAINER:(111036,DCM,"Mammography CAD Report")=SEPARATE>  # TID 4000 (DCMR)
  <has concept mod CODE:(121049,DCM,"Language of Content Item and Descendants")=(eng,ISO639_2,"English")>
    <has concept mod CODE:(121046,DCM,"Country of Language")=(US,ISO3166_1,"UNITED STATES")>
  <contains CONTAINER:(111028,DCM,"Image Library")=SEPARATE>
  ...