GetAgeValue Example for C++ 6.0 and later
long lCount;
short nRet;
IDicomDSElementPtr pCurrentElement=NULL;
IAGEVALUEItemPtr pAgeValue=NULL;
m_pLEADDicomDS->EnableMethodErrors = FALSE;
//move to the root element
m_pLEADDicomDS->MoveFirstElement(FALSE);
m_pLEADDicomDS->MoveRootElement();
m_List1.ShowWindow(SW_SHOW);
m_List1.ResetContent();
//insert a new element for the Age Values
nRet = m_pLEADDicomDS->InsertElement(FALSE, TAG_PATIENT_AGE, VR_AS, FALSE, 0);
//insert an Age value into the element
m_pLEADDicomDS->AgeValueCount = 1;
pAgeValue = m_pLEADDicomDS->GetAgeValues(0);
pAgeValue->Number = 21;
pAgeValue->Reference = 'Y';
//set the age
nRet = m_pLEADDicomDS->SetAgeValue(1);
if(nRet != 0)
{
AfxMessageBox("Error");
return;
}
m_pLEADDicomDS->AgeValueCount = 0; //free the vale
//get the value count
lCount = m_pLEADDicomDS->GetValueCount();
CString szOut;
szOut.Format("There are %ld values!", lCount);
AfxMessageBox(szOut);
//get the value
nRet = m_pLEADDicomDS->GetAgeValue (0, lCount);
//display the value
pAgeValue = m_pLEADDicomDS->GetAgeValues (0);
szOut.Format("Number: %d", pAgeValue->GetNumber());
m_List1.AddString(szOut);
szOut.Format("Reference: %c", (char)pAgeValue->GetReference());
m_List1.AddString(szOut);
AfxMessageBox("wait");