from dcmqrscp import start_dcmqrscp from dicom.dataset import Dataset # first create a partner start_dcmqrscp(server_port=2001, server_AET='AE1', populate=True) for ii in range(20): print # call back def OnAssociateResponse(association): print "Association response received" # create application entity MyAE = AE('localhost', 9999, [PatientRootFindSOPClass, VerificationSOPClass], []) MyAE.OnAssociateResponse = OnAssociateResponse # remote application entity RemoteAE = {'Address': 'localhost', 'Port': 2001, 'AET': 'AE1'} # create association with remote AE print "Request association" assoc = MyAE.RequestAssociation(RemoteAE) # perform a DICOM ECHO print "DICOM Echo ... ", st = assoc.VerificationSOPClass.SCU(1) print 'done with status "%s"' % st
# ds is the identifyer dataset # pretend that we lookup the database to find a list of datasets to be # moved yield dict(AET=remoteAE, Port=2001, Address='localhost') nop = 10 yield nop for ii in range(nop): # create fake dataset ds = dicom.read_file(os.path.join(testfiles_dir(), "rtplan.dcm")) print "sending fake dataset" yield ds # create application entity MyAE = AE('localhost', 9999, [RTPlanStorageSOPClass], [PatientRootMoveSOPClass, VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveMove = OnReceiveMove dcmtkscu.run_in_term( 'movescu -v -P -aem AE1 -k 0010,0010="*" -k 0008,0052="PATIENT" ' 'localhost 9999') # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
def OnReceiveEcho(self): print print "Echo received" return True def OnReceiveFind(self, ds): for ii in range(1000): ds.PatientsName = 'titi' + str(ii) print "sending fake response: patient name: %s" % ds.PatientsName yield ds, 0xFF00 # responding to find request # create application entity MyAE = AE('localhost', 9999, [], [PatientRootFindSOPClass, VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveFind = OnReceiveFind dcmtkscu.run_in_term( 'findscu -v -P -aec AE1 -k 0010,0010="*" -k 0008,0052="PATIENT"' ' localhost 9999') # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
# call back def OnAssociateResponse(association): print "Association response received" def OnReceiveStore(SOPClass, DS): print "Received C-STORE" print DS return 0 # create application entity MyAE = AE( 'LocalAE', 9998, [PatientRootGetSOPClass, VerificationSOPClass], [RTPlanStorageSOPClass, CTImageStorageSOPClass, MRImageStorageSOPClass, RTImageStorageSOPClass]) MyAE.OnAssociateResponse = OnAssociateResponse MyAE.OnReceiveStore = OnReceiveStore # remote application entity RemoteAE = {'Address': 'localhost', 'Port': 2001, 'AET': 'AE1'} # create association with remote AE print "Request association" assoc = MyAE.RequestAssociation(RemoteAE) # perform a DICOM ECHO print "DICOM Echo ... ", st = assoc.VerificationSOPClass.SCU(1)
import pydicom import dcmqrscp from utils import testfiles_dir # start peer dcmqrscp.start_dcmqrscp() # call back def OnAssociateResponse(association): print "Association response received" # create application entity MyAE = AE('localhost', 9999, [RTPlanStorageSOPClass, VerificationSOPClass], []) MyAE.OnAssociateResponse = OnAssociateResponse # remote application entity RemoteAE = {'Address': 'localhost', 'Port': 2000, 'AET': 'OFFIS_AE'} # create some dataset d = dicom.read_file(os.path.join(testfiles_dir(), "rtplan.dcm")) # create association with remote AE print "Request association" assoc = MyAE.RequestAssociation(RemoteAE) # perform a DICOM ECHO # time.sleep(2) print "DICOM Echo ... ",
from dcmqrscp import start_dcmqrscp from dicom.dataset import Dataset # first create a partner start_dcmqrscp(server_port=2001, server_AET='AE1', populate=True) for ii in range(20): print # call back def OnAssociateResponse(association): print "Association response received" # create application entity MyAE = AE('localhost', 9999, [PatientRootFindSOPClass, VerificationSOPClass], []) MyAE.OnAssociateResponse = OnAssociateResponse # remote application entity RemoteAE = {'Address': 'localhost', 'Port': 2001, 'AET': 'AE1'} # create association with remote AE print "Request association" assoc = MyAE.RequestAssociation(RemoteAE) # perform a DICOM ECHO print "DICOM Echo ... ", st = assoc.VerificationSOPClass.SCU(1) print 'done with status "%s"' % st # send dataset using RTPlanStorageSOPClass
from dicom.dataset import Dataset # first create a partner start_dcmqrscp(server_port=2001, server_AET='AE1', populate=True) start_dcmqrscp(server_port=2002, server_AET='AE2', populate=True) for ii in range(20): print # call back def OnAssociateResponse(association): print "Association response received" # create application entity MyAE = AE('LocalAE', 9998, [PatientRootMoveSOPClass, VerificationSOPClass], []) MyAE.OnAssociateResponse = OnAssociateResponse # remote application entity RemoteAE = {'Address': 'localhost', 'Port': 2001, 'AET': 'AE1'} # create association with remote AE print "Request association" assoc = MyAE.RequestAssociation(RemoteAE) # perform a DICOM ECHO print "DICOM Echo ... ", st = assoc.VerificationSOPClass.SCU(1) print 'done with status "%s"' % st # send dataset using RTPlanStorageSOPClass
def OnReceiveMove(self, ident, remoteAE): # ds is the identifyer dataset # pretend that we lookup the database to find a list of datasets to be moved yield dict(AET=remoteAE, Port=2001, Address='localhost') nop = 10 yield nop for ii in range(nop): # create fake dataset ds = dicom.read_file(os.path.join(testfiles_dir(), "rtplan.dcm")) print "sending fake dataset" yield ds # create application entity MyAE = AE('localhost', 9999, [RTPlanStorageSOPClass], [PatientRootMoveSOPClass, VerificationSOPClass]) MyAE.OnAssociateRequest = OnAssociateRequest MyAE.OnReceiveEcho = OnReceiveEcho MyAE.OnReceiveMove = OnReceiveMove dcmtkscu.run_in_term( 'movescu -v -P -aem AE1 -k 0010,0010="*" -k 0008,0052="PATIENT" localhost 9999' ) # start application entity MyAE.start() MyAE.QuitOnKeyboardInterrupt()
# call back def OnAssociateResponse(association): print "Association response received" def OnReceiveStore(SOPClass, DS): print "Received C-STORE" print DS return 0 # create application entity MyAE = AE('LocalAE', 9998, [PatientRootGetSOPClass, VerificationSOPClass], [ RTPlanStorageSOPClass, CTImageStorageSOPClass, MRImageStorageSOPClass, RTImageStorageSOPClass, ]) MyAE.OnAssociateResponse = OnAssociateResponse MyAE.OnReceiveStore = OnReceiveStore # remote application entity RemoteAE = {'Address': 'localhost', 'Port': 2001, 'AET': 'AE1'} # create association with remote AE print "Request association" assoc = MyAE.RequestAssociation(RemoteAE) # perform a DICOM ECHO print "DICOM Echo ... ", st = assoc.VerificationSOPClass.SCU(1)