imednet.models package¶
Models package for the iMedNet SDK.
This package contains all data models used by the SDK to represent iMedNet resources.
Submodules¶
imednet.models.base module¶
Base models for the iMedNet SDK.
- class imednet.models.base.ApiResponse[source]¶
Bases:
ImednetBaseModelGeneric API response model.
- pagination: Pagination | None = None¶
- data: T | None = None¶
- class imednet.models.base.Error[source]¶
Bases:
ImednetBaseModelError information in an API response.
- code: str = ''¶
Error code
- description: str = ''¶
Error description message
- message: str = ''¶
Error message
- field: ErrorField | None = None¶
Offending request field details
- details: dict[str, Any] = dict()¶
- class imednet.models.base.ErrorField[source]¶
Bases:
ImednetBaseModelOffending request field details in an API error response.
- attribute: str = ''¶
Origination request attribute which caused the error
- variable: str = ''¶
Origination variable which caused the error
- value: str = ''¶
The value of request attribute passed in the request
- class imednet.models.base.ImednetBaseModel[source]¶
Bases:
BaseModelCore base model for all iMedNet API responses.
Design philosophy: extra=’ignore’ silently drops new undocumented fields the API introduces. populate_by_name allows models to be instantiated using either pythonic snake_case names or original API camelCase names via Field aliases. str_strip_whitespace trims leading and trailing whitespace from string values.
- class imednet.models.base.Metadata[source]¶
Bases:
ImednetBaseModelMetadata information in an API response.
- status: str = ''¶
Response status
- method: str = ''¶
HTTP method
- path: str = ''¶
Request path
- timestamp: datetime¶
Required.
- class imednet.models.base.Pagination[source]¶
Bases:
ImednetBaseModelPagination information in an API response.
- current_page: int = 0¶
API field
currentPage.
- size: int = 25¶
- total_pages: int = 0¶
API field
totalPages.
- total_elements: int = 0¶
API field
totalElements.
- class imednet.models.base.SortField[source]¶
Bases:
ImednetBaseModelSorting information for a field in a paginated response.
- property: str¶
Required. Property to sort by
- direction: str¶
Required. Sort direction (ASC or DESC)
imednet.models.codings module¶
Medical coding models for iMedNet.
- class imednet.models.codings.Coding[source]¶
Bases:
ImednetBaseModelRepresents a medical coding entry associated with a record.
- study_key: str | None = None¶
API field
studyKey.
- site_name: str | None = None¶
API field
siteName.
- site_id: int | None = None¶
API field
siteId.
- subject_id: int | None = None¶
API field
subjectId.
- subject_key: str | None = None¶
API field
subjectKey.
- form_id: int | None = None¶
API field
formId.
- form_name: str | None = None¶
API field
formName.
- form_key: str | None = None¶
API field
formKey.
- record_id: int | None = None¶
API field
recordId.
- variable: str | None = None¶
API field
variable.
- value: str | None = None¶
API field
value.
- coding_id: int | None = None¶
API field
codingId.
- code: str | None = None¶
API field
code.
- coded_by: str | None = None¶
API field
codedBy.
- dictionary_name: str | None = None¶
API field
dictionaryName.
- dictionary_version: str | None = None¶
API field
dictionaryVersion.
- date_coded: str | None = None¶
API field
dateCoded.
- reason: str | None = None¶
API field
reason.
- revision: int | None = None¶
API field
revision.
- last_updated: str | None = None¶
API field
lastUpdated.
imednet.models.contract module¶
Unified contract definitions.
- class imednet.models.contract.APIContract[source]¶
Bases:
BaseModelUnified API Contract.
- models: dict[str, ModelDefinition] = dict()¶
- paths: dict[str, str] = dict()¶
- class imednet.models.contract.ContractBuilder[source]¶
Bases:
objectBuilder for APIContract.
- ingest_openapi(file_path)[source]¶
Ingest an OpenAPI specification JSON file.
- Parameters:
file_path (str) –
- Return type:
None
- ingest_postman(file_path)[source]¶
Ingest a Postman collection JSON file.
- Parameters:
file_path (str) –
- Return type:
None
- class imednet.models.contract.FieldDefinition[source]¶
Bases:
BaseModelInternal contract for a model field.
- name: str¶
Required.
- type_name: str¶
Required.
- default_value: Any = None¶
- alias: str | None = None¶
- class imednet.models.contract.ModelDefinition[source]¶
Bases:
BaseModelInternal contract for a model.
- name: str¶
Required.
- fields: dict[str, FieldDefinition]¶
Required.
imednet.models.engine module¶
Dynamic model generation engine based on unified contract schemas.
- class imednet.models.engine.ModelEngine[source]¶
Bases:
objectEngine for dynamically creating Pydantic models from schemas.
- classmethod generate_stubs(output_dir)[source]¶
Generate type stubs for dynamic models.
- Parameters:
output_dir (str) –
- Return type:
None
- classmethod get_model(model_name, base_cls=None)[source]¶
Get or create a dynamic Pydantic model for the given name.
- Parameters:
model_name (str) – The name of the model (e.g., ‘Subject’, ‘Record’).
base_cls (type[Any] | None) – Optional base class override; defaults to the canonical model subclass.
- Returns:
A Pydantic model class.
- Return type:
type[Any]
- classmethod register(model_or_name: type[_ModelT]) type[_ModelT][source]¶
- classmethod register(model_or_name: str) Callable[[type[_ModelT]], type[_ModelT]]
Register and enrich a static model class with dynamic contract fields.
- Parameters:
model_or_name – Either the model class being decorated directly or a contract model name string.
- Returns:
The dynamically enriched Pydantic model subclass, or a class decorator when
model_or_nameis a contract name string.
- class imednet.models.engine.ResourceRegistry[source]¶
Bases:
objectUnified resource governance registry serving as the single source of truth for fields.
imednet.models.forms module¶
Form metadata models for iMedNet.
- class imednet.models.forms.Form[source]¶
Bases:
ImednetBaseModelConfiguration and metadata for a CRF (Case Report Form).
- subject_record_report: bool | None = None¶
API field
subjectRecordReport.
- unscheduled_visit: bool | None = None¶
API field
unscheduledVisit.
- disabled: bool | None = None¶
- study_key: str | None = None¶
API field
studyKey.
- form_id: int | None = None¶
API field
formId.
- form_key: str | None = None¶
API field
formKey.
- form_name: str | None = None¶
API field
formName.
- form_type: str | None = None¶
API field
formType.
- revision: int | None = None¶
API field
revision.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- epro_form: bool | None = None¶
API field
eproForm.
- allow_copy: bool | None = None¶
API field
allowCopy.
- embedded_log: bool | None = None¶
API field
embeddedLog.
- enforce_ownership: bool | None = None¶
API field
enforceOwnership.
- other_forms: bool | None = None¶
API field
otherForms.
- user_agreement: bool | None = None¶
API field
userAgreement.
- last_updated: str | None = None¶
API field
lastUpdated.
imednet.models.intervals module¶
Interval (visit definition) models for iMedNet.
- class imednet.models.intervals.FormSummary[source]¶
Bases:
ImednetBaseModelMinimal form details embedded within an interval definition.
- form_id: int | None = None¶
API field
formId.
- form_key: str | None = None¶
API field
formKey.
- form_name: str | None = None¶
API field
formName.
- class imednet.models.intervals.Interval[source]¶
Bases:
ImednetBaseModelRepresents a visit interval or event within the study timeline.
- forms: list[FormSummary] | None = None¶
- study_key: str | None = None¶
API field
studyKey.
- interval_id: int | None = None¶
API field
intervalId.
- interval_name: str | None = None¶
API field
intervalName.
- interval_description: str | None = None¶
API field
intervalDescription.
- interval_sequence: int | None = None¶
API field
intervalSequence.
- interval_group_id: int | None = None¶
API field
intervalGroupId.
- interval_group_name: str | None = None¶
API field
intervalGroupName.
- disabled: bool | None = None¶
API field
disabled.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- actual_date: str | None = None¶
API field
actualDate.
- actual_date_form: str | None = None¶
API field
actualDateForm.
- defined_using_interval: str | None = None¶
API field
definedUsingInterval.
- due_date_will_be_in: int | None = None¶
API field
dueDateWillBeIn.
- epro_grace_period: int | None = None¶
API field
eproGracePeriod.
- negative_slack: int | None = None¶
API field
negativeSlack.
- positive_slack: int | None = None¶
API field
positiveSlack.
- timeline: str | None = None¶
API field
timeline.
- window_calculation_date: str | None = None¶
API field
windowCalculationDate.
- window_calculation_form: str | None = None¶
API field
windowCalculationForm.
- last_updated: str | None = None¶
API field
lastUpdated.
imednet.models.jobs module¶
Job and background operation models for iMedNet.
- exception imednet.models.jobs.InvalidJobStateError[source]¶
Bases:
ImednetError,ValueErrorRaised when an unrecognized job state string is encountered.
- __init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)¶
Initialize the error.
- Parameters:
message (str) –
status_code (int | None) –
code (int | None) –
status (Any) –
diagnostic_context (DiagnosticContext | None) –
- Return type:
None
- property attempt_count: int | None¶
Return the number of attempts executed before failure, if present.
- property cause_type: str | None¶
Return the underlying exception class name, if present.
- property method: str | None¶
Return the HTTP method from
diagnostic_context, if present.
- property retry_after: float | None¶
Return the parsed
Retry-Afterdelay in seconds, if present.
- property url: str | None¶
Return the sanitized request URL from
diagnostic_context, if present.
- exception imednet.models.jobs.InvalidJobTransitionError[source]¶
Bases:
ImednetError,ValueErrorRaised when an invalid state transition is attempted.
- __init__(message='', status_code=None, code=None, status=None, *, diagnostic_context=None)¶
Initialize the error.
- Parameters:
message (str) –
status_code (int | None) –
code (int | None) –
status (Any) –
diagnostic_context (DiagnosticContext | None) –
- Return type:
None
- property attempt_count: int | None¶
Return the number of attempts executed before failure, if present.
- property cause_type: str | None¶
Return the underlying exception class name, if present.
- property method: str | None¶
Return the HTTP method from
diagnostic_context, if present.
- property retry_after: float | None¶
Return the parsed
Retry-Afterdelay in seconds, if present.
- property url: str | None¶
Return the sanitized request URL from
diagnostic_context, if present.
- imednet.models.jobs.InvalidStateTransitionError¶
alias of
InvalidJobTransitionError
- class imednet.models.jobs.Job[source]¶
Bases:
ImednetBaseModelRepresents an asynchronous background job.
- job_id: str | None = None¶
API field
jobId.
- batch_id: str | None = None¶
API field
batchId.
- date_created: str | None = None¶
API field
dateCreated.
- date_finished: str | None = None¶
API field
dateFinished.
- date_started: str | None = None¶
API field
dateStarted.
- property is_failed: bool¶
Checks if the job failed or was cancelled.
- property is_successful: bool¶
Checks if the job completed successfully.
- property is_terminal: bool¶
Checks if the job has reached a final state (Success/Failed/Cancelled).
- class imednet.models.jobs.JobState[source]¶
Bases:
str,EnumEnumeration of valid job states.
- PENDING: str = 'PENDING'¶
- QUEUED: str = 'QUEUED'¶
- OPEN: str = 'OPEN'¶
- RUNNING: str = 'RUNNING'¶
- PROCESSING: str = 'PROCESSING'¶
- COMPLETED: str = 'COMPLETED'¶
- COMPLETE: str = 'COMPLETE'¶
- SUCCESS: str = 'SUCCESS'¶
- FAILED: str = 'FAILED'¶
- CANCELLED: str = 'CANCELLED'¶
- TIMEOUT: str = 'TIMEOUT'¶
- property allowed_transitions: set[imednet.models.jobs.JobState]¶
Return the set of allowed target states from this state.
- class imednet.models.jobs.JobStatus[source]¶
Bases:
JobExtended job information returned when polling.
- job_id: str | None = None¶
API field
jobId.
- batch_id: str | None = None¶
API field
batchId.
- date_created: str | None = None¶
API field
dateCreated.
- date_finished: str | None = None¶
API field
dateFinished.
- date_started: str | None = None¶
API field
dateStarted.
- progress: int | None = None¶
- result_url: str | None = None¶
API field
resultUrl.
- results: Any = None¶
- record_total_count: int | None = None¶
API field
totalRecords.
- record_success_count: int | None = None¶
API field
successfulRecords.
- record_failure_count: int | None = None¶
API field
failedRecords.
- result_error: str | None = None¶
API field
resultError.
- property failed_records: int | None¶
Return the total number of failed records processed, or None when unknown.
- property is_failed: bool¶
Checks if the job failed, was cancelled, or finished with record/result errors.
- property is_successful: bool¶
Checks if the job completed in a success state with zero failed records.
- property is_terminal: bool¶
Checks if the job has reached a final state (Success/Failed/Cancelled).
- property successful_records: int | None¶
Return the total number of successful records processed, or None when unknown.
- property total_records: int | None¶
Return the total number of records processed, or None when unknown.
- imednet.models.jobs.is_valid_job_transition(from_state, to_state)[source]¶
Check if transitioning from from_state to to_state is permitted.
- imednet.models.jobs.normalize_job_state(state)[source]¶
Normalize and validate a job state string into a JobState enum member.
- Parameters:
state (JobState | str) – The job state to normalize (JobState enum member or string).
- Returns:
The normalized JobState enum member.
- Raises:
InvalidJobStateError – If the state string is unrecognized.
- Return type:
- imednet.models.jobs.validate_job_transition(from_state, to_state)[source]¶
Validate that transitioning from from_state to to_state is permitted.
- Parameters:
- Returns:
True if the transition is valid.
- Raises:
InvalidJobStateError – If either state is not a recognized JobState.
InvalidJobTransitionError – If the transition moves backwards or is not permitted.
- Return type:
bool
imednet.models.queries module¶
Query and annotation models for iMedNet.
- class imednet.models.queries.Query[source]¶
Bases:
ImednetBaseModelRepresents a data query (discrepancy) raised on a record.
- query_comments: list[QueryComment] | None = list()¶
API field
queryComments.
- status: QueryStatus = <QueryStatus.OPEN: 'OPEN'>¶
- study_key: str | None = None¶
API field
studyKey.
- subject_id: int | None = None¶
API field
subjectId.
- annotation_id: int | None = None¶
API field
annotationId.
- description: str | None = None¶
API field
description.
- record_id: int | None = None¶
API field
recordId.
- variable: str | None = None¶
API field
variable.
- subject_key: str | None = None¶
API field
subjectKey.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- annotation_type: str | None = None¶
API field
annotationType.
- subject_oid: str | None = None¶
API field
subjectOid.
- type: str | None = None¶
API field
type.
- last_updated: str | None = None¶
API field
lastUpdated.
- can_transition_to(target_status)[source]¶
Determine if transitioning to target_status is permissible.
- Parameters:
target_status (QueryStatus | str) –
- Return type:
bool
- transition_to(target_status)[source]¶
Transition query to a new status with validation.
- Parameters:
target_status (QueryStatus | str) –
- Return type:
- update_status(target_status)[source]¶
Update query discrepancy status, validating state lifecycle rules.
- Parameters:
target_status (QueryStatus | str) –
- Return type:
- class imednet.models.queries.QueryComment[source]¶
Bases:
ImednetBaseModelA comment or response within a data query thread.
- closed: bool | None = None¶
- sequence: int | None = None¶
- annotation_status: str | None = None¶
API field
annotationStatus.
- user: str | None = None¶
- comment: str | None = None¶
- date: str | None = None¶
- class imednet.models.queries.QueryStatus[source]¶
Bases:
str,EnumEnumeration of clinical query discrepancy lifecycle states.
- OPEN: str = 'OPEN'¶
- ANSWERED: str = 'ANSWERED'¶
- CLOSED: str = 'CLOSED'¶
- CANCELLED: str = 'CANCELLED'¶
- property allowed_transitions: set[imednet.models.queries.QueryStatus]¶
Set of permissible next statuses from the current query state.
- can_transition_to(target)[source]¶
Check whether a transition to target query status is allowed.
- Parameters:
target (QueryStatus | str) –
- Return type:
bool
- validate_transition_to(target)[source]¶
Validate transition to target status, raising ValueError if disallowed.
- Parameters:
target (QueryStatus | str) –
- Return type:
bool
- imednet.models.queries.calculate_legacy_status(query_comments)[source]¶
Calculate fallback QueryStatus for legacy payloads lacking explicit status.
- Parameters:
query_comments (list[Any] | None) –
- Return type:
- imednet.models.queries.is_valid_query_transition(from_status, to_status)[source]¶
Check if transitioning between query discrepancy statuses is permitted.
- Parameters:
from_status (QueryStatus | str) –
to_status (QueryStatus | str) –
- Return type:
bool
- imednet.models.queries.is_valid_transition(from_status, to_status)¶
Check if transitioning between query discrepancy statuses is permitted.
- Parameters:
from_status (QueryStatus | str) –
to_status (QueryStatus | str) –
- Return type:
bool
- imednet.models.queries.validate_query_transition(from_status, to_status)[source]¶
Validate query status change, raising ValueError on forbidden transitions.
- Parameters:
from_status (QueryStatus | str) –
to_status (QueryStatus | str) –
- Return type:
bool
- imednet.models.queries.validate_transition(from_status, to_status)¶
Validate query status change, raising ValueError on forbidden transitions.
- Parameters:
from_status (QueryStatus | str) –
to_status (QueryStatus | str) –
- Return type:
bool
imednet.models.record_revisions module¶
Record revision history models for iMedNet.
- class imednet.models.record_revisions.RecordRevision[source]¶
Bases:
ImednetBaseModelHistorical version of a record including change reason and user.
- record_revision: int | None = None¶
API field
recordRevision.
- data_revision: int | None = None¶
API field
dataRevision.
- record_status: RecordStatus | str | None = None¶
API field
recordStatus.
- study_key: str | None = None¶
API field
studyKey.
- record_revision_id: int | None = None¶
API field
recordRevisionId.
- record_id: int | None = None¶
API field
recordId.
- subject_id: int | None = None¶
API field
subjectId.
- subject_key: str | None = None¶
API field
subjectKey.
- site_id: int | None = None¶
API field
siteId.
- form_key: str | None = None¶
API field
formKey.
- interval_id: int | None = None¶
API field
intervalId.
- deleted: bool | None = None¶
API field
deleted.
- date_created: str | None = None¶
API field
dateCreated.
- reason_for_change: str | None = None¶
API field
reasonForChange.
- record_oid: str | None = None¶
API field
recordOid.
- role: str | None = None¶
API field
role.
- subject_oid: str | None = None¶
API field
subjectOid.
- user: str | None = None¶
API field
user.
- last_updated: str | None = None¶
API field
lastUpdated.
- can_follow(previous, *, allow_partial=False)[source]¶
Return True if this revision monotonically follows previous.
- Parameters:
previous (RecordRevision) –
allow_partial (bool) –
- Return type:
bool
- classmethod validate_chain(revisions, *, allow_partial=False)[source]¶
Validate a chronological sequence of record revisions for monotonicity.
- Parameters:
revisions (Sequence[RecordRevision | dict[str, Any]]) –
allow_partial (bool) –
- Return type:
list[RecordRevision]
- validate_follows(previous, *, allow_partial=False)[source]¶
Validate that this revision chronologically follows previous.
- Parameters:
previous (RecordRevision) – Immediately preceding revision in the sequence.
allow_partial (bool) – When True, allow gaps > +1 in
record_revisionfor actor-filtered or date-bounded audit slices while still enforcing strictly increasingrecord_revision, non-decreasingdata_revision, ordereddate_createdtimestamps, and irreversible deletions.
- Return type:
bool
- imednet.models.record_revisions.is_valid_record_revision_chain(revisions, *, allow_partial=False)[source]¶
Return True if revisions satisfy bounds and monotonic chain invariants.
- Parameters:
revisions (Sequence[RecordRevision | dict[str, Any]]) –
allow_partial (bool) –
- Return type:
bool
- imednet.models.record_revisions.validate_record_revision_chain(revisions, *, allow_partial=False)[source]¶
Validate strict or partial-slice 21 CFR Part 11 invariants across revisions.
- Parameters:
revisions (Sequence[RecordRevision | dict[str, Any]]) –
allow_partial (bool) –
- Return type:
list[RecordRevision]
imednet.models.records module¶
Record (form instance) models for iMedNet.
- class imednet.models.records.BaseRecordRequest[source]¶
Bases:
ImednetBaseModelBase class for record creation and update requests.
Declares all 14 optional iMednet REST API
POST /recordswrite attributes withNonedefaults, forbids undeclared keys (extra="forbid"), and serializes to camelCase keys omittingNoneand blank identifiers by default.- form_key: str | None = None¶
API field
formKey.
- form_id: int | None = None¶
API field
formId.
- site_name: str | None = None¶
API field
siteName.
- site_id: int | None = None¶
API field
siteId.
- subject_key: str | None = None¶
API field
subjectKey.
- subject_id: int | None = None¶
API field
subjectId.
- subject_oid: str | None = None¶
API field
subjectOid.
- interval_name: str | None = None¶
API field
intervalName.
- interval_id: int | None = None¶
API field
intervalId.
- visit_id: int | None = None¶
API field
visitId.
- record_id: int | None = None¶
API field
recordId.
- record_oid: str | None = None¶
API field
recordOid.
- record_status: RecordStatus | str | None = None¶
API field
recordStatus.
- reason_for_change: str | None = None¶
API field
reasonForChange.
- data: RecordData = RecordData({})¶
- class imednet.models.records.CreateNewRecordRequest[source]¶
Bases:
BaseRecordRequestPayload for creating a new unscheduled record.
Targets a form and subject via
formKey/formIdandsubjectKey/subjectId/subjectOid, with optional site, interval, status, and audit reason attributes.- form_key: str | None = None¶
API field
formKey.
- form_id: int | None = None¶
API field
formId.
- site_name: str | None = None¶
API field
siteName.
- site_id: int | None = None¶
API field
siteId.
- subject_key: str | None = None¶
API field
subjectKey.
- subject_id: int | None = None¶
API field
subjectId.
- subject_oid: str | None = None¶
API field
subjectOid.
- interval_name: str | None = None¶
API field
intervalName.
- interval_id: int | None = None¶
API field
intervalId.
- visit_id: int | None = None¶
API field
visitId.
- record_id: int | None = None¶
API field
recordId.
- record_oid: str | None = None¶
API field
recordOid.
- record_status: RecordStatus | str | None = None¶
API field
recordStatus.
- reason_for_change: str | None = None¶
API field
reasonForChange.
- data: RecordData = RecordData({})¶
- model_dump(**kwargs)¶
Serialize record request payload to camelCase keys, omitting None fields by default.
- Parameters:
kwargs (Any) –
- Return type:
dict[str, Any]
- class imednet.models.records.Keyword[source]¶
Bases:
ImednetBaseModelA keyword or tag associated with a record.
- keyword_name: str = ''¶
API field
keywordName.
- keyword_key: str = ''¶
API field
keywordKey.
- keyword_id: int | None = None¶
API field
keywordId.
- date_added: datetime | None = None¶
API field
dateAdded.
- class imednet.models.records.Record[source]¶
Bases:
ImednetBaseModelA data record for a subject, form, and visit.
- record_data: dict[str, Any] | None = dict()¶
API field
recordData.
- record_status: RecordStatus | str | None = None¶
API field
recordStatus.
- deleted: bool | None = None¶
- study_key: str | None = None¶
API field
studyKey.
- interval_id: int | None = None¶
API field
intervalId.
- form_id: int | None = None¶
API field
formId.
- form_key: str | None = None¶
API field
formKey.
- site_id: int | None = None¶
API field
siteId.
- record_id: int | None = None¶
API field
recordId.
- record_oid: str | None = None¶
API field
recordOid.
- record_type: str | None = None¶
API field
recordType.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- subject_id: int | None = None¶
API field
subjectId.
- subject_oid: str | None = None¶
API field
subjectOid.
- subject_key: str | None = None¶
API field
subjectKey.
- visit_id: int | None = None¶
API field
visitId.
- parent_record_id: int | None = None¶
API field
parentRecordId.
- last_updated: str | None = None¶
API field
lastUpdated.
- can_transition_to(target_status)[source]¶
Return True if transitioning to target_status is allowed.
- Parameters:
target_status (RecordStatus | str) –
- Return type:
bool
- property effective_status: RecordStatus | str | None¶
Return DELETED when
deleted=True, otherwiserecord_status.
- property is_deleted: bool¶
Return True when the record is soft-deleted.
- transition_to(target_status)[source]¶
Transition record to target_status, enforcing soft-delete invariants.
- Parameters:
target_status (RecordStatus | str) –
- Return type:
RecordStatus | str
- update_status(target_status)[source]¶
Alias for
transition_to().- Parameters:
target_status (RecordStatus | str) –
- Return type:
RecordStatus | str
- class imednet.models.records.RecordData[source]¶
Bases:
RootModel[dict[str, Any]]Arbitrary record data as a dictionary.
- root: RootModelRootType¶
Required.
- class imednet.models.records.RecordJobResponse[source]¶
Bases:
ImednetBaseModelResponse for a record-related job (batch operations, etc).
- job_id: str = ''¶
API field
jobId.
- batch_id: str = ''¶
API field
batchId.
- state: str = ''¶
- class imednet.models.records.RecordStatus[source]¶
Bases:
str,EnumNormalized lifecycle statuses for eCRF form records.
- RECORD_INCOMPLETE: str = 'Record Incomplete'¶
- RECORD_COMPLETE: str = 'Record Complete'¶
- INCOMPLETE: str = 'Incomplete'¶
- COMPLETE: str = 'Complete'¶
- PARTIAL: str = 'Partial'¶
- LOCKED: str = 'Locked'¶
- FROZEN: str = 'Frozen'¶
- SIGNED: str = 'Signed'¶
- VERIFIED: str = 'Verified'¶
- APPROVED: str = 'Approved'¶
- DELETED: str = 'DELETED'¶
- property allowed_transitions: set[imednet.models.records.RecordStatus]¶
Return permissible next statuses from this status.
- can_transition_to(target)[source]¶
Return True if transitioning from this status to target is permitted.
- Parameters:
target (RecordStatus | str) –
- Return type:
bool
- validate_transition_to(target)[source]¶
Validate transition to target, raising ValueError if disallowed.
- Parameters:
target (RecordStatus | str) –
- Return type:
bool
- class imednet.models.records.RegisterSubjectRequest[source]¶
Bases:
BaseRecordRequestPayload for registering (enrolling) a new subject.
Typically supplies
formKey(orformId) and a site identifier (siteNameorsiteId). OptionalsubjectKey,subjectId, andsubjectOidattributes are omitted whenNoneor blank so server-assigned subject keys continue working by default; when explicitly supplied, they are preserved for enrollment and deduplication.- form_key: str | None = None¶
API field
formKey.
- form_id: int | None = None¶
API field
formId.
- site_name: str | None = None¶
API field
siteName.
- site_id: int | None = None¶
API field
siteId.
- subject_key: str | None = None¶
API field
subjectKey.
- subject_id: int | None = None¶
API field
subjectId.
- subject_oid: str | None = None¶
API field
subjectOid.
- interval_name: str | None = None¶
API field
intervalName.
- interval_id: int | None = None¶
API field
intervalId.
- visit_id: int | None = None¶
API field
visitId.
- record_id: int | None = None¶
API field
recordId.
- record_oid: str | None = None¶
API field
recordOid.
- record_status: RecordStatus | str | None = None¶
API field
recordStatus.
- reason_for_change: str | None = None¶
API field
reasonForChange.
- data: RecordData = RecordData({})¶
- model_dump(**kwargs)¶
Serialize record request payload to camelCase keys, omitting None fields by default.
- Parameters:
kwargs (Any) –
- Return type:
dict[str, Any]
- class imednet.models.records.UpdateRecordRequest[source]¶
Bases:
BaseRecordRequestPayload for directly updating an existing record by identifier.
Targets an existing record via
recordId,recordOid, orvisitId, with optionalformKey/formId,recordStatus,reasonForChange, and clinicaldataupdates.- form_key: str | None = None¶
API field
formKey.
- form_id: int | None = None¶
API field
formId.
- site_name: str | None = None¶
API field
siteName.
- site_id: int | None = None¶
API field
siteId.
- subject_key: str | None = None¶
API field
subjectKey.
- subject_id: int | None = None¶
API field
subjectId.
- subject_oid: str | None = None¶
API field
subjectOid.
- interval_name: str | None = None¶
API field
intervalName.
- interval_id: int | None = None¶
API field
intervalId.
- visit_id: int | None = None¶
API field
visitId.
- record_id: int | None = None¶
API field
recordId.
- record_oid: str | None = None¶
API field
recordOid.
- record_status: RecordStatus | str | None = None¶
API field
recordStatus.
- reason_for_change: str | None = None¶
API field
reasonForChange.
- data: RecordData = RecordData({})¶
- model_dump(**kwargs)¶
Serialize record request payload to camelCase keys, omitting None fields by default.
- Parameters:
kwargs (Any) –
- Return type:
dict[str, Any]
- class imednet.models.records.UpdateScheduledRecordRequest[source]¶
Bases:
BaseRecordRequestPayload for updating an existing scheduled record.
Targets a scheduled form instance via
formKey/formId,subjectKey/subjectId/subjectOid, andintervalName/intervalId(orvisitId), with optionalrecordStatusandreasonForChange.- form_key: str | None = None¶
API field
formKey.
- form_id: int | None = None¶
API field
formId.
- site_name: str | None = None¶
API field
siteName.
- site_id: int | None = None¶
API field
siteId.
- subject_key: str | None = None¶
API field
subjectKey.
- subject_id: int | None = None¶
API field
subjectId.
- subject_oid: str | None = None¶
API field
subjectOid.
- interval_name: str | None = None¶
API field
intervalName.
- interval_id: int | None = None¶
API field
intervalId.
- visit_id: int | None = None¶
API field
visitId.
- record_id: int | None = None¶
API field
recordId.
- record_oid: str | None = None¶
API field
recordOid.
- record_status: RecordStatus | str | None = None¶
API field
recordStatus.
- reason_for_change: str | None = None¶
API field
reasonForChange.
- data: RecordData = RecordData({})¶
- model_dump(**kwargs)¶
Serialize record request payload to camelCase keys, omitting None fields by default.
- Parameters:
kwargs (Any) –
- Return type:
dict[str, Any]
- imednet.models.records.is_valid_record_transition(from_status, to_status, *, deleted=None)[source]¶
Return True if transitioning a record from from_status to to_status is valid.
- Parameters:
from_status (RecordStatus | str | None) –
to_status (RecordStatus | str) –
deleted (bool | None) –
- Return type:
bool
- imednet.models.records.normalize_record_status(value)[source]¶
Normalize known record statuses while preserving custom study status strings.
- Parameters:
value (RecordStatus | str | None) –
- Return type:
RecordStatus | str | None
- imednet.models.records.validate_record_transition(from_status, to_status, *, deleted=None)[source]¶
Validate a record status transition, raising ValueError if soft-deleted or invalid.
- Parameters:
from_status (RecordStatus | str | None) –
to_status (RecordStatus | str) –
deleted (bool | None) –
- Return type:
bool
imednet.models.reporting module¶
Reporting and analysis models for iMedNet, including CDISC-aligned datasets.
- class imednet.models.reporting.AdverseEvent[source]¶
Bases:
ImednetBaseModelCanonical CDISC-aligned Adverse Event (AE) reporting model.
- subject_key: str¶
Required. Unique subject identifier
- ae_term: str¶
Required. Reported term for the adverse event (AETERM)
- ae_decod: str | None = None¶
Dictionary-derived preferred term (AEDECOD)
- ae_severity: str¶
Required. Severity/intensity: MILD, MODERATE, SEVERE (AESEV)
- ae_serious: bool = False¶
Serious Adverse Event flag (AESER)
- ae_start_date: datetime | None = None¶
Start date/time of event (AESTDTC)
- ae_end_date: datetime | None = None¶
End date/time of event (AEENDTC)
- ae_outcome: str | None = None¶
Outcome of adverse event (AEOUT)
- ae_relationship: str | None = None¶
Causality / relationship to study drug/device (AEREL)
- ae_action_taken: str | None = None¶
Action taken with study drug/device (AEACN)
- class imednet.models.reporting.AnalysisAdverseEvent[source]¶
Bases:
ImednetBaseModelAnalysis Adverse Event Dataset (ADAE).
- subject_key: str¶
Required. API field
subjectKey.
- class imednet.models.reporting.AnalysisLabResult[source]¶
Bases:
ImednetBaseModelAnalysis Lab Result Dataset (ADLB).
- subject_key: str¶
Required. API field
subjectKey.
- class imednet.models.reporting.Demographics[source]¶
Bases:
ImednetBaseModelCanonical CDISC-aligned Demographics (DM) reporting model.
- subject_key: str¶
Required. Unique subject identifier
- sex: str¶
Required. Biological sex of the subject (SEX)
- birth_date: datetime | None = None¶
Date of birth of the subject (BRTHDTC)
- age: int | None = None¶
Age in years of the subject (AGE)
- race: str | None = None¶
Reported race of the subject (RACE)
- ethnicity: str | None = None¶
Ethnicity of the subject (ETHNIC)
- class imednet.models.reporting.DeviceDeficiency[source]¶
Bases:
ImednetBaseModelCanonical CDISC-aligned Device Deficiency (DD) reporting model.
- subject_key: str¶
Required. Unique subject identifier
- dd_term: str¶
Required. Deficiency term (DDTERM)
- dd_category: str¶
Required. Category of deficiency (DDCAT)
- dd_serious: bool = False¶
Serious Adverse Event relation flag (DDSPID)
- dd_date: datetime¶
Required. Date/time of deficiency occurrence (DDSTDTC)
- class imednet.models.reporting.ProtocolDeviation[source]¶
Bases:
ImednetBaseModelCanonical CDISC-aligned Protocol Deviation (PD) reporting model.
- subject_key: str¶
Required. Unique subject identifier
- dv_term: str¶
Required. Description of the deviation (DVTERM)
- dv_category: str¶
Required. Deviation category, e.g., ELIGIBILITY, CONSENT, PROCEDURE (DVCAT)
- dv_severity: str¶
Required. Deviation classification: MAJOR, MINOR, CRITICAL
- dv_date: datetime¶
Required. Date/time of deviation (DVSTDTC)
- dv_status: str = 'Unreviewed'¶
Triage status: Unreviewed, Approved, Escalated
- class imednet.models.reporting.SubjectLevelAnalysis[source]¶
Bases:
ImednetBaseModelSubject-Level Analysis Dataset (ADSL).
- subject_key: str¶
Required. API field
subjectKey.
- imednet.models.reporting.VitalSign¶
alias of
VitalSigns
- class imednet.models.reporting.VitalSigns[source]¶
Bases:
ImednetBaseModelCanonical CDISC-aligned Vital Signs (VS) reporting model.
- subject_key: str¶
Required. Unique subject identifier
- vs_test: str¶
Required. Vital signs test name (VSTEST)
- vs_test_cd: str | None = None¶
Vital signs test short code (VSTESTCD)
- vs_result: float | str¶
Required. Vital signs measurement result (VSORRES/VSSTRESN)
- vs_unit: str | None = None¶
Vital signs measurement unit (VSORRESU/VSSTRESU)
- vs_date: datetime¶
Required. Date/time of vital signs measurement (VSDTC)
imednet.models.sdtm module¶
Core CDISC SDTM domain transformation, variable naming, and PHI-safe row mapping.
- async imednet.models.sdtm.async_iter_subject_ordered_sdtm_records(records, *, study_key, sdtm_domain=None, form_domain_map=None, study_config=None, pipeline=<object object>, mask_phi=True, source_is_ordered=False)[source]¶
Asynchronously yield Study Records grouped by Subject and ordered chronologically per domain.
- Parameters:
records (AsyncIterable[Any] | Iterable[Any]) –
study_key (str) –
sdtm_domain (str | None) –
form_domain_map (Mapping[Any, str] | None) –
study_config (Any | None) –
pipeline (Any) –
mask_phi (bool) –
source_is_ordered (bool) –
- Return type:
AsyncIterator[Any]
- imednet.models.sdtm.build_form_sdtm_domain_map(forms=None, *, study_config=None, mappings=None, study_key=None)[source]¶
Build a
{form_id / form_key: SDTM_DOMAIN}map fromFormmetadata &StudyConfiguration.- Parameters:
forms (Iterable[Any] | None) –
study_config (Any | None) –
mappings (Iterable[Any] | None) –
study_key (str | None) –
- Return type:
dict[Any, str]
- imednet.models.sdtm.deduplicate_sdtm_rows(rows)[source]¶
Deduplicate transformed SDTM rows by composite key
(STUDYID, DOMAIN, USUBJID[, <DOM>SEQ]).- Parameters:
rows (Sequence[dict[str, Any]]) –
- Return type:
list[dict[str, Any]]
- imednet.models.sdtm.extract_record_form_ref(rec)[source]¶
Extract
(form_id, form_key)from aRecordmodel or dictionary.- Parameters:
rec (Any) –
- Return type:
tuple[int | None, str | None]
- imednet.models.sdtm.extract_sdtm_composite_key(row)[source]¶
Return
(STUDYID, DOMAIN, USUBJID, seq_col, seq_val)for a transformed SDTM row.- Parameters:
row (Mapping[str, Any]) –
- Return type:
tuple[str, str, str, str | None, int | None] | None
- imednet.models.sdtm.filter_forms_by_sdtm_domain(forms, domain, *, study_config=None, mappings=None, study_key=None)[source]¶
Return forms whose resolved SDTM domain matches
domain.- Parameters:
forms (Iterable[Any]) –
domain (str | None) –
study_config (Any | None) –
mappings (Iterable[Any] | None) –
study_key (str | None) –
- Return type:
list[Any]
- imednet.models.sdtm.format_iso8601_dtc(val, *, mask_phi=False, redact_to_year=False)[source]¶
Convert a timestamp/date value to standard CDISC ISO 8601 DTC string.
- Parameters:
val (Any) – Date, datetime, string, or numeric value to convert.
mask_phi (bool) – When True, redact parsed dates to a four-digit ISO 8601 year or None.
redact_to_year (bool) – Alias for
mask_phito emit onlyYYYYor None.
- Returns:
30:00’, ‘2026-01-15’, or ‘1985’), or None when missing or redacted without a valid year.
- Return type:
Formatted ISO 8601 string (e.g. ‘2026-01-15T09
- imednet.models.sdtm.format_nested_variable_name(name, convention, *, domain=None)[source]¶
Format a flat or dotted/indexed nested clinical variable key using
convention.- Parameters:
name (str) –
convention (str | None) –
domain (str | None) –
- Return type:
str
- imednet.models.sdtm.format_variable_name(name, convention, *, domain=None, is_metadata=False)[source]¶
Format a metadata or clinical variable key using
convention.Supported conventions:
None(unchanged),"snake_case","camelCase","sdtm".- Parameters:
name (str) –
convention (str | None) –
domain (str | None) –
is_metadata (bool) –
- Return type:
str
- imednet.models.sdtm.get_sdtm_domain_variables(domain)[source]¶
Return standard uppercase SDTM variable list for
domain.- Parameters:
domain (str) –
- Return type:
list[str]
- imednet.models.sdtm.iter_subject_ordered_sdtm_records(records, *, study_key, sdtm_domain=None, form_domain_map=None, study_config=None, pipeline=<object object>, mask_phi=True, source_is_ordered=False)[source]¶
Yield active Study Records grouped by Subject and ordered chronologically per SDTM domain.
When
source_is_orderedisTrue(upstream pagination uses_SDTM_RECORDS_SORTandStudyConfigurationdoes not remapUSUBJID), buffers at most one Subject’s Records in memory at a time so streamingbatch_size=1/chunk_size=1exports assign identical<DOM>SEQvalues to full-batch runs.- Parameters:
records (Iterable[Any]) –
study_key (str) –
sdtm_domain (str | None) –
form_domain_map (Mapping[Any, str] | None) –
study_config (Any | None) –
pipeline (Any) –
mask_phi (bool) –
source_is_ordered (bool) –
- Return type:
Iterator[Any]
- imednet.models.sdtm.merge_form_ids_into_record_filter(record_filter, form_ids)[source]¶
Merge domain-matched
formIdvalues into ansdk.records.listfilter.- Parameters:
record_filter (Any) –
form_ids (Sequence[Any] | None) –
- Return type:
Any
- imednet.models.sdtm.normalize_naming_convention(convention)[source]¶
Validate and canonicalize a SinkConfig naming_convention value.
- Parameters:
convention (str | None) –
- Return type:
str | None
- imednet.models.sdtm.prefix_colliding_variable_name(col, metadata_lower=frozenset({}), *, convention=None, used_lower=None)[source]¶
Prefix metadata collisions with
var_/VAR_and disambiguate case-insensitive duplicates.- Parameters:
col (str) –
metadata_lower (Set[str]) –
convention (str | None) –
used_lower (set[str] | None) –
- Return type:
str
- imednet.models.sdtm.record_matches_sdtm_domain(rec, domain, form_domain_map=None, *, study_config=None, mappings=None, study_key=None)[source]¶
Return True when
recbelongs todomain(via Form map,StudyConfiguration, or key).- Parameters:
rec (Any) –
domain (str) –
form_domain_map (Mapping[Any, str] | None) –
study_config (Any | None) –
mappings (Iterable[Any] | None) –
study_key (str | None) –
- Return type:
bool
- imednet.models.sdtm.resolve_form_sdtm_domain(form, *, study_config=None, mappings=None, study_key=None, form_domain_map=None, fallback='AE', _cfg_lookup=None)[source]¶
Resolve the canonical SDTM domain for a
Form, mapping dict, or form key/name string.- Parameters:
form (Any) –
study_config (Any | None) –
mappings (Iterable[Any] | None) –
study_key (str | None) –
form_domain_map (Mapping[Any, str] | None) –
fallback (str) –
_cfg_lookup (Mapping[str, str] | None) –
- Return type:
str
- imednet.models.sdtm.resolve_sdtm_domain(domain, *, fallback='AE')[source]¶
Canonicalize an SDTM domain code or form/domain alias (e.g. ‘PD’ -> ‘DV’).
- Parameters:
domain (str | None) –
fallback (str) –
- Return type:
str
- imednet.models.sdtm.transform_records_to_sdtm(records, domain, study_key, *, include_deleted=False, mask_phi=True, seq_counters=None, record_seqs=None, preserve_record_id=False, seq_overrides=None, lineage_out=None, phi_keys=None, registry=None, pipeline=<object object>, enrichment_pipeline=<object object>)[source]¶
Transform clinical records into a normalized CDISC SDTM domain DataFrame.
Maps subject keys to USUBJID, study keys to STUDYID, sorts records per subject by canonical
--DTCtimestamp, domain topic variable, and record identifier, sequences records per subject (omittingDMSEQonDM), enforces PHI redaction andStudyConfigurationrules, and converts event timestamps to standard ISO 8601 DTC string formats.- Parameters:
records (Iterable[Any]) –
domain (str) –
study_key (str) –
include_deleted (bool) –
mask_phi (bool) –
seq_counters (dict[str, int] | None) –
record_seqs (dict[str, int] | None) –
preserve_record_id (bool) –
seq_overrides (Mapping[str, int] | None) –
lineage_out (dict[str, dict[str, Any]] | None) –
phi_keys (Iterable[str] | None) –
registry (SensitivityRegistry | None) –
pipeline (Any) –
enrichment_pipeline (Any) –
- Return type:
DataFrame
- imednet.models.sdtm.transform_records_to_sdtm_rows(records, domain, study_key, *, include_deleted=False, mask_phi=True, seq_counters=None, record_seqs=None, preserve_record_id=False, seq_overrides=None, lineage_out=None, phi_keys=None, registry=None, pipeline=<object object>, enrichment_pipeline=<object object>)[source]¶
Transform clinical records into normalized CDISC SDTM row dictionaries.
Applies
SensitivityRegistryand customphi_keys/EnrichmentPipelinemasking before constructingUSUBJIDor mapping SDTM domain variables, redacts maskedBRTHDTCvalues to 4-digit ISO 8601 years orNone, sorts records per subject by(--DTC, topic_vars, recordId), omitsDMSEQonDM, and maintains per-USUBJIDsequence counters across streaming batches whenseq_countersis supplied.- Parameters:
records (Iterable[Any]) –
domain (str) –
study_key (str) –
include_deleted (bool) –
mask_phi (bool) –
seq_counters (dict[str, int] | None) –
record_seqs (dict[str, int] | None) –
preserve_record_id (bool) –
seq_overrides (Mapping[str, int] | None) –
lineage_out (dict[str, dict[str, Any]] | None) –
phi_keys (Iterable[str] | None) –
registry (SensitivityRegistry | None) –
pipeline (Any) –
enrichment_pipeline (Any) –
- Return type:
list[dict[str, Any]]
imednet.models.sites module¶
Site (study location) models for iMedNet.
- class imednet.models.sites.Site[source]¶
Bases:
ImednetBaseModelA site participating in a study.
- site_enrollment_status: SiteEnrollmentStatus | str | None = None¶
API field
siteEnrollmentStatus.
- study_key: str | None = None¶
API field
studyKey.
- site_id: int | None = None¶
API field
siteId.
- site_name: str | None = None¶
API field
siteName.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- last_updated: str | None = None¶
API field
lastUpdated.
- property is_eligible: bool¶
Alias for
is_enrollment_open.
- property is_enrollment_open: bool¶
Return True when this site is open/active for subject enrollment.
- class imednet.models.sites.SiteEnrollmentStatus[source]¶
Bases:
str,EnumNormalized enrollment lifecycle statuses for study sites.
- ENROLLMENT_OPEN: str = 'Enrollment Open'¶
- ENROLLMENT_CLOSED: str = 'Enrollment Closed'¶
- ACTIVE: str = 'Active'¶
- CLOSED: str = 'Closed'¶
- INACTIVE: str = 'Inactive'¶
- READ_ONLY: str = 'Read Only'¶
- property is_eligible: bool¶
Return True when the site status permits subject enrollment.
- imednet.models.sites.is_site_enrollment_eligible(value)[source]¶
Return True if value represents an open/active enrollment site status.
- Parameters:
value (SiteEnrollmentStatus | str | None) –
- Return type:
bool
- imednet.models.sites.normalize_site_enrollment_status(value)[source]¶
Normalize known site enrollment statuses while preserving custom strings.
- Parameters:
value (SiteEnrollmentStatus | str | None) –
- Return type:
SiteEnrollmentStatus | str | None
imednet.models.standards module¶
Data standard profiles and validation models for clinical domains.
- class imednet.models.standards.BiologicSafetyProfile[source]¶
Bases:
StandardsProfileBiologic safety profile for biologic and biosimilar clinical trials.
- expected_fields(domain)¶
Return the list of expected (required + recommended) fields for a domain.
- Parameters:
domain (str) –
- Return type:
list[str]
- validate(domain, data)¶
Validate a data dictionary against the profile for a specific domain.
- Parameters:
domain (str) – The domain name (e.g., ‘AE’, ‘PD’, ‘DM’, ‘VS’).
data (dict[str, Any]) – The data dictionary to validate.
- Returns:
A list of ValidationViolation objects.
- Return type:
list[ValidationViolation]
- class imednet.models.standards.CategoricalNormalizer[source]¶
Bases:
objectNormalize explicit terminology/date selections without inferring clinical meaning.
- __init__(cdisc_ct=None, *, date_fields=(), boolean_fields=(), date_order=None)[source]¶
Snapshot caller-selected codelists, date fields, and boolean fields.
No unversioned vocabulary or guessed date/boolean field selection is enabled by default. cdisc_ct retains its proposed API name; supplying it does not establish CDISC conformance. Study lookups take precedence over codelists.
- Parameters:
cdisc_ct (dict[str, set[str]] | None) –
date_fields (Collection[str]) –
boolean_fields (Collection[str]) –
date_order (Literal['MDY', 'DMY'] | None) –
- Return type:
None
- normalize_lookups(terminology_lookups=None)[source]¶
Normalize terminology lookup keys for case-insensitive matching.
- Parameters:
terminology_lookups (dict[str, dict[str, str]] | None) –
- Return type:
dict[str, dict[str, str]]
- normalize_record(record, *, terminology_lookups=None, normalized_lookups=None, study_key=None)[source]¶
Normalize a single data record.
- Parameters:
record (dict[str, Any]) –
terminology_lookups (dict[str, dict[str, str]] | None) –
normalized_lookups (dict[str, dict[str, str]] | None) –
study_key (str | None) –
- Return type:
- class imednet.models.standards.DeviceSafetyProfile[source]¶
Bases:
StandardsProfileDevice safety profile including device deficiency (DD) requirements.
- expected_fields(domain)¶
Return the list of expected (required + recommended) fields for a domain.
- Parameters:
domain (str) –
- Return type:
list[str]
- validate(domain, data)[source]¶
Validate device-specific constraints for DD and other domains.
- Parameters:
domain (str) –
data (dict[str, Any]) –
- Return type:
list[ValidationViolation]
- class imednet.models.standards.DrugSafetyProfile[source]¶
Bases:
StandardsProfileDrug safety profile with stricter requirements for AE and safety domains.
- expected_fields(domain)¶
Return the list of expected (required + recommended) fields for a domain.
- Parameters:
domain (str) –
- Return type:
list[str]
- validate(domain, data)¶
Validate a data dictionary against the profile for a specific domain.
- Parameters:
domain (str) – The domain name (e.g., ‘AE’, ‘PD’, ‘DM’, ‘VS’).
data (dict[str, Any]) – The data dictionary to validate.
- Returns:
A list of ValidationViolation objects.
- Return type:
list[ValidationViolation]
- class imednet.models.standards.GeneralClinicalProfile[source]¶
Bases:
StandardsProfileGeneral clinical profile with basic AE, PD, DM, VS, LB, CM, EX, and MH requirements.
- expected_fields(domain)¶
Return the list of expected (required + recommended) fields for a domain.
- Parameters:
domain (str) –
- Return type:
list[str]
- validate(domain, data)¶
Validate a data dictionary against the profile for a specific domain.
- Parameters:
domain (str) – The domain name (e.g., ‘AE’, ‘PD’, ‘DM’, ‘VS’).
data (dict[str, Any]) – The data dictionary to validate.
- Returns:
A list of ValidationViolation objects.
- Return type:
list[ValidationViolation]
- class imednet.models.standards.NormalizationResult[source]¶
Bases:
BaseModelResult of a record normalization operation.
- normalized_record: dict[str, Any]¶
Required.
- warnings: list[str] = list()¶
- class imednet.models.standards.StandardsProfile[source]¶
Bases:
objectA profile defining required, recommended, and optional fields for data domains.
- __init__(*, profile_name, required_fields=None, recommended_fields=None, optional_fields=None, value_constraints=None)[source]¶
Initialize a standards profile.
- Parameters:
profile_name (str) – Unique name for the profile.
required_fields (dict[str, list[str]] | None) – Mapping of domain to required field names.
recommended_fields (dict[str, list[str]] | None) – Mapping of domain to recommended field names.
optional_fields (dict[str, list[str]] | None) – Mapping of domain to optional field names.
value_constraints (dict[str, list[Any]] | None) – Mapping of field or domain.field to allowed values.
- Return type:
None
- expected_fields(domain)[source]¶
Return the list of expected (required + recommended) fields for a domain.
- Parameters:
domain (str) –
- Return type:
list[str]
- validate(domain, data)[source]¶
Validate a data dictionary against the profile for a specific domain.
- Parameters:
domain (str) – The domain name (e.g., ‘AE’, ‘PD’, ‘DM’, ‘VS’).
data (dict[str, Any]) – The data dictionary to validate.
- Returns:
A list of ValidationViolation objects.
- Return type:
list[ValidationViolation]
- class imednet.models.standards.StandardsProfileRegistry[source]¶
Bases:
objectRegistry for managing and retrieving standards profiles.
- get(profile_name)[source]¶
Retrieve a profile by its name.
- Parameters:
profile_name (str) –
- Return type:
- register(profile)[source]¶
Register a new standards profile.
- Parameters:
profile (StandardsProfile) –
- Return type:
None
- class imednet.models.standards.StandardsReadinessReport[source]¶
Bases:
ImednetBaseModelComprehensive report on the readiness of data records against clinical standards.
- score: float¶
Required.
- successfully_validated_fields: int¶
Required.
- total_expected_fields: int¶
Required.
- warnings: list[str] = list()¶
- violations: list[ValidationViolation] = list()¶
- profile: str = 'general'¶
- checked_records: int = 0¶
- domain_scores: dict[str, float] = dict()¶
- property checked_fields: int¶
Alias for
total_expected_fieldsused by CLI and export readiness reports.
- property is_ready: bool¶
Return True when score reaches 100, all domains are ready, and no ERROR violations exist.
- class imednet.models.standards.StandardsReadinessValidator[source]¶
Bases:
objectValidates and scores data records against a clinical standards profile.
- __init__(profile, normalizer=None)[source]¶
Initialize the validator.
- Parameters:
profile (StandardsProfile | str) –
normalizer (CategoricalNormalizer | None) –
- Return type:
None
- class imednet.models.standards.VaccineSafetyProfile[source]¶
Bases:
StandardsProfileVaccine safety profile for immunization and reactogenicity clinical trials.
- expected_fields(domain)¶
Return the list of expected (required + recommended) fields for a domain.
- Parameters:
domain (str) –
- Return type:
list[str]
- validate(domain, data)¶
Validate a data dictionary against the profile for a specific domain.
- Parameters:
domain (str) – The domain name (e.g., ‘AE’, ‘PD’, ‘DM’, ‘VS’).
data (dict[str, Any]) – The data dictionary to validate.
- Returns:
A list of ValidationViolation objects.
- Return type:
list[ValidationViolation]
- class imednet.models.standards.ValidationViolation[source]¶
Bases:
BaseModelRepresents a violation of a data standard constraint.
- field: str¶
Required.
- message: str¶
Required.
- severity: str¶
Required.
- imednet.models.standards.is_valid_cdash_variable(target_field, domain)[source]¶
Check whether a target passes the local CDASH-style naming heuristic.
- Parameters:
target_field (str) –
domain (str) –
- Return type:
bool
- imednet.models.standards.resolve_standards_profile(profile)[source]¶
Resolve a profile name (‘general’, ‘drug’, ‘biologic’, ‘vaccine’, ‘device’) or instance.
- Parameters:
profile (str | StandardsProfile | None) –
- Return type:
- imednet.models.standards.validate_cdash_variable(target_field, domain)[source]¶
Check the local reporting-name syntax and configured domain-prefix policy.
This heuristic accepts project aliases; it does not establish membership in an official CDASH/SDTM version or certify standards conformance.
- Parameters:
target_field (str) – The field name to validate.
domain (str) – The clinical domain code (e.g. ‘AE’, ‘PD’, ‘DD’).
- Returns:
A tuple of (is_valid, error_message_or_none).
- Return type:
tuple[bool, str | None]
imednet.models.studies module¶
Study metadata models for iMedNet.
- class imednet.models.studies.Study[source]¶
Bases:
ImednetBaseModelRepresents a clinical study and its metadata.
- sponsor_key: str | None = None¶
API field
sponsorKey.
- study_key: str | None = None¶
API field
studyKey.
- study_id: int | None = None¶
API field
studyId.
- study_name: str | None = None¶
API field
studyName.
- study_description: str | None = None¶
API field
studyDescription.
- study_type: str | None = None¶
API field
studyType.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- last_updated: str | None = None¶
API field
lastUpdated.
imednet.models.study_config module¶
Study configuration models and validation.
This module provides Pydantic models for parsing and validating study configurations, including reporting profiles, widgets, and mapping rules.
- class imednet.models.study_config.MappingRule[source]¶
Bases:
ImednetBaseModelMapping from raw source variable to canonical reporting field.
- domain: str¶
Required.
- target_field: str¶
Required. API field
targetField.
- source_form_key: str¶
Required. API field
sourceFormKey.
- source_variable_name: str¶
Required. API field
sourceVariableName.
- fallback_value: str | None = None¶
API field
fallbackValue.
- business_logic: str | None = None¶
API field
businessLogic.
- is_baseline: bool = False¶
API field
isBaseline.
- strict: bool = False¶
- strict_mode: bool = False¶
API field
strictMode.
- strict_cdash: bool = False¶
API field
strictCdash.
- class imednet.models.study_config.StudyConfiguration[source]¶
Bases:
ImednetBaseModelSerialized study reporting dashboard configuration.
- version: str = '1.0.0'¶
- study_key: str¶
Required. API field
studyKey.
- reporting_profile: str = 'general'¶
API field
reportingProfile.
- mappings: list[MappingRule] = list()¶
- terminology_lookups: dict[str, dict[str, str]] = dict()¶
API field
terminologyLookups.
- widgets: list[WidgetConfig] = list()¶
- phi_fields: list[str] = list()¶
API field
phiFields.
- strict: bool = False¶
- strict_mode: bool = False¶
API field
strictMode.
- strict_cdash: bool = False¶
API field
strictCdash.
- class imednet.models.study_config.WidgetConfig[source]¶
Bases:
ImednetBaseModelDeclarative dashboard widget configuration.
- widget_id: str¶
Required. API field
widgetId.
- type: str¶
Required.
- title: str¶
Required.
- domain: str¶
Required.
- x_axis: str | None = None¶
API field
xAxis.
- y_axis: str | None = None¶
API field
yAxis.
- layout_cols: int = 12¶
API field
layoutCols.
imednet.models.study_structure module¶
Models for representing the hierarchical structure of a study.
- class imednet.models.study_structure.FormStructure[source]¶
Bases:
ImednetBaseModelHierarchical representation of a form including its variables.
- form_id: int¶
Required. API field
formId.
- form_key: str¶
Required. API field
formKey.
- form_name: str¶
Required. API field
formName.
- form_type: str¶
Required. API field
formType.
- revision: int¶
Required.
- disabled: bool | None = None¶
- epro_form: bool¶
Required. API field
eproForm.
- allow_copy: bool¶
Required. API field
allowCopy.
- date_created: datetime | None = None¶
API field
dateCreated.
- date_modified: datetime | None = None¶
API field
dateModified.
- class imednet.models.study_structure.IntervalStructure[source]¶
Bases:
ImednetBaseModelHierarchical representation of an interval including its forms.
- interval_id: int¶
Required. API field
intervalId.
- interval_name: str¶
Required. API field
intervalName.
- interval_sequence: int¶
Required. API field
intervalSequence.
- interval_description: str¶
Required. API field
intervalDescription.
- interval_group_name: str¶
Required. API field
intervalGroupName.
- disabled: bool | None = None¶
- date_created: datetime | None = None¶
API field
dateCreated.
- date_modified: datetime | None = None¶
API field
dateModified.
- forms: list[FormStructure] = list()¶
- classmethod from_interval(interval, forms)[source]¶
Creates IntervalStructure from an Interval model and its associated FormStructures.
- Parameters:
interval (Interval) –
forms (list[FormStructure]) –
- Return type:
- class imednet.models.study_structure.StudyStructure[source]¶
Bases:
ImednetBaseModelHierarchical representation of a full study including intervals and forms.
- study_key: str¶
Required. API field
studyKey.
- intervals: list[IntervalStructure] = list()¶
- forms: list[FormStructure] = list()¶
imednet.models.subjects module¶
Models for subjects and participant keywords.
- class imednet.models.subjects.Subject[source]¶
Bases:
ImednetBaseModelA subject (participant) in a study, with status and site info.
- keywords: list[SubjectKeyword] | None = list()¶
- subject_status: SubjectStatus | str | None = None¶
API field
subjectStatus.
- deleted: bool | None = None¶
- study_key: str | None = None¶
API field
studyKey.
- subject_id: int | None = None¶
API field
subjectId.
- subject_key: str | None = None¶
API field
subjectKey.
- site_id: int | None = None¶
API field
siteId.
- site_name: str | None = None¶
API field
siteName.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- enrollment_start_date: str | None = None¶
API field
enrollmentStartDate.
- subject_oid: str | None = None¶
API field
subjectOid.
- last_updated: str | None = None¶
API field
lastUpdated.
- can_transition_to(target_status)[source]¶
Return True if transitioning to target_status is allowed.
- Parameters:
target_status (SubjectStatus | str) –
- Return type:
bool
- property effective_status: SubjectStatus | str | None¶
Return DELETED when
deleted=True, otherwisesubject_status.
- property is_deleted: bool¶
Return True when the subject is soft-deleted.
- transition_to(target_status)[source]¶
Transition subject to target_status, enforcing soft-delete invariants.
- Parameters:
target_status (SubjectStatus | str) –
- Return type:
SubjectStatus | str
- update_status(target_status)[source]¶
Alias for
transition_to().- Parameters:
target_status (SubjectStatus | str) –
- Return type:
SubjectStatus | str
- class imednet.models.subjects.SubjectKeyword[source]¶
Bases:
ImednetBaseModelA keyword or tag associated with a subject.
- keyword_name: str = ''¶
API field
keywordName.
- keyword_key: str = ''¶
API field
keywordKey.
- keyword_id: int | None = None¶
API field
keywordId.
- date_added: datetime | None = None¶
API field
dateAdded.
- class imednet.models.subjects.SubjectStatus[source]¶
Bases:
str,EnumNormalized lifecycle statuses for clinical study subjects.
- SCREENED: str = 'Screened'¶
- REGISTERED: str = 'Registered'¶
- BASELINE: str = 'Baseline'¶
- ENROLLED: str = 'Enrolled'¶
- ACTIVE: str = 'Active'¶
- COMPLETED: str = 'Completed'¶
- WITHDRAWN: str = 'Withdrawn'¶
- SCREEN_FAILED: str = 'Screen Failed'¶
- CLOSED: str = 'Closed'¶
- INACTIVE: str = 'Inactive'¶
- DELETED: str = 'DELETED'¶
- property allowed_transitions: set[imednet.models.subjects.SubjectStatus]¶
Return permissible next statuses from this status.
- can_transition_to(target)[source]¶
Return True if transitioning from this status to target is permitted.
- Parameters:
target (SubjectStatus | str) –
- Return type:
bool
- validate_transition_to(target)[source]¶
Validate transition to target, raising ValueError if disallowed.
- Parameters:
target (SubjectStatus | str) –
- Return type:
bool
- imednet.models.subjects.is_valid_subject_transition(from_status, to_status, *, deleted=None)[source]¶
Return True if transitioning a subject from from_status to to_status is valid.
- Parameters:
from_status (SubjectStatus | str | None) –
to_status (SubjectStatus | str) –
deleted (bool | None) –
- Return type:
bool
- imednet.models.subjects.normalize_subject_status(value)[source]¶
Normalize known subject statuses while preserving custom study status strings.
- Parameters:
value (SubjectStatus | str | None) –
- Return type:
SubjectStatus | str | None
- imednet.models.subjects.validate_subject_transition(from_status, to_status, *, deleted=None)[source]¶
Validate a subject status transition, raising ValueError if soft-deleted or invalid.
- Parameters:
from_status (SubjectStatus | str | None) –
to_status (SubjectStatus | str) –
deleted (bool | None) –
- Return type:
bool
imednet.models.triage module¶
Models for triage and reviewer workflows.
- class imednet.models.triage.TriageAnnotation[source]¶
Bases:
ImednetBaseModelReviewer note attached to a triage item.
- annotation_id: str¶
Required.
- user_id: str¶
Required.
- comment: str¶
Required.
- timestamp: datetime¶
Required.
- class imednet.models.triage.TriageHistoryEntry[source]¶
Bases:
ImednetBaseModelStatus transition audit entry for a triage item.
- transition_id: str¶
Required.
- from_status: TriageStatus¶
Required.
- to_status: TriageStatus¶
Required.
- user_id: str¶
Required.
- comment: str | None = None¶
- timestamp: datetime¶
Required.
- class imednet.models.triage.TriageItem[source]¶
Bases:
ImednetBaseModelCore triage item used by queue and reviewer workflows.
- item_id: str¶
Required.
- study_key: str¶
Required.
- status: TriageStatus = <TriageStatus.NEW: 'NEW'>¶
- assignee: str | None = None¶
- severity: str¶
Required.
- annotations: list[TriageAnnotation] = list()¶
- history: list[TriageHistoryEntry] = list()¶
- class imednet.models.triage.TriageStatus[source]¶
Bases:
str,EnumEnumeration of possible triage statuses.
- NEW: str = 'NEW'¶
- UNDER_REVIEW: str = 'UNDER_REVIEW'¶
- RESOLVED: str = 'RESOLVED'¶
- property allowed_transitions: set[imednet.models.triage.TriageStatus]¶
Return the set of allowed target statuses from this status.
- can_transition_to(target)[source]¶
Check if this status can transition to target status.
- Parameters:
target (TriageStatus | str) –
- Return type:
bool
- validate_transition_to(target)[source]¶
Validate transition from this status to target status, raising ValueError if invalid.
- Parameters:
target (TriageStatus | str) –
- Return type:
bool
- imednet.models.triage.can_transition(from_status, to_status)¶
Return whether transitioning from from_status to to_status is permitted.
- Parameters:
from_status (TriageStatus | str) – The source triage status.
to_status (TriageStatus | str) – The target triage status.
- Returns:
True if the transition is allowed, False otherwise.
- Return type:
bool
- imednet.models.triage.is_valid_status_transition(from_status, to_status)¶
Return whether transitioning from from_status to to_status is permitted.
- Parameters:
from_status (TriageStatus | str) – The source triage status.
to_status (TriageStatus | str) – The target triage status.
- Returns:
True if the transition is allowed, False otherwise.
- Return type:
bool
- imednet.models.triage.is_valid_transition(from_status, to_status)[source]¶
Return whether transitioning from from_status to to_status is permitted.
- Parameters:
from_status (TriageStatus | str) – The source triage status.
to_status (TriageStatus | str) – The target triage status.
- Returns:
True if the transition is allowed, False otherwise.
- Return type:
bool
- imednet.models.triage.validate_status_transition(from_status, to_status)¶
Validate that transitioning from from_status to to_status is permitted.
- Parameters:
from_status (TriageStatus | str) – The source triage status.
to_status (TriageStatus | str) – The target triage status.
- Returns:
True if the transition is permitted.
- Raises:
ValueError – If either status is invalid or the transition is forbidden.
- Return type:
bool
- imednet.models.triage.validate_transition(from_status, to_status)[source]¶
Validate that transitioning from from_status to to_status is permitted.
- Parameters:
from_status (TriageStatus | str) – The source triage status.
to_status (TriageStatus | str) – The target triage status.
- Returns:
True if the transition is permitted.
- Raises:
ValueError – If either status is invalid or the transition is forbidden.
- Return type:
bool
imednet.models.users module¶
Models for users and roles within iMedNet.
- class imednet.models.users.Role[source]¶
Bases:
ImednetBaseModelA role assigned to a user within a study or community.
- role_id: str | None = None¶
API field
roleId.
- name: str | None = None¶
- description: str | None = None¶
- level: int | None = None¶
- type: str | None = None¶
- inactive: bool | None = None¶
- community_id: int | None = None¶
API field
communityId.
- date_created: datetime | None = None¶
API field
dateCreated.
- date_modified: datetime | None = None¶
API field
dateModified.
- class imednet.models.users.User[source]¶
Bases:
ImednetBaseModelA user account in the system.
- first_name: str | None = None¶
API field
firstName.
- last_name: str | None = None¶
API field
lastName.
- user_id: str | None = None¶
API field
userId.
- login: str | None = None¶
API field
login.
- email: str | None = None¶
API field
email.
- user_active_in_study: bool | None = None¶
API field
userActiveInStudy.
- property name: str¶
A convenience full-name property so you can do user.name.
instead of f”{user.first_name} {user.last_name}” everywhere.
imednet.models.variables module¶
Models for form variables (data fields) in iMedNet.
- class imednet.models.variables.Variable[source]¶
Bases:
ImednetBaseModelDefinition of a data field (question) on a form.
- label: str | None = None¶
- variable_oid: str | None = None¶
API field
variableOid.
- required: bool | str | None = None¶
- study_key: str | None = None¶
API field
studyKey.
- variable_id: int | None = None¶
API field
variableId.
- variable_type: str | None = None¶
API field
variableType.
- variable_name: str | None = None¶
API field
variableName.
- sequence: int | None = None¶
API field
sequence.
- revision: int | None = None¶
API field
revision.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- form_id: int | None = None¶
API field
formId.
- form_key: str | None = None¶
API field
formKey.
- form_name: str | None = None¶
API field
formName.
- blinded: bool | None = None¶
API field
blinded.
- deleted: bool | None = None¶
API field
deleted.
- disabled: bool | None = None¶
API field
disabled.
- last_updated: str | None = None¶
API field
lastUpdated.
imednet.models.verification module¶
Structured results consumed by the CI verification report aggregator.
- class imednet.models.verification.VerificationPerformanceMetric[source]¶
Bases:
BaseModelA named numeric measurement with an optional unit.
- name: str¶
Required.
- value: float¶
Required.
- unit: str | None = None¶
- class imednet.models.verification.VerificationReport[source]¶
Bases:
BaseModelVersioned report shared by verification tracks.
- version: Literal['1.0']¶
Required.
- track: Literal['fuzzing', 'performance', 'validation', 'live_tests', 'drift']¶
Required.
- status: Literal['passed', 'failed']¶
Required.
- violations: list[VerificationViolation]¶
Required.
- metrics: list[VerificationPerformanceMetric] = list()¶
- summary: str¶
Required.
imednet.models.visits module¶
Models for subject visits and study events.
- class imednet.models.visits.Visit[source]¶
Bases:
ImednetBaseModelA specific instance of a subject visiting a site (or equivalent event).
- visit_id: int | None = None¶
API field
visitId.
- study_key: str | None = None¶
API field
studyKey.
- interval_id: int | None = None¶
API field
intervalId.
- interval_name: str | None = None¶
API field
intervalName.
- subject_id: int | None = None¶
API field
subjectId.
- subject_key: str | None = None¶
API field
subjectKey.
- start_date: str | None = None¶
API field
startDate.
- end_date: str | None = None¶
API field
endDate.
- due_date: str | None = None¶
API field
dueDate.
- visit_date: str | None = None¶
API field
visitDate.
- deleted: bool | None = None¶
API field
deleted.
- date_created: str | None = None¶
API field
dateCreated.
- date_modified: str | None = None¶
API field
dateModified.
- visit_date_form: str | None = None¶
API field
visitDateForm.
- visit_date_question: str | None = None¶
API field
visitDateQuestion.
- last_updated: str | None = None¶
API field
lastUpdated.