Custom Segment/Message Difficulties

Discussion of open issues, suggestions and bugs regarding to (known as Delphi HL7) HL7 Components
Post Reply
Milan Vydareny
Posts: 5
Joined: Wed May 21, 2014 5:18 pm

Custom Segment/Message Difficulties

Post by Milan Vydareny »

I am trying to learn how to create custom segments and messages for HL7 2.3. I downloaded the demo and discovered it uses 2.2 and 2.4, neither of which I have. Next, I took the sample code and modified all of the references to use 2.3 but it will not compile because of the final statement of the message INIT procedure. The statement is Parse(InitMsg) however the signature doesn't match the 2.3 version that also expects a second parameter of type TdiMessageInfo.

Can you post sample code that will successfully compile and execute using HL7 2.3?

Thanks for your help.

Milan Vydareny
admin
Site Admin
Posts: 256
Joined: Sun Jun 05, 2011 8:06 pm

Re: Custom Segment/Message Difficulties

Post by admin »

Hi,

Please download guide and see page 9
http://www.delphihl7.com/download/DelphiHL7_Guide.pdf
and demo contains custom segment and message example.
sample unit:

Code: Select all

unit uCustom;

interface
uses diHL7Base,diHL724, diHL7DT24, diHL7Grp24;

type
  TdiZAU_24 = class(TdiSegment)
  protected
    function Getinscarrier1: TdiST_24;
    function Getinscarrier2: TdiST_24;
    function Getinscarrier3: TdiST_24;
    function Getinscarrier4: TdiST_24;
    function Getinscarrier5: TdiST_24;
    function Getinscarrier6: TdiST_24;
    function Getpreauthcd1: TdiST_24;
    function Getpreauthcd2: TdiST_24;
    function Getpreauthcd3: TdiST_24;
    function Getpreauthcd4: TdiST_24;
    function Getpreauthcd5: TdiST_24;
    function Getpreauthcd6: TdiST_24;
    procedure Setinscarrier1(const Value: TdiST_24);
    procedure Setinscarrier2(const Value: TdiST_24);
    procedure Setinscarrier3(const Value: TdiST_24);
    procedure Setinscarrier4(const Value: TdiST_24);
    procedure Setinscarrier5(const Value: TdiST_24);
    procedure Setinscarrier6(const Value: TdiST_24);
    procedure Setpreauthcd1(const Value: TdiST_24);
    procedure Setpreauthcd2(const Value: TdiST_24);
    procedure Setpreauthcd3(const Value: TdiST_24);
    procedure Setpreauthcd4(const Value: TdiST_24);
    procedure Setpreauthcd5(const Value: TdiST_24);
    procedure Setpreauthcd6(const Value: TdiST_24);
  public
    property inscarrier1 : TdiST_24 read Getinscarrier1 write Setinscarrier1;
    property preauthcd1 : TdiST_24 read Getpreauthcd1 write Setpreauthcd1;
    property inscarrier2 : TdiST_24 read Getinscarrier2 write Setinscarrier2;
    property preauthcd2 : TdiST_24 read Getpreauthcd2 write Setpreauthcd2;
    property inscarrier3 : TdiST_24 read Getinscarrier3 write Setinscarrier3;
    property preauthcd3 : TdiST_24 read Getpreauthcd3 write Setpreauthcd3;
    property inscarrier4 : TdiST_24 read Getinscarrier4 write Setinscarrier4;
    property preauthcd4 : TdiST_24 read Getpreauthcd4 write Setpreauthcd4;
    property inscarrier5 : TdiST_24 read Getinscarrier5 write Setinscarrier5;
    property preauthcd5 : TdiST_24 read Getpreauthcd5 write Setpreauthcd5;
    property inscarrier6 : TdiST_24 read Getinscarrier6 write Setinscarrier6;
    property preauthcd6 : TdiST_24 read Getpreauthcd6 write Setpreauthcd6;
    procedure Init;override;
  end;

TdiZIN_24 = class(TdiSegment)
  protected
    function Getifcondition: TdiST_24;
    function Getcondition: TdiST_24;
    procedure Setifcondition(const Value: TdiST_24);
    procedure Setcondition(const Value: TdiST_24);
  public
    property ifcondition : TdiST_24 read Getifcondition write Setifcondition;
    property condition : TdiST_24 read Getcondition write Setcondition;
    procedure Init;override;
  end;

  TdiZPI_Z01_24= class(TdiMessage)
  protected
    function GetIN1: TdiIN1_24;
    function GetMSA: TdiMSA_24;
    function GetMSH: TdiMSH_24;
    function GetPID: TdiPID_24;
    function GetPRD: TdiPRD_24;
    function GetZAU: TdiZAU_24;
    function GetZIN: TdiZIN_24;
    procedure SetIN1(const Value: TdiIN1_24);
    procedure SetMSA(const Value: TdiMSA_24);
    procedure SetMSH(const Value: TdiMSH_24);
    procedure SetPID(const Value: TdiPID_24);
    procedure SetPRD(const Value: TdiPRD_24);
    procedure SetZAU(const Value: TdiZAU_24);
    procedure SetZIN(const Value: TdiZIN_24);
  public
    property MSH : TdiMSH_24 read GetMSH write SetMSH;
    property MSA : TdiMSA_24 read GetMSA write SetMSA;
    property ZAU : TdiZAU_24 read GetZAU write SetZAU;
    property PRD : TdiPRD_24 read GetPRD write SetPRD;
    property PID : TdiPID_24 read GetPID write SetPID;
    property IN1 : TdiIN1_24 read GetIN1 write SetIN1;
    property ZIN : TdiZIN_24 read GetZIN write SetZIN;
    procedure Init;override;
  end;

implementation

{ TdiZAU_24 }

procedure TdiZAU_24.Init;
begin
  inherited;
  Name :='ZAU';
  Definitions.Add('inscarrier1',TdiST_24,0,1);
  Definitions.Add('preauthcd1',TdiST_24,0,1);
  Definitions.Add('inscarrier2',TdiST_24,0,1);
  Definitions.Add('preauthcd2',TdiST_24,0,1);
  Definitions.Add('inscarrier3',TdiST_24,0,1);
  Definitions.Add('preauthcd3',TdiST_24,0,1);
  Definitions.Add('inscarrier4',TdiST_24,0,1);
  Definitions.Add('preauthcd4',TdiST_24,0,1);
  Definitions.Add('inscarrier5',TdiST_24,0,1);
  Definitions.Add('preauthcd5',TdiST_24,0,1);
  Definitions.Add('inscarrier6',TdiST_24,0,1);
  Definitions.Add('preauthcd6',TdiST_24,0,1);
end;

function TdiZAU_24.Getinscarrier1: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('inscarrier1',0));
end;

function TdiZAU_24.Getinscarrier2: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('inscarrier2',0));
end;

function TdiZAU_24.Getinscarrier3: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('inscarrier3',0));
end;

function TdiZAU_24.Getinscarrier4: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('inscarrier4',0));
end;

function TdiZAU_24.Getinscarrier5: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('inscarrier5',0));
end;

function TdiZAU_24.Getinscarrier6: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('inscarrier6',0));
end;

function TdiZAU_24.Getpreauthcd1: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('preauthcd1',0));
end;

function TdiZAU_24.Getpreauthcd2: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('preauthcd2',0));
end;

function TdiZAU_24.Getpreauthcd3: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('preauthcd3',0));
end;

function TdiZAU_24.Getpreauthcd4: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('preauthcd4',0));
end;

function TdiZAU_24.Getpreauthcd5: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('preauthcd5',0));
end;

function TdiZAU_24.Getpreauthcd6: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('preauthcd6',0));
end;

procedure TdiZAU_24.Setinscarrier1(const Value: TdiST_24);
begin
  SetStructure('inscarrier1',0,Value);
end;

procedure TdiZAU_24.Setinscarrier2(const Value: TdiST_24);
begin
  SetStructure('inscarrier2',0,Value);
end;

procedure TdiZAU_24.Setinscarrier3(const Value: TdiST_24);
begin
  SetStructure('inscarrier3',0,Value);
end;

procedure TdiZAU_24.Setinscarrier4(const Value: TdiST_24);
begin
  SetStructure('inscarrier4',0,Value);
end;

procedure TdiZAU_24.Setinscarrier5(const Value: TdiST_24);
begin
  SetStructure('inscarrier5',0,Value);
end;

procedure TdiZAU_24.Setinscarrier6(const Value: TdiST_24);
begin
  SetStructure('inscarrier6',0,Value);
end;

procedure TdiZAU_24.Setpreauthcd1(const Value: TdiST_24);
begin
  SetStructure('preauthcd1',0,Value);
end;

procedure TdiZAU_24.Setpreauthcd2(const Value: TdiST_24);
begin
  SetStructure('preauthcd2',0,Value);
end;

procedure TdiZAU_24.Setpreauthcd3(const Value: TdiST_24);
begin
  SetStructure('preauthcd3',0,Value);
end;

procedure TdiZAU_24.Setpreauthcd4(const Value: TdiST_24);
begin
  SetStructure('preauthcd4',0,Value);
end;

procedure TdiZAU_24.Setpreauthcd5(const Value: TdiST_24);
begin
  SetStructure('preauthcd5',0,Value);
end;

procedure TdiZAU_24.Setpreauthcd6(const Value: TdiST_24);
begin
  SetStructure('preauthcd6',0,Value);
end;

{ TdiZIN_24 }

procedure TdiZIN_24.Init;
begin
  inherited;
  Name :='ZIN';
  Definitions.Add('condition',TdiST_24,0,1);
  Definitions.Add('ifcondition',TdiST_24,0,1);
end;

function TdiZIN_24.Getcondition: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('condition',0));
end;

function TdiZIN_24.Getifcondition: TdiST_24;
begin
  Result:= TdiST_24(GetStructure('ifcondition',0));
end;

procedure TdiZIN_24.Setcondition(const Value: TdiST_24);
begin
  SetStructure('condition',0,Value);
end;

procedure TdiZIN_24.Setifcondition(const Value: TdiST_24);
begin
  SetStructure('ifcondition',0,Value);
end;

{ 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;

function TdiZPI_Z01_24.GetIN1: TdiIN1_24;
begin
  Result:=TdiIN1_24(GetStructure('IN1',0));
end;

function TdiZPI_Z01_24.GetMSA: TdiMSA_24;
begin
  Result:=TdiMSA_24(GetStructure('MSA',0));
end;

function TdiZPI_Z01_24.GetMSH: TdiMSH_24;
begin
  Result:=TdiMSH_24(GetStructure('MSH',0));
end;

function TdiZPI_Z01_24.GetPID: TdiPID_24;
begin
  Result:=TdiPID_24(GetStructure('PID',0));
end;

function TdiZPI_Z01_24.GetPRD: TdiPRD_24;
begin
  Result:=TdiPRD_24(GetStructure('PRD',0));
end;

function TdiZPI_Z01_24.GetZAU: TdiZAU_24;
begin
  Result:=TdiZAU_24(GetStructure('ZAU',0));
end;

function TdiZPI_Z01_24.GetZIN: TdiZIN_24;
begin
  Result:=TdiZIN_24(GetStructure('ZIN',0));
end;

procedure TdiZPI_Z01_24.SetIN1(const Value: TdiIN1_24);
begin
  SetStructure('IN1',0,Value);
end;

procedure TdiZPI_Z01_24.SetMSA(const Value: TdiMSA_24);
begin
  SetStructure('MSA',0,Value);
end;

procedure TdiZPI_Z01_24.SetMSH(const Value: TdiMSH_24);
begin
  SetStructure('MSH',0,Value);
end;

procedure TdiZPI_Z01_24.SetPID(const Value: TdiPID_24);
begin
  SetStructure('PID',0,Value);
end;

procedure TdiZPI_Z01_24.SetPRD(const Value: TdiPRD_24);
begin
  SetStructure('PRD',0,Value);
end;

procedure TdiZPI_Z01_24.SetZAU(const Value: TdiZAU_24);
begin
  SetStructure('ZAU',0,Value);
end;

procedure TdiZPI_Z01_24.SetZIN(const Value: TdiZIN_24);
begin
  SetStructure('ZIN',0,Value);
end;

initialization
  diRegisterClass(TdiZAU_24,'ZAU','2.4');
  diRegisterClass(TdiZIN_24,'ZIN','2.4');
  diRegisterClass(TdiZPI_Z01_24,'ZPI_Z01','2.4');

finalization
  diUnRegisterClass(TdiZAU_24);
  diUnRegisterClass(TdiZIN_24);
  diUnRegisterClass(TdiZPI_Z01_24);


end.
for version 2.3.1,

custom segment

Code: Select all

TdiZIN_231 = class(TdiSegment)
  protected
    function Getifcondition: TdiST_231;
    function Getcondition: TdiST_231;
    procedure Setifcondition(const Value: TdiST_231);
    procedure Setcondition(const Value: TdiST_231);
  public
    property ifcondition : TdiST_231 read Getifcondition write Setifcondition;
    property condition : TdiST_231 read Getcondition write Setcondition;
    procedure Init;override;
  end;
  ....

initialization
  diRegisterClass(TdiZIN_231,'ZIN','2.3.1');

finalization
  diUnRegisterClass(TdiZIN_231);
custom message

Code: Select all


  TdiZPI_Z01_231= class(TdiMessage)
  protected
    function GetIN1: TdiIN1_231;
    function GetMSA: TdiMSA_231;
    function GetMSH: TdiMSH_231;
    function GetPID: TdiPID_231;
    function GetPRD: TdiPRD_231;
    function GetZAU: TdiZAU_231;
    function GetZIN: TdiZIN_231;
    procedure SetIN1(const Value: TdiIN1_231);
    procedure SetMSA(const Value: TdiMSA_231);
    procedure SetMSH(const Value: TdiMSH_231);
    procedure SetPID(const Value: TdiPID_231);
    procedure SetPRD(const Value: TdiPRD_231);
    procedure SetZAU(const Value: TdiZAU_231);
    procedure SetZIN(const Value: TdiZIN_231);
  public
    property MSH : TdiMSH_231 read GetMSH write SetMSH;
    property MSA : TdiMSA_231 read GetMSA write SetMSA;
    property ZAU : TdiZAU_231 read GetZAU write SetZAU;
    property PRD : TdiPRD_231 read GetPRD write SetPRD;
    property PID : TdiPID_231 read GetPID write SetPID;
    property IN1 : TdiIN1_231 read GetIN1 write SetIN1;
    property ZIN : TdiZIN_231 read GetZIN write SetZIN;
    procedure Init;override;
  end;



procedure TdiZPI_Z01_231.Init;
begin
  inherited;
   Name :='ZPI_Z01';
   MessageType :='ZPI';
   TriggerEvent :='Z01';
   HL7Version :='2.3.1';
   Definitions.Add('MSH',TdiMSH_231,1,1);
   Definitions.Add('MSA',TdiMSA_231,1,1);
   Definitions.Add('ZAU',TdiZAU_231,1,1);
   Definitions.Add('PRD',TdiPRD_231,1,1);
   Definitions.Add('PID',TdiPID_231,0,1);
   Definitions.Add('IN1',TdiIN1_231,0,1);
   Definitions.Add('ZIN',TdiZIN_231,0,1);

   ParseHL7(InitMsg);
end;

initialization
  diRegisterClass(TdiZPI_Z01_231,'ZPI_Z01','2.3.1');

finalization
  diUnRegisterClass(TdiZPI_Z01_231);

Best regards.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests