web stats
Need to delete OBX segments I don't need - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 03-12-2009, 08:06 AM
aht75 aht75 is offline
OBX.2 Kenobi
 
Join Date: Oct 2008
Location: Atlanta, GA
Posts: 61
aht75
Default Need to delete OBX segments I don't need

Can someone tell me what it is I am doing wrong with this code? I'm trying to delete OBX segments, where the OBX-3.1 field is "DELETE".


var segCountOBX = 0;

for each (segment in msg.children() ){
if(segment.name() == "OBX"){
if (msg['OBX'][segCountOBX]['OBX.3']['OBX.3.1'].toString() == "DELETE") {

delete msg['OBX'][segCountOBX];
}

segCountOBX = segCountOBX + 1;

}
}


This is the error I keep getting:

ERROR-300: Transformer error
ERROR MESSAGE: Error evaluating transformer
com.webreach.mirth.server.MirthJavascriptTransform erException:
CHANNEL: Nursing Mod
CONNECTOR: sourceConnector
SCRIPT SOURCE:
LINE NUMBER: 137
DETAILS: TypeError: Cannot read property "OBX.3" from undefined
at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.evaluateScript(JavaScriptTransform er.java:448)
at com.webreach.mirth.server.mule.transformers.JavaSc riptTransformer.transform(JavaScriptTransformer.ja va:350)
at org.mule.transformers.AbstractEventAwareTransforme r.doTransform(AbstractEventAwareTransformer.java:4 8)
at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:197)
at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
at org.mule.transformers.AbstractTransformer.transfor m(AbstractTransformer.java:200)
at org.mule.impl.MuleEvent.getTransformedMessage(Mule Event.java:251)
at org.mule.routing.inbound.SelectiveConsumer.isMatch (SelectiveConsumer.java:61)
at org.mule.routing.inbound.InboundMessageRouter.rout e(InboundMessageRouter.java:83)
at org.mule.providers.AbstractMessageReceiver$Default InternalMessageListener.onMessage(AbstractMessageR eceiver.java:493)
at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:272)
at org.mule.providers.AbstractMessageReceiver.routeMe ssage(AbstractMessageReceiver.java:244)
at com.webreach.mirth.connectors.mllp.MllpMessageRece iver$TcpWorker.processHL7Data(MllpMessageReceiver. java:476)
at com.webreach.mirth.connectors.mllp.MllpMessageRece iver$TcpWorker.processData(MllpMessageReceiver.jav a:436)
at com.webreach.mirth.connectors.mllp.MllpMessageRece iver$TcpWorker.run(MllpMessageReceiver.java:353)
at org.mule.impl.work.WorkerContext.run(WorkerContext .java:290)
at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.runTask(ThreadPoolExecutor. java:650)
at edu.emory.mathcs.backport.java.util.concurrent.Thr eadPoolExecutor$Worker.run(ThreadPoolExecutor.java :675)
at java.lang.Thread.run(Unknown Source)


This is a sample of what the HL7 looks like:

MSH|^~\&|PreOpPlanner|INH|MediTech Nursing Module|INH|20090311||ORU^R01|39|P|2.3
PID|1||M30112009||Eleven^March||19501010|M|||||||| ||C30112009
OBR|1|||^Vitals|||20090311
OBX|1|SN|DELETE^Current wheezing or difficulty breathing^Docusys_HQ||1||||||F
OBX|2|SN|Pregnant^Patient pregnancy status^Docusys_HQ||||||||F
OBX|3|SN|DELETE^C/O chest pain at rest^Docusys_HQ||1||||||F
OBX|4|ST|DELETE^C/O chest pain at rest comment^Docusys_HQ||||||||F
OBX|5|SN|DELETE^C/O chest pain at rest diagnosed^Docusys_HQ||1||||||F
OBX|6||Conditions^Conditions^Docusys_HQ||||||||F
OBX|7||DELETE^METS^Docusys_HQ||||||||F

Post edited by: aht75, at: 03/12/2009 08:12
Reply With Quote
  #2  
Old 03-12-2009, 08:30 AM
MikeCaldwell MikeCaldwell is offline
Where are the forums?
 
Join Date: Mar 2008
Location: Sacramento, CA
Posts: 156
MikeCaldwell
Default Re:Need to delete OBX segments I don't need

That is the same thign I was trying with IN1 and got the same type error, hopefully someone can help. Both the OBX and IN1 have muliple nodes I guess it's called.
__________________
Mike Caldwell
Alliance HealthCare - GE VAR
Rocklin, CA
Centricity PM/EMR Support - Developer - Network Engineer
http://MirthPRO.Com
Reply With Quote
  #3  
Old 03-12-2009, 09:09 AM
aht75 aht75 is offline
OBX.2 Kenobi
 
Join Date: Oct 2008
Location: Atlanta, GA
Posts: 61
aht75
Default Re:Need to delete OBX segments I don't need

The code should work, I can't really understand why it doesn't. If I try to apply a literal value to a particular field using the same code, it works fine, but somehow when I try to delete those specific repetitions of OBX it does not.

Any pointers on how to handle this would be greatly appreciated.
Reply With Quote
  #4  
Old 03-12-2009, 05:43 PM
MikeCaldwell MikeCaldwell is offline
Where are the forums?
 
Join Date: Mar 2008
Location: Sacramento, CA
Posts: 156
MikeCaldwell
Default Re:Need to delete OBX segments I don't need

This code works to change IN1-2.1="K" so that later I want to delete the segment with IN1|K||||||

var count = 1;
var segCount = 0;
for each (segment in msg.children() )
{
if(segment.name() == "IN1")
{
channelMap.put(msg['IN1'][segCount]['IN1.2']['IN1.2.1'],'IN1-2.1');
//
switch (msg['IN1'][segCount]['IN1.47']['IN1.47.1'].toString())
{
case("M"):
msg['IN1'][segCount]['IN1.47']['IN1.47.1'] = "MEDICAL";
msg['IN1'][segCount]['IN1.2']['IN1.2.1'] = count;
count++;
break;
//
case("D"):
msg['IN1'][segCount]['IN1.47']['IN1.47.1'] = "DENTAL";
msg['IN1'][segCount]['IN1.2']['IN1.2.1'] = count;
count++;
break;
//
case("O"):case("P"):case"":
msg['IN1'][segCount]['IN1.2']['IN1.2.1'] = "K";
// delete msg['IN1'][segCount]; <<<<<<<<<<< THIS DIDNT WORK
// delete tmp['IN1'][segCount]; <<<<<<<<<<< THIS SAID THERE IS NOT tmp[xx]...
break;
}
segCount = segCount + 1;
}
}

SO my output was this:

IN1|1|||...
IN1|2|||...
IN1|K|||...
IN1|K|||...

IN1|3|||...

I just wanted to go back and KILL the items with "K" in IN1-1 and this code won't do it either. I just wanted to use the one line. At one point somehow I was deleting segments.

var segCountIN1 = 0;
for each (segment in msg.children())
{
if(segment.name() == "IN1")
{
if (msg['IN1'][segCountIN1]['IN1.1']['IN1.1'].toString() == "K")
{
delete msg['IN1'][segCountIN1];
}
segCountIN1++;
}
}
__________________
Mike Caldwell
Alliance HealthCare - GE VAR
Rocklin, CA
Centricity PM/EMR Support - Developer - Network Engineer
http://MirthPRO.Com
Reply With Quote
  #5  
Old 03-12-2009, 09:06 PM
aht75 aht75 is offline
OBX.2 Kenobi
 
Join Date: Oct 2008
Location: Atlanta, GA
Posts: 61
aht75
Default Re:Need to delete OBX segments I don't need

I've tried the very same logic, putting a zero "0" for the set ID's for OBXs I didn't need to try and delete them later, and it didn't work. Not sure if this is a bug, or if there is something we're missing. I can apply all sorts of logic and mapping, the only thing I can't do is delete based on that condition.
Reply With Quote
  #6  
Old 03-12-2009, 10:07 PM
MikeCaldwell MikeCaldwell is offline
Where are the forums?
 
Join Date: Mar 2008
Location: Sacramento, CA
Posts: 156
MikeCaldwell
Default Re:Need to delete OBX segments I don't need

I have
IN1|1|
..
IN1|8|


WHY does this delete IN1-1 1,3,5,7 and leaves IN1 2,4,6,8
makes no sense at all.

DOES ANYONE KNOW WHY DELETE DOES NOT WORK????

var segCountIN1 = 0;
//for each (segment in msg.children())
for each (obx in msg..IN1)
{
// if(in1.name() == "IN1")
// {
//if (msg['IN1'][segCountIN1]['IN1.1']['IN1.1.1'] = "K")
//{
delete msg['IN1'][segCountIN1];
//}
channelMap.put(segCountIN1,'segCountIN1')
channelMap.put(msg['IN1'][segCountIN1],'segCountIN1MSG-'+segCountIN1)
segCountIN1 = segCountIN1 + 1;
// }
}
__________________
Mike Caldwell
Alliance HealthCare - GE VAR
Rocklin, CA
Centricity PM/EMR Support - Developer - Network Engineer
http://MirthPRO.Com
Reply With Quote
  #7  
Old 03-13-2009, 03:03 PM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default Re:Need to delete OBX segments I don't need

// this code should work.
for(var i=0;i<msg['OBX'].length();i++ ){
if (msg['OBX'][i]['OBX.3']['OBX.3.1'].toString() == "DELETE") {
delete msg['OBX'][i];
i--;
}
}
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #8  
Old 03-13-2009, 03:04 PM
dans dans is offline
Mirth Employee
 
Join Date: Apr 2007
Location: Irvine, CA
Posts: 590
dans is an unknown quantity at this point
Default Re:Need to delete OBX segments I don't need

the indexes change when you delete a segment. If you delete the first segment the second segment is now the first segment etc.
__________________
Daniel Svanstedt
Software Engineer
Mirth Corporation

Want professional services, support, and enterprise or virtual appliances? It's all available from the Mirth Corporation:
Mirth Support | Mirth Training | Mirth Appliances | Online Training | Developer Q&A

Don't forget, Mirth Support gives you access to all of our online training videos, and silver support gives you access to developer Q&As!
Reply With Quote
  #9  
Old 03-13-2009, 06:12 PM
aht75 aht75 is offline
OBX.2 Kenobi
 
Join Date: Oct 2008
Location: Atlanta, GA
Posts: 61
aht75
Default Re:Need to delete OBX segments I don't need

THAT WORKED Thank you very much Dan, I really appreciate your help.
Reply With Quote
  #10  
Old 08-14-2012, 01:47 PM
hjohnson hjohnson is offline
OBX.1 Kenobi
 
Join Date: Dec 2006
Location: Little Rock, AR
Posts: 30
hjohnson
Default

I used 'downto' in loops deleting elements in Delphi. Would this work?

for(var i=msg['OBX'].length(); i>-1 ;i-- )
{
if (msg['OBX'][i]['OBX.3']['OBX.3.1'].toString() == "DELETE")
{
delete msg['OBX'][i];
}
}
Reply With Quote
Reply

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete old files JasonGriffith Support 2 10-09-2009 12:49 AM
Multiple IN1 Segments with Optional IN2 Segments bdilworth Support 4 07-29-2008 11:24 AM
How to delete a segment from message...? faisalamjad Development 1 04-28-2008 01:57 PM
simple transformer to delete OBX 16 cgbullock Support 5 12-05-2007 01:15 PM
Please delete this post jlehew Support 0 10-31-2007 02:45 PM


All times are GMT -8. The time now is 04:53 PM.


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