Flexpa Documentation

website·Indexed 34 days ago

https://www.flexpa.com/docs

A healthcare data platform providing patient-consented health insurance claims, plan details, and medical records.

Tokens
682
Snippets
4
Records
5
Agent score
21%

What's inside Flexpa

  1. Understand Flexpa Core Concepts and Integration Flow

    Flexpa is a healthcare data platform that provides patient-consented health insurance claims, plan details, and medical records via FHIR R4 compliant APIs. It consists of three main components:

    1. Network: A directory of payer FHIR endpoints in the US for accessing health plans and insurers.
    2. Consent (Flexpa Link): A secure, embeddable SDK used to obtain patient consent for data access.
    3. Records (Flexpa API): A FHIR R4 compliant REST API used to retrieve standardized health records.

    The typical integration flow is: Patient consents via Flexpa Link $\rightarrow$ Exchange public token for access token $\rightarrow$ Query FHIR API for health records.

  2. Exchange Authorization Code for Access Token

    After the patient completes the OAuth flow, use the authorization code and the previously generated code verifier to obtain an access token via the Flexpa Node SDK.
    // Server-side example (e.g., in your callback handler)
    const client = await FlexpaClient.fromAuthorizationCode(
      code,
      codeVerifier,
      redirectUri,
      publishableKey
    );
    
    const accessToken = client.getAccessToken();
  3. Initiate OAuth Flow with Flexpa Link

    To start the patient consent process, generate a code verifier and challenge, then build the authorization URL using the Flexpa Node SDK. The user is then redirected to this URL to provide consent.
    import FlexpaClient from '@flexpa/node-sdk';
    
    // Client-side (browser) example
    (async () => {
      const codeVerifier = await FlexpaClient.generateCodeVerifier();
      const codeChallenge = await FlexpaClient.generateCodeChallenge(codeVerifier);
    
      const authUrl = FlexpaClient.buildAuthorizationUrl({
        publishableKey: 'pk_test_...',
        redirectUri: 'https://yourapp.com/callback',
        codeChallenge,
        externalId: 'user-123',
      });
    
      window.location.href = authUrl;
    })();
  4. Extract Data using ViewDefinition

    You can extract specific data by sending a POST request to the ViewDefinition/$run endpoint. The request body must be a FHIR Parameters resource containing the viewResource (the ViewDefinition).
    const response = await fetch('https://api.flexpa.com/fhir/ViewDefinition/$run', {
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${accessToken}`,
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        resourceType: 'Parameters',
        parameter: [{ name: 'viewResource', resource: viewDefinition }]
      })
    });
  5. Fetch Patient Health Records via FHIR API

    Use a bearer token to initialize the Flexpa client and retrieve health data. You can fetch all available data using the $everything endpoint or search for specific FHIR resources like ExplanationOfBenefit (claims).
    const client = FlexpaClient.fromBearerToken(accessToken);
    const everything = await client.$everything();
    const claims = await client.search('ExplanationOfBenefit');