Search code examples
c#hl7nhapi

HL7 - Parsing Specimen Source (OBR-15) using nHapi in c#


I was wondering if any wonderful person with experience of using nHAPI in C# would be able to help a newbie out with the OBR-15 field (Specimen Source) of an HL7 message? I've dug around and I can't find any documentation online to help me out, so I'd be grateful for any suggestions.

My problem is, I can't find the correct method for filling the OBR-15 field using nHAPI. I'm hoping to send an OBR segment that looks like this (I've removed data from all other fields except OBR15, so my actually message isn't as bare as this):

OBR|1||||||||||||||T034^Blood||||||||||||||||||||

I've tried every way possible to form this field with no success. I'm always getting an ampersand that appears in the front everything I'm sending, which means that the field is unreadable in downstream applications:

OBR|1||||||||||||||&T034^^^^^^&Blood||||||||||||||||||||

My OBR-15 code snippet (I've just kept the relevant stuff in here, as otherwise this section would be massive):

using System;
using System.Collections.Generic;
using System.Web.Services;
using NHapi.Model.V24.Message;
using NHapi.Model.V24.Segment;
using NHapi.Model.V24.Group;
using System.Data;
using System.Text;
using NHapi.Base.Parser;
using NHapi.Model.V24.Datatype;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Data.SqlClient;


namespace HL7WebService
{

    public class HL7Reporting : System.Web.Services.WebService
    {
        private ORU_R01 Create_ORU_R01(Dictionary <string,string> reportData, int reportNumber)
        {
            ORU_R01 oruR01 = new ORU_R01();

            // lots of stuff removed for clarity

            ORU_R01_ORDER_OBSERVATION oruR01OrderObs = oruR01.GetPATIENT_RESULT().GetORDER_OBSERVATION(1);
            OBR obr = oruR01OrderObs.OBR;

            // OBR-15 Specimen Source
            obr.SpecimenSource.SpecimenSourceNameOrCode.Text.Value = "T034";
            obr.SpecimenSource.SpecimenRole.Text.Value = "Blood";

            // lots of other stuff removed for clarity

            return oruR01;
        }
    }
}

I'm using nHapi (v2.5.0.6) and visual studio 2015. If I've missed anything out or you require any further information, just let me know and I'll provide it. Thanks!


Solution

  • I solved it by declaring OBR-15 the following way:

    obr.SpecimenSource.SpecimenSourceNameOrCode.Identifier.Value = "T034"; 
    obr.SpecimenSource.Additives.Value = "Blood";