我正在使用hl7apy来解析python中的hl7文件,并遵循this链接。当我使用样品.hl7我得到了预期的结果,但当我使用我自己的hl7文件,我得到了下面的错误
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "hl7apy/parser.py", line 82, in parse_message
m.structure_by_name)
File "hl7apy/parser.py", line 144, in parse_segments
reference))
File "hl7apy/parser.py", line 189, in parse_segment
reference=reference)
File "hl7apy/core.py", line 1564, in __init__
validation_level, traversal_parent)
File "hl7apy/core.py", line 632, in __init__
self._find_structure(reference)
File "hl7apy/core.py", line 808, in _find_structure
structure = ElementFinder.get_structure(self, reference)
File "hl7apy/core.py", line 524, in get_structure
raise InvalidName(element.classname, element.name)
hl7apy.exceptions.InvalidName: Invalid name for Segment:
我不明白我做错了什么。在
编辑: 这是我正在使用的样品。在
^{pr2}$代码:这是我用来解析hl7文件的代码,也是我在分析上面链接中提到的示例hl7文件时使用的代码。在
from hl7apy import parser
from hl7apy.exceptions import UnsupportedVersion
hl7 = open('ICD9.hl7', 'r').read()
try:
m = parser.parse_message(hl7)
except UnsupportedVersion:
m = parser.parse_message(hl7.replace("n", "r"))
你应该在这里显示你的文件中的信息,以获得明确的答案。在
但最可能的原因是,您的文件内容不遵循HL7规则。是否确定使用了正确的段分隔符(ASCII 13或HEX 0D)?您是否使用非标准段名称?在
只要检查一下Free Online HL7 Messages Validation就可以得到这些
但这并不能解释您的错误信息。你确定你读了邮件文件并分析了内容吗?在
您的代码有错误。应该是的
^{pr2}$如果要替换错误的段分隔符。在
相关问题 更多 >
编程相关推荐