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,EnumPossible 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:
objectConsolidated 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:
objectAutomated 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:
imednet_workflows.uat.generator module¶
Synthetic record payload generator for UAT.
- class imednet_workflows.uat.generator.GeneratedRecordSet[source]¶
Bases:
ImednetBaseModelOutput 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:
objectGenerate 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:
spec (UATSpecification) –
snapshot (StudySnapshot) –
subject_keys (list[str] | None) –
data_dictionary (DataDictionary | None) –
schema (ValidationSchemaProtocol | None) –
- 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:
objectAsynchronously 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:
- clear_cache(study_key=None)¶
Clear snapshot cache for one study key or all keys.
- Parameters:
study_key (str | None) –
- Return type:
None
- class imednet_workflows.uat.inspector.StudySchemaInspector[source]¶
Bases:
objectFetch 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:
- clear_cache(study_key=None)¶
Clear snapshot cache for one study key or all keys.
- Parameters:
study_key (str | None) –
- Return type:
None
- class imednet_workflows.uat.inspector.StudySnapshot[source]¶
Bases:
ImednetBaseModelPoint-in-time snapshot of a study’s structural metadata.
- study_key: str¶
Required.
- captured_at: datetime = datetime.now(UTC)¶
- classmethod from_data_dictionary(dd, study_key, *, site_name=None, spec_site_names=None)[source]¶
Synthesize an offline
StudySnapshotfrom a canonicalDataDictionary.- Parameters:
dd (DataDictionary) –
study_key (str) –
site_name (str | None) –
spec_site_names (Sequence[str] | None) –
- Return type:
- model_post_init(_StudySnapshot__context)[source]¶
Initialize derived lookup dictionaries after model initialization.
- Parameters:
_StudySnapshot__context (object) –
- Return type:
None
imednet_workflows.uat.models module¶
Pydantic models describing a complete UAT specification.
- exception imednet_workflows.uat.models.InvalidUATStateTransitionError[source]¶
Bases:
ValueErrorRaised when an invalid UAT workflow state transition is attempted.
- class imednet_workflows.uat.models.RecordTestType[source]¶
Bases:
str,EnumWhat 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:
UATBaseModelForm-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:
UATBaseModelRoot 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]
- class imednet_workflows.uat.models.UATSubjectSpec[source]¶
Bases:
UATBaseModelDefines 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.
- class imednet_workflows.uat.models.UATVariableSpec[source]¶
Bases:
UATBaseModelVariable-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¶
- class imednet_workflows.uat.models.UATWorkflowState[source]¶
Bases:
str,EnumLifecycle 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:
target (UATWorkflowState | str) –
dry_run (bool) –
- 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:
target (UATWorkflowState | str) –
dry_run (bool) –
- Return type:
bool
- class imednet_workflows.uat.models.VariableTestStrategy[source]¶
Bases:
str,EnumHow 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:
- 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:
UATWorkflowAsynchronous 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:
sdk (AsyncImednetFacade) –
batch_size (int) –
poll_interval (float) –
poll_timeout (float) –
seed (int | None) –
data_dictionary (DataDictionary | None) –
on_progress (JobProgressCallback | Callable[[JobStatusEvent], None] | None) –
on_phase_change (Callable[[UATWorkflowState], None] | None) –
- Return type:
None
- build_spec(snapshot, **kwargs)¶
Auto-generate a UATSpecification from the StudySnapshot.
- Parameters:
snapshot (Any) –
kwargs (Any) –
- Return type:
- generate(spec, snapshot, *, data_dictionary=None, schema=None, seed=None)¶
Create synthetic record payloads via SyntheticRecordGenerator.
- Parameters:
spec (UATSpecification) –
snapshot (Any) –
data_dictionary (DataDictionary | None) –
schema (ValidationSchemaProtocol | None) –
seed (int | None) –
- 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:
study_key (str) –
submission_result (SubmissionResult) –
- 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:
- 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:
study_key (str) –
record_sets (list[GeneratedRecordSet]) –
email_notify (bool | str | None) –
schema (ValidationSchemaProtocol | None) –
- Return type:
- 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:
- class imednet_workflows.uat.orchestrator.UATRunPhase[source]¶
Bases:
str,EnumPhases 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:
ImednetBaseModelComplete 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.
- class imednet_workflows.uat.orchestrator.UATSpecificationBuilder[source]¶
Bases:
objectAuto-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:
- resolve_site_name(snapshot, site_name)[source]¶
Validate an explicit site or select the first enrollment-eligible site when None.
- Parameters:
snapshot (StudySnapshot) –
site_name (str | None) –
- 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:
objectEnd-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:
sdk (ImednetFacade) –
batch_size (int) –
poll_interval (float) –
poll_timeout (float) –
seed (int | None) –
data_dictionary (DataDictionary | None) –
on_progress (JobProgressCallback | None) –
on_phase_change (Callable[[UATWorkflowState], None] | None) –
- Return type:
None
- build_spec(snapshot, **kwargs)[source]¶
Auto-generate a UATSpecification from the StudySnapshot.
- Parameters:
snapshot (Any) –
kwargs (Any) –
- Return type:
- generate(spec, snapshot, *, data_dictionary=None, schema=None, seed=None)[source]¶
Create synthetic record payloads via SyntheticRecordGenerator.
- Parameters:
spec (UATSpecification) –
snapshot (Any) –
data_dictionary (DataDictionary | None) –
schema (ValidationSchemaProtocol | None) –
seed (int | None) –
- 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:
study_key (str) –
submission_result (SubmissionResult) –
- Return type:
Any
- 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:
- 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:
study_key (str) –
record_sets (list[GeneratedRecordSet]) –
email_notify (bool | str | None) –
schema (ValidationSchemaProtocol | None) –
- Return type:
- 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:
imednet_workflows.uat.submission module¶
Two-phase bulk record submission workflow for UAT.
- class imednet_workflows.uat.submission.AsyncBulkRecordSubmissionWorkflow[source]¶
Bases:
BulkRecordSubmissionWorkflowAsynchronous 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:
study_key (str) –
record_sets (list[GeneratedRecordSet]) –
email_notify (bool | str | None) –
keyword_tag (str) –
schema (ValidationSchemaProtocol | None) –
resolve_results (bool | None) –
- Return type:
- transition_to(target)¶
Transition the submission workflow to an approved target phase.
- Parameters:
target (SubmissionPhase | str) –
- Return type:
- class imednet_workflows.uat.submission.BatchSubmission[source]¶
Bases:
ImednetBaseModelTracks 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.
- submitted_at: datetime = datetime.now(UTC)¶
- class imednet_workflows.uat.submission.BulkRecordSubmissionWorkflow[source]¶
Bases:
objectTwo-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.
- submit(study_key, record_sets, *, email_notify=None, keyword_tag='UAT', schema=None, resolve_results=None)[source]¶
Execute the two-phase submission synchronously.
- Parameters:
study_key (str) –
record_sets (list[GeneratedRecordSet]) –
email_notify (bool | str | None) –
keyword_tag (str) –
schema (ValidationSchemaProtocol | None) –
resolve_results (bool | None) –
- Return type:
- transition_to(target)[source]¶
Transition the submission workflow to an approved target phase.
- Parameters:
target (SubmissionPhase | str) –
- Return type:
- exception imednet_workflows.uat.submission.BulkSubmissionError[source]¶
Bases:
ExceptionRaised 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:
ValueErrorRaised when an invalid bulk submission phase transition is attempted.
- class imednet_workflows.uat.submission.SubmissionPhase[source]¶
Bases:
StrEnumPhases 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
targetis 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
targetis permitted.- Parameters:
target (SubmissionPhase | str) –
- Return type:
bool
- class imednet_workflows.uat.submission.SubmissionResult[source]¶
Bases:
ImednetBaseModelAggregate 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_phasetoto_phaseis allowed.- Parameters:
from_phase (SubmissionPhase | str) –
to_phase (SubmissionPhase | str) –
- Return type:
bool
- imednet_workflows.uat.submission.normalize_submission_phase(phase)[source]¶
Normalize a phase value into a
SubmissionPhaseenum member.- Parameters:
phase (SubmissionPhase | str) –
- Return type:
- imednet_workflows.uat.submission.validate_submission_transition(from_phase, to_phase)[source]¶
Validate that
from_phasemay transition toto_phase.- Parameters:
from_phase (SubmissionPhase | str) –
to_phase (SubmissionPhase | str) –
- Return type:
bool