discrete micro results

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf discrete micro results

  • Creator
    Topic
  • #51065
    Mason Miller
    Participant

      I need to know how I can change the order of OBX segment I am working on a discrete micro interface and all the OBX segment with the same test name in OBX.3 need to be grouped together here is an example of what I need to do

      Code:


      OBX|1|TX|RESPC^CULT SPUTUM/BRONCH WASH||Incubation in progress~Normal respiratory flora~Candida species noted||||||P
      OBX|2|TX|GRAM1^GRAM STAIN||Many WBC~Moderate Gram negative bacilli||||||F
      OBX|3|CE|RESPC^CULT SPUTUM/BRONCH WASH|1|Escherichia coli||||||P
      OBX|4|TX|RESPC^CULT SPUTUM/BRONCH WASH|1|Large amount~MIC pending||||||P
      OBX|5|CE|RESPC^CULT SPUTUM/BRONCH WASH|2|||||||P
      OBX|6|TX|RESPC^CULT SPUTUM/BRONCH WASH|2|Large amount~2nd Gram negative bacillus~ID/MIC pending||||||P

      to

      OBX|2|TX|GRAM1^GRAM STAIN||Many WBC~Moderate Gram negative bacilli||||||F
      OBX|1|TX|RESPC^CULT SPUTUM/BRONCH WASH||Incubation in progress~Normal respiratory flora~Candida species noted||||||P
      OBX|3|CE|RESPC^CULT SPUTUM/BRONCH WASH|1|Escherichia coli||||||P
      OBX|4|TX|RESPC^CULT SPUTUM/BRONCH WASH|1|Large amount~MIC pending||||||P
      OBX|5|CE|RESPC^CULT SPUTUM/BRONCH WASH|2|||||||P
      OBX|6|TX|RESPC^CULT SPUTUM/BRONCH WASH|2|Large amount~2nd Gram negative bacillus~ID/MIC pending||||||P

    Viewing 6 reply threads
    • Author
      Replies
      • #68651
        Mark Perschbacher
        Participant

          Mason, how are you at writing tcl code?  I wouldn’t think this would be too difficult.  You could copy OBX3.1 to a variable, and write a string match true or false.  If true, renumber OBX 2 with some type of math operation.

        • #68652
          Mason Miller
          Participant

            I can stumble my way though some tcl but not real strong I was going to see if someone had done anything simular and I could modify to work for me.

            Thanks

          • #68653
            David Barr
            Participant

              Something like this might work:

              set msg [msgget $mh]
              set fld_sep [string index $msg 3]
              set segs [split $msg r]
              set obx_segs [lsearch -inline -all $segs {^OBX}]
              set obx_nums [lsearch -all $segs {^OBX}]
              foreach seg $obx_segs {

              [code]set msg [msgget $mh]
              set fld_sep [string index $msg 3]
              set segs [split $msg r]
              set obx_segs [lsearch -inline -all $segs {^OBX}]
              set obx_nums [lsearch -all $segs {^OBX}]
              foreach seg $obx_segs {

            • #68654
              Mason Miller
              Participant

                thanks that worked but now I am running into an issue where I have repeating obr segments with obx segments under each I need to put something in where it will only sort the obx sements before the second obr.

                Thanks again this was very helpful

              • #68655
                Mason Miller
                Participant

                  if I have the a transaction like this example how could I just sort the OBX segments before the second OBR?

                  Code:

                  MSH|^~&|MIC|SCC|SMH||200906101314||ORU^R01|00000868|P|2.2
                  PID|||401919||UPGRADE^KATHY^G||19550505|F||W||||||||100324136
                  PV1|1|I|NTIU^NT43^A0||100324136||005538||||||||||005538
                  ORC|RE|160434^LAB^1|821|F0100005|||^^^20090610^^R||200906100956|KFG||005538
                  OBR||160434^LAB^1|821|URNC^URINE CULTURE^^LAB0173|||200906100800|||NSG||||200906100956|UILEO^^Ileoconduit|005538||||||||MICRO|F||^^^20090610^^R
                  OBX|1|CE|URNC^URINE CULTURE|1|Klebsiella pneumoniae||||||F
                  OBX|2|TX|GRAM^URINE CULTURE|1|Colony count: >100,000 col/ml||||||F
                  OBX|3|CE|URNC^URINE CULTURE|2|Escherichia coli||||||F
                  OBX|4|TX|URNC^URINE CULTURE|2|Colony count: >100,000 col/ml||||||F
                  OBX|5|CE|URNC^URINE CULTURE|3|Candida albicans||||||F
                  OBX|6|TX|URNC^URINE CULTURE|3|Colony count: >100,000 col/ml||||||F
                  OBR|2|||MIC||||||||||||||||||||||^1
                  OBX|1|ST|Aug^Amox/K Clav’ate|1||mcg/mL||S
                  OBX|2|ST|A/S^Amp/Sulbactam|1||mcg/mL||S
                  OBX|3|ST|Am^Ampicillin|1||mcg/mL||S
                  OBX|4|ST|Azt^Aztreonam|1||mcg/mL||I
                  OBX|5|ST|Cfz^Cefazolin|1||mcg/mL||I
                  OBX|6|ST|Cpe^Cefepime|1||mcg/mL||R
                  OBX|7|ST|Cft/CA^Cefotaxime/K Clavulanate|1||mcg/mL||BLAC
                  OBX|8|ST|Caz/CA^Ceftazidime/K Clavulanate|1||mcg/mL||S
                  OBX|9|ST|Cax^Ceftriaxone|1||mcg/mL||R
                  OBX|10|ST|Cf^Cephalothin|1||mcg/mL||R*
                  OBX|11|ST|Cip^Ciprofloxacin|1||mcg/mL||ESBL
                  OBX|12|ST|Gm^Gentamicin|1||mcg/mL||BLAC
                  OBX|13|ST|Imp^Imipenem|1||mcg/mL||S
                  OBX|14|ST|Lvx^Levofloxacin|1||mcg/mL||S
                  OBX|15|ST|Fd^Nitrofurantoin|1||mcg/mL||S
                  OBX|16|ST|P/T^Piperacillin/Taz|1||mcg/mL||S
                  OBX|17|ST|Te^Tetracycline|1||mcg/mL||S
                  OBX|18|ST|To^Tobramycin|1||mcg/mL||S
                  OBX|19|ST|T/S^Trimeth/Sulfa|1||mcg/mL||S
                  OBX|20|ST|T^Trimethoprim|1||mcg/mL||S
                  OBR|3|||MIC||||||||||||||||||||||^2
                  OBX|1|ST|Aug^Amox/K Clav’ate|2||mcg/mL||S
                  OBX|2|ST|A/S^Amp/Sulbactam|2||mcg/mL||S
                  OBX|3|ST|Am^Ampicillin|2||mcg/mL||S
                  OBX|4|ST|Azt^Aztreonam|2||mcg/mL||S
                  OBX|5|ST|Cfz^Cefazolin|2||mcg/mL||S
                  OBX|6|ST|Cpe^Cefepime|2||mcg/mL||S
                  OBX|7|ST|Cft/CA^Cefotaxime/K Clavulanate|2||mcg/mL||R
                  OBX|8|ST|Caz/CA^Ceftazidime/K Clavulanate|2||mcg/mL||R
                  OBX|9|ST|Cax^Ceftriaxone|2||mcg/mL||S
                  OBX|10|ST|Cf^Cephalothin|2||mcg/mL||S
                  OBX|11|ST|Cip^Ciprofloxacin|2||mcg/mL||I
                  OBX|12|ST|Gm^Gentamicin|2||mcg/mL||R*
                  OBX|13|ST|Imp^Imipenem|2||mcg/mL||ESBL
                  OBX|14|ST|Lvx^Levofloxacin|2||mcg/mL||BLAC
                  OBX|15|ST|Fd^Nitrofurantoin|2||mcg/mL||S
                  OBX|16|ST|P/T^Piperacillin/Taz|2||mcg/mL||S
                  OBX|17|ST|Te^Tetracycline|2||mcg/mL||S
                  OBX|18|ST|To^Tobramycin|2||mcg/mL||S
                  OBX|19|ST|T/S^Trimeth/Sulfa|2||mcg/mL||S
                  OBR|3|||MIC||||||||||||||||||||||^3

                • #68656
                  Mason Miller
                  Participant

                    Here is what I have but now I need something that says only sort the ones that z is equal to or less than obx1

                    Code:

                    run {
                               # ‘run’ mode always has a MSGID; fetch and process it
                               
                                set mh [keylget args MSGID]

                    set msg [msgget $mh]
                    set fld_sep [string index $msg 3]
                    set segs [split $msg r]
                    set obx_segs [lsearch -inline -all $segs {OBX*}]
                    set obx_nums [lsearch -all $segs {OBX*}]
                    set z 0

                    foreach line $obx_segs {
                    set line2 [split $line $fld_sep]
                    set obx1 [lindex $line2 1]
                    incr z

                    puts $obx1
                    puts $z}
                    foreach seg $obx_segs {
                    lappend obx_segs2 [split $seg $fld_sep]
                    }
                    # sort with OBX.3 as the key
                    set obx_segs2 [lsort -index 3 $obx_segs2]  
                    for { set i 0 } { $i < [llength $obx_segs2] } { incr i } {
                    set j [lindex $obx_nums $i]
                        set segs [lreplace $segs $j $j [join [lindex $obx_segs2 $i] $fld_sep]]
                    }

                    msgset $mh [join $segs r]

                     lappend dispList "CONTINUE $mh"
                           }

                  • #68657
                    Mason Miller
                    Participant

                      I figured it out Thanks for your help!!

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