mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-12 06:06:10 +00:00
Drop a reference window whose floor sits above its ceiling
A lab report's reference range reaches the record by four paths. Three of them validate that the floor does not exceed the ceiling; the document path did not, and the catalog store writes what it is handed. An integration run against a real Postgres confirmed the consequence: a 100/30 pair landed on the row and on the freshly minted biomarker, so every later reading of that analyte inherited a window that cannot be true and a high value came back reassuring. Dropping beats swapping. A transposed pair says the transcription is wrong, not which of the two numbers is, and inventing an order would state something the report never printed. The verbatim string survives either way, so nothing the document actually said is lost. Three points, answering according to what each one is: - the extraction schema drops the pair, because every field there is catch-guarded so one bad value cannot sink a 120-fact document - the review-screen edit refuses with the wording the lab schemas already use, because a person can see both numbers and fix them - the commit path drops it as the last gate, which is what covers facts staged before this rule existed and confirmed afterwards parseReferenceRange has answered a transposed PRINTED window this way since it was written, and the commit path already counts a window it could not read at all. This extends both to the case that was readable and cannot be true.
This commit is contained in:
1 parent
a852860654
commit
963f61cf0f
4 files changed
+256
-3
No files matched your search
@@ -83,8 +83,16 @@ async function commitObservation(
|
||||
// existed has no text, and the numeric bounds the model reported are then
|
||||
// the whole of what it stated.
|
||||
const printed = parseReferenceRange(data.referenceText, data.unit);
|
||||
const sourceLow = printed?.low ?? data.referenceLow;
|
||||
const sourceHigh = printed?.high ?? data.referenceHigh;
|
||||
const rawLow = printed?.low ?? data.referenceLow;
|
||||
const rawHigh = printed?.high ?? data.referenceHigh;
|
||||
// Last gate on an impossible window, and the one that matters for facts
|
||||
// already sitting in the table: a document staged before the extraction
|
||||
// schema learned this rule still carries whatever the model reported, and it
|
||||
// arrives here on confirmation. Dropping beats swapping — the pair says the
|
||||
// transcription is wrong, not which of the two numbers is.
|
||||
const transposed = rawLow !== null && rawHigh !== null && rawLow > rawHigh;
|
||||
const sourceLow = transposed ? null : rawLow;
|
||||
const sourceHigh = transposed ? null : rawHigh;
|
||||
const sourceText = printed?.text ?? null;
|
||||
// A window the report printed and the parser could not read is the case that
|
||||
// used to pass without a trace: the reading is then judged against the
|
||||
@@ -99,6 +107,15 @@ async function commitObservation(
|
||||
meta: { surface: "document.commit", length: printed?.text.length ?? 0 },
|
||||
});
|
||||
}
|
||||
// The same reasoning one step further along: a window that WAS readable and
|
||||
// cannot be true. Counted rather than merely dropped, because a rising count
|
||||
// says something about the extraction that no individual row does.
|
||||
if (transposed) {
|
||||
annotate({
|
||||
action: { name: "labs.referenceRange.transposed" },
|
||||
meta: { surface: "document.commit" },
|
||||
});
|
||||
}
|
||||
|
||||
const biomarker = await resolveOrMintBiomarker(userId, {
|
||||
analyte: data.label,
|
||||
|
||||
Reference in new issue
Block a user