Remove repeating fields based on condition

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Remove repeating fields based on condition

  • Creator
    Topic
  • #50852
    Shaun Beckman
    Participant

    In MFNs we are attempting to send the physicin’s fax number in STF10, and remove all other numbers. The only number that should appear in STF10 is the one ending in “CF”, and it is not always in the same repitition location.

    Example:  STF|13380||TEST^TESTER^^^^MD|P|M|19730924|A||IM|(815)555-9999CH~(815)555-9876CO~(815)555-2468CF~(815)555-1111CB

    We are on v5.5 rev 1

    Any assistance would be greatly appreciated.

Viewing 10 reply threads
  • Author
    Replies
    • #67771
      Jim Levy
      Participant

      Hi Shaun,

      Here’s something I did to strip out everything but MRN from PID.3.

                   # Strip out all numbers in PID.3 except MRN

                   set NumOfPID_3reps [$hl7msg countFieldReps PID.3]

                   set mrn “”

                   for {set j 0} { $j < $NumOfPID_3reps } {incr j} {

                     if {[string equal [$hl7msg getField PID.3.4] “MR”]} {

                       set mrn [$hl7msg getField PID.3.0]

                       set mrn [string trimleft $mrn “0”]

                     }

                   }

                   if {$mrn ne “”} {

                     $hl7msg setField PID.3 $mrn

                   }

      I hope this helps!

      Jim

    • #67772
      Jim Kosloskey
      Participant

      Shaun,

      If you want to do this in the Xlate, then this appears to be a repeating field.

      You could iterate through the field repetition and apply some Tcl code to  to return the last 2 characters in a temp variabel.

      Then inside the ITERATE and after your COPy setting the Temp variable, use an IF Action to check to see if the temp variable built above is equal to “CF”.

      If true COPY that repetition to the first field repetition. If false don’t do anything.

      That should work.

      If you do not have an xltp type proc that extracts the characters, let me know via email and I will send you one.

      email: jim.kosloskey@jim-kosloskey.com

    • #67773
      Tom Rioux
      Participant

      Shaun,

      If you are in an xlate…

      Using a Bulkcopy for the message OR

      Using a Pathcopy for the segment,…

      Then build an iterate on the STF10 repeating field.

    • #67774
      Charlie Bursell
      Participant

      I think what Jim is alluding to is something like this:

      Inside your Xlate:

      COPY @null => @FAX

      Iterate %f1 on STF.#10

      Inside the iterate

      COPY STF.#10(%f1) => @null

      Inside the COPY statement add the Tcl code:

      set inp [lindex $xlateInVals 0]

      if {[regexp — {CF$} $inp]} {

         xpmstore $xlateId @FAX c $inp

      }

      After the iterate

      PATHCOPY @null => STF.#10

      COPY @FAX => STD.#10

      If the CF number exists it will be the only one in STF.#10 otherwise the field is empty.

      FWIW, not everyone has, or wants  😉 , the hl7msg procs

    • #67775
      Shaun Beckman
      Participant

      Thanks to all of you for your help.

      I used the code from Charlie and it worked as expected. i.e. ~(815)555-1234CF

      Now I just have to remove the tilde and I’m all set.

      Thanks again.

    • #67776
      Tom Rioux
      Participant

      In my testing with the code I posted, I was able to get the results you wanted, without the tilde.

      Either way, I’m glad you got it working!

    • #67777
      Charlie Bursell
      Participant

      Shawn:

      I don’t know where you sre seeing the tilde.  It should not be there.  If I test this code with an input like:

      0(0).MSH(0)  :  >|^~&|XDSDEMO_ADT|XDSDEMO|XDSDEMO_ADT|XDSDEM O|20090504131932-0

      400||MFN^M02|3779953719204734406|P|2.4<

      0(0).MFI(0)  :  >|1|2|3<

      1(0).MFE(0)  :  >|1|2|3<

      1(0).STF(0)  :  >|13380||TEST^TESTER^^^^MD|P|M|19730924|A||IM|(815)555-9999CH~(8

      15)555-9876CO~(815)555-2468CF~(815)555-1111CB<

      I get output like:

      0(0).MSH(0)  :  >|^~&|XDSDEMO_ADT|XDSDEMO|XDSDEMO_ADT|XDSDEM O|20090504131932-0

      400||MFN^M02|3779953719204734406|P|2.4<

      0(0).MFI(0)  :  >|1|2|3<

      1(0).MFE(0)  :  >|1|2|3<

      1(0).STF(0)  :  >|13380||TEST^TESTER^^^^MD|P|M|19730924|A||IM|(815)555-2468CF<

      Note no tilde.

      FWIW if you were using CL 5.7 you could have done this with no Tcl at all by using an IF statement with CONTAINS logic

    • #67778
      Jim Kosloskey
      Participant

      Shaun,

      I suspect you are not iterating through the repeating field.

      That iteration will present you each repetition and thus eliminate the tilde.

      If you do not use the iteration and thus get the entire element you could have tildes and then have to deal with them.

      Why not use the Xlate functionality?

      email: jim.kosloskey@jim-kosloskey.com

    • #67779
      Shaun Beckman
      Participant

      I tried Thomas’s suggestion, but still receive the tilde.

      The STF segment is in a group iterate with the MFE segement, so I’m wondering if the group iterate is causing the issue.

    • #67780
      Tom Rioux
      Participant

      Shaun,

      In your copy statement where you are putting the xlt proc, (for the code that I have),  if you leave off the iteration variable on your outbound destination, then you will not recieve the tilde.   For example, make your copy statement something like:

      STF(0).10(%f1) ==>  STF(0).10(0)

      Hope this helps…Tom

    • #67781
      Shaun Beckman
      Participant

      Tom,

      That did it. Thanks!

      Thanks again to eveyone for your help.

Viewing 10 reply threads
  • The forum ‘Cloverleaf’ is closed to new topics and replies.

Forum Statistics

Registered Users
4,966
Forums
28
Topics
9,106
Replies
33,627
Topic Tags
248