web stats
OBX manipulation and headers - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 08-24-2016, 12:33 PM
fchang888 fchang888 is offline
Mirth Newb
 
Join Date: Mar 2015
Posts: 19
fchang888 is on a distinguished road
Default OBX manipulation and headers

Mirth v3.2.2.7694

I need to compare OBX-3.1 with the next OBX-3.1 then place a header OBX.
So if the compare is different, I insert the OBX header (see the expected output). I have to create the header for the first one regardless.

I've tried many different options but I am at a point where I would like
a 2nd set of eyes from the forum.

Sample code :


// Header OBX already created...
...
...

var k = 0;
var next_k = 1;

// maxOBXcount contain the number of OBXs
if (next_k < maxOBXcount){

if (msg['OBX'][k]['OBX.3.1'].toString() == msg['OBX'][next_k]['OBX.3.1'].toString()){

// This is where the inbound OBX is being overwritten.

}


Sample inbound...

OBX|1|ST|104^Case Report^CHGENLRR^^^^^^LAB AP CASE REPORT||Gynecologic Cytology Case: C16-00237 ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xx BARB
OBX|2|ST|104^Case Report^CHGENLRR^^^^^^LAB AP CASE REPORT||Authorizing Provider: Margaret L Dodds, MD Collected: 07/28/2016 0800 ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx xx^^xxx xxx^CA^xx^USA^B^^xxx BARB
OBX|3|ST|104^Case Report^CHGENLRR^^^^^^LAB AP CASE REPORT||First Screen: Cytotechnologist Pathology Received: 07/28/2016 0813 ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|4|ST|104^Case Report^CHGENLRR^^^^^^LAB AP CASE REPORT||Specimen: ThinPrep, Imaged, Cervix/Endocervix ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|5|ST|1810924^CLINICAL HISTORY^CHGENLRR^^^^^^LAB AP CLINICAL HISTORY||None Provided||||||F|||20160728080000|||||2016080811233 0||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|6|ST|16^INTERPRETATION^CHGENLRR^^^^^^LAB AP GYN INTERPRETATION||NEGATIVE FOR INTRAEPITHELIAL LESION OR MALIGNANCY||||||F|||20160728080000|||||20160808112 330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB


Expected outbound

OBX|1|ST|REPORT||Case Report ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|1|ST|REPORT||Gynecologic Cytology Case: C16-00237 ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|2|ST|REPORT||Authorizing Provider: Margaret L Dodds, MD Collected: 07/28/2016 0800 ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|3|ST|REPORT||First Screen: Cytotechnologist Pathology Received: 07/28/2016 0813 ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|4|ST|REPORT||Specimen: ThinPrep, Imaged, Cervix/Endocervix ||||||F|||20160728080000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|5|ST|REPORT||CLINICAL HISTORY||||||F|||20160728080000|||||20160808112330 ||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|5|ST|REPORT||None Provided||||||F|||20160728080000|||||2016080811233 0||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|6|ST|REPORT||INTERPRETATION||||||F|||201607280 80000|||||20160808112330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
OBX|6|ST|REPORT||NEGATIVE FOR INTRAEPITHELIAL LESION OR MALIGNANCY||||||F|||20160728080000|||||20160808112 330||||PD CORE LABORATORY^D^^^^CLIA^XX^^^05D0668637|xxx xxx xxx AVENUE^^xxx xxx^CA^xxx^USA^B^^xxx BARB
Reply With Quote
  #2  
Old 08-24-2016, 01:40 PM
eduardoa eduardoa is offline
Mirth Employee
 
Join Date: Mar 2013
Location: Santa Fe Springs, California
Posts: 134
eduardoa is on a distinguished road
Default

I think for what you're looking for you can just insert a header anytime you find a new 3.1. Maybe something like this could get you started.

Code:
var currentHeader;
for each(seg in msg.children()){
	if(seg.name() == 'OBX'){
		if(!seg['OBX.3']['OBX.3.1'].toString() == currentHeader){
			currentHeader = seg['OBX.3']['OBX.3.1'].toString();

			//create header and modify as needed
			var headerOBX = new XML("<OBX></OBX>");
			headerOBX['OBX.3']['OBX.3.1'] = currentHeader;
			msg.insertChildBefore(seg, headerOBX);
		}

		//can still modify current obx seg as needed
		//seg['OBX.3']['OBX.3.1'] = 
	}
}
Reply With Quote
  #3  
Old 08-25-2016, 04:34 PM
fchang888 fchang888 is offline
Mirth Newb
 
Join Date: Mar 2015
Posts: 19
fchang888 is on a distinguished road
Thumbs up

Thanks eduardoa! This works with some additional coding in there for other items.

Quote:
Originally Posted by eduardoa View Post
I think for what you're looking for you can just insert a header anytime you find a new 3.1. Maybe something like this could get you started.

Code:
var currentHeader;
for each(seg in msg.children()){
	if(seg.name() == 'OBX'){
		if(!seg['OBX.3']['OBX.3.1'].toString() == currentHeader){
			currentHeader = seg['OBX.3']['OBX.3.1'].toString();

			//create header and modify as needed
			var headerOBX = new XML("<OBX></OBX>");
			headerOBX['OBX.3']['OBX.3.1'] = currentHeader;
			msg.insertChildBefore(seg, headerOBX);
		}

		//can still modify current obx seg as needed
		//seg['OBX.3']['OBX.3.1'] = 
	}
}
Reply With Quote
Reply

Tags
compare, obx, renumbering

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 12:38 AM.


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