🤖🔥FHIR + GPT: Generate Recipes for Patients Based on MedHx and Allergies
![🤖🔥FHIR + GPT: Generate Recipes for Patients Based on MedHx and Allergies](/content/images/size/w960/2024/01/DALL-E-2024-01-15-11.31.30---A-high-tech--modern-kitchen-with-a-large-digital-screen-displaying-the-title--FHIR---GPT_-Generate-Recipes-for-Patients-Based-on-MedHx-and-Allergies-.png)
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](https://www.patient.dev/content/images/2023/08/Screen-Shot-2023-01-12-at-6.54.21-AM.png)
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](https://www.patient.dev/content/images/2023/08/fscreencapture-code-console-cerner-console-register-2023-01-12-06_57_44.png)
Millenium
FHIR R4
![image](https://www.patient.dev/content/images/2023/08/fscreencapture-code-console-cerner-console-register-2023-01-12-06_59_43.png)
Go to Patient Product API to bottom
check AllergyIntolerance read
check Condition read
check Patient read
![image](https://www.patient.dev/content/images/2023/08/fscreencapture-code-console-cerner-console-register-2023-01-12-07_00_39.png)
Agree to TOS
Submit
![image](https://www.patient.dev/content/images/2023/08/fscreencapture-code-console-cerner-console-register-2023-01-12-07_01_18.png)
You have client_id to add to your repl in launch.html
![image](https://www.patient.dev/content/images/2023/08/fScreen-Shot-2023-01-12-at-7.02.39-AM.png)
Change client_id to your one in repl.it
![image](https://www.patient.dev/content/images/2023/08/fScreen-Shot-2023-01-12-at-7.10.17-AM.png)
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](https://www.patient.dev/content/images/2023/08/fScreen-Shot-2023-01-12-at-7.12.26-AM.png)
Click on link and login fredricksmart Cerner01
Login info at https://groups.google.com/g/cerner-fhir-developers > Public Sandbox Test Patient
![image](https://www.patient.dev/content/images/2023/08/fScreen-Shot-2023-01-12-at-7.14.11-AM.png)
![image](https://www.patient.dev/content/images/2023/08/fScreen-Shot-2023-01-12-at-7.15.30-AM.png)
Unknown app > Proceed Anyway … Allow Access
![image](https://www.patient.dev/content/images/2023/08/fScreen-Shot-2023-01-12-at-7.16.24-AM.png)
![image](https://www.patient.dev/content/images/2023/08/fscreencapture-authorization-cerner-tenants-ec2458f2-1e24-41c8-b71b-0e701af7583d-protocols-oauth2-profiles-smart-v1-personas-patient-authorize-2023-01-12-07_16_33.png)
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