Business · Product · Technology · AI

Adapt legacy patient edits without replacing canonical identity

A Movo-X compatibility case tracing older field aliases, stored record identity, partial profile candidates, null/empty semantics and independent database version/access checks.

Work directly with Omer Muneer Qazi · Reviewed 29 November 2026

The scenario: an older edit shape reaches a canonical record

A mature application can have older screens whose field names differ from the current database model. A partial note edit should not accidentally replace a stored identity with missing values, while a compatibility layer must still distinguish omission, an intentional clear and an invalid write. Translating names is only one part of that contract.

The pinned Movo-X patient adapter constructs a canonical update candidate from a submitted legacy body and a supplied current record. Two existing and two supplemental TypeScript cases passed using invented objects. Selected route and database definitions were inspected separately; no real patient edit or database transaction occurred.

Anchor the candidate to the record selected by the route

The adapter obtains the candidate identifier from the supplied stored record rather than an id in the edit body. Existing and supplemental cases check that selected body tenant/facility values are absent from its output. Another supplemental input supplies an invented conflicting identifier and still receives the stored identifier.

The route source first retrieves the existing row using its selected tenant, facility and path identifier. That lookup placement was reviewed without execution here. The helper’s output shape does not prove that the lookup was authorized, nor that every related API prevents cross-clinic access. Scope selection and current permission remain server responsibilities.

Map the legacy vocabulary deliberately

The selected compatibility mapping translates named inputs such as gender, phone_1, ic_number and street_1 into canonical fields. It also uses a selected metadata identity-type value when supplied and maps a legacy drug-allergy string into a profile field. The existing alias case checks representative outputs from that mapping.

This is not a generic object patch that accepts every canonical-looking body key. The supplemental fixture shows that an arbitrary sex key does not override the stored value through this legacy adapter. Mapping the name of a clinically sensitive field also does not establish that its free-text content has been clinically reviewed or reconciled with another record model.

Preserve omission without confusing null and empty

For selected canonical fields, the adapter’s nullish fallback retains a supplied stored value when the corresponding body value is absent or null. A supplemental case checks that behaviour for name, date and phone. The same case supplies explicit empty strings and observes an empty candidate field instead.

Those observations describe candidate construction, not approval of every blank. The inspected core command has its own patient-detail validation, including refusal of a blank name. A caller therefore cannot infer that because the adapter can represent an empty field, every downstream write should accept it. A compatibility handover needs a field-by-field clear/retain contract.

Treat profile updates as selected patches with their own semantics

The profile object includes selected keys that are actually present in the legacy body. A present null value for a selected profile string becomes an empty string in the candidate. The helper does not copy every old profile property into that new object, and its supplemental case leaves the original body and record unchanged.

Selected profile SQL defines a top-level JSON merge after its validation and command handling. That is source-reviewed behaviour, not an executed persistence result here. Nested metadata is not deeply merged by this helper; a provided metadata object becomes that selected profile value. Do not promise preservation of every omitted nested property without testing the authoritative merge policy.

Carry the client version as a precondition rather than proof

The adapter forwards the selected body version, not a replacement version copied from the freshly read row. The supplemental case checks that distinction. A compatibility read before a write must not silently waive a stale-client condition merely because the server can obtain a newer record.

The inspected core command compares the expected version with a locked row before updating and increments the stored version on acceptance. Those SQL branches were not run. The local adapter case does not establish actual conflict detection, lock behaviour, retry safety or the correctness of an installed migration chain.

Retain independent command authorization and request identity

Selected command definitions check clinical access and request shape, acquire a scoped transaction lock and recheck access after that lock. They also define behaviour for a repeated request identity and changed input. A later selected wrapper adds profile validation and rejects editing an archived record.

These are historical source definitions at the pinned revision, not a complete audit of every later wrapper or current installed function. A valid adapter candidate still depends on current membership, facility state, command permission and the authoritative version decision. None of the four pure cases exercises an actual staff session or proves full command isolation.

Review the legacy route as a compatibility port

The selected API branch dispatches the candidate under the patient-update action after its scoped lookup. It does not submit arbitrary body fields as a replacement for route-owned scope. Other operations in that route have their own input construction and are not covered by these adapter cases.

A useful acceptance set includes missing and archived rows, denied staff, stale versions, duplicate request identity, explicit clear values and nested profile changes. Exercise them through the real route and isolated database before assuming that matching a few field names proves every legacy edit remains compatible.

A reviewable canonical-record migration package

Keep the existing partial-edit/alias cases and supplemental null/empty, identity-anchor, version and no-mutation assertions. Add authoritative transaction fixtures and controlled UI journeys with synthetic records. Document which fields are retained, cleared, translated, rejected and merged at each layer.

For a CTO modernizing an established medical application, the deliverable is a clear compatibility boundary rather than another independent patient model. The selected local cases make candidate construction inspectable. They leave current installed definitions, actual staff permission, durable merge semantics and clinical record correctness to their own acceptance evidence.

Compare the reviewed boundaries

Independent responsibilities in a legacy patient edit

On smaller screens, scroll across to compare every column. Keyboard users can focus the table and use the arrow keys.

BoundarySelected evidenceSeparate acceptance
Record selectionStored id used; body scope omittedAuthorized route lookup
Field translationSelected aliases and null/empty casesFinal patient-detail validation
Profile mergeHelper patch shape and SQL sourceNested/durable merge acceptance
ConcurrencyForwarded client versionLocked-row comparison and replay handling

Illustrative control flow

Pseudocode summarizing the decision boundary. It is not copied production code or a deployment instruction.

old = retrieve_authorized_current_record(route_scope, path_id)
candidate = map_legacy_fields_using_stored_identity(body, old)
candidate.version = submitted_expected_version
result = execute_current_authorized_command(candidate)
# Constructing a candidate does not satisfy permission or version preconditions.

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 ↗
WhatsApp Omer about this project ↗