ISReferral.UnlinkUsualPrescription

Description

This function unlinks the prescription from the referral of the selected patient.

Syntax

object.UnlinkUsualPrescription aUsualPrescription

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

Example

Unlink the prescription from the referral of the selected patient.

sub main
  Dim aPatient
  Dim aFilter
  Dim aReferrals, aReferral
  Dim aUsualPrescriptions, aUsualPrescription
  Dim aMessage

  Set aPatient = Profile.SelectPatient
  set aFilter = Profile.CreateReferralsFilter
  aFilter.Patient = aPatient
  set aReferrals = Profile.LoadReferrals(aFilter)

  aMessage = "INITIAL STATE:" & GetLinkedUsuslaMedicationsInfo(aReferrals)
  
  for each aReferral in aReferrals
    set aUsualPrescriptions = aReferral.LinkedUsualPrescriptions  
    for i = aUsualPrescriptions.Count - 1 to 0 step -1
      aReferral.UnlinkUsualPrescription aUsualPrescriptions.Item(i)
    next
  next
  aMessage = aMessage & vbNewLine & vbNewLine &_ 
    "REFERRALS AFTER USUAL PRESCRIPTIONS UNLINKING:" & GetLinkedUsuslaMedicationsInfo(aReferrals) & vbNewLine
  
  Profile.MsgBox(aMessage)
end sub

function GetLinkedUsuslaMedicationsInfo(aReferrals)
  Dim aInfo
  Dim aReferral
  Dim aUsualPrescriptions, aUsualPrescription
  
  for each aReferral in aReferrals
    aInfo = aInfo & vbNewLine & "Referral Id: " & aReferral.Id
    set aUsualPrescriptions = aReferral.LinkedUsualPrescriptions
    if aUsualPrescriptions.Count > 0 then aInfo = aInfo & vbNewLine & "  Med IDs: "   
    for each aUsualPrescription in aUsualPrescriptions
      aInfo = aInfo & aUsualPrescription.Oid & ", "
    next
  next
  GetLinkedUsuslaMedicationsInfo = aInfo
end function
Note:

In Profile Client v8 on User Interface Usual Prescriptions can be found and unlinked in Patient > Patient Referrals > Open Outward Referral > Attachments > ticked items in Usual Medications node.

See also

Version information

Added in v8.4.32