Noob Help.

  • Creator
    Topic
  • #50477
    Ian Morris
    Participant

    Ultimately, I’m trying to use a split to break up a message to find each OBX segment.  However, for this example I’m just trying to get some out put for each {} in the List.  I’m having a problem with running the foreach on my seglist.

    Here’s an example of the top part of the code.

    Code:


    proc filter_FCHCMuse { args } {
    keylget args MODE mode  ;# Extract the operation mode from the run params
       set dispList {}         ;# Initialize the proc result list

       switch -exact — $mode {
           start {
           }

           run {
             # Extract the HL7 message “handle”
             keylget args MSGID mh
             # Derive the message type
             set HL7Msg   [msgget $mh]
     set FldSep   [cindex $HL7Msg 3]
             set SubSep   [cindex $HL7Msg 4]
             set SegList  [split $HL7Msg r]
     foreach sl [$SegList]{
     echo hello
     }

    Here’s the message I’m trying to process

    Code:


    MSH|^~&|ADM||||200811191057||ADT^A04|133785|D|2.2|||AL|NE
    EVN|A04|200811191057
    PID|1|HSMTVD0000054|H000036|H41|MOUSE^MICKEY^^^^||19470101|M|^^^^^|CA|11011 MAIN ST^^ORLANDO^FL^12358||(555)555-1111|(717)263-9281||M||H00000023358|888-88-8888||
    NK1|1|MOUSE^MINNIE^^^^|WI^01 WIFE|11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111||NOK
    NK1|2|DUCK^DONALD^^^^|FR^21 FRIEND|11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111||NOT
    NK1|3|CHBGAREA||435 STANLEY AVE^^CHAMBERSBURG^PA^17201||(717)263-9281|EMP|||FT|||CHAMBERSBURG AREA SCHOOL DIST|||||||||||||||||||||FT
    PV1|1|O|KFCHC^^|EL|||HESSR^Hess^Reuben^D^^^M.D.|||||||PHY||||CLI||WC|||||||||||||||||||KPS||REG|||200811191053||||||||HESSR^Hess^Reuben^D^^^M.D.|
    PV2|||WORK INJURY
    OBX|1|CE|ZADCALLAH2^Is patient a Call-Ahead?^ADM||N^Not a Call Ahead||||||F
    OBX|2|CE|ZADCOUNTY2^Enter county of patient:^ADM||FRANKLIN^Franklin County||||||F
    OBX|3|TX|ZADECF^Is Patient a transfer from an Extended Care Facility?^ADM||||||||F
    OBX|4|TX|ZADHISPAN2^Is Patient of Hispanic or Latino Origin?^ADM||N||||||F
    OBX|5|TX|ZADINSCOMM^Verified Information^ADM||ADJUSTER IS HOMER SIMPSON 717-123-4562 CLAIM~#123456 DOI 10/05/08||||||F
    OBX|6|TX|ZADINTRP^Interpreter Needed?^ADM||N||||||F
    OBX|7|TX|ZKPSEKG^WILL PATIENT HAVE AN EKG?^ADM||Y||||||F
    OBX|8|TX|ZADMCRNOT9^Comment^ADM||||||||F
    OBX|9|TX|ZADMRSA^Have you ever had the infectious bacteria MRSA?^ADM||N||||||F
    OBX|10|TX|ZADPRIV1^Date Privacy Notice Was Given:^ADM||20080320||||||F
    OBX|11|TX|ZADPRIV2^Was Privacy Acknowledgement Form Refused?^ADM||N||||||F
    OBX|12|TX|ZADPRIV3^Reason Patient or Representative Refused to Sign:^ADM||||||||F
    OBX|13|TX|ZADTREATM2^Is patient part of a treatment plan?^ADM||||||||F
    OBX|14|TX|ZADVRE^Have you ever had the infectious bacteria, VRE?^ADM||N||||||F
    OBX|15|TX|ZADEFFDAT2^ ^INS^^^MAACCPLUS||20081119||||||F
    OBX|16|TX|ZADHCB2^ ^INS^^^MAACCPLUS||02||||||F
    OBX|17|TX|ZADMAELIG2^Verified eligibility on EVS (Y/N):^INS^^^MAACCPLUS||Y||||||F
    OBX|18|TX|ZADMAELIG3^Date Verified:^INS^^^MAACCPLUS||20081119||||||F
    OBX|19|TX|ZADMAPSC^ ^INS^^^MAACCPLUS||00||||||F
    OBX|20|TX|ZADMMACA^Enter:^INS^^^MAACCPLUS||PH||||||F
    AL1|1|DA^^^Allergy|F006000568^Peanut^CODED|SV|SWELLING|20080722
    AL1|2|DA^^^Allergy|F006000593^Digoxin^CODED|SV|PATIENT UNSURE|20080722
    AL1|3|DA^^^Allergy|F006001550^Codeine^CODED|SV|NAUSEA AND VOMITING|20080722
    AL1|4|DA^^^Allergy|F006002084^Warfarin^CODED|SV|SHORTNESS OF BREATH|20080722
    AL1|5|DA^^^Allergy|F006002307^Furosemide^CODED|SV|HIVES|20080722
    AL1|6|DA^^^Allergy|F006002373^Indomethacin^CODED^From Indocin^^allergy.id|SV|PATIENT DENIES|20080722
    AL1|7|DA^^^Allergy|F006003476^Omeprazole^CODED|SV|RASH & SWELLING & HIVES|20080722
    AL1|8|DA^^^Allergy|F006003675^Amoxicillin^CODED|SV|HIVES|20080722
    AL1|9|DA^^^Allergy|F006006006^Pantoprazole^CODED|SV|RASH|20080722
    AL1|10|DA^^^Allergy|F006008393^Chocolate Flavor^CODED|SV|PATIENT UNRESPONSIVE|20080722
    AL1|11|^^^Allergy|ACET^ACET^UNCODED|SV|NAUSEA AND VOMITING|20080722
    GT1|1||MOUSE^MICKEY||11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111|||||SP|888-88-8888||||CHBGAREA|435 STANLEY AVE^^CHAMBERSBURG^PA^17201|(717)263-9281||FT|
    IN1|1|WCPMA||PMA MEDICAL BILL PAYMENT|PO BOX 2854^^CLINTON^IA^52733-2854||(888)476-2669||||CHAMBERSBURG SCHOOL DSTRICT|||||DISTRICT^CHAMBERSBURG^SCHOOL^^^|EM||||||||||||20081119|WMUMMA||||||123456||||||FT^1 FULL-TIME EMPLOYED|||QUEUED
    IN1|2|MAACCPLUS||MED ASSIST ACCESS PLUS|PO BOX 8013^^HARRISBURG^PA^17105||||||RE|||||MOUSE^MICKEY^^^^|SP||||||||||||20081119|WMUMMA||||||7894561230||||||RE^5 RETIRED|||QUEUED
    UB2|||||||04^20081005

    Here’s the error I’m getting

    Code:


    result = ‘invalid command name “{MSH|^~&|ADM||||200811191057||ADT^A04|133785|D|2.2|||AL|NE} EVN|A04|200811191057 {PID|1|HSMTVD0000054|H000036|H41|MOUSE^MICKEY^^^^||19470101|M|^^^^^|CA|11011 MAIN ST^^ORLANDO^FL^12358||(555)555-1111|(717)263-9281||M||H00000023358|888-88-8888||} {NK1|1|MOUSE^MINNIE^^^^|WI^01 WIFE|11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111||NOK} {NK1|2|DUCK^DONALD^^^^|FR^21 FRIEND|11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111||NOT} {NK1|3|CHBGAREA||435 STANLEY AVE^^CHAMBERSBURG^PA^17201||(717)263-9281|EMP|||FT|||CHAMBERSBURG AREA SCHOOL DIST|||||||||||||||||||||FT} PV1|1|O|KFCHC^^|EL|||HESSR^Hess^Reuben^D^^^M.D.|||||||PHY||||CLI||WC|||||||||||||||||||KPS||REG|||200811191053||||||||HESSR^Hess^Reuben^D^^^M.D.| {PV2|||WORK INJURY} {OBX|1|CE|ZADCALLAH2^Is patient a Call-Ahead?^ADM||N^Not a Call Ahead||||||F} {OBX|2|CE|ZADCOUNTY2^Enter county of patient:^ADM||FRANKLIN^Franklin County||||||F} {OBX|3|TX|ZADECF^Is Patient a transfer from an Extended Care Facility?^ADM||||||||F} {OBX|4|TX|ZADHISPAN2^Is Patient of Hispanic or Latino Origin?^ADM||N||||||F} {OBX|5|TX|ZADINSCOMM^Verified Information^ADM||ADJUSTER IS HOMER SIMPSON 717-123-4562 CLAIM~#123456 DOI 10/05/08||||||F} {OBX|6|TX|ZADINTRP^Interpreter Needed?^ADM||N||||||F} {OBX|7|TX|ZKPSEKG^WILL PATIENT HAVE AN EKG?^ADM||Y||||||F} OBX|8|TX|ZADMCRNOT9^Comment^ADM||||||||F {OBX|9|TX|ZADMRSA^Have you ever had the infectious bacteria MRSA?^ADM||N||||||F} {OBX|10|TX|ZADPRIV1^Date Privacy Notice Was Given:^ADM||20080320||||||F} {OBX|11|TX|ZADPRIV2^Was Privacy Acknowledgement Form Refused?^ADM||N||||||F} {OBX|12|TX|ZADPRIV3^Reason Patient or Representative Refused to Sign:^ADM||||||||F} {OBX|13|TX|ZADTREATM2^Is patient part of a treatment plan?^ADM||||||||F} {OBX|14|TX|ZADVRE^Have you ever had the infectious bacteria, VRE?^ADM||N||||||F} {OBX|15|TX|ZADEFFDAT2^ ^INS^^^MAACCPLUS||20081119||||||F} {OBX|16|TX|ZADHCB2^ ^INS^^^MAACCPLUS||02||||||F} {OBX|17|TX|ZADMAELIG2^Verified eligibility on EVS (Y/N):^INS^^^MAACCPLUS||Y||||||F} {OBX|18|TX|ZADMAELIG3^Date Verified:^INS^^^MAACCPLUS||20081119||||||F} {OBX|19|TX|ZADMAPSC^ ^INS^^^MAACCPLUS||00||||||F} OBX|20|TX|ZADMMACA^Enter:^INS^^^MAACCPLUS||PH||||||F AL1|1|DA^^^Allergy|F006000568^Peanut^CODED|SV|SWELLING|20080722 {AL1|2|DA^^^Allergy|F006000593^Digoxin^CODED|SV|PATIENT UNSURE|20080722} {AL1|3|DA^^^Allergy|F006001550^Codeine^CODED|SV|NAUSEA AND VOMITING|20080722} {AL1|4|DA^^^Allergy|F006002084^Warfarin^CODED|SV|SHORTNESS OF BREATH|20080722} AL1|5|DA^^^Allergy|F006002307^Furosemide^CODED|SV|HIVES|20080722 {AL1|6|DA^^^Allergy|F006002373^Indomethacin^CODED^From Indocin^^allergy.id|SV|PATIENT DENIES|20080722} {AL1|7|DA^^^Allergy|F006003476^Omeprazole^CODED|SV|RASH & SWELLING & HIVES|20080722} AL1|8|DA^^^Allergy|F006003675^Amoxicillin^CODED|SV|HIVES|20080722 AL1|9|DA^^^Allergy|F006006006^Pantoprazole^CODED|SV|RASH|20080722 {AL1|10|DA^^^Allergy|F006008393^Chocolate Flavor^CODED|SV|PATIENT UNRESPONSIVE|20080722} {AL1|11|^^^Allergy|ACET^ACET^UNCODED|SV|NAUSEA AND VOMITING|20080722} {GT1|1||MOUSE^MICKEY||11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111|||||SP|888-88-8888||||CHBGAREA|435 STANLEY AVE^^CHAMBERSBURG^PA^17201|(717)263-9281||FT|} {IN1|1|WCPMA||PMA MEDICAL BILL PAYMENT|PO BOX 2854^^CLINTON^IA^52733-2854||(888)476-2669||||CHAMBERSBURG SCHOOL DSTRICT|||||DISTRICT^CHAMBERSBURG^SCHOOL^^^|EM||||||||||||20081119|WMUMMA||||||123456||||||FT^1 FULL-TIME EMPLOYED|||QUEUED} {IN1|2|MAACCPLUS||MED ASSIST ACCESS PLUS|PO BOX 8013^^HARRISBURG^PA^17105||||||RE|||||MOUSE^MICKEY^^^^|SP||||||||||||20081119|WMUMMA||||||7894561230||||||RE^5 RETIRED|||QUEUED} UB2|||||||04^20081005″‘
    errorInfo: ‘
    invalid command name “{MSH|^~&|ADM||||200811191057||ADT^A04|133785|D|2.2|||AL|NE} EVN|A04|200811191057 {PID|1|HSMTVD0000054|H000036|H41|MOUSE^MICKEY^^^^||19470101|M|^^^^^|CA|11011 MAIN ST^^ORLANDO^FL^12358||(555)555-1111|(717)263-9281||M||H00000023358|888-88-8888||} {NK1|1|MOUSE^MINNIE^^^^|WI^01 WIFE|11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111||NOK} {NK1|2|DUCK^DONALD^^^^|FR^21 FRIEND|11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111||NOT} {NK1|3|CHBGAREA||435 STANLEY AVE^^CHAMBERSBURG^PA^17201||(717)263-9281|EMP|||FT|||CHAMBERSBURG AREA SCHOOL DIST|||||||||||||||||||||FT} PV1|1|O|KFCHC^^|EL|||HESSR^Hess^Reuben^D^^^M.D.|||||||PHY||||CLI||WC|||||||||||||||||||KPS||REG|||200811191053||||||||HESSR^Hess^Reuben^D^^^M.D.| {PV2|||WORK INJURY} {OBX|1|CE|ZADCALLAH2^Is patient a Call-Ahead?^ADM||N^Not a Call Ahead||||||F} {OBX|2|CE|ZADCOUNTY2^Enter county of patient:^ADM||FRANKLIN^Franklin County||||||F} {OBX|3|TX|ZADECF^Is Patient a transfer from an Extended Care Facility?^ADM||||||||F} {OBX|4|TX|ZADHISPAN2^Is Patient of Hispanic or Latino Origin?^ADM||N||||||F} {OBX|5|TX|ZADINSCOMM^Verified Information^ADM||ADJUSTER IS HOMER SIMPSON 717-123-4562 CLAIM~#123456 DOI 10/05/08||||||F} {OBX|6|TX|ZADINTRP^Interpreter Needed?^ADM||N||||||F} {OBX|7|TX|ZKPSEKG^WILL PATIENT HAVE AN EKG?^ADM||Y||||||F} OBX|8|TX|ZADMCRNOT9^Comment^ADM||||||||F {OBX|9|TX|ZADMRSA^Have you ever had the infectious bacteria MRSA?^ADM||N||||||F} {OBX|10|TX|ZADPRIV1^Date Privacy Notice Was Given:^ADM||20080320||||||F} {OBX|11|TX|ZADPRIV2^Was Privacy Acknowledgement Form Refused?^ADM||N||||||F} {OBX|12|TX|ZADPRIV3^Reason Patient or Representative Refused to Sign:^ADM||||||||F} {OBX|13|TX|ZADTREATM2^Is patient part of a treatment plan?^ADM||||||||F} {OBX|14|TX|ZADVRE^Have you ever had the infectious bacteria, VRE?^ADM||N||||||F} {OBX|15|TX|ZADEFFDAT2^ ^INS^^^MAACCPLUS||20081119||||||F} {OBX|16|TX|ZADHCB2^ ^INS^^^MAACCPLUS||02||||||F} {OBX|17|TX|ZADMAELIG2^Verified eligibility on EVS (Y/N):^INS^^^MAACCPLUS||Y||||||F} {OBX|18|TX|ZADMAELIG3^Date Verified:^INS^^^MAACCPLUS||20081119||||||F} {OBX|19|TX|ZADMAPSC^ ^INS^^^MAACCPLUS||00||||||F} OBX|20|TX|ZADMMACA^Enter:^INS^^^MAACCPLUS||PH||||||F AL1|1|DA^^^Allergy|F006000568^Peanut^CODED|SV|SWELLING|20080722 {AL1|2|DA^^^Allergy|F006000593^Digoxin^CODED|SV|PATIENT UNSURE|20080722} {AL1|3|DA^^^Allergy|F006001550^Codeine^CODED|SV|NAUSEA AND VOMITING|20080722} {AL1|4|DA^^^Allergy|F006002084^Warfarin^CODED|SV|SHORTNESS OF BREATH|20080722} AL1|5|DA^^^Allergy|F006002307^Furosemide^CODED|SV|HIVES|20080722 {AL1|6|DA^^^Allergy|F006002373^Indomethacin^CODED^From Indocin^^allergy.id|SV|PATIENT DENIES|20080722} {AL1|7|DA^^^Allergy|F006003476^Omeprazole^CODED|SV|RASH & SWELLING & HIVES|20080722} AL1|8|DA^^^Allergy|F006003675^Amoxicillin^CODED|SV|HIVES|20080722 AL1|9|DA^^^Allergy|F006006006^Pantoprazole^CODED|SV|RASH|20080722 {AL1|10|DA^^^Allergy|F006008393^Chocolate Flavor^CODED|SV|PATIENT UNRESPONSIVE|20080722} {AL1|11|^^^Allergy|ACET^ACET^UNCODED|SV|NAUSEA AND VOMITING|20080722} {GT1|1||MOUSE^MICKEY||11011 MAIN ST^^ORLANDO^FL^12358|(555)555-1111|||||SP|888-88-8888||||CHBGAREA|435 STANLEY AVE^^CHAMBERSBURG^PA^17201|(717)263-9281||FT|} {IN1|1|WCPMA||PMA MEDICAL BILL PAYMENT|PO BOX 2854^^CLINTON^IA^52733-2854||(888)476-2669||||CHAMBERSBURG SCHOOL DSTRICT|||||DISTRICT^CHAMBERSBURG^SCHOOL^^^|EM||||||||||||20081119|WMUMMA||||||123456||||||FT^1 FULL-TIME EMPLOYED|||QUEUED} {IN1|2|MAACCPLUS||MED ASSIST ACCESS PLUS|PO BOX 8013^^HARRISBURG^PA^17105||||||RE|||||MOUSE^MICKEY^^^^|SP||||||||||||20081119|WMUMMA||||||7894561230||||||RE^5 RETIRED|||QUEUED} UB2|||||||04^20081005”
       while executing
    “$SegList”

    I think the problem is that the List is getting messed up because if you look at the error you’ll see that some elements are not in “{}”.

    Any ideas?

    Thank you,

    Ian

Viewing 3 reply threads
  • Author
    Replies
    • #66249
      Jim Kosloskey
      Participant

      Ian,

      Instead of

      foreach sl [$SegList]{

          echo hello

          }

      Take the [] from around $SegList like this:

      foreach sl $SegList {

          echo $sl

          }

      I also changed the echo – ‘hello’ seemed useless.

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

    • #66250
      Ian Morris
      Participant

      Jim Kosloskey wrote:

      Ian,

      Instead of

      foreach sl [$SegList]{

          echo hello

          }

      Take the [] from around $SegList like this:

      foreach sl $SegList {

          echo $sl

          }

      I also changed the echo – ‘hello’ seemed useless.

      Thanks for your response.  When I don’t use the [] I get this error:

      Code:


      Tcl error:
      msgId = message0
      proc = ‘filter_FCHCMuse’
      args = ”
      result = ‘wrong # args: should be “foreach varList list ?varList list …? command”‘
      errorInfo: ‘
      wrong # args: should be “foreach varList list ?varList list …? command”
         while executing
      “foreach sl $SegList{”
         (”run” arm line 15)
         invoked from within
      “switch -exact — $mode {
             start {
             }

             run {
               # Extract the HL7 message “handle”
               keylget args MSGID mh

           …”
         (procedure “filter_FCHCMuse” line 5)
         invoked from within
      “filter_FCHCMuse {MSGID message0} {CONTEXT sms_ib_data} {ARGS {}} {MODE run} {VERSION 3.0}”‘

      I’m having a problem no matter which way I do it.

      Here is my full code…Top to bottom:

      Code:


      ######################################################################
      proc filter_FCHCMuse { args } {
         keylget args MODE mode  ;# Extract the operation mode from the run params
         set dispList {}         ;# Initialize the proc result list

         switch -exact — $mode {
             start {
             }

             run {
               # Extract the HL7 message “handle”
               keylget args MSGID mh

               # Derive the message type
               set HL7Msg   [msgget $mh]
      echo “HL7 Message————————-”
      echo $HL7Msg
               set FldSep   [cindex $HL7Msg 3]
               set SubSep   [cindex $HL7Msg 4]
               set SegList  [split $HL7Msg “r”]
      echo “SegList————————-”
      echo $SegList
      foreach sl $SegList{
      echo hello
      }

      set MSHSeg   [lindex $SegList 0]
                set FldList  [split $MSHSeg $FldSep]
               set MsgType  [lindex $FldList 8]
               set MsgType  [translit $SubSep “_” $MsgType]

               # Derive the patient’s location from the message
               set datList  [datlist] ;# Preserve the datum handle list
               set grmId    [grmcreate -msg $mh hl7 2.2 meditech $MsgType]

      #echo “————————-”
      set myData [grmfetch $grmId {0(0).PID.00105.[0]}]
      set myData2  [datget $myData VALUE]
      echo Patient is $myData2
      #echo “————————-”

               set grmData1 [grmfetch $grmId {0(0).PV1.00133.[0]}]
      echo Patient Location is [datget $grmData1 VALUE]
      set grmData2  [grmfetch $grmId {0(0).PV1.00169.[0]}]
      echo Patient Facility is [datget $grmData2 VALUE]
      #set grmData3  [grmfetch $grmId {0(0).OBX.00571}]
      set grmData3  [grmfetch $grmId {0(0).OBX.00571.[7]}]
      echo “—————-”
      echo [datget $grmData3 VALUE]
      echo “—————-”

      set grmData4  [grmfetch $grmId {0(0).OBX.00573.[0]}]
      echo Patient OBX 573 is [datget $grmData4 VALUE]

               set PTLoc  [datget $grmData1 VALUE]
      set Facility  [datget $grmData2 VALUE]
      #set Y  [datget $grmData3 VALUE]
      #set Z  [datget $grmData4 VALUE]

               # Set the filter to allow only OrderType CL.ACARDCATH
               if {[cequal $PTLoc “KFCHC”] && [cequal $Facility “KPS”]} {
                set Results “CONTINUE $mh”
               } else {
      echo Message for patient $myData2 was killed because ptloc=KFCHC and patfac=KPS
               set Results “KILL $mh”
               }

               # Clear memory resources
               grmdestroy $grmId
               hcidatlistreset $datList

               #Set the filtering result
               lappend dispList $Results
             }

             time {
             }
             
             shutdown {
             }

             default {
               error “Unknown mode ‘$mode’ passed to filter_FCHCMuse”
             }
         }

         return $dispList
      }

    • #66251
      John Mercogliano
      Participant

      Ian,

        Looking at the error you are missing a space after $SegList. Add a space between the variable and the {.

      John Mercogliano
      Sentara Healthcare
      Hampton Roads, VA

    • #66252
      Ian Morris
      Participant

      John Mercogliano wrote:

      Ian,

        Looking at the error you are missing a space after $SegList. Add a space between the variable and the {.

      John,

      You’re a genious.

      Thanks!

Viewing 3 reply threads
  • The forum ‘Tcl Library’ is closed to new topics and replies.

Forum Statistics

Registered Users
5,126
Forums
28
Topics
9,296
Replies
34,439
Topic Tags
287
Empty Topic Tags
10