problem with repetitive segments

Discussion of open issues, suggestions and bugs regarding to (known as Delphi HL7) HL7 Components
Post Reply
ibarrols
Posts: 11
Joined: Thu Nov 24, 2011 5:20 pm

problem with repetitive segments

Post by ibarrols »

I have a query:
when I create a message TdiZQA_Z02_24 of authorization, with the repetitive segments that are PR1, AUT and ZAU...
the proper way to create the message should be as follows::

Code: Select all

MSH|.........
PRD|.........
PRD|.........
PID|.........
PR1|1||420001^^2 
AUT||||||||1 
ZAU||0 
PR1|1||420102^^1 
AUT||||||||1 
ZAU||0 
PV1||O||P|||||||||||||||||||||||||||||||||||||||||||||||V
now when I'm creating in my application the message appears as follows:

Code: Select all

MSH|.........
PRD|.........
PRD|.........
PID|.........
PR1|100||420101^^10
PR1|200||420101^^20
AUT||||||||1
AUT||||||||2
ZAU||0
ZAU||1
the problem is the order of PR1 to have to go with their respective segments and Zau AUT.
step the code I was developing:

Code: Select all

TdiZQA_Z02_24 = class(TdiMessage)
  private
      MSHList:TdiSegmentList;
      PRDList:TdiSegmentList;
      PIDList:TdiSegmentList;

      {Inicio - Segmentos repetitivos}
      PR1List:TdiSegmentList;
      AUTList:TdiSegmentList;
      ZAUList:TdiSegmentList;
      {Fin - Segmentos repetitivos}

      PV1List:TdiSegmentList;
  protected
      function GetMSH: TdiMSH_24;
      {begin - repeated segments}
      function GetPRD(RepCount : Integer ) : TdiPRD_24;
      {end - repeated segments}

      //function GetPRD1: TdiPRD_24;
      function GetPID: TdiPID_24;

      {repeated segments}
      function GetPR1(RepCount : Integer ) : TdiPR1_24;
      function GetAUT(RepCount : Integer ) : TdiAUT_24;
      function GetZAU(RepCount : Integer ) : TdiZAU_24;


      function GetPV1: TdiPV1_24;

      procedure SetMSH(const Value: TdiMSH_24);
      {repeated segments}
      procedure SetPRD( RepCount : Integer; const Value : TdiPRD_24);
      
      procedure SetPID(const Value: TdiPID_24);

      {repeated segments}
      procedure SetPR1( RepCount : Integer; const Value : TdiPR1_24);
      procedure SetAUT( RepCount : Integer; const Value : TdiAUT_24);
      procedure SetZAU( RepCount : Integer; const Value : TdiZAU_24);

      procedure SetPV1(const Value: TdiPV1_24);
  public
      property MSH: TdiMSH_24 read GetMSH write SetMSH;
 
     {repeated segments}
      property PRD[RepCount : Integer ] : TdiPRD_24 read GetPRD write SetPRD;
      
      property PID: TdiPID_24 read GetPID write SetPID;

      {repeated segments}
      property PR1[RepCount : Integer ] : TdiPR1_24 read GetPR1 write SetPR1;
      property AUT[RepCount : Integer ] : TdiAUT_24 read GetAUT write SetAUT;
      property ZAU[RepCount : Integer ] : TdiZAU_24 read GetZAU write SetZAU;
      function PR1RepCount : Integer;
      function AUTRepCount : Integer;
      function ZAURepCount : Integer;

      property PV1: TdiPV1_24 read GetPV1 write SetPV1;

      constructor Create; override;
  end;
constructor

Code: Select all

constructor TdiZQA_Z02_24.Create;
begin
  inherited;
   Name :='ZQA_Z02';
   MessageType :='ZQA';
   TriggerEvent :='Z02';
   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,2,Self);
   Add(PRDList);

   PIDList:=TdiSegmentList.Create;
   PIDList.SetDefault('PID','TdiPID_24',2,1,1,Self);
   Add(PIDList);

   {repeated segments}
   PR1List:=TdiSegmentList.Create;
   PR1List.SetDefault('PR1','TdiPR1_24',3,1,5,Self);
   Add(PR1List);
   AUTList:=TdiSegmentList.Create;
   AUTList.SetDefault('AUT','TdiAUT_24',4,1,5,Self);
   Add(AUTList);
   ZAUList:=TdiSegmentList.Create;
   ZAUList.SetDefault('ZAU','TdiZAU_24',5,1,10,Self);
   Add(ZAUList);

   PV1List:=TdiSegmentList.Create;
   PV1List.SetDefault('PV1','TdiPV1_24',6,0,1,Self);
   Add(PV1List);

   Parse(InitMsg);

end;
create message:

Code: Select all

   {PRACTICE 1}
  msgAuth.PR1[0].SetIDPR1.AsString := '100';
  msgAuth.PR1[0].ProcedureCode.Identifier.AsString := '420101';
  msgAuth.PR1[0].ProcedureCode.Nameofcodingsystem.AsString := '10';
  msgAuth.AUT[0].RequestedNumberofTreatments.AsString := '1';
  msgAuth.ZAU[0].inscarrier2.AsString := '0';

 {PRACTICE 2}
  msgAuth.PR1[1].SetIDPR1.AsString := '200';
  msgAuth.PR1[1].ProcedureCode.Identifier.AsString := '420101';
  msgAuth.PR1[1].ProcedureCode.Nameofcodingsystem.AsString := '20';
  msgAuth.AUT[1].RequestedNumberofTreatments.AsString := '2';
  msgAuth.ZAU[1].inscarrier2.AsString := '1';
thanks and best regards!!!
admin
Site Admin
Posts: 256
Joined: Sun Jun 05, 2011 8:06 pm

Re: problem with repetitive segments

Post by admin »

Hi,

You need message sub groups.

Code: Select all

TdiGroupName_24= class(TdiSegmentGroup)
private
   PR1List:TdiSegmentList;
   AUTList:TdiSegmentList;
   ZAUList:TdiSegmentList;
protected
   function GetPR1(RepCount : Integer ) : TdiPR1_24;
   function GetAUT(RepCount : Integer ) : TdiAUT_24;
   function GetZAU(RepCount : Integer ) : TdiZAU_24;
   procedure SetPR1( RepCount : Integer; const Value : TdiPR1_24);
   procedure SetAUT( RepCount : Integer; const Value : TdiAUT_24);
   procedure SetZAU( RepCount : Integer; const Value : TdiZAU_24);
public
   property PR1[RepCount : Integer ] : TdiPR1_24 read GetPR1 write SetPR1;
   property AUT[RepCount : Integer ] : TdiAUT_24 read GetAUT write SetAUT;
   property ZAU[RepCount : Integer ] : TdiZAU_24 read GetZAU write SetZAU;
   function PR1RepCount : Integer;
   function AUTRepCount : Integer;
   function ZAURepCount : Integer;
end;
... and your main message must be:

Code: Select all

TdiZQA_Z02_24 = class(TdiMessage)
private
   MSHList:TdiSegmentList;
   PRDList:TdiSegmentList;
   PIDList:TdiSegmentList;

   GroupNameList : TdiSegmentList;

   PV1List:TdiSegmentList;
protected
   function GetMSH: TdiMSH_24;
    {begin - repeated segments}
    function GetPRD(RepCount : Integer ) : TdiPRD_24;
    {end - repeated segments}

    //function GetPRD1: TdiPRD_24;
     function GetPID: TdiPID_24;

    {repeated segments}
    function GetGroupName(RepCount : Integer ) : TdiGroupName_24;

    function GetPV1: TdiPV1_24;

    procedure SetMSH(const Value: TdiMSH_24);
    {repeated segments}
    procedure SetPRD( RepCount : Integer; const Value : TdiPRD_24);
         
    procedure SetPID(const Value: TdiPID_24);

    {repeated segments}
    procedure SetGroupName( RepCount : Integer; const Value : TdiGroupName_24);

    procedure SetPV1(const Value: TdiPV1_24);
public
    property MSH: TdiMSH_24 read GetMSH write SetMSH;

    {repeated segments}
    property PRD[RepCount : Integer ] : TdiPRD_24 read GetPRD write SetPRD;
       
    property PID: TdiPID_24 read GetPID write SetPID;

    {repeated segments}
    property GroupName[RepCount : Integer ] : TdiGroupName_24 read GetGroupName write SetGroupName;
    function GroupNameRepCount : Integer;

    property PV1: TdiPV1_24 read GetPV1 write SetPV1;

    constructor Create; override;
end;
Messages can contain message groups.
Message groups can contain message sub groups.

Best regards.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests