Iterate from 2

Homepage Clovertech Forums Cloverleaf Iterate from 2

  • Creator
    Topic
  • #120922
    Doug Haskins
    Participant

    A client is sending us OBX Indication data in ORM messages. The format is not how we expect and we are trying to clean this up. They send a Question in OBX-3.2 and an Answer in OBX-5.2, and we are expecting this data in field 1 for each. Simple enough to move one to the other and delete the extra, but to add to this, they want certain tags to appear at the top.

    So they send this

    2(0).1(0).1(0).0(0).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(0).OBX(0).#3(0) : >AAAAA^AAAtrauma<
    2(0).1(0).1(0).0(0).OBX(0).#5(0) : >^AAADATA test<
    2(0).1(0).1(0).0(1).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(1).OBX(0).#3(0) : >BBBBB^BBBtrauma<
    2(0).1(0).1(0).0(1).OBX(0).#5(0) : >^BBBDATA test<
    2(0).1(0).1(0).0(2).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(2).OBX(0).#3(0) : >CCCCC^CCCtrauma<
    2(0).1(0).1(0).0(2).OBX(0).#5(0) : >^CCCDATA test<
    2(0).1(0).1(0).0(3).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(3).OBX(0).#3(0) : >DDDDD^DDDtrauma<
    2(0).1(0).1(0).0(3).OBX(0).#5(0) : >^DDDDATA test<
    2(0).1(0).1(0).0(4).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(4).OBX(0).#3(0) : >EEEEE^EEEtrauma<
    2(0).1(0).1(0).0(4).OBX(0).#5(0) : >^EEEDATA test<
    2(0).1(0).1(0).0(5).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(5).OBX(0).#3(0) : >FFFFF^FFFtrauma<
    2(0).1(0).1(0).0(5).OBX(0).#5(0) : >^FFFDATA test<

    And want this

    2(0).1(0).1(0).0(0).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(0).OBX(0).#3(0) : >FFFFF^FFFtrauma<
    2(0).1(0).1(0).0(0).OBX(0).#5(0) : >^FFFDATA test<
    2(0).1(0).1(0).0(1).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(1).OBX(0).#3(0) : >DDDDD^DDDtrauma<
    2(0).1(0).1(0).0(1).OBX(0).#5(0) : >^DDDDATA test<
    2(0).1(0).1(0).0(2).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(2).OBX(0).#3(0) : >AAAAA^AAAtrauma<
    2(0).1(0).1(0).0(2).OBX(0).#5(0) : >^AAADATA test<
    2(0).1(0).1(0).0(3).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(3).OBX(0).#3(0) : >BBBBB^BBBtrauma<
    2(0).1(0).1(0).0(3).OBX(0).#5(0) : >^BBBDATA test<
    2(0).1(0).1(0).0(4).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(4).OBX(0).#3(0) : >CCCCC^CCCtrauma<
    2(0).1(0).1(0).0(4).OBX(0).#5(0) : >^CCCDATA test<
    2(0).1(0).1(0).0(5).OBX(0).#1(0) : >1<
    2(0).1(0).1(0).0(5).OBX(0).#3(0) : >EEEEE^EEEtrauma<
    2(0).1(0).1(0).0(5).OBX(0).#5(0) : >^EEEDATA test<

    The tags for this being FFFFF and DDDDD, always at the top, with the rest (one to many) falling below.

    So Easy enough to gather all of these variables, and then I can overwrite the first two, but then how to Iterate the rest?

    Is there a way to iterate beginning at 2 instead of 0?

    I tried %g2 + 2 but that does nothing, is there a trick?

Viewing 3 reply threads
  • Author
    Replies
    • #120924
      Jim Vilbrandt
      Participant

      Hi Doug,

      what about reading all OBX segments into a TCL list in an inbound data TPS, then sorting that list before sending to the XLate?

      I would create a list with two fields, the first is your sort criteria and the second is the raw OBX string.

      keylget args MSGID mh

      # Get HL7 Message
      set msg [msgget $mh]
      set segs [split $msg “\x0d”]
      set fdlm [cindex $segs 4] ;# HL7 Field Delimiter
      set cdlm [cindex $segs 5] ;# HL7 Component Delimiter
      set rdlm [cindex $segs 6] ;# HL7 Repeat Delimiter
      set sdlm [cindex $segs 8] ;# HL7 Sub-Component Delimiter
      set mshID {}

      foreach seg $segs {
      set fields [split $seg $fdlm]
      set segname [lindex $fields 0]
      switch -regexp — $segname {
      OBX {…

      Regards, Jim

    • #120926
      Jim Kosloskey
      Participant

      This can be done all in the Xlate without Tcl. There are multiple techniques that can be used based on the criteria.

      There is nothing that says you cannot ITERATE over the IB multiple times. email me and I will work with you to show you how this can be done.

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #120927
      Jim Kosloskey
      Participant

      Here is one potential solution (assuming tagged items are already in order or order does not matter).

      You will need to manage your own Iteration Counter (variable) – let’s say it is %g99.

      This will require 2 ITERATEs.

      1<sup>st</sup> ITERATE is to find and move the tags. Inside the ITERATE an IF checking for the tags, if the item is a tagged item of interest, COPY it to the OB using your counter (%g99) for the OB, if not of interest don’t do anything. If you want to you can keep track of whether you have found all of your items of interest and if that is the case you can BREAK out of the ITERATE so that you do not ITERATE over all of the IB – but – it should not be a big deal.

      When the above ITERATE is finished, your counter points to the last position populated OB (maybe a value of 1 if there are 2 tag items of interest).

      2<sup>nd</sup> ITERATE is to COPY all of the other items. An IF again checks for if a tag of interest. If it is not a tag of interest, COPY from IB to OB using your counter (%g99) for the OB.

      Don’t forget to initialize your counter and increment as needed.

      There are other potential solutions depending on criteria but I think the above addresses the problem as stated.

       

      email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

    • #120928
      Doug Haskins
      Participant

      Thanks all. I did manage to get this working. Probably not as slick as it could be, nor pretty, but it works.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.

Forum Statistics

Registered Users
5,127
Forums
28
Topics
9,299
Replies
34,443
Topic Tags
288
Empty Topic Tags
10