imednet.validation package
Submodules
imednet.validation.cache module
- class imednet.validation.cache.AsyncSchemaCache[source]
Bases:
BaseSchemaCache
[AsyncImednetSDK
]
- class imednet.validation.cache.BaseSchemaCache(is_async)[source]
Bases:
Generic
[_TClient
]Cache of variables by form key with optional async refresh.
- Parameters:
is_async (bool) –
- refresh(forms, variables, study_key=None)[source]
- Return type:
Any
- Parameters:
forms (FormsEndpoint) –
variables (VariablesEndpoint) –
study_key (str | None) –
- class imednet.validation.cache.SchemaCache[source]
Bases:
BaseSchemaCache
[ImednetSDK
]
- class imednet.validation.cache.SchemaValidator(sdk)[source]
Bases:
_ValidatorMixin
Validate record payloads using variable metadata from the API.
- Parameters:
sdk (ImednetSDK | AsyncImednetSDK) –
- refresh(study_key)[source]
Populate the schema cache for
study_key
from the Variables endpoint.Returns
None
when used with a synchronous validator or a coroutine for an asynchronous validator. This method never raisesValidationError
; any API errors bubble up asApiError
.- Return type:
Any
- Parameters:
study_key (str) –
- imednet.validation.cache.validate_record_data(schema, form_key, data)[source]
Validate
data
forform_key
using the provided schema cache.- Raises:
ValidationError – If the form key is not present in the schema or the data fails validation checks.
- Return type:
None
- Parameters:
schema (BaseSchemaCache[Any]) –
form_key (str) –
data (Dict[str, Any]) –
imednet.validation.schema module
- class imednet.validation.schema.BaseSchemaCache(is_async)[source]
Bases:
Generic
[_TClient
]Cache of variables by form key with optional async refresh.
- Parameters:
is_async (bool) –
- refresh(forms, variables, study_key=None)[source]
- Return type:
Any
- Parameters:
forms (FormsEndpoint) –
variables (VariablesEndpoint) –
study_key (str | None) –
- class imednet.validation.schema.SchemaValidator(sdk)[source]
Bases:
_ValidatorMixin
Validate record payloads using variable metadata from the API.
- Parameters:
sdk (ImednetSDK | AsyncImednetSDK) –
- refresh(study_key)[source]
Populate the schema cache for
study_key
from the Variables endpoint.Returns
None
when used with a synchronous validator or a coroutine for an asynchronous validator. This method never raisesValidationError
; any API errors bubble up asApiError
.- Return type:
Any
- Parameters:
study_key (str) –
- imednet.validation.schema.validate_record_data(schema, form_key, data)[source]
Validate
data
forform_key
using the provided schema cache.- Raises:
ValidationError – If the form key is not present in the schema or the data fails validation checks.
- Return type:
None
- Parameters:
schema (BaseSchemaCache[Any]) –
form_key (str) –
data (Dict[str, Any]) –
Module contents
- class imednet.validation.AsyncSchemaCache[source]
Bases:
BaseSchemaCache
[AsyncImednetSDK
]
- class imednet.validation.BaseSchemaCache(is_async)[source]
Bases:
Generic
[_TClient
]Cache of variables by form key with optional async refresh.
- Parameters:
is_async (bool) –
- refresh(forms, variables, study_key=None)[source]
- Return type:
Any
- Parameters:
forms (FormsEndpoint) –
variables (VariablesEndpoint) –
study_key (str | None) –
- class imednet.validation.DataDictionary(business_logic, choices, forms, questions)[source]
Bases:
object
Container for data dictionary CSV content.
- Parameters:
business_logic (list[dict[str, str]]) –
choices (list[dict[str, str]]) –
forms (list[dict[str, str]]) –
questions (list[dict[str, str]]) –
-
business_logic:
list
[dict
[str
,str
]]
-
choices:
list
[dict
[str
,str
]]
-
forms:
list
[dict
[str
,str
]]
-
questions:
list
[dict
[str
,str
]]
- class imednet.validation.DataDictionaryLoader[source]
Bases:
object
Load data dictionary files from various sources.
- REQUIRED_FILES = {'BUSINESS_LOGIC.csv': 'business_logic', 'CHOICES.csv': 'choices', 'FORMS.csv': 'forms', 'QUESTIONS.csv': 'questions'}
- classmethod from_directory(directory)[source]
Load all required CSV files from
directory
.- Return type:
- Parameters:
directory (Path | str) –
- classmethod from_files(*, business_logic, choices, forms, questions)[source]
Load a data dictionary from individual CSV files.
- Return type:
- Parameters:
business_logic (Path | TextIO) –
choices (Path | TextIO) –
forms (Path | TextIO) –
questions (Path | TextIO) –
- class imednet.validation.SchemaCache[source]
Bases:
BaseSchemaCache
[ImednetSDK
]
- class imednet.validation.SchemaValidator(sdk)[source]
Bases:
_ValidatorMixin
Validate record payloads using variable metadata from the API.
- Parameters:
sdk (ImednetSDK | AsyncImednetSDK) –
- refresh(study_key)[source]
Populate the schema cache for
study_key
from the Variables endpoint.Returns
None
when used with a synchronous validator or a coroutine for an asynchronous validator. This method never raisesValidationError
; any API errors bubble up asApiError
.- Return type:
Any
- Parameters:
study_key (str) –
- imednet.validation.validate_record_data(schema, form_key, data)[source]
Validate
data
forform_key
using the provided schema cache.- Raises:
ValidationError – If the form key is not present in the schema or the data fails validation checks.
- Return type:
None
- Parameters:
schema (BaseSchemaCache[Any]) –
form_key (str) –
data (Dict[str, Any]) –