Mirth Community

Mirth Community (http://www.mirthcorp.com/community/forums/index.php)
-   Support (http://www.mirthcorp.com/community/forums/forumdisplay.php?f=6)
-   -   Remove 1 OBX line based on beginning text (http://www.mirthcorp.com/community/forums/showthread.php?t=12668)

Jaypell22 01-08-2015 09:13 AM

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||||||

cory_cole 01-08-2015 09:15 AM

for each (obx in msg..OBX)
{
if (obx['OBX.5']['OBX.5.1'].toString().toUpperCase() == 'EXAM')
{
delete obx;
}
}

Jaypell22 01-08-2015 09:53 AM

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?

cory_cole 01-08-2015 09:56 AM

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;
}
}

Jaypell22 01-08-2015 10:42 AM

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||||||

cory_cole 01-08-2015 11:56 AM

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++;
}

Jaypell22 01-08-2015 12:21 PM

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++;
}

deuteronomy 09-02-2015 07:59 AM

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}

deuteronomy 09-02-2015 08:39 AM

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--];
}


All times are GMT -8. The time now is 11:12 AM.

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