ISReferral.LinkCDOForm

Description

This function links a CDO Form to the patient's referral.

Syntax

object.LinkCDOForm aForm

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

Example

Link the CDO Form to the patient's referral and display its ID.

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.LinkCDOForm aHRC
    next 
  next
  
  aTrans.Commit  
  
  set aTrans = Profile.StartMapTransaction  
  set aReferrals = Profile.LoadReferrals(aReferralsFilter)  
  aMessage = aMessage & vbNewLine & vbNewLine &_ 
    "REFERRALS AFTER CDO Forms LINKING:" & 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: This function throws exception when the link between the objects already exists.

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

See also

Version information

Added in v7.8.0