Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Health Expense Sample #193

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions samples/health-expense/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Health Expense

## Summary

This sample allows the user to predict their Health Expense using a Machine Learning Model and then get a detailed personalized plan to save for it.

|Starting Screen|Output 1 |Output 2 |
:-------------------------:|:-------------------------:|:-------------------------:
![starting page](assets/startScreen.jpg) | ![output 1](assets/output1.jpg) | ![output 2](assets/output2.jpg)

## Applies to

* [Microsoft Power Apps](https://docs.microsoft.com/powerapps/)

## Compatibility

> Don't worry about this section, we'll take care of it. Unless you really want to...

![Power Apps Source File Pack and Unpack Utility 0.20](https://img.shields.io/badge/Packing%20Tool-0.20-green.svg)
![Premium License](https://img.shields.io/badge/Premium%20License-Not%20Required-green.svg "Premium Power Apps license not required")
![Experimental Features](https://img.shields.io/badge/Experimental%20Features-No-green.svg "Does not rely on experimental features")
![On-Premises Connectors](https://img.shields.io/badge/On--Premises%20Connectors-No-green.svg "Does not use on-premise connectors")
![Custom Connectors](https://img.shields.io/badge/Custom%20Connectors-Not%20Required-green.svg "Does not use custom connectors")

## Authors

Solution|Author(s)
--------|---------
HealthExpense | [Aaryan Arora](https://github.com/aaryan2134), Delhi Technological University

## Version history

Version|Date|Comments
-------|----|--------
1.0|March 25, 2023|Initial release

## Features

This sample allows the user to:

* Predict Health expenses based on various parameters like age, sex, bmi, number of children and whether they are a smoker or not
* Uses a custom built Azure Auto ML model integrated to Power Apps using Power Automate Flow
* Provides a customized plan to save for health expenses based on inputs and the result of the model using Open AI's API

## Prerequisites

You need to get an API key from [OpenAI](https://platform.openai.com/)

## Solution Components

The following solution components are used in this sample:

* HealthExpense (Canvas app)
* Azure Auto ML Flow (Power Automate flow)
* Azure Auto ML Model for predictions

## Data Sources

### Open AI Connector
This connector connects to the Open AI API and uses the information to create a health expense plan. You can add it to the app as follows:

* In the Data tab, click Add data->connectors->OpenAI.
* Next, click on Add a new connection.
* Enter the API key and click Connect.

### Power Automate Flow
Use a Power Automate Flow to pass the input to the model and get the results back.

* The flow uses HTTP to POST the inputs to the Model Endpoint
* It then uses Parse JSON to parse the output
* Finally sends it back to the Power App

A screenshot for the flow:
![starting page](assets/PowerAutomateFlow.jpg)

## Instructions to Deploy your own Azure AutoML Model
* Go to Azure Machine Learning Studio and create a new Workspace
* Select Automated ML and Select +New automated ML job
* Follow the instructions on the screen to add dataset
* After that, configure the job and forecast settings
* Run the experiment
* Once training is completed, select the best model from the results
* Select Deploy
* This process might take a while
* Once deploying is completed, go to the deployed model and copy the end point URL
* This end point URL can be used directly in the Power Automate Flow to connect the model with Power Apps

Check out [this](https://learn.microsoft.com/azure/machine-learning/tutorial-automated-ml-forecast?view=azureml-api-2&wt.mc_id=studentamb_133327) for more detailed instructions.

## Minimal Path to Awesome

* [Download](./solution/HealthExpense.zip) the solution `.zip` from the `solution` folder
* Within **https://make.powerapps.com**, import the `.zip` file via **Solutions** > **Import solution** > **Browse** and select the `.zip` file you just downloaded.
* Select the Data tab
* Connect the app with OpenAI Connector as stated above.
* Add the ML Model flow as stated above.

## Using the Source Code

You can also use the [Power Apps CLI](https://aka.ms/pac/docs) to pack the source code by following these steps::

* Clone the repository to a local drive
* Pack the source files back into `.zip` file:
```bash
pac solution pack --folder pathtosourcefolder --zipfile pathtosolution --processCanvasApps
```
Making sure to replace `pathtosourcefolder` to point to the path to this sample's `sourcecode` folder, and `pathtosolution` to point to the path of this solution's `.zip` file (located under the `solution` folder)
* Within **https://make.powerapps.com**, import the `.zip` file via **Solutions** > **Import solution** > **Browse** and select the `.zip` file you just downloaded.
* Click next.

## Disclaimer

**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

## Help

> Note: don't worry about this section, we'll update the links.

We do not support samples, but we this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.

If you encounter any issues while using this sample, you can [create a new issue](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=YOURSAMPLENAME&authors=@YOURGITHUBUSERNAME&title=YOURSAMPLENAME%20-%20).

For questions regarding this sample, [create a new question](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=YOURSAMPLENAME&authors=@YOURGITHUBUSERNAME&title=YOURSAMPLENAME%20-%20).

Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=YOURSAMPLENAME&authors=@YOURGITHUBUSERNAME&title=YOURSAMPLENAME%20-%20).

## For more information

- [Overview of creating apps in Power Apps](https://docs.microsoft.com/powerapps/maker/)
- [Power Apps canvas apps documentation](https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/)


<img src="https://telemetry.sharepointpnp.com/powerapps-samples/samples/readme-template" />

---
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/health-expense/assets/output1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/health-expense/assets/output2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/health-expense/assets/startScreen.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<CanvasApp xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Name>aaryan_healthexpense_45a52</Name>
<AppVersion>2023-04-10T20:08:57Z</AppVersion>
<Status>Ready</Status>
<CreatedByClientVersion>3.23033.15.0</CreatedByClientVersion>
<MinClientVersion>3.23033.15.0</MinClientVersion>
<Tags>{"primaryDeviceWidth":"1366","primaryDeviceHeight":"768","supportsPortrait":"true","supportsLandscape":"true","primaryFormFactor":"Tablet","publisherVersion":"3.23033.15","minimumRequiredApiVersion":"2.2.0","hasComponent":"false","hasUnlockedComponent":"false","isUnifiedRootApp":"false","sienaVersion":"20230410T200857Z-3.23033.15.0"}</Tags>
<IsCdsUpgraded>0</IsCdsUpgraded>
<GalleryItemId xsi:nil="true"></GalleryItemId>
<BackgroundColor>RGBA(0,176,240,1)</BackgroundColor>
<DisplayName>HealthExpense</DisplayName>
<Description>Used to get a detailed health expense plan</Description>
<CommitMessage xsi:nil="true"></CommitMessage>
<Publisher xsi:nil="true"></Publisher>
<AuthorizationReferences>[]</AuthorizationReferences>
<ConnectionReferences>{"df224940-9fe0-4d88-b9bc-a03f4f98302f":{"id":"/providers/microsoft.powerapps/apis/shared_logicflows","displayName":"Logic flows","iconUri":"https://connectoricons-prod.azureedge.net/releases/v1.0.1615/1.0.1615.3163/logicflows/icon.png","dataSources":["AzureAutoMLFlow"],"dependencies":[],"dependents":[],"parameterHints":{"workflowName":{"value":"e08bc6dc-64b4-4fd2-a4fd-4115693aea07"},"workflowEntityId":{}},"parameterHintsV2":{"workflowName":{"value":"e08bc6dc-64b4-4fd2-a4fd-4115693aea07"},"workflowEntityId":{}},"isOnPremiseConnection":false,"bypassConsent":false,"dataSets":{},"apiTier":"Standard","actions":["Run"]},"73da3206-fcd6-4da3-bda8-3e77fca4aee4":{"id":"/providers/microsoft.powerapps/apis/shared_openaiip","displayName":"OpenAI (Independent Publisher)","iconUri":"https://connectoricons-prod.azureedge.net/releases/v1.0.1618/1.0.1618.3179/openaiip/icon.png","dataSources":["OpenAI(IndependentPublisher)"],"dependencies":[],"dependents":[],"parameterHints":{},"parameterHintsV2":{},"isOnPremiseConnection":false,"bypassConsent":false,"dataSets":{},"apiTier":"Premium","actions":["Completion"]}}</ConnectionReferences>
<DatabaseReferences>{}</DatabaseReferences>
<AppComponents>[]</AppComponents>
<AppComponentDependencies>[]</AppComponentDependencies>
<CanConsumeAppPass>1</CanConsumeAppPass>
<CanvasAppType>0</CanvasAppType>
<BypassConsent>0</BypassConsent>
<AdminControlBypassConsent>0</AdminControlBypassConsent>
<EmbeddedApp xsi:nil="true"></EmbeddedApp>
<IntroducedVersion>1.0</IntroducedVersion>
<CdsDependencies>{"cdsdependencies":[]}</CdsDependencies>
<IsCustomizable>1</IsCustomizable>
<BackgroundImageUri>/CanvasApps/aaryan_healthexpense_45a52_BackgroundImageUri</BackgroundImageUri>
<DocumentUri>/CanvasApps/aaryan_healthexpense_45a52_DocumentUri.msapp</DocumentUri>
</CanvasApp>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"FormatVersion": "0.24",
"Header": {
"DocVersion": "1.330",
"MinVersionToLoad": "1.327",
"MSAppStructureVersion": "2.0"
},
"Properties": {
"AppCreationSource": "AppFromScratch",
"AppDescription": "Used to get a detailed health expense plan",
"AppPreviewFlagsMap": {
"aibuilderserviceenrollment": false,
"allowmultiplescreensincanvaspages": false,
"appinsightserrortracing": false,
"appinstrumentationcorrelationtracing": false,
"autocreateenvironmentvariables": false,
"backfromhostaction": false,
"behaviorpropertyui": false,
"blockmovingcontrol": true,
"cdsdataformatting": false,
"classiccontrols": false,
"consistentreturnschemafortabularfunctions": true,
"copyandmerge": false,
"datatablev2control": true,
"dataverseactionsenabled": false,
"delaycontrolrendering": true,
"delayloadscreens": true,
"disablecdsfileandlargeimage": false,
"dynamicschema": false,
"enableappembeddingux": false,
"enablechatbotfeature": false,
"enablecomponentnamemaps": false,
"enablecomponentscopeoldbehavior": false,
"enablecopilotcontrol": false,
"enableeditcacherefreshfrequency": false,
"enableexcelonlinebusinessv2connector": true,
"enableideaspanel": true,
"enablelegacybarcodescanner": false,
"enableonstart": true,
"enableonstartnavigate": false,
"enablepcfmoderndatasets": true,
"enablepowerautomatepane": true,
"enablerowscopeonetonexpand": false,
"enablerpawarecomponentdependency": true,
"enablerulespanel": false,
"enableruntimepolicies": false,
"enablesaveloadcleardataonweb": false,
"enhanceddelegation": true,
"enhancedgalleryinitialization": true,
"errorhandling": true,
"excelcompatibility": false,
"expandedsavedatasupport": true,
"exportimportcomponents2": true,
"externalmessage": false,
"fluentv9controls": true,
"fluentv9controlspreview": false,
"formuladataprefetch": true,
"formularepair": true,
"generatedebugpublishedapp": false,
"herocontrols": false,
"improvedmediacapture": false,
"improvedtabstopbehavior": false,
"keeprecentscreensloaded": false,
"longlivingcache": false,
"namedformulas": false,
"nativecdsexperimental": true,
"optimizedforteamsmeeting": false,
"packagemodernruntime": false,
"parallelcodegen": false,
"pdffunction": false,
"projectionmapping": true,
"reactformulabar": false,
"reliableconcurrent": true,
"reverttooldpowerautomate": false,
"rtlinstudiopreview": false,
"rtlsupport": false,
"supportcolumnnamesasidentifiers": false,
"tabledoesntwraprecords": true,
"untypedobject": false,
"usedisplaynamemetadata": true,
"useenforcesavedatalimits": true,
"useexperimentalcdsconnector": true,
"useexperimentalsqlconnector": true,
"useguiddatatypes": true,
"usenonblockingonstartrule": true,
"webbarcodescanner": false,
"zeroalltabindexes": false
},
"Author": "",
"ContainsThirdPartyPcfControls": false,
"DefaultConnectedDataSourceMaxGetRowsCount": 500,
"DocumentAppType": "DesktopOrTablet",
"DocumentLayoutHeight": 768,
"DocumentLayoutLockOrientation": false,
"DocumentLayoutMaintainAspectRatio": true,
"DocumentLayoutOrientation": "landscape",
"DocumentLayoutScaleToFit": true,
"DocumentLayoutWidth": 1366,
"DocumentType": "App",
"EnableInstrumentation": false,
"FileID": "f18c2804-9368-454e-ab31-e485ba4272b4",
"Id": "f18c2804-9368-454e-ab31-e485ba4272b4",
"InstrumentationKey": "",
"LocalDatabaseReferences": "{}",
"Name": "HealthExpense",
"OriginatingVersion": "1.330"
},
"PublishInfo": {
"AppName": "HealthExpense",
"BackgroundColor": "RGBA(0,176,240,1)",
"IconColor": "RGBA(255,255,255,1)",
"IconName": "Edit",
"LogoFileName": "",
"PublishDataLocally": false,
"PublishResourcesLocally": false,
"PublishTarget": "player",
"UserLocale": "en-US"
},
"ScreenOrder": [
"Screen1"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"73da3206-fcd6-4da3-bda8-3e77fca4aee4": {
"connectionParameters": {
"sku": "Enterprise"
},
"connectionRef": {
"displayName": "OpenAI (Independent Publisher)",
"iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1618/1.0.1618.3179/openaiip/icon.png",
"id": "/providers/microsoft.powerapps/apis/shared_openaiip"
},
"datasets": {},
"dataSources": [
"OpenAI(IndependentPublisher)"
],
"dependencies": {},
"dependents": [],
"id": "73da3206-fcd6-4da3-bda8-3e77fca4aee4"
},
"df224940-9fe0-4d88-b9bc-a03f4f98302f": {
"connectionParameters": {
"logicAppHostType": "ARM",
"workFlowCallbackUri": "https://prod-76.westus.logic.azure.com:443/workflows/0db86377d2e64edaadabafaf502a9254/triggers/manual/paths/invoke?api-version=2016-06-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=xXjoH8EWw6h6DZoq0JnfNh3y4XJFUHWfE9ZoMi0I1cQ",
"workflowEndpoint": "/subscriptions/775928be-834e-40da-bde6-b48f96905a08/resourceGroups/84c31ca0ac3b4eaead11519d80233e6f-f8687448f66b45609ac69739a4a018f4/providers/Microsoft.Logic/workflows/d235e8d0-30ad-4439-a5cb-d6bc4fca8911",
"workflowName": "d235e8d0-30ad-4439-a5cb-d6bc4fca8911",
"workflowPath": "/subscriptions/775928be-834e-40da-bde6-b48f96905a08/resourceGroups/84c31ca0ac3b4eaead11519d80233e6f-f8687448f66b45609ac69739a4a018f4/providers/Microsoft.Logic/workflows/d235e8d0-30ad-4439-a5cb-d6bc4fca8911"
},
"connectionRef": {
"apiTier": "Standard",
"displayName": "Logic flows",
"iconUri": "https://connectoricons-prod.azureedge.net/releases/v1.0.1615/1.0.1615.3163/logicflows/icon.png",
"id": "/providers/microsoft.powerapps/apis/shared_logicflows",
"parameterHints": {
"workflowEntityId": {},
"workflowName": {
"value": "d235e8d0-30ad-4439-a5cb-d6bc4fca8911"
}
},
"parameterHintsV2": {
"workflowEntityId": {},
"workflowName": {
"value": "d235e8d0-30ad-4439-a5cb-d6bc4fca8911"
}
}
},
"datasets": {},
"dataSources": [
"AzureAutoMLFlow"
],
"dependencies": {},
"dependents": [],
"id": "df224940-9fe0-4d88-b9bc-a03f4f98302f"
}
}
Loading