fix(labs): let a marker without a unit be edited

A marker minted from a text result (OCR, CSV import, inbound document)
stores an empty unit: none has been chosen yet, and its first numeric
reading sets it. The editor read that empty unit as a unit still to be
typed and refused to save, ticking "No unit" sent "1", and the update
route refused any unit change on a marker with readings. Every save of
such a marker failed, a plain rename included, because the form always
sent the unit.

- The form opens an empty unit with "No unit" ticked and sends the unit
  only when it changed; the empty unit and the unity count as the same
  "no unit" there, so a rename leaves the stored unit as it is.
- PUT /api/biomarkers/{id} locks the unit only on a real change while
  numeric readings exist (deleted ones included). Another spelling of
  the stored unit is no change, and text results carry no number the
  unit could misstate, so a text-only marker may take any unit.
- The empty unit stays distinct from "1": it still adopts the unit of
  its first number, which "1" must not. No stored value changes.

Refs #1393
This commit is contained in:
Marc-André Bombeck committed 2026-11-15 23:32:18 +01:00
1 parent 78c2601e2d
commit 31253ff615
11 files changed
+289 -28

No files matched your search

+17 -11
View File
@@ -17803,9 +17803,11 @@ paths:
v1.43 `aliases` (0..50, each 1..120 characters) replaces the marker's set of other spellings: listed spellings
stay or are added, unlisted ones are removed; omitting the field leaves them as they are. Audits as
`biomarker.update`. Since v1.40.0 a `unit` different from the stored one is refused with 422
`biomarkers.unit.locked` while any reading is linked to the marker (`meta.readingCount` carries how many):
readers label every linked reading with the marker's unit, so a change would relabel stored numbers without
converting them. Sending the current unit, or changing it on a marker with no readings, is accepted."
`biomarkers.unit.locked` while a numeric reading is linked to the marker, a deleted one included
(`meta.readingCount` carries how many): readers label every linked number with the marker's unit, so a change
would relabel stored numbers without converting them. Sending the current unit or another spelling of it
(`mg/dl` for `mg/dL`), or changing it on a marker whose readings are all text or that has none, is accepted. A
marker minted from a text result has an empty unit, so any unit may be set on it."
parameters:
- in: path
name: id
@@ -78491,11 +78493,13 @@ components:
type: string
unit:
type: string
description: 'The unit the value is in, free-form as the report prints it (e.g. `mg/dL`). `"1"`, the UCUM unity, means
description: "The unit the value is in, free-form as the report prints it (e.g. `mg/dL`). `\"1\"`, the UCUM unity, means
the value has no unit: a ratio or an index such as INR or cholesterol/HDL. It is an explicit choice and a
unit of its own: it matches only `"1"`, so a reading without a unit is refused under a marker kept in a real
unit and the other way round. Clients show nothing beside such a value. An empty unit on a numeric value is
never read as `"1"` and stays refused.'
unit of its own: it matches only `\"1\"`, so a reading without a unit is refused under a marker kept in a
real unit and the other way round. Clients show nothing beside such a value. An empty unit on a numeric
value is never read as `\"1\"` and stays refused. On a marker, an empty unit means none has been chosen yet:
the marker was minted from a text result, and its first numeric reading gives it that reading's unit. It is
not the unity: it holds no number, so a `PUT` may set any unit on it."
lowerBound:
type:
- number
@@ -78595,11 +78599,13 @@ components:
type: string
unit:
type: string
description: 'The unit the value is in, free-form as the report prints it (e.g. `mg/dL`). `"1"`, the UCUM unity, means
description: "The unit the value is in, free-form as the report prints it (e.g. `mg/dL`). `\"1\"`, the UCUM unity, means
the value has no unit: a ratio or an index such as INR or cholesterol/HDL. It is an explicit choice and a
unit of its own: it matches only `"1"`, so a reading without a unit is refused under a marker kept in a real
unit and the other way round. Clients show nothing beside such a value. An empty unit on a numeric value is
never read as `"1"` and stays refused.'
unit of its own: it matches only `\"1\"`, so a reading without a unit is refused under a marker kept in a
real unit and the other way round. Clients show nothing beside such a value. An empty unit on a numeric
value is never read as `\"1\"` and stays refused. On a marker, an empty unit means none has been chosen yet:
the marker was minted from a text result, and its first numeric reading gives it that reading's unit. It is
not the unity: it holds no number, so a `PUT` may set any unit on it."
lowerBound:
type:
- number