Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   How to hardcode something with repeating obx segments (http://www.mirthcorp.com/community/forums/showthread.php?t=6909)

achilton 04-18-2012 02:03 AM

How to hardcode something with repeating obx segments
 
Good morning,
We are haveing trouple coming up with an Idea on how to hardcode &BODY to every OBX segment. explample below
RAD3102&BODY^WRISTS RTLT 2 VIEW EACH.
Also we need to hardcode &IMP one each Impression segment.
RAD3102&IMP^WRISTS RTLT 2 VIEW EACH

Bassically they are want to know what part of the HL7 result message is th body of the report and what is the Impresion.

What we are having trouble with is we will never know how many repeating OBX segments will be for us to harde Code the Impression? Does anyone have any ideas one what we could try,

Below is an example of what we need the message to look like.

OBX|1|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Examination||||||F
OBX|2|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||WRISTS RT/LT 2 VIEW EACH ||||||F
OBX|3|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH|| ||||||F
OBX|4|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Clinical History||||||F
OBX|5|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||WRIST PAIN ||||||F
OBX|6|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH|| ||||||F
OBX|7|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Comparison||||||F
OBX|8|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||None. ||||||F
OBX|9|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH|| ||||||F
OBX|10|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Technique||||||F
OBX|11|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Imaging of the right wrist was performed. ||||||F
OBX|12|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH|| ||||||F
OBX|13|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Imaging of the left wrist was performed. ||||||F
OBX|14|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH|| ||||||F
OBX|15|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Findings||||||F
OBX|16|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Left Hand: Mild carpometacarpal degenerative is of the 1st digit are ||||||F
OBX|17|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||present. Soft tissues are unremarkable. ||||||F
OBX|18|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH|| ||||||F
OBX|19|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||Right Hand: Minimal 1st carpometacarpal degenerative changes are ||||||F
OBX|20|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH||present. Soft tissues are unremarkable. ||||||F
OBX|21|FT|RAD3102&BODY^WRISTS RTLT 2 VIEW EACH|| ||||||F
OBX|22|FT|RAD3102&IMP^WRISTS RTLT 2 VIEW EACH||Impression||||||F
OBX|23|FT|RAD3102&IMP^WRISTS RTLT 2 VIEW EACH||Mild degenerative changes of bilateral 1st carpometacarpal ||||||F
OBX|24|FT|RAD3102&IMP^WRISTS RTLT 2 VIEW EACH||articulations.||||||F

narupley 04-18-2012 03:51 AM

You could do this:

Code:

var imp = false;
for each (obx in msg.OBX) {
        if (obx.elements('OBX.5').length() > 0)
                if (obx['OBX.5']['OBX.5.1'].toString() == 'Impression')
                        imp = true;
        if (obx['OBX.3']['OBX.3.1'].hasSimpleContent()) {
                var obx31 = <OBX.3.1/>;
                obx31['OBX.3.1.1'] = obx['OBX.3']['OBX.3.1'].toString();
                obx['OBX.3']['OBX.3.1'] = obx31;
        }
        obx['OBX.3']['OBX.3.1']['OBX.3.1.2'] = imp ? 'IMP' : 'BODY';
}

That iterates through all OBXs in the entire message at once, and assumes that once an "Impression" OBX is hit, the rest of the OBXs in the message are also IMPs. Alter it as you see fit for your specific case..

achilton 04-19-2012 07:49 AM

Thank you so much this worked perfect!!!

Now we need to be able to Delete OBX segments that are not always in the same place.
Example:
OBX|1|FT|MRI3721^MRI LOWER JOINT WO||Examination||||||F
OBX|2|FT|MRI3721^MRI LOWER JOINT WO||MRI LOWER JOINT WO ||||||F
OBX|3|FT|MRI3721^MRI LOWER JOINT WO|| ||||||F
OBX|4|FT|MRI3721^MRI LOWER JOINT WO||Clinical History||||||F
OBX|5|FT|MRI3721^MRI LOWER JOINT WO||PAIN AND SWELLING LEFT KNEE ||||||F



OBX|1|FT|RAD1020^CHEST PA LATERAL TWO VIEW||Examination||||||F
OBX|2|FT|RAD1020^CHEST PA LATERAL TWO VIEW||CHEST PA LATERAL TWO VIEW ||||||F
OBX|3|FT|RAD1020^CHEST PA LATERAL TWO VIEW|| ||||||F
OBX|4|FT|RAD1020^CHEST PA LATERAL TWO VIEW|| ||||||F
OBX|5|FT|RAD1020^CHEST PA LATERAL TWO VIEW||Clinical History||||||F
OBX|6|FT|RAD1020^CHEST PA LATERAL TWO VIEW||ROUTINE ||||||F

We need to be able to delete everything contating clinical History and above. As you can see these they are not always in the same place for us to delete. The First message has 5 segments that we need to be deleted, the next one has 6 segments. What would be the best way to do this? The other system has everything hardcoded so when we send all these it duplicates everything.

Thanks

narupley 04-19-2012 08:52 AM

You can delete elements of an object in JavaScript with the "delete" operator. Every time you delete a segment though, it's child index is decremented, so make sure to account for that.

Jaypell22 08-16-2012 10:24 AM

Hi all. Thanks for this helpful thread. The code looks great but isn't working 100% for me. Every 5.1 field has &BODY even after Impression: I did add a ":" to the word Impression but I tried it without that as well. I'm sure it is something obvious but I have stared at it so long I could really use a fresh set of eyes. Thanks- Jay

Here is the code copied from my transformer and the tranformed msg below that

Code:

var imp = false;
for each (obx in msg.OBX) {
        if (obx.elements('OBX.5').length() > 0)
                if (obx['OBX.5']['OBX.5.1'].toString() == 'Impression:')
                        imp = true;
        if (obx['OBX.3']['OBX.3.1'].hasSimpleContent()) {
                var obx31 = <OBX.3.1/>;
                obx31['OBX.3.1.1'] = obx['OBX.3']['OBX.3.1'].toString();
                obx['OBX.3']['OBX.3.1'] = obx31;
        }
        obx['OBX.3']['OBX.3.1']['OBX.3.1.2'] = imp ? 'IMP' : 'BODY';
}

OBX|1|ST|&BODY||Referring Physician: Joe Physician||||||F||||||
OBX|2|ST|&BODY||||||||F||||||
OBX|3|ST|&BODY||Patient Name: EMERGENCY TEST||||||F||||||
OBX|4|ST|&BODY||||||||F||||||
OBX|5|ST|&BODY||||||||F||||||
OBX|6|ST|&BODY||EXAM: CT ABDOMEN AND PELVIS:||||||F||||||
OBX|7|ST|&BODY||COMPARISON: NONE||||||F||||||
OBX|8|ST|&BODY||||||||F||||||
OBX|9|ST|&BODY||PROTOCOL: Axial images|F||||||
OBX|10|ST|&BODY||||||||F||||||
OBX|11|ST|&BODY||FINDINGS: The liver, spleen, adrenal glands, ||||||F||||||
OBX|12|ST|&BODY||||||||F||||||
OBX|13|ST|&BODY||PELVIS: The large and small bowel .||||||F||||||
OBX|14|ST|&BODY||||||||F||||||
OBX|15|ST|&BODY||IMPRESSION: ||||||F||||||
OBX|16|ST|&BODY||1. Normal CT scan of the abdomen and pelvis.||||||F||||||
OBX|17|ST|&BODY||||||||F||||||
OBX|18|ST|&BODY||IMAGES: 85||||||F||||||
OBX|19|ST|&BODY||||||||F||||||
OBX|20|ST|&BODY||COMPARISON: NONE||||||F||||||
OBX|21|ST|&BODY||||||||F||||||
OBX|22|ST|&BODY||INDICATION: indication||||||F||||||
OBX|23|ST|&BODY||||||||F||||||
OBX|24|ST|&BODY||FINDINGS: findings||||||F||||||
OBX|25|ST|&BODY||||||||F||||||
OBX|26|ST|&BODY||IMPRESSION: text for test||||||F||||||
OBX|27|ST|&BODY||||||||F||||||
OBX|28|ST|&BODY||THIS DOCUMENT HAS BEEN ELECTRONICALLY SIGNED||||||F||||||
OBX|29|ST|&BODY||||||||F||||||
OBX|30|ST|&BODY||Joe Doctor, MD||||||F||||||
OBX|31|ST|&BODY||||||||F||||||
OBX|32|ST|&BODY||08/16/2012 11:36 EST||||||F||||||
OBX|33|ST|&BODY||||||||F||||||
OBX|34|ST|&BODY||M.D. Please call with questions.||||||F||||||
OBX|35|ST|&BODY||||||||F||||||
OBX|36|ST|&BODY||||||||F||||||

Jaypell22 02-06-2014 09:39 AM

Hey Guys. Still getting stuck with this. &BODY shows up in all 3.1 fields however I am looking to get &IMP in 3.1 for every line starting where the word "Impression" shows up. It should look like this when its working:

OBX|1|ST|&BODY||Referring Physician: Joe Physician||||||F||||||
OBX|2|ST|&BODY||||||||F||||||
OBX|3|ST|&BODY||Patient Name: EMERGENCY TEST||||||F||||||
OBX|4|ST|&BODY||||||||F||||||
OBX|5|ST|&BODY||||||||F||||||
OBX|6|ST|&BODY||EXAM: CT ABDOMEN AND PELVIS:||||||F||||||
OBX|7|ST|&BODY||COMPARISON: NONE||||||F||||||
OBX|8|ST|&BODY||||||||F||||||
OBX|9|ST|&BODY||PROTOCOL: Axial images|F||||||
OBX|10|ST|&BODY||||||||F||||||
OBX|11|ST|&BODY||FINDINGS: The liver, spleen, adrenal glands, ||||||F||||||
OBX|12|ST|&BODY||||||||F||||||
OBX|13|ST|&BODY||PELVIS: The large and small bowel .||||||F||||||
OBX|14|ST|&BODY||||||||F||||||
OBX|15|ST|&BODY||IMPRESSION: ||||||F||||||
OBX|16|ST|&BODY||1. Normal CT scan of the abdomen and pelvis.||||||F||||||
OBX|17|ST|&BODY||||||||F||||||
OBX|18|ST|&BODY||IMAGES: 85||||||F||||||
OBX|19|ST|&BODY||||||||F||||||
OBX|20|ST|&BODY||COMPARISON: NONE||||||F||||||
OBX|21|ST|&BODY||||||||F||||||
OBX|22|ST|&BODY||INDICATION: indication||||||F||||||
OBX|23|ST|&BODY||||||||F||||||
OBX|24|ST|&BODY||FINDINGS: findings||||||F||||||
OBX|25|ST|&BODY||||||||F||||||
OBX|26|ST|&IMP||IMPRESSION: text for test||||||F||||||
OBX|27|ST|&IMP||||||||F||||||
OBX|28|ST|&IMP||THIS DOCUMENT HAS BEEN ELECTRONICALLY SIGNED||||||F||||||
OBX|29|ST|&IMP||||||||F||||||
OBX|30|ST|&IMP||Joe Doctor, MD||||||F||||||
OBX|31|ST|&IMP||||||||F||||||
OBX|32|ST|&IMP||08/16/2012 11:36 EST||||||F||||||
OBX|33|ST|&IMP||||||||F||||||
OBX|34|ST|&IMP||M.D. Please call with questions.||||||F||||||
OBX|35|ST|&IMP||||||||F||||||
OBX|36|ST|&IMP||||||||F||||||


All times are GMT -8. The time now is 03:29 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation