Adding PV1-3.4 Subfield to message when it doesn’t exist

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Adding PV1-3.4 Subfield to message when it doesn’t exist

  • Creator
    Topic
  • #50612
    Eric Sligh
    Participant

    I am trying to add the PV1-3.4 into an ADT message using tcl. We currently have no Xlates or Variants on this site and I inherited this architecture so given the time constraints I have no choice but to do it in tcl.

    Here is where we build the segments:

    foreach seg $msg {

                         set fields [split $seg |]

                 set type [csubstr $seg 0 3]

                 switch -exact — $type {

    Then each segment is listed for the message.

    Here is the code where the PV1 Segment is being built:

    PV1 {

                       # Assigned patient location

                       # .1 Nurse .2 Station/Point of care, .3 Room, .4 Bed,

                       # .5 facility, .6 location status, .7person location type,

                       # .8 building, .9 floor, .10 location description

                       set pv1_3 [lindex $fields 3]

                       set bed [lindex [split $pv1_3 $sub_sep] 2]

    What do I need to add to make the PV1-3.4 populate this message after hitting this proc? I need to put an “A” in as the value.

    Something like:

    set facility [lindex [split $pv1_3 $sub_sep] 3]

    Any helped is greatly appreciated.

    Eric

Viewing 13 reply threads
  • Author
    Replies
    • #66781
      Anonymous
      Participant

      The code you have here is pulling things out of the existing messages.

      What you want is to build a new messaegs.

      We need to see the rest of the code. There are many ways to sking a cat and to help you we need to know if you started on the left side or the top side.

      But really it would be very very easy to do a bulkcopy and add one line to add the field you want.

    • #66782

      It could be as simple as …

      Code:

      set pv1_3 “[lindex $fields 3]^^^fooBar”

      -- Max Drown (Infor)

    • #66783
      Eric Sligh
      Participant

      ######################################################################

      # Name: z_fixHmsToMcKesson.0.1.tcl

      #

      # Purpose:

      #

      #

      #

      #

      # UPoC type: tps

      # Args: tps keyedlist containing the following keys:

      #       MODE    run mode (“start”, “run” or “time”)

      #       MSGID   message handle

      #       ARGS    user-supplied arguments:

      #         Example: {HMSID 000} {MCKID A} {TOSYS HPF}

      #                    hmsId       mckId   toSys

      #            cannot be: {{HMSID 000} {MCKID A} {TOSYS HPF}}

      #

      # Returns: tps disposition list:

      #

      # McH Procs included here:

      #    tps_chs_hmsdftadjust.tcl

      #    tps_chs_hmshciadjust.tcl

      #      Purpose: 1. Change from ZEM to ZPI.

      #            2. Copy PV1-16 to PV2-21.

      #             #Will need to reorder NK1 to be before PV1 for HCI.

      #              This was not done in this proc.

      #   tps_chs_hmshlabadjust.tcl

      #      Purpose: 1. reformatting PID-10 (Race code), PID-15 (Language), PID-17 (Religion).

      #   tps_chs_hmshmmadjust.tcl

      #      Purpose: 1. reformatting PID-10 (Race code), PID-15 (Language), PID-17 (Religion).

      #   tps_chs_hmihomadjust.tcl

      #      Purpose: These coding are based on HRM-HOM implement doc Rev9.

      #          1. 4.3.1.2 OBR4 modification and 4.3.1.7 rev9 – Re-format OBR-4.1 and OBR-4.3.

      #          Requires: chs_hrmhom_icd9.tbl

      #

      proc z_fixHmsToMcKesson.0.1 { args } {

         keylget args MODE mode

         set dispList {}

         switch -exact — $mode {

             start {

                 # Perform special init functions

               # N.B.: there may or may not be a MSGID key in args

             }

             run {

                # ‘run’ mode always has a MSGID; fetch and process it

                keylget args MSGID mh

                keylget args ARGS USERARGS

                keylget args ARGS.HMSID hmsId

                keylget args ARGS.MCKID mckId

                keylget args ARGS.TOSYS toSys

                set msg [msgget $mh]

                set field_sep [csubstr $msg 3 1]

                set sub_sep [csubstr $msg 4 1]

                set ssub_sep [csubstr $msg 5 1]

            set msg [split $msg r]

            set today [exec date]

            set tempvar “”

            set tempObr “”

            set tempOrc “”

            set resetNk1 0

            set resetObr 0

            set resetOrc 0

            set pv1_2 “”

            set pv1_8 “”

            set pv1_9 “”

            set pv1_10 “”

            set pv1_16 “”

            set pv1_17 “”

            set pv1_18 “”

            set pv1_19 “”

            set pv1_44 “”

            set pv1_45 “”

           

           

               

                foreach seg $msg {

               set fields [split $seg |]

                   set type [csubstr $seg 0 3]

                   switch -exact — $type {

                      MSH {

                         set msg_type_1 [lindex [split [lindex $fields 8] $sub_sep] 0]

                         set msg_type_2 [lindex [split [lindex $fields 8] $sub_sep] 1]

                         catch {set fields [lreplace $fields 3 3 $mckId]}

                         if {$toSys == “PACS”} {

                            catch {set fields [lreplace $fields 4 4 $hmsId]}

                         } else {

                            catch {set fields [lreplace $fields 4 4 $toSys]}

                         }

                         catch {set fields [lreplace $fields 5 5 $mckId]}

                         if {($toSys == “HLAB”) && ($msg_type_2 == “A35”)} {

                            # change MSH-8 from A35 to A41.

                        catch {set fields [lreplace $fields 8 8 “ADT^A41”]}

                     }

                         set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      EVN {

                         if {($toSys == “HLAB”) && ($msg_type_2 == “A35”)} {

                            catch {set fields [lreplace $fields 1 1 “A41”]}

                         }

                         set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      PID {

                         set pid10 [lindex $fields 10]

                         set pid15 [lindex $fields 15]

                         set msh3 $hmsId

                         set npid3 “”

                     set pid3 [lindex $fields 3]

                     append npid3 $pid3 $sub_sep $sub_sep $sub_sep “HMS” $msh3 $sub_sep “MR”

                     catch {set fields [lreplace $fields 3 3 $npid3]}

                     if {$toSys == “HMM”} {

                        # PID 10 table lookup

                       if {$pid10 != “”} {

                               set val1 “”

                               set val1 [tbllookup -side input hmshmm_race $pid10]

                               if {![cequal $val1 “”]} {

                                  catch {set fields [lreplace $fields 10 10 $val1]}

                               }

                            }

                            #    extract PID-15 (Language code).

                            if {$pid15 != “”} {

                               set val2 “”

                               set val2 [tbllookup -side input hmshmm_lang $pid15]

                               if {![cequal $val2 “”]} {

                                  catch {set fields [lreplace $fields 15 15 $val2]}

                               }

                            }

                         }

                     # SSN formatting.

                     set pid19 [lindex $fields 19]

                     if {$pid19 != “”} {

                        if {[string length $pid19] > 9} {

                         set nssn “”

                         set pid19_1 [csubstr $pid19 0 3]

                         set pid19_2 [csubstr $pid19 3 2]

                         set pid19_3 [csubstr $pid19 5 4]

                         #

                         if {($pid19 == “888-88-8888”) || ($pid19 == “999-99-9999”)} {

                            catch {set fields [lreplace $fields 19 19 “”]}

                         } else {

                            append nssn $pid19_1 “-” $pid19_2 “-” $pid19_3

                            catch {set fields [lreplace $fields 19 19 $nssn]}

                         }

                        }

                     }

                     # blank out PID-18 for ONLY A34.

                     if {$msg_type_2 == “A34”} {

                      catch {set fields [lreplace $fields 18 18 “”]}

                     }

                     set pid23 [lindex $fields 23]

                   set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      PD1 {

                         #set pd1_4 [lindex $fields 4]

                         set pd1_4_list [split [lindex $fields 4] $sub_sep]

                         set DocNumber_4_0 [lindex $pd1_4_list 0]

                         if {$DocNumber_4_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_4_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set pd1_4 [join [lreplace $pd1_4_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 4 4 $pv1_8]

                         }

                         set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      PV1 {

                         # Patient Class

                         set pv1_2 [lindex $fields 2]

                         # Assigned patient location

                         # .1 Nurse .2 Station/Point of care, .3 Room, .4 Bed,

                         # .5 facility, .6 location status, .7person location type,

                         # .8 building, .9 floor, .10 location description

                         set pv1_3 [lindex $fields 3]

                         set bed [lindex [split $pv1_3 $sub_sep] 2]

                         # Attending Doc

                         set pv1_7_list [split [lindex $fields 7] $sub_sep]

                         set DocNumber_7_0 [lindex $pv1_7_list 0]

                         if {$DocNumber_7_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_7_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set pv1_7 [join [lreplace $pv1_7_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 7 7 $pv1_7]

                         }

                         # Referring Doc

                         #set pv1_8 [lindex $fields 8]

                         set pv1_8_list [split [lindex $fields 8] $sub_sep]

                         set DocNumber_8_0 [lindex $pv1_8_list 0]

                         if {$DocNumber_8_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_8_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set pv1_8 [join [lreplace $pv1_8_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 8 8 $pv1_8]

                         }

                         # Consultinging Doc

                         #set pv1_9 [lindex $fields 9]

                         set pv1_9_list [split [lindex $fields 9] $sub_sep]

                         set DocNumber_9_0 [lindex $pv1_9_list 0]

                         if {$DocNumber_9_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_9_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set pv1_9 [join [lreplace $pv1_9_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 9 9 $pv1_9]

                         }

                         set pv1_10 [lindex $fields 10]

                         # re-formatting PV1-3.

                   if {($pv1_3 == $pv1_10) && ($pv1_2 == “O”)} {

                    set pv1_3 “”

                    append pv1_3 “OP”

                    catch {set fieldList [lreplace $fieldList 3 3 $pv1_3]}

                   }

                         set pv1_16 [lindex $fields 16]

                         # Admitting Doc

                         #set pv1_17 [lindex $fields 17]

                         set pv1_17_list [split [lindex $fields 17] $sub_sep]

                         set DocNumber_17_0 [lindex $pv1_17_list 0]

                         if {$DocNumber_17_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_17_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set pv1_17 [join [lreplace $pv1_17_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 17 17 $pv1_17]

                         }

                         set pv1_18 [lindex $fields 18]

                         # Visit Number

                         set pv1_19 [lindex $fields 19]

                         set pv1_45 [lindex $fields 45]

                   # Added code on 8/7/2008 to account for LAB and LAR in PV1-10.

               if {$toSys == “HLAB”} {

                  if {$pid23 != “” && $pv1_10 == “LFR”} {

                         catch {set fields [lreplace $fields 3 3 $pid23]}

                      } elseif {$pid23 != “” && $pv1_10 == “LAB”} {

                         catch {set fields [lreplace $fields 3 3 $pid23]}

                     } elseif {$pid23 != “” && $pv1_10 == “LAR”} {

                        catch {set fields [lreplace $fields 3 3 $pid23]}

                      } elseif {$pid23 != “” && $pv1_10 == “IND”} {

                         catch {set fields [lreplace $fields 3 3 $pid23]}

                      }

                   }

                   if {($toSys == “HCI”) && ($pv1_2 == “O”)} {

                            if {$pv1_18 != “E”} {

                               catch {set fields [lreplace $fields 18 18 $pv1_10]}

                            }

                         }

                         if {($toSys == “HCI”) && ([cequal $pv1_2 “I”] || [cequal $pv1_10 “EOP”])} {

                            catch {set fields [lreplace $fields 18 18 $pv1_10]}

                         }

                         ###########  HMM

                         if {$toSys == “HMM”} {

                            set it [tbllookup hmshmm_hospService $pv1_10]

                            if {$pv1_45 != “” && $msg_type_2 == “A08” && $bed == “” && $pv1_2 == “O” && $pv1_18 == “E” && $it == 0} {

                               catch {set fieldList [lreplace $fieldList 45 45 “”]}

                            }

                            # code below is added on June 2, 2008.

                            catch {set fieldList [lreplace $fieldList 18 18 $pv1_10]}

       

                            # code below is added on June 19, 2008. RQ by Jawad.

                            if {$msg_type_2 == “A05”} {

                               catch {set fieldList [lreplace $fieldList 44 44 $pv2_8]}

                            }

                         }

                         #

                         set segment [join $fields $field_sep]

                         append newMsg ${segment}r

                      }

                      PV2 {

                         set pv2_8 [lindex $fields 8]

                         if {$msg_type_2 == “A11”} {

                            catch {set fields [lreplace $fields 8 8 “”””]}

                         }

                         if {($toSys == “HCI”) && ($pv1_16 != “”)} {

                            catch {set fields [lreplace $fields 21 21 $pv1_16]}

                         }

                         catch {set fields [lreplace $fields 18 18 $pv1_10]}

                         set segment [join $fields $field_sep]

                         append newMsg ${segment}r

                      }

                      NK1 {

                         set segment [join $fields $field_sep]

                         if {$toSys == “HCI”} {

                            set resetNk1 1

                            append tempvar ${segment}r

                         } else {

                            append newMsg ${segment}r

                         }

                      }

                      ORC {

                         # Ordering Doc

                         set orc_12_list [split [lindex $fields 12] $sub_sep]

                         set DocNumber_12_0 [lindex $orc_12_list 0]

                         if {$DocNumber_12_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_12_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set orc_12 [join [lreplace $orc_12_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 12 12 $orc_12]

                         }

                         #To go back and change  ORC.2 to Unique ID

                         if {($toSys == “HCI”) && ([regexp $msg_type_1 “ORU|ORM|BAR”])} {

                            set resetOrc 1

                         }

                         set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      OBR {

                         set obr2 [lindex $fields 2]

                     # Remove trailing sub seperator in OBR.2

                     set obr2 [lindex $fields 2]

                     catch {set obr2 [string trimright $obr2 $sub_sep]}

                     catch {set fields [lreplace $fields 2 2 $obr2]}

                     #

                     if {$toSys == “HOM”} {

                       set obr4 [lindex $fields 4]

                        set obr4_1 [lindex [split $obr4 ^] 0]

                        set obr4_3 [lindex [split $obr4 ^] 2]

                        if {$obr4_1 != “”} {

                           set obr4_x [csubstr $obr4_1 0 3]

                           set retval [tbllookup chs_hrmhom_icd9.tbl $obr4_x]

                           catch {set fields [lreplace $fields 2 2 $retval]}

                         

                        }

                     }

                     # Ordering Doc

                         set obr_16_list [split [lindex $fields 16] $sub_sep]

                         set DocNumber_16_0 [lindex $obr_16_list 0]

                         if {$DocNumber_16_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_16_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set obr_16 [join [lreplace $obr_16_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 16 16 $obr_16]

                         }

                         # Unique Id for HCI from OBR.20

                         # To go into OBR.2 and ORC.2

                     set segment [join $fields $field_sep]

                     if {($toSys == “HCI”) && ([regexp $msg_type_1 “ORU|ORM|BAR”])} {

                        set obr_20 [lindex $fields 20]

                        catch {set fields [lreplace $fields 2 2 $obr_20]}

                     }

                         set segment [join $fields $field_sep]

                         append newMsg ${segment}r

                  }

                  OBX {

                     set segment [join $fields $field_sep]

                     append newMsg ${segment}r

                  }

                  ACC {

                     set acc_1 [lindex $fields 1]

                     if {$acc_1 != “”} {

                        set segment [join $fields $field_sep]

                        append newMsg ${segment}r

                     }

                  }

                  GT1 {

                     set gt1_12 [lindex $fields 12]

                     if {[string length $gt1_12] == 9} {

                      set ngt1_12 “”

                      set gt1_12_1 [csubstr $gt1_12 0 3]

                      set gt1_12_2 [csubstr $gt1_12 3 2]

                      set gt1_12_3 [csubstr $gt1_12 5 4]

                      #

                      append ngt1_12 $gt1_12_1 “-” $gt1_12_2 “-” $gt1_12_3

                      catch {set fieldList [lreplace $fields 12 12 $ngt1_12]}

                     }

                     set segment [join $fields $field_sep]

                     append newMsg ${segment}r

                  }

                  FT1 {

                     if {$msg_type_1 == “DFT”} {

                        set ft1_10 [lindex $fields 10]

                        # Don’t do anything if FT1-10 is less then 999.

                        if {$ft1_10 > 999} {

                           # determine the number of FT1 segments that need to be created.

                               set tempvar “”

                               set i 1

                               set ncnt [expr $ft1_10 / 999]

                               set remainder [expr $ft1_10 % 999]

                               while {$i <= $ncnt} {

                                  catch {set fields [lreplace $fields 10 10 “999”]}

                                  catch {set fields [lreplace $fields 1 1 $i]}

                                  set segment [join $fields $field_sep]

                                  append newMsg ${segment}r

                                  incr i

                               }

                               # NOW create the FT1-segment with the remainder value.

                               if {$remainder != 0} {

                                  catch {set fields [lreplace $fields 10 10 $remainder]}

                                  catch {set fields [lreplace $fields 1 1 $i]}

                                  set segment [join $fields $field_sep]

                                  append newMsg ${segment}r

                               }

                            }

                         }

                      }

                      MFE {

                         #set mfe_4 [lindex $fields 4]

                         set mfe_4_list [split [lindex $fields 4] $sub_sep]

                         set DocNumber_4_0 [lindex $mfe_4_list 0]

                         if {$DocNumber_4_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_4_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set mfe_4 [join [lreplace $mfe_4_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 4 4 $mfe_4]

                         }

                         set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      PR1 {

                         #set pr1_11 [lindex $fields 11]

                         set pr1_11_list [split [lindex $fields 11] $sub_sep]

                         set DocNumber_11_0 [lindex $pr1_11_list 0]

                         if {$DocNumber_11_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_11_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set pr1_11 [join [lreplace $pr1_11_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 11 11 $pr1_11]

                         }

                         set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      PRA {

                         #set pra_1 [lindex $fields 1]

                         set pra_1_list [split [lindex $fields 1] $sub_sep]

                         set DocNumber_1_0 [lindex $pra_1_list 0]

                         if {$DocNumber_1_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_1_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set pra_1 [join [lreplace $pra_1_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 1 1 $pra_1]

                         }

                         set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      STF {

                         #set stf_1 [lindex $fields 1]

                         set stf_1_list [split [lindex $fields 1] $sub_sep]

                         set DocNumber_1_0 [lindex $stf_1_list 0]

                         if {$DocNumber_1_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_1_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set stf_1 [join [lreplace $stf_1_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 1 1 $stf_1]

                         }

                         #set stf_2 [lindex $fields 2]

                         set stf_2_list [split [lindex $fields 2] $sub_sep]

                         set DocNumber_2_0 [lindex $stf_2_list 0]

                         if {$DocNumber_2_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_2_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set stf_2 [join [lreplace $stf_2_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 2 2 $stf_2]

                         }

                         if {$msg_type_1 == “MFN”} {

                            set stf10 [lindex $fields 10]

                            set stf10_list [split $stf10 $ssub_sep]

                            if {$stf10 != “”} {

                               set nval “”

                               set wpn “”

                               set orn “”

                               set bpn “”

                               set prn “”

                               #

                               foreach x $stf10_list {

                                  if {$x != “”} {

                                  set x_list [split $x $sub_sep]

                                  set x_1 [lindex $x_list 0]

                                  set x_2 [lindex $x_list 1]

                                  set x_3 [lindex $x_list 2]

                                  if {$x_2 == “WPN”} {

                                     append wpn $x_1 “CO”

                                  }

                                  if {$x_2 == “ORN”} {

                                     append orn $x_1 “CF”

                                  }

                                  if {$x_2 == “BPN”} {

                                     append bpn $x_1 “CB”

                                  }

                                  if {$x_2 == “PRN”} {

                                     append prn $x_1 “CH”

                                  }

                               }

                            }

                            append nval $wpn $ssub_sep $orn $ssub_sep $bpn $ssub_sep $prn

                            catch {set fields [lreplace $fields 10 10 $nval]}

                            }

                         }

                         set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      MRG {

                         set mrg1 [lindex $fields 1]

                         append nmrg1 $mrg1 $sub_sep $sub_sep $sub_sep “HMS” $msh3 $sub_sep

                         catch {set fields [lreplace $fields 1 1 $nmrg1]}

                         if {$msg_type_2 == “A35”} {

                    catch {set fields [lreplace $fields 1 1 $npid3]}

                   }

                   set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                      }

                      ZEM {

                     #set fields [split $segment $field_sep]

                     set zem1 [lindex $fields 1]

                     set zem1_1 “”

                     if {$zem1 != “”} {

                      set zem_1_1 [lindex [split $zem1 $sub_sep] 1]

                        set zem2 [lindex [split $zem1 $sub_sep] 2]

                        set segment “ZPI|1||||||||||||||$zem1_1|$zem2|”

                        append newMsg ${segment}r

                         }

                  }

                  ZIT {

                     if {$toSys == “HSM”} {

                        set zit18 [lindex $fields 18]

                        if {$zit18 != “”} {

                         set retval [tbllookup -side input chs_hmshsm.tbl $zit18]

                         catch {set fields [lreplace $fields 33 33 $retval]}

                        }

                     }

                     set segment [join $fields $field_sep]

                   append newMsg ${segment}r

                  }

                  ZMF {

                     #set zmf_1 [lindex $fields 1]

                     set zmf_1_list [split [lindex $fields 1] $sub_sep]

                         set DocNumber_1_0 [lindex $zmf_1_list 0]

                         if {$DocNumber_1_0 != “”} {

                            set nDocNum [x_prepenZeros 5 $DocNumber_1_0]

                            set replaceDocNum “”

                            append replaceDocNum $hmsId $nDocNum

                            set zmf_1 [join [lreplace $zmf_1_list 0 0 $replaceDocNum] $sub_sep]

                            set fields [lreplace $fields 1 1 $zmf_1]

                         }

                  }

                  default {

                         if {$seg != “”} {

                            puts “Untouched Segment: [lindex $fields 0]”

                            set segment [join $fields $field_sep]

                      append newMsg ${segment}r

                   }

                  }

               }

            }

                # If NK1 present and toSys is HCI; place NK1 prior to PV1

                if {$resetNk1 == “1”} {

                   set msg [split $newMsg r]

                   set newMsg “”

                   foreach seg $msg {

                      set type [csubstr $seg 0 3]

                      switch -exact — $type {

                         PV1 {

                           append newMsg ${tempvar}

                           append newMsg ${seg}r

                         }

                         default {

                           append newMsg ${seg}r

                         }

                      }

                   }

               

                }

                #To go back and change  ORC.2 to Unique ID

                # if $resetOrc == 1

                if {$resetOrc == “1”} {

                   set msg [split $newMsg r]

                   set newMsg “”

                   foreach seg $msg {

                      set type [csubstr $seg 0 3]

                      switch -exact — $type {

                         ORC {

                           catch {set fields [lreplace $fields 2 2 $obr_20]}

                           append newMsg ${seg}r

                         }

                         default {

                           append newMsg ${seg}r

                         }

                      }

                   }

               

                }

               

                msgset $mh $newMsg

                lappend dispList “CONTINUE $mh”

             }

             time {

                # Timer-based processing

                # N.B.: there may or may not be a MSGID key in args

             }

             shutdown {

                # Doing some clean-up work

           }

         }

         return $dispList

      }

    • #66784

      Wow. Your life would be so much easier if you put most or all of that into an xlate.

      -- Max Drown (Infor)

    • #66785
      Eric Sligh
      Participant

      since we are building Variants and Xlates. We inherited this when we came in a couple months ago.

    • #66786

      Max Drown wrote:

      It could be as simple as …

      Code:

      set pv1_3 “[lindex $fields 3]^^^fooBar”

      Did you try this?

      -- Max Drown (Infor)

    • #66787
      Eric Sligh
      Participant

      I did and it still will not populate the field in the message.

    • #66788

      You’ll need this line, too:

      Code:

      catch {set fieldList [lreplace $fieldList 3 3 $pv1_3]}

      I copied that from lower down in the code in the only other place I could see that you are working with pv1_3.

      -- Max Drown (Infor)

    • #66789
      Eric Sligh
      Participant

      It is still not populating that subfield. Any other ideas?

    • #66790
      Anonymous
      Participant

      Looks like Max has the couple of lines you need.

      The important one is to replace the PV1_3 part of fieldList before you join and append it to the message.

      Is it working for you know ?

      It would be time well spent to put this into and Xlate where it all belongs. In this form I’m sure you know it is really not very supportable.

    • #66791
      Eric Sligh
      Participant

      We are eventually going to go back and build the variants and Xlates but for now we really don’t have the time to do it. I am going to try what you suggested and see if I can’t get it to work.

    • #66792
      Anonymous
      Participant

      If you are still having issues and can’t get it to work. Email me and I will see what I can do to help you.

      John.hamilton2@kelsey-seybold.com

    • #66793
      Robert Milfajt
      Participant

      Please don’t take this wrong, because many a time I have been caught by this.

      Did you bounce the thread/process to make sure the TCL code took effect?  I did not see what version of Cloverleaf you were on, but recall (and I could be wrong) an issue with reloading TCL procs and some versions.

      Hope this helps,

      Robert Milfajt
      Northwestern Medicine
      Chicago, IL

    • #66794
      Charlie Bursell
      Participant

      You are doing the lreplace inside of a catch which will hide any errors and the desired action does not occur.

      One of theproblems with lreplace, which has been discussed to no end within the Tcl community, is it will give you an error if you attempt to lreplace a field that does not exist.  If there is any doubt there will be enough fields, here is what I do.

      Assume you are to lreplace field 5 (0-based) which is actually the 6th field:

       while {[llength $list] <= 6} { lappend list {} }

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

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,447
Topic Tags
288
Empty Topic Tags
10