Build Bot Applications to Improve Patient Services in Healthcare

There are many ways to improve patient services with technologies today. In this blog post, I will discuss how to build a bot application to provide real-time medication pricing for patients. Applications like this can be used by doctors who may need to let patients know at the point of care how much their prescriptions may cost and furthermore how much their insurance policies may cover, etc.

 

image    image

 

Creating the Bot App

 

Using Visual Studio, I created a bot app that lists a list of medications for a patient, and for a given medication different prices from pharmacies. To keep it simple, I have two medications, Lipitor and Crestor, in the bot app, and use prices publically available at GoodRx from HealthWharehouse, Membership warehouse, Target(CVS), Walmart, Sams Club, CVS Pharmacy, and Walgreens. All data including images is included in the VS solution. So there is no web service call. The source code, tested with Visual Studio 2017, Microsoft Bot Builder SDK, Microsoft Bot Connector, and Bot Framework Channel Emulator, is available at github. To learn how to get started with developing bot applications, check my previous blog.

 

The solution consists of several components as shown below.

Models – Medication and LUISModel. They define data properties. The images are kept in the data folder.

Services - LUISService, MedicationService, PricingService. MedicationService returns list of medications whereas PricingService returns list of prices for a given medication.

Dialogs – MainDialog, ListMedicationDialog, ListPricingDialog. They essentially provide the user interface with the bot app.

MessagesController – The default method (Post). It displays a greeting message, and provides an entry point to the MainDialog.

 

Wire up with Microsoft Cognitive Services – LUIS

 

To help the Bot app understand a user’s input, for example, list medications for a patient, I used LUIS, one of Microsoft Cognitive Services available at luis.ai. I created a LUIS app with two Entities - PatientName, MedicationName, two Intents - ListMedication and GetMedicationPricing, and added a few utterances for each of them.

 

image image

 

And then train and publish the app. The endpoint url is added to the web.config file in Visual Studio solution.

 

image

 

In Visual Studio, I used the GetIntentFromLUIS method to find the matching Intent or action, and then use it to open medication or pricing dialogs from the MainDialog.

 

image   image

 

Publish the Bot app to Azure App Service and Register it

 

After testing the Bot app with the local emulator, I published it to Azure App Service and registered the app at dev.botframework.com. Make a note of the Bot app ID and password.

 

image  image

 

After the successful publication, I enabled Bot Authentication in the MessagesController file, bot app info in the web.config file, and the image urls in the MedicationService. And re-publish the bot app. You can now test the Bot app with the web chat channel.

 

MessageController file

image

 

Web.Config file

image

 

MedicationService file

image

 

Add the Bot app to Skype

 

Normally you’d add bot apps like this one to channels such Skype for Business (available in preview). For testing purposes I used Skype Desktop.

 

From my dev.botframework.com account, I clicked the Skype icon to add the app to my Skype desktop app.

 

image  image

 

The Bot app essentially became a new contact in my Skype desktop app, and I could talk to the Bot just like I would with a real person.

image

 

Connect the Bot app to Cortana

 

To use Cortana in the Bot app, I needed Cortana Skill, which is currently in private preview.

 

High level overview of how users interact with Cortana skills

 

From my private preview account, I configured a skill for the bot app. The process was rather simple. All I had to do was to specify the endpoint, which was a combination of “bot” and the registered Bot app name. From there, you could download the Cortana app on supported devices, for example, Android, log in to the app using the same account where the bot app was registered, and talk to Cortana using the invocation phase you configured, something like “Ask Medication Pricing.” If all configurations were done properly, you’d hear the beautiful Cortana voice and your Bot would start on the mobile device.