ISContact.RemoveTag

Description

This function removes the tag from the contact.

Syntax

object.RemoveTag aClinicalTagID

Part Attribute Type Description
object Required
The object always implements the ISContact interface
aClinicalTagID In, Required
int
ID of the clinical tag

Example

Remove the tag with the specified description from the contact and display the number of the tags before and after removing.

sub main
  Dim aTr
  Dim aPatient   
  Dim aShortCode, aShortCodeID     
  Dim aFilter              
  Dim aEncounters, aEncounter
  Dim i
  Dim aEncounterTags, aEncounterTag
  Dim aMessage
  Dim aContact
  Dim aPrescriptions, aPrescription

  Set aTr = Profile.StartMapTransaction

  set aPatient = Profile.SelectPatient 
  set aFilter = Profile.CreateEncounterFilter
  aFilter.MaxCount = 1
  aFilter.PatientId = aPatient.ID                 
  set aEncounters = aPatient.LoadEncounters(aFilter)
  if aEncounters.Count = 0 then
    Profile.MsgBox("No encounters")
    exit sub
  end if

  set aShortCode = Profile.LoadShortCodeByCodeType("AUDIT", 171) 'sscClinicalTag
  aShortCodeID = aShortCode.ID                                                                                              

  set aEncounter = aEncounters.Item(0)
  set aContact = aEncounter.Contacts.Item(0)   

  aMessage = aMessage & vbNewLine & "Before Adding: " & vbNewLine &_
    GetEncounterTagsInfo(aContact.EncounterTags)
   
  aContact.AddTag aShortCodeID, "abab", "dede"

  aTr.SnapShot

  aMessage = aMessage & vbNewLine & "After Adding: " & vbNewLine &_
    GetEncounterTagsInfo(aContact.EncounterTags)    
        
  aId = GetTagIdByDescription(aContact.EncounterTags, "Audited")
  if aId > 0 then     
    aContact.RemoveTag(aId)
    aMessage = aMessage & vbNewLine & "After Deleting: " & vbNewLine &_
      GetEncounterTagsInfo(aContact.EncounterTags)
  else          
    aMessage = aMessage & vbNewLine & "No Items were deleted: " & vbNewLine   
  end if      
                                       
  Profile.MsgBox(aMessage)
end sub

function GetEncounterTagsInfo(aEncounterTags)
  aInfo = "Encounter Tags Count is " & aEncounterTags.Count & vbNewLine

  for i = 0 to aEncounterTags.Count - 1
    set aEncounterTag = aEncounterTags.Item(i) 
    aInfo = aInfo & "Tag Description: " & aEncounterTag.Description & vbNewLine     
  next 
  GetEncounterTagsInfo = aInfo
end function

function GetTagIdByDescription(aEncounterTags, aTagDescription)
  aId = 0
  for i = 0 to aEncounterTags.Count - 1
    set aEncounterTag = aEncounterTags.Item(i)
    if aEncounterTag.Description = aTagDescription then aId = aEncounterTag.Id    
  next 
  GetTagIdByDescription = aId
end function
Note:

In Profile Client v8 on User Interface Encounter Tags can be found and deleted in Clinical > Medical Record > Encounters > Open Encounter.

Version information

Added in v8.3.0