fix: NovaBio Flex2 - do not emit pH measurement when only vessel temperature is present - #1261
Merged
Merged
Conversation
…erature is present A sample with a vessel temperature but a blank pH aborted the entire file conversion: pH and temperature are grouped into one ph-detection measurement, which was emitted whenever either value was present, but the Allotrope pH-detector schema requires a pH value. Skip a detection type when its schema-required measured value is absent.
This was referenced Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converting a NovaBio BioProfile Flex2
SampleResults.csvfailed schema validation and aborted the entire file whenever any row had aVessel Temperature (°C)value but a blankpH. Reported by a customer (CUST-12475) whose failing sample had a vessel temperature of 37 °C and no pH reading.Root cause
DETECTION_PROPERTY_MAPPING["ph-detection"]groupsphandtemperatureinto a single measurement, and_get_measurements()emitted that measurement whenever any of its properties was non-None:A row with a temperature but no pH therefore produced a
ph-detectionmeasurement carrying only a temperature. The Allotrope pH-detector schema (adm/ph/REC/2024/09/ph-detector.schema.json,measurementDocumentItems) marks pH as required and temperature as optional, so the measurement failed theanyOfvalidation:Fix
Skip a detection type when its schema-required measured value is absent. Implemented as a small mapping rather than a one-off
if detection_type == "ph-detection"check, so the same guard can cover other detection types later:The guard sits at the top of the loop body, so it also avoids building
kwargsneedlessly.Temperature-only samples now simply produce no pH measurement; every other detection type on the sample is unaffected.
Test plan
test_ph_detection_requires_ph_valuecovers all four pH/temperature combinations: temperature-only and empty samples yield noph-detection, while both pH cases still do.SampleResults2025-02-09_104000.csvfixture (plus generated.jsonsnapshot) exercises full file conversion across three samples: temperature-without-pH, pH-with-temperature, and pH-without-temperature. The first yields only metabolite and blood-gas measurements; the other two retainph-detection.ruff,black, andmypyclean on the changed files.Manual validation
Before the fix this raised
AllotropeValidationError; after the fix it converts and validates cleanly, keeping the metabolite detection:Out of scope
Two pre-existing behaviors are deliberately left alone, as neither is the reported scenario and both need a different remedy:
metabolite-detectionmeasurement is emitted.po2_unit/pco2_unitare populated from that row even when the PO2/PCO2 values are blank, making theany(value is not None ...)guard true and emitting a valuelessblood-gas-detectionmeasurement that fails validation the same way. This has the same shape as the bug fixed here, but the trigger is a units-only measurement rather than a missing required field. The new fixture supplies gas values on every row to avoid it.