The scenario: assistance arrives after a clinician has started writing
A consultation editor can contain a mixture of clinician-authored text and still-empty fields when an AI suggestion arrives. Replacing the whole form would turn assistance into an overwrite operation. Appending every generated explanation to the treatment or notes would create a different problem: material intended for review could enter fields with another audience and purpose.
The inspected Movo-X helper gives these inputs separate destinations. It fills selected empty draft fields, preserves populated values and composes a separate AI-assistance text field for saving. Four isolated cases examine that transformation and serialization boundary, with synthetic text and no provider call.
Define empty by trimmed content while preserving populated text exactly
The helper checks whether presenting illness, examination, diagnosis and treatment contain non-whitespace content. A populated field is returned as typed, including its existing formatting. A whitespace-only field can receive the corresponding suggested value after trimming and bounding that suggestion.
The supplemental case checks all four populated fields, the chief complaint and notes for exact preservation. It then supplies whitespace-only values and verifies replacement with the intended suggestion. This is more precise than saying the helper never changes the form: changing selected empty fields is its purpose. The important boundary is preservation of an existing substantive draft.
Keep existing state in the update that applies the suggestion
The reviewed editor invokes the helper through a functional state update. That supplies the form state available when the update is applied, rather than unconditionally replacing it with an earlier captured form object. The helper returns a new form object with the selected changes.
This source pattern supports a clear merge policy, but the pure helper tests do not simulate every React scheduling or interaction sequence. A rendered editor acceptance test should include typing while a suggestion is pending, a second suggestion and deliberate clearing of a field. Those interactions determine what a user actually experiences around the transformation.
Treat a filled draft as material requiring review
The editor maps suggested history, examination, diagnosis, plan and codes into the helper and shows a review instruction after applying the draft. The source also exposes an action to use the retained suggestion again; populated fields remain protected by the same helper rule.
Prefill is not evidence that a finding was observed or that a proposed diagnosis is established. The inspected transformation does not validate clinical correctness or independently confirm an examination. Product acceptance needs to make draft status and review responsibility clear wherever generated material can reach a consequential record field.
Separate safety commentary from the normal plan and notes
The suggestion object contains reasoning, diagnosis, treatment plan and safety notes. The draft helper uses the diagnosis and plan for their selected empty fields, while leaving the notes exactly as supplied. It does not append the separate safety-notes string to either treatment or notes.
The existing fixture checks that separation and preserves a clinician note. The save helper then emits the normal form values alongside a separate aiAssist field. That is an explicit request-body distinction. It should not be promoted into a claim that every downstream API, export, print view or permission boundary has been audited.
Compose provenance text within its actual shared budget
The separate AI text uses labelled sections in a fixed order: reasoning, diagnosis, treatment plan and safety notes. Individual text values are bounded, then the joined block is truncated to a final twelve-thousand-unit JavaScript string budget. The source does not reserve an independent guaranteed share for each section.
The supplemental long-reasoning case reaches the final budget before the later safety section appears. Its overflow does not get appended to the ordinary plan or notes. Consequently, the saved block is bounded assistance text, not guaranteed complete retention of the provider response. If complete provenance is required, a separately specified retention design is needed.
Distinguish existing-code preservation from universal deduplication
The helper retains the form’s existing code entries and filters suggested additions against the set of codes already present. The existing fixture checks that an existing code is not added again and a new code can be appended. It does not overwrite an existing code description with the suggested description.
That selected behaviour is narrower than a universal uniqueness guarantee for every possible incoming suggestion array. Code validation, duplicate suggestions within one generated response and clinical coding correctness need explicit policy and coverage. A passing merge example should not silently establish those additional requirements.
Trace the save call without inventing endpoint acceptance
The reviewed Queue editor spreads the helper’s fields into its consultation-save request along with record identity, version and status inputs. The AI suggestion remains available for the separate saved assistance field after the user applies it. The source also retains entered data when a save reports failure.
This chapter reviews those call sites and executes the pure helpers. It does not send that request to a real endpoint, query the resulting database row or verify patient-facing output. Current authorization, version-conflict handling, persistence and audience-specific rendering remain separate integration boundaries with their own evidence needs.
A practical acceptance package for assisted editing
Keep a compact fixture set for populated fields, whitespace-only fields, exact notes, repeated suggestion application, code additions and long assistance text. Add rendered interaction and endpoint tests around those deterministic helpers. Where material has different audiences, verify the actual persisted and rendered representations instead of relying on field names or comments.
For a CTO, the design makes the draft merge and save destinations understandable. The pinned source and four scoped cases establish selected preservation, prefill and bounded serialization behaviour. They provide a concrete foundation for reviewing the product without claiming clinical quality, complete provenance retention or production acceptance from helper tests alone.
Compare the reviewed boundaries
Different responsibilities in assisted consultation editing
On smaller screens, scroll across to compare every column. Keyboard users can focus the table and use the arrow keys.
| Responsibility | Observed boundary | Separate acceptance |
|---|---|---|
| Draft merge | Selected empty fields fill; substantive text stays exact | Rendered pending-response interactions |
| AI commentary | Separate assistance field in save payload | Actual storage and audience-specific output |
| Text budget | Fixed-order block with a shared final limit | Complete provenance retention policy |
| Clinical review | Draft review instruction in editor source | Professional review and clinical correctness |
Illustrative control flow
Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.
current = latest_editor_form()
draft = fill_selected_empty_fields(current, suggestion)
assert_existing_substantive_fields_preserved(current, draft)
payload = serialize_form_and_separate_bounded_ai_text(draft, suggestion)
# Prefill is a draft transformation; it is not clinical confirmation.About this engineering series
Written by Omer Muneer Qazi from a review of Movo-X implementation and dated engineering records. This article explains source behaviour and historical observations; current production, clinical outcomes and store availability require their own verification. Examples are synthetic and proposed test cases are identified as such.
Explore the Movo-X engineering series → · Related implementation experience →
Discuss a similar engineering problem
Send the workflow, current platform and the decision your team needs to make. I can help define an implementation or review scope with concrete acceptance evidence.
Discuss your project on WhatsApp ↗