imednet_workflows.uat package

UAT specification models.

Submodules

imednet_workflows.uat.engine module

Engine for automated UAT (User Acceptance Testing) and edit check verification.

class imednet_workflows.uat.engine.EditCheckResultStatus[source]

Bases: str, Enum

Possible outcomes for an edit check verification rule.

PASS: str = 'Pass'
FAIL: str = 'Fail'
ERROR: str = 'Error'
SKIPPED: str = 'Skipped'
class imednet_workflows.uat.engine.EditCheckVerificationReport[source]

Bases: object

Consolidated report for an automated edit check verification run.

study_key: str

Required.

total_rules: int = 0
passed_rules: int = 0
failed_rules: int = 0
skipped_rules: int = 0
results: list[dict[str, Any]] = list()
class imednet_workflows.uat.engine.UATExecutionEngine[source]

Bases: object

Automated Edit Check Verification execution engine.

__init__(sdk, data_dictionary, *, poll_interval=5.0, poll_timeout=300.0)[source]

Initialize the UAT execution engine.

Parameters:
  • sdk (ImednetFacade) – An instance of the iMednet SDK facade.

  • data_dictionary (DataDictionary) – The data dictionary containing business rules.

  • poll_interval (float) – Seconds between background job status polls.

  • poll_timeout (float) – Maximum seconds to wait for background jobs.

Return type:

None

generate_negative_test_case(rule)[source]

Generate a data payload designed to violate (trigger) the given rule.

Parameters:

rule (dict[str, Any]) –

Return type:

dict[str, Any]

run_verification(study_key, form_scope=None, site_name='TestSite', *, poll_interval=None, poll_timeout=None)[source]

Run the end-to-end UAT verification against the EDC API.

Parameters:
  • study_key (str) –

  • form_scope (str | None) –

  • site_name (str) –

  • poll_interval (float | None) –

  • poll_timeout (float | None) –

Return type:

EditCheckVerificationReport

imednet_workflows.uat.generator module

Synthetic record payload generator for UAT.

class imednet_workflows.uat.generator.GeneratedRecordSet[source]

Bases: ImednetBaseModel

Output of the generator for a single form spec.

form_key: str

Required.

form_name: str

Required.

test_type: RecordTestType

Required.

payloads: list[dict[str, Any]]

Required.

subject_keys: list[str]

Required.

warnings: list[str] = list()
class imednet_workflows.uat.generator.SyntheticRecordGenerator[source]

Bases: object

Generate synthetic record payloads from a UATSpecification and StudySnapshot.

Parameters

seedOptional[int]

Random seed for reproducible generation. None means non-deterministic.

localestr

Locale (no longer used, kept for backwards compatibility).

__init__(seed=None, locale='en_US', data_dictionary=None)[source]

Initialize the generator.

Parameters:
  • seed (int | None) – Optional seed for reproducibility.

  • locale (str) – Ignored.

  • data_dictionary (DataDictionary | None) – Optional DataDictionary used to enrich variable choices and bounds.

Return type:

None

generate(spec, snapshot, *, subject_keys=None, data_dictionary=None, schema=None)[source]

Generate all record payloads for the enabled forms in the spec.

Returns one GeneratedRecordSet per enabled UATFormSpec, in the correct submission order: RegisterSubject records first, then scheduled/unscheduled.

Parameters:
Return type:

list[GeneratedRecordSet]

static resolve_subject_keys(record_sets, enrolled_subject_keys, *, placeholder_keys=None, preserved_keys=None)[source]

Bind server-assigned Phase 1 Subject keys into Phase 2 GeneratedRecordSet payloads.

Parameters:
  • record_sets (list[GeneratedRecordSet]) –

  • enrolled_subject_keys (list[str]) –

  • placeholder_keys (list[str | None] | list[str] | None) –

  • preserved_keys (set[str] | None) –

Return type:

dict[str, str]

imednet_workflows.uat.inspector module

Study metadata inspector for UAT specification generation.

class imednet_workflows.uat.inspector.AsyncStudySchemaInspector[source]

Bases: object

Asynchronously fetch and index structural metadata for an iMednet study.

__init__(sdk)[source]

Initialize the async study schema inspector.

Parameters:

sdk (AsyncImednetFacade) –

Return type:

None

async_inspect(study_key, *, force_refresh=False)[source]

Deprecated alias for inspect().

Parameters:
  • study_key (str) –

  • force_refresh (bool) –

Return type:

StudySnapshot

clear_cache(study_key=None)

Clear snapshot cache for one study key or all keys.

Parameters:

study_key (str | None) –

Return type:

None

async inspect(study_key, *, force_refresh=False)[source]

Asynchronously fetch metadata concurrently and return a study snapshot.

Parameters:
  • study_key (str) –

  • force_refresh (bool) –

Return type:

StudySnapshot

class imednet_workflows.uat.inspector.StudySchemaInspector[source]

Bases: object

Fetch and index all structural metadata for an iMednet study.

__init__(sdk)[source]

Initialize the study schema inspector.

Parameters:

sdk (ImednetFacade | AsyncImednetFacade) –

Return type:

None

async_inspect(study_key, *, force_refresh=False)[source]

Deprecated async alias for fetching metadata concurrently.

Parameters:
  • study_key (str) –

  • force_refresh (bool) –

Return type:

StudySnapshot

clear_cache(study_key=None)

Clear snapshot cache for one study key or all keys.

Parameters:

study_key (str | None) –

Return type:

None

inspect(study_key, *, force_refresh=False)[source]

Synchronously fetch and return a study snapshot.

Parameters:
  • study_key (str) –

  • force_refresh (bool) –

Return type:

StudySnapshot

class imednet_workflows.uat.inspector.StudySnapshot[source]

Bases: ImednetBaseModel

Point-in-time snapshot of a study’s structural metadata.

study_key: str

Required.

captured_at: datetime = datetime.now(UTC)
forms: list[Form]

Required.

variables: list[Variable]

Required.

intervals: list[Interval]

Required.

sites: list[Site]

Required.

forms_by_key: dict[str, Form] = dict()
variables_by_form: dict[str, list[Variable]] = dict()
intervals_by_name: dict[str, Interval] = dict()
active_sites()[source]

Return sites that are actively enrolling.

Return type:

list[Site]

enrollment_forms()[source]

Return active subject registration forms.

Return type:

list[Form]

classmethod from_data_dictionary(dd, study_key, *, site_name=None, spec_site_names=None)[source]

Synthesize an offline StudySnapshot from a canonical DataDictionary.

Parameters:
  • dd (DataDictionary) –

  • study_key (str) –

  • site_name (str | None) –

  • spec_site_names (Sequence[str] | None) –

Return type:

StudySnapshot

model_post_init(_StudySnapshot__context)[source]

Initialize derived lookup dictionaries after model initialization.

Parameters:

_StudySnapshot__context (object) –

Return type:

None

scheduled_forms()[source]

Return active scheduled subject forms (excluding enrollment, unscheduled, and non-subject).

Return type:

list[Form]

unscheduled_forms()[source]

Return active unscheduled subject forms.

Return type:

list[Form]

imednet_workflows.uat.models module

Pydantic models describing a complete UAT specification.

exception imednet_workflows.uat.models.InvalidUATStateTransitionError[source]

Bases: ValueError

Raised when an invalid UAT workflow state transition is attempted.

class imednet_workflows.uat.models.RecordTestType[source]

Bases: str, Enum

What kind of record submission is being tested.

REGISTER_SUBJECT: str = 'register_subject'
UPDATE_SCHEDULED_RECORD: str = 'update_scheduled_record'
CREATE_NEW_RECORD: str = 'create_new_record'
class imednet_workflows.uat.models.UATFormSpec[source]

Bases: UATBaseModel

Form-level UAT test specification.

form_key: str

Required. API field formKey.

form_name: str

Required. API field formName.

form_type: str

Required. API field formType.

test_type: RecordTestType

Required. API field testType.

interval_name: str | None = None

API field intervalName.

subject_count: int = 1

API field subjectCount.

variables: list[UATVariableSpec] = list()
required_variable_names: list[str] = list()

API field requiredVariableNames.

enabled: bool = True
notes: str | None = None
classmethod validate_subject_count(value)[source]

Enforce safe subject count bounds.

Parameters:

value (int) –

Return type:

int

classmethod validate_unique_variable_names(variables)[source]

Ensure variables are uniquely identified by variable_name.

Parameters:

variables (list[UATVariableSpec]) –

Return type:

list[UATVariableSpec]

class imednet_workflows.uat.models.UATSpecification[source]

Bases: UATBaseModel

Root model for a complete UAT test plan.

spec_version: str = '1.0'

API field specVersion.

study_key: str

Required. API field studyKey.

study_name: str

Required. API field studyName.

generated_at: datetime = datetime.now(UTC)

API field generatedAt.

generated_by: str = 'imednet-sdk-uat'

API field generatedBy.

subject_specs: list[UATSubjectSpec] = list()

API field subjectSpecs.

form_specs: list[UATFormSpec] = list()

API field formSpecs.

global_date_value: date | None = None

API field globalDateValue.

global_text_length: int = 10

API field globalTextLength.

forms_snapshot_count: int = 0

API field formsSnapshotCount.

variables_snapshot_count: int = 0

API field variablesSnapshotCount.

intervals_snapshot_count: int = 0

API field intervalsSnapshotCount.

sites_snapshot_count: int = 0

API field sitesSnapshotCount.

seed: int | None = None
enabled_forms()[source]

Return only enabled forms.

Return type:

list[UATFormSpec]

forms_by_type(test_type)[source]

Return enabled forms matching a specific test type.

Parameters:

test_type (RecordTestType) –

Return type:

list[UATFormSpec]

classmethod from_json(payload)[source]

Load a UAT specification from JSON text, bytes, or file path.

Parameters:

payload (str | bytes | Path) –

Return type:

UATSpecification

classmethod validate_spec_version(value)[source]

Pin this release to v1.0 schema.

Parameters:

value (str) –

Return type:

str

class imednet_workflows.uat.models.UATSubjectSpec[source]

Bases: UATBaseModel

Defines synthetic test subjects to register before form submission.

site_name: str

Required. API field siteName.

subject_count: int = 1

API field subjectCount.

subject_key_prefix: str = 'UAT-TEST-'

API field subjectKeyPrefix.

keyword_tag: str = 'UAT'

API field keywordTag.

classmethod validate_subject_count(value)[source]

Enforce safe subject count bounds.

Parameters:

value (int) –

Return type:

int

class imednet_workflows.uat.models.UATVariableSpec[source]

Bases: UATBaseModel

Variable-level test specification.

variable_name: str

Required. API field variableName.

variable_key: str

Required. API field variableKey.

variable_type: str

Required. API field variableType.

form_key: str

Required. API field formKey.

strategy: VariableTestStrategy = <VariableTestStrategy.SYNTHETIC: 'synthetic'>
fixed_value: Any | None = None

API field fixedValue.

min_value: float | None = None

API field minValue.

max_value: float | None = None

API field maxValue.

max_length: int | None = None

API field maxLength.

coded_values: list[str] = list()

API field codedValues.

required: bool = False
notes: str | None = None
classmethod validate_fixed_strategy(data)[source]

Require a fixed value when FIXED strategy is selected.

Parameters:

data (Any) –

Return type:

Any

class imednet_workflows.uat.models.UATWorkflowState[source]

Bases: str, Enum

Lifecycle states for a UAT workflow execution.

PENDING: str = 'PENDING'
INSPECTING: str = 'INSPECTING'
BUILDING_SPEC: str = 'BUILDING_SPEC'
GENERATING: str = 'GENERATING'
SUBMITTING: str = 'SUBMITTING'
MONITORING: str = 'MONITORING'
COMPLETED: str = 'COMPLETED'
FAILED: str = 'FAILED'
property allowed_transitions: set[imednet_workflows.uat.models.UATWorkflowState]

Return the set of allowed target states from this state.

can_transition_to(target, *, dry_run=False)[source]

Check if this state can transition to target state.

Parameters:
Return type:

bool

property is_terminal: bool

Return True if this is a terminal state.

validate_transition_to(target, *, dry_run=False)[source]

Validate transition from this state to target state.

Parameters:
Return type:

bool

class imednet_workflows.uat.models.VariableTestStrategy[source]

Bases: str, Enum

How a variable’s test value should be determined.

SYNTHETIC: str = 'synthetic'
FIXED: str = 'fixed'
SKIP: str = 'skip'
BOUNDARY: str = 'boundary'
CODED_ALL: str = 'coded_all'
imednet_workflows.uat.models.is_valid_uat_transition(from_state, to_state, *, dry_run=False)[source]

Check if transitioning from from_state to to_state is permitted.

Parameters:
  • from_state (UATWorkflowState | str) – The source state.

  • to_state (UATWorkflowState | str) – The target state.

  • dry_run (bool) – Whether dry-run mode is active (allowing GENERATING -> COMPLETED).

Returns:

True if permitted, False otherwise.

Return type:

bool

imednet_workflows.uat.models.normalize_uat_state(state)[source]

Normalize and validate a state into a UATWorkflowState enum member.

Parameters:

state (UATWorkflowState | str) – State to normalize.

Returns:

The normalized UATWorkflowState enum member.

Raises:

InvalidUATStateTransitionError – If the state is not recognized.

Return type:

UATWorkflowState

imednet_workflows.uat.models.validate_uat_transition(from_state, to_state, *, dry_run=False)[source]

Validate that transitioning from from_state to to_state is permitted.

Parameters:
  • from_state (UATWorkflowState | str) – The current or originating state.

  • to_state (UATWorkflowState | str) – The target state.

  • dry_run (bool) – Whether dry-run mode is active (allowing GENERATING -> COMPLETED).

Returns:

True if the transition is permitted.

Raises:

InvalidUATStateTransitionError – If the transition is not allowed.

Return type:

bool

imednet_workflows.uat.orchestrator module

End-to-end UAT execution orchestrator.

class imednet_workflows.uat.orchestrator.AsyncUATWorkflow[source]

Bases: UATWorkflow

Asynchronous end-to-end UAT execution coordinator.

__init__(sdk, *, batch_size=100, poll_interval=10.0, poll_timeout=600.0, seed=None, data_dictionary=None, on_progress=None, on_phase_change=None)[source]

Initialize the async UAT workflow orchestrator.

Parameters:
Return type:

None

build_spec(snapshot, **kwargs)

Auto-generate a UATSpecification from the StudySnapshot.

Parameters:
  • snapshot (Any) –

  • kwargs (Any) –

Return type:

UATSpecification

generate(spec, snapshot, *, data_dictionary=None, schema=None, seed=None)

Create synthetic record payloads via SyntheticRecordGenerator.

Parameters:
Return type:

list[GeneratedRecordSet]

async inspect(study_key)[source]

Asynchronously fetch study metadata via AsyncStudySchemaInspector.

Parameters:

study_key (str) –

Return type:

Any

property last_result: UATRunResult | None

Return the result of the last run execution.

async monitor(study_key, submission_result)[source]

Asynchronously poll all resulting jobs to completion.

Parameters:
Return type:

Any

reset()

Reset the workflow state machine back to PENDING.

Return type:

None

async run(study_key, *, spec=None, subject_count=None, site_name=None, enabled_form_keys=None, email_notify=None, data_dictionary=None, schema=None, seed=None, dry_run=False)[source]

Asynchronously execute the full UAT pipeline and return a UATRunResult.

Parameters:
  • study_key (str) –

  • spec (UATSpecification | None) –

  • subject_count (int | None) –

  • site_name (str | None) –

  • enabled_form_keys (list[str] | None) –

  • email_notify (bool | str | None) –

  • data_dictionary (DataDictionary | None) –

  • schema (ValidationSchemaProtocol | None) –

  • seed (int | None) –

  • dry_run (bool) –

Return type:

UATRunResult

property state: UATWorkflowState

Return the current lifecycle state of the workflow.

property state_history: list[imednet_workflows.uat.models.UATWorkflowState]

Return the recorded history of lifecycle states.

async submit(study_key, record_sets, email_notify=None, *, schema=None)[source]

Asynchronously execute the two-phase bulk submission.

Parameters:
Return type:

SubmissionResult

transition_to(target, *, dry_run=False)

Transition workflow to a new state along an approved lifecycle path.

Parameters:
  • target (UATWorkflowState | str) – Desired target state.

  • dry_run (bool) – Whether dry-run mode is active (allowing GENERATING -> COMPLETED).

Returns:

The newly set state.

Raises:

InvalidUATStateTransitionError – If the transition is not permitted.

Return type:

UATWorkflowState

class imednet_workflows.uat.orchestrator.UATRunPhase[source]

Bases: str, Enum

Phases of a UAT workflow execution.

INSPECT: str = 'inspect'
BUILD_SPEC: str = 'build_spec'
GENERATE: str = 'generate'
SUBMIT: str = 'submit'
MONITOR: str = 'monitor'
class imednet_workflows.uat.orchestrator.UATRunResult[source]

Bases: ImednetBaseModel

Complete result of a UATWorkflow.run() execution.

study_key: str

Required.

run_id: str = str(uuid.uuid4())
started_at: datetime

Required.

completed_at: datetime | None = None
state: UATWorkflowState = <UATWorkflowState.COMPLETED: 'COMPLETED'>
state_history: list[UATWorkflowState] = list()
failure_phase: UATWorkflowState | str | None = None
error_message: str | None = None
spec: UATSpecification | None = None
record_sets: list[GeneratedRecordSet] = list()
submission_result: SubmissionResult | None = None
poll_summary: Any = None
dry_run: bool = False
validation_report: Any = None
phase_durations: dict[str, float] = dict()
property failed_phase: UATWorkflowState | str | None

Alias for failure_phase.

property is_terminal: bool

Return True if the run reached a terminal state.

property overall_success: bool

Return True if all executed phases in the run were successful.

summary()[source]

Return a human-readable summary string suitable for CLI output.

Return type:

str

class imednet_workflows.uat.orchestrator.UATSpecificationBuilder[source]

Bases: object

Auto-generate a UATSpecification from a StudySnapshot.

The generated spec uses SYNTHETIC strategy for all variables. Users can then edit the JSON output to apply FIXED or SKIP strategies for specific variables before feeding it back into UATWorkflow.run().

__init__(data_dictionary=None)[source]

Initialize the specification builder with an optional DataDictionary.

Parameters:

data_dictionary (DataDictionary | None) –

Return type:

None

build(snapshot, *, subject_count=2, site_name=None, enabled_form_keys=None, seed=None, data_dictionary=None)[source]

Build a complete UATSpecification from a StudySnapshot.

Parameters

snapshotStudySnapshot

The study metadata snapshot from StudySchemaInspector.

subject_countint

Number of test subjects to register. Default 2.

site_nameOptional[str]

Site to register subjects at. If None, uses the first active site.

enabled_form_keysOptional[List[str]]

Restrict to a subset of forms. If None, all non-disabled forms are included.

seedOptional[int]

Passed through to UATSpecification for traceability.

data_dictionaryOptional[DataDictionary]

Optional offline DataDictionary providing Choice lists, bounds, and required policies.

Parameters:
  • snapshot (StudySnapshot) –

  • subject_count (int) –

  • site_name (str | None) –

  • enabled_form_keys (list[str] | None) –

  • seed (int | None) –

  • data_dictionary (DataDictionary | None) –

Return type:

UATSpecification

resolve_site_name(snapshot, site_name)[source]

Validate an explicit site or select the first enrollment-eligible site when None.

Parameters:
Return type:

str

validate_enabled_form_keys(snapshot, enabled_form_keys)[source]

Validate requested form keys exist on the snapshot and are not disabled.

Parameters:
  • snapshot (StudySnapshot) –

  • enabled_form_keys (list[str] | None) –

Return type:

list[str] | None

class imednet_workflows.uat.orchestrator.UATWorkflow[source]

Bases: object

End-to-end UAT execution coordinator.

Composes StudySchemaInspector, UATSpecificationBuilder, SyntheticRecordGenerator, BulkRecordSubmissionWorkflow, and JobPoller into a single pipeline.

__init__(sdk, *, batch_size=100, poll_interval=10.0, poll_timeout=600.0, seed=None, data_dictionary=None, on_progress=None, on_phase_change=None)[source]

Initialize the UAT workflow orchestrator.

Parameters:
Return type:

None

build_spec(snapshot, **kwargs)[source]

Auto-generate a UATSpecification from the StudySnapshot.

Parameters:
  • snapshot (Any) –

  • kwargs (Any) –

Return type:

UATSpecification

generate(spec, snapshot, *, data_dictionary=None, schema=None, seed=None)[source]

Create synthetic record payloads via SyntheticRecordGenerator.

Parameters:
Return type:

list[GeneratedRecordSet]

inspect(study_key)[source]

Fetch study metadata via StudySchemaInspector.

Parameters:

study_key (str) –

Return type:

Any

property last_result: UATRunResult | None

Return the result of the last run execution.

monitor(study_key, submission_result)[source]

Poll all resulting jobs to completion via facade poll_jobs (or JobPoller fallback).

Parameters:
Return type:

Any

reset()[source]

Reset the workflow state machine back to PENDING.

Return type:

None

run(study_key, *, spec=None, subject_count=None, site_name=None, enabled_form_keys=None, email_notify=None, data_dictionary=None, schema=None, seed=None, dry_run=False)[source]

Execute the full UAT pipeline synchronously.

Parameters:
  • study_key (str) –

  • spec (UATSpecification | None) –

  • subject_count (int | None) –

  • site_name (str | None) –

  • enabled_form_keys (list[str] | None) –

  • email_notify (bool | str | None) –

  • data_dictionary (DataDictionary | None) –

  • schema (ValidationSchemaProtocol | None) –

  • seed (int | None) –

  • dry_run (bool) –

Return type:

UATRunResult

property state: UATWorkflowState

Return the current lifecycle state of the workflow.

property state_history: list[imednet_workflows.uat.models.UATWorkflowState]

Return the recorded history of lifecycle states.

submit(study_key, record_sets, email_notify=None, *, schema=None)[source]

Execute the two-phase bulk submission.

Parameters:
Return type:

SubmissionResult

transition_to(target, *, dry_run=False)[source]

Transition workflow to a new state along an approved lifecycle path.

Parameters:
  • target (UATWorkflowState | str) – Desired target state.

  • dry_run (bool) – Whether dry-run mode is active (allowing GENERATING -> COMPLETED).

Returns:

The newly set state.

Raises:

InvalidUATStateTransitionError – If the transition is not permitted.

Return type:

UATWorkflowState

imednet_workflows.uat.submission module

Two-phase bulk record submission workflow for UAT.

class imednet_workflows.uat.submission.AsyncBulkRecordSubmissionWorkflow[source]

Bases: BulkRecordSubmissionWorkflow

Asynchronous two-phase bulk record submission for UAT scenarios.

__init__(sdk, batch_size=100, await_registration=True, registration_timeout=600.0, skip_existing_subjects=True, registration_poll_interval=None, resolve_results=True)[source]

Initialize the async bulk record submission workflow.

Parameters:
  • sdk (AsyncImednetFacade) –

  • batch_size (int) –

  • await_registration (bool) –

  • registration_timeout (float) –

  • skip_existing_subjects (bool) –

  • registration_poll_interval (float | None) –

  • resolve_results (bool) –

Return type:

None

property phase: SubmissionPhase

Return the current lifecycle phase of the submission workflow.

reset()

Reset the submission workflow phase back to PENDING.

Return type:

None

async submit(study_key, record_sets, *, email_notify=None, keyword_tag='UAT', schema=None, resolve_results=None)[source]

Asynchronously execute the two-phase submission.

Parameters:
Return type:

SubmissionResult

transition_to(target)

Transition the submission workflow to an approved target phase.

Parameters:

target (SubmissionPhase | str) –

Return type:

SubmissionPhase

class imednet_workflows.uat.submission.BatchSubmission[source]

Bases: ImednetBaseModel

Tracks a single API call to records.create().

phase: Literal['registration', 'data'] | SubmissionPhase

Required.

form_key: str | None = None
form_name: str | None = None
record_count: int

Required.

job: Job

Required.

submitted_at: datetime = datetime.now(UTC)
class imednet_workflows.uat.submission.BulkRecordSubmissionWorkflow[source]

Bases: object

Two-phase bulk record submission for UAT scenarios.

Phase 1: Submit all RegisterSubjectRequest payloads and await job completion. Phase 2: Submit all UpdateScheduledRecordRequest and CreateNewRecordRequest payloads.

Parameters

sdkImednetFacade

Initialized synchronous SDK instance.

batch_sizeint

Maximum number of records per API call. Default: 100.

await_registrationbool

If True, block until all Phase 1 jobs reach terminal state before submitting Phase 2 records. Default: True.

registration_timeoutfloat

Seconds to wait for Phase 1 jobs. Default: 600.

skip_existing_subjectsbool

If True, query the API for existing UAT-tagged subjects and skip registration for any that already exist. Default: True.

__init__(sdk, batch_size=100, await_registration=True, registration_timeout=600.0, skip_existing_subjects=True, registration_poll_interval=None, resolve_results=True)[source]

Initialize the workflow.

Parameters:
  • sdk (ImednetFacade) –

  • batch_size (int) –

  • await_registration (bool) –

  • registration_timeout (float) –

  • skip_existing_subjects (bool) –

  • registration_poll_interval (float | None) –

  • resolve_results (bool) –

Return type:

None

property phase: SubmissionPhase

Return the current lifecycle phase of the submission workflow.

reset()[source]

Reset the submission workflow phase back to PENDING.

Return type:

None

submit(study_key, record_sets, *, email_notify=None, keyword_tag='UAT', schema=None, resolve_results=None)[source]

Execute the two-phase submission synchronously.

Parameters:
Return type:

SubmissionResult

transition_to(target)[source]

Transition the submission workflow to an approved target phase.

Parameters:

target (SubmissionPhase | str) –

Return type:

SubmissionPhase

exception imednet_workflows.uat.submission.BulkSubmissionError[source]

Bases: Exception

Raised when Phase 1 registration jobs fail, blocking Phase 2 submission.

__init__(message, failed_batches)[source]

Initialize the error.

Parameters:
  • message (str) – The error message.

  • failed_batches (list[BatchSubmission]) – List of batches that failed during submission.

Return type:

None

exception imednet_workflows.uat.submission.InvalidSubmissionPhaseTransitionError[source]

Bases: ValueError

Raised when an invalid bulk submission phase transition is attempted.

class imednet_workflows.uat.submission.SubmissionPhase[source]

Bases: StrEnum

Phases of a two-phase bulk submission workflow.

PENDING: str = 'pending'
REGISTRATION: str = 'registration'
AWAITING_REGISTRATION: str = 'awaiting_registration'
DATA: str = 'data'
COMPLETED: str = 'completed'
FAILED: str = 'failed'
property allowed_transitions: set[imednet_workflows.uat.submission.SubmissionPhase]

Return the set of allowed target phases from this phase.

can_transition_to(target)[source]

Return True if transitioning from this phase to target is permitted.

Parameters:

target (SubmissionPhase | str) –

Return type:

bool

property is_terminal: bool

Return True if this submission phase is terminal.

validate_transition_to(target)[source]

Validate that transitioning from this phase to target is permitted.

Parameters:

target (SubmissionPhase | str) –

Return type:

bool

class imednet_workflows.uat.submission.SubmissionResult[source]

Bases: ImednetBaseModel

Aggregate result of a full UAT submission run.

study_key: str

Required.

started_at: datetime

Required.

completed_at: datetime | None = None
registration_batches: list[BatchSubmission] = list()
data_batches: list[BatchSubmission] = list()
enrolled_subject_keys: list[str] = list()
skipped_forms: list[str] = list()
warnings: list[str] = list()
property all_batch_ids: list[str]

Return all batch IDs from all submitted jobs.

property all_batches: list[imednet_workflows.uat.submission.BatchSubmission]

Return all submission batches from both phases.

property total_records_submitted: int

Return the total count of records submitted across all batches.

imednet_workflows.uat.submission.is_valid_submission_transition(from_phase, to_phase)[source]

Return True if transitioning from_phase to to_phase is allowed.

Parameters:
Return type:

bool

imednet_workflows.uat.submission.normalize_submission_phase(phase)[source]

Normalize a phase value into a SubmissionPhase enum member.

Parameters:

phase (SubmissionPhase | str) –

Return type:

SubmissionPhase

imednet_workflows.uat.submission.validate_submission_transition(from_phase, to_phase)[source]

Validate that from_phase may transition to to_phase.

Parameters:
Return type:

bool