Exemplo n.º 1
0
    def loadStudy(self):
        """Extract Study domain object according to ODM from metadata XML
        """
        study = None

        # Check if file path is setup
        if (self.isFileLoaded):
            documentTree = ET.ElementTree(file=self.filename)

            # Locate Study data in XML file via XPath
            for element in documentTree.iterfind('.//odm:Study',
                                                 namespaces=nsmaps):
                study = Study()
                study.setOid(element.attrib['OID'])

                for studyName in documentTree.iterfind(
                        './/odm:Study[@OID="' + study.oid() +
                        '"]/odm:GlobalVariables/odm:StudyName',
                        namespaces=nsmaps):
                    study.setName(studyName.text)

                for studyDescription in documentTree.iterfind(
                        './/odm:Study[@OID="' + study.oid() +
                        '"]/odm:GlobalVariables/odm:StudyDescription',
                        namespaces=nsmaps):
                    study.setDescription(studyDescription.text)

                # # In case I need this information later
                # for studyProtocolName in documentTree.iterfind('.//odm:Study[@OID="' + study.oid() + '"]/odm:GlobalVariables/odm:ProtocolName', namespaces=nsmaps):
                #     print studyProtocolName.text

        # The resulting study element
        return study
Exemplo n.º 2
0
    def listAll(self):
        """Get hierarchical list of studies together with their study sites
        """
        result = ""
        studies = []

        params = SimpleXMLElement("""<?xml version="1.0" encoding="UTF-8"?>
            <listAllRequest />""")
        response = self.client.call('listAllRequest', params)

        documentTree = ET.ElementTree((ET.fromstring(str(response.as_xml()))))

        # Locate Study data in XML file via XPath
        for study in documentTree.iterfind('.//study:study',
                                           namespaces=nsmaps):
            identifier = ""
            oid = ""
            name = ""
            sites = []
            for element in study:
                print element.tag
                if (str(element.tag)).strip(
                ) == "{http://openclinica.org/ws/study/v1}identifier":
                    identifier = element.text
                elif (str(element.tag)
                      ).strip() == "{http://openclinica.org/ws/study/v1}oid":
                    oid = element.text
                elif (str(element.tag)
                      ).strip() == "{http://openclinica.org/ws/study/v1}name":
                    name = element.text

                if (str(element.tag)
                    ).strip() == "{http://openclinica.org/ws/study/v1}sites":
                    for site in element:
                        siteid = ""
                        siteoid = ""
                        sitename = ""
                        for siteelement in site:
                            if (str(siteelement.tag)).strip(
                            ) == "{http://openclinica.org/ws/study/v1}identifier":
                                siteid = siteelement.text
                            elif (str(siteelement.tag)).strip(
                            ) == "{http://openclinica.org/ws/study/v1}oid":
                                siteoid = siteelement.text
                            elif (str(siteelement.tag)).strip(
                            ) == "{http://openclinica.org/ws/study/v1}name":
                                sitename = siteelement.text

                        obtainedSite = StudySite(siteid, siteoid, sitename)
                        sites.append(obtainedSite)

            obtainedStudy = Study(identifier, oid, name)
            obtainedStudy.sites = sites
            studies.append(obtainedStudy)

        # Result of WS call
        result = str(response.result)
        return result, studies
    def listAll(self):
        """Get hierarchical list of studies together with their study sites
        """
        result = ""
        studies = []

        params = SimpleXMLElement("""<?xml version="1.0" encoding="UTF-8"?>
            <listAllRequest />""")
        response = self.client.call('listAllRequest', params)

        documentTree = ET.ElementTree((ET.fromstring(str(response.as_xml()))))

        # Locate Study data in XML file via XPath
        for study in documentTree.iterfind('.//study:study', namespaces=nsmaps):
            identifier = ""
            oid = ""
            name = ""
            sites = []
            for element in study:
                print element.tag
                if (str(element.tag)).strip() == "{http://openclinica.org/ws/study/v1}identifier":
                    identifier = element.text
                elif (str(element.tag)).strip() == "{http://openclinica.org/ws/study/v1}oid":
                    oid = element.text
                elif (str(element.tag)).strip() == "{http://openclinica.org/ws/study/v1}name":
                    name = element.text

                if (str(element.tag)).strip() == "{http://openclinica.org/ws/study/v1}sites":
                    for site in element:
                        siteid = ""
                        siteoid = ""
                        sitename = ""
                        for siteelement in site:
                            if (str(siteelement.tag)).strip() == "{http://openclinica.org/ws/study/v1}identifier":
                                siteid = siteelement.text
                            elif (str(siteelement.tag)).strip() == "{http://openclinica.org/ws/study/v1}oid":
                                siteoid = siteelement.text
                            elif (str(siteelement.tag)).strip() == "{http://openclinica.org/ws/study/v1}name":
                                sitename = siteelement.text

                        obtainedSite = StudySite(siteid, siteoid, sitename)
                        sites.append(obtainedSite)

            obtainedStudy = Study(identifier, oid, name)
            obtainedStudy.sites = sites
            studies.append(obtainedStudy)

        # Result of WS call
        result = str(response.result)
        return result, studies
    def loadStudy(self):
        """Extract Study domain object according to ODM from metadata XML
        """
        study = None

        # Check if file path is setup
        if (self.isFileLoaded) :
            documentTree = ET.ElementTree(file=self.filename)

            # Locate Study data in XML file via XPath
            for element in documentTree.iterfind('.//odm:Study', namespaces=nsmaps):
                study = Study()
                study.setOid(element.attrib['OID'])

                for studyName in documentTree.iterfind('.//odm:Study[@OID="' + study.oid() + '"]/odm:GlobalVariables/odm:StudyName', namespaces=nsmaps):
                    study.setName(studyName.text)

                for studyDescription in documentTree.iterfind('.//odm:Study[@OID="' + study.oid() + '"]/odm:GlobalVariables/odm:StudyDescription', namespaces=nsmaps):
                    study.setDescription(studyDescription.text)

                # # In case I need this information later
                # for studyProtocolName in documentTree.iterfind('.//odm:Study[@OID="' + study.oid() + '"]/odm:GlobalVariables/odm:ProtocolName', namespaces=nsmaps):
                #     print studyProtocolName.text

        # The resulting study element
        return study