LEADTOOLS Medical (Leadtools.Dicom.Scu assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
Find(DicomScp,FindQuery) Method
See Also 
Leadtools.Dicom.Scu Namespace > QueryRetrieveScu Class > Find Method : Find(DicomScp,FindQuery) Method




Scp
The peer connection to send the C-FIND-REQ to.
Query
The query information that describes the DICOM datasets to be found.
Scp
The peer connection to send the C-FIND-REQ to.
Query
The query information that describes the DICOM datasets to be found.
Sends a C-FIND-REQ message to a peer member of a connection defined by Scp.

Syntax

Visual Basic (Declaration) 
Overloads Public Sub Find( _
   ByVal Scp As DicomScp, _
   ByVal Query As FindQuery _
) 
Visual Basic (Usage)Copy Code
Dim instance As QueryRetrieveScu
Dim Scp As DicomScp
Dim Query As FindQuery
 
instance.Find(Scp, Query)
C# 
public void Find( 
   DicomScp Scp,
   FindQuery Query
)
Managed Extensions for C++ 
public: void Find( 
   DicomScp* Scp,
   FindQuery* Query
) 
C++/CLI 
public:
void Find( 
   DicomScp^ Scp,
   FindQuery^ Query
) 

Parameters

Scp
The peer connection to send the C-FIND-REQ to.
Query
The query information that describes the DICOM datasets to be found.

Example

This example queries a DICOM server and performs a a Study Level C-FIND-REQ.

Visual BasicCopy Code
Public Sub FindStudy()
    DicomEngine.Startup()
    DicomNet.Startup()

    Dim cfindStudy As QueryRetrieveScu = New QueryRetrieveScu()
    Dim query As FindQuery = New FindQuery()
    Dim scp As DicomScp = New DicomScp()

    scp.AETitle = "MI_SERVER"
    scp.Port = 104
    scp.Timeout = 60
    scp.PeerAddress = IPAddress.Parse("10.1.1.96")

    '
    ' Find all studies
    '
    query.QueryLevel = QueryLevel.Study
    AddHandler cfindStudy.BeforeConnect, AddressOf cfindStudy_BeforeConnect
    AddHandler cfindStudy.AfterConnect, AddressOf cfindStudy_AfterConnect
    AddHandler cfindStudy.BeforeCFind, AddressOf cfindStudy_BeforeCFind
    AddHandler cfindStudy.MatchStudy, AddressOf cfindStudy_MatchStudy
    AddHandler cfindStudy.AfterCFind, AddressOf cfindStudy_AfterCFind
    cfindStudy.Find(scp, query)

    cfindStudy = Nothing
    query = Nothing
    scp = Nothing

    DicomNet.Shutdown()
    DicomEngine.Shutdown()
End Sub

Private Sub cfindStudy_BeforeConnect(ByVal sender As Object, ByVal e As BeforeConnectEventArgs)
    Console.WriteLine("Connecting to: " & e.Scp.PeerAddress.ToString())
End Sub

Private Sub cfindStudy_AfterConnect(ByVal sender As Object, ByVal e As AfterConnectEventArgs)
    Console.WriteLine("Connection status: " & e.Error)
End Sub

Private Sub cfindStudy_BeforeCFind(ByVal sender As Object, ByVal e As BeforeCFindEventArgs)
    Console.WriteLine("Before CFind: " & e.QueryLevel.ToString())
    Console.WriteLine("Association supports relational queries: {0}", e.Scp.Relational)
    Console.WriteLine("Association Information")
    Dim i As Integer = 0
    Do While i < e.Scp.Association.PresentationContextCount
        Dim pid As Byte = e.Scp.Association.GetPresentationContextID(i)
        Dim absSyntax As String = e.Scp.Association.GetAbstract(pid)
        Dim result As DicomAssociateAcceptResultType = e.Scp.Association.GetResult(pid)
        Dim uid As DicomUid = DicomUidTable.Instance.Find(absSyntax)

        Console.WriteLine(Constants.vbTab & "PresentationContext ({0})", pid)
        Console.WriteLine(Constants.vbTab + Constants.vbTab & "AbstractSyntax: {0}", absSyntax)
        If Not uid Is Nothing Then
            Console.WriteLine(Constants.vbTab + Constants.vbTab & "Description: {0}", uid.Name)
        End If
        Console.WriteLine(Constants.vbTab + Constants.vbTab & "Result: {0}", result)
        i += 1
    Loop
End Sub

Private Sub cfindStudy_MatchStudy(ByVal sender As Object, ByVal e As MatchEventArgs(Of Study))
    Console.WriteLine("Accession #: " & e.Info.AccessionNumber)
    Console.WriteLine("Admitting Diagnosis Description: " & e.Info.AdmitDiagDescrp)
    If e.Info.Age.HasValue Then
        Console.WriteLine("Age: " & (e.Info.Age.Value.Number.ToString() & e.Info.Age.Value.Reference))
    Else
        Console.WriteLine("Age: " & ("No Age"))
    End If
    Console.WriteLine("Study Date: " & e.Info.Date.Value)
    If (e.Info.Time.HasValue) Then
        Console.WriteLine("Study Time: " & e.Info.Time.ToString())
    End If
    Console.WriteLine("Study Description: " & e.Info.Description)
    Console.WriteLine("Study Id: " & e.Info.Id)
    Console.WriteLine("Study Instance: " & e.Info.InstanceUID)
    If Not e.Info.ModalitiesInStudy Is Nothing Then
        Console.WriteLine("Modalities in Study: " & e.Info.ModalitiesInStudy.ToString())
    End If
    If Not e.Info.NameOfDrsReading Is Nothing Then
        Console.WriteLine("Name of drs reading Study: " & e.Info.NameOfDrsReading.ToString())
    End If
    Console.WriteLine("Number of Related Instances: " & e.Info.NumberOfRelatedInstances)
    Console.WriteLine("Number of Related Series: " & e.Info.NumberofRelatedSeries)
    Console.WriteLine("Referring Dr Name: " & e.Info.ReferringPhysiciansName.Full)
    Console.WriteLine("Patient Size: " & e.Info.Size.Value)
    Console.WriteLine("Patient Weight: " & e.Info.Weight.Value)
    Console.WriteLine("Patient Birth Date: " & e.Info.Patient.BirthDate.Value)
    Console.WriteLine("Patient Comments: " & e.Info.Patient.Comments)
    Console.WriteLine("Patient Id: " & e.Info.Patient.Id)
    Console.WriteLine("Patient Sex: " & e.Info.Patient.Sex)
    Console.WriteLine("Patient Name")
    Console.WriteLine(Constants.vbTab & "Family Name: " & e.Info.Patient.Name.Family)
    Console.WriteLine(Constants.vbTab & "Given Name: " & e.Info.Patient.Name.Given)
    Console.WriteLine(Constants.vbTab & "Middle Name: " & e.Info.Patient.Name.Middle)
    Console.WriteLine(Constants.vbTab & "Name Prefix: " & e.Info.Patient.Name.Prefix)
    Console.WriteLine(Constants.vbTab & "Name Suffix: " & e.Info.Patient.Name.Suffix)
    Console.WriteLine(Constants.vbTab & "Full Name: " & e.Info.Patient.Name.Full)
    Console.WriteLine(Constants.vbTab & "Full Name Dicom Encoded: " & e.Info.Patient.Name.FullDicomEncoded)
    Console.WriteLine("==========================================================" & Constants.vbCrLf)
End Sub

Private Sub cfindStudy_AfterCFind(ByVal sender As Object, ByVal e As AfterCFindEventArgs)
    Debug.Assert(e.Status = DicomCommandStatusType.Success)
End Sub
C#Copy Code
public void FindStudy()
{
    DicomEngine.Startup();
    DicomNet.Startup();

    QueryRetrieveScu findStudy = new QueryRetrieveScu();
    FindQuery query = new FindQuery();
    DicomScp scp = new DicomScp();

    scp.AETitle = "MI_SERVER";
    scp.Port = 104;
    scp.Timeout = 60;
    scp.PeerAddress = IPAddress.Parse("10.1.1.96");

    //
    // Find all studies
    //
    query.QueryLevel = QueryLevel.Study;
    findStudy.BeforeConnect += new BeforeConnectDelegate(findStudy_BeforeConnect);
    findStudy.AfterConnect += new AfterConnectDelegate(findStudy_AfterConnect);
    findStudy.BeforeCFind += new BeforeCFindDelegate(findStudy_BeforeCFind);
    findStudy.MatchStudy += new MatchStudyDelegate(findStudy_MatchStudy);
    findStudy.AfterCFind += new AfterCFindDelegate(findStudy_AfterCFind);
    findStudy.Find(scp, query);

    findStudy = null;
    query = null;
    scp = null;

    DicomNet.Shutdown();
    DicomEngine.Shutdown();
}

void findStudy_BeforeConnect(object sender, BeforeConnectEventArgs e)
{
    Console.WriteLine("Connecting to: " + e.Scp.PeerAddress.ToString());
}

void findStudy_AfterConnect(object sender, AfterConnectEventArgs e)
{
    Console.WriteLine("Connection status: " + e.Error);
}

void findStudy_BeforeCFind(object sender, BeforeCFindEventArgs e)
{
    Console.WriteLine("Before CFind: " + e.QueryLevel.ToString());
    Console.WriteLine("Association supports relational queries: {0}", e.Scp.Relational);
    Console.WriteLine("Association Information");
    for (int i = 0; i < e.Scp.Association.PresentationContextCount; i++)
    {
        byte pid = e.Scp.Association.GetPresentationContextID(i);
        string absSyntax = e.Scp.Association.GetAbstract(pid);
        DicomAssociateAcceptResultType result = e.Scp.Association.GetResult(pid);
        DicomUid uid = DicomUidTable.Instance.Find(absSyntax);

        Console.WriteLine("\tPresentationContext ({0})", pid);
        Console.WriteLine("\t\tAbstractSyntax: {0}", absSyntax);
        if (uid != null)
            Console.WriteLine("\t\tDescription: {0}", uid.Name);
        Console.WriteLine("\t\tResult: {0}", result);
    }
}

void findStudy_MatchStudy(object sender, MatchEventArgs<Study> e)
{
    Console.WriteLine("Accession #: " + e.Info.AccessionNumber);
    Console.WriteLine("Admitting Diagnosis Description: " + e.Info.AdmitDiagDescrp);
    Console.WriteLine("Age: " + (e.Info.Age.HasValue ? e.Info.Age.Value.Number.ToString() + e.Info.Age.Value.Reference : "No Age"));
    Console.WriteLine("Study Date: " + e.Info.Date);
    Console.WriteLine("Study Time: " + e.Info.Time);
    Console.WriteLine("Study Description: " + e.Info.Description);
    Console.WriteLine("Study Id: " + e.Info.Id);
    Console.WriteLine("Study Instance: " + e.Info.InstanceUID);
    if (e.Info.ModalitiesInStudy != null)
        Console.WriteLine("Modalities in Study: " + e.Info.ModalitiesInStudy.ToString());
    if (e.Info.NameOfDrsReading != null)
        Console.WriteLine("Name of drs reading Study: " + e.Info.NameOfDrsReading.ToString());
    Console.WriteLine("Number of Related Instances: " + e.Info.NumberOfRelatedInstances);
    Console.WriteLine("Number of Related Series: " + e.Info.NumberofRelatedSeries);
    Console.WriteLine("Referring Dr Name: " + e.Info.ReferringPhysiciansName.Full);
    Console.WriteLine("Patient Size: " + e.Info.Size);
    Console.WriteLine("Patient Weight: " + e.Info.Weight);
    Console.WriteLine("Patient Birth Date: " + e.Info.Patient.BirthDate);
    Console.WriteLine("Patient Comments: " + e.Info.Patient.Comments);
    Console.WriteLine("Patient Id: " + e.Info.Patient.Id);
    Console.WriteLine("Patient Sex: " + e.Info.Patient.Sex);
    Console.WriteLine("Patient Name");
    Console.WriteLine("\tFamily Name: " + e.Info.Patient.Name.Family);
    Console.WriteLine("\tGiven Name: " + e.Info.Patient.Name.Given);
    Console.WriteLine("\tMiddle Name: " + e.Info.Patient.Name.Middle);
    Console.WriteLine("\tName Prefix: " + e.Info.Patient.Name.Prefix);
    Console.WriteLine("\tName Suffix: " + e.Info.Patient.Name.Suffix);
    Console.WriteLine("\tFull Name: " + e.Info.Patient.Name.Full);
    Console.WriteLine("\tFull Name Dicom Encoded: " + e.Info.Patient.Name.FullDicomEncoded);
    Console.WriteLine("==========================================================\r\n");
}

void findStudy_AfterCFind(object sender, AfterCFindEventArgs e)
{
    Debug.Assert(e.Status == DicomCommandStatusType.Success);
}

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 2000, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7

See Also

Leadtools.Dicom.Scu requires a Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features