Setting Up a Web Application
This tutorial will guide you through building a simple web application that interacts with the Haste Health FHIR server using our TypeScript SDK. By the end of this tutorial, you'll have a basic web app that can read and display patient data.
Set up the server
- Open the haste health admin application.
- Go to your project, or create one from the system console's Projects tab and click Open console.
- Pick ClientApplication from the sidebar's resource types, then click New ClientApplication.
- On the JSON tab, paste the following, then choose Actions → Create:
{
"resourceType": "ClientApplication",
"name": "Web App",
"grantType": [
"refresh_token",
"authorization_code"
],
"responseTypes": "token",
"redirectUri": [
"http://localhost:5173"
],
"scope": "offline_access openid email profile fhirUser user/*.*"
}
- After saving the Client Application, copy its ID for later use.
- Open Settings from the sidebar and, under FHIR and OIDC Endpoints, click FHIR R4 Base URL to copy it.
- In the same view, the User and Project Context card has your Tenant and Project IDs. Click either value to copy it.
Set up the web application
- Clone the following repository.
- Create a .env file with the following content (filled with values copied from the server setup):
VITE_TENANT_ID=your-tenant-id
VITE_PROJECT_ID=your-project-id
VITE_FHIR_BASE_URL=your-fhir-base-url
VITE_CLIENT_ID=your-client-id
- Run the following commands:
npm install
npm run dev
- Open your browser and navigate to
http://localhost:5173. - You should see a simple web application that allows you to authenticate and view patient data.