omop-constructs 0.3.4__tar.gz → 0.3.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/PKG-INFO +1 -1
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/pyproject.toml +1 -1
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/concepts/concept_standardisation.py +1 -2
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/surgical_joins.py +0 -1
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/events/__init__.py +6 -1
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/events/dx_linked_event_mv.py +0 -3
- omop_constructs-0.3.5/src/omop_constructs/alchemy/events/dx_linked_procedure_mv.py +44 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/events/event_factories.py +56 -2
- omop_constructs-0.3.5/src/omop_constructs/alchemy/events/procedure_queries.py +12 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/README.md +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/adapters.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/concepts/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/concepts/concept_mappers.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/conditions/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/conditions/condition_joins.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/conditions/condition_mappers.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/demography/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/demography/demography_matview.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/demography/demography_queries.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/condition_episode_mv.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/condition_episode_objects.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/episode_factories.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/episode_joins.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/surgical_procedure_mv.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/treatment_summary_joins.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/events/event_queries.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/modifiers/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/modifiers/condition_modifier_join.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/modifiers/condition_modifier_mv.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/modifiers/modifier_factories.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/modifiers/modifier_joins.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/modifiers/modifier_mappers.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/source_factories.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/core/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/core/base.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/core/constructs.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/core/ddl.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/core/errors.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/core/materialized.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/core/plan.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/core/registry.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/py.typed +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/semantics/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/semantics/adapters.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/semantics/lookups.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/semantics/runtime_lookups.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/services/__init__.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/services/concept.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/services/person.py +0 -0
- {omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/typing.py +0 -0
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/events/__init__.py
RENAMED
|
@@ -12,6 +12,10 @@ from .dx_linked_event_mv import (
|
|
|
12
12
|
DxMeasurementMV
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
+
from .dx_linked_procedure_mv import (
|
|
16
|
+
DxProcedureMV,
|
|
17
|
+
)
|
|
18
|
+
|
|
15
19
|
__all__ = [
|
|
16
20
|
"WeightDxMV",
|
|
17
21
|
"WeightChangeDxMV",
|
|
@@ -23,5 +27,6 @@ __all__ = [
|
|
|
23
27
|
"DistressThermometerDxMV",
|
|
24
28
|
"ECOGDxMV",
|
|
25
29
|
"SmokingPYHDxMV",
|
|
26
|
-
"DxMeasurementMV"
|
|
30
|
+
"DxMeasurementMV",
|
|
31
|
+
"DxProcedureMV",
|
|
27
32
|
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import sqlalchemy as sa
|
|
2
|
+
import sqlalchemy.orm as so
|
|
3
|
+
from datetime import date
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from orm_loader.helpers import Base
|
|
6
|
+
|
|
7
|
+
from omop_constructs.alchemy.episodes.condition_episode_mv import ConditionEpisodeMV
|
|
8
|
+
from ...core.materialized import MaterializedViewMixin
|
|
9
|
+
from ...core.constructs import register_construct
|
|
10
|
+
from ..episodes import ConditionEpisodeMV
|
|
11
|
+
from .procedure_queries import (
|
|
12
|
+
dx_all_procedures
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
class ConditionEpisodeProcedureCols:
|
|
16
|
+
__table_args__ = {"extend_existing": True}
|
|
17
|
+
|
|
18
|
+
mv_id: so.Mapped[int] = so.mapped_column(primary_key=True)
|
|
19
|
+
|
|
20
|
+
person_id: so.Mapped[int] = so.mapped_column(sa.Integer)
|
|
21
|
+
event_id: so.Mapped[int] = so.mapped_column(sa.Integer)
|
|
22
|
+
event_date: so.Mapped[date] = so.mapped_column(sa.Date)
|
|
23
|
+
event_concept_id: so.Mapped[int] = so.mapped_column(sa.Integer)
|
|
24
|
+
event_label: so.Mapped[Optional[str]] = so.mapped_column(sa.String, nullable=True)
|
|
25
|
+
|
|
26
|
+
episode_id: so.Mapped[Optional[int]] = so.mapped_column(sa.Integer, nullable=True)
|
|
27
|
+
episode_concept_id: so.Mapped[Optional[int]] = so.mapped_column(sa.Integer, nullable=True)
|
|
28
|
+
episode_label: so.Mapped[Optional[str]] = so.mapped_column(sa.String, nullable=True)
|
|
29
|
+
|
|
30
|
+
episode_start_date: so.Mapped[Optional[date]] = so.mapped_column(sa.Date, nullable=True)
|
|
31
|
+
episode_end_date: so.Mapped[Optional[date]] = so.mapped_column(sa.Date, nullable=True)
|
|
32
|
+
|
|
33
|
+
episode_delta_days: so.Mapped[Optional[int]] = so.mapped_column(sa.Integer, nullable=True)
|
|
34
|
+
|
|
35
|
+
@register_construct
|
|
36
|
+
class DxProcedureMV(ConditionEpisodeProcedureCols, MaterializedViewMixin, Base):
|
|
37
|
+
__mv_name__ = "dx_procedure_mv"
|
|
38
|
+
__mv_select__ = dx_all_procedures.select()
|
|
39
|
+
__mv_index__ = "person_id"
|
|
40
|
+
__deps__ = (ConditionEpisodeMV.__mv_name__,)
|
|
41
|
+
__tablename__ = __mv_name__
|
|
42
|
+
|
|
43
|
+
procedure_concept_id: so.Mapped[int] = so.mapped_column(sa.Integer)
|
|
44
|
+
procedure_datetime: so.Mapped[Optional[date]] = so.mapped_column(sa.DateTime)
|
|
@@ -5,12 +5,13 @@ from typing import Iterable, Any, Sequence, Union
|
|
|
5
5
|
from omop_constructs.alchemy.episodes import ConditionEpisodeMV
|
|
6
6
|
from omop_alchemy.cdm.model.structural import Episode_Event
|
|
7
7
|
from omop_semantics.runtime.default_valuesets import runtime # type: ignore
|
|
8
|
-
from omop_alchemy.cdm.model import Measurement, Concept
|
|
9
|
-
|
|
8
|
+
from omop_alchemy.cdm.model import Measurement, Concept, Procedure_Occurrence
|
|
10
9
|
from sqlalchemy.orm.attributes import InstrumentedAttribute
|
|
10
|
+
|
|
11
11
|
SQLExpr = Union[ColumnElement[Any], InstrumentedAttribute[Any]]
|
|
12
12
|
|
|
13
13
|
modifier_concept = so.aliased(Concept, name="modifier_concept")
|
|
14
|
+
procedure_concept = so.aliased(Concept, name="procedure_concept")
|
|
14
15
|
|
|
15
16
|
def attach_to_condition_episode_via_episode_event(
|
|
16
17
|
base_event_subq: sa.Subquery,
|
|
@@ -120,6 +121,59 @@ def attach_to_condition_episode(
|
|
|
120
121
|
.subquery(name=name)
|
|
121
122
|
)
|
|
122
123
|
|
|
124
|
+
def procedure_event_core(
|
|
125
|
+
*,
|
|
126
|
+
concept_ids: Iterable[int] | None = None,
|
|
127
|
+
name: str = "procedure_core",
|
|
128
|
+
include_cols: Sequence[SQLExpr] = (),
|
|
129
|
+
) -> sa.Subquery:
|
|
130
|
+
"""
|
|
131
|
+
Minimal procedure event surface (person/id/date/concept/label + extras).
|
|
132
|
+
"""
|
|
133
|
+
q = (
|
|
134
|
+
sa.select(
|
|
135
|
+
Procedure_Occurrence.person_id.label("person_id"),
|
|
136
|
+
Procedure_Occurrence.procedure_occurrence_id.label("event_id"),
|
|
137
|
+
Procedure_Occurrence.procedure_date.label("event_date"),
|
|
138
|
+
Procedure_Occurrence.procedure_concept_id.label("event_concept_id"),
|
|
139
|
+
procedure_concept.concept_name.label("event_label"),
|
|
140
|
+
*include_cols,
|
|
141
|
+
)
|
|
142
|
+
.join(
|
|
143
|
+
procedure_concept,
|
|
144
|
+
procedure_concept.concept_id == Procedure_Occurrence.procedure_concept_id,
|
|
145
|
+
isouter=True,
|
|
146
|
+
)
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
if concept_ids is not None:
|
|
150
|
+
q = q.where(Procedure_Occurrence.procedure_concept_id.in_(list(concept_ids)))
|
|
151
|
+
|
|
152
|
+
return q.subquery(name=name)
|
|
153
|
+
|
|
154
|
+
def procedure_attached_to_condition_episode(
|
|
155
|
+
*,
|
|
156
|
+
concept_ids: Iterable[int] | None = None,
|
|
157
|
+
include_cols: Sequence[SQLExpr] = (),
|
|
158
|
+
name: str,
|
|
159
|
+
prefer_explicit_link: bool = True,
|
|
160
|
+
) -> sa.Subquery:
|
|
161
|
+
core = procedure_event_core(
|
|
162
|
+
concept_ids=concept_ids,
|
|
163
|
+
include_cols=include_cols,
|
|
164
|
+
name=f"{name}_core",
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
return attach_to_condition_episode(
|
|
168
|
+
core,
|
|
169
|
+
event_id_col=core.c.event_id,
|
|
170
|
+
date_col=core.c.event_date,
|
|
171
|
+
person_col=core.c.person_id,
|
|
172
|
+
name=name,
|
|
173
|
+
prefer_explicit_link=prefer_explicit_link,
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
|
|
123
177
|
def measurement_event_core(
|
|
124
178
|
*,
|
|
125
179
|
concept_ids: Iterable[int] | None = None,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from .event_factories import procedure_attached_to_condition_episode, episode_relevant_window
|
|
2
|
+
|
|
3
|
+
dx_all_procedures = episode_relevant_window(
|
|
4
|
+
procedure_attached_to_condition_episode(
|
|
5
|
+
concept_ids=None,
|
|
6
|
+
include_cols=[],
|
|
7
|
+
name="dx_all_procedures",
|
|
8
|
+
),
|
|
9
|
+
max_days_post=90,
|
|
10
|
+
max_days_prior=30,
|
|
11
|
+
name="dx_all_procedures_windowed",
|
|
12
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/concepts/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/conditions/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/demography/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/episodes/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/events/event_queries.py
RENAMED
|
File without changes
|
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/modifiers/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/alchemy/source_factories.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{omop_constructs-0.3.4 → omop_constructs-0.3.5}/src/omop_constructs/semantics/runtime_lookups.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|