Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,48 +75,40 @@ def create(data: SeriesData) -> RawMeasurement:
if error == BELOW_TEST_RANGE:
error = data.get(str, "original concentration value", error)

custom_info = data.get_custom_keys(
{"detection kit", "detection kit range", "analyte code"}
)
custom_info["record type"] = data.get(str, "row type", None)
data.mark_read(
{
"sample identifier",
"batch identifier",
"col4",
"col5",
"col6",
"col8",
"col10",
"col11",
"col12",
"col13",
"original concentration value",
"sample role type",
}
)

if error:
custom_info["flag"] = error

measurement = RawMeasurement(
return RawMeasurement(
data[str, "analyte name"],
data[str, "measurement time"],
value,
unit,
data[str, "analyte code"],
error,
{},
custom_info=dict(
sorted(
{
**{
# analyte code is read to generate the analyte id, but is not saved to a field, so include in custom data.
"analyte code": data.get(str, "analyte code"),
"record type": data.get(str, "row type"),
"flag": error or None,
},
**data.get_unread(
skip={
# Sample and batch identifier are read in groupby operation.
"sample identifier",
"batch identifier",
# Read by reader
"sample role type",
# Only read if there is an error.
"original concentration value",
# Skip unidentified columns (col1, col2, etc)
r"col[\d]+",
}
),
}.items()
)
),
)

if isinstance(measurement.custom_info, dict):
custom_info.update(data.get_unread())
custom_info_sorted = dict(sorted(custom_info.items()))

measurement.custom_info.update(custom_info_sorted)

return measurement

@staticmethod
def _get_value_and_unit(value: JsonFloat, unit: str) -> tuple[JsonFloat, str]:
multiplier = 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_create_measurements() -> None:
"g/L",
"LAC2B",
None,
{"analyte code": "LAC2B", "record type": None},
{"analyte code": "LAC2B", "record type": None, "flag": None},
),
"glutamine_GLN2B": RawMeasurement(
"glutamine",
Expand All @@ -122,7 +122,7 @@ def test_create_measurements() -> None:
"mmol/L",
"GLN2B",
None,
{"analyte code": "GLN2B", "record type": None},
{"analyte code": "GLN2B", "record type": None, "flag": None},
),
"osmolality_OSM2B": RawMeasurement(
"osmolality",
Expand All @@ -131,7 +131,7 @@ def test_create_measurements() -> None:
"mosm/kg",
"OSM2B",
None,
{"analyte code": "OSM2B", "record type": None},
{"analyte code": "OSM2B", "record type": None, "flag": None},
),
}
}
Expand Down Expand Up @@ -162,7 +162,7 @@ def test_create_measurements_more_than_one_measurement_docs() -> None:
"g/L",
"LAC2B",
None,
{"analyte code": "LAC2B", "record type": None},
{"analyte code": "LAC2B", "record type": None, "flag": None},
),
"glutamine_GLN2B": RawMeasurement(
"glutamine",
Expand All @@ -171,7 +171,7 @@ def test_create_measurements_more_than_one_measurement_docs() -> None:
"mmol/L",
"GLN2B",
None,
{"analyte code": "GLN2B", "record type": None},
{"analyte code": "GLN2B", "record type": None, "flag": None},
),
},
"2021-05-21T16:57:51+00:00": {
Expand All @@ -182,7 +182,7 @@ def test_create_measurements_more_than_one_measurement_docs() -> None:
"mmol/L",
"GLN2B",
None,
{"analyte code": "GLN2B", "record type": None},
{"analyte code": "GLN2B", "record type": None, "flag": None},
),
},
}
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_create_sample() -> None:
"g/L",
"LAC2B",
None,
{"analyte code": "LAC2B", "record type": None},
{"analyte code": "LAC2B", "record type": None, "flag": None},
),
"glutamine_GLN2B": RawMeasurement(
"glutamine",
Expand All @@ -251,7 +251,7 @@ def test_create_sample() -> None:
"mmol/L",
"GLN2B",
None,
{"analyte code": "GLN2B", "record type": None},
{"analyte code": "GLN2B", "record type": None, "flag": None},
),
}
}
Loading