Exemplo n.º 1
0
 def _verifyReceiptOfOrm(self, patientID, accessionNumber, maxSecondsToWait):
     status = None;
     edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
     for i in range(maxSecondsToWait):
         sleep(1);
         status = edgeDb.getLatestReportStatus(patientID, accessionNumber);
         if (status != None):
             break;
     return status;
 def _verifyReceiptOfOrm(self, patientID, accessionNumber, maxSecondsToWait):
     status = None;
     edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
     for i in range(maxSecondsToWait):
         sleep(1);
         status = edgeDb.getLatestReportStatus(patientID, accessionNumber);
         if (status != None):
             break;
     return status;
    def startNewJobAndTransactionOnEdge(self, patientID, accessionNumber):
        # Get EDGE ID for new patient and exam
        edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
        newPatientEdgeID = edgeDb.getPatientIndex(patientID);
        newExamEdgeID = edgeDb.getExamID(newPatientEdgeID, accessionNumber)

        transactionStatusCode = 1;
        jobId = edgeDb.submitNewJobTransaction(newPatientEdgeID, newExamEdgeID, transactionStatusCode, "");
        print 'JobId: ' + str(jobId) + ' Transaction status set to ' + str(transactionStatusCode) + '\n';
        return jobId;
Exemplo n.º 4
0
    def startNewJobAndTransactionOnEdge(self, patientID, accessionNumber):
        # Get EDGE ID for new patient and exam
        edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
        newPatientEdgeID = edgeDb.getPatientIndex(patientID);
        newExamEdgeID = edgeDb.getExamID(newPatientEdgeID, accessionNumber)

        transactionStatusCode = 1;
        jobId = edgeDb.submitNewJobTransaction(newPatientEdgeID, newExamEdgeID, transactionStatusCode, "");
        print 'JobId: ' + str(jobId) + ' Transaction status set to ' + str(transactionStatusCode) + '\n';
        return jobId;
 def waitForTransactionStatusCode(self, jobId, statusCode, maxSecondsToWait):
     ## Wait for arbitrary transaction status
     transactionStatusCode = 0;
     edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
     for i in range(int(maxSecondsToWait)):
         sleep(1);
         transactionStatusCode = edgeDb.getLastestTransactionStatus(jobId)
         if (int(transactionStatusCode) < 0 or int(transactionStatusCode) == int(statusCode)):
             print 'JobId: ' + str(jobId) + ' Transaction Status: ' + str(transactionStatusCode);
             break;
     return transactionStatusCode;
 def waitForCompletedXdsXfer(self, jobId, maxSecondsToWait):
     ## Wait for transaction status '40'
     transactionStatusCode = 0;
     edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
     for i in range(int(maxSecondsToWait/4)):
         sleep(4);
         transactionStatusCode = edgeDb.getLastestTransactionStatus(jobId)
         if (int(transactionStatusCode) < 0 or int(transactionStatusCode) == 40):
             print 'JobId: ' + str(jobId) + ' Transaction Status: ' + str(transactionStatusCode);
             break;
     return transactionStatusCode;
Exemplo n.º 7
0
 def waitForTransactionStatusCode(self, jobId, statusCode, maxSecondsToWait):
     ## Wait for arbitrary transaction status
     transactionStatusCode = 0;
     edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
     for i in range(int(maxSecondsToWait)):
         sleep(1);
         transactionStatusCode = edgeDb.getLastestTransactionStatus(jobId)
         if (int(transactionStatusCode) < 0 or int(transactionStatusCode) == int(statusCode)):
             print 'JobId: ' + str(jobId) + ' Transaction Status: ' + str(transactionStatusCode);
             break;
     return transactionStatusCode;
Exemplo n.º 8
0
 def waitForCompletedXdsXfer(self, jobId, maxSecondsToWait):
     ## Wait for transaction status '40'
     transactionStatusCode = 0;
     edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
     for i in range(int(maxSecondsToWait/4)):
         sleep(4);
         transactionStatusCode = edgeDb.getLastestTransactionStatus(jobId)
         if (int(transactionStatusCode) < 0 or int(transactionStatusCode) == 40):
             print 'JobId: ' + str(jobId) + ' Transaction Status: ' + str(transactionStatusCode);
             break;
     return transactionStatusCode;
def main():
	global tempDir;
	global mesaDir;
	global mesaToolDir;
	global dataDir;
	global dcm4CheDir;
	
	# Verify environment
	if not 'MESA_TARGET' in os.environ:
		print "Missing MESA_TARGET"
		exit(1)
	if not 'VERIF_VALID_HOME' in os.environ:
		print "Missing VERIF_VALID_HOME"
		exit(1)

	if not 'DCM4CHE_HOME' in os.environ:
		print "Missing DCM4CHE_HOME"
		exit(1)


	tempRoot = '/tmp'
	mesaDir = os.environ['MESA_TARGET'];
	mesaToolDir = mesaDir + '/bin';
	dataDir = os.environ['VERIF_VALID_HOME'] + '/data/A-7001';
	dcm4CheDir = os.environ['DCM4CHE_HOME'];
	
	registryURL = 'http://172.20.175.67:9080/axis2/services/xdsregistryb';
	repositoryURL = 'http://172.20.175.67:9080/axis2/services/xdsrepositoryb';
	repositoryUID = '1.2.3.4.5.6.7.8';
	

	customDemographics = generateDemographics();
	print customDemographics
	customFieldsDictionary = loadParameters(customDemographics[0],customDemographics[1],customDemographics[2],customDemographics[3]);	
	
	
	tempDir = tempRoot + '/' + customFieldsDictionary['ACCESSION_NUMBER'];
	if not os.path.exists(tempDir):
		os.makedirs(tempDir);
	
	# build and send ORM
	constructHl7OrmOrOru(tempDir + '/orm.hl7', dataDir + '/ihe_sched.tpl', dataDir + '/A-7001-01.var', customFieldsDictionary);
	xmitHl7('localhost', '20000', tempDir + '/orm.hl7');
	
	print "ORM HL7 messages sent\n";

	# build and send ORU
	constructHl7OrmOrOru(tempDir + '/oru.hl7', dataDir + '/ihe_oru.tpl', dataDir + '/A-7001-01.var', customFieldsDictionary);
	xmitHl7('localhost', '20000', tempDir + '/oru.hl7');

	print "ORU HL7 messages sent\n";

	# Get EDGE ID for new patient and exam
	edgeDb = EdgeDbManager('rsnadb');
	newPatientEdgeID = edgeDb.getMaxPatientID();
	newExamEdgeID = edgeDb.getMaxExamID();
	
	
	patientName = customFieldsDictionary['PATIENT_NAME'];
	print 'patientName:' + patientName;
	patientID = customFieldsDictionary['PATIENT_ID'];
	print 'patientID:' + patientID;
	accessionNumber = customFieldsDictionary['ACCESSION_NUMBER'];
	print 'accessionNumber:' + accessionNumber;
	
	
	## Prepare temp send data folder
	sentItemsDirName =  tempDir + '/sent'
	
	## Send DICOM files to DCM4CHEE on nibib-3 device
	aeTitle = 'DCM4CHEE';
	dcmHost = '172.20.175.63';
	dcmPort = '11112';
	dcmFileFolder = dataDir + '/dicom_files'

	dcmManager = DicomManager(dcm4CheDir, aeTitle, dcmHost, dcmPort);
	# Verify Dicom connection
	dcmManager.checkDicomRcvr();
	# Send files
	dcmManager.sendDicomFiles(dcmFileFolder, patientName, patientID, accessionNumber);
	print 'DICOM files transmitted\n';
	

	## Instruct EDGE device to retrieve DICOM files
	transactionStatusCode = 1;
	jobId = edgeDb.submitNewJobTransaction(newPatientEdgeID, newExamEdgeID, transactionStatusCode, "");
	print 'JobId: ' + str(jobId) + ' Transaction status set to ' + str(transactionStatusCode) + '\n';
	
	## Wait for transaction status '40'
	for i in range(10):
		sleep(1);
		transactionStatusCode = edgeDb.getLastestTransactionStatus(jobId)
		if (int(transactionStatusCode) < 0 or int(transactionStatusCode) == 40):
			print 'JobId: ' + str(jobId) + ' Transaction Status: ' + str(transactionStatusCode);
			break;
	if transactionStatusCode != 40:
		exit(1);
	
	
	## Query Clearinghouse for transmitted documents
	clearinghouse = ClearinghouseManager(registryURL, repositoryURL, repositoryUID);
	retreivedFilesDirectory = tempDir + '/retrieved';
	clearinghousePatientID = edgeDb.getSingleUsePatientID(jobId);
	
	PATIENT_ID_ASSIGNING_AUTHORITY = '1.3.6.1.4.1.19376.2.840.1.1.1.1';
	PATIENT_ID_ASSIGNING_AUTHORITY_TYPE = 'ISO';
	fullPatientID = clearinghousePatientID + r'^^^&' + PATIENT_ID_ASSIGNING_AUTHORITY + r'&' + PATIENT_ID_ASSIGNING_AUTHORITY_TYPE;
	
	clearinghouse.retreiveFilesByPatientID(clearinghousePatientID, retreivedFilesDirectory)

	## Retrieved files should be in 'retreivedFilesDirectory'
	print 'Retrieved Files to: ' + retreivedFilesDirectory;
	for name in os.listdir(retreivedFilesDirectory):
		print name;
 def updateTransactionStatusCode(self, jobId, statusCode):
     edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
     edgeDb.insertTransaction(jobId, statusCode, "Forced status update by test.");
Exemplo n.º 11
0
 def updateTransactionStatusCode(self, jobId, statusCode):
     edgeDb = EdgeDbManager('rsnadb', self.rsnaDbHost, self.rsnaDbUser, self.rsnaDbPassword);
     edgeDb.insertTransaction(jobId, statusCode, "Forced status update by test.");
Exemplo n.º 12
0
def main():
    global tempDir
    global mesaDir
    global mesaToolDir
    global dataDir
    global dcm4CheDir

    # Verify environment
    if not 'MESA_TARGET' in os.environ:
        print "Missing MESA_TARGET"
        exit(1)
    if not 'VERIF_VALID_HOME' in os.environ:
        print "Missing VERIF_VALID_HOME"
        exit(1)

    if not 'DCM4CHE_HOME' in os.environ:
        print "Missing DCM4CHE_HOME"
        exit(1)

    tempRoot = '/tmp'
    mesaDir = os.environ['MESA_TARGET']
    mesaToolDir = mesaDir + '/bin'
    dataDir = os.environ['VERIF_VALID_HOME'] + '/data/A-7001'
    dcm4CheDir = os.environ['DCM4CHE_HOME']

    registryURL = 'http://172.20.175.67:9080/axis2/services/xdsregistryb'
    repositoryURL = 'http://172.20.175.67:9080/axis2/services/xdsrepositoryb'
    repositoryUID = '1.2.3.4.5.6.7.8'

    customDemographics = generateDemographics()
    print customDemographics
    customFieldsDictionary = loadParameters(customDemographics[0],
                                            customDemographics[1],
                                            customDemographics[2],
                                            customDemographics[3])

    tempDir = tempRoot + '/' + customFieldsDictionary['ACCESSION_NUMBER']
    if not os.path.exists(tempDir):
        os.makedirs(tempDir)

    # build and send ORM
    constructHl7OrmOrOru(tempDir + '/orm.hl7', dataDir + '/ihe_sched.tpl',
                         dataDir + '/A-7001-01.var', customFieldsDictionary)
    xmitHl7('localhost', '20000', tempDir + '/orm.hl7')

    print "ORM HL7 messages sent\n"

    # build and send ORU
    constructHl7OrmOrOru(tempDir + '/oru.hl7', dataDir + '/ihe_oru.tpl',
                         dataDir + '/A-7001-01.var', customFieldsDictionary)
    xmitHl7('localhost', '20000', tempDir + '/oru.hl7')

    print "ORU HL7 messages sent\n"

    # Get EDGE ID for new patient and exam
    edgeDb = EdgeDbManager('rsnadb')
    newPatientEdgeID = edgeDb.getMaxPatientID()
    newExamEdgeID = edgeDb.getMaxExamID()

    patientName = customFieldsDictionary['PATIENT_NAME']
    print 'patientName:' + patientName
    patientID = customFieldsDictionary['PATIENT_ID']
    print 'patientID:' + patientID
    accessionNumber = customFieldsDictionary['ACCESSION_NUMBER']
    print 'accessionNumber:' + accessionNumber

    ## Prepare temp send data folder
    sentItemsDirName = tempDir + '/sent'

    ## Send DICOM files to DCM4CHEE on nibib-3 device
    aeTitle = 'DCM4CHEE'
    dcmHost = '172.20.175.63'
    dcmPort = '11112'
    dcmFileFolder = dataDir + '/dicom_files'

    dcmManager = DicomManager(dcm4CheDir, aeTitle, dcmHost, dcmPort)
    # Verify Dicom connection
    dcmManager.checkDicomRcvr()
    # Send files
    dcmManager.sendDicomFiles(dcmFileFolder, patientName, patientID,
                              accessionNumber)
    print 'DICOM files transmitted\n'

    ## Instruct EDGE device to retrieve DICOM files
    transactionStatusCode = 1
    jobId = edgeDb.submitNewJobTransaction(newPatientEdgeID, newExamEdgeID,
                                           transactionStatusCode, "")
    print 'JobId: ' + str(jobId) + ' Transaction status set to ' + str(
        transactionStatusCode) + '\n'

    ## Wait for transaction status '40'
    for i in range(10):
        sleep(1)
        transactionStatusCode = edgeDb.getLastestTransactionStatus(jobId)
        if (int(transactionStatusCode) < 0
                or int(transactionStatusCode) == 40):
            print 'JobId: ' + str(jobId) + ' Transaction Status: ' + str(
                transactionStatusCode)
            break
    if transactionStatusCode != 40:
        exit(1)

    ## Query Clearinghouse for transmitted documents
    clearinghouse = ClearinghouseManager(registryURL, repositoryURL,
                                         repositoryUID)
    retreivedFilesDirectory = tempDir + '/retrieved'
    clearinghousePatientID = edgeDb.getSingleUsePatientID(jobId)

    PATIENT_ID_ASSIGNING_AUTHORITY = '1.3.6.1.4.1.19376.2.840.1.1.1.1'
    PATIENT_ID_ASSIGNING_AUTHORITY_TYPE = 'ISO'
    fullPatientID = clearinghousePatientID + r'^^^&' + PATIENT_ID_ASSIGNING_AUTHORITY + r'&' + PATIENT_ID_ASSIGNING_AUTHORITY_TYPE

    clearinghouse.retreiveFilesByPatientID(clearinghousePatientID,
                                           retreivedFilesDirectory)

    ## Retrieved files should be in 'retreivedFilesDirectory'
    print 'Retrieved Files to: ' + retreivedFilesDirectory
    for name in os.listdir(retreivedFilesDirectory):
        print name