ISReferral.UnlinkCDOForm

Description

This function unlinks the CDO Form from the referral of the selected patient.

Syntax

object.UnlinkCDOForm aForm

Part Attribute Type Description
object Required
The object always implements the ISReferral interface
aForm In, Required
The form linked to the referral

Example

Unlink the CDO Form from the referral of the selected patient.

sub main
  Dim aFilter 
  Dim aPatient
  Dim aCDOForms
  Dim aReferralsFilter
  Dim aTrans
  Dim aReferrals, aReferral
  Dim aCDOForm
  Dim aHRC
  
  Dim aMessage

  Set aPatient = Profile.SelectPatient

  set aFilter = Profile.CreateCdoFormFilter
  aFilter.PatientId = aPatient.Id
  set aCDOForms = Profile.LoadCdoForms(aFilter)

  set aReferralsFilter = Profile.CreateReferralsFilter
  aReferralsFilter.Patient = aPatient.Id
  
  set aTrans = Profile.StartMapTransaction  
  set aReferrals = Profile.LoadReferrals(aReferralsFilter)
  aMessage = "INITIAL STATE:" & GetLinkedCDOFormsInfo(aReferrals) 
  
  for each aReferral in aReferrals
    for i = 0 to aCDOForms.Count - 1
      set aCDOForm = aCDOForms.Item(i)
      set aHRC = aCDOForm.AsHRC 
      aReferral.UnlinkCDOForm aHRC
    next 
  next
  
  aTrans.Commit  
  
  set aTrans = Profile.StartMapTransaction  
  set aReferrals = Profile.LoadReferrals(aReferralsFilter)  
  aMessage = aMessage & vbNewLine & vbNewLine &_ 
    "REFERRALS AFTER CDO Forms UNLINKING:" & GetLinkedCDOFormsInfo(aReferrals) & vbNewLine

  Profile.MsgBox (aMessage)
end sub

function GetLinkedCDOFormsInfo(aReferrals)
  Dim aInfo
  Dim aReferral
  Dim aCDOForms, aCDOForm
  
  for each aReferral in aReferrals
    aInfo = aInfo & vbNewLine & "Referral Id: " & aReferral.Id
    set aCDOForms = aReferral.LinkedCDOForms
    if aCDOForms.Count > 0 then aInfo = aInfo & vbNewLine & "  CDOForms IDs: "   
    for i = 0 to aCDOForms.Count - 1
      set aCDOForm = aCDOForms.Item(i)
      aInfo = aInfo & aCDOForm.Id & ", "
    next
  next
  GetLinkedCDOFormsInfo = aInfo
end function 
Note:

In Profile Client v8 on User Interface CDO Forms can be found and unlinked in Patient > Patient Referrals > Open selected Referral > Attachments > Forms.

See also

Version information

Added in v8.4.32
parameter aForm added in v8.5.0
parameter aCDOTransaction removed in v8.5.0