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
ComputedRef<Form | undefined>A reference to the currently active form. If no form is active, it returns undefined.
state
EngineStateProvides the current state of the engine. It encapsulates essential values, including the engine's status and the active form key.
config
ResolvedEngineConfigThe currently loaded configuration of the engine.
forms
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
(options?: EngineOptions) => Promise<void>Resets the engine with a provided configuration and plugins. This effectively resets all loaded resources, plugins, and configurations.
loadFhirResource
(resource: r4.Resource) => EngineAPIProcesses a FHIR Questionnaire or QuestionnaireResponse. Converts Questionnaires to Form and applies QuestionnaireResponses to a Form.
nextForm
() => EngineAPIAdvances the engine to the next form, if available.
prevForm
() => EngineAPITakes the engine back to the previous form, if available.
setFormIndex
(index: number) => EngineAPISets the active form based on the provided index.
setAnswer
(linkId: string, value: unknown) => EngineAPIUpdates the value for a specific question linkId on the active form.
setPrefillAnswer
(origin: string, linkId: string, value: unknown) => EngineAPISets a prefilled value for a specific question linkId on the active form. The origin represents the data source (e.g., EPIC, CERNER).
save
(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.