#include "Ltdic.h"
L_LTDIC_API L_INT L_DicomGetDateRangeValue(hDS, pElement, nIndex, pValue)
Fills a VALUEDATERANGE structure with Date Range information stored in the Value Field of the specified element.
A DICOM handle.
Pointer to a DICOMELEMENT structure within the Data Set.
Index value that indicates which value to retrieve when more than one value is stored in the Value Field. The index is zero-based.
Pointer to the VALUEDATERANGE structure to be filled. For more information, see VALUEDATERANGE structure.
Value | Meaning |
---|---|
DICOM_SUCCESS | The function was successful. |
>0 | An error occurred. Refer to Return Codes. |
If you have more than one value stored in the Value Field of the specified Data Element, you can retrieve one or more of those elements. For example, if the Value Field of the specified Data Element contains three Date values, and you are only interested in retrieving the last two Date values, set nIndex to 1 and nCount to 2. This tells the function to retrieve the Date values starting at position 1 (the index is zero based) and retrieve two values. Therefore you would retrieve the values in positions 1 and 2 in the Value Field.
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
Win32, x64, Linux.
This example gets the range of values for an element.
L_VOID ShowRangeValue(HDICOMDS hDS, pDICOMELEMENT pElement)
{
L_INT32 i;
L_INT32 nCount;
L_TCHAR szText[256];
VALUEDATERANGE DateRange;
VALUETIMERANGE TimeRange;
VALUEDATETIMERANGE DateTimeRange;
L_INT nRet;
nCount = L_DicomGetCountValue(hDS, 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 = L_DicomGetDateRangeValue(hDS, 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);
MessageBox(NULL, szText, TEXT("Value"), MB_OK);
}
}
break;
case VR_TM: // Time Range
for (i = 0; i < nCount; i++)
{
nRet = L_DicomGetTimeRangeValue(hDS, 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);
MessageBox(NULL, szText, TEXT("Value"), MB_OK);
}
}
break;
case VR_DT: // Date Time
for (i = 0; i < nCount; i++)
{
nRet = L_DicomGetDateTimeRangeValue(hDS, 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);
MessageBox(NULL, szText, TEXT("Value"), MB_OK);
}
}
break;
default:
wsprintf(szText, TEXT("Element is not a range value element!"));
MessageBox(NULL, szText, TEXT("Value"), MB_OK);
break;
}
L_DicomFreeValue(hDS, pElement);
}
L_INT LDicomDS_GetDateRangeValueExample()
{
L_INT nRet;
HDICOMDS hDS;
pDICOMELEMENT pElement;
hDS = L_DicomCreateDS(NULL);
nRet = L_DicomLoadDS(hDS, MAKE_IMAGE_PATH(TEXT("Image1.dcm")), 0);
if(nRet != DICOM_SUCCESS)
return nRet;
pElement = L_DicomFindFirstElement(hDS, NULL, TAG_STUDY_DATE, FALSE);
L_DicomDeleteElement(hDS, pElement);
pElement = L_DicomFindFirstElement(hDS, NULL, TAG_STUDY_TIME, FALSE);
L_DicomDeleteElement(hDS, pElement);
pElement = L_DicomFindFirstElement(hDS,NULL, TAG_CONTRIBUTION_DATETIME, FALSE);
L_DicomDeleteElement(hDS,pElement);
pElement = L_DicomInsertElement(hDS, 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;
L_DicomSetDateRangeValue(hDS, pElement, &DateRange, 1);
ShowRangeValue(hDS, pElement);
pElement = L_DicomInsertElement(hDS, 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;
L_DicomSetTimeRangeValue(hDS, pElement, &TimeRange, 1);
ShowRangeValue(hDS, pElement);
pElement = L_DicomInsertElement(hDS, 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;
L_DicomSetDateTimeRangeValue(hDS, pElement, &DateTimeRange, 1);
ShowRangeValue(hDS, pElement);
nRet = L_DicomSaveDS(hDS, MAKE_IMAGE_PATH(TEXT("test.dcm")), 0);
L_DicomFreeDS(hDS);
return DICOM_SUCCESS;
}