Page 1 of 1

How to parse a custom message?

Posted: Fri Aug 22, 2014 3:49 pm
by xiang_1988
Hi,admin!
But I don't know how to parse a custom message.

procedure TForm1.Button12Click(Sender: TObject);
var
Msg: TdiZPI_Z01_24;
begin//use uCustom.pas
//MSH|^~\&|||||20140822231346||MFN^M01||P|2.4
//ZAU|||||||||ins carrier 5
//ZIN||con

try
Msg := TdiZPI_Z01_24.Create;
// Msg.EnableEscapedValues:=False;
Msg.AsString := Memo2.Text;
Memo1.Clear;
Memo1.Lines.Append(Msg.ZAU.inscarrier5.AsString);
Memo1.Lines.Append(Msg.ZIN.ifcondition.AsString);
finally
Msg.Free;
end;

This code can't parse customised message, could you tell me where is wrong?

Re: How to parse a custom message?

Posted: Fri Aug 29, 2014 7:57 am
by xiang_1988
How to parse a custom message??

Re: How to parse a custom message?

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

TdiZPI_Z01_24 message defined as : (see uCustom.pas )

Code: Select all

{ TdiZPI_Z01_24 }

procedure TdiZPI_Z01_24.Init;
begin
  inherited;
   Name :='ZPI_Z01';
   MessageType :='ZPI';
   TriggerEvent :='Z01';
   HL7Version :='2.4';
   Definitions.Add('MSH',TdiMSH_24,1,1); 
   Definitions.Add('MSA',TdiMSA_24,1,1);
   Definitions.Add('ZAU',TdiZAU_24,1,1); 
   Definitions.Add('PRD',TdiPRD_24,1,1); 
   Definitions.Add('PID',TdiPID_24,0,1);
   Definitions.Add('IN1',TdiIN1_24,0,1);
   Definitions.Add('ZIN',TdiZIN_24,0,1);

   ParseHL7(InitMsg);
end;
In this definition
Definitions.Add('MSA',TdiMSA_24,1,1);
says for 'MSA' segment use TdiMSA_24 class and min: 1 max : 1
please change like this :
Definitions.Add('MSA',TdiMSA_24,0,1);

apply similar changes to not used other segments.

Best Regards.