←Select platform

InsertCodedConcept Method

Summary
Adds a new Coded Concept to the specified Context Group.
Syntax
C#
Objective-C
C++/CLI
- (nullable LTDicomCodedConcept *)insertCodedConcept:(LTDicomContextGroup *)contextGroup codingSchemeDesignator:(NSString *)codingSchemeDesignator codingSchemeVersion:(NSString *)codingSchemeVersion codeValue:(NSString *)codeValue codeMeaning:(NSString *)codeMeaning contextGroupLocalVersion:(LTDicomDateTimeValue *)contextGroupLocalVersion contextGroupExtensionCreatorUID:(NSString *)contextGroupExtensionCreatorUID flags:(LTDicomContextGroupTableInsertFlags)flags; 

Parameters

contextGroup
The Context Group to which the new Coded Concept is to be added.

codingSchemeDesignator
The Coding Scheme Designator (0008,0102) for the new Coded Concept.

codingSchemeVersion
The Coding Scheme Version (0008,0103) for the new Coded Concept. Set this to null if no Coding Scheme Version is to be defined for the new Coded Concept.

codeValue
The Code Value (0008,0100) for the new Coded Concept.

codeMeaning
The Code Meaning (0008,0104) for the new Coded Concept.

contextGroupLocalVersion
The Context Group Local Version (0008,0107) for the new Coded Concept. Set this to null if no Context Group Local Version is to be defined for the new Coded Concept.

contextGroupExtensionCreatorUID
The Context Group Extension Creator UID (0008,010D) for the new Coded Concept. Set this to null if no Context Group Extension Creator UID is to be defined for the new Coded Concept.

flags
flag that controls the behavior of this method

Return Value

DicomCodedConcept object that specifies the newly inserted Coded Concept. null if the method failed to allocate memory.

Remarks
  • Please note that if the Coding Scheme Designator, the Code Value, and the Code Meaning of the new Coded Concept are not specified, the method fails and returns null.
  • If a Context Group in the Context Group Table has a corresponding Group in the internal table maintained by LEADTOOLS, then you can use the Default method to discard any changes made to the Context Group, including any additions of new Coded Concepts.
Example
C#
using Leadtools; 
using Leadtools.Dicom; 
 
 
       
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); 
 
   Console.WriteLine($"{title.ToString()}: {msg.ToString()}"); 
} 
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); 
 
      Console.WriteLine($"Context Group: {msg}"); 
      EnumCodedConcepts(group); 
 
      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); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom Assembly