Posos Widgets JavaScript SDK
    Preparing search index...

    Class AnalysisWidget

    Class representing an analysis widget.

    Hierarchy

    • Widget<typeof ANALYSIS_EVENTS>
      • AnalysisWidget
    Index

    Constructors

    • Creates an instance of AnalysisWidget.

      Parameters

      • container: Element | null

        The DOM element where the widget will be injected.

      • options: WidgetOptions

        The options of the widget.

        • OptionalauthToken?: string

          The authentication token (JWT) for the widget.

        • OptionalbaseUrl?: string

          The base URL of the widget.

        • Optionaldebug?: boolean

          Whether to enable debug mode.

          false
          
        • Optionalenv?: "preprod" | "production"

          The widget environment.

          "production"
          

          This option has no effect if baseUrl is set.

        • OptionalframeHeight?: number

          The height of the widget’s iframe (in pixels).

          768
          

          The minimum accepted height is 768.

        • OptionalframeWidth?: number

          The width of the widget’s iframe (in pixels).

          600
          

          The minimum accepted width is 600.

        • Optionallocale?: string

          The language for the user interface of the widget.

          "fr"
          
        • OptionalsigningKey?: string

          The base64-encoded signing key using the ES256 algorithm.

          Please use the new authentication flow with authToken. Check out the documentation for more information.

        • OptionalsoftwareId?: string

          The software identifier making the widget call.

          Please use the new authentication flow with authToken. Check out the documentation for more information.

        • Optionaltheme?: string

          The widget’s user interface theme.

          "posos"
          
        • OptionaluserId?: string

          The identifier of the user making the widget call.

          Please use the new authentication flow with authToken. Check out the documentation for more information.

      Returns AnalysisWidget

      const container = document.getElementById("posos-widget");
      const widget = new AnalysisWidget(container, {
      authToken: "your-auth-token",
      });

    Methods

    • Trigger a new analysis with the provided payload.

      Parameters

      • payload: AnalysisRequest

        The data required for the analysis containing a drug list and a patient profile.

      Returns void

      widget.analyze({
      drugs: [
      {
      coding: {
      code: "60234100",
      terminology: "cis",
      },
      type: "branded_drug",
      },
      {
      coding: {
      code: "67346461",
      terminology: "cis",
      },
      type: "branded_drug",
      },
      {
      coding: {
      code: "61547468",
      terminology: "cis",
      },
      type: "branded_drug",
      },
      ],
      patientProfile: {
      allergies: [
      {
      coding: {
      code: "47703008",
      terminology: "snomed",
      },
      },
      ],
      birthDate: "1983-11-22",
      concurrentTreatments: [
      {
      coding: {
      code: "MV00001487",
      terminology: "posos",
      },
      },
      ],
      conditions: [
      {
      coding: {
      code: "186963008",
      terminology: "snomed",
      },
      isLongTermIllness: false,
      modifiers: [],
      },
      ],
      gfr: 110,
      height: 185,
      sex: "male",
      weight: 81,
      },
      });
    • Destroys the widget instance by cleaning up resources and performing necessary teardown operations.

      This method should be called when the widget is no longer needed to ensure proper cleanup and avoid memory leaks.

      Returns void

      widget.destroy();
      
    • Registers a callback to handle authentication token refresh requests.

      This function is invoked when the widget detects that a new token is needed, for example when the current token is about to expire or has expired.

      Parameters

      • refreshAuthToken: () => string | Promise<string>

        A function that returns a fresh authentication token.

      Returns void

      • If the invoked function does not return a valid authentication token.
      widget.onAuthTokenRefresh(async () => {
      // Fetch a new auth token from your server
      const newAuthToken = await fetchNewAuthToken();

      return newAuthToken;
      });
    • Reloads the current widget.

      Returns void

      Throws an error if the widget is not accessible.

      widget.reload();
      
    • Updates the authentication token in the widget.

      Parameters

      • authToken: string

        The new authentication token to be set.

      Returns void

      • If the given authentication token is invalid.
      widget.setAuthToken('new-auth-token');