Ejemplo n.º 1
0
    #logger.debug("pydicom::Dataset()")
    meta = Dataset()
    meta.MediaStorageSOPClassUID = dataset.SOPClassUID
    meta.MediaStorageSOPInstanceUID = '1.2.3'
    meta.ImplementationClassUID = '1.2.3.4'
    
    #logger.debug("pydicom::FileDataset()")
    ds = FileDataset(filename, {}, file_meta=meta, preamble=b"\0" * 128)
    ds.update(dataset)
    ds.is_little_endian = True
    ds.is_implicit_VR = True
    #logger.debug("pydicom::save_as()")
    ds.save_as(filename)
        
    return sop_class.Success

ae.on_c_store = on_c_store

# Send query
if assoc.is_established:
    if args.move_aet:
        response = assoc.send_c_move(d, args.move_aet, query_model=query_model)
    else:
        response = assoc.send_c_move(d, args.calling_aet, query_model=query_model)
    
    time.sleep(1)
    for (status, d) in response:
        pass
    
    assoc.release()
Ejemplo n.º 2
0
    # Add the file meta to the dataset
    ds.file_meta = meta

    # Set the transfer syntax attributes of the dataset
    ds.is_little_endian = context.transfer_syntax.is_little_endian
    ds.is_implicit_VR = context.transfer_syntax.is_implicit_VR

    # Save the dataset using the SOP Instance UID as the filename
    ds.save_as(ds.SOPInstanceUID + ".dcm", write_like_original=False)

    # Return a 'Success' status
    return 0x0000


ae.on_c_store = on_c_store

# Associate with peer AE at IP 127.0.0.1 and port 11112
assoc = ae.associate('127.0.0.1', 11112, ext_neg=ext_neg)

if assoc.is_established:
    # Use the C-GET service to send the identifier
    # A query_model value of 'P' means use the 'Patient Root Query Retrieve
    #     Information Model - Get' presentation context
    responses = assoc.send_c_get(ds, query_model='P')

    for (status, identifier) in responses:
        if status:
            print('C-GET query status: 0x{0:04x}'.format(status.Status))

            # If the status is 'Pending' then `identifier` is the C-GET response