Enumerating the Coded Concepts of a Context Group Example for C++ 6.0 and later
BOOL DisplayCodedConcept(ILEADDicomDSPtr& spDicomDS, BOOL bYesNo)
{
IDicomCodedConceptPtr spConcept = spDicomDS->CurrentCodedConcept;
char szMsg[256], szTitle[32];
spDicomDS->MoveCodedConceptGroup ();
wsprintf(szTitle, "Coded Concept (%s)",
spDicomDS->CurrentContextGroup->ContextIdentifier.operator char *());
// Coding Scheme Designator
wsprintf(szMsg, "%s\n",
spConcept->CodingSchemeDesignator.operator char *());
// Coding Scheme Version
if (spConcept->CodingSchemeVersion.length())
{
wsprintf(szMsg, "%s%s\n", szMsg,
spConcept->CodingSchemeVersion.operator char *());
}
// Code Value and Code Meaning
wsprintf(szMsg, "%s%s\n%s\n", szMsg,
spConcept->CodeValue.operator char *(),
spConcept->CodeMeaning.operator char *());
// Context Group Local Version
if (spConcept->IsContextGroupLocalVersion)
{
wsprintf(szMsg, "%s%04hd%02hd%02hd\n", szMsg,
spConcept->ContextGroupLocalVersion->Year,
spConcept->ContextGroupLocalVersion->Month,
spConcept->ContextGroupLocalVersion->Day);
}
// Context Group Extension Creator UID
if (spConcept->ContextGroupExtensionCreatorUID.length())
{
wsprintf(szMsg, "%s%s\n", szMsg,
spConcept->ContextGroupExtensionCreatorUID.operator char *());
}
if (bYesNo)
{
lstrcat(szMsg, "\nContinue?");
return (::MessageBox(NULL, szMsg, szTitle, MB_YESNO) == IDYES);
}
else
{
::MessageBox(NULL, szMsg, szTitle, MB_OK);
return TRUE;
}
}
void EnumCodedConcepts(ILEADDicomDSPtr& spDicomDS)
{
VARIANT_BOOL bRet;
// Enumerate the Coded Concepts in the current Context Group (3 possible ways)
#if 1
// One possible way to enumerate the Coded Concepts
bRet = spDicomDS->MoveFirstCodedConcept();
while (bRet)
{
if (!DisplayCodedConcept(spDicomDS, TRUE))
{
break;
}
bRet = spDicomDS->MoveNextCodedConcept ();
}
#elif 0
// Another way to enumerate the Coded Concepts
long lConceptsCount = spDicomDS->GetCodedConceptCount ();
for (long i = 0; i < lConceptsCount; i++)
{
spDicomDS->FindIndexCodedConcept (i);
if (!DisplayCodedConcept(spDicomDS, TRUE))
{
break;
}
}
#elif 0
// A third way to enumerate the Coded Concepts
bRet = spDicomDS->MoveLastCodedConcept ();
while (bRet)
{
if (!DisplayCodedConcept(spDicomDS, TRUE))
{
break;
}
bRet = spDicomDS->MovePrevCodedConcept ();
}
#endif
}