Page 1 of 2

I'm using HL7 2.3...

Posted: Thu Aug 28, 2014 7:56 pm
by RicardoLT
Hi there ...
I am a delphi programmer, use the version that is currently XE2. I'm doing an evaluation of the HL7 component, and I'm trying to read a HL7 file, following the examples that come with the trial, but these examples are version 2.2 and the version of the file I'm trying to read and convert is 2.3, and what I've noticed is that the classes are different from the version of the example, so it has been hard for me to understand how to adapt the example version 2.2 to version 2.3. You could give me a simple example of how to convert this file or read ???


MSH | ^ ~ \ & | PxLab | 01 | Abbott | 01 | 20140714175947 || ORU ^ R01 || P | 2.3 ||||||
PID | 1 || PEG-C8E5-9E5A || ^ Alvarez Ramon Gonzalez ^ 20,140,701,151,146 || | M ||| ^^^^^ |
PV1 | 1 | I |||||||||||||||||| Miguel Hidalgo No. 272, Col. La Cruz Del Iztacalco CP 08310 Mexico, DF |. 85,005,233 ||||||| |||||||||||||||| 20140701151146
ORC | 1 ||||| 20140701151146 | 20140714175947 | 20140714175947 ||| ^ Dolores Estrada Julia Guzman ^^ |
OBR | 01 | PEG-579 C8E5-9E5A || ^^ load ^ ^ hepc Basal PCR viral load of Hepatitis C (HCV) | Method: Technical o: Real Time RT-PCR |||||||||| 20140701175947 20140714180123 ||||||| ||| F ||
OBX | 01 || ^^^^ HCV viral particles || 162,946 | IU / mL | Detection Limit: Up 6.00, Limit of Quantification: Up 12.00 | 20140714180123 || 41821407 | gerardoh |
OBX | 02 || ^^^^ logarithm || 5.21 | Log IU / mL | Detection Limit: Up to 0.78, Limit of Quantification: Up 1.08 | 20140714180123 || 41821407 | gerardoh |
OBR | 01 | PEG-2460 C8E5-9E5A || ^^ hep C genotype ^ ^ PCR genotyping hepatitis C virus (HCV) | Method: o Technical: Real Time RT-PCR ||||||||| | 20140701175947 20140714180123 ||||||| ||| F ||
OBX | 01 || ^^^^ Positive Genotype 1 || ||| || 20140714180123 41821407 | gerardoh |
OBX | 02 || ^^^^ || b Subtype ||| || 20140714180123 41821407 | gerardoh |
OBX | 03 || ^^^^ Negative Genotype 2 || ||| || 20140714180123 41821407 | gerardoh |
OBX | 04 || ^^^^ Negative Genotype 3 || ||| || 20140714180123 41821407 | gerardoh |
OBX | 05 || ^^^^ Negative Genotype 4 || ||| || 20140714180123 41821407 | gerardoh |
OBX | 06 || ^^^^ Genotype 5 || Negative ||| || 20140714180123 41821407 | gerardoh |
OBX | 07 || ^^^^ Genotype 6 || Negative ||| || 20140714180123 41821407 | gerardoh |
NTE | 1 || N / S

Thank you.

Re: I'm using HL7 2.3...

Posted: Sat Aug 30, 2014 2:52 am
by admin
Hi,

Your message type ORU R01 version 2.3
For parse this message you need TdiORU_R01_23 (more mesages : http://www.delphihl7.com/doc/html/diHL723.html)

const
MsgStr=
MSH | ^ ~ \ & | PxLab | 01 | Abbott | 01 | 20140714175947 || ORU ^ R01 || P | 2.3 ||||||
PID | 1 || PEG-C8E5-9E5A || ^ Alvarez Ramon Gonzalez ^ 20,140,701,151,146 || | M ||| ^^^^^ |
PV1 | 1 | I |||||||||||||||||| Miguel Hidalgo No. 272, Col. La Cruz Del Iztacalco CP 08310 Mexico, DF |. 85,005,233 ||||||| |||||||||||||||| 20140701151146
ORC | 1 ||||| 20140701151146 | 20140714175947 | 20140714175947 ||| ^ Dolores Estrada Julia Guzman ^^ |
OBR | 01 | PEG-579 C8E5-9E5A || ^^ load ^ ^ hepc Basal PCR viral load of Hepatitis C (HCV) | Method: Technical o: Real Time RT-PCR |||||||||| 20140701175947 20140714180123 ||||||| ||| F ||
OBX | 01 || ^^^^ HCV viral particles || 162,946 | IU / mL | Detection Limit: Up 6.00, Limit of Quantification: Up 12.00 | 20140714180123 || 41821407 | gerardoh |
OBX | 02 || ^^^^ logarithm || 5.21 | Log IU / mL | Detection Limit: Up to 0.78, Limit of Quantification: Up 1.08 | 20140714180123 || 41821407 | gerardoh |
OBR | 01 | PEG-2460 C8E5-9E5A || ^^ hep C genotype ^ ^ PCR genotyping hepatitis C virus (HCV) | Method: o Technical: Real Time RT-PCR ||||||||| | 20140701175947 20140714180123 ||||||| ||| F ||
OBX | 01 || ^^^^ Positive Genotype 1 || ||| || 20140714180123 41821407 | gerardoh |
OBX | 02 || ^^^^ || b Subtype ||| || 20140714180123 41821407 | gerardoh |
OBX | 03 || ^^^^ Negative Genotype 2 || ||| || 20140714180123 41821407 | gerardoh |
OBX | 04 || ^^^^ Negative Genotype 3 || ||| || 20140714180123 41821407 | gerardoh |
OBX | 05 || ^^^^ Negative Genotype 4 || ||| || 20140714180123 41821407 | gerardoh |
OBX | 06 || ^^^^ Genotype 5 || Negative ||| || 20140714180123 41821407 | gerardoh |
OBX | 07 || ^^^^ Genotype 6 || Negative ||| || 20140714180123 41821407 | gerardoh |
NTE | 1 || N / S

var
msg : TdiORU_R01_23;
begin
msg:=TdiORU_R01_23.Create;
msg.AsString:=MsgStr; // Its Parsed.
msg.MSH. .... // You can acces what do you need.
msg.Free;


Thank you.

Re: I'm using HL7 2.3...

Posted: Sat Aug 30, 2014 6:29 pm
by RicardoLT
Hello again !!!
Thanks for your reply, but I still have problems ... :'(
I am completely new to the subject of HL7, so I beg your patience ...

This is the code from my unit:

unit uHL723;

interface

uses
Winapi.Windows,
System.SysUtils,
Vcl.Dialogs,
RTT_General,RTTFunctions,
diHL7Base, diHL723, diHL7DT23, diHL7Grp23;

Function GetFileHL7_23(fsFilter:String; Var fsFile:String):Boolean;
Function GetContentFileHL7_23(fsFile:String;fbMsg:Boolean; Var fwsContent:WideString):Boolean;
Function ReadContentMsgHL7_23(fwsContent:WideString; Var wsMsg:WideString):Boolean;

implementation

Function GetFileHL7_23(fsFilter:String; Var fsFile:String):Boolean;
Var
odOpenHL7:TOpenDialog;
lsCaption,lsFiltro:String;
Begin
fsFile:='';
Result:=False;
odOpenHL7:=TOpenDialog.Create(Nil);
if Trim(fsFilter)<>'' then
lsFiltro:=fsFilter
else
lsFiltro:='*';
with odOpenHL7 do begin
Filter:='Archivo HL7|'+lsFiltro+'.hl7';
Options:=[ofReadOnly,ofHideReadOnly,ofEnableSizing];
Title:='Seleccionar Archivo HL7';
if (Execute and (Trim(FileName)<>'')) then begin
Result:=Trim(FileName)<>'';
fsFile:=Trim(FileName);
end;
end;
End;

Function GetContentFileHL7_23(fsFile:String;fbMsg:Boolean; Var fwsContent:WideString):Boolean;
Var
ltfArchivo:TextFile;
lsLine:String;
liLine:Int64;
Begin
fwsContent:='';
liLine:=0;
Result:=FileExists(fsFile);
if Result then begin
try
AssignFile(ltfArchivo,fsFile);
Reset(ltfArchivo);
while not Eof(ltfArchivo) do begin
Readln(ltfArchivo,lsLine);
if liLine=0 then
fwsContent:=lsLine
else
fwsContent:=fwsContent+#13+lsLine;
Inc(liLine);
end;
CloseFile(ltfArchivo);
Result:=True;
except
if fbMsg then
Mensaje('Archivo HL7','Ocurrio un error al abrir el archivo',MB_ICONERROR);
end;
end else if fbMsg then
Mensaje('Archivo HL7','El archivo HL7 seleccionado no existe',MB_ICONERROR);
End;

Function ReadContentMsgHL7_23(fwsContent:WideString; Var wsMsg:WideString):Boolean;
Var
Msg:TdiORU_R01_23;
Begin
Result:=False;
try
Msg:=TdiORU_R01_23.Create;
Msg.AsString:=fwsContent; {This is where brand error:}
{... exception class Exception with message 'Can not found '' type class. Please check class is registered.'.}
Result:=True;
except

end;
End;

end.


And this is the code in my form:

unit uPruebaHL7;

interface

uses
Winapi.Windows, Winapi.Messages,
System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls,
diHL723, diHL7DT23, diHL7Grp23,
RTTFunctions,RTT_General, Vcl.StdCtrls, Vcl.Buttons;

type
TfrmPruebaHL7 = class(TForm)
pnUser: TPanel;
diHL7231: TdiHL723;
mHL7: TMemo;
sbOpen: TSpeedButton;
procedure sbOpenClick(Sender: TObject);
private
Function LecturaHL723:Boolean;
public
{ Public declarations }
end;

var
frmPruebaHL7: TfrmPruebaHL7;

implementation

uses
uHL723;

{$R *.dfm}

Function TfrmPruebaHL7.LecturaHL723:Boolean;
Var
lsFile:String;
wsMsgFile,wsMsgResult:WideString;
Begin
Result:=GetFileHL7_23('',lsFile);
if Result then begin
Result:=GetContentFileHL7_23(lsFile,True,wsMsgFile);
if Result then begin
Result:=ReadContentMsgHL7_23(wsMsgFile,wsMsgResult);
if Result then
mHL7.Text:=wsMsgResult;
end;
end;
End;

procedure TfrmPruebaHL7.sbOpenClick(Sender: TObject);
begin
if LecturaHL723 then

end;

end.


And I try this on the unit:

Function ReadContentMsgHL7_23(fwsContent:WideString; Var wsMsg:WideString):Boolean;
Var
Msg:TdiORU_R01_23;
Const
MsgStr=
'MSH | ^ ~ \ & | PxLab | 01 | Abbott | 01 | 20140714175947 || ORU ^ R01 || P | 2.3 ||||||'+#13+
'PID | 1 || PEG-C8E5-9E5A || ^ Alvarez Ramon Gonzalez ^ 20,140,701,151,146 || | M ||| ^^^^^ |'+#13+
'PV1 | 1 | I |||||||||||||||||| Miguel Hidalgo No. 272, Col. La Cruz Del Iztacalco CP 08310 Mexico, DF |. 85,005,233 ||||||| |||||||||||||||| 20140701151146'+#13+
'ORC | 1 ||||| 20140701151146 | 20140714175947 | 20140714175947 ||| ^ Dolores Estrada Julia Guzman ^^ |'+#13+
'OBR | 01 | PEG-579 C8E5-9E5A || ^^ load ^ ^ hepc Basal PCR viral load of Hepatitis C (HCV) | Method: Technical o: Real Time RT-PCR |||||||||| 20140701175947 20140714180123 ||||||| ||| F ||'+#13+
'OBX | 01 || ^^^^ HCV viral particles || 162,946 | IU / mL | Detection Limit: Up 6.00, Limit of Quantification: Up 12.00 | 20140714180123 || 41821407 | gerardoh |'+#13+
'OBX | 02 || ^^^^ logarithm || 5.21 | Log IU / mL | Detection Limit: Up to 0.78, Limit of Quantification: Up 1.08 | 20140714180123 || 41821407 | gerardoh |'+#13+
'OBR | 01 | PEG-2460 C8E5-9E5A || ^^ hep C genotype ^ ^ PCR genotyping hepatitis C virus (HCV) | Method: o Technical: Real Time RT-PCR ||||||||| | 20140701175947 20140714180123 ||||||| ||| F ||'+#13+
'OBX | 01 || ^^^^ Positive Genotype 1 || ||| || 20140714180123 41821407 | gerardoh |'+#13+
'OBX | 02 || ^^^^ || b Subtype ||| || 20140714180123 41821407 | gerardoh |'+#13+
'OBX | 03 || ^^^^ Negative Genotype 2 || ||| || 20140714180123 41821407 | gerardoh |'+#13+
'OBX | 04 || ^^^^ Negative Genotype 3 || ||| || 20140714180123 41821407 | gerardoh |'+#13+
'OBX | 05 || ^^^^ Negative Genotype 4 || ||| || 20140714180123 41821407 | gerardoh |'+#13+
'OBX | 06 || ^^^^ Genotype 5 || Negative ||| || 20140714180123 41821407 | gerardoh |'+#13+
'OBX | 07 || ^^^^ Genotype 6 || Negative ||| || 20140714180123 41821407 | gerardoh |'+#13+
'NTE | 1 || N /S';
Begin
Result:=False;
try
Msg:=TdiORU_R01_23.Create;
Msg.AsString:=MsgStr; {But here gives the following error:}
{... raised exception class EAccessViolation with message 'Access violation at address 005358F9 in module 'PruebasHL7.exe'. Read of address 0000000C.}
Result:=True;
except

end;
End;

So it is that I could advance testing of their product, which I'm evaluating to buy it. Please Help Me...
Thank You.

Re: I'm using HL7 2.3...

Posted: Sat Aug 30, 2014 8:21 pm
by admin
Can you attach your project source ?

Re: I'm using HL7 2.3...

Posted: Mon Sep 01, 2014 3:42 pm
by RicardoLT
Sure, and thanks for the attention...

Re: I'm using HL7 2.3...

Posted: Mon Sep 01, 2014 7:55 pm
by admin
Hi,
Your HL7 message is invalid. Added Extra space character. Its cannot be parsed.

For Example :
MSH | ^ ~ \ & | PxLab | 01 | Abbott | 01 | 20140714175947 || ORU ^ R01 || P | 2.3 ||||||

must be similar like this:
MSH|^~\&|PxLab|01|Abbott|01|20140714175947||ORU^R01||P|2.3||||||

Please add original message.

Re: I'm using HL7 2.3...

Posted: Mon Sep 01, 2014 10:36 pm
by RicardoLT
Ohhh ... Right ... Thanks ... But I corrected the problem and now the error is:
... exception class Exception with message 'Can not found '' type class. Please check class is registered.'.
:( :S :'(

Re: I'm using HL7 2.3...

Posted: Tue Sep 02, 2014 3:45 am
by admin
I think that the message may have been corrupted. If the message received from a document, the document please share. You can send in the mail. mail : support@delphihl7.com

Re: I'm using HL7 2.3...

Posted: Wed Sep 03, 2014 4:56 am
by admin
Hi,
OBX represent avalue, a value need a value type.
like String, Range...
When added value type your message its parsed.
ST-->String

'OBX|01|ST|^^^^Partículas virales HCV||162 946|UI/mL|Límite de detección: Hasta 6.00, Límite de cuantificación: Hasta 12.00|20140714180123||41821407|gerardoh|'+#13+

Code: Select all

Const
MsgStr=
'MSH|^~\&|PxLab|01|Abbott|01|20140714175947||ORU^R01||P|2.3||||||'+#13+
'PID|1||PEG-C8E5-9E5A||Alvarez^Gonzalez^Ramon||20140701151146|M|||^^^^^|'+#13+
'PV1|1|I||||||||||||||||||Miguel Hidalgo No. 272, Col. La Cruz C.P 08310 Del. Iztacalco Mexico, DF|85005233|||||||||||||||||||||||20140701151146'+#13+
'ORC|1|||||20140701151146|20140714175947|20140714175947|||^Julia Dolores Estrada Guzman^^|'+#13+
'OBR|01|PEG-C8E5-9E5A||^^579^carga hepc^PCR Basal carga viral de Hepatitis C (HCV)|Método :o técnica: RT-PCR Tiempo Real||||||||||20140701175947|||||||20140714180123|||F||'+#13+
'OBX|01|ST|^^^^Partículas virales HCV||162 946|UI/mL|Límite de detección: Hasta  6.00, Límite de cuantificación: Hasta  12.00|20140714180123||41821407|gerardoh|'+#13+
'OBX|02|ST|^^^^Logaritmo||5.21|Log UI/mL|Límite de detección: Hasta  0.78, Límite de cuantificación: Hasta  1.08|20140714180123||41821407|gerardoh|'+#13+
'OBR|01|PEG-C8E5-9E5A||^^2460^genotipo hep C^PCR Genotipo del virus de la Hepatitis C (HCV)|Método :o técnica: RT-PCR Tiempo Real||||||||||20140701175947|||||||20140714180123|||F||'+#13+
'OBX|01|ST|^^^^Genotipo 1||Positivo|||20140714180123||41821407|gerardoh|'+#13+
'OBX|02|ST|^^^^Subtipo||b|||20140714180123||41821407|gerardoh|'+#13+
'OBX|03|ST|^^^^Genotipo 2||Negativo|||20140714180123||41821407|gerardoh|'+#13+
'OBX|04|ST|^^^^Genotipo 3||Negativo|||20140714180123||41821407|gerardoh|'+#13+
'OBX|05|ST|^^^^Genotipo 4||Negativo|||20140714180123||41821407|gerardoh|'+#13+
'OBX|06|ST|^^^^Genotipo 5||Negativo|||20140714180123||41821407|gerardoh|'+#13+
'OBX|07|ST|^^^^Genotipo 6||Negativo|||20140714180123||41821407|gerardoh|'+#13+
'NTE|1||N/S'+#13;
and parse code

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
var
  msg : TdiORU_R01_23;
  I: Integer;
  j: Integer;
  k: Integer;
begin
  msg := TdiORU_R01_23.Create;

  msg.AsString:=MsgStr;
 
  for I := 0 to msg.RESPONSERepCount-1 do
  begin
    Memo1.Lines.Append('Family Name :'+ msg.RESPONSE[0].PATIENT.PID.PatientName.FamilyName.AsString);
    for j := 0 to msg.RESPONSE[I].ORDER_OBSERVATIONRepCount-1 do
    begin
      for k := 0 to msg.RESPONSE[I].ORDER_OBSERVATION[J].OBSERVATIONRepCount-1 do
      begin
         Memo1.Lines.Add(
         // Typecast to ST type (TdiST_23)
         TdiST_23( msg.RESPONSE[I].ORDER_OBSERVATION[J].OBSERVATION[K].OBX.ObservationValue[0]).AsString
         );
      end;

    end;

  end;

  msg.Free;
end;

Re: I'm using HL7 2.3...

Posted: Wed Sep 03, 2014 6:50 pm
by RicardoLT
Heyyy !!!
Thank you very much !!!
I made the correction in the file and I'm working without any problems !!!
Now, I will continue in the evaluation process ...