我正在尝试使用hl7apy解析 hl7 文件,我有以下 hl7 示例
样本 :
MSH|^~\&|XXXX|C|PRIORITYHEALTH|PRIORITYHEALTH|20080511103530||ORU^R01|Q335939501T337311002|P|2.3|||
PID|1||94000000000^^^Priority Health||LASTNAME^FIRSTNAME^INIT||19460101|M|||||
PD1|1|||1234567890^PCPLAST^PCPFIRST^M^^^^^NPI|
OBR|1||185L29839X64489JLPF~X64489^ACC_NUM|JLPF^Lipid Panel - C||||||||||||1694^DOCLAST^DOCFIRST^^MD||||||20080511103529|||
OBX|1|NM|JHDL^HDL Cholesterol (CAD)|1|62|CD:289^mg/dL|>40^>40|""||""|F|||20080511103500|||^^^""|
OBX|2|NM|JTRIG^Triglyceride (CAD)|1|72|CD:289^mg/dL|35-150^35^150|""||""|F|||20080511103500|||^^^""|
OBX|3|NM|JVLDL^VLDL-C (calc - CAD)|1|14|CD:289^mg/dL||""||""|F|||20080511103500|||^^^""|
OBX|4|NM|JLDL^LDL-C (calc - CAD)|1|134|CD:289^mg/dL|0-100^0^100|H||""|F|||20080511103500|||^^^""|
OBX|5|NM|JCHO^Cholesterol (CAD)|1|210|CD:289^mg/dL|90-200^90^200|H||""|F|||20080511103500|||^^^""|
代码:
from hl7apy import parser
from hl7apy.exceptions import UnsupportedVersion
hl7 = open('sample.hl7', 'r').read()
try:
m = parser.parse_message(hl7)
except UnsupportedVersion:
m = parser.parse_message(hl7.replace("n", "r"))
print(m.obx.obx_1.value)
但是当我试图读取 OBX(重复段)时,我没有得到任何数据,它什么也不显示。我在做什么错?