NHapi is a port of the original project HAPI.
NHapi allows Microsoft .NET developers to easily use an HL7 2.x object model. This object model allows for parsing and encoding HL7 2.x data to/from Pipe Delimited or XML formats. A very handy program for use in the health care industry.
With 7 years experience of developing HL7 related applications (HL7 messaging and integration), I have found that in reality, people do not always conformant with HL7’s specification, thus there are always something more or less in the actual HL7 message than what the specification says. This makes the static object model sometime not able to represent the HL7 it is processing, to solve this problem, Terser is introduced to read values from the HL7 regardless the static structure of a particular version of HL7. Terser uses path to locate a particular value. The path consists of segment, field and component, sub component. Unfortunately, the segment consists of group and the name of segment, but group are vary from version to version of HL7, for example, a PRD of REF^I12 in version 2.3.1 is under group PROVIDER, but it is not in any group in version 2.4. Another problem is that I have not been able to find a document in which tells you what groups are in a type of message for each version of HL7, this then leaves you only way to figure out is by guessing. After I have gain more experience of NHAPI, I now can use following code to print out a whole path picture of a specified message:
static void PrintNames(string ident,IStructure s)
{
Console.Write(ident);
Console.Write(s.GetStructureName());
if (! (s is IGroup))
{
Console.WriteLine("");
return;
}
Console.WriteLine("(Group)");IGroup g = (IGroup)s;
foreach (var sn in (g.Names))
{
IStructure ss = g.GetStructure(sn);
if (ss is IGroup)
{
PrintNames(ident + " ", ss);
}
else
{
Console.Write(ident + " ");
Console.WriteLine(sn);}
//Console.WriteLine("");
}
}
Call it with
REF_I12 r= new REF_I12;
PrintNames(“”,r)
we can get the path tree:
REF_I12(Group)
MSH
RF1
AUTHORIZATION_CONTACT(Group)
AUT
CTD
PROVIDER(Group)
PRD
CTD
PID
NK1
GT1
INSURANCE(Group)
IN1
IN2
IN3
ACC
DG1
DRG
AL1
PROCEDURE(Group)
PR1
AUTHORIZATION_CONTACT(Group)
AUT
CTD
OBSERVATION(Group)
OBR
NTE
RESULTS_NOTES(Group)
OBX
NTE
PATIENT_VISIT(Group)
PV1
PV2
NTE
No comments:
Post a Comment