Skip to content
On this page

EngineAPI Interface Documentation

The EngineAPI interface represents the core interactions developers will have with the Visiontree Fhir Engine. It provides various methods and properties that allow for manipulating and interacting with forms, questionnaires, and their corresponding state.


Overview

EngineAPI serves as the central bridge between your application and the FHIR engine. Through it, developers can manage forms, navigate through them, load FHIR resources, and much more.


Properties

activeForm

typescript
ComputedRef<Form | undefined>

A reference to the currently active form. If no form is active, it returns undefined.


state

typescript
EngineState

Provides the current state of the engine. It encapsulates essential values, including the engine's status and the active form key.


config

typescript
ResolvedEngineConfig

The currently loaded configuration of the engine.


forms

typescript
Map<string, Form>

A map containing all the FHIR Questionnaires that have been loaded and converted to the Form type. The key for this map is the Questionnaire's URL.


Methods

refresh

typescript
(options?: EngineOptions) => Promise<void>

Resets the engine with a provided configuration and plugins. This effectively resets all loaded resources, plugins, and configurations.


loadFhirResource

typescript
(resource: r4.Resource) => EngineAPI

Processes a FHIR Questionnaire or QuestionnaireResponse. Converts Questionnaires to Form and applies QuestionnaireResponses to a Form.


nextForm

typescript
() => EngineAPI

Advances the engine to the next form, if available.


prevForm

typescript
() => EngineAPI

Takes the engine back to the previous form, if available.


setFormIndex

typescript
(index: number) => EngineAPI

Sets the active form based on the provided index.


setAnswer

typescript
(linkId: string, value: unknown) => EngineAPI

Updates the value for a specific question linkId on the active form.


setPrefillAnswer

typescript
(origin: string, linkId: string, value: unknown) => EngineAPI

Sets a prefilled value for a specific question linkId on the active form. The origin represents the data source (e.g., EPIC, CERNER).


save

typescript
(status?: 'in-progress' | 'completed') => Promise<void>

Saves the current form. Generates a QuestionnaireResponse based on the form's current state.


Conclusion

The EngineAPI interface is the backbone for interactions with the Visiontree Fhir Engine. By leveraging its methods and properties, developers can seamlessly integrate, manipulate, and extend the capabilities of the FHIR engine within their applications.