Announcement

Collapse
No announcement yet.

Combining OBX lines into one AND inserting 80 character limit ~ tilde

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

  • Combining OBX lines into one AND inserting 80 character limit ~ tilde

    Version 2.2.1.5861.
    I am currently using the below code to create one OBX line from Multiple OBX lines. This has been working great however I now have to ensure there is a ~ no more than 80 characters apart within this one line as this is a limitation by the vendor's engine I am sending ORU messages to and is getting rejected.

    I did try to first limit each OBX line to 80 characters but it then truncated an lost the rest of the line instead of inserting it into a new one. I think this can be done 2 ways. Before and after this code (who knows maybe in the middle of it!)

    So in short.... I need to insert a ~ 80 characters or less apart but not falling in the middle of a word splitting it up in addition to the code I already have in place that combines all OBX.5 data.

    Thanks for any help - Jay

    Code I am using:

    var newOBX = <OBX/>;
    newOBX['OBX.1']['OBX.1.1'] = '1';
    newOBX['OBX.2']['OBX.2.1'] = 'FT';
    newOBX['OBX.5'] = '';
    for each (seg in msg.children())
    if (seg.name().toString() == 'OBX')
    for each (obx5 in seg['OBX.5'])
    newOBX['OBX.5'] = newOBX['OBX.5'].toString() ? newOBX['OBX.5']+obx5 : obx5;
    newOBX['OBX.14']['OBX.14.1'] = msg['OBR']['OBR.8']['OBR.8.1'].toString();
    newOBX['OBX.16']['OBX.16.1'] = msg['OBR']['OBR.32']['OBR.32.1'];
    newOBX['OBX.16']['OBX.16.2'] = msg['OBR']['OBR.32']['OBR.32.2'];
    newOBX['OBX.16']['OBX.16.3'] = msg['OBR']['OBR.32']['OBR.32.3'];
    msg.OBX = newOBX;
    Last edited by Jaypell22; 10-05-2013, 09:52 AM.

  • #2
    give this a try.

    var newOBX = <OBX/>;
    newOBX['OBX.1']['OBX.1.1'] = '1';
    newOBX['OBX.2']['OBX.2.1'] = 'FT';
    newOBX['OBX.5'] = '';
    for each (obx in msg.OBX)
    {
    var obxArray = new Array();
    for each (obx5 in obx['OBX.5'])
    {
    while(obx5.toString().length() > 80)
    {
    var tmpOBX = obx.toString().substring(0,80);
    var obxIndex = tmpObx.lastIndexOf(' ');
    obxArray.push(tmpOBX.substring(0,obxIndex));
    obx5 = obx5.toString().subString(80,obx5.toString().lengt h());
    }
    obxArray.push(obx5);
    }
    }

    for(i = 0; i < obxArray.length(); i++)
    {
    newOBX['OBX.5']['OBX.5.' + i] = obxArray[i];
    }

    newOBX['OBX.14']['OBX.14.1'] = msg['OBR']['OBR.8']['OBR.8.1'].toString();
    newOBX['OBX.16']['OBX.16.1'] = msg['OBR']['OBR.32']['OBR.32.1'];
    newOBX['OBX.16']['OBX.16.2'] = msg['OBR']['OBR.32']['OBR.32.2'];
    newOBX['OBX.16']['OBX.16.3'] = msg['OBR']['OBR.32']['OBR.32.3'];
    msg.OBX = newOBX;

    Comment


    • #3
      Thanks for your Help! I am hitting a snag right now however. Maybe you can understand the error. That is the first OBX Line that it gets stuck on. Let me know if you have any ideas - also if you are going to test or use the code there is just an extra space in this line in the word length which I highlighted below

      obx5 = obx5.toString().subString(80,obx5.toString().lengt h()); this was fixed so not causing problems, just an FYI.

      ERROR-300: Transformer error
      ERROR MESSAGE: Error evaluating transformer
      com.mirth.connect.server.MirthJavascriptTransforme rException:
      CHANNEL: TEST CHANNEL
      CONNECTOR: Test to Channel
      SCRIPT SOURCE:
      SOURCE CODE:
      193: for each (obx in msg.OBX)
      194: {
      195: var obxArray = new Array();
      196: for each (obx5 in obx['OBX.5'])
      197: {
      198: while(obx5.toString().length() > 80)
      199: {
      200: var tmpOBX = obx.toString().substring(0,80);
      201: var obxIndex = tmpObx.lastIndexOf(' ');
      202: obxArray.push(tmpOBX.substring(0,obxIndex));
      LINE NUMBER: 198
      DETAILS: TypeError: Cannot call property length in object <OBX.5><OBX.5.1>Referring Physician: FIRSTNAME, LASTNAME, PA</OBX.5.1></OBX.5>. It is not a function, it is "number".
      at com.mirth.connect.server.mule.transformers.JavaScr iptTransformer.evaluateScript(JavaScriptTransforme r.java:398)
      Last edited by Jaypell22; 10-09-2013, 09:12 AM.

      Comment


      • #4
        while(obx5.toString().length() > 80)

        change to

        while(obx5.toString().length > 80)

        Comment


        • #5
          Shouldn't this also be looking at OBX.5.1 rather than the whole of OBX.5?

          e.g.
          Code:
          for each (obx5 in obx['OBX.5']['OBX.5.1'])
          {
          [...]
          }

          Comment


          • #6
            Not if he want each of the entries. That loop is to look at each one individually.

            Comment


            • #7
              So I have been playing around with this, made a few tweaks/fixes for capitalizations, and removed 2 "()" which were hanging things up. Everything processes now but look at the OBX. It deletes everything and puts "~" in OBX.4! That is slightly mind-blowing! I don't think I have any other code that would cause it to show up in OBX.4

              OBX|1|FT||~||||||||||201310091417||123456^LAST^FIR ST


              Below is the current code I'm using.



              Code:
              var newOBX = <OBX/>;
              newOBX['OBX.1']['OBX.1.1'] = '1';
              newOBX['OBX.2']['OBX.2.1'] = 'FT';
              newOBX['OBX.5'] = '';
              for each (obx in msg.OBX)
              { 
              var obxArray = new Array();
              for each (obx5 in obx['OBX.5'])
              {
              while(obx5.toString().length > 80)
              {
              var tmpOBX = obx.toString().substring(0,80);
              var obxIndex = tmpOBX.lastIndexOf(' ');
              obxArray.push(tmpOBX.substring(0,obxIndex));
              obx5 = obx5.toString().substring(80,obx5.toString().length);
              }
              obxArray.push(obx5);
              }
              }
              
              for(i = 0; i < obxArray.length; i++)
              {
              newOBX['OBX.5']['OBX.5.' + i] = obxArray[i];
              }
              
              newOBX['OBX.14']['OBX.14.1'] = msg['OBR']['OBR.8']['OBR.8.1'].toString();
              newOBX['OBX.16']['OBX.16.1'] = msg['OBR']['OBR.32']['OBR.32.1'];
              newOBX['OBX.16']['OBX.16.2'] = msg['OBR']['OBR.32']['OBR.32.2'];
              newOBX['OBX.16']['OBX.16.3'] = msg['OBR']['OBR.32']['OBR.32.3'];
              msg.OBX = newOBX;

              Comment


              • #8
                Try this:

                Code:
                var newOBX = <OBX/>;
                newOBX['OBX.1']['OBX.1.1'] = '1';
                newOBX['OBX.2']['OBX.2.1'] = 'FT';
                newOBX['OBX.5'] = '';
                var obxArray = new Array();
                for each (obx in msg.OBX)
                {
                	for each (obx5 in obx['OBX.5'])
                	{
                		while(obx5.toString().length > 80)
                		{
                			var tmpOBX = obx.toString().substring(0,80);
                			var obxIndex = tmpOBX.lastIndexOf(' ');
                			obxArray.push(tmpOBX.substring(0,obxIndex));
                			obx5 = obx5.toString().substring(80,obx5.toString().length);
                		}
                		obxArray.push(obx5);
                	}
                }
                
                for(i = 0; i < obxArray.length; i++)
                {
                	newOBX['OBX.5'][i] = obxArray[i];
                }
                
                newOBX['OBX.14']['OBX.14.1'] = msg['OBR']['OBR.8']['OBR.8.1'].toString();
                newOBX['OBX.16']['OBX.16.1'] = msg['OBR']['OBR.32']['OBR.32.1'];
                newOBX['OBX.16']['OBX.16.2'] = msg['OBR']['OBR.32']['OBR.32.2'];
                newOBX['OBX.16']['OBX.16.3'] = msg['OBR']['OBR.32']['OBR.32.3'];
                msg.OBX = newOBX;
                The obxArray was going out of scope (was declared in the first for each), and each new piece of OBX.5 needed to be assigned on OBX.5, not OBX.5.*, since each string already contained the whole OBX.5 structure, eg

                Code:
                <OBX.5><OBX.5.1>Referring Physician: FIRSTNAME, LASTNAME, PA</OBX.5.1></OBX.5>

                Comment


                • #9
                  Getting there, Now I get this as a result using the most recent code.

                  OBX|1|FT|||Referring Physician: MR DOCTOR, MD~~Patient Name: FIRST LAST~~~5>~~Exam: X-ray 2 view PA lateral chest.~~~~~~~~.</OBX.5.1></OBX.5>~~~tudy of 10/4/13.</OBX.5.1></OBX.5>~~~THIS DOCUMENT HAS BEEN ELECTRONICALLY SIGNED~~DR Me M.D.~~10/09/2013 15:03~|||||||||201310091504||123456^last^First

                  Comment


                  • #10
                    What does the original message look like (with PHI cleaned of course)? It's probably due to splitting the entirety of OBX.5 (including the XML structure) rather than picking an individual field (like OBX.5.1).

                    Comment


                    • #11
                      Yes Sry, should have thrown that out to you guys.

                      Code:
                      MSH|^~\&|HOSP||HOSP||201310091515||ORU^R01|201310091515341948794|P|2.3
                      PID|1|1234401834|1234401834||NAME^NAME^W||19600123|M||||||||||||
                      PV1|1||HOSPTAL|||||Blank|||||||||||||||||||||||||||||||||||||||||||||
                      ORC|RE
                      OBR|1||123456|VENOUS DOPPLER RIGHT LEG^VENOUS DOPPLER RIGHT LEG||201310091117|201310091117|||||||||Blank||||123456789456123456||201310091515||US|P|||||||123456^FIRST^LAST|||||
                      OBX|1|ST|||Referring Physician: DOC, MD||||||P||||||
                      OBX|2|ST|||||||||P||||||
                      OBX|3|ST|||Patient Name: PATIENT NAME||||||P||||||
                      OBX|4|ST|||||||||P||||||
                      OBX|5|ST|||History: LEG pain.||||||P||||||
                      OBX|6|ST|||||||||P||||||
                      OBX|7|ST|||Exam: Right lower extremity duplex venous doppler.||||||P||||||
                      OBX|8|ST|||||||||P||||||
                      OBX|9|ST|||Date of Service: 2013-10-09 14:21:26.0||||||P||||||
                      OBX|10|ST|||||||||P||||||
                      OBX|11|ST|||Technique: Gray scale and color Doppler sonographic images were obtained of the right lower extremity.||||||P||||||
                      OBX|12|ST|||||||||P||||||
                      OBX|13|ST|||Findings: FINDINGS HERE||||||P||||||
                      OBX|14|ST|||||||||P||||||
                      OBX|15|ST|||The contralateral left external iliac vein demonstrates normal color doppler flow.||||||P||||||
                      OBX|16|ST|||||||||P||||||
                      OBX|17|ST|||Impression: No evidence of DVT of the right lower extremity.||||||P||||||
                      OBX|18|ST|||||||||P||||||
                      OBX|19|ST|||||||||P||||||
                      OBX|20|ST|||||||||P||||||
                      OBX|21|ST|||THIS DOCUMENT HAS BEEN ELECTRONICALLY SIGNED||||||P||||||
                      OBX|22|ST|||||||||P||||||
                      OBX|23|ST|||DOC M.D.||||||P||||||
                      OBX|24|ST|||||||||P||||||
                      OBX|25|ST|||10/09/2013 15:14||||||P||||||
                      OBX|26|ST|||||||||P||||||

                      Comment


                      • #12
                        Would there ever be a case of more than just OBX.5.1 being used?

                        Comment


                        • #13
                          Never in the Raw message however I do insert various data in other fields per my code.

                          Comment


                          • #14
                            If just working with OBX.5.1, this seems to work out. Fyi, "for each" also has no order guarantee.

                            Code:
                            var newOBX = <OBX/>;
                            newOBX['OBX.1']['OBX.1.1'] = '1';
                            newOBX['OBX.2']['OBX.2.1'] = 'FT';
                            newOBX['OBX.5'] = '';
                            var obxArray = new Array();
                            for each (obx in msg.OBX)
                            {
                            	for each (obx5 in obx['OBX.5']['OBX.5.1']) 
                            	{
                            		while(obx5.toString().length > 80)
                            		{
                            			var tmpOBX = obx5.toString().substring(0,80);
                            			var obxIndex = tmpOBX.lastIndexOf(' ');
                            			obxArray.push(tmpOBX.substring(0,obxIndex));
                            			obx5 = obx5.toString().substring(obxIndex,obx5.toString().length);
                            		}
                            		obxArray.push(obx5);
                            	}
                            }
                            var obx5Def = newOBX['OBX.5']; //get a default OBX.5 to get repeating segments working
                            for(i = 0; i < obxArray.length; i++)
                            {
                            	newOBX['OBX.5'][i] += obx5Def;
                            	newOBX['OBX.5'][i]['OBX.5.1'] = obxArray[i];
                            }
                            
                            newOBX['OBX.14']['OBX.14.1'] = msg['OBR']['OBR.8']['OBR.8.1'].toString();
                            newOBX['OBX.16']['OBX.16.1'] = msg['OBR']['OBR.32']['OBR.32.1'];
                            newOBX['OBX.16']['OBX.16.2'] = msg['OBR']['OBR.32']['OBR.32.2'];
                            newOBX['OBX.16']['OBX.16.3'] = msg['OBR']['OBR.32']['OBR.32.3'];
                            msg.OBX = newOBX;

                            Comment


                            • #15
                              Implemented new code and everything looks good except for the additional ~'s needed where line breaks are. My original code put in ~ for each line break. The first result below is the latest results with the newest code. It is long but wanted to show all of the ~'s. The second result is what I was getting prior to the changes, you can see the multiple ~~~ however that lacks the 80 character ~'s.

                              If I could add the ~'s every 80 characters AFTER the old code does its thing that would be perfect!


                              NEW CODE RESULTS:
                              OBX|1|FT|||Referring Physician: ME, MD~Patient Name: John Doe~Final report~EXAM: FLUOROSCOPIC GUIDED TUNNELED DIALYSIS CATHETER EXCHANGE AND CENTRAL~ VENOUS ANGIOPLASTY .~IMAGES: 12~EXAM DATE AND TIME: 2013-10-09 10:18:18.0~REASON FOR EXAM: Poorly functioning left subclavian tunneled dialysis catheter.~COMPARISON: None.~OPERATOR: dr. me operator, MD~REFERRING PHYSICIAN: Dr. Me ~PREPROCEDURE DIAGNOSIS: Poorly functioning tunneled hemodialysis catheter.~POST PROCEDURE DIAGNOSIS: Same. Central venous stenosis.~ANESTHESIA: ~Moderate sedation with Anesthesiology.~Local anesthesia with 10 mL of 1% lidocaine.~PROCEDURES:~1. Fluoroscopic-guided exchange of tunneled central venous catheter.~2. Venous angioplasty of central venous stenosis.~PROCEDURE IN DETAIL:~After an explanation of the procedure including risks and benefits, written~ informed consent was obtained.~The patient was premedicated with 25 mg of Benadryl IV because of history of~ hives with IV contrast.~The patient was placed supine on the angiographic table and the indwelling left~ subclavian tunneled dialysis catheter and the area around it were cleaned and~ draped in usual sterile fashion. Propofol anesthesia was given by the Nurse~ Anesthetist via the indwelling catheter because of the lack of peripheral IV~ access. Generous local anesthesia was instilled at the exit site of the~ catheter and around the cuff using 1% lidocaine local anesthesia. The cuff was~ freed using blunt dissection techniques. Contrast injection via both ports of~ the catheter showed no fibrin sheath. A 0.035 inch Bentson guidewire and a~ 0.035 inch angled Glidewire was then advanced via both ports and the tips~ manipulated into the IVC under fluoroscopic guidance. The catheter was then~ pulled back until the tip was in the left subclavian vein. A central venogram~ was then performed which showed high-grade stenosis of the brachiocephalic~ vein and SVC to the size of the catheter. A 12 mm high-pressure Conquest~ balloon was then used to perform angioplasty of the stenosed segment of vein~ with improvement and collateral circulation noted on followup venogram.~A new 23 cm tip to cuff Equistream tunneled dialysis catheter was then advanced~ via the guidewire until the tip was in the right atrium under fluoroscopic~ guidance.~Flow parameters with a 10 cc syringe were excellent. Hemostasis was ensured.~ The catheter was then secured to the skin using 2/0 Prolene sutures and a dry~ dressing was then placed over the catheter.~The patient tolerated the procedure well without immediate complications and~ was transferred from the angiography suite in stable condition.~EBL: Minimal. 2 mL.~CONTRAST: 18 mL of Visipaque 320 intravenous contrast.~RADIATION TIME/DOSE: 3.3 min; 84 mGy~IMPRESSION~Fluoroscopic guided Left subclavian vein tunneled dialysis catheter exchange as~ above.~Angioplasty of central venous stenosis as above.~The catheter may be used now for dialysis. ~CPT CODES: 33586581, 7237001, 3522475 and 7597228.~THIS DOCUMENT HAS BEEN ELECTRONICALLY SIGNED~Mr Doctor, MD.~10/09/2013 16:32~|||||||||201310091635||123456^TEST^DOC

                              OLD CODE RESULTS:

                              OBX|1|FT|||Referring Physician: ME, MD~~Patient Name: John Doe~~final report~~EXAM: FLUOROSCOPIC GUIDED TUNNELED DIALYSIS CATHETER EXCHANGE AND CENTRAL VENOUS ANGIOPLASTY .~~IMAGES: 12~~EXAM DATE AND TIME: 2013-10-09 10:18:18.0~~REASON FOR EXAM: Poorly functioning left subclavian tunneled dialysis catheter.~~COMPARISON: None.~~OPERATOR: Dr. me operator, MD~~REFERRING PHYSICIAN: Dr. Me~~PREPROCEDURE DIAGNOSIS: Poorly functioning tunneled hemodialysis catheter.~~POST PROCEDURE DIAGNOSIS: Same. Central venous stenosis.~~ANESTHESIA: ~Moderate sedation with Anesthesiology.~Local anesthesia with 10 mL of 1% lidocaine.~~PROCEDURES:~1. Fluoroscopic-guided exchange of tunneled central venous catheter.~2. Venous angioplasty of central venous stenosis.~~PROCEDURE IN DETAIL:~After an explanation of the procedure including risks and benefits, written informed consent was obtained.~~The patient was premedicated with 25 mg of Benadryl IV because of history of hives with IV contrast.~~The patient was placed supine on the angiographic table and the indwelling left subclavian tunneled dialysis catheter and the area around it were cleaned and draped in usual sterile fashion. Propofol anesthesia was given by the Nurse Anesthetist via the indwelling catheter because of the lack of peripheral IV access. Generous local anesthesia was instilled at the exit site of the catheter and around the cuff using 1% lidocaine local anesthesia. The cuff was freed using blunt dissection techniques. Contrast injection via both ports of the catheter showed no fibrin sheath. A 0.035 inch Bentson guidewire and a 0.035 inch angled Glidewire was then advanced via both ports and the tips manipulated into the IVC under fluoroscopic guidance. The catheter was then pulled back until the tip was in the left subclavian vein. A central venogram was then performed which showed high-grade stenosis of the brachiocephalic vein and SVC to the size of the catheter. A 12 mm high-pressure Conquest balloon was then used to perform angioplasty of the stenosed segment of vein with improvement and collateral circulation noted on followup venogram.~~A new 23 cm tip to cuff Equistream tunneled dialysis catheter was then advanced via the guidewire until the tip was in the right atrium under fluoroscopic guidance.~~Flow parameters with a 10 cc syringe were excellent. Hemostasis was ensured. The catheter was then secured to the skin using 2/0 Prolene sutures and a dry dressing was then placed over the catheter.~~The patient tolerated the procedure well without immediate complications and was transferred from the angiography suite in stable condition.~~EBL: Minimal. 2 mL.~~CONTRAST: 18 mL of Visipaque 320 intravenous contrast.~~RADIATION TIME/DOSE: 3.3 min; 84 mGy~~IMPRESSION~Fluoroscopic guided Left subclavian vein tunneled dialysis catheter exchange as above.~~Angioplasty of central venous stenosis as above.~~The catheter may be used now for dialysis. ~~CPT CODES: 3655512481, 77052301, 35147425 and 754591278.~~~~THIS DOCUMENT HAS BEEN ELECTRONICALLY SIGNED~~Mr. Doctor, MD.~~10/09/2013 16:32~|||||||||201310091635||123456^TEST^DOC
                              Last edited by Jaypell22; 10-10-2013, 08:20 AM.

                              Comment

                              Working...
                              X