Hi,
You need custom message definition like this:
Code: Select all
// Custom message
TdiZQI_Z01_24= class(TdiMessage)
private
MSHList:TdiSegmentList;
PRDList:TdiSegmentList;
PIDList:TdiSegmentList;
protected
function GetMSH : TdiMSH_24;
procedure SetMSH(Value : TdiMSH_24);
function GetPRD : TdiPRD_24;
procedure SetPRD(Value : TdiPRD_24);
function GetPID : TdiPID_24;
procedure SetPID(Value : TdiPID_24);
public
property MSH : TdiMSH_24 read GetMSH write SetMSH;
property PRD : TdiPRD_24 read GetPRD write SetPRD;
property PID : TdiPID_24 read GetPID write SetPID;
constructor Create; override;
end;
{ TdiZQI_Z01_24 }
constructor TdiZQI_Z01_24.Create;
begin
inherited;
Name :='ZQI_Z01';
MessageType :='ZQI';
TriggerEvent :='Z01';
HL7Version :='2.4';
MSHList:=TdiSegmentList.Create;
MSHList.SetDefault('MSH','TdiMSH_24',0,1,1,Self);
Add(MSHList);
PRDList:=TdiSegmentList.Create;
PRDList.SetDefault('PRD','TdiPRD_24',1,1,1,Self);
Add(PRDList);
PIDList:=TdiSegmentList.Create;
PIDList.SetDefault('PID','TdiPID_24',2,1,1,Self);
Add(PIDList);
Parse(InitMsg);
end;
function TdiZQI_Z01_24.GetMSH: TdiMSH_24;
begin
Result:=TdiMSH_24(Find('MSH',0));
end;
function TdiZQI_Z01_24.GetPID: TdiPID_24;
begin
Result:=TdiPID_24(Find('PID',0));
end;
function TdiZQI_Z01_24.GetPRD: TdiPRD_24;
begin
Result:=TdiPRD_24(Find('PRD',0));
end;
procedure TdiZQI_Z01_24.SetMSH(Value: TdiMSH_24);
begin
SetByName('MSH',0,Value);
end;
procedure TdiZQI_Z01_24.SetPID(Value: TdiPID_24);
begin
SetByName('PID',0,Value);
end;
procedure TdiZQI_Z01_24.SetPRD(Value: TdiPRD_24);
begin
SetByName('PRD',0,Value);
end;
sample unit:
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, diHL7Base,diHL724,diHL7DT24, StdCtrls;
type
TForm1 = class(TForm)
diHL7241: TdiHL724;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TdiZQI_Z01_24= class(TdiMessage)
private
MSHList:TdiSegmentList;
PRDList:TdiSegmentList;
PIDList:TdiSegmentList;
protected
function GetMSH : TdiMSH_24;
procedure SetMSH(Value : TdiMSH_24);
function GetPRD : TdiPRD_24;
procedure SetPRD(Value : TdiPRD_24);
function GetPID : TdiPID_24;
procedure SetPID(Value : TdiPID_24);
public
property MSH : TdiMSH_24 read GetMSH write SetMSH;
property PRD : TdiPRD_24 read GetPRD write SetPRD;
property PID : TdiPID_24 read GetPID write SetPID;
constructor Create; override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
m: TdiZQI_Z01_24;
begin
m:=TdiZQI_Z01_24.Create;
m.SubcomponentSeparator:='{';
m.MSH.SendingApplication.NamespaceID.AsString:='TRIA0100M';
//...
m.PRD.ProviderRole[0].Identifier.AsString:='PS';
m.PRD.ProviderRole[0].Text.AsString:='Prestador Solicitante';
m.PRD.ProviderIdentifiers[0].IDNumber.AsString:='30500974016';
m.PRD.ProviderIdentifiers[0].TypeOfIDNumber.AsString:='CU';
m.PID.PatientIdentifierList[0].ID.AsString:='0001024902';
m.PID.PatientIdentifierList[0].Assigningauthority.NamespaceID.AsString:='SAMA';
m.PID.PatientIdentifierList[0].Identifiertypecode.AsString:='HC';
m.PID.PatientName[0].Familyname.Surname.AsString:='UNKNOWN';
ShowMessage(m.AsString);
FreeAndNil(m);
end;
{ TdiZQI_Z01_24 }
constructor TdiZQI_Z01_24.Create;
begin
inherited;
Name :='ZQI_Z01';
MessageType :='ZQI';
TriggerEvent :='Z01';
HL7Version :='2.4';
MSHList:=TdiSegmentList.Create;
MSHList.SetDefault('MSH','TdiMSH_24',0,1,1,Self);
Add(MSHList);
PRDList:=TdiSegmentList.Create;
PRDList.SetDefault('PRD','TdiPRD_24',1,1,1,Self);
Add(PRDList);
PIDList:=TdiSegmentList.Create;
PIDList.SetDefault('PID','TdiPID_24',2,1,1,Self);
Add(PIDList);
Parse(InitMsg);
end;
function TdiZQI_Z01_24.GetMSH: TdiMSH_24;
begin
Result:=TdiMSH_24(Find('MSH',0));
end;
function TdiZQI_Z01_24.GetPID: TdiPID_24;
begin
Result:=TdiPID_24(Find('PID',0));
end;
function TdiZQI_Z01_24.GetPRD: TdiPRD_24;
begin
Result:=TdiPRD_24(Find('PRD',0));
end;
procedure TdiZQI_Z01_24.SetMSH(Value: TdiMSH_24);
begin
SetByName('MSH',0,Value);
end;
procedure TdiZQI_Z01_24.SetPID(Value: TdiPID_24);
begin
SetByName('PID',0,Value);
end;
procedure TdiZQI_Z01_24.SetPRD(Value: TdiPRD_24);
begin
SetByName('PRD',0,Value);
end;
end.
Best regards.