Deletes the series records that match the given query parameters, with an option to delete orphaned records.
public virtual int DeleteSeries(
MatchingParameterCollection matchingEntitiesCollection,
bool removeOrphanRecords
)
public:
virtual Int32 DeleteSeries(
MatchingParameterCollection^ matchingEntitiesCollection,
bool removeOrphanRecords
)
matchingEntitiesCollection
A MatchingParameterCollection which includes the matching parameters for a query.
removeOrphanRecords
true to remove orphaned records created by calling this method; false otherwise.
A value representing the number of deleted series.
Deleting one or more series can potentially leave orphaned database records.
For example:
Removing Series1 leaves the following orphaned records:
Pass true for the removeOrphanRecords argument to automatically remove orphaned when calling this method.
using Leadtools.Dicom;
using Leadtools.DicomDemos;
using Leadtools.Medical.DataAccessLayer;
using Leadtools.Medical.DataAccessLayer.Catalog;
using Leadtools.Medical.Storage.DataAccessLayer;
using Leadtools.Medical.Storage.DataAccessLayer.Configuration;
public static IStorageDataAccessAgent7 GetStorageDataAccessAgent7()
{
// Before running this sample, follow these steps:
// 1. Run CSPacsDatabaseConfigurationDemo.exe to create the databases
// 2. Run CSPACSConfigDemo.exe to create the DICOM services
// 3. Set 'serviceDirectory' to the DICOM service folder
string serviceDirectory = @"d:\LEADTOOLS22\Bin\Dotnet4\x64\L22_PACS_SCP64";
string productName = "StorageServer";
string serviceName = "L22_PACS_SCP64";
System.Configuration.Configuration configuration = DicomDemoSettingsManager.GetGlobalPacsAddinsConfiguration(serviceDirectory);
StorageDataAccessConfigurationView view = new StorageDataAccessConfigurationView(configuration, productName, serviceName);
IStorageDataAccessAgent7 agent = DataAccessFactory.GetInstance(view).CreateDataAccessAgent<IStorageDataAccessAgent7>();
return agent;
}
public static void InsertDicomFile(IStorageDataAccessAgent7 agent, string filename)
{
using (DicomDataSet ds = new DicomDataSet())
{
ds.Load(filename, DicomDataSetLoadFlags.None);
agent.StoreDicom(ds, filename, string.Empty, null, true, true, true, true);
}
}
public static void RemoveInstance(IStorageDataAccessAgent7 agent, string sopInstanceUid, bool removeOrphanedRecords)
{
ICatalogEntity instanceEntity = RegisteredEntities.GetInstanceEntity(sopInstanceUid);
MatchingParameterCollection mpc = new MatchingParameterCollection();
MatchingParameterList mpl = new MatchingParameterList();
mpl.Add(instanceEntity);
mpc.Add(mpl);
agent.DeleteInstance(mpc, removeOrphanedRecords);
}
public static void AddDicomImages(IStorageDataAccessAgent7 agent)
{
// Clear the database
agent.EmptyTable(Table.Patient);
agent.EmptyTable(Table.Study);
agent.EmptyTable(Table.Series);
agent.EmptyTable(Table.Instance);
// Add four DICOM Images, all the same Patient, Study, and Series
InsertDicomFile(agent, @"D:\LEADTOOLS22\Resources\Images\DICOM\MG\mg1.dcm");
InsertDicomFile(agent, @"D:\LEADTOOLS22\Resources\Images\DICOM\MG\mg2.dcm");
InsertDicomFile(agent, @"D:\LEADTOOLS22\Resources\Images\DICOM\MG\mg3.dcm");
InsertDicomFile(agent, @"D:\LEADTOOLS22\Resources\Images\DICOM\MG\mg4.dcm");
// Add another image that will not have orphans
InsertDicomFile(agent, @"D:\LEADTOOLS22\Resources\Images\DICOM\image2.dcm");
}
public static void CreatePatientStudySeriesOrphan(IStorageDataAccessAgent7 agent)
{
AddDicomImages(agent);
MatchingParameterCollection mc = new MatchingParameterCollection();
DataSet ds = agent.QueryPatients(mc);
// Remove the four SOPInstanceUID without removing orphans
bool removeOrphanedRecords = false;
RemoveInstance(agent, "1.2.840.114257.1.9.1245.56421.20124.5464751.12465.120.3", removeOrphanedRecords);
RemoveInstance(agent, "1.2.840.114257.1.9.1245.56421.52314.14567.124.2124", removeOrphanedRecords);
RemoveInstance(agent, "1.2.840.114257.1.9.1245.56421.52314.5647.124.2124.1", removeOrphanedRecords);
RemoveInstance(agent, "1.2.840.114257.1.9.1245.56421.7124.1245.1245.9542.1245", removeOrphanedRecords);
}
public static void StorageDatAccessOrphanExample()
{
try
{
DicomEngine.Startup();
IStorageDataAccessAgent7 agent = GetStorageDataAccessAgent7();
// This creates orphans:
// 1 Patient orphan
// 1 Study orphan
// 1 Series orphan
// 1 Instance orphan
CreatePatientStudySeriesOrphan(agent);
// Test 1
// Remove all orphans in the database
agent.RemoveOrphanRecords(null, OrphanTables.All);
// Create the 3 orphans again
CreatePatientStudySeriesOrphan(agent);
// Test 2
// This time remove only orphan records for a particular patient
MatchingParameterCollection mc = new MatchingParameterCollection();
MatchingParameterList mpl = new MatchingParameterList();
string patientId = "656421";
ICatalogEntity patientEntity = RegisteredEntities.GetPatientEntity(patientId);
mpl.Add(patientEntity);
mc.Add(mpl);
try
{
// Set diagnostic level to 1 to see debug messages in an application like DebugView
agent.DiagnosticLevel = 1;
agent.RemoveOrphanRecords(mc, OrphanTables.Series);
agent.RemoveOrphanRecords(mc, OrphanTables.Study);
agent.RemoveOrphanRecords(mc, OrphanTables.Patient);
}
finally
{
// Set diagnostic level back to 0 to stop showing debug messages
agent.DiagnosticLevel = 0;
}
// Test 3
// Add DICOM images, and then delete instances, studies, patients while removing orphans
AddDicomImages(agent);
agent.DeleteInstance(null, true);
// Test 4
// Add DICOM images, delete series removing all orphans.
AddDicomImages(agent);
agent.DeleteSeries(null, true);
// Test 5
// Add DICOM images. delete study removing all orphans.
AddDicomImages(agent);
agent.DeleteStudy(null, true);
}
finally
{
DicomEngine.Shutdown();
}
Console.WriteLine("Finished");
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.