ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Not able to map HL7 segments in the needed order

Post new topic  Reply to topic
 Not able to map HL7 segments in the needed order « View previous topic :: View next topic » 
Author Message
sovee
PostPosted: Mon Jul 23, 2012 2:13 am    Post subject: Not able to map HL7 segments in the needed order Reply with quote

Novice

Joined: 23 Jul 2012
Posts: 12

Hi All,

I have been trying to map an input XML message to HL7.As per the requirement the output is expected as follows :

MSH
PID
OBR
VND1
PKG1
VND2
PKG2

But the output message as of now is getting printed as :

MSH
PID
OBR
VND1
VND2
PKG1
PKG2

A while loop is used to print the values as blow:

WHILE (CONDITION)

SET OutputRoot.HL7.VND[i].c1 = yyy;
SET OutputRoot.HL7.PKG[i].c1 = 123;

SET i=i+1;
END WHILE;

Please let me know if any specific cormmand needs to be included to ensure the order.
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jul 23, 2012 2:36 am    Post subject: Re: Not able to map HL7 segments in the needed order Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

sovee wrote:
Please let me know if any specific cormmand needs to be included to ensure the order.


Not so much a specific command as the correct method. You're handling the segment names as if they're array elements so obviously they're going to be continuous.

If you want them in a specific order, you have to CREATE them in that order in the message tree; just that order chronologically won't do it.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jul 23, 2012 4:33 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

As Vitor says, use something like this:
Code:
CREATE LASTCHILD OF OutputRoot.HL7.VND[i] TYPE NameValue Name "c1" VALUE "yyy";
CREATE LASTCHILD OF OutputRoot.HL7.PKG[i] TYPE NameValue Name "c1" VALUE 123; [i]

etc
Back to top
View user's profile Send private message
sovee
PostPosted: Mon Jul 23, 2012 11:02 am    Post subject: Reply with quote

Novice

Joined: 23 Jul 2012
Posts: 12

Thanks for your comments.
But here since we are using HL7, c1 is not the name of the field.It is a component in the segment.Can we still use the same command.

CREATE LASTCHILD OF OutputRoot.HL7.VND[i].f1.c1 TYPE NAMEVALUE VALUE 'YYY';

Is the above correct. I am getting parser excepion while trying to do this.Please help
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jul 23, 2012 11:47 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

sovee wrote:
Is the above correct.


Apparently not, because....

sovee wrote:
I am getting parser excepion while trying to do this.


What led you to use that construction of the command?

sovee wrote:
Please help


Only if you help first. Apart from the question above, what's the text of the parser exception? WMB produces a number of them for a number of different reasons. At what point in processing is the exception produced?

Most importantly, what have you already attempted to resolve this exception apart from posting here?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Jul 23, 2012 11:57 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Fair comment - the approach that I suggested is probably not the best.
I suspect that you want to use REFERENCE variables for the source and target, as in the example code snippet here : http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/ak05090_.htm

Suggestions welcome from others.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jul 23, 2012 8:25 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Have you tried something completely different like:
Code:

DECLARE myref REFERENCE TO OutputRoot.HL7;
DECLARE FNAME CHARACTER '';

WHILE (CONDITION)
   SET FNAME = '';
--SET OutputRoot.HL7.VND[i].c1 = yyy;
   SET FNAME = 'VND' || CAST (i to CHAR format 'z9'); --  check for correct format clause
  SET myref.{FNAME}.c1=yyy;
--SET OutputRoot.HL7.PKG[i].c1 = 123;
  -- same way as above for VND

SET i=i+1;
END WHILE;


Seems like first you need to build the field name, and then dynamically instanciate it. This can be done either in a create last child of xref name FNAME VALUE fieldvalue, or via substitution as shown above...

If you have a lot of fields to set in the segment (VNDi, PKGi), create the segment, reference it for assigning the field names. Should be way faster than substituting the name for every assignment...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Tue Jul 24, 2012 12:19 am    Post subject: Re: Not able to map HL7 segments in the needed order Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

sovee wrote:
Code:
WHILE (CONDITION)
    SET OutputRoot.HL7.VND[i].c1 = yyy;
    SET OutputRoot.HL7.PKG[i].c1 = 123;

    SET i=i+1;
END WHILE;

Please let me know if any specific cormmand needs to be included to ensure the order.

The 'VND' and 'PKG' segments must be created and positioned explicitly:

Code:
    CREATE LASTCHILD OF OutputRoot.HL7 NAME 'VND';
    SET OutputRoot.HL7.VND[i].f1.c1 = yyy;
    CREATE LASTCHILD OF OutputRoot.HL7 NAME 'PKG';
    SET OutputRoot.HL7.PKG[i].f1.c1 = '123';

For a more detailed explanation, look here. The SET statements could be replaced with CREATE statements, but that's not really necessary; what is necessary though is that NAMEVALUE elements have both a name and a value:

Code:
    CREATE LASTCHILD OF OutputRoot.HL7 NAME 'VND';
    CREATE LASTCHILD OF OutputRoot.HL7.VND[i].f1 NAME 'c1' VALUE yyy;
    CREATE LASTCHILD OF OutputRoot.HL7 NAME 'PKG';
    CREATE LASTCHILD OF OutputRoot.HL7.PKG[i].f1 NAME 'c1' VALUE '123';

Using references instead of indexes would improve performance.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Tue Jul 24, 2012 2:31 am    Post subject: Re: Not able to map HL7 segments in the needed order Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

rekarm01 wrote:
Using references instead of indexes would improve performance.


For performance you could use "a (couple of) reference(s) on the input- and output-tree":

Code:
    DECLARE REFERENCE rIn TO InputRoot.inHL7List;
    MOVE rIn FIRSTCHILD NAME 'item';    --  Do a "move", because the LASTMOVE(rIn) of the WHILE-loop (below) needs to have a "last move"
    DECLARE REFERENCE rOut TO OutputRoot;
    CREATE LASTCHILD OF rOut AS rOut NAME 'HL7';
    DECLARE REFERENCE rHL7 TO rOut;    -- While you go down the input- or output-message-tree (within your code) "save" references for later reuse (if needed)
    CREATE LASTCHILD OF rOut AS rOut NAME 'MSH';
    CREATE NEXTSIBLING OF rOut AS rOut NAME 'PID';
    CREATE NEXTSIBLING OF rOut AS rOut NAME 'OBR';
    DECLARE i INTEGER 1;
    WHILE (LASTMOVE(rIn)) DO
         DECLARE suffix CHAR CAST (i TO CHAR format 'z9'); --  check for correct format clause ;   & check if you want that... or if it is a mistake in your first post.
         CREATE LASTCHILD OF rOut AS rOut NAME 'VND' || suffix;   -- check if you want the suffix in the field-name
         CREATE LASTCHILD OF rOut AS rOut NAME 'f1';
         CREATE LASTCHILD OF rOut AS rOut NAME c1' VALUE rIn.in_VND_c1_value;  -- 'yyy'
         -- Can't create a LAST- or NEXT-CHILD: (re-)use a reference (that was saved up the code/tree)):
         MOVE rOut TO rHL7;
         CREATE LASTCHILD OF rOut AS rOut NAME 'PKG' || suffix;   -- check if you want the suffix in the field-name
         CREATE LASTCHILD OF rOut AS rOut NAME 'f1';
         CREATE LASTCHILD OF rOut AS rOut NAME 'c1' VALUE rIn.in_PKG_c1_value;  -- '123'
         MOVE rIn NEXTSIBLING REPEATE TYPE NAME;
         SET i = i + 1;
     END WHILE;


Now that you might get lost in references... I usually get the debugger attached and take a close look there
Back to top
View user's profile Send private message
rekarm01
PostPosted: Tue Jul 24, 2012 8:53 am    Post subject: Re: Not able to map HL7 segments in the needed order Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

mqsiuser wrote:
For performance you could use "a (couple of) reference(s) on the input- and output-tree":

... assuming the input is coming from an input tree.

It's typically easier to just use a SET statement whenever possible, and only use the CREATE statement to do what a SET statement can't do.

HL7 segment identifiers are 3-character elements. The 'VND1', 'PKG1', 'VND2', 'PKG2', etc., above is a bit misleading; it's actually 'VND[1]', 'PKG[1]', 'VND[2]', 'PKG[2]', etc. .
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Tue Jul 24, 2012 11:43 am    Post subject: Re: Not able to map HL7 segments in the needed order Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

rekarm01 wrote:
... assuming the input is coming from an input tree.

O.k. honestly what else can there be ? If you are doing a mapping, then I have always had InputRoot and OutputRoot (if there is no mapping there is just "Root" like on the FlowOrder-Node).

rekarm01 wrote:
It's typically easier to just use a SET statement whenever possible, and only use the CREATE statement to do what a SET statement can't do.

mgk wrote:
SET [and CREATE FIELD statements] will try to navigate to the requested element and if found will change its value. If not found (and the index is not out of range), they create a new element "after the last found element" If the element does not exist at all, then the position will be at the end (lastchild).


"try to navigate to" / "If the element does not exist at all" means go through a list (the currently existing list) ? ... I'd rather prefer to just say "create my new field at the end" (This means I'd use "CREATE LASTCHILD" or "NEXTSIBLING").

But: I must admit that I write (and I actually see) a lot of code which just uses references and SET:


Code:
    SET OutputRoot.HL7.MSH = '';    -- Well... also included here is an awkward trick... just to create the field assign it the empty string
    DECLARE rOutHL7 REFERENCE TO OutputRoot.HL7;  -- walking once again to HL7: probably/likely fair enough.
    SET rOutHL7.PID = '';   -- The awkward trick again (if necessary). At least not walking into the tree again :-)
    SET rOutHL7.OBR = '';
    SET rOutHL7.VND.f1.c1 = 'yyy';   -- Here start the problems of the OP anyway.
    SET rOutHL7.PKG.f1.c1 = '123';   -- You need to start using CREATE LASTCHILD here


but... wouldn't CREATE + LASTCHILD / NEXTSIBLING be always faster then ?

Is "SET-Statements"-code just more convenient to write ?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Jul 24, 2012 11:49 am    Post subject: Re: Not able to map HL7 segments in the needed order Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

mqsiuser wrote:
but... wouldn't CREATE + LASTCHILD / NEXTSIBLING be always faster then ?

Is "SET-Statements"-code just more convenient to write ?


There's not a significant difference in performance between a set and a create field, afaik.

The performance comes in with using references to identify and point to siblings over using [n] notation.

Using a set can be more readable than using a create field.

I personally will generally use a create field to create a repeating segment, and then use set to populate the children of that repeating segment.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Mon Jul 30, 2012 12:03 am    Post subject: Re: Not able to map HL7 segments in the needed order Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

mqsiuser wrote:
"try to navigate to" / "If the element does not exist at all" means go through a list (the currently existing list) ? ... I'd rather prefer to just say "create my new field at the end" ... wouldn't CREATE + LASTCHILD / NEXTSIBLING be always faster then ?

A SET statement that modifies/creates a field performs identically to the equivalent CREATE FIELD statement.
A SET statement that only creates a field can perform marginally better or worse than the equivalent CREATE [NEXTSIBLING/LASTCHILD] statement.
Outside of a loop, the performance difference between the SET and CREATE statements is usually not enough to worry about.

mqsiuser wrote:
Code:
    SET OutputRoot.HL7.MSH = '';    -- Well... also included here is an awkward trick... just to create the field assign it the empty string
    DECLARE rOutHL7 REFERENCE TO OutputRoot.HL7;  -- walking once again to HL7: probably/likely fair enough.
    SET rOutHL7.PID = '';   -- The awkward trick again (if necessary). At least not walking into the tree again :-)
    SET rOutHL7.OBR = '';
    -- ...

If the MSH, PID, and OBR fields are supposed to be Name elements, then assigning values to them would be an error.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Not able to map HL7 segments in the needed order
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.