L_DicomGetEncapsulatedDocument

Summary

Retrieves an encapsulated document and corresponding DICOM elements from a DICOM data set.

Syntax

#include "ltdic.h"

L_LTDIC_API L_UINT16 EXT_FUNCTION L_DicomGetEncapsulatedDocument(hDS, pElement, bChild, pszFileDocument, pEncapsulatedDocument, pConceptNameCodeSequence)

Parameters

HDICOMDS hDS

A DICOM handle.

pDICOMELEMENT pElement

Pointer to a DICOMELEMENT structure that contains an item in the Data Set. The inserted item will be inserted as a neighbor to this item, or as a child, depending on the value of bChild.

L_BOOL bChild

Flag that indicates where to insert the item. Possible values are:

Value Meaning
TRUE The new item will be inserted as the last child of pElement.
FALSE The new item will be inserted as the last sibling of pElement.

L_TCHAR * pszFileDocument

Character string that contains the name of the file that will be encapsulated. This should either be a PDF or a CDA file.

pDICOMENCAPSULATEDDOCUMENT pEncapsulatedDocument

Pointer to a DICOMENCAPSULATEDDOCUMENT structure, which is filled with the encapsulated document module attributes. This member must NOT be NULL.

pDICOMCODESEQUENCEITEM pConceptNameCodeSequence

Pointer to a DICOMCODESEQUENCEITEM structure, which is filled with the Concept Name Code Sequence attributes. This member can be NULL.

Returns

Value Meaning
DICOM_SUCCESS The function was successful.
> 0 An error occurred. Refer to Return Codes.

Comments

The members of the DICOMENCAPSULATEDDOCUMENT structure and the DICOMCODESEQUENCEITEM structure together represent the set of attributes contained in the "Encapsulated Document Module Attributes". The Encapsulated Information Object Definition (IOD) describes either a

that has been encapsulated within a DICOM information object.

For more information, refer to Part 3 of the DICOM standard.

The DICOMENCAPSULATEDDOCUMENT structure corresponds to the Encapsulated Document Module Attributes described in part 3 of the DICOM specification. To retrieve the Concept Name Code Sequence element (0040,A043) pass a pointer to a pConceptNameCodeSequence item.

The pszFileDocument argument points to a file location that will contain the encapsulated document after it is extracted. If this file already exists, it will be over written.

Before calling this function:

  1. Initialize pEncapsulatedDocument->uStructSize to be sizeof(DICOMENCAPSULATEDDOCUMENT). After a successful function call, the fields of this structure will either point to the element values, or contain NULL. If a field contains NULL, this means that the corresponding element does not exist in the data set.

  2. If retrieving the Concept Name Code Sequence element, pConceptNameCodeSequence should be the address of a DICOMCODESEQUENCEITEM structure. Initialize pConceptNameCodeSequence->uStructSize to be sizeof(DICOMCODESEQUENCEITEM). After a successful function call, the fields of this structure will either point to the element values, or contain NULL. If a field contains NULL, this means that the corresponding element does not exist in the data set.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example extracts an encapsulated document and the corresponding DICOM tags from a DICOM data set.
The contents of the tags are displayed.

#ifndef MSG_BUFFER_SIZE 
#define MSG_BUFFER_SIZE 1000 
#endif 
 
#ifndef MSG_BUFFER_SMALL_SIZE 
#define MSG_BUFFER_SMALL_SIZE 100 
#endif 
 
L_TCHAR* DumpDate( pVALUEDATE p, L_TCHAR *pszMsg) 
{ 
   if (p && pszMsg) 
   { 
      wsprintf(pszMsg, TEXT("%.02d/%.02d/%.04d"), p->nMonth, p->nDay, p->nYear); 
   } 
   return pszMsg; 
} 
 
L_TCHAR* DumpTime(pVALUETIME p, L_TCHAR *pszMsg) 
{ 
   if (p && pszMsg) 
   { 
      wsprintf(pszMsg, TEXT("%.02d:%.02d:%.02d:%.06d"), p->nHours, p->nMinutes, p->nSeconds, p->nFractions); 
   } 
   return pszMsg; 
} 
 
L_TCHAR* DumpDateTime(pVALUEDATETIME p, L_TCHAR *pszMsg) 
{ 
   if (p && pszMsg) 
   { 
      wsprintf(pszMsg, TEXT("%.02d/%.02d/%.04d  %.02d:%.02d:%.02d:%.06d%+05d"), p->nMonth, p->nDay, p->nYear, p->nHours, p->nMinutes, p->nSeconds, p->nFractions, p->nOffset); 
   } 
   return pszMsg; 
} 
 
#define DUMPSTRING(p) (p ? p : TEXT("")) 
 
L_VOID DumpEncapsulatedDocumentTags(L_TCHAR *pszMsg,  DICOMENCAPSULATEDDOCUMENT &EncapsulatedDocument, DICOMCODESEQUENCEITEM &ConceptNameCodeSequence) 
{ 
   L_TCHAR szMsg1[MSG_BUFFER_SIZE] = {0}; 
   L_TCHAR szDate[MSG_BUFFER_SMALL_SIZE] = {0}; 
   L_TCHAR szTime[MSG_BUFFER_SMALL_SIZE] = {0}; 
   L_TCHAR szDateTime[MSG_BUFFER_SMALL_SIZE] = {0}; 
   L_TCHAR szDateTimeContextGroupVersion[MSG_BUFFER_SMALL_SIZE] = {0}; 
   L_TCHAR szContextGroupLocalVersion[MSG_BUFFER_SMALL_SIZE] = {0}; 
 
   wsprintf(szMsg1, TEXT("%s\n\nuType: %s\nInstanceNumber: %d\nContentDate: %s\nContentTime: %s\nAcquisitionDateTime: %s\nBurnedInAnnotation: %s\nDocumentTitle: %s\nVerificationFlag: %s\nHL7InstanceIdentifier: %s\nMIMETypeOfEncapsulatedDocument: %s\nListOfMIMETypes: %s\n\n"),  
      pszMsg, 
      EncapsulatedDocument.uType == ENCAPSULATED_DOCUMENT_PDF ? L"ENCAPSULATED_DOCUMENT_PDF" : L"ENCAPSULATED_DOCUMENT_CDA", 
      EncapsulatedDocument.nInstanceNumber, 
      DumpDate(EncapsulatedDocument.pContentDate, szDate), 
      DumpTime(EncapsulatedDocument.pContentTime, szTime), 
      DumpDateTime(EncapsulatedDocument.pAcquisitionDateTime, szDateTime), 
      DUMPSTRING(EncapsulatedDocument.pszBurnedInAnnotation), 
      DUMPSTRING(EncapsulatedDocument.pszDocumentTitle), 
      DUMPSTRING(EncapsulatedDocument.pszVerificationFlag), 
      DUMPSTRING(EncapsulatedDocument.pszHL7InstanceIdentifier), 
      DUMPSTRING(EncapsulatedDocument.pszMIMETypeOfEncapsulatedDocument), 
      DUMPSTRING(EncapsulatedDocument.pszListOfMIMETypes) 
      ); 
 
   // ConceptNameCodeSequence 
   L_TCHAR szMsg2[MSG_BUFFER_SIZE] = {0}; 
 
   wsprintf(szMsg2, TEXT("CodeValue: %s\nCodingSchemeDesignator: %s\nCodingSchemeVersion: %s\nCodeMeaning: %s\nContextIdentifier: %s\nMappingResource: %s\nContextGroupVersion: %s\nContextGroupLocalVersion: %s\nContextGroupExtensionCreatorUID: %s"), 
      DUMPSTRING(ConceptNameCodeSequence.pszCodeValue), 
      DUMPSTRING(ConceptNameCodeSequence.pszCodingSchemeDesignator), 
      DUMPSTRING(ConceptNameCodeSequence.pszCodingSchemeVersion), 
      DUMPSTRING(ConceptNameCodeSequence.pszCodeMeaning), 
      DUMPSTRING(ConceptNameCodeSequence.pszContextIdentifier), 
      DUMPSTRING(ConceptNameCodeSequence.pszMappingResource), 
      DumpDateTime(ConceptNameCodeSequence.pContextGroupVersion, szDateTimeContextGroupVersion), 
      DumpDateTime(ConceptNameCodeSequence.pContextGroupLocalVersion, szContextGroupLocalVersion), 
      DUMPSTRING(ConceptNameCodeSequence.pszContextGroupExtensionCreatorUID) 
      ); 
 
   _tcscat_s(szMsg1, MSG_BUFFER_SIZE, szMsg2); 
 
   MessageBox(NULL, szMsg1, TEXT(""), MB_OK); 
} 
 
 
L_INT DicomGetEncapsulatedDocumentExample(pDICOMELEMENT pElement, L_BOOL bChild, HDICOMDS hDS, L_TCHAR *pszFileDocument ) 
{ 
   DICOMENCAPSULATEDDOCUMENT EncapsulatedDocument = {0}; 
   EncapsulatedDocument.uStructSize = sizeof(DICOMENCAPSULATEDDOCUMENT); 
 
   DICOMCODESEQUENCEITEM ConceptNameCodeSequence = {0}; 
   ConceptNameCodeSequence.uStructSize = sizeof(DICOMCODESEQUENCEITEM); 
 
   L_UINT16 uRet = L_DicomGetEncapsulatedDocument(hDS, pElement, bChild, pszFileDocument, &EncapsulatedDocument, &ConceptNameCodeSequence); 
   if (uRet == DICOM_SUCCESS) 
   { 
      L_TCHAR szMsg[MSG_BUFFER_SMALL_SIZE] = {0}; 
      wsprintf(szMsg, TEXT("Encapsulated Document Extracted: %s"), pszFileDocument); 
      DumpEncapsulatedDocumentTags( szMsg, EncapsulatedDocument, ConceptNameCodeSequence); 
   } 
   return uRet; 
} 

Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.