Skip to content

Commit fdb8daf

Browse files
feat: Roche Cedex Bioht - use get_unread (#1084)
Co-authored-by: james-leinas <157071641+james-leinas@users.noreply.github.com>
1 parent 00d30ce commit fdb8daf

10 files changed

Lines changed: 3606 additions & 1202 deletions

src/allotropy/parsers/roche_cedex_bioht/roche_cedex_bioht_structure.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Title:
3939

4040
@staticmethod
4141
def create(title_data: SeriesData) -> Title:
42+
title_data.get_unread()
4243
return Title(
4344
title_data[str, "data processing time"],
4445
title_data[str, "analyst"],
@@ -69,28 +70,53 @@ def create(data: SeriesData) -> RawMeasurement:
6970
concentration_value, data[str, "concentration unit"]
7071
)
7172

72-
custom_info = data.get_custom_keys({"detection kit", "detection kit range"})
73-
74-
if error:
75-
custom_info["flag"] = error
76-
77-
custom_info_sorted = dict(sorted(custom_info.items()))
78-
7973
# Instead of reporting '< TEST RNG' as the error, we report the original concentration value,
8074
# as the error, which comes as a string like '< 8.706'
8175
if error == BELOW_TEST_RANGE:
8276
error = data.get(str, "original concentration value", error)
8377

84-
return RawMeasurement(
78+
custom_info = data.get_custom_keys(
79+
{"detection kit", "detection kit range", "analyte code"}
80+
)
81+
custom_info["record type"] = data.get(str, "row type", None)
82+
data.mark_read(
83+
{
84+
"sample identifier",
85+
"batch identifier",
86+
"col4",
87+
"col5",
88+
"col6",
89+
"col8",
90+
"col10",
91+
"col11",
92+
"col12",
93+
"col13",
94+
"original concentration value",
95+
"sample role type",
96+
}
97+
)
98+
99+
if error:
100+
custom_info["flag"] = error
101+
102+
measurement = RawMeasurement(
85103
data[str, "analyte name"],
86104
data[str, "measurement time"],
87105
value,
88106
unit,
89107
data[str, "analyte code"],
90108
error,
91-
custom_info_sorted,
109+
{},
92110
)
93111

112+
if isinstance(measurement.custom_info, dict):
113+
custom_info.update(data.get_unread())
114+
custom_info_sorted = dict(sorted(custom_info.items()))
115+
116+
measurement.custom_info.update(custom_info_sorted)
117+
118+
return measurement
119+
94120
@staticmethod
95121
def _get_value_and_unit(value: JsonFloat, unit: str) -> tuple[JsonFloat, str]:
96122
multiplier = 1.0

tests/parsers/roche_cedex_bioht/roche_cedex_bioht_structure_test.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ def test_create_measurements() -> None:
107107
assert measurements == {
108108
"2021-05-20T16:55:51+00:00": {
109109
"lactate_LAC2B": RawMeasurement(
110-
"lactate", "2021-05-20T16:55:51+00:00", 2.45, "g/L", "LAC2B", None, {}
110+
"lactate",
111+
"2021-05-20T16:55:51+00:00",
112+
2.45,
113+
"g/L",
114+
"LAC2B",
115+
None,
116+
{"analyte code": "LAC2B", "record type": None},
111117
),
112118
"glutamine_GLN2B": RawMeasurement(
113119
"glutamine",
@@ -116,7 +122,7 @@ def test_create_measurements() -> None:
116122
"mmol/L",
117123
"GLN2B",
118124
None,
119-
{},
125+
{"analyte code": "GLN2B", "record type": None},
120126
),
121127
"osmolality_OSM2B": RawMeasurement(
122128
"osmolality",
@@ -125,7 +131,7 @@ def test_create_measurements() -> None:
125131
"mosm/kg",
126132
"OSM2B",
127133
None,
128-
{},
134+
{"analyte code": "OSM2B", "record type": None},
129135
),
130136
}
131137
}
@@ -150,7 +156,13 @@ def test_create_measurements_more_than_one_measurement_docs() -> None:
150156
assert measurements == {
151157
"2021-05-20T16:55:51+00:00": {
152158
"lactate_LAC2B": RawMeasurement(
153-
"lactate", "2021-05-20T16:55:51+00:00", 2.45, "g/L", "LAC2B", None, {}
159+
"lactate",
160+
"2021-05-20T16:55:51+00:00",
161+
2.45,
162+
"g/L",
163+
"LAC2B",
164+
None,
165+
{"analyte code": "LAC2B", "record type": None},
154166
),
155167
"glutamine_GLN2B": RawMeasurement(
156168
"glutamine",
@@ -159,7 +171,7 @@ def test_create_measurements_more_than_one_measurement_docs() -> None:
159171
"mmol/L",
160172
"GLN2B",
161173
None,
162-
{},
174+
{"analyte code": "GLN2B", "record type": None},
163175
),
164176
},
165177
"2021-05-21T16:57:51+00:00": {
@@ -170,7 +182,7 @@ def test_create_measurements_more_than_one_measurement_docs() -> None:
170182
"mmol/L",
171183
"GLN2B",
172184
None,
173-
{},
185+
{"analyte code": "GLN2B", "record type": None},
174186
),
175187
},
176188
}
@@ -224,10 +236,22 @@ def test_create_sample() -> None:
224236
assert sample.measurements == {
225237
"2021-05-20 16:55:51": {
226238
"lactate_LAC2B": RawMeasurement(
227-
"lactate", "2021-05-20 16:55:51", 2.45, "g/L", "LAC2B", None, {}
239+
"lactate",
240+
"2021-05-20 16:55:51",
241+
2.45,
242+
"g/L",
243+
"LAC2B",
244+
None,
245+
{"analyte code": "LAC2B", "record type": None},
228246
),
229247
"glutamine_GLN2B": RawMeasurement(
230-
"glutamine", "2021-05-20 16:56:51", 4.35, "mmol/L", "GLN2B", None, {}
248+
"glutamine",
249+
"2021-05-20 16:56:51",
250+
4.35,
251+
"mmol/L",
252+
"GLN2B",
253+
None,
254+
{"analyte code": "GLN2B", "record type": None},
231255
),
232256
}
233257
}

0 commit comments

Comments
 (0)