Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing FormData attributes #140

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
jobs:
test-publish:
name: Test Publish
runs-on:
ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -32,6 +34,8 @@ jobs:
publish:
needs: test-publish
name: Publish to PyPI
runs-on:
ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand Down
1,085 changes: 567 additions & 518 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ requests = "*"
six = "*"
click = "*"
faker = "*"
urllib3 = "^1.26.9"
urllib3 = "*"
Sphinx = { version = "^5.1.1", optional = true }


Expand Down
12 changes: 11 additions & 1 deletion rwslib/builders/clinicaldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,19 @@ class FormData(TransactionalElement, LastUpdateMixin, MilestoneMixin):

ALLOWED_TRANSACTION_TYPES = ["Insert", "Update", "Upsert", "Context", "Remove"]

def __init__(self, formoid, transaction_type=None, form_repeat_key=None):
def __init__(self, formoid, transaction_type=None, form_repeat_key=None, lab_reference=None, lab_type=None):
"""
:param str formoid: :class:`FormDef` OID
:param str transaction_type: Transaction Type for Data (one of **Insert**, **Update**, **Upsert**, **Context**, **Remove**)
:param str form_repeat_key: Repeat Key for FormData
:param str lab_reference: Name for the Lab with the ranges
:param LabType lab_type: Type of the Lab (Central, Local)
"""
super(FormData, self).__init__(transaction_type)
self.formoid = formoid
self.form_repeat_key = form_repeat_key
self.lab_reference = lab_reference
self.lab_type = lab_type
self.itemgroups = []
#: :class:`Signature` for FormData
self.signature = None # type: Signature
Expand All @@ -254,6 +258,12 @@ def build(self, builder):
if self.form_repeat_key is not None:
params["FormRepeatKey"] = str(self.form_repeat_key)

if self.lab_reference is not None:
params["mdsol:LaboratoryRef"] = str(self.lab_reference)

if self.lab_type is not None:
params["mdsol:LaboratoryType"] = self.lab_type.value

# mixins
self.mixin()
self.mixin_params(params)
Expand Down
9 changes: 9 additions & 0 deletions rwslib/builders/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ class LocationType(enum.Enum):
Other = 'Other'


class LabType(enum.Enum):
"""
Type of LaboratoryType
Applies to a :class:`FormData`
"""
Local = 'Local'
Central = 'Central'


class UserType(enum.Enum):
"""
User Type Enumeration
Expand Down
5 changes: 5 additions & 0 deletions rwslib/tests/test_builders_clinicaldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ def test_add_signature(self):
self.assertEqual(self.__class__.__name__[4:], t.tag)
self.assertTrue(len(list(t)) == 4) # three igdata + 1 signature

def test_lab_settings(self):
tested = FormData("TESTFORM_A", lab_reference="A Lab", lab_type=LabType.Local)
doc = obj_to_doc(tested)
self.assertEqual(doc.attrib["mdsol:LaboratoryRef"], "A Lab")
self.assertEqual(doc.attrib["mdsol:LaboratoryType"], "Local")

class TestItemGroupData(unittest.TestCase):
"""Test ItemGroupData classes"""
Expand Down