LEADTOOLS Medical (Leadtools.Dicom assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
Insert(String,String,Boolean,DicomDateTimeValue,DicomContextGroupTableInsertFlags) Method
See Also 
Leadtools.Dicom Namespace > DicomContextGroupTable Class > Insert Method : Insert(String,String,Boolean,DicomDateTimeValue,DicomContextGroupTableInsertFlags) Method



contextIdentifier
The Context Identifier (0008,010F) of the new Context Group. For a list of values, refer to Context Identifier Values.
name
The name of the new Context Group.
isExtensible
Indicates whether the new Context Group is Extensible or not. true, The new Context Group is extensible. false, The new Context Group is Non-extensible.
contextGroupVersion
The Context Group Version (0008,0106) of the new Context Group.
flags
Flag that controls the behavior of this method.
contextIdentifier
The Context Identifier (0008,010F) of the new Context Group. For a list of values, refer to Context Identifier Values.
name
The name of the new Context Group.
isExtensible
Indicates whether the new Context Group is Extensible or not. true, The new Context Group is extensible. false, The new Context Group is Non-extensible.
contextGroupVersion
The Context Group Version (0008,0106) of the new Context Group.
flags
Flag that controls the behavior of this method.
Adds a new Context Group to the Context Group Table.

Syntax

Visual Basic (Declaration) 
Overloads Public Function Insert( _
   ByVal contextIdentifier As String, _
   ByVal name As String, _
   ByVal isExtensible As Boolean, _
   ByVal contextGroupVersion As DicomDateTimeValue, _
   ByVal flags As DicomContextGroupTableInsertFlags _
) As DicomContextGroup
Visual Basic (Usage)Copy Code
Dim instance As DicomContextGroupTable
Dim contextIdentifier As String
Dim name As String
Dim isExtensible As Boolean
Dim contextGroupVersion As DicomDateTimeValue
Dim flags As DicomContextGroupTableInsertFlags
Dim value As DicomContextGroup
 
value = instance.Insert(contextIdentifier, name, isExtensible, contextGroupVersion, flags)

Parameters

contextIdentifier
The Context Identifier (0008,010F) of the new Context Group. For a list of values, refer to Context Identifier Values.
name
The name of the new Context Group.
isExtensible
Indicates whether the new Context Group is Extensible or not. true, The new Context Group is extensible. false, The new Context Group is Non-extensible.
contextGroupVersion
The Context Group Version (0008,0106) of the new Context Group.
flags
Flag that controls the behavior of this method.

Return Value

DicomContextGroup object that specifies the newly inserted Context Group.

Example

Visual BasicCopy Code
<Test> _
Private Sub InsertContextGroup()
  Dim version As DicomDateTimeValue = New DicomDateTimeValue()

  version.Year = 2004
  version.Month = 3
  version.Day = 22
  version.Hours = 0
  version.Minutes = 0
  version.Seconds = 0
  version.Fractions = 0
  version.Offset = 0

  ' Insert a (testing) Context Group
  Dim group As DicomContextGroup = DicomContextGroupTable.Instance.Insert("CID XXXX", "New Context Group", True, version, DicomContextGroupTableInsertFlags.None)
  If group Is Nothing Then
    Return
  End If

  ' Fill the Context Group with some (testing) Coded Concepts
  DicomContextGroupTable.Instance.InsertCodedConcept(group, "CSD1", Nothing, "CV1", "CM1", DicomDateTimeValue.Empty, Nothing, DicomContextGroupTableInsertFlags.None)
  DicomContextGroupTable.Instance.InsertCodedConcept(group, "CSD2", Nothing, "CV2", "CM2", DicomDateTimeValue.Empty, Nothing, DicomContextGroupTableInsertFlags.None)
  DicomContextGroupTable.Instance.InsertCodedConcept(group, "CSD3", Nothing, "CV3", "CM3", DicomDateTimeValue.Empty, Nothing, DicomContextGroupTableInsertFlags.None)

  EnumCodedConcepts(group)

  ' Delete the Context Group
  DicomContextGroupTable.Instance.Delete(group)
End Sub

Private Sub DisplayCodedConcept(ByVal concept As DicomCodedConcept)
  Dim group As DicomContextGroup = DicomContextGroupTable.Instance.GetContextGroup(concept)
  Dim title As StringBuilder = New StringBuilder()
  Dim msg As StringBuilder = New StringBuilder()

  title.AppendFormat("Coded Concept ({0} '{1}')", group.ContextIdentifier, group.ContextIdentifierValue)

  If Not concept.CodingSchemeVersion Is Nothing Then
     msg.AppendFormat("Coding Scheme Designator: {0}{1}Coding Scheme Version: {2}{1}Code Value:{3}{1}Code Meaning: {4}", concept.CodingSchemeDesignator, Environment.NewLine,concept.CodingSchemeVersion, concept.CodeValue, concept.CodeMeaning)
  Else
     msg.AppendFormat("Coding Scheme Designator: {0}{1}Coding Scheme Version: {2}{1}Code Value:{3}{1}Code Meaning: {4}", concept.CodingSchemeDesignator, Environment.NewLine,"N/A", concept.CodeValue, concept.CodeMeaning)
  End If

  MessageBox.Show(msg.ToString(), title.ToString(), MessageBoxButtons.OK)
End Sub

Private Sub EnumCodedConcepts(ByVal group As DicomContextGroup)
  ' Enumerate the Coded Concepts in the Context Group (3 possible ways) 

  ' One possible way to enumerate the Coded Concepts
  Dim concept As DicomCodedConcept = DicomContextGroupTable.Instance.GetFirstCodedConcept(group)
  Do While Not concept Is Nothing
    DisplayCodedConcept(concept)
    concept = DicomContextGroupTable.Instance.GetNextCodedConcept(concept)
  Loop

  ' This code is commented out on purpose, it shows two other ways of 
  ' enumerating the Coded Concepts

  '
  '// Another way to enumerate the Coded Concepts
  'for (int i = 0; i < DicomContextGroupTable.Instance.GetCodedConceptCount(group); i++)
  '{
    'concept = DicomContextGroupTable.Instance.FindCodedConceptByIndex(group, i);
    'DisplayCodedConcept(concept);
  '}

  '// A third way to enumerate the Coded Concepts
  'concept = DicomContextGroupTable.Instance.GetLastCodedConcept(group);
  'while (concept != null)
  '{
    'DisplayCodedConcept(concept);
    'concept = DicomContextGroupTable.Instance.GetPreviousCodedConcept(concept);
  '}
  '
End Sub

Private Sub EnumContextGroups()
  DicomContextGroupTable.Instance.Reset()
  ' Load all the Context Groups
    DicomContextGroupTable.Instance.Load(String.Empty)

  ' Enumerate them (3 possible ways) 

  ' One possible way to enumerate the Context Groups
  Dim group As DicomContextGroup = DicomContextGroupTable.Instance.GetFirst()
  Do While Not group Is Nothing
    Dim msg As StringBuilder = New StringBuilder()
    msg.AppendFormat("{0}{2}{1}{2}{2}Enumerate Coded Concepts?", group.ContextIdentifier, group.Name, Environment.NewLine)

    Dim result As DialogResult = MessageBox.Show(msg.ToString(), "Context Group", MessageBoxButtons.YesNoCancel)
    If result = DialogResult.Yes Then
       EnumCodedConcepts(group)
    Else If result = DialogResult.Cancel Then
       Exit Do
    End If

    group = DicomContextGroupTable.Instance.GetNext(group)
  Loop

  ' This code is commented out on purpose, it shows two other ways of 
  ' enumerating Context Groups

  '
  '// Another way to enumerate the Context Groups
  'for (int i = 0; i < DicomContextGroupTable.Instance.Count; i++)
  '{
    'group = DicomContextGroupTable.Instance.FindIndex(i);

    'msg.AppendFormat("{0}{2}{1}{2}{2}Enumerate Coded Concepts?",
       'group.ContextIdentifier,
       'group.Name,
       'Environment.NewLine);

    'DialogResult result  = MessageBox.Show(msg.ToString(), "Context Group", MessageBoxButtons.YesNoCancel);
    'if(result == DialogResult.Yes)
    '{
       'EnumCodedConcepts(group);
    '}
    'else if (result == DialogResult.Cancel)
    '{
       'break;
    '}
  '}

  '// A third way to enumerate the Context Groups
  'group = DicomContextGroupTable.Instance.GetLast();
  'while (group != null)
  '{

    'msg.AppendFormat("{0}{2}{1}{2}{2}Enumerate Coded Concepts?",
       'group.ContextIdentifier,
       'group.Name,
       'Environment.NewLine);

    'DialogResult result = MessageBox.Show(msg.ToString(), "Context Group", MessageBoxButtons.YesNoCancel);
    'if (result == DialogResult.Yes)
    '{
       'EnumCodedConcepts(group);
    '}
    'else if (result == DialogResult.Cancel)
    '{
       'break;
    '}
    'group = group = DicomContextGroupTable.Instance.GetPrev(group);
  '}

  '
End Sub

Private Sub ModifyContextGroup()
  DicomContextGroupTable.Instance.Reset()
    DicomContextGroupTable.Instance.Load(String.Empty)

  Dim group As DicomContextGroup = Nothing
  Dim concept As DicomCodedConcept = Nothing

  ' Look for a Context Group
  group = DicomContextGroupTable.Instance.Find(DicomContextIdentifierType.CID6019)
  If group Is Nothing Then
    Return
  End If

  ' Look for a Coded Concept in the Context Group
  concept = DicomContextGroupTable.Instance.FindCodedConcept(group, "SRT", "F-01781")
  If concept Is Nothing Then
    Return
  End If

  ' Set the Code Meaning of the Coded Concept (French translation) 
  If DicomContextGroupTable.Instance.SetCodeMeaning(concept, "Situ� � 1 heure") = False Then
    Return
  End If

  DisplayCodedConcept(concept)

  ' Delete the Coded Concept
  DicomContextGroupTable.Instance.DeleteCodedConcept(concept)

  ' Add a (testing) Coded Concept to the Context Group
  concept = DicomContextGroupTable.Instance.InsertCodedConcept(group, "CSD", Nothing, "CV", "CM", DicomDateTimeValue.Empty, Nothing, DicomContextGroupTableInsertFlags.None)

  If concept Is Nothing Then
    Return
  End If
  DisplayCodedConcept(concept)

  ' Restore the Context Group (discard all the changes made to the Group) 
  DicomContextGroupTable.Instance.Default(group)
  EnumCodedConcepts(group)
  ' Delete the Context Group
  DicomContextGroupTable.Instance.Delete(group)
End Sub
C#Copy Code
public void InsertContextGroup()
{

   DicomDateTimeValue version = new DicomDateTimeValue();

   version.Year = 2004;
   version.Month = 3;
   version.Day = 22;
   version.Hours = 0;
   version.Minutes = 0;
   version.Seconds = 0;
   version.Fractions = 0;
   version.Offset = 0;

   // Insert a (testing) Context Group
   DicomContextGroup group = DicomContextGroupTable.Instance.Insert("CID XXXX", "New Context Group", true, version, DicomContextGroupTableInsertFlags.None);
   if (group == null)
   {
      return;
   }

   // Fill the Context Group with some (testing) Coded Concepts
   DicomContextGroupTable.Instance.InsertCodedConcept(group, "CSD1", null, "CV1", "CM1", DicomDateTimeValue.Empty, null, DicomContextGroupTableInsertFlags.None);
   DicomContextGroupTable.Instance.InsertCodedConcept(group, "CSD2", null, "CV2", "CM2", DicomDateTimeValue.Empty, null, DicomContextGroupTableInsertFlags.None);
   DicomContextGroupTable.Instance.InsertCodedConcept(group, "CSD3", null, "CV3", "CM3", DicomDateTimeValue.Empty, null, DicomContextGroupTableInsertFlags.None);

   EnumCodedConcepts(group);

   // Delete the Context Group
   DicomContextGroupTable.Instance.Delete(group);
}

void DisplayCodedConcept(DicomCodedConcept concept)
{
   DicomContextGroup group = DicomContextGroupTable.Instance.GetContextGroup(concept);
   StringBuilder title = new StringBuilder();
   StringBuilder msg = new StringBuilder();

   title.AppendFormat("Coded Concept ({0} '{1}')", group.ContextIdentifier, group.ContextIdentifierValue);

   msg.AppendFormat("Coding Scheme Designator: {0}{1}Coding Scheme Version: {2}{1}Code Value:{3}{1}Code Meaning: {4}",
         concept.CodingSchemeDesignator,
         Environment.NewLine,
         concept.CodingSchemeVersion != null ? concept.CodingSchemeVersion : "N/A",
         concept.CodeValue,
         concept.CodeMeaning);

   MessageBox.Show(msg.ToString(), title.ToString(), MessageBoxButtons.OK);
}

void EnumCodedConcepts(DicomContextGroup group)
{
   // Enumerate the Coded Concepts in the Context Group (3 possible ways) 

   // One possible way to enumerate the Coded Concepts
   DicomCodedConcept concept = DicomContextGroupTable.Instance.GetFirstCodedConcept(group);
   while (concept != null)
   {
      DisplayCodedConcept(concept);
      concept = DicomContextGroupTable.Instance.GetNextCodedConcept(concept);
   }

   // This code is commented out on purpose, it shows two other ways of 
   // enumerating the Coded Concepts

   /*
   // Another way to enumerate the Coded Concepts
   for (int i = 0; i < DicomContextGroupTable.Instance.GetCodedConceptCount(group); i++)
   {
      concept = DicomContextGroupTable.Instance.FindCodedConceptByIndex(group, i);
      DisplayCodedConcept(concept);
   }

   // A third way to enumerate the Coded Concepts
   concept = DicomContextGroupTable.Instance.GetLastCodedConcept(group);
   while (concept != null) 
   {
      DisplayCodedConcept(concept);
      concept = DicomContextGroupTable.Instance.GetPreviousCodedConcept(concept);
   }
   */
}

void EnumContextGroups()
{
   DicomContextGroupTable.Instance.Reset();
   // Load all the Context Groups
   DicomContextGroupTable.Instance.Load(null);

   // Enumerate them (3 possible ways) 

   // One possible way to enumerate the Context Groups
   DicomContextGroup group = DicomContextGroupTable.Instance.GetFirst();
   while (group != null)
   {
      StringBuilder msg = new StringBuilder();
      msg.AppendFormat("{0}{2}{1}{2}{2}Enumerate Coded Concepts?",
         group.ContextIdentifier,
         group.Name,
         Environment.NewLine);

      DialogResult result = MessageBox.Show(msg.ToString(), "Context Group", MessageBoxButtons.YesNoCancel);
      if (result == DialogResult.Yes)
      {
         EnumCodedConcepts(group);
      }
      else if (result == DialogResult.Cancel)
      {
         break;
      }

      group = DicomContextGroupTable.Instance.GetNext(group);
   }

   // This code is commented out on purpose, it shows two other ways of 
   // enumerating Context Groups

   /*
   // Another way to enumerate the Context Groups
   for (int i = 0; i < DicomContextGroupTable.Instance.Count; i++)
   {
      group = DicomContextGroupTable.Instance.FindIndex(i); 

      msg.AppendFormat("{0}{2}{1}{2}{2}Enumerate Coded Concepts?",
         group.ContextIdentifier,
         group.Name,
         Environment.NewLine); 

      DialogResult result  = MessageBox.Show(msg.ToString(), "Context Group", MessageBoxButtons.YesNoCancel);
      if(result == DialogResult.Yes)
      {
         EnumCodedConcepts(group); 
      }
      else if (result == DialogResult.Cancel) 
      {
         break; 
      }
   }

   // A third way to enumerate the Context Groups
   group = DicomContextGroupTable.Instance.GetLast();
   while (group != null) 
   {

      msg.AppendFormat("{0}{2}{1}{2}{2}Enumerate Coded Concepts?",
         group.ContextIdentifier,
         group.Name,
         Environment.NewLine);

      DialogResult result = MessageBox.Show(msg.ToString(), "Context Group", MessageBoxButtons.YesNoCancel);
      if (result == DialogResult.Yes)
      {
         EnumCodedConcepts(group);
      }
      else if (result == DialogResult.Cancel)
      {
         break;
      }
      group = group = DicomContextGroupTable.Instance.GetPrev(group); 
   }

   */
}

void ModifyContextGroup()
{
   DicomContextGroupTable.Instance.Reset();
   DicomContextGroupTable.Instance.Load(null);

   DicomContextGroup group = null;
   DicomCodedConcept concept = null;

   // Look for a Context Group
   group = DicomContextGroupTable.Instance.Find(DicomContextIdentifierType.CID6019);
   if (group == null)
   {
      return;
   }

   // Look for a Coded Concept in the Context Group
   concept = DicomContextGroupTable.Instance.FindCodedConcept(group, "SRT", "F-01781");
   if (concept == null)
   {
      return;
   }

   // Set the Code Meaning of the Coded Concept (French translation) 
   if (DicomContextGroupTable.Instance.SetCodeMeaning(concept, "Situ� � 1 heure") == false)
   {
      return;
   }

   DisplayCodedConcept(concept);

   // Delete the Coded Concept
   DicomContextGroupTable.Instance.DeleteCodedConcept(concept);

   // Add a (testing) Coded Concept to the Context Group
   concept = DicomContextGroupTable.Instance.InsertCodedConcept(group,
                                                                  "CSD",
                                                                  null,
                                                                  "CV",
                                                                  "CM",
                                                                  DicomDateTimeValue.Empty,
                                                                  null,
                                                                  DicomContextGroupTableInsertFlags.None);

   if (concept == null)
   {
      return;
   }
   DisplayCodedConcept(concept);

   // Restore the Context Group (discard all the changes made to the Group) 
   DicomContextGroupTable.Instance.Default(group);
   EnumCodedConcepts(group);
   // Delete the Context Group
   DicomContextGroupTable.Instance.Delete(group);
}
SilverlightCSharpCopy Code
SilverlightVBCopy Code

Remarks

  • Please note that if the Context Identifier, Name, and Context Group Version of the new Context Group are not specified, the method fails and returns null.
  • A Context Group can be added to the Context Group Table either by loading it from the internal table maintained by LEADTOOLS or by inserting it into the Context Group Table directly. Use DicomContextGroupTable.Insert method to insert a new Context Group to the Context Group Table. To load Context Groups from the internal table, use the Leadtools.Dicom.DicomContextGroupTable.Load method.
  • Use the method DicomContextGroupTable.InsertCodedConcept to add Coded Concepts to a Context Group in the Context Group Table.

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also

Leadtools.Dicom requires a Medical toolkit server license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features