Skip to content
Closed
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: 1 addition & 7 deletions src/imednet/core/endpoint/mixins/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
DefaultParamProcessor,
KeepStudyKeyStrategy,
OptionalStudyKeyStrategy,
PopStudyKeyStrategy,
StudyKeyStrategy,
)
from imednet.core.endpoint.structs import ParamState
Expand All @@ -20,8 +19,6 @@ class ParamMixin:
"""Mixin for handling endpoint parameters and filters."""

requires_study_key: bool = True
_pop_study_filter: bool = False
_missing_study_exception: type[Exception] = ValueError

PARAM_PROCESSOR: Optional[ParamProcessor] = None
PARAM_PROCESSOR_CLS: type[ParamProcessor] = DefaultParamProcessor
Expand All @@ -38,11 +35,8 @@ def study_key_strategy(self) -> StudyKeyStrategy:
if self.STUDY_KEY_STRATEGY:
return self.STUDY_KEY_STRATEGY

# Backward compatibility logic
if self.requires_study_key:
if self._pop_study_filter:
return PopStudyKeyStrategy(exception_cls=self._missing_study_exception)
return KeepStudyKeyStrategy(exception_cls=self._missing_study_exception)
return KeepStudyKeyStrategy()
return OptionalStudyKeyStrategy()

@property
Expand Down
2 changes: 0 additions & 2 deletions src/imednet/core/endpoint/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ class EndpointProtocol(Protocol):
_enable_cache: bool
requires_study_key: bool
PAGE_SIZE: int
_pop_study_filter: bool
_missing_study_exception: type[Exception]

def _auto_filter(self, filters: Dict[str, Any]) -> Dict[str, Any]:
"""Apply automatic filters (e.g., default study key)."""
Expand Down
4 changes: 2 additions & 2 deletions src/imednet/endpoints/codings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from imednet.core.endpoint.base import GenericEndpoint
from imednet.core.endpoint.edc_mixin import EdcEndpointMixin
from imednet.core.endpoint.mixins import FilterGetEndpointMixin, ListEndpointMixin
from imednet.core.endpoint.strategies import PopStudyKeyStrategy
from imednet.models.codings import Coding


Expand All @@ -21,5 +22,4 @@ class CodingsEndpoint(
PATH = "codings"
MODEL = Coding
_id_param = "codingId"
_pop_study_filter = True
_missing_study_exception = KeyError
STUDY_KEY_STRATEGY = PopStudyKeyStrategy(exception_cls=KeyError)
4 changes: 2 additions & 2 deletions src/imednet/endpoints/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from imednet.core.endpoint.base import GenericEndpoint
from imednet.core.endpoint.edc_mixin import EdcEndpointMixin
from imednet.core.endpoint.mixins import FilterGetEndpointMixin, ListEndpointMixin
from imednet.core.endpoint.strategies import PopStudyKeyStrategy
from imednet.models.forms import Form


Expand All @@ -22,6 +23,5 @@ class FormsEndpoint(
MODEL = Form
_id_param = "formId"
_enable_cache = True
_pop_study_filter = True
_missing_study_exception = KeyError
STUDY_KEY_STRATEGY = PopStudyKeyStrategy(exception_cls=KeyError)
PAGE_SIZE = 500
4 changes: 2 additions & 2 deletions src/imednet/endpoints/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from imednet.core.endpoint.base import GenericEndpoint
from imednet.core.endpoint.edc_mixin import EdcEndpointMixin
from imednet.core.endpoint.mixins import FilterGetEndpointMixin, ListEndpointMixin
from imednet.core.endpoint.strategies import PopStudyKeyStrategy
from imednet.models.intervals import Interval


Expand All @@ -22,6 +23,5 @@ class IntervalsEndpoint(
MODEL = Interval
_id_param = "intervalId"
_enable_cache = True
_pop_study_filter = True
_missing_study_exception = KeyError
STUDY_KEY_STRATEGY = PopStudyKeyStrategy(exception_cls=KeyError)
PAGE_SIZE = 500
1 change: 0 additions & 1 deletion src/imednet/endpoints/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class RecordsEndpoint(
PATH = "records"
MODEL = Record
_id_param = "recordId"
_pop_study_filter = False
PARAM_PROCESSOR = MappingParamProcessor({"record_data_filter": "recordDataFilter"})

def create(
Expand Down
4 changes: 2 additions & 2 deletions src/imednet/endpoints/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from imednet.core.endpoint.base import GenericEndpoint
from imednet.core.endpoint.edc_mixin import EdcEndpointMixin
from imednet.core.endpoint.mixins import FilterGetEndpointMixin, ListEndpointMixin
from imednet.core.endpoint.strategies import PopStudyKeyStrategy
from imednet.models.sites import Site


Expand All @@ -21,5 +22,4 @@ class SitesEndpoint(
PATH = "sites"
MODEL = Site
_id_param = "siteId"
_pop_study_filter = True
_missing_study_exception = KeyError
STUDY_KEY_STRATEGY = PopStudyKeyStrategy(exception_cls=KeyError)
4 changes: 2 additions & 2 deletions src/imednet/endpoints/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from imednet.core.endpoint.base import GenericEndpoint
from imednet.core.endpoint.edc_mixin import EdcEndpointMixin
from imednet.core.endpoint.mixins import FilterGetEndpointMixin, ListEndpointMixin
from imednet.core.endpoint.strategies import MappingParamProcessor
from imednet.core.endpoint.strategies import MappingParamProcessor, PopStudyKeyStrategy
from imednet.models.users import User


Expand All @@ -22,7 +22,7 @@ class UsersEndpoint(
PATH = "users"
MODEL = User
_id_param = "userId"
_pop_study_filter = True
STUDY_KEY_STRATEGY = PopStudyKeyStrategy()
PARAM_PROCESSOR = MappingParamProcessor(
mapping={"include_inactive": "includeInactive"},
defaults={"include_inactive": False},
Expand Down
4 changes: 2 additions & 2 deletions src/imednet/endpoints/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from imednet.core.endpoint.base import GenericEndpoint
from imednet.core.endpoint.edc_mixin import EdcEndpointMixin
from imednet.core.endpoint.mixins import FilterGetEndpointMixin, ListEndpointMixin
from imednet.core.endpoint.strategies import PopStudyKeyStrategy
from imednet.models.variables import Variable


Expand All @@ -22,6 +23,5 @@ class VariablesEndpoint(
MODEL = Variable
_id_param = "variableId"
_enable_cache = True
_pop_study_filter = True
_missing_study_exception = KeyError
STUDY_KEY_STRATEGY = PopStudyKeyStrategy(exception_cls=KeyError)
PAGE_SIZE = 500
Loading