ISReferral.LinkUsualPrescription

Description

This function links the prescription to the referral of the selected patient.

Syntax

object.LinkUsualPrescription aUsualPrescription

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

Example

Link the prescription to the referral of the selected patient and display its ID.

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)
  
  set aUsualPrescriptions = aPatient.Medications.Usual
  for each aReferral in aReferrals 
    for each aUsualPrescription in aUsualPrescriptions
      aReferral.LinkUsualPrescription aUsualPrescription
    next
  next
  aMessage = aMessage & vbNewLine & vbNewLine &_ 
    "REFERRALS AFTER USUAL PRESCRIPTIONS LINKING:" & 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: This function throws exception when the link between the objects already exists.

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

See also

Version information

Added in v8.4.32