updateTemplate is a host callback that lets your EMR (SINA/HIS) hand SofIA whatever the doctor has already written in your own form fields. SofIA merges that content into the extraction template as context, so the generated clinical note integrates what is already documented instead of:
- producing an identical copy on Regenerate, or
- ignoring notes the doctor typed during the consultation.
How it fits into the flow
The SDK pulls your callback at four moments and merges the result into the template it sends to the extraction backend:1
Recording starts
updateTemplate() feeds the live partial extraction — a note can carry context before recording even starts.2
Recording stops
updateTemplate() feeds the background auto-draft.3
Generate clicked
updateTemplate() is pulled again for the generated report.4
Regenerate clicked
updateTemplate() is pulled again so the regenerated note reflects the latest form content.properties.<field>.existingValue, then sent to the extraction backend as generation context. You do not call anything yourself — just assign the function, and the SDK invokes it whenever it needs the freshest content.
The contract
- Keys must match template property ids exactly. Keys that don’t match any property are ignored.
- Empty values are skipped. Empty strings, whitespace-only strings, empty arrays,
null, andundefinedare dropped — that field falls back to normal generation from the transcript alone (no degradation). - The function may be sync or async. Return
null/undefined/{}when there is nothing to contribute. - Return only the fields you have content for — you don’t need to send every key.
Using it
Props reference
What the SDK does with it
- Pull — calls
updateTemplate()(awaiting it if it returns a Promise). - Merge — for each returned key that matches a template property and has non-empty content, injects it as
template.properties.<field>.existingValue. The template you passed is never mutated — a copy is sent. - Anonymize (outbound) — the injected
existingValueis scrubbed with the same real→placeholder map already applied to the transcript, before it leaves for the transcriber (WebSocket) and the extraction LLM (HTTP). You do not need to anonymize anything yourself. - De-anonymize (inbound) — when the model echoes your content back in the result, the SDK restores the real values, so the doctor sees exactly what they wrote — never a placeholder.
properties.<field>.existingValue in the json_schema it receives. No changes to the request payload shape are needed — the content rides inside the template that is already sent.
Anonymization here mirrors the patient data flow: the direct identifiers in
patientdata and the injected existingValue are masked before leaving the browser and restored in the final output.Behavior when there is nothing to add
This path is intentionally safe:updateTemplatenot provided → the SDK behaves exactly as before.- Returns
null/undefined/{}→ nothing is injected; normal generation. - A field is empty or its key doesn’t match a property → that field is skipped; other fields are still used.
Quick checklist
- You pass a
template(JSON Schema) to the SDK. -
updateTemplatereturns an object keyed by template property ids. - Prose fields are strings; array sections are arrays of entries.
- Empty/unknown fields are omitted (or just left empty — the SDK skips them).
- Your backend reads
properties.<field>.existingValuefrom thejson_schema. - (No action needed for PII) — the SDK anonymizes outbound and restores inbound.
Next steps
- Clinical data schemas — the
templatewhose property ids your keys must match - Insertion preview modal — let the doctor curate the generated report before it reaches your app
- Patient data — how contextual data is anonymized