Announcement

Collapse
No announcement yet.

Extract data from a single OBX segment based on word separators

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extract data from a single OBX segment based on word separators

    I am trying to figure out how to extract exam descriptions from an ORU message that will sometimes be separated by "and" or "\T\". The field will not always be on the same OBX line however will always follow "EXAM:" in OBX.5.1. There can be as many as 3 exam descriptions. I need to insert them into a MySQL database after separated. If it's easy to move them each into separate OBR fields I can then easily move them to the MySQL database.

    Any assistance would be greatly appreciated.

    For the examples below I am looking to get 3 separate entries
    CT abdomen without contrast
    CT pelvis without contrast
    CT chest without contrast

    Examples:


    OBX|7|ST|||EXAM: CT abdomen without contrast and CT pelvis without contrast and CT chest without contrast||||||P||||||
    OBX|8|ST|||||||||P||||||

    OBX|7|ST|||EXAM: CT abdomen without contrast \T\ and CT pelvis without contrast \T\ CT Chest without contrast||||||P||||||
    OBX|8|ST|||||||||P||||||

  • #2
    You can do this:

    Code:
    for each (obx in msg.OBX) {
    	var obsVal = new java.lang.String(obx['OBX.5']['OBX.5.1'].toString());
    	if (obsVal.startsWith('EXAM:')) {
    		for each (exam in obsVal.substring(5).split('and|\\\\T\\\\')) {
    			// Do something with exam.trim()
    		}
    	}
    }
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment


    • #3
      Thanks for that info! I am trying to figure out how to separate those 2 or 3 results from the split into separate OBR fields. I was looking to use some random OBR fields to throw them into then I can pull them into the DB. Thoughts anyone?
      Thanks!

      Comment


      • #4
        Originally posted by Jaypell22 View Post
        Thanks for that info! I am trying to figure out how to separate those 2 or 3 results from the split into separate OBR fields. I was looking to use some random OBR fields to throw them into then I can pull them into the DB. Thoughts anyone?
        Thanks!
        One common thing to do there is to convert each "line" into a discrete NTE segment in the observation group. So this:

        Code:
        OBX|7|ST|||EXAM: CT abdomen without contrast \T\ and CT pelvis without contrast \T\ CT Chest without contrast||||||P||||||
        Would become this:

        Code:
        OBX|7|ST|||SEE NOTE||||||P||||||
        NTE|1|ST|CT abdomen without contrast
        NTE|2|ST|CT pelvis without contrast
        NTE|3|ST|CT Chest without contrast
        Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

        Nicholas Rupley
        Work: 949-237-6069
        Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


        - How do I foo?
        - You just bar.

        Comment


        • #5
          Thanks for the reply Nick.

          Is there a way to bypass adding the split descriptions into NTE lines since I am going to be inserting them into a MySQL DB or is that a necessity? I wonder if there is a more direct way. If there was just one result I would not have a problem with the code but since there is 2 or 3 I don't quite see how to separate them out even If i wanted to put them into NTE lines. I have been digging around in the forums and this seems somewhat unique, or I am not looking in the right places.

          Thanks for your help as always.

          Jay

          Comment


          • #6
            Originally posted by Jaypell22 View Post
            Thanks for the reply Nick.

            Is there a way to bypass adding the split descriptions into NTE lines since I am going to be inserting them into a MySQL DB or is that a necessity? I wonder if there is a more direct way. If there was just one result I would not have a problem with the code but since there is 2 or 3 I don't quite see how to separate them out even If i wanted to put them into NTE lines. I have been digging around in the forums and this seems somewhat unique, or I am not looking in the right places.

            Thanks for your help as always.

            Jay
            I'm not understanding the question... can you rephrase that with some clear examples?
            Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

            Nicholas Rupley
            Work: 949-237-6069
            Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


            - How do I foo?
            - You just bar.

            Comment


            • #7
              Do you simply need to have access to the data, and not necessarily parse it out into the HL7 messages? If so, you could probably get away with using an array or a Java ArrayList. Just for each item, add it to the array/arraylist, and after collecting everything, iterate over the array/arraylist.

              Code:
              var examList = new Packages.java.util.ArrayList();
              for each (obx in msg.OBX) {
              	var obsVal = new java.lang.String(obx['OBX.5']['OBX.5.1'].toString());
              	if (obsVal.startsWith('EXAM:')) {
              		for each (exam in obsVal.substring(5).split('and|\\\\T\\\\')) {
              			examList.add(exam.trim());
              		}
              	}
              }
              
              for (var i = 0; i < examList.size(); i++) {
              	//do something with examList.get(i);
              }

              Comment


              • #8
                Thanks Sandersmr, I will give that a shot as I don't need the info in the actual HL7 message however I am used to pulling info from HL7 messages to put into my DB.

                Nick, Sorry for the confusion.

                If I stick with the idea of putting everything into new NTE lines as you recommended I don't know how to do that when it comes to the code. I guess that is the short of it. If it were one item I can code it.

                Specifically I need to be able to separate each of the below "split" 3 pieces of data into separate MySQL columns. I am looking for the easiest way to do so and possibly bypass having to put it into NTE lines.

                CT abdomen without contrast
                CT pelvis without contrast
                CT Chest without contrast

                Hope that didn't make it muddier.

                Comment


                • #9
                  In each of these code examples posted here so far, there's a section of the code where we direct you to "do something with" the specific exam. That's where you need to inject your own code to perform a database update. There are templates in the References tab which will help to get connected to a database and execute a statement.
                  Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

                  Nicholas Rupley
                  Work: 949-237-6069
                  Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


                  - How do I foo?
                  - You just bar.

                  Comment


                  • #10
                    narupley - I sent J off line help on manipulating the results. Your code example above does work of course.
                    Question

                    if (obsVal.startsWith('EXAM:'))

                    startsWith ... is this prototyped into javascript as part of the Mirth build or part of current javascript release? Looking on WEB at W3Schools for example it doesn't come up in the standard section on javascript string functions.

                    Where in Mirth info can I find this and all the rest of implemented/available language constructs & syntax that are at our fingertips with just a bit of reading?

                    Thank you!

                    Comment


                    • #11
                      In the line above that, that's actually a Java String, not a JavaScript string. Therefore, it's able to use methods available to the String class.

                      http://docs.oracle.com/javase/6/docs...lang.String%29

                      Comment

                      Working...
                      X