Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __lshift__(self, other):
if not isinstance(other, (Annotation,)):
raise ValueError("Annotations cannot accept a child element of type %s" % other.__class__.__name__)
self.set_list_attribute(other, Annotation, 'annotations')
return other
def __init__(self, annotation_id=None, seqnum=1,
flags=None, comment=None,
transaction_type=None):
"""
:param id: ID for this Annotation (required if contained within an Annotations element)
:type id: str or None
:param int seqnum: :attr:`SeqNum` for Annotation
:param flags: one or more :class:`Flag` for the Annotation
:type flags: Flag or list(Flag)
:param comment: one or more :class:`Comment` for the Annotation
:type comment: Comment
:param transaction_type: :attr:`TransactionType` for Annotation (one of **Insert**, **Update**, *Remove*, **Upsert**, **Context**)
"""
super(Annotation, self).__init__(transaction_type=transaction_type)
# initialise the flags collection
self.flags = []
if flags:
if isinstance(flags, (list, tuple)):
for flag in flags:
self << flag
elif isinstance(flags, Flag):
self << flags
else:
raise AttributeError("Flags attribute should be an iterable or Flag")
self._id = None
if annotation_id is not None:
self.annotation_id = annotation_id
self._seqnum = None
if seqnum is not None:
# validate the input
def __lshift__(self, other):
if not isinstance(other, (Annotation,)):
raise ValueError("Annotations cannot accept a child element of type %s" % other.__class__.__name__)
self.set_list_attribute(other, Annotation, 'annotations')
return other
whole_item_group=False, annotations=None):
"""
:param str transaction_type: TransactionType for the ItemGroupData
:param int item_group_repeat_key: RepeatKey for the ItemGroupData
:param bool whole_item_group: Is this the entire ItemGroupData, or just parts? - *Rave specific attribute*
:param annotations: Annotation for the ItemGroup - *Not supported by Rave*
:type annotations: list(Annotation) or Annotation
"""
super(self.__class__, self).__init__(transaction_type)
self.item_group_repeat_key = item_group_repeat_key
self.whole_item_group = whole_item_group
self.items = OrderedDict()
self.annotations = []
if annotations:
# Add the annotations
if isinstance(annotations, Annotation):
self << annotations
elif isinstance(annotations, list):
for annotation in annotations:
self << annotation
#: :class:`Signature` for ItemGroupData
self.signature = None
self.itemgroupoid = itemgroupoid
def mixin(self):
"""
Add the annotations to the ODM Element (if defined)
:return:
"""
if self.milestones:
from rwslib.builders.clinicaldata import Annotation, Flag, FlagValue
annotation = Annotation()
for codelist, milestones in self.milestones.items():
for milestone in milestones:
annotation << Flag() << FlagValue(milestone, codelist_oid=codelist)
self.annotations.append(annotation)