[英]Not properly processing lines in an HL7 document?
I have a script that is supposed to check the first 4 characters of each line. 我有一个脚本,应该检查每行的前4个字符。 It's not working.
没用 I'm processing HL7 documents that look like this:
我正在处理如下所示的HL7文档:
MSH|...
EVN|...
PID|...
MSH|...
EVN|...
PID|...
MSH|...
EVN|...
PID|...
and here is my code: 这是我的代码:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile (f.path, 1)
Do Until file.AtEndOfStream
line = file.Readline
wscript.echo left(line,4)
Loop
This outputs the following: 输出以下内容:
MSH|
MSH|
MSH|
Is there something I should use besides Readline
? 除了
Readline
我还应该使用其他东西吗?
Revisited this for another task and found a better way. 再次讨论此任务,并找到了更好的方法。 The following set of loops and conditions will break down a .dat file full of HL7 messages into Message, Segment, Field and Subfield.
以下一组循环和条件将一个充满HL7消息的.dat文件分解为Message,Segment,Field和Subfield。 It does not account for repeating fields (~).
它不考虑重复的字段(〜)。
The first two FOR
statments solve the original issue with line feeds vs carriage returns. 前两个
FOR
语句使用换行符和回车符解决了原始问题。 It turns out there is a lf between each message and a cr between each segment. 事实证明,每个消息之间都有一个lf,每个段之间有一个cr。
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
file = fso.OpenTextFile(f.path).ReadAll
for each msg in split(file,vbLf)
if msg <> "" then
msgType = split(split(msg,"|")(8),"^")(1) 'results in something like A08
for each line in split(msg,vbCr)
if line <> "" then
seg = left(line,3) 'MSH, PID, etc
for each field in split(line,"|")
if instr(field,"^") > 0 then
for each subfield in split(field,"^")
'do code here for each subfield
next
end if
next
end if
next
end if
next
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.