Announcement

Collapse
No announcement yet.

Example Lab Report

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

  • Example Lab Report

    Hello Guys,

    Does any one have a example Lab Report with OBR , OBX and NTE combined?

    Thanks in advance

  • #2
    currently i have used this layout... but i cannot combine them all together :-

    var results = new XML('<tbody></tbody>');
    var tr;

    for each (mOBX in msg..OBX) {

    tr = new XML('<tr></tr>');

    tr['td'][0] = '';
    if (mOBX['OBX.8']['OBX.8.1'].toString() != "N") {
    tr['td'][0]['img']['@src'] = '/mirth/graphics/flag_red.png';
    }
    // Test Name
    tr['td'][1] = mOBX['OBX.3']['OBX.3.2'].toString();
    // Result
    tr['td'][2] = mOBX['OBX.5']['OBX.5.1'].toString() + " "+ mOBX['OBX.6']['OBX.6.1'].toString();
    // Flag - Red if not N = normal
    tr['td'][3] = mOBX['OBX.8']['OBX.8.1'].toString();
    // Reference range
    tr['td'][4] = mOBX['OBX.7']['OBX.7.1'].toString() + " " + mOBX['OBX.6']['OBX.6.1'].toString();

    results[''] += tr;
    }

    channelMap.put("Results",results);

    Comment


    • #3
      This code template should help.

      https://github.com/nextgenhealthcare...ular%20Segment

      Comment


      • #4
        thanks for this, but having diffculty incorporating this into the script. having looked through all the material but still having difficulty.

        I am a mirth newbie and trying to get this transformer : -

        // Test Name
        tr['td'][1] = mOBX['OBX.3']['OBX.3.2'].toString();
        // Result
        tr['td'][2] = mOBX['OBX.5']['OBX.5.1'].toString() + " "+ mOBX['OBX.6']['OBX.6.1'].toString();
        // Flag - Red if not = normal
        tr['td'][3] = mOBX['OBX.8']['OBX.8.1'].toString();
        // Reference range
        tr['td'][4] = mOBX['OBX.7']['OBX.7.1'].toString() + " " + mOBX['OBX.6']['OBX.6.1'].toString();

        followed by the NTE comments

        thanks in advance

        Comment


        • #5
          I set the outbound type to xml and the outbound template to <tbody/>. Then you can modify tmp (instead of results) and it will become the encoded data (i.e. actually transform the message) so you don't have to stick your results in the channelMap.

          For each OBR/OBX/NTE grouping I add them to a new xml object called group to make accessing them easier. This isn't necessary, and if you don't want to do it that way, at least you can see how getSegmentsAfter can be used.

          I used e4x templating to create the new row in one step. The way you were doing it will work, but I wanted to show an alternative way that some may prefer.

          I didn't know how you wanted to use fields from OBR and NTE, so I just picked a random field from each and added them to a new column in your table. The NTE value is wrapped in a <div> tag by passing it to another function. It will support multiple NTE segments for the same group, wrapping each value separately.

          Code:
          const red_flag = <img src="/mirth/graphics/flag_red.png"/>;
          
          for each (var obr in msg.OBR) {
              var group = <group>{obr}</group>;
              getSegmentsAfter(msg, obr, /OBX|NTE/, true).forEach(function(seg) {group.appendChild(seg)});
              var obx8 = group['OBX']['OBX.8']['OBX.8.1'].toString();
              var tr = <tr>
                  <td>{obx8 != 'N' ? red_flag : ''}</td>
                  <td>{group.OBX['OBX.3']['OBX.3.2'].toString()}</td>
                  <td>{group.OBX['OBX.5']['OBX.5.1'].toString() + " "+ group.OBX['OBX.6']['OBX.6.1'].toString()}</td>
                  <td>{obx8}</td>
                  <td>{group.OBX['OBX.7']['OBX.7.1'].toString() + " " + group.OBX['OBX.6']['OBX.6.1'].toString()}</td>
                  <td>{group.OBR['OBR.2']['OBR.2.1'].toString()}</td>
                  <td>{divWrap(group.NTE['NTE.2']['NTE.2.1'])}</td>
              </tr>;
              tmp.appendChild(tr);
          }
          
          // takes an XMLList and returns a new list of the string value of each list item
          // wrapped in div tags
          function divWrap(list) {
              var ret = <></>;
              for each (var e in list) {
                  ret += <div>{e.toString()}</div>
              }
              return ret;
          }
          Last edited by agermano; 07-24-2019, 09:01 PM.

          Comment


          • #6
            thanks for this ageramo,

            just a quick question is i change the output to xml would this code go as a javascript in the transformer?

            Comment


            • #7
              confused

              I have added and used this script: -
              var results5 = new XML('<tbody></tbody>');
              var tr;

              const red_flag = <img src="/mirth/graphics/flag_red.png"/>;

              for each (var obr in msg.OBR) {
              var group = <group>{obr}</group>;
              getSegmentsAfter(msg, obr, /OBX|NTE/, true).forEach(function(seg) {group.appendChild(seg)});
              var obx8 = group['OBX']['OBX.8']['OBX.8.1'].toString();
              var tr = <tr>
              <td>{obx8 != 'N' ? red_flag : ''}</td>
              <td>{group.OBX['OBX.3']['OBX.3.2'].toString()}</td>
              <td>{group.OBX['OBX.5']['OBX.5.1'].toString() + " "+ group.OBX['OBX.6']['OBX.6.1'].toString()}</td>
              <td>{obx8}</td>
              <td>{group.OBX['OBX.7']['OBX.7.1'].toString() + " " + group.OBX['OBX.6']['OBX.6.1'].toString()}</td>
              <td>{group.OBR['OBR.2']['OBR.2.1'].toString()}</td>
              <td>{divWrap(group.NTE['NTE.2']['NTE.2.1'])}</td>
              </tr>;
              tmp.appendChild(tr);
              }

              // takes an XMLList and returns a new list of the string value of each list item
              // wrapped in div tags
              function divWrap(list) {
              var ret = <></>;
              for each (var e in list) {
              ret += <div>{e.toString()}</div>
              }
              return ret;
              }
              channelMap.put("Results5",results5);

              but it does not do anything just returns an blank, is there something i have missed?

              Comment


              • #8
                Originally posted by agermano View Post
                I set the outbound type to xml and the outbound template to <tbody/>. Then you can modify tmp (instead of results) and it will become the encoded data (i.e. actually transform the message) so you don't have to stick your results in the channelMap.
                I think you missed this part.

                If you need to build multiple tables or something and that's why you're putting the results into the channelMap rather than transforming the message, change tmp.appendChild(tr) to results5.appendChild(tr).
                Last edited by agermano; 08-07-2019, 12:48 PM.

                Comment


                • #9
                  hey thanks for that, it works now, but still doesnt produce the OBX followed by the NTE........

                  Comment


                  • #10
                    I showed in my example how to include fields from OBR, OBX, and multiple NTE segments. You never provided sample messages or sample output, so I just made something up.

                    Comment


                    • #11
                      I have attached a HL7 Message as example with multiple OBR, OBX and NTE
                      Attached Files

                      Comment


                      • #12
                        and what do you expect your table to look like after it runs?

                        Comment


                        • #13
                          The following structure

                          Header OBR4.2
                          Test Name | Result | Flag | Reference Range
                          OBX3.2 | OBX5.1 + OBX 6.1 | OBX8.1 | OBX7.1+OBX6.1
                          NTE3.1

                          The difficulty is trying to get the NTE to follow as the message.

                          As as the moment the NTE reiterates at the bottom, which doesnt flow.

                          thanks for all your help

                          Comment


                          • #14
                            Sorry, I'm still not clear on what you want. Can you post what you want the html to look like for the sample hl7 message?

                            Comment


                            • #15
                              hey sorry, i have attached the exampe HTML,

                              currently the {$Results} Javascript doesnt have the OBR or the NTE.
                              Attached Files

                              Comment

                              Working...
                              X