web stats
Remove 1 OBX line based on beginning text - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-08-2015, 09:13 AM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 33
Jaypell22 is on a distinguished road
Default Remove 1 OBX line based on beginning text

Hi All. I am trying to remove a single OBX line from an ORU that will not be on the same line number each time. This line will always begin with "EXAM:" in OBX.5 and may be capitalized, lower case or a combination. The text "EXAM" will be in other lines but will never be at the beginning of the line. Thanks for any help. Example message below.

OBX|1|ST|||Referring Physician: TEST REF||||||P||||||
OBX|2|ST|||||||||P||||||
OBX|3|ST|||Patient Name: TEST PATIENT||||||P||||||
OBX|4|ST|||||||||P||||||
OBX|5|ST|||FINAL REPORT||||||P||||||
OBX|6|ST||| ||||||P||||||
OBX|7|ST|||EXAM: CT abdomen with contrast and CT pelvis with contrast||||||P||||||
OBX|8|ST||| ||||||P||||||
OBX|9|ST|||IMAGES: 306||||||P||||||
OBX|10|ST||| ||||||P||||||
OBX|11|ST|||EXAM DATE AND TIME: 2015-01-08 02:56:07.0||||||P||||||
OBX|12|ST||| ||||||P||||||
OBX|13|ST|||REASON FOR EXAM: ||||||P||||||
OBX|14|ST||| ||||||P||||||
OBX|15|ST|||Left abdominal pain||||||P||||||
OBX|16|ST||| ||||||P||||||
OBX|17|ST|||COMPARISON: None.||||||P||||||
OBX|18|ST||| ||||||P||||||
OBX|19|ST|||FINDINGS:||||||P||||||
Reply With Quote
  #2  
Old 01-08-2015, 09:15 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

for each (obx in msg..OBX)
{
if (obx['OBX.5']['OBX.5.1'].toString().toUpperCase() == 'EXAM')
{
delete obx;
}
}
Reply With Quote
  #3  
Old 01-08-2015, 09:53 AM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 33
Jaypell22 is on a distinguished road
Default

Thanks for the quick reply Cory. I'm trying to find code that specifically looks at the line to see if it starts with "EXAM:" not equals. Any ideas?
Reply With Quote
  #4  
Old 01-08-2015, 09:56 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

sorry meant to add that ...

for each (obx in msg..OBX)
{
if (obx['OBX.5']['OBX.5.1'].toString().substring(0,4).toUpperCase() == 'EXAM')
{
delete obx;
}
}
Reply With Quote
  #5  
Old 01-08-2015, 10:42 AM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 33
Jaypell22 is on a distinguished road
Default

It does not seem to do anything. Below is one of the exact messages I am processing.

MSH|^~\&|Mirth||Mirth||201501080752||ORU^R01|20150 1080752102500292|P|2.3
PID|1|123456|123456||Test^Joe^||19470116|M|||||||| ||||
PV1|1||Test Hospital|||||Blank|||||||||||||||||||||||||||||||| |||||||||||||
ORC|RE
OBR|1||12345|^CHEST, PORTABLE|||201501080705|||||||||Blank||||||||CR|P| ||||||joerad^rad^joe|||||||||||||
OBX|1|ST|||COMPARISON: Chest x-ray||||||P||||||
OBX|2|ST||| ||||||P||||||
OBX|3|ST|||FINDINGS: Frontal portable chest radiograph.||||||P||||||
OBX|4|ST||| ||||||P||||||
OBX|5|ST|||Exam: There is been interval pole of the endotracheal tube and NG tube. Stable cardiomegaly. Bibasilar patchy infiltrates again seen, may be mildly improved on the right. There are small bilateral pleural effusions. No definite pneumothorax. Lung fields are hyperinflated.||||||P||||||
OBX|6|ST||| ||||||P||||||
OBX|7|ST|||IMPRESSION: Interval removal of an endotracheal tube and NG tube. Patchy bibasilar infiltrates again seen, maybe mildly improved on the right.||||||P||||||
OBX|8|ST|||||||||P||||||
OBX|9|ST|||||||||P||||||
OBX|10|ST|||THIS DOCUMENT HAS BEEN ELECTRONICALLY SIGNED||||||P||||||
OBX|11|ST|||||||||P||||||
OBX|12|ST|||Joe Rad M.D||||||P||||||
OBX|13|ST|||||||||P||||||
OBX|14|ST|||01/01/2015 01:51||||||P||||||
OBX|15|ST|||||||||P||||||
Reply With Quote
  #6  
Old 01-08-2015, 11:56 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,360
cory_cole is on a distinguished road
Default

Try this...


var i = 0;
for each (obx in msg..OBX)
{
if (obx['OBX.5']['OBX.5.1'].toString().substring(0,4).toUpperCase() == 'EXAM')
{
delete msg['OBX'][i];
}
i++;
}
Reply With Quote
  #7  
Old 01-08-2015, 12:21 PM
Jaypell22 Jaypell22 is offline
OBX.1 Kenobi
 
Join Date: Jul 2011
Location: Upstate NY
Posts: 33
Jaypell22 is on a distinguished road
Thumbs up

Brilliant!! Thank you. Worked like a charm. Only item I had to add was the below code to re-number the OBX lines. Again...thanks for your help!


var OBXCounter = 1;
for each (seg in msg..OBX)
{
seg['OBX.1']['OBX.1.1'] = OBXCounter;
OBXCounter++;
}
Reply With Quote
  #8  
Old 09-02-2015, 07:59 AM
deuteronomy deuteronomy is offline
Mirth Newb
 
Join Date: Dec 2014
Posts: 22
deuteronomy is on a distinguished road
Default not working

Hi, I adapted this javascript to remove any OBX that has ED in OBX 2.1 but some messages, out of thousands thats work, did not remove all the OBX lines

var i = 0;
for each (obx in msg..OBX)
{
if (obx['OBX.2']['OBX.2.1'].toString().substring(0,2).toUpperCase() == 'ED')
{
delete msg['OBX'][i];
logger.debug("Stripping OBX attatchments");
}
i++;
}


eg RAW

OBX|1|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:15ef9a75-d8f8-4ffd-99e4-c35217493158}
OBX|2|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:26e30c85-bf7a-4068-b843-ea4ffe52b358}
OBX|3|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:dddaeb2d-34a2-407c-bb93-a4da2e29644f}
OBX|4|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:766b0d5c-7731-4ec6-9bd7-42fc965ee2d8}
OBX|5|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:291e0edb-ccf6-443d-b6f0-a16b2d01f459}
OBX|6|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:75e2b42e-457a-4025-9f84-cbfe5df06a22}
OBX|7|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:5307dbce-6089-423b-ab0e-7d8919a35a54}

SENT

OBX|2|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:26e30c85-bf7a-4068-b843-ea4ffe52b358}
OBX|4|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:766b0d5c-7731-4ec6-9bd7-42fc965ee2d8}
OBX|6|ED|REQCARD^REQCARD^||^IM^JPEG^Base64^${ATTAC H:75e2b42e-457a-4025-9f84-cbfe5df06a22}
Reply With Quote
  #9  
Old 09-02-2015, 08:39 AM
deuteronomy deuteronomy is offline
Mirth Newb
 
Join Date: Dec 2014
Posts: 22
deuteronomy is on a distinguished road
Default

I believe this does the trick

for (var i = 0; i <= msg.elements('OBX').length()-1; i++) {
msg.OBX[i]['OBX.1']['OBX.1.1'] = i+1;
if (msg.OBX[i]['OBX.2']['OBX.2.1'].toString() == 'ED')
delete msg.OBX[i--];
}
Reply With Quote
Reply

Tags
obx delete, obx single line

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 08:36 PM.


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