Skip to content

Commit 844d120

Browse files
committed
- readme
- app template - react
0 parents  commit 844d120

32 files changed

+5722
-0
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @getvim/vim-os

.github/workflows/publish.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
on: [push]
2+
3+
jobs:
4+
publish:
5+
runs-on: ubuntu-latest
6+
if: github.ref == 'refs/heads/main'
7+
permissions:
8+
contents: read
9+
deployments: write
10+
name: Publish project to Demo env of Cloudflare Pages
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
15+
- name: Install Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: 20
19+
20+
- name: Install dependencies
21+
run: cd vim--base-app-template--react && npm install
22+
- name: Build react app
23+
run: cd vim--base-app-template--react && npm run build
24+
- name: Publish to Cloudflare Pages
25+
uses: cloudflare/pages-action@v1
26+
with:
27+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
28+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
29+
projectName: vim--base-app-template--react
30+
directory: dist
31+
workingDirectory: vim--base-app-template--react

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.11.1

LICENSE

Lines changed: 124 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Vim Canvas Base App Template
2+
3+
![Cloudflare](https://img.shields.io/badge/Cloudflare-F38020?style=for-the-badge&logo=Cloudflare&logoColor=white) ![TypeScript](https://img.shields.io/badge/typescript-%23007ACC.svg?style=for-the-badge&logo=typescript&logoColor=white)
4+
![Vite](https://img.shields.io/badge/vite-%23646CFF.svg?style=for-the-badge&logo=vite&logoColor=white)
5+
![React](https://img.shields.io/badge/react-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB)
6+
7+
<img src='https://static.getvim.com/img/vim-canvas-landing.png?v=2' width='100%' >
8+
9+
## Quick Links
10+
11+
* [Vim Canvas™️ Developer Platform](https://getvim.com/vim-canvas-developer-platform/)
12+
* [Vim Canvas™️ Docs](https://docs.getvim.com/)
13+
* [VimOS.js Canvas™️ SDK](https://www.npmjs.com/package/vim-os-js-browser)
14+
15+
## What is Vim Canvas™️?
16+
Vim is the middleware platform for healthcare. Vim Canvas™️ is a self-service platform that empowers application developers to embed their application into Electronic Health Record (EHR) workflows, resulting in a streamlined and low-friction experience for end users. With Vim, you can deploy your applications on top of Vim Connect - Vim's in-EHR connectivity layer - accelerating time to market at reduced cost and improved flexibility.
17+
18+
# Repo Overview 😎
19+
20+
This repo contains example template for building applications on top of Vim Canvas™️.
21+
The applications in different frameworks demonstrates how to use the VimOS.js Canvas™️ SDK to interact with the Vim Canvas™️ platform. The app showcases the following features:
22+
23+
* Authentication with Vim Canvas™️
24+
* Embedding an application into the Vim Canvas™️ platform
25+
26+
## Vim Base Template App (React)
27+
28+
Under the `vim--base-app--template` we have a project that uses cloudflare pages to host the Vim Base Template App built with React & also the serverless service needed for the authentication flow.
29+
30+
The app is built with `vite` and `react`.
31+
32+
### Folder Structure
33+
34+
* `functions` - Contains [cloudflare pages functions](https://developers.cloudflare.com/pages/functions/) for the authentication flow.
35+
* `src/components/ui` - Contains UI components generated with [Shadcn](https://ui.shadcn.com/).
36+
* `src/hooks` - Contains custom hooks for the application, including hooks that wrap the VimOS.js Canvas™️ SDK - [following the docs examples](https://docs.getvim.com/vim-os-js/reactjs.html#react-integration-guide-for-vimos.js).
37+
38+
### Running the example code
39+
40+
#### Prerequisites
41+
In order to see the demo code in action, you must first configure an application in the [Vim Canvas™️ Developer Platform](https://console.getvim.com/organization-admin/).
42+
43+
If you don’t have a Vim Canvas™️ developer account yet, register [here](https://getvim.com/vim-canvas-developer-platform/) to gain access.
44+
45+
> **You don't need a cloudflare user / account** to run the app locally.
46+
47+
#### Installation
48+
49+
To install and run the app locally, follow these steps:
50+
51+
1. Clone the repository:
52+
53+
```bash
54+
git clone https://github.com/getvim/vim-canvas-demo-app.git
55+
```
56+
57+
2. Navigate to the project directory:
58+
59+
```bash
60+
cd vim-canvas-demo-app-react
61+
```
62+
63+
3. Install the dependencies:
64+
65+
```bash
66+
npm install
67+
```
68+
69+
4. Create a `.dev.vars` file with the following content:
70+
71+
```.env
72+
CLIENT_ID=<<YOU ACCOUNT CLIENT ID>>
73+
CLIENT_SECRET=<<YOUR ACCOUNT CLIENT SECRET>>
74+
REDIRECT_URL=http://localhost:8788
75+
```
76+
77+
5. Start the development server:
78+
79+
```bash
80+
npm run dev
81+
```
82+
83+
> This will start both the backend at `http://localhost:8788` and the frontend at `http://localhost:3000`. <br>
84+
The backend will proxy the frontend - **making both API & frontend available at `http://localhost:8788`**.
85+
86+
6. Follow up on [Testing Your Application](https://docs.getvim.com/platform/testing.html#testing-your-application) in the official docs
87+
88+
### Authentication Flow
89+
90+
The `functions` folder is a cloudflare pages function that handles the authentication flow for the app.
91+
92+
When running locally the api server starts at `http://localhost:8788` & exposes the following endpoints:
93+
* `/api/launch` - This endpoint is used to initiate the authentication flow.
94+
* `/api/token` - This endpoint is used to handle the callback from the Vim Canvas™️ platform to create a token.
95+
96+
## Settings Application Demo
97+
98+
On top of using VimOS.js to integrate your application's iframe within Vim Connect and display it in the Vim Hub on EHRs, you can also inject an additional optional iframe into the Vim Console. This allows you to create a dedicated Settings Application where organization administrators can customize and configure your main application.
99+
100+
This settings application is implemented under `/settings` route.
101+
102+
[For further information](https://docs.getvim.com/platform/platform.html#app-settings)
103+
104+
# Vim Canvas™️ Pricing
105+
106+
| Starter Access | Patient-Based | User-Based |
107+
| --- | --- | --- |
108+
| **Design and test your application before choosing a plan.** | **Active Member Pricing (AMP) Billed Based on Per Member Per Month (PMPM)** | **Per User Per Month (PUPM)** |
109+
| *Who is this right for?* | *Who is this right for?* | *Who is this right for?* |
110+
| - Access to developer platform<br>- Ability to build application using Vim workflows<br>- Design and testing only. Activation and distribution of application requires a package | - Patient-based pricing model in use or applicable to workflow<br>- Application is enabled based on patient in context in the EHR<br>- Allows for unlimited clinic-level users | - User-based pricing model in use or applicable to application<br>- Application is always available and is not specific to patients<br>- Based on number of users/year for which the application is enabled |
111+
| | Example:<br>A mental health referral solution | Example:<br>An efficiency solution such as a medical documentation tool |
112+
113+
# Contributing
114+
* How can I submit an improvement?
115+
* Improvements are always welcomed! 🥳 Open a PR with a proper description and we'll review it as soon as possible
116+
* Spot a bug 🕷 ?
117+
* We welcome code changes that improve the apps or fix a problem. Please make sure to follow all best practices and open an "Issue" and we'll review it as soon as possible.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
.wrangler
15+
.dev.vars
16+
17+
functions/**/*.js
18+
19+
# Editor directories and files
20+
.vscode/*
21+
!.vscode/extensions.json
22+
.idea
23+
.DS_Store
24+
*.suo
25+
*.ntvs*
26+
*.njsproj
27+
*.sln
28+
*.sw?
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": false,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "src/globals.css",
9+
"baseColor": "slate",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils"
16+
}
17+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import reactRefresh from "eslint-plugin-react-refresh";
5+
import tseslint from "typescript-eslint";
6+
7+
export default tseslint.config(
8+
{ ignores: ["dist"] },
9+
{
10+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11+
files: ["**/*.{ts,tsx}"],
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
globals: globals.browser,
15+
},
16+
plugins: {
17+
"react-hooks": reactHooks,
18+
"react-refresh": reactRefresh,
19+
},
20+
rules: {
21+
...reactHooks.configs.recommended.rules,
22+
"react-refresh/only-export-components": [
23+
"warn",
24+
{ allowConstantExport: true },
25+
],
26+
"@typescript-eslint/no-unused-vars": [
27+
"error",
28+
{
29+
argsIgnorePattern: "^_",
30+
varsIgnorePattern: "^_",
31+
ignoreRestSiblings: true,
32+
},
33+
],
34+
},
35+
}
36+
);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Note
2+
`functions` is a Wrangler - CloudFlare Backend Framework.
3+
- It exposes a File Based Routing
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Env } from "../context-env";
2+
3+
const SETTINGS_LAUNCH_TYPE = "APP_SETTINGS";
4+
5+
/** NOTE: Route is `/api/launch` */
6+
export const onRequestGet: PagesFunction<Env> = async (context) => {
7+
8+
const url = new URL(context.request.url);
9+
const queryParams = url.searchParams;
10+
const launchId = queryParams.get("launch_id");
11+
const launchType = queryParams.get("launch_type");
12+
13+
// Redirect to the settings application page if the launch type is APP_SETTINGS
14+
let redirect_uri = context.env.REDIRECT_URL ?? "http://localhost:8788";
15+
redirect_uri =
16+
launchType === SETTINGS_LAUNCH_TYPE
17+
? `${redirect_uri}/settings`
18+
: redirect_uri;
19+
20+
const redirectUrl = new URL(
21+
context.env.VIM_AUTHORIZE_ENDPOINT ??
22+
"https://api.getvim.com/v1/oauth/authorize"
23+
);
24+
redirectUrl.searchParams.append("launch_id", launchId);
25+
redirectUrl.searchParams.append("client_id", context.env.CLIENT_ID);
26+
redirectUrl.searchParams.append("redirect_uri", redirect_uri);
27+
redirectUrl.searchParams.append("response_type", "code");
28+
return Response.redirect(redirectUrl.toString(), 302);
29+
};

0 commit comments

Comments
 (0)