Skip to content

Commit 2639f56

Browse files
committed
fix: remove id from dict()
1 parent f756b47 commit 2639f56

File tree

7 files changed

+4
-23
lines changed

7 files changed

+4
-23
lines changed

execution_engine/execution_engine.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ def load_recommendation(
9898
)
9999
return recommendation
100100

101+
# recommendation could not be loaded from database, fetch it from FHIR server
102+
101103
recommendation = self.fhir_parser.parse_recommendation_from_url(
102104
url=recommendation_url,
103105
package_version=recommendation_package_version,
@@ -210,16 +212,6 @@ def _hash(obj: Serializable) -> tuple[bytes, str]:
210212

211213
def register_recommendation(self, recommendation: cohort.Recommendation) -> None:
212214
"""Registers the Recommendation in the result database."""
213-
# We don't want to include any ids in the hash since ids
214-
# "accidental" in the sense that they depend on, at least, the
215-
# order in which recommendations are inserted into the
216-
# database.
217-
assert recommendation._id is None
218-
assert recommendation._base_criterion._id is None
219-
for pi_pair in recommendation._pi_pairs:
220-
assert pi_pair._id is None
221-
for criterion in pi_pair.flatten():
222-
assert criterion._id is None
223215
# Get the hash but ignore the JSON representation for now
224216
# since we will compute and insert a complete JSON
225217
# representation later when we know all ids.
@@ -306,8 +298,6 @@ def register_population_intervention_pair(
306298
:param pi_pair: The Population/Intervention Pair.
307299
:param recommendation_id: The ID of the Population/Intervention Pair.
308300
"""
309-
# We don't want to include the id in the hash
310-
assert pi_pair._id is None
311301
_, pi_pair_hash = self._hash(pi_pair)
312302
query = select(result_db.PopulationInterventionPair).where(
313303
result_db.PopulationInterventionPair.pi_pair_hash == pi_pair_hash

execution_engine/omop/cohort/population_intervention_pair.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ def dict(self) -> dict[str, Any]:
263263
population = self._population
264264
intervention = self._intervention
265265
return {
266-
"id": self._id,
267266
"name": self.name,
268267
"url": self.url,
269268
"base_criterion": {
@@ -295,7 +294,6 @@ def from_dict(cls, data: Dict[str, Any]) -> "PopulationInterventionPair":
295294
CriterionCombination, criterion_factory(**data["intervention"])
296295
)
297296
object = cls(
298-
id=data["id"],
299297
name=data["name"],
300298
url=data["url"],
301299
base_criterion=base_criterion,

execution_engine/omop/cohort/recommendation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ def dict(self) -> dict:
255255
"""
256256
base_criterion = self._base_criterion
257257
return {
258-
"id": self._id,
259258
"population_intervention_pairs": [c.dict() for c in self._pi_pairs],
260259
"base_criterion": {
261260
"class_name": base_criterion.__class__.__name__,
@@ -291,5 +290,4 @@ def from_dict(cls, data: Dict[str, Any]) -> Self:
291290
version=data["recommendation_version"],
292291
description=data["recommendation_description"],
293292
package_version=data["recommendation_package_version"],
294-
recommendation_id=data["id"],
295293
)

execution_engine/omop/criterion/concept.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def dict(self) -> dict[str, Any]:
136136
Get a JSON representation of the criterion.
137137
"""
138138
return {
139-
"id": self._id,
140139
"category": self._category.value,
141140
"concept": self._concept.model_dump(),
142141
"value": (
@@ -159,7 +158,6 @@ def from_dict(cls, data: Dict[str, Any]) -> "ConceptCriterion":
159158
"""
160159

161160
return cls(
162-
id=data["id"],
163161
category=CohortCategory(data["category"]),
164162
concept=Concept(**data["concept"]),
165163
value=(

execution_engine/omop/criterion/drug_exposure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,6 @@ def from_dict(cls, data: Dict[str, Any]) -> "DrugExposure":
379379
assert dose is None or isinstance(dose, Dosage), "Dose must be a Dosage or None"
380380

381381
return cls(
382-
id=data["id"],
383382
category=CohortCategory(data["category"]),
384383
ingredient_concept=Concept(**data["ingredient_concept"]),
385384
dose=dose,

execution_engine/omop/criterion/procedure_occurrence.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ def dict(self) -> dict[str, Any]:
160160
assert self._concept is not None, "Concept must be set"
161161

162162
return {
163-
"id": self._id,
164163
"category": self._category.value,
165164
"concept": self._concept.model_dump(),
166165
"value": (
@@ -192,7 +191,6 @@ def from_dict(cls, data: Dict[str, Any]) -> "ProcedureOccurrence":
192191
), "timing must be a ValueNumber"
193192

194193
return cls(
195-
id=data["id"],
196194
category=CohortCategory(data["category"]),
197195
concept=Concept(**data["concept"]),
198196
value=value,

execution_engine/omop/criterion/visit_occurrence.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ def dict(self) -> dict[str, Any]:
8888
"""
8989
Get a JSON representation of the criterion.
9090
"""
91-
return {"id": self._id}
91+
return {}
9292

9393
@classmethod
9494
def from_dict(cls, data: Dict[str, Any]) -> "ActivePatients":
9595
"""
9696
Create a criterion from a JSON representation.
9797
"""
98-
return cls(id=data["id"])
98+
return cls()
9999

100100

101101
class PatientsActiveDuringPeriod(ActivePatients):

0 commit comments

Comments
 (0)