Click or drag to resize

Person Search

SDK provides the ability to search for people with specified criteria and retrieve their information. In other words it exposes similar functionality as the Person Search screen in the Epic UI except through an api.
Post /api/person_search

This method is used to retrieve person information based on specified criteria. In other words, this method mimics the Epic behaviour of the following screen:

Person Search

Can be accessed via the URI [Your_SDK_Service]/api/person_search.

Request Body

Response

Examples

Get persons by first and last name.

VB
 1' Dim SDK_SERVICE_URI As New Uri("https://Fully_Qualified_Service_Computer_Name/SDK_Service")
 2' Constant DATABASE preset to current database name
 3' Constant AUTHENTICATION_KEY set to current authentication key
 4
 5'This sample will retrieve the existing persons with matching first and last name.  
 6Try
 7  Dim sUrl As String = SDK_SERVICE_URI & "/api/person_search"
 8  Dim dictRequest As New Dictionary(Of String, Object) From {
 9                            {"first_name", "John"},
10                            {"last_name", "Smith"}
11                          }
12
13  Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer
14  Dim sRequestBody As String = jss.Serialize(dictRequest)
15
16  Dim sResponse As String
17  Using oWebclient As New WebClient
18    oWebclient.Encoding = Encoding.UTF8
19    With oWebclient.Headers
20      .Add("AuthenticationKey", AUTHENTICATION_KEY)
21      .Add("DatabaseName", DATABASE)
22      .Add("Content-type", "application/json")
23    End With
24    Dim aResponse As Byte() = oWebclient.UploadData(sUrl, "POST", Encoding.ASCII.GetBytes(sRequestBody))
25    sResponse = oWebclient.Encoding.GetString(aResponse)
26  End Using
27
28  Dim dictPersonSearchResponse As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(sResponse)
29  Dim lstPersons As ArrayList = CType(dictPersonSearchResponse("persons"), ArrayList)
30  For Each dictPerson As Dictionary(Of String, Object) In lstPersons
31    Console.WriteLine("Person Guid: " & dictPerson("first_name").ToString)
32    Dim lstContacts As ArrayList = CType(dictPerson("person_contacts"), ArrayList)
33    For Each dictContact As Dictionary(Of String, Object) In lstContacts
34      Console.WriteLine("Lookup Code: " & dictContact("lookup_code").ToString)
35      Console.WriteLine("Contact Prefix: " & dictContact("prefix").ToString)
36      Dim dictAddress As Dictionary(Of String, Object) = CType(dictContact("address"), Dictionary(Of String, Object))
37      Console.WriteLine("City: " & dictAddress("city").ToString)
38      Console.WriteLine("Street 1: " & dictAddress("street1").ToString)
39    Next
40  Next
41
42Catch ex As WebException
43  Dim sStatusCode As String = ex.Status.ToString
44  Dim sError As String = New IO.StreamReader(ex.Response.GetResponseStream).ReadToEnd
45  Console.WriteLine("Status Code: " & sStatusCode & ", Error: " & sError)
46Catch ex As Exception
47  Console.WriteLine(ex.Message)
48End Try
See Also