Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS DICOM C++ Class Library Help

LDicomDS::GetDateRangeValue

Show in webframe

#include "Ltdic.h"

L_INT LDicomDS::GetDateRangeValue(pElement, nIndex, pValue)

pDICOMELEMENT pElement;

/* pointer to a DICOMELEMENT structure */

L_UINT32 nIndex;

/* index used when multiple values are stored */

pVALUEDATERANGE pValue;

/* pointer to a VALUEDATERANGE structure */

Fills the VALUEDATERANGE structure, with the date range information stored in the Value Field of the specified element.

Parameter

Description

pElement

Pointer to a DICOMELEMENT structure within the Data Set.

nIndex

Index value that indicates which value to retrieve when more than one value is stored in the Value Field. The index is zero-based.

pValue

Pointer to a VALUEDATERANGE structure that will be filled with the date range value.

Returns

0

SUCCESS

>0

An error occurred. Refer to Return Codes.

Comments

This function can be called only if the Value Representation of the Data Element is VR_DA. For more information about Value Representations, refer to Default Value Representation Table.

Required DLLs and Libraries

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

Platforms

Win32, x64

See Also

Functions:

LDicomDS::SetDateRangeValue, LDicomDS::GetDateValue, LDicomDS::SetDateValue

Topics:

Working with Data Sets

 

How to Disable the Automatic Loading of the default DICOM IOD Table

Example

This example gets the range value for an element.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_VOID ShowRangeValue(LDicomDS *pDS, pDICOMELEMENT pElement)
{
   L_INT32              i;
   L_INT32              nCount;
   L_TCHAR              szText[256];
   VALUEDATERANGE       DateRange;
   VALUETIMERANGE       TimeRange;
   VALUEDATETIMERANGE   DateTimeRange;
   L_INT                nRet;
   nCount = pDS->GetCountValue(pElement);
   if (((pElement->nLength == ELEMENT_LENGTH_MAX)) || 
      (pElement->nLength > 1024) || 
      (nCount == 0))
   {
      return;
   }
   switch (pElement->nVR)
   {
   case VR_DA:    // Date Range
      for (i = 0; i < nCount; i++)
      {
         nRet = pDS->GetDateRangeValue(pElement, i, &DateRange);
         if(nRet == DICOM_SUCCESS)
         {
            wsprintf(szText, TEXT("Type: %ld - Date1: %02u%02u%u - Date2: %02u%02u%u"),
                     DateRange.nFlags,
                     DateRange.Date1.nMonth, DateRange.Date1.nDay, DateRange.Date1.nYear,
                     DateRange.Date2.nMonth, DateRange.Date2.nDay, DateRange.Date2.nYear);
            AfxMessageBox(szText);
         }
      }
      break;
   case VR_TM:    // Time Range
      for (i = 0; i < nCount; i++)
      {
         nRet = pDS->GetTimeRangeValue(pElement, i, &TimeRange);
         if(nRet == DICOM_SUCCESS)
         {
            wsprintf(szText, TEXT("Type: %ld - Time1: %02u:%02u:%u.%lu - Time2: %02u:%02u:%u.%lu"),
                     TimeRange.nFlags,
                     TimeRange.Time1.nHours, TimeRange.Time1.nMinutes, TimeRange.Time1.nSeconds, TimeRange.Time1.nFractions,
                     TimeRange.Time2.nHours, TimeRange.Time2.nMinutes, TimeRange.Time2.nSeconds, TimeRange.Time2.nFractions);
            AfxMessageBox(szText);
         }
      }
      break;
   case VR_DT:    // Date Time
      for (i = 0; i < nCount; i++)
      {
         nRet = pDS->GetDateTimeRangeValue(pElement, i, &DateTimeRange);
         if(nRet == DICOM_SUCCESS)
         {
            wsprintf(szText, TEXT("Type: %ld - DateTime1: %02u%02u%u  %02u:%02u:%u.%lu&%lu - DateTime2: %02u%02u%u  %02u:%02u:%u.%lu&%lu"), 
                     DateTimeRange.nFlags,
            DateTimeRange.DateTime1.nMonth, DateTimeRange.DateTime1.nDay, DateTimeRange.DateTime1.nYear,
            DateTimeRange.DateTime1.nHours, DateTimeRange.DateTime1.nMinutes, DateTimeRange.DateTime1.nSeconds, DateTimeRange.DateTime1.nFractions, DateTimeRange.DateTime1.nOffset,
            DateTimeRange.DateTime2.nMonth, DateTimeRange.DateTime2.nDay, DateTimeRange.DateTime2.nYear,
            DateTimeRange.DateTime2.nHours, DateTimeRange.DateTime2.nMinutes, DateTimeRange.DateTime2.nSeconds, DateTimeRange.DateTime2.nFractions, DateTimeRange.DateTime2.nOffset);
            AfxMessageBox(szText);
         }
      }
      break;
   default:
      wsprintf(szText, TEXT("Element is not a range value element!"));
      AfxMessageBox(szText);
      break;
   }
   pDS->FreeValue(pElement);
}
L_INT LDicomDS_GetDateRangeValueExample()
{
   L_INT          nRet;
   LDicomDS      *pDS;
   pDICOMELEMENT  pElement;
   pDS = new LDicomDS(NULL);
   nRet = pDS->LoadDS(MAKE_IMAGE_PATH(TEXT("image1.dcm")), 0);
   if(nRet != DICOM_SUCCESS)
      return nRet;
   pElement = pDS->FindFirstElement(NULL, TAG_STUDY_DATE, FALSE);
   pDS->DeleteElement(pElement);
   pElement = pDS->FindFirstElement(NULL, TAG_STUDY_TIME, FALSE);
   pDS->DeleteElement(pElement);
   pElement = pDS->FindFirstElement(NULL, TAG_CONTRIBUTION_DATETIME, FALSE);
   pDS->DeleteElement(pElement);
   pElement = pDS->InsertElement(NULL, FALSE, TAG_STUDY_DATE, VR_DA, FALSE, 0); 
   VALUEDATERANGE DateRange;
   DateRange.nFlags = VALUE_RANGE_BOTH;
   DateRange.Date1.nDay = 1;
   DateRange.Date1.nMonth = 2;
   DateRange.Date1.nYear = 2005;
   DateRange.Date2.nDay = 10;
   DateRange.Date2.nMonth = 25;
   DateRange.Date2.nYear = 2005;
   pDS->SetDateRangeValue(pElement, &DateRange, 1); 
   ShowRangeValue(pDS, pElement);
   pElement = pDS->InsertElement(NULL, FALSE, TAG_STUDY_TIME, VR_TM, FALSE, 0); 
   VALUETIMERANGE TimeRange;
   TimeRange.nFlags = VALUE_RANGE_BOTH;
   TimeRange.Time1.nHours = 12;
   TimeRange.Time1.nMinutes = 0;
   TimeRange.Time1.nSeconds = 0;
   TimeRange.Time1.nFractions = 0;
   TimeRange.Time2.nHours = 24;
   TimeRange.Time2.nMinutes = 30;
   TimeRange.Time2.nSeconds = 0;
   TimeRange.Time2.nFractions = 0;
   pDS->SetTimeRangeValue(pElement, &TimeRange, 1); 
   ShowRangeValue(pDS, pElement);
   pElement = pDS->InsertElement(NULL, FALSE, TAG_CONTRIBUTION_DATETIME, VR_DT, FALSE, 0); 
   VALUEDATETIMERANGE DateTimeRange;
   DateTimeRange.nFlags = VALUE_RANGE_BOTH;
   DateTimeRange.DateTime1.nDay = 1;
   DateTimeRange.DateTime1.nMonth = 2;
   DateTimeRange.DateTime1.nYear = 2005;
   DateTimeRange.DateTime1.nHours = 12;
   DateTimeRange.DateTime1.nMinutes = 0;
   DateTimeRange.DateTime1.nSeconds = 0;
   DateTimeRange.DateTime1.nFractions = 0;
   DateTimeRange.DateTime1.nOffset = 0;
   DateTimeRange.DateTime2.nDay = 25;
   DateTimeRange.DateTime2.nMonth = 12;
   DateTimeRange.DateTime2.nYear = 2005;
   DateTimeRange.DateTime2.nHours = 12;
   DateTimeRange.DateTime2.nMinutes = 0;
   DateTimeRange.DateTime2.nSeconds = 0;
   DateTimeRange.DateTime2.nFractions = 0;
   DateTimeRange.DateTime2.nOffset = 0;
   pDS->SetDateTimeRangeValue(pElement, &DateTimeRange, 1);
   ShowRangeValue(pDS, pElement);
   pDS->SaveDS(MAKE_IMAGE_PATH(L_TEXT("test.dcm")), 0);
   delete pDS;
   return DICOM_SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.