def tblStudySubjectItemChanged(self, current, previous):
        """Event handler which is triggered when selectedStudySubject change
        """
        self.tvStudyEvents.setModel(None)
        self.tvDicomStudies.setModel(None)
        self.textBrowserProgress.clear()

        # Take the first column of selected row from table view
        index = self.studySubjectProxyModel.index(current.row(), 1)
        if index.data().toPyObject():
            self._selectedStudySubject = (first.first(
                subject for subject in self._studySubjects
                if subject.label().encode(
                    "utf-8") == index.data().toPyObject().toUtf8()))

            # TODO: enable this when you migrate to a new version of OC
            # I need to load a SubjectKey
            # ssREST = self._svcHttp.getStudyCasebookSubject(
            #         self._mySite.edc.edcbaseurl,
            #         self.getStudyOid(),
            #         self._selectedStudySubject.label()
            #     )
            # if ssREST != None:
            #     self._selectedStudySubject.oid = ssREST.oid
            #     self.logger.debug("Loaded subject key: " + self._selectedStudySubject.oid)

            # TODO: I dont like it, get rid of it ()
            # Propagate PatientID into service
            self._svcDicom.PatientID = self._selectedStudySubject.subject.uniqueIdentifier
Beispiel #2
0
    def tblSeriesItemChanged(self, current, previous):
        """On selected DICOM series changed
        """
        self.teReport.clear()

        # Take the 4th column (UID) of selected row from table view
        index = self.seriesProxyModel.index(current.row(), 3)
        if index.data().toPyObject():
            self._selectedSerie = first.first(
                serie for serie in self._studySeries
                if str(serie.suid) == index.data().toPyObject())

            if self._selectedSerie.modality == "SR":
                self.tabWidget.setTabEnabled(1, True)
                self.teReport.setEnabled(True)
                self.btnApprove.setEnabled(True)

                if self._selectedSerie.isApproved:
                    self.teReport.clear()
                    self.teReport.insertPlainText(
                        self._selectedSerie.approvedReportText)
                    self.teReport.setStyleSheet(self.greenStyle)
                else:
                    self.teReport.setStyleSheet(self.redStyle)
                    for doc in self._selectedSerie.dsrDocuments:
                        self.teReport.insertPlainText(doc.renderText())
            else:
                self.tabWidget.setTabEnabled(1, False)
                self.teReport.setEnabled(False)
                self.btnApprove.setEnabled(False)
    def tblStudyItemChanged(self, current, previous):
        """Event handler which is triggered when selectedStudy change

        When the study is selected I have to clean all the other data elements
        Which depends on study. It means: StudySubjects, StudyEventDefinitions, StudyEventCRFs
        """
        self.textBrowserProgress.clear()

        # Take the first column of selected row from table view
        index = self.studyProxyModel.index(current.row(), 0)

        # Multicentric
        if len(self._selectedStudy.sites) > 0:
            self._selectedStudySite = first.first(
                studySite for studySite in self._selectedStudy.sites
                if studySite.identifier.encode(
                    "utf-8") == index.data().toPyObject().toUtf8())
            # Enabled download button
            if (self._selectedStudySite is not None):
                self.btnDownload.setDisabled(False)
        else:
            if (self._selectedStudy is not None):
                self.btnDownload.setDisabled(False)

        # Get the study metadata
        self.reloadStudyMetadata()

        # Show the selected upload target
        msg = "Selected study for download: "
        msg += self._selectedStudy.name() + "/"
        if len(self._selectedStudy.sites) > 0:
            msg += self._selectedStudySite.name + "/"

        self.textBrowserProgress.append(msg)
Beispiel #4
0
    def tblStudyItemChanged(self, current, previous):
        """Event handler which is triggered when selectedStudy change

        When the study is selected I have to clean all the other data elements
        Which depends on study. It means: StudySubjects, StudyEventDefinitions, StudyEventCRFs
        """
        # Clean the model before loading the new one
        self.tvStudySubjects.setModel(None)
        self.tvStudyEvents.setModel(None)
        self.tvCrfs.setModel(None)
        self.tvItems.setModel(None)
        self.textBrowserProgress.clear()

        # Take the first column of selected row from table view
        index = self.studyProxyModel.index(current.row(), 0)

        # Multicentric
        if len(self._selectedStudy.sites) > 0:
            self._selectedStudySite = first.first(
                studySite
                for studySite in self._selectedStudy.sites
                if studySite.identifier.encode("utf-8") == index.data().toPyObject().toUtf8()
            )

        # Get the study metadata
        self.reloadStudyMetadata()
Beispiel #5
0
    def tblCrfFieldItemChanged(self, current, previous):
        """
        """
        self.textBrowserProgress.clear()

        # Take the second column (OID) of selected row from table view
        column = 1
        index = self.itemProxyModel.index(current.row(), column)

        if index.data().toPyObject():
            self._selectedItem = first.first(
                i for i in self._selectedCrf.items if i.oid.encode("utf-8") == index.data().toPyObject().toUtf8()
            )

            # Show the selected import target
            msg = "Selected import target: "
            msg += self._selectedStudy.name + "/"
            if len(self._selectedStudy.sites) > 0:
                msg += self._selectedStudySite.name + "/"
            msg += "StudySubjectID: " + self._selectedStudySubject.label + "/"
            if self._selectedStudyEvent.isRepeating:
                msg += self._selectedStudyEvent.name + " [" + self._selectedStudyEvent.studyEventRepeatKey + "]/"
            else:
                msg += self._selectedStudyEvent.name + "/"
            msg += self._selectedCrf.name + "/"
            msg += self._selectedItem.name

            self._logger.debug(msg)

            self.textBrowserProgress.append(msg)
    def tblCrfFieldItemChanged(self, current, previous):
        """
        """
        self.textBrowserProgress.clear()

        # Take the second column (OID) of selected row from table view
        column = 1
        index = self.itemProxyModel.index(current.row(), column);

        if index.data().toPyObject(): 
            self._selectedItem = (
                first.first(
                    i for i in self._selectedCrf.items if i.oid.encode("utf-8") == index.data().toPyObject().toUtf8()
                )
            )

            # Show the selected import target
            msg = "Selected import target: "
            msg += self._selectedStudy.name + "/"
            if len(self._selectedStudy.sites) > 0:
                msg += self._selectedStudySite.name + "/"
            msg += "StudySubjectID: " + self._selectedStudySubject.label + "/"
            if self._selectedStudyEvent.isRepeating:
                msg += self._selectedStudyEvent.name + " [" + self._selectedStudyEvent.studyEventRepeatKey + "]/"
            else:
                msg += self._selectedStudyEvent.name + "/"
            msg += self._selectedCrf.name + "/"
            msg += self._selectedItem.name 

            self._logger.debug(msg)

            self.textBrowserProgress.append(msg)
Beispiel #7
0
    def cmbDataFieldsChanged(self, text):
        """
        """
        # Selected data to map to metadata
        self.dataMapping.data = first.first(dataHeader
                                            for dataHeader in self.dataHeaders
                                            if dataHeader == text)

        # Now extract data values from data file according to selection
        self.dataValues = []

        # Load data values from data file according to selection
        for i in range(1, self.dataService.size()):
            dataRow = self.dataService.getRow(i)
            dataIndex = self.dataService.headers.index(self.dataMapping.data)
            dataValue = dataRow[dataIndex]

            self.dataValues.append(dataValue)

        # Create view model for preview table view
        self.model = QtGui.QStandardItemModel()
        self.model.setHorizontalHeaderLabels(
            ["Raw Data", "Mapping transformed data"])

        row = 0
        for data in self.dataValues:
            itemDataField = QtGui.QStandardItem(data)
            itemTransformedData = QtGui.QStandardItem("")
            self.model.setItem(row, 0, itemDataField)
            self.model.setItem(row, 1, itemTransformedData)
            row = row + 1

        self.tvDataMappingPreview.setModel(self.model)
        self.tvDataMappingPreview.resizeColumnsToContents()
    def cmbPatIdColumnChanged(self, text):
        """PatientID column changed
        """
        # Set selected study and reload sites
        self._selectedPatIdColumn = first.first(
            col for col in self._columns
            if col.encode("utf-8") == text.toUtf8())

        # Enable ok button
        if self._selectedPatIdColumn:
            self.btnOk.setDisabled(False)
        else:
            self.btnOk.setDisabled(True)
    def cmbStudyChanged(self, text):
        """Executed when the concrete study is selected from studies combobox
        """
        # Reset table views
        self.tvStudies.setModel(None)
        self.textBrowserProgress.clear()

        # Set selected study and reload sites
        self._selectedStudy = first.first(
            study for study in self._studies
            if study.name().encode("utf-8") == text.toUtf8())

        # Disable download button
        self._selectedStudySite = None
        self.btnDownload.setDisabled(True)

        # Reload study sites
        self.reloadStudySites()
    def tblEventCrfItemChanged(self, current, previous):
        """
        """
        self.tvItems.setModel(None)
        self.textBrowserProgress.clear()

        # Take the second column (OID) of selected row from table view
        column = 1
        index = self.crfProxyModel.index(current.row(), column);

        if index.data().toPyObject(): 
            self._selectedCrf = (
                first.first(
                    crf for crf in self._selectedStudyEvent.forms if crf.oid.encode("utf-8") == index.data().toPyObject().toUtf8()
                )
            )

        self.reloadItems()
Beispiel #11
0
    def tblEventCrfItemChanged(self, current, previous):
        """
        """
        self.tvItems.setModel(None)
        self.textBrowserProgress.clear()

        # Take the second column (OID) of selected row from table view
        column = 1
        index = self.crfProxyModel.index(current.row(), column)

        if index.data().toPyObject():
            self._selectedCrf = first.first(
                crf
                for crf in self._selectedStudyEvent.forms
                if crf.oid.encode("utf-8") == index.data().toPyObject().toUtf8()
            )

        self.reloadItems()
    def cmbStudyChanged(self, text):
        """Executed when the concrete study is selected from studies combobox
        """
        # Reset table views
        self.tvStudies.setModel(None)
        self.tvStudySubjects.setModel(None)
        self.tvStudyEvents.setModel(None)
        self.tvCrfs.setModel(None)
        self.tvItems.setModel(None)
        self.textBrowserProgress.clear()

        # Set selected study and reload sites
        self._selectedStudy = first.first(
            study for study in self._studies if study.name.encode("utf-8") == text.toUtf8()
        )
    
        # Reload study sites
        if self._selectedStudy:
            self._logger.debug("Selected study: %s" % (self._selectedStudy.name))
            self.reloadStudySites()
Beispiel #13
0
    def cmbStudyChanged(self, text):
        """Executed when the concrete study is selected from studies combobox
        """
        # Reset table views
        self.tvStudies.setModel(None)
        self.tvStudySubjects.setModel(None)
        self.tvStudyEvents.setModel(None)
        self.tvCrfs.setModel(None)
        self.tvItems.setModel(None)
        self.textBrowserProgress.clear()

        # Set selected study and reload sites
        self._selectedStudy = first.first(
            study for study in self._studies if study.name.encode("utf-8") == text.toUtf8()
        )

        # Reload study sites
        if self._selectedStudy:
            self._logger.debug("Selected study: %s" % (self._selectedStudy.name))
            self.reloadStudySites()
    def loadModuleData(self, selectedIndex):
        if selectedIndex == 0:
            self.reloadSites()
            self.tvStudies.selectionModel().currentChanged.connect(
                self.tvStudyChanged)
        elif selectedIndex == 1:
            self.reloadSubjects()
            self.tvSubjects.selectionModel().currentChanged.connect(
                self.tvSubjectChanged)
        elif selectedIndex == 2:
            self.reloadSubjects()
            self.tvSubjects.selectionModel().currentChanged.connect(
                self.tvSubjectChanged)

            self.selectedSubject = first.first(
                subject for subject in self.subjects
                if subject.subject.uniqueIdentifier ==
                self.selectedSubject.subject.uniqueIdentifier)

            self.reloadEvents()
            self.tvEvents.selectionModel().currentChanged.connect(
                self.tvEventsChanged)
Beispiel #15
0
    def cmbStudyEventChanged(self, text):
        """
        """
        # I need to find StudyEvent object according to name (text)
        self.__selectedStudyEvent = first.first(event
                                                for event in self.__studyEvents
                                                if event.name() == text)

        # When selected event found search CRFs for the event
        if self.__selectedStudyEvent is not None:
            # Load list of Study Event Form Definition domain objects
            self.__studyEventCrfs = self.fileMetaDataService.loadEventCrfs(
                self.__selectedStudyEvent)

            # And prepare ViewModel for the GUI
            sefModel = QtGui.QStandardItemModel()

            for studyEventCrf in self.__studyEventCrfs:
                text = QtGui.QStandardItem(studyEventCrf.name())
                sefModel.appendRow([text])

            self.cmbEventForm.setModel(sefModel)
Beispiel #16
0
    def tblStudySubjectItemChanged(self, current, previous):
        """Event handler which is triggered when selectedStudySubject change
        """
        self.tvStudyEvents.setModel(None)
        self.tvCrfs.setModel(None)
        self.tvItems.setModel(None)
        self.textBrowserProgress.clear()

        # Take the second column (StudySubjectID) of selected row from table view
        column = 1
        index = self.studySubjectProxyModel.index(current.row(), column)
        print index.data().toPyObject()
        if index.data().toPyObject():
            self._selectedStudySubject = first.first(
                subject
                for subject in self._studySubjects
                if subject.label.encode("utf-8") == index.data().toPyObject().toUtf8()
            )

            if self._selectedStudySubject:

                # Load scheduled events for selected subject
                self.reloadEvents()
    def tblStudySubjectItemChanged(self, current, previous):
        """Event handler which is triggered when selectedStudySubject change
        """
        self.tvStudyEvents.setModel(None)
        self.tvCrfs.setModel(None)
        self.tvItems.setModel(None)
        self.textBrowserProgress.clear()

        # Take the second column (StudySubjectID) of selected row from table view
        column = 1
        index = self.studySubjectProxyModel.index(current.row(), column);
        print index.data().toPyObject()
        if index.data().toPyObject(): 
            self._selectedStudySubject = (
                first.first(
                    subject for subject in self._studySubjects if subject.label.encode("utf-8") == index.data().toPyObject().toUtf8()
                    )
                )

            if self._selectedStudySubject:

                # Load scheduled events for selected subject
                self.reloadEvents()
    def tblStudyItemChanged(self, current, previous):
        """Event handler which is triggered when selectedStudy change

        When the study is selected I have to clean all the other data elements
        Which depends on study. It means: StudySubjects, StudyEventDefinitions, StudyEventCRFs
        """
        # Clean the model before loading the new one
        self.tvStudySubjects.setModel(None)
        self.tvStudyEvents.setModel(None)
        self.tvCrfs.setModel(None)
        self.tvItems.setModel(None)  
        self.textBrowserProgress.clear()  

        # Take the first column of selected row from table view
        index = self.studyProxyModel.index(current.row(), 0); 

        # Multicentric
        if len(self._selectedStudy.sites) > 0:
            self._selectedStudySite = first.first(
                studySite for studySite in self._selectedStudy.sites if studySite.identifier.encode("utf-8") == index.data().toPyObject().toUtf8()
            )

        # Get the study metadata
        self.reloadStudyMetadata()
Beispiel #19
0
 def get_ordered_time(self):
     return first(
         self.order_events,
         lambda oe: oe.event_id == Event.get_ordered_id()).timestamp
Beispiel #20
0
 def cmbEventFormChanged(self, text):
     """
     """
     self.__selectedEventCrf = first.first(crf
                                           for crf in self.__studyEventCrfs
                                           if crf.name() == text)
 def cmbStudyEventsChanged(self, text):
     """
     """
     self.selectedEvent = first.first(
         unsheduledEvent for unsheduledEvent in self.studyEvents
         if unsheduledEvent.oid == text)
Beispiel #22
0
 def __get_beer_pub_product(self, product):
     return first(self.beer_pub_products,
                  lambda bpp: bpp.product_id == product.id)