Menu

#5 Z Segments NUnit Sample

open
nobody
None
5
2014-08-21
2006-08-23
DaBuddhaMan
No

In
http://sourceforge.net/tracker/index.php?func=detail&aid=1523688&group_id=166900&atid=840798
I told about a shortcome of the PipeParser,
DefaultXMLParser and XMLParser classes when you want to
programmically add Z Segments (not generate them from
the HL7 database, because not every body has the database).

So I wrote a NUnit test to show how simple it is to
extend the base messages (in my case v22 messages) and
add your own Z Segments.

The additional HL7 packages (assemblies) containing the
derived messages with the Z Segments can be configured
in the app.config file under the 'hl7PackageConfig'
section.

Example configuration:
<hl7PackageConfig>
<hl7PackageCollection>
<add hl7Package="NHapi.Model.V22_ZSegments" />
</hl7PackageCollection>
</hl7PackageConfig>

Code:
- The HL7PackageConfigurationSection.cs holds the code
for the config section.
- The ZSegmentsModelClassFactory.cs holds a 99% copy of
the DefaultModelClassFactory class. The only difference
is that we can add our customized packages (defined in
the 'hl7PackageConfig' config section from the
app.config) first in the loadPackages() function.
- We also need to add this chained constructor to the
PipeParser class
public PipeParser(ModelClassFactory theFactory) :
base(theFactory)
{
}

It would be nice I if such a mechanism - of loading
assemblies with Z segments - would be integrated in nHapi.

Discussion

  • DaBuddhaMan

    DaBuddhaMan - 2006-08-23

    Z Segments assembly with NUnit test

     
  • ChadC

    ChadC - 2006-08-28

    Logged In: YES
    user_id=1522633

    I like this way of loading custom packages. I can use this
    to load my custom packages also. I'm going to incorporate
    this into the library shortly. Thanks for the comments and
    code!