如何将 OBR 添加到 HL7 消息中?

How to ADD OBR to the HL7 message?

我正在尝试使用 Python 库 hl7apy 生成 HL7 消息,但是当生成 HL7 消息时它没有在输出中给出 OBR 段,请尝试解决这个问题。

密码是

from hl7apy import core
hl7 = core.Message("ORM_O01")
hl7.msh.msh_3 = "SendingApp"
hl7.msh.msh_4 = "SendingFac"
hl7.msh.msh_5 = "ReceivingApp"
hl7.msh.msh_6 = "ReceivingFac"
hl7.msh.msh_9 = "ORM^O01^ORM_O01"
hl7.msh.msh_10 = "168715"
hl7.msh.msh_11 = "P"

# PID
hl7.add_group("ORM_O01_PATIENT")
hl7.ORM_O01_PATIENT.pid.pid_2 = "1"
hl7.ORM_O01_PATIENT.pid.pid_3 = "A-10001"
hl7.ORM_O01_PATIENT.pid.pid_5 = "B-10001"
hl7.ORM_O01_PATIENT.pid.pid_6 = "DOE^JOHN"

# ORC
hl7.ORM_O01_ORDER.orc.orc_1 = "1"
hl7.ORM_O01_ORDER.ORC.orc_10 = "20150414120000"

# OBR
# We must explicitly add the OBR segment, then populate fields
hl7.ORM_O01_ORDER.ORM_O01_ORDER_DETAIL.ORM_O01_OBSERVATION.ORM_O01_ORDER_CHOICE.add_segment("OBR")
hl7.ORM_O01_ORDER.ORM_O01_ORDER_DETAIL.ORM_O01_OBSERVATION.ORM_O01_ORDER_CHOICE.OBR.obr_2 = "1"
hl7.ORM_O01_ORDER.ORM_O01_ORDER_DETAIL.ORM_O01_OBSERVATION.ORM_O01_ORDER_CHOICE.OBR.obr_3 = "2"
hl7.ORM_O01_ORDER.ORM_O01_ORDER_DETAIL.ORM_O01_OBSERVATION.ORM_O01_ORDER_CHOICE.OBR.obr_4 = "1100"

assert hl7.validate() is True

print "\n Validate HL7 Message: ", hl7.validate()

print "\n\n HL7 Message : \n\n", hl7.value
print "\n\n"
# Returns True

您应该在添加和填充 OBR 段之前添加一个 OrderDetailGroup。