imednet.form_designer package

Submodules

imednet.form_designer.builder module

class imednet.form_designer.builder.FormBuilder[source]

Bases: object

Builder class to construct iMedNet Form Designer payloads programmatically.

Manages ID generation and hierarchical structure.

add_field(type, label, question_name, required=False, choices=None, max_length=None, is_float=False)[source]

Add a standard field (Label + Control).

Parameters:
  • type (Literal['text', 'number', 'radio', 'dropdown', 'datetime', 'upload', 'checkbox', 'memo']) – Field type.

  • label (str) – Display label (HTML allowed).

  • question_name (str) – Variable OID.

  • required (bool) – If True, sets bl_req=’hard’.

  • choices (Optional[List[tuple[str, str]]]) – List of (text, code) for radios/dropdowns.

  • max_length (Optional[int]) – Max chars (text/memo) or digits (number).

  • is_float (bool) – For numbers, allow decimals.

Return type:

None

add_group_header(label)[source]

Add a group header (Label-only row).

Return type:

None

Parameters:

label (str) –

add_page()[source]

Add a new page to the form.

Return type:

None

add_section_header(label)[source]

Add a separator/section header.

Return type:

None

Parameters:

label (str) –

build()[source]

Return the final layout.

Return type:

ProtocolDeviationFormPayload

property current_page: Page

imednet.form_designer.client module

class imednet.form_designer.client.FormDesignerClient(base_url, phpsessid, timeout=30.0)[source]

Bases: object

Client for the iMedNet Form Designer endpoint.

Handles the specific authentication and payload requirements of the legacy formdez_save.php endpoint.

Parameters:
  • base_url (str) –

  • phpsessid (str) –

  • timeout (float) –

save_form(csrf_key, form_id, community_id, revision, layout)[source]

Submit the form layout to the server.

Parameters:
  • csrf_key (str) – The CSRF token (scraped from page).

  • form_id (int) – The ID of the form being edited.

  • community_id (int) – The study ID.

  • revision (int) – The NEXT revision number.

  • layout (ProtocolDeviationFormPayload) – The Form Layout object.

Return type:

str

Returns:

The raw response text from the server.

Raises:
  • httpx.HTTPStatusError – If the server returns a non-2xx status code.

  • ValueError – If the server returns an error.

imednet.form_designer.models module

class imednet.form_designer.models.BaseFieldProps(**data)[source]

Bases: BaseModel

Shared properties for all data capture fields.

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

bl_future_date: Optional[int]
bl_future_date_id: Optional[Union[int, str]]
bl_inherit_date: Optional[int]
bl_inherit_date_id: Optional[Union[int, str]]
bl_req: Optional[Literal['optional', 'hard', 'soft', 'autoquery', 'confirm']]
bl_req_id: Optional[Union[int, str]]
blinded_roles: Optional[List[str]]
catalog: Optional[str]
comments: Optional[str]
fld_id: Optional[Union[int, str]]
is_blinded: Optional[int]
label: Optional[str]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

mv: Optional[int]
new_fld_id: Optional[Union[int, str]]
nodelete: Optional[int]
page_no: Optional[str]
question_id: Optional[Union[int, str]]
question_name: Optional[str]
sas_label: Optional[str]
sdv_req: Optional[Literal['yes', 'no']]
sequence: Optional[str]
class imednet.form_designer.models.CheckboxFieldProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['checkbox']) –

  • choices (List[Choice] | None) –

choices: Optional[List[Choice]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['checkbox']
class imednet.form_designer.models.Choice(**data)[source]

Bases: BaseModel

A choice for radio or dropdown fields.

Parameters:
  • text (str) –

  • choice_id (int | str) –

  • code (str) –

choice_id: Union[int, str]
code: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

text: str
class imednet.form_designer.models.Col(**data)[source]

Bases: BaseModel

A column in a layout table row.

Parameters:

entities (List[Entity] | None) –

entities: Optional[List[Entity]]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class imednet.form_designer.models.DateTimeFieldProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['datetime']) –

  • time_ctrl (int | None) –

  • date_ctrl (int | None) –

  • use_seconds (int | None) –

  • record_comp_date (int | None) –

  • record_key_date (int | None) –

  • allow_no_day (int | None) –

  • allow_no_month (int | None) –

  • allow_no_year (int | None) –

allow_no_day: Optional[int]
allow_no_month: Optional[int]
allow_no_year: Optional[int]
date_ctrl: Optional[int]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

record_comp_date: Optional[int]
record_key_date: Optional[int]
time_ctrl: Optional[int]
type: Literal['datetime']
use_seconds: Optional[int]
class imednet.form_designer.models.DropdownFieldProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['dropdown']) –

  • choices (List[Choice]) –

  • lab_condition (str | None) –

  • lab_default_form (str | None) –

  • lab_default_form_type (str | None) –

  • lab_default_question (str | None) –

  • lab_normal (str | None) –

choices: List[Choice]
lab_condition: Optional[str]
lab_default_form: Optional[str]
lab_default_form_type: Optional[str]
lab_default_question: Optional[str]
lab_normal: Optional[str]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['dropdown']
class imednet.form_designer.models.Entity(**data)[source]

Bases: BaseModel

The ‘Component’ in the Composite Pattern.

Parameters:
id: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

props: EntityProps
rows: Optional[List[Row]]
class imednet.form_designer.models.ExtQuestionProps(**data)[source]

Bases: BaseModel

Parameters:
  • type (Literal['ext_question']) –

  • ext_source (Literal['interval', 'form']) –

  • label (str) –

  • interval_source (str | None) –

  • form (int | None) –

  • field (int | None) –

  • source (int | None) –

ext_source: Literal['interval', 'form']
field: Optional[int]
form: Optional[int]
interval_source: Optional[str]
label: str
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

source: Optional[int]
type: Literal['ext_question']
class imednet.form_designer.models.FileUploadProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['upload']) –

  • mfs (int) –

  • max_files (str | int) –

max_files: Union[str, int]
mfs: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['upload']
class imednet.form_designer.models.LabelProps(**data)[source]

Bases: BaseModel

Parameters:
  • type (Literal['label']) –

  • label (str) –

  • label_id (str | None) –

  • label_name (str | None) –

  • fld_id (int | str | None) –

  • new_fld_id (int | str | None) –

fld_id: Optional[Union[int, str]]
label: str
label_id: Optional[str]
label_name: Optional[str]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

new_fld_id: Optional[Union[int, str]]
type: Literal['label']
imednet.form_designer.models.Layout

alias of ProtocolDeviationFormPayload

class imednet.form_designer.models.MemoFieldProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['memo']) –

  • length (str | int) –

  • columns (str | int) –

  • rows (str | int) –

columns: Union[str, int]
length: Union[str, int]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

rows: Union[str, int]
type: Literal['memo']
class imednet.form_designer.models.NumberFieldProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['number']) –

  • length (str | int) –

  • columns (int | str | None) –

  • real (int | None) –

  • suffix (str | None) –

columns: Optional[Union[str, int]]
length: Union[str, int]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

real: Optional[int]
suffix: Optional[str]
type: Literal['number']
class imednet.form_designer.models.Page(**data)[source]

Bases: BaseModel

Represents a single page within the electronic Case Report Form (CRF).

Parameters:

entities (List[Entity]) –

entities: List[Entity]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class imednet.form_designer.models.PrecisionDateFieldProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['precisiondate']) –

  • precision_secs (int | None) –

  • precision_time (int | None) –

  • allow_no_day (int | None) –

  • allow_no_month (int | None) –

  • allow_no_year (int | None) –

  • allow_no_time (int | None) –

  • impute_time (str | None) –

  • impute_day (str | None) –

  • impute_month (int | None) –

  • impute_year (int | None) –

  • display_text_time (str | None) –

  • display_text_day (str | None) –

  • display_text_month (str | None) –

  • display_text_year (str | None) –

  • record_key_date (int | None) –

  • record_comp_date (int | None) –

allow_no_day: Optional[int]
allow_no_month: Optional[int]
allow_no_time: Optional[int]
allow_no_year: Optional[int]
display_text_day: Optional[str]
display_text_month: Optional[str]
display_text_time: Optional[str]
display_text_year: Optional[str]
impute_day: Optional[str]
impute_month: Optional[int]
impute_time: Optional[str]
impute_year: Optional[int]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

precision_secs: Optional[int]
precision_time: Optional[int]
record_comp_date: Optional[int]
record_key_date: Optional[int]
type: Literal['precisiondate']
class imednet.form_designer.models.ProtocolDeviationFormPayload(**data)[source]

Bases: BaseModel

Root object representing the entire form definition payload.

Parameters:

pages (List[Page]) –

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

pages: List[Page]
class imednet.form_designer.models.RadioFieldProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['radio']) –

  • choices (List[Choice]) –

  • radio (int | None) –

choices: List[Choice]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

radio: Optional[int]
type: Literal['radio']
class imednet.form_designer.models.Row(**data)[source]

Bases: BaseModel

A row in a layout table.

Parameters:

cols (List[Col]) –

cols: List[Col]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class imednet.form_designer.models.SeparatorProps(**data)[source]

Bases: BaseModel

Parameters:
  • type (Literal['sep']) –

  • septype (int) –

  • label (str | None) –

label: Optional[str]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

septype: int
type: Literal['sep']
class imednet.form_designer.models.TableProps(**data)[source]

Bases: BaseModel

Parameters:
  • type (Literal['table']) –

  • columns (int) –

columns: int
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['table']
class imednet.form_designer.models.TextFieldProps(**data)[source]

Bases: BaseFieldProps

Parameters:
  • fld_id (int | str | None) –

  • question_id (int | str | None) –

  • question_name (str | None) –

  • label (str | None) –

  • sas_label (str | None) –

  • sequence (str | None) –

  • page_no (str | None) –

  • sdv_req (Literal['yes', 'no'] | None) –

  • bl_req (Literal['optional', 'hard', 'soft', 'autoquery', 'confirm'] | None) –

  • bl_req_id (int | str | None) –

  • bl_future_date (int | None) –

  • bl_future_date_id (int | str | None) –

  • bl_inherit_date (int | None) –

  • bl_inherit_date_id (int | str | None) –

  • bl_related (str | List[Any] | None) –

  • is_blinded (int | None) –

  • blinded_roles (List[str] | None) –

  • mv (int | None) –

  • nodelete (int | None) –

  • catalog (str | None) –

  • comments (str | None) –

  • new_fld_id (int | str | None) –

  • type (Literal['text']) –

  • length (str | int) –

  • columns (int | str | None) –

columns: Optional[Union[str, int]]
length: Union[str, int]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

type: Literal['text']

imednet.form_designer.presets module

imednet.form_designer.presets.build_cv_pathology(builder)[source]

A CV Pathology sample form.

Return type:

None

Parameters:

builder (FormBuilder) –

imednet.form_designer.presets.build_demo_form(builder)[source]

A demo form with various field types.

Return type:

None

Parameters:

builder (FormBuilder) –

Module contents

class imednet.form_designer.FormBuilder[source]

Bases: object

Builder class to construct iMedNet Form Designer payloads programmatically.

Manages ID generation and hierarchical structure.

add_field(type, label, question_name, required=False, choices=None, max_length=None, is_float=False)[source]

Add a standard field (Label + Control).

Parameters:
  • type (Literal['text', 'number', 'radio', 'dropdown', 'datetime', 'upload', 'checkbox', 'memo']) – Field type.

  • label (str) – Display label (HTML allowed).

  • question_name (str) – Variable OID.

  • required (bool) – If True, sets bl_req=’hard’.

  • choices (Optional[List[tuple[str, str]]]) – List of (text, code) for radios/dropdowns.

  • max_length (Optional[int]) – Max chars (text/memo) or digits (number).

  • is_float (bool) – For numbers, allow decimals.

Return type:

None

add_group_header(label)[source]

Add a group header (Label-only row).

Return type:

None

Parameters:

label (str) –

add_page()[source]

Add a new page to the form.

Return type:

None

add_section_header(label)[source]

Add a separator/section header.

Return type:

None

Parameters:

label (str) –

build()[source]

Return the final layout.

Return type:

ProtocolDeviationFormPayload

property current_page: Page
class imednet.form_designer.FormDesignerClient(base_url, phpsessid, timeout=30.0)[source]

Bases: object

Client for the iMedNet Form Designer endpoint.

Handles the specific authentication and payload requirements of the legacy formdez_save.php endpoint.

Parameters:
  • base_url (str) –

  • phpsessid (str) –

  • timeout (float) –

save_form(csrf_key, form_id, community_id, revision, layout)[source]

Submit the form layout to the server.

Parameters:
  • csrf_key (str) – The CSRF token (scraped from page).

  • form_id (int) – The ID of the form being edited.

  • community_id (int) – The study ID.

  • revision (int) – The NEXT revision number.

  • layout (ProtocolDeviationFormPayload) – The Form Layout object.

Return type:

str

Returns:

The raw response text from the server.

Raises:
  • httpx.HTTPStatusError – If the server returns a non-2xx status code.

  • ValueError – If the server returns an error.

imednet.form_designer.Layout

alias of ProtocolDeviationFormPayload