Error processing SSI file
LEADTOOLS Medical (Leadtools.Ccow assembly)

Show in webframe

JoinCommonContext Method






The context participant interface provided by the application.
Name of the application. This string must be unique relative to the other applications that have already joined the common context session.
If set to true participate in context change surveys. If false the application will only be informed when a context change has been accepted.
If set to true wait for the current context change transaction to complete.
Enables an application to join a common context session.
Syntax
'Declaration
 
Function JoinCommonContext( _
   ByVal contextParticipant As IContextParticipant, _
   ByVal applicationName As String, _
   ByVal survey As Boolean, _
   ByVal wait As Boolean _
) As Integer
'Usage
 
Dim instance As IContextManager
Dim contextParticipant As IContextParticipant
Dim applicationName As String
Dim survey As Boolean
Dim wait As Boolean
Dim value As Integer
 
value = instance.JoinCommonContext(contextParticipant, applicationName, survey, wait)

Parameters

contextParticipant
The context participant interface provided by the application.
applicationName
Name of the application. This string must be unique relative to the other applications that have already joined the common context session.
survey
If set to true participate in context change surveys. If false the application will only be informed when a context change has been accepted.
wait
If set to true wait for the current context change transaction to complete.

Return Value

A participant coupon that the application uses to denote itself to the context manager.
Example

Joins a common context and set patient information.

Copy Code  
Imports Leadtools
        Imports Leadtools.Ccow
        Imports Leadtools.Ccow.UI

        Private ApplicationName As String = "LEADTOOLS CCOW App"
        <TestMethod()> _
        Public Sub JoinCommonContext()
            Dim contextManager As IContextManager = Utils.COMCreateObject(Of IContextManager)(CcowProgId)
            Dim participant As ContextParticipant = New ContextParticipant()
            Dim coupon As Integer = 0

            Try
                coupon = contextManager.JoinCommonContext(participant, ApplicationName, True, False)

                '
                ' Set Patient Context
                '
                SetPatientContext(contextManager, coupon)

                '
                ' Get Patient Context
                '
                GetPatientContext(contextManager, coupon)

                contextManager.LeaveCommonContext(coupon)
            Catch e As Exception
                Debug.WriteLine(e.Message)
            End Try
        End Sub

        Public Sub SetPatientContext(ByVal contextManager As IContextManager, ByVal coupon As Integer)
            Dim patientSubject As Subject = New Subject("Patient")
            Dim contextData As IContextData = TryCast(contextManager, IContextData)
            Dim transactionCoupon As Integer = 0
            Dim noContinue As Boolean = True, disconnect As Boolean = False
            Dim reasons As Object
            Dim decision As String = "accept"

            patientSubject.Items.Add(New ContextItem("Patient.id.mrn", "123456789"))
            patientSubject.Items.Add(New ContextItem("Patient.co.Patientname", "Doe^John^^^"))

            Try
                transactionCoupon = contextManager.StartContextChanges(coupon)
                contextData.SetItemValues(coupon, patientSubject.ToItemNameArray(), patientSubject.ToItemValueArray(), transactionCoupon)
                reasons = contextManager.EndContextChanges(transactionCoupon, noContinue)

                '
                ' If any application responded that they cannot apply the change we need to display
                ' a dialog that displays the reasons for the problems.
                '
                If (Not reasons Is Nothing AndAlso (CType(reasons, String())).Length > 0) OrElse noContinue Then
                    Dim pd As ProblemDialog = New ProblemDialog(CType(reasons, String()), noContinue)
                    Dim result As DialogResult

                    result = pd.ShowDialog()
                    If noContinue Then
                        decision = "cancel"
                    End If
                    If result = System.Windows.Forms.DialogResult.OK Then
                        decision = "accept"
                    ElseIf result = DialogResult.Cancel Then
                        decision = "cancel"
                    Else
                        decision = "cancel"
                        disconnect = True
                    End If
                End If

                contextManager.PublishChangesDecision(transactionCoupon, decision)

                '
                ' If user decided to break context we must leave
                '
                If disconnect Then
                    contextManager.LeaveCommonContext(coupon)
                End If
            Catch e As Exception
                Debug.WriteLine(e.Message)
            End Try
        End Sub

        Public Sub GetPatientContext(ByVal contextManager As IContextManager, ByVal coupon As Integer)
            Dim contextData As IContextData = TryCast(contextManager, IContextData)
            Dim data As Object = Nothing

            Try
                data = contextData.GetItemNames(contextManager.MostRecentContextCoupon)
                If data.GetType() Is GetType(String()) AndAlso (CType(data, String())).Length > 0 Then
                    Dim names As String() = CType(data, String())

                    For Each name As String In names
                        Debug.WriteLine(name)
                    Next name
                    data = contextData.GetItemValues(data, False, contextManager.MostRecentContextCoupon)
                    If data.GetType() Is GetType(Object()) Then
                        Dim values As Object() = CType(data, Object())

                        Dim i As Integer = 0
                        Do While i < values.Length
                            Debug.Write(values(i).ToString())
                            Debug.Write("     ")
                            Debug.WriteLine(values(i + 1).ToString())
                            i += 2
                        Loop
                    End If
                End If
            Catch e As Exception
                Debug.WriteLine(e.Message)
            End Try
        End Sub

        <ComVisible(True)> _
        Public Class ContextParticipant
            Implements IContextParticipant
#Region "IContextParticipant Members"

            Public Sub CommonContextTerminated() Implements IContextParticipant.CommonContextTerminated
                Console.WriteLine("CommonContextTerminated")
            End Sub

            Public Sub ContextChangesAccepted(ByVal contextCoupon As Integer) Implements IContextParticipant.ContextChangesAccepted
                Console.WriteLine("ContextChangesAccepted")
            End Sub

            Public Sub ContextChangesCanceled(ByVal contextCoupon As Integer) Implements IContextParticipant.ContextChangesCanceled
                Console.WriteLine("ContextChangesCanceled")
            End Sub

            Public Function ContextChangesPending(ByVal contextCoupon As Integer, ByRef reason As String) As String Implements IContextParticipant.ContextChangesPending
                reason = String.Empty
                Console.WriteLine("ContextChangesPending")
                Return "accept"
            End Function

            Public Sub Ping() Implements IContextParticipant.Ping
            End Sub

#End Region
        End Class
using Leadtools;
using Leadtools.Ccow;
using Leadtools.Ccow.UI;

private string ApplicationName = "LEADTOOLS CCOW App";
[TestMethod]
public void JoinCommonContext()
{
    IContextManager contextManager = Utils.COMCreateObject<IContextManager>(CcowProgId);
    ContextParticipant participant = new ContextParticipant();
    int coupon = 0;

    try
    {
        coupon = contextManager.JoinCommonContext(participant, ApplicationName, true, false);

        //
        // Set Patient Context
        //

        SetPatientContext(contextManager, coupon);

        //
        // Get Patient Context
        //

        GetPatientContext(contextManager, coupon);

        contextManager.LeaveCommonContext(coupon);
    }
    catch (Exception e)
    {
        Debug.WriteLine(e.Message);
    }
}

public void SetPatientContext(IContextManager contextManager, int coupon)
{
    Subject patientSubject = new Subject("Patient");
    IContextData contextData = contextManager as IContextData;
    int transactionCoupon = 0;
    bool noContinue = true, disconnect = false;
    object reasons;
    string decision = "accept";

    patientSubject.Items.Add(new ContextItem("Patient.id.mrn", "123456789"));
    patientSubject.Items.Add(new ContextItem("Patient.co.Patientname", "Doe^John^^^"));

    try
    {
        transactionCoupon = contextManager.StartContextChanges(coupon);
        contextData.SetItemValues(coupon, patientSubject.ToItemNameArray(), patientSubject.ToItemValueArray(), transactionCoupon);
        reasons = contextManager.EndContextChanges(transactionCoupon, ref noContinue);

        //
        // If any application responded that they cannot apply the change we need to display
        // a dialog that displays the reasons for the problems.
        //

        if ((reasons != null && ((string[])reasons).Length > 0) || noContinue)
        {
            ProblemDialog pd = new ProblemDialog((string[])reasons, noContinue);
            DialogResult result;

            result = pd.ShowDialog();
            if (noContinue)
                decision = "cancel";
            if (result == DialogResult.OK)
                decision = "accept";
            else if (result == DialogResult.Cancel)
                decision = "cancel";
            else
            {
                decision = "cancel";
                disconnect = true;
            }
        }

        contextManager.PublishChangesDecision(transactionCoupon, decision);

        //
        // If user decided to break context we must leave
        //

        if (disconnect)
        {
            contextManager.LeaveCommonContext(coupon);
        }
    }
    catch (Exception e)
    {
        Debug.WriteLine(e.Message);
    }
}

public void GetPatientContext(IContextManager contextManager, int coupon)
{
    IContextData contextData = contextManager as IContextData;
    object data = null;

    try
    {
        data = contextData.GetItemNames(contextManager.MostRecentContextCoupon);
        if (data.GetType() == typeof(string[]) && ((string[])data).Length > 0)
        {
            string[] names = (string[])data;

            foreach (string name in names)
            {
                Debug.WriteLine(name);
            }
            data = contextData.GetItemValues(data, false, contextManager.MostRecentContextCoupon);
            if (data.GetType() == typeof(object[]))
            {
                object[] values = (object[])data;

                for (int i = 0; i < values.Length; i += 2)
                {
                    Debug.Write(values[i].ToString());
                    Debug.Write("     ");
                    Debug.WriteLine(values[i + 1].ToString());
                }
            }
        }
    }
    catch (Exception e)
    {
        Debug.WriteLine(e.Message);
    }
}

[ComVisible(true)]
public class ContextParticipant : IContextParticipant
{
    #region IContextParticipant Members

    public void CommonContextTerminated()
    {
        Console.WriteLine("CommonContextTerminated");
    }

    public void ContextChangesAccepted(int contextCoupon)
    {
        Console.WriteLine("ContextChangesAccepted");
    }

    public void ContextChangesCanceled(int contextCoupon)
    {
        Console.WriteLine("ContextChangesCanceled");
    }

    public string ContextChangesPending(int contextCoupon, ref string reason)
    {
        reason = string.Empty;
        Console.WriteLine("ContextChangesPending");
        return "accept";
    }

    public void Ping()
    {
    }

    #endregion
}
Requirements

Target Platforms

See Also

Reference

IContextManager Interface
IContextManager Members

Error processing SSI file
Leadtools.Ccow requires a Medical toolkit server license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features