コード例 #1
0
    def retrieve_request(self, d_filteredHits):
        """
        Perform a request to "move" the image data at SERIES level.

        This essentially loops over all the SeriesInstanceUID in the
        query space structure.

        For the special case of a dockerized run, this method will attempt
        to also restart the 'xinet.d' service within the container.

        NOTE: Some PACS servers require the StudyInstanceUID in addition
        to the SeriesInstanceUID.

        """
        self.systemlevel_run(self.arg, {'f_commandGen': self.xinetd_command})
        studyIndex = 0
        l_run = []
        for study in d_filteredHits['report']['json']:
            seriesIndex = 0
            str_header = d_filteredHits['report']['rawText'][studyIndex][
                'header']
            self.dp.qprint('\n%s' % str_header)
            for series, seriesUID in zip(study['body'],
                                         study['bodySeriesUID']):
                str_seriesDescription = series['SeriesDescription']
                str_seriesUID = seriesUID['SeriesInstanceUID']
                str_studyUID = d_filteredHits['data'][studyIndex][
                    'StudyInstanceUID']['value']
                self.dp.qprint(Colors.LIGHT_CYAN +
                               'Requesting SeriesDescription... ' +
                               Colors.YELLOW + str_seriesDescription)
                if self.move:
                    self.arg['SeriesInstanceUID'] = str_seriesUID
                    self.arg['StudyInstanceUID'] = str_studyUID
                    d_moveRun = pypx.move({
                        **self.arg,
                    })
                else:
                    d_moveRun = self.systemlevel_run(
                        self.arg, {
                            'f_commandGen': self.movescu_command,
                            'series_uid': str_seriesUID,
                            'study_uid': str_studyUID
                        })
                l_run.append(d_moveRun)
                if 'SeriesDescription' in study['body'][seriesIndex]:
                    study['body'][seriesIndex]['PACS_Retrieve'] = " [ OK ] "
                seriesIndex += 1
                time.sleep(1)
            studyIndex += 1
            # pudb.set_trace()
        return l_run
コード例 #2
0
ファイル: test_move.py プロジェクト: valentinafuentealba/pypx
    def test_move_command(self):
        options = {
            'executable': '/bin/movescu',
            'aec': 'MY-AEC',
            'aet': 'MY-AET',
            'aet_listener': 'LISTENER-AET',
            'series_uid': '123.354345.4545',
            'server_ip': '192.168.1.110',
            'server_port': '4242'
            }
        output = pypx.move(options)
        command = '/bin/movescu --move LISTENER-AET --timeout 5 \
-k QueryRetrieveLevel=SERIES \
-k SeriesInstanceUID=123.354345.4545  \
-aec MY-AEC -aet MY-AET 192.168.1.110 4242'
        self.assertEqual(output['command'], command)
コード例 #3
0
    def PACSinteract_process(self, *args, **kwargs):
        """
        The PACS Q/R handler.
        """

        b_status = True
        d_query = {}
        d_request = {}
        d_meta = {}
        str_path = ''
        d_ret = {}
        tree = self.s.T
        T = C_stree()
        for k, v in kwargs.items():
            if k == 'request': d_request = v

        # pudb.set_trace()
        d_meta = d_request['meta']
        if 'PACS' in d_meta:
            str_path = '/PACS/' + d_meta['PACS']
            if tree.isdir(str_path):
                tree.copy(startPath=str_path, destination=T)
                d_tree = dict(T.snode_root)
                d_service = d_tree['PACS'][d_meta['PACS']]
            else:
                return {'status': False, 'msg': 'Invalid PACS specified.'}
            # pudb.set_trace()
            if 'do' in d_meta:
                if 'on' in d_meta:
                    d_on = d_meta['on']
                if d_meta['do'] == 'query':
                    d_service['executable'] = tree.cat('/bin/findscu')
                    d_ret = pypx.find({**d_service, **d_on})
                    if d_ret['status'] == 'error' or not len(d_ret['data']):
                        b_status = False
                if d_meta['do'] == 'retrieve':
                    d_service['executable'] = tree.cat('/bin/movescu')
                    d_ret = pypx.move({**d_service, **d_on})
                    if d_ret['status'] == 'error':
                        b_status = False
                if d_meta['do'] == 'retrieveStatus':
                    d_ret = self.PACSinteract_checkStatus(request=d_request)
                    b_status = d_ret['status']
            else:
                return {'status': False, 'msg': 'No "do" directive specified.'}

        return {'status': b_status, d_meta['do']: d_ret}
コード例 #4
0
ファイル: do.py プロジェクト: SheriefEmam/pypx
 def retrieve_do() -> dict:
     """
     Nested retrieve handler
     """
     nonlocal series, studyIndex, seriesIndex
     seriesInstances : int   = series['NumberOfSeriesRelatedInstances']['value']
     d_then          : dict  = {}
     d_db            : dict  = db.seriesMapMeta(
                                 'NumberOfSeriesRelatedInstances',
                                 seriesInstances
                             )
     str_line        = presenter.seriesRetrieve_print(
         studyIndex  = studyIndex, seriesIndex = seriesIndex
     )
     if self.arg['withFeedBack']: self.log(str_line)
     series['SeriesMetaDescription']  = {
                             'tag'   : "0,0",
                             'value' : str_line,
                             'label' : 'inlineRetrieveText'
                         }
     if self.move:
         d_then      = pypx.move({
                         **self.arg,
                     })
     else:
         d_then = self.systemlevel_run(self.arg,
                 {
                     'f_commandGen'      : self.movescu_command,
                     'series_uid'        : str_seriesUID,
                     'study_uid'         : str_studyUID
                 }
         )
     series['PACS_retrieve'] = {
         'requested' :   '%s' % datetime.now()
     }
     d_db    = db.seriesMapMeta('retrieve', d_then)
     return d_then