No announcement yet.

Unable to add new field in OBR segment

  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to add new field in OBR segment

    Hi Everyone,

    I am new to Mirth,

    Got an opportunity to work in Mirth recently to add an entry in the OBR field. With the help of this forum, I was able to edit an existing data, that works perfectly fine. But failing to add a data to a field which doesn't exist in the source HL7. Below is the example,


    PV2|||||||System Alert Off~0437689973~ABC-KOTHAI-AUS
    In the DestinationHL7, I want to check if PV2.7.2 has "KOTHAI", if yes, then update the OBR.16 as below

    With the below Javascript, I am able to see the last value in OBR is changed as M but no "KOTHAI" is available. I could see the change in Transformed data but not in Encoded data. Could you let me know what am I doing wrong.

    var code = tmp['ORU_R01.PATIENT_RESULT']['ORU_R01.PATIENT']['ORU_R01.VISIT']['PV2']['PV2.7'][2].toString();
    if (code.indexOf("ARSTALL") != -1 )
    }else {

  • #2
    You're using the strict parser, so you need to make sure everything is named correctly depending on hl7 datatype.

    I think you want to do this:


    • #3
      Hi Tony,
      Thanks for this,
      I am unable to add a new field to the segment.
      Maybe I need to let you know how I have configured my Channel. Attached is the FileReader and FileWriter config.

      Below is the msg format.

      MSH|^~\&|Care|Company|HealthLink|PMS3Medd|20190610220158||ORU^R01^ORU_R01|20190610220158737721|P^T|2.3.1|||AL|NE|||||IHE_PCD_ORU_R01^IHE PCD^^ISO
      PID|||MODEL:ABCD^^^MDT^U~Test101^^^^Patient ID~KoRocks^^^^External Patient ID||Black^Jack||19870823000000+0000||||11 Sunnymeade Close^^Carlford^NSW^2077^Australia
      OBX|2|ST|720898^MDC_IDC_DEV_MODEL^MDC||Evera XT DR DDBB2D4||||||C
      OBX|6|ST|1001039^MDT_EVALUATION_MISCELLANEOUSCOMMENT^MDT||Device: Model XT DR DDBB2D4 Serial Number: ABCD606197S Date of Interrogation: 15-Aug-2018 05:11:21 \X0A\Clinical Status Since 13-Aug-2014 \X0A\Treated \X0A\VF (Off)  \X0A\FVT (Off)  \X0A\VT (Off)  \X0A\AT/AF(Monitor)  \X0A0A\Monitored \X0A\VT (Off)  \X0A\VT-NS (>4 beats, >188 bpm) 0 \X0A\High Rate-NS 0 \X0A\SVT: VT/VF Rx Withheld 0 \X0A\V. Oversensing-TWave Rx Withheld 0 \X0A\V. Oversensing-Noise Rx Withheld 0 \X0A\AT/AF 0 \X0A0A\Time in AT/AF 0.0 hr/day (0.0%) \X0A0A\Functional Last Week \X0A\Patient Activity NA < 1 week \X0A\Cardiac Compass Trends (Aug-2018 to Aug-2018) \X0A\Therapy Summary VT/VF AT/AF \X0A\Pace-Terminated Episodes 0 0 \X0A\Shock-Terminated Episodes 0 0 \X0A\Total Shocks 0 0 \X0A\Aborted Charges 0 0 \X0A\Pacing  (% of Time Since 13-Aug-2014) \X0A\Total VP 0.0% (MVP On) \X0A\AS-VS 0.0%  \X0A\AS-VP 0.0%  \X0A\AP-VS 0.0%  \X0A\AP-VP 0.0%  \X0A\OBSERVATIONS (2) \X0A\· Remaining Longevity is not available, potentially due to cold temperature. Store at room temperature for 48 hours and re-interrogate. \X0A\· VF Detection is OFF. \X0A\Device Status \X0A\Remaining Longevity Pre-Implant \X0A\(15-Aug-2018) \X0A\(based on initial interrogation) \X0A0A\ Atrial RV \X0A\Pacing Impedance - - -  - - -  \X0A\Defibrillation Impedance  RV=- - - \X0A0A\Capture Threshold - - -  V @ 0.40 ms - - -  V @ 0.40 ms \X0A\Measured On - - -  - - -  \X0A\Programmed Amplitude/Pulse Width 3.50 V / 0.40 ms 3.50 V / 0.40 ms \X0A0A\Measured P/ R Wave - - -  - - -  \X0A\Programmed Sensitivity 0.30 mV 0.30 mV \X0A\Parameter Summary \X0A\Mode AAI<=>DDD Lower Rate 60 bpm Paced AV 180 ms \X0A\Mode Switch 171 bpm Upper Track 130 bpm Sensed AV 150 ms \X0A\  Upper Sensor 120 bpm   \X0A0A\Detection  Rates Therapies   \X0A\AT/AF Monitor >171 bpm All Rx Off \X0A\VF OFF  (Detection is OFF)    ATP During Charging, 35J x 6 \X0A\FVT OFF  All Rx Off \X0A\VT OFF  All Rx Off \X0A0A\Enhancements On:  TWave, Noise(Timeout)||||||C
      OBX|7|ED|18750-0^Cardiac Electrophysiology Report^LN|1|Application^pdf^^Base64^
      Now, I need to update the PV1 segment as

      PV1|1|O|4.PREOP||||||060093FB^KOVAC^PAUL MARK^^^DR^^^AUSHICPR^^^^^|||||||||
      Attached Files


      • #4
        Are you using a message template? If not and you're working in a transformer, I suggest the msg variable directly. One typically see use of the "tmp" variable is used for channels that use a message template (I under it is not an abbreviation for temporary). Furthermore, you modified the "tmp" variable but you didn't subsequently update the "msg" variable which is what you're sending, I reckon.

        To assign a value to OBR.25, I suggest you work directly with the msg varaible and resolve you target field right down to the first sub-component - OBR.25.1:

        msg["OBR"]["OBR.25"]["OBR.25.1"] = "MyUpdatedContent";


        • #5
          @kirt's advice is good to update msg directly instead of tmp. When you specify an outbound template, that template will be deserialized to the tmp variable, and tmp will be used to produce your encoded data. If you don't specify an outbound template, tmp will be undefined and msg will be used to produce your encoded data.

          The first line of shared code employs what I consider bad practice of using
          This will point tmp at the same object at which msg points. This means it doesn't matter which variable you use because they will both modify the same object, and they will both retrieve the same object.

          That being said, what mirth version are you using? It looks old from your screenshots.


          • #6
            Thanks Kirt and Tony for the updates,

            Yes, I used the template first to know how the segment field looks like.

            I was able to update the PV1 segment with the below code in Javascript console.

            the output looks like this
            If this is bad coding, apologize. Can I just update the "msg", I need to revise this a lot, because I need to update the PV1 based on a lookup table.

            @Tony, the version installed on our server is Mirth Connect Server

            Is this too old?
            I now have a another question, probably I will create a separate post for that.
            Not sure if I can tag you to that post.



            • #7
              Oh yeah. That IS OLD!!

              Mirth Connect Server
              Is this too old?

              Oh yeah. That IS OLD!!

              Wed, 29 Feb 2012 19:59:51 UTC

              We are now at 3.7.1. So I suggest to update ASAP.
              X Connections


              • #8
                Oh no, I will need to check with our US team if we can use the latest version.
                Thanks for your reply.


                • #9

                  Upgrading from 2.x to 3.x can be a pretty big change for some.