This project has moved. For the latest updates, please go here.

 

Using the Client API

With the release of 1.2 of the MEDIC CR, a series of client APIs are published with the CR (see client tools download). This small package contains a series of helper methods combined from a series of other MEDIC projects which our development team has found useful. These client tools allow a developer to connect to the MEDIC CR easily with the following technologies:

  • C# .NET and/or Visual Basic .NET (3.5 or higher)
  • Visual Basic for Applications (VBA) platforms such as:
    • Microsoft Access
    • Microsoft Excel
    • Microsoft Visual Basic 6
    • Microsoft JScript

 

Connecting to the MEDIC CR from VBA

To connect to the MEDIC CR with VBA you will need Microsoft Office 2010 or newer and the Microsoft .NET Framework 3.5 or higher installed. For this tutorial, we’re going to connect the “Northwind traders” (standard Access sample database) to an instance of the MEDIC CR, we’ll modify the employee window to register and search for patients on the MPI.

First, we’ll open the employees window and add a field for Gender, DOB, Health Insurance # and MPI Identifier.

image

 

Next, we’ll add those fields to the employee details window and will add a button to send the user to the EMPI

 

image

 

Next, we will wire up the click event on the register in MPI button. Our procedure is empty, but before we can access the MPI client API a reference to the MEDICEmpiClient control needs to be added. To do that click Tools > References and select MEDICEmpiClient

image

 

All helpers are in the MEDICEmpiClient namespace. The first thing that every application needs is a connection to the MPI, this is done with an EMPIClient object:

 

' First we need to create a client that will connect to the MPI
Dim mpiClient As New MEDICEmpiClient.EmpiClient

 

Next, since we’re registering a patient in the EMPI, we need to create a patient object and populate some of its properties. The EMPIClient will assist you in this with auto-complete

image

 

The collections : “Addresses, Identifiers, and Names” provide shortcut methods for adding/removing items easily. The next task is to map what is in our local database to what is in the MPI patient object:

' Next we need to register the person as a patient so we need a patient object
    Dim mpiPatient As New MEDICEmpiClient.Patient
   
    ' Set the properties of the patient
    mpiPatient.Names.AddBasic Last_Name.Value, First_Name.Value
    mpiPatient.Addresses.AddBasic Country_Region.Value, State_Province.Value, "", City.Value, Address.Value, "", ZIP_Postal_Code.Value
    mpiPatient.Telephone = Home_Phone.Value
    mpiPatient.DateOfBirth = DateOfBirth.Value
   
   
    ' Gender is codified so I have to map it from my string
    If (Gender.Value = "M") Then
        mpiPatient.Gender = GenderType_Male
    ElseIf (Gender.Value = "F") Then
        mpiPatient.Gender = GenderType_Female
    Else
        mpiPatient.Gender = GenderType_None
    End If
   
    ' We also need to tell the MPI what the person's local ID is
    mpiPatient.Identifiers.Add_2 "NORTHWIND", ID.Value
   
    ' We'll pass up the health insurance # too so the MPI Can match
    mpiPatient.Identifiers.Add_2 "GOVT_ELB_HIN", HealthInsuranceNo.Value
   

The next thing we need to do is to tell the MPI what our details are, and we need to connect the MPI client to the actual MPI. To do this we set some properties on the MPI object itself. There is also a chance an error will be thrown, so we need to account for that as well.. If all goes well, we will pull down the MPI identifier and store it locally

' Setup the MPI Connection
mpiClient.Endpoint = "llp://192.168.0.100:8080"
mpiClient.SendingApplication = "NORTHWIND_DB"
mpiClient.SendingFacility = "NORTHWIND_INC"

' Open the connection
mpiClient.Open

' Register the patient
mpiClient.RegisterPatient mpiPatient

' Was that successful?
If (Err <> 0) Then
    MsgBox "Something went wrong:" + Error
Else
    ' Pull down the MPI identifier and store it locally
    MPIId.Value = mpiClient.CrossReferenceQuery(mpiPatient.Identifiers.Item(0), "ENT_ID")
End If

' Close the connection
mpiClient.Close

 

If successful, when we press “Register in MPI” the MPI identifier will be populated.

image

 

This patient will also appear in the client registry administration portal.

 

image

Last edited Mar 4 at 4:27 AM by jf03cg, version 2