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) –

form_key_from_id(form_id)[source]
Return type:

Optional[str]

Parameters:

form_id (int) –

property forms: Dict[str, Dict[str, Variable]]

Return cached variables grouped by form key.

refresh(forms, variables, study_key=None)[source]
Return type:

Any

Parameters:
variables_for_form(form_key)[source]
Return type:

Dict[str, Variable]

Parameters:

form_key (str) –

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 raises ValidationError; any API errors bubble up as ApiError.

Return type:

Any

Parameters:

study_key (str) –

validate_batch(study_key, records)[source]
Return type:

Any

Parameters:
  • study_key (str) –

  • records (list[Dict[str, Any]]) –

validate_record(study_key, record)[source]
Return type:

Any

Parameters:
  • study_key (str) –

  • record (Dict[str, Any]) –

imednet.validation.cache.validate_record_data(schema, form_key, data)[source]

Validate data for form_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) –

form_key_from_id(form_id)[source]
Return type:

Optional[str]

Parameters:

form_id (int) –

property forms: Dict[str, Dict[str, Variable]]

Return cached variables grouped by form key.

refresh(forms, variables, study_key=None)[source]
Return type:

Any

Parameters:
variables_for_form(form_key)[source]
Return type:

Dict[str, Variable]

Parameters:

form_key (str) –

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 raises ValidationError; any API errors bubble up as ApiError.

Return type:

Any

Parameters:

study_key (str) –

validate_batch(study_key, records)[source]
Return type:

Any

Parameters:
  • study_key (str) –

  • records (list[Dict[str, Any]]) –

validate_record(study_key, record)[source]
Return type:

Any

Parameters:
  • study_key (str) –

  • record (Dict[str, Any]) –

imednet.validation.schema.validate_record_data(schema, form_key, data)[source]

Validate data for form_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) –

form_key_from_id(form_id)[source]
Return type:

Optional[str]

Parameters:

form_id (int) –

property forms: Dict[str, Dict[str, Variable]]

Return cached variables grouped by form key.

refresh(forms, variables, study_key=None)[source]
Return type:

Any

Parameters:
variables_for_form(form_key)[source]
Return type:

Dict[str, Variable]

Parameters:

form_key (str) –

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:

DataDictionary

Parameters:

directory (Path | str) –

classmethod from_files(*, business_logic, choices, forms, questions)[source]

Load a data dictionary from individual CSV files.

Return type:

DataDictionary

Parameters:
  • business_logic (Path | TextIO) –

  • choices (Path | TextIO) –

  • forms (Path | TextIO) –

  • questions (Path | TextIO) –

classmethod from_zip(source)[source]

Load a data dictionary from a ZIP archive containing the required CSVs.

Return type:

DataDictionary

Parameters:

source (Path | BinaryIO) –

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 raises ValidationError; any API errors bubble up as ApiError.

Return type:

Any

Parameters:

study_key (str) –

validate_batch(study_key, records)[source]
Return type:

Any

Parameters:
  • study_key (str) –

  • records (list[Dict[str, Any]]) –

validate_record(study_key, record)[source]
Return type:

Any

Parameters:
  • study_key (str) –

  • record (Dict[str, Any]) –

imednet.validation.validate_record_data(schema, form_key, data)[source]

Validate data for form_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]) –