Sunday, May 3, 2009

Electronic Medical Records

The 2009 Federal Stimulus Package devotes $20 billion dollars to electron medical records and another $7.2 billion to broadband Internet access. The spending is unprecedented not only on scale, but also on breath of technology. There is $17.6 billion allocated for incentive payments to health-care providers who adopt electronic health records and $2 billion for coordinating information technology.

This financing is intended to move health care to a new level of quality as well as cost containment.

The healthcare industry exists to heal the human body when it becomes ill. But it needs assistance to overcome inefficient, manual, paper-based processes by automating methods utilizing collaboration, electronic forms, and enhanced patient care.

Automate information capture through electronic registration, health histories, consent forms, and disclosure forms could streamline the entry process. A nurse or administrator can verify health data extract data to electronic medical record (EMR) systems. Then trigger other processes such as billing or scheduling automatically. As a patient's medical record evolves over time, content can be consolidated into a single secure file.

An Electronic Medical Record (EMR) is an electronic record of health-related information on an individual created by authorized staff within one health care organization.

An Electronic Health Record (HER) is an electronic record of health-related information on an individual that conforms to nationally recognized interoperability standards that is managed by authorized staff across more than one health care organization.

A Personal Health Record (PHR) is an electronic record of health-related information on an individual that conforms to nationally recognized interoperability standards and that can be drawn from multiple sources.

The goal is to leverage industry standards and integrate them with enterprise documentation systems through EMR, HER and PHR.

Of the more than 800,000 clinicians in the US, only 17% have EHRs today. This leaves 664,000 who need EHRs. Over the next 5 years the early adopters will gain the full stimulus incentive amounts available in 2011-2012.

There are over 100 companies developing EHRs such as the market leaders are eClinicalWorks, Allscripts, NextGen, GE Centricity, and Meditech/LSS.

One of the most cost effect information technology upgrades for addressing the voluminous data intensive mega-file healthcare records is through parallel processing. We can expect to see tremendous innovation in this area.

Sunday, March 29, 2009

Primer on PLINQ

In this presentation, we present a primer on LINQ and then we extended its reach to the parallel version Parallel Language Integrated Query (or Parallel LINQ). Parallel LINQ (PLINQ) provides Declarative data parallelism through the ParallelEnumerable and ParallelQuery Classes. We concentrate on the ParallelQuery Class which has two methods (AsParallel, AsSequential).

Language Integrated Query (LINQ) is a special kind of search that locates data from various data sources. LINQ shortens queries while simplifying connecting to a variety of data source. It is all about searching efficiently and consistently with less effort. LINQ searches an array as one searches a Structured Query Language (SQL) server. It divides queries into four common types: LINQ-to-Object and LINQ-to-XML (which we will find also support PLINQ), as well as, LINQ-to-Dataset and LINQ-to-SQL.

The NET Framework LINQ namespaces create a different kind of data connection. The System.Linq namespace contains all the basic classes for LINQ and the System.Linq.Expressions namespace contains the classes, interfaces, and enumerations used to create expressions.

The three Stages in a Query Operation are

1/. Get the data source. If the source is an array you must declare the array and assign values.
2/. Define the query expression
3/. Execute the query to return the results.

For example, a LINQ query that retrieves data from an array would show these three stages as:

int[] nums = new int[] { 0, 4, 2, 6, 3, 8, 3, 0, 4, 2, 1 };

var result = from n in nums
where n < 5
orderby n
select n;

foreach (int i in result)

The standard LINQ operators consist of a collection of 50 methods that define extension methods on the static Enumerable and Queryable classes from the System.Linq namespace. The operators fall into one of two categories: for deferred execution of a query where the query will not execute until you consume the results, and Other operators will execute a query immediately.

LINQ uses keywords for making a query. They tell LINQ what to search for, starting with defining the from and in keywords. The where, orderby, join, and let provide additional conditions. A LINQ query requires four lines. First a variable that holds the query. An Enumerator object to select individual query values. The var keyword identifies the query variable. For example:

var MyQuery =
from StringValue
in QueryString
select StringValue;

Parallel LINQ (PLINQ) forms declarative data parallelism. Parallel Language Integrated Query (PLINQ) uses System.Linq namespace in the System.Threading.dll assembly. LINQ's declarative nature provides the flexibility for a clever implementation of PLINQ to use parallelization. PLINQ extends LINQ developers to use multiple cores for their LINQ expressions by running any LINQ-to-objects query using data parallelism. PLINQ fully supports all .NET query operators and the existing LINQ model.

PLINQ uses two classes:

 The ParallelEnumerable method exposed through System.Linq.ParallelEnumerable Class
 The AsParallel method exposed through System.Linq.ParallelQuery Class

PLINQ is a query execution engine that accepts any LINQ-to-Objects or LINQ-to-XML query and automatically utilizes multiple processors or cores for execution when they are available. The change in programming model is tiny, meaning you don't need to be a concurrency guru to use it.

With PLINQ you don't need to move your entire database server processing logic over to in-memory LINQ-to-Objects queries in the client. Instead, PLINQ offers an incremental way of using parallelism for existing solutions.

Internally, PLINQ uses Tasks and the parallelizing query gets processed by multiple threads. Preserving the order is an extra step that gives up some of the performance gains.

The following Listing expanding on an example provides an AsParallel methods for finding prime numbers in a loop using PLINQ based upon an example provided by Steven Toub.

Counting Prime Numbers In For Loop

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Xml;
using System.Diagnostics;
using System.Threading;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine(Time(delegate
{
Queue primes = new Queue();

for (int i = 0; i < 2000000; i++)
{
if (CheckPrime(i)) primes.Enqueue(i);

}
}));

Console.WriteLine(Time(delegate
{
Queue primes = new Queue();
Parallel.For(0, 2000000, i =>
{
if (CheckPrime(i)) primes.Enqueue(i);

});
}));
Console.ReadLine();
}
}

private static bool CheckPrime(int p)
{
if (p < 2) return false;
int upperBound = (int)Math.Sqrt(p);
for (int i = 2; i <= upperBound; i++)
{
if (p % i == 0) return false;
}
return true;
}

static TimeSpan Time(Action a)
{
Stopwatch sw = Stopwatch.StartNew();
a();
return sw.Elapsed;
}

}
}

SUMMARY

In this presentation, we began with a primer on LINQ and then we extended its reach to the parallel version Parallel Language Integrated Query (or Parallel LINQ). Parallel LINQ (PLINQ) provides Declarative data parallelism through the ParallelEnumerable and ParallelQuery Classes. We concentrated on the ParallelQuery Class which has two methods (AsParallel, AsSequential) and provide applications to demonstrate its capabilities.

REFERENCES

[1] Alesso, H. P. and Smith, C. F., Connections: Patterns of Discovery, John Wiley & Sons Inc., New York, NY, 2007.

[2] Alesso, H. P. and Smith, C. F., Thinking on the Web: Berners-lee, Turing and Godel, John Wiley & Sons, Inc. 2008.

[3] Microsoft Visual Studio 2010

Thursday, January 15, 2009

C# Concurrent Programming

Concurrent Programming is being developed to be scalable and produce high performance as manycore hardware systems are now being released for PCs, routers, and small devices. Programming for parallel processing will require optimizing multiple task execution.

Microsoft is planning on releasing concurrent programming tools for windows developers as fast as they can.

The Windows and .NET Framework platforms currently offer threading support for scheduling performance, synchronization AI, and memory hierarchy awareness. Microsoft’s Visual Studio 2010 will add concurrency at the library level for native as well as managed .NET languages.

Traditionally programming languages perform computations using syntax and semantic rules based upon the basic constructs: sequential statements, looping, branching and hierarchical organization. For C# managed code Microsoft has developed a Task Class, a Parallel Class, and a Enumerable Class to take advantage of these constructs for optimizing and simplifying concurrent programming.

Amdahl’s Law applies directly to the optimization of serial and parallel operations performed by software including branching (If, switch, etc.) operations and looping (do, for, and foreach) operations in programs where repetitious operations offer efficient points for concurrent programming methods.

While Microsoft has supported threading operations for many years thread have many hazards associated with simultaneous access of shared memory by different threads. This can lead to hazards that arise from competing threads that jeopardize state management including: deadlocks, livelocks, and race conditions. The next generation of Visual Studio 2010 tools addresses these difficulties.

As a result, Microsoft has developed a Task Program Library to exploits concurrency in program operations without the complexity and error prone direct exposure to threads. In addition, Microsoft’s implementation of these features optimizes core utilization while minimizing complexity.

The following Figure show the Visual Studio 2010 model for building parallel tasks for managed and native code on top of both threads and thread pools.



Figure: Visual Studio 2010 Programming Model

Parallel Extensions for .NET 3.5 provides library-based support for concurrency with any .NET language, such as C++, C# and Visual Basic. It includes: Task Parallel Library, Parallel LINQ, and parallel method extensions.

Visual Studio 2010 and .NET 4.0 provide these extensions in the form of a library for rapid development:

 Task Parallel Library (TPL)
 Imperative task parallelism – Task Class
 Imperative data parallelism – Parallel Class (Parallel.For)
 Parallel LINQ (PLINQ)
 Declarative data parallelism – ParallelEnumerable and AsParallel Class

The Task Parallel Library (TPL) provides support for imperative data and task parallelism. The Task Parallel Library (TPL) makes it easy to add data and task parallelization to an application.

Parallel LINQ (PLINQ) provides support for declarative data parallelism. PLINQ is an extension of LINQ where the query is run in parallel. PLINQ takes advantage of TPL by taking query iterations and assigning work units to threads (typically processor cores). Adding concurrent programming capabilities to LINQ is a natural extension of LINQ.

Coordination Data Structures (CDS) provide support for work coordination and managing shared state.

The .NET application developers can look forward to the release of Visual Studio 2010 for the tools and techniques to write simple efficient thread-safe code for manycore systems.

[1] Alesso, H. P. and Smith, C. F., Connections: Patterns of Discovery, John Wiley & Sons Inc., New York, NY, 2007.

[2] Alesso, H. P. and Smith, C. F., Thinking on the Web: Berners-lee, Turing and Godel, John Wiley & Sons, Inc. 2008.

[3] Microsoft Visual Studio 2010