Oscar Integration with Meditech: NE LHIN

Oscar Integration with Meditech has occurred in Northern Ontario through the North East LHIN with the Physician Office Integration project


Preface

The North East LHIN has provided HL7 file output from many of the regions hospitals.  A similar export is available in the North West LHIN.  The HL7 files provided do not currently render properly under Oscar.  This is a method to make them work.

Document Version History

This document is copyright by Peter Hutten-Czapski 2013 © under the Creative Commons Attribution-Share Alike 3.0 Unported License

 

 

Prerequisites

It is assumed that you or the implementation person(s) will require

  1. some knowledge of Mirth (fairly easy)
  2. a good knowledge of javascript and regular expressions to parse the input
  3. a thorough understanding of HL7 messaging
  4. some understanding of how to set up the mule transport that OSCAR uses to suck up HL7 (fairly easy)
  5. significant time to tune to your particular output formats

HOW TO CONNECT TO MEDITECH HL7 OUTPUT

 

all software is open source unless identified as not

Step 1. Get a file of output

Speak to Sudbury to get authentication credentials to SFTP access to files for your group

Step 2. Install HL7 File transport on Client

Configure a "CML" channel to Oscar through instructions provided with the hl7_file_management project

NOTE it currently is a maven project.  If you prefer you can download an older version that is an ant project

Step 3. Install Mirth Connect on Client.

You have in step 1 gotten access to files in POI HL7 dialect  and in step 2 configured a way to receive CML type files.  Mirth Connect bridges those two pieces.  It does the following

  1. It will regularly poll the Sudbury POI sftp site for your files
  2. It downloads them and will transform them into CML format with a XML script that is provided below
  3. It will then send the transformed file to the incoming directory for CML that you configured in 2

I use Mirth currently 1.8.0.4126 with Sun Java 1.6.0_11 configured to store messages in MySQL http://www.mirthproject.org/

 

The following is the channel that I currently use with anything sensitive replaced with xxx 

To install save the following as sudbury.xml and import into your Mirth Connect instance

 

<com.webreach.mirth.model.Channel>
  <id>06dd2dce-2745-4559-a5ab-132e30ac89ef</id>
  <name>Sudbury to OSCAR - LIVE</name>
  <description>Takes semi-valid HL7 v2 and &quot;cleans them&quot; for OSCAR including&#x0D;
1) Drop PV1&#x0D;
2) Add in ORC&#x0D;
3) Changing OBX  to &apos;NTE&apos; so they map clean&#x0D;
1000000 ms poling is about every 16 minutes&#x0D;
&#x0D;
Password needs to be changed every so often&#x0D;
</description>
  <enabled>true</enabled>
  <version>1.8.0.4126</version>
  <lastModified>
    <time>1360195537000</time>
    <timezone>America/New_York</timezone>
  </lastModified>
  <revision>538</revision>
  <sourceConnector>
    <name>sourceConnector</name>
    <properties>
      <property name="binary">0</property>
      <property name="fileFilter">*.HL7</property>
      <property name="password">xxxxx</property>
      <property name="username">xxxx</property>
      <property name="moveToDirectory"></property>
      <property name="moveToErrorDirectory">C:/messages/errorHL7dir</property>
      <property name="pollingType">interval</property>
      <property name="charsetEncoding">DEFAULT_ENCODING</property>
      <property name="scheme">sftp</property>
      <property name="host">xxx.xxxxxxx.xx/xxxxx/xxxx/xxxx</property>
      <property name="pollingFrequency">1000000</property>
      <property name="validateConnections">1</property>
      <property name="DataType">File Reader</property>
      <property name="processBatchFiles">0</property>
      <property name="passive">1</property>
      <property name="checkFileAge">1</property>
      <property name="fileAge">1000</property>
      <property name="sortAttribute">date</property>
      <property name="FTPAnonymous">0</property>
      <property name="moveToPattern"></property>
      <property name="autoDelete">1</property>
    </properties>
    <transformer>
      <steps/>
      <inboundTemplate></inboundTemplate>
      <outboundTemplate></outboundTemplate>
      <inboundProtocol>HL7V2</inboundProtocol>
      <outboundProtocol>HL7V2</outboundProtocol>
      <inboundProperties>
        <property name="handleRepetitions">false</property>
        <property name="convertLFtoCR">false</property>
        <property name="useStrictValidation">false</property>
        <property name="useStrictParser">false</property>
      </inboundProperties>
      <outboundProperties>
        <property name="handleRepetitions">false</property>
        <property name="convertLFtoCR">true</property>
        <property name="useStrictValidation">false</property>
        <property name="useStrictParser">false</property>
      </outboundProperties>
    </transformer>
    <filter>
      <rules/>
    </filter>
    <transportName>File Reader</transportName>
    <mode>SOURCE</mode>
    <enabled>true</enabled>
  </sourceConnector>
  <destinationConnectors>
    <com.webreach.mirth.model.Connector>
      <name>File writer to C:/messages...</name>
      <properties>
        <property name="scheme">file</property>
        <property name="binary">0</property>
        <property name="username">anonymous</property>
        <property name="outputPattern">t_${COUNT}${ORIGINALNAME}</property>
        <property name="validateConnections">1</property>
        <property name="DataType">File Writer</property>
        <property name="FTPAnonymous">1</property>
        <property name="charsetEncoding">DEFAULT_ENCODING</property>
        <property name="password">anonymous</property>
        <property name="passive">1</property>
        <property name="template">${message.encodedData}</property>
        <property name="outputAppend">0</property>
        <property name="host">C:/messages/incomingHL7dir</property>
      </properties>
      <transformer>
        <steps>
          <com.webreach.mirth.model.Step>
            <sequenceNumber>0</sequenceNumber>
            <name>Sudbury to OSCAR</name>
            <script>// Copyright (c) 2011-2012 by Peter Hutten-Czapski

//msg - array representing XML of the data being transformed

//makework fix the input back to Su=dbury standard Processing ID
msg[&apos;MSH&apos;][&apos;MSH.11&apos;][&apos;MSH.11.1&apos;]=&quot;T&quot;;
//end makework

//OSCAR handles versions 2.5, 2.6, 2.3, 2.2
//so make HAPI happy if its 2.4 by downgrading
//if (msg[&apos;MSH&apos;][&apos;MSH.12&apos;][&apos;MSH.12.1&apos;].toString()==&quot;2.4&quot;) {
	msg[&apos;MSH&apos;][&apos;MSH.12&apos;][&apos;MSH.12.1&apos;]=&quot;2.3&quot;;
//}

//set some natural language locations, especially if particularly obscure
if (msg[&apos;MSH&apos;][&apos;MSH.4&apos;][&apos;MSH.4.1&apos;].toString()==&quot;TEM&quot;){
	msg[&apos;MSH&apos;][&apos;MSH.4&apos;][&apos;MSH.4.1&apos;]=&quot;Temiskaming Hospital&quot;;
}
if (msg[&apos;MSH&apos;][&apos;MSH.4&apos;][&apos;MSH.4.1&apos;].toString()==&quot;SJH&quot;){
	msg[&apos;MSH&apos;][&apos;MSH.4&apos;][&apos;MSH.4.1&apos;]=&quot;North Bay Regional&quot;;
}

// fudge if something has passed all prior opportunities
	if (msg[&apos;OBX&apos;][0][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;].length()&lt;1) {
		msg[&apos;OBX&apos;][0][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;]=&quot;Report&quot;;
	}
var i=0;
var hin=&quot;&quot;;
for (pid in msg..PID){
	// populate PID.4 the Alternate Patient ID with the HIN from PID.3 so Oscar can display it
	msg[&apos;PID&apos;][i][&apos;PID.4&apos;][&apos;PID.4.1&apos;] =  msg[&apos;PID&apos;][i][&apos;PID.2&apos;][&apos;PID.2.1&apos;].toString();
	msg[&apos;PID&apos;][i][&apos;PID.4&apos;][&apos;PID.4.2&apos;] =  msg[&apos;PID&apos;][i][&apos;PID.2&apos;][&apos;PID.2.2&apos;].toString();
	//msg[&apos;PID&apos;][i][&apos;PID.4&apos;][&apos;PID.4.3&apos;] =  msg[&apos;PID&apos;][i][&apos;PID.2&apos;][&apos;PID.2.3&apos;].toString();

	i++;

}

//Iterate through the segments OBX observations/results
// add and remove some

var NTEcount = 0; // new notes start at 0
var OBRcount = 0;
var OBXcount = 0;
var nte = createSegment(&apos;NTE&apos;);
var noteArray=new Array();
var noteIndex=new Array();
var ptCount=0;
var PV1count=0;
var categorytype=&quot;REPORT&quot;;
var reporttype=&quot;NEON REPORT&quot;;
var obr42=&quot;&quot;;
var obx31=&quot;&quot;;
var x=&quot;t&quot;;

i=0;

for each(segment in msg.children()){
	if(segment.name() == &quot;PID&quot;){

		var dob = segment[&apos;PID&apos;][&apos;PID.7&apos;][&apos;PID.7.1&apos;].toString();
		var gender = segment[&apos;PID&apos;][&apos;PID.8&apos;][&apos;PID.8.1&apos;].toString();
	
	}
	if(segment.name() == &quot;PV1&quot;){
		var attdocid = msg[&apos;OBR&apos;][ptCount][&apos;OBR.32&apos;][&apos;OBR.32.1&apos;].toString()
		var docid = attdocid.split(&quot;&amp;&quot;);
		//var attdocid = msg[&apos;PV1&apos;][ptCount][&apos;PV1.17&apos;][&apos;PV1.17.3&apos;].toString()
		//var docid = attdocid.split(&quot;~&quot;);
		attdocid=docid[0]||&quot;111111&quot;;
		//var attdocName=msg[&apos;PV1&apos;][ptCount][&apos;PV1.17&apos;][&apos;PV1.17.2&apos;].toString()+&quot;, &quot;+ msg[&apos;PV1&apos;][ptCount][&apos;PV1.17&apos;][&apos;PV1.17.3&apos;].toString();
		var attdocName=(docid[1]||&quot;&quot;)+&quot;, &quot;+(docid[2]||&quot;&quot;)
		var orc=createSegment(&apos;ORC&apos;);
		createSegmentAfter(&apos;ORC&apos;, msg[&apos;PV1&apos;][ptCount]);
		msg[&apos;ORC&apos;][ptCount] = orc;
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.1&apos;][&apos;ORC.1.1&apos;] = ptCount+1;
		// provide UUID or Accession Number to ORC.2
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.2&apos;][&apos;ORC.2.1&apos;] = msg[&apos;OBR&apos;][ptCount][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString();
		//provide order status from OBR 25.1
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.5&apos;][&apos;ORC.5.1&apos;] = msg[&apos;OBR&apos;][ptCount][&apos;OBR.25&apos;][&apos;OBR.25.1&apos;].toString();
		//parse OBR28 looking for local doc or use PV1.52
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.12&apos;][&apos;ORC.12.1&apos;] = attdocid
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.12&apos;][&apos;ORC.12.2&apos;] = attdocName
		//order effective time set to message time
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.15&apos;][&apos;ORC.15.1&apos;] = msg[&apos;MSH&apos;][&apos;MSH.7&apos;][&apos;MSH.7.1&apos;].toString();

		delete msg[&apos;PV1&apos;][ptCount];
		ptCount = ptCount+1; //sequence incriment
	}

	if(segment.name() == &quot;OBR&quot;){
		//for sake of argument we will call ther placer (2) to have the same order number as the filler (3)
		msg[&apos;OBR&apos;][OBRcount][&apos;OBR.2&apos;][&apos;OBR.2.1&apos;]=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString();
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.4&apos;][&apos;OBR.4.1&apos;].toString().length&gt;0) {
			//leave it
		} else {
			msg[&apos;OBR&apos;][OBRcount][&apos;OBR.4&apos;][&apos;OBR.4.1&apos;]=&quot;Report&quot;; 
		}
		//fudge to change requested date with observerd date as we look to when a Xray was taken as its  date not the report 
		//if (msg[&apos;OBR&apos;][&apos;OBR.7&apos;][&apos;OBR.7.1&apos;].toString().length&gt;0) {
			//var tdate=msg[&apos;OBR&apos;][&apos;OBR.7&apos;][&apos;OBR.7.1&apos;].toString();
					//msg[&apos;OBR&apos;][&apos;OBR.7&apos;][&apos;OBR.7.1&apos;]=msg[&apos;OBR&apos;][&apos;OBR.6&apos;][&apos;OBR.6.1&apos;].toString();
			//msg[&apos;OBR&apos;][&apos;OBR.6&apos;][&apos;OBR.6.1&apos;]=tdate;
		//}

		//OBR 4.2 not needed and more compact output if dropped, but keep the value
		obr42=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.4&apos;][&apos;OBR.4.2&apos;].toString();
		msg[&apos;OBR&apos;][OBRcount][&apos;OBR.4&apos;][&apos;OBR.4.2&apos;]=&quot;&quot;;
		//if (!((msg[&apos;OBR&apos;][OBRcount][&apos;OBR.21&apos;][&apos;OBR.21.1&apos;].toString()==&quot;TEDIIDIR&quot;)||(msg[&apos;OBR&apos;][OBRcount][&apos;OBR.21&apos;][&apos;OBR.21.1&apos;].toString()==&quot;TEDIIMAM&quot;))) {
		if (msg[&apos;OBR&apos;][&apos;OBR.16&apos;][&apos;OBR.16.1&apos;].toString().length&lt;1) {
			msg[&apos;OBR&apos;][OBRcount][&apos;OBR.16&apos;][&apos;OBR.16.1&apos;]=attdocid;
		}
		if (msg[&apos;OBR&apos;][&apos;OBR.16&apos;][&apos;OBR.16.2&apos;].toString().length&lt;1) {
			msg[&apos;OBR&apos;][OBRcount][&apos;OBR.16&apos;][&apos;OBR.16.2&apos;]=attdocName;
		}
		// OBR20 codes.  DEPRECATED OR CONTAINS SENDING FACILITY FOR SOME OUTPUT
		// CAR Cardiology
		// DII Diagnostic Imaging
		// EDS Electrodiagnostic Services
		// HER Health Records
		// MEH Mental Health
		// RET Respiratory Therapy
		// THS Therapeutic Services 		
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.20&apos;][&apos;OBR.20.1&apos;].toString().length&gt;0) {
			categorytype=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.20&apos;][&apos;OBR.20.1&apos;].toString();
			if (categorytype==&quot;HER&quot;) {
				categorytype=&quot;Health Records&quot;;
			}
			if (categorytype==&quot;DII&quot;) {
				categorytype=&quot;Imaging&quot;;
			}
		}
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.21&apos;][&apos;OBR.21.1&apos;].toString().length&gt;0) {
			reporttype=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.21&apos;][&apos;OBR.21.1&apos;].toString();
		}

		// OBR24.1 codes
		// MIC Microbiology 
		// LAB Labwork
		// PTH Pathology
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.24&apos;][&apos;OBR.24.1&apos;].length()&gt;0) {
			categorytype=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.24&apos;][&apos;OBR.24.1&apos;].toString();

		}
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.25&apos;][&apos;OBR.25.1&apos;].length()==0) {
			//if report status NULL assume it F
			msg[&apos;OBR&apos;][OBRcount][&apos;OBR.25&apos;][&apos;OBR.25.1&apos;]=&quot;F&quot;;

		}
		OBRcount= OBRcount+1;		
	}
	if(segment.name() == &quot;OBX&quot;){
		obx31=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;].toString();
		x=obx31;
		switch (obx31)
  			{
  			case &quot;TSH_N&quot;:
			    x=&quot;4025&quot;;
 			    break;
			case &quot;INRP&quot;:
			    x=&quot;2165&quot;;
			    break;
			case &quot;BILIC&quot;:
			    x=&quot;26196&quot;;
			    break;
			case &quot;BILIU&quot;:
			    x=&quot;26194&quot;;
			    break;
			case &quot;ALP&quot;:
			    x=&quot;3360&quot;;
			    break;
  			case &quot;K&quot;:
			    x=&quot;3220&quot;;
			    break;
  			case &quot;NA&quot;:
			    x=&quot;3210&quot;;
			    break;
  			case &quot;CL&quot;:
			    x=&quot;3230&quot;;
			    break;
  			case &quot;CREAT&quot;:
			    x=&quot;3180&quot;;
			    break;
  			case &quot;HGB&quot;:
			    x=&quot;2010&quot;;
			    break;
  			case &quot;WBC&quot;:
			    x=&quot;2016&quot;;
			    break;
  			case &quot;PLTC&quot;:
			    x=&quot;2111&quot;;
			    break;
  			case &quot;NE#&quot;:
			    x=&quot;2191&quot;;
			    break;
  			case &quot;RBC&quot;:
			    x=&quot;2019&quot;;
			    break;
  			case &quot;MG&quot;:
			    x=&quot;3165&quot;;
			    break;
  			case &quot;CA&quot;:
			    x=&quot;3280&quot;;
			    break;
 			case &quot;AST&quot;:
			    x=&quot;3370&quot;;
			    break;
  			case &quot;ALT&quot;:
			    x=&quot;3380&quot;;
			    break;
  			case &quot;LDH&quot;:
			    x=&quot;3390&quot;;
			    break;
  			case &quot;CK&quot;:
			    x=&quot;3400&quot;;
			    break;
  			case &quot;PSA&quot;:
			    x=&quot;4190&quot;;
			    break;
  			case &quot;DIGOXIN&quot;:
			    x=&quot;4080&quot;;
			    break;
			case &quot;CHOL&quot;:
			    x=&quot;3120&quot;;
			    break;
			case &quot;LDL&quot;:
			    x=&quot;3933&quot;;
			    break;
			case &quot;HDL_N&quot;:
			    x=&quot;3923&quot;;
			    break;
			case &quot;ALB&quot;:
			    x=&quot;28872&quot;;
			    break;
  			}


		msg[&apos;OBX&apos;][OBXcount][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=categorytype+ &apos;/&apos; +reporttype;
		if(( categorytype != &quot;LAB&quot;)&amp;&amp;( categorytype != &quot;MIC&quot;)&amp;&amp;( categorytype != &quot;CHE&quot;)&amp;&amp;( categorytype != &quot;POC&quot;)&amp;&amp;( categorytype != &quot;IMM&quot;)&amp;&amp;( categorytype != &quot;COA&quot;)&amp;&amp;( categorytype != &quot;HEM&quot;)&amp;&amp;( categorytype != &quot;HCM&quot;)&amp;&amp;( categorytype != &quot;BOF&quot;)&amp;&amp;( categorytype != &quot;URI&quot;)){
		// Reformat OBX&apos;s into NTE text output
		// how about discharge summery or similar

			msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;]=obr42+categorytype;
			createSegmentAfter(&apos;NTE&apos;, msg[&apos;OBX&apos;][OBXcount]);
			//noteIndex[NTEcount]=msg[&apos;OBX&apos;][i][&apos;OBX.1&apos;][&apos;OBX.1.1&apos;].toString()-1;
			noteArray[NTEcount]=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;].toString();
			NTEcount++;
			if (OBXcount&gt;0) {
				msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;] = &quot;DNR&quot;; //mark to delete
			} else {
				var payload=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;].toString();
				var re = /H&apos;d4PITAL R&apos;c9GIONAL DE /g ;
				msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;] = (payload).replace(re, &quot;&quot;);
				msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;] = obr42+categorytype;
				
			} 
		} else {
			// get the displayed lab to the specfic and not the group
			//if (msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;].length()&gt;0) {
				//msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;]=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;];
			//}
			msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;]=x;
			var y=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;].toString();
			switch (categorytype)
  			{
  			case &quot;CHE&quot;:
			    y=&quot;CHEMISTRY&quot;;
 			    break;
  			case &quot;HEM&quot;:
			    y=&quot;HEMATOLOGY&quot;;
 			    break;
			}
			msg[&apos;OBX&apos;][OBXcount][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=y;
			
		}


		if (msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;].toString()==&quot;3180&quot;) {
		// since The Hospital doesn&apos;t supply eGFR calculate one
			var cr = msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;];
			var today = new Date();
			var year=today.getFullYear();
			var age=year-dob.substring(0,4);
			
			var female_sex=false;
			if (gender==&quot;F&quot;) {
				female_sex=true;
			}
			var eGFR= Math.round(Math.min((186.0  
              		* Math.pow((cr/88.4),-1.154)
              		* Math.pow(age, -0.203)	
              		* (female_sex ? 0.742 : 1.0)),90)); // changes in values over (60) 90 120 are not clinically significant
   
		//OBX|2|ST|3190^eGFR|CHEMISTRY^^|71||||||F||303^1003190||70
			var obx=createSegment(&apos;OBX&apos;);
			createSegmentAfter(&apos;OBX&apos;, msg[&apos;OBX&apos;][OBXcount]);
			msg[&apos;OBX&apos;][OBXcount+1] = obx;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.1&apos;][&apos;OBX.1.1&apos;] = msg[&apos;OBX&apos;][i][&apos;OBX.1&apos;][&apos;OBX.1.1&apos;]-0+1;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.2&apos;][&apos;OBX.2.1&apos;] = &quot;ST&quot;;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;] = &quot;3190&quot;; //id
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;] = &quot;eGFR&quot;; //id
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;] = &quot;CHEMISTRY&quot;; 
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;] = eGFR; // result
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.6&apos;] = &quot;ml/min&quot;; //units
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.7&apos;] = &quot;&gt;60&quot;; //reference range
			if (eGFR&lt;60) {msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.8&apos;] = &quot;A&quot;;} //abnormal flag
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.13&apos;][&apos;OBX.13.1&apos;] = &quot;303&quot;;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.13&apos;][&apos;OBX.13.2&apos;] = &quot;1003190&quot;;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.15&apos;][&apos;OBX.15.1&apos;] = &quot;70&quot;;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.11&apos;][&apos;OBX.11.1&apos;] = &quot;F&quot;; //&apos;F&apos;inal 
			i++;
			OBXcount++;
		}
		i++;
		OBXcount++;
	} //end OBX
}// end segment


//concat the payload and clean it up
var payload=noteArray.join(&quot;%%&quot;);
//fix
//H&apos;d4PITAL R&apos;c9GIONAL
var re = /H&apos;d4PITAL R&apos;c9GIONAL DE /g ;
payload = (payload).replace(re, &quot;&quot;);
//drop multiple __ and or spaces
re = /[-_\s]{3,}/gi ;
payload = (payload).replace(re, &quot; &quot;);

//formatting codes
//\T\ Oscar supports and changes to &amp;
// the following are Sudbury specific and rarely used
// and would require more code to support
// \ZU\ underline
// \ZI\ italic
// \ZIU\ italic underline
// \ZHI\ bold italic
// \ZHIU\ bold italic underlined
// \ZTAB\ tab

// drop unsupported formatting tags
re = /\\ZU\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZI\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZIU\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZHI\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZHIU\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZTAB\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\H\\/g ;
payload = (payload).replace(re, &quot;&quot;);

//abstract data
//CC: Leary,Tara J MD; McDermott,Thomas M MD 
//OBR.28.1
re = /CC:\s(.*?)%%/ ; //*? non greedy
if (payload.match(re)){
	var match = re.exec(payload);
	msg[&apos;OBR&apos;][0][&apos;OBR.28&apos;][&apos;OBX.28.2&apos;]=match[1];
}
//Copies to: MCDERMOTT, THOMAS M&#x0D;//  RAHN, RAYMOND J
//the following captures both at this point
re = /Copies to:\s(.*?)&lt;br&gt;/ ; //*? non greedy  ,?\s?[A-Z]*\s*?[A-Z]?
if (payload.match(re)){
	var match = re.exec(payload);
	msg[&apos;OBR&apos;][0][&apos;OBR.28&apos;][&apos;OBR.28.2&apos;]=match[1];
}


if ( msg[&apos;OBR&apos;][0][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString().length &gt;0 ) {
	msg[&apos;ORC&apos;][0][&apos;ORC.2&apos;][&apos;ORC.2.1&apos;]=msg[&apos;OBR&apos;][0][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString();
	msg[&apos;OBR&apos;][0][&apos;OBR.2&apos;][&apos;OBR.2.1&apos;]=msg[&apos;OBR&apos;][0][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString();
} else {
	//Report  #: 2107-007
	re = /Report\s*?#:\s(.*?)\s/ ; //*? non greedy
	if (payload.match(re)){
		var match = re.exec(payload);
	//ORC.2 OBR.2
		msg[&apos;ORC&apos;][0][&apos;ORC.2&apos;][&apos;ORC.2.1&apos;]=match[1];
		msg[&apos;OBR&apos;][0][&apos;OBR.2&apos;][&apos;OBR.2.1&apos;]=match[1];
	}
}


//label consults as such
// note this will potentially overcall so let it be overwritten 
// with more specific terms if appropriate by
// putting this check first
re = /Consultation Note|Consultation Report/i ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Consult&quot;;
}
//label h&amp;p as such
re = /HISTORY\s*PHYSICAL/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;History&quot;;
}
//label discharge summaries as such
re = /Discharge Date:.*Date of Admission:|DISCHARGE SUMMARY/i ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Discharge Summary&quot;;
}
//label operative summaries as such
re = /OPERATION|OPERATIVE REPORT/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Operative Report&quot;;
}

// Radiology reports non greedy!
re = /PROCEDURES:  Radiology Chest/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;CXR&quot;;
}
//re = /PROCEDURES:\s*Radiology\s*([A-Z]\D*\b)\s?[\d\.]/ ;


//label cancer clinic summaries as such
re = /Regional Cancer Program/i ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Cancer Clinic&quot;;
}

//label progress notes as such
re = /PROGRESS NOTE|Progress Note/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Progress Note&quot;;
}

//label respiratory notes as such
re = /RESPIRATORY THERAPY REPORT/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Respiratory&quot;;
}

//label letters as such
re = /LETTER/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Letter&quot;;
}
//label outpatient notes as such
re = /OUTPATIENT CLINIC NOTE|OUTPATIENT NOTE|Ambulatory Care Unit Note/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Clinics&quot;;
}


// ### CLEANUP THE OUTPUT ###

// drop pagation headers as Oscar pagation is different
// remove the footer and header in multipage reports
//myRe = /[%\s]*\w*\s\w*\sCont.*?Page\s\d\sof\s\d[%\s]*/g;
// better handling of two page HISTORY &amp; PHYSICAL
//myRe = /[%\s]*\w*(\s&amp;)?\s\w*\sCont.*?Page\s\d\sof\s\d[%\s]*/g;
// works ish myRe = /[%\s]*(TEMISKAMING|OUTPATIENT CLINIC NOTE Contd)[\w\W]*?[%\s]*Page\s\d\sof\s\d[%\s]*/g;
re = /[%\s]*TEMISKAMING[\w\s%-:#]*?[%\s]*Page\s\d\sof\s\d[%\s]*/g;
if (payload.match(re)) {
	payload=payload.replace(re,&quot;%%&quot;);
} else {
	// for New Liskeard Echo
	//[%\s]*?Page\s\d\sof\s\d.*?%%
	re = /[%\s]*?Page\s\d\sof\s\d.*?%%/g;
	if (payload.match(re)) {
		payload=payload.replace(re,&quot;%%&quot;);

	} else {
		// for North Bay header
		re = /NORTH BAY REGIONAL HEALTH CENTRE.{190,290}\(continued\)\s?%{2,}\s?/ ;
		if (payload.match(re)) {
			payload = (payload).replace(re, &quot; &quot;);
		}
	}
}

// To keep HAPI happpy do not give it more than one ##
re = /#{2,}\s*/gi ;
payload = (payload).replace(re, &quot;#&quot;);

// four or more %% is an intentional paragraph break
re = /\s?%{4,}\s*/gi ;
payload = (payload).replace(re, &quot;&lt;br&gt;&lt;br&gt;&quot;);
// A capitalised heading followed by %% is an intentional paragraph break
re = /([A-Z]\s*:)\s?%{2,}\s*/g ;
payload = (payload).replace(re, &quot;$1&lt;br&gt;&lt;br&gt;&quot;);
// a period followed by %% is an intentional paragraph break
// EXCEPT when it is an abbreviation such as Dr.
re = /Dr\.\s*?%{2,}\s*/gi ;
payload = (payload).replace(re, &quot;Dr. &quot;);
// a period followed by %% is an intentional paragraph break
re = /\.\s*?%{2,}\s*/gi ;
payload = (payload).replace(re, &quot;.&lt;br&gt;&lt;br&gt;&quot;);
// for Cancer Clinic  --108 is an intentional paragraph break
re = /--108\s*/gi ;
payload = (payload).replace(re, &quot;&lt;br&gt;&lt;br&gt;&quot;);
// Patient:  HUTTEN,PETER
re = /(Patient:\s\s[A-Z]{3,})/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);
// Unit#:  SH00590986
re = /(Unit#:\s\s[A-Z]{2})/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);
// DOB - Age
re = /(DOB\s-\sAge)/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);
// Account#: SC196219/12 
re = /(Account#:\s\s[A-Z])/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);
// Patient Location: SRM CLIDIA 
re = /(Patient\sLocation:\s[A-Z]{3,})/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);

// drop single line breaks as they mess up the output
re = /\s?%{2,}\s?/gi ;
payload = (payload).replace(re, &quot; &quot;);
re = /&amp;/gi ;
payload = (payload).replace(re, &quot; and &quot;);



//word wrap the output
//payload=payload+&quot; &quot;;
//wordwrap(payload,100,&apos;&lt;br&gt;&apos;);
//reform the array
noteArray=payload.split(&quot;&lt;br&gt;&lt;br&gt;&quot;);

//populate the notes
var j=0;
for(var i=0;i&lt;msg[&apos;NTE&apos;].length();i++ ){
	if (j&lt;noteArray.length) {
		msg[&apos;NTE&apos;][i][&apos;NTE.2&apos;][&apos;NTE.2.1&apos;] = &quot;L&quot;; //source of comment
		if (msg[&apos;NTE&apos;][i][&apos;NTE.3&apos;][&apos;NTE.3.1&apos;].toString().length&lt;1){
			//if (noteArray[j].toString().length&lt;1){ j++;}	
			if ((noteArray[j].toString().length&gt;0)&amp;&amp;((noteArray[j].toString()).lastIndexOf(&apos;.&apos;,noteArray[j].toString().length)&lt;(noteArray[j].length-1))) {noteArray[j]=noteArray[j].toString()+&apos; &apos;}
			
			msg[&apos;NTE&apos;][i][&apos;NTE.3&apos;][&apos;NTE.3.1&apos;] = wordwrap(noteArray[j].toString(),100,&apos;&lt;br&gt;&apos;);

			j++;
			
		}
	} 
}

// delete unwanted results marked as DNR do not report.
// note that deleting the node resets the index so we have to do i--
for(var i=0;i&lt;msg[&apos;OBX&apos;].length();i++ ){
	if (msg[&apos;OBX&apos;][i][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;].toString() == &quot;DNR&quot;) {
		delete msg[&apos;OBX&apos;][i];
		i--;
	}
}

// clean up OBX

for(var i=0;i&lt;msg[&apos;OBX&apos;].length();i++ ){
	var re = /\s*\\H\\\s/ ;
	msg[&apos;OBX&apos;][i][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;]= msg[&apos;OBX&apos;][i][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;].toString().replace(re,&quot;&quot;);
}

// delete unwanted results marked as DNR do not report.
// note that deleting the node resets the index so we have to do i--
for(var i=0;i&lt;msg[&apos;NTE&apos;].length();i++ ){
	if (msg[&apos;NTE&apos;][i][&apos;NTE.3&apos;][&apos;NTE.3.1&apos;].toString() == &quot;&quot;) {
		delete msg[&apos;NTE&apos;][i];
		i--;
	}
}

//OSCAR will allow &lt;br&gt; to format both screen and pdf output
function wordwrap( str, width, brk ) {
 
    brk = brk || &apos;\n&apos;;
    width = width || 80;
    if (!str) { return str; }
 // doesnt work   var myRe = new RegExp(&apos;(.{1,&apos;+width+&apos;}[\\s|.|$])&apos;,&apos;g&apos;);
     var myRe = /(.{1,100}[\s|.|$])/g;

    //***test for match first***
    if (str.match(myRe)) {
	/*Success!*/
	return str.match( myRe ).join( brk ); 
    } else {
 	// there is no match for lines between paragraphs   
    return str;
    }
}
//end</script>
            <type>JavaScript</type>
            <data class="map">
              <entry>
                <string>Script</string>
                <string>// Copyright (c) 2011-2012 by Peter Hutten-Czapski

//msg - array representing XML of the data being transformed

//makework fix the input back to Su=dbury standard Processing ID
msg[&apos;MSH&apos;][&apos;MSH.11&apos;][&apos;MSH.11.1&apos;]=&quot;T&quot;;
//end makework

//OSCAR handles versions 2.5, 2.6, 2.3, 2.2
//so make HAPI happy if its 2.4 by downgrading
//if (msg[&apos;MSH&apos;][&apos;MSH.12&apos;][&apos;MSH.12.1&apos;].toString()==&quot;2.4&quot;) {
	msg[&apos;MSH&apos;][&apos;MSH.12&apos;][&apos;MSH.12.1&apos;]=&quot;2.3&quot;;
//}

//set some natural language locations, especially if particularly obscure
if (msg[&apos;MSH&apos;][&apos;MSH.4&apos;][&apos;MSH.4.1&apos;].toString()==&quot;TEM&quot;){
	msg[&apos;MSH&apos;][&apos;MSH.4&apos;][&apos;MSH.4.1&apos;]=&quot;Temiskaming Hospital&quot;;
}
if (msg[&apos;MSH&apos;][&apos;MSH.4&apos;][&apos;MSH.4.1&apos;].toString()==&quot;SJH&quot;){
	msg[&apos;MSH&apos;][&apos;MSH.4&apos;][&apos;MSH.4.1&apos;]=&quot;North Bay Regional&quot;;
}

// fudge if something has passed all prior opportunities
	if (msg[&apos;OBX&apos;][0][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;].length()&lt;1) {
		msg[&apos;OBX&apos;][0][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;]=&quot;Report&quot;;
	}
var i=0;
var hin=&quot;&quot;;
for (pid in msg..PID){
	// populate PID.4 the Alternate Patient ID with the HIN from PID.3 so Oscar can display it
	msg[&apos;PID&apos;][i][&apos;PID.4&apos;][&apos;PID.4.1&apos;] =  msg[&apos;PID&apos;][i][&apos;PID.2&apos;][&apos;PID.2.1&apos;].toString();
	msg[&apos;PID&apos;][i][&apos;PID.4&apos;][&apos;PID.4.2&apos;] =  msg[&apos;PID&apos;][i][&apos;PID.2&apos;][&apos;PID.2.2&apos;].toString();
	//msg[&apos;PID&apos;][i][&apos;PID.4&apos;][&apos;PID.4.3&apos;] =  msg[&apos;PID&apos;][i][&apos;PID.2&apos;][&apos;PID.2.3&apos;].toString();

	i++;

}

//Iterate through the segments OBX observations/results
// add and remove some

var NTEcount = 0; // new notes start at 0
var OBRcount = 0;
var OBXcount = 0;
var nte = createSegment(&apos;NTE&apos;);
var noteArray=new Array();
var noteIndex=new Array();
var ptCount=0;
var PV1count=0;
var categorytype=&quot;REPORT&quot;;
var reporttype=&quot;NEON REPORT&quot;;
var obr42=&quot;&quot;;
var obx31=&quot;&quot;;
var x=&quot;t&quot;;

i=0;

for each(segment in msg.children()){
	if(segment.name() == &quot;PID&quot;){

		var dob = segment[&apos;PID&apos;][&apos;PID.7&apos;][&apos;PID.7.1&apos;].toString();
		var gender = segment[&apos;PID&apos;][&apos;PID.8&apos;][&apos;PID.8.1&apos;].toString();
	
	}
	if(segment.name() == &quot;PV1&quot;){
		var attdocid = msg[&apos;OBR&apos;][ptCount][&apos;OBR.32&apos;][&apos;OBR.32.1&apos;].toString()
		var docid = attdocid.split(&quot;&amp;&quot;);
		//var attdocid = msg[&apos;PV1&apos;][ptCount][&apos;PV1.17&apos;][&apos;PV1.17.3&apos;].toString()
		//var docid = attdocid.split(&quot;~&quot;);
		attdocid=docid[0]||&quot;111111&quot;;
		//var attdocName=msg[&apos;PV1&apos;][ptCount][&apos;PV1.17&apos;][&apos;PV1.17.2&apos;].toString()+&quot;, &quot;+ msg[&apos;PV1&apos;][ptCount][&apos;PV1.17&apos;][&apos;PV1.17.3&apos;].toString();
		var attdocName=(docid[1]||&quot;&quot;)+&quot;, &quot;+(docid[2]||&quot;&quot;)
		var orc=createSegment(&apos;ORC&apos;);
		createSegmentAfter(&apos;ORC&apos;, msg[&apos;PV1&apos;][ptCount]);
		msg[&apos;ORC&apos;][ptCount] = orc;
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.1&apos;][&apos;ORC.1.1&apos;] = ptCount+1;
		// provide UUID or Accession Number to ORC.2
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.2&apos;][&apos;ORC.2.1&apos;] = msg[&apos;OBR&apos;][ptCount][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString();
		//provide order status from OBR 25.1
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.5&apos;][&apos;ORC.5.1&apos;] = msg[&apos;OBR&apos;][ptCount][&apos;OBR.25&apos;][&apos;OBR.25.1&apos;].toString();
		//parse OBR28 looking for local doc or use PV1.52
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.12&apos;][&apos;ORC.12.1&apos;] = attdocid
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.12&apos;][&apos;ORC.12.2&apos;] = attdocName
		//order effective time set to message time
		msg[&apos;ORC&apos;][ptCount][&apos;ORC.15&apos;][&apos;ORC.15.1&apos;] = msg[&apos;MSH&apos;][&apos;MSH.7&apos;][&apos;MSH.7.1&apos;].toString();

		delete msg[&apos;PV1&apos;][ptCount];
		ptCount = ptCount+1; //sequence incriment
	}

	if(segment.name() == &quot;OBR&quot;){
		//for sake of argument we will call ther placer (2) to have the same order number as the filler (3)
		msg[&apos;OBR&apos;][OBRcount][&apos;OBR.2&apos;][&apos;OBR.2.1&apos;]=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString();
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.4&apos;][&apos;OBR.4.1&apos;].toString().length&gt;0) {
			//leave it
		} else {
			msg[&apos;OBR&apos;][OBRcount][&apos;OBR.4&apos;][&apos;OBR.4.1&apos;]=&quot;Report&quot;; 
		}
		//fudge to change requested date with observerd date as we look to when a Xray was taken as its  date not the report 
		//if (msg[&apos;OBR&apos;][&apos;OBR.7&apos;][&apos;OBR.7.1&apos;].toString().length&gt;0) {
			//var tdate=msg[&apos;OBR&apos;][&apos;OBR.7&apos;][&apos;OBR.7.1&apos;].toString();
					//msg[&apos;OBR&apos;][&apos;OBR.7&apos;][&apos;OBR.7.1&apos;]=msg[&apos;OBR&apos;][&apos;OBR.6&apos;][&apos;OBR.6.1&apos;].toString();
			//msg[&apos;OBR&apos;][&apos;OBR.6&apos;][&apos;OBR.6.1&apos;]=tdate;
		//}

		//OBR 4.2 not needed and more compact output if dropped, but keep the value
		obr42=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.4&apos;][&apos;OBR.4.2&apos;].toString();
		msg[&apos;OBR&apos;][OBRcount][&apos;OBR.4&apos;][&apos;OBR.4.2&apos;]=&quot;&quot;;
		//if (!((msg[&apos;OBR&apos;][OBRcount][&apos;OBR.21&apos;][&apos;OBR.21.1&apos;].toString()==&quot;TEDIIDIR&quot;)||(msg[&apos;OBR&apos;][OBRcount][&apos;OBR.21&apos;][&apos;OBR.21.1&apos;].toString()==&quot;TEDIIMAM&quot;))) {
		if (msg[&apos;OBR&apos;][&apos;OBR.16&apos;][&apos;OBR.16.1&apos;].toString().length&lt;1) {
			msg[&apos;OBR&apos;][OBRcount][&apos;OBR.16&apos;][&apos;OBR.16.1&apos;]=attdocid;
		}
		if (msg[&apos;OBR&apos;][&apos;OBR.16&apos;][&apos;OBR.16.2&apos;].toString().length&lt;1) {
			msg[&apos;OBR&apos;][OBRcount][&apos;OBR.16&apos;][&apos;OBR.16.2&apos;]=attdocName;
		}
		// OBR20 codes.  DEPRECATED OR CONTAINS SENDING FACILITY FOR SOME OUTPUT
		// CAR Cardiology
		// DII Diagnostic Imaging
		// EDS Electrodiagnostic Services
		// HER Health Records
		// MEH Mental Health
		// RET Respiratory Therapy
		// THS Therapeutic Services 		
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.20&apos;][&apos;OBR.20.1&apos;].toString().length&gt;0) {
			categorytype=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.20&apos;][&apos;OBR.20.1&apos;].toString();
			if (categorytype==&quot;HER&quot;) {
				categorytype=&quot;Health Records&quot;;
			}
			if (categorytype==&quot;DII&quot;) {
				categorytype=&quot;Imaging&quot;;
			}
		}
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.21&apos;][&apos;OBR.21.1&apos;].toString().length&gt;0) {
			reporttype=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.21&apos;][&apos;OBR.21.1&apos;].toString();
		}

		// OBR24.1 codes
		// MIC Microbiology 
		// LAB Labwork
		// PTH Pathology
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.24&apos;][&apos;OBR.24.1&apos;].length()&gt;0) {
			categorytype=msg[&apos;OBR&apos;][OBRcount][&apos;OBR.24&apos;][&apos;OBR.24.1&apos;].toString();

		}
		if (msg[&apos;OBR&apos;][OBRcount][&apos;OBR.25&apos;][&apos;OBR.25.1&apos;].length()==0) {
			//if report status NULL assume it F
			msg[&apos;OBR&apos;][OBRcount][&apos;OBR.25&apos;][&apos;OBR.25.1&apos;]=&quot;F&quot;;

		}
		OBRcount= OBRcount+1;		
	}
	if(segment.name() == &quot;OBX&quot;){
		obx31=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;].toString();
		x=obx31;
		switch (obx31)
  			{
  			case &quot;TSH_N&quot;:
			    x=&quot;4025&quot;;
 			    break;
			case &quot;INRP&quot;:
			    x=&quot;2165&quot;;
			    break;
			case &quot;BILIC&quot;:
			    x=&quot;26196&quot;;
			    break;
			case &quot;BILIU&quot;:
			    x=&quot;26194&quot;;
			    break;
			case &quot;ALP&quot;:
			    x=&quot;3360&quot;;
			    break;
  			case &quot;K&quot;:
			    x=&quot;3220&quot;;
			    break;
  			case &quot;NA&quot;:
			    x=&quot;3210&quot;;
			    break;
  			case &quot;CL&quot;:
			    x=&quot;3230&quot;;
			    break;
  			case &quot;CREAT&quot;:
			    x=&quot;3180&quot;;
			    break;
  			case &quot;HGB&quot;:
			    x=&quot;2010&quot;;
			    break;
  			case &quot;WBC&quot;:
			    x=&quot;2016&quot;;
			    break;
  			case &quot;PLTC&quot;:
			    x=&quot;2111&quot;;
			    break;
  			case &quot;NE#&quot;:
			    x=&quot;2191&quot;;
			    break;
  			case &quot;RBC&quot;:
			    x=&quot;2019&quot;;
			    break;
  			case &quot;MG&quot;:
			    x=&quot;3165&quot;;
			    break;
  			case &quot;CA&quot;:
			    x=&quot;3280&quot;;
			    break;
 			case &quot;AST&quot;:
			    x=&quot;3370&quot;;
			    break;
  			case &quot;ALT&quot;:
			    x=&quot;3380&quot;;
			    break;
  			case &quot;LDH&quot;:
			    x=&quot;3390&quot;;
			    break;
  			case &quot;CK&quot;:
			    x=&quot;3400&quot;;
			    break;
  			case &quot;PSA&quot;:
			    x=&quot;4190&quot;;
			    break;
  			case &quot;DIGOXIN&quot;:
			    x=&quot;4080&quot;;
			    break;
			case &quot;CHOL&quot;:
			    x=&quot;3120&quot;;
			    break;
			case &quot;LDL&quot;:
			    x=&quot;3933&quot;;
			    break;
			case &quot;HDL_N&quot;:
			    x=&quot;3923&quot;;
			    break;
			case &quot;ALB&quot;:
			    x=&quot;28872&quot;;
			    break;
  			}


		msg[&apos;OBX&apos;][OBXcount][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=categorytype+ &apos;/&apos; +reporttype;
		if(( categorytype != &quot;LAB&quot;)&amp;&amp;( categorytype != &quot;MIC&quot;)&amp;&amp;( categorytype != &quot;CHE&quot;)&amp;&amp;( categorytype != &quot;POC&quot;)&amp;&amp;( categorytype != &quot;IMM&quot;)&amp;&amp;( categorytype != &quot;COA&quot;)&amp;&amp;( categorytype != &quot;HEM&quot;)&amp;&amp;( categorytype != &quot;HCM&quot;)&amp;&amp;( categorytype != &quot;BOF&quot;)&amp;&amp;( categorytype != &quot;URI&quot;)){
		// Reformat OBX&apos;s into NTE text output
		// how about discharge summery or similar

			msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;]=obr42+categorytype;
			createSegmentAfter(&apos;NTE&apos;, msg[&apos;OBX&apos;][OBXcount]);
			//noteIndex[NTEcount]=msg[&apos;OBX&apos;][i][&apos;OBX.1&apos;][&apos;OBX.1.1&apos;].toString()-1;
			noteArray[NTEcount]=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;].toString();
			NTEcount++;
			if (OBXcount&gt;0) {
				msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;] = &quot;DNR&quot;; //mark to delete
			} else {
				var payload=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;].toString();
				var re = /H&apos;d4PITAL R&apos;c9GIONAL DE /g ;
				msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;] = (payload).replace(re, &quot;&quot;);
				msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;] = obr42+categorytype;
				
			} 
		} else {
			// get the displayed lab to the specfic and not the group
			//if (msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;].length()&gt;0) {
				//msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;]=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;];
			//}
			msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;]=x;
			var y=msg[&apos;OBX&apos;][OBXcount][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;].toString();
			switch (categorytype)
  			{
  			case &quot;CHE&quot;:
			    y=&quot;CHEMISTRY&quot;;
 			    break;
  			case &quot;HEM&quot;:
			    y=&quot;HEMATOLOGY&quot;;
 			    break;
			}
			msg[&apos;OBX&apos;][OBXcount][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=y;
			
		}


		if (msg[&apos;OBX&apos;][OBXcount][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;].toString()==&quot;3180&quot;) {
		// since The Hospital doesn&apos;t supply eGFR calculate one
			var cr = msg[&apos;OBX&apos;][OBXcount][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;];
			var today = new Date();
			var year=today.getFullYear();
			var age=year-dob.substring(0,4);
			
			var female_sex=false;
			if (gender==&quot;F&quot;) {
				female_sex=true;
			}
			var eGFR= Math.round(Math.min((186.0  
              		* Math.pow((cr/88.4),-1.154)
              		* Math.pow(age, -0.203)	
              		* (female_sex ? 0.742 : 1.0)),90)); // changes in values over (60) 90 120 are not clinically significant
   
		//OBX|2|ST|3190^eGFR|CHEMISTRY^^|71||||||F||303^1003190||70
			var obx=createSegment(&apos;OBX&apos;);
			createSegmentAfter(&apos;OBX&apos;, msg[&apos;OBX&apos;][OBXcount]);
			msg[&apos;OBX&apos;][OBXcount+1] = obx;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.1&apos;][&apos;OBX.1.1&apos;] = msg[&apos;OBX&apos;][i][&apos;OBX.1&apos;][&apos;OBX.1.1&apos;]-0+1;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.2&apos;][&apos;OBX.2.1&apos;] = &quot;ST&quot;;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.3&apos;][&apos;OBX.3.1&apos;] = &quot;3190&quot;; //id
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.3&apos;][&apos;OBX.3.2&apos;] = &quot;eGFR&quot;; //id
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;] = &quot;CHEMISTRY&quot;; 
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;] = eGFR; // result
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.6&apos;] = &quot;ml/min&quot;; //units
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.7&apos;] = &quot;&gt;60&quot;; //reference range
			if (eGFR&lt;60) {msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.8&apos;] = &quot;A&quot;;} //abnormal flag
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.13&apos;][&apos;OBX.13.1&apos;] = &quot;303&quot;;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.13&apos;][&apos;OBX.13.2&apos;] = &quot;1003190&quot;;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.15&apos;][&apos;OBX.15.1&apos;] = &quot;70&quot;;
			msg[&apos;OBX&apos;][OBXcount+1][&apos;OBX.11&apos;][&apos;OBX.11.1&apos;] = &quot;F&quot;; //&apos;F&apos;inal 
			i++;
			OBXcount++;
		}
		i++;
		OBXcount++;
	} //end OBX
}// end segment


//concat the payload and clean it up
var payload=noteArray.join(&quot;%%&quot;);
//fix
//H&apos;d4PITAL R&apos;c9GIONAL
var re = /H&apos;d4PITAL R&apos;c9GIONAL DE /g ;
payload = (payload).replace(re, &quot;&quot;);
//drop multiple __ and or spaces
re = /[-_\s]{3,}/gi ;
payload = (payload).replace(re, &quot; &quot;);

//formatting codes
//\T\ Oscar supports and changes to &amp;
// the following are Sudbury specific and rarely used
// and would require more code to support
// \ZU\ underline
// \ZI\ italic
// \ZIU\ italic underline
// \ZHI\ bold italic
// \ZHIU\ bold italic underlined
// \ZTAB\ tab

// drop unsupported formatting tags
re = /\\ZU\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZI\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZIU\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZHI\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZHIU\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\ZTAB\\/g ;
payload = (payload).replace(re, &quot;&quot;);
re = /\\H\\/g ;
payload = (payload).replace(re, &quot;&quot;);

//abstract data
//CC: Leary,Tara J MD; McDermott,Thomas M MD 
//OBR.28.1
re = /CC:\s(.*?)%%/ ; //*? non greedy
if (payload.match(re)){
	var match = re.exec(payload);
	msg[&apos;OBR&apos;][0][&apos;OBR.28&apos;][&apos;OBX.28.2&apos;]=match[1];
}
//Copies to: MCDERMOTT, THOMAS M&#x0D;//  RAHN, RAYMOND J
//the following captures both at this point
re = /Copies to:\s(.*?)&lt;br&gt;/ ; //*? non greedy  ,?\s?[A-Z]*\s*?[A-Z]?
if (payload.match(re)){
	var match = re.exec(payload);
	msg[&apos;OBR&apos;][0][&apos;OBR.28&apos;][&apos;OBR.28.2&apos;]=match[1];
}


if ( msg[&apos;OBR&apos;][0][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString().length &gt;0 ) {
	msg[&apos;ORC&apos;][0][&apos;ORC.2&apos;][&apos;ORC.2.1&apos;]=msg[&apos;OBR&apos;][0][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString();
	msg[&apos;OBR&apos;][0][&apos;OBR.2&apos;][&apos;OBR.2.1&apos;]=msg[&apos;OBR&apos;][0][&apos;OBR.3&apos;][&apos;OBR.3.1&apos;].toString();
} else {
	//Report  #: 2107-007
	re = /Report\s*?#:\s(.*?)\s/ ; //*? non greedy
	if (payload.match(re)){
		var match = re.exec(payload);
	//ORC.2 OBR.2
		msg[&apos;ORC&apos;][0][&apos;ORC.2&apos;][&apos;ORC.2.1&apos;]=match[1];
		msg[&apos;OBR&apos;][0][&apos;OBR.2&apos;][&apos;OBR.2.1&apos;]=match[1];
	}
}


//label consults as such
// note this will potentially overcall so let it be overwritten 
// with more specific terms if appropriate by
// putting this check first
re = /Consultation Note|Consultation Report/i ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Consult&quot;;
}
//label h&amp;p as such
re = /HISTORY\s*PHYSICAL/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;History&quot;;
}
//label discharge summaries as such
re = /Discharge Date:.*Date of Admission:|DISCHARGE SUMMARY/i ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Discharge Summary&quot;;
}
//label operative summaries as such
re = /OPERATION|OPERATIVE REPORT/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Operative Report&quot;;
}

// Radiology reports non greedy!
re = /PROCEDURES:  Radiology Chest/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;CXR&quot;;
}
//re = /PROCEDURES:\s*Radiology\s*([A-Z]\D*\b)\s?[\d\.]/ ;


//label cancer clinic summaries as such
re = /Regional Cancer Program/i ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Cancer Clinic&quot;;
}

//label progress notes as such
re = /PROGRESS NOTE|Progress Note/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Progress Note&quot;;
}

//label respiratory notes as such
re = /RESPIRATORY THERAPY REPORT/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Respiratory&quot;;
}

//label letters as such
re = /LETTER/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Letter&quot;;
}
//label outpatient notes as such
re = /OUTPATIENT CLINIC NOTE|OUTPATIENT NOTE|Ambulatory Care Unit Note/ ;
if (payload.match(re)){
	msg[&apos;OBX&apos;][0][&apos;OBX.4&apos;][&apos;OBX.4.1&apos;]=&quot;Clinics&quot;;
}


// ### CLEANUP THE OUTPUT ###

// drop pagation headers as Oscar pagation is different
// remove the footer and header in multipage reports
//myRe = /[%\s]*\w*\s\w*\sCont.*?Page\s\d\sof\s\d[%\s]*/g;
// better handling of two page HISTORY &amp; PHYSICAL
//myRe = /[%\s]*\w*(\s&amp;)?\s\w*\sCont.*?Page\s\d\sof\s\d[%\s]*/g;
// works ish myRe = /[%\s]*(TEMISKAMING|OUTPATIENT CLINIC NOTE Contd)[\w\W]*?[%\s]*Page\s\d\sof\s\d[%\s]*/g;
re = /[%\s]*TEMISKAMING[\w\s%-:#]*?[%\s]*Page\s\d\sof\s\d[%\s]*/g;
if (payload.match(re)) {
	payload=payload.replace(re,&quot;%%&quot;);
} else {
	// for New Liskeard Echo
	//[%\s]*?Page\s\d\sof\s\d.*?%%
	re = /[%\s]*?Page\s\d\sof\s\d.*?%%/g;
	if (payload.match(re)) {
		payload=payload.replace(re,&quot;%%&quot;);

	} else {
		// for North Bay header
		re = /NORTH BAY REGIONAL HEALTH CENTRE.{190,290}\(continued\)\s?%{2,}\s?/ ;
		if (payload.match(re)) {
			payload = (payload).replace(re, &quot; &quot;);
		}
	}
}

// To keep HAPI happpy do not give it more than one ##
re = /#{2,}\s*/gi ;
payload = (payload).replace(re, &quot;#&quot;);

// four or more %% is an intentional paragraph break
re = /\s?%{4,}\s*/gi ;
payload = (payload).replace(re, &quot;&lt;br&gt;&lt;br&gt;&quot;);
// A capitalised heading followed by %% is an intentional paragraph break
re = /([A-Z]\s*:)\s?%{2,}\s*/g ;
payload = (payload).replace(re, &quot;$1&lt;br&gt;&lt;br&gt;&quot;);
// a period followed by %% is an intentional paragraph break
// EXCEPT when it is an abbreviation such as Dr.
re = /Dr\.\s*?%{2,}\s*/gi ;
payload = (payload).replace(re, &quot;Dr. &quot;);
// a period followed by %% is an intentional paragraph break
re = /\.\s*?%{2,}\s*/gi ;
payload = (payload).replace(re, &quot;.&lt;br&gt;&lt;br&gt;&quot;);
// for Cancer Clinic  --108 is an intentional paragraph break
re = /--108\s*/gi ;
payload = (payload).replace(re, &quot;&lt;br&gt;&lt;br&gt;&quot;);
// Patient:  HUTTEN,PETER
re = /(Patient:\s\s[A-Z]{3,})/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);
// Unit#:  SH00590986
re = /(Unit#:\s\s[A-Z]{2})/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);
// DOB - Age
re = /(DOB\s-\sAge)/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);
// Account#: SC196219/12 
re = /(Account#:\s\s[A-Z])/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);
// Patient Location: SRM CLIDIA 
re = /(Patient\sLocation:\s[A-Z]{3,})/ ;
payload = (payload).replace(re, &quot;&lt;br&gt;$1&quot;);

// drop single line breaks as they mess up the output
re = /\s?%{2,}\s?/gi ;
payload = (payload).replace(re, &quot; &quot;);
re = /&amp;/gi ;
payload = (payload).replace(re, &quot; and &quot;);



//word wrap the output
//payload=payload+&quot; &quot;;
//wordwrap(payload,100,&apos;&lt;br&gt;&apos;);
//reform the array
noteArray=payload.split(&quot;&lt;br&gt;&lt;br&gt;&quot;);

//populate the notes
var j=0;
for(var i=0;i&lt;msg[&apos;NTE&apos;].length();i++ ){
	if (j&lt;noteArray.length) {
		msg[&apos;NTE&apos;][i][&apos;NTE.2&apos;][&apos;NTE.2.1&apos;] = &quot;L&quot;; //source of comment
		if (msg[&apos;NTE&apos;][i][&apos;NTE.3&apos;][&apos;NTE.3.1&apos;].toString().length&lt;1){
			//if (noteArray[j].toString().length&lt;1){ j++;}	
			if ((noteArray[j].toString().length&gt;0)&amp;&amp;((noteArray[j].toString()).lastIndexOf(&apos;.&apos;,noteArray[j].toString().length)&lt;(noteArray[j].length-1))) {noteArray[j]=noteArray[j].toString()+&apos; &apos;}
			
			msg[&apos;NTE&apos;][i][&apos;NTE.3&apos;][&apos;NTE.3.1&apos;] = wordwrap(noteArray[j].toString(),100,&apos;&lt;br&gt;&apos;);

			j++;
			
		}
	} 
}

// delete unwanted results marked as DNR do not report.
// note that deleting the node resets the index so we have to do i--
for(var i=0;i&lt;msg[&apos;OBX&apos;].length();i++ ){
	if (msg[&apos;OBX&apos;][i][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;].toString() == &quot;DNR&quot;) {
		delete msg[&apos;OBX&apos;][i];
		i--;
	}
}

// clean up OBX

for(var i=0;i&lt;msg[&apos;OBX&apos;].length();i++ ){
	var re = /\s*\\H\\\s/ ;
	msg[&apos;OBX&apos;][i][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;]= msg[&apos;OBX&apos;][i][&apos;OBX.5&apos;][&apos;OBX.5.1&apos;].toString().replace(re,&quot;&quot;);
}

// delete unwanted results marked as DNR do not report.
// note that deleting the node resets the index so we have to do i--
for(var i=0;i&lt;msg[&apos;NTE&apos;].length();i++ ){
	if (msg[&apos;NTE&apos;][i][&apos;NTE.3&apos;][&apos;NTE.3.1&apos;].toString() == &quot;&quot;) {
		delete msg[&apos;NTE&apos;][i];
		i--;
	}
}

//OSCAR will allow &lt;br&gt; to format both screen and pdf output
function wordwrap( str, width, brk ) {
 
    brk = brk || &apos;\n&apos;;
    width = width || 80;
    if (!str) { return str; }
 // doesnt work   var myRe = new RegExp(&apos;(.{1,&apos;+width+&apos;}[\\s|.|$])&apos;,&apos;g&apos;);
     var myRe = /(.{1,100}[\s|.|$])/g;

    //***test for match first***
    if (str.match(myRe)) {
	/*Success!*/
	return str.match( myRe ).join( brk ); 
    } else {
 	// there is no match for lines between paragraphs   
    return str;
    }
}
//end</string>
              </entry>
            </data>
          </com.webreach.mirth.model.Step>
        </steps>
        <inboundTemplate>MSH|^~\&amp;|ITS|SRH|||20110629134750||ORU^R01|15A0-4E0B6546DF|T|2.3&#x0D;PID|1|9792463243^LX^ON^0641002|9792463243^LX^ON||TEST^JENNA||19850731|F|||12 TEST LANE^^SUDBURY^ON^P3A 1J8|||||||SI000150/11|1111111116
ORC|NW|0101-0042|||F|||||||247486^OrderingMD|||20101129&#x0D;PV1|1|I|SRHSPED3^SRH3110^2|L|||TST.FISCO^Fisher^Cory^IT Tech^^^^PRV~56789^^^^^^^PPN|TST.KULAN^Kulyski^Andrea^IT Tech^^^^PRV~25874^^^^^^^PPN|TST.BRORE^BROOKIE^BECKS^^^^^PRV~98745^^^^^^^PPN|PEME||||04|||TST.KULAN^Kulyski^Andrea^IT Tech^^^^PRV~25874^^^^^^^PPN|IN||01|||||||||||||||||||SRH||ADM|||201009281023||||||||TST.KULAN^Kulyski^Andrea^^^^^PRV~25874^^^^^^^PPN~HUTTE.PE01^Hutten-Czapski^Peter^^^^^PRV~57283^^^^^^^PPN&#x0D;OBR|1||1102:H00280R^SRH|HER^HER|||201106291319|201106291319||||||||173948^DR MCDERMOTT||||HER|SRFN|201106291322|||P|||TST.ROSDA^Ross^Dan^ITS^^^^PRV~12345^^^^^^^PPN~TST.FISCO^Fisher^Cory^IT Tech^^^^PRV~56789^^^^^^^PPN~DSUDHER^Serv.^HRSRH^Health Information^^^^PRV~^^^^^^^PPN||||HUTTE.PE01&amp;Hutten-Czapski&amp;Peter&amp;A&amp;&amp;&amp;MD&amp;PRV|||ROSDA01&amp;&amp;&amp;&amp;&amp;&amp;&amp;PRV~&amp;&amp;&amp;&amp;&amp;&amp;&amp;NPI&#x0D;OBX|1|TX|ITS^ITS REPORT||                                                                           \H\ Sudbury Regional Hospital ||||||P&#x0D;OBX|2|TX|ITS^ITS REPORT||                                                                              Health Records||||||P&#x0D;OBX|3|TX|ITS^ITS REPORT||                                                                          HRSRH Laurentian Site||||||P&#x0D;OBX|4|TX|ITS^ITS REPORT||  ______________________________________________________________________________________________________||||||P&#x0D;OBX|5|TX|ITS^ITS REPORT||  Patient:  TEST,JENNA                                                                 Unit#:  SH00001057||||||P&#x0D;OBX|6|TX|ITS^ITS REPORT||  DOB - Age- Sex: 31/07/1985 - 25 - F       Account#: SI000150/11||||||P&#x0D;OBX|7|TX|ITS^ITS REPORT||  Dictating Doctor:: Hutten-Czapski,Peter A MD                           ||||||P&#x0D;OBX|8|TX|ITS^ITS REPORT||  Patient Location: SRHSPED3                                                    ||||||P&#x0D;OBX|9|TX|ITS^ITS REPORT||                            SRH3110-2||||||P&#x0D;OBX|10|TX|ITS^ITS REPORT||  Discharge Date:                                                          ||||||P&#x0D;OBX|11|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|12|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|13|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|14|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|15|TX|ITS^ITS REPORT||  Test||||||P&#x0D;OBX|16|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|17|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|18|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|19|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|20|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|21|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|22|TX|ITS^ITS REPORT||  CC:   Fisher,Cory IT Tech; HRSRH Health Information Serv.; Hutten-Czapski,Peter A MD; Kulyski,Andrea IT Tech; Ross,Dan ITS ||||||P&#x0D;OBX|23|TX|ITS^ITS REPORT||                                           Report  #:   2906-0002 ||||||P&#x0D;OBX|24|TX|ITS^ITS REPORT||   Transcribed Date/Time  : 29/06/11 1319                                                Transcribed By :  ROSDA01||||||P&#x0D;OBX|25|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|26|TX|ITS^ITS REPORT||||||||P&#x0D;OBX|27|TX|ITS^ITS REPORT||||||||P&#x0D;</inboundTemplate>
        <outboundTemplate></outboundTemplate>
        <inboundProtocol>HL7V2</inboundProtocol>
        <outboundProtocol>HL7V2</outboundProtocol>
        <inboundProperties>
          <property name="handleRepetitions">false</property>
          <property name="convertLFtoCR">true</property>
          <property name="useStrictValidation">false</property>
          <property name="useStrictParser">false</property>
        </inboundProperties>
        <outboundProperties>
          <property name="handleRepetitions">false</property>
          <property name="convertLFtoCR">false</property>
          <property name="useStrictValidation">false</property>
          <property name="useStrictParser">false</property>
        </outboundProperties>
      </transformer>
      <filter>
        <rules/>
      </filter>
      <transportName>File Writer</transportName>
      <mode>DESTINATION</mode>
      <enabled>true</enabled>
    </com.webreach.mirth.model.Connector>
    <com.webreach.mirth.model.Connector>
      <name>email notification to PHC</name>
      <properties>
        <property name="fromAddress">phuttenczapski@haileyburyfht.org</property>
        <property name="attachmentNames">&lt;list/&gt;</property>
        <property name="emailSecure">none</property>
        <property name="attachmentContents">&lt;list/&gt;</property>
        <property name="username"></property>
        <property name="DataType">Email Sender</property>
        <property name="body">This is an automated notification that the HICL channel that transforms HICL data has just processed a file attributed to you ${ORIGINALNAME}</property>
        <property name="subject">You have Labwork ${ORIGINALNAME}</property>
        <property name="hostname">smtp.localhost.ca</property>
        <property name="smtpPort">25</property>
        <property name="toAddresses">phuttenczapski@gmail.com</property>
        <property name="contentType">text/plain</property>
        <property name="password"></property>
        <property name="attachmentTypes">&lt;list/&gt;</property>
      </properties>
      <transformer>
        <steps/>
        <inboundTemplate></inboundTemplate>
        <outboundTemplate></outboundTemplate>
        <inboundProtocol>HL7V2</inboundProtocol>
        <outboundProtocol>HL7V2</outboundProtocol>
        <inboundProperties>
          <property name="handleRepetitions">false</property>
          <property name="convertLFtoCR">true</property>
          <property name="useStrictValidation">false</property>
          <property name="useStrictParser">false</property>
        </inboundProperties>
        <outboundProperties/>
      </transformer>
      <filter>
        <rules>
          <com.webreach.mirth.model.Rule>
            <sequenceNumber>0</sequenceNumber>
            <name>New Rule</name>
            <data class="map">
              <entry>
                <string>Script</string>
                <string>return true;</string>
              </entry>
            </data>
            <type>JavaScript</type>
            <script>return true;</script>
            <operator>NONE</operator>
          </com.webreach.mirth.model.Rule>
        </rules>
      </filter>
      <transportName>Email Sender</transportName>
      <mode>DESTINATION</mode>
      <enabled>false</enabled>
    </com.webreach.mirth.model.Connector>
  </destinationConnectors>
  <properties>
    <property name="synchronous">true</property>
    <property name="removeNamespace">true</property>
    <property name="transactional">false</property>
    <property name="initialState">started</property>
    <property name="dont_store_filtered">false</property>
    <property name="error_messages_only">false</property>
    <property name="max_message_age">60</property>
    <property name="store_messages">true</property>
    <property name="encryptData">true</property>
  </properties>
  <preprocessingScript>// Modify the message variable below to pre process data&#x0D;
return message;</preprocessingScript>
  <postprocessingScript>// This script executes once after a message has been processed
return;</postprocessingScript>
  <deployScript>// This script executes once when the mule engine is started
// You only have access to the globalMap here to persist data
return;</deployScript>
  <shutdownScript>// This script executes once when the mule engine is stopped
// You only have access to the globalMap here to persist data
return;</shutdownScript>
</com.webreach.mirth.model.Channel>