Skip to content
Closed

Fixes #278

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
8 changes: 6 additions & 2 deletions execution_engine/converter/criterion.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ def parse_value(
eps = float(value_numeric) / 1e5
match value.comparator:
case "<=" | "<":
value_max = value_numeric - (eps if value.comparator == "<" else 0)
value_max = float(value_numeric) - (
eps if value.comparator == "<" else 0
)
value_numeric = None
case ">=" | ">":
value_min = value_numeric + (eps if value.comparator == "<" else 0)
value_min = float(value_numeric) + (
eps if value.comparator == "<" else 0
)
value_numeric = None
case _:
raise ValueError(f'Unknown quantity operator: "{value.comparator}"')
Expand Down
3 changes: 3 additions & 0 deletions execution_engine/converter/parser/fhir_parser_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def parse_time_from_event(

new_combo = converter.to_temporal_combination(combo)

if not isinstance(new_combo, CriterionCombination):
raise ValueError(f"Expected CriterionCombination, got {type(new_combo)}")

return new_combo

def parse_characteristics(self, ev: EvidenceVariable) -> CriterionCombination:
Expand Down
6 changes: 5 additions & 1 deletion execution_engine/omop/sqlclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pandas as pd
import sqlalchemy
from sqlalchemy import and_, bindparam, event, func, select, text
from sqlalchemy import NullPool, and_, bindparam, event, func, select, text
from sqlalchemy.engine.interfaces import DBAPIConnection
from sqlalchemy.pool import ConnectionPoolEntry
from sqlalchemy.sql import Insert, Select
Expand Down Expand Up @@ -83,6 +83,7 @@ def __init__(
result_schema: str,
timezone: str = "Europe/Berlin",
disable_triggers: bool = False,
null_pool: bool = False,
) -> None:
"""Initialize the OMOP SQL client."""

Expand All @@ -97,6 +98,9 @@ def __init__(
connection_string,
connect_args={"options": "-csearch_path={}".format(self._data_schema)},
future=True,
poolclass=(
NullPool if null_pool else None
), # <--- ensures no persistent pool
)

if disable_triggers:
Expand Down
10 changes: 10 additions & 0 deletions execution_engine/omop/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ class ICD10GM(AbstractStandardVocabulary):
omop_vocab_name = "ICD10GM"


class ICD10CM(AbstractStandardVocabulary):
"""
ICD10 Clinical Modification
"""

system_uri = "http://hl7.org/fhir/sid/icd-10-cm"
omop_vocab_name = "ICD10CM"


class UCUM(AbstractStandardVocabulary):
"""
UCUM vocabulary.
Expand Down Expand Up @@ -232,6 +241,7 @@ def init(self) -> None:
self.register(UCUM)
self.register(ATCDE)
self.register(ICD10GM)
self.register(ICD10CM)
self.register(CODEXCELIDA)

def register(self, vocabulary: Type[AbstractVocabulary]) -> None:
Expand Down
1 change: 1 addition & 0 deletions execution_engine/task/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def get_engine() -> OMOPSQLClient:
return OMOPSQLClient(
**get_config().omop.model_dump(by_alias=True),
timezone=get_config().timezone,
null_pool=get_config().multiprocessing_use,
)


Expand Down
3 changes: 0 additions & 3 deletions execution_engine/util/value/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ class ValueScalar(ValueNumeric[float, None]):

unit: None = None

_validate_value = field_validator("value", mode="before")(check_int)
_validate_value_min = field_validator("value_min", mode="before")(check_int)
_validate_value_max = field_validator("value_max", mode="before")(check_int)
_validate_no_unit = field_validator("unit", mode="before")(check_unit_none)

def supports_units(self) -> bool:
Expand Down