如何在c#中使用NHapi dll添加OBX-5观察值?

时间:2013-09-11 09:24:46

标签: c# hl7

 ORU_R01_OBSERVATION observation = orderObservation.GetOBSERVATION(0);
 OBX obx = observation.OBX;
 obx.ValueType.Value = "AD";
 obx.ObservationIdentifier.Identifier.Value = "Report";
 obx.ObservResultStatus.Value = "F";

这里我想添加 OBX-5观察值。我该如何添加?

2 个答案:

答案 0 :(得分:1)

我知道这是一个非常晚的答案,但我希望它可以在将来帮助某人。这就是我设置OBX段值的方法。

ORU_R01 oru = new ORU_R01();
ORU_R01_ORDER_OBSERVATION orderObservation = oru.GetRESPONSE().GetORDER_OBSERVATION();
OBX obx = orderObservation.GetOBSERVATION(0).OBX;
obx.ValueType.Value = "AD";
obx.ObservationIdentifier.Identifier.Value = "Report";
obx.ObservResultStatus.Value = "F";
CE ce = new CE(oru);
ce.Identifier.Value = obv.ObservationValue;
Varies value = obx.GetObservationValue(0);
value.Data = ce;

希望这有帮助。

答案 1 :(得分:0)

这是@hardrada 最初指出的代码: 这是一个迟到的答案,因为我最近一直试图找到这样的东西,我觉得HL7的例子还不够

通过这里的回路机器找到了它:

http://web.archive.org/web/20130318202508/http://www.ecomb.ch/nhapi-example-for-creating-a-hl7-message-with-msh-pid-pv1-obr-and-obx-segment/

private string createHL7()
{
    ORU_R01 oruR01 = new ORU_R01();
    ORU_R01_ORDER_OBSERVATION orderObservation = oruR01.GetRESPONSE().GetORDER_OBSERVATION();

    ORU_R01_PATIENT patient = oruR01.GetRESPONSE().PATIENT;
    ORU_R01_VISIT visit = patient.VISIT;
    PV1 pv1 = visit.PV1;

    OBR obr = orderObservation.OBR;

    ORU_R01_OBSERVATION observation = orderObservation.GetOBSERVATION(0);
    OBX obx = observation.OBX;

    oruR01.MSH.FieldSeparator.Value = "|";
    oruR01.MSH.EncodingCharacters.Value = @"^~\&";
    oruR01.MSH.SendingApplication.NamespaceID.Value = "SP";
    oruR01.MSH.SendingFacility.NamespaceID.Value = "SPZH";
    oruR01.MSH.ReceivingApplication.NamespaceID.Value = "MF";
    oruR01.MSH.ReceivingFacility.NamespaceID.Value = "INTRA";
    oruR01.MSH.DateTimeOfMessage.TimeOfAnEvent.SetLongDate(DateTime.Now);
    oruR01.MSH.ProcessingID.ProcessingID.Value = "P";
    oruR01.MSH.VersionID.Value = "2.3";

    PID pid = oruR01.GetRESPONSE().PATIENT.PID;
    pid.SetIDPatientID.Value = "12345";
    pid.PatientName.FamilyName.Value = "Joe";
    pid.PatientName.GivenName.Value = "Bloggs";
    pid.DateOfBirth.TimeOfAnEvent.SetLongDate(DateTime.MinValue);
    pid.Sex.Value = "M";

    pv1.SetIDPatientVisit.Value = "1";
    pv1.VisitNumber.ID.Value = "3333333";

    obr.FillerOrderNumber.UniversalID.Value = "123456";
    obr.UniversalServiceIdentifier.Text.Value = "Document";
    obr.ObservationEndDateTime.TimeOfAnEvent.SetLongDate(DateTime.Now);
    obr.ResultStatus.Value = "F";

    obx.SetIDOBX.Value = "0";
    obx.ValueType.Value = "RP";
    obx.ObservationIdentifier.Identifier.Value = "Report";

    PipeParser parser = new PipeParser();
    string encodedMessage = parser.Encode(oruR01);

    return encodedMessage;
}