Announcement

Collapse
No announcement yet.

OBX manipulation and headers

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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'] = 
    	}
    }

    Comment


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

      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'] = 
      	}
      }

      Comment

      Working...
      X