3 min read

🤖🔥FHIR + GPT: Generate Recipes for Patients Based on MedHx and Allergies

Can GPT suggest recipes that respects the allergies documented in a patient portal?
🤖🔥FHIR + GPT: Generate Recipes for Patients Based on MedHx and Allergies
💡
Disclaimer

Obviously, this is health information and you need better security (HIPAA/BAA/all that good stuff). This is meant to just show possibilities.

“Paths are made by walking them”

MSFT apparently has HIPAA APIs in Azure coming (https://azure.microsoft.com/en-us/blog/general-availability-of-azure-openai-service-expands-access-to-large-advanced-ai-models-with-added-enterprise-benefits/)

How to build a FHIR to GPT3 app

Create and host an app somewhere (repl)

Register a FHIR app

Have some way to connect to OpenAI (lambda in this case)

Login as a patient

Render

Create and host an app

You can just fork mine at https://replit.com/@patientDev/GPT3-FHIR#index.html

image

Register the app (Cerner in this case)

https://code-console.cerner.com/

Add Name

Change to Patient

Select “Online”

Select Public

Add redirect (which is your repl url + “/app.html” — don’t use my repl.it or it won’t work right)

image

Millenium

FHIR R4

image

Go to Patient Product API to bottom

check AllergyIntolerance read

check Condition read

check Patient read

image

Agree to TOS

Submit

image

You have client_id to add to your repl in launch.html

image

Change client_id to your one in repl.it

image

Also copy your repl url to “redirect_url” but keep the app.html (ie this is the redirect url you registered above, not the redirect of my repl)

OpenAI

You can get API key here … https://beta.openai.com/account/api-keys

You can’t put OpenAI API key in your front end code, I put it in a lambda with functions url, no IAM, CORS … I will change the API key after the meetup so it won’t work. But code for lambda is linked at https://patient.dev/simple-lambda-for-openai/

Use It

Launch with little arrow coming out of box

image

Click on link and login fredricksmart Cerner01

Login info at https://groups.google.com/g/cerner-fhir-developers > Public Sandbox Test Patient

image
image

Unknown app > Proceed Anyway … Allow Access

image
image

Try out

Try in “Freetext”

Give me a recipe for peanut butter for someone who is allergic to nuts

Make a recipe for jam for someone who is diabetic.

Make a recipe for jam for someone who is allergic to blueberries.

Make a recipe for peanut butter for someone who is allergic to nuts.

Make a recipe for salad for someone who takes the medication warfarin. (FAIL)

Give me a recipe for grapefruit juice for someone with the following allergies: chocolate and who is on the following medications: atorvastatin