# C-STORE requests for the supported SOP classes ext_neg = [] for context in ae.presentation_contexts_scu: tmp = SCP_SCU_RoleSelectionNegotiation() tmp.sop_class_uid = context.AbstractSyntax tmp.scu_role = False tmp.scp_role = True ext_neg.append(tmp) # Request association with remote assoc = ae.associate(args.peer, args.port, args.called_aet, ext_neg=ext_neg) # Create query dataset d = Dataset() d.PatientsName = '*' d.QueryRetrieveLevel = "PATIENT" if args.patient: query_model = 'P' elif args.study: query_model = 'S' elif args.psonly: query_model = 'O' else: query_model = 'P' def on_c_store(sop_class, dataset): """ Function replacing ApplicationEntity.on_store(). Called when a dataset is received following a C-STORE. Write the received dataset to file
# remote application entity RemoteAE = dict(Address=args.remotehost, Port=args.remoteport, AET=args.aec) # 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 print "DICOM FindSCU ... ", d = Dataset() d.PatientsName = args.searchstring d.QueryRetrieveLevel = "PATIENT" d.PatientID = "*" st = assoc.PatientRootFindSOPClass.SCU(d, 1) print 'done with status "%s"' % st for ss in st: if not ss[1]: continue # print ss[1] try: d.PatientID = ss[1].PatientID except: continue print "Moving" print d
if args.key: pass # Format examples: # "(gggg,eeee)=" Null value # "(gggg,eeee)=CITIZEN*" Typical use # "(gggg,eeee)[0].Modality=CT" Sequence # "(gggg,eeee)[*].Modality=CT" Sequence with wildcard # "(gggg,eeee)=1\\2\\3\\4" VM of 4 # Parse (), [], ., =, \\ # () to get tag # ()[]()[]()[]() # ()[].()[].()[].() # Create query dataset dataset = Dataset() dataset.PatientsName = '*' dataset.QueryRetrieveLevel = "PATIENT" # Query/Retrieve Information Models if args.worklist: query_model = 'W' elif args.patient: query_model = 'P' elif args.study: query_model = 'S' elif args.psonly: # Retired query_model = 'O' else: query_model = 'W'