Enumerating Context Groups Example for Visual Basic
Private Function DisplayContextGroup(objDS As LEADDicomDS) As VbMsgBoxResult
Dim objGroup As DicomContextGroup
Set objGroup = objDS.CurrentContextGroup
Dim sMsg As String
' Context ID and name
sMsg = objGroup.ContextIdentifier & vbNewLine & _
objGroup.Name & vbNewLine
' Extensibility
If objGroup.Extensible Then
sMsg = sMsg & "Extensible" & vbNewLine
Else
sMsg = sMsg & "Non-extensible" & vbNewLine
End If
' Context Group Version
Dim sYear As String, sMonth As String, sDay As String
With objGroup.ContextGroupVersion
sYear = .Year
Do While Len(sYear) < 4
sYear = "0" & sYear
Loop
sMonth = .Month
If Len(sMonth) < 2 Then sMonth = "0" & sMonth
sDay = .Day
If Len(sDay) < 2 Then sDay = "0" & sDay
End With
sMsg = sMsg & sYear & sMonth & sDay & vbNewLine
sMsg = sMsg & vbNewLine & "Enumerate Coded Concepts?"
DisplayContextGroup = MsgBox(sMsg, vbYesNoCancel, "Context Group")
End Function
Private Sub EnumContextGroups(objDS As LEADDicomDS)
Dim bRet As Boolean, sMsg As String
objDS.ResetContextGroup
' Load all the Context Groups
objDS.LoadContextGroup
' Enumerate them (3 possible ways)
If True Then
' One possible way to enumerate the Context Groups
bRet = objDS.MoveFirstContextGroup()
Do While bRet
Select Case DisplayContextGroup(objDS)
Case vbYes
' Refer to Enumerating the Coded Concepts of a Context Group
' Example for Visual Basic for the procedure EnumCodedConcepts
EnumCodedConcepts objDS
Case vbCancel
Exit Do
End Select
bRet = objDS.MoveNextContextGroup ()
Loop
ElseIf False Then
' Another way to enumerate the Context Groups
Dim I As Long
For I = 0 To objDS.GetContextGroupCount () - 1
objDS.FindIndexContextGroup I
Select Case DisplayContextGroup(objDS)
Case vbYes
EnumCodedConcepts objDS
Case vbCancel
Exit For
End Select
Next
ElseIf False Then
' A third way to enumerate the Context Groups
bRet = objDS.MoveLastContextGroup ()
Do While bRet
Select Case DisplayContextGroup(objDS)
Case vbYes
EnumCodedConcepts objDS
Case vbCancel
Exit Do
End Select
bRet = objDS.MovePrevContextGroup ()
Loop
End If
End Sub