def setUp(self) -> None: self.odm_file_1 = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'data', 'cdash-odm-test.xml') self.parser = P.ODMParser(self.odm_file_1) self.root = self.parser.parse() self.mdv = self.parser.MetaDataVersion()
def test_clinical_data_from_xml(self): parser = ODM_PARSER.ODMParser(self.odm_test_file) parser.parse() rd = parser.ReferenceData() igd_list = parser.ItemGroupData(parent=rd[0]) item_data = parser.ItemData(parent=igd_list[1]["elem"]) self.assertEqual(item_data[0]["Value"], "2")
def test_clinical_data_from_xml(self): parser = ODM_PARSER.ODMParser(self.odm_test_file) parser.parse() cd = parser.ClinicalData() subj_list = parser.SubjectData(parent=cd[1]) sed = parser.StudyEventData(parent=subj_list[0]["elem"]) fd = parser.FormData(parent=sed[0]["elem"]) igd = parser.ItemGroupData(parent=fd[0]["elem"]) item_data = parser.ItemData(parent=igd[0]["elem"]) self.assertEqual(item_data[0]["Value"], "Fever")
def test_itemgroupdef_parse_xml(self): parser = ODM_PARSER.ODMParser(self.input_file, self.nsr) parser.parse() mdv = parser.MetaDataVersion() igd_list = parser.ItemGroupDef(parent=mdv[0]) igd_dict = igd_list[0] self.assertEqual(igd_dict["OID"], "IG.TS") ir_list = parser.ItemRef(parent=igd_dict["elem"]) # tests the __len__ in ItemGroupDef as well as the add_item_ref self.assertEqual(len(ir_list), 6) igd_class = parser.Class(parent=igd_dict["elem"], ns_prefix="def") self.assertEqual(igd_class[0]["Name"], "TRIAL DESIGN")
def test_itemgroupdef_iterator(self): """ test the ability to reference a specific or slice of ItemRefs """ attrs = self.set_itemgroupdef_attributes() igd = DEFINE.ItemGroupDef(**attrs) tt = DEFINE.TranslatedText(_content="Vital Signs", lang="en") igd.Description = DEFINE.Description() igd.Description.TranslatedText = [tt] item_refs = self.set_itemrefs() igd.ItemRef = item_refs parser = ODM_PARSER.ODMParser(self.test_file, self.nsr) parser.parse() parser.MetaDataVersion() irs = [ir.ItemOID for ir in igd] self.assertEqual(len(irs), 10)
def setUp(self) -> None: self.odm_file_1 = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'data', 'define2-0-0-sdtm-test.xml') NS.NamespaceRegistry(prefix="odm", uri="http://www.cdisc.org/ns/odm/v1.3", is_default=True) NS.NamespaceRegistry(prefix="def", uri="http://www.cdisc.org/ns/def/v2.0") self.nsr = NS.NamespaceRegistry( prefix="nciodm", uri="http://ncicb.nci.nih.gov/xml/odm/EVS/CDISC") self.parser = P.ODMParser(self.odm_file_1, self.nsr) self.root = self.parser.parse() self.mdv = self.parser.MetaDataVersion()
def test_itemgroupdef_slice(self): """ test the ability to reference a specific or slice of ItemRefs """ attrs = self.set_itemgroupdef_attributes() igd = ODM.ItemGroupDef(**attrs) tt = ODM.TranslatedText(_content="Vital Signs", lang="en") igd.Description = ODM.Description() igd.Description.TranslatedText = [tt] item_refs = self.set_itemrefs() igd.ItemRef = item_refs parser = ODM_PARSER.ODMParser(self.odm_test_file) parser.parse() parser.MetaDataVersion() self.assertEqual(len(igd), 13) self.assertEqual(igd.ItemRef[0].ItemOID, "IT.STUDYID") slice_itr = igd.ItemRef[1:5] self.assertEqual(slice_itr[1].ItemOID, "IT.VS.USUBJID")
def test_itemgroupdef_round_trip(self): """ system test to create and serialize an ItemGroupDef object """ attrs = self.set_itemgroupdef_attributes() igd = ODM.ItemGroupDef(**attrs) tt = ODM.TranslatedText(_content="Vital Signs", lang="en") igd.Description = ODM.Description() igd.Description.TranslatedText = [tt] item_refs = self.set_itemrefs() igd.ItemRef = item_refs parser = ODM_PARSER.ODMParser(self.odm_test_file) parser.parse() mdv = parser.MetaDataVersion() igd_list = parser.ItemGroupDef(parent=mdv[0]) igd_dict = igd_list[0] self.assertEqual(igd_dict["OID"], "IG.VS") ir_list = parser.ItemRef(parent=igd_dict["elem"]) # tests the __len__ in ItemGroupDef as well as the add_item_ref self.assertEqual(len(ir_list), len(igd))
def setUp(self) -> None: self.odm_file_1 = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'data', 'defineV21-SDTM-metadata.xml') NS.NamespaceRegistry(prefix="odm", uri="http://www.cdisc.org/ns/odm/v1.3", is_default=True) NS.NamespaceRegistry(prefix="def", uri="http://www.cdisc.org/ns/def/v2.1") self.nsr = NS.NamespaceRegistry( prefix="nciodm", uri="http://ncicb.nci.nih.gov/xml/odm/EVS/CDISC") self.parser = P.ODMParser(self.odm_file_1, self.nsr) self.loader = LD.ODMLoader( OL.XMLDefineLoader(model_package="define_2_1", ns_uri="http://www.cdisc.org/ns/def/v2.1")) self.root = self.loader.create_document(self.odm_file_1) self.odm = self.loader.load_odm() self.parser.parse() self.mdv = self.parser.MetaDataVersion()
def create_document(self, filename, namespace_registry=None): self.filename = filename self._set_namespace(namespace_registry) self.parser = P.ODMParser(self.filename, self.nsr) root = self.parser.parse() return root
def test_validate_tree_invalid(self): odm_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data', 'cdash-odm-test-invalid.xml') self.parser = P.ODMParser(odm_file) tree = self.parser.parse_tree() is_valid = self.validator.validate_tree(tree) self.assertFalse(is_valid)
def test_validate_tree_valid(self): self.parser = P.ODMParser(self.odm_file) tree = self.parser.parse_tree() is_valid = self.validator.validate_tree(tree) self.assertTrue(is_valid)