Skip to main content
These properties allow you to customize the behavior and appearance of the SofIA SDK component to fit the specific needs of your implementation.

Active Properties

Interface Control

PropertyTypeDefault ValueDescription
isopenbooleantrueComponent visibility state, allows bidirectional control of the open/closed state. When not provided, the component starts open by default

Callbacks

PropertyTypeDescription
handleReportfunctionCallback function that receives the structured clinical report generated by SofIA. Also available as handle-report attribute. Can be referenced as a global function name
setIsOpenfunctionCallback function to handle visibility changes requested by the component
setGetLastReportfunctionA callback that receives a function to retrieve the last generated report

Callback Signatures

handleReport
handleReport: (report: Record<string, unknown>) => void
Called when the user triggers report generation. The report object matches the structure defined in your template JSON Schema. Example payload:
{
  "diagnosis": "Type 2 Diabetes Mellitus",
  "treatment_plan": "Metformin 500mg twice daily"
}
setIsOpen
setIsOpen: (isOpen: boolean) => void
Called when the SDK requests a visibility change (e.g., user clicks the close button). setGetLastReport
setGetLastReport: (getter: () => Promise<Record<string, unknown> | undefined>) => void
Called once during initialization. Provides a function you can store and call later to retrieve the last generated report for the current patient/user session.

Contextual Data

PropertyTypeDefault ValueDescription
patientdatastring (JSON) | objectundefinedContextual patient information (background, previous notes, referrals) to enrich clinical processing
PropertyTypeDefault ValueDescription
showconsentindicatorbooleanfalseShow the consent status indicator in the header. Works with the signedConsent field in patientdata

Localization

PropertyTypeDefault ValueDescription
languagestring"es"Interface language. Supported values: "es" (Spanish), "en" (English)
The default language is "es" (Spanish). If your application targets English-speaking users, set language="en" explicitly.

Debugging

PropertyTypeDefault ValueDescription
debugbooleanfalseEnables detailed logging for debugging purposes

Manual Report Retrieval

In addition to receiving the report automatically, you can request it on-demand from your application. The set-get-last-report property executes a callback that provides you with an asynchronous function. You should store this reference to use it whenever you need to retrieve the last generated report.
let getLastReportFn = null;

// Callback assigned to: set-get-last-report
function registerGetter(fn) {
  getLastReportFn = fn;
}

// Example of use in an external button
async function handleSaveClick() {
  if (getLastReportFn) {
    const report = await getLastReportFn();
    console.log("Report retrieved:", report);
  }
}

Usage Examples

Basic setup with patient data

<sofia-sdk
  patientdata='{"age": 45, "history": "Arterial hypertension"}'
  language="es"
  baseurl="https://api.example.com/v1"
  wssurl="wss://ws.example.com"
  apikey="sk-your-api-key-here"
  userid="user_12345"
  patientid="patient_67890"
  template='{"type": "object"}'
  templateid="soap-general-v1"
  isopen="true"
  handleReport="handleReport"
  setIsOpen="setIsOpen"
>
</sofia-sdk>

Chat-only mode (no report generation)

To use SofIA in chat-only mode, simply omit the template and templateid properties. The generate button will not appear.
<sofia-sdk
  baseurl="https://api.example.com/v1"
  wssurl="wss://ws.example.com"
  apikey="sk-your-api-key-here"
  userid="user_12345"
  patientid="patient_67890"
  language="es"
>
</sofia-sdk>

Advanced configuration with callbacks

<sofia-sdk
  setGetLastReport="setGetReportFunction"
  handleReport="handleReport"
  debug="true"
  baseurl="https://api.example.com/v1"
  wssurl="wss://ws.example.com"
  apikey="sk-your-api-key-here"
  userid="user_12345"
  patientid="patient_67890"
>
</sofia-sdk>
Naming convention for callbacks: When assigning callbacks via JavaScript, use camelCase (e.g., element.handleReport = fn). In HTML attributes, handle-report is also supported as an alias. Simple properties like isopen, patientdata, and debug use the same lowercase name in both HTML and JS.
HTML attributeJS propertyNotes
handle-report or handleReporthandleReportBoth forms work as HTML attribute
setIsOpensetIsOpenUse camelCase in HTML
setGetLastReportsetGetLastReportUse camelCase in HTML
patientdatapatientdataSame in both
isopenisopenSame in both
debugdebugSame in both

Deprecated Properties

The following properties are deprecated and will be removed in v2.0. They have no effect in the current Chat-based UI architecture.
PropertyMigration
toolsargsRenamed to template. See Required Properties
isonlychatNo longer needed. Chat-only mode is automatic when template/templateid are not provided
disableactionsTo disable all actions, do not mount the <sofia-sdk> component
disablegenerateTo hide the generate button, do not pass template/templateid
sofiatitleNo longer configurable. The title is always “SofIA”
isscreenloadingNot available in Chat-based UI
transcriptorselectvaluesNot used in Chat-based UI
render-report-contentNot available in Chat-based UI
handleFillNot available in Chat-based UI
toastNo longer has effect

Important Notes

  • patientdata: Should only contain information necessary for the clinical context, following data minimization principles.
  • States: Changes in boolean properties are immediately reflected in the interface.
  • Localization: Changing the language affects the entire component interface, including error messages and labels.
  • Callbacks: Functions can be referenced by their global name (e.g., handleReport="myFunction" resolves to window.myFunction) or assigned programmatically (e.g., element.handleReport = fn).