Custom Medical Storage Data Access Layer

A Custom Medical Storage Data Access Layer must contain the following classes:

Requirement

My.Medical.Storage.DataAccessLayer Implementation

Data access agent that implements IStorageDataAccessAgent

class MyStorageSqlDbDataAccessAgent

Data access configuration view that implements IDataAccessConfigurationView. This helper class is used to create the data access agent.

class MyStorageDataAccessConfigurationView

One class for each table that extracts DICOM data from System.Data.DataRow

class MyPatientInfo : IPatientInfo

class MyStudyInfo : IStudyInfo

class MySeriesInfo : ISeriesInfo

class MyInstanceInfo : IInstanceInfo

A strongly typed class that represents the custom database (derives from System.Data.DataSet )

class MyDataSet : System.Data.DataSet

One class for each table that is used with the MatchingParameterCollection to generate the WHERE statement of the database query

class MyPatient : CatalogEntity

class MyStudy : CatalogEntity

class MySeries : CatalogEntity

class MyInstance : CatalogEntity

The medical storage data access layer used in the tutorial also includes the following helper classes, which are not strictly required but simplify implementation:

Helper Class My.Medical.Storage.DataAccessLayer Implementation

Extracts the patient, study, series, and instance information from a DicomDataSet object, and add/updates the System.Data.DataSet tables (patient, study, series, instance) accordingly

class MyDicomDataSetConvertor

SQL query statements and statement fragments used to build SQL query statements

class MyConstants

class MySqlStatments

The sample custom medical storage data access layer is called My.Medical.Storage.DataAccessLayer. It is included in the LEAD installation as a sample project.  It contains all of the classes in the two tables. 

Open the project file in Visual Studio, and you will see the files in the project:

The following table describes the contents of each file

Folder

FileName

Contents

Configuration

Classes to extract DICOM data from a System.Data.DataRow

MyPatientInfo.cs

class MyPatientInfo : IPatientInfo

MyStudyInfo.cs

class MyStudyInfo : IStudyInfo

MySeriesInfo.cs

class MySeriesInfo : ISeriesInfo

MyInstanceInfo.cs

class MyInstanceInfo : IInstanceInfo

DataAccessLogic\BusinessEntity

A strongly typed class that represents an in-memory representation of your custom database

MyDataSet.xsd

Schema for custom database

MyDataSet.cs

class MyDataSet

DataAccessLogic\ComponentFactory

Helper class used to create the data access agent

MyDataAccessConfigurationView.cs

class MyStorageDataAccessConfigurationView

DataAccessLogic\DataAccessAgent\Database\SqlServer

Implementation of IStorageDataAccessAgent that uses SQL-specific methods

MyCommandText.cs

class MyStorageSqlDbDataAccessAgent

MyConstants.cs

class MyConstants

class MySqlStatments

MyStorageSqlDataAccessAgent.cs

class MyStorageSqlDbDataAccessAgent

DataAccessLogic\DataAccessAgent

Implementation of IStorageDataAccessAgent, containing methods that are not SQL-specific

MyStorageDbDataAccessAgent.cs

class MyStorageSqlDbDataAccessAgent

DataAccessLogic\DicomDataSetConvertor

MyDicomDataSetConvertor.cs

class MyDicomDataSetConvertor

Entities

classes used with the MatchingParameterCollection to generate the WHERE statement of the database query

MyPatientBase.cs

class MyPatient : CatalogEntity

MyStudyBase.cs

class MyStudy< : CatalogEntity

MySeriesBase.cs

class MySeriesInfo : ISeriesInfo

MyInstanceBase.cs

class MyInstanceInfo : IInstanceInfo

Utilities

Utilities class containing extension methods

Utils.cs

class MyUtils

These classes are described in detail below, and organized by namespace

namespace My.Medical.Storage.DataAccessLayer

namespace My.Medical.Storage.DataAccessLayer.DataAccessLogic.BusinessEntity

namespace My.Medical.Storage.DataAccessLayer.DataAccessLogic.DataAccessAgent.Database.SqlServer

namespace My.Medical.Storage.DataAccessLayer.DataAccessLogic.DicomDataSetConvertor

namespace My.Medical.Storage.DataAccessLayer.Entities

C#
// This example builds an IDbCommand  
// for querying the MyPatient table 
// The generated WHERE clause contains PatientName and PatientSex 
public void MyExample() 
{ 
    MatchingParameterCollection matchingParamCollection = new MatchingParameterCollection(); 
    MatchingParameterList matchingParamList = new MatchingParameterList(); 
 
    MyPatient myPatient = new MyPatient(); 
    myPatient.PatientName = "Smith"; 
    myPatient.PatientSex = "M"; 
 
    matchingParamList.Add(myPatient); 
    matchingParamCollection.Add(matchingParamList); 
 
    IDbCommand command = new SqlCommand(); 
 
    // This reads the storage catalog 
    // Before you run this, make sure and add the following to your application configuration file 
 
    //<configSections> 
    //    <section name="xmlStorageCatalogSettings" type="Leadtools.Medical.Storage.DataAccessLayer.XmlStorageCatalogSettings, Leadtools.Medical.Storage.DataAccessLayer" /> 
    //</configSections> 
    StorageCatalog myCatalog = new StorageCatalog(); 
 
    Collection<CatalogElement[]> catalogElements = CatalogDescriptor.GetElementsCollection(matchingParamCollection, myCatalog , true); 
 
    PreparePatientsQueryCommand(command, catalogElements); 
 
    // The 'WHERE' clause of command.CommandText is the following: 
    //    WHERE ( (  MyPatientTable.PatientName LIKE  'Smith' ) AND (  MyPatientTable.PatientSex LIKE  'M' ) ) 
    Console.WriteLine(command.CommandText); 
} 

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Imaging, Medical, and Document
Click or drag to resize