Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for step in self.check_steps:
step.build(builder)
for action in self.check_actions:
action.build(builder)
builder.end('mdsol:EditCheckDef')
def __lshift__(self, other):
"""Override << operator"""
if not isinstance(other, (MdsolCheckStep, MdsolCheckAction,)):
raise ValueError('EditCheck cannot accept a {0} as a child element'.format(other.__class__.__name__))
self.set_list_attribute(other, MdsolCheckStep, 'check_steps')
self.set_list_attribute(other, MdsolCheckAction, 'check_actions')
class MdsolConfirmationMessage(ODMElement):
"""
Form is saved confirmation message
.. note:: this is a Medidata Rave Specific Element
"""
def __init__(self, message, lang=None):
"""
:param str message: Content of confirmation message
:param str lang: Language declaration for Message
"""
self.message = message
self.lang = lang
def build(self, builder):
"""Build XML by appending to builder"""
builder.end("AdminData")
def __lshift__(self, other):
"""Override << operator"""
if not isinstance(other, (User, Location,)):
raise ValueError('{0} cannot accept a {1} as a child element'.format(self.__class__.__name__,
other.__class__.__name__))
self.set_list_attribute(other, User, 'users')
self.set_list_attribute(other, Location, 'locations')
return other
class MetaDataVersionRef(ODMElement):
"""
A reference to a MetaDataVersion used at the containing Location.
The EffectiveDate expresses the fact that the metadata used at a location can vary over time.
"""
def __init__(self, study_oid, metadata_version_oid, effective_date):
"""
:param str study_oid: References the :class:`Study` that uses this metadata version.
:param str metadata_version_oid: References the :class:`rwslib.builders.MetaDataVersion` (within the above Study).
:param datetime.datetime effective_date: Effective Date for this version and Site
"""
super(MetaDataVersionRef, self).__init__()
self.study_oid = study_oid
self.metadata_version_oid = metadata_version_oid
self.effective_date = effective_date
def build(self, builder):
if value in (None, '') or value.strip() == "":
raise AttributeError("Empty CodeListOID value is invalid.")
self._codelist_oid = value
def build(self, builder):
"""
Build XML by appending to builder
"""
if self.codelist_oid is None:
raise ValueError("CodeListOID not set.")
builder.start("FlagType", dict(CodeListOID=self.codelist_oid))
builder.data(self.flag_type)
builder.end("FlagType")
class FlagValue(ODMElement):
"""
The value of the flag. The meaning of this value is typically dependent on the associated FlagType.
The actual value must be a member of the referenced CodeList.
.. note:: FlagValue is not supported by Rave
"""
def __init__(self, flag_value, codelist_oid=None):
"""
:param flag_value: Value for :class:`Flag`
"""
self.flag_value = flag_value
self._codelist_oid = None
if codelist_oid is not None:
self.codelist_oid = codelist_oid
if value in (None, '') or value.strip() == "":
raise AttributeError("Empty CodeListOID value is invalid.")
self._codelist_oid = value
def build(self, builder):
"""
Build XML by appending to builder
"""
if self.codelist_oid is None:
raise ValueError("CodeListOID not set.")
builder.start("FlagValue", dict(CodeListOID=self.codelist_oid))
builder.data(self.flag_value)
builder.end("FlagValue")
class UserRef(ODMElement):
"""
Reference to a :class:`User`
"""
def __init__(self, oid):
"""
:param str oid: OID for referenced :class:`User`
"""
self.oid = oid
def build(self, builder):
"""
Build XML by appending to builder
"""
builder.start("UserRef", dict(UserOID=self.oid))
builder.end("UserRef")
def __init__(self, reason):
"""
:param str reason: Supplied Reason for change
"""
self.reason = reason
def build(self, builder):
"""
Build XML by appending to builder
"""
builder.start("ReasonForChange", {})
builder.data(self.reason)
builder.end("ReasonForChange")
class DateTimeStamp(ODMElement):
"""
The date/time that the data entry, modification, or signature was performed.
This applies to the initial occurrence of the action, not to subsequent transfers between computer systems.
"""
def __init__(self, date_time):
#: specified DateTime for event
self.date_time = date_time
def build(self, builder):
"""
Build XML by appending to builder
"""
builder.start("DateTimeStamp", {})
if isinstance(self.date_time, datetime):
builder.data(dt_to_iso8601(self.date_time))
#: TransactionType for the Attribute
self.transaction_type = transaction_type
def build(self, builder):
"""Build XML by appending to builder"""
params = dict(Namespace=self.namespace,
Name=self.name,
Value=self.value,
TransactionType=self.transaction_type,
)
builder.start('mdsol:Attribute', params)
builder.end('mdsol:Attribute')
class MdsolCustomFunctionDef(ODMElement):
"""
Extension for Rave Custom functions
.. note:: This is a Medidata Rave Specific Extension
.. note:: VB was deprecated in later Rave versions.
"""
VB = "VB" # VB was deprecated in later Rave versions.
C_SHARP = "C#"
SQL = "SQ"
VALID_LANGUAGES = [C_SHARP, SQL, VB]
def __init__(self, oid, code, language="C#"):
"""
:param str oid: OID for CustomFunction
:param str code: Content for the CustomFunction
:param str language: Language for the CustomFunction
for alias in self.aliases:
alias.build(builder)
builder.end("CodeListItem")
def __lshift__(self, other):
"""Override << operator"""
if not isinstance(other, (Decode, Alias,)):
raise ValueError('CodelistItem cannot accept child of type {0}'.format(other.__class__.__name__))
self.set_single_attribute(other, Decode, 'decode')
self.set_list_attribute(other, Alias, 'aliases')
return other
class Decode(ODMElement):
"""
The displayed value relating to the CodedValue
"""
def __init__(self):
#: Collection of :class:`Translation` for the Decode
self.translations = []
def build(self, builder):
"""Build XML by appending to builder"""
builder.start("Decode", {})
for translation in self.translations:
translation.build(builder)
builder.end("Decode")
def __lshift__(self, other):
def __init__(self, value):
"""
:param str value: Value for a :class:`RangeCheck`
"""
self.value = value
def build(self, builder):
"""Build XML by appending to builder"""
builder.start('CheckValue', {})
builder.data(str(self.value))
builder.end('CheckValue')
class CodeListRef(ODMElement):
"""
A reference to a :class:`CodeList` definition.
"""
def __init__(self, oid):
"""
:param oid: OID for :class:`CodeList`
"""
self.oid = oid
def build(self, builder):
"""Build XML by appending to builder"""
builder.start('CodeListRef', {'CodeListOID': self.oid})
builder.end('CodeListRef')
A reference to a :class:`CodeList` definition.
"""
def __init__(self, oid):
"""
:param oid: OID for :class:`CodeList`
"""
self.oid = oid
def build(self, builder):
"""Build XML by appending to builder"""
builder.start('CodeListRef', {'CodeListOID': self.oid})
builder.end('CodeListRef')
class CodeList(ODMElement):
"""
Defines a discrete set of permitted values for an item.
.. note:: Equates to a Rave Dictionary
.. note:: Does not support ExternalCodeList
"""
VALID_DATATYPES = [DataType.Integer, DataType.Text, DataType.Float, DataType.String]
def __init__(self, oid, name, datatype, sas_format_name=None):
"""
:param str oid: CodeList OID
:param str name: Name of CodeList
:param str datatype: DataType restricts the values that can appear in the CodeList whether internal or external
(*integer* | *float* | *text* | *string* )
:param str sas_format_name: SASFormatName must be a legal SAS format for CodeList
"""
for mdv in self.metadata_versions:
mdv.build(builder)
builder.end("Location")
def __lshift__(self, other):
"""Override << operator"""
if not isinstance(other, (MetaDataVersionRef,)):
raise ValueError('{0} cannot accept a {1} as a child element'.format(self.__class__.__name__,
other.__class__.__name__))
self.set_list_attribute(other, MetaDataVersionRef, 'metadata_versions')
return other
class Address(ODMElement):
"""
The user's postal address.
"""
def __init__(self, street_names=None, city=None, state_prov=None, country=None, postal_code=None, other_text=None):
"""
:param list(Address) street_names: User street names
:param City city: User City
:param StateProv state_prov: User State or Provence
:param Country country: User City
:param PostalCode postal_code: User City
:param OtherText other_text: User Other Text
"""
super(Address, self).__init__()
self.street_names = street_names or []
self.city = city
self.state_prov = state_prov